1b9526c6aSmrg#! /usr/bin/env sh 27204935cSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3b9526c6aSmrg## by inline-source v2019-02-19.15 41016ad83Smrg 5b9526c6aSmrg# libtool (GNU libtool) 2.4.7 67204935cSmrg# Provide generalized library-building support services. 71016ad83Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 81016ad83Smrg 9b9526c6aSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 101016ad83Smrg# This is free software; see the source for copying conditions. There is NO 111016ad83Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 121016ad83Smrg 131016ad83Smrg# GNU Libtool is free software; you can redistribute it and/or modify 141016ad83Smrg# it under the terms of the GNU General Public License as published by 151016ad83Smrg# the Free Software Foundation; either version 2 of the License, or 161016ad83Smrg# (at your option) any later version. 171016ad83Smrg# 181016ad83Smrg# As a special exception to the GNU General Public License, 191016ad83Smrg# if you distribute this file as part of a program or library that 201016ad83Smrg# is built using GNU Libtool, you may include this file under the 211016ad83Smrg# same distribution terms that you use for the rest of that program. 221016ad83Smrg# 231016ad83Smrg# GNU Libtool is distributed in the hope that it will be useful, but 241016ad83Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 251016ad83Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 261016ad83Smrg# General Public License for more details. 271016ad83Smrg# 281016ad83Smrg# You should have received a copy of the GNU General Public License 297204935cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 301016ad83Smrg 311016ad83Smrg 321016ad83SmrgPROGRAM=libtool 331016ad83SmrgPACKAGE=libtool 34b9526c6aSmrgVERSION=2.4.7 35b9526c6aSmrgpackage_revision=2.4.7 361016ad83Smrg 377204935cSmrg 387204935cSmrg## ------ ## 397204935cSmrg## Usage. ## 407204935cSmrg## ------ ## 417204935cSmrg 427204935cSmrg# Run './libtool --help' for help with using this script from the 437204935cSmrg# command line. 447204935cSmrg 457204935cSmrg 467204935cSmrg## ------------------------------- ## 477204935cSmrg## User overridable command paths. ## 487204935cSmrg## ------------------------------- ## 497204935cSmrg 507204935cSmrg# After configure completes, it has a better idea of some of the 517204935cSmrg# shell tools we need than the defaults used by the functions shared 527204935cSmrg# with bootstrap, so set those here where they can still be over- 537204935cSmrg# ridden by the user, but otherwise take precedence. 547204935cSmrg 557204935cSmrg: ${AUTOCONF="autoconf"} 567204935cSmrg: ${AUTOMAKE="automake"} 577204935cSmrg 587204935cSmrg 597204935cSmrg## -------------------------- ## 607204935cSmrg## Source external libraries. ## 617204935cSmrg## -------------------------- ## 627204935cSmrg 637204935cSmrg# Much of our low-level functionality needs to be sourced from external 647204935cSmrg# libraries, which are installed to $pkgauxdir. 657204935cSmrg 667204935cSmrg# Set a version string for this script. 67b9526c6aSmrgscriptversion=2019-02-19.15; # UTC 687204935cSmrg 697204935cSmrg# General shell script boiler plate, and helper functions. 707204935cSmrg# Written by Gary V. Vaughan, 2004 717204935cSmrg 72b9526c6aSmrg# This is free software. There is NO warranty; not even for 73b9526c6aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74b9526c6aSmrg# 75b9526c6aSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76b9526c6aSmrg# 77b9526c6aSmrg# This file is dual licensed under the terms of the MIT license 78b9526c6aSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79b9526c6aSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80b9526c6aSmrg# these licenses when using or redistributing this software or any of 81b9526c6aSmrg# the files within it. See the URLs above, or the file `LICENSE` 82b9526c6aSmrg# included in the Bootstrap distribution for the full license texts. 837204935cSmrg 84b9526c6aSmrg# Please report bugs or propose patches to: 85b9526c6aSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 867204935cSmrg 877204935cSmrg 887204935cSmrg## ------ ## 897204935cSmrg## Usage. ## 907204935cSmrg## ------ ## 917204935cSmrg 927204935cSmrg# Evaluate this file near the top of your script to gain access to 937204935cSmrg# the functions and variables defined here: 947204935cSmrg# 957204935cSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 967204935cSmrg# 977204935cSmrg# If you need to override any of the default environment variable 987204935cSmrg# settings, do that before evaluating this file. 997204935cSmrg 1007204935cSmrg 1017204935cSmrg## -------------------- ## 1027204935cSmrg## Shell normalisation. ## 1037204935cSmrg## -------------------- ## 1047204935cSmrg 1057204935cSmrg# Some shells need a little help to be as Bourne compatible as possible. 1067204935cSmrg# Before doing anything else, make sure all that help has been provided! 1077204935cSmrg 1087204935cSmrgDUALCASE=1; export DUALCASE # for MKS sh 1097204935cSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1101016ad83Smrg emulate sh 1111016ad83Smrg NULLCMD=: 1127204935cSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1131016ad83Smrg # is contrary to our usage. Disable this feature. 1141016ad83Smrg alias -g '${1+"$@"}'='"$@"' 1151016ad83Smrg setopt NO_GLOB_SUBST 1161016ad83Smrgelse 1177204935cSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1181016ad83Smrgfi 1191016ad83Smrg 1207204935cSmrg# NLS nuisances: We save the old values in case they are required later. 1217204935cSmrg_G_user_locale= 1227204935cSmrg_G_safe_locale= 1237204935cSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1241016ad83Smrgdo 1257204935cSmrg eval "if test set = \"\${$_G_var+set}\"; then 1267204935cSmrg save_$_G_var=\$$_G_var 1277204935cSmrg $_G_var=C 1287204935cSmrg export $_G_var 1297204935cSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1307204935cSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1311016ad83Smrg fi" 1321016ad83Smrgdone 133b9526c6aSmrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134b9526c6aSmrg# in case the environment reset is needed later and the $save_* variant is not 135b9526c6aSmrg# defined (see the code above). 136b9526c6aSmrgLC_ALL=C 137b9526c6aSmrgLANGUAGE=C 138b9526c6aSmrgexport LANGUAGE LC_ALL 1391016ad83Smrg 1407204935cSmrg# Make sure IFS has a sensible default 1417204935cSmrgsp=' ' 1427204935cSmrgnl=' 1437204935cSmrg' 1447204935cSmrgIFS="$sp $nl" 1457204935cSmrg 1467204935cSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1477204935cSmrgif test "${PATH_SEPARATOR+set}" != set; then 1487204935cSmrg PATH_SEPARATOR=: 1497204935cSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1507204935cSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1517204935cSmrg PATH_SEPARATOR=';' 1527204935cSmrg } 1537204935cSmrgfi 1541016ad83Smrg 1551016ad83Smrg 156b9526c6aSmrg# func_unset VAR 157b9526c6aSmrg# -------------- 158b9526c6aSmrg# Portably unset VAR. 159b9526c6aSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160b9526c6aSmrg# status if VAR is already unset, which might be problematic if the 161b9526c6aSmrg# statement is used at the end of a function (thus poisoning its return 162b9526c6aSmrg# value) or when 'set -e' is active (causing even a spurious abort of 163b9526c6aSmrg# the script in this case). 164b9526c6aSmrgfunc_unset () 165b9526c6aSmrg{ 166b9526c6aSmrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167b9526c6aSmrg} 168b9526c6aSmrg 169b9526c6aSmrg 170b9526c6aSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171b9526c6aSmrgfunc_unset CDPATH 172b9526c6aSmrg 173b9526c6aSmrg# Make sure ${,E,F}GREP behave sanely. 174b9526c6aSmrgfunc_unset GREP_OPTIONS 175b9526c6aSmrg 1761016ad83Smrg 1777204935cSmrg## ------------------------- ## 1787204935cSmrg## Locate command utilities. ## 1797204935cSmrg## ------------------------- ## 1807204935cSmrg 1817204935cSmrg 1827204935cSmrg# func_executable_p FILE 1837204935cSmrg# ---------------------- 1847204935cSmrg# Check that FILE is an executable regular file. 1857204935cSmrgfunc_executable_p () 1867204935cSmrg{ 1877204935cSmrg test -f "$1" && test -x "$1" 1887204935cSmrg} 1897204935cSmrg 1907204935cSmrg 1917204935cSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1927204935cSmrg# -------------------------------------------- 1937204935cSmrg# Search for either a program that responds to --version with output 1947204935cSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1957204935cSmrg# trying all the directories in PATH with each of the elements of 1967204935cSmrg# PROGS_LIST. 1977204935cSmrg# 1987204935cSmrg# CHECK_FUNC should accept the path to a candidate program, and 1997204935cSmrg# set $func_check_prog_result if it truncates its output less than 2007204935cSmrg# $_G_path_prog_max characters. 2017204935cSmrgfunc_path_progs () 2027204935cSmrg{ 2037204935cSmrg _G_progs_list=$1 2047204935cSmrg _G_check_func=$2 2057204935cSmrg _G_PATH=${3-"$PATH"} 2067204935cSmrg 2077204935cSmrg _G_path_prog_max=0 2087204935cSmrg _G_path_prog_found=false 2097204935cSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2107204935cSmrg for _G_dir in $_G_PATH; do 2117204935cSmrg IFS=$_G_save_IFS 2127204935cSmrg test -z "$_G_dir" && _G_dir=. 2137204935cSmrg for _G_prog_name in $_G_progs_list; do 2147204935cSmrg for _exeext in '' .EXE; do 2157204935cSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2167204935cSmrg func_executable_p "$_G_path_prog" || continue 2177204935cSmrg case `"$_G_path_prog" --version 2>&1` in 2187204935cSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2197204935cSmrg *) $_G_check_func $_G_path_prog 2207204935cSmrg func_path_progs_result=$func_check_prog_result 2217204935cSmrg ;; 2227204935cSmrg esac 2237204935cSmrg $_G_path_prog_found && break 3 2247204935cSmrg done 2257204935cSmrg done 2267204935cSmrg done 2277204935cSmrg IFS=$_G_save_IFS 2287204935cSmrg test -z "$func_path_progs_result" && { 2297204935cSmrg echo "no acceptable sed could be found in \$PATH" >&2 2307204935cSmrg exit 1 2317204935cSmrg } 2327204935cSmrg} 2337204935cSmrg 2347204935cSmrg 2357204935cSmrg# We want to be able to use the functions in this file before configure 2367204935cSmrg# has figured out where the best binaries are kept, which means we have 2377204935cSmrg# to search for them ourselves - except when the results are already set 2387204935cSmrg# where we skip the searches. 2397204935cSmrg 2407204935cSmrg# Unless the user overrides by setting SED, search the path for either GNU 2417204935cSmrg# sed, or the sed that truncates its output the least. 2427204935cSmrgtest -z "$SED" && { 2437204935cSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2447204935cSmrg for _G_i in 1 2 3 4 5 6 7; do 2457204935cSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2467204935cSmrg done 2477204935cSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2487204935cSmrg _G_sed_script= 2497204935cSmrg 2507204935cSmrg func_check_prog_sed () 2517204935cSmrg { 2527204935cSmrg _G_path_prog=$1 2537204935cSmrg 2547204935cSmrg _G_count=0 2557204935cSmrg printf 0123456789 >conftest.in 2567204935cSmrg while : 2577204935cSmrg do 2587204935cSmrg cat conftest.in conftest.in >conftest.tmp 2597204935cSmrg mv conftest.tmp conftest.in 2607204935cSmrg cp conftest.in conftest.nl 2617204935cSmrg echo '' >> conftest.nl 2627204935cSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2637204935cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2647204935cSmrg _G_count=`expr $_G_count + 1` 2657204935cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2667204935cSmrg # Best one so far, save it but keep looking for a better one 2677204935cSmrg func_check_prog_result=$_G_path_prog 2687204935cSmrg _G_path_prog_max=$_G_count 2697204935cSmrg fi 2707204935cSmrg # 10*(2^10) chars as input seems more than enough 2717204935cSmrg test 10 -lt "$_G_count" && break 2727204935cSmrg done 2737204935cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2747204935cSmrg } 2757204935cSmrg 276b9526c6aSmrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2777204935cSmrg rm -f conftest.sed 2787204935cSmrg SED=$func_path_progs_result 2797204935cSmrg} 2807204935cSmrg 2817204935cSmrg 2827204935cSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2837204935cSmrg# grep, or the grep that truncates its output the least. 2847204935cSmrgtest -z "$GREP" && { 2857204935cSmrg func_check_prog_grep () 2867204935cSmrg { 2877204935cSmrg _G_path_prog=$1 2887204935cSmrg 2897204935cSmrg _G_count=0 2907204935cSmrg _G_path_prog_max=0 2917204935cSmrg printf 0123456789 >conftest.in 2927204935cSmrg while : 2937204935cSmrg do 2947204935cSmrg cat conftest.in conftest.in >conftest.tmp 2957204935cSmrg mv conftest.tmp conftest.in 2967204935cSmrg cp conftest.in conftest.nl 2977204935cSmrg echo 'GREP' >> conftest.nl 2987204935cSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2997204935cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3007204935cSmrg _G_count=`expr $_G_count + 1` 3017204935cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3027204935cSmrg # Best one so far, save it but keep looking for a better one 3037204935cSmrg func_check_prog_result=$_G_path_prog 3047204935cSmrg _G_path_prog_max=$_G_count 3057204935cSmrg fi 3067204935cSmrg # 10*(2^10) chars as input seems more than enough 3077204935cSmrg test 10 -lt "$_G_count" && break 3087204935cSmrg done 3097204935cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3107204935cSmrg } 3117204935cSmrg 312b9526c6aSmrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3137204935cSmrg GREP=$func_path_progs_result 3147204935cSmrg} 3157204935cSmrg 3167204935cSmrg 3177204935cSmrg## ------------------------------- ## 3187204935cSmrg## User overridable command paths. ## 3197204935cSmrg## ------------------------------- ## 3207204935cSmrg 3217204935cSmrg# All uppercase variable names are used for environment variables. These 3227204935cSmrg# variables can be overridden by the user before calling a script that 3237204935cSmrg# uses them if a suitable command of that name is not already available 3247204935cSmrg# in the command search PATH. 3251016ad83Smrg 3261016ad83Smrg: ${CP="cp -f"} 3277204935cSmrg: ${ECHO="printf %s\n"} 3287204935cSmrg: ${EGREP="$GREP -E"} 3297204935cSmrg: ${FGREP="$GREP -F"} 3307204935cSmrg: ${LN_S="ln -s"} 3311016ad83Smrg: ${MAKE="make"} 3321016ad83Smrg: ${MKDIR="mkdir"} 3331016ad83Smrg: ${MV="mv -f"} 3341016ad83Smrg: ${RM="rm -f"} 3351016ad83Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3361016ad83Smrg 3371016ad83Smrg 3387204935cSmrg## -------------------- ## 3397204935cSmrg## Useful sed snippets. ## 3407204935cSmrg## -------------------- ## 3411016ad83Smrg 3427204935cSmrgsed_dirname='s|/[^/]*$||' 3437204935cSmrgsed_basename='s|^.*/||' 3441016ad83Smrg 3457204935cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3467204935cSmrg# metacharacters that are still active within double-quoted strings. 3477204935cSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3481016ad83Smrg 3497204935cSmrg# Same as above, but do not quote variable references. 3507204935cSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3511016ad83Smrg 3527204935cSmrg# Sed substitution that turns a string into a regex matching for the 3537204935cSmrg# string literally. 3547204935cSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3551016ad83Smrg 3567204935cSmrg# Sed substitution that converts a w32 file name or path 3577204935cSmrg# that contains forward slashes, into one that contains 3587204935cSmrg# (escaped) backslashes. A very naive implementation. 3597204935cSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3607204935cSmrg 3617204935cSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3627204935cSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3637204935cSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3647204935cSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3657204935cSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3667204935cSmrg_G_bs='\\' 3677204935cSmrg_G_bs2='\\\\' 3687204935cSmrg_G_bs4='\\\\\\\\' 3697204935cSmrg_G_dollar='\$' 3707204935cSmrgsed_double_backslash="\ 3717204935cSmrg s/$_G_bs4/&\\ 3727204935cSmrg/g 3737204935cSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3747204935cSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3757204935cSmrg s/\n//g" 3761016ad83Smrg 377b9526c6aSmrg# require_check_ifs_backslash 378b9526c6aSmrg# --------------------------- 379b9526c6aSmrg# Check if we can use backslash as IFS='\' separator, and set 380b9526c6aSmrg# $check_ifs_backshlash_broken to ':' or 'false'. 381b9526c6aSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382b9526c6aSmrgfunc_require_check_ifs_backslash () 383b9526c6aSmrg{ 384b9526c6aSmrg _G_save_IFS=$IFS 385b9526c6aSmrg IFS='\' 386b9526c6aSmrg _G_check_ifs_backshlash='a\\b' 387b9526c6aSmrg for _G_i in $_G_check_ifs_backshlash 388b9526c6aSmrg do 389b9526c6aSmrg case $_G_i in 390b9526c6aSmrg a) 391b9526c6aSmrg check_ifs_backshlash_broken=false 392b9526c6aSmrg ;; 393b9526c6aSmrg '') 394b9526c6aSmrg break 395b9526c6aSmrg ;; 396b9526c6aSmrg *) 397b9526c6aSmrg check_ifs_backshlash_broken=: 398b9526c6aSmrg break 399b9526c6aSmrg ;; 400b9526c6aSmrg esac 401b9526c6aSmrg done 402b9526c6aSmrg IFS=$_G_save_IFS 403b9526c6aSmrg require_check_ifs_backslash=: 404b9526c6aSmrg} 405b9526c6aSmrg 4061016ad83Smrg 4077204935cSmrg## ----------------- ## 4087204935cSmrg## Global variables. ## 4097204935cSmrg## ----------------- ## 4101016ad83Smrg 4117204935cSmrg# Except for the global variables explicitly listed below, the following 4127204935cSmrg# functions in the '^func_' namespace, and the '^require_' namespace 4137204935cSmrg# variables initialised in the 'Resource management' section, sourcing 4147204935cSmrg# this file will not pollute your global namespace with anything 4157204935cSmrg# else. There's no portable way to scope variables in Bourne shell 4167204935cSmrg# though, so actually running these functions will sometimes place 4177204935cSmrg# results into a variable named after the function, and often use 4187204935cSmrg# temporary variables in the '^_G_' namespace. If you are careful to 4197204935cSmrg# avoid using those namespaces casually in your sourcing script, things 4207204935cSmrg# should continue to work as you expect. And, of course, you can freely 4217204935cSmrg# overwrite any of the functions or variables defined here before 4227204935cSmrg# calling anything to customize them. 4231016ad83Smrg 4247204935cSmrgEXIT_SUCCESS=0 4257204935cSmrgEXIT_FAILURE=1 4267204935cSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4277204935cSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 4281016ad83Smrg 4297204935cSmrg# Allow overriding, eg assuming that you follow the convention of 4307204935cSmrg# putting '$debug_cmd' at the start of all your functions, you can get 4317204935cSmrg# bash to show function call trace with: 4327204935cSmrg# 4337204935cSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4347204935cSmrgdebug_cmd=${debug_cmd-":"} 4357204935cSmrgexit_cmd=: 4361016ad83Smrg 4377204935cSmrg# By convention, finish your script with: 4387204935cSmrg# 4397204935cSmrg# exit $exit_status 4407204935cSmrg# 4417204935cSmrg# so that you can set exit_status to non-zero if you want to indicate 4427204935cSmrg# something went wrong during execution without actually bailing out at 4437204935cSmrg# the point of failure. 4447204935cSmrgexit_status=$EXIT_SUCCESS 4451016ad83Smrg 4467204935cSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4477204935cSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4487204935cSmrg# the _XPG environment variable is not equal to 1 (one), the special 4497204935cSmrg# positional parameter $0, within a function call, is the name of the 4507204935cSmrg# function. 4517204935cSmrgprogpath=$0 4521016ad83Smrg 4537204935cSmrg# The name of this program. 4547204935cSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4551016ad83Smrg 4567204935cSmrg# Make sure we have an absolute progpath for reexecution: 4571016ad83Smrgcase $progpath in 4581016ad83Smrg [\\/]*|[A-Za-z]:\\*) ;; 4591016ad83Smrg *[\\/]*) 4607204935cSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4611016ad83Smrg progdir=`cd "$progdir" && pwd` 4627204935cSmrg progpath=$progdir/$progname 4631016ad83Smrg ;; 4641016ad83Smrg *) 4657204935cSmrg _G_IFS=$IFS 4661016ad83Smrg IFS=${PATH_SEPARATOR-:} 4671016ad83Smrg for progdir in $PATH; do 4687204935cSmrg IFS=$_G_IFS 4691016ad83Smrg test -x "$progdir/$progname" && break 4701016ad83Smrg done 4717204935cSmrg IFS=$_G_IFS 4721016ad83Smrg test -n "$progdir" || progdir=`pwd` 4737204935cSmrg progpath=$progdir/$progname 4741016ad83Smrg ;; 4751016ad83Smrgesac 4761016ad83Smrg 4771016ad83Smrg 4787204935cSmrg## ----------------- ## 4797204935cSmrg## Standard options. ## 4807204935cSmrg## ----------------- ## 4811016ad83Smrg 4827204935cSmrg# The following options affect the operation of the functions defined 4837204935cSmrg# below, and should be set appropriately depending on run-time para- 4847204935cSmrg# meters passed on the command line. 4851016ad83Smrg 4861016ad83Smrgopt_dry_run=false 4871016ad83Smrgopt_quiet=false 4881016ad83Smrgopt_verbose=false 4891016ad83Smrg 4907204935cSmrg# Categories 'all' and 'none' are always available. Append any others 4917204935cSmrg# you will pass as the first argument to func_warning from your own 4927204935cSmrg# code. 4937204935cSmrgwarning_categories= 4941016ad83Smrg 4957204935cSmrg# By default, display warnings according to 'opt_warning_types'. Set 4967204935cSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4977204935cSmrg# treat the next displayed warning as a fatal error. 4987204935cSmrgwarning_func=func_warn_and_continue 4991016ad83Smrg 5007204935cSmrg# Set to 'all' to display all warnings, 'none' to suppress all 5017204935cSmrg# warnings, or a space delimited list of some subset of 5027204935cSmrg# 'warning_categories' to display only the listed warnings. 5037204935cSmrgopt_warning_types=all 5041016ad83Smrg 5051016ad83Smrg 5067204935cSmrg## -------------------- ## 5077204935cSmrg## Resource management. ## 5087204935cSmrg## -------------------- ## 5091016ad83Smrg 5107204935cSmrg# This section contains definitions for functions that each ensure a 5117204935cSmrg# particular resource (a file, or a non-empty configuration variable for 5127204935cSmrg# example) is available, and if appropriate to extract default values 5137204935cSmrg# from pertinent package files. Call them using their associated 5147204935cSmrg# 'require_*' variable to ensure that they are executed, at most, once. 5157204935cSmrg# 5167204935cSmrg# It's entirely deliberate that calling these functions can set 5177204935cSmrg# variables that don't obey the namespace limitations obeyed by the rest 5187204935cSmrg# of this file, in order that that they be as useful as possible to 5197204935cSmrg# callers. 5201016ad83Smrg 5211016ad83Smrg 5227204935cSmrg# require_term_colors 5237204935cSmrg# ------------------- 5247204935cSmrg# Allow display of bold text on terminals that support it. 5257204935cSmrgrequire_term_colors=func_require_term_colors 5267204935cSmrgfunc_require_term_colors () 5271016ad83Smrg{ 5287204935cSmrg $debug_cmd 5297204935cSmrg 5307204935cSmrg test -t 1 && { 5317204935cSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 5327204935cSmrg # precedence, because most terminfo databases neglect to describe 5337204935cSmrg # whether color sequences are supported. 5347204935cSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5357204935cSmrg 5367204935cSmrg if test 1 = "$USE_ANSI_COLORS"; then 5377204935cSmrg # Standard ANSI escape sequences 5387204935cSmrg tc_reset='[0m' 5397204935cSmrg tc_bold='[1m'; tc_standout='[7m' 5407204935cSmrg tc_red='[31m'; tc_green='[32m' 5417204935cSmrg tc_blue='[34m'; tc_cyan='[36m' 5427204935cSmrg else 5437204935cSmrg # Otherwise trust the terminfo database after all. 5447204935cSmrg test -n "`tput sgr0 2>/dev/null`" && { 5457204935cSmrg tc_reset=`tput sgr0` 5467204935cSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5477204935cSmrg tc_standout=$tc_bold 5487204935cSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5497204935cSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5507204935cSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5517204935cSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5527204935cSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5537204935cSmrg } 5547204935cSmrg fi 5557204935cSmrg } 5561016ad83Smrg 5577204935cSmrg require_term_colors=: 5581016ad83Smrg} 5591016ad83Smrg 5601016ad83Smrg 5617204935cSmrg## ----------------- ## 5627204935cSmrg## Function library. ## 5637204935cSmrg## ----------------- ## 5647204935cSmrg 5657204935cSmrg# This section contains a variety of useful functions to call in your 5667204935cSmrg# scripts. Take note of the portable wrappers for features provided by 5677204935cSmrg# some modern shells, which will fall back to slower equivalents on 5687204935cSmrg# less featureful shells. 5697204935cSmrg 5707204935cSmrg 5717204935cSmrg# func_append VAR VALUE 5727204935cSmrg# --------------------- 5737204935cSmrg# Append VALUE onto the existing contents of VAR. 5747204935cSmrg 5757204935cSmrg # We should try to minimise forks, especially on Windows where they are 5767204935cSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5777204935cSmrg # being used: 5787204935cSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5797204935cSmrg : ${_G_HAVE_ARITH_OP="yes"} 5807204935cSmrg : ${_G_HAVE_XSI_OPS="yes"} 5817204935cSmrg # The += operator was introduced in bash 3.1 5827204935cSmrg case $BASH_VERSION in 5837204935cSmrg [12].* | 3.0 | 3.0*) ;; 5847204935cSmrg *) 5857204935cSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5867204935cSmrg ;; 5877204935cSmrg esac 5887204935cSmrg fi 5897204935cSmrg 5907204935cSmrg # _G_HAVE_PLUSEQ_OP 5917204935cSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5927204935cSmrg # useable or anything else if it does not work. 5937204935cSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5947204935cSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5957204935cSmrg && _G_HAVE_PLUSEQ_OP=yes 5967204935cSmrg 5977204935cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5987204935cSmrgthen 5997204935cSmrg # This is an XSI compatible shell, allowing a faster implementation... 6007204935cSmrg eval 'func_append () 6017204935cSmrg { 6027204935cSmrg $debug_cmd 6037204935cSmrg 6047204935cSmrg eval "$1+=\$2" 6057204935cSmrg }' 6067204935cSmrgelse 6077204935cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 6087204935cSmrg func_append () 6097204935cSmrg { 6107204935cSmrg $debug_cmd 6117204935cSmrg 6127204935cSmrg eval "$1=\$$1\$2" 6137204935cSmrg } 6147204935cSmrgfi 6157204935cSmrg 6167204935cSmrg 6177204935cSmrg# func_append_quoted VAR VALUE 6187204935cSmrg# ---------------------------- 6197204935cSmrg# Quote VALUE and append to the end of shell variable VAR, separated 6207204935cSmrg# by a space. 6217204935cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6227204935cSmrg eval 'func_append_quoted () 6237204935cSmrg { 6247204935cSmrg $debug_cmd 6257204935cSmrg 626b9526c6aSmrg func_quote_arg pretty "$2" 627b9526c6aSmrg eval "$1+=\\ \$func_quote_arg_result" 6287204935cSmrg }' 6297204935cSmrgelse 6307204935cSmrg func_append_quoted () 6317204935cSmrg { 6327204935cSmrg $debug_cmd 6337204935cSmrg 634b9526c6aSmrg func_quote_arg pretty "$2" 635b9526c6aSmrg eval "$1=\$$1\\ \$func_quote_arg_result" 6367204935cSmrg } 6377204935cSmrgfi 6387204935cSmrg 6397204935cSmrg 6407204935cSmrg# func_append_uniq VAR VALUE 6417204935cSmrg# -------------------------- 6427204935cSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6437204935cSmrg# entries are delimited by the first character of VALUE. For example: 6447204935cSmrg# 6457204935cSmrg# func_append_uniq options " --another-option option-argument" 6467204935cSmrg# 6477204935cSmrg# will only append to $options if " --another-option option-argument " 6487204935cSmrg# is not already present somewhere in $options already (note spaces at 6497204935cSmrg# each end implied by leading space in second argument). 6507204935cSmrgfunc_append_uniq () 6517204935cSmrg{ 6527204935cSmrg $debug_cmd 6537204935cSmrg 6547204935cSmrg eval _G_current_value='`$ECHO $'$1'`' 6557204935cSmrg _G_delim=`expr "$2" : '\(.\)'` 6567204935cSmrg 6577204935cSmrg case $_G_delim$_G_current_value$_G_delim in 6587204935cSmrg *"$2$_G_delim"*) ;; 6597204935cSmrg *) func_append "$@" ;; 6607204935cSmrg esac 6617204935cSmrg} 6627204935cSmrg 6637204935cSmrg 6647204935cSmrg# func_arith TERM... 6657204935cSmrg# ------------------ 6667204935cSmrg# Set func_arith_result to the result of evaluating TERMs. 6677204935cSmrg test -z "$_G_HAVE_ARITH_OP" \ 6687204935cSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6697204935cSmrg && _G_HAVE_ARITH_OP=yes 6707204935cSmrg 6717204935cSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6727204935cSmrg eval 'func_arith () 6737204935cSmrg { 6747204935cSmrg $debug_cmd 6757204935cSmrg 6767204935cSmrg func_arith_result=$(( $* )) 6777204935cSmrg }' 6787204935cSmrgelse 6797204935cSmrg func_arith () 6807204935cSmrg { 6817204935cSmrg $debug_cmd 6827204935cSmrg 6837204935cSmrg func_arith_result=`expr "$@"` 6847204935cSmrg } 6857204935cSmrgfi 6867204935cSmrg 6877204935cSmrg 6887204935cSmrg# func_basename FILE 6897204935cSmrg# ------------------ 6907204935cSmrg# Set func_basename_result to FILE with everything up to and including 6917204935cSmrg# the last / stripped. 6927204935cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6937204935cSmrg # If this shell supports suffix pattern removal, then use it to avoid 6947204935cSmrg # forking. Hide the definitions single quotes in case the shell chokes 6957204935cSmrg # on unsupported syntax... 6967204935cSmrg _b='func_basename_result=${1##*/}' 6977204935cSmrg _d='case $1 in 6987204935cSmrg */*) func_dirname_result=${1%/*}$2 ;; 6997204935cSmrg * ) func_dirname_result=$3 ;; 7007204935cSmrg esac' 7017204935cSmrg 7027204935cSmrgelse 7037204935cSmrg # ...otherwise fall back to using sed. 7047204935cSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7057204935cSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7067204935cSmrg if test "X$func_dirname_result" = "X$1"; then 7077204935cSmrg func_dirname_result=$3 7087204935cSmrg else 7097204935cSmrg func_append func_dirname_result "$2" 7107204935cSmrg fi' 7117204935cSmrgfi 7127204935cSmrg 7137204935cSmrgeval 'func_basename () 7147204935cSmrg{ 7157204935cSmrg $debug_cmd 7167204935cSmrg 7177204935cSmrg '"$_b"' 7187204935cSmrg}' 7197204935cSmrg 7207204935cSmrg 7217204935cSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7227204935cSmrg# ------------------------------------------- 7237204935cSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7247204935cSmrg# otherwise set result to NONDIR_REPLACEMENT. 7257204935cSmrgeval 'func_dirname () 7267204935cSmrg{ 7277204935cSmrg $debug_cmd 7287204935cSmrg 7297204935cSmrg '"$_d"' 7307204935cSmrg}' 7317204935cSmrg 7327204935cSmrg 7337204935cSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7347204935cSmrg# -------------------------------------------------------- 7357204935cSmrg# Perform func_basename and func_dirname in a single function 7367204935cSmrg# call: 7377204935cSmrg# dirname: Compute the dirname of FILE. If nonempty, 7387204935cSmrg# add APPEND to the result, otherwise set result 7397204935cSmrg# to NONDIR_REPLACEMENT. 7407204935cSmrg# value returned in "$func_dirname_result" 7417204935cSmrg# basename: Compute filename of FILE. 7427204935cSmrg# value retuned in "$func_basename_result" 7437204935cSmrg# For efficiency, we do not delegate to the functions above but instead 7447204935cSmrg# duplicate the functionality here. 7457204935cSmrgeval 'func_dirname_and_basename () 7467204935cSmrg{ 7477204935cSmrg $debug_cmd 7487204935cSmrg 7497204935cSmrg '"$_b"' 7507204935cSmrg '"$_d"' 7517204935cSmrg}' 7527204935cSmrg 7537204935cSmrg 7547204935cSmrg# func_echo ARG... 7557204935cSmrg# ---------------- 7567204935cSmrg# Echo program name prefixed message. 7577204935cSmrgfunc_echo () 7587204935cSmrg{ 7597204935cSmrg $debug_cmd 7607204935cSmrg 7617204935cSmrg _G_message=$* 7627204935cSmrg 7637204935cSmrg func_echo_IFS=$IFS 7647204935cSmrg IFS=$nl 7657204935cSmrg for _G_line in $_G_message; do 7667204935cSmrg IFS=$func_echo_IFS 7677204935cSmrg $ECHO "$progname: $_G_line" 7687204935cSmrg done 7697204935cSmrg IFS=$func_echo_IFS 7707204935cSmrg} 7717204935cSmrg 7727204935cSmrg 7737204935cSmrg# func_echo_all ARG... 7747204935cSmrg# -------------------- 7757204935cSmrg# Invoke $ECHO with all args, space-separated. 7767204935cSmrgfunc_echo_all () 7777204935cSmrg{ 7787204935cSmrg $ECHO "$*" 7797204935cSmrg} 7807204935cSmrg 7817204935cSmrg 7827204935cSmrg# func_echo_infix_1 INFIX ARG... 7837204935cSmrg# ------------------------------ 7847204935cSmrg# Echo program name, followed by INFIX on the first line, with any 7857204935cSmrg# additional lines not showing INFIX. 7867204935cSmrgfunc_echo_infix_1 () 7877204935cSmrg{ 7887204935cSmrg $debug_cmd 7897204935cSmrg 7907204935cSmrg $require_term_colors 7917204935cSmrg 7927204935cSmrg _G_infix=$1; shift 7937204935cSmrg _G_indent=$_G_infix 7947204935cSmrg _G_prefix="$progname: $_G_infix: " 7957204935cSmrg _G_message=$* 7967204935cSmrg 7977204935cSmrg # Strip color escape sequences before counting printable length 7987204935cSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7997204935cSmrg do 8007204935cSmrg test -n "$_G_tc" && { 8017204935cSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8027204935cSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8037204935cSmrg } 8047204935cSmrg done 8057204935cSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8067204935cSmrg 8077204935cSmrg func_echo_infix_1_IFS=$IFS 8087204935cSmrg IFS=$nl 8097204935cSmrg for _G_line in $_G_message; do 8107204935cSmrg IFS=$func_echo_infix_1_IFS 8117204935cSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8127204935cSmrg _G_prefix=$_G_indent 8137204935cSmrg done 8147204935cSmrg IFS=$func_echo_infix_1_IFS 8157204935cSmrg} 8167204935cSmrg 8177204935cSmrg 8187204935cSmrg# func_error ARG... 8197204935cSmrg# ----------------- 8207204935cSmrg# Echo program name prefixed message to standard error. 8217204935cSmrgfunc_error () 8227204935cSmrg{ 8237204935cSmrg $debug_cmd 8247204935cSmrg 8257204935cSmrg $require_term_colors 8267204935cSmrg 8277204935cSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8287204935cSmrg} 8297204935cSmrg 8307204935cSmrg 8317204935cSmrg# func_fatal_error ARG... 8327204935cSmrg# ----------------------- 8337204935cSmrg# Echo program name prefixed message to standard error, and exit. 8347204935cSmrgfunc_fatal_error () 8357204935cSmrg{ 8367204935cSmrg $debug_cmd 8377204935cSmrg 8387204935cSmrg func_error "$*" 8397204935cSmrg exit $EXIT_FAILURE 8407204935cSmrg} 8417204935cSmrg 8427204935cSmrg 8437204935cSmrg# func_grep EXPRESSION FILENAME 8447204935cSmrg# ----------------------------- 8451016ad83Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8461016ad83Smrgfunc_grep () 8471016ad83Smrg{ 8487204935cSmrg $debug_cmd 8497204935cSmrg 8501016ad83Smrg $GREP "$1" "$2" >/dev/null 2>&1 8511016ad83Smrg} 8521016ad83Smrg 8531016ad83Smrg 8547204935cSmrg# func_len STRING 8557204935cSmrg# --------------- 8567204935cSmrg# Set func_len_result to the length of STRING. STRING may not 8577204935cSmrg# start with a hyphen. 8587204935cSmrg test -z "$_G_HAVE_XSI_OPS" \ 8597204935cSmrg && (eval 'x=a/b/c; 8607204935cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8617204935cSmrg && _G_HAVE_XSI_OPS=yes 8627204935cSmrg 8637204935cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8647204935cSmrg eval 'func_len () 8657204935cSmrg { 8667204935cSmrg $debug_cmd 8677204935cSmrg 8687204935cSmrg func_len_result=${#1} 8697204935cSmrg }' 8707204935cSmrgelse 8717204935cSmrg func_len () 8727204935cSmrg { 8737204935cSmrg $debug_cmd 8747204935cSmrg 8757204935cSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8767204935cSmrg } 8777204935cSmrgfi 8787204935cSmrg 8797204935cSmrg 8807204935cSmrg# func_mkdir_p DIRECTORY-PATH 8817204935cSmrg# --------------------------- 8821016ad83Smrg# Make sure the entire path to DIRECTORY-PATH is available. 8831016ad83Smrgfunc_mkdir_p () 8841016ad83Smrg{ 8857204935cSmrg $debug_cmd 8861016ad83Smrg 8877204935cSmrg _G_directory_path=$1 8887204935cSmrg _G_dir_list= 8891016ad83Smrg 8907204935cSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8917204935cSmrg 8927204935cSmrg # Protect directory names starting with '-' 8937204935cSmrg case $_G_directory_path in 8947204935cSmrg -*) _G_directory_path=./$_G_directory_path ;; 8951016ad83Smrg esac 8961016ad83Smrg 8971016ad83Smrg # While some portion of DIR does not yet exist... 8987204935cSmrg while test ! -d "$_G_directory_path"; do 8991016ad83Smrg # ...make a list in topmost first order. Use a colon delimited 9001016ad83Smrg # list incase some portion of path contains whitespace. 9017204935cSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 9021016ad83Smrg 9031016ad83Smrg # If the last portion added has no slash in it, the list is done 9047204935cSmrg case $_G_directory_path in */*) ;; *) break ;; esac 9051016ad83Smrg 9061016ad83Smrg # ...otherwise throw away the child directory and loop 9077204935cSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 9081016ad83Smrg done 9097204935cSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 9101016ad83Smrg 9117204935cSmrg func_mkdir_p_IFS=$IFS; IFS=: 9127204935cSmrg for _G_dir in $_G_dir_list; do 9137204935cSmrg IFS=$func_mkdir_p_IFS 9147204935cSmrg # mkdir can fail with a 'File exist' error if two processes 9151016ad83Smrg # try to create one of the directories concurrently. Don't 9161016ad83Smrg # stop in that case! 9177204935cSmrg $MKDIR "$_G_dir" 2>/dev/null || : 9181016ad83Smrg done 9197204935cSmrg IFS=$func_mkdir_p_IFS 9201016ad83Smrg 9211016ad83Smrg # Bail out if we (or some other process) failed to create a directory. 9227204935cSmrg test -d "$_G_directory_path" || \ 9237204935cSmrg func_fatal_error "Failed to create '$1'" 9241016ad83Smrg fi 9251016ad83Smrg} 9261016ad83Smrg 9271016ad83Smrg 9287204935cSmrg# func_mktempdir [BASENAME] 9297204935cSmrg# ------------------------- 9301016ad83Smrg# Make a temporary directory that won't clash with other running 9311016ad83Smrg# libtool processes, and avoids race conditions if possible. If 9327204935cSmrg# given, BASENAME is the basename for that directory. 9331016ad83Smrgfunc_mktempdir () 9341016ad83Smrg{ 9357204935cSmrg $debug_cmd 9367204935cSmrg 9377204935cSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9381016ad83Smrg 9397204935cSmrg if test : = "$opt_dry_run"; then 9401016ad83Smrg # Return a directory name, but don't create it in dry-run mode 9417204935cSmrg _G_tmpdir=$_G_template-$$ 9421016ad83Smrg else 9431016ad83Smrg 9441016ad83Smrg # If mktemp works, use that first and foremost 9457204935cSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9461016ad83Smrg 9477204935cSmrg if test ! -d "$_G_tmpdir"; then 9481016ad83Smrg # Failing that, at least try and use $RANDOM to avoid a race 9497204935cSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9501016ad83Smrg 9517204935cSmrg func_mktempdir_umask=`umask` 9521016ad83Smrg umask 0077 9537204935cSmrg $MKDIR "$_G_tmpdir" 9547204935cSmrg umask $func_mktempdir_umask 9551016ad83Smrg fi 9561016ad83Smrg 9571016ad83Smrg # If we're not in dry-run mode, bomb out on failure 9587204935cSmrg test -d "$_G_tmpdir" || \ 9597204935cSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9607204935cSmrg fi 9617204935cSmrg 9627204935cSmrg $ECHO "$_G_tmpdir" 9637204935cSmrg} 9647204935cSmrg 9657204935cSmrg 9667204935cSmrg# func_normal_abspath PATH 9677204935cSmrg# ------------------------ 9687204935cSmrg# Remove doubled-up and trailing slashes, "." path components, 9697204935cSmrg# and cancel out any ".." path components in PATH after making 9707204935cSmrg# it an absolute path. 9717204935cSmrgfunc_normal_abspath () 9727204935cSmrg{ 9737204935cSmrg $debug_cmd 9747204935cSmrg 9757204935cSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9767204935cSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9777204935cSmrg _G_pathcdr='s|^/[^/]*||' 9787204935cSmrg _G_removedotparts=':dotsl 9797204935cSmrg s|/\./|/|g 9807204935cSmrg t dotsl 9817204935cSmrg s|/\.$|/|' 9827204935cSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9837204935cSmrg _G_finalslash='s|/*$|/|' 9847204935cSmrg 9857204935cSmrg # Start from root dir and reassemble the path. 9867204935cSmrg func_normal_abspath_result= 9877204935cSmrg func_normal_abspath_tpath=$1 9887204935cSmrg func_normal_abspath_altnamespace= 9897204935cSmrg case $func_normal_abspath_tpath in 9907204935cSmrg "") 9917204935cSmrg # Empty path, that just means $cwd. 9927204935cSmrg func_stripname '' '/' "`pwd`" 9937204935cSmrg func_normal_abspath_result=$func_stripname_result 9947204935cSmrg return 9957204935cSmrg ;; 9967204935cSmrg # The next three entries are used to spot a run of precisely 9977204935cSmrg # two leading slashes without using negated character classes; 9987204935cSmrg # we take advantage of case's first-match behaviour. 9997204935cSmrg ///*) 10007204935cSmrg # Unusual form of absolute path, do nothing. 10017204935cSmrg ;; 10027204935cSmrg //*) 10037204935cSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10047204935cSmrg # and for example Cygwin uses it to access remote file shares 10057204935cSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 10067204935cSmrg func_normal_abspath_altnamespace=/ 10077204935cSmrg ;; 10087204935cSmrg /*) 10097204935cSmrg # Absolute path, do nothing. 10107204935cSmrg ;; 10117204935cSmrg *) 10127204935cSmrg # Relative path, prepend $cwd. 10137204935cSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10147204935cSmrg ;; 10157204935cSmrg esac 10167204935cSmrg 10177204935cSmrg # Cancel out all the simple stuff to save iterations. We also want 10187204935cSmrg # the path to end with a slash for ease of parsing, so make sure 10197204935cSmrg # there is one (and only one) here. 10207204935cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10217204935cSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10227204935cSmrg while :; do 10237204935cSmrg # Processed it all yet? 10247204935cSmrg if test / = "$func_normal_abspath_tpath"; then 10257204935cSmrg # If we ascended to the root using ".." the result may be empty now. 10267204935cSmrg if test -z "$func_normal_abspath_result"; then 10277204935cSmrg func_normal_abspath_result=/ 10287204935cSmrg fi 10297204935cSmrg break 10307204935cSmrg fi 10317204935cSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10327204935cSmrg -e "$_G_pathcar"` 10337204935cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10347204935cSmrg -e "$_G_pathcdr"` 10357204935cSmrg # Figure out what to do with it 10367204935cSmrg case $func_normal_abspath_tcomponent in 10377204935cSmrg "") 10387204935cSmrg # Trailing empty path component, ignore it. 10397204935cSmrg ;; 10407204935cSmrg ..) 10417204935cSmrg # Parent dir; strip last assembled component from result. 10427204935cSmrg func_dirname "$func_normal_abspath_result" 10437204935cSmrg func_normal_abspath_result=$func_dirname_result 10447204935cSmrg ;; 10457204935cSmrg *) 10467204935cSmrg # Actual path component, append it. 10477204935cSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10487204935cSmrg ;; 10497204935cSmrg esac 10507204935cSmrg done 10517204935cSmrg # Restore leading double-slash if one was found on entry. 10527204935cSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10537204935cSmrg} 10547204935cSmrg 10557204935cSmrg 10567204935cSmrg# func_notquiet ARG... 10577204935cSmrg# -------------------- 10587204935cSmrg# Echo program name prefixed message only when not in quiet mode. 10597204935cSmrgfunc_notquiet () 10607204935cSmrg{ 10617204935cSmrg $debug_cmd 10627204935cSmrg 10637204935cSmrg $opt_quiet || func_echo ${1+"$@"} 10647204935cSmrg 10657204935cSmrg # A bug in bash halts the script if the last line of a function 10667204935cSmrg # fails when set -e is in force, so we need another command to 10677204935cSmrg # work around that: 10687204935cSmrg : 10697204935cSmrg} 10707204935cSmrg 10717204935cSmrg 10727204935cSmrg# func_relative_path SRCDIR DSTDIR 10737204935cSmrg# -------------------------------- 10747204935cSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10757204935cSmrgfunc_relative_path () 10767204935cSmrg{ 10777204935cSmrg $debug_cmd 10787204935cSmrg 10797204935cSmrg func_relative_path_result= 10807204935cSmrg func_normal_abspath "$1" 10817204935cSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10827204935cSmrg func_normal_abspath "$2" 10837204935cSmrg func_relative_path_tbindir=$func_normal_abspath_result 10847204935cSmrg 10857204935cSmrg # Ascend the tree starting from libdir 10867204935cSmrg while :; do 10877204935cSmrg # check if we have found a prefix of bindir 10887204935cSmrg case $func_relative_path_tbindir in 10897204935cSmrg $func_relative_path_tlibdir) 10907204935cSmrg # found an exact match 10917204935cSmrg func_relative_path_tcancelled= 10927204935cSmrg break 10937204935cSmrg ;; 10947204935cSmrg $func_relative_path_tlibdir*) 10957204935cSmrg # found a matching prefix 10967204935cSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10977204935cSmrg func_relative_path_tcancelled=$func_stripname_result 10987204935cSmrg if test -z "$func_relative_path_result"; then 10997204935cSmrg func_relative_path_result=. 11007204935cSmrg fi 11017204935cSmrg break 11027204935cSmrg ;; 11037204935cSmrg *) 11047204935cSmrg func_dirname $func_relative_path_tlibdir 11057204935cSmrg func_relative_path_tlibdir=$func_dirname_result 11067204935cSmrg if test -z "$func_relative_path_tlibdir"; then 11077204935cSmrg # Have to descend all the way to the root! 11087204935cSmrg func_relative_path_result=../$func_relative_path_result 11097204935cSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 11107204935cSmrg break 11117204935cSmrg fi 11127204935cSmrg func_relative_path_result=../$func_relative_path_result 11137204935cSmrg ;; 11147204935cSmrg esac 11157204935cSmrg done 11167204935cSmrg 11177204935cSmrg # Now calculate path; take care to avoid doubling-up slashes. 11187204935cSmrg func_stripname '' '/' "$func_relative_path_result" 11197204935cSmrg func_relative_path_result=$func_stripname_result 11207204935cSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11217204935cSmrg if test -n "$func_stripname_result"; then 11227204935cSmrg func_append func_relative_path_result "/$func_stripname_result" 11237204935cSmrg fi 11247204935cSmrg 11257204935cSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 11267204935cSmrg if test -n "$func_relative_path_result"; then 11277204935cSmrg func_stripname './' '' "$func_relative_path_result" 11287204935cSmrg func_relative_path_result=$func_stripname_result 11291016ad83Smrg fi 11301016ad83Smrg 11317204935cSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 11327204935cSmrg 11337204935cSmrg : 11347204935cSmrg} 11357204935cSmrg 11367204935cSmrg 1137b9526c6aSmrg# func_quote_portable EVAL ARG 1138b9526c6aSmrg# ---------------------------- 1139b9526c6aSmrg# Internal function to portably implement func_quote_arg. Note that we still 1140b9526c6aSmrg# keep attention to performance here so we as much as possible try to avoid 1141b9526c6aSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142b9526c6aSmrgfunc_quote_portable () 11437204935cSmrg{ 11447204935cSmrg $debug_cmd 11457204935cSmrg 1146b9526c6aSmrg $require_check_ifs_backslash 1147fe12f63cSmrg 1148b9526c6aSmrg func_quote_portable_result=$2 1149fe12f63cSmrg 1150b9526c6aSmrg # one-time-loop (easy break) 1151b9526c6aSmrg while true 1152b9526c6aSmrg do 1153b9526c6aSmrg if $1; then 1154b9526c6aSmrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155b9526c6aSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156b9526c6aSmrg break 1157b9526c6aSmrg fi 1158b9526c6aSmrg 1159b9526c6aSmrg # Quote for eval. 1160b9526c6aSmrg case $func_quote_portable_result in 1161b9526c6aSmrg *[\\\`\"\$]*) 1162b9526c6aSmrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163b9526c6aSmrg # contains the shell wildcard characters. 1164b9526c6aSmrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165b9526c6aSmrg :*|*[\[\*\?]*) 1166b9526c6aSmrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167b9526c6aSmrg | $SED "$sed_quote_subst"` 1168b9526c6aSmrg break 1169aa30ed02Smrg ;; 1170b9526c6aSmrg esac 1171b9526c6aSmrg 1172b9526c6aSmrg func_quote_portable_old_IFS=$IFS 1173b9526c6aSmrg for _G_char in '\' '`' '"' '$' 1174b9526c6aSmrg do 1175b9526c6aSmrg # STATE($1) PREV($2) SEPARATOR($3) 1176b9526c6aSmrg set start "" "" 1177b9526c6aSmrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178b9526c6aSmrg IFS=$_G_char 1179b9526c6aSmrg for _G_part in $func_quote_portable_result 1180b9526c6aSmrg do 1181b9526c6aSmrg case $1 in 1182b9526c6aSmrg quote) 1183b9526c6aSmrg func_append func_quote_portable_result "$3$2" 1184b9526c6aSmrg set quote "$_G_part" "\\$_G_char" 1185b9526c6aSmrg ;; 1186b9526c6aSmrg start) 1187b9526c6aSmrg set first "" "" 1188b9526c6aSmrg func_quote_portable_result= 1189b9526c6aSmrg ;; 1190b9526c6aSmrg first) 1191b9526c6aSmrg set quote "$_G_part" "" 1192b9526c6aSmrg ;; 1193b9526c6aSmrg esac 1194b9526c6aSmrg done 1195fe12f63cSmrg done 1196b9526c6aSmrg IFS=$func_quote_portable_old_IFS 1197b9526c6aSmrg ;; 1198b9526c6aSmrg *) ;; 1199b9526c6aSmrg esac 1200b9526c6aSmrg break 1201b9526c6aSmrg done 1202b9526c6aSmrg 1203b9526c6aSmrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204b9526c6aSmrg case $func_quote_portable_result in 1205b9526c6aSmrg # double-quote args containing shell metacharacters to delay 1206b9526c6aSmrg # word splitting, command substitution and variable expansion 1207b9526c6aSmrg # for a subsequent eval. 1208b9526c6aSmrg # many bourne shells cannot handle close brackets correctly 1209b9526c6aSmrg # in scan sets, so we specify it separately. 1210b9526c6aSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211b9526c6aSmrg func_quote_portable_result=\"$func_quote_portable_result\" 1212fe12f63cSmrg ;; 1213fe12f63cSmrg esac 12147204935cSmrg} 12157204935cSmrg 12167204935cSmrg 1217b9526c6aSmrg# func_quotefast_eval ARG 1218b9526c6aSmrg# ----------------------- 1219b9526c6aSmrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220b9526c6aSmrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221b9526c6aSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222b9526c6aSmrg printf -v _GL_test_printf_tilde %q '~' 1223b9526c6aSmrg if test '\~' = "$_GL_test_printf_tilde"; then 1224b9526c6aSmrg func_quotefast_eval () 1225b9526c6aSmrg { 1226b9526c6aSmrg printf -v func_quotefast_eval_result %q "$1" 1227b9526c6aSmrg } 1228b9526c6aSmrg else 1229b9526c6aSmrg # Broken older Bash implementations. Make those faster too if possible. 1230b9526c6aSmrg func_quotefast_eval () 1231b9526c6aSmrg { 1232b9526c6aSmrg case $1 in 1233b9526c6aSmrg '~'*) 1234b9526c6aSmrg func_quote_portable false "$1" 1235b9526c6aSmrg func_quotefast_eval_result=$func_quote_portable_result 1236aa30ed02Smrg ;; 1237aa30ed02Smrg *) 1238b9526c6aSmrg printf -v func_quotefast_eval_result %q "$1" 1239b9526c6aSmrg ;; 1240aa30ed02Smrg esac 1241b9526c6aSmrg } 1242b9526c6aSmrg fi 1243b9526c6aSmrgelse 1244b9526c6aSmrg func_quotefast_eval () 1245b9526c6aSmrg { 1246b9526c6aSmrg func_quote_portable false "$1" 1247b9526c6aSmrg func_quotefast_eval_result=$func_quote_portable_result 1248b9526c6aSmrg } 1249b9526c6aSmrgfi 1250aa30ed02Smrg 1251aa30ed02Smrg 1252b9526c6aSmrg# func_quote_arg MODEs ARG 1253b9526c6aSmrg# ------------------------ 1254b9526c6aSmrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255b9526c6aSmrg# specifiers listed below separated by ',' character. This function returns two 1256b9526c6aSmrg# values: 1257b9526c6aSmrg# i) func_quote_arg_result 1258b9526c6aSmrg# double-quoted (when needed), suitable for a subsequent eval 1259b9526c6aSmrg# ii) func_quote_arg_unquoted_result 1260b9526c6aSmrg# has all characters that are still active within double 1261b9526c6aSmrg# quotes backslashified. Available only if 'unquoted' is specified. 1262b9526c6aSmrg# 1263b9526c6aSmrg# Available modes: 1264b9526c6aSmrg# ---------------- 1265b9526c6aSmrg# 'eval' (default) 1266b9526c6aSmrg# - escape shell special characters 1267b9526c6aSmrg# 'expand' 1268b9526c6aSmrg# - the same as 'eval'; but do not quote variable references 1269b9526c6aSmrg# 'pretty' 1270b9526c6aSmrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271b9526c6aSmrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272b9526c6aSmrg# of 'echo a\ b'. This is slower than default on some shells. 1273b9526c6aSmrg# 'unquoted' 1274b9526c6aSmrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275b9526c6aSmrg# wrapping double-quotes. 1276b9526c6aSmrg# 1277b9526c6aSmrg# Examples for 'func_quote_arg pretty,unquoted string': 1278b9526c6aSmrg# 1279b9526c6aSmrg# string | *_result | *_unquoted_result 1280b9526c6aSmrg# ------------+-----------------------+------------------- 1281b9526c6aSmrg# " | \" | \" 1282b9526c6aSmrg# a b | "a b" | a b 1283b9526c6aSmrg# "a b" | "\"a b\"" | \"a b\" 1284b9526c6aSmrg# * | "*" | * 1285b9526c6aSmrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286b9526c6aSmrg# 1287b9526c6aSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288b9526c6aSmrg# 1289b9526c6aSmrg# string | *_result | *_unquoted_result 1290b9526c6aSmrg# --------------+---------------------+-------------------- 1291b9526c6aSmrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292b9526c6aSmrgfunc_quote_arg () 1293b9526c6aSmrg{ 1294b9526c6aSmrg _G_quote_expand=false 1295b9526c6aSmrg case ,$1, in 1296b9526c6aSmrg *,expand,*) 1297b9526c6aSmrg _G_quote_expand=: 1298b9526c6aSmrg ;; 1299aa30ed02Smrg esac 1300aa30ed02Smrg 1301b9526c6aSmrg case ,$1, in 1302b9526c6aSmrg *,pretty,*|*,expand,*|*,unquoted,*) 1303b9526c6aSmrg func_quote_portable $_G_quote_expand "$2" 1304b9526c6aSmrg func_quote_arg_result=$func_quote_portable_result 1305b9526c6aSmrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306b9526c6aSmrg ;; 1307b9526c6aSmrg *) 1308b9526c6aSmrg # Faster quote-for-eval for some shells. 1309b9526c6aSmrg func_quotefast_eval "$2" 1310b9526c6aSmrg func_quote_arg_result=$func_quotefast_eval_result 1311aa30ed02Smrg ;; 1312aa30ed02Smrg esac 1313b9526c6aSmrg} 1314aa30ed02Smrg 1315b9526c6aSmrg 1316b9526c6aSmrg# func_quote MODEs ARGs... 1317b9526c6aSmrg# ------------------------ 1318b9526c6aSmrg# Quote all ARGs to be evaled later and join them into single command. See 1319b9526c6aSmrg# func_quote_arg's description for more info. 1320b9526c6aSmrgfunc_quote () 1321b9526c6aSmrg{ 1322b9526c6aSmrg $debug_cmd 1323b9526c6aSmrg _G_func_quote_mode=$1 ; shift 1324b9526c6aSmrg func_quote_result= 1325b9526c6aSmrg while test 0 -lt $#; do 1326b9526c6aSmrg func_quote_arg "$_G_func_quote_mode" "$1" 1327b9526c6aSmrg if test -n "$func_quote_result"; then 1328b9526c6aSmrg func_append func_quote_result " $func_quote_arg_result" 1329b9526c6aSmrg else 1330b9526c6aSmrg func_append func_quote_result "$func_quote_arg_result" 1331b9526c6aSmrg fi 1332b9526c6aSmrg shift 1333b9526c6aSmrg done 1334aa30ed02Smrg} 1335aa30ed02Smrg 1336aa30ed02Smrg 13377204935cSmrg# func_stripname PREFIX SUFFIX NAME 13387204935cSmrg# --------------------------------- 13397204935cSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13407204935cSmrg# PREFIX and SUFFIX must not contain globbing or regex special 13417204935cSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13427204935cSmrg# dot (in which case that matches only a dot). 13437204935cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 13447204935cSmrg eval 'func_stripname () 13457204935cSmrg { 13467204935cSmrg $debug_cmd 13477204935cSmrg 13487204935cSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13497204935cSmrg # positional parameters, so assign one to ordinary variable first. 13507204935cSmrg func_stripname_result=$3 13517204935cSmrg func_stripname_result=${func_stripname_result#"$1"} 13527204935cSmrg func_stripname_result=${func_stripname_result%"$2"} 13537204935cSmrg }' 13547204935cSmrgelse 13557204935cSmrg func_stripname () 13567204935cSmrg { 13577204935cSmrg $debug_cmd 13587204935cSmrg 13597204935cSmrg case $2 in 13607204935cSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13617204935cSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13627204935cSmrg esac 13637204935cSmrg } 13647204935cSmrgfi 13657204935cSmrg 13667204935cSmrg 13677204935cSmrg# func_show_eval CMD [FAIL_EXP] 13687204935cSmrg# ----------------------------- 13697204935cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13707204935cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13717204935cSmrg# is given, then evaluate it. 13727204935cSmrgfunc_show_eval () 13737204935cSmrg{ 13747204935cSmrg $debug_cmd 13757204935cSmrg 13767204935cSmrg _G_cmd=$1 13777204935cSmrg _G_fail_exp=${2-':'} 13787204935cSmrg 1379b9526c6aSmrg func_quote_arg pretty,expand "$_G_cmd" 1380b9526c6aSmrg eval "func_notquiet $func_quote_arg_result" 13817204935cSmrg 13827204935cSmrg $opt_dry_run || { 13837204935cSmrg eval "$_G_cmd" 13847204935cSmrg _G_status=$? 13857204935cSmrg if test 0 -ne "$_G_status"; then 13867204935cSmrg eval "(exit $_G_status); $_G_fail_exp" 13877204935cSmrg fi 13887204935cSmrg } 13897204935cSmrg} 13907204935cSmrg 13917204935cSmrg 13927204935cSmrg# func_show_eval_locale CMD [FAIL_EXP] 13937204935cSmrg# ------------------------------------ 13947204935cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13957204935cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13967204935cSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13977204935cSmrgfunc_show_eval_locale () 13987204935cSmrg{ 13997204935cSmrg $debug_cmd 14007204935cSmrg 14017204935cSmrg _G_cmd=$1 14027204935cSmrg _G_fail_exp=${2-':'} 14037204935cSmrg 14047204935cSmrg $opt_quiet || { 1405b9526c6aSmrg func_quote_arg expand,pretty "$_G_cmd" 1406b9526c6aSmrg eval "func_echo $func_quote_arg_result" 14077204935cSmrg } 14087204935cSmrg 14097204935cSmrg $opt_dry_run || { 14107204935cSmrg eval "$_G_user_locale 14117204935cSmrg $_G_cmd" 14127204935cSmrg _G_status=$? 14137204935cSmrg eval "$_G_safe_locale" 14147204935cSmrg if test 0 -ne "$_G_status"; then 14157204935cSmrg eval "(exit $_G_status); $_G_fail_exp" 14167204935cSmrg fi 14177204935cSmrg } 14187204935cSmrg} 14197204935cSmrg 14207204935cSmrg 14217204935cSmrg# func_tr_sh 14227204935cSmrg# ---------- 14237204935cSmrg# Turn $1 into a string suitable for a shell variable name. 14247204935cSmrg# Result is stored in $func_tr_sh_result. All characters 14257204935cSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14267204935cSmrg# if $1 begins with a digit, a '_' is prepended as well. 14277204935cSmrgfunc_tr_sh () 14287204935cSmrg{ 14297204935cSmrg $debug_cmd 14307204935cSmrg 14317204935cSmrg case $1 in 14327204935cSmrg [0-9]* | *[!a-zA-Z0-9_]*) 14337204935cSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14347204935cSmrg ;; 14357204935cSmrg * ) 14367204935cSmrg func_tr_sh_result=$1 14377204935cSmrg ;; 14387204935cSmrg esac 14397204935cSmrg} 14407204935cSmrg 14417204935cSmrg 14427204935cSmrg# func_verbose ARG... 14437204935cSmrg# ------------------- 14447204935cSmrg# Echo program name prefixed message in verbose mode only. 14457204935cSmrgfunc_verbose () 14467204935cSmrg{ 14477204935cSmrg $debug_cmd 14487204935cSmrg 14497204935cSmrg $opt_verbose && func_echo "$*" 14507204935cSmrg 14517204935cSmrg : 14527204935cSmrg} 14537204935cSmrg 14547204935cSmrg 14557204935cSmrg# func_warn_and_continue ARG... 14567204935cSmrg# ----------------------------- 14577204935cSmrg# Echo program name prefixed warning message to standard error. 14587204935cSmrgfunc_warn_and_continue () 14597204935cSmrg{ 14607204935cSmrg $debug_cmd 14617204935cSmrg 14627204935cSmrg $require_term_colors 14637204935cSmrg 14647204935cSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14657204935cSmrg} 14667204935cSmrg 14677204935cSmrg 14687204935cSmrg# func_warning CATEGORY ARG... 14697204935cSmrg# ---------------------------- 14707204935cSmrg# Echo program name prefixed warning message to standard error. Warning 14717204935cSmrg# messages can be filtered according to CATEGORY, where this function 14727204935cSmrg# elides messages where CATEGORY is not listed in the global variable 14737204935cSmrg# 'opt_warning_types'. 14747204935cSmrgfunc_warning () 14757204935cSmrg{ 14767204935cSmrg $debug_cmd 14777204935cSmrg 14787204935cSmrg # CATEGORY must be in the warning_categories list! 14797204935cSmrg case " $warning_categories " in 14807204935cSmrg *" $1 "*) ;; 14817204935cSmrg *) func_internal_error "invalid warning category '$1'" ;; 14827204935cSmrg esac 14837204935cSmrg 14847204935cSmrg _G_category=$1 14857204935cSmrg shift 14867204935cSmrg 14877204935cSmrg case " $opt_warning_types " in 14887204935cSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14897204935cSmrg esac 14907204935cSmrg} 14917204935cSmrg 14927204935cSmrg 14937204935cSmrg# func_sort_ver VER1 VER2 14947204935cSmrg# ----------------------- 14957204935cSmrg# 'sort -V' is not generally available. 14967204935cSmrg# Note this deviates from the version comparison in automake 14977204935cSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14987204935cSmrg# but this should suffice as we won't be specifying old 14997204935cSmrg# version formats or redundant trailing .0 in bootstrap.conf. 15007204935cSmrg# If we did want full compatibility then we should probably 15017204935cSmrg# use m4_version_compare from autoconf. 15027204935cSmrgfunc_sort_ver () 15037204935cSmrg{ 15047204935cSmrg $debug_cmd 15057204935cSmrg 15067204935cSmrg printf '%s\n%s\n' "$1" "$2" \ 15077204935cSmrg | 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 15087204935cSmrg} 15097204935cSmrg 15107204935cSmrg# func_lt_ver PREV CURR 15117204935cSmrg# --------------------- 15127204935cSmrg# Return true if PREV and CURR are in the correct order according to 15137204935cSmrg# func_sort_ver, otherwise false. Use it like this: 15147204935cSmrg# 15157204935cSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15167204935cSmrgfunc_lt_ver () 15177204935cSmrg{ 15187204935cSmrg $debug_cmd 15197204935cSmrg 15207204935cSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15217204935cSmrg} 15227204935cSmrg 15237204935cSmrg 15247204935cSmrg# Local variables: 15257204935cSmrg# mode: shell-script 15267204935cSmrg# sh-indentation: 2 15277204935cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 15287204935cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15297204935cSmrg# time-stamp-time-zone: "UTC" 15307204935cSmrg# End: 15317204935cSmrg#! /bin/sh 15327204935cSmrg 15337204935cSmrg# A portable, pluggable option parser for Bourne shell. 15347204935cSmrg# Written by Gary V. Vaughan, 2010 15357204935cSmrg 1536b9526c6aSmrg# This is free software. There is NO warranty; not even for 1537b9526c6aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538b9526c6aSmrg# 1539b9526c6aSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540b9526c6aSmrg# 1541b9526c6aSmrg# This file is dual licensed under the terms of the MIT license 1542b9526c6aSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543b9526c6aSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544b9526c6aSmrg# these licenses when using or redistributing this software or any of 1545b9526c6aSmrg# the files within it. See the URLs above, or the file `LICENSE` 1546b9526c6aSmrg# included in the Bootstrap distribution for the full license texts. 15477204935cSmrg 1548b9526c6aSmrg# Please report bugs or propose patches to: 1549b9526c6aSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 15507204935cSmrg 1551b9526c6aSmrg# Set a version string for this script. 1552b9526c6aSmrgscriptversion=2019-02-19.15; # UTC 15537204935cSmrg 15547204935cSmrg 15557204935cSmrg## ------ ## 15567204935cSmrg## Usage. ## 15577204935cSmrg## ------ ## 15587204935cSmrg 15597204935cSmrg# This file is a library for parsing options in your shell scripts along 15607204935cSmrg# with assorted other useful supporting features that you can make use 15617204935cSmrg# of too. 15627204935cSmrg# 15637204935cSmrg# For the simplest scripts you might need only: 15647204935cSmrg# 15657204935cSmrg# #!/bin/sh 15667204935cSmrg# . relative/path/to/funclib.sh 15677204935cSmrg# . relative/path/to/options-parser 15687204935cSmrg# scriptversion=1.0 15697204935cSmrg# func_options ${1+"$@"} 15707204935cSmrg# eval set dummy "$func_options_result"; shift 15717204935cSmrg# ...rest of your script... 15727204935cSmrg# 15737204935cSmrg# In order for the '--version' option to work, you will need to have a 15747204935cSmrg# suitably formatted comment like the one at the top of this file 1575b9526c6aSmrg# starting with '# Written by ' and ending with '# Copyright'. 15767204935cSmrg# 15777204935cSmrg# For '-h' and '--help' to work, you will also need a one line 15787204935cSmrg# description of your script's purpose in a comment directly above the 15797204935cSmrg# '# Written by ' line, like the one at the top of this file. 15807204935cSmrg# 15817204935cSmrg# The default options also support '--debug', which will turn on shell 15827204935cSmrg# execution tracing (see the comment above debug_cmd below for another 15837204935cSmrg# use), and '--verbose' and the func_verbose function to allow your script 15847204935cSmrg# to display verbose messages only when your user has specified 15857204935cSmrg# '--verbose'. 15867204935cSmrg# 1587b9526c6aSmrg# After sourcing this file, you can plug in processing for additional 15887204935cSmrg# options by amending the variables from the 'Configuration' section 15897204935cSmrg# below, and following the instructions in the 'Option parsing' 15907204935cSmrg# section further down. 15917204935cSmrg 15927204935cSmrg## -------------- ## 15937204935cSmrg## Configuration. ## 15947204935cSmrg## -------------- ## 15957204935cSmrg 15967204935cSmrg# You should override these variables in your script after sourcing this 15977204935cSmrg# file so that they reflect the customisations you have added to the 15987204935cSmrg# option parser. 15997204935cSmrg 16007204935cSmrg# The usage line for option parsing errors and the start of '-h' and 16017204935cSmrg# '--help' output messages. You can embed shell variables for delayed 16027204935cSmrg# expansion at the time the message is displayed, but you will need to 16037204935cSmrg# quote other shell meta-characters carefully to prevent them being 16047204935cSmrg# expanded when the contents are evaled. 16057204935cSmrgusage='$progpath [OPTION]...' 16067204935cSmrg 16077204935cSmrg# Short help message in response to '-h' and '--help'. Add to this or 16087204935cSmrg# override it after sourcing this library to reflect the full set of 16097204935cSmrg# options your script accepts. 16107204935cSmrgusage_message="\ 16117204935cSmrg --debug enable verbose shell tracing 16127204935cSmrg -W, --warnings=CATEGORY 16137204935cSmrg report the warnings falling in CATEGORY [all] 16147204935cSmrg -v, --verbose verbosely report processing 16157204935cSmrg --version print version information and exit 16167204935cSmrg -h, --help print short or long help message and exit 16177204935cSmrg" 16187204935cSmrg 16197204935cSmrg# Additional text appended to 'usage_message' in response to '--help'. 16207204935cSmrglong_help_message=" 16217204935cSmrgWarning categories include: 16227204935cSmrg 'all' show all warnings 16237204935cSmrg 'none' turn off all the warnings 16247204935cSmrg 'error' warnings are treated as fatal errors" 16257204935cSmrg 16267204935cSmrg# Help message printed before fatal option parsing errors. 16277204935cSmrgfatal_help="Try '\$progname --help' for more information." 16287204935cSmrg 16297204935cSmrg 16307204935cSmrg 16317204935cSmrg## ------------------------- ## 16327204935cSmrg## Hook function management. ## 16337204935cSmrg## ------------------------- ## 16347204935cSmrg 16357204935cSmrg# This section contains functions for adding, removing, and running hooks 1636b9526c6aSmrg# in the main code. A hook is just a list of function names that can be 1637b9526c6aSmrg# run in order later on. 16387204935cSmrg 16397204935cSmrg# func_hookable FUNC_NAME 16407204935cSmrg# ----------------------- 16417204935cSmrg# Declare that FUNC_NAME will run hooks added with 16427204935cSmrg# 'func_add_hook FUNC_NAME ...'. 16437204935cSmrgfunc_hookable () 16447204935cSmrg{ 16457204935cSmrg $debug_cmd 16467204935cSmrg 16477204935cSmrg func_append hookable_fns " $1" 16487204935cSmrg} 16497204935cSmrg 16507204935cSmrg 16517204935cSmrg# func_add_hook FUNC_NAME HOOK_FUNC 16527204935cSmrg# --------------------------------- 16537204935cSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16547204935cSmrg# first have been declared "hookable" by a call to 'func_hookable'. 16557204935cSmrgfunc_add_hook () 16567204935cSmrg{ 16577204935cSmrg $debug_cmd 16587204935cSmrg 16597204935cSmrg case " $hookable_fns " in 16607204935cSmrg *" $1 "*) ;; 16617204935cSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16627204935cSmrg esac 16637204935cSmrg 16647204935cSmrg eval func_append ${1}_hooks '" $2"' 16657204935cSmrg} 16667204935cSmrg 16677204935cSmrg 16687204935cSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 16697204935cSmrg# ------------------------------------ 1670b9526c6aSmrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671b9526c6aSmrg# FUNC_NAME. 16727204935cSmrgfunc_remove_hook () 16737204935cSmrg{ 16747204935cSmrg $debug_cmd 16757204935cSmrg 16767204935cSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16777204935cSmrg} 16787204935cSmrg 16797204935cSmrg 1680b9526c6aSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681b9526c6aSmrg# --------------------------------------------- 1682b9526c6aSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683b9526c6aSmrg# *_result variable of FUNC_NAME_B. 1684b9526c6aSmrgfunc_propagate_result () 1685b9526c6aSmrg{ 1686b9526c6aSmrg $debug_cmd 1687b9526c6aSmrg 1688b9526c6aSmrg func_propagate_result_result=: 1689b9526c6aSmrg if eval "test \"\${${1}_result+set}\" = set" 1690b9526c6aSmrg then 1691b9526c6aSmrg eval "${2}_result=\$${1}_result" 1692b9526c6aSmrg else 1693b9526c6aSmrg func_propagate_result_result=false 1694b9526c6aSmrg fi 1695b9526c6aSmrg} 1696b9526c6aSmrg 1697b9526c6aSmrg 16987204935cSmrg# func_run_hooks FUNC_NAME [ARG]... 16997204935cSmrg# --------------------------------- 17007204935cSmrg# Run all hook functions registered to FUNC_NAME. 1701b9526c6aSmrg# It's assumed that the list of hook functions contains nothing more 17027204935cSmrg# than a whitespace-delimited list of legal shell function names, and 17037204935cSmrg# no effort is wasted trying to catch shell meta-characters or preserve 17047204935cSmrg# whitespace. 17057204935cSmrgfunc_run_hooks () 17067204935cSmrg{ 17077204935cSmrg $debug_cmd 17087204935cSmrg 17097204935cSmrg case " $hookable_fns " in 17107204935cSmrg *" $1 "*) ;; 1711b9526c6aSmrg *) func_fatal_error "'$1' does not support hook functions." ;; 17127204935cSmrg esac 17137204935cSmrg 17147204935cSmrg eval _G_hook_fns=\$$1_hooks; shift 17157204935cSmrg 17167204935cSmrg for _G_hook in $_G_hook_fns; do 1717b9526c6aSmrg func_unset "${_G_hook}_result" 1718b9526c6aSmrg eval $_G_hook '${1+"$@"}' 1719b9526c6aSmrg func_propagate_result $_G_hook func_run_hooks 1720b9526c6aSmrg if $func_propagate_result_result; then 1721b9526c6aSmrg eval set dummy "$func_run_hooks_result"; shift 1722b9526c6aSmrg fi 17237204935cSmrg done 17247204935cSmrg} 17257204935cSmrg 17267204935cSmrg 17277204935cSmrg 17287204935cSmrg## --------------- ## 17297204935cSmrg## Option parsing. ## 17307204935cSmrg## --------------- ## 17317204935cSmrg 17327204935cSmrg# In order to add your own option parsing hooks, you must accept the 1733b9526c6aSmrg# full positional parameter list from your hook function. You may remove 1734b9526c6aSmrg# or edit any options that you action, and then pass back the remaining 1735b9526c6aSmrg# unprocessed options in '<hooked_function_name>_result', escaped 1736b9526c6aSmrg# suitably for 'eval'. 1737b9526c6aSmrg# 1738b9526c6aSmrg# The '<hooked_function_name>_result' variable is automatically unset 1739b9526c6aSmrg# before your hook gets called; for best performance, only set the 1740b9526c6aSmrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741b9526c6aSmrg# function unnecessarily because it can be an expensive operation on some 1742b9526c6aSmrg# machines). 1743b9526c6aSmrg# 1744b9526c6aSmrg# Like this: 17457204935cSmrg# 17467204935cSmrg# my_options_prep () 17477204935cSmrg# { 17487204935cSmrg# $debug_cmd 17497204935cSmrg# 17507204935cSmrg# # Extend the existing usage message. 17517204935cSmrg# usage_message=$usage_message' 17527204935cSmrg# -s, --silent don'\''t print informational messages 17537204935cSmrg# ' 1754b9526c6aSmrg# # No change in '$@' (ignored completely by this hook). Leave 1755b9526c6aSmrg# # my_options_prep_result variable intact. 17567204935cSmrg# } 17577204935cSmrg# func_add_hook func_options_prep my_options_prep 17587204935cSmrg# 17597204935cSmrg# 17607204935cSmrg# my_silent_option () 17617204935cSmrg# { 17627204935cSmrg# $debug_cmd 17637204935cSmrg# 1764b9526c6aSmrg# args_changed=false 1765b9526c6aSmrg# 1766b9526c6aSmrg# # Note that, for efficiency, we parse as many options as we can 17677204935cSmrg# # recognise in a loop before passing the remainder back to the 17687204935cSmrg# # caller on the first unrecognised argument we encounter. 17697204935cSmrg# while test $# -gt 0; do 17707204935cSmrg# opt=$1; shift 17717204935cSmrg# case $opt in 1772b9526c6aSmrg# --silent|-s) opt_silent=: 1773b9526c6aSmrg# args_changed=: 1774b9526c6aSmrg# ;; 17757204935cSmrg# # Separate non-argument short options: 17767204935cSmrg# -s*) func_split_short_opt "$_G_opt" 17777204935cSmrg# set dummy "$func_split_short_opt_name" \ 17787204935cSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 17797204935cSmrg# shift 1780b9526c6aSmrg# args_changed=: 17817204935cSmrg# ;; 1782b9526c6aSmrg# *) # Make sure the first unrecognised option "$_G_opt" 1783b9526c6aSmrg# # is added back to "$@" in case we need it later, 1784b9526c6aSmrg# # if $args_changed was set to 'true'. 1785b9526c6aSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17867204935cSmrg# esac 17877204935cSmrg# done 17887204935cSmrg# 1789b9526c6aSmrg# # Only call 'func_quote' here if we processed at least one argument. 1790b9526c6aSmrg# if $args_changed; then 1791b9526c6aSmrg# func_quote eval ${1+"$@"} 1792b9526c6aSmrg# my_silent_option_result=$func_quote_result 1793b9526c6aSmrg# fi 17947204935cSmrg# } 17957204935cSmrg# func_add_hook func_parse_options my_silent_option 17967204935cSmrg# 17977204935cSmrg# 17987204935cSmrg# my_option_validation () 17997204935cSmrg# { 18007204935cSmrg# $debug_cmd 18017204935cSmrg# 18027204935cSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18037204935cSmrg# '--silent' and '--verbose' options are mutually exclusive." 18047204935cSmrg# } 18057204935cSmrg# func_add_hook func_validate_options my_option_validation 18067204935cSmrg# 1807b9526c6aSmrg# You'll also need to manually amend $usage_message to reflect the extra 18087204935cSmrg# options you parse. It's preferable to append if you can, so that 18097204935cSmrg# multiple option parsing hooks can be added safely. 18107204935cSmrg 18117204935cSmrg 1812b9526c6aSmrg# func_options_finish [ARG]... 1813b9526c6aSmrg# ---------------------------- 1814b9526c6aSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815b9526c6aSmrgfunc_options_finish () 1816b9526c6aSmrg{ 1817b9526c6aSmrg $debug_cmd 1818b9526c6aSmrg 1819b9526c6aSmrg func_run_hooks func_options ${1+"$@"} 1820b9526c6aSmrg func_propagate_result func_run_hooks func_options_finish 1821b9526c6aSmrg} 1822b9526c6aSmrg 1823b9526c6aSmrg 18247204935cSmrg# func_options [ARG]... 18257204935cSmrg# --------------------- 18267204935cSmrg# All the functions called inside func_options are hookable. See the 18277204935cSmrg# individual implementations for details. 18287204935cSmrgfunc_hookable func_options 18297204935cSmrgfunc_options () 18307204935cSmrg{ 18317204935cSmrg $debug_cmd 18327204935cSmrg 1833b9526c6aSmrg _G_options_quoted=false 1834fe12f63cSmrg 1835b9526c6aSmrg for my_func in options_prep parse_options validate_options options_finish 1836b9526c6aSmrg do 1837b9526c6aSmrg func_unset func_${my_func}_result 1838b9526c6aSmrg func_unset func_run_hooks_result 1839b9526c6aSmrg eval func_$my_func '${1+"$@"}' 1840b9526c6aSmrg func_propagate_result func_$my_func func_options 1841b9526c6aSmrg if $func_propagate_result_result; then 1842b9526c6aSmrg eval set dummy "$func_options_result"; shift 1843b9526c6aSmrg _G_options_quoted=: 1844b9526c6aSmrg fi 1845b9526c6aSmrg done 18467204935cSmrg 1847b9526c6aSmrg $_G_options_quoted || { 1848b9526c6aSmrg # As we (func_options) are top-level options-parser function and 1849b9526c6aSmrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850b9526c6aSmrg # caller. 1851b9526c6aSmrg func_quote eval ${1+"$@"} 1852b9526c6aSmrg func_options_result=$func_quote_result 1853b9526c6aSmrg } 18541016ad83Smrg} 18551016ad83Smrg 18561016ad83Smrg 18577204935cSmrg# func_options_prep [ARG]... 18587204935cSmrg# -------------------------- 18597204935cSmrg# All initialisations required before starting the option parse loop. 18607204935cSmrg# Note that when calling hook functions, we pass through the list of 18617204935cSmrg# positional parameters. If a hook function modifies that list, and 1862b9526c6aSmrg# needs to propagate that back to rest of this script, then the complete 1863b9526c6aSmrg# modified list must be put in 'func_run_hooks_result' before returning. 18647204935cSmrgfunc_hookable func_options_prep 18657204935cSmrgfunc_options_prep () 18661016ad83Smrg{ 18677204935cSmrg $debug_cmd 18681016ad83Smrg 18697204935cSmrg # Option defaults: 18707204935cSmrg opt_verbose=false 18717204935cSmrg opt_warning_types= 18727204935cSmrg 1873aa30ed02Smrg func_run_hooks func_options_prep ${1+"$@"} 1874b9526c6aSmrg func_propagate_result func_run_hooks func_options_prep 18751016ad83Smrg} 18761016ad83Smrg 18771016ad83Smrg 18787204935cSmrg# func_parse_options [ARG]... 18797204935cSmrg# --------------------------- 18807204935cSmrg# The main option parsing loop. 18817204935cSmrgfunc_hookable func_parse_options 18827204935cSmrgfunc_parse_options () 18831016ad83Smrg{ 18847204935cSmrg $debug_cmd 18851016ad83Smrg 1886b9526c6aSmrg _G_parse_options_requote=false 18877204935cSmrg # this just eases exit handling 18887204935cSmrg while test $# -gt 0; do 18897204935cSmrg # Defer to hook functions for initial option parsing, so they 18907204935cSmrg # get priority in the event of reusing an option name. 1891aa30ed02Smrg func_run_hooks func_parse_options ${1+"$@"} 1892b9526c6aSmrg func_propagate_result func_run_hooks func_parse_options 1893b9526c6aSmrg if $func_propagate_result_result; then 1894b9526c6aSmrg eval set dummy "$func_parse_options_result"; shift 1895b9526c6aSmrg # Even though we may have changed "$@", we passed the "$@" array 1896b9526c6aSmrg # down into the hook and it quoted it for us (because we are in 1897b9526c6aSmrg # this if-branch). No need to quote it again. 1898b9526c6aSmrg _G_parse_options_requote=false 1899b9526c6aSmrg fi 19001016ad83Smrg 19017204935cSmrg # Break out of the loop if we already parsed every option. 19027204935cSmrg test $# -gt 0 || break 19031016ad83Smrg 1904b9526c6aSmrg # We expect that one of the options parsed in this function matches 1905b9526c6aSmrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906b9526c6aSmrg _G_match_parse_options=: 19077204935cSmrg _G_opt=$1 19087204935cSmrg shift 19097204935cSmrg case $_G_opt in 19107204935cSmrg --debug|-x) debug_cmd='set -x' 1911b9526c6aSmrg func_echo "enabling shell trace mode" >&2 19127204935cSmrg $debug_cmd 19137204935cSmrg ;; 19147204935cSmrg 19157204935cSmrg --no-warnings|--no-warning|--no-warn) 19167204935cSmrg set dummy --warnings none ${1+"$@"} 19177204935cSmrg shift 19187204935cSmrg ;; 19191016ad83Smrg 19207204935cSmrg --warnings|--warning|-W) 1921b9526c6aSmrg if test $# = 0 && func_missing_arg $_G_opt; then 1922b9526c6aSmrg _G_parse_options_requote=: 1923b9526c6aSmrg break 1924b9526c6aSmrg fi 19257204935cSmrg case " $warning_categories $1" in 19267204935cSmrg *" $1 "*) 19277204935cSmrg # trailing space prevents matching last $1 above 19287204935cSmrg func_append_uniq opt_warning_types " $1" 19297204935cSmrg ;; 19307204935cSmrg *all) 19317204935cSmrg opt_warning_types=$warning_categories 19327204935cSmrg ;; 19337204935cSmrg *none) 19347204935cSmrg opt_warning_types=none 19357204935cSmrg warning_func=: 19367204935cSmrg ;; 19377204935cSmrg *error) 19387204935cSmrg opt_warning_types=$warning_categories 19397204935cSmrg warning_func=func_fatal_error 19407204935cSmrg ;; 19417204935cSmrg *) 19427204935cSmrg func_fatal_error \ 19437204935cSmrg "unsupported warning category: '$1'" 19447204935cSmrg ;; 19457204935cSmrg esac 19467204935cSmrg shift 19477204935cSmrg ;; 19487204935cSmrg 19497204935cSmrg --verbose|-v) opt_verbose=: ;; 19507204935cSmrg --version) func_version ;; 19517204935cSmrg -\?|-h) func_usage ;; 19527204935cSmrg --help) func_help ;; 19537204935cSmrg 19547204935cSmrg # Separate optargs to long options (plugins may need this): 19557204935cSmrg --*=*) func_split_equals "$_G_opt" 19567204935cSmrg set dummy "$func_split_equals_lhs" \ 19577204935cSmrg "$func_split_equals_rhs" ${1+"$@"} 19587204935cSmrg shift 19597204935cSmrg ;; 19607204935cSmrg 19617204935cSmrg # Separate optargs to short options: 19627204935cSmrg -W*) 19637204935cSmrg func_split_short_opt "$_G_opt" 19647204935cSmrg set dummy "$func_split_short_opt_name" \ 19657204935cSmrg "$func_split_short_opt_arg" ${1+"$@"} 19667204935cSmrg shift 19677204935cSmrg ;; 19687204935cSmrg 19697204935cSmrg # Separate non-argument short options: 19707204935cSmrg -\?*|-h*|-v*|-x*) 19717204935cSmrg func_split_short_opt "$_G_opt" 19727204935cSmrg set dummy "$func_split_short_opt_name" \ 19737204935cSmrg "-$func_split_short_opt_arg" ${1+"$@"} 19747204935cSmrg shift 19757204935cSmrg ;; 19767204935cSmrg 1977b9526c6aSmrg --) _G_parse_options_requote=: ; break ;; 19787204935cSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979b9526c6aSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980b9526c6aSmrg _G_match_parse_options=false 1981b9526c6aSmrg break 1982b9526c6aSmrg ;; 19837204935cSmrg esac 1984b9526c6aSmrg 1985b9526c6aSmrg if $_G_match_parse_options; then 1986b9526c6aSmrg _G_parse_options_requote=: 1987b9526c6aSmrg fi 19887204935cSmrg done 19897204935cSmrg 1990b9526c6aSmrg if $_G_parse_options_requote; then 1991b9526c6aSmrg # save modified positional parameters for caller 1992b9526c6aSmrg func_quote eval ${1+"$@"} 1993b9526c6aSmrg func_parse_options_result=$func_quote_result 1994b9526c6aSmrg fi 19951016ad83Smrg} 19961016ad83Smrg 19971016ad83Smrg 19987204935cSmrg# func_validate_options [ARG]... 19997204935cSmrg# ------------------------------ 20007204935cSmrg# Perform any sanity checks on option settings and/or unconsumed 20017204935cSmrg# arguments. 20027204935cSmrgfunc_hookable func_validate_options 20037204935cSmrgfunc_validate_options () 20041016ad83Smrg{ 20057204935cSmrg $debug_cmd 20061016ad83Smrg 20077204935cSmrg # Display all warnings if -W was not given. 20087204935cSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20091016ad83Smrg 2010aa30ed02Smrg func_run_hooks func_validate_options ${1+"$@"} 2011b9526c6aSmrg func_propagate_result func_run_hooks func_validate_options 20121016ad83Smrg 20137204935cSmrg # Bail if the options were screwed! 20147204935cSmrg $exit_cmd $EXIT_FAILURE 20151016ad83Smrg} 20161016ad83Smrg 20171016ad83Smrg 20181016ad83Smrg 20197204935cSmrg## ----------------- ## 20207204935cSmrg## Helper functions. ## 20217204935cSmrg## ----------------- ## 20221016ad83Smrg 20237204935cSmrg# This section contains the helper functions used by the rest of the 20247204935cSmrg# hookable option parser framework in ascii-betical order. 20257204935cSmrg 20267204935cSmrg 20277204935cSmrg# func_fatal_help ARG... 20287204935cSmrg# ---------------------- 20297204935cSmrg# Echo program name prefixed message to standard error, followed by 20307204935cSmrg# a help hint, and exit. 20317204935cSmrgfunc_fatal_help () 20321016ad83Smrg{ 20337204935cSmrg $debug_cmd 20341016ad83Smrg 20357204935cSmrg eval \$ECHO \""Usage: $usage"\" 20367204935cSmrg eval \$ECHO \""$fatal_help"\" 20377204935cSmrg func_error ${1+"$@"} 20387204935cSmrg exit $EXIT_FAILURE 20391016ad83Smrg} 20401016ad83Smrg 20417204935cSmrg 20427204935cSmrg# func_help 20437204935cSmrg# --------- 20447204935cSmrg# Echo long help message to standard output and exit. 20451016ad83Smrgfunc_help () 20461016ad83Smrg{ 20477204935cSmrg $debug_cmd 20487204935cSmrg 20497204935cSmrg func_usage_message 20507204935cSmrg $ECHO "$long_help_message" 20517204935cSmrg exit 0 20521016ad83Smrg} 20531016ad83Smrg 20547204935cSmrg 20557204935cSmrg# func_missing_arg ARGNAME 20567204935cSmrg# ------------------------ 20571016ad83Smrg# Echo program name prefixed message to standard error and set global 20581016ad83Smrg# exit_cmd. 20591016ad83Smrgfunc_missing_arg () 20601016ad83Smrg{ 20617204935cSmrg $debug_cmd 20621016ad83Smrg 20637204935cSmrg func_error "Missing argument for '$1'." 20641016ad83Smrg exit_cmd=exit 20651016ad83Smrg} 20661016ad83Smrg 20671016ad83Smrg 20687204935cSmrg# func_split_equals STRING 20697204935cSmrg# ------------------------ 2070b9526c6aSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071b9526c6aSmrg# after splitting STRING at the '=' sign. 20727204935cSmrgtest -z "$_G_HAVE_XSI_OPS" \ 20737204935cSmrg && (eval 'x=a/b/c; 20747204935cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20757204935cSmrg && _G_HAVE_XSI_OPS=yes 20767204935cSmrg 20777204935cSmrgif test yes = "$_G_HAVE_XSI_OPS" 20787204935cSmrgthen 20797204935cSmrg # This is an XSI compatible shell, allowing a faster implementation... 20807204935cSmrg eval 'func_split_equals () 20817204935cSmrg { 20827204935cSmrg $debug_cmd 20837204935cSmrg 20847204935cSmrg func_split_equals_lhs=${1%%=*} 20857204935cSmrg func_split_equals_rhs=${1#*=} 2086b9526c6aSmrg if test "x$func_split_equals_lhs" = "x$1"; then 2087b9526c6aSmrg func_split_equals_rhs= 2088b9526c6aSmrg fi 20897204935cSmrg }' 20907204935cSmrgelse 20917204935cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 20927204935cSmrg func_split_equals () 20937204935cSmrg { 20947204935cSmrg $debug_cmd 20957204935cSmrg 20967204935cSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20977204935cSmrg func_split_equals_rhs= 2098b9526c6aSmrg test "x$func_split_equals_lhs=" = "x$1" \ 20997204935cSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21007204935cSmrg } 21017204935cSmrgfi #func_split_equals 21027204935cSmrg 21037204935cSmrg 21047204935cSmrg# func_split_short_opt SHORTOPT 21057204935cSmrg# ----------------------------- 21061016ad83Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 21071016ad83Smrg# variables after splitting SHORTOPT after the 2nd character. 21087204935cSmrgif test yes = "$_G_HAVE_XSI_OPS" 21097204935cSmrgthen 21107204935cSmrg # This is an XSI compatible shell, allowing a faster implementation... 21117204935cSmrg eval 'func_split_short_opt () 21127204935cSmrg { 21137204935cSmrg $debug_cmd 21147204935cSmrg 21157204935cSmrg func_split_short_opt_arg=${1#??} 21167204935cSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21177204935cSmrg }' 21187204935cSmrgelse 21197204935cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 21207204935cSmrg func_split_short_opt () 21217204935cSmrg { 21227204935cSmrg $debug_cmd 21237204935cSmrg 2124b9526c6aSmrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21257204935cSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21267204935cSmrg } 21277204935cSmrgfi #func_split_short_opt 21287204935cSmrg 21297204935cSmrg 21307204935cSmrg# func_usage 21317204935cSmrg# ---------- 21327204935cSmrg# Echo short help message to standard output and exit. 21337204935cSmrgfunc_usage () 21341016ad83Smrg{ 21357204935cSmrg $debug_cmd 21361016ad83Smrg 21377204935cSmrg func_usage_message 21387204935cSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21397204935cSmrg exit 0 21407204935cSmrg} 21411016ad83Smrg 21421016ad83Smrg 21437204935cSmrg# func_usage_message 21447204935cSmrg# ------------------ 21457204935cSmrg# Echo short help message to standard output. 21467204935cSmrgfunc_usage_message () 21471016ad83Smrg{ 21487204935cSmrg $debug_cmd 21491016ad83Smrg 21507204935cSmrg eval \$ECHO \""Usage: $usage"\" 21517204935cSmrg echo 21527204935cSmrg $SED -n 's|^# || 21537204935cSmrg /^Written by/{ 21547204935cSmrg x;p;x 21557204935cSmrg } 21567204935cSmrg h 21577204935cSmrg /^Written by/q' < "$progpath" 21587204935cSmrg echo 21597204935cSmrg eval \$ECHO \""$usage_message"\" 21607204935cSmrg} 21611016ad83Smrg 21621016ad83Smrg 21637204935cSmrg# func_version 21647204935cSmrg# ------------ 21657204935cSmrg# Echo version message to standard output and exit. 2166b9526c6aSmrg# The version message is extracted from the calling file's header 2167b9526c6aSmrg# comments, with leading '# ' stripped: 2168b9526c6aSmrg# 1. First display the progname and version 2169b9526c6aSmrg# 2. Followed by the header comment line matching /^# Written by / 2170b9526c6aSmrg# 3. Then a blank line followed by the first following line matching 2171b9526c6aSmrg# /^# Copyright / 2172b9526c6aSmrg# 4. Immediately followed by any lines between the previous matches, 2173b9526c6aSmrg# except lines preceding the intervening completely blank line. 2174b9526c6aSmrg# For example, see the header comments of this file. 21757204935cSmrgfunc_version () 21767204935cSmrg{ 21777204935cSmrg $debug_cmd 21781016ad83Smrg 21797204935cSmrg printf '%s\n' "$progname $scriptversion" 21807204935cSmrg $SED -n ' 2181b9526c6aSmrg /^# Written by /!b 2182b9526c6aSmrg s|^# ||; p; n 2183b9526c6aSmrg 2184b9526c6aSmrg :fwd2blnk 2185b9526c6aSmrg /./ { 2186b9526c6aSmrg n 2187b9526c6aSmrg b fwd2blnk 21887204935cSmrg } 2189b9526c6aSmrg p; n 2190b9526c6aSmrg 2191b9526c6aSmrg :holdwrnt 2192b9526c6aSmrg s|^# || 2193b9526c6aSmrg s|^# *$|| 2194b9526c6aSmrg /^Copyright /!{ 2195b9526c6aSmrg /./H 2196b9526c6aSmrg n 2197b9526c6aSmrg b holdwrnt 21987204935cSmrg } 2199b9526c6aSmrg 2200b9526c6aSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201b9526c6aSmrg G 2202b9526c6aSmrg s|\(\n\)\n*|\1|g 2203b9526c6aSmrg p; q' < "$progpath" 22041016ad83Smrg 22057204935cSmrg exit $? 22067204935cSmrg} 22071016ad83Smrg 22081016ad83Smrg 22097204935cSmrg# Local variables: 22107204935cSmrg# mode: shell-script 22117204935cSmrg# sh-indentation: 2 22127204935cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213b9526c6aSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22147204935cSmrg# time-stamp-time-zone: "UTC" 22157204935cSmrg# End: 22161016ad83Smrg 22177204935cSmrg# Set a version string. 2218b9526c6aSmrgscriptversion='(GNU libtool) 2.4.7' 22191016ad83Smrg 22201016ad83Smrg 22217204935cSmrg# func_echo ARG... 22227204935cSmrg# ---------------- 22237204935cSmrg# Libtool also displays the current mode in messages, so override 22247204935cSmrg# funclib.sh func_echo with this custom definition. 22257204935cSmrgfunc_echo () 22261016ad83Smrg{ 22277204935cSmrg $debug_cmd 22281016ad83Smrg 22297204935cSmrg _G_message=$* 22301016ad83Smrg 22317204935cSmrg func_echo_IFS=$IFS 22327204935cSmrg IFS=$nl 22337204935cSmrg for _G_line in $_G_message; do 22347204935cSmrg IFS=$func_echo_IFS 22357204935cSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22367204935cSmrg done 22377204935cSmrg IFS=$func_echo_IFS 22387204935cSmrg} 22391016ad83Smrg 22407204935cSmrg 22417204935cSmrg# func_warning ARG... 22427204935cSmrg# ------------------- 22437204935cSmrg# Libtool warnings are not categorized, so override funclib.sh 22447204935cSmrg# func_warning with this simpler definition. 22457204935cSmrgfunc_warning () 22461016ad83Smrg{ 22477204935cSmrg $debug_cmd 22481016ad83Smrg 22497204935cSmrg $warning_func ${1+"$@"} 22507204935cSmrg} 22511016ad83Smrg 22521016ad83Smrg 22537204935cSmrg## ---------------- ## 22547204935cSmrg## Options parsing. ## 22557204935cSmrg## ---------------- ## 22567204935cSmrg 22577204935cSmrg# Hook in the functions to make sure our own options are parsed during 22587204935cSmrg# the option parsing loop. 22597204935cSmrg 22607204935cSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 22617204935cSmrg 22627204935cSmrg# Short help message in response to '-h'. 22637204935cSmrgusage_message="Options: 22647204935cSmrg --config show all configuration variables 22657204935cSmrg --debug enable verbose shell tracing 22667204935cSmrg -n, --dry-run display commands without modifying any files 22677204935cSmrg --features display basic configuration information and exit 22687204935cSmrg --mode=MODE use operation mode MODE 22697204935cSmrg --no-warnings equivalent to '-Wnone' 22707204935cSmrg --preserve-dup-deps don't remove duplicate dependency libraries 22717204935cSmrg --quiet, --silent don't print informational messages 22727204935cSmrg --tag=TAG use configuration variables from tag TAG 22737204935cSmrg -v, --verbose print more informational messages than default 22747204935cSmrg --version print version information 22757204935cSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22767204935cSmrg -h, --help, --help-all print short, long, or detailed help message 22777204935cSmrg" 22781016ad83Smrg 22797204935cSmrg# Additional text appended to 'usage_message' in response to '--help'. 22807204935cSmrgfunc_help () 22811016ad83Smrg{ 22827204935cSmrg $debug_cmd 22837204935cSmrg 22847204935cSmrg func_usage_message 22857204935cSmrg $ECHO "$long_help_message 22867204935cSmrg 22877204935cSmrgMODE must be one of the following: 22887204935cSmrg 22897204935cSmrg clean remove files from the build directory 22907204935cSmrg compile compile a source file into a libtool object 22917204935cSmrg execute automatically set library path, then run a program 22927204935cSmrg finish complete the installation of libtool libraries 22937204935cSmrg install install libraries or executables 22947204935cSmrg link create a library or an executable 22957204935cSmrg uninstall remove libraries from an installed directory 22967204935cSmrg 22977204935cSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22987204935cSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22997204935cSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23007204935cSmrg 23017204935cSmrgWhen reporting a bug, please describe a test case to reproduce it and 23027204935cSmrginclude the following information: 23037204935cSmrg 23047204935cSmrg host-triplet: $host 23057204935cSmrg shell: $SHELL 23067204935cSmrg compiler: $LTCC 23077204935cSmrg compiler flags: $LTCFLAGS 23087204935cSmrg linker: $LD (gnu? $with_gnu_ld) 2309b9526c6aSmrg version: $progname (GNU libtool) 2.4.7 23107204935cSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23117204935cSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23127204935cSmrg 23137204935cSmrgReport bugs to <bug-libtool@gnu.org>. 2314aa30ed02SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23157204935cSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23167204935cSmrg exit 0 23177204935cSmrg} 23181016ad83Smrg 23191016ad83Smrg 23207204935cSmrg# func_lo2o OBJECT-NAME 23217204935cSmrg# --------------------- 23227204935cSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23237204935cSmrg# object suffix. 23247204935cSmrg 23257204935cSmrglo2o=s/\\.lo\$/.$objext/ 23267204935cSmrgo2lo=s/\\.$objext\$/.lo/ 23277204935cSmrg 23287204935cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 23297204935cSmrg eval 'func_lo2o () 23307204935cSmrg { 23317204935cSmrg case $1 in 23327204935cSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23337204935cSmrg * ) func_lo2o_result=$1 ;; 23347204935cSmrg esac 23357204935cSmrg }' 23367204935cSmrg 23377204935cSmrg # func_xform LIBOBJ-OR-SOURCE 23387204935cSmrg # --------------------------- 23397204935cSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23407204935cSmrg # suffix to a '.lo' libtool-object suffix. 23417204935cSmrg eval 'func_xform () 23427204935cSmrg { 23437204935cSmrg func_xform_result=${1%.*}.lo 23447204935cSmrg }' 23457204935cSmrgelse 23467204935cSmrg # ...otherwise fall back to using sed. 23477204935cSmrg func_lo2o () 23487204935cSmrg { 23497204935cSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23507204935cSmrg } 23517204935cSmrg 23527204935cSmrg func_xform () 23537204935cSmrg { 23547204935cSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23557204935cSmrg } 23567204935cSmrgfi 23571016ad83Smrg 23581016ad83Smrg 23597204935cSmrg# func_fatal_configuration ARG... 23607204935cSmrg# ------------------------------- 23611016ad83Smrg# Echo program name prefixed message to standard error, followed by 23621016ad83Smrg# a configuration failure hint, and exit. 23631016ad83Smrgfunc_fatal_configuration () 23641016ad83Smrg{ 2365b9526c6aSmrg func_fatal_error ${1+"$@"} \ 23667204935cSmrg "See the $PACKAGE documentation for more information." \ 23677204935cSmrg "Fatal configuration error." 23681016ad83Smrg} 23691016ad83Smrg 23701016ad83Smrg 23711016ad83Smrg# func_config 23727204935cSmrg# ----------- 23731016ad83Smrg# Display the configuration for all the tags in this script. 23741016ad83Smrgfunc_config () 23751016ad83Smrg{ 23761016ad83Smrg re_begincf='^# ### BEGIN LIBTOOL' 23771016ad83Smrg re_endcf='^# ### END LIBTOOL' 23781016ad83Smrg 23791016ad83Smrg # Default configuration. 23801016ad83Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 23811016ad83Smrg 23821016ad83Smrg # Now print the configurations for the tags. 23831016ad83Smrg for tagname in $taglist; do 23841016ad83Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23851016ad83Smrg done 23861016ad83Smrg 23871016ad83Smrg exit $? 23881016ad83Smrg} 23891016ad83Smrg 23907204935cSmrg 23911016ad83Smrg# func_features 23927204935cSmrg# ------------- 23931016ad83Smrg# Display the features supported by this script. 23941016ad83Smrgfunc_features () 23951016ad83Smrg{ 23961016ad83Smrg echo "host: $host" 23977204935cSmrg if test yes = "$build_libtool_libs"; then 23981016ad83Smrg echo "enable shared libraries" 23991016ad83Smrg else 24001016ad83Smrg echo "disable shared libraries" 24011016ad83Smrg fi 24027204935cSmrg if test yes = "$build_old_libs"; then 24031016ad83Smrg echo "enable static libraries" 24041016ad83Smrg else 24051016ad83Smrg echo "disable static libraries" 24061016ad83Smrg fi 24071016ad83Smrg 24081016ad83Smrg exit $? 24091016ad83Smrg} 24101016ad83Smrg 24117204935cSmrg 24127204935cSmrg# func_enable_tag TAGNAME 24137204935cSmrg# ----------------------- 24141016ad83Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 24151016ad83Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 24161016ad83Smrg# variable here. 24171016ad83Smrgfunc_enable_tag () 24181016ad83Smrg{ 24197204935cSmrg # Global variable: 24207204935cSmrg tagname=$1 24211016ad83Smrg 24227204935cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24237204935cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24247204935cSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24251016ad83Smrg 24267204935cSmrg # Validate tagname. 24277204935cSmrg case $tagname in 24287204935cSmrg *[!-_A-Za-z0-9,/]*) 24297204935cSmrg func_fatal_error "invalid tag name: $tagname" 24307204935cSmrg ;; 24317204935cSmrg esac 24321016ad83Smrg 24337204935cSmrg # Don't test for the "default" C tag, as we know it's 24347204935cSmrg # there but not specially marked. 24357204935cSmrg case $tagname in 24367204935cSmrg CC) ;; 24371016ad83Smrg *) 24387204935cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24397204935cSmrg taglist="$taglist $tagname" 24407204935cSmrg 24417204935cSmrg # Evaluate the configuration. Be careful to quote the path 24427204935cSmrg # and the sed script, to avoid splitting on whitespace, but 24437204935cSmrg # also don't use non-portable quotes within backquotes within 24447204935cSmrg # quotes we have to do it in 2 steps: 24457204935cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24467204935cSmrg eval "$extractedcf" 24477204935cSmrg else 24487204935cSmrg func_error "ignoring unknown tag $tagname" 24497204935cSmrg fi 24507204935cSmrg ;; 24517204935cSmrg esac 24521016ad83Smrg} 24531016ad83Smrg 24547204935cSmrg 24551016ad83Smrg# func_check_version_match 24567204935cSmrg# ------------------------ 24571016ad83Smrg# Ensure that we are using m4 macros, and libtool script from the same 24581016ad83Smrg# release of libtool. 24591016ad83Smrgfunc_check_version_match () 24601016ad83Smrg{ 24617204935cSmrg if test "$package_revision" != "$macro_revision"; then 24627204935cSmrg if test "$VERSION" != "$macro_version"; then 24637204935cSmrg if test -z "$macro_version"; then 24647204935cSmrg cat >&2 <<_LT_EOF 24651016ad83Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24661016ad83Smrg$progname: definition of this LT_INIT comes from an older release. 24671016ad83Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24681016ad83Smrg$progname: and run autoconf again. 24691016ad83Smrg_LT_EOF 24707204935cSmrg else 24717204935cSmrg cat >&2 <<_LT_EOF 24721016ad83Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24731016ad83Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 24741016ad83Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24751016ad83Smrg$progname: and run autoconf again. 24761016ad83Smrg_LT_EOF 24777204935cSmrg fi 24787204935cSmrg else 24797204935cSmrg cat >&2 <<_LT_EOF 24801016ad83Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 24811016ad83Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 24821016ad83Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 24831016ad83Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 24841016ad83Smrg_LT_EOF 24857204935cSmrg fi 24861016ad83Smrg 24877204935cSmrg exit $EXIT_MISMATCH 24887204935cSmrg fi 24891016ad83Smrg} 24901016ad83Smrg 24911016ad83Smrg 24927204935cSmrg# libtool_options_prep [ARG]... 24937204935cSmrg# ----------------------------- 24947204935cSmrg# Preparation for options parsed by libtool. 24957204935cSmrglibtool_options_prep () 24967204935cSmrg{ 24977204935cSmrg $debug_mode 24981016ad83Smrg 24997204935cSmrg # Option defaults: 25007204935cSmrg opt_config=false 25017204935cSmrg opt_dlopen= 25027204935cSmrg opt_dry_run=false 25037204935cSmrg opt_help=false 25047204935cSmrg opt_mode= 25057204935cSmrg opt_preserve_dup_deps=false 25067204935cSmrg opt_quiet=false 25071016ad83Smrg 25087204935cSmrg nonopt= 25097204935cSmrg preserve_args= 25101016ad83Smrg 2511b9526c6aSmrg _G_rc_lt_options_prep=: 2512b9526c6aSmrg 25137204935cSmrg # Shorthand for --mode=foo, only valid as the first argument 25147204935cSmrg case $1 in 25157204935cSmrg clean|clea|cle|cl) 25167204935cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 25177204935cSmrg ;; 25187204935cSmrg compile|compil|compi|comp|com|co|c) 25197204935cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 25207204935cSmrg ;; 25217204935cSmrg execute|execut|execu|exec|exe|ex|e) 25227204935cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 25237204935cSmrg ;; 25247204935cSmrg finish|finis|fini|fin|fi|f) 25257204935cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 25267204935cSmrg ;; 25277204935cSmrg install|instal|insta|inst|ins|in|i) 25287204935cSmrg shift; set dummy --mode install ${1+"$@"}; shift 25297204935cSmrg ;; 25307204935cSmrg link|lin|li|l) 25317204935cSmrg shift; set dummy --mode link ${1+"$@"}; shift 25327204935cSmrg ;; 25337204935cSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25347204935cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25357204935cSmrg ;; 2536b9526c6aSmrg *) 2537b9526c6aSmrg _G_rc_lt_options_prep=false 2538b9526c6aSmrg ;; 25397204935cSmrg esac 25407204935cSmrg 2541b9526c6aSmrg if $_G_rc_lt_options_prep; then 2542b9526c6aSmrg # Pass back the list of options. 2543b9526c6aSmrg func_quote eval ${1+"$@"} 2544b9526c6aSmrg libtool_options_prep_result=$func_quote_result 2545b9526c6aSmrg fi 25467204935cSmrg} 25477204935cSmrgfunc_add_hook func_options_prep libtool_options_prep 25481016ad83Smrg 25491016ad83Smrg 25507204935cSmrg# libtool_parse_options [ARG]... 25517204935cSmrg# --------------------------------- 25527204935cSmrg# Provide handling for libtool specific options. 25537204935cSmrglibtool_parse_options () 25541016ad83Smrg{ 25557204935cSmrg $debug_cmd 25561016ad83Smrg 2557b9526c6aSmrg _G_rc_lt_parse_options=false 2558b9526c6aSmrg 25597204935cSmrg # Perform our own loop to consume as many options as possible in 25607204935cSmrg # each iteration. 25617204935cSmrg while test $# -gt 0; do 2562b9526c6aSmrg _G_match_lt_parse_options=: 25637204935cSmrg _G_opt=$1 25647204935cSmrg shift 25657204935cSmrg case $_G_opt in 25667204935cSmrg --dry-run|--dryrun|-n) 25677204935cSmrg opt_dry_run=: 25687204935cSmrg ;; 25697204935cSmrg 25707204935cSmrg --config) func_config ;; 25717204935cSmrg 25727204935cSmrg --dlopen|-dlopen) 25737204935cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 25747204935cSmrg}$1" 25757204935cSmrg shift 25767204935cSmrg ;; 25777204935cSmrg 25787204935cSmrg --preserve-dup-deps) 25797204935cSmrg opt_preserve_dup_deps=: ;; 25807204935cSmrg 25817204935cSmrg --features) func_features ;; 25827204935cSmrg 25837204935cSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25847204935cSmrg 25857204935cSmrg --help) opt_help=: ;; 25867204935cSmrg 25877204935cSmrg --help-all) opt_help=': help-all' ;; 25887204935cSmrg 25897204935cSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25907204935cSmrg opt_mode=$1 25917204935cSmrg case $1 in 25927204935cSmrg # Valid mode arguments: 25937204935cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25947204935cSmrg 25957204935cSmrg # Catch anything else as an error 25967204935cSmrg *) func_error "invalid argument for $_G_opt" 25977204935cSmrg exit_cmd=exit 25987204935cSmrg break 25997204935cSmrg ;; 26007204935cSmrg esac 26017204935cSmrg shift 26027204935cSmrg ;; 26037204935cSmrg 26047204935cSmrg --no-silent|--no-quiet) 26057204935cSmrg opt_quiet=false 26067204935cSmrg func_append preserve_args " $_G_opt" 26077204935cSmrg ;; 26087204935cSmrg 26097204935cSmrg --no-warnings|--no-warning|--no-warn) 26107204935cSmrg opt_warning=false 26117204935cSmrg func_append preserve_args " $_G_opt" 26127204935cSmrg ;; 26137204935cSmrg 26147204935cSmrg --no-verbose) 26157204935cSmrg opt_verbose=false 26167204935cSmrg func_append preserve_args " $_G_opt" 26177204935cSmrg ;; 26187204935cSmrg 26197204935cSmrg --silent|--quiet) 26207204935cSmrg opt_quiet=: 26217204935cSmrg opt_verbose=false 26227204935cSmrg func_append preserve_args " $_G_opt" 26237204935cSmrg ;; 26247204935cSmrg 26257204935cSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26267204935cSmrg opt_tag=$1 26277204935cSmrg func_append preserve_args " $_G_opt $1" 26287204935cSmrg func_enable_tag "$1" 26297204935cSmrg shift 26307204935cSmrg ;; 26317204935cSmrg 26327204935cSmrg --verbose|-v) opt_quiet=false 26337204935cSmrg opt_verbose=: 26347204935cSmrg func_append preserve_args " $_G_opt" 26357204935cSmrg ;; 26367204935cSmrg 2637b9526c6aSmrg # An option not handled by this hook function: 2638b9526c6aSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639b9526c6aSmrg _G_match_lt_parse_options=false 2640b9526c6aSmrg break 2641b9526c6aSmrg ;; 26427204935cSmrg esac 2643b9526c6aSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26447204935cSmrg done 26451016ad83Smrg 2646b9526c6aSmrg if $_G_rc_lt_parse_options; then 2647b9526c6aSmrg # save modified positional parameters for caller 2648b9526c6aSmrg func_quote eval ${1+"$@"} 2649b9526c6aSmrg libtool_parse_options_result=$func_quote_result 2650b9526c6aSmrg fi 26517204935cSmrg} 26527204935cSmrgfunc_add_hook func_parse_options libtool_parse_options 26531016ad83Smrg 26541016ad83Smrg 26551016ad83Smrg 26567204935cSmrg# libtool_validate_options [ARG]... 26577204935cSmrg# --------------------------------- 26587204935cSmrg# Perform any sanity checks on option settings and/or unconsumed 26597204935cSmrg# arguments. 26607204935cSmrglibtool_validate_options () 26617204935cSmrg{ 26627204935cSmrg # save first non-option argument 26637204935cSmrg if test 0 -lt $#; then 26647204935cSmrg nonopt=$1 26657204935cSmrg shift 26661016ad83Smrg fi 26671016ad83Smrg 26687204935cSmrg # preserve --debug 26697204935cSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 26701016ad83Smrg 26717204935cSmrg case $host in 26727204935cSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26737204935cSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26747204935cSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26757204935cSmrg # don't eliminate duplications in $postdeps and $predeps 26767204935cSmrg opt_duplicate_compiler_generated_deps=: 26777204935cSmrg ;; 26787204935cSmrg *) 26797204935cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26807204935cSmrg ;; 26817204935cSmrg esac 26821016ad83Smrg 26837204935cSmrg $opt_help || { 26847204935cSmrg # Sanity checks first: 26857204935cSmrg func_check_version_match 26867204935cSmrg 26877204935cSmrg test yes != "$build_libtool_libs" \ 26887204935cSmrg && test yes != "$build_old_libs" \ 26897204935cSmrg && func_fatal_configuration "not configured to build any kind of library" 26907204935cSmrg 26917204935cSmrg # Darwin sucks 26927204935cSmrg eval std_shrext=\"$shrext_cmds\" 26937204935cSmrg 26947204935cSmrg # Only execute mode is allowed to have -dlopen flags. 26957204935cSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26967204935cSmrg func_error "unrecognized option '-dlopen'" 26977204935cSmrg $ECHO "$help" 1>&2 26987204935cSmrg exit $EXIT_FAILURE 26997204935cSmrg fi 27001016ad83Smrg 27017204935cSmrg # Change the help message to a mode-specific one. 27027204935cSmrg generic_help=$help 27037204935cSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 27047204935cSmrg } 27051016ad83Smrg 27067204935cSmrg # Pass back the unparsed argument list 2707b9526c6aSmrg func_quote eval ${1+"$@"} 2708b9526c6aSmrg libtool_validate_options_result=$func_quote_result 27091016ad83Smrg} 27107204935cSmrgfunc_add_hook func_validate_options libtool_validate_options 27111016ad83Smrg 27121016ad83Smrg 27137204935cSmrg# Process options as early as possible so that --help and --version 27147204935cSmrg# can return quickly. 27157204935cSmrgfunc_options ${1+"$@"} 27167204935cSmrgeval set dummy "$func_options_result"; shift 27177204935cSmrg 27181016ad83Smrg 27191016ad83Smrg 27201016ad83Smrg## ----------- ## 27211016ad83Smrg## Main. ## 27221016ad83Smrg## ----------- ## 27231016ad83Smrg 27247204935cSmrgmagic='%%%MAGIC variable%%%' 27257204935cSmrgmagic_exe='%%%MAGIC EXE variable%%%' 27267204935cSmrg 27277204935cSmrg# Global variables. 27287204935cSmrgextracted_archives= 27297204935cSmrgextracted_serial=0 27307204935cSmrg 27317204935cSmrg# If this variable is set in any of the actions, the command in it 27327204935cSmrg# will be execed at the end. This prevents here-documents from being 27337204935cSmrg# left over by shells. 27347204935cSmrgexec_cmd= 27357204935cSmrg 27367204935cSmrg 27377204935cSmrg# A function that is used when there is no print builtin or printf. 27387204935cSmrgfunc_fallback_echo () 27397204935cSmrg{ 27407204935cSmrg eval 'cat <<_LTECHO_EOF 27417204935cSmrg$1 27427204935cSmrg_LTECHO_EOF' 27437204935cSmrg} 27447204935cSmrg 27457204935cSmrg# func_generated_by_libtool 27467204935cSmrg# True iff stdin has been generated by Libtool. This function is only 27477204935cSmrg# a basic sanity check; it will hardly flush out determined imposters. 27487204935cSmrgfunc_generated_by_libtool_p () 27497204935cSmrg{ 27507204935cSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27517204935cSmrg} 27527204935cSmrg 27531016ad83Smrg# func_lalib_p file 27547204935cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27551016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 27561016ad83Smrg# determined imposters. 27571016ad83Smrgfunc_lalib_p () 27581016ad83Smrg{ 27591016ad83Smrg test -f "$1" && 27607204935cSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 27611016ad83Smrg} 27621016ad83Smrg 27631016ad83Smrg# func_lalib_unsafe_p file 27647204935cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27651016ad83Smrg# This function implements the same check as func_lalib_p without 27661016ad83Smrg# resorting to external programs. To this end, it redirects stdin and 27671016ad83Smrg# closes it afterwards, without saving the original file descriptor. 27681016ad83Smrg# As a safety measure, use it only where a negative result would be 27697204935cSmrg# fatal anyway. Works if 'file' does not exist. 27701016ad83Smrgfunc_lalib_unsafe_p () 27711016ad83Smrg{ 27721016ad83Smrg lalib_p=no 27731016ad83Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 27741016ad83Smrg for lalib_p_l in 1 2 3 4 27751016ad83Smrg do 27761016ad83Smrg read lalib_p_line 27777204935cSmrg case $lalib_p_line in 27781016ad83Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 27791016ad83Smrg esac 27801016ad83Smrg done 27811016ad83Smrg exec 0<&5 5<&- 27821016ad83Smrg fi 27837204935cSmrg test yes = "$lalib_p" 27841016ad83Smrg} 27851016ad83Smrg 27861016ad83Smrg# func_ltwrapper_script_p file 27871016ad83Smrg# True iff FILE is a libtool wrapper script 27881016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 27891016ad83Smrg# determined imposters. 27901016ad83Smrgfunc_ltwrapper_script_p () 27911016ad83Smrg{ 27927204935cSmrg test -f "$1" && 27937204935cSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 27941016ad83Smrg} 27951016ad83Smrg 27961016ad83Smrg# func_ltwrapper_executable_p file 27971016ad83Smrg# True iff FILE is a libtool wrapper executable 27981016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 27991016ad83Smrg# determined imposters. 28001016ad83Smrgfunc_ltwrapper_executable_p () 28011016ad83Smrg{ 28021016ad83Smrg func_ltwrapper_exec_suffix= 28031016ad83Smrg case $1 in 28041016ad83Smrg *.exe) ;; 28051016ad83Smrg *) func_ltwrapper_exec_suffix=.exe ;; 28061016ad83Smrg esac 28071016ad83Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 28081016ad83Smrg} 28091016ad83Smrg 28101016ad83Smrg# func_ltwrapper_scriptname file 28111016ad83Smrg# Assumes file is an ltwrapper_executable 28121016ad83Smrg# uses $file to determine the appropriate filename for a 28131016ad83Smrg# temporary ltwrapper_script. 28141016ad83Smrgfunc_ltwrapper_scriptname () 28151016ad83Smrg{ 28161016ad83Smrg func_dirname_and_basename "$1" "" "." 28171016ad83Smrg func_stripname '' '.exe' "$func_basename_result" 28187204935cSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 28191016ad83Smrg} 28201016ad83Smrg 28211016ad83Smrg# func_ltwrapper_p file 28221016ad83Smrg# True iff FILE is a libtool wrapper script or wrapper executable 28231016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 28241016ad83Smrg# determined imposters. 28251016ad83Smrgfunc_ltwrapper_p () 28261016ad83Smrg{ 28271016ad83Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 28281016ad83Smrg} 28291016ad83Smrg 28301016ad83Smrg 28311016ad83Smrg# func_execute_cmds commands fail_cmd 28321016ad83Smrg# Execute tilde-delimited COMMANDS. 28331016ad83Smrg# If FAIL_CMD is given, eval that upon failure. 28341016ad83Smrg# FAIL_CMD may read-access the current command in variable CMD! 28351016ad83Smrgfunc_execute_cmds () 28361016ad83Smrg{ 28377204935cSmrg $debug_cmd 28387204935cSmrg 28391016ad83Smrg save_ifs=$IFS; IFS='~' 28401016ad83Smrg for cmd in $1; do 28417204935cSmrg IFS=$sp$nl 28421016ad83Smrg eval cmd=\"$cmd\" 28437204935cSmrg IFS=$save_ifs 28441016ad83Smrg func_show_eval "$cmd" "${2-:}" 28451016ad83Smrg done 28461016ad83Smrg IFS=$save_ifs 28471016ad83Smrg} 28481016ad83Smrg 28491016ad83Smrg 28501016ad83Smrg# func_source file 28511016ad83Smrg# Source FILE, adding directory component if necessary. 28521016ad83Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 28531016ad83Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 28541016ad83Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28557204935cSmrg# 'FILE.' does not work on cygwin managed mounts. 28561016ad83Smrgfunc_source () 28571016ad83Smrg{ 28587204935cSmrg $debug_cmd 28597204935cSmrg 28601016ad83Smrg case $1 in 28611016ad83Smrg */* | *\\*) . "$1" ;; 28621016ad83Smrg *) . "./$1" ;; 28631016ad83Smrg esac 28641016ad83Smrg} 28651016ad83Smrg 28661016ad83Smrg 28671016ad83Smrg# func_resolve_sysroot PATH 28681016ad83Smrg# Replace a leading = in PATH with a sysroot. Store the result into 28691016ad83Smrg# func_resolve_sysroot_result 28701016ad83Smrgfunc_resolve_sysroot () 28711016ad83Smrg{ 28721016ad83Smrg func_resolve_sysroot_result=$1 28731016ad83Smrg case $func_resolve_sysroot_result in 28741016ad83Smrg =*) 28751016ad83Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 28761016ad83Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 28771016ad83Smrg ;; 28781016ad83Smrg esac 28791016ad83Smrg} 28801016ad83Smrg 28811016ad83Smrg# func_replace_sysroot PATH 28821016ad83Smrg# If PATH begins with the sysroot, replace it with = and 28831016ad83Smrg# store the result into func_replace_sysroot_result. 28841016ad83Smrgfunc_replace_sysroot () 28851016ad83Smrg{ 28867204935cSmrg case $lt_sysroot:$1 in 28871016ad83Smrg ?*:"$lt_sysroot"*) 28881016ad83Smrg func_stripname "$lt_sysroot" '' "$1" 28897204935cSmrg func_replace_sysroot_result='='$func_stripname_result 28901016ad83Smrg ;; 28911016ad83Smrg *) 28921016ad83Smrg # Including no sysroot. 28931016ad83Smrg func_replace_sysroot_result=$1 28941016ad83Smrg ;; 28951016ad83Smrg esac 28961016ad83Smrg} 28971016ad83Smrg 28981016ad83Smrg# func_infer_tag arg 28991016ad83Smrg# Infer tagged configuration to use if any are available and 29001016ad83Smrg# if one wasn't chosen via the "--tag" command line option. 29011016ad83Smrg# Only attempt this if the compiler in the base compile 29021016ad83Smrg# command doesn't match the default compiler. 29031016ad83Smrg# arg is usually of the form 'gcc ...' 29041016ad83Smrgfunc_infer_tag () 29051016ad83Smrg{ 29067204935cSmrg $debug_cmd 29077204935cSmrg 29081016ad83Smrg if test -n "$available_tags" && test -z "$tagname"; then 29091016ad83Smrg CC_quoted= 29101016ad83Smrg for arg in $CC; do 29111016ad83Smrg func_append_quoted CC_quoted "$arg" 29121016ad83Smrg done 29131016ad83Smrg CC_expanded=`func_echo_all $CC` 29141016ad83Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29151016ad83Smrg case $@ in 29161016ad83Smrg # Blanks in the command may have been stripped by the calling shell, 29171016ad83Smrg # but not from the CC environment variable when configure was run. 29181016ad83Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29191016ad83Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 29201016ad83Smrg # Blanks at the start of $base_compile will cause this to fail 29211016ad83Smrg # if we don't check for them as well. 29221016ad83Smrg *) 29231016ad83Smrg for z in $available_tags; do 29241016ad83Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 29251016ad83Smrg # Evaluate the configuration. 29267204935cSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 29271016ad83Smrg CC_quoted= 29281016ad83Smrg for arg in $CC; do 29291016ad83Smrg # Double-quote args containing other shell metacharacters. 29301016ad83Smrg func_append_quoted CC_quoted "$arg" 29311016ad83Smrg done 29321016ad83Smrg CC_expanded=`func_echo_all $CC` 29331016ad83Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29341016ad83Smrg case "$@ " in 29351016ad83Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29361016ad83Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 29371016ad83Smrg # The compiler in the base compile command matches 29381016ad83Smrg # the one in the tagged configuration. 29391016ad83Smrg # Assume this is the tagged configuration we want. 29401016ad83Smrg tagname=$z 29411016ad83Smrg break 29421016ad83Smrg ;; 29431016ad83Smrg esac 29441016ad83Smrg fi 29451016ad83Smrg done 29461016ad83Smrg # If $tagname still isn't set, then no tagged configuration 29471016ad83Smrg # was found and let the user know that the "--tag" command 29481016ad83Smrg # line option must be used. 29491016ad83Smrg if test -z "$tagname"; then 29501016ad83Smrg func_echo "unable to infer tagged configuration" 29517204935cSmrg func_fatal_error "specify a tag with '--tag'" 29521016ad83Smrg# else 29531016ad83Smrg# func_verbose "using $tagname tagged configuration" 29541016ad83Smrg fi 29551016ad83Smrg ;; 29561016ad83Smrg esac 29571016ad83Smrg fi 29581016ad83Smrg} 29591016ad83Smrg 29601016ad83Smrg 29611016ad83Smrg 29621016ad83Smrg# func_write_libtool_object output_name pic_name nonpic_name 29631016ad83Smrg# Create a libtool object file (analogous to a ".la" file), 29641016ad83Smrg# but don't create it if we're doing a dry run. 29651016ad83Smrgfunc_write_libtool_object () 29661016ad83Smrg{ 29677204935cSmrg write_libobj=$1 29687204935cSmrg if test yes = "$build_libtool_libs"; then 29697204935cSmrg write_lobj=\'$2\' 29701016ad83Smrg else 29711016ad83Smrg write_lobj=none 29721016ad83Smrg fi 29731016ad83Smrg 29747204935cSmrg if test yes = "$build_old_libs"; then 29757204935cSmrg write_oldobj=\'$3\' 29761016ad83Smrg else 29771016ad83Smrg write_oldobj=none 29781016ad83Smrg fi 29791016ad83Smrg 29801016ad83Smrg $opt_dry_run || { 29811016ad83Smrg cat >${write_libobj}T <<EOF 29821016ad83Smrg# $write_libobj - a libtool object file 29837204935cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 29841016ad83Smrg# 29851016ad83Smrg# Please DO NOT delete this file! 29861016ad83Smrg# It is necessary for linking the library. 29871016ad83Smrg 29881016ad83Smrg# Name of the PIC object. 29891016ad83Smrgpic_object=$write_lobj 29901016ad83Smrg 29911016ad83Smrg# Name of the non-PIC object 29921016ad83Smrgnon_pic_object=$write_oldobj 29931016ad83Smrg 29941016ad83SmrgEOF 29957204935cSmrg $MV "${write_libobj}T" "$write_libobj" 29961016ad83Smrg } 29971016ad83Smrg} 29981016ad83Smrg 29991016ad83Smrg 30001016ad83Smrg################################################## 30011016ad83Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 30021016ad83Smrg################################################## 30031016ad83Smrg 30041016ad83Smrg# func_convert_core_file_wine_to_w32 ARG 30051016ad83Smrg# Helper function used by file name conversion functions when $build is *nix, 30061016ad83Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 30071016ad83Smrg# correctly configured wine environment available, with the winepath program 30081016ad83Smrg# in $build's $PATH. 30091016ad83Smrg# 30101016ad83Smrg# ARG is the $build file name to be converted to w32 format. 30111016ad83Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 30121016ad83Smrg# be empty on error (or when ARG is empty) 30131016ad83Smrgfunc_convert_core_file_wine_to_w32 () 30141016ad83Smrg{ 30157204935cSmrg $debug_cmd 30167204935cSmrg 30177204935cSmrg func_convert_core_file_wine_to_w32_result=$1 30181016ad83Smrg if test -n "$1"; then 30191016ad83Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 30201016ad83Smrg # are forced to check the contents of stdout. On the other hand, if the 30211016ad83Smrg # command is not found, the shell will set an exit code of 127 and print 30221016ad83Smrg # *an error message* to stdout. So we must check for both error code of 30231016ad83Smrg # zero AND non-empty stdout, which explains the odd construction: 30241016ad83Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30257204935cSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 30261016ad83Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30277204935cSmrg $SED -e "$sed_naive_backslashify"` 30281016ad83Smrg else 30291016ad83Smrg func_convert_core_file_wine_to_w32_result= 30301016ad83Smrg fi 30311016ad83Smrg fi 30321016ad83Smrg} 30331016ad83Smrg# end: func_convert_core_file_wine_to_w32 30341016ad83Smrg 30351016ad83Smrg 30361016ad83Smrg# func_convert_core_path_wine_to_w32 ARG 30371016ad83Smrg# Helper function used by path conversion functions when $build is *nix, and 30381016ad83Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 30391016ad83Smrg# configured wine environment available, with the winepath program in $build's 30401016ad83Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 30411016ad83Smrg# 30421016ad83Smrg# ARG is path to be converted from $build format to win32. 30431016ad83Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 30441016ad83Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 30451016ad83Smrg# are convertible, then the result may be empty. 30461016ad83Smrgfunc_convert_core_path_wine_to_w32 () 30471016ad83Smrg{ 30487204935cSmrg $debug_cmd 30497204935cSmrg 30501016ad83Smrg # unfortunately, winepath doesn't convert paths, only file names 30517204935cSmrg func_convert_core_path_wine_to_w32_result= 30521016ad83Smrg if test -n "$1"; then 30531016ad83Smrg oldIFS=$IFS 30541016ad83Smrg IFS=: 30551016ad83Smrg for func_convert_core_path_wine_to_w32_f in $1; do 30561016ad83Smrg IFS=$oldIFS 30571016ad83Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30587204935cSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 30591016ad83Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30607204935cSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 30611016ad83Smrg else 30621016ad83Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 30631016ad83Smrg fi 30641016ad83Smrg fi 30651016ad83Smrg done 30661016ad83Smrg IFS=$oldIFS 30671016ad83Smrg fi 30681016ad83Smrg} 30691016ad83Smrg# end: func_convert_core_path_wine_to_w32 30701016ad83Smrg 30711016ad83Smrg 30721016ad83Smrg# func_cygpath ARGS... 30731016ad83Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 30741016ad83Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 30751016ad83Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 30761016ad83Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 30771016ad83Smrg# file name or path is assumed to be in w32 format, as previously converted 30781016ad83Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 30791016ad83Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 30801016ad83Smrg# Cygwin format). Returns an empty string on error. 30811016ad83Smrg# 30821016ad83Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 30831016ad83Smrg# be converted. 30841016ad83Smrg# 30851016ad83Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 30861016ad83Smrg# environment variable; do not put it in $PATH. 30871016ad83Smrgfunc_cygpath () 30881016ad83Smrg{ 30897204935cSmrg $debug_cmd 30907204935cSmrg 30911016ad83Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 30921016ad83Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 30931016ad83Smrg if test "$?" -ne 0; then 30941016ad83Smrg # on failure, ensure result is empty 30951016ad83Smrg func_cygpath_result= 30961016ad83Smrg fi 30971016ad83Smrg else 30981016ad83Smrg func_cygpath_result= 30997204935cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 31001016ad83Smrg fi 31011016ad83Smrg} 31021016ad83Smrg#end: func_cygpath 31031016ad83Smrg 31041016ad83Smrg 31051016ad83Smrg# func_convert_core_msys_to_w32 ARG 31061016ad83Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 31071016ad83Smrg# result in func_convert_core_msys_to_w32_result. 31081016ad83Smrgfunc_convert_core_msys_to_w32 () 31091016ad83Smrg{ 31107204935cSmrg $debug_cmd 31117204935cSmrg 31121016ad83Smrg # awkward: cmd appends spaces to result 31131016ad83Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31147204935cSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 31151016ad83Smrg} 31161016ad83Smrg#end: func_convert_core_msys_to_w32 31171016ad83Smrg 31181016ad83Smrg 31191016ad83Smrg# func_convert_file_check ARG1 ARG2 31201016ad83Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 31211016ad83Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 31221016ad83Smrg# func_to_host_file_result to ARG1). 31231016ad83Smrgfunc_convert_file_check () 31241016ad83Smrg{ 31257204935cSmrg $debug_cmd 31267204935cSmrg 31277204935cSmrg if test -z "$2" && test -n "$1"; then 31281016ad83Smrg func_error "Could not determine host file name corresponding to" 31297204935cSmrg func_error " '$1'" 31301016ad83Smrg func_error "Continuing, but uninstalled executables may not work." 31311016ad83Smrg # Fallback: 31327204935cSmrg func_to_host_file_result=$1 31331016ad83Smrg fi 31341016ad83Smrg} 31351016ad83Smrg# end func_convert_file_check 31361016ad83Smrg 31371016ad83Smrg 31381016ad83Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 31391016ad83Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 31401016ad83Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 31411016ad83Smrg# func_to_host_file_result to a simplistic fallback value (see below). 31421016ad83Smrgfunc_convert_path_check () 31431016ad83Smrg{ 31447204935cSmrg $debug_cmd 31457204935cSmrg 31461016ad83Smrg if test -z "$4" && test -n "$3"; then 31471016ad83Smrg func_error "Could not determine the host path corresponding to" 31487204935cSmrg func_error " '$3'" 31491016ad83Smrg func_error "Continuing, but uninstalled executables may not work." 31501016ad83Smrg # Fallback. This is a deliberately simplistic "conversion" and 31511016ad83Smrg # should not be "improved". See libtool.info. 31521016ad83Smrg if test "x$1" != "x$2"; then 31531016ad83Smrg lt_replace_pathsep_chars="s|$1|$2|g" 31541016ad83Smrg func_to_host_path_result=`echo "$3" | 31551016ad83Smrg $SED -e "$lt_replace_pathsep_chars"` 31561016ad83Smrg else 31577204935cSmrg func_to_host_path_result=$3 31581016ad83Smrg fi 31591016ad83Smrg fi 31601016ad83Smrg} 31611016ad83Smrg# end func_convert_path_check 31621016ad83Smrg 31631016ad83Smrg 31641016ad83Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 31651016ad83Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 31661016ad83Smrg# and appending REPL if ORIG matches BACKPAT. 31671016ad83Smrgfunc_convert_path_front_back_pathsep () 31681016ad83Smrg{ 31697204935cSmrg $debug_cmd 31707204935cSmrg 31711016ad83Smrg case $4 in 31727204935cSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 31731016ad83Smrg ;; 31741016ad83Smrg esac 31751016ad83Smrg case $4 in 31761016ad83Smrg $2 ) func_append func_to_host_path_result "$3" 31771016ad83Smrg ;; 31781016ad83Smrg esac 31791016ad83Smrg} 31801016ad83Smrg# end func_convert_path_front_back_pathsep 31811016ad83Smrg 31821016ad83Smrg 31831016ad83Smrg################################################## 31841016ad83Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 31851016ad83Smrg################################################## 31867204935cSmrg# invoked via '$to_host_file_cmd ARG' 31871016ad83Smrg# 31881016ad83Smrg# In each case, ARG is the path to be converted from $build to $host format. 31891016ad83Smrg# Result will be available in $func_to_host_file_result. 31901016ad83Smrg 31911016ad83Smrg 31921016ad83Smrg# func_to_host_file ARG 31931016ad83Smrg# Converts the file name ARG from $build format to $host format. Return result 31941016ad83Smrg# in func_to_host_file_result. 31951016ad83Smrgfunc_to_host_file () 31961016ad83Smrg{ 31977204935cSmrg $debug_cmd 31987204935cSmrg 31991016ad83Smrg $to_host_file_cmd "$1" 32001016ad83Smrg} 32011016ad83Smrg# end func_to_host_file 32021016ad83Smrg 32031016ad83Smrg 32041016ad83Smrg# func_to_tool_file ARG LAZY 32051016ad83Smrg# converts the file name ARG from $build format to toolchain format. Return 32061016ad83Smrg# result in func_to_tool_file_result. If the conversion in use is listed 32071016ad83Smrg# in (the comma separated) LAZY, no conversion takes place. 32081016ad83Smrgfunc_to_tool_file () 32091016ad83Smrg{ 32107204935cSmrg $debug_cmd 32117204935cSmrg 32121016ad83Smrg case ,$2, in 32131016ad83Smrg *,"$to_tool_file_cmd",*) 32141016ad83Smrg func_to_tool_file_result=$1 32151016ad83Smrg ;; 32161016ad83Smrg *) 32171016ad83Smrg $to_tool_file_cmd "$1" 32181016ad83Smrg func_to_tool_file_result=$func_to_host_file_result 32191016ad83Smrg ;; 32201016ad83Smrg esac 32211016ad83Smrg} 32221016ad83Smrg# end func_to_tool_file 32231016ad83Smrg 32241016ad83Smrg 32251016ad83Smrg# func_convert_file_noop ARG 32261016ad83Smrg# Copy ARG to func_to_host_file_result. 32271016ad83Smrgfunc_convert_file_noop () 32281016ad83Smrg{ 32297204935cSmrg func_to_host_file_result=$1 32301016ad83Smrg} 32311016ad83Smrg# end func_convert_file_noop 32321016ad83Smrg 32331016ad83Smrg 32341016ad83Smrg# func_convert_file_msys_to_w32 ARG 32351016ad83Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 32361016ad83Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 32371016ad83Smrg# func_to_host_file_result. 32381016ad83Smrgfunc_convert_file_msys_to_w32 () 32391016ad83Smrg{ 32407204935cSmrg $debug_cmd 32417204935cSmrg 32427204935cSmrg func_to_host_file_result=$1 32431016ad83Smrg if test -n "$1"; then 32441016ad83Smrg func_convert_core_msys_to_w32 "$1" 32457204935cSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 32461016ad83Smrg fi 32471016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32481016ad83Smrg} 32491016ad83Smrg# end func_convert_file_msys_to_w32 32501016ad83Smrg 32511016ad83Smrg 32521016ad83Smrg# func_convert_file_cygwin_to_w32 ARG 32531016ad83Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 32541016ad83Smrg# func_to_host_file_result. 32551016ad83Smrgfunc_convert_file_cygwin_to_w32 () 32561016ad83Smrg{ 32577204935cSmrg $debug_cmd 32587204935cSmrg 32597204935cSmrg func_to_host_file_result=$1 32601016ad83Smrg if test -n "$1"; then 32611016ad83Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 32621016ad83Smrg # LT_CYGPATH in this case. 32631016ad83Smrg func_to_host_file_result=`cygpath -m "$1"` 32641016ad83Smrg fi 32651016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32661016ad83Smrg} 32671016ad83Smrg# end func_convert_file_cygwin_to_w32 32681016ad83Smrg 32691016ad83Smrg 32701016ad83Smrg# func_convert_file_nix_to_w32 ARG 32711016ad83Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 32721016ad83Smrg# and a working winepath. Returns result in func_to_host_file_result. 32731016ad83Smrgfunc_convert_file_nix_to_w32 () 32741016ad83Smrg{ 32757204935cSmrg $debug_cmd 32767204935cSmrg 32777204935cSmrg func_to_host_file_result=$1 32781016ad83Smrg if test -n "$1"; then 32791016ad83Smrg func_convert_core_file_wine_to_w32 "$1" 32807204935cSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 32811016ad83Smrg fi 32821016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32831016ad83Smrg} 32841016ad83Smrg# end func_convert_file_nix_to_w32 32851016ad83Smrg 32861016ad83Smrg 32871016ad83Smrg# func_convert_file_msys_to_cygwin ARG 32881016ad83Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32891016ad83Smrg# Returns result in func_to_host_file_result. 32901016ad83Smrgfunc_convert_file_msys_to_cygwin () 32911016ad83Smrg{ 32927204935cSmrg $debug_cmd 32937204935cSmrg 32947204935cSmrg func_to_host_file_result=$1 32951016ad83Smrg if test -n "$1"; then 32961016ad83Smrg func_convert_core_msys_to_w32 "$1" 32971016ad83Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32987204935cSmrg func_to_host_file_result=$func_cygpath_result 32991016ad83Smrg fi 33001016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 33011016ad83Smrg} 33021016ad83Smrg# end func_convert_file_msys_to_cygwin 33031016ad83Smrg 33041016ad83Smrg 33051016ad83Smrg# func_convert_file_nix_to_cygwin ARG 33061016ad83Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 33071016ad83Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 33081016ad83Smrg# in func_to_host_file_result. 33091016ad83Smrgfunc_convert_file_nix_to_cygwin () 33101016ad83Smrg{ 33117204935cSmrg $debug_cmd 33127204935cSmrg 33137204935cSmrg func_to_host_file_result=$1 33141016ad83Smrg if test -n "$1"; then 33151016ad83Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 33161016ad83Smrg func_convert_core_file_wine_to_w32 "$1" 33171016ad83Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33187204935cSmrg func_to_host_file_result=$func_cygpath_result 33191016ad83Smrg fi 33201016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 33211016ad83Smrg} 33221016ad83Smrg# end func_convert_file_nix_to_cygwin 33231016ad83Smrg 33241016ad83Smrg 33251016ad83Smrg############################################# 33261016ad83Smrg# $build to $host PATH CONVERSION FUNCTIONS # 33271016ad83Smrg############################################# 33287204935cSmrg# invoked via '$to_host_path_cmd ARG' 33291016ad83Smrg# 33301016ad83Smrg# In each case, ARG is the path to be converted from $build to $host format. 33311016ad83Smrg# The result will be available in $func_to_host_path_result. 33321016ad83Smrg# 33331016ad83Smrg# Path separators are also converted from $build format to $host format. If 33341016ad83Smrg# ARG begins or ends with a path separator character, it is preserved (but 33351016ad83Smrg# converted to $host format) on output. 33361016ad83Smrg# 33371016ad83Smrg# All path conversion functions are named using the following convention: 33381016ad83Smrg# file name conversion function : func_convert_file_X_to_Y () 33391016ad83Smrg# path conversion function : func_convert_path_X_to_Y () 33401016ad83Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 33411016ad83Smrg# same. If conversion functions are added for new $build/$host combinations, 33421016ad83Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 33431016ad83Smrg# will break. 33441016ad83Smrg 33451016ad83Smrg 33461016ad83Smrg# func_init_to_host_path_cmd 33471016ad83Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 33481016ad83Smrg# appropriate value, based on the value of $to_host_file_cmd. 33491016ad83Smrgto_host_path_cmd= 33501016ad83Smrgfunc_init_to_host_path_cmd () 33511016ad83Smrg{ 33527204935cSmrg $debug_cmd 33537204935cSmrg 33541016ad83Smrg if test -z "$to_host_path_cmd"; then 33551016ad83Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33567204935cSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 33571016ad83Smrg fi 33581016ad83Smrg} 33591016ad83Smrg 33601016ad83Smrg 33611016ad83Smrg# func_to_host_path ARG 33621016ad83Smrg# Converts the path ARG from $build format to $host format. Return result 33631016ad83Smrg# in func_to_host_path_result. 33641016ad83Smrgfunc_to_host_path () 33651016ad83Smrg{ 33667204935cSmrg $debug_cmd 33677204935cSmrg 33681016ad83Smrg func_init_to_host_path_cmd 33691016ad83Smrg $to_host_path_cmd "$1" 33701016ad83Smrg} 33711016ad83Smrg# end func_to_host_path 33721016ad83Smrg 33731016ad83Smrg 33741016ad83Smrg# func_convert_path_noop ARG 33751016ad83Smrg# Copy ARG to func_to_host_path_result. 33761016ad83Smrgfunc_convert_path_noop () 33771016ad83Smrg{ 33787204935cSmrg func_to_host_path_result=$1 33791016ad83Smrg} 33801016ad83Smrg# end func_convert_path_noop 33811016ad83Smrg 33821016ad83Smrg 33831016ad83Smrg# func_convert_path_msys_to_w32 ARG 33841016ad83Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 33851016ad83Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 33861016ad83Smrg# func_to_host_path_result. 33871016ad83Smrgfunc_convert_path_msys_to_w32 () 33881016ad83Smrg{ 33897204935cSmrg $debug_cmd 33907204935cSmrg 33917204935cSmrg func_to_host_path_result=$1 33921016ad83Smrg if test -n "$1"; then 33931016ad83Smrg # Remove leading and trailing path separator characters from ARG. MSYS 33941016ad83Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 33951016ad83Smrg # and winepath ignores them completely. 33961016ad83Smrg func_stripname : : "$1" 33971016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 33981016ad83Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33997204935cSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 34001016ad83Smrg func_convert_path_check : ";" \ 34011016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34021016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34031016ad83Smrg fi 34041016ad83Smrg} 34051016ad83Smrg# end func_convert_path_msys_to_w32 34061016ad83Smrg 34071016ad83Smrg 34081016ad83Smrg# func_convert_path_cygwin_to_w32 ARG 34091016ad83Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 34101016ad83Smrg# func_to_host_file_result. 34111016ad83Smrgfunc_convert_path_cygwin_to_w32 () 34121016ad83Smrg{ 34137204935cSmrg $debug_cmd 34147204935cSmrg 34157204935cSmrg func_to_host_path_result=$1 34161016ad83Smrg if test -n "$1"; then 34171016ad83Smrg # See func_convert_path_msys_to_w32: 34181016ad83Smrg func_stripname : : "$1" 34191016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 34201016ad83Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 34211016ad83Smrg func_convert_path_check : ";" \ 34221016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34231016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34241016ad83Smrg fi 34251016ad83Smrg} 34261016ad83Smrg# end func_convert_path_cygwin_to_w32 34271016ad83Smrg 34281016ad83Smrg 34291016ad83Smrg# func_convert_path_nix_to_w32 ARG 34301016ad83Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 34311016ad83Smrg# a working winepath. Returns result in func_to_host_file_result. 34321016ad83Smrgfunc_convert_path_nix_to_w32 () 34331016ad83Smrg{ 34347204935cSmrg $debug_cmd 34357204935cSmrg 34367204935cSmrg func_to_host_path_result=$1 34371016ad83Smrg if test -n "$1"; then 34381016ad83Smrg # See func_convert_path_msys_to_w32: 34391016ad83Smrg func_stripname : : "$1" 34401016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 34411016ad83Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34427204935cSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 34431016ad83Smrg func_convert_path_check : ";" \ 34441016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34451016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34461016ad83Smrg fi 34471016ad83Smrg} 34481016ad83Smrg# end func_convert_path_nix_to_w32 34491016ad83Smrg 34501016ad83Smrg 34511016ad83Smrg# func_convert_path_msys_to_cygwin ARG 34521016ad83Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 34531016ad83Smrg# Returns result in func_to_host_file_result. 34541016ad83Smrgfunc_convert_path_msys_to_cygwin () 34551016ad83Smrg{ 34567204935cSmrg $debug_cmd 34577204935cSmrg 34587204935cSmrg func_to_host_path_result=$1 34591016ad83Smrg if test -n "$1"; then 34601016ad83Smrg # See func_convert_path_msys_to_w32: 34611016ad83Smrg func_stripname : : "$1" 34621016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 34631016ad83Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 34641016ad83Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34657204935cSmrg func_to_host_path_result=$func_cygpath_result 34661016ad83Smrg func_convert_path_check : : \ 34671016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34681016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34691016ad83Smrg fi 34701016ad83Smrg} 34711016ad83Smrg# end func_convert_path_msys_to_cygwin 34721016ad83Smrg 34731016ad83Smrg 34741016ad83Smrg# func_convert_path_nix_to_cygwin ARG 34751016ad83Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 34761016ad83Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 34771016ad83Smrg# func_to_host_file_result. 34781016ad83Smrgfunc_convert_path_nix_to_cygwin () 34791016ad83Smrg{ 34807204935cSmrg $debug_cmd 34817204935cSmrg 34827204935cSmrg func_to_host_path_result=$1 34831016ad83Smrg if test -n "$1"; then 34841016ad83Smrg # Remove leading and trailing path separator characters from 34851016ad83Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 34861016ad83Smrg # into '.;' and ';.', and winepath ignores them completely. 34871016ad83Smrg func_stripname : : "$1" 34881016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 34891016ad83Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34901016ad83Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34917204935cSmrg func_to_host_path_result=$func_cygpath_result 34921016ad83Smrg func_convert_path_check : : \ 34931016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34941016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34951016ad83Smrg fi 34961016ad83Smrg} 34971016ad83Smrg# end func_convert_path_nix_to_cygwin 34981016ad83Smrg 34991016ad83Smrg 35007204935cSmrg# func_dll_def_p FILE 35017204935cSmrg# True iff FILE is a Windows DLL '.def' file. 35027204935cSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35037204935cSmrgfunc_dll_def_p () 35047204935cSmrg{ 35057204935cSmrg $debug_cmd 35067204935cSmrg 35077204935cSmrg func_dll_def_p_tmp=`$SED -n \ 35087204935cSmrg -e 's/^[ ]*//' \ 35097204935cSmrg -e '/^\(;.*\)*$/d' \ 35107204935cSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35117204935cSmrg -e q \ 35127204935cSmrg "$1"` 35137204935cSmrg test DEF = "$func_dll_def_p_tmp" 35147204935cSmrg} 35157204935cSmrg 35167204935cSmrg 35171016ad83Smrg# func_mode_compile arg... 35181016ad83Smrgfunc_mode_compile () 35191016ad83Smrg{ 35207204935cSmrg $debug_cmd 35217204935cSmrg 35221016ad83Smrg # Get the compilation command and the source file. 35231016ad83Smrg base_compile= 35247204935cSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 35251016ad83Smrg suppress_opt=yes 35261016ad83Smrg suppress_output= 35271016ad83Smrg arg_mode=normal 35281016ad83Smrg libobj= 35291016ad83Smrg later= 35301016ad83Smrg pie_flag= 35311016ad83Smrg 35321016ad83Smrg for arg 35331016ad83Smrg do 35341016ad83Smrg case $arg_mode in 35351016ad83Smrg arg ) 35361016ad83Smrg # do not "continue". Instead, add this to base_compile 35377204935cSmrg lastarg=$arg 35381016ad83Smrg arg_mode=normal 35391016ad83Smrg ;; 35401016ad83Smrg 35411016ad83Smrg target ) 35427204935cSmrg libobj=$arg 35431016ad83Smrg arg_mode=normal 35441016ad83Smrg continue 35451016ad83Smrg ;; 35461016ad83Smrg 35471016ad83Smrg normal ) 35481016ad83Smrg # Accept any command-line options. 35491016ad83Smrg case $arg in 35501016ad83Smrg -o) 35511016ad83Smrg test -n "$libobj" && \ 35527204935cSmrg func_fatal_error "you cannot specify '-o' more than once" 35531016ad83Smrg arg_mode=target 35541016ad83Smrg continue 35551016ad83Smrg ;; 35561016ad83Smrg 35571016ad83Smrg -pie | -fpie | -fPIE) 35581016ad83Smrg func_append pie_flag " $arg" 35591016ad83Smrg continue 35601016ad83Smrg ;; 35611016ad83Smrg 35621016ad83Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 35631016ad83Smrg func_append later " $arg" 35641016ad83Smrg continue 35651016ad83Smrg ;; 35661016ad83Smrg 35671016ad83Smrg -no-suppress) 35681016ad83Smrg suppress_opt=no 35691016ad83Smrg continue 35701016ad83Smrg ;; 35711016ad83Smrg 35721016ad83Smrg -Xcompiler) 35731016ad83Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 35741016ad83Smrg continue # The current "srcfile" will either be retained or 35751016ad83Smrg ;; # replaced later. I would guess that would be a bug. 35761016ad83Smrg 35771016ad83Smrg -Wc,*) 35781016ad83Smrg func_stripname '-Wc,' '' "$arg" 35791016ad83Smrg args=$func_stripname_result 35801016ad83Smrg lastarg= 35817204935cSmrg save_ifs=$IFS; IFS=, 35821016ad83Smrg for arg in $args; do 35837204935cSmrg IFS=$save_ifs 35841016ad83Smrg func_append_quoted lastarg "$arg" 35851016ad83Smrg done 35867204935cSmrg IFS=$save_ifs 35871016ad83Smrg func_stripname ' ' '' "$lastarg" 35881016ad83Smrg lastarg=$func_stripname_result 35891016ad83Smrg 35901016ad83Smrg # Add the arguments to base_compile. 35911016ad83Smrg func_append base_compile " $lastarg" 35921016ad83Smrg continue 35931016ad83Smrg ;; 35941016ad83Smrg 35951016ad83Smrg *) 35961016ad83Smrg # Accept the current argument as the source file. 35971016ad83Smrg # The previous "srcfile" becomes the current argument. 35981016ad83Smrg # 35997204935cSmrg lastarg=$srcfile 36007204935cSmrg srcfile=$arg 36011016ad83Smrg ;; 36021016ad83Smrg esac # case $arg 36031016ad83Smrg ;; 36041016ad83Smrg esac # case $arg_mode 36051016ad83Smrg 36061016ad83Smrg # Aesthetically quote the previous argument. 36071016ad83Smrg func_append_quoted base_compile "$lastarg" 36081016ad83Smrg done # for arg 36091016ad83Smrg 36101016ad83Smrg case $arg_mode in 36111016ad83Smrg arg) 36121016ad83Smrg func_fatal_error "you must specify an argument for -Xcompile" 36131016ad83Smrg ;; 36141016ad83Smrg target) 36157204935cSmrg func_fatal_error "you must specify a target with '-o'" 36161016ad83Smrg ;; 36171016ad83Smrg *) 36181016ad83Smrg # Get the name of the library object. 36191016ad83Smrg test -z "$libobj" && { 36201016ad83Smrg func_basename "$srcfile" 36217204935cSmrg libobj=$func_basename_result 36221016ad83Smrg } 36231016ad83Smrg ;; 36241016ad83Smrg esac 36251016ad83Smrg 36261016ad83Smrg # Recognize several different file suffixes. 36271016ad83Smrg # If the user specifies -o file.o, it is replaced with file.lo 36281016ad83Smrg case $libobj in 36291016ad83Smrg *.[cCFSifmso] | \ 36301016ad83Smrg *.ada | *.adb | *.ads | *.asm | \ 36311016ad83Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36321016ad83Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 36331016ad83Smrg func_xform "$libobj" 36341016ad83Smrg libobj=$func_xform_result 36351016ad83Smrg ;; 36361016ad83Smrg esac 36371016ad83Smrg 36381016ad83Smrg case $libobj in 36391016ad83Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36401016ad83Smrg *) 36417204935cSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 36421016ad83Smrg ;; 36431016ad83Smrg esac 36441016ad83Smrg 36451016ad83Smrg func_infer_tag $base_compile 36461016ad83Smrg 36471016ad83Smrg for arg in $later; do 36481016ad83Smrg case $arg in 36491016ad83Smrg -shared) 36507204935cSmrg test yes = "$build_libtool_libs" \ 36517204935cSmrg || func_fatal_configuration "cannot build a shared library" 36521016ad83Smrg build_old_libs=no 36531016ad83Smrg continue 36541016ad83Smrg ;; 36551016ad83Smrg 36561016ad83Smrg -static) 36571016ad83Smrg build_libtool_libs=no 36581016ad83Smrg build_old_libs=yes 36591016ad83Smrg continue 36601016ad83Smrg ;; 36611016ad83Smrg 36621016ad83Smrg -prefer-pic) 36631016ad83Smrg pic_mode=yes 36641016ad83Smrg continue 36651016ad83Smrg ;; 36661016ad83Smrg 36671016ad83Smrg -prefer-non-pic) 36681016ad83Smrg pic_mode=no 36691016ad83Smrg continue 36701016ad83Smrg ;; 36711016ad83Smrg esac 36721016ad83Smrg done 36731016ad83Smrg 3674b9526c6aSmrg func_quote_arg pretty "$libobj" 3675b9526c6aSmrg test "X$libobj" != "X$func_quote_arg_result" \ 36761016ad83Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36777204935cSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 36781016ad83Smrg func_dirname_and_basename "$obj" "/" "" 36797204935cSmrg objname=$func_basename_result 36807204935cSmrg xdir=$func_dirname_result 36817204935cSmrg lobj=$xdir$objdir/$objname 36821016ad83Smrg 36831016ad83Smrg test -z "$base_compile" && \ 36841016ad83Smrg func_fatal_help "you must specify a compilation command" 36851016ad83Smrg 36861016ad83Smrg # Delete any leftover library objects. 36877204935cSmrg if test yes = "$build_old_libs"; then 36881016ad83Smrg removelist="$obj $lobj $libobj ${libobj}T" 36891016ad83Smrg else 36901016ad83Smrg removelist="$lobj $libobj ${libobj}T" 36911016ad83Smrg fi 36921016ad83Smrg 36931016ad83Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 36941016ad83Smrg case $host_os in 36951016ad83Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36961016ad83Smrg pic_mode=default 36971016ad83Smrg ;; 36981016ad83Smrg esac 36997204935cSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 37001016ad83Smrg # non-PIC code in shared libraries is not supported 37011016ad83Smrg pic_mode=default 37021016ad83Smrg fi 37031016ad83Smrg 37041016ad83Smrg # Calculate the filename of the output object if compiler does 37051016ad83Smrg # not support -o with -c 37067204935cSmrg if test no = "$compiler_c_o"; then 37077204935cSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37087204935cSmrg lockfile=$output_obj.lock 37091016ad83Smrg else 37101016ad83Smrg output_obj= 37111016ad83Smrg need_locks=no 37121016ad83Smrg lockfile= 37131016ad83Smrg fi 37141016ad83Smrg 37151016ad83Smrg # Lock this critical section if it is needed 37161016ad83Smrg # We use this script file to make the link, it avoids creating a new file 37177204935cSmrg if test yes = "$need_locks"; then 37181016ad83Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37191016ad83Smrg func_echo "Waiting for $lockfile to be removed" 37201016ad83Smrg sleep 2 37211016ad83Smrg done 37227204935cSmrg elif test warn = "$need_locks"; then 37231016ad83Smrg if test -f "$lockfile"; then 37241016ad83Smrg $ECHO "\ 37251016ad83Smrg*** ERROR, $lockfile exists and contains: 37261016ad83Smrg`cat $lockfile 2>/dev/null` 37271016ad83Smrg 37281016ad83SmrgThis indicates that another process is trying to use the same 37291016ad83Smrgtemporary object file, and libtool could not work around it because 37307204935cSmrgyour compiler does not support '-c' and '-o' together. If you 37311016ad83Smrgrepeat this compilation, it may succeed, by chance, but you had better 37321016ad83Smrgavoid parallel builds (make -j) in this platform, or get a better 37331016ad83Smrgcompiler." 37341016ad83Smrg 37351016ad83Smrg $opt_dry_run || $RM $removelist 37361016ad83Smrg exit $EXIT_FAILURE 37371016ad83Smrg fi 37381016ad83Smrg func_append removelist " $output_obj" 37391016ad83Smrg $ECHO "$srcfile" > "$lockfile" 37401016ad83Smrg fi 37411016ad83Smrg 37421016ad83Smrg $opt_dry_run || $RM $removelist 37431016ad83Smrg func_append removelist " $lockfile" 37441016ad83Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37451016ad83Smrg 37461016ad83Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 37471016ad83Smrg srcfile=$func_to_tool_file_result 3748b9526c6aSmrg func_quote_arg pretty "$srcfile" 3749b9526c6aSmrg qsrcfile=$func_quote_arg_result 37501016ad83Smrg 37511016ad83Smrg # Only build a PIC object if we are building libtool libraries. 37527204935cSmrg if test yes = "$build_libtool_libs"; then 37531016ad83Smrg # Without this assignment, base_compile gets emptied. 37541016ad83Smrg fbsd_hideous_sh_bug=$base_compile 37551016ad83Smrg 37567204935cSmrg if test no != "$pic_mode"; then 37571016ad83Smrg command="$base_compile $qsrcfile $pic_flag" 37581016ad83Smrg else 37591016ad83Smrg # Don't build PIC code 37601016ad83Smrg command="$base_compile $qsrcfile" 37611016ad83Smrg fi 37621016ad83Smrg 37631016ad83Smrg func_mkdir_p "$xdir$objdir" 37641016ad83Smrg 37651016ad83Smrg if test -z "$output_obj"; then 37661016ad83Smrg # Place PIC objects in $objdir 37671016ad83Smrg func_append command " -o $lobj" 37681016ad83Smrg fi 37691016ad83Smrg 37701016ad83Smrg func_show_eval_locale "$command" \ 37711016ad83Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37721016ad83Smrg 37737204935cSmrg if test warn = "$need_locks" && 37741016ad83Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 37751016ad83Smrg $ECHO "\ 37761016ad83Smrg*** ERROR, $lockfile contains: 37771016ad83Smrg`cat $lockfile 2>/dev/null` 37781016ad83Smrg 37791016ad83Smrgbut it should contain: 37801016ad83Smrg$srcfile 37811016ad83Smrg 37821016ad83SmrgThis indicates that another process is trying to use the same 37831016ad83Smrgtemporary object file, and libtool could not work around it because 37847204935cSmrgyour compiler does not support '-c' and '-o' together. If you 37851016ad83Smrgrepeat this compilation, it may succeed, by chance, but you had better 37861016ad83Smrgavoid parallel builds (make -j) in this platform, or get a better 37871016ad83Smrgcompiler." 37881016ad83Smrg 37891016ad83Smrg $opt_dry_run || $RM $removelist 37901016ad83Smrg exit $EXIT_FAILURE 37911016ad83Smrg fi 37921016ad83Smrg 37931016ad83Smrg # Just move the object if needed, then go on to compile the next one 37941016ad83Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 37951016ad83Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 37961016ad83Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37971016ad83Smrg fi 37981016ad83Smrg 37991016ad83Smrg # Allow error messages only from the first compilation. 38007204935cSmrg if test yes = "$suppress_opt"; then 38011016ad83Smrg suppress_output=' >/dev/null 2>&1' 38021016ad83Smrg fi 38031016ad83Smrg fi 38041016ad83Smrg 38051016ad83Smrg # Only build a position-dependent object if we build old libraries. 38067204935cSmrg if test yes = "$build_old_libs"; then 38077204935cSmrg if test yes != "$pic_mode"; then 38081016ad83Smrg # Don't build PIC code 38091016ad83Smrg command="$base_compile $qsrcfile$pie_flag" 38101016ad83Smrg else 38111016ad83Smrg command="$base_compile $qsrcfile $pic_flag" 38121016ad83Smrg fi 38137204935cSmrg if test yes = "$compiler_c_o"; then 38141016ad83Smrg func_append command " -o $obj" 38151016ad83Smrg fi 38161016ad83Smrg 38171016ad83Smrg # Suppress compiler output if we already did a PIC compilation. 38181016ad83Smrg func_append command "$suppress_output" 38191016ad83Smrg func_show_eval_locale "$command" \ 38201016ad83Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38211016ad83Smrg 38227204935cSmrg if test warn = "$need_locks" && 38231016ad83Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 38241016ad83Smrg $ECHO "\ 38251016ad83Smrg*** ERROR, $lockfile contains: 38261016ad83Smrg`cat $lockfile 2>/dev/null` 38271016ad83Smrg 38281016ad83Smrgbut it should contain: 38291016ad83Smrg$srcfile 38301016ad83Smrg 38311016ad83SmrgThis indicates that another process is trying to use the same 38321016ad83Smrgtemporary object file, and libtool could not work around it because 38337204935cSmrgyour compiler does not support '-c' and '-o' together. If you 38341016ad83Smrgrepeat this compilation, it may succeed, by chance, but you had better 38351016ad83Smrgavoid parallel builds (make -j) in this platform, or get a better 38361016ad83Smrgcompiler." 38371016ad83Smrg 38381016ad83Smrg $opt_dry_run || $RM $removelist 38391016ad83Smrg exit $EXIT_FAILURE 38401016ad83Smrg fi 38411016ad83Smrg 38421016ad83Smrg # Just move the object if needed 38431016ad83Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 38441016ad83Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 38451016ad83Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38461016ad83Smrg fi 38471016ad83Smrg fi 38481016ad83Smrg 38491016ad83Smrg $opt_dry_run || { 38501016ad83Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38511016ad83Smrg 38521016ad83Smrg # Unlock the critical section if it was locked 38537204935cSmrg if test no != "$need_locks"; then 38541016ad83Smrg removelist=$lockfile 38551016ad83Smrg $RM "$lockfile" 38561016ad83Smrg fi 38571016ad83Smrg } 38581016ad83Smrg 38591016ad83Smrg exit $EXIT_SUCCESS 38601016ad83Smrg} 38611016ad83Smrg 38621016ad83Smrg$opt_help || { 38637204935cSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 38641016ad83Smrg} 38651016ad83Smrg 38661016ad83Smrgfunc_mode_help () 38671016ad83Smrg{ 38681016ad83Smrg # We need to display help for each of the modes. 38691016ad83Smrg case $opt_mode in 38701016ad83Smrg "") 38711016ad83Smrg # Generic help is extracted from the usage comments 38721016ad83Smrg # at the start of this file. 38731016ad83Smrg func_help 38741016ad83Smrg ;; 38751016ad83Smrg 38761016ad83Smrg clean) 38771016ad83Smrg $ECHO \ 38781016ad83Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38791016ad83Smrg 38801016ad83SmrgRemove files from the build directory. 38811016ad83Smrg 38821016ad83SmrgRM is the name of the program to use to delete files associated with each FILE 38837204935cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 38841016ad83Smrgto RM. 38851016ad83Smrg 38861016ad83SmrgIf FILE is a libtool library, object or program, all the files associated 38871016ad83Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 38881016ad83Smrg ;; 38891016ad83Smrg 38901016ad83Smrg compile) 38911016ad83Smrg $ECHO \ 38921016ad83Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38931016ad83Smrg 38941016ad83SmrgCompile a source file into a libtool library object. 38951016ad83Smrg 38961016ad83SmrgThis mode accepts the following additional options: 38971016ad83Smrg 38981016ad83Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 38991016ad83Smrg -no-suppress do not suppress compiler output for multiple passes 39001016ad83Smrg -prefer-pic try to build PIC objects only 39011016ad83Smrg -prefer-non-pic try to build non-PIC objects only 39027204935cSmrg -shared do not build a '.o' file suitable for static linking 39037204935cSmrg -static only build a '.o' file suitable for static linking 3904b9526c6aSmrg -Wc,FLAG 3905b9526c6aSmrg -Xcompiler FLAG pass FLAG directly to the compiler 39061016ad83Smrg 39077204935cSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 39081016ad83Smrgfrom the given SOURCEFILE. 39091016ad83Smrg 39101016ad83SmrgThe output file name is determined by removing the directory component from 39117204935cSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39127204935cSmrglibrary object suffix, '.lo'." 39131016ad83Smrg ;; 39141016ad83Smrg 39151016ad83Smrg execute) 39161016ad83Smrg $ECHO \ 39171016ad83Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39181016ad83Smrg 39191016ad83SmrgAutomatically set library path, then run a program. 39201016ad83Smrg 39211016ad83SmrgThis mode accepts the following additional options: 39221016ad83Smrg 39231016ad83Smrg -dlopen FILE add the directory containing FILE to the library path 39241016ad83Smrg 39257204935cSmrgThis mode sets the library path environment variable according to '-dlopen' 39261016ad83Smrgflags. 39271016ad83Smrg 39281016ad83SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 39291016ad83Smrginto their corresponding uninstalled binary, and any of their required library 39301016ad83Smrgdirectories are added to the library path. 39311016ad83Smrg 39321016ad83SmrgThen, COMMAND is executed, with ARGS as arguments." 39331016ad83Smrg ;; 39341016ad83Smrg 39351016ad83Smrg finish) 39361016ad83Smrg $ECHO \ 39371016ad83Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39381016ad83Smrg 39391016ad83SmrgComplete the installation of libtool libraries. 39401016ad83Smrg 39411016ad83SmrgEach LIBDIR is a directory that contains libtool libraries. 39421016ad83Smrg 39431016ad83SmrgThe commands that this mode executes may require superuser privileges. Use 39447204935cSmrgthe '--dry-run' option if you just want to see what would be executed." 39451016ad83Smrg ;; 39461016ad83Smrg 39471016ad83Smrg install) 39481016ad83Smrg $ECHO \ 39491016ad83Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39501016ad83Smrg 39511016ad83SmrgInstall executables or libraries. 39521016ad83Smrg 39531016ad83SmrgINSTALL-COMMAND is the installation command. The first component should be 39547204935cSmrgeither the 'install' or 'cp' program. 39551016ad83Smrg 39561016ad83SmrgThe following components of INSTALL-COMMAND are treated specially: 39571016ad83Smrg 39581016ad83Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39591016ad83Smrg 39601016ad83SmrgThe rest of the components are interpreted as arguments to that command (only 39611016ad83SmrgBSD-compatible install options are recognized)." 39621016ad83Smrg ;; 39631016ad83Smrg 39641016ad83Smrg link) 39651016ad83Smrg $ECHO \ 39661016ad83Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39671016ad83Smrg 39681016ad83SmrgLink object files or libraries together to form another library, or to 39691016ad83Smrgcreate an executable program. 39701016ad83Smrg 39711016ad83SmrgLINK-COMMAND is a command using the C compiler that you would use to create 39721016ad83Smrga program from several object files. 39731016ad83Smrg 39741016ad83SmrgThe following components of LINK-COMMAND are treated specially: 39751016ad83Smrg 39761016ad83Smrg -all-static do not do any dynamic linking at all 39771016ad83Smrg -avoid-version do not add a version suffix if possible 39781016ad83Smrg -bindir BINDIR specify path to binaries directory (for systems where 39791016ad83Smrg libraries must be found in the PATH setting at runtime) 39807204935cSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 39811016ad83Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 39821016ad83Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 39831016ad83Smrg -export-symbols SYMFILE 39841016ad83Smrg try to export only the symbols listed in SYMFILE 39851016ad83Smrg -export-symbols-regex REGEX 39861016ad83Smrg try to export only the symbols matching REGEX 39871016ad83Smrg -LLIBDIR search LIBDIR for required installed libraries 39881016ad83Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 39891016ad83Smrg -module build a library that can dlopened 39901016ad83Smrg -no-fast-install disable the fast-install mode 39911016ad83Smrg -no-install link a not-installable executable 39921016ad83Smrg -no-undefined declare that a library does not refer to external symbols 39931016ad83Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39947204935cSmrg -objectlist FILE use a list of object files found in FILE to specify objects 39957204935cSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 39961016ad83Smrg -precious-files-regex REGEX 39971016ad83Smrg don't remove output files matching REGEX 39981016ad83Smrg -release RELEASE specify package release information 39991016ad83Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 40001016ad83Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 40011016ad83Smrg -shared only do dynamic linking of libtool libraries 40021016ad83Smrg -shrext SUFFIX override the standard shared library file extension 40031016ad83Smrg -static do not do any dynamic linking of uninstalled libtool libraries 40041016ad83Smrg -static-libtool-libs 40051016ad83Smrg do not do any dynamic linking of libtool libraries 40061016ad83Smrg -version-info CURRENT[:REVISION[:AGE]] 40071016ad83Smrg specify library version info [each variable defaults to 0] 40081016ad83Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 40091016ad83Smrg -Wc,FLAG 40101016ad83Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011b9526c6aSmrg -Wa,FLAG 4012b9526c6aSmrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 40131016ad83Smrg -Wl,FLAG 40141016ad83Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 40151016ad83Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40161016ad83Smrg 40177204935cSmrgAll other options (arguments beginning with '-') are ignored. 40181016ad83Smrg 40197204935cSmrgEvery other argument is treated as a filename. Files ending in '.la' are 40201016ad83Smrgtreated as uninstalled libtool libraries, other files are standard or library 40211016ad83Smrgobject files. 40221016ad83Smrg 40237204935cSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40247204935cSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 40251016ad83Smrgrequired, except when creating a convenience library. 40261016ad83Smrg 40277204935cSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40287204935cSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 40291016ad83Smrg 40307204935cSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 40311016ad83Smrgis created, otherwise an executable program is created." 40321016ad83Smrg ;; 40331016ad83Smrg 40341016ad83Smrg uninstall) 40351016ad83Smrg $ECHO \ 40361016ad83Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40371016ad83Smrg 40381016ad83SmrgRemove libraries from an installation directory. 40391016ad83Smrg 40401016ad83SmrgRM is the name of the program to use to delete files associated with each FILE 40417204935cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 40421016ad83Smrgto RM. 40431016ad83Smrg 40441016ad83SmrgIf FILE is a libtool library, all the files associated with it are deleted. 40451016ad83SmrgOtherwise, only FILE itself is deleted using RM." 40461016ad83Smrg ;; 40471016ad83Smrg 40481016ad83Smrg *) 40497204935cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 40501016ad83Smrg ;; 40511016ad83Smrg esac 40521016ad83Smrg 40531016ad83Smrg echo 40547204935cSmrg $ECHO "Try '$progname --help' for more information about other modes." 40551016ad83Smrg} 40561016ad83Smrg 40571016ad83Smrg# Now that we've collected a possible --mode arg, show help if necessary 40581016ad83Smrgif $opt_help; then 40597204935cSmrg if test : = "$opt_help"; then 40601016ad83Smrg func_mode_help 40611016ad83Smrg else 40621016ad83Smrg { 40631016ad83Smrg func_help noexit 40641016ad83Smrg for opt_mode in compile link execute install finish uninstall clean; do 40651016ad83Smrg func_mode_help 40661016ad83Smrg done 40677204935cSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 40681016ad83Smrg { 40691016ad83Smrg func_help noexit 40701016ad83Smrg for opt_mode in compile link execute install finish uninstall clean; do 40711016ad83Smrg echo 40721016ad83Smrg func_mode_help 40731016ad83Smrg done 40741016ad83Smrg } | 40757204935cSmrg $SED '1d 40761016ad83Smrg /^When reporting/,/^Report/{ 40771016ad83Smrg H 40781016ad83Smrg d 40791016ad83Smrg } 40801016ad83Smrg $x 40811016ad83Smrg /information about other modes/d 40821016ad83Smrg /more detailed .*MODE/d 40831016ad83Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 40841016ad83Smrg fi 40851016ad83Smrg exit $? 40861016ad83Smrgfi 40871016ad83Smrg 40881016ad83Smrg 40891016ad83Smrg# func_mode_execute arg... 40901016ad83Smrgfunc_mode_execute () 40911016ad83Smrg{ 40927204935cSmrg $debug_cmd 40937204935cSmrg 40941016ad83Smrg # The first argument is the command name. 40957204935cSmrg cmd=$nonopt 40961016ad83Smrg test -z "$cmd" && \ 40971016ad83Smrg func_fatal_help "you must specify a COMMAND" 40981016ad83Smrg 40991016ad83Smrg # Handle -dlopen flags immediately. 41001016ad83Smrg for file in $opt_dlopen; do 41011016ad83Smrg test -f "$file" \ 41027204935cSmrg || func_fatal_help "'$file' is not a file" 41031016ad83Smrg 41041016ad83Smrg dir= 41051016ad83Smrg case $file in 41061016ad83Smrg *.la) 41071016ad83Smrg func_resolve_sysroot "$file" 41081016ad83Smrg file=$func_resolve_sysroot_result 41091016ad83Smrg 41101016ad83Smrg # Check to see that this really is a libtool archive. 41111016ad83Smrg func_lalib_unsafe_p "$file" \ 41127204935cSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 41131016ad83Smrg 41141016ad83Smrg # Read the libtool library. 41151016ad83Smrg dlname= 41161016ad83Smrg library_names= 41171016ad83Smrg func_source "$file" 41181016ad83Smrg 41191016ad83Smrg # Skip this library if it cannot be dlopened. 41201016ad83Smrg if test -z "$dlname"; then 41211016ad83Smrg # Warn if it was a shared library. 41221016ad83Smrg test -n "$library_names" && \ 41237204935cSmrg func_warning "'$file' was not linked with '-export-dynamic'" 41241016ad83Smrg continue 41251016ad83Smrg fi 41261016ad83Smrg 41271016ad83Smrg func_dirname "$file" "" "." 41287204935cSmrg dir=$func_dirname_result 41291016ad83Smrg 41301016ad83Smrg if test -f "$dir/$objdir/$dlname"; then 41311016ad83Smrg func_append dir "/$objdir" 41321016ad83Smrg else 41331016ad83Smrg if test ! -f "$dir/$dlname"; then 41347204935cSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 41351016ad83Smrg fi 41361016ad83Smrg fi 41371016ad83Smrg ;; 41381016ad83Smrg 41391016ad83Smrg *.lo) 41401016ad83Smrg # Just add the directory containing the .lo file. 41411016ad83Smrg func_dirname "$file" "" "." 41427204935cSmrg dir=$func_dirname_result 41431016ad83Smrg ;; 41441016ad83Smrg 41451016ad83Smrg *) 41467204935cSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41471016ad83Smrg continue 41481016ad83Smrg ;; 41491016ad83Smrg esac 41501016ad83Smrg 41511016ad83Smrg # Get the absolute pathname. 41521016ad83Smrg absdir=`cd "$dir" && pwd` 41537204935cSmrg test -n "$absdir" && dir=$absdir 41541016ad83Smrg 41551016ad83Smrg # Now add the directory to shlibpath_var. 41561016ad83Smrg if eval "test -z \"\$$shlibpath_var\""; then 41571016ad83Smrg eval "$shlibpath_var=\"\$dir\"" 41581016ad83Smrg else 41591016ad83Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41601016ad83Smrg fi 41611016ad83Smrg done 41621016ad83Smrg 41631016ad83Smrg # This variable tells wrapper scripts just to set shlibpath_var 41641016ad83Smrg # rather than running their programs. 41657204935cSmrg libtool_execute_magic=$magic 41661016ad83Smrg 41671016ad83Smrg # Check if any of the arguments is a wrapper script. 41681016ad83Smrg args= 41691016ad83Smrg for file 41701016ad83Smrg do 41711016ad83Smrg case $file in 41721016ad83Smrg -* | *.la | *.lo ) ;; 41731016ad83Smrg *) 41741016ad83Smrg # Do a test to see if this is really a libtool program. 41751016ad83Smrg if func_ltwrapper_script_p "$file"; then 41761016ad83Smrg func_source "$file" 41771016ad83Smrg # Transform arg to wrapped name. 41787204935cSmrg file=$progdir/$program 41791016ad83Smrg elif func_ltwrapper_executable_p "$file"; then 41801016ad83Smrg func_ltwrapper_scriptname "$file" 41811016ad83Smrg func_source "$func_ltwrapper_scriptname_result" 41821016ad83Smrg # Transform arg to wrapped name. 41837204935cSmrg file=$progdir/$program 41841016ad83Smrg fi 41851016ad83Smrg ;; 41861016ad83Smrg esac 41871016ad83Smrg # Quote arguments (to preserve shell metacharacters). 41881016ad83Smrg func_append_quoted args "$file" 41891016ad83Smrg done 41901016ad83Smrg 41917204935cSmrg if $opt_dry_run; then 41927204935cSmrg # Display what would be done. 41937204935cSmrg if test -n "$shlibpath_var"; then 41947204935cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41957204935cSmrg echo "export $shlibpath_var" 41967204935cSmrg fi 41977204935cSmrg $ECHO "$cmd$args" 41987204935cSmrg exit $EXIT_SUCCESS 41997204935cSmrg else 42001016ad83Smrg if test -n "$shlibpath_var"; then 42011016ad83Smrg # Export the shlibpath_var. 42021016ad83Smrg eval "export $shlibpath_var" 42031016ad83Smrg fi 42041016ad83Smrg 42051016ad83Smrg # Restore saved environment variables 42061016ad83Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 42071016ad83Smrg do 42081016ad83Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 42091016ad83Smrg $lt_var=\$save_$lt_var; export $lt_var 42101016ad83Smrg else 42111016ad83Smrg $lt_unset $lt_var 42121016ad83Smrg fi" 42131016ad83Smrg done 42141016ad83Smrg 42151016ad83Smrg # Now prepare to actually exec the command. 42167204935cSmrg exec_cmd=\$cmd$args 42171016ad83Smrg fi 42181016ad83Smrg} 42191016ad83Smrg 42207204935cSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42211016ad83Smrg 42221016ad83Smrg 42231016ad83Smrg# func_mode_finish arg... 42241016ad83Smrgfunc_mode_finish () 42251016ad83Smrg{ 42267204935cSmrg $debug_cmd 42277204935cSmrg 42281016ad83Smrg libs= 42291016ad83Smrg libdirs= 42301016ad83Smrg admincmds= 42311016ad83Smrg 42321016ad83Smrg for opt in "$nonopt" ${1+"$@"} 42331016ad83Smrg do 42341016ad83Smrg if test -d "$opt"; then 42351016ad83Smrg func_append libdirs " $opt" 42361016ad83Smrg 42371016ad83Smrg elif test -f "$opt"; then 42381016ad83Smrg if func_lalib_unsafe_p "$opt"; then 42391016ad83Smrg func_append libs " $opt" 42401016ad83Smrg else 42417204935cSmrg func_warning "'$opt' is not a valid libtool archive" 42421016ad83Smrg fi 42431016ad83Smrg 42441016ad83Smrg else 42457204935cSmrg func_fatal_error "invalid argument '$opt'" 42461016ad83Smrg fi 42471016ad83Smrg done 42481016ad83Smrg 42491016ad83Smrg if test -n "$libs"; then 42501016ad83Smrg if test -n "$lt_sysroot"; then 42511016ad83Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 42521016ad83Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 42531016ad83Smrg else 42541016ad83Smrg sysroot_cmd= 42551016ad83Smrg fi 42561016ad83Smrg 42571016ad83Smrg # Remove sysroot references 42581016ad83Smrg if $opt_dry_run; then 42591016ad83Smrg for lib in $libs; do 42607204935cSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 42611016ad83Smrg done 42621016ad83Smrg else 42631016ad83Smrg tmpdir=`func_mktempdir` 42641016ad83Smrg for lib in $libs; do 42657204935cSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 42661016ad83Smrg > $tmpdir/tmp-la 42671016ad83Smrg mv -f $tmpdir/tmp-la $lib 42681016ad83Smrg done 42691016ad83Smrg ${RM}r "$tmpdir" 42701016ad83Smrg fi 42711016ad83Smrg fi 42721016ad83Smrg 42731016ad83Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42741016ad83Smrg for libdir in $libdirs; do 42751016ad83Smrg if test -n "$finish_cmds"; then 42761016ad83Smrg # Do each command in the finish commands. 42771016ad83Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 42781016ad83Smrg'"$cmd"'"' 42791016ad83Smrg fi 42801016ad83Smrg if test -n "$finish_eval"; then 42811016ad83Smrg # Do the single finish_eval. 42821016ad83Smrg eval cmds=\"$finish_eval\" 42831016ad83Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 42841016ad83Smrg $cmds" 42851016ad83Smrg fi 42861016ad83Smrg done 42871016ad83Smrg fi 42881016ad83Smrg 42891016ad83Smrg # Exit here if they wanted silent mode. 42907204935cSmrg $opt_quiet && exit $EXIT_SUCCESS 42911016ad83Smrg 42921016ad83Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42931016ad83Smrg echo "----------------------------------------------------------------------" 42941016ad83Smrg echo "Libraries have been installed in:" 42951016ad83Smrg for libdir in $libdirs; do 42961016ad83Smrg $ECHO " $libdir" 42971016ad83Smrg done 42981016ad83Smrg echo 42991016ad83Smrg echo "If you ever happen to want to link against installed libraries" 43001016ad83Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43017204935cSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 43021016ad83Smrg echo "flag during linking and do at least one of the following:" 43031016ad83Smrg if test -n "$shlibpath_var"; then 43047204935cSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 43051016ad83Smrg echo " during execution" 43061016ad83Smrg fi 43071016ad83Smrg if test -n "$runpath_var"; then 43087204935cSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 43091016ad83Smrg echo " during linking" 43101016ad83Smrg fi 43111016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 43121016ad83Smrg libdir=LIBDIR 43131016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 43141016ad83Smrg 43157204935cSmrg $ECHO " - use the '$flag' linker flag" 43161016ad83Smrg fi 43171016ad83Smrg if test -n "$admincmds"; then 43181016ad83Smrg $ECHO " - have your system administrator run these commands:$admincmds" 43191016ad83Smrg fi 43201016ad83Smrg if test -f /etc/ld.so.conf; then 43217204935cSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 43221016ad83Smrg fi 43231016ad83Smrg echo 43241016ad83Smrg 43251016ad83Smrg echo "See any operating system documentation about shared libraries for" 43261016ad83Smrg case $host in 43271016ad83Smrg solaris2.[6789]|solaris2.1[0-9]) 43281016ad83Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 43291016ad83Smrg echo "pages." 43301016ad83Smrg ;; 43311016ad83Smrg *) 43321016ad83Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43331016ad83Smrg ;; 43341016ad83Smrg esac 43351016ad83Smrg echo "----------------------------------------------------------------------" 43361016ad83Smrg fi 43371016ad83Smrg exit $EXIT_SUCCESS 43381016ad83Smrg} 43391016ad83Smrg 43407204935cSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43411016ad83Smrg 43421016ad83Smrg 43431016ad83Smrg# func_mode_install arg... 43441016ad83Smrgfunc_mode_install () 43451016ad83Smrg{ 43467204935cSmrg $debug_cmd 43477204935cSmrg 43481016ad83Smrg # There may be an optional sh(1) argument at the beginning of 43491016ad83Smrg # install_prog (especially on Windows NT). 43507204935cSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 43511016ad83Smrg # Allow the use of GNU shtool's install command. 43527204935cSmrg case $nonopt in *shtool*) :;; *) false;; esac 43537204935cSmrg then 43541016ad83Smrg # Aesthetically quote it. 4355b9526c6aSmrg func_quote_arg pretty "$nonopt" 4356b9526c6aSmrg install_prog="$func_quote_arg_result " 43571016ad83Smrg arg=$1 43581016ad83Smrg shift 43591016ad83Smrg else 43601016ad83Smrg install_prog= 43611016ad83Smrg arg=$nonopt 43621016ad83Smrg fi 43631016ad83Smrg 43641016ad83Smrg # The real first argument should be the name of the installation program. 43651016ad83Smrg # Aesthetically quote it. 4366b9526c6aSmrg func_quote_arg pretty "$arg" 4367b9526c6aSmrg func_append install_prog "$func_quote_arg_result" 43681016ad83Smrg install_shared_prog=$install_prog 43691016ad83Smrg case " $install_prog " in 43701016ad83Smrg *[\\\ /]cp\ *) install_cp=: ;; 43711016ad83Smrg *) install_cp=false ;; 43721016ad83Smrg esac 43731016ad83Smrg 43741016ad83Smrg # We need to accept at least all the BSD install flags. 43751016ad83Smrg dest= 43761016ad83Smrg files= 43771016ad83Smrg opts= 43781016ad83Smrg prev= 43791016ad83Smrg install_type= 43807204935cSmrg isdir=false 43811016ad83Smrg stripme= 43821016ad83Smrg no_mode=: 43831016ad83Smrg for arg 43841016ad83Smrg do 43851016ad83Smrg arg2= 43861016ad83Smrg if test -n "$dest"; then 43871016ad83Smrg func_append files " $dest" 43881016ad83Smrg dest=$arg 43891016ad83Smrg continue 43901016ad83Smrg fi 43911016ad83Smrg 43921016ad83Smrg case $arg in 43937204935cSmrg -d) isdir=: ;; 43941016ad83Smrg -f) 43951016ad83Smrg if $install_cp; then :; else 43961016ad83Smrg prev=$arg 43971016ad83Smrg fi 43981016ad83Smrg ;; 43991016ad83Smrg -g | -m | -o) 44001016ad83Smrg prev=$arg 44011016ad83Smrg ;; 44021016ad83Smrg -s) 44031016ad83Smrg stripme=" -s" 44041016ad83Smrg continue 44051016ad83Smrg ;; 44061016ad83Smrg -*) 44071016ad83Smrg ;; 44081016ad83Smrg *) 44091016ad83Smrg # If the previous option needed an argument, then skip it. 44101016ad83Smrg if test -n "$prev"; then 44117204935cSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 44121016ad83Smrg arg2=$install_override_mode 44131016ad83Smrg no_mode=false 44141016ad83Smrg fi 44151016ad83Smrg prev= 44161016ad83Smrg else 44171016ad83Smrg dest=$arg 44181016ad83Smrg continue 44191016ad83Smrg fi 44201016ad83Smrg ;; 44211016ad83Smrg esac 44221016ad83Smrg 44231016ad83Smrg # Aesthetically quote the argument. 4424b9526c6aSmrg func_quote_arg pretty "$arg" 4425b9526c6aSmrg func_append install_prog " $func_quote_arg_result" 44261016ad83Smrg if test -n "$arg2"; then 4427b9526c6aSmrg func_quote_arg pretty "$arg2" 44281016ad83Smrg fi 4429b9526c6aSmrg func_append install_shared_prog " $func_quote_arg_result" 44301016ad83Smrg done 44311016ad83Smrg 44321016ad83Smrg test -z "$install_prog" && \ 44331016ad83Smrg func_fatal_help "you must specify an install program" 44341016ad83Smrg 44351016ad83Smrg test -n "$prev" && \ 44367204935cSmrg func_fatal_help "the '$prev' option requires an argument" 44371016ad83Smrg 44381016ad83Smrg if test -n "$install_override_mode" && $no_mode; then 44391016ad83Smrg if $install_cp; then :; else 4440b9526c6aSmrg func_quote_arg pretty "$install_override_mode" 4441b9526c6aSmrg func_append install_shared_prog " -m $func_quote_arg_result" 44421016ad83Smrg fi 44431016ad83Smrg fi 44441016ad83Smrg 44451016ad83Smrg if test -z "$files"; then 44461016ad83Smrg if test -z "$dest"; then 44471016ad83Smrg func_fatal_help "no file or destination specified" 44481016ad83Smrg else 44491016ad83Smrg func_fatal_help "you must specify a destination" 44501016ad83Smrg fi 44511016ad83Smrg fi 44521016ad83Smrg 44531016ad83Smrg # Strip any trailing slash from the destination. 44541016ad83Smrg func_stripname '' '/' "$dest" 44551016ad83Smrg dest=$func_stripname_result 44561016ad83Smrg 44571016ad83Smrg # Check to see that the destination is a directory. 44587204935cSmrg test -d "$dest" && isdir=: 44597204935cSmrg if $isdir; then 44607204935cSmrg destdir=$dest 44611016ad83Smrg destname= 44621016ad83Smrg else 44631016ad83Smrg func_dirname_and_basename "$dest" "" "." 44647204935cSmrg destdir=$func_dirname_result 44657204935cSmrg destname=$func_basename_result 44661016ad83Smrg 44671016ad83Smrg # Not a directory, so check to see that there is only one file specified. 44681016ad83Smrg set dummy $files; shift 44691016ad83Smrg test "$#" -gt 1 && \ 44707204935cSmrg func_fatal_help "'$dest' is not a directory" 44711016ad83Smrg fi 44721016ad83Smrg case $destdir in 44731016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44741016ad83Smrg *) 44751016ad83Smrg for file in $files; do 44761016ad83Smrg case $file in 44771016ad83Smrg *.lo) ;; 44781016ad83Smrg *) 44797204935cSmrg func_fatal_help "'$destdir' must be an absolute directory name" 44801016ad83Smrg ;; 44811016ad83Smrg esac 44821016ad83Smrg done 44831016ad83Smrg ;; 44841016ad83Smrg esac 44851016ad83Smrg 44861016ad83Smrg # This variable tells wrapper scripts just to set variables rather 44871016ad83Smrg # than running their programs. 44887204935cSmrg libtool_install_magic=$magic 44891016ad83Smrg 44901016ad83Smrg staticlibs= 44911016ad83Smrg future_libdirs= 44921016ad83Smrg current_libdirs= 44931016ad83Smrg for file in $files; do 44941016ad83Smrg 44951016ad83Smrg # Do each installation. 44961016ad83Smrg case $file in 44971016ad83Smrg *.$libext) 44981016ad83Smrg # Do the static libraries later. 44991016ad83Smrg func_append staticlibs " $file" 45001016ad83Smrg ;; 45011016ad83Smrg 45021016ad83Smrg *.la) 45031016ad83Smrg func_resolve_sysroot "$file" 45041016ad83Smrg file=$func_resolve_sysroot_result 45051016ad83Smrg 45061016ad83Smrg # Check to see that this really is a libtool archive. 45071016ad83Smrg func_lalib_unsafe_p "$file" \ 45087204935cSmrg || func_fatal_help "'$file' is not a valid libtool archive" 45091016ad83Smrg 45101016ad83Smrg library_names= 45111016ad83Smrg old_library= 45121016ad83Smrg relink_command= 45131016ad83Smrg func_source "$file" 45141016ad83Smrg 45151016ad83Smrg # Add the libdir to current_libdirs if it is the destination. 45161016ad83Smrg if test "X$destdir" = "X$libdir"; then 45171016ad83Smrg case "$current_libdirs " in 45181016ad83Smrg *" $libdir "*) ;; 45191016ad83Smrg *) func_append current_libdirs " $libdir" ;; 45201016ad83Smrg esac 45211016ad83Smrg else 45221016ad83Smrg # Note the libdir as a future libdir. 45231016ad83Smrg case "$future_libdirs " in 45241016ad83Smrg *" $libdir "*) ;; 45251016ad83Smrg *) func_append future_libdirs " $libdir" ;; 45261016ad83Smrg esac 45271016ad83Smrg fi 45281016ad83Smrg 45291016ad83Smrg func_dirname "$file" "/" "" 45307204935cSmrg dir=$func_dirname_result 45311016ad83Smrg func_append dir "$objdir" 45321016ad83Smrg 45331016ad83Smrg if test -n "$relink_command"; then 45341016ad83Smrg # Determine the prefix the user has applied to our future dir. 45351016ad83Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45361016ad83Smrg 45371016ad83Smrg # Don't allow the user to place us outside of our expected 45381016ad83Smrg # location b/c this prevents finding dependent libraries that 45391016ad83Smrg # are installed to the same prefix. 45401016ad83Smrg # At present, this check doesn't affect windows .dll's that 45411016ad83Smrg # are installed into $libdir/../bin (currently, that works fine) 45421016ad83Smrg # but it's something to keep an eye on. 45431016ad83Smrg test "$inst_prefix_dir" = "$destdir" && \ 45447204935cSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 45451016ad83Smrg 45461016ad83Smrg if test -n "$inst_prefix_dir"; then 45471016ad83Smrg # Stick the inst_prefix_dir data into the link command. 45481016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45491016ad83Smrg else 45501016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45511016ad83Smrg fi 45521016ad83Smrg 45537204935cSmrg func_warning "relinking '$file'" 45541016ad83Smrg func_show_eval "$relink_command" \ 45557204935cSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 45561016ad83Smrg fi 45571016ad83Smrg 45581016ad83Smrg # See the names of the shared library. 45591016ad83Smrg set dummy $library_names; shift 45601016ad83Smrg if test -n "$1"; then 45617204935cSmrg realname=$1 45621016ad83Smrg shift 45631016ad83Smrg 45647204935cSmrg srcname=$realname 45657204935cSmrg test -n "$relink_command" && srcname=${realname}T 45661016ad83Smrg 45671016ad83Smrg # Install the shared library and build the symlinks. 45681016ad83Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 45691016ad83Smrg 'exit $?' 45707204935cSmrg tstripme=$stripme 45711016ad83Smrg case $host_os in 45721016ad83Smrg cygwin* | mingw* | pw32* | cegcc*) 45731016ad83Smrg case $realname in 45741016ad83Smrg *.dll.a) 45757204935cSmrg tstripme= 45767204935cSmrg ;; 45777204935cSmrg esac 45787204935cSmrg ;; 45797204935cSmrg os2*) 45807204935cSmrg case $realname in 45817204935cSmrg *_dll.a) 45827204935cSmrg tstripme= 45831016ad83Smrg ;; 45841016ad83Smrg esac 45851016ad83Smrg ;; 45861016ad83Smrg esac 45871016ad83Smrg if test -n "$tstripme" && test -n "$striplib"; then 45881016ad83Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45891016ad83Smrg fi 45901016ad83Smrg 45911016ad83Smrg if test "$#" -gt 0; then 45921016ad83Smrg # Delete the old symlinks, and create new ones. 45937204935cSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 45941016ad83Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 45951016ad83Smrg # so we also need to try rm && ln -s. 45961016ad83Smrg for linkname 45971016ad83Smrg do 45981016ad83Smrg test "$linkname" != "$realname" \ 45991016ad83Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46001016ad83Smrg done 46011016ad83Smrg fi 46021016ad83Smrg 46031016ad83Smrg # Do each command in the postinstall commands. 46047204935cSmrg lib=$destdir/$realname 46051016ad83Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 46061016ad83Smrg fi 46071016ad83Smrg 46081016ad83Smrg # Install the pseudo-library for information purposes. 46091016ad83Smrg func_basename "$file" 46107204935cSmrg name=$func_basename_result 46117204935cSmrg instname=$dir/${name}i 46121016ad83Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46131016ad83Smrg 46141016ad83Smrg # Maybe install the static library, too. 46151016ad83Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 46161016ad83Smrg ;; 46171016ad83Smrg 46181016ad83Smrg *.lo) 46191016ad83Smrg # Install (i.e. copy) a libtool object. 46201016ad83Smrg 46211016ad83Smrg # Figure out destination file name, if it wasn't already specified. 46221016ad83Smrg if test -n "$destname"; then 46237204935cSmrg destfile=$destdir/$destname 46241016ad83Smrg else 46251016ad83Smrg func_basename "$file" 46267204935cSmrg destfile=$func_basename_result 46277204935cSmrg destfile=$destdir/$destfile 46281016ad83Smrg fi 46291016ad83Smrg 46301016ad83Smrg # Deduce the name of the destination old-style object file. 46311016ad83Smrg case $destfile in 46321016ad83Smrg *.lo) 46331016ad83Smrg func_lo2o "$destfile" 46341016ad83Smrg staticdest=$func_lo2o_result 46351016ad83Smrg ;; 46361016ad83Smrg *.$objext) 46377204935cSmrg staticdest=$destfile 46381016ad83Smrg destfile= 46391016ad83Smrg ;; 46401016ad83Smrg *) 46417204935cSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46421016ad83Smrg ;; 46431016ad83Smrg esac 46441016ad83Smrg 46451016ad83Smrg # Install the libtool object if requested. 46461016ad83Smrg test -n "$destfile" && \ 46471016ad83Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46481016ad83Smrg 46491016ad83Smrg # Install the old object if enabled. 46507204935cSmrg if test yes = "$build_old_libs"; then 46511016ad83Smrg # Deduce the name of the old-style object file. 46521016ad83Smrg func_lo2o "$file" 46531016ad83Smrg staticobj=$func_lo2o_result 46541016ad83Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 46551016ad83Smrg fi 46561016ad83Smrg exit $EXIT_SUCCESS 46571016ad83Smrg ;; 46581016ad83Smrg 46591016ad83Smrg *) 46601016ad83Smrg # Figure out destination file name, if it wasn't already specified. 46611016ad83Smrg if test -n "$destname"; then 46627204935cSmrg destfile=$destdir/$destname 46631016ad83Smrg else 46641016ad83Smrg func_basename "$file" 46657204935cSmrg destfile=$func_basename_result 46667204935cSmrg destfile=$destdir/$destfile 46671016ad83Smrg fi 46681016ad83Smrg 46691016ad83Smrg # If the file is missing, and there is a .exe on the end, strip it 46701016ad83Smrg # because it is most likely a libtool script we actually want to 46711016ad83Smrg # install 46727204935cSmrg stripped_ext= 46731016ad83Smrg case $file in 46741016ad83Smrg *.exe) 46751016ad83Smrg if test ! -f "$file"; then 46761016ad83Smrg func_stripname '' '.exe' "$file" 46771016ad83Smrg file=$func_stripname_result 46787204935cSmrg stripped_ext=.exe 46791016ad83Smrg fi 46801016ad83Smrg ;; 46811016ad83Smrg esac 46821016ad83Smrg 46831016ad83Smrg # Do a test to see if this is really a libtool program. 46841016ad83Smrg case $host in 46851016ad83Smrg *cygwin* | *mingw*) 46861016ad83Smrg if func_ltwrapper_executable_p "$file"; then 46871016ad83Smrg func_ltwrapper_scriptname "$file" 46881016ad83Smrg wrapper=$func_ltwrapper_scriptname_result 46891016ad83Smrg else 46901016ad83Smrg func_stripname '' '.exe' "$file" 46911016ad83Smrg wrapper=$func_stripname_result 46921016ad83Smrg fi 46931016ad83Smrg ;; 46941016ad83Smrg *) 46951016ad83Smrg wrapper=$file 46961016ad83Smrg ;; 46971016ad83Smrg esac 46981016ad83Smrg if func_ltwrapper_script_p "$wrapper"; then 46991016ad83Smrg notinst_deplibs= 47001016ad83Smrg relink_command= 47011016ad83Smrg 47021016ad83Smrg func_source "$wrapper" 47031016ad83Smrg 47041016ad83Smrg # Check the variables that should have been set. 47051016ad83Smrg test -z "$generated_by_libtool_version" && \ 47067204935cSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47071016ad83Smrg 47087204935cSmrg finalize=: 47091016ad83Smrg for lib in $notinst_deplibs; do 47101016ad83Smrg # Check to see that each library is installed. 47111016ad83Smrg libdir= 47121016ad83Smrg if test -f "$lib"; then 47131016ad83Smrg func_source "$lib" 47141016ad83Smrg fi 47157204935cSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 47161016ad83Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47177204935cSmrg func_warning "'$lib' has not been installed in '$libdir'" 47187204935cSmrg finalize=false 47191016ad83Smrg fi 47201016ad83Smrg done 47211016ad83Smrg 47221016ad83Smrg relink_command= 47231016ad83Smrg func_source "$wrapper" 47241016ad83Smrg 47251016ad83Smrg outputname= 47267204935cSmrg if test no = "$fast_install" && test -n "$relink_command"; then 47271016ad83Smrg $opt_dry_run || { 47287204935cSmrg if $finalize; then 47291016ad83Smrg tmpdir=`func_mktempdir` 47301016ad83Smrg func_basename "$file$stripped_ext" 47317204935cSmrg file=$func_basename_result 47327204935cSmrg outputname=$tmpdir/$file 47331016ad83Smrg # Replace the output file specification. 47341016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 47351016ad83Smrg 47367204935cSmrg $opt_quiet || { 4737b9526c6aSmrg func_quote_arg expand,pretty "$relink_command" 4738b9526c6aSmrg eval "func_echo $func_quote_arg_result" 47391016ad83Smrg } 47401016ad83Smrg if eval "$relink_command"; then : 47411016ad83Smrg else 47427204935cSmrg func_error "error: relink '$file' with the above command before installing it" 47431016ad83Smrg $opt_dry_run || ${RM}r "$tmpdir" 47441016ad83Smrg continue 47451016ad83Smrg fi 47467204935cSmrg file=$outputname 47471016ad83Smrg else 47487204935cSmrg func_warning "cannot relink '$file'" 47491016ad83Smrg fi 47501016ad83Smrg } 47511016ad83Smrg else 47521016ad83Smrg # Install the binary that we compiled earlier. 47531016ad83Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47541016ad83Smrg fi 47551016ad83Smrg fi 47561016ad83Smrg 47571016ad83Smrg # remove .exe since cygwin /usr/bin/install will append another 47581016ad83Smrg # one anyway 47591016ad83Smrg case $install_prog,$host in 47601016ad83Smrg */usr/bin/install*,*cygwin*) 47611016ad83Smrg case $file:$destfile in 47621016ad83Smrg *.exe:*.exe) 47631016ad83Smrg # this is ok 47641016ad83Smrg ;; 47651016ad83Smrg *.exe:*) 47661016ad83Smrg destfile=$destfile.exe 47671016ad83Smrg ;; 47681016ad83Smrg *:*.exe) 47691016ad83Smrg func_stripname '' '.exe' "$destfile" 47701016ad83Smrg destfile=$func_stripname_result 47711016ad83Smrg ;; 47721016ad83Smrg esac 47731016ad83Smrg ;; 47741016ad83Smrg esac 47751016ad83Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 47761016ad83Smrg $opt_dry_run || if test -n "$outputname"; then 47771016ad83Smrg ${RM}r "$tmpdir" 47781016ad83Smrg fi 47791016ad83Smrg ;; 47801016ad83Smrg esac 47811016ad83Smrg done 47821016ad83Smrg 47831016ad83Smrg for file in $staticlibs; do 47841016ad83Smrg func_basename "$file" 47857204935cSmrg name=$func_basename_result 47861016ad83Smrg 47871016ad83Smrg # Set up the ranlib parameters. 47887204935cSmrg oldlib=$destdir/$name 47891016ad83Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47901016ad83Smrg tool_oldlib=$func_to_tool_file_result 47911016ad83Smrg 47921016ad83Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47931016ad83Smrg 47941016ad83Smrg if test -n "$stripme" && test -n "$old_striplib"; then 47951016ad83Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47961016ad83Smrg fi 47971016ad83Smrg 47981016ad83Smrg # Do each command in the postinstall commands. 47991016ad83Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 48001016ad83Smrg done 48011016ad83Smrg 48021016ad83Smrg test -n "$future_libdirs" && \ 48037204935cSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 48041016ad83Smrg 48051016ad83Smrg if test -n "$current_libdirs"; then 48061016ad83Smrg # Maybe just do a dry run. 48071016ad83Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48087204935cSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 48091016ad83Smrg else 48101016ad83Smrg exit $EXIT_SUCCESS 48111016ad83Smrg fi 48121016ad83Smrg} 48131016ad83Smrg 48147204935cSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48151016ad83Smrg 48161016ad83Smrg 48171016ad83Smrg# func_generate_dlsyms outputname originator pic_p 48181016ad83Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 48191016ad83Smrg# a dlpreopen symbol table. 48201016ad83Smrgfunc_generate_dlsyms () 48211016ad83Smrg{ 48227204935cSmrg $debug_cmd 48237204935cSmrg 48247204935cSmrg my_outputname=$1 48257204935cSmrg my_originator=$2 48267204935cSmrg my_pic_p=${3-false} 48277204935cSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 48281016ad83Smrg my_dlsyms= 48291016ad83Smrg 48307204935cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 48311016ad83Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48327204935cSmrg my_dlsyms=${my_outputname}S.c 48331016ad83Smrg else 48341016ad83Smrg func_error "not configured to extract global symbols from dlpreopened files" 48351016ad83Smrg fi 48361016ad83Smrg fi 48371016ad83Smrg 48381016ad83Smrg if test -n "$my_dlsyms"; then 48391016ad83Smrg case $my_dlsyms in 48401016ad83Smrg "") ;; 48411016ad83Smrg *.c) 48421016ad83Smrg # Discover the nlist of each of the dlfiles. 48437204935cSmrg nlist=$output_objdir/$my_outputname.nm 48441016ad83Smrg 48451016ad83Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48461016ad83Smrg 48471016ad83Smrg # Parse the name list into a source file. 48481016ad83Smrg func_verbose "creating $output_objdir/$my_dlsyms" 48491016ad83Smrg 48501016ad83Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48517204935cSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48527204935cSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48531016ad83Smrg 48541016ad83Smrg#ifdef __cplusplus 48551016ad83Smrgextern \"C\" { 48561016ad83Smrg#endif 48571016ad83Smrg 48587204935cSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 48591016ad83Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 48601016ad83Smrg#endif 48611016ad83Smrg 48621016ad83Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48637204935cSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48647204935cSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 48651016ad83Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 48661016ad83Smrg# define LT_DLSYM_CONST 48677204935cSmrg#elif defined __osf__ 48681016ad83Smrg/* This system does not cope well with relocations in const data. */ 48691016ad83Smrg# define LT_DLSYM_CONST 48701016ad83Smrg#else 48711016ad83Smrg# define LT_DLSYM_CONST const 48721016ad83Smrg#endif 48731016ad83Smrg 48747204935cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48757204935cSmrg 48761016ad83Smrg/* External symbol declarations for the compiler. */\ 48771016ad83Smrg" 48781016ad83Smrg 48797204935cSmrg if test yes = "$dlself"; then 48807204935cSmrg func_verbose "generating symbol list for '$output'" 48811016ad83Smrg 48821016ad83Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48831016ad83Smrg 48841016ad83Smrg # Add our own program objects to the symbol list. 48851016ad83Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 48861016ad83Smrg for progfile in $progfiles; do 48871016ad83Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48887204935cSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 48891016ad83Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48901016ad83Smrg done 48911016ad83Smrg 48921016ad83Smrg if test -n "$exclude_expsyms"; then 48931016ad83Smrg $opt_dry_run || { 48941016ad83Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 48951016ad83Smrg eval '$MV "$nlist"T "$nlist"' 48961016ad83Smrg } 48971016ad83Smrg fi 48981016ad83Smrg 48991016ad83Smrg if test -n "$export_symbols_regex"; then 49001016ad83Smrg $opt_dry_run || { 49011016ad83Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 49021016ad83Smrg eval '$MV "$nlist"T "$nlist"' 49031016ad83Smrg } 49041016ad83Smrg fi 49051016ad83Smrg 49061016ad83Smrg # Prepare the list of exported symbols 49071016ad83Smrg if test -z "$export_symbols"; then 49087204935cSmrg export_symbols=$output_objdir/$outputname.exp 49091016ad83Smrg $opt_dry_run || { 49101016ad83Smrg $RM $export_symbols 49117204935cSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 49121016ad83Smrg case $host in 49131016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 49141016ad83Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49151016ad83Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 49161016ad83Smrg ;; 49171016ad83Smrg esac 49181016ad83Smrg } 49191016ad83Smrg else 49201016ad83Smrg $opt_dry_run || { 49217204935cSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 49221016ad83Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 49231016ad83Smrg eval '$MV "$nlist"T "$nlist"' 49241016ad83Smrg case $host in 49251016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 49261016ad83Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49271016ad83Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 49281016ad83Smrg ;; 49291016ad83Smrg esac 49301016ad83Smrg } 49311016ad83Smrg fi 49321016ad83Smrg fi 49331016ad83Smrg 49341016ad83Smrg for dlprefile in $dlprefiles; do 49357204935cSmrg func_verbose "extracting global C symbols from '$dlprefile'" 49361016ad83Smrg func_basename "$dlprefile" 49377204935cSmrg name=$func_basename_result 49381016ad83Smrg case $host in 49391016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 49401016ad83Smrg # if an import library, we need to obtain dlname 49411016ad83Smrg if func_win32_import_lib_p "$dlprefile"; then 49421016ad83Smrg func_tr_sh "$dlprefile" 49431016ad83Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49447204935cSmrg dlprefile_dlbasename= 49451016ad83Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 49461016ad83Smrg # Use subshell, to avoid clobbering current variable values 49471016ad83Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49487204935cSmrg if test -n "$dlprefile_dlname"; then 49491016ad83Smrg func_basename "$dlprefile_dlname" 49507204935cSmrg dlprefile_dlbasename=$func_basename_result 49511016ad83Smrg else 49521016ad83Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 49531016ad83Smrg $sharedlib_from_linklib_cmd "$dlprefile" 49541016ad83Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 49551016ad83Smrg fi 49561016ad83Smrg fi 49571016ad83Smrg $opt_dry_run || { 49587204935cSmrg if test -n "$dlprefile_dlbasename"; then 49591016ad83Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 49601016ad83Smrg else 49611016ad83Smrg func_warning "Could not compute DLL name from $name" 49621016ad83Smrg eval '$ECHO ": $name " >> "$nlist"' 49631016ad83Smrg fi 49641016ad83Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49651016ad83Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 49661016ad83Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 49671016ad83Smrg } 49681016ad83Smrg else # not an import lib 49691016ad83Smrg $opt_dry_run || { 49701016ad83Smrg eval '$ECHO ": $name " >> "$nlist"' 49711016ad83Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49721016ad83Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49731016ad83Smrg } 49741016ad83Smrg fi 49751016ad83Smrg ;; 49761016ad83Smrg *) 49771016ad83Smrg $opt_dry_run || { 49781016ad83Smrg eval '$ECHO ": $name " >> "$nlist"' 49791016ad83Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49801016ad83Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49811016ad83Smrg } 49821016ad83Smrg ;; 49831016ad83Smrg esac 49841016ad83Smrg done 49851016ad83Smrg 49861016ad83Smrg $opt_dry_run || { 49871016ad83Smrg # Make sure we have at least an empty file. 49881016ad83Smrg test -f "$nlist" || : > "$nlist" 49891016ad83Smrg 49901016ad83Smrg if test -n "$exclude_expsyms"; then 49911016ad83Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 49921016ad83Smrg $MV "$nlist"T "$nlist" 49931016ad83Smrg fi 49941016ad83Smrg 49951016ad83Smrg # Try sorting and uniquifying the output. 49961016ad83Smrg if $GREP -v "^: " < "$nlist" | 49971016ad83Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 49981016ad83Smrg sort -k 3 49991016ad83Smrg else 50001016ad83Smrg sort +2 50011016ad83Smrg fi | 50021016ad83Smrg uniq > "$nlist"S; then 50031016ad83Smrg : 50041016ad83Smrg else 50051016ad83Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 50061016ad83Smrg fi 50071016ad83Smrg 50081016ad83Smrg if test -f "$nlist"S; then 50091016ad83Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50101016ad83Smrg else 50111016ad83Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50121016ad83Smrg fi 50131016ad83Smrg 50147204935cSmrg func_show_eval '$RM "${nlist}I"' 50157204935cSmrg if test -n "$global_symbol_to_import"; then 50167204935cSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50177204935cSmrg fi 50187204935cSmrg 50191016ad83Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50201016ad83Smrg 50211016ad83Smrg/* The mapping between symbol names and symbols. */ 50221016ad83Smrgtypedef struct { 50231016ad83Smrg const char *name; 50241016ad83Smrg void *address; 50251016ad83Smrg} lt_dlsymlist; 50261016ad83Smrgextern LT_DLSYM_CONST lt_dlsymlist 50277204935cSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50287204935cSmrg" 50297204935cSmrg 50307204935cSmrg if test -s "$nlist"I; then 50317204935cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50327204935cSmrgstatic void lt_syminit(void) 50337204935cSmrg{ 50347204935cSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50357204935cSmrg for (; symbol->name; ++symbol) 50367204935cSmrg {" 50377204935cSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50387204935cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50397204935cSmrg } 50407204935cSmrg}" 50417204935cSmrg fi 50427204935cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50431016ad83SmrgLT_DLSYM_CONST lt_dlsymlist 50441016ad83Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50457204935cSmrg{ {\"$my_originator\", (void *) 0}," 50467204935cSmrg 50477204935cSmrg if test -s "$nlist"I; then 50487204935cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50497204935cSmrg {\"@INIT@\", (void *) <_syminit}," 50507204935cSmrg fi 50511016ad83Smrg 50521016ad83Smrg case $need_lib_prefix in 50531016ad83Smrg no) 50541016ad83Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50551016ad83Smrg ;; 50561016ad83Smrg *) 50571016ad83Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50581016ad83Smrg ;; 50591016ad83Smrg esac 50601016ad83Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50611016ad83Smrg {0, (void *) 0} 50621016ad83Smrg}; 50631016ad83Smrg 50641016ad83Smrg/* This works around a problem in FreeBSD linker */ 50651016ad83Smrg#ifdef FREEBSD_WORKAROUND 50661016ad83Smrgstatic const void *lt_preloaded_setup() { 50671016ad83Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 50681016ad83Smrg} 50691016ad83Smrg#endif 50701016ad83Smrg 50711016ad83Smrg#ifdef __cplusplus 50721016ad83Smrg} 50731016ad83Smrg#endif\ 50741016ad83Smrg" 50751016ad83Smrg } # !$opt_dry_run 50761016ad83Smrg 50771016ad83Smrg pic_flag_for_symtable= 50781016ad83Smrg case "$compile_command " in 50791016ad83Smrg *" -static "*) ;; 50801016ad83Smrg *) 50811016ad83Smrg case $host in 50821016ad83Smrg # compiling the symbol table file with pic_flag works around 50831016ad83Smrg # a FreeBSD bug that causes programs to crash when -lm is 50841016ad83Smrg # linked before any other PIC object. But we must not use 50851016ad83Smrg # pic_flag when linking with -static. The problem exists in 50861016ad83Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50871016ad83Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 50881016ad83Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 50891016ad83Smrg *-*-hpux*) 50901016ad83Smrg pic_flag_for_symtable=" $pic_flag" ;; 50911016ad83Smrg *) 50927204935cSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 50931016ad83Smrg ;; 50941016ad83Smrg esac 50951016ad83Smrg ;; 50961016ad83Smrg esac 50971016ad83Smrg symtab_cflags= 50981016ad83Smrg for arg in $LTCFLAGS; do 50991016ad83Smrg case $arg in 51001016ad83Smrg -pie | -fpie | -fPIE) ;; 51011016ad83Smrg *) func_append symtab_cflags " $arg" ;; 51021016ad83Smrg esac 51031016ad83Smrg done 51041016ad83Smrg 51051016ad83Smrg # Now compile the dynamic symbol file. 51061016ad83Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51071016ad83Smrg 51081016ad83Smrg # Clean up the generated files. 51097204935cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51101016ad83Smrg 51111016ad83Smrg # Transform the symbol file into the correct name. 51127204935cSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 51131016ad83Smrg case $host in 51141016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 51151016ad83Smrg if test -f "$output_objdir/$my_outputname.def"; then 51161016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51171016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51181016ad83Smrg else 51191016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51201016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51211016ad83Smrg fi 51221016ad83Smrg ;; 51231016ad83Smrg *) 51241016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51251016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51261016ad83Smrg ;; 51271016ad83Smrg esac 51281016ad83Smrg ;; 51291016ad83Smrg *) 51307204935cSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 51311016ad83Smrg ;; 51321016ad83Smrg esac 51331016ad83Smrg else 51341016ad83Smrg # We keep going just in case the user didn't refer to 51351016ad83Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 51361016ad83Smrg # really was required. 51371016ad83Smrg 51381016ad83Smrg # Nullify the symbol file. 51391016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 51401016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51411016ad83Smrg fi 51421016ad83Smrg} 51431016ad83Smrg 51447204935cSmrg# func_cygming_gnu_implib_p ARG 51457204935cSmrg# This predicate returns with zero status (TRUE) if 51467204935cSmrg# ARG is a GNU/binutils-style import library. Returns 51477204935cSmrg# with nonzero status (FALSE) otherwise. 51487204935cSmrgfunc_cygming_gnu_implib_p () 51497204935cSmrg{ 51507204935cSmrg $debug_cmd 51517204935cSmrg 51527204935cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51537204935cSmrg 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)$'` 51547204935cSmrg test -n "$func_cygming_gnu_implib_tmp" 51557204935cSmrg} 51567204935cSmrg 51577204935cSmrg# func_cygming_ms_implib_p ARG 51587204935cSmrg# This predicate returns with zero status (TRUE) if 51597204935cSmrg# ARG is an MS-style import library. Returns 51607204935cSmrg# with nonzero status (FALSE) otherwise. 51617204935cSmrgfunc_cygming_ms_implib_p () 51627204935cSmrg{ 51637204935cSmrg $debug_cmd 51647204935cSmrg 51657204935cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51667204935cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51677204935cSmrg test -n "$func_cygming_ms_implib_tmp" 51687204935cSmrg} 51697204935cSmrg 51701016ad83Smrg# func_win32_libid arg 51711016ad83Smrg# return the library type of file 'arg' 51721016ad83Smrg# 51731016ad83Smrg# Need a lot of goo to handle *both* DLLs and import libs 51741016ad83Smrg# Has to be a shell function in order to 'eat' the argument 51751016ad83Smrg# that is supplied when $file_magic_command is called. 51761016ad83Smrg# Despite the name, also deal with 64 bit binaries. 51771016ad83Smrgfunc_win32_libid () 51781016ad83Smrg{ 51797204935cSmrg $debug_cmd 51807204935cSmrg 51817204935cSmrg win32_libid_type=unknown 51821016ad83Smrg win32_fileres=`file -L $1 2>/dev/null` 51831016ad83Smrg case $win32_fileres in 51841016ad83Smrg *ar\ archive\ import\ library*) # definitely import 51851016ad83Smrg win32_libid_type="x86 archive import" 51861016ad83Smrg ;; 51871016ad83Smrg *ar\ archive*) # could be an import, or static 51881016ad83Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 51891016ad83Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 51901016ad83Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51917204935cSmrg case $nm_interface in 51927204935cSmrg "MS dumpbin") 51937204935cSmrg if func_cygming_ms_implib_p "$1" || 51947204935cSmrg func_cygming_gnu_implib_p "$1" 51957204935cSmrg then 51967204935cSmrg win32_nmres=import 51977204935cSmrg else 51987204935cSmrg win32_nmres= 51997204935cSmrg fi 52007204935cSmrg ;; 52017204935cSmrg *) 52027204935cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52037204935cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52047204935cSmrg $SED -n -e ' 52051016ad83Smrg 1,100{ 52061016ad83Smrg / I /{ 52077204935cSmrg s|.*|import| 52081016ad83Smrg p 52091016ad83Smrg q 52101016ad83Smrg } 52111016ad83Smrg }'` 52127204935cSmrg ;; 52137204935cSmrg esac 52141016ad83Smrg case $win32_nmres in 52151016ad83Smrg import*) win32_libid_type="x86 archive import";; 52161016ad83Smrg *) win32_libid_type="x86 archive static";; 52171016ad83Smrg esac 52181016ad83Smrg fi 52191016ad83Smrg ;; 52201016ad83Smrg *DLL*) 52211016ad83Smrg win32_libid_type="x86 DLL" 52221016ad83Smrg ;; 52231016ad83Smrg *executable*) # but shell scripts are "executable" too... 52241016ad83Smrg case $win32_fileres in 52251016ad83Smrg *MS\ Windows\ PE\ Intel*) 52261016ad83Smrg win32_libid_type="x86 DLL" 52271016ad83Smrg ;; 52281016ad83Smrg esac 52291016ad83Smrg ;; 52301016ad83Smrg esac 52311016ad83Smrg $ECHO "$win32_libid_type" 52321016ad83Smrg} 52331016ad83Smrg 52341016ad83Smrg# func_cygming_dll_for_implib ARG 52351016ad83Smrg# 52361016ad83Smrg# Platform-specific function to extract the 52371016ad83Smrg# name of the DLL associated with the specified 52381016ad83Smrg# import library ARG. 52391016ad83Smrg# Invoked by eval'ing the libtool variable 52401016ad83Smrg# $sharedlib_from_linklib_cmd 52411016ad83Smrg# Result is available in the variable 52421016ad83Smrg# $sharedlib_from_linklib_result 52431016ad83Smrgfunc_cygming_dll_for_implib () 52441016ad83Smrg{ 52457204935cSmrg $debug_cmd 52467204935cSmrg 52471016ad83Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 52481016ad83Smrg} 52491016ad83Smrg 52501016ad83Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 52511016ad83Smrg# 52521016ad83Smrg# The is the core of a fallback implementation of a 52531016ad83Smrg# platform-specific function to extract the name of the 52541016ad83Smrg# DLL associated with the specified import library LIBNAME. 52551016ad83Smrg# 52561016ad83Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 52571016ad83Smrg# on the platform and compiler that created the implib. 52581016ad83Smrg# 52591016ad83Smrg# Echos the name of the DLL associated with the 52601016ad83Smrg# specified import library. 52611016ad83Smrgfunc_cygming_dll_for_implib_fallback_core () 52621016ad83Smrg{ 52637204935cSmrg $debug_cmd 52647204935cSmrg 52651016ad83Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 52661016ad83Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 52671016ad83Smrg $SED '/^Contents of section '"$match_literal"':/{ 52681016ad83Smrg # Place marker at beginning of archive member dllname section 52691016ad83Smrg s/.*/====MARK====/ 52701016ad83Smrg p 52711016ad83Smrg d 52721016ad83Smrg } 52731016ad83Smrg # These lines can sometimes be longer than 43 characters, but 52741016ad83Smrg # are always uninteresting 52751016ad83Smrg /:[ ]*file format pe[i]\{,1\}-/d 52761016ad83Smrg /^In archive [^:]*:/d 52771016ad83Smrg # Ensure marker is printed 52781016ad83Smrg /^====MARK====/p 52791016ad83Smrg # Remove all lines with less than 43 characters 52801016ad83Smrg /^.\{43\}/!d 52811016ad83Smrg # From remaining lines, remove first 43 characters 52821016ad83Smrg s/^.\{43\}//' | 52831016ad83Smrg $SED -n ' 52841016ad83Smrg # Join marker and all lines until next marker into a single line 52851016ad83Smrg /^====MARK====/ b para 52861016ad83Smrg H 52871016ad83Smrg $ b para 52881016ad83Smrg b 52891016ad83Smrg :para 52901016ad83Smrg x 52911016ad83Smrg s/\n//g 52921016ad83Smrg # Remove the marker 52931016ad83Smrg s/^====MARK====// 52941016ad83Smrg # Remove trailing dots and whitespace 52951016ad83Smrg s/[\. \t]*$// 52961016ad83Smrg # Print 52971016ad83Smrg /./p' | 52981016ad83Smrg # we now have a list, one entry per line, of the stringified 52991016ad83Smrg # contents of the appropriate section of all members of the 53007204935cSmrg # archive that possess that section. Heuristic: eliminate 53017204935cSmrg # all those that have a first or second character that is 53021016ad83Smrg # a '.' (that is, objdump's representation of an unprintable 53031016ad83Smrg # character.) This should work for all archives with less than 53041016ad83Smrg # 0x302f exports -- but will fail for DLLs whose name actually 53051016ad83Smrg # begins with a literal '.' or a single character followed by 53061016ad83Smrg # a '.'. 53071016ad83Smrg # 53081016ad83Smrg # Of those that remain, print the first one. 53091016ad83Smrg $SED -e '/^\./d;/^.\./d;q' 53101016ad83Smrg} 53111016ad83Smrg 53121016ad83Smrg# func_cygming_dll_for_implib_fallback ARG 53131016ad83Smrg# Platform-specific function to extract the 53141016ad83Smrg# name of the DLL associated with the specified 53151016ad83Smrg# import library ARG. 53161016ad83Smrg# 53171016ad83Smrg# This fallback implementation is for use when $DLLTOOL 53181016ad83Smrg# does not support the --identify-strict option. 53191016ad83Smrg# Invoked by eval'ing the libtool variable 53201016ad83Smrg# $sharedlib_from_linklib_cmd 53211016ad83Smrg# Result is available in the variable 53221016ad83Smrg# $sharedlib_from_linklib_result 53231016ad83Smrgfunc_cygming_dll_for_implib_fallback () 53241016ad83Smrg{ 53257204935cSmrg $debug_cmd 53267204935cSmrg 53277204935cSmrg if func_cygming_gnu_implib_p "$1"; then 53281016ad83Smrg # binutils import library 53291016ad83Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53307204935cSmrg elif func_cygming_ms_implib_p "$1"; then 53311016ad83Smrg # ms-generated import library 53321016ad83Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 53331016ad83Smrg else 53341016ad83Smrg # unknown 53357204935cSmrg sharedlib_from_linklib_result= 53361016ad83Smrg fi 53371016ad83Smrg} 53381016ad83Smrg 53391016ad83Smrg 53401016ad83Smrg# func_extract_an_archive dir oldlib 53411016ad83Smrgfunc_extract_an_archive () 53421016ad83Smrg{ 53437204935cSmrg $debug_cmd 53447204935cSmrg 53457204935cSmrg f_ex_an_ar_dir=$1; shift 53467204935cSmrg f_ex_an_ar_oldlib=$1 53477204935cSmrg if test yes = "$lock_old_archive_extraction"; then 53481016ad83Smrg lockfile=$f_ex_an_ar_oldlib.lock 53491016ad83Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 53501016ad83Smrg func_echo "Waiting for $lockfile to be removed" 53511016ad83Smrg sleep 2 53521016ad83Smrg done 53531016ad83Smrg fi 53541016ad83Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 53551016ad83Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53567204935cSmrg if test yes = "$lock_old_archive_extraction"; then 53571016ad83Smrg $opt_dry_run || rm -f "$lockfile" 53581016ad83Smrg fi 53591016ad83Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 53601016ad83Smrg : 53611016ad83Smrg else 53621016ad83Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 53631016ad83Smrg fi 53641016ad83Smrg} 53651016ad83Smrg 53661016ad83Smrg 53671016ad83Smrg# func_extract_archives gentop oldlib ... 53681016ad83Smrgfunc_extract_archives () 53691016ad83Smrg{ 53707204935cSmrg $debug_cmd 53717204935cSmrg 53727204935cSmrg my_gentop=$1; shift 53731016ad83Smrg my_oldlibs=${1+"$@"} 53747204935cSmrg my_oldobjs= 53757204935cSmrg my_xlib= 53767204935cSmrg my_xabs= 53777204935cSmrg my_xdir= 53781016ad83Smrg 53791016ad83Smrg for my_xlib in $my_oldlibs; do 53801016ad83Smrg # Extract the objects. 53811016ad83Smrg case $my_xlib in 53827204935cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 53831016ad83Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 53841016ad83Smrg esac 53851016ad83Smrg func_basename "$my_xlib" 53867204935cSmrg my_xlib=$func_basename_result 53871016ad83Smrg my_xlib_u=$my_xlib 53881016ad83Smrg while :; do 53891016ad83Smrg case " $extracted_archives " in 53901016ad83Smrg *" $my_xlib_u "*) 53911016ad83Smrg func_arith $extracted_serial + 1 53921016ad83Smrg extracted_serial=$func_arith_result 53931016ad83Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 53941016ad83Smrg *) break ;; 53951016ad83Smrg esac 53961016ad83Smrg done 53971016ad83Smrg extracted_archives="$extracted_archives $my_xlib_u" 53987204935cSmrg my_xdir=$my_gentop/$my_xlib_u 53991016ad83Smrg 54001016ad83Smrg func_mkdir_p "$my_xdir" 54011016ad83Smrg 54021016ad83Smrg case $host in 54031016ad83Smrg *-darwin*) 54041016ad83Smrg func_verbose "Extracting $my_xabs" 54051016ad83Smrg # Do not bother doing anything if just a dry run 54061016ad83Smrg $opt_dry_run || { 54071016ad83Smrg darwin_orig_dir=`pwd` 54081016ad83Smrg cd $my_xdir || exit $? 54091016ad83Smrg darwin_archive=$my_xabs 54101016ad83Smrg darwin_curdir=`pwd` 54117204935cSmrg func_basename "$darwin_archive" 54127204935cSmrg darwin_base_archive=$func_basename_result 54131016ad83Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 54141016ad83Smrg if test -n "$darwin_arches"; then 54151016ad83Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 54161016ad83Smrg darwin_arch= 54171016ad83Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54187204935cSmrg for darwin_arch in $darwin_arches; do 54197204935cSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54207204935cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54217204935cSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54227204935cSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 54231016ad83Smrg cd "$darwin_curdir" 54247204935cSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 54251016ad83Smrg done # $darwin_arches 54261016ad83Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54277204935cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 54281016ad83Smrg darwin_file= 54291016ad83Smrg darwin_files= 54301016ad83Smrg for darwin_file in $darwin_filelist; do 54311016ad83Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 54321016ad83Smrg $LIPO -create -output "$darwin_file" $darwin_files 54331016ad83Smrg done # $darwin_filelist 54341016ad83Smrg $RM -rf unfat-$$ 54351016ad83Smrg cd "$darwin_orig_dir" 54361016ad83Smrg else 54371016ad83Smrg cd $darwin_orig_dir 54381016ad83Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54391016ad83Smrg fi # $darwin_arches 54401016ad83Smrg } # !$opt_dry_run 54411016ad83Smrg ;; 54421016ad83Smrg *) 54431016ad83Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54441016ad83Smrg ;; 54451016ad83Smrg esac 54461016ad83Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 54471016ad83Smrg done 54481016ad83Smrg 54497204935cSmrg func_extract_archives_result=$my_oldobjs 54501016ad83Smrg} 54511016ad83Smrg 54521016ad83Smrg 54531016ad83Smrg# func_emit_wrapper [arg=no] 54541016ad83Smrg# 54551016ad83Smrg# Emit a libtool wrapper script on stdout. 54561016ad83Smrg# Don't directly open a file because we may want to 54571016ad83Smrg# incorporate the script contents within a cygwin/mingw 54581016ad83Smrg# wrapper executable. Must ONLY be called from within 54591016ad83Smrg# func_mode_link because it depends on a number of variables 54601016ad83Smrg# set therein. 54611016ad83Smrg# 54621016ad83Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 54631016ad83Smrg# variable will take. If 'yes', then the emitted script 54647204935cSmrg# will assume that the directory where it is stored is 54651016ad83Smrg# the $objdir directory. This is a cygwin/mingw-specific 54661016ad83Smrg# behavior. 54671016ad83Smrgfunc_emit_wrapper () 54681016ad83Smrg{ 54691016ad83Smrg func_emit_wrapper_arg1=${1-no} 54701016ad83Smrg 54711016ad83Smrg $ECHO "\ 54721016ad83Smrg#! $SHELL 54731016ad83Smrg 54741016ad83Smrg# $output - temporary wrapper script for $objdir/$outputname 54757204935cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 54761016ad83Smrg# 54771016ad83Smrg# The $output program cannot be directly executed until all the libtool 54781016ad83Smrg# libraries that it depends on are installed. 54791016ad83Smrg# 54801016ad83Smrg# This wrapper script should never be moved out of the build directory. 54811016ad83Smrg# If it is, it will not operate correctly. 54821016ad83Smrg 54831016ad83Smrg# Sed substitution that helps us do robust quoting. It backslashifies 54841016ad83Smrg# metacharacters that are still active within double-quoted strings. 54851016ad83Smrgsed_quote_subst='$sed_quote_subst' 54861016ad83Smrg 54871016ad83Smrg# Be Bourne compatible 54881016ad83Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 54891016ad83Smrg emulate sh 54901016ad83Smrg NULLCMD=: 54911016ad83Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 54921016ad83Smrg # is contrary to our usage. Disable this feature. 54931016ad83Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 54941016ad83Smrg setopt NO_GLOB_SUBST 54951016ad83Smrgelse 54961016ad83Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 54971016ad83Smrgfi 54981016ad83SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 54991016ad83SmrgDUALCASE=1; export DUALCASE # for MKS sh 55001016ad83Smrg 55011016ad83Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 55021016ad83Smrg# if CDPATH is set. 55031016ad83Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55041016ad83Smrg 55051016ad83Smrgrelink_command=\"$relink_command\" 55061016ad83Smrg 55071016ad83Smrg# This environment variable determines our operation mode. 55081016ad83Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 55091016ad83Smrg # install mode needs the following variables: 55101016ad83Smrg generated_by_libtool_version='$macro_version' 55111016ad83Smrg notinst_deplibs='$notinst_deplibs' 55121016ad83Smrgelse 55131016ad83Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 55141016ad83Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 55151016ad83Smrg file=\"\$0\"" 55161016ad83Smrg 5517b9526c6aSmrg func_quote_arg pretty "$ECHO" 5518b9526c6aSmrg qECHO=$func_quote_arg_result 55191016ad83Smrg $ECHO "\ 55201016ad83Smrg 55211016ad83Smrg# A function that is used when there is no print builtin or printf. 55221016ad83Smrgfunc_fallback_echo () 55231016ad83Smrg{ 55241016ad83Smrg eval 'cat <<_LTECHO_EOF 55251016ad83Smrg\$1 55261016ad83Smrg_LTECHO_EOF' 55271016ad83Smrg} 5528b9526c6aSmrg ECHO=$qECHO 55291016ad83Smrg fi 55301016ad83Smrg 55311016ad83Smrg# Very basic option parsing. These options are (a) specific to 55321016ad83Smrg# the libtool wrapper, (b) are identical between the wrapper 55337204935cSmrg# /script/ and the wrapper /executable/ that is used only on 55341016ad83Smrg# windows platforms, and (c) all begin with the string "--lt-" 55357204935cSmrg# (application programs are unlikely to have options that match 55361016ad83Smrg# this pattern). 55371016ad83Smrg# 55381016ad83Smrg# There are only two supported options: --lt-debug and 55391016ad83Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 55401016ad83Smrg# 55411016ad83Smrg# The first argument to this parsing function should be the 55421016ad83Smrg# script's $0 value, followed by "$@". 55431016ad83Smrglt_option_debug= 55441016ad83Smrgfunc_parse_lt_options () 55451016ad83Smrg{ 55461016ad83Smrg lt_script_arg0=\$0 55471016ad83Smrg shift 55481016ad83Smrg for lt_opt 55491016ad83Smrg do 55501016ad83Smrg case \"\$lt_opt\" in 55511016ad83Smrg --lt-debug) lt_option_debug=1 ;; 55521016ad83Smrg --lt-dump-script) 55531016ad83Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 55541016ad83Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 55551016ad83Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 55561016ad83Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 55571016ad83Smrg exit 0 55581016ad83Smrg ;; 55591016ad83Smrg --lt-*) 55601016ad83Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 55611016ad83Smrg exit 1 55621016ad83Smrg ;; 55631016ad83Smrg esac 55641016ad83Smrg done 55651016ad83Smrg 55661016ad83Smrg # Print the debug banner immediately: 55671016ad83Smrg if test -n \"\$lt_option_debug\"; then 55687204935cSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 55691016ad83Smrg fi 55701016ad83Smrg} 55711016ad83Smrg 55721016ad83Smrg# Used when --lt-debug. Prints its arguments to stdout 55731016ad83Smrg# (redirection is the responsibility of the caller) 55741016ad83Smrgfunc_lt_dump_args () 55751016ad83Smrg{ 55761016ad83Smrg lt_dump_args_N=1; 55771016ad83Smrg for lt_arg 55781016ad83Smrg do 55797204935cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 55801016ad83Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 55811016ad83Smrg done 55821016ad83Smrg} 55831016ad83Smrg 55841016ad83Smrg# Core function for launching the target application 55851016ad83Smrgfunc_exec_program_core () 55861016ad83Smrg{ 55871016ad83Smrg" 55881016ad83Smrg case $host in 55891016ad83Smrg # Backslashes separate directories on plain windows 55901016ad83Smrg *-*-mingw | *-*-os2* | *-cegcc*) 55911016ad83Smrg $ECHO "\ 55921016ad83Smrg if test -n \"\$lt_option_debug\"; then 55937204935cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 55941016ad83Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55951016ad83Smrg fi 55961016ad83Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 55971016ad83Smrg" 55981016ad83Smrg ;; 55991016ad83Smrg 56001016ad83Smrg *) 56011016ad83Smrg $ECHO "\ 56021016ad83Smrg if test -n \"\$lt_option_debug\"; then 56037204935cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 56041016ad83Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 56051016ad83Smrg fi 56061016ad83Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 56071016ad83Smrg" 56081016ad83Smrg ;; 56091016ad83Smrg esac 56101016ad83Smrg $ECHO "\ 56111016ad83Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 56121016ad83Smrg exit 1 56131016ad83Smrg} 56141016ad83Smrg 56151016ad83Smrg# A function to encapsulate launching the target application 56161016ad83Smrg# Strips options in the --lt-* namespace from \$@ and 56171016ad83Smrg# launches target application with the remaining arguments. 56181016ad83Smrgfunc_exec_program () 56191016ad83Smrg{ 56201016ad83Smrg case \" \$* \" in 56211016ad83Smrg *\\ --lt-*) 56221016ad83Smrg for lt_wr_arg 56231016ad83Smrg do 56241016ad83Smrg case \$lt_wr_arg in 56251016ad83Smrg --lt-*) ;; 56261016ad83Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56271016ad83Smrg esac 56281016ad83Smrg shift 56291016ad83Smrg done ;; 56301016ad83Smrg esac 56311016ad83Smrg func_exec_program_core \${1+\"\$@\"} 56321016ad83Smrg} 56331016ad83Smrg 56341016ad83Smrg # Parse options 56351016ad83Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56361016ad83Smrg 56371016ad83Smrg # Find the directory that this script lives in. 56381016ad83Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 56391016ad83Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56401016ad83Smrg 56411016ad83Smrg # Follow symbolic links until we get to the real thisdir. 56421016ad83Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 56431016ad83Smrg while test -n \"\$file\"; do 56441016ad83Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56451016ad83Smrg 56461016ad83Smrg # If there was a directory component, then change thisdir. 56471016ad83Smrg if test \"x\$destdir\" != \"x\$file\"; then 56481016ad83Smrg case \"\$destdir\" in 56491016ad83Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 56501016ad83Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 56511016ad83Smrg esac 56521016ad83Smrg fi 56531016ad83Smrg 56541016ad83Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 56551016ad83Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 56561016ad83Smrg done 56571016ad83Smrg 56581016ad83Smrg # Usually 'no', except on cygwin/mingw when embedded into 56591016ad83Smrg # the cwrapper. 56601016ad83Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 56611016ad83Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 56621016ad83Smrg # special case for '.' 56631016ad83Smrg if test \"\$thisdir\" = \".\"; then 56641016ad83Smrg thisdir=\`pwd\` 56651016ad83Smrg fi 56661016ad83Smrg # remove .libs from thisdir 56671016ad83Smrg case \"\$thisdir\" in 56681016ad83Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 56691016ad83Smrg $objdir ) thisdir=. ;; 56701016ad83Smrg esac 56711016ad83Smrg fi 56721016ad83Smrg 56731016ad83Smrg # Try to get the absolute directory name. 56741016ad83Smrg absdir=\`cd \"\$thisdir\" && pwd\` 56751016ad83Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 56761016ad83Smrg" 56771016ad83Smrg 56787204935cSmrg if test yes = "$fast_install"; then 56791016ad83Smrg $ECHO "\ 56801016ad83Smrg program=lt-'$outputname'$exeext 56811016ad83Smrg progdir=\"\$thisdir/$objdir\" 56821016ad83Smrg 56831016ad83Smrg if test ! -f \"\$progdir/\$program\" || 56847204935cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 56851016ad83Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56861016ad83Smrg 56871016ad83Smrg file=\"\$\$-\$program\" 56881016ad83Smrg 56891016ad83Smrg if test ! -d \"\$progdir\"; then 56901016ad83Smrg $MKDIR \"\$progdir\" 56911016ad83Smrg else 56921016ad83Smrg $RM \"\$progdir/\$file\" 56931016ad83Smrg fi" 56941016ad83Smrg 56951016ad83Smrg $ECHO "\ 56961016ad83Smrg 56971016ad83Smrg # relink executable if necessary 56981016ad83Smrg if test -n \"\$relink_command\"; then 56991016ad83Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 57001016ad83Smrg else 57017204935cSmrg \$ECHO \"\$relink_command_output\" >&2 57021016ad83Smrg $RM \"\$progdir/\$file\" 57031016ad83Smrg exit 1 57041016ad83Smrg fi 57051016ad83Smrg fi 57061016ad83Smrg 57071016ad83Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 57081016ad83Smrg { $RM \"\$progdir/\$program\"; 57091016ad83Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 57101016ad83Smrg $RM \"\$progdir/\$file\" 57111016ad83Smrg fi" 57121016ad83Smrg else 57131016ad83Smrg $ECHO "\ 57141016ad83Smrg program='$outputname' 57151016ad83Smrg progdir=\"\$thisdir/$objdir\" 57161016ad83Smrg" 57171016ad83Smrg fi 57181016ad83Smrg 57191016ad83Smrg $ECHO "\ 57201016ad83Smrg 57211016ad83Smrg if test -f \"\$progdir/\$program\"; then" 57221016ad83Smrg 57231016ad83Smrg # fixup the dll searchpath if we need to. 57241016ad83Smrg # 57251016ad83Smrg # Fix the DLL searchpath if we need to. Do this before prepending 57261016ad83Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 57271016ad83Smrg # libraries must come first. 57281016ad83Smrg if test -n "$dllsearchpath"; then 57291016ad83Smrg $ECHO "\ 57301016ad83Smrg # Add the dll search path components to the executable PATH 57311016ad83Smrg PATH=$dllsearchpath:\$PATH 57321016ad83Smrg" 57331016ad83Smrg fi 57341016ad83Smrg 57351016ad83Smrg # Export our shlibpath_var if we have one. 57367204935cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 57371016ad83Smrg $ECHO "\ 57381016ad83Smrg # Add our own library path to $shlibpath_var 57391016ad83Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57401016ad83Smrg 57411016ad83Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 57421016ad83Smrg # The second colon is a workaround for a bug in BeOS R4 sed 57431016ad83Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57441016ad83Smrg 57451016ad83Smrg export $shlibpath_var 57461016ad83Smrg" 57471016ad83Smrg fi 57481016ad83Smrg 57491016ad83Smrg $ECHO "\ 57501016ad83Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 57511016ad83Smrg # Run the actual program with our arguments. 57521016ad83Smrg func_exec_program \${1+\"\$@\"} 57531016ad83Smrg fi 57541016ad83Smrg else 57551016ad83Smrg # The program doesn't exist. 57567204935cSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 57571016ad83Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 57581016ad83Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 57591016ad83Smrg exit 1 57601016ad83Smrg fi 57611016ad83Smrgfi\ 57621016ad83Smrg" 57631016ad83Smrg} 57641016ad83Smrg 57651016ad83Smrg 57661016ad83Smrg# func_emit_cwrapperexe_src 57671016ad83Smrg# emit the source code for a wrapper executable on stdout 57681016ad83Smrg# Must ONLY be called from within func_mode_link because 57691016ad83Smrg# it depends on a number of variable set therein. 57701016ad83Smrgfunc_emit_cwrapperexe_src () 57711016ad83Smrg{ 57721016ad83Smrg cat <<EOF 57731016ad83Smrg 57741016ad83Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57757204935cSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57761016ad83Smrg 57771016ad83Smrg The $output program cannot be directly executed until all the libtool 57781016ad83Smrg libraries that it depends on are installed. 57791016ad83Smrg 57801016ad83Smrg This wrapper executable should never be moved out of the build directory. 57811016ad83Smrg If it is, it will not operate correctly. 57821016ad83Smrg*/ 57831016ad83SmrgEOF 57841016ad83Smrg cat <<"EOF" 57851016ad83Smrg#ifdef _MSC_VER 57861016ad83Smrg# define _CRT_SECURE_NO_DEPRECATE 1 57871016ad83Smrg#endif 57881016ad83Smrg#include <stdio.h> 57891016ad83Smrg#include <stdlib.h> 57901016ad83Smrg#ifdef _MSC_VER 57911016ad83Smrg# include <direct.h> 57921016ad83Smrg# include <process.h> 57931016ad83Smrg# include <io.h> 57941016ad83Smrg#else 57951016ad83Smrg# include <unistd.h> 57961016ad83Smrg# include <stdint.h> 57971016ad83Smrg# ifdef __CYGWIN__ 57981016ad83Smrg# include <io.h> 57991016ad83Smrg# endif 58001016ad83Smrg#endif 58011016ad83Smrg#include <malloc.h> 58021016ad83Smrg#include <stdarg.h> 58031016ad83Smrg#include <assert.h> 58041016ad83Smrg#include <string.h> 58051016ad83Smrg#include <ctype.h> 58061016ad83Smrg#include <errno.h> 58071016ad83Smrg#include <fcntl.h> 58081016ad83Smrg#include <sys/stat.h> 58091016ad83Smrg 58107204935cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58117204935cSmrg 58121016ad83Smrg/* declarations of non-ANSI functions */ 58137204935cSmrg#if defined __MINGW32__ 58141016ad83Smrg# ifdef __STRICT_ANSI__ 58151016ad83Smrgint _putenv (const char *); 58161016ad83Smrg# endif 58177204935cSmrg#elif defined __CYGWIN__ 58181016ad83Smrg# ifdef __STRICT_ANSI__ 58191016ad83Smrgchar *realpath (const char *, char *); 58201016ad83Smrgint putenv (char *); 58211016ad83Smrgint setenv (const char *, const char *, int); 58221016ad83Smrg# endif 58237204935cSmrg/* #elif defined other_platform || defined ... */ 58241016ad83Smrg#endif 58251016ad83Smrg 58261016ad83Smrg/* portability defines, excluding path handling macros */ 58277204935cSmrg#if defined _MSC_VER 58281016ad83Smrg# define setmode _setmode 58291016ad83Smrg# define stat _stat 58301016ad83Smrg# define chmod _chmod 58311016ad83Smrg# define getcwd _getcwd 58321016ad83Smrg# define putenv _putenv 58331016ad83Smrg# define S_IXUSR _S_IEXEC 58347204935cSmrg#elif defined __MINGW32__ 58351016ad83Smrg# define setmode _setmode 58361016ad83Smrg# define stat _stat 58371016ad83Smrg# define chmod _chmod 58381016ad83Smrg# define getcwd _getcwd 58391016ad83Smrg# define putenv _putenv 58407204935cSmrg#elif defined __CYGWIN__ 58411016ad83Smrg# define HAVE_SETENV 58421016ad83Smrg# define FOPEN_WB "wb" 58437204935cSmrg/* #elif defined other platforms ... */ 58441016ad83Smrg#endif 58451016ad83Smrg 58467204935cSmrg#if defined PATH_MAX 58471016ad83Smrg# define LT_PATHMAX PATH_MAX 58487204935cSmrg#elif defined MAXPATHLEN 58491016ad83Smrg# define LT_PATHMAX MAXPATHLEN 58501016ad83Smrg#else 58511016ad83Smrg# define LT_PATHMAX 1024 58521016ad83Smrg#endif 58531016ad83Smrg 58541016ad83Smrg#ifndef S_IXOTH 58551016ad83Smrg# define S_IXOTH 0 58561016ad83Smrg#endif 58571016ad83Smrg#ifndef S_IXGRP 58581016ad83Smrg# define S_IXGRP 0 58591016ad83Smrg#endif 58601016ad83Smrg 58611016ad83Smrg/* path handling portability macros */ 58621016ad83Smrg#ifndef DIR_SEPARATOR 58631016ad83Smrg# define DIR_SEPARATOR '/' 58641016ad83Smrg# define PATH_SEPARATOR ':' 58651016ad83Smrg#endif 58661016ad83Smrg 58677204935cSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58687204935cSmrg defined __OS2__ 58691016ad83Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 58701016ad83Smrg# define FOPEN_WB "wb" 58711016ad83Smrg# ifndef DIR_SEPARATOR_2 58721016ad83Smrg# define DIR_SEPARATOR_2 '\\' 58731016ad83Smrg# endif 58741016ad83Smrg# ifndef PATH_SEPARATOR_2 58751016ad83Smrg# define PATH_SEPARATOR_2 ';' 58761016ad83Smrg# endif 58771016ad83Smrg#endif 58781016ad83Smrg 58791016ad83Smrg#ifndef DIR_SEPARATOR_2 58801016ad83Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 58811016ad83Smrg#else /* DIR_SEPARATOR_2 */ 58821016ad83Smrg# define IS_DIR_SEPARATOR(ch) \ 58831016ad83Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 58841016ad83Smrg#endif /* DIR_SEPARATOR_2 */ 58851016ad83Smrg 58861016ad83Smrg#ifndef PATH_SEPARATOR_2 58871016ad83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 58881016ad83Smrg#else /* PATH_SEPARATOR_2 */ 58891016ad83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 58901016ad83Smrg#endif /* PATH_SEPARATOR_2 */ 58911016ad83Smrg 58921016ad83Smrg#ifndef FOPEN_WB 58931016ad83Smrg# define FOPEN_WB "w" 58941016ad83Smrg#endif 58951016ad83Smrg#ifndef _O_BINARY 58961016ad83Smrg# define _O_BINARY 0 58971016ad83Smrg#endif 58981016ad83Smrg 58991016ad83Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 59001016ad83Smrg#define XFREE(stale) do { \ 59017204935cSmrg if (stale) { free (stale); stale = 0; } \ 59021016ad83Smrg} while (0) 59031016ad83Smrg 59047204935cSmrg#if defined LT_DEBUGWRAPPER 59051016ad83Smrgstatic int lt_debug = 1; 59061016ad83Smrg#else 59071016ad83Smrgstatic int lt_debug = 0; 59081016ad83Smrg#endif 59091016ad83Smrg 59101016ad83Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 59111016ad83Smrg 59121016ad83Smrgvoid *xmalloc (size_t num); 59131016ad83Smrgchar *xstrdup (const char *string); 59141016ad83Smrgconst char *base_name (const char *name); 59151016ad83Smrgchar *find_executable (const char *wrapper); 59161016ad83Smrgchar *chase_symlinks (const char *pathspec); 59171016ad83Smrgint make_executable (const char *path); 59181016ad83Smrgint check_executable (const char *path); 59191016ad83Smrgchar *strendzap (char *str, const char *pat); 59201016ad83Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 59211016ad83Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 59221016ad83Smrgstatic const char *nonnull (const char *s); 59231016ad83Smrgstatic const char *nonempty (const char *s); 59241016ad83Smrgvoid lt_setenv (const char *name, const char *value); 59251016ad83Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 59261016ad83Smrgvoid lt_update_exe_path (const char *name, const char *value); 59271016ad83Smrgvoid lt_update_lib_path (const char *name, const char *value); 59281016ad83Smrgchar **prepare_spawn (char **argv); 59291016ad83Smrgvoid lt_dump_script (FILE *f); 59301016ad83SmrgEOF 59311016ad83Smrg 59321016ad83Smrg cat <<EOF 59337204935cSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59347204935cSmrg# define externally_visible volatile 59357204935cSmrg#else 59367204935cSmrg# define externally_visible __attribute__((externally_visible)) volatile 59377204935cSmrg#endif 59387204935cSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 59391016ad83Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 59401016ad83SmrgEOF 59411016ad83Smrg 59427204935cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 59431016ad83Smrg func_to_host_path "$temp_rpath" 59441016ad83Smrg cat <<EOF 59451016ad83Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59461016ad83SmrgEOF 59471016ad83Smrg else 59481016ad83Smrg cat <<"EOF" 59491016ad83Smrgconst char * LIB_PATH_VALUE = ""; 59501016ad83SmrgEOF 59511016ad83Smrg fi 59521016ad83Smrg 59531016ad83Smrg if test -n "$dllsearchpath"; then 59541016ad83Smrg func_to_host_path "$dllsearchpath:" 59551016ad83Smrg cat <<EOF 59561016ad83Smrgconst char * EXE_PATH_VARNAME = "PATH"; 59571016ad83Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 59581016ad83SmrgEOF 59591016ad83Smrg else 59601016ad83Smrg cat <<"EOF" 59611016ad83Smrgconst char * EXE_PATH_VARNAME = ""; 59621016ad83Smrgconst char * EXE_PATH_VALUE = ""; 59631016ad83SmrgEOF 59641016ad83Smrg fi 59651016ad83Smrg 59667204935cSmrg if test yes = "$fast_install"; then 59671016ad83Smrg cat <<EOF 59681016ad83Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 59691016ad83SmrgEOF 59701016ad83Smrg else 59711016ad83Smrg cat <<EOF 59721016ad83Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 59731016ad83SmrgEOF 59741016ad83Smrg fi 59751016ad83Smrg 59761016ad83Smrg 59771016ad83Smrg cat <<"EOF" 59781016ad83Smrg 59791016ad83Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59801016ad83Smrg 59811016ad83Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 59821016ad83Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 59831016ad83Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59841016ad83Smrg 59851016ad83Smrgint 59861016ad83Smrgmain (int argc, char *argv[]) 59871016ad83Smrg{ 59881016ad83Smrg char **newargz; 59891016ad83Smrg int newargc; 59901016ad83Smrg char *tmp_pathspec; 59911016ad83Smrg char *actual_cwrapper_path; 59921016ad83Smrg char *actual_cwrapper_name; 59931016ad83Smrg char *target_name; 59941016ad83Smrg char *lt_argv_zero; 59957204935cSmrg int rval = 127; 59961016ad83Smrg 59971016ad83Smrg int i; 59981016ad83Smrg 59991016ad83Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60007204935cSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 60011016ad83Smrg 60021016ad83Smrg /* very simple arg parsing; don't want to rely on getopt 60031016ad83Smrg * also, copy all non cwrapper options to newargz, except 60041016ad83Smrg * argz[0], which is handled differently 60051016ad83Smrg */ 60061016ad83Smrg newargc=0; 60071016ad83Smrg for (i = 1; i < argc; i++) 60081016ad83Smrg { 60097204935cSmrg if (STREQ (argv[i], dumpscript_opt)) 60101016ad83Smrg { 60111016ad83SmrgEOF 60127204935cSmrg case $host in 60131016ad83Smrg *mingw* | *cygwin* ) 60141016ad83Smrg # make stdout use "unix" line endings 60151016ad83Smrg echo " setmode(1,_O_BINARY);" 60161016ad83Smrg ;; 60171016ad83Smrg esac 60181016ad83Smrg 60191016ad83Smrg cat <<"EOF" 60201016ad83Smrg lt_dump_script (stdout); 60211016ad83Smrg return 0; 60221016ad83Smrg } 60237204935cSmrg if (STREQ (argv[i], debug_opt)) 60241016ad83Smrg { 60251016ad83Smrg lt_debug = 1; 60261016ad83Smrg continue; 60271016ad83Smrg } 60287204935cSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 60291016ad83Smrg { 60301016ad83Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 60311016ad83Smrg namespace, but it is not one of the ones we know about and 60321016ad83Smrg have already dealt with, above (inluding dump-script), then 60331016ad83Smrg report an error. Otherwise, targets might begin to believe 60341016ad83Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 60351016ad83Smrg namespace. The first time any user complains about this, we'll 60361016ad83Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 60371016ad83Smrg or a configure.ac-settable value. 60381016ad83Smrg */ 60391016ad83Smrg lt_fatal (__FILE__, __LINE__, 60401016ad83Smrg "unrecognized %s option: '%s'", 60411016ad83Smrg ltwrapper_option_prefix, argv[i]); 60421016ad83Smrg } 60431016ad83Smrg /* otherwise ... */ 60441016ad83Smrg newargz[++newargc] = xstrdup (argv[i]); 60451016ad83Smrg } 60461016ad83Smrg newargz[++newargc] = NULL; 60471016ad83Smrg 60481016ad83SmrgEOF 60491016ad83Smrg cat <<EOF 60501016ad83Smrg /* The GNU banner must be the first non-error debug message */ 60517204935cSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 60521016ad83SmrgEOF 60531016ad83Smrg cat <<"EOF" 60541016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 60551016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 60561016ad83Smrg 60571016ad83Smrg tmp_pathspec = find_executable (argv[0]); 60581016ad83Smrg if (tmp_pathspec == NULL) 60591016ad83Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 60601016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 60611016ad83Smrg "(main) found exe (before symlink chase) at: %s\n", 60621016ad83Smrg tmp_pathspec); 60631016ad83Smrg 60641016ad83Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 60651016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 60661016ad83Smrg "(main) found exe (after symlink chase) at: %s\n", 60671016ad83Smrg actual_cwrapper_path); 60681016ad83Smrg XFREE (tmp_pathspec); 60691016ad83Smrg 60701016ad83Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 60711016ad83Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 60721016ad83Smrg 60731016ad83Smrg /* wrapper name transforms */ 60741016ad83Smrg strendzap (actual_cwrapper_name, ".exe"); 60751016ad83Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 60761016ad83Smrg XFREE (actual_cwrapper_name); 60771016ad83Smrg actual_cwrapper_name = tmp_pathspec; 60781016ad83Smrg tmp_pathspec = 0; 60791016ad83Smrg 60801016ad83Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 60811016ad83Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 60821016ad83Smrg strendzap (target_name, ".exe"); 60831016ad83Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 60841016ad83Smrg XFREE (target_name); 60851016ad83Smrg target_name = tmp_pathspec; 60861016ad83Smrg tmp_pathspec = 0; 60871016ad83Smrg 60881016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 60891016ad83Smrg "(main) libtool target name: %s\n", 60901016ad83Smrg target_name); 60911016ad83SmrgEOF 60921016ad83Smrg 60931016ad83Smrg cat <<EOF 60941016ad83Smrg newargz[0] = 60951016ad83Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 60961016ad83Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 60971016ad83Smrg strcpy (newargz[0], actual_cwrapper_path); 60981016ad83Smrg strcat (newargz[0], "$objdir"); 60991016ad83Smrg strcat (newargz[0], "/"); 61001016ad83SmrgEOF 61011016ad83Smrg 61021016ad83Smrg cat <<"EOF" 61031016ad83Smrg /* stop here, and copy so we don't have to do this twice */ 61041016ad83Smrg tmp_pathspec = xstrdup (newargz[0]); 61051016ad83Smrg 61061016ad83Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 61071016ad83Smrg strcat (newargz[0], actual_cwrapper_name); 61081016ad83Smrg 61091016ad83Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 61101016ad83Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 61111016ad83Smrg XFREE (tmp_pathspec); 61121016ad83Smrg tmp_pathspec = NULL; 61131016ad83SmrgEOF 61141016ad83Smrg 61151016ad83Smrg case $host_os in 61161016ad83Smrg mingw*) 61171016ad83Smrg cat <<"EOF" 61181016ad83Smrg { 61191016ad83Smrg char* p; 61201016ad83Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 61211016ad83Smrg { 61221016ad83Smrg *p = '/'; 61231016ad83Smrg } 61241016ad83Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 61251016ad83Smrg { 61261016ad83Smrg *p = '/'; 61271016ad83Smrg } 61281016ad83Smrg } 61291016ad83SmrgEOF 61301016ad83Smrg ;; 61311016ad83Smrg esac 61321016ad83Smrg 61331016ad83Smrg cat <<"EOF" 61341016ad83Smrg XFREE (target_name); 61351016ad83Smrg XFREE (actual_cwrapper_path); 61361016ad83Smrg XFREE (actual_cwrapper_name); 61371016ad83Smrg 61381016ad83Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 61391016ad83Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 61401016ad83Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 61411016ad83Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 61421016ad83Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 61431016ad83Smrg libraries must come first. */ 61441016ad83Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 61451016ad83Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61461016ad83Smrg 61471016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 61481016ad83Smrg nonnull (lt_argv_zero)); 61491016ad83Smrg for (i = 0; i < newargc; i++) 61501016ad83Smrg { 61511016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 61521016ad83Smrg i, nonnull (newargz[i])); 61531016ad83Smrg } 61541016ad83Smrg 61551016ad83SmrgEOF 61561016ad83Smrg 61571016ad83Smrg case $host_os in 61581016ad83Smrg mingw*) 61591016ad83Smrg cat <<"EOF" 61601016ad83Smrg /* execv doesn't actually work on mingw as expected on unix */ 61611016ad83Smrg newargz = prepare_spawn (newargz); 61627204935cSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 61631016ad83Smrg if (rval == -1) 61641016ad83Smrg { 61651016ad83Smrg /* failed to start process */ 61661016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 61671016ad83Smrg "(main) failed to launch target \"%s\": %s\n", 61681016ad83Smrg lt_argv_zero, nonnull (strerror (errno))); 61691016ad83Smrg return 127; 61701016ad83Smrg } 61711016ad83Smrg return rval; 61721016ad83SmrgEOF 61731016ad83Smrg ;; 61741016ad83Smrg *) 61751016ad83Smrg cat <<"EOF" 61761016ad83Smrg execv (lt_argv_zero, newargz); 61771016ad83Smrg return rval; /* =127, but avoids unused variable warning */ 61781016ad83SmrgEOF 61791016ad83Smrg ;; 61801016ad83Smrg esac 61811016ad83Smrg 61821016ad83Smrg cat <<"EOF" 61831016ad83Smrg} 61841016ad83Smrg 61851016ad83Smrgvoid * 61861016ad83Smrgxmalloc (size_t num) 61871016ad83Smrg{ 61881016ad83Smrg void *p = (void *) malloc (num); 61891016ad83Smrg if (!p) 61901016ad83Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61911016ad83Smrg 61921016ad83Smrg return p; 61931016ad83Smrg} 61941016ad83Smrg 61951016ad83Smrgchar * 61961016ad83Smrgxstrdup (const char *string) 61971016ad83Smrg{ 61981016ad83Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 61991016ad83Smrg string) : NULL; 62001016ad83Smrg} 62011016ad83Smrg 62021016ad83Smrgconst char * 62031016ad83Smrgbase_name (const char *name) 62041016ad83Smrg{ 62051016ad83Smrg const char *base; 62061016ad83Smrg 62077204935cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62081016ad83Smrg /* Skip over the disk name in MSDOS pathnames. */ 62091016ad83Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 62101016ad83Smrg name += 2; 62111016ad83Smrg#endif 62121016ad83Smrg 62131016ad83Smrg for (base = name; *name; name++) 62141016ad83Smrg if (IS_DIR_SEPARATOR (*name)) 62151016ad83Smrg base = name + 1; 62161016ad83Smrg return base; 62171016ad83Smrg} 62181016ad83Smrg 62191016ad83Smrgint 62201016ad83Smrgcheck_executable (const char *path) 62211016ad83Smrg{ 62221016ad83Smrg struct stat st; 62231016ad83Smrg 62241016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 62251016ad83Smrg nonempty (path)); 62261016ad83Smrg if ((!path) || (!*path)) 62271016ad83Smrg return 0; 62281016ad83Smrg 62291016ad83Smrg if ((stat (path, &st) >= 0) 62301016ad83Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 62311016ad83Smrg return 1; 62321016ad83Smrg else 62331016ad83Smrg return 0; 62341016ad83Smrg} 62351016ad83Smrg 62361016ad83Smrgint 62371016ad83Smrgmake_executable (const char *path) 62381016ad83Smrg{ 62391016ad83Smrg int rval = 0; 62401016ad83Smrg struct stat st; 62411016ad83Smrg 62421016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 62431016ad83Smrg nonempty (path)); 62441016ad83Smrg if ((!path) || (!*path)) 62451016ad83Smrg return 0; 62461016ad83Smrg 62471016ad83Smrg if (stat (path, &st) >= 0) 62481016ad83Smrg { 62491016ad83Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 62501016ad83Smrg } 62511016ad83Smrg return rval; 62521016ad83Smrg} 62531016ad83Smrg 62541016ad83Smrg/* Searches for the full path of the wrapper. Returns 62551016ad83Smrg newly allocated full path name if found, NULL otherwise 62561016ad83Smrg Does not chase symlinks, even on platforms that support them. 62571016ad83Smrg*/ 62581016ad83Smrgchar * 62591016ad83Smrgfind_executable (const char *wrapper) 62601016ad83Smrg{ 62611016ad83Smrg int has_slash = 0; 62621016ad83Smrg const char *p; 62631016ad83Smrg const char *p_next; 62641016ad83Smrg /* static buffer for getcwd */ 62651016ad83Smrg char tmp[LT_PATHMAX + 1]; 62667204935cSmrg size_t tmp_len; 62671016ad83Smrg char *concat_name; 62681016ad83Smrg 62691016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 62701016ad83Smrg nonempty (wrapper)); 62711016ad83Smrg 62721016ad83Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 62731016ad83Smrg return NULL; 62741016ad83Smrg 62751016ad83Smrg /* Absolute path? */ 62767204935cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62771016ad83Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 62781016ad83Smrg { 62791016ad83Smrg concat_name = xstrdup (wrapper); 62801016ad83Smrg if (check_executable (concat_name)) 62811016ad83Smrg return concat_name; 62821016ad83Smrg XFREE (concat_name); 62831016ad83Smrg } 62841016ad83Smrg else 62851016ad83Smrg { 62861016ad83Smrg#endif 62871016ad83Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 62881016ad83Smrg { 62891016ad83Smrg concat_name = xstrdup (wrapper); 62901016ad83Smrg if (check_executable (concat_name)) 62911016ad83Smrg return concat_name; 62921016ad83Smrg XFREE (concat_name); 62931016ad83Smrg } 62947204935cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62951016ad83Smrg } 62961016ad83Smrg#endif 62971016ad83Smrg 62981016ad83Smrg for (p = wrapper; *p; p++) 62991016ad83Smrg if (*p == '/') 63001016ad83Smrg { 63011016ad83Smrg has_slash = 1; 63021016ad83Smrg break; 63031016ad83Smrg } 63041016ad83Smrg if (!has_slash) 63051016ad83Smrg { 63061016ad83Smrg /* no slashes; search PATH */ 63071016ad83Smrg const char *path = getenv ("PATH"); 63081016ad83Smrg if (path != NULL) 63091016ad83Smrg { 63101016ad83Smrg for (p = path; *p; p = p_next) 63111016ad83Smrg { 63121016ad83Smrg const char *q; 63131016ad83Smrg size_t p_len; 63141016ad83Smrg for (q = p; *q; q++) 63151016ad83Smrg if (IS_PATH_SEPARATOR (*q)) 63161016ad83Smrg break; 63177204935cSmrg p_len = (size_t) (q - p); 63181016ad83Smrg p_next = (*q == '\0' ? q : q + 1); 63191016ad83Smrg if (p_len == 0) 63201016ad83Smrg { 63211016ad83Smrg /* empty path: current directory */ 63221016ad83Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63231016ad83Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63241016ad83Smrg nonnull (strerror (errno))); 63251016ad83Smrg tmp_len = strlen (tmp); 63261016ad83Smrg concat_name = 63271016ad83Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63281016ad83Smrg memcpy (concat_name, tmp, tmp_len); 63291016ad83Smrg concat_name[tmp_len] = '/'; 63301016ad83Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63311016ad83Smrg } 63321016ad83Smrg else 63331016ad83Smrg { 63341016ad83Smrg concat_name = 63351016ad83Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 63361016ad83Smrg memcpy (concat_name, p, p_len); 63371016ad83Smrg concat_name[p_len] = '/'; 63381016ad83Smrg strcpy (concat_name + p_len + 1, wrapper); 63391016ad83Smrg } 63401016ad83Smrg if (check_executable (concat_name)) 63411016ad83Smrg return concat_name; 63421016ad83Smrg XFREE (concat_name); 63431016ad83Smrg } 63441016ad83Smrg } 63451016ad83Smrg /* not found in PATH; assume curdir */ 63461016ad83Smrg } 63471016ad83Smrg /* Relative path | not found in path: prepend cwd */ 63481016ad83Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63491016ad83Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63501016ad83Smrg nonnull (strerror (errno))); 63511016ad83Smrg tmp_len = strlen (tmp); 63521016ad83Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63531016ad83Smrg memcpy (concat_name, tmp, tmp_len); 63541016ad83Smrg concat_name[tmp_len] = '/'; 63551016ad83Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63561016ad83Smrg 63571016ad83Smrg if (check_executable (concat_name)) 63581016ad83Smrg return concat_name; 63591016ad83Smrg XFREE (concat_name); 63601016ad83Smrg return NULL; 63611016ad83Smrg} 63621016ad83Smrg 63631016ad83Smrgchar * 63641016ad83Smrgchase_symlinks (const char *pathspec) 63651016ad83Smrg{ 63661016ad83Smrg#ifndef S_ISLNK 63671016ad83Smrg return xstrdup (pathspec); 63681016ad83Smrg#else 63691016ad83Smrg char buf[LT_PATHMAX]; 63701016ad83Smrg struct stat s; 63711016ad83Smrg char *tmp_pathspec = xstrdup (pathspec); 63721016ad83Smrg char *p; 63731016ad83Smrg int has_symlinks = 0; 63741016ad83Smrg while (strlen (tmp_pathspec) && !has_symlinks) 63751016ad83Smrg { 63761016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 63771016ad83Smrg "checking path component for symlinks: %s\n", 63781016ad83Smrg tmp_pathspec); 63791016ad83Smrg if (lstat (tmp_pathspec, &s) == 0) 63801016ad83Smrg { 63811016ad83Smrg if (S_ISLNK (s.st_mode) != 0) 63821016ad83Smrg { 63831016ad83Smrg has_symlinks = 1; 63841016ad83Smrg break; 63851016ad83Smrg } 63861016ad83Smrg 63871016ad83Smrg /* search backwards for last DIR_SEPARATOR */ 63881016ad83Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 63891016ad83Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63901016ad83Smrg p--; 63911016ad83Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63921016ad83Smrg { 63931016ad83Smrg /* no more DIR_SEPARATORS left */ 63941016ad83Smrg break; 63951016ad83Smrg } 63961016ad83Smrg *p = '\0'; 63971016ad83Smrg } 63981016ad83Smrg else 63991016ad83Smrg { 64001016ad83Smrg lt_fatal (__FILE__, __LINE__, 64011016ad83Smrg "error accessing file \"%s\": %s", 64021016ad83Smrg tmp_pathspec, nonnull (strerror (errno))); 64031016ad83Smrg } 64041016ad83Smrg } 64051016ad83Smrg XFREE (tmp_pathspec); 64061016ad83Smrg 64071016ad83Smrg if (!has_symlinks) 64081016ad83Smrg { 64091016ad83Smrg return xstrdup (pathspec); 64101016ad83Smrg } 64111016ad83Smrg 64121016ad83Smrg tmp_pathspec = realpath (pathspec, buf); 64131016ad83Smrg if (tmp_pathspec == 0) 64141016ad83Smrg { 64151016ad83Smrg lt_fatal (__FILE__, __LINE__, 64161016ad83Smrg "could not follow symlinks for %s", pathspec); 64171016ad83Smrg } 64181016ad83Smrg return xstrdup (tmp_pathspec); 64191016ad83Smrg#endif 64201016ad83Smrg} 64211016ad83Smrg 64221016ad83Smrgchar * 64231016ad83Smrgstrendzap (char *str, const char *pat) 64241016ad83Smrg{ 64251016ad83Smrg size_t len, patlen; 64261016ad83Smrg 64271016ad83Smrg assert (str != NULL); 64281016ad83Smrg assert (pat != NULL); 64291016ad83Smrg 64301016ad83Smrg len = strlen (str); 64311016ad83Smrg patlen = strlen (pat); 64321016ad83Smrg 64331016ad83Smrg if (patlen <= len) 64341016ad83Smrg { 64351016ad83Smrg str += len - patlen; 64367204935cSmrg if (STREQ (str, pat)) 64371016ad83Smrg *str = '\0'; 64381016ad83Smrg } 64391016ad83Smrg return str; 64401016ad83Smrg} 64411016ad83Smrg 64421016ad83Smrgvoid 64431016ad83Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 64441016ad83Smrg{ 64451016ad83Smrg va_list args; 64461016ad83Smrg if (lt_debug) 64471016ad83Smrg { 64481016ad83Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 64491016ad83Smrg va_start (args, fmt); 64501016ad83Smrg (void) vfprintf (stderr, fmt, args); 64511016ad83Smrg va_end (args); 64521016ad83Smrg } 64531016ad83Smrg} 64541016ad83Smrg 64551016ad83Smrgstatic void 64561016ad83Smrglt_error_core (int exit_status, const char *file, 64571016ad83Smrg int line, const char *mode, 64581016ad83Smrg const char *message, va_list ap) 64591016ad83Smrg{ 64601016ad83Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 64611016ad83Smrg vfprintf (stderr, message, ap); 64621016ad83Smrg fprintf (stderr, ".\n"); 64631016ad83Smrg 64641016ad83Smrg if (exit_status >= 0) 64651016ad83Smrg exit (exit_status); 64661016ad83Smrg} 64671016ad83Smrg 64681016ad83Smrgvoid 64691016ad83Smrglt_fatal (const char *file, int line, const char *message, ...) 64701016ad83Smrg{ 64711016ad83Smrg va_list ap; 64721016ad83Smrg va_start (ap, message); 64731016ad83Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 64741016ad83Smrg va_end (ap); 64751016ad83Smrg} 64761016ad83Smrg 64771016ad83Smrgstatic const char * 64781016ad83Smrgnonnull (const char *s) 64791016ad83Smrg{ 64801016ad83Smrg return s ? s : "(null)"; 64811016ad83Smrg} 64821016ad83Smrg 64831016ad83Smrgstatic const char * 64841016ad83Smrgnonempty (const char *s) 64851016ad83Smrg{ 64861016ad83Smrg return (s && !*s) ? "(empty)" : nonnull (s); 64871016ad83Smrg} 64881016ad83Smrg 64891016ad83Smrgvoid 64901016ad83Smrglt_setenv (const char *name, const char *value) 64911016ad83Smrg{ 64921016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 64931016ad83Smrg "(lt_setenv) setting '%s' to '%s'\n", 64941016ad83Smrg nonnull (name), nonnull (value)); 64951016ad83Smrg { 64961016ad83Smrg#ifdef HAVE_SETENV 64971016ad83Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 64981016ad83Smrg char *str = xstrdup (value); 64991016ad83Smrg setenv (name, str, 1); 65001016ad83Smrg#else 65017204935cSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 65021016ad83Smrg char *str = XMALLOC (char, len); 65031016ad83Smrg sprintf (str, "%s=%s", name, value); 65041016ad83Smrg if (putenv (str) != EXIT_SUCCESS) 65051016ad83Smrg { 65061016ad83Smrg XFREE (str); 65071016ad83Smrg } 65081016ad83Smrg#endif 65091016ad83Smrg } 65101016ad83Smrg} 65111016ad83Smrg 65121016ad83Smrgchar * 65131016ad83Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 65141016ad83Smrg{ 65151016ad83Smrg char *new_value; 65161016ad83Smrg if (orig_value && *orig_value) 65171016ad83Smrg { 65187204935cSmrg size_t orig_value_len = strlen (orig_value); 65197204935cSmrg size_t add_len = strlen (add); 65201016ad83Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 65211016ad83Smrg if (to_end) 65221016ad83Smrg { 65231016ad83Smrg strcpy (new_value, orig_value); 65241016ad83Smrg strcpy (new_value + orig_value_len, add); 65251016ad83Smrg } 65261016ad83Smrg else 65271016ad83Smrg { 65281016ad83Smrg strcpy (new_value, add); 65291016ad83Smrg strcpy (new_value + add_len, orig_value); 65301016ad83Smrg } 65311016ad83Smrg } 65321016ad83Smrg else 65331016ad83Smrg { 65341016ad83Smrg new_value = xstrdup (add); 65351016ad83Smrg } 65361016ad83Smrg return new_value; 65371016ad83Smrg} 65381016ad83Smrg 65391016ad83Smrgvoid 65401016ad83Smrglt_update_exe_path (const char *name, const char *value) 65411016ad83Smrg{ 65421016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 65431016ad83Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 65441016ad83Smrg nonnull (name), nonnull (value)); 65451016ad83Smrg 65461016ad83Smrg if (name && *name && value && *value) 65471016ad83Smrg { 65481016ad83Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65491016ad83Smrg /* some systems can't cope with a ':'-terminated path #' */ 65507204935cSmrg size_t len = strlen (new_value); 65517204935cSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 65521016ad83Smrg { 65537204935cSmrg new_value[--len] = '\0'; 65541016ad83Smrg } 65551016ad83Smrg lt_setenv (name, new_value); 65561016ad83Smrg XFREE (new_value); 65571016ad83Smrg } 65581016ad83Smrg} 65591016ad83Smrg 65601016ad83Smrgvoid 65611016ad83Smrglt_update_lib_path (const char *name, const char *value) 65621016ad83Smrg{ 65631016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 65641016ad83Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 65651016ad83Smrg nonnull (name), nonnull (value)); 65661016ad83Smrg 65671016ad83Smrg if (name && *name && value && *value) 65681016ad83Smrg { 65691016ad83Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65701016ad83Smrg lt_setenv (name, new_value); 65711016ad83Smrg XFREE (new_value); 65721016ad83Smrg } 65731016ad83Smrg} 65741016ad83Smrg 65751016ad83SmrgEOF 65761016ad83Smrg case $host_os in 65771016ad83Smrg mingw*) 65781016ad83Smrg cat <<"EOF" 65791016ad83Smrg 65801016ad83Smrg/* Prepares an argument vector before calling spawn(). 65811016ad83Smrg Note that spawn() does not by itself call the command interpreter 65821016ad83Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 65831016ad83Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 65841016ad83Smrg GetVersionEx(&v); 65851016ad83Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 65861016ad83Smrg }) ? "cmd.exe" : "command.com"). 65871016ad83Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 65881016ad83Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 65891016ad83Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 65901016ad83Smrg special way: 65911016ad83Smrg - Space and tab are interpreted as delimiters. They are not treated as 65921016ad83Smrg delimiters if they are surrounded by double quotes: "...". 65931016ad83Smrg - Unescaped double quotes are removed from the input. Their only effect is 65941016ad83Smrg that within double quotes, space and tab are treated like normal 65951016ad83Smrg characters. 65961016ad83Smrg - Backslashes not followed by double quotes are not special. 65971016ad83Smrg - But 2*n+1 backslashes followed by a double quote become 65981016ad83Smrg n backslashes followed by a double quote (n >= 0): 65991016ad83Smrg \" -> " 66001016ad83Smrg \\\" -> \" 66011016ad83Smrg \\\\\" -> \\" 66021016ad83Smrg */ 66031016ad83Smrg#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" 66041016ad83Smrg#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" 66051016ad83Smrgchar ** 66061016ad83Smrgprepare_spawn (char **argv) 66071016ad83Smrg{ 66081016ad83Smrg size_t argc; 66091016ad83Smrg char **new_argv; 66101016ad83Smrg size_t i; 66111016ad83Smrg 66121016ad83Smrg /* Count number of arguments. */ 66131016ad83Smrg for (argc = 0; argv[argc] != NULL; argc++) 66141016ad83Smrg ; 66151016ad83Smrg 66161016ad83Smrg /* Allocate new argument vector. */ 66171016ad83Smrg new_argv = XMALLOC (char *, argc + 1); 66181016ad83Smrg 66191016ad83Smrg /* Put quoted arguments into the new argument vector. */ 66201016ad83Smrg for (i = 0; i < argc; i++) 66211016ad83Smrg { 66221016ad83Smrg const char *string = argv[i]; 66231016ad83Smrg 66241016ad83Smrg if (string[0] == '\0') 66251016ad83Smrg new_argv[i] = xstrdup ("\"\""); 66261016ad83Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 66271016ad83Smrg { 66281016ad83Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 66291016ad83Smrg size_t length; 66301016ad83Smrg unsigned int backslashes; 66311016ad83Smrg const char *s; 66321016ad83Smrg char *quoted_string; 66331016ad83Smrg char *p; 66341016ad83Smrg 66351016ad83Smrg length = 0; 66361016ad83Smrg backslashes = 0; 66371016ad83Smrg if (quote_around) 66381016ad83Smrg length++; 66391016ad83Smrg for (s = string; *s != '\0'; s++) 66401016ad83Smrg { 66411016ad83Smrg char c = *s; 66421016ad83Smrg if (c == '"') 66431016ad83Smrg length += backslashes + 1; 66441016ad83Smrg length++; 66451016ad83Smrg if (c == '\\') 66461016ad83Smrg backslashes++; 66471016ad83Smrg else 66481016ad83Smrg backslashes = 0; 66491016ad83Smrg } 66501016ad83Smrg if (quote_around) 66511016ad83Smrg length += backslashes + 1; 66521016ad83Smrg 66531016ad83Smrg quoted_string = XMALLOC (char, length + 1); 66541016ad83Smrg 66551016ad83Smrg p = quoted_string; 66561016ad83Smrg backslashes = 0; 66571016ad83Smrg if (quote_around) 66581016ad83Smrg *p++ = '"'; 66591016ad83Smrg for (s = string; *s != '\0'; s++) 66601016ad83Smrg { 66611016ad83Smrg char c = *s; 66621016ad83Smrg if (c == '"') 66631016ad83Smrg { 66641016ad83Smrg unsigned int j; 66651016ad83Smrg for (j = backslashes + 1; j > 0; j--) 66661016ad83Smrg *p++ = '\\'; 66671016ad83Smrg } 66681016ad83Smrg *p++ = c; 66691016ad83Smrg if (c == '\\') 66701016ad83Smrg backslashes++; 66711016ad83Smrg else 66721016ad83Smrg backslashes = 0; 66731016ad83Smrg } 66741016ad83Smrg if (quote_around) 66751016ad83Smrg { 66761016ad83Smrg unsigned int j; 66771016ad83Smrg for (j = backslashes; j > 0; j--) 66781016ad83Smrg *p++ = '\\'; 66791016ad83Smrg *p++ = '"'; 66801016ad83Smrg } 66811016ad83Smrg *p = '\0'; 66821016ad83Smrg 66831016ad83Smrg new_argv[i] = quoted_string; 66841016ad83Smrg } 66851016ad83Smrg else 66861016ad83Smrg new_argv[i] = (char *) string; 66871016ad83Smrg } 66881016ad83Smrg new_argv[argc] = NULL; 66891016ad83Smrg 66901016ad83Smrg return new_argv; 66911016ad83Smrg} 66921016ad83SmrgEOF 66931016ad83Smrg ;; 66941016ad83Smrg esac 66951016ad83Smrg 66961016ad83Smrg cat <<"EOF" 66971016ad83Smrgvoid lt_dump_script (FILE* f) 66981016ad83Smrg{ 66991016ad83SmrgEOF 67001016ad83Smrg func_emit_wrapper yes | 67011016ad83Smrg $SED -n -e ' 67021016ad83Smrgs/^\(.\{79\}\)\(..*\)/\1\ 67031016ad83Smrg\2/ 67041016ad83Smrgh 67051016ad83Smrgs/\([\\"]\)/\\\1/g 67061016ad83Smrgs/$/\\n/ 67071016ad83Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67081016ad83Smrgg 67091016ad83SmrgD' 67101016ad83Smrg cat <<"EOF" 67111016ad83Smrg} 67121016ad83SmrgEOF 67131016ad83Smrg} 67141016ad83Smrg# end: func_emit_cwrapperexe_src 67151016ad83Smrg 67161016ad83Smrg# func_win32_import_lib_p ARG 67171016ad83Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 67181016ad83Smrgfunc_win32_import_lib_p () 67191016ad83Smrg{ 67207204935cSmrg $debug_cmd 67217204935cSmrg 67221016ad83Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 67231016ad83Smrg *import*) : ;; 67241016ad83Smrg *) false ;; 67251016ad83Smrg esac 67261016ad83Smrg} 67271016ad83Smrg 67287204935cSmrg# func_suncc_cstd_abi 67297204935cSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67307204935cSmrg# Several compiler flags select an ABI that is incompatible with the 67317204935cSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67327204935cSmrgfunc_suncc_cstd_abi () 67337204935cSmrg{ 67347204935cSmrg $debug_cmd 67357204935cSmrg 67367204935cSmrg case " $compile_command " in 67377204935cSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67387204935cSmrg suncc_use_cstd_abi=no 67397204935cSmrg ;; 67407204935cSmrg *) 67417204935cSmrg suncc_use_cstd_abi=yes 67427204935cSmrg ;; 67437204935cSmrg esac 67447204935cSmrg} 67457204935cSmrg 67461016ad83Smrg# func_mode_link arg... 67471016ad83Smrgfunc_mode_link () 67481016ad83Smrg{ 67497204935cSmrg $debug_cmd 67507204935cSmrg 67511016ad83Smrg case $host in 67521016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 67531016ad83Smrg # It is impossible to link a dll without this setting, and 67541016ad83Smrg # we shouldn't force the makefile maintainer to figure out 67557204935cSmrg # what system we are compiling for in order to pass an extra 67561016ad83Smrg # flag for every libtool invocation. 67571016ad83Smrg # allow_undefined=no 67581016ad83Smrg 67591016ad83Smrg # FIXME: Unfortunately, there are problems with the above when trying 67607204935cSmrg # to make a dll that has undefined symbols, in which case not 67611016ad83Smrg # even a static library is built. For now, we need to specify 67621016ad83Smrg # -no-undefined on the libtool link line when we can be certain 67631016ad83Smrg # that all symbols are satisfied, otherwise we get a static library. 67641016ad83Smrg allow_undefined=yes 67651016ad83Smrg ;; 67661016ad83Smrg *) 67671016ad83Smrg allow_undefined=yes 67681016ad83Smrg ;; 67691016ad83Smrg esac 67701016ad83Smrg libtool_args=$nonopt 67711016ad83Smrg base_compile="$nonopt $@" 67721016ad83Smrg compile_command=$nonopt 67731016ad83Smrg finalize_command=$nonopt 67741016ad83Smrg 67751016ad83Smrg compile_rpath= 67761016ad83Smrg finalize_rpath= 67771016ad83Smrg compile_shlibpath= 67781016ad83Smrg finalize_shlibpath= 67791016ad83Smrg convenience= 67801016ad83Smrg old_convenience= 67811016ad83Smrg deplibs= 67821016ad83Smrg old_deplibs= 67831016ad83Smrg compiler_flags= 67841016ad83Smrg linker_flags= 67851016ad83Smrg dllsearchpath= 67861016ad83Smrg lib_search_path=`pwd` 67871016ad83Smrg inst_prefix_dir= 67881016ad83Smrg new_inherited_linker_flags= 67891016ad83Smrg 67901016ad83Smrg avoid_version=no 67911016ad83Smrg bindir= 67921016ad83Smrg dlfiles= 67931016ad83Smrg dlprefiles= 67941016ad83Smrg dlself=no 67951016ad83Smrg export_dynamic=no 67961016ad83Smrg export_symbols= 67971016ad83Smrg export_symbols_regex= 67981016ad83Smrg generated= 67991016ad83Smrg libobjs= 68001016ad83Smrg ltlibs= 68011016ad83Smrg module=no 68021016ad83Smrg no_install=no 68031016ad83Smrg objs= 68047204935cSmrg os2dllname= 68051016ad83Smrg non_pic_objects= 68061016ad83Smrg precious_files_regex= 68071016ad83Smrg prefer_static_libs=no 68087204935cSmrg preload=false 68091016ad83Smrg prev= 68101016ad83Smrg prevarg= 68111016ad83Smrg release= 68121016ad83Smrg rpath= 68131016ad83Smrg xrpath= 68141016ad83Smrg perm_rpath= 68151016ad83Smrg temp_rpath= 68161016ad83Smrg thread_safe=no 68171016ad83Smrg vinfo= 68181016ad83Smrg vinfo_number=no 68191016ad83Smrg weak_libs= 68207204935cSmrg single_module=$wl-single_module 68211016ad83Smrg func_infer_tag $base_compile 68221016ad83Smrg 68231016ad83Smrg # We need to know -static, to get the right output filenames. 68241016ad83Smrg for arg 68251016ad83Smrg do 68261016ad83Smrg case $arg in 68271016ad83Smrg -shared) 68287204935cSmrg test yes != "$build_libtool_libs" \ 68297204935cSmrg && func_fatal_configuration "cannot build a shared library" 68301016ad83Smrg build_old_libs=no 68311016ad83Smrg break 68321016ad83Smrg ;; 68331016ad83Smrg -all-static | -static | -static-libtool-libs) 68341016ad83Smrg case $arg in 68351016ad83Smrg -all-static) 68367204935cSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 68371016ad83Smrg func_warning "complete static linking is impossible in this configuration" 68381016ad83Smrg fi 68391016ad83Smrg if test -n "$link_static_flag"; then 68401016ad83Smrg dlopen_self=$dlopen_self_static 68411016ad83Smrg fi 68421016ad83Smrg prefer_static_libs=yes 68431016ad83Smrg ;; 68441016ad83Smrg -static) 68451016ad83Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68461016ad83Smrg dlopen_self=$dlopen_self_static 68471016ad83Smrg fi 68481016ad83Smrg prefer_static_libs=built 68491016ad83Smrg ;; 68501016ad83Smrg -static-libtool-libs) 68511016ad83Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68521016ad83Smrg dlopen_self=$dlopen_self_static 68531016ad83Smrg fi 68541016ad83Smrg prefer_static_libs=yes 68551016ad83Smrg ;; 68561016ad83Smrg esac 68571016ad83Smrg build_libtool_libs=no 68581016ad83Smrg build_old_libs=yes 68591016ad83Smrg break 68601016ad83Smrg ;; 68611016ad83Smrg esac 68621016ad83Smrg done 68631016ad83Smrg 68641016ad83Smrg # See if our shared archives depend on static archives. 68651016ad83Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68661016ad83Smrg 68671016ad83Smrg # Go through the arguments, transforming them on the way. 68681016ad83Smrg while test "$#" -gt 0; do 68697204935cSmrg arg=$1 68701016ad83Smrg shift 6871b9526c6aSmrg func_quote_arg pretty,unquoted "$arg" 6872b9526c6aSmrg qarg=$func_quote_arg_unquoted_result 6873b9526c6aSmrg func_append libtool_args " $func_quote_arg_result" 68741016ad83Smrg 68751016ad83Smrg # If the previous option needs an argument, assign it. 68761016ad83Smrg if test -n "$prev"; then 68771016ad83Smrg case $prev in 68781016ad83Smrg output) 68791016ad83Smrg func_append compile_command " @OUTPUT@" 68801016ad83Smrg func_append finalize_command " @OUTPUT@" 68811016ad83Smrg ;; 68821016ad83Smrg esac 68831016ad83Smrg 68841016ad83Smrg case $prev in 68851016ad83Smrg bindir) 68867204935cSmrg bindir=$arg 68871016ad83Smrg prev= 68881016ad83Smrg continue 68891016ad83Smrg ;; 68901016ad83Smrg dlfiles|dlprefiles) 68917204935cSmrg $preload || { 68921016ad83Smrg # Add the symbol object into the linking commands. 68931016ad83Smrg func_append compile_command " @SYMFILE@" 68941016ad83Smrg func_append finalize_command " @SYMFILE@" 68957204935cSmrg preload=: 68967204935cSmrg } 68971016ad83Smrg case $arg in 68981016ad83Smrg *.la | *.lo) ;; # We handle these cases below. 68991016ad83Smrg force) 69007204935cSmrg if test no = "$dlself"; then 69011016ad83Smrg dlself=needless 69021016ad83Smrg export_dynamic=yes 69031016ad83Smrg fi 69041016ad83Smrg prev= 69051016ad83Smrg continue 69061016ad83Smrg ;; 69071016ad83Smrg self) 69087204935cSmrg if test dlprefiles = "$prev"; then 69091016ad83Smrg dlself=yes 69107204935cSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 69111016ad83Smrg dlself=yes 69121016ad83Smrg else 69131016ad83Smrg dlself=needless 69141016ad83Smrg export_dynamic=yes 69151016ad83Smrg fi 69161016ad83Smrg prev= 69171016ad83Smrg continue 69181016ad83Smrg ;; 69191016ad83Smrg *) 69207204935cSmrg if test dlfiles = "$prev"; then 69211016ad83Smrg func_append dlfiles " $arg" 69221016ad83Smrg else 69231016ad83Smrg func_append dlprefiles " $arg" 69241016ad83Smrg fi 69251016ad83Smrg prev= 69261016ad83Smrg continue 69271016ad83Smrg ;; 69281016ad83Smrg esac 69291016ad83Smrg ;; 69301016ad83Smrg expsyms) 69317204935cSmrg export_symbols=$arg 69321016ad83Smrg test -f "$arg" \ 69337204935cSmrg || func_fatal_error "symbol file '$arg' does not exist" 69341016ad83Smrg prev= 69351016ad83Smrg continue 69361016ad83Smrg ;; 69371016ad83Smrg expsyms_regex) 69387204935cSmrg export_symbols_regex=$arg 69391016ad83Smrg prev= 69401016ad83Smrg continue 69411016ad83Smrg ;; 69421016ad83Smrg framework) 69431016ad83Smrg case $host in 69441016ad83Smrg *-*-darwin*) 69451016ad83Smrg case "$deplibs " in 69461016ad83Smrg *" $qarg.ltframework "*) ;; 69471016ad83Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 69481016ad83Smrg ;; 69491016ad83Smrg esac 69501016ad83Smrg ;; 69511016ad83Smrg esac 69521016ad83Smrg prev= 69531016ad83Smrg continue 69541016ad83Smrg ;; 69551016ad83Smrg inst_prefix) 69567204935cSmrg inst_prefix_dir=$arg 69577204935cSmrg prev= 69587204935cSmrg continue 69597204935cSmrg ;; 69607204935cSmrg mllvm) 69617204935cSmrg # Clang does not use LLVM to link, so we can simply discard any 69627204935cSmrg # '-mllvm $arg' options when doing the link step. 69631016ad83Smrg prev= 69641016ad83Smrg continue 69651016ad83Smrg ;; 69661016ad83Smrg objectlist) 69671016ad83Smrg if test -f "$arg"; then 69681016ad83Smrg save_arg=$arg 69691016ad83Smrg moreargs= 69701016ad83Smrg for fil in `cat "$save_arg"` 69711016ad83Smrg do 69721016ad83Smrg# func_append moreargs " $fil" 69731016ad83Smrg arg=$fil 69741016ad83Smrg # A libtool-controlled object. 69751016ad83Smrg 69761016ad83Smrg # Check to see that this really is a libtool object. 69771016ad83Smrg if func_lalib_unsafe_p "$arg"; then 69781016ad83Smrg pic_object= 69791016ad83Smrg non_pic_object= 69801016ad83Smrg 69811016ad83Smrg # Read the .lo file 69821016ad83Smrg func_source "$arg" 69831016ad83Smrg 69841016ad83Smrg if test -z "$pic_object" || 69851016ad83Smrg test -z "$non_pic_object" || 69867204935cSmrg test none = "$pic_object" && 69877204935cSmrg test none = "$non_pic_object"; then 69887204935cSmrg func_fatal_error "cannot find name of object for '$arg'" 69891016ad83Smrg fi 69901016ad83Smrg 69911016ad83Smrg # Extract subdirectory from the argument. 69921016ad83Smrg func_dirname "$arg" "/" "" 69937204935cSmrg xdir=$func_dirname_result 69941016ad83Smrg 69957204935cSmrg if test none != "$pic_object"; then 69961016ad83Smrg # Prepend the subdirectory the object is found in. 69977204935cSmrg pic_object=$xdir$pic_object 69981016ad83Smrg 69997204935cSmrg if test dlfiles = "$prev"; then 70007204935cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 70011016ad83Smrg func_append dlfiles " $pic_object" 70021016ad83Smrg prev= 70031016ad83Smrg continue 70041016ad83Smrg else 70051016ad83Smrg # If libtool objects are unsupported, then we need to preload. 70061016ad83Smrg prev=dlprefiles 70071016ad83Smrg fi 70081016ad83Smrg fi 70091016ad83Smrg 70101016ad83Smrg # CHECK ME: I think I busted this. -Ossama 70117204935cSmrg if test dlprefiles = "$prev"; then 70121016ad83Smrg # Preload the old-style object. 70131016ad83Smrg func_append dlprefiles " $pic_object" 70141016ad83Smrg prev= 70151016ad83Smrg fi 70161016ad83Smrg 70171016ad83Smrg # A PIC object. 70181016ad83Smrg func_append libobjs " $pic_object" 70197204935cSmrg arg=$pic_object 70201016ad83Smrg fi 70211016ad83Smrg 70221016ad83Smrg # Non-PIC object. 70237204935cSmrg if test none != "$non_pic_object"; then 70241016ad83Smrg # Prepend the subdirectory the object is found in. 70257204935cSmrg non_pic_object=$xdir$non_pic_object 70261016ad83Smrg 70271016ad83Smrg # A standard non-PIC object 70281016ad83Smrg func_append non_pic_objects " $non_pic_object" 70297204935cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 70307204935cSmrg arg=$non_pic_object 70311016ad83Smrg fi 70321016ad83Smrg else 70331016ad83Smrg # If the PIC object exists, use it instead. 70341016ad83Smrg # $xdir was prepended to $pic_object above. 70357204935cSmrg non_pic_object=$pic_object 70361016ad83Smrg func_append non_pic_objects " $non_pic_object" 70371016ad83Smrg fi 70381016ad83Smrg else 70391016ad83Smrg # Only an error if not doing a dry-run. 70401016ad83Smrg if $opt_dry_run; then 70411016ad83Smrg # Extract subdirectory from the argument. 70421016ad83Smrg func_dirname "$arg" "/" "" 70437204935cSmrg xdir=$func_dirname_result 70441016ad83Smrg 70451016ad83Smrg func_lo2o "$arg" 70461016ad83Smrg pic_object=$xdir$objdir/$func_lo2o_result 70471016ad83Smrg non_pic_object=$xdir$func_lo2o_result 70481016ad83Smrg func_append libobjs " $pic_object" 70491016ad83Smrg func_append non_pic_objects " $non_pic_object" 70501016ad83Smrg else 70517204935cSmrg func_fatal_error "'$arg' is not a valid libtool object" 70521016ad83Smrg fi 70531016ad83Smrg fi 70541016ad83Smrg done 70551016ad83Smrg else 70567204935cSmrg func_fatal_error "link input file '$arg' does not exist" 70571016ad83Smrg fi 70581016ad83Smrg arg=$save_arg 70591016ad83Smrg prev= 70601016ad83Smrg continue 70611016ad83Smrg ;; 70627204935cSmrg os2dllname) 70637204935cSmrg os2dllname=$arg 70647204935cSmrg prev= 70657204935cSmrg continue 70667204935cSmrg ;; 70671016ad83Smrg precious_regex) 70687204935cSmrg precious_files_regex=$arg 70691016ad83Smrg prev= 70701016ad83Smrg continue 70711016ad83Smrg ;; 70721016ad83Smrg release) 70737204935cSmrg release=-$arg 70741016ad83Smrg prev= 70751016ad83Smrg continue 70761016ad83Smrg ;; 70771016ad83Smrg rpath | xrpath) 70781016ad83Smrg # We need an absolute path. 70791016ad83Smrg case $arg in 70801016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 70811016ad83Smrg *) 70821016ad83Smrg func_fatal_error "only absolute run-paths are allowed" 70831016ad83Smrg ;; 70841016ad83Smrg esac 70857204935cSmrg if test rpath = "$prev"; then 70861016ad83Smrg case "$rpath " in 70871016ad83Smrg *" $arg "*) ;; 70881016ad83Smrg *) func_append rpath " $arg" ;; 70891016ad83Smrg esac 70901016ad83Smrg else 70911016ad83Smrg case "$xrpath " in 70921016ad83Smrg *" $arg "*) ;; 70931016ad83Smrg *) func_append xrpath " $arg" ;; 70941016ad83Smrg esac 70951016ad83Smrg fi 70961016ad83Smrg prev= 70971016ad83Smrg continue 70981016ad83Smrg ;; 70991016ad83Smrg shrext) 71007204935cSmrg shrext_cmds=$arg 71011016ad83Smrg prev= 71021016ad83Smrg continue 71031016ad83Smrg ;; 71041016ad83Smrg weak) 71051016ad83Smrg func_append weak_libs " $arg" 71061016ad83Smrg prev= 71071016ad83Smrg continue 71081016ad83Smrg ;; 7109b9526c6aSmrg xassembler) 7110b9526c6aSmrg func_append compiler_flags " -Xassembler $qarg" 7111b9526c6aSmrg prev= 7112b9526c6aSmrg func_append compile_command " -Xassembler $qarg" 7113b9526c6aSmrg func_append finalize_command " -Xassembler $qarg" 7114b9526c6aSmrg continue 7115b9526c6aSmrg ;; 71161016ad83Smrg xcclinker) 71171016ad83Smrg func_append linker_flags " $qarg" 71181016ad83Smrg func_append compiler_flags " $qarg" 71191016ad83Smrg prev= 71201016ad83Smrg func_append compile_command " $qarg" 71211016ad83Smrg func_append finalize_command " $qarg" 71221016ad83Smrg continue 71231016ad83Smrg ;; 71241016ad83Smrg xcompiler) 71251016ad83Smrg func_append compiler_flags " $qarg" 71261016ad83Smrg prev= 71271016ad83Smrg func_append compile_command " $qarg" 71281016ad83Smrg func_append finalize_command " $qarg" 71291016ad83Smrg continue 71301016ad83Smrg ;; 71311016ad83Smrg xlinker) 71321016ad83Smrg func_append linker_flags " $qarg" 71331016ad83Smrg func_append compiler_flags " $wl$qarg" 71341016ad83Smrg prev= 71351016ad83Smrg func_append compile_command " $wl$qarg" 71361016ad83Smrg func_append finalize_command " $wl$qarg" 71371016ad83Smrg continue 71381016ad83Smrg ;; 71391016ad83Smrg *) 71401016ad83Smrg eval "$prev=\"\$arg\"" 71411016ad83Smrg prev= 71421016ad83Smrg continue 71431016ad83Smrg ;; 71441016ad83Smrg esac 71451016ad83Smrg fi # test -n "$prev" 71461016ad83Smrg 71477204935cSmrg prevarg=$arg 71481016ad83Smrg 71491016ad83Smrg case $arg in 71501016ad83Smrg -all-static) 71511016ad83Smrg if test -n "$link_static_flag"; then 71521016ad83Smrg # See comment for -static flag below, for more details. 71531016ad83Smrg func_append compile_command " $link_static_flag" 71541016ad83Smrg func_append finalize_command " $link_static_flag" 71551016ad83Smrg fi 71561016ad83Smrg continue 71571016ad83Smrg ;; 71581016ad83Smrg 71591016ad83Smrg -allow-undefined) 71601016ad83Smrg # FIXME: remove this flag sometime in the future. 71617204935cSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 71621016ad83Smrg ;; 71631016ad83Smrg 71641016ad83Smrg -avoid-version) 71651016ad83Smrg avoid_version=yes 71661016ad83Smrg continue 71671016ad83Smrg ;; 71681016ad83Smrg 71691016ad83Smrg -bindir) 71701016ad83Smrg prev=bindir 71711016ad83Smrg continue 71721016ad83Smrg ;; 71731016ad83Smrg 71741016ad83Smrg -dlopen) 71751016ad83Smrg prev=dlfiles 71761016ad83Smrg continue 71771016ad83Smrg ;; 71781016ad83Smrg 71791016ad83Smrg -dlpreopen) 71801016ad83Smrg prev=dlprefiles 71811016ad83Smrg continue 71821016ad83Smrg ;; 71831016ad83Smrg 71841016ad83Smrg -export-dynamic) 71851016ad83Smrg export_dynamic=yes 71861016ad83Smrg continue 71871016ad83Smrg ;; 71881016ad83Smrg 71891016ad83Smrg -export-symbols | -export-symbols-regex) 71901016ad83Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 71911016ad83Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 71921016ad83Smrg fi 71937204935cSmrg if test X-export-symbols = "X$arg"; then 71941016ad83Smrg prev=expsyms 71951016ad83Smrg else 71961016ad83Smrg prev=expsyms_regex 71971016ad83Smrg fi 71981016ad83Smrg continue 71991016ad83Smrg ;; 72001016ad83Smrg 72011016ad83Smrg -framework) 72021016ad83Smrg prev=framework 72031016ad83Smrg continue 72041016ad83Smrg ;; 72051016ad83Smrg 72061016ad83Smrg -inst-prefix-dir) 72071016ad83Smrg prev=inst_prefix 72081016ad83Smrg continue 72091016ad83Smrg ;; 72101016ad83Smrg 72111016ad83Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 72121016ad83Smrg # so, if we see these flags be careful not to treat them like -L 72131016ad83Smrg -L[A-Z][A-Z]*:*) 72141016ad83Smrg case $with_gcc/$host in 72151016ad83Smrg no/*-*-irix* | /*-*-irix*) 72161016ad83Smrg func_append compile_command " $arg" 72171016ad83Smrg func_append finalize_command " $arg" 72181016ad83Smrg ;; 72191016ad83Smrg esac 72201016ad83Smrg continue 72211016ad83Smrg ;; 72221016ad83Smrg 72231016ad83Smrg -L*) 72241016ad83Smrg func_stripname "-L" '' "$arg" 72251016ad83Smrg if test -z "$func_stripname_result"; then 72261016ad83Smrg if test "$#" -gt 0; then 72277204935cSmrg func_fatal_error "require no space between '-L' and '$1'" 72281016ad83Smrg else 72297204935cSmrg func_fatal_error "need path for '-L' option" 72301016ad83Smrg fi 72311016ad83Smrg fi 72321016ad83Smrg func_resolve_sysroot "$func_stripname_result" 72331016ad83Smrg dir=$func_resolve_sysroot_result 72341016ad83Smrg # We need an absolute path. 72351016ad83Smrg case $dir in 72361016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 72371016ad83Smrg *) 72381016ad83Smrg absdir=`cd "$dir" && pwd` 72391016ad83Smrg test -z "$absdir" && \ 72407204935cSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72417204935cSmrg dir=$absdir 72421016ad83Smrg ;; 72431016ad83Smrg esac 72441016ad83Smrg case "$deplibs " in 72451016ad83Smrg *" -L$dir "* | *" $arg "*) 72461016ad83Smrg # Will only happen for absolute or sysroot arguments 72471016ad83Smrg ;; 72481016ad83Smrg *) 72491016ad83Smrg # Preserve sysroot, but never include relative directories 72501016ad83Smrg case $dir in 72511016ad83Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 72521016ad83Smrg *) func_append deplibs " -L$dir" ;; 72531016ad83Smrg esac 72541016ad83Smrg func_append lib_search_path " $dir" 72551016ad83Smrg ;; 72561016ad83Smrg esac 72571016ad83Smrg case $host in 72581016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 72591016ad83Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 72601016ad83Smrg case :$dllsearchpath: in 72611016ad83Smrg *":$dir:"*) ;; 72621016ad83Smrg ::) dllsearchpath=$dir;; 72631016ad83Smrg *) func_append dllsearchpath ":$dir";; 72641016ad83Smrg esac 72651016ad83Smrg case :$dllsearchpath: in 72661016ad83Smrg *":$testbindir:"*) ;; 72671016ad83Smrg ::) dllsearchpath=$testbindir;; 72681016ad83Smrg *) func_append dllsearchpath ":$testbindir";; 72691016ad83Smrg esac 72701016ad83Smrg ;; 72711016ad83Smrg esac 72721016ad83Smrg continue 72731016ad83Smrg ;; 72741016ad83Smrg 72751016ad83Smrg -l*) 72767204935cSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 72771016ad83Smrg case $host in 72781016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 72791016ad83Smrg # These systems don't actually have a C or math library (as such) 72801016ad83Smrg continue 72811016ad83Smrg ;; 72821016ad83Smrg *-*-os2*) 72831016ad83Smrg # These systems don't actually have a C library (as such) 72847204935cSmrg test X-lc = "X$arg" && continue 72851016ad83Smrg ;; 7286b9526c6aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 72871016ad83Smrg # Do not include libc due to us having libc/libc_r. 72887204935cSmrg test X-lc = "X$arg" && continue 72891016ad83Smrg ;; 72901016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 72911016ad83Smrg # Rhapsody C and math libraries are in the System framework 72921016ad83Smrg func_append deplibs " System.ltframework" 72931016ad83Smrg continue 72941016ad83Smrg ;; 72951016ad83Smrg *-*-sco3.2v5* | *-*-sco5v6*) 72961016ad83Smrg # Causes problems with __ctype 72977204935cSmrg test X-lc = "X$arg" && continue 72981016ad83Smrg ;; 72991016ad83Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 73001016ad83Smrg # Compiler inserts libc in the correct place for threads to work 73017204935cSmrg test X-lc = "X$arg" && continue 73021016ad83Smrg ;; 73031016ad83Smrg esac 73047204935cSmrg elif test X-lc_r = "X$arg"; then 73051016ad83Smrg case $host in 7306b9526c6aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 73071016ad83Smrg # Do not include libc_r directly, use -pthread flag. 73081016ad83Smrg continue 73091016ad83Smrg ;; 73101016ad83Smrg esac 73111016ad83Smrg fi 73121016ad83Smrg func_append deplibs " $arg" 73131016ad83Smrg continue 73141016ad83Smrg ;; 73151016ad83Smrg 73167204935cSmrg -mllvm) 73177204935cSmrg prev=mllvm 73187204935cSmrg continue 73197204935cSmrg ;; 73207204935cSmrg 73211016ad83Smrg -module) 73221016ad83Smrg module=yes 73231016ad83Smrg continue 73241016ad83Smrg ;; 73251016ad83Smrg 73261016ad83Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 73271016ad83Smrg # classes, name mangling, and exception handling. 73281016ad83Smrg # Darwin uses the -arch flag to determine output architecture. 73291016ad83Smrg -model|-arch|-isysroot|--sysroot) 73301016ad83Smrg func_append compiler_flags " $arg" 73311016ad83Smrg func_append compile_command " $arg" 73321016ad83Smrg func_append finalize_command " $arg" 73331016ad83Smrg prev=xcompiler 73341016ad83Smrg continue 73351016ad83Smrg ;; 7336b9526c6aSmrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337b9526c6aSmrg -pthread) 7338b9526c6aSmrg case $host in 7339b9526c6aSmrg *solaris2*) ;; 7340b9526c6aSmrg *) 7341b9526c6aSmrg case "$new_inherited_linker_flags " in 7342b9526c6aSmrg *" $arg "*) ;; 7343b9526c6aSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344b9526c6aSmrg esac 7345b9526c6aSmrg ;; 7346b9526c6aSmrg esac 7347b9526c6aSmrg continue 7348b9526c6aSmrg ;; 7349b9526c6aSmrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73501016ad83Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 73511016ad83Smrg func_append compiler_flags " $arg" 73521016ad83Smrg func_append compile_command " $arg" 73531016ad83Smrg func_append finalize_command " $arg" 73541016ad83Smrg case "$new_inherited_linker_flags " in 73551016ad83Smrg *" $arg "*) ;; 73561016ad83Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73571016ad83Smrg esac 7358aa30ed02Smrg 7359aa30ed02Smrg # As we are forced to pass -nostdlib to g++ during linking, the option 7360aa30ed02Smrg # -pthread{,s} is not in effect; add the -lpthread to $deplist 7361aa30ed02Smrg # explicitly to link correctly. 7362aa30ed02Smrg if test "$tagname" = CXX -a x"$with_gcc" = xyes; then 7363aa30ed02Smrg case "$arg" in 7364aa30ed02Smrg -pthread*) func_append deplibs " -lpthread" ;; 7365aa30ed02Smrg esac 7366aa30ed02Smrg fi 7367aa30ed02Smrg 73681016ad83Smrg continue 73691016ad83Smrg ;; 73701016ad83Smrg 73711016ad83Smrg -multi_module) 73727204935cSmrg single_module=$wl-multi_module 73731016ad83Smrg continue 73741016ad83Smrg ;; 73751016ad83Smrg 73761016ad83Smrg -no-fast-install) 73771016ad83Smrg fast_install=no 73781016ad83Smrg continue 73791016ad83Smrg ;; 73801016ad83Smrg 73811016ad83Smrg -no-install) 73821016ad83Smrg case $host in 73831016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 73841016ad83Smrg # The PATH hackery in wrapper scripts is required on Windows 73851016ad83Smrg # and Darwin in order for the loader to find any dlls it needs. 73867204935cSmrg func_warning "'-no-install' is ignored for $host" 73877204935cSmrg func_warning "assuming '-no-fast-install' instead" 73881016ad83Smrg fast_install=no 73891016ad83Smrg ;; 73901016ad83Smrg *) no_install=yes ;; 73911016ad83Smrg esac 73921016ad83Smrg continue 73931016ad83Smrg ;; 73941016ad83Smrg 73951016ad83Smrg -no-undefined) 73961016ad83Smrg allow_undefined=no 73971016ad83Smrg continue 73981016ad83Smrg ;; 73991016ad83Smrg 74001016ad83Smrg -objectlist) 74011016ad83Smrg prev=objectlist 74021016ad83Smrg continue 74031016ad83Smrg ;; 74041016ad83Smrg 74057204935cSmrg -os2dllname) 74067204935cSmrg prev=os2dllname 74077204935cSmrg continue 74087204935cSmrg ;; 74097204935cSmrg 74101016ad83Smrg -o) prev=output ;; 74111016ad83Smrg 74121016ad83Smrg -precious-files-regex) 74131016ad83Smrg prev=precious_regex 74141016ad83Smrg continue 74151016ad83Smrg ;; 74161016ad83Smrg 74171016ad83Smrg -release) 74181016ad83Smrg prev=release 74191016ad83Smrg continue 74201016ad83Smrg ;; 74211016ad83Smrg 74221016ad83Smrg -rpath) 74231016ad83Smrg prev=rpath 74241016ad83Smrg continue 74251016ad83Smrg ;; 74261016ad83Smrg 74271016ad83Smrg -R) 74281016ad83Smrg prev=xrpath 74291016ad83Smrg continue 74301016ad83Smrg ;; 74311016ad83Smrg 74321016ad83Smrg -R*) 74331016ad83Smrg func_stripname '-R' '' "$arg" 74341016ad83Smrg dir=$func_stripname_result 74351016ad83Smrg # We need an absolute path. 74361016ad83Smrg case $dir in 74371016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 74381016ad83Smrg =*) 74391016ad83Smrg func_stripname '=' '' "$dir" 74401016ad83Smrg dir=$lt_sysroot$func_stripname_result 74411016ad83Smrg ;; 74421016ad83Smrg *) 74431016ad83Smrg func_fatal_error "only absolute run-paths are allowed" 74441016ad83Smrg ;; 74451016ad83Smrg esac 74461016ad83Smrg case "$xrpath " in 74471016ad83Smrg *" $dir "*) ;; 74481016ad83Smrg *) func_append xrpath " $dir" ;; 74491016ad83Smrg esac 74501016ad83Smrg continue 74511016ad83Smrg ;; 74521016ad83Smrg 74531016ad83Smrg -shared) 74541016ad83Smrg # The effects of -shared are defined in a previous loop. 74551016ad83Smrg continue 74561016ad83Smrg ;; 74571016ad83Smrg 74581016ad83Smrg -shrext) 74591016ad83Smrg prev=shrext 74601016ad83Smrg continue 74611016ad83Smrg ;; 74621016ad83Smrg 74631016ad83Smrg -static | -static-libtool-libs) 74641016ad83Smrg # The effects of -static are defined in a previous loop. 74651016ad83Smrg # We used to do the same as -all-static on platforms that 74661016ad83Smrg # didn't have a PIC flag, but the assumption that the effects 74671016ad83Smrg # would be equivalent was wrong. It would break on at least 74681016ad83Smrg # Digital Unix and AIX. 74691016ad83Smrg continue 74701016ad83Smrg ;; 74711016ad83Smrg 74721016ad83Smrg -thread-safe) 74731016ad83Smrg thread_safe=yes 74741016ad83Smrg continue 74751016ad83Smrg ;; 74761016ad83Smrg 74771016ad83Smrg -version-info) 74781016ad83Smrg prev=vinfo 74791016ad83Smrg continue 74801016ad83Smrg ;; 74811016ad83Smrg 74821016ad83Smrg -version-number) 74831016ad83Smrg prev=vinfo 74841016ad83Smrg vinfo_number=yes 74851016ad83Smrg continue 74861016ad83Smrg ;; 74871016ad83Smrg 74881016ad83Smrg -weak) 74891016ad83Smrg prev=weak 74901016ad83Smrg continue 74911016ad83Smrg ;; 74921016ad83Smrg 74931016ad83Smrg -Wc,*) 74941016ad83Smrg func_stripname '-Wc,' '' "$arg" 74951016ad83Smrg args=$func_stripname_result 74961016ad83Smrg arg= 74977204935cSmrg save_ifs=$IFS; IFS=, 74981016ad83Smrg for flag in $args; do 74997204935cSmrg IFS=$save_ifs 7500b9526c6aSmrg func_quote_arg pretty "$flag" 7501b9526c6aSmrg func_append arg " $func_quote_arg_result" 7502b9526c6aSmrg func_append compiler_flags " $func_quote_arg_result" 75031016ad83Smrg done 75047204935cSmrg IFS=$save_ifs 75051016ad83Smrg func_stripname ' ' '' "$arg" 75061016ad83Smrg arg=$func_stripname_result 75071016ad83Smrg ;; 75081016ad83Smrg 75091016ad83Smrg -Wl,*) 75101016ad83Smrg func_stripname '-Wl,' '' "$arg" 75111016ad83Smrg args=$func_stripname_result 75121016ad83Smrg arg= 75137204935cSmrg save_ifs=$IFS; IFS=, 75141016ad83Smrg for flag in $args; do 75157204935cSmrg IFS=$save_ifs 7516b9526c6aSmrg func_quote_arg pretty "$flag" 7517b9526c6aSmrg func_append arg " $wl$func_quote_arg_result" 7518b9526c6aSmrg func_append compiler_flags " $wl$func_quote_arg_result" 7519b9526c6aSmrg func_append linker_flags " $func_quote_arg_result" 75201016ad83Smrg done 75217204935cSmrg IFS=$save_ifs 75221016ad83Smrg func_stripname ' ' '' "$arg" 75231016ad83Smrg arg=$func_stripname_result 75241016ad83Smrg ;; 75251016ad83Smrg 7526b9526c6aSmrg -Xassembler) 7527b9526c6aSmrg prev=xassembler 7528b9526c6aSmrg continue 7529b9526c6aSmrg ;; 7530b9526c6aSmrg 75311016ad83Smrg -Xcompiler) 75321016ad83Smrg prev=xcompiler 75331016ad83Smrg continue 75341016ad83Smrg ;; 75351016ad83Smrg 75361016ad83Smrg -Xlinker) 75371016ad83Smrg prev=xlinker 75381016ad83Smrg continue 75391016ad83Smrg ;; 75401016ad83Smrg 75411016ad83Smrg -XCClinker) 75421016ad83Smrg prev=xcclinker 75431016ad83Smrg continue 75441016ad83Smrg ;; 75451016ad83Smrg 75461016ad83Smrg # -msg_* for osf cc 75471016ad83Smrg -msg_*) 7548b9526c6aSmrg func_quote_arg pretty "$arg" 7549b9526c6aSmrg arg=$func_quote_arg_result 75501016ad83Smrg ;; 75511016ad83Smrg 75521016ad83Smrg # Flags to be passed through unchanged, with rationale: 75531016ad83Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 75541016ad83Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 75551016ad83Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 75561016ad83Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 75571016ad83Smrg # -q* compiler args for the IBM compiler 75581016ad83Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 75591016ad83Smrg # -F/path path to uninstalled frameworks, gcc on darwin 75601016ad83Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75617204935cSmrg # -fstack-protector* stack protector flags for GCC 75621016ad83Smrg # @file GCC response files 75631016ad83Smrg # -tp=* Portland pgcc target processor selection 75641016ad83Smrg # --sysroot=* for sysroot support 75657204935cSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7566fe12f63cSmrg # -specs=* GCC specs files 75677204935cSmrg # -stdlib=* select c++ std lib with clang 7568fe12f63cSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 7569aa30ed02Smrg # -fuse-ld=* Linker select flags for GCC 7570b9526c6aSmrg # -Wa,* Pass flags directly to the assembler 7571b9526c6aSmrg # -Werror, -Werror=* Report (specified) warnings as errors 75721016ad83Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 75731016ad83Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7574fe12f63cSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7575b9526c6aSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*|-Werror|-Werror=*) 7576b9526c6aSmrg func_quote_arg pretty "$arg" 7577b9526c6aSmrg arg=$func_quote_arg_result 75781016ad83Smrg func_append compile_command " $arg" 75791016ad83Smrg func_append finalize_command " $arg" 75801016ad83Smrg func_append compiler_flags " $arg" 75811016ad83Smrg continue 75821016ad83Smrg ;; 75831016ad83Smrg 75847204935cSmrg -Z*) 75857204935cSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75867204935cSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 75877204935cSmrg compiler_flags="$compiler_flags $arg" 75887204935cSmrg func_append compile_command " $arg" 75897204935cSmrg func_append finalize_command " $arg" 75907204935cSmrg case $arg in 75917204935cSmrg -Zlinker | -Zstack) 75927204935cSmrg prev=xcompiler 75937204935cSmrg ;; 75947204935cSmrg esac 75957204935cSmrg continue 75967204935cSmrg else 75977204935cSmrg # Otherwise treat like 'Some other compiler flag' below 7598b9526c6aSmrg func_quote_arg pretty "$arg" 7599b9526c6aSmrg arg=$func_quote_arg_result 76007204935cSmrg fi 76017204935cSmrg ;; 76027204935cSmrg 76031016ad83Smrg # Some other compiler flag. 76041016ad83Smrg -* | +*) 7605b9526c6aSmrg func_quote_arg pretty "$arg" 7606b9526c6aSmrg arg=$func_quote_arg_result 76071016ad83Smrg ;; 76081016ad83Smrg 76091016ad83Smrg *.$objext) 76101016ad83Smrg # A standard object. 76111016ad83Smrg func_append objs " $arg" 76121016ad83Smrg ;; 76131016ad83Smrg 76141016ad83Smrg *.lo) 76151016ad83Smrg # A libtool-controlled object. 76161016ad83Smrg 76171016ad83Smrg # Check to see that this really is a libtool object. 76181016ad83Smrg if func_lalib_unsafe_p "$arg"; then 76191016ad83Smrg pic_object= 76201016ad83Smrg non_pic_object= 76211016ad83Smrg 76221016ad83Smrg # Read the .lo file 76231016ad83Smrg func_source "$arg" 76241016ad83Smrg 76251016ad83Smrg if test -z "$pic_object" || 76261016ad83Smrg test -z "$non_pic_object" || 76277204935cSmrg test none = "$pic_object" && 76287204935cSmrg test none = "$non_pic_object"; then 76297204935cSmrg func_fatal_error "cannot find name of object for '$arg'" 76301016ad83Smrg fi 76311016ad83Smrg 76321016ad83Smrg # Extract subdirectory from the argument. 76331016ad83Smrg func_dirname "$arg" "/" "" 76347204935cSmrg xdir=$func_dirname_result 76351016ad83Smrg 76367204935cSmrg test none = "$pic_object" || { 76371016ad83Smrg # Prepend the subdirectory the object is found in. 76387204935cSmrg pic_object=$xdir$pic_object 76391016ad83Smrg 76407204935cSmrg if test dlfiles = "$prev"; then 76417204935cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 76421016ad83Smrg func_append dlfiles " $pic_object" 76431016ad83Smrg prev= 76441016ad83Smrg continue 76451016ad83Smrg else 76461016ad83Smrg # If libtool objects are unsupported, then we need to preload. 76471016ad83Smrg prev=dlprefiles 76481016ad83Smrg fi 76491016ad83Smrg fi 76501016ad83Smrg 76511016ad83Smrg # CHECK ME: I think I busted this. -Ossama 76527204935cSmrg if test dlprefiles = "$prev"; then 76531016ad83Smrg # Preload the old-style object. 76541016ad83Smrg func_append dlprefiles " $pic_object" 76551016ad83Smrg prev= 76561016ad83Smrg fi 76571016ad83Smrg 76581016ad83Smrg # A PIC object. 76591016ad83Smrg func_append libobjs " $pic_object" 76607204935cSmrg arg=$pic_object 76617204935cSmrg } 76621016ad83Smrg 76631016ad83Smrg # Non-PIC object. 76647204935cSmrg if test none != "$non_pic_object"; then 76651016ad83Smrg # Prepend the subdirectory the object is found in. 76667204935cSmrg non_pic_object=$xdir$non_pic_object 76671016ad83Smrg 76681016ad83Smrg # A standard non-PIC object 76691016ad83Smrg func_append non_pic_objects " $non_pic_object" 76707204935cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 76717204935cSmrg arg=$non_pic_object 76721016ad83Smrg fi 76731016ad83Smrg else 76741016ad83Smrg # If the PIC object exists, use it instead. 76751016ad83Smrg # $xdir was prepended to $pic_object above. 76767204935cSmrg non_pic_object=$pic_object 76771016ad83Smrg func_append non_pic_objects " $non_pic_object" 76781016ad83Smrg fi 76791016ad83Smrg else 76801016ad83Smrg # Only an error if not doing a dry-run. 76811016ad83Smrg if $opt_dry_run; then 76821016ad83Smrg # Extract subdirectory from the argument. 76831016ad83Smrg func_dirname "$arg" "/" "" 76847204935cSmrg xdir=$func_dirname_result 76851016ad83Smrg 76861016ad83Smrg func_lo2o "$arg" 76871016ad83Smrg pic_object=$xdir$objdir/$func_lo2o_result 76881016ad83Smrg non_pic_object=$xdir$func_lo2o_result 76891016ad83Smrg func_append libobjs " $pic_object" 76901016ad83Smrg func_append non_pic_objects " $non_pic_object" 76911016ad83Smrg else 76927204935cSmrg func_fatal_error "'$arg' is not a valid libtool object" 76931016ad83Smrg fi 76941016ad83Smrg fi 76951016ad83Smrg ;; 76961016ad83Smrg 76971016ad83Smrg *.$libext) 76981016ad83Smrg # An archive. 76991016ad83Smrg func_append deplibs " $arg" 77001016ad83Smrg func_append old_deplibs " $arg" 77011016ad83Smrg continue 77021016ad83Smrg ;; 77031016ad83Smrg 77041016ad83Smrg *.la) 77051016ad83Smrg # A libtool-controlled library. 77061016ad83Smrg 77071016ad83Smrg func_resolve_sysroot "$arg" 77087204935cSmrg if test dlfiles = "$prev"; then 77091016ad83Smrg # This library was specified with -dlopen. 77101016ad83Smrg func_append dlfiles " $func_resolve_sysroot_result" 77111016ad83Smrg prev= 77127204935cSmrg elif test dlprefiles = "$prev"; then 77131016ad83Smrg # The library was specified with -dlpreopen. 77141016ad83Smrg func_append dlprefiles " $func_resolve_sysroot_result" 77151016ad83Smrg prev= 77161016ad83Smrg else 77171016ad83Smrg func_append deplibs " $func_resolve_sysroot_result" 77181016ad83Smrg fi 77191016ad83Smrg continue 77201016ad83Smrg ;; 77211016ad83Smrg 77221016ad83Smrg # Some other compiler argument. 77231016ad83Smrg *) 77241016ad83Smrg # Unknown arguments in both finalize_command and compile_command need 77251016ad83Smrg # to be aesthetically quoted because they are evaled later. 7726b9526c6aSmrg func_quote_arg pretty "$arg" 7727b9526c6aSmrg arg=$func_quote_arg_result 77281016ad83Smrg ;; 77291016ad83Smrg esac # arg 77301016ad83Smrg 77311016ad83Smrg # Now actually substitute the argument into the commands. 77321016ad83Smrg if test -n "$arg"; then 77331016ad83Smrg func_append compile_command " $arg" 77341016ad83Smrg func_append finalize_command " $arg" 77351016ad83Smrg fi 77361016ad83Smrg done # argument parsing loop 77371016ad83Smrg 77381016ad83Smrg test -n "$prev" && \ 77397204935cSmrg func_fatal_help "the '$prevarg' option requires an argument" 77401016ad83Smrg 77417204935cSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 77421016ad83Smrg eval arg=\"$export_dynamic_flag_spec\" 77431016ad83Smrg func_append compile_command " $arg" 77441016ad83Smrg func_append finalize_command " $arg" 77451016ad83Smrg fi 77461016ad83Smrg 77471016ad83Smrg oldlibs= 77481016ad83Smrg # calculate the name of the file, without its directory 77491016ad83Smrg func_basename "$output" 77507204935cSmrg outputname=$func_basename_result 77517204935cSmrg libobjs_save=$libobjs 77521016ad83Smrg 77531016ad83Smrg if test -n "$shlibpath_var"; then 77541016ad83Smrg # get the directories listed in $shlibpath_var 77557204935cSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77561016ad83Smrg else 77571016ad83Smrg shlib_search_path= 77581016ad83Smrg fi 77591016ad83Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 77601016ad83Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77611016ad83Smrg 77627204935cSmrg # Definition is injected by LT_CONFIG during libtool generation. 77637204935cSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77647204935cSmrg 77651016ad83Smrg func_dirname "$output" "/" "" 77667204935cSmrg output_objdir=$func_dirname_result$objdir 77671016ad83Smrg func_to_tool_file "$output_objdir/" 77681016ad83Smrg tool_output_objdir=$func_to_tool_file_result 77691016ad83Smrg # Create the object directory. 77701016ad83Smrg func_mkdir_p "$output_objdir" 77711016ad83Smrg 77721016ad83Smrg # Determine the type of output 77731016ad83Smrg case $output in 77741016ad83Smrg "") 77751016ad83Smrg func_fatal_help "you must specify an output file" 77761016ad83Smrg ;; 77771016ad83Smrg *.$libext) linkmode=oldlib ;; 77781016ad83Smrg *.lo | *.$objext) linkmode=obj ;; 77791016ad83Smrg *.la) linkmode=lib ;; 77801016ad83Smrg *) linkmode=prog ;; # Anything else should be a program. 77811016ad83Smrg esac 77821016ad83Smrg 77831016ad83Smrg specialdeplibs= 77841016ad83Smrg 77851016ad83Smrg libs= 77861016ad83Smrg # Find all interdependent deplibs by searching for libraries 77871016ad83Smrg # that are linked more than once (e.g. -la -lb -la) 77881016ad83Smrg for deplib in $deplibs; do 77897204935cSmrg if $opt_preserve_dup_deps; then 77901016ad83Smrg case "$libs " in 77911016ad83Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 77921016ad83Smrg esac 77931016ad83Smrg fi 77941016ad83Smrg func_append libs " $deplib" 77951016ad83Smrg done 77961016ad83Smrg 77977204935cSmrg if test lib = "$linkmode"; then 77981016ad83Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 77991016ad83Smrg 78001016ad83Smrg # Compute libraries that are listed more than once in $predeps 78011016ad83Smrg # $postdeps and mark them as special (i.e., whose duplicates are 78021016ad83Smrg # not to be eliminated). 78031016ad83Smrg pre_post_deps= 78041016ad83Smrg if $opt_duplicate_compiler_generated_deps; then 78051016ad83Smrg for pre_post_dep in $predeps $postdeps; do 78061016ad83Smrg case "$pre_post_deps " in 78071016ad83Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 78081016ad83Smrg esac 78091016ad83Smrg func_append pre_post_deps " $pre_post_dep" 78101016ad83Smrg done 78111016ad83Smrg fi 78121016ad83Smrg pre_post_deps= 78131016ad83Smrg fi 78141016ad83Smrg 78151016ad83Smrg deplibs= 78161016ad83Smrg newdependency_libs= 78171016ad83Smrg newlib_search_path= 78181016ad83Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 78191016ad83Smrg notinst_deplibs= # not-installed libtool libraries 78201016ad83Smrg notinst_path= # paths that contain not-installed libtool libraries 78211016ad83Smrg 78221016ad83Smrg case $linkmode in 78231016ad83Smrg lib) 78241016ad83Smrg passes="conv dlpreopen link" 78251016ad83Smrg for file in $dlfiles $dlprefiles; do 78261016ad83Smrg case $file in 78271016ad83Smrg *.la) ;; 78281016ad83Smrg *) 78297204935cSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 78301016ad83Smrg ;; 78311016ad83Smrg esac 78321016ad83Smrg done 78331016ad83Smrg ;; 78341016ad83Smrg prog) 78351016ad83Smrg compile_deplibs= 78361016ad83Smrg finalize_deplibs= 78377204935cSmrg alldeplibs=false 78381016ad83Smrg newdlfiles= 78391016ad83Smrg newdlprefiles= 78401016ad83Smrg passes="conv scan dlopen dlpreopen link" 78411016ad83Smrg ;; 78421016ad83Smrg *) passes="conv" 78431016ad83Smrg ;; 78441016ad83Smrg esac 78451016ad83Smrg 78461016ad83Smrg for pass in $passes; do 78471016ad83Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 78481016ad83Smrg # so that -L comes before libs that need it for instance... 78497204935cSmrg if test lib,link = "$linkmode,$pass"; then 78501016ad83Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 78511016ad83Smrg ## order, and fix it there properly 78521016ad83Smrg tmp_deplibs= 78531016ad83Smrg for deplib in $deplibs; do 78541016ad83Smrg tmp_deplibs="$deplib $tmp_deplibs" 78551016ad83Smrg done 78567204935cSmrg deplibs=$tmp_deplibs 78571016ad83Smrg fi 78581016ad83Smrg 78597204935cSmrg if test lib,link = "$linkmode,$pass" || 78607204935cSmrg test prog,scan = "$linkmode,$pass"; then 78617204935cSmrg libs=$deplibs 78621016ad83Smrg deplibs= 78631016ad83Smrg fi 78647204935cSmrg if test prog = "$linkmode"; then 78651016ad83Smrg case $pass in 78667204935cSmrg dlopen) libs=$dlfiles ;; 78677204935cSmrg dlpreopen) libs=$dlprefiles ;; 7868aa30ed02Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 78691016ad83Smrg esac 78701016ad83Smrg fi 78717204935cSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 78721016ad83Smrg # Collect and forward deplibs of preopened libtool libs 78731016ad83Smrg for lib in $dlprefiles; do 78741016ad83Smrg # Ignore non-libtool-libs 78751016ad83Smrg dependency_libs= 78761016ad83Smrg func_resolve_sysroot "$lib" 78771016ad83Smrg case $lib in 78781016ad83Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 78791016ad83Smrg esac 78801016ad83Smrg 78811016ad83Smrg # Collect preopened libtool deplibs, except any this library 78821016ad83Smrg # has declared as weak libs 78831016ad83Smrg for deplib in $dependency_libs; do 78841016ad83Smrg func_basename "$deplib" 78851016ad83Smrg deplib_base=$func_basename_result 78861016ad83Smrg case " $weak_libs " in 78871016ad83Smrg *" $deplib_base "*) ;; 78881016ad83Smrg *) func_append deplibs " $deplib" ;; 78891016ad83Smrg esac 78901016ad83Smrg done 78911016ad83Smrg done 78927204935cSmrg libs=$dlprefiles 78931016ad83Smrg fi 78947204935cSmrg if test dlopen = "$pass"; then 78951016ad83Smrg # Collect dlpreopened libraries 78967204935cSmrg save_deplibs=$deplibs 78971016ad83Smrg deplibs= 78981016ad83Smrg fi 78991016ad83Smrg 79001016ad83Smrg for deplib in $libs; do 79011016ad83Smrg lib= 79027204935cSmrg found=false 79031016ad83Smrg case $deplib in 79041016ad83Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 79051016ad83Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 79067204935cSmrg if test prog,link = "$linkmode,$pass"; then 79071016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 79081016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 79091016ad83Smrg else 79101016ad83Smrg func_append compiler_flags " $deplib" 79117204935cSmrg if test lib = "$linkmode"; then 79121016ad83Smrg case "$new_inherited_linker_flags " in 79131016ad83Smrg *" $deplib "*) ;; 79141016ad83Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79151016ad83Smrg esac 79161016ad83Smrg fi 79171016ad83Smrg fi 79181016ad83Smrg continue 79191016ad83Smrg ;; 79201016ad83Smrg -l*) 79217204935cSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79227204935cSmrg func_warning "'-l' is ignored for archives/objects" 79231016ad83Smrg continue 79241016ad83Smrg fi 79251016ad83Smrg func_stripname '-l' '' "$deplib" 79261016ad83Smrg name=$func_stripname_result 79277204935cSmrg if test lib = "$linkmode"; then 79281016ad83Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 79291016ad83Smrg else 79301016ad83Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 79311016ad83Smrg fi 79321016ad83Smrg for searchdir in $searchdirs; do 79331016ad83Smrg for search_ext in .la $std_shrext .so .a; do 79341016ad83Smrg # Search the libtool library 79357204935cSmrg lib=$searchdir/lib$name$search_ext 79361016ad83Smrg if test -f "$lib"; then 79377204935cSmrg if test .la = "$search_ext"; then 79387204935cSmrg found=: 79391016ad83Smrg else 79407204935cSmrg found=false 79411016ad83Smrg fi 79421016ad83Smrg break 2 79431016ad83Smrg fi 79441016ad83Smrg done 79451016ad83Smrg done 79467204935cSmrg if $found; then 79477204935cSmrg # deplib is a libtool library 79481016ad83Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 79491016ad83Smrg # We need to do some special things here, and not later. 79507204935cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 79511016ad83Smrg case " $predeps $postdeps " in 79521016ad83Smrg *" $deplib "*) 79531016ad83Smrg if func_lalib_p "$lib"; then 79541016ad83Smrg library_names= 79551016ad83Smrg old_library= 79561016ad83Smrg func_source "$lib" 79571016ad83Smrg for l in $old_library $library_names; do 79587204935cSmrg ll=$l 79591016ad83Smrg done 79607204935cSmrg if test "X$ll" = "X$old_library"; then # only static version available 79617204935cSmrg found=false 79621016ad83Smrg func_dirname "$lib" "" "." 79637204935cSmrg ladir=$func_dirname_result 79641016ad83Smrg lib=$ladir/$old_library 79657204935cSmrg if test prog,link = "$linkmode,$pass"; then 79661016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 79671016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 79681016ad83Smrg else 79691016ad83Smrg deplibs="$deplib $deplibs" 79707204935cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79711016ad83Smrg fi 79721016ad83Smrg continue 79731016ad83Smrg fi 79741016ad83Smrg fi 79751016ad83Smrg ;; 79761016ad83Smrg *) ;; 79771016ad83Smrg esac 79781016ad83Smrg fi 79797204935cSmrg else 79807204935cSmrg # deplib doesn't seem to be a libtool library 79817204935cSmrg if test prog,link = "$linkmode,$pass"; then 79827204935cSmrg compile_deplibs="$deplib $compile_deplibs" 79837204935cSmrg finalize_deplibs="$deplib $finalize_deplibs" 79847204935cSmrg else 79857204935cSmrg deplibs="$deplib $deplibs" 79867204935cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79877204935cSmrg fi 79887204935cSmrg continue 79891016ad83Smrg fi 79901016ad83Smrg ;; # -l 79911016ad83Smrg *.ltframework) 79927204935cSmrg if test prog,link = "$linkmode,$pass"; then 79931016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 79941016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 79951016ad83Smrg else 79961016ad83Smrg deplibs="$deplib $deplibs" 79977204935cSmrg if test lib = "$linkmode"; then 79981016ad83Smrg case "$new_inherited_linker_flags " in 79991016ad83Smrg *" $deplib "*) ;; 80001016ad83Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 80011016ad83Smrg esac 80021016ad83Smrg fi 80031016ad83Smrg fi 80041016ad83Smrg continue 80051016ad83Smrg ;; 80061016ad83Smrg -L*) 80071016ad83Smrg case $linkmode in 80081016ad83Smrg lib) 80091016ad83Smrg deplibs="$deplib $deplibs" 80107204935cSmrg test conv = "$pass" && continue 80111016ad83Smrg newdependency_libs="$deplib $newdependency_libs" 80121016ad83Smrg func_stripname '-L' '' "$deplib" 80131016ad83Smrg func_resolve_sysroot "$func_stripname_result" 80141016ad83Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80151016ad83Smrg ;; 80161016ad83Smrg prog) 80177204935cSmrg if test conv = "$pass"; then 80181016ad83Smrg deplibs="$deplib $deplibs" 80191016ad83Smrg continue 80201016ad83Smrg fi 80217204935cSmrg if test scan = "$pass"; then 80221016ad83Smrg deplibs="$deplib $deplibs" 80231016ad83Smrg else 80241016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 80251016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 80261016ad83Smrg fi 80271016ad83Smrg func_stripname '-L' '' "$deplib" 80281016ad83Smrg func_resolve_sysroot "$func_stripname_result" 80291016ad83Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80301016ad83Smrg ;; 80311016ad83Smrg *) 80327204935cSmrg func_warning "'-L' is ignored for archives/objects" 80331016ad83Smrg ;; 80341016ad83Smrg esac # linkmode 80351016ad83Smrg continue 80361016ad83Smrg ;; # -L 80371016ad83Smrg -R*) 80387204935cSmrg if test link = "$pass"; then 80391016ad83Smrg func_stripname '-R' '' "$deplib" 80401016ad83Smrg func_resolve_sysroot "$func_stripname_result" 80411016ad83Smrg dir=$func_resolve_sysroot_result 80421016ad83Smrg # Make sure the xrpath contains only unique directories. 80431016ad83Smrg case "$xrpath " in 80441016ad83Smrg *" $dir "*) ;; 80451016ad83Smrg *) func_append xrpath " $dir" ;; 80461016ad83Smrg esac 80471016ad83Smrg fi 80481016ad83Smrg deplibs="$deplib $deplibs" 80491016ad83Smrg continue 80501016ad83Smrg ;; 80511016ad83Smrg *.la) 80521016ad83Smrg func_resolve_sysroot "$deplib" 80531016ad83Smrg lib=$func_resolve_sysroot_result 80541016ad83Smrg ;; 80551016ad83Smrg *.$libext) 80567204935cSmrg if test conv = "$pass"; then 80571016ad83Smrg deplibs="$deplib $deplibs" 80581016ad83Smrg continue 80591016ad83Smrg fi 80601016ad83Smrg case $linkmode in 80611016ad83Smrg lib) 80621016ad83Smrg # Linking convenience modules into shared libraries is allowed, 80631016ad83Smrg # but linking other static libraries is non-portable. 80641016ad83Smrg case " $dlpreconveniencelibs " in 80651016ad83Smrg *" $deplib "*) ;; 80661016ad83Smrg *) 80677204935cSmrg valid_a_lib=false 80681016ad83Smrg case $deplibs_check_method in 80691016ad83Smrg match_pattern*) 80701016ad83Smrg set dummy $deplibs_check_method; shift 80711016ad83Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 80721016ad83Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 80731016ad83Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80747204935cSmrg valid_a_lib=: 80751016ad83Smrg fi 80761016ad83Smrg ;; 80771016ad83Smrg pass_all) 80787204935cSmrg valid_a_lib=: 80791016ad83Smrg ;; 80801016ad83Smrg esac 80817204935cSmrg if $valid_a_lib; then 80827204935cSmrg echo 80837204935cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 80847204935cSmrg $ECHO "*** static library $deplib is not portable!" 80857204935cSmrg deplibs="$deplib $deplibs" 80867204935cSmrg else 80871016ad83Smrg echo 80881016ad83Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 80891016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 80901016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 80911016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 80921016ad83Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 80931016ad83Smrg echo "*** that it is just a static archive that I should not use here." 80941016ad83Smrg fi 80951016ad83Smrg ;; 80961016ad83Smrg esac 80971016ad83Smrg continue 80981016ad83Smrg ;; 80991016ad83Smrg prog) 81007204935cSmrg if test link != "$pass"; then 81011016ad83Smrg deplibs="$deplib $deplibs" 81021016ad83Smrg else 81031016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 81041016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 81051016ad83Smrg fi 81061016ad83Smrg continue 81071016ad83Smrg ;; 81081016ad83Smrg esac # linkmode 81091016ad83Smrg ;; # *.$libext 81101016ad83Smrg *.lo | *.$objext) 81117204935cSmrg if test conv = "$pass"; then 81121016ad83Smrg deplibs="$deplib $deplibs" 81137204935cSmrg elif test prog = "$linkmode"; then 81147204935cSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 81151016ad83Smrg # If there is no dlopen support or we're linking statically, 81161016ad83Smrg # we need to preload. 81171016ad83Smrg func_append newdlprefiles " $deplib" 81181016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 81191016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 81201016ad83Smrg else 81211016ad83Smrg func_append newdlfiles " $deplib" 81221016ad83Smrg fi 81231016ad83Smrg fi 81241016ad83Smrg continue 81251016ad83Smrg ;; 81261016ad83Smrg %DEPLIBS%) 81277204935cSmrg alldeplibs=: 81281016ad83Smrg continue 81291016ad83Smrg ;; 81301016ad83Smrg esac # case $deplib 81311016ad83Smrg 81327204935cSmrg $found || test -f "$lib" \ 81337204935cSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 81341016ad83Smrg 81351016ad83Smrg # Check to see that this really is a libtool archive. 81361016ad83Smrg func_lalib_unsafe_p "$lib" \ 81377204935cSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 81381016ad83Smrg 81391016ad83Smrg func_dirname "$lib" "" "." 81407204935cSmrg ladir=$func_dirname_result 81411016ad83Smrg 81421016ad83Smrg dlname= 81431016ad83Smrg dlopen= 81441016ad83Smrg dlpreopen= 81451016ad83Smrg libdir= 81461016ad83Smrg library_names= 81471016ad83Smrg old_library= 81481016ad83Smrg inherited_linker_flags= 81491016ad83Smrg # If the library was installed with an old release of libtool, 81501016ad83Smrg # it will not redefine variables installed, or shouldnotlink 81511016ad83Smrg installed=yes 81521016ad83Smrg shouldnotlink=no 81531016ad83Smrg avoidtemprpath= 81541016ad83Smrg 81551016ad83Smrg 81561016ad83Smrg # Read the .la file 81571016ad83Smrg func_source "$lib" 81581016ad83Smrg 81591016ad83Smrg # Convert "-framework foo" to "foo.ltframework" 81601016ad83Smrg if test -n "$inherited_linker_flags"; then 81611016ad83Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 81621016ad83Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 81631016ad83Smrg case " $new_inherited_linker_flags " in 81641016ad83Smrg *" $tmp_inherited_linker_flag "*) ;; 81651016ad83Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 81661016ad83Smrg esac 81671016ad83Smrg done 81681016ad83Smrg fi 81691016ad83Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81707204935cSmrg if test lib,link = "$linkmode,$pass" || 81717204935cSmrg test prog,scan = "$linkmode,$pass" || 81727204935cSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 81731016ad83Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 81741016ad83Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 81751016ad83Smrg fi 81761016ad83Smrg 81777204935cSmrg if test conv = "$pass"; then 81781016ad83Smrg # Only check for convenience libraries 81791016ad83Smrg deplibs="$lib $deplibs" 81801016ad83Smrg if test -z "$libdir"; then 81811016ad83Smrg if test -z "$old_library"; then 81827204935cSmrg func_fatal_error "cannot find name of link library for '$lib'" 81831016ad83Smrg fi 81841016ad83Smrg # It is a libtool convenience library, so add in its objects. 81851016ad83Smrg func_append convenience " $ladir/$objdir/$old_library" 81861016ad83Smrg func_append old_convenience " $ladir/$objdir/$old_library" 81877204935cSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81887204935cSmrg func_fatal_error "'$lib' is not a convenience library" 81891016ad83Smrg fi 8190aa30ed02Smrg tmp_libs= 8191aa30ed02Smrg for deplib in $dependency_libs; do 8192aa30ed02Smrg deplibs="$deplib $deplibs" 8193aa30ed02Smrg if $opt_preserve_dup_deps; then 8194aa30ed02Smrg case "$tmp_libs " in 8195aa30ed02Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8196aa30ed02Smrg esac 8197aa30ed02Smrg fi 8198aa30ed02Smrg func_append tmp_libs " $deplib" 8199aa30ed02Smrg done 82001016ad83Smrg continue 82011016ad83Smrg fi # $pass = conv 82021016ad83Smrg 82031016ad83Smrg 82041016ad83Smrg # Get the name of the library we link against. 82051016ad83Smrg linklib= 82061016ad83Smrg if test -n "$old_library" && 82077204935cSmrg { test yes = "$prefer_static_libs" || 82087204935cSmrg test built,no = "$prefer_static_libs,$installed"; }; then 82091016ad83Smrg linklib=$old_library 82101016ad83Smrg else 82111016ad83Smrg for l in $old_library $library_names; do 82127204935cSmrg linklib=$l 82131016ad83Smrg done 82141016ad83Smrg fi 82151016ad83Smrg if test -z "$linklib"; then 82167204935cSmrg func_fatal_error "cannot find name of link library for '$lib'" 82171016ad83Smrg fi 82181016ad83Smrg 82191016ad83Smrg # This library was specified with -dlopen. 82207204935cSmrg if test dlopen = "$pass"; then 82217204935cSmrg test -z "$libdir" \ 82227204935cSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 82231016ad83Smrg if test -z "$dlname" || 82247204935cSmrg test yes != "$dlopen_support" || 82257204935cSmrg test no = "$build_libtool_libs" 82267204935cSmrg then 82271016ad83Smrg # If there is no dlname, no dlopen support or we're linking 82281016ad83Smrg # statically, we need to preload. We also need to preload any 82291016ad83Smrg # dependent libraries so libltdl's deplib preloader doesn't 82301016ad83Smrg # bomb out in the load deplibs phase. 82311016ad83Smrg func_append dlprefiles " $lib $dependency_libs" 82321016ad83Smrg else 82331016ad83Smrg func_append newdlfiles " $lib" 82341016ad83Smrg fi 82351016ad83Smrg continue 82361016ad83Smrg fi # $pass = dlopen 82371016ad83Smrg 82381016ad83Smrg # We need an absolute path. 82391016ad83Smrg case $ladir in 82407204935cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 82411016ad83Smrg *) 82421016ad83Smrg abs_ladir=`cd "$ladir" && pwd` 82431016ad83Smrg if test -z "$abs_ladir"; then 82447204935cSmrg func_warning "cannot determine absolute directory name of '$ladir'" 82451016ad83Smrg func_warning "passing it literally to the linker, although it might fail" 82467204935cSmrg abs_ladir=$ladir 82471016ad83Smrg fi 82481016ad83Smrg ;; 82491016ad83Smrg esac 82501016ad83Smrg func_basename "$lib" 82517204935cSmrg laname=$func_basename_result 82521016ad83Smrg 82531016ad83Smrg # Find the relevant object directory and library name. 82547204935cSmrg if test yes = "$installed"; then 82551016ad83Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82567204935cSmrg func_warning "library '$lib' was moved." 82577204935cSmrg dir=$ladir 82587204935cSmrg absdir=$abs_ladir 82597204935cSmrg libdir=$abs_ladir 82601016ad83Smrg else 82617204935cSmrg dir=$lt_sysroot$libdir 82627204935cSmrg absdir=$lt_sysroot$libdir 82631016ad83Smrg fi 82647204935cSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 82651016ad83Smrg else 82661016ad83Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82677204935cSmrg dir=$ladir 82687204935cSmrg absdir=$abs_ladir 82691016ad83Smrg # Remove this search path later 82701016ad83Smrg func_append notinst_path " $abs_ladir" 82711016ad83Smrg else 82727204935cSmrg dir=$ladir/$objdir 82737204935cSmrg absdir=$abs_ladir/$objdir 82741016ad83Smrg # Remove this search path later 82751016ad83Smrg func_append notinst_path " $abs_ladir" 82761016ad83Smrg fi 82771016ad83Smrg fi # $installed = yes 82781016ad83Smrg func_stripname 'lib' '.la' "$laname" 82791016ad83Smrg name=$func_stripname_result 82801016ad83Smrg 82811016ad83Smrg # This library was specified with -dlpreopen. 82827204935cSmrg if test dlpreopen = "$pass"; then 82837204935cSmrg if test -z "$libdir" && test prog = "$linkmode"; then 82847204935cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 82851016ad83Smrg fi 82867204935cSmrg case $host in 82871016ad83Smrg # special handling for platforms with PE-DLLs. 82881016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 82891016ad83Smrg # Linker will automatically link against shared library if both 82901016ad83Smrg # static and shared are present. Therefore, ensure we extract 82911016ad83Smrg # symbols from the import library if a shared library is present 82921016ad83Smrg # (otherwise, the dlopen module name will be incorrect). We do 82931016ad83Smrg # this by putting the import library name into $newdlprefiles. 82941016ad83Smrg # We recover the dlopen module name by 'saving' the la file 82951016ad83Smrg # name in a special purpose variable, and (later) extracting the 82961016ad83Smrg # dlname from the la file. 82971016ad83Smrg if test -n "$dlname"; then 82981016ad83Smrg func_tr_sh "$dir/$linklib" 82991016ad83Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 83001016ad83Smrg func_append newdlprefiles " $dir/$linklib" 83011016ad83Smrg else 83021016ad83Smrg func_append newdlprefiles " $dir/$old_library" 83031016ad83Smrg # Keep a list of preopened convenience libraries to check 83041016ad83Smrg # that they are being used correctly in the link pass. 83051016ad83Smrg test -z "$libdir" && \ 83061016ad83Smrg func_append dlpreconveniencelibs " $dir/$old_library" 83071016ad83Smrg fi 83081016ad83Smrg ;; 83091016ad83Smrg * ) 83101016ad83Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 83111016ad83Smrg # are required to link). 83121016ad83Smrg if test -n "$old_library"; then 83131016ad83Smrg func_append newdlprefiles " $dir/$old_library" 83141016ad83Smrg # Keep a list of preopened convenience libraries to check 83151016ad83Smrg # that they are being used correctly in the link pass. 83161016ad83Smrg test -z "$libdir" && \ 83171016ad83Smrg func_append dlpreconveniencelibs " $dir/$old_library" 83181016ad83Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 83191016ad83Smrg elif test -n "$dlname"; then 83201016ad83Smrg func_append newdlprefiles " $dir/$dlname" 83211016ad83Smrg else 83221016ad83Smrg func_append newdlprefiles " $dir/$linklib" 83231016ad83Smrg fi 83241016ad83Smrg ;; 83251016ad83Smrg esac 83261016ad83Smrg fi # $pass = dlpreopen 83271016ad83Smrg 83281016ad83Smrg if test -z "$libdir"; then 83291016ad83Smrg # Link the convenience library 83307204935cSmrg if test lib = "$linkmode"; then 83311016ad83Smrg deplibs="$dir/$old_library $deplibs" 83327204935cSmrg elif test prog,link = "$linkmode,$pass"; then 83331016ad83Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 83341016ad83Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 83351016ad83Smrg else 83361016ad83Smrg deplibs="$lib $deplibs" # used for prog,scan pass 83371016ad83Smrg fi 83381016ad83Smrg continue 83391016ad83Smrg fi 83401016ad83Smrg 83411016ad83Smrg 83427204935cSmrg if test prog = "$linkmode" && test link != "$pass"; then 83431016ad83Smrg func_append newlib_search_path " $ladir" 83441016ad83Smrg deplibs="$lib $deplibs" 83451016ad83Smrg 83467204935cSmrg linkalldeplibs=false 83477204935cSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83487204935cSmrg test no = "$build_libtool_libs"; then 83497204935cSmrg linkalldeplibs=: 83501016ad83Smrg fi 83511016ad83Smrg 83521016ad83Smrg tmp_libs= 83531016ad83Smrg for deplib in $dependency_libs; do 83541016ad83Smrg case $deplib in 83551016ad83Smrg -L*) func_stripname '-L' '' "$deplib" 83561016ad83Smrg func_resolve_sysroot "$func_stripname_result" 83571016ad83Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 83581016ad83Smrg ;; 83591016ad83Smrg esac 83601016ad83Smrg # Need to link against all dependency_libs? 83617204935cSmrg if $linkalldeplibs; then 83621016ad83Smrg deplibs="$deplib $deplibs" 83631016ad83Smrg else 83641016ad83Smrg # Need to hardcode shared library paths 83651016ad83Smrg # or/and link against static libraries 83661016ad83Smrg newdependency_libs="$deplib $newdependency_libs" 83671016ad83Smrg fi 83687204935cSmrg if $opt_preserve_dup_deps; then 83691016ad83Smrg case "$tmp_libs " in 83701016ad83Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 83711016ad83Smrg esac 83721016ad83Smrg fi 83731016ad83Smrg func_append tmp_libs " $deplib" 83741016ad83Smrg done # for deplib 83751016ad83Smrg continue 83761016ad83Smrg fi # $linkmode = prog... 83771016ad83Smrg 83787204935cSmrg if test prog,link = "$linkmode,$pass"; then 83791016ad83Smrg if test -n "$library_names" && 83807204935cSmrg { { test no = "$prefer_static_libs" || 83817204935cSmrg test built,yes = "$prefer_static_libs,$installed"; } || 83821016ad83Smrg test -z "$old_library"; }; then 83831016ad83Smrg # We need to hardcode the library path 83847204935cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 83851016ad83Smrg # Make sure the rpath contains only unique directories. 83867204935cSmrg case $temp_rpath: in 83871016ad83Smrg *"$absdir:"*) ;; 83881016ad83Smrg *) func_append temp_rpath "$absdir:" ;; 83891016ad83Smrg esac 83901016ad83Smrg fi 83911016ad83Smrg 83921016ad83Smrg # Hardcode the library path. 83931016ad83Smrg # Skip directories that are in the system default run-time 83941016ad83Smrg # search path. 83951016ad83Smrg case " $sys_lib_dlsearch_path " in 83961016ad83Smrg *" $absdir "*) ;; 83971016ad83Smrg *) 83981016ad83Smrg case "$compile_rpath " in 83991016ad83Smrg *" $absdir "*) ;; 84001016ad83Smrg *) func_append compile_rpath " $absdir" ;; 84011016ad83Smrg esac 84021016ad83Smrg ;; 84031016ad83Smrg esac 84041016ad83Smrg case " $sys_lib_dlsearch_path " in 84051016ad83Smrg *" $libdir "*) ;; 84061016ad83Smrg *) 84071016ad83Smrg case "$finalize_rpath " in 84081016ad83Smrg *" $libdir "*) ;; 84091016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 84101016ad83Smrg esac 84111016ad83Smrg ;; 84121016ad83Smrg esac 84131016ad83Smrg fi # $linkmode,$pass = prog,link... 84141016ad83Smrg 84157204935cSmrg if $alldeplibs && 84167204935cSmrg { test pass_all = "$deplibs_check_method" || 84177204935cSmrg { test yes = "$build_libtool_libs" && 84181016ad83Smrg test -n "$library_names"; }; }; then 84191016ad83Smrg # We only need to search for static libraries 84201016ad83Smrg continue 84211016ad83Smrg fi 84221016ad83Smrg fi 84231016ad83Smrg 84241016ad83Smrg link_static=no # Whether the deplib will be linked statically 84251016ad83Smrg use_static_libs=$prefer_static_libs 84267204935cSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 84271016ad83Smrg use_static_libs=no 84281016ad83Smrg fi 84291016ad83Smrg if test -n "$library_names" && 84307204935cSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 84311016ad83Smrg case $host in 84327204935cSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 84331016ad83Smrg # No point in relinking DLLs because paths are not encoded 84341016ad83Smrg func_append notinst_deplibs " $lib" 84351016ad83Smrg need_relink=no 84361016ad83Smrg ;; 84371016ad83Smrg *) 84387204935cSmrg if test no = "$installed"; then 84391016ad83Smrg func_append notinst_deplibs " $lib" 84401016ad83Smrg need_relink=yes 84411016ad83Smrg fi 84421016ad83Smrg ;; 84431016ad83Smrg esac 84441016ad83Smrg # This is a shared library 84451016ad83Smrg 84461016ad83Smrg # Warn about portability, can't link against -module's on some 84471016ad83Smrg # systems (darwin). Don't bleat about dlopened modules though! 84487204935cSmrg dlopenmodule= 84491016ad83Smrg for dlpremoduletest in $dlprefiles; do 84501016ad83Smrg if test "X$dlpremoduletest" = "X$lib"; then 84517204935cSmrg dlopenmodule=$dlpremoduletest 84521016ad83Smrg break 84531016ad83Smrg fi 84541016ad83Smrg done 84557204935cSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 84561016ad83Smrg echo 84577204935cSmrg if test prog = "$linkmode"; then 84581016ad83Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 84591016ad83Smrg else 84601016ad83Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 84611016ad83Smrg fi 84621016ad83Smrg $ECHO "*** $linklib is not portable!" 84631016ad83Smrg fi 84647204935cSmrg if test lib = "$linkmode" && 84657204935cSmrg test yes = "$hardcode_into_libs"; then 84661016ad83Smrg # Hardcode the library path. 84671016ad83Smrg # Skip directories that are in the system default run-time 84681016ad83Smrg # search path. 84691016ad83Smrg case " $sys_lib_dlsearch_path " in 84701016ad83Smrg *" $absdir "*) ;; 84711016ad83Smrg *) 84721016ad83Smrg case "$compile_rpath " in 84731016ad83Smrg *" $absdir "*) ;; 84741016ad83Smrg *) func_append compile_rpath " $absdir" ;; 84751016ad83Smrg esac 84761016ad83Smrg ;; 84771016ad83Smrg esac 84781016ad83Smrg case " $sys_lib_dlsearch_path " in 84791016ad83Smrg *" $libdir "*) ;; 84801016ad83Smrg *) 84811016ad83Smrg case "$finalize_rpath " in 84821016ad83Smrg *" $libdir "*) ;; 84831016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 84841016ad83Smrg esac 84851016ad83Smrg ;; 84861016ad83Smrg esac 84871016ad83Smrg fi 84881016ad83Smrg 84891016ad83Smrg if test -n "$old_archive_from_expsyms_cmds"; then 84901016ad83Smrg # figure out the soname 84911016ad83Smrg set dummy $library_names 84921016ad83Smrg shift 84937204935cSmrg realname=$1 84941016ad83Smrg shift 84951016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 84961016ad83Smrg # use dlname if we got it. it's perfectly good, no? 84971016ad83Smrg if test -n "$dlname"; then 84987204935cSmrg soname=$dlname 84991016ad83Smrg elif test -n "$soname_spec"; then 85001016ad83Smrg # bleh windows 85011016ad83Smrg case $host in 85027204935cSmrg *cygwin* | mingw* | *cegcc* | *os2*) 85031016ad83Smrg func_arith $current - $age 85041016ad83Smrg major=$func_arith_result 85057204935cSmrg versuffix=-$major 85061016ad83Smrg ;; 85071016ad83Smrg esac 85081016ad83Smrg eval soname=\"$soname_spec\" 85091016ad83Smrg else 85107204935cSmrg soname=$realname 85111016ad83Smrg fi 85121016ad83Smrg 85131016ad83Smrg # Make a new name for the extract_expsyms_cmds to use 85147204935cSmrg soroot=$soname 85151016ad83Smrg func_basename "$soroot" 85167204935cSmrg soname=$func_basename_result 85171016ad83Smrg func_stripname 'lib' '.dll' "$soname" 85181016ad83Smrg newlib=libimp-$func_stripname_result.a 85191016ad83Smrg 85201016ad83Smrg # If the library has no export list, then create one now 85211016ad83Smrg if test -f "$output_objdir/$soname-def"; then : 85221016ad83Smrg else 85237204935cSmrg func_verbose "extracting exported symbol list from '$soname'" 85241016ad83Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 85251016ad83Smrg fi 85261016ad83Smrg 85271016ad83Smrg # Create $newlib 85281016ad83Smrg if test -f "$output_objdir/$newlib"; then :; else 85297204935cSmrg func_verbose "generating import library for '$soname'" 85301016ad83Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 85311016ad83Smrg fi 85321016ad83Smrg # make sure the library variables are pointing to the new library 85331016ad83Smrg dir=$output_objdir 85341016ad83Smrg linklib=$newlib 85351016ad83Smrg fi # test -n "$old_archive_from_expsyms_cmds" 85361016ad83Smrg 85377204935cSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 85381016ad83Smrg add_shlibpath= 85391016ad83Smrg add_dir= 85401016ad83Smrg add= 85411016ad83Smrg lib_linked=yes 85421016ad83Smrg case $hardcode_action in 85431016ad83Smrg immediate | unsupported) 85447204935cSmrg if test no = "$hardcode_direct"; then 85457204935cSmrg add=$dir/$linklib 85461016ad83Smrg case $host in 85477204935cSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85487204935cSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 85491016ad83Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85507204935cSmrg *-*-unixware7*) add_dir=-L$dir ;; 85511016ad83Smrg *-*-darwin* ) 85527204935cSmrg # if the lib is a (non-dlopened) module then we cannot 85531016ad83Smrg # link against it, someone is ignoring the earlier warnings 85541016ad83Smrg if /usr/bin/file -L $add 2> /dev/null | 85557204935cSmrg $GREP ": [^:]* bundle" >/dev/null; then 85561016ad83Smrg if test "X$dlopenmodule" != "X$lib"; then 85571016ad83Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85587204935cSmrg if test -z "$old_library"; then 85591016ad83Smrg echo 85601016ad83Smrg echo "*** And there doesn't seem to be a static archive available" 85611016ad83Smrg echo "*** The link will probably fail, sorry" 85621016ad83Smrg else 85637204935cSmrg add=$dir/$old_library 85641016ad83Smrg fi 85651016ad83Smrg elif test -n "$old_library"; then 85667204935cSmrg add=$dir/$old_library 85671016ad83Smrg fi 85681016ad83Smrg fi 85691016ad83Smrg esac 85707204935cSmrg elif test no = "$hardcode_minus_L"; then 85711016ad83Smrg case $host in 85727204935cSmrg *-*-sunos*) add_shlibpath=$dir ;; 85731016ad83Smrg esac 85747204935cSmrg add_dir=-L$dir 85757204935cSmrg add=-l$name 85767204935cSmrg elif test no = "$hardcode_shlibpath_var"; then 85777204935cSmrg add_shlibpath=$dir 85787204935cSmrg add=-l$name 85791016ad83Smrg else 85801016ad83Smrg lib_linked=no 85811016ad83Smrg fi 85821016ad83Smrg ;; 85831016ad83Smrg relink) 85847204935cSmrg if test yes = "$hardcode_direct" && 85857204935cSmrg test no = "$hardcode_direct_absolute"; then 85867204935cSmrg add=$dir/$linklib 85877204935cSmrg elif test yes = "$hardcode_minus_L"; then 85887204935cSmrg add_dir=-L$absdir 85891016ad83Smrg # Try looking first in the location we're being installed to. 85901016ad83Smrg if test -n "$inst_prefix_dir"; then 85911016ad83Smrg case $libdir in 85921016ad83Smrg [\\/]*) 85931016ad83Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 85941016ad83Smrg ;; 85951016ad83Smrg esac 85961016ad83Smrg fi 85977204935cSmrg add=-l$name 85987204935cSmrg elif test yes = "$hardcode_shlibpath_var"; then 85997204935cSmrg add_shlibpath=$dir 86007204935cSmrg add=-l$name 86011016ad83Smrg else 86021016ad83Smrg lib_linked=no 86031016ad83Smrg fi 86041016ad83Smrg ;; 86051016ad83Smrg *) lib_linked=no ;; 86061016ad83Smrg esac 86071016ad83Smrg 86087204935cSmrg if test yes != "$lib_linked"; then 86091016ad83Smrg func_fatal_configuration "unsupported hardcode properties" 86101016ad83Smrg fi 86111016ad83Smrg 86121016ad83Smrg if test -n "$add_shlibpath"; then 86131016ad83Smrg case :$compile_shlibpath: in 86141016ad83Smrg *":$add_shlibpath:"*) ;; 86151016ad83Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 86161016ad83Smrg esac 86171016ad83Smrg fi 86187204935cSmrg if test prog = "$linkmode"; then 86191016ad83Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 86201016ad83Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 86211016ad83Smrg else 86221016ad83Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86231016ad83Smrg test -n "$add" && deplibs="$add $deplibs" 86247204935cSmrg if test yes != "$hardcode_direct" && 86257204935cSmrg test yes != "$hardcode_minus_L" && 86267204935cSmrg test yes = "$hardcode_shlibpath_var"; then 86271016ad83Smrg case :$finalize_shlibpath: in 86281016ad83Smrg *":$libdir:"*) ;; 86291016ad83Smrg *) func_append finalize_shlibpath "$libdir:" ;; 86301016ad83Smrg esac 86311016ad83Smrg fi 86321016ad83Smrg fi 86331016ad83Smrg fi 86341016ad83Smrg 86357204935cSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 86361016ad83Smrg add_shlibpath= 86371016ad83Smrg add_dir= 86381016ad83Smrg add= 86391016ad83Smrg # Finalize command for both is simple: just hardcode it. 86407204935cSmrg if test yes = "$hardcode_direct" && 86417204935cSmrg test no = "$hardcode_direct_absolute"; then 86427204935cSmrg add=$libdir/$linklib 86437204935cSmrg elif test yes = "$hardcode_minus_L"; then 86447204935cSmrg add_dir=-L$libdir 86457204935cSmrg add=-l$name 86467204935cSmrg elif test yes = "$hardcode_shlibpath_var"; then 86471016ad83Smrg case :$finalize_shlibpath: in 86481016ad83Smrg *":$libdir:"*) ;; 86491016ad83Smrg *) func_append finalize_shlibpath "$libdir:" ;; 86501016ad83Smrg esac 86517204935cSmrg add=-l$name 86527204935cSmrg elif test yes = "$hardcode_automatic"; then 86531016ad83Smrg if test -n "$inst_prefix_dir" && 86547204935cSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86557204935cSmrg add=$inst_prefix_dir$libdir/$linklib 86561016ad83Smrg else 86577204935cSmrg add=$libdir/$linklib 86581016ad83Smrg fi 86591016ad83Smrg else 86601016ad83Smrg # We cannot seem to hardcode it, guess we'll fake it. 86617204935cSmrg add_dir=-L$libdir 86621016ad83Smrg # Try looking first in the location we're being installed to. 86631016ad83Smrg if test -n "$inst_prefix_dir"; then 86641016ad83Smrg case $libdir in 86651016ad83Smrg [\\/]*) 86661016ad83Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 86671016ad83Smrg ;; 86681016ad83Smrg esac 86691016ad83Smrg fi 86707204935cSmrg add=-l$name 86711016ad83Smrg fi 86721016ad83Smrg 86737204935cSmrg if test prog = "$linkmode"; then 86741016ad83Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 86751016ad83Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 86761016ad83Smrg else 86771016ad83Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86781016ad83Smrg test -n "$add" && deplibs="$add $deplibs" 86791016ad83Smrg fi 86801016ad83Smrg fi 86817204935cSmrg elif test prog = "$linkmode"; then 86821016ad83Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 86831016ad83Smrg # is not unsupported. This is valid on all known static and 86841016ad83Smrg # shared platforms. 86857204935cSmrg if test unsupported != "$hardcode_direct"; then 86867204935cSmrg test -n "$old_library" && linklib=$old_library 86871016ad83Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 86881016ad83Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 86891016ad83Smrg else 86901016ad83Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 86911016ad83Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 86921016ad83Smrg fi 86937204935cSmrg elif test yes = "$build_libtool_libs"; then 86941016ad83Smrg # Not a shared library 86957204935cSmrg if test pass_all != "$deplibs_check_method"; then 86961016ad83Smrg # We're trying link a shared library against a static one 86971016ad83Smrg # but the system doesn't support it. 86981016ad83Smrg 86991016ad83Smrg # Just print a warning and add the library to dependency_libs so 87001016ad83Smrg # that the program can be linked against the static library. 87011016ad83Smrg echo 87027204935cSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 87031016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 87041016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 87051016ad83Smrg echo "*** shared version of the library, which you do not appear to have." 87067204935cSmrg if test yes = "$module"; then 87071016ad83Smrg echo "*** But as you try to build a module library, libtool will still create " 87081016ad83Smrg echo "*** a static module, that should work as long as the dlopening application" 87091016ad83Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 87101016ad83Smrg if test -z "$global_symbol_pipe"; then 87111016ad83Smrg echo 87121016ad83Smrg echo "*** However, this would only work if libtool was able to extract symbol" 87137204935cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 87141016ad83Smrg echo "*** not find such a program. So, this module is probably useless." 87157204935cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 87161016ad83Smrg fi 87177204935cSmrg if test no = "$build_old_libs"; then 87181016ad83Smrg build_libtool_libs=module 87191016ad83Smrg build_old_libs=yes 87201016ad83Smrg else 87211016ad83Smrg build_libtool_libs=no 87221016ad83Smrg fi 87231016ad83Smrg fi 87241016ad83Smrg else 87251016ad83Smrg deplibs="$dir/$old_library $deplibs" 87261016ad83Smrg link_static=yes 87271016ad83Smrg fi 87281016ad83Smrg fi # link shared/static library? 87291016ad83Smrg 87307204935cSmrg if test lib = "$linkmode"; then 87311016ad83Smrg if test -n "$dependency_libs" && 87327204935cSmrg { test yes != "$hardcode_into_libs" || 87337204935cSmrg test yes = "$build_old_libs" || 87347204935cSmrg test yes = "$link_static"; }; then 87351016ad83Smrg # Extract -R from dependency_libs 87361016ad83Smrg temp_deplibs= 87371016ad83Smrg for libdir in $dependency_libs; do 87381016ad83Smrg case $libdir in 87391016ad83Smrg -R*) func_stripname '-R' '' "$libdir" 87401016ad83Smrg temp_xrpath=$func_stripname_result 87411016ad83Smrg case " $xrpath " in 87421016ad83Smrg *" $temp_xrpath "*) ;; 87431016ad83Smrg *) func_append xrpath " $temp_xrpath";; 87441016ad83Smrg esac;; 87451016ad83Smrg *) func_append temp_deplibs " $libdir";; 87461016ad83Smrg esac 87471016ad83Smrg done 87487204935cSmrg dependency_libs=$temp_deplibs 87491016ad83Smrg fi 87501016ad83Smrg 87511016ad83Smrg func_append newlib_search_path " $absdir" 87521016ad83Smrg # Link against this library 87537204935cSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 87541016ad83Smrg # ... and its dependency_libs 87551016ad83Smrg tmp_libs= 87561016ad83Smrg for deplib in $dependency_libs; do 87571016ad83Smrg newdependency_libs="$deplib $newdependency_libs" 87581016ad83Smrg case $deplib in 87591016ad83Smrg -L*) func_stripname '-L' '' "$deplib" 87601016ad83Smrg func_resolve_sysroot "$func_stripname_result";; 87611016ad83Smrg *) func_resolve_sysroot "$deplib" ;; 87621016ad83Smrg esac 87637204935cSmrg if $opt_preserve_dup_deps; then 87641016ad83Smrg case "$tmp_libs " in 87651016ad83Smrg *" $func_resolve_sysroot_result "*) 87661016ad83Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 87671016ad83Smrg esac 87681016ad83Smrg fi 87691016ad83Smrg func_append tmp_libs " $func_resolve_sysroot_result" 87701016ad83Smrg done 87711016ad83Smrg 87727204935cSmrg if test no != "$link_all_deplibs"; then 87731016ad83Smrg # Add the search paths of all dependency libraries 87741016ad83Smrg for deplib in $dependency_libs; do 87751016ad83Smrg path= 87761016ad83Smrg case $deplib in 87777204935cSmrg -L*) path=$deplib ;; 87781016ad83Smrg *.la) 87791016ad83Smrg func_resolve_sysroot "$deplib" 87801016ad83Smrg deplib=$func_resolve_sysroot_result 87811016ad83Smrg func_dirname "$deplib" "" "." 87821016ad83Smrg dir=$func_dirname_result 87831016ad83Smrg # We need an absolute path. 87841016ad83Smrg case $dir in 87857204935cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 87861016ad83Smrg *) 87871016ad83Smrg absdir=`cd "$dir" && pwd` 87881016ad83Smrg if test -z "$absdir"; then 87897204935cSmrg func_warning "cannot determine absolute directory name of '$dir'" 87907204935cSmrg absdir=$dir 87911016ad83Smrg fi 87921016ad83Smrg ;; 87931016ad83Smrg esac 87941016ad83Smrg if $GREP "^installed=no" $deplib > /dev/null; then 87951016ad83Smrg case $host in 87961016ad83Smrg *-*-darwin*) 87971016ad83Smrg depdepl= 87987204935cSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87997204935cSmrg if test -n "$deplibrary_names"; then 88007204935cSmrg for tmp in $deplibrary_names; do 88011016ad83Smrg depdepl=$tmp 88021016ad83Smrg done 88037204935cSmrg if test -f "$absdir/$objdir/$depdepl"; then 88047204935cSmrg depdepl=$absdir/$objdir/$depdepl 88057204935cSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 88061016ad83Smrg if test -z "$darwin_install_name"; then 88077204935cSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 88081016ad83Smrg fi 88097204935cSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 88107204935cSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 88111016ad83Smrg path= 88121016ad83Smrg fi 88131016ad83Smrg fi 88141016ad83Smrg ;; 88151016ad83Smrg *) 88167204935cSmrg path=-L$absdir/$objdir 88171016ad83Smrg ;; 88181016ad83Smrg esac 88191016ad83Smrg else 88207204935cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 88211016ad83Smrg test -z "$libdir" && \ 88227204935cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 88231016ad83Smrg test "$absdir" != "$libdir" && \ 88247204935cSmrg func_warning "'$deplib' seems to be moved" 88251016ad83Smrg 88267204935cSmrg path=-L$absdir 88271016ad83Smrg fi 88281016ad83Smrg ;; 88291016ad83Smrg esac 88301016ad83Smrg case " $deplibs " in 88311016ad83Smrg *" $path "*) ;; 88321016ad83Smrg *) deplibs="$path $deplibs" ;; 88331016ad83Smrg esac 88341016ad83Smrg done 88351016ad83Smrg fi # link_all_deplibs != no 88361016ad83Smrg fi # linkmode = lib 88371016ad83Smrg done # for deplib in $libs 88387204935cSmrg if test link = "$pass"; then 88397204935cSmrg if test prog = "$linkmode"; then 88401016ad83Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 88411016ad83Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 88421016ad83Smrg else 88431016ad83Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 88441016ad83Smrg fi 88451016ad83Smrg fi 88467204935cSmrg dependency_libs=$newdependency_libs 88477204935cSmrg if test dlpreopen = "$pass"; then 88481016ad83Smrg # Link the dlpreopened libraries before other libraries 88491016ad83Smrg for deplib in $save_deplibs; do 88501016ad83Smrg deplibs="$deplib $deplibs" 88511016ad83Smrg done 88521016ad83Smrg fi 88537204935cSmrg if test dlopen != "$pass"; then 88547204935cSmrg test conv = "$pass" || { 88551016ad83Smrg # Make sure lib_search_path contains only unique directories. 88561016ad83Smrg lib_search_path= 88571016ad83Smrg for dir in $newlib_search_path; do 88581016ad83Smrg case "$lib_search_path " in 88591016ad83Smrg *" $dir "*) ;; 88601016ad83Smrg *) func_append lib_search_path " $dir" ;; 88611016ad83Smrg esac 88621016ad83Smrg done 88631016ad83Smrg newlib_search_path= 88647204935cSmrg } 88651016ad83Smrg 88667204935cSmrg if test prog,link = "$linkmode,$pass"; then 88671016ad83Smrg vars="compile_deplibs finalize_deplibs" 88687204935cSmrg else 88697204935cSmrg vars=deplibs 88701016ad83Smrg fi 88711016ad83Smrg for var in $vars dependency_libs; do 88721016ad83Smrg # Add libraries to $var in reverse order 88731016ad83Smrg eval tmp_libs=\"\$$var\" 88741016ad83Smrg new_libs= 88751016ad83Smrg for deplib in $tmp_libs; do 88761016ad83Smrg # FIXME: Pedantically, this is the right thing to do, so 88771016ad83Smrg # that some nasty dependency loop isn't accidentally 88781016ad83Smrg # broken: 88791016ad83Smrg #new_libs="$deplib $new_libs" 88801016ad83Smrg # Pragmatically, this seems to cause very few problems in 88811016ad83Smrg # practice: 88821016ad83Smrg case $deplib in 88831016ad83Smrg -L*) new_libs="$deplib $new_libs" ;; 88841016ad83Smrg -R*) ;; 88851016ad83Smrg *) 88861016ad83Smrg # And here is the reason: when a library appears more 88871016ad83Smrg # than once as an explicit dependence of a library, or 88881016ad83Smrg # is implicitly linked in more than once by the 88891016ad83Smrg # compiler, it is considered special, and multiple 88901016ad83Smrg # occurrences thereof are not removed. Compare this 88911016ad83Smrg # with having the same library being listed as a 88921016ad83Smrg # dependency of multiple other libraries: in this case, 88931016ad83Smrg # we know (pedantically, we assume) the library does not 88941016ad83Smrg # need to be listed more than once, so we keep only the 88951016ad83Smrg # last copy. This is not always right, but it is rare 88961016ad83Smrg # enough that we require users that really mean to play 88971016ad83Smrg # such unportable linking tricks to link the library 88981016ad83Smrg # using -Wl,-lname, so that libtool does not consider it 88991016ad83Smrg # for duplicate removal. 89001016ad83Smrg case " $specialdeplibs " in 89011016ad83Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 89021016ad83Smrg *) 89031016ad83Smrg case " $new_libs " in 89041016ad83Smrg *" $deplib "*) ;; 89051016ad83Smrg *) new_libs="$deplib $new_libs" ;; 89061016ad83Smrg esac 89071016ad83Smrg ;; 89081016ad83Smrg esac 89091016ad83Smrg ;; 89101016ad83Smrg esac 89111016ad83Smrg done 89121016ad83Smrg tmp_libs= 89131016ad83Smrg for deplib in $new_libs; do 89141016ad83Smrg case $deplib in 89151016ad83Smrg -L*) 89161016ad83Smrg case " $tmp_libs " in 89171016ad83Smrg *" $deplib "*) ;; 89181016ad83Smrg *) func_append tmp_libs " $deplib" ;; 89191016ad83Smrg esac 89201016ad83Smrg ;; 89211016ad83Smrg *) func_append tmp_libs " $deplib" ;; 89221016ad83Smrg esac 89231016ad83Smrg done 89241016ad83Smrg eval $var=\"$tmp_libs\" 89251016ad83Smrg done # for var 89261016ad83Smrg fi 89277204935cSmrg 89287204935cSmrg # Add Sun CC postdeps if required: 89297204935cSmrg test CXX = "$tagname" && { 89307204935cSmrg case $host_os in 89317204935cSmrg linux*) 8932b9526c6aSmrg case `$CC -V 2>&1 | $SED 5q` in 89337204935cSmrg *Sun\ C*) # Sun C++ 5.9 89347204935cSmrg func_suncc_cstd_abi 89357204935cSmrg 89367204935cSmrg if test no != "$suncc_use_cstd_abi"; then 89377204935cSmrg func_append postdeps ' -library=Cstd -library=Crun' 89387204935cSmrg fi 89397204935cSmrg ;; 89407204935cSmrg esac 89417204935cSmrg ;; 89427204935cSmrg 89437204935cSmrg solaris*) 89447204935cSmrg func_cc_basename "$CC" 89457204935cSmrg case $func_cc_basename_result in 89467204935cSmrg CC* | sunCC*) 89477204935cSmrg func_suncc_cstd_abi 89487204935cSmrg 89497204935cSmrg if test no != "$suncc_use_cstd_abi"; then 89507204935cSmrg func_append postdeps ' -library=Cstd -library=Crun' 89517204935cSmrg fi 89527204935cSmrg ;; 89537204935cSmrg esac 89547204935cSmrg ;; 89557204935cSmrg esac 89567204935cSmrg } 89577204935cSmrg 89581016ad83Smrg # Last step: remove runtime libs from dependency_libs 89591016ad83Smrg # (they stay in deplibs) 89601016ad83Smrg tmp_libs= 89617204935cSmrg for i in $dependency_libs; do 89621016ad83Smrg case " $predeps $postdeps $compiler_lib_search_path " in 89631016ad83Smrg *" $i "*) 89647204935cSmrg i= 89651016ad83Smrg ;; 89661016ad83Smrg esac 89677204935cSmrg if test -n "$i"; then 89681016ad83Smrg func_append tmp_libs " $i" 89691016ad83Smrg fi 89701016ad83Smrg done 89711016ad83Smrg dependency_libs=$tmp_libs 89721016ad83Smrg done # for pass 89737204935cSmrg if test prog = "$linkmode"; then 89747204935cSmrg dlfiles=$newdlfiles 89751016ad83Smrg fi 89767204935cSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89777204935cSmrg dlprefiles=$newdlprefiles 89781016ad83Smrg fi 89791016ad83Smrg 89801016ad83Smrg case $linkmode in 89811016ad83Smrg oldlib) 89827204935cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89837204935cSmrg func_warning "'-dlopen' is ignored for archives" 89841016ad83Smrg fi 89851016ad83Smrg 89861016ad83Smrg case " $deplibs" in 89871016ad83Smrg *\ -l* | *\ -L*) 89887204935cSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 89891016ad83Smrg esac 89901016ad83Smrg 89911016ad83Smrg test -n "$rpath" && \ 89927204935cSmrg func_warning "'-rpath' is ignored for archives" 89931016ad83Smrg 89941016ad83Smrg test -n "$xrpath" && \ 89957204935cSmrg func_warning "'-R' is ignored for archives" 89961016ad83Smrg 89971016ad83Smrg test -n "$vinfo" && \ 89987204935cSmrg func_warning "'-version-info/-version-number' is ignored for archives" 89991016ad83Smrg 90001016ad83Smrg test -n "$release" && \ 90017204935cSmrg func_warning "'-release' is ignored for archives" 90021016ad83Smrg 90031016ad83Smrg test -n "$export_symbols$export_symbols_regex" && \ 90047204935cSmrg func_warning "'-export-symbols' is ignored for archives" 90051016ad83Smrg 90061016ad83Smrg # Now set the variables for building old libraries. 90071016ad83Smrg build_libtool_libs=no 90087204935cSmrg oldlibs=$output 90091016ad83Smrg func_append objs "$old_deplibs" 90101016ad83Smrg ;; 90111016ad83Smrg 90121016ad83Smrg lib) 90137204935cSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 90141016ad83Smrg case $outputname in 90151016ad83Smrg lib*) 90161016ad83Smrg func_stripname 'lib' '.la' "$outputname" 90171016ad83Smrg name=$func_stripname_result 90181016ad83Smrg eval shared_ext=\"$shrext_cmds\" 90191016ad83Smrg eval libname=\"$libname_spec\" 90201016ad83Smrg ;; 90211016ad83Smrg *) 90227204935cSmrg test no = "$module" \ 90237204935cSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 90241016ad83Smrg 90257204935cSmrg if test no != "$need_lib_prefix"; then 90261016ad83Smrg # Add the "lib" prefix for modules if required 90271016ad83Smrg func_stripname '' '.la' "$outputname" 90281016ad83Smrg name=$func_stripname_result 90291016ad83Smrg eval shared_ext=\"$shrext_cmds\" 90301016ad83Smrg eval libname=\"$libname_spec\" 90311016ad83Smrg else 90321016ad83Smrg func_stripname '' '.la' "$outputname" 90331016ad83Smrg libname=$func_stripname_result 90341016ad83Smrg fi 90351016ad83Smrg ;; 90361016ad83Smrg esac 90371016ad83Smrg 90381016ad83Smrg if test -n "$objs"; then 90397204935cSmrg if test pass_all != "$deplibs_check_method"; then 90407204935cSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 90411016ad83Smrg else 90421016ad83Smrg echo 90431016ad83Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 90441016ad83Smrg $ECHO "*** objects $objs is not portable!" 90451016ad83Smrg func_append libobjs " $objs" 90461016ad83Smrg fi 90471016ad83Smrg fi 90481016ad83Smrg 90497204935cSmrg test no = "$dlself" \ 90507204935cSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 90511016ad83Smrg 90521016ad83Smrg set dummy $rpath 90531016ad83Smrg shift 90547204935cSmrg test 1 -lt "$#" \ 90557204935cSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 90561016ad83Smrg 90577204935cSmrg install_libdir=$1 90581016ad83Smrg 90591016ad83Smrg oldlibs= 90601016ad83Smrg if test -z "$rpath"; then 90617204935cSmrg if test yes = "$build_libtool_libs"; then 90621016ad83Smrg # Building a libtool convenience library. 90637204935cSmrg # Some compilers have problems with a '.al' extension so 90641016ad83Smrg # convenience libraries should have the same extension an 90651016ad83Smrg # archive normally would. 90661016ad83Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 90671016ad83Smrg build_libtool_libs=convenience 90681016ad83Smrg build_old_libs=yes 90691016ad83Smrg fi 90701016ad83Smrg 90711016ad83Smrg test -n "$vinfo" && \ 90727204935cSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 90731016ad83Smrg 90741016ad83Smrg test -n "$release" && \ 90757204935cSmrg func_warning "'-release' is ignored for convenience libraries" 90761016ad83Smrg else 90771016ad83Smrg 90781016ad83Smrg # Parse the version information argument. 90797204935cSmrg save_ifs=$IFS; IFS=: 90801016ad83Smrg set dummy $vinfo 0 0 0 90811016ad83Smrg shift 90827204935cSmrg IFS=$save_ifs 90831016ad83Smrg 90841016ad83Smrg test -n "$7" && \ 90857204935cSmrg func_fatal_help "too many parameters to '-version-info'" 90861016ad83Smrg 90871016ad83Smrg # convert absolute version numbers to libtool ages 90881016ad83Smrg # this retains compatibility with .la files and attempts 90891016ad83Smrg # to make the code below a bit more comprehensible 90901016ad83Smrg 90911016ad83Smrg case $vinfo_number in 90921016ad83Smrg yes) 90937204935cSmrg number_major=$1 90947204935cSmrg number_minor=$2 90957204935cSmrg number_revision=$3 90961016ad83Smrg # 90971016ad83Smrg # There are really only two kinds -- those that 90981016ad83Smrg # use the current revision as the major version 90991016ad83Smrg # and those that subtract age and use age as 91001016ad83Smrg # a minor version. But, then there is irix 91017204935cSmrg # that has an extra 1 added just for fun 91021016ad83Smrg # 91031016ad83Smrg case $version_type in 91041016ad83Smrg # correct linux to gnu/linux during the next big refactor 9105b9526c6aSmrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 91061016ad83Smrg func_arith $number_major + $number_minor 91071016ad83Smrg current=$func_arith_result 91087204935cSmrg age=$number_minor 91097204935cSmrg revision=$number_revision 91101016ad83Smrg ;; 91117204935cSmrg freebsd-aout|qnx|sunos) 91127204935cSmrg current=$number_major 91137204935cSmrg revision=$number_minor 91147204935cSmrg age=0 91151016ad83Smrg ;; 91161016ad83Smrg irix|nonstopux) 91171016ad83Smrg func_arith $number_major + $number_minor 91181016ad83Smrg current=$func_arith_result 91197204935cSmrg age=$number_minor 91207204935cSmrg revision=$number_minor 91211016ad83Smrg lt_irix_increment=no 91221016ad83Smrg ;; 91231016ad83Smrg esac 91241016ad83Smrg ;; 91251016ad83Smrg no) 91267204935cSmrg current=$1 91277204935cSmrg revision=$2 91287204935cSmrg age=$3 91291016ad83Smrg ;; 91301016ad83Smrg esac 91311016ad83Smrg 91321016ad83Smrg # Check that each of the things are valid numbers. 91331016ad83Smrg case $current in 91341016ad83Smrg 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]) ;; 91351016ad83Smrg *) 91367204935cSmrg func_error "CURRENT '$current' must be a nonnegative integer" 91377204935cSmrg func_fatal_error "'$vinfo' is not valid version information" 91381016ad83Smrg ;; 91391016ad83Smrg esac 91401016ad83Smrg 91411016ad83Smrg case $revision in 91421016ad83Smrg 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]) ;; 91431016ad83Smrg *) 91447204935cSmrg func_error "REVISION '$revision' must be a nonnegative integer" 91457204935cSmrg func_fatal_error "'$vinfo' is not valid version information" 91461016ad83Smrg ;; 91471016ad83Smrg esac 91481016ad83Smrg 91491016ad83Smrg case $age in 91501016ad83Smrg 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]) ;; 91511016ad83Smrg *) 91527204935cSmrg func_error "AGE '$age' must be a nonnegative integer" 91537204935cSmrg func_fatal_error "'$vinfo' is not valid version information" 91541016ad83Smrg ;; 91551016ad83Smrg esac 91561016ad83Smrg 91571016ad83Smrg if test "$age" -gt "$current"; then 91587204935cSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 91597204935cSmrg func_fatal_error "'$vinfo' is not valid version information" 91601016ad83Smrg fi 91611016ad83Smrg 91621016ad83Smrg # Calculate the version variables. 91631016ad83Smrg major= 91641016ad83Smrg versuffix= 91651016ad83Smrg verstring= 91661016ad83Smrg case $version_type in 91671016ad83Smrg none) ;; 91681016ad83Smrg 91691016ad83Smrg darwin) 91701016ad83Smrg # Like Linux, but with the current version available in 91711016ad83Smrg # verstring for coding it into the library header 91721016ad83Smrg func_arith $current - $age 91731016ad83Smrg major=.$func_arith_result 91747204935cSmrg versuffix=$major.$age.$revision 91751016ad83Smrg # Darwin ld doesn't like 0 for these options... 91761016ad83Smrg func_arith $current + 1 91771016ad83Smrg minor_current=$func_arith_result 91787204935cSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91791016ad83Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91807204935cSmrg # On Darwin other compilers 91817204935cSmrg case $CC in 91827204935cSmrg nagfor*) 91837204935cSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91847204935cSmrg ;; 91857204935cSmrg *) 91867204935cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91877204935cSmrg ;; 91887204935cSmrg esac 91891016ad83Smrg ;; 91901016ad83Smrg 91911016ad83Smrg freebsd-aout) 91927204935cSmrg major=.$current 91937204935cSmrg versuffix=.$current.$revision 91941016ad83Smrg ;; 91951016ad83Smrg 9196b9526c6aSmrg freebsd-elf | midnightbsd-elf) 91977204935cSmrg func_arith $current - $age 91987204935cSmrg major=.$func_arith_result 91997204935cSmrg versuffix=$major.$age.$revision 92001016ad83Smrg ;; 92011016ad83Smrg 92021016ad83Smrg irix | nonstopux) 92037204935cSmrg if test no = "$lt_irix_increment"; then 92041016ad83Smrg func_arith $current - $age 92051016ad83Smrg else 92061016ad83Smrg func_arith $current - $age + 1 92071016ad83Smrg fi 92081016ad83Smrg major=$func_arith_result 92091016ad83Smrg 92101016ad83Smrg case $version_type in 92111016ad83Smrg nonstopux) verstring_prefix=nonstopux ;; 92121016ad83Smrg *) verstring_prefix=sgi ;; 92131016ad83Smrg esac 92147204935cSmrg verstring=$verstring_prefix$major.$revision 92151016ad83Smrg 92161016ad83Smrg # Add in all the interfaces that we are compatible with. 92171016ad83Smrg loop=$revision 92187204935cSmrg while test 0 -ne "$loop"; do 92191016ad83Smrg func_arith $revision - $loop 92201016ad83Smrg iface=$func_arith_result 92211016ad83Smrg func_arith $loop - 1 92221016ad83Smrg loop=$func_arith_result 92237204935cSmrg verstring=$verstring_prefix$major.$iface:$verstring 92241016ad83Smrg done 92251016ad83Smrg 92267204935cSmrg # Before this point, $major must not contain '.'. 92271016ad83Smrg major=.$major 92287204935cSmrg versuffix=$major.$revision 92291016ad83Smrg ;; 92301016ad83Smrg 92311016ad83Smrg linux) # correct to gnu/linux during the next big refactor 92321016ad83Smrg func_arith $current - $age 92331016ad83Smrg major=.$func_arith_result 92347204935cSmrg versuffix=$major.$age.$revision 92351016ad83Smrg ;; 92361016ad83Smrg 92371016ad83Smrg osf) 92381016ad83Smrg func_arith $current - $age 92391016ad83Smrg major=.$func_arith_result 92407204935cSmrg versuffix=.$current.$age.$revision 92417204935cSmrg verstring=$current.$age.$revision 92421016ad83Smrg 92431016ad83Smrg # Add in all the interfaces that we are compatible with. 92441016ad83Smrg loop=$age 92457204935cSmrg while test 0 -ne "$loop"; do 92461016ad83Smrg func_arith $current - $loop 92471016ad83Smrg iface=$func_arith_result 92481016ad83Smrg func_arith $loop - 1 92491016ad83Smrg loop=$func_arith_result 92507204935cSmrg verstring=$verstring:$iface.0 92511016ad83Smrg done 92521016ad83Smrg 92531016ad83Smrg # Make executables depend on our current version. 92547204935cSmrg func_append verstring ":$current.0" 92551016ad83Smrg ;; 92561016ad83Smrg 92571016ad83Smrg qnx) 92587204935cSmrg major=.$current 92597204935cSmrg versuffix=.$current 92607204935cSmrg ;; 92617204935cSmrg 92627204935cSmrg sco) 92637204935cSmrg major=.$current 92647204935cSmrg versuffix=.$current 92651016ad83Smrg ;; 92661016ad83Smrg 92671016ad83Smrg sunos) 92687204935cSmrg major=.$current 92697204935cSmrg versuffix=.$current.$revision 92701016ad83Smrg ;; 92711016ad83Smrg 92721016ad83Smrg windows) 92731016ad83Smrg # Use '-' rather than '.', since we only want one 92747204935cSmrg # extension on DOS 8.3 file systems. 92751016ad83Smrg func_arith $current - $age 92761016ad83Smrg major=$func_arith_result 92777204935cSmrg versuffix=-$major 92781016ad83Smrg ;; 92791016ad83Smrg 92801016ad83Smrg *) 92817204935cSmrg func_fatal_configuration "unknown library version type '$version_type'" 92821016ad83Smrg ;; 92831016ad83Smrg esac 92841016ad83Smrg 92851016ad83Smrg # Clear the version info if we defaulted, and they specified a release. 92861016ad83Smrg if test -z "$vinfo" && test -n "$release"; then 92871016ad83Smrg major= 92881016ad83Smrg case $version_type in 92891016ad83Smrg darwin) 92901016ad83Smrg # we can't check for "0.0" in archive_cmds due to quoting 92911016ad83Smrg # problems, so we reset it completely 92921016ad83Smrg verstring= 92931016ad83Smrg ;; 92941016ad83Smrg *) 92957204935cSmrg verstring=0.0 92961016ad83Smrg ;; 92971016ad83Smrg esac 92987204935cSmrg if test no = "$need_version"; then 92991016ad83Smrg versuffix= 93001016ad83Smrg else 93017204935cSmrg versuffix=.0.0 93021016ad83Smrg fi 93031016ad83Smrg fi 93041016ad83Smrg 93051016ad83Smrg # Remove version info from name if versioning should be avoided 93067204935cSmrg if test yes,no = "$avoid_version,$need_version"; then 93071016ad83Smrg major= 93081016ad83Smrg versuffix= 93097204935cSmrg verstring= 93101016ad83Smrg fi 93111016ad83Smrg 93121016ad83Smrg # Check to see if the archive will have undefined symbols. 93137204935cSmrg if test yes = "$allow_undefined"; then 93147204935cSmrg if test unsupported = "$allow_undefined_flag"; then 93157204935cSmrg if test yes = "$build_old_libs"; then 93167204935cSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93177204935cSmrg build_libtool_libs=no 93187204935cSmrg else 93197204935cSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93207204935cSmrg fi 93211016ad83Smrg fi 93221016ad83Smrg else 93231016ad83Smrg # Don't allow undefined symbols. 93247204935cSmrg allow_undefined_flag=$no_undefined_flag 93251016ad83Smrg fi 93261016ad83Smrg 93271016ad83Smrg fi 93281016ad83Smrg 93297204935cSmrg func_generate_dlsyms "$libname" "$libname" : 93301016ad83Smrg func_append libobjs " $symfileobj" 93317204935cSmrg test " " = "$libobjs" && libobjs= 93321016ad83Smrg 93337204935cSmrg if test relink != "$opt_mode"; then 93341016ad83Smrg # Remove our outputs, but don't remove object files since they 93351016ad83Smrg # may have been created when compiling PIC objects. 93361016ad83Smrg removelist= 93371016ad83Smrg tempremovelist=`$ECHO "$output_objdir/*"` 93381016ad83Smrg for p in $tempremovelist; do 93391016ad83Smrg case $p in 93401016ad83Smrg *.$objext | *.gcno) 93411016ad83Smrg ;; 93427204935cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93437204935cSmrg if test -n "$precious_files_regex"; then 93441016ad83Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 93451016ad83Smrg then 93461016ad83Smrg continue 93471016ad83Smrg fi 93481016ad83Smrg fi 93491016ad83Smrg func_append removelist " $p" 93501016ad83Smrg ;; 93511016ad83Smrg *) ;; 93521016ad83Smrg esac 93531016ad83Smrg done 93541016ad83Smrg test -n "$removelist" && \ 93551016ad83Smrg func_show_eval "${RM}r \$removelist" 93561016ad83Smrg fi 93571016ad83Smrg 93581016ad83Smrg # Now set the variables for building old libraries. 93597204935cSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 93601016ad83Smrg func_append oldlibs " $output_objdir/$libname.$libext" 93611016ad83Smrg 93621016ad83Smrg # Transform .lo files to .o files. 93637204935cSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 93641016ad83Smrg fi 93651016ad83Smrg 93661016ad83Smrg # Eliminate all temporary directories. 93671016ad83Smrg #for path in $notinst_path; do 93681016ad83Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 93691016ad83Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 93701016ad83Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 93711016ad83Smrg #done 93721016ad83Smrg 93731016ad83Smrg if test -n "$xrpath"; then 93741016ad83Smrg # If the user specified any rpath flags, then add them. 93751016ad83Smrg temp_xrpath= 93761016ad83Smrg for libdir in $xrpath; do 93771016ad83Smrg func_replace_sysroot "$libdir" 93781016ad83Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 93791016ad83Smrg case "$finalize_rpath " in 93801016ad83Smrg *" $libdir "*) ;; 93811016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 93821016ad83Smrg esac 93831016ad83Smrg done 93847204935cSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 93851016ad83Smrg dependency_libs="$temp_xrpath $dependency_libs" 93861016ad83Smrg fi 93871016ad83Smrg fi 93881016ad83Smrg 93891016ad83Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93907204935cSmrg old_dlfiles=$dlfiles 93911016ad83Smrg dlfiles= 93921016ad83Smrg for lib in $old_dlfiles; do 93931016ad83Smrg case " $dlprefiles $dlfiles " in 93941016ad83Smrg *" $lib "*) ;; 93951016ad83Smrg *) func_append dlfiles " $lib" ;; 93961016ad83Smrg esac 93971016ad83Smrg done 93981016ad83Smrg 93991016ad83Smrg # Make sure dlprefiles contains only unique files 94007204935cSmrg old_dlprefiles=$dlprefiles 94011016ad83Smrg dlprefiles= 94021016ad83Smrg for lib in $old_dlprefiles; do 94031016ad83Smrg case "$dlprefiles " in 94041016ad83Smrg *" $lib "*) ;; 94051016ad83Smrg *) func_append dlprefiles " $lib" ;; 94061016ad83Smrg esac 94071016ad83Smrg done 94081016ad83Smrg 94097204935cSmrg if test yes = "$build_libtool_libs"; then 94101016ad83Smrg if test -n "$rpath"; then 94111016ad83Smrg case $host in 94121016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 94131016ad83Smrg # these systems don't actually have a c library (as such)! 94141016ad83Smrg ;; 94151016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 94161016ad83Smrg # Rhapsody C library is in the System framework 94171016ad83Smrg func_append deplibs " System.ltframework" 94181016ad83Smrg ;; 94191016ad83Smrg *-*-netbsd*) 94201016ad83Smrg # Don't link with libc until the a.out ld.so is fixed. 94211016ad83Smrg ;; 9422b9526c6aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 94231016ad83Smrg # Do not include libc due to us having libc/libc_r. 94241016ad83Smrg ;; 94251016ad83Smrg *-*-sco3.2v5* | *-*-sco5v6*) 94261016ad83Smrg # Causes problems with __ctype 94271016ad83Smrg ;; 94281016ad83Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 94291016ad83Smrg # Compiler inserts libc in the correct place for threads to work 94301016ad83Smrg ;; 94311016ad83Smrg *) 94321016ad83Smrg # Add libc to deplibs on all other systems if necessary. 94337204935cSmrg if test yes = "$build_libtool_need_lc"; then 94341016ad83Smrg func_append deplibs " -lc" 94351016ad83Smrg fi 94361016ad83Smrg ;; 94371016ad83Smrg esac 94381016ad83Smrg fi 94391016ad83Smrg 94401016ad83Smrg # Transform deplibs into only deplibs that can be linked in shared. 94411016ad83Smrg name_save=$name 94421016ad83Smrg libname_save=$libname 94431016ad83Smrg release_save=$release 94441016ad83Smrg versuffix_save=$versuffix 94451016ad83Smrg major_save=$major 94461016ad83Smrg # I'm not sure if I'm treating the release correctly. I think 94471016ad83Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 94481016ad83Smrg # add it in twice. Is that correct? 94497204935cSmrg release= 94507204935cSmrg versuffix= 94517204935cSmrg major= 94521016ad83Smrg newdeplibs= 94531016ad83Smrg droppeddeps=no 94541016ad83Smrg case $deplibs_check_method in 94551016ad83Smrg pass_all) 94561016ad83Smrg # Don't check for shared/static. Everything works. 94571016ad83Smrg # This might be a little naive. We might want to check 94581016ad83Smrg # whether the library exists or not. But this is on 94591016ad83Smrg # osf3 & osf4 and I'm not really sure... Just 94601016ad83Smrg # implementing what was already the behavior. 94611016ad83Smrg newdeplibs=$deplibs 94621016ad83Smrg ;; 94631016ad83Smrg test_compile) 94641016ad83Smrg # This code stresses the "libraries are programs" paradigm to its 94651016ad83Smrg # limits. Maybe even breaks it. We compile a program, linking it 94661016ad83Smrg # against the deplibs as a proxy for the library. Then we can check 94671016ad83Smrg # whether they linked in statically or dynamically with ldd. 94681016ad83Smrg $opt_dry_run || $RM conftest.c 94691016ad83Smrg cat > conftest.c <<EOF 94701016ad83Smrg int main() { return 0; } 94711016ad83SmrgEOF 94721016ad83Smrg $opt_dry_run || $RM conftest 94731016ad83Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 94741016ad83Smrg ldd_output=`ldd conftest` 94751016ad83Smrg for i in $deplibs; do 94761016ad83Smrg case $i in 94771016ad83Smrg -l*) 94781016ad83Smrg func_stripname -l '' "$i" 94791016ad83Smrg name=$func_stripname_result 94807204935cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94811016ad83Smrg case " $predeps $postdeps " in 94821016ad83Smrg *" $i "*) 94831016ad83Smrg func_append newdeplibs " $i" 94847204935cSmrg i= 94851016ad83Smrg ;; 94861016ad83Smrg esac 94871016ad83Smrg fi 94887204935cSmrg if test -n "$i"; then 94891016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 94901016ad83Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 94911016ad83Smrg set dummy $deplib_matches; shift 94921016ad83Smrg deplib_match=$1 94937204935cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 94941016ad83Smrg func_append newdeplibs " $i" 94951016ad83Smrg else 94961016ad83Smrg droppeddeps=yes 94971016ad83Smrg echo 94981016ad83Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 94991016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 95001016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 95011016ad83Smrg echo "*** shared version of the library, which I believe you do not have" 95021016ad83Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 95031016ad83Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 95041016ad83Smrg fi 95051016ad83Smrg fi 95061016ad83Smrg ;; 95071016ad83Smrg *) 95081016ad83Smrg func_append newdeplibs " $i" 95091016ad83Smrg ;; 95101016ad83Smrg esac 95111016ad83Smrg done 95121016ad83Smrg else 95131016ad83Smrg # Error occurred in the first compile. Let's try to salvage 95141016ad83Smrg # the situation: Compile a separate program for each library. 95151016ad83Smrg for i in $deplibs; do 95161016ad83Smrg case $i in 95171016ad83Smrg -l*) 95181016ad83Smrg func_stripname -l '' "$i" 95191016ad83Smrg name=$func_stripname_result 95201016ad83Smrg $opt_dry_run || $RM conftest 95211016ad83Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 95221016ad83Smrg ldd_output=`ldd conftest` 95237204935cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95241016ad83Smrg case " $predeps $postdeps " in 95251016ad83Smrg *" $i "*) 95261016ad83Smrg func_append newdeplibs " $i" 95277204935cSmrg i= 95281016ad83Smrg ;; 95291016ad83Smrg esac 95301016ad83Smrg fi 95317204935cSmrg if test -n "$i"; then 95321016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 95331016ad83Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 95341016ad83Smrg set dummy $deplib_matches; shift 95351016ad83Smrg deplib_match=$1 95367204935cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 95371016ad83Smrg func_append newdeplibs " $i" 95381016ad83Smrg else 95391016ad83Smrg droppeddeps=yes 95401016ad83Smrg echo 95411016ad83Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 95421016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 95431016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 95441016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 95451016ad83Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 95461016ad83Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 95471016ad83Smrg fi 95481016ad83Smrg fi 95491016ad83Smrg else 95501016ad83Smrg droppeddeps=yes 95511016ad83Smrg echo 95521016ad83Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 95531016ad83Smrg echo "*** make it link in! You will probably need to install it or some" 95541016ad83Smrg echo "*** library that it depends on before this library will be fully" 95551016ad83Smrg echo "*** functional. Installing it before continuing would be even better." 95561016ad83Smrg fi 95571016ad83Smrg ;; 95581016ad83Smrg *) 95591016ad83Smrg func_append newdeplibs " $i" 95601016ad83Smrg ;; 95611016ad83Smrg esac 95621016ad83Smrg done 95631016ad83Smrg fi 95641016ad83Smrg ;; 95651016ad83Smrg file_magic*) 95661016ad83Smrg set dummy $deplibs_check_method; shift 95671016ad83Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 95681016ad83Smrg for a_deplib in $deplibs; do 95691016ad83Smrg case $a_deplib in 95701016ad83Smrg -l*) 95711016ad83Smrg func_stripname -l '' "$a_deplib" 95721016ad83Smrg name=$func_stripname_result 95737204935cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95741016ad83Smrg case " $predeps $postdeps " in 95751016ad83Smrg *" $a_deplib "*) 95761016ad83Smrg func_append newdeplibs " $a_deplib" 95777204935cSmrg a_deplib= 95781016ad83Smrg ;; 95791016ad83Smrg esac 95801016ad83Smrg fi 95817204935cSmrg if test -n "$a_deplib"; then 95821016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 95831016ad83Smrg if test -n "$file_magic_glob"; then 95841016ad83Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 95851016ad83Smrg else 95861016ad83Smrg libnameglob=$libname 95871016ad83Smrg fi 95887204935cSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 95891016ad83Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95907204935cSmrg if test yes = "$want_nocaseglob"; then 95911016ad83Smrg shopt -s nocaseglob 95921016ad83Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95931016ad83Smrg $nocaseglob 95941016ad83Smrg else 95951016ad83Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95961016ad83Smrg fi 95971016ad83Smrg for potent_lib in $potential_libs; do 95981016ad83Smrg # Follow soft links. 95991016ad83Smrg if ls -lLd "$potent_lib" 2>/dev/null | 96001016ad83Smrg $GREP " -> " >/dev/null; then 96011016ad83Smrg continue 96021016ad83Smrg fi 96031016ad83Smrg # The statement above tries to avoid entering an 96041016ad83Smrg # endless loop below, in case of cyclic links. 96051016ad83Smrg # We might still enter an endless loop, since a link 96061016ad83Smrg # loop can be closed while we follow links, 96071016ad83Smrg # but so what? 96087204935cSmrg potlib=$potent_lib 96091016ad83Smrg while test -h "$potlib" 2>/dev/null; do 96107204935cSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 96111016ad83Smrg case $potliblink in 96127204935cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96137204935cSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 96141016ad83Smrg esac 96151016ad83Smrg done 96161016ad83Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 96171016ad83Smrg $SED -e 10q | 96181016ad83Smrg $EGREP "$file_magic_regex" > /dev/null; then 96191016ad83Smrg func_append newdeplibs " $a_deplib" 96207204935cSmrg a_deplib= 96211016ad83Smrg break 2 96221016ad83Smrg fi 96231016ad83Smrg done 96241016ad83Smrg done 96251016ad83Smrg fi 96267204935cSmrg if test -n "$a_deplib"; then 96271016ad83Smrg droppeddeps=yes 96281016ad83Smrg echo 96291016ad83Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96301016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 96311016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 96321016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 96331016ad83Smrg echo "*** because I did check the linker path looking for a file starting" 96347204935cSmrg if test -z "$potlib"; then 96351016ad83Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 96361016ad83Smrg else 96371016ad83Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96381016ad83Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 96391016ad83Smrg fi 96401016ad83Smrg fi 96411016ad83Smrg ;; 96421016ad83Smrg *) 96431016ad83Smrg # Add a -L argument. 96441016ad83Smrg func_append newdeplibs " $a_deplib" 96451016ad83Smrg ;; 96461016ad83Smrg esac 96471016ad83Smrg done # Gone through all deplibs. 96481016ad83Smrg ;; 96491016ad83Smrg match_pattern*) 96501016ad83Smrg set dummy $deplibs_check_method; shift 96511016ad83Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 96521016ad83Smrg for a_deplib in $deplibs; do 96531016ad83Smrg case $a_deplib in 96541016ad83Smrg -l*) 96551016ad83Smrg func_stripname -l '' "$a_deplib" 96561016ad83Smrg name=$func_stripname_result 96577204935cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96581016ad83Smrg case " $predeps $postdeps " in 96591016ad83Smrg *" $a_deplib "*) 96601016ad83Smrg func_append newdeplibs " $a_deplib" 96617204935cSmrg a_deplib= 96621016ad83Smrg ;; 96631016ad83Smrg esac 96641016ad83Smrg fi 96657204935cSmrg if test -n "$a_deplib"; then 96661016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 96671016ad83Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 96681016ad83Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 96691016ad83Smrg for potent_lib in $potential_libs; do 96707204935cSmrg potlib=$potent_lib # see symlink-check above in file_magic test 96711016ad83Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 96721016ad83Smrg $EGREP "$match_pattern_regex" > /dev/null; then 96731016ad83Smrg func_append newdeplibs " $a_deplib" 96747204935cSmrg a_deplib= 96751016ad83Smrg break 2 96761016ad83Smrg fi 96771016ad83Smrg done 96781016ad83Smrg done 96791016ad83Smrg fi 96807204935cSmrg if test -n "$a_deplib"; then 96811016ad83Smrg droppeddeps=yes 96821016ad83Smrg echo 96831016ad83Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96841016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 96851016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 96861016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 96871016ad83Smrg echo "*** because I did check the linker path looking for a file starting" 96887204935cSmrg if test -z "$potlib"; then 96891016ad83Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 96901016ad83Smrg else 96911016ad83Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96921016ad83Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 96931016ad83Smrg fi 96941016ad83Smrg fi 96951016ad83Smrg ;; 96961016ad83Smrg *) 96971016ad83Smrg # Add a -L argument. 96981016ad83Smrg func_append newdeplibs " $a_deplib" 96991016ad83Smrg ;; 97001016ad83Smrg esac 97011016ad83Smrg done # Gone through all deplibs. 97021016ad83Smrg ;; 97031016ad83Smrg none | unknown | *) 97047204935cSmrg newdeplibs= 97051016ad83Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 97067204935cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 97077204935cSmrg for i in $predeps $postdeps; do 97081016ad83Smrg # can't use Xsed below, because $i might contain '/' 97097204935cSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 97101016ad83Smrg done 97111016ad83Smrg fi 97121016ad83Smrg case $tmp_deplibs in 97131016ad83Smrg *[!\ \ ]*) 97141016ad83Smrg echo 97157204935cSmrg if test none = "$deplibs_check_method"; then 97161016ad83Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 97171016ad83Smrg else 97181016ad83Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 97191016ad83Smrg fi 97201016ad83Smrg echo "*** All declared inter-library dependencies are being dropped." 97211016ad83Smrg droppeddeps=yes 97221016ad83Smrg ;; 97231016ad83Smrg esac 97241016ad83Smrg ;; 97251016ad83Smrg esac 97261016ad83Smrg versuffix=$versuffix_save 97271016ad83Smrg major=$major_save 97281016ad83Smrg release=$release_save 97291016ad83Smrg libname=$libname_save 97301016ad83Smrg name=$name_save 97311016ad83Smrg 97321016ad83Smrg case $host in 97331016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 97341016ad83Smrg # On Rhapsody replace the C library with the System framework 97351016ad83Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 97361016ad83Smrg ;; 97371016ad83Smrg esac 97381016ad83Smrg 97397204935cSmrg if test yes = "$droppeddeps"; then 97407204935cSmrg if test yes = "$module"; then 97411016ad83Smrg echo 97421016ad83Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 97431016ad83Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 97441016ad83Smrg echo "*** a static module, that should work as long as the dlopening" 97451016ad83Smrg echo "*** application is linked with the -dlopen flag." 97461016ad83Smrg if test -z "$global_symbol_pipe"; then 97471016ad83Smrg echo 97481016ad83Smrg echo "*** However, this would only work if libtool was able to extract symbol" 97497204935cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 97501016ad83Smrg echo "*** not find such a program. So, this module is probably useless." 97517204935cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 97521016ad83Smrg fi 97537204935cSmrg if test no = "$build_old_libs"; then 97547204935cSmrg oldlibs=$output_objdir/$libname.$libext 97551016ad83Smrg build_libtool_libs=module 97561016ad83Smrg build_old_libs=yes 97571016ad83Smrg else 97581016ad83Smrg build_libtool_libs=no 97591016ad83Smrg fi 97601016ad83Smrg else 97611016ad83Smrg echo "*** The inter-library dependencies that have been dropped here will be" 97621016ad83Smrg echo "*** automatically added whenever a program is linked with this library" 97631016ad83Smrg echo "*** or is declared to -dlopen it." 97641016ad83Smrg 97657204935cSmrg if test no = "$allow_undefined"; then 97661016ad83Smrg echo 97671016ad83Smrg echo "*** Since this library must not contain undefined symbols," 97681016ad83Smrg echo "*** because either the platform does not support them or" 97691016ad83Smrg echo "*** it was explicitly requested with -no-undefined," 97701016ad83Smrg echo "*** libtool will only create a static version of it." 97717204935cSmrg if test no = "$build_old_libs"; then 97727204935cSmrg oldlibs=$output_objdir/$libname.$libext 97731016ad83Smrg build_libtool_libs=module 97741016ad83Smrg build_old_libs=yes 97751016ad83Smrg else 97761016ad83Smrg build_libtool_libs=no 97771016ad83Smrg fi 97781016ad83Smrg fi 97791016ad83Smrg fi 97801016ad83Smrg fi 97811016ad83Smrg # Done checking deplibs! 97821016ad83Smrg deplibs=$newdeplibs 97831016ad83Smrg fi 97841016ad83Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 97851016ad83Smrg case $host in 97861016ad83Smrg *-*-darwin*) 97871016ad83Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97881016ad83Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97891016ad83Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97901016ad83Smrg ;; 97911016ad83Smrg esac 97921016ad83Smrg 97931016ad83Smrg # move library search paths that coincide with paths to not yet 97941016ad83Smrg # installed libraries to the beginning of the library search list 97951016ad83Smrg new_libs= 97961016ad83Smrg for path in $notinst_path; do 97971016ad83Smrg case " $new_libs " in 97981016ad83Smrg *" -L$path/$objdir "*) ;; 97991016ad83Smrg *) 98001016ad83Smrg case " $deplibs " in 98011016ad83Smrg *" -L$path/$objdir "*) 98021016ad83Smrg func_append new_libs " -L$path/$objdir" ;; 98031016ad83Smrg esac 98041016ad83Smrg ;; 98051016ad83Smrg esac 98061016ad83Smrg done 98071016ad83Smrg for deplib in $deplibs; do 98081016ad83Smrg case $deplib in 98091016ad83Smrg -L*) 98101016ad83Smrg case " $new_libs " in 98111016ad83Smrg *" $deplib "*) ;; 98121016ad83Smrg *) func_append new_libs " $deplib" ;; 98131016ad83Smrg esac 98141016ad83Smrg ;; 98151016ad83Smrg *) func_append new_libs " $deplib" ;; 98161016ad83Smrg esac 98171016ad83Smrg done 98187204935cSmrg deplibs=$new_libs 98191016ad83Smrg 98201016ad83Smrg # All the library-specific variables (install_libdir is set above). 98211016ad83Smrg library_names= 98221016ad83Smrg old_library= 98231016ad83Smrg dlname= 98241016ad83Smrg 98251016ad83Smrg # Test again, we may have decided not to build it any more 98267204935cSmrg if test yes = "$build_libtool_libs"; then 98277204935cSmrg # Remove $wl instances when linking with ld. 98281016ad83Smrg # FIXME: should test the right _cmds variable. 98291016ad83Smrg case $archive_cmds in 98301016ad83Smrg *\$LD\ *) wl= ;; 98311016ad83Smrg esac 98327204935cSmrg if test yes = "$hardcode_into_libs"; then 98331016ad83Smrg # Hardcode the library paths 98341016ad83Smrg hardcode_libdirs= 98351016ad83Smrg dep_rpath= 98367204935cSmrg rpath=$finalize_rpath 98377204935cSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 98381016ad83Smrg for libdir in $rpath; do 98391016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 98401016ad83Smrg if test -n "$hardcode_libdir_separator"; then 98411016ad83Smrg func_replace_sysroot "$libdir" 98421016ad83Smrg libdir=$func_replace_sysroot_result 98431016ad83Smrg if test -z "$hardcode_libdirs"; then 98447204935cSmrg hardcode_libdirs=$libdir 98451016ad83Smrg else 98461016ad83Smrg # Just accumulate the unique libdirs. 98471016ad83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 98481016ad83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 98491016ad83Smrg ;; 98501016ad83Smrg *) 98511016ad83Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 98521016ad83Smrg ;; 98531016ad83Smrg esac 98541016ad83Smrg fi 98551016ad83Smrg else 98561016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 98571016ad83Smrg func_append dep_rpath " $flag" 98581016ad83Smrg fi 98591016ad83Smrg elif test -n "$runpath_var"; then 98601016ad83Smrg case "$perm_rpath " in 98611016ad83Smrg *" $libdir "*) ;; 98621016ad83Smrg *) func_append perm_rpath " $libdir" ;; 98631016ad83Smrg esac 98641016ad83Smrg fi 98651016ad83Smrg done 98661016ad83Smrg # Substitute the hardcoded libdirs into the rpath. 98671016ad83Smrg if test -n "$hardcode_libdir_separator" && 98681016ad83Smrg test -n "$hardcode_libdirs"; then 98697204935cSmrg libdir=$hardcode_libdirs 98701016ad83Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 98711016ad83Smrg fi 98721016ad83Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 98731016ad83Smrg # We should set the runpath_var. 98741016ad83Smrg rpath= 98751016ad83Smrg for dir in $perm_rpath; do 98761016ad83Smrg func_append rpath "$dir:" 98771016ad83Smrg done 98781016ad83Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 98791016ad83Smrg fi 98801016ad83Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 98811016ad83Smrg fi 98821016ad83Smrg 98837204935cSmrg shlibpath=$finalize_shlibpath 98847204935cSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 98851016ad83Smrg if test -n "$shlibpath"; then 98861016ad83Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 98871016ad83Smrg fi 98881016ad83Smrg 98891016ad83Smrg # Get the real and link names of the library. 98901016ad83Smrg eval shared_ext=\"$shrext_cmds\" 98911016ad83Smrg eval library_names=\"$library_names_spec\" 98921016ad83Smrg set dummy $library_names 98931016ad83Smrg shift 98947204935cSmrg realname=$1 98951016ad83Smrg shift 98961016ad83Smrg 98971016ad83Smrg if test -n "$soname_spec"; then 98981016ad83Smrg eval soname=\"$soname_spec\" 98991016ad83Smrg else 99007204935cSmrg soname=$realname 99011016ad83Smrg fi 99021016ad83Smrg if test -z "$dlname"; then 99031016ad83Smrg dlname=$soname 99041016ad83Smrg fi 99051016ad83Smrg 99067204935cSmrg lib=$output_objdir/$realname 99071016ad83Smrg linknames= 99081016ad83Smrg for link 99091016ad83Smrg do 99101016ad83Smrg func_append linknames " $link" 99111016ad83Smrg done 99121016ad83Smrg 99131016ad83Smrg # Use standard objects if they are pic 99141016ad83Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 99151016ad83Smrg test "X$libobjs" = "X " && libobjs= 99161016ad83Smrg 99171016ad83Smrg delfiles= 99181016ad83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99191016ad83Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99207204935cSmrg export_symbols=$output_objdir/$libname.uexp 99211016ad83Smrg func_append delfiles " $export_symbols" 99221016ad83Smrg fi 99231016ad83Smrg 99241016ad83Smrg orig_export_symbols= 99251016ad83Smrg case $host_os in 99261016ad83Smrg cygwin* | mingw* | cegcc*) 99271016ad83Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 99281016ad83Smrg # exporting using user supplied symfile 99297204935cSmrg func_dll_def_p "$export_symbols" || { 99301016ad83Smrg # and it's NOT already a .def file. Must figure out 99311016ad83Smrg # which of the given symbols are data symbols and tag 99321016ad83Smrg # them as such. So, trigger use of export_symbols_cmds. 99331016ad83Smrg # export_symbols gets reassigned inside the "prepare 99341016ad83Smrg # the list of exported symbols" if statement, so the 99351016ad83Smrg # include_expsyms logic still works. 99367204935cSmrg orig_export_symbols=$export_symbols 99371016ad83Smrg export_symbols= 99381016ad83Smrg always_export_symbols=yes 99397204935cSmrg } 99401016ad83Smrg fi 99411016ad83Smrg ;; 99421016ad83Smrg esac 99431016ad83Smrg 99441016ad83Smrg # Prepare the list of exported symbols 99451016ad83Smrg if test -z "$export_symbols"; then 99467204935cSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99477204935cSmrg func_verbose "generating symbol list for '$libname.la'" 99487204935cSmrg export_symbols=$output_objdir/$libname.exp 99491016ad83Smrg $opt_dry_run || $RM $export_symbols 99501016ad83Smrg cmds=$export_symbols_cmds 99517204935cSmrg save_ifs=$IFS; IFS='~' 99521016ad83Smrg for cmd1 in $cmds; do 99537204935cSmrg IFS=$save_ifs 99541016ad83Smrg # Take the normal branch if the nm_file_list_spec branch 99551016ad83Smrg # doesn't work or if tool conversion is not needed. 99561016ad83Smrg case $nm_file_list_spec~$to_tool_file_cmd in 99571016ad83Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 99581016ad83Smrg try_normal_branch=yes 99591016ad83Smrg eval cmd=\"$cmd1\" 99601016ad83Smrg func_len " $cmd" 99611016ad83Smrg len=$func_len_result 99621016ad83Smrg ;; 99631016ad83Smrg *) 99641016ad83Smrg try_normal_branch=no 99651016ad83Smrg ;; 99661016ad83Smrg esac 99677204935cSmrg if test yes = "$try_normal_branch" \ 99681016ad83Smrg && { test "$len" -lt "$max_cmd_len" \ 99691016ad83Smrg || test "$max_cmd_len" -le -1; } 99701016ad83Smrg then 99711016ad83Smrg func_show_eval "$cmd" 'exit $?' 99721016ad83Smrg skipped_export=false 99731016ad83Smrg elif test -n "$nm_file_list_spec"; then 99741016ad83Smrg func_basename "$output" 99751016ad83Smrg output_la=$func_basename_result 99761016ad83Smrg save_libobjs=$libobjs 99771016ad83Smrg save_output=$output 99787204935cSmrg output=$output_objdir/$output_la.nm 99791016ad83Smrg func_to_tool_file "$output" 99801016ad83Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 99811016ad83Smrg func_append delfiles " $output" 99821016ad83Smrg func_verbose "creating $NM input file list: $output" 99831016ad83Smrg for obj in $save_libobjs; do 99841016ad83Smrg func_to_tool_file "$obj" 99851016ad83Smrg $ECHO "$func_to_tool_file_result" 99861016ad83Smrg done > "$output" 99871016ad83Smrg eval cmd=\"$cmd1\" 99881016ad83Smrg func_show_eval "$cmd" 'exit $?' 99891016ad83Smrg output=$save_output 99901016ad83Smrg libobjs=$save_libobjs 99911016ad83Smrg skipped_export=false 99921016ad83Smrg else 99931016ad83Smrg # The command line is too long to execute in one step. 99941016ad83Smrg func_verbose "using reloadable object file for export list..." 99951016ad83Smrg skipped_export=: 99961016ad83Smrg # Break out early, otherwise skipped_export may be 99971016ad83Smrg # set to false by a later but shorter cmd. 99981016ad83Smrg break 99991016ad83Smrg fi 100001016ad83Smrg done 100017204935cSmrg IFS=$save_ifs 100027204935cSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 100031016ad83Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 100041016ad83Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 100051016ad83Smrg fi 100061016ad83Smrg fi 100071016ad83Smrg fi 100081016ad83Smrg 100091016ad83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 100107204935cSmrg tmp_export_symbols=$export_symbols 100117204935cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 100121016ad83Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 100131016ad83Smrg fi 100141016ad83Smrg 100157204935cSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 100161016ad83Smrg # The given exports_symbols file has to be filtered, so filter it. 100177204935cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 100181016ad83Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100197204935cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 100201016ad83Smrg # though. Also, the filter scales superlinearly with the number of 100211016ad83Smrg # global variables. join(1) would be nice here, but unfortunately 100221016ad83Smrg # isn't a blessed tool. 100231016ad83Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100241016ad83Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 100251016ad83Smrg export_symbols=$output_objdir/$libname.def 100261016ad83Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100271016ad83Smrg fi 100281016ad83Smrg 100291016ad83Smrg tmp_deplibs= 100301016ad83Smrg for test_deplib in $deplibs; do 100311016ad83Smrg case " $convenience " in 100321016ad83Smrg *" $test_deplib "*) ;; 100331016ad83Smrg *) 100341016ad83Smrg func_append tmp_deplibs " $test_deplib" 100351016ad83Smrg ;; 100361016ad83Smrg esac 100371016ad83Smrg done 100387204935cSmrg deplibs=$tmp_deplibs 100391016ad83Smrg 100401016ad83Smrg if test -n "$convenience"; then 100411016ad83Smrg if test -n "$whole_archive_flag_spec" && 100427204935cSmrg test yes = "$compiler_needs_object" && 100431016ad83Smrg test -z "$libobjs"; then 100441016ad83Smrg # extract the archives, so we have objects to list. 100451016ad83Smrg # TODO: could optimize this to just extract one archive. 100461016ad83Smrg whole_archive_flag_spec= 100471016ad83Smrg fi 100481016ad83Smrg if test -n "$whole_archive_flag_spec"; then 100491016ad83Smrg save_libobjs=$libobjs 100501016ad83Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 100511016ad83Smrg test "X$libobjs" = "X " && libobjs= 100521016ad83Smrg else 100537204935cSmrg gentop=$output_objdir/${outputname}x 100541016ad83Smrg func_append generated " $gentop" 100551016ad83Smrg 100561016ad83Smrg func_extract_archives $gentop $convenience 100571016ad83Smrg func_append libobjs " $func_extract_archives_result" 100581016ad83Smrg test "X$libobjs" = "X " && libobjs= 100591016ad83Smrg fi 100601016ad83Smrg fi 100611016ad83Smrg 100627204935cSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 100631016ad83Smrg eval flag=\"$thread_safe_flag_spec\" 100641016ad83Smrg func_append linker_flags " $flag" 100651016ad83Smrg fi 100661016ad83Smrg 100671016ad83Smrg # Make a backup of the uninstalled library when relinking 100687204935cSmrg if test relink = "$opt_mode"; then 100691016ad83Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 100701016ad83Smrg fi 100711016ad83Smrg 100721016ad83Smrg # Do each of the archive commands. 100737204935cSmrg if test yes = "$module" && test -n "$module_cmds"; then 100741016ad83Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100751016ad83Smrg eval test_cmds=\"$module_expsym_cmds\" 100761016ad83Smrg cmds=$module_expsym_cmds 100771016ad83Smrg else 100781016ad83Smrg eval test_cmds=\"$module_cmds\" 100791016ad83Smrg cmds=$module_cmds 100801016ad83Smrg fi 100811016ad83Smrg else 100821016ad83Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100831016ad83Smrg eval test_cmds=\"$archive_expsym_cmds\" 100841016ad83Smrg cmds=$archive_expsym_cmds 100851016ad83Smrg else 100861016ad83Smrg eval test_cmds=\"$archive_cmds\" 100871016ad83Smrg cmds=$archive_cmds 100881016ad83Smrg fi 100891016ad83Smrg fi 100901016ad83Smrg 100917204935cSmrg if test : != "$skipped_export" && 100921016ad83Smrg func_len " $test_cmds" && 100931016ad83Smrg len=$func_len_result && 100941016ad83Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100951016ad83Smrg : 100961016ad83Smrg else 100971016ad83Smrg # The command line is too long to link in one step, link piecewise 100981016ad83Smrg # or, if using GNU ld and skipped_export is not :, use a linker 100991016ad83Smrg # script. 101001016ad83Smrg 101011016ad83Smrg # Save the value of $output and $libobjs because we want to 101021016ad83Smrg # use them later. If we have whole_archive_flag_spec, we 101031016ad83Smrg # want to use save_libobjs as it was before 101041016ad83Smrg # whole_archive_flag_spec was expanded, because we can't 101051016ad83Smrg # assume the linker understands whole_archive_flag_spec. 101061016ad83Smrg # This may have to be revisited, in case too many 101071016ad83Smrg # convenience libraries get linked in and end up exceeding 101081016ad83Smrg # the spec. 101091016ad83Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 101101016ad83Smrg save_libobjs=$libobjs 101111016ad83Smrg fi 101121016ad83Smrg save_output=$output 101131016ad83Smrg func_basename "$output" 101141016ad83Smrg output_la=$func_basename_result 101151016ad83Smrg 101161016ad83Smrg # Clear the reloadable object creation command queue and 101171016ad83Smrg # initialize k to one. 101181016ad83Smrg test_cmds= 101191016ad83Smrg concat_cmds= 101201016ad83Smrg objlist= 101211016ad83Smrg last_robj= 101221016ad83Smrg k=1 101231016ad83Smrg 101247204935cSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101257204935cSmrg output=$output_objdir/$output_la.lnkscript 101261016ad83Smrg func_verbose "creating GNU ld script: $output" 101271016ad83Smrg echo 'INPUT (' > $output 101281016ad83Smrg for obj in $save_libobjs 101291016ad83Smrg do 101301016ad83Smrg func_to_tool_file "$obj" 101311016ad83Smrg $ECHO "$func_to_tool_file_result" >> $output 101321016ad83Smrg done 101331016ad83Smrg echo ')' >> $output 101341016ad83Smrg func_append delfiles " $output" 101351016ad83Smrg func_to_tool_file "$output" 101361016ad83Smrg output=$func_to_tool_file_result 101377204935cSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101387204935cSmrg output=$output_objdir/$output_la.lnk 101391016ad83Smrg func_verbose "creating linker input file list: $output" 101401016ad83Smrg : > $output 101411016ad83Smrg set x $save_libobjs 101421016ad83Smrg shift 101431016ad83Smrg firstobj= 101447204935cSmrg if test yes = "$compiler_needs_object"; then 101451016ad83Smrg firstobj="$1 " 101461016ad83Smrg shift 101471016ad83Smrg fi 101481016ad83Smrg for obj 101491016ad83Smrg do 101501016ad83Smrg func_to_tool_file "$obj" 101511016ad83Smrg $ECHO "$func_to_tool_file_result" >> $output 101521016ad83Smrg done 101531016ad83Smrg func_append delfiles " $output" 101541016ad83Smrg func_to_tool_file "$output" 101551016ad83Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 101561016ad83Smrg else 101571016ad83Smrg if test -n "$save_libobjs"; then 101581016ad83Smrg func_verbose "creating reloadable object files..." 101597204935cSmrg output=$output_objdir/$output_la-$k.$objext 101601016ad83Smrg eval test_cmds=\"$reload_cmds\" 101611016ad83Smrg func_len " $test_cmds" 101621016ad83Smrg len0=$func_len_result 101631016ad83Smrg len=$len0 101641016ad83Smrg 101651016ad83Smrg # Loop over the list of objects to be linked. 101661016ad83Smrg for obj in $save_libobjs 101671016ad83Smrg do 101681016ad83Smrg func_len " $obj" 101691016ad83Smrg func_arith $len + $func_len_result 101701016ad83Smrg len=$func_arith_result 101717204935cSmrg if test -z "$objlist" || 101721016ad83Smrg test "$len" -lt "$max_cmd_len"; then 101731016ad83Smrg func_append objlist " $obj" 101741016ad83Smrg else 101751016ad83Smrg # The command $test_cmds is almost too long, add a 101761016ad83Smrg # command to the queue. 101777204935cSmrg if test 1 -eq "$k"; then 101781016ad83Smrg # The first file doesn't have a previous command to add. 101791016ad83Smrg reload_objs=$objlist 101801016ad83Smrg eval concat_cmds=\"$reload_cmds\" 101811016ad83Smrg else 101821016ad83Smrg # All subsequent reloadable object files will link in 101831016ad83Smrg # the last one created. 101841016ad83Smrg reload_objs="$objlist $last_robj" 101851016ad83Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 101861016ad83Smrg fi 101877204935cSmrg last_robj=$output_objdir/$output_la-$k.$objext 101881016ad83Smrg func_arith $k + 1 101891016ad83Smrg k=$func_arith_result 101907204935cSmrg output=$output_objdir/$output_la-$k.$objext 101911016ad83Smrg objlist=" $obj" 101921016ad83Smrg func_len " $last_robj" 101931016ad83Smrg func_arith $len0 + $func_len_result 101941016ad83Smrg len=$func_arith_result 101951016ad83Smrg fi 101961016ad83Smrg done 101971016ad83Smrg # Handle the remaining objects by creating one last 101981016ad83Smrg # reloadable object file. All subsequent reloadable object 101991016ad83Smrg # files will link in the last one created. 102001016ad83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102011016ad83Smrg reload_objs="$objlist $last_robj" 102027204935cSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 102031016ad83Smrg if test -n "$last_robj"; then 102047204935cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102051016ad83Smrg fi 102061016ad83Smrg func_append delfiles " $output" 102071016ad83Smrg 102081016ad83Smrg else 102091016ad83Smrg output= 102101016ad83Smrg fi 102111016ad83Smrg 102127204935cSmrg ${skipped_export-false} && { 102137204935cSmrg func_verbose "generating symbol list for '$libname.la'" 102147204935cSmrg export_symbols=$output_objdir/$libname.exp 102151016ad83Smrg $opt_dry_run || $RM $export_symbols 102161016ad83Smrg libobjs=$output 102171016ad83Smrg # Append the command to create the export file. 102181016ad83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102191016ad83Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 102201016ad83Smrg if test -n "$last_robj"; then 102211016ad83Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102221016ad83Smrg fi 102237204935cSmrg } 102241016ad83Smrg 102251016ad83Smrg test -n "$save_libobjs" && 102261016ad83Smrg func_verbose "creating a temporary reloadable object file: $output" 102271016ad83Smrg 102281016ad83Smrg # Loop through the commands generated above and execute them. 102297204935cSmrg save_ifs=$IFS; IFS='~' 102301016ad83Smrg for cmd in $concat_cmds; do 102317204935cSmrg IFS=$save_ifs 102327204935cSmrg $opt_quiet || { 10233b9526c6aSmrg func_quote_arg expand,pretty "$cmd" 10234b9526c6aSmrg eval "func_echo $func_quote_arg_result" 102351016ad83Smrg } 102361016ad83Smrg $opt_dry_run || eval "$cmd" || { 102371016ad83Smrg lt_exit=$? 102381016ad83Smrg 102391016ad83Smrg # Restore the uninstalled library and exit 102407204935cSmrg if test relink = "$opt_mode"; then 102411016ad83Smrg ( cd "$output_objdir" && \ 102421016ad83Smrg $RM "${realname}T" && \ 102431016ad83Smrg $MV "${realname}U" "$realname" ) 102441016ad83Smrg fi 102451016ad83Smrg 102461016ad83Smrg exit $lt_exit 102471016ad83Smrg } 102481016ad83Smrg done 102497204935cSmrg IFS=$save_ifs 102501016ad83Smrg 102511016ad83Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 102521016ad83Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 102531016ad83Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102541016ad83Smrg fi 102551016ad83Smrg fi 102561016ad83Smrg 102577204935cSmrg ${skipped_export-false} && { 102581016ad83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102597204935cSmrg tmp_export_symbols=$export_symbols 102607204935cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 102611016ad83Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 102621016ad83Smrg fi 102631016ad83Smrg 102641016ad83Smrg if test -n "$orig_export_symbols"; then 102651016ad83Smrg # The given exports_symbols file has to be filtered, so filter it. 102667204935cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 102671016ad83Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102687204935cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 102691016ad83Smrg # though. Also, the filter scales superlinearly with the number of 102701016ad83Smrg # global variables. join(1) would be nice here, but unfortunately 102711016ad83Smrg # isn't a blessed tool. 102721016ad83Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 102731016ad83Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 102741016ad83Smrg export_symbols=$output_objdir/$libname.def 102751016ad83Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 102761016ad83Smrg fi 102777204935cSmrg } 102781016ad83Smrg 102791016ad83Smrg libobjs=$output 102801016ad83Smrg # Restore the value of output. 102811016ad83Smrg output=$save_output 102821016ad83Smrg 102831016ad83Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 102841016ad83Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 102851016ad83Smrg test "X$libobjs" = "X " && libobjs= 102861016ad83Smrg fi 102871016ad83Smrg # Expand the library linking commands again to reset the 102881016ad83Smrg # value of $libobjs for piecewise linking. 102891016ad83Smrg 102901016ad83Smrg # Do each of the archive commands. 102917204935cSmrg if test yes = "$module" && test -n "$module_cmds"; then 102921016ad83Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 102931016ad83Smrg cmds=$module_expsym_cmds 102941016ad83Smrg else 102951016ad83Smrg cmds=$module_cmds 102961016ad83Smrg fi 102971016ad83Smrg else 102981016ad83Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 102991016ad83Smrg cmds=$archive_expsym_cmds 103001016ad83Smrg else 103011016ad83Smrg cmds=$archive_cmds 103021016ad83Smrg fi 103031016ad83Smrg fi 103041016ad83Smrg fi 103051016ad83Smrg 103061016ad83Smrg if test -n "$delfiles"; then 103071016ad83Smrg # Append the command to remove temporary files to $cmds. 103081016ad83Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 103091016ad83Smrg fi 103101016ad83Smrg 103111016ad83Smrg # Add any objects from preloaded convenience libraries 103121016ad83Smrg if test -n "$dlprefiles"; then 103137204935cSmrg gentop=$output_objdir/${outputname}x 103141016ad83Smrg func_append generated " $gentop" 103151016ad83Smrg 103161016ad83Smrg func_extract_archives $gentop $dlprefiles 103171016ad83Smrg func_append libobjs " $func_extract_archives_result" 103181016ad83Smrg test "X$libobjs" = "X " && libobjs= 103191016ad83Smrg fi 103201016ad83Smrg 103217204935cSmrg save_ifs=$IFS; IFS='~' 103221016ad83Smrg for cmd in $cmds; do 103237204935cSmrg IFS=$sp$nl 103241016ad83Smrg eval cmd=\"$cmd\" 103257204935cSmrg IFS=$save_ifs 103267204935cSmrg $opt_quiet || { 10327b9526c6aSmrg func_quote_arg expand,pretty "$cmd" 10328b9526c6aSmrg eval "func_echo $func_quote_arg_result" 103291016ad83Smrg } 103301016ad83Smrg $opt_dry_run || eval "$cmd" || { 103311016ad83Smrg lt_exit=$? 103321016ad83Smrg 103331016ad83Smrg # Restore the uninstalled library and exit 103347204935cSmrg if test relink = "$opt_mode"; then 103351016ad83Smrg ( cd "$output_objdir" && \ 103361016ad83Smrg $RM "${realname}T" && \ 103371016ad83Smrg $MV "${realname}U" "$realname" ) 103381016ad83Smrg fi 103391016ad83Smrg 103401016ad83Smrg exit $lt_exit 103411016ad83Smrg } 103421016ad83Smrg done 103437204935cSmrg IFS=$save_ifs 103441016ad83Smrg 103451016ad83Smrg # Restore the uninstalled library and exit 103467204935cSmrg if test relink = "$opt_mode"; then 103471016ad83Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103481016ad83Smrg 103491016ad83Smrg if test -n "$convenience"; then 103501016ad83Smrg if test -z "$whole_archive_flag_spec"; then 103511016ad83Smrg func_show_eval '${RM}r "$gentop"' 103521016ad83Smrg fi 103531016ad83Smrg fi 103541016ad83Smrg 103551016ad83Smrg exit $EXIT_SUCCESS 103561016ad83Smrg fi 103571016ad83Smrg 103581016ad83Smrg # Create links to the real library. 103591016ad83Smrg for linkname in $linknames; do 103601016ad83Smrg if test "$realname" != "$linkname"; then 103611016ad83Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103621016ad83Smrg fi 103631016ad83Smrg done 103641016ad83Smrg 103651016ad83Smrg # If -module or -export-dynamic was specified, set the dlname. 103667204935cSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 103671016ad83Smrg # On all known operating systems, these are identical. 103687204935cSmrg dlname=$soname 103691016ad83Smrg fi 103701016ad83Smrg fi 103711016ad83Smrg ;; 103721016ad83Smrg 103731016ad83Smrg obj) 103747204935cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103757204935cSmrg func_warning "'-dlopen' is ignored for objects" 103761016ad83Smrg fi 103771016ad83Smrg 103781016ad83Smrg case " $deplibs" in 103791016ad83Smrg *\ -l* | *\ -L*) 103807204935cSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 103811016ad83Smrg esac 103821016ad83Smrg 103831016ad83Smrg test -n "$rpath" && \ 103847204935cSmrg func_warning "'-rpath' is ignored for objects" 103851016ad83Smrg 103861016ad83Smrg test -n "$xrpath" && \ 103877204935cSmrg func_warning "'-R' is ignored for objects" 103881016ad83Smrg 103891016ad83Smrg test -n "$vinfo" && \ 103907204935cSmrg func_warning "'-version-info' is ignored for objects" 103911016ad83Smrg 103921016ad83Smrg test -n "$release" && \ 103937204935cSmrg func_warning "'-release' is ignored for objects" 103941016ad83Smrg 103951016ad83Smrg case $output in 103961016ad83Smrg *.lo) 103971016ad83Smrg test -n "$objs$old_deplibs" && \ 103987204935cSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 103991016ad83Smrg 104001016ad83Smrg libobj=$output 104011016ad83Smrg func_lo2o "$libobj" 104021016ad83Smrg obj=$func_lo2o_result 104031016ad83Smrg ;; 104041016ad83Smrg *) 104051016ad83Smrg libobj= 104067204935cSmrg obj=$output 104071016ad83Smrg ;; 104081016ad83Smrg esac 104091016ad83Smrg 104101016ad83Smrg # Delete the old objects. 104111016ad83Smrg $opt_dry_run || $RM $obj $libobj 104121016ad83Smrg 104131016ad83Smrg # Objects from convenience libraries. This assumes 104141016ad83Smrg # single-version convenience libraries. Whenever we create 104151016ad83Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 104161016ad83Smrg # the extraction. 104171016ad83Smrg reload_conv_objs= 104181016ad83Smrg gentop= 104197204935cSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 104207204935cSmrg # whole_archive_flag_spec and hope we can get by with turning comma 104217204935cSmrg # into space. 104227204935cSmrg case $reload_cmds in 104237204935cSmrg *\$LD[\ \$]*) wl= ;; 104247204935cSmrg esac 104251016ad83Smrg if test -n "$convenience"; then 104261016ad83Smrg if test -n "$whole_archive_flag_spec"; then 104271016ad83Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104287204935cSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104297204935cSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 104301016ad83Smrg else 104317204935cSmrg gentop=$output_objdir/${obj}x 104321016ad83Smrg func_append generated " $gentop" 104331016ad83Smrg 104341016ad83Smrg func_extract_archives $gentop $convenience 104351016ad83Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 104361016ad83Smrg fi 104371016ad83Smrg fi 104381016ad83Smrg 104391016ad83Smrg # If we're not building shared, we need to use non_pic_objs 104407204935cSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104411016ad83Smrg 104421016ad83Smrg # Create the old-style object. 104437204935cSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104441016ad83Smrg 104457204935cSmrg output=$obj 104461016ad83Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104471016ad83Smrg 104481016ad83Smrg # Exit if we aren't doing a library object file. 104491016ad83Smrg if test -z "$libobj"; then 104501016ad83Smrg if test -n "$gentop"; then 104511016ad83Smrg func_show_eval '${RM}r "$gentop"' 104521016ad83Smrg fi 104531016ad83Smrg 104541016ad83Smrg exit $EXIT_SUCCESS 104551016ad83Smrg fi 104561016ad83Smrg 104577204935cSmrg test yes = "$build_libtool_libs" || { 104581016ad83Smrg if test -n "$gentop"; then 104591016ad83Smrg func_show_eval '${RM}r "$gentop"' 104601016ad83Smrg fi 104611016ad83Smrg 104621016ad83Smrg # Create an invalid libtool object if no PIC, so that we don't 104631016ad83Smrg # accidentally link it into a program. 104641016ad83Smrg # $show "echo timestamp > $libobj" 104651016ad83Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 104661016ad83Smrg exit $EXIT_SUCCESS 104677204935cSmrg } 104681016ad83Smrg 104697204935cSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 104701016ad83Smrg # Only do commands if we really have different PIC objects. 104711016ad83Smrg reload_objs="$libobjs $reload_conv_objs" 104727204935cSmrg output=$libobj 104731016ad83Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104741016ad83Smrg fi 104751016ad83Smrg 104761016ad83Smrg if test -n "$gentop"; then 104771016ad83Smrg func_show_eval '${RM}r "$gentop"' 104781016ad83Smrg fi 104791016ad83Smrg 104801016ad83Smrg exit $EXIT_SUCCESS 104811016ad83Smrg ;; 104821016ad83Smrg 104831016ad83Smrg prog) 104841016ad83Smrg case $host in 104851016ad83Smrg *cygwin*) func_stripname '' '.exe' "$output" 104861016ad83Smrg output=$func_stripname_result.exe;; 104871016ad83Smrg esac 104881016ad83Smrg test -n "$vinfo" && \ 104897204935cSmrg func_warning "'-version-info' is ignored for programs" 104901016ad83Smrg 104911016ad83Smrg test -n "$release" && \ 104927204935cSmrg func_warning "'-release' is ignored for programs" 104931016ad83Smrg 104947204935cSmrg $preload \ 104957204935cSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104967204935cSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 104971016ad83Smrg 104981016ad83Smrg case $host in 104991016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 105001016ad83Smrg # On Rhapsody replace the C library is the System framework 105011016ad83Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 105021016ad83Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 105031016ad83Smrg ;; 105041016ad83Smrg esac 105051016ad83Smrg 105061016ad83Smrg case $host in 105071016ad83Smrg *-*-darwin*) 105081016ad83Smrg # Don't allow lazy linking, it breaks C++ global constructors 105091016ad83Smrg # But is supposedly fixed on 10.4 or later (yay!). 105107204935cSmrg if test CXX = "$tagname"; then 105111016ad83Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 105121016ad83Smrg 10.[0123]) 105137204935cSmrg func_append compile_command " $wl-bind_at_load" 105147204935cSmrg func_append finalize_command " $wl-bind_at_load" 105151016ad83Smrg ;; 105161016ad83Smrg esac 105171016ad83Smrg fi 105181016ad83Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 105191016ad83Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105201016ad83Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105211016ad83Smrg ;; 105221016ad83Smrg esac 105231016ad83Smrg 105241016ad83Smrg 105251016ad83Smrg # move library search paths that coincide with paths to not yet 105261016ad83Smrg # installed libraries to the beginning of the library search list 105271016ad83Smrg new_libs= 105281016ad83Smrg for path in $notinst_path; do 105291016ad83Smrg case " $new_libs " in 105301016ad83Smrg *" -L$path/$objdir "*) ;; 105311016ad83Smrg *) 105321016ad83Smrg case " $compile_deplibs " in 105331016ad83Smrg *" -L$path/$objdir "*) 105341016ad83Smrg func_append new_libs " -L$path/$objdir" ;; 105351016ad83Smrg esac 105361016ad83Smrg ;; 105371016ad83Smrg esac 105381016ad83Smrg done 105391016ad83Smrg for deplib in $compile_deplibs; do 105401016ad83Smrg case $deplib in 105411016ad83Smrg -L*) 105421016ad83Smrg case " $new_libs " in 105431016ad83Smrg *" $deplib "*) ;; 105441016ad83Smrg *) func_append new_libs " $deplib" ;; 105451016ad83Smrg esac 105461016ad83Smrg ;; 105471016ad83Smrg *) func_append new_libs " $deplib" ;; 105481016ad83Smrg esac 105491016ad83Smrg done 105507204935cSmrg compile_deplibs=$new_libs 105511016ad83Smrg 105521016ad83Smrg 105531016ad83Smrg func_append compile_command " $compile_deplibs" 105541016ad83Smrg func_append finalize_command " $finalize_deplibs" 105551016ad83Smrg 105561016ad83Smrg if test -n "$rpath$xrpath"; then 105571016ad83Smrg # If the user specified any rpath flags, then add them. 105581016ad83Smrg for libdir in $rpath $xrpath; do 105591016ad83Smrg # This is the magic to use -rpath. 105601016ad83Smrg case "$finalize_rpath " in 105611016ad83Smrg *" $libdir "*) ;; 105621016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 105631016ad83Smrg esac 105641016ad83Smrg done 105651016ad83Smrg fi 105661016ad83Smrg 105671016ad83Smrg # Now hardcode the library paths 105681016ad83Smrg rpath= 105691016ad83Smrg hardcode_libdirs= 105701016ad83Smrg for libdir in $compile_rpath $finalize_rpath; do 105711016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 105721016ad83Smrg if test -n "$hardcode_libdir_separator"; then 105731016ad83Smrg if test -z "$hardcode_libdirs"; then 105747204935cSmrg hardcode_libdirs=$libdir 105751016ad83Smrg else 105761016ad83Smrg # Just accumulate the unique libdirs. 105771016ad83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 105781016ad83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 105791016ad83Smrg ;; 105801016ad83Smrg *) 105811016ad83Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 105821016ad83Smrg ;; 105831016ad83Smrg esac 105841016ad83Smrg fi 105851016ad83Smrg else 105861016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 105871016ad83Smrg func_append rpath " $flag" 105881016ad83Smrg fi 105891016ad83Smrg elif test -n "$runpath_var"; then 105901016ad83Smrg case "$perm_rpath " in 105911016ad83Smrg *" $libdir "*) ;; 105921016ad83Smrg *) func_append perm_rpath " $libdir" ;; 105931016ad83Smrg esac 105941016ad83Smrg fi 105951016ad83Smrg case $host in 105961016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105977204935cSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 105981016ad83Smrg case :$dllsearchpath: in 105991016ad83Smrg *":$libdir:"*) ;; 106001016ad83Smrg ::) dllsearchpath=$libdir;; 106011016ad83Smrg *) func_append dllsearchpath ":$libdir";; 106021016ad83Smrg esac 106031016ad83Smrg case :$dllsearchpath: in 106041016ad83Smrg *":$testbindir:"*) ;; 106051016ad83Smrg ::) dllsearchpath=$testbindir;; 106061016ad83Smrg *) func_append dllsearchpath ":$testbindir";; 106071016ad83Smrg esac 106081016ad83Smrg ;; 106091016ad83Smrg esac 106101016ad83Smrg done 106111016ad83Smrg # Substitute the hardcoded libdirs into the rpath. 106121016ad83Smrg if test -n "$hardcode_libdir_separator" && 106131016ad83Smrg test -n "$hardcode_libdirs"; then 106147204935cSmrg libdir=$hardcode_libdirs 106151016ad83Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106161016ad83Smrg fi 106177204935cSmrg compile_rpath=$rpath 106181016ad83Smrg 106191016ad83Smrg rpath= 106201016ad83Smrg hardcode_libdirs= 106211016ad83Smrg for libdir in $finalize_rpath; do 106221016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 106231016ad83Smrg if test -n "$hardcode_libdir_separator"; then 106241016ad83Smrg if test -z "$hardcode_libdirs"; then 106257204935cSmrg hardcode_libdirs=$libdir 106261016ad83Smrg else 106271016ad83Smrg # Just accumulate the unique libdirs. 106281016ad83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 106291016ad83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 106301016ad83Smrg ;; 106311016ad83Smrg *) 106321016ad83Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 106331016ad83Smrg ;; 106341016ad83Smrg esac 106351016ad83Smrg fi 106361016ad83Smrg else 106371016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 106381016ad83Smrg func_append rpath " $flag" 106391016ad83Smrg fi 106401016ad83Smrg elif test -n "$runpath_var"; then 106411016ad83Smrg case "$finalize_perm_rpath " in 106421016ad83Smrg *" $libdir "*) ;; 106431016ad83Smrg *) func_append finalize_perm_rpath " $libdir" ;; 106441016ad83Smrg esac 106451016ad83Smrg fi 106461016ad83Smrg done 106471016ad83Smrg # Substitute the hardcoded libdirs into the rpath. 106481016ad83Smrg if test -n "$hardcode_libdir_separator" && 106491016ad83Smrg test -n "$hardcode_libdirs"; then 106507204935cSmrg libdir=$hardcode_libdirs 106511016ad83Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106521016ad83Smrg fi 106537204935cSmrg finalize_rpath=$rpath 106541016ad83Smrg 106557204935cSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 106561016ad83Smrg # Transform all the library objects into standard objects. 106571016ad83Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106581016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106591016ad83Smrg fi 106601016ad83Smrg 106617204935cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106621016ad83Smrg 106631016ad83Smrg # template prelinking step 106641016ad83Smrg if test -n "$prelink_cmds"; then 106651016ad83Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 106661016ad83Smrg fi 106671016ad83Smrg 106687204935cSmrg wrappers_required=: 106691016ad83Smrg case $host in 106701016ad83Smrg *cegcc* | *mingw32ce*) 106711016ad83Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106727204935cSmrg wrappers_required=false 106731016ad83Smrg ;; 106741016ad83Smrg *cygwin* | *mingw* ) 106757204935cSmrg test yes = "$build_libtool_libs" || wrappers_required=false 106761016ad83Smrg ;; 106771016ad83Smrg *) 106787204935cSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106797204935cSmrg wrappers_required=false 106801016ad83Smrg fi 106811016ad83Smrg ;; 106821016ad83Smrg esac 106837204935cSmrg $wrappers_required || { 106841016ad83Smrg # Replace the output file specification. 106851016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106867204935cSmrg link_command=$compile_command$compile_rpath 106871016ad83Smrg 106881016ad83Smrg # We have no uninstalled library dependencies, so finalize right now. 106891016ad83Smrg exit_status=0 106901016ad83Smrg func_show_eval "$link_command" 'exit_status=$?' 106911016ad83Smrg 106921016ad83Smrg if test -n "$postlink_cmds"; then 106931016ad83Smrg func_to_tool_file "$output" 106941016ad83Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 106951016ad83Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 106961016ad83Smrg fi 106971016ad83Smrg 106981016ad83Smrg # Delete the generated files. 106997204935cSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 107007204935cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 107011016ad83Smrg fi 107021016ad83Smrg 107031016ad83Smrg exit $exit_status 107047204935cSmrg } 107051016ad83Smrg 107061016ad83Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 107071016ad83Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 107081016ad83Smrg fi 107091016ad83Smrg if test -n "$finalize_shlibpath"; then 107101016ad83Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 107111016ad83Smrg fi 107121016ad83Smrg 107131016ad83Smrg compile_var= 107141016ad83Smrg finalize_var= 107151016ad83Smrg if test -n "$runpath_var"; then 107161016ad83Smrg if test -n "$perm_rpath"; then 107171016ad83Smrg # We should set the runpath_var. 107181016ad83Smrg rpath= 107191016ad83Smrg for dir in $perm_rpath; do 107201016ad83Smrg func_append rpath "$dir:" 107211016ad83Smrg done 107221016ad83Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107231016ad83Smrg fi 107241016ad83Smrg if test -n "$finalize_perm_rpath"; then 107251016ad83Smrg # We should set the runpath_var. 107261016ad83Smrg rpath= 107271016ad83Smrg for dir in $finalize_perm_rpath; do 107281016ad83Smrg func_append rpath "$dir:" 107291016ad83Smrg done 107301016ad83Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107311016ad83Smrg fi 107321016ad83Smrg fi 107331016ad83Smrg 107347204935cSmrg if test yes = "$no_install"; then 107351016ad83Smrg # We don't need to create a wrapper script. 107367204935cSmrg link_command=$compile_var$compile_command$compile_rpath 107371016ad83Smrg # Replace the output file specification. 107381016ad83Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 107391016ad83Smrg # Delete the old output file. 107401016ad83Smrg $opt_dry_run || $RM $output 107411016ad83Smrg # Link the executable and exit 107421016ad83Smrg func_show_eval "$link_command" 'exit $?' 107431016ad83Smrg 107441016ad83Smrg if test -n "$postlink_cmds"; then 107451016ad83Smrg func_to_tool_file "$output" 107461016ad83Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 107471016ad83Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107481016ad83Smrg fi 107491016ad83Smrg 107501016ad83Smrg exit $EXIT_SUCCESS 107511016ad83Smrg fi 107521016ad83Smrg 107537204935cSmrg case $hardcode_action,$fast_install in 107547204935cSmrg relink,*) 107557204935cSmrg # Fast installation is not supported 107567204935cSmrg link_command=$compile_var$compile_command$compile_rpath 107577204935cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107581016ad83Smrg 107597204935cSmrg func_warning "this platform does not like uninstalled shared libraries" 107607204935cSmrg func_warning "'$output' will be relinked during installation" 107617204935cSmrg ;; 107627204935cSmrg *,yes) 107637204935cSmrg link_command=$finalize_var$compile_command$finalize_rpath 107647204935cSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107657204935cSmrg ;; 107667204935cSmrg *,no) 107677204935cSmrg link_command=$compile_var$compile_command$compile_rpath 107687204935cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107697204935cSmrg ;; 107707204935cSmrg *,needless) 107717204935cSmrg link_command=$finalize_var$compile_command$finalize_rpath 107727204935cSmrg relink_command= 107737204935cSmrg ;; 107747204935cSmrg esac 107751016ad83Smrg 107761016ad83Smrg # Replace the output file specification. 107771016ad83Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107781016ad83Smrg 107791016ad83Smrg # Delete the old output files. 107801016ad83Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107811016ad83Smrg 107821016ad83Smrg func_show_eval "$link_command" 'exit $?' 107831016ad83Smrg 107841016ad83Smrg if test -n "$postlink_cmds"; then 107851016ad83Smrg func_to_tool_file "$output_objdir/$outputname" 107861016ad83Smrg 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'` 107871016ad83Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107881016ad83Smrg fi 107891016ad83Smrg 107901016ad83Smrg # Now create the wrapper script. 107911016ad83Smrg func_verbose "creating $output" 107921016ad83Smrg 107931016ad83Smrg # Quote the relink command for shipping. 107941016ad83Smrg if test -n "$relink_command"; then 107951016ad83Smrg # Preserve any variables that may affect compiler behavior 107961016ad83Smrg for var in $variables_saved_for_relink; do 107971016ad83Smrg if eval test -z \"\${$var+set}\"; then 107981016ad83Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107991016ad83Smrg elif eval var_value=\$$var; test -z "$var_value"; then 108001016ad83Smrg relink_command="$var=; export $var; $relink_command" 108011016ad83Smrg else 10802b9526c6aSmrg func_quote_arg pretty "$var_value" 10803b9526c6aSmrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 108041016ad83Smrg fi 108051016ad83Smrg done 10806b9526c6aSmrg func_quote eval cd "`pwd`" 10807b9526c6aSmrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10808b9526c6aSmrg relink_command=$func_quote_arg_unquoted_result 108091016ad83Smrg fi 108101016ad83Smrg 108111016ad83Smrg # Only actually do things if not in dry run mode. 108121016ad83Smrg $opt_dry_run || { 108131016ad83Smrg # win32 will think the script is a binary if it has 108141016ad83Smrg # a .exe suffix, so we strip it off here. 108151016ad83Smrg case $output in 108161016ad83Smrg *.exe) func_stripname '' '.exe' "$output" 108171016ad83Smrg output=$func_stripname_result ;; 108181016ad83Smrg esac 108191016ad83Smrg # test for cygwin because mv fails w/o .exe extensions 108201016ad83Smrg case $host in 108211016ad83Smrg *cygwin*) 108221016ad83Smrg exeext=.exe 108231016ad83Smrg func_stripname '' '.exe' "$outputname" 108241016ad83Smrg outputname=$func_stripname_result ;; 108251016ad83Smrg *) exeext= ;; 108261016ad83Smrg esac 108271016ad83Smrg case $host in 108281016ad83Smrg *cygwin* | *mingw* ) 108291016ad83Smrg func_dirname_and_basename "$output" "" "." 108301016ad83Smrg output_name=$func_basename_result 108311016ad83Smrg output_path=$func_dirname_result 108327204935cSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108337204935cSmrg cwrapper=$output_path/$output_name.exe 108341016ad83Smrg $RM $cwrappersource $cwrapper 108351016ad83Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 108361016ad83Smrg 108371016ad83Smrg func_emit_cwrapperexe_src > $cwrappersource 108381016ad83Smrg 108391016ad83Smrg # The wrapper executable is built using the $host compiler, 108401016ad83Smrg # because it contains $host paths and files. If cross- 108411016ad83Smrg # compiling, it, like the target executable, must be 108421016ad83Smrg # executed on the $host or under an emulation environment. 108431016ad83Smrg $opt_dry_run || { 108441016ad83Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 108451016ad83Smrg $STRIP $cwrapper 108461016ad83Smrg } 108471016ad83Smrg 108481016ad83Smrg # Now, create the wrapper script for func_source use: 108491016ad83Smrg func_ltwrapper_scriptname $cwrapper 108501016ad83Smrg $RM $func_ltwrapper_scriptname_result 108511016ad83Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 108521016ad83Smrg $opt_dry_run || { 108531016ad83Smrg # note: this script will not be executed, so do not chmod. 108547204935cSmrg if test "x$build" = "x$host"; then 108551016ad83Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 108561016ad83Smrg else 108571016ad83Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 108581016ad83Smrg fi 108591016ad83Smrg } 108601016ad83Smrg ;; 108611016ad83Smrg * ) 108621016ad83Smrg $RM $output 108631016ad83Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108641016ad83Smrg 108651016ad83Smrg func_emit_wrapper no > $output 108661016ad83Smrg chmod +x $output 108671016ad83Smrg ;; 108681016ad83Smrg esac 108691016ad83Smrg } 108701016ad83Smrg exit $EXIT_SUCCESS 108711016ad83Smrg ;; 108721016ad83Smrg esac 108731016ad83Smrg 108741016ad83Smrg # See if we need to build an old-fashioned archive. 108751016ad83Smrg for oldlib in $oldlibs; do 108761016ad83Smrg 108777204935cSmrg case $build_libtool_libs in 108787204935cSmrg convenience) 108797204935cSmrg oldobjs="$libobjs_save $symfileobj" 108807204935cSmrg addlibs=$convenience 108811016ad83Smrg build_libtool_libs=no 108827204935cSmrg ;; 108837204935cSmrg module) 108847204935cSmrg oldobjs=$libobjs_save 108857204935cSmrg addlibs=$old_convenience 108867204935cSmrg build_libtool_libs=no 108877204935cSmrg ;; 108887204935cSmrg *) 108891016ad83Smrg oldobjs="$old_deplibs $non_pic_objects" 108907204935cSmrg $preload && test -f "$symfileobj" \ 108917204935cSmrg && func_append oldobjs " $symfileobj" 108927204935cSmrg addlibs=$old_convenience 108937204935cSmrg ;; 108947204935cSmrg esac 108951016ad83Smrg 108961016ad83Smrg if test -n "$addlibs"; then 108977204935cSmrg gentop=$output_objdir/${outputname}x 108981016ad83Smrg func_append generated " $gentop" 108991016ad83Smrg 109001016ad83Smrg func_extract_archives $gentop $addlibs 109011016ad83Smrg func_append oldobjs " $func_extract_archives_result" 109021016ad83Smrg fi 109031016ad83Smrg 109041016ad83Smrg # Do each command in the archive commands. 109057204935cSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 109061016ad83Smrg cmds=$old_archive_from_new_cmds 109071016ad83Smrg else 109081016ad83Smrg 109091016ad83Smrg # Add any objects from preloaded convenience libraries 109101016ad83Smrg if test -n "$dlprefiles"; then 109117204935cSmrg gentop=$output_objdir/${outputname}x 109121016ad83Smrg func_append generated " $gentop" 109131016ad83Smrg 109141016ad83Smrg func_extract_archives $gentop $dlprefiles 109151016ad83Smrg func_append oldobjs " $func_extract_archives_result" 109161016ad83Smrg fi 109171016ad83Smrg 109181016ad83Smrg # POSIX demands no paths to be encoded in archives. We have 109191016ad83Smrg # to avoid creating archives with duplicate basenames if we 109201016ad83Smrg # might have to extract them afterwards, e.g., when creating a 109211016ad83Smrg # static archive out of a convenience library, or when linking 109221016ad83Smrg # the entirety of a libtool archive into another (currently 109231016ad83Smrg # not supported by libtool). 109241016ad83Smrg if (for obj in $oldobjs 109251016ad83Smrg do 109261016ad83Smrg func_basename "$obj" 109271016ad83Smrg $ECHO "$func_basename_result" 109281016ad83Smrg done | sort | sort -uc >/dev/null 2>&1); then 109291016ad83Smrg : 109301016ad83Smrg else 109311016ad83Smrg echo "copying selected object files to avoid basename conflicts..." 109327204935cSmrg gentop=$output_objdir/${outputname}x 109331016ad83Smrg func_append generated " $gentop" 109341016ad83Smrg func_mkdir_p "$gentop" 109351016ad83Smrg save_oldobjs=$oldobjs 109361016ad83Smrg oldobjs= 109371016ad83Smrg counter=1 109381016ad83Smrg for obj in $save_oldobjs 109391016ad83Smrg do 109401016ad83Smrg func_basename "$obj" 109417204935cSmrg objbase=$func_basename_result 109421016ad83Smrg case " $oldobjs " in 109431016ad83Smrg " ") oldobjs=$obj ;; 109441016ad83Smrg *[\ /]"$objbase "*) 109451016ad83Smrg while :; do 109461016ad83Smrg # Make sure we don't pick an alternate name that also 109471016ad83Smrg # overlaps. 109481016ad83Smrg newobj=lt$counter-$objbase 109491016ad83Smrg func_arith $counter + 1 109501016ad83Smrg counter=$func_arith_result 109511016ad83Smrg case " $oldobjs " in 109521016ad83Smrg *[\ /]"$newobj "*) ;; 109531016ad83Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 109541016ad83Smrg esac 109551016ad83Smrg done 109561016ad83Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 109571016ad83Smrg func_append oldobjs " $gentop/$newobj" 109581016ad83Smrg ;; 109591016ad83Smrg *) func_append oldobjs " $obj" ;; 109601016ad83Smrg esac 109611016ad83Smrg done 109621016ad83Smrg fi 109631016ad83Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109641016ad83Smrg tool_oldlib=$func_to_tool_file_result 109651016ad83Smrg eval cmds=\"$old_archive_cmds\" 109661016ad83Smrg 109671016ad83Smrg func_len " $cmds" 109681016ad83Smrg len=$func_len_result 109691016ad83Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 109701016ad83Smrg cmds=$old_archive_cmds 109711016ad83Smrg elif test -n "$archiver_list_spec"; then 109721016ad83Smrg func_verbose "using command file archive linking..." 109731016ad83Smrg for obj in $oldobjs 109741016ad83Smrg do 109751016ad83Smrg func_to_tool_file "$obj" 109761016ad83Smrg $ECHO "$func_to_tool_file_result" 109771016ad83Smrg done > $output_objdir/$libname.libcmd 109781016ad83Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 109791016ad83Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 109801016ad83Smrg cmds=$old_archive_cmds 109811016ad83Smrg else 109821016ad83Smrg # the command line is too long to link in one step, link in parts 109831016ad83Smrg func_verbose "using piecewise archive linking..." 109841016ad83Smrg save_RANLIB=$RANLIB 109851016ad83Smrg RANLIB=: 109861016ad83Smrg objlist= 109871016ad83Smrg concat_cmds= 109881016ad83Smrg save_oldobjs=$oldobjs 109891016ad83Smrg oldobjs= 109901016ad83Smrg # Is there a better way of finding the last object in the list? 109911016ad83Smrg for obj in $save_oldobjs 109921016ad83Smrg do 109931016ad83Smrg last_oldobj=$obj 109941016ad83Smrg done 109951016ad83Smrg eval test_cmds=\"$old_archive_cmds\" 109961016ad83Smrg func_len " $test_cmds" 109971016ad83Smrg len0=$func_len_result 109981016ad83Smrg len=$len0 109991016ad83Smrg for obj in $save_oldobjs 110001016ad83Smrg do 110011016ad83Smrg func_len " $obj" 110021016ad83Smrg func_arith $len + $func_len_result 110031016ad83Smrg len=$func_arith_result 110041016ad83Smrg func_append objlist " $obj" 110051016ad83Smrg if test "$len" -lt "$max_cmd_len"; then 110061016ad83Smrg : 110071016ad83Smrg else 110081016ad83Smrg # the above command should be used before it gets too long 110091016ad83Smrg oldobjs=$objlist 110107204935cSmrg if test "$obj" = "$last_oldobj"; then 110111016ad83Smrg RANLIB=$save_RANLIB 110121016ad83Smrg fi 110131016ad83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110147204935cSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 110151016ad83Smrg objlist= 110161016ad83Smrg len=$len0 110171016ad83Smrg fi 110181016ad83Smrg done 110191016ad83Smrg RANLIB=$save_RANLIB 110201016ad83Smrg oldobjs=$objlist 110217204935cSmrg if test -z "$oldobjs"; then 110221016ad83Smrg eval cmds=\"\$concat_cmds\" 110231016ad83Smrg else 110241016ad83Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 110251016ad83Smrg fi 110261016ad83Smrg fi 110271016ad83Smrg fi 110281016ad83Smrg func_execute_cmds "$cmds" 'exit $?' 110291016ad83Smrg done 110301016ad83Smrg 110311016ad83Smrg test -n "$generated" && \ 110321016ad83Smrg func_show_eval "${RM}r$generated" 110331016ad83Smrg 110341016ad83Smrg # Now create the libtool archive. 110351016ad83Smrg case $output in 110361016ad83Smrg *.la) 110371016ad83Smrg old_library= 110387204935cSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 110391016ad83Smrg func_verbose "creating $output" 110401016ad83Smrg 110411016ad83Smrg # Preserve any variables that may affect compiler behavior 110421016ad83Smrg for var in $variables_saved_for_relink; do 110431016ad83Smrg if eval test -z \"\${$var+set}\"; then 110441016ad83Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 110451016ad83Smrg elif eval var_value=\$$var; test -z "$var_value"; then 110461016ad83Smrg relink_command="$var=; export $var; $relink_command" 110471016ad83Smrg else 11048b9526c6aSmrg func_quote_arg pretty,unquoted "$var_value" 11049b9526c6aSmrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110501016ad83Smrg fi 110511016ad83Smrg done 110521016ad83Smrg # Quote the link command for shipping. 11053b9526c6aSmrg func_quote eval cd "`pwd`" 11054b9526c6aSmrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11055b9526c6aSmrg func_quote_arg pretty,unquoted "$relink_command" 11056b9526c6aSmrg relink_command=$func_quote_arg_unquoted_result 110577204935cSmrg if test yes = "$hardcode_automatic"; then 110581016ad83Smrg relink_command= 110591016ad83Smrg fi 110601016ad83Smrg 110611016ad83Smrg # Only create the output if not a dry run. 110621016ad83Smrg $opt_dry_run || { 110631016ad83Smrg for installed in no yes; do 110647204935cSmrg if test yes = "$installed"; then 110651016ad83Smrg if test -z "$install_libdir"; then 110661016ad83Smrg break 110671016ad83Smrg fi 110687204935cSmrg output=$output_objdir/${outputname}i 110691016ad83Smrg # Replace all uninstalled libtool libraries with the installed ones 110701016ad83Smrg newdependency_libs= 110711016ad83Smrg for deplib in $dependency_libs; do 110721016ad83Smrg case $deplib in 110731016ad83Smrg *.la) 110741016ad83Smrg func_basename "$deplib" 110757204935cSmrg name=$func_basename_result 110761016ad83Smrg func_resolve_sysroot "$deplib" 110777204935cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 110781016ad83Smrg test -z "$libdir" && \ 110797204935cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 110801016ad83Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 110811016ad83Smrg ;; 110821016ad83Smrg -L*) 110831016ad83Smrg func_stripname -L '' "$deplib" 110841016ad83Smrg func_replace_sysroot "$func_stripname_result" 110851016ad83Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 110861016ad83Smrg ;; 110871016ad83Smrg -R*) 110881016ad83Smrg func_stripname -R '' "$deplib" 110891016ad83Smrg func_replace_sysroot "$func_stripname_result" 110901016ad83Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 110911016ad83Smrg ;; 110921016ad83Smrg *) func_append newdependency_libs " $deplib" ;; 110931016ad83Smrg esac 110941016ad83Smrg done 110957204935cSmrg dependency_libs=$newdependency_libs 110961016ad83Smrg newdlfiles= 110971016ad83Smrg 110981016ad83Smrg for lib in $dlfiles; do 110991016ad83Smrg case $lib in 111001016ad83Smrg *.la) 111011016ad83Smrg func_basename "$lib" 111027204935cSmrg name=$func_basename_result 111037204935cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111041016ad83Smrg test -z "$libdir" && \ 111057204935cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 111061016ad83Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 111071016ad83Smrg ;; 111081016ad83Smrg *) func_append newdlfiles " $lib" ;; 111091016ad83Smrg esac 111101016ad83Smrg done 111117204935cSmrg dlfiles=$newdlfiles 111121016ad83Smrg newdlprefiles= 111131016ad83Smrg for lib in $dlprefiles; do 111141016ad83Smrg case $lib in 111151016ad83Smrg *.la) 111161016ad83Smrg # Only pass preopened files to the pseudo-archive (for 111171016ad83Smrg # eventual linking with the app. that links it) if we 111181016ad83Smrg # didn't already link the preopened objects directly into 111191016ad83Smrg # the library: 111201016ad83Smrg func_basename "$lib" 111217204935cSmrg name=$func_basename_result 111227204935cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111231016ad83Smrg test -z "$libdir" && \ 111247204935cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 111251016ad83Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 111261016ad83Smrg ;; 111271016ad83Smrg esac 111281016ad83Smrg done 111297204935cSmrg dlprefiles=$newdlprefiles 111301016ad83Smrg else 111311016ad83Smrg newdlfiles= 111321016ad83Smrg for lib in $dlfiles; do 111331016ad83Smrg case $lib in 111347204935cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111351016ad83Smrg *) abs=`pwd`"/$lib" ;; 111361016ad83Smrg esac 111371016ad83Smrg func_append newdlfiles " $abs" 111381016ad83Smrg done 111397204935cSmrg dlfiles=$newdlfiles 111401016ad83Smrg newdlprefiles= 111411016ad83Smrg for lib in $dlprefiles; do 111421016ad83Smrg case $lib in 111437204935cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111441016ad83Smrg *) abs=`pwd`"/$lib" ;; 111451016ad83Smrg esac 111461016ad83Smrg func_append newdlprefiles " $abs" 111471016ad83Smrg done 111487204935cSmrg dlprefiles=$newdlprefiles 111491016ad83Smrg fi 111501016ad83Smrg $RM $output 111511016ad83Smrg # place dlname in correct position for cygwin 111521016ad83Smrg # In fact, it would be nice if we could use this code for all target 111531016ad83Smrg # systems that can't hard-code library paths into their executables 111541016ad83Smrg # and that have no shared library path variable independent of PATH, 111551016ad83Smrg # but it turns out we can't easily determine that from inspecting 111561016ad83Smrg # libtool variables, so we have to hard-code the OSs to which it 111571016ad83Smrg # applies here; at the moment, that means platforms that use the PE 111581016ad83Smrg # object format with DLL files. See the long comment at the top of 111591016ad83Smrg # tests/bindir.at for full details. 111601016ad83Smrg tdlname=$dlname 111611016ad83Smrg case $host,$output,$installed,$module,$dlname in 111621016ad83Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 111631016ad83Smrg # If a -bindir argument was supplied, place the dll there. 111647204935cSmrg if test -n "$bindir"; then 111651016ad83Smrg func_relative_path "$install_libdir" "$bindir" 111667204935cSmrg tdlname=$func_relative_path_result/$dlname 111671016ad83Smrg else 111681016ad83Smrg # Otherwise fall back on heuristic. 111691016ad83Smrg tdlname=../bin/$dlname 111701016ad83Smrg fi 111711016ad83Smrg ;; 111721016ad83Smrg esac 111731016ad83Smrg $ECHO > $output "\ 111741016ad83Smrg# $outputname - a libtool library file 111757204935cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 111761016ad83Smrg# 111771016ad83Smrg# Please DO NOT delete this file! 111781016ad83Smrg# It is necessary for linking the library. 111791016ad83Smrg 111801016ad83Smrg# The name that we can dlopen(3). 111811016ad83Smrgdlname='$tdlname' 111821016ad83Smrg 111831016ad83Smrg# Names of this library. 111841016ad83Smrglibrary_names='$library_names' 111851016ad83Smrg 111861016ad83Smrg# The name of the static archive. 111871016ad83Smrgold_library='$old_library' 111881016ad83Smrg 111897204935cSmrg# Linker flags that cannot go in dependency_libs. 111901016ad83Smrginherited_linker_flags='$new_inherited_linker_flags' 111911016ad83Smrg 111921016ad83Smrg# Libraries that this one depends upon. 111931016ad83Smrgdependency_libs='$dependency_libs' 111941016ad83Smrg 111951016ad83Smrg# Names of additional weak libraries provided by this library 111961016ad83Smrgweak_library_names='$weak_libs' 111971016ad83Smrg 111981016ad83Smrg# Version information for $libname. 111991016ad83Smrgcurrent=$current 112001016ad83Smrgage=$age 112011016ad83Smrgrevision=$revision 112021016ad83Smrg 112031016ad83Smrg# Is this an already installed library? 112041016ad83Smrginstalled=$installed 112051016ad83Smrg 112061016ad83Smrg# Should we warn about portability when linking against -modules? 112071016ad83Smrgshouldnotlink=$module 112081016ad83Smrg 112091016ad83Smrg# Files to dlopen/dlpreopen 112101016ad83Smrgdlopen='$dlfiles' 112111016ad83Smrgdlpreopen='$dlprefiles' 112121016ad83Smrg 112131016ad83Smrg# Directory that this library needs to be installed in: 112141016ad83Smrglibdir='$install_libdir'" 112157204935cSmrg if test no,yes = "$installed,$need_relink"; then 112161016ad83Smrg $ECHO >> $output "\ 112171016ad83Smrgrelink_command=\"$relink_command\"" 112181016ad83Smrg fi 112191016ad83Smrg done 112201016ad83Smrg } 112211016ad83Smrg 112221016ad83Smrg # Do a symbolic link so that the libtool archive can be found in 112231016ad83Smrg # LD_LIBRARY_PATH before the program is installed. 112241016ad83Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 112251016ad83Smrg ;; 112261016ad83Smrg esac 112271016ad83Smrg exit $EXIT_SUCCESS 112281016ad83Smrg} 112291016ad83Smrg 112307204935cSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112317204935cSmrg func_mode_link ${1+"$@"} 112327204935cSmrgfi 112331016ad83Smrg 112341016ad83Smrg 112351016ad83Smrg# func_mode_uninstall arg... 112361016ad83Smrgfunc_mode_uninstall () 112371016ad83Smrg{ 112387204935cSmrg $debug_cmd 112397204935cSmrg 112407204935cSmrg RM=$nonopt 112411016ad83Smrg files= 112427204935cSmrg rmforce=false 112431016ad83Smrg exit_status=0 112441016ad83Smrg 112451016ad83Smrg # This variable tells wrapper scripts just to set variables rather 112461016ad83Smrg # than running their programs. 112477204935cSmrg libtool_install_magic=$magic 112481016ad83Smrg 112491016ad83Smrg for arg 112501016ad83Smrg do 112511016ad83Smrg case $arg in 112527204935cSmrg -f) func_append RM " $arg"; rmforce=: ;; 112531016ad83Smrg -*) func_append RM " $arg" ;; 112541016ad83Smrg *) func_append files " $arg" ;; 112551016ad83Smrg esac 112561016ad83Smrg done 112571016ad83Smrg 112581016ad83Smrg test -z "$RM" && \ 112591016ad83Smrg func_fatal_help "you must specify an RM program" 112601016ad83Smrg 112611016ad83Smrg rmdirs= 112621016ad83Smrg 112631016ad83Smrg for file in $files; do 112641016ad83Smrg func_dirname "$file" "" "." 112657204935cSmrg dir=$func_dirname_result 112667204935cSmrg if test . = "$dir"; then 112677204935cSmrg odir=$objdir 112681016ad83Smrg else 112697204935cSmrg odir=$dir/$objdir 112701016ad83Smrg fi 112711016ad83Smrg func_basename "$file" 112727204935cSmrg name=$func_basename_result 112737204935cSmrg test uninstall = "$opt_mode" && odir=$dir 112741016ad83Smrg 112751016ad83Smrg # Remember odir for removal later, being careful to avoid duplicates 112767204935cSmrg if test clean = "$opt_mode"; then 112771016ad83Smrg case " $rmdirs " in 112781016ad83Smrg *" $odir "*) ;; 112791016ad83Smrg *) func_append rmdirs " $odir" ;; 112801016ad83Smrg esac 112811016ad83Smrg fi 112821016ad83Smrg 112831016ad83Smrg # Don't error if the file doesn't exist and rm -f was used. 112841016ad83Smrg if { test -L "$file"; } >/dev/null 2>&1 || 112851016ad83Smrg { test -h "$file"; } >/dev/null 2>&1 || 112861016ad83Smrg test -f "$file"; then 112871016ad83Smrg : 112881016ad83Smrg elif test -d "$file"; then 112891016ad83Smrg exit_status=1 112901016ad83Smrg continue 112917204935cSmrg elif $rmforce; then 112921016ad83Smrg continue 112931016ad83Smrg fi 112941016ad83Smrg 112957204935cSmrg rmfiles=$file 112961016ad83Smrg 112971016ad83Smrg case $name in 112981016ad83Smrg *.la) 112991016ad83Smrg # Possibly a libtool archive, so verify it. 113001016ad83Smrg if func_lalib_p "$file"; then 113011016ad83Smrg func_source $dir/$name 113021016ad83Smrg 113031016ad83Smrg # Delete the libtool libraries and symlinks. 113041016ad83Smrg for n in $library_names; do 113051016ad83Smrg func_append rmfiles " $odir/$n" 113061016ad83Smrg done 113071016ad83Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 113081016ad83Smrg 113097204935cSmrg case $opt_mode in 113101016ad83Smrg clean) 113111016ad83Smrg case " $library_names " in 113121016ad83Smrg *" $dlname "*) ;; 113131016ad83Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113141016ad83Smrg esac 113151016ad83Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113161016ad83Smrg ;; 113171016ad83Smrg uninstall) 113181016ad83Smrg if test -n "$library_names"; then 113191016ad83Smrg # Do each command in the postuninstall commands. 113207204935cSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113211016ad83Smrg fi 113221016ad83Smrg 113231016ad83Smrg if test -n "$old_library"; then 113241016ad83Smrg # Do each command in the old_postuninstall commands. 113257204935cSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113261016ad83Smrg fi 113271016ad83Smrg # FIXME: should reinstall the best remaining shared library. 113281016ad83Smrg ;; 113291016ad83Smrg esac 113301016ad83Smrg fi 113311016ad83Smrg ;; 113321016ad83Smrg 113331016ad83Smrg *.lo) 113341016ad83Smrg # Possibly a libtool object, so verify it. 113351016ad83Smrg if func_lalib_p "$file"; then 113361016ad83Smrg 113371016ad83Smrg # Read the .lo file 113381016ad83Smrg func_source $dir/$name 113391016ad83Smrg 113401016ad83Smrg # Add PIC object to the list of files to remove. 113417204935cSmrg if test -n "$pic_object" && test none != "$pic_object"; then 113421016ad83Smrg func_append rmfiles " $dir/$pic_object" 113431016ad83Smrg fi 113441016ad83Smrg 113451016ad83Smrg # Add non-PIC object to the list of files to remove. 113467204935cSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 113471016ad83Smrg func_append rmfiles " $dir/$non_pic_object" 113481016ad83Smrg fi 113491016ad83Smrg fi 113501016ad83Smrg ;; 113511016ad83Smrg 113521016ad83Smrg *) 113537204935cSmrg if test clean = "$opt_mode"; then 113541016ad83Smrg noexename=$name 113551016ad83Smrg case $file in 113561016ad83Smrg *.exe) 113571016ad83Smrg func_stripname '' '.exe' "$file" 113581016ad83Smrg file=$func_stripname_result 113591016ad83Smrg func_stripname '' '.exe' "$name" 113601016ad83Smrg noexename=$func_stripname_result 113611016ad83Smrg # $file with .exe has already been added to rmfiles, 113621016ad83Smrg # add $file without .exe 113631016ad83Smrg func_append rmfiles " $file" 113641016ad83Smrg ;; 113651016ad83Smrg esac 113661016ad83Smrg # Do a test to see if this is a libtool program. 113671016ad83Smrg if func_ltwrapper_p "$file"; then 113681016ad83Smrg if func_ltwrapper_executable_p "$file"; then 113691016ad83Smrg func_ltwrapper_scriptname "$file" 113701016ad83Smrg relink_command= 113711016ad83Smrg func_source $func_ltwrapper_scriptname_result 113721016ad83Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 113731016ad83Smrg else 113741016ad83Smrg relink_command= 113751016ad83Smrg func_source $dir/$noexename 113761016ad83Smrg fi 113771016ad83Smrg 113781016ad83Smrg # note $name still contains .exe if it was in $file originally 113791016ad83Smrg # as does the version of $file that was added into $rmfiles 113807204935cSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113817204935cSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 113821016ad83Smrg func_append rmfiles " $odir/lt-$name" 113831016ad83Smrg fi 113847204935cSmrg if test "X$noexename" != "X$name"; then 113857204935cSmrg func_append rmfiles " $odir/lt-$noexename.c" 113861016ad83Smrg fi 113871016ad83Smrg fi 113881016ad83Smrg fi 113891016ad83Smrg ;; 113901016ad83Smrg esac 113911016ad83Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113921016ad83Smrg done 113931016ad83Smrg 113947204935cSmrg # Try to remove the $objdir's in the directories where we deleted files 113951016ad83Smrg for dir in $rmdirs; do 113961016ad83Smrg if test -d "$dir"; then 113971016ad83Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113981016ad83Smrg fi 113991016ad83Smrg done 114001016ad83Smrg 114011016ad83Smrg exit $exit_status 114021016ad83Smrg} 114031016ad83Smrg 114047204935cSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 114057204935cSmrg func_mode_uninstall ${1+"$@"} 114067204935cSmrgfi 114071016ad83Smrg 114081016ad83Smrgtest -z "$opt_mode" && { 114097204935cSmrg help=$generic_help 114101016ad83Smrg func_fatal_help "you must specify a MODE" 114111016ad83Smrg} 114121016ad83Smrg 114131016ad83Smrgtest -z "$exec_cmd" && \ 114147204935cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 114151016ad83Smrg 114161016ad83Smrgif test -n "$exec_cmd"; then 114171016ad83Smrg eval exec "$exec_cmd" 114181016ad83Smrg exit $EXIT_FAILURE 114191016ad83Smrgfi 114201016ad83Smrg 114211016ad83Smrgexit $exit_status 114221016ad83Smrg 114231016ad83Smrg 114241016ad83Smrg# The TAGs below are defined such that we never get into a situation 114257204935cSmrg# where we disable both kinds of libraries. Given conflicting 114261016ad83Smrg# choices, we go for a static library, that is the most portable, 114271016ad83Smrg# since we can't tell whether shared libraries were disabled because 114281016ad83Smrg# the user asked for that or because the platform doesn't support 114291016ad83Smrg# them. This is particularly important on AIX, because we don't 114301016ad83Smrg# support having both static and shared libraries enabled at the same 114311016ad83Smrg# time on that platform, so we default to a shared-only configuration. 114321016ad83Smrg# If a disable-shared tag is given, we'll fallback to a static-only 114331016ad83Smrg# configuration. But we'll never go from static-only to shared-only. 114341016ad83Smrg 114351016ad83Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 114361016ad83Smrgbuild_libtool_libs=no 114371016ad83Smrgbuild_old_libs=yes 114381016ad83Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 114391016ad83Smrg 114401016ad83Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 114411016ad83Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114421016ad83Smrg# ### END LIBTOOL TAG CONFIG: disable-static 114431016ad83Smrg 114441016ad83Smrg# Local Variables: 114451016ad83Smrg# mode:shell-script 114461016ad83Smrg# sh-indentation:2 114471016ad83Smrg# End: 11448