1*b50261e2SCy Schubert#! /bin/sh 2*b50261e2SCy Schubert## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3*b50261e2SCy Schubert## by inline-source v2018-07-24.06 4*b50261e2SCy Schubert 5*b50261e2SCy Schubert# libtool (GNU libtool) 2.4.6.42-b88ce-dirty 6*b50261e2SCy Schubert# Provide generalized library-building support services. 7*b50261e2SCy Schubert# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8*b50261e2SCy Schubert 9*b50261e2SCy Schubert# Copyright (C) 1996-2018 Free Software Foundation, Inc. 10*b50261e2SCy Schubert# This is free software; see the source for copying conditions. There is NO 11*b50261e2SCy Schubert# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12*b50261e2SCy Schubert 13*b50261e2SCy Schubert# GNU Libtool is free software; you can redistribute it and/or modify 14*b50261e2SCy Schubert# it under the terms of the GNU General Public License as published by 15*b50261e2SCy Schubert# the Free Software Foundation; either version 2 of the License, or 16*b50261e2SCy Schubert# (at your option) any later version. 17*b50261e2SCy Schubert# 18*b50261e2SCy Schubert# As a special exception to the GNU General Public License, 19*b50261e2SCy Schubert# if you distribute this file as part of a program or library that 20*b50261e2SCy Schubert# is built using GNU Libtool, you may include this file under the 21*b50261e2SCy Schubert# same distribution terms that you use for the rest of that program. 22*b50261e2SCy Schubert# 23*b50261e2SCy Schubert# GNU Libtool is distributed in the hope that it will be useful, but 24*b50261e2SCy Schubert# WITHOUT ANY WARRANTY; without even the implied warranty of 25*b50261e2SCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26*b50261e2SCy Schubert# General Public License for more details. 27*b50261e2SCy Schubert# 28*b50261e2SCy Schubert# You should have received a copy of the GNU General Public License 29*b50261e2SCy Schubert# along with this program. If not, see <http://www.gnu.org/licenses/>. 30*b50261e2SCy Schubert 31*b50261e2SCy Schubert 32*b50261e2SCy SchubertPROGRAM=libtool 33*b50261e2SCy SchubertPACKAGE=libtool 34*b50261e2SCy SchubertVERSION=2.4.6.42-b88ce-dirty 35*b50261e2SCy Schubertpackage_revision=2.4.6.42 36*b50261e2SCy Schubert 37*b50261e2SCy Schubert 38*b50261e2SCy Schubert## ------ ## 39*b50261e2SCy Schubert## Usage. ## 40*b50261e2SCy Schubert## ------ ## 41*b50261e2SCy Schubert 42*b50261e2SCy Schubert# Run './libtool --help' for help with using this script from the 43*b50261e2SCy Schubert# command line. 44*b50261e2SCy Schubert 45*b50261e2SCy Schubert 46*b50261e2SCy Schubert## ------------------------------- ## 47*b50261e2SCy Schubert## User overridable command paths. ## 48*b50261e2SCy Schubert## ------------------------------- ## 49*b50261e2SCy Schubert 50*b50261e2SCy Schubert# After configure completes, it has a better idea of some of the 51*b50261e2SCy Schubert# shell tools we need than the defaults used by the functions shared 52*b50261e2SCy Schubert# with bootstrap, so set those here where they can still be over- 53*b50261e2SCy Schubert# ridden by the user, but otherwise take precedence. 54*b50261e2SCy Schubert 55*b50261e2SCy Schubert: ${AUTOCONF="autoconf"} 56*b50261e2SCy Schubert: ${AUTOMAKE="automake"} 57*b50261e2SCy Schubert 58*b50261e2SCy Schubert 59*b50261e2SCy Schubert## -------------------------- ## 60*b50261e2SCy Schubert## Source external libraries. ## 61*b50261e2SCy Schubert## -------------------------- ## 62*b50261e2SCy Schubert 63*b50261e2SCy Schubert# Much of our low-level functionality needs to be sourced from external 64*b50261e2SCy Schubert# libraries, which are installed to $pkgauxdir. 65*b50261e2SCy Schubert 66*b50261e2SCy Schubert# Set a version string for this script. 67*b50261e2SCy Schubertscriptversion=2018-07-24.06; # UTC 68*b50261e2SCy Schubert 69*b50261e2SCy Schubert# General shell script boiler plate, and helper functions. 70*b50261e2SCy Schubert# Written by Gary V. Vaughan, 2004 71*b50261e2SCy Schubert 72*b50261e2SCy Schubert# This is free software. There is NO warranty; not even for 73*b50261e2SCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74*b50261e2SCy Schubert# 75*b50261e2SCy Schubert# Copyright (C) 2004-2018 Bootstrap Authors 76*b50261e2SCy Schubert# 77*b50261e2SCy Schubert# This file is dual licensed under the terms of the MIT license 78*b50261e2SCy Schubert# <https://opensource.org/license/MIT>, and GPL version 3 or later 79*b50261e2SCy Schubert# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80*b50261e2SCy Schubert# these licenses when using or redistributing this software or any of 81*b50261e2SCy Schubert# the files within it. See the URLs above, or the file `LICENSE` 82*b50261e2SCy Schubert# included in the Bootstrap distribution for the full license texts. 83*b50261e2SCy Schubert 84*b50261e2SCy Schubert# Please report bugs or propose patches to: 85*b50261e2SCy Schubert# <https://github.com/gnulib-modules/bootstrap/issues> 86*b50261e2SCy Schubert 87*b50261e2SCy Schubert 88*b50261e2SCy Schubert## ------ ## 89*b50261e2SCy Schubert## Usage. ## 90*b50261e2SCy Schubert## ------ ## 91*b50261e2SCy Schubert 92*b50261e2SCy Schubert# Evaluate this file near the top of your script to gain access to 93*b50261e2SCy Schubert# the functions and variables defined here: 94*b50261e2SCy Schubert# 95*b50261e2SCy Schubert# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96*b50261e2SCy Schubert# 97*b50261e2SCy Schubert# If you need to override any of the default environment variable 98*b50261e2SCy Schubert# settings, do that before evaluating this file. 99*b50261e2SCy Schubert 100*b50261e2SCy Schubert 101*b50261e2SCy Schubert## -------------------- ## 102*b50261e2SCy Schubert## Shell normalisation. ## 103*b50261e2SCy Schubert## -------------------- ## 104*b50261e2SCy Schubert 105*b50261e2SCy Schubert# Some shells need a little help to be as Bourne compatible as possible. 106*b50261e2SCy Schubert# Before doing anything else, make sure all that help has been provided! 107*b50261e2SCy Schubert 108*b50261e2SCy SchubertDUALCASE=1; export DUALCASE # for MKS sh 109*b50261e2SCy Schubertif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110*b50261e2SCy Schubert emulate sh 111*b50261e2SCy Schubert NULLCMD=: 112*b50261e2SCy Schubert # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113*b50261e2SCy Schubert # is contrary to our usage. Disable this feature. 114*b50261e2SCy Schubert alias -g '${1+"$@"}'='"$@"' 115*b50261e2SCy Schubert setopt NO_GLOB_SUBST 116*b50261e2SCy Schubertelse 117*b50261e2SCy Schubert case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118*b50261e2SCy Schubertfi 119*b50261e2SCy Schubert 120*b50261e2SCy Schubert# NLS nuisances: We save the old values in case they are required later. 121*b50261e2SCy Schubert_G_user_locale= 122*b50261e2SCy Schubert_G_safe_locale= 123*b50261e2SCy Schubertfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124*b50261e2SCy Schubertdo 125*b50261e2SCy Schubert eval "if test set = \"\${$_G_var+set}\"; then 126*b50261e2SCy Schubert save_$_G_var=\$$_G_var 127*b50261e2SCy Schubert $_G_var=C 128*b50261e2SCy Schubert export $_G_var 129*b50261e2SCy Schubert _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130*b50261e2SCy Schubert _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131*b50261e2SCy Schubert fi" 132*b50261e2SCy Schubertdone 133*b50261e2SCy Schubert 134*b50261e2SCy Schubert# Make sure IFS has a sensible default 135*b50261e2SCy Schubertsp=' ' 136*b50261e2SCy Schubertnl=' 137*b50261e2SCy Schubert' 138*b50261e2SCy SchubertIFS="$sp $nl" 139*b50261e2SCy Schubert 140*b50261e2SCy Schubert# There are apparently some retarded systems that use ';' as a PATH separator! 141*b50261e2SCy Schubertif test "${PATH_SEPARATOR+set}" != set; then 142*b50261e2SCy Schubert PATH_SEPARATOR=: 143*b50261e2SCy Schubert (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 144*b50261e2SCy Schubert (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 145*b50261e2SCy Schubert PATH_SEPARATOR=';' 146*b50261e2SCy Schubert } 147*b50261e2SCy Schubertfi 148*b50261e2SCy Schubert 149*b50261e2SCy Schubert 150*b50261e2SCy Schubert# func_unset VAR 151*b50261e2SCy Schubert# -------------- 152*b50261e2SCy Schubert# Portably unset VAR. 153*b50261e2SCy Schubert# In some shells, an 'unset VAR' statement leaves a non-zero return 154*b50261e2SCy Schubert# status if VAR is already unset, which might be problematic if the 155*b50261e2SCy Schubert# statement is used at the end of a function (thus poisoning its return 156*b50261e2SCy Schubert# value) or when 'set -e' is active (causing even a spurious abort of 157*b50261e2SCy Schubert# the script in this case). 158*b50261e2SCy Schubertfunc_unset () 159*b50261e2SCy Schubert{ 160*b50261e2SCy Schubert { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 161*b50261e2SCy Schubert} 162*b50261e2SCy Schubert 163*b50261e2SCy Schubert 164*b50261e2SCy Schubert# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 165*b50261e2SCy Schubertfunc_unset CDPATH 166*b50261e2SCy Schubert 167*b50261e2SCy Schubert# Make sure ${,E,F}GREP behave sanely. 168*b50261e2SCy Schubertfunc_unset GREP_OPTIONS 169*b50261e2SCy Schubert 170*b50261e2SCy Schubert 171*b50261e2SCy Schubert## ------------------------- ## 172*b50261e2SCy Schubert## Locate command utilities. ## 173*b50261e2SCy Schubert## ------------------------- ## 174*b50261e2SCy Schubert 175*b50261e2SCy Schubert 176*b50261e2SCy Schubert# func_executable_p FILE 177*b50261e2SCy Schubert# ---------------------- 178*b50261e2SCy Schubert# Check that FILE is an executable regular file. 179*b50261e2SCy Schubertfunc_executable_p () 180*b50261e2SCy Schubert{ 181*b50261e2SCy Schubert test -f "$1" && test -x "$1" 182*b50261e2SCy Schubert} 183*b50261e2SCy Schubert 184*b50261e2SCy Schubert 185*b50261e2SCy Schubert# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 186*b50261e2SCy Schubert# -------------------------------------------- 187*b50261e2SCy Schubert# Search for either a program that responds to --version with output 188*b50261e2SCy Schubert# containing "GNU", or else returned by CHECK_FUNC otherwise, by 189*b50261e2SCy Schubert# trying all the directories in PATH with each of the elements of 190*b50261e2SCy Schubert# PROGS_LIST. 191*b50261e2SCy Schubert# 192*b50261e2SCy Schubert# CHECK_FUNC should accept the path to a candidate program, and 193*b50261e2SCy Schubert# set $func_check_prog_result if it truncates its output less than 194*b50261e2SCy Schubert# $_G_path_prog_max characters. 195*b50261e2SCy Schubertfunc_path_progs () 196*b50261e2SCy Schubert{ 197*b50261e2SCy Schubert _G_progs_list=$1 198*b50261e2SCy Schubert _G_check_func=$2 199*b50261e2SCy Schubert _G_PATH=${3-"$PATH"} 200*b50261e2SCy Schubert 201*b50261e2SCy Schubert _G_path_prog_max=0 202*b50261e2SCy Schubert _G_path_prog_found=false 203*b50261e2SCy Schubert _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 204*b50261e2SCy Schubert for _G_dir in $_G_PATH; do 205*b50261e2SCy Schubert IFS=$_G_save_IFS 206*b50261e2SCy Schubert test -z "$_G_dir" && _G_dir=. 207*b50261e2SCy Schubert for _G_prog_name in $_G_progs_list; do 208*b50261e2SCy Schubert for _exeext in '' .EXE; do 209*b50261e2SCy Schubert _G_path_prog=$_G_dir/$_G_prog_name$_exeext 210*b50261e2SCy Schubert func_executable_p "$_G_path_prog" || continue 211*b50261e2SCy Schubert case `"$_G_path_prog" --version 2>&1` in 212*b50261e2SCy Schubert *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 213*b50261e2SCy Schubert *) $_G_check_func $_G_path_prog 214*b50261e2SCy Schubert func_path_progs_result=$func_check_prog_result 215*b50261e2SCy Schubert ;; 216*b50261e2SCy Schubert esac 217*b50261e2SCy Schubert $_G_path_prog_found && break 3 218*b50261e2SCy Schubert done 219*b50261e2SCy Schubert done 220*b50261e2SCy Schubert done 221*b50261e2SCy Schubert IFS=$_G_save_IFS 222*b50261e2SCy Schubert test -z "$func_path_progs_result" && { 223*b50261e2SCy Schubert echo "no acceptable sed could be found in \$PATH" >&2 224*b50261e2SCy Schubert exit 1 225*b50261e2SCy Schubert } 226*b50261e2SCy Schubert} 227*b50261e2SCy Schubert 228*b50261e2SCy Schubert 229*b50261e2SCy Schubert# We want to be able to use the functions in this file before configure 230*b50261e2SCy Schubert# has figured out where the best binaries are kept, which means we have 231*b50261e2SCy Schubert# to search for them ourselves - except when the results are already set 232*b50261e2SCy Schubert# where we skip the searches. 233*b50261e2SCy Schubert 234*b50261e2SCy Schubert# Unless the user overrides by setting SED, search the path for either GNU 235*b50261e2SCy Schubert# sed, or the sed that truncates its output the least. 236*b50261e2SCy Schuberttest -z "$SED" && { 237*b50261e2SCy Schubert _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 238*b50261e2SCy Schubert for _G_i in 1 2 3 4 5 6 7; do 239*b50261e2SCy Schubert _G_sed_script=$_G_sed_script$nl$_G_sed_script 240*b50261e2SCy Schubert done 241*b50261e2SCy Schubert echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 242*b50261e2SCy Schubert _G_sed_script= 243*b50261e2SCy Schubert 244*b50261e2SCy Schubert func_check_prog_sed () 245*b50261e2SCy Schubert { 246*b50261e2SCy Schubert _G_path_prog=$1 247*b50261e2SCy Schubert 248*b50261e2SCy Schubert _G_count=0 249*b50261e2SCy Schubert printf 0123456789 >conftest.in 250*b50261e2SCy Schubert while : 251*b50261e2SCy Schubert do 252*b50261e2SCy Schubert cat conftest.in conftest.in >conftest.tmp 253*b50261e2SCy Schubert mv conftest.tmp conftest.in 254*b50261e2SCy Schubert cp conftest.in conftest.nl 255*b50261e2SCy Schubert echo '' >> conftest.nl 256*b50261e2SCy Schubert "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 257*b50261e2SCy Schubert diff conftest.out conftest.nl >/dev/null 2>&1 || break 258*b50261e2SCy Schubert _G_count=`expr $_G_count + 1` 259*b50261e2SCy Schubert if test "$_G_count" -gt "$_G_path_prog_max"; then 260*b50261e2SCy Schubert # Best one so far, save it but keep looking for a better one 261*b50261e2SCy Schubert func_check_prog_result=$_G_path_prog 262*b50261e2SCy Schubert _G_path_prog_max=$_G_count 263*b50261e2SCy Schubert fi 264*b50261e2SCy Schubert # 10*(2^10) chars as input seems more than enough 265*b50261e2SCy Schubert test 10 -lt "$_G_count" && break 266*b50261e2SCy Schubert done 267*b50261e2SCy Schubert rm -f conftest.in conftest.tmp conftest.nl conftest.out 268*b50261e2SCy Schubert } 269*b50261e2SCy Schubert 270*b50261e2SCy Schubert func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 271*b50261e2SCy Schubert rm -f conftest.sed 272*b50261e2SCy Schubert SED=$func_path_progs_result 273*b50261e2SCy Schubert} 274*b50261e2SCy Schubert 275*b50261e2SCy Schubert 276*b50261e2SCy Schubert# Unless the user overrides by setting GREP, search the path for either GNU 277*b50261e2SCy Schubert# grep, or the grep that truncates its output the least. 278*b50261e2SCy Schuberttest -z "$GREP" && { 279*b50261e2SCy Schubert func_check_prog_grep () 280*b50261e2SCy Schubert { 281*b50261e2SCy Schubert _G_path_prog=$1 282*b50261e2SCy Schubert 283*b50261e2SCy Schubert _G_count=0 284*b50261e2SCy Schubert _G_path_prog_max=0 285*b50261e2SCy Schubert printf 0123456789 >conftest.in 286*b50261e2SCy Schubert while : 287*b50261e2SCy Schubert do 288*b50261e2SCy Schubert cat conftest.in conftest.in >conftest.tmp 289*b50261e2SCy Schubert mv conftest.tmp conftest.in 290*b50261e2SCy Schubert cp conftest.in conftest.nl 291*b50261e2SCy Schubert echo 'GREP' >> conftest.nl 292*b50261e2SCy Schubert "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 293*b50261e2SCy Schubert diff conftest.out conftest.nl >/dev/null 2>&1 || break 294*b50261e2SCy Schubert _G_count=`expr $_G_count + 1` 295*b50261e2SCy Schubert if test "$_G_count" -gt "$_G_path_prog_max"; then 296*b50261e2SCy Schubert # Best one so far, save it but keep looking for a better one 297*b50261e2SCy Schubert func_check_prog_result=$_G_path_prog 298*b50261e2SCy Schubert _G_path_prog_max=$_G_count 299*b50261e2SCy Schubert fi 300*b50261e2SCy Schubert # 10*(2^10) chars as input seems more than enough 301*b50261e2SCy Schubert test 10 -lt "$_G_count" && break 302*b50261e2SCy Schubert done 303*b50261e2SCy Schubert rm -f conftest.in conftest.tmp conftest.nl conftest.out 304*b50261e2SCy Schubert } 305*b50261e2SCy Schubert 306*b50261e2SCy Schubert func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 307*b50261e2SCy Schubert GREP=$func_path_progs_result 308*b50261e2SCy Schubert} 309*b50261e2SCy Schubert 310*b50261e2SCy Schubert 311*b50261e2SCy Schubert## ------------------------------- ## 312*b50261e2SCy Schubert## User overridable command paths. ## 313*b50261e2SCy Schubert## ------------------------------- ## 314*b50261e2SCy Schubert 315*b50261e2SCy Schubert# All uppercase variable names are used for environment variables. These 316*b50261e2SCy Schubert# variables can be overridden by the user before calling a script that 317*b50261e2SCy Schubert# uses them if a suitable command of that name is not already available 318*b50261e2SCy Schubert# in the command search PATH. 319*b50261e2SCy Schubert 320*b50261e2SCy Schubert: ${CP="cp -f"} 321*b50261e2SCy Schubert: ${ECHO="printf %s\n"} 322*b50261e2SCy Schubert: ${EGREP="$GREP -E"} 323*b50261e2SCy Schubert: ${FGREP="$GREP -F"} 324*b50261e2SCy Schubert: ${LN_S="ln -s"} 325*b50261e2SCy Schubert: ${MAKE="make"} 326*b50261e2SCy Schubert: ${MKDIR="mkdir"} 327*b50261e2SCy Schubert: ${MV="mv -f"} 328*b50261e2SCy Schubert: ${RM="rm -f"} 329*b50261e2SCy Schubert: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 330*b50261e2SCy Schubert 331*b50261e2SCy Schubert 332*b50261e2SCy Schubert## -------------------- ## 333*b50261e2SCy Schubert## Useful sed snippets. ## 334*b50261e2SCy Schubert## -------------------- ## 335*b50261e2SCy Schubert 336*b50261e2SCy Schubertsed_dirname='s|/[^/]*$||' 337*b50261e2SCy Schubertsed_basename='s|^.*/||' 338*b50261e2SCy Schubert 339*b50261e2SCy Schubert# Sed substitution that helps us do robust quoting. It backslashifies 340*b50261e2SCy Schubert# metacharacters that are still active within double-quoted strings. 341*b50261e2SCy Schubertsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 342*b50261e2SCy Schubert 343*b50261e2SCy Schubert# Same as above, but do not quote variable references. 344*b50261e2SCy Schubertsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 345*b50261e2SCy Schubert 346*b50261e2SCy Schubert# Sed substitution that turns a string into a regex matching for the 347*b50261e2SCy Schubert# string literally. 348*b50261e2SCy Schubertsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 349*b50261e2SCy Schubert 350*b50261e2SCy Schubert# Sed substitution that converts a w32 file name or path 351*b50261e2SCy Schubert# that contains forward slashes, into one that contains 352*b50261e2SCy Schubert# (escaped) backslashes. A very naive implementation. 353*b50261e2SCy Schubertsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 354*b50261e2SCy Schubert 355*b50261e2SCy Schubert# Re-'\' parameter expansions in output of sed_double_quote_subst that 356*b50261e2SCy Schubert# were '\'-ed in input to the same. If an odd number of '\' preceded a 357*b50261e2SCy Schubert# '$' in input to sed_double_quote_subst, that '$' was protected from 358*b50261e2SCy Schubert# expansion. Since each input '\' is now two '\'s, look for any number 359*b50261e2SCy Schubert# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 360*b50261e2SCy Schubert_G_bs='\\' 361*b50261e2SCy Schubert_G_bs2='\\\\' 362*b50261e2SCy Schubert_G_bs4='\\\\\\\\' 363*b50261e2SCy Schubert_G_dollar='\$' 364*b50261e2SCy Schubertsed_double_backslash="\ 365*b50261e2SCy Schubert s/$_G_bs4/&\\ 366*b50261e2SCy Schubert/g 367*b50261e2SCy Schubert s/^$_G_bs2$_G_dollar/$_G_bs&/ 368*b50261e2SCy Schubert s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 369*b50261e2SCy Schubert s/\n//g" 370*b50261e2SCy Schubert 371*b50261e2SCy Schubert 372*b50261e2SCy Schubert## ----------------- ## 373*b50261e2SCy Schubert## Global variables. ## 374*b50261e2SCy Schubert## ----------------- ## 375*b50261e2SCy Schubert 376*b50261e2SCy Schubert# Except for the global variables explicitly listed below, the following 377*b50261e2SCy Schubert# functions in the '^func_' namespace, and the '^require_' namespace 378*b50261e2SCy Schubert# variables initialised in the 'Resource management' section, sourcing 379*b50261e2SCy Schubert# this file will not pollute your global namespace with anything 380*b50261e2SCy Schubert# else. There's no portable way to scope variables in Bourne shell 381*b50261e2SCy Schubert# though, so actually running these functions will sometimes place 382*b50261e2SCy Schubert# results into a variable named after the function, and often use 383*b50261e2SCy Schubert# temporary variables in the '^_G_' namespace. If you are careful to 384*b50261e2SCy Schubert# avoid using those namespaces casually in your sourcing script, things 385*b50261e2SCy Schubert# should continue to work as you expect. And, of course, you can freely 386*b50261e2SCy Schubert# overwrite any of the functions or variables defined here before 387*b50261e2SCy Schubert# calling anything to customize them. 388*b50261e2SCy Schubert 389*b50261e2SCy SchubertEXIT_SUCCESS=0 390*b50261e2SCy SchubertEXIT_FAILURE=1 391*b50261e2SCy SchubertEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 392*b50261e2SCy SchubertEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 393*b50261e2SCy Schubert 394*b50261e2SCy Schubert# Allow overriding, eg assuming that you follow the convention of 395*b50261e2SCy Schubert# putting '$debug_cmd' at the start of all your functions, you can get 396*b50261e2SCy Schubert# bash to show function call trace with: 397*b50261e2SCy Schubert# 398*b50261e2SCy Schubert# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 399*b50261e2SCy Schubertdebug_cmd=${debug_cmd-":"} 400*b50261e2SCy Schubertexit_cmd=: 401*b50261e2SCy Schubert 402*b50261e2SCy Schubert# By convention, finish your script with: 403*b50261e2SCy Schubert# 404*b50261e2SCy Schubert# exit $exit_status 405*b50261e2SCy Schubert# 406*b50261e2SCy Schubert# so that you can set exit_status to non-zero if you want to indicate 407*b50261e2SCy Schubert# something went wrong during execution without actually bailing out at 408*b50261e2SCy Schubert# the point of failure. 409*b50261e2SCy Schubertexit_status=$EXIT_SUCCESS 410*b50261e2SCy Schubert 411*b50261e2SCy Schubert# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 412*b50261e2SCy Schubert# is ksh but when the shell is invoked as "sh" and the current value of 413*b50261e2SCy Schubert# the _XPG environment variable is not equal to 1 (one), the special 414*b50261e2SCy Schubert# positional parameter $0, within a function call, is the name of the 415*b50261e2SCy Schubert# function. 416*b50261e2SCy Schubertprogpath=$0 417*b50261e2SCy Schubert 418*b50261e2SCy Schubert# The name of this program. 419*b50261e2SCy Schubertprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 420*b50261e2SCy Schubert 421*b50261e2SCy Schubert# Make sure we have an absolute progpath for reexecution: 422*b50261e2SCy Schubertcase $progpath in 423*b50261e2SCy Schubert [\\/]*|[A-Za-z]:\\*) ;; 424*b50261e2SCy Schubert *[\\/]*) 425*b50261e2SCy Schubert progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 426*b50261e2SCy Schubert progdir=`cd "$progdir" && pwd` 427*b50261e2SCy Schubert progpath=$progdir/$progname 428*b50261e2SCy Schubert ;; 429*b50261e2SCy Schubert *) 430*b50261e2SCy Schubert _G_IFS=$IFS 431*b50261e2SCy Schubert IFS=${PATH_SEPARATOR-:} 432*b50261e2SCy Schubert for progdir in $PATH; do 433*b50261e2SCy Schubert IFS=$_G_IFS 434*b50261e2SCy Schubert test -x "$progdir/$progname" && break 435*b50261e2SCy Schubert done 436*b50261e2SCy Schubert IFS=$_G_IFS 437*b50261e2SCy Schubert test -n "$progdir" || progdir=`pwd` 438*b50261e2SCy Schubert progpath=$progdir/$progname 439*b50261e2SCy Schubert ;; 440*b50261e2SCy Schubertesac 441*b50261e2SCy Schubert 442*b50261e2SCy Schubert 443*b50261e2SCy Schubert## ----------------- ## 444*b50261e2SCy Schubert## Standard options. ## 445*b50261e2SCy Schubert## ----------------- ## 446*b50261e2SCy Schubert 447*b50261e2SCy Schubert# The following options affect the operation of the functions defined 448*b50261e2SCy Schubert# below, and should be set appropriately depending on run-time para- 449*b50261e2SCy Schubert# meters passed on the command line. 450*b50261e2SCy Schubert 451*b50261e2SCy Schubertopt_dry_run=false 452*b50261e2SCy Schubertopt_quiet=false 453*b50261e2SCy Schubertopt_verbose=false 454*b50261e2SCy Schubert 455*b50261e2SCy Schubert# Categories 'all' and 'none' are always available. Append any others 456*b50261e2SCy Schubert# you will pass as the first argument to func_warning from your own 457*b50261e2SCy Schubert# code. 458*b50261e2SCy Schubertwarning_categories= 459*b50261e2SCy Schubert 460*b50261e2SCy Schubert# By default, display warnings according to 'opt_warning_types'. Set 461*b50261e2SCy Schubert# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 462*b50261e2SCy Schubert# treat the next displayed warning as a fatal error. 463*b50261e2SCy Schubertwarning_func=func_warn_and_continue 464*b50261e2SCy Schubert 465*b50261e2SCy Schubert# Set to 'all' to display all warnings, 'none' to suppress all 466*b50261e2SCy Schubert# warnings, or a space delimited list of some subset of 467*b50261e2SCy Schubert# 'warning_categories' to display only the listed warnings. 468*b50261e2SCy Schubertopt_warning_types=all 469*b50261e2SCy Schubert 470*b50261e2SCy Schubert 471*b50261e2SCy Schubert## -------------------- ## 472*b50261e2SCy Schubert## Resource management. ## 473*b50261e2SCy Schubert## -------------------- ## 474*b50261e2SCy Schubert 475*b50261e2SCy Schubert# This section contains definitions for functions that each ensure a 476*b50261e2SCy Schubert# particular resource (a file, or a non-empty configuration variable for 477*b50261e2SCy Schubert# example) is available, and if appropriate to extract default values 478*b50261e2SCy Schubert# from pertinent package files. Call them using their associated 479*b50261e2SCy Schubert# 'require_*' variable to ensure that they are executed, at most, once. 480*b50261e2SCy Schubert# 481*b50261e2SCy Schubert# It's entirely deliberate that calling these functions can set 482*b50261e2SCy Schubert# variables that don't obey the namespace limitations obeyed by the rest 483*b50261e2SCy Schubert# of this file, in order that that they be as useful as possible to 484*b50261e2SCy Schubert# callers. 485*b50261e2SCy Schubert 486*b50261e2SCy Schubert 487*b50261e2SCy Schubert# require_term_colors 488*b50261e2SCy Schubert# ------------------- 489*b50261e2SCy Schubert# Allow display of bold text on terminals that support it. 490*b50261e2SCy Schubertrequire_term_colors=func_require_term_colors 491*b50261e2SCy Schubertfunc_require_term_colors () 492*b50261e2SCy Schubert{ 493*b50261e2SCy Schubert $debug_cmd 494*b50261e2SCy Schubert 495*b50261e2SCy Schubert test -t 1 && { 496*b50261e2SCy Schubert # COLORTERM and USE_ANSI_COLORS environment variables take 497*b50261e2SCy Schubert # precedence, because most terminfo databases neglect to describe 498*b50261e2SCy Schubert # whether color sequences are supported. 499*b50261e2SCy Schubert test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 500*b50261e2SCy Schubert 501*b50261e2SCy Schubert if test 1 = "$USE_ANSI_COLORS"; then 502*b50261e2SCy Schubert # Standard ANSI escape sequences 503*b50261e2SCy Schubert tc_reset='[0m' 504*b50261e2SCy Schubert tc_bold='[1m'; tc_standout='[7m' 505*b50261e2SCy Schubert tc_red='[31m'; tc_green='[32m' 506*b50261e2SCy Schubert tc_blue='[34m'; tc_cyan='[36m' 507*b50261e2SCy Schubert else 508*b50261e2SCy Schubert # Otherwise trust the terminfo database after all. 509*b50261e2SCy Schubert test -n "`tput sgr0 2>/dev/null`" && { 510*b50261e2SCy Schubert tc_reset=`tput sgr0` 511*b50261e2SCy Schubert test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 512*b50261e2SCy Schubert tc_standout=$tc_bold 513*b50261e2SCy Schubert test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 514*b50261e2SCy Schubert test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 515*b50261e2SCy Schubert test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 516*b50261e2SCy Schubert test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 517*b50261e2SCy Schubert test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 518*b50261e2SCy Schubert } 519*b50261e2SCy Schubert fi 520*b50261e2SCy Schubert } 521*b50261e2SCy Schubert 522*b50261e2SCy Schubert require_term_colors=: 523*b50261e2SCy Schubert} 524*b50261e2SCy Schubert 525*b50261e2SCy Schubert 526*b50261e2SCy Schubert## ----------------- ## 527*b50261e2SCy Schubert## Function library. ## 528*b50261e2SCy Schubert## ----------------- ## 529*b50261e2SCy Schubert 530*b50261e2SCy Schubert# This section contains a variety of useful functions to call in your 531*b50261e2SCy Schubert# scripts. Take note of the portable wrappers for features provided by 532*b50261e2SCy Schubert# some modern shells, which will fall back to slower equivalents on 533*b50261e2SCy Schubert# less featureful shells. 534*b50261e2SCy Schubert 535*b50261e2SCy Schubert 536*b50261e2SCy Schubert# func_append VAR VALUE 537*b50261e2SCy Schubert# --------------------- 538*b50261e2SCy Schubert# Append VALUE onto the existing contents of VAR. 539*b50261e2SCy Schubert 540*b50261e2SCy Schubert # We should try to minimise forks, especially on Windows where they are 541*b50261e2SCy Schubert # unreasonably slow, so skip the feature probes when bash or zsh are 542*b50261e2SCy Schubert # being used: 543*b50261e2SCy Schubert if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 544*b50261e2SCy Schubert : ${_G_HAVE_ARITH_OP="yes"} 545*b50261e2SCy Schubert : ${_G_HAVE_XSI_OPS="yes"} 546*b50261e2SCy Schubert # The += operator was introduced in bash 3.1 547*b50261e2SCy Schubert case $BASH_VERSION in 548*b50261e2SCy Schubert [12].* | 3.0 | 3.0*) ;; 549*b50261e2SCy Schubert *) 550*b50261e2SCy Schubert : ${_G_HAVE_PLUSEQ_OP="yes"} 551*b50261e2SCy Schubert ;; 552*b50261e2SCy Schubert esac 553*b50261e2SCy Schubert fi 554*b50261e2SCy Schubert 555*b50261e2SCy Schubert # _G_HAVE_PLUSEQ_OP 556*b50261e2SCy Schubert # Can be empty, in which case the shell is probed, "yes" if += is 557*b50261e2SCy Schubert # useable or anything else if it does not work. 558*b50261e2SCy Schubert test -z "$_G_HAVE_PLUSEQ_OP" \ 559*b50261e2SCy Schubert && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 560*b50261e2SCy Schubert && _G_HAVE_PLUSEQ_OP=yes 561*b50261e2SCy Schubert 562*b50261e2SCy Schubertif test yes = "$_G_HAVE_PLUSEQ_OP" 563*b50261e2SCy Schubertthen 564*b50261e2SCy Schubert # This is an XSI compatible shell, allowing a faster implementation... 565*b50261e2SCy Schubert eval 'func_append () 566*b50261e2SCy Schubert { 567*b50261e2SCy Schubert $debug_cmd 568*b50261e2SCy Schubert 569*b50261e2SCy Schubert eval "$1+=\$2" 570*b50261e2SCy Schubert }' 571*b50261e2SCy Schubertelse 572*b50261e2SCy Schubert # ...otherwise fall back to using expr, which is often a shell builtin. 573*b50261e2SCy Schubert func_append () 574*b50261e2SCy Schubert { 575*b50261e2SCy Schubert $debug_cmd 576*b50261e2SCy Schubert 577*b50261e2SCy Schubert eval "$1=\$$1\$2" 578*b50261e2SCy Schubert } 579*b50261e2SCy Schubertfi 580*b50261e2SCy Schubert 581*b50261e2SCy Schubert 582*b50261e2SCy Schubert# func_append_quoted VAR VALUE 583*b50261e2SCy Schubert# ---------------------------- 584*b50261e2SCy Schubert# Quote VALUE and append to the end of shell variable VAR, separated 585*b50261e2SCy Schubert# by a space. 586*b50261e2SCy Schubertif test yes = "$_G_HAVE_PLUSEQ_OP"; then 587*b50261e2SCy Schubert eval 'func_append_quoted () 588*b50261e2SCy Schubert { 589*b50261e2SCy Schubert $debug_cmd 590*b50261e2SCy Schubert 591*b50261e2SCy Schubert func_quote_arg pretty "$2" 592*b50261e2SCy Schubert eval "$1+=\\ \$func_quote_arg_result" 593*b50261e2SCy Schubert }' 594*b50261e2SCy Schubertelse 595*b50261e2SCy Schubert func_append_quoted () 596*b50261e2SCy Schubert { 597*b50261e2SCy Schubert $debug_cmd 598*b50261e2SCy Schubert 599*b50261e2SCy Schubert func_quote_arg pretty "$2" 600*b50261e2SCy Schubert eval "$1=\$$1\\ \$func_quote_arg_result" 601*b50261e2SCy Schubert } 602*b50261e2SCy Schubertfi 603*b50261e2SCy Schubert 604*b50261e2SCy Schubert 605*b50261e2SCy Schubert# func_append_uniq VAR VALUE 606*b50261e2SCy Schubert# -------------------------- 607*b50261e2SCy Schubert# Append unique VALUE onto the existing contents of VAR, assuming 608*b50261e2SCy Schubert# entries are delimited by the first character of VALUE. For example: 609*b50261e2SCy Schubert# 610*b50261e2SCy Schubert# func_append_uniq options " --another-option option-argument" 611*b50261e2SCy Schubert# 612*b50261e2SCy Schubert# will only append to $options if " --another-option option-argument " 613*b50261e2SCy Schubert# is not already present somewhere in $options already (note spaces at 614*b50261e2SCy Schubert# each end implied by leading space in second argument). 615*b50261e2SCy Schubertfunc_append_uniq () 616*b50261e2SCy Schubert{ 617*b50261e2SCy Schubert $debug_cmd 618*b50261e2SCy Schubert 619*b50261e2SCy Schubert eval _G_current_value='`$ECHO $'$1'`' 620*b50261e2SCy Schubert _G_delim=`expr "$2" : '\(.\)'` 621*b50261e2SCy Schubert 622*b50261e2SCy Schubert case $_G_delim$_G_current_value$_G_delim in 623*b50261e2SCy Schubert *"$2$_G_delim"*) ;; 624*b50261e2SCy Schubert *) func_append "$@" ;; 625*b50261e2SCy Schubert esac 626*b50261e2SCy Schubert} 627*b50261e2SCy Schubert 628*b50261e2SCy Schubert 629*b50261e2SCy Schubert# func_arith TERM... 630*b50261e2SCy Schubert# ------------------ 631*b50261e2SCy Schubert# Set func_arith_result to the result of evaluating TERMs. 632*b50261e2SCy Schubert test -z "$_G_HAVE_ARITH_OP" \ 633*b50261e2SCy Schubert && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 634*b50261e2SCy Schubert && _G_HAVE_ARITH_OP=yes 635*b50261e2SCy Schubert 636*b50261e2SCy Schubertif test yes = "$_G_HAVE_ARITH_OP"; then 637*b50261e2SCy Schubert eval 'func_arith () 638*b50261e2SCy Schubert { 639*b50261e2SCy Schubert $debug_cmd 640*b50261e2SCy Schubert 641*b50261e2SCy Schubert func_arith_result=$(( $* )) 642*b50261e2SCy Schubert }' 643*b50261e2SCy Schubertelse 644*b50261e2SCy Schubert func_arith () 645*b50261e2SCy Schubert { 646*b50261e2SCy Schubert $debug_cmd 647*b50261e2SCy Schubert 648*b50261e2SCy Schubert func_arith_result=`expr "$@"` 649*b50261e2SCy Schubert } 650*b50261e2SCy Schubertfi 651*b50261e2SCy Schubert 652*b50261e2SCy Schubert 653*b50261e2SCy Schubert# func_basename FILE 654*b50261e2SCy Schubert# ------------------ 655*b50261e2SCy Schubert# Set func_basename_result to FILE with everything up to and including 656*b50261e2SCy Schubert# the last / stripped. 657*b50261e2SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 658*b50261e2SCy Schubert # If this shell supports suffix pattern removal, then use it to avoid 659*b50261e2SCy Schubert # forking. Hide the definitions single quotes in case the shell chokes 660*b50261e2SCy Schubert # on unsupported syntax... 661*b50261e2SCy Schubert _b='func_basename_result=${1##*/}' 662*b50261e2SCy Schubert _d='case $1 in 663*b50261e2SCy Schubert */*) func_dirname_result=${1%/*}$2 ;; 664*b50261e2SCy Schubert * ) func_dirname_result=$3 ;; 665*b50261e2SCy Schubert esac' 666*b50261e2SCy Schubert 667*b50261e2SCy Schubertelse 668*b50261e2SCy Schubert # ...otherwise fall back to using sed. 669*b50261e2SCy Schubert _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 670*b50261e2SCy Schubert _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 671*b50261e2SCy Schubert if test "X$func_dirname_result" = "X$1"; then 672*b50261e2SCy Schubert func_dirname_result=$3 673*b50261e2SCy Schubert else 674*b50261e2SCy Schubert func_append func_dirname_result "$2" 675*b50261e2SCy Schubert fi' 676*b50261e2SCy Schubertfi 677*b50261e2SCy Schubert 678*b50261e2SCy Schuberteval 'func_basename () 679*b50261e2SCy Schubert{ 680*b50261e2SCy Schubert $debug_cmd 681*b50261e2SCy Schubert 682*b50261e2SCy Schubert '"$_b"' 683*b50261e2SCy Schubert}' 684*b50261e2SCy Schubert 685*b50261e2SCy Schubert 686*b50261e2SCy Schubert# func_dirname FILE APPEND NONDIR_REPLACEMENT 687*b50261e2SCy Schubert# ------------------------------------------- 688*b50261e2SCy Schubert# Compute the dirname of FILE. If nonempty, add APPEND to the result, 689*b50261e2SCy Schubert# otherwise set result to NONDIR_REPLACEMENT. 690*b50261e2SCy Schuberteval 'func_dirname () 691*b50261e2SCy Schubert{ 692*b50261e2SCy Schubert $debug_cmd 693*b50261e2SCy Schubert 694*b50261e2SCy Schubert '"$_d"' 695*b50261e2SCy Schubert}' 696*b50261e2SCy Schubert 697*b50261e2SCy Schubert 698*b50261e2SCy Schubert# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 699*b50261e2SCy Schubert# -------------------------------------------------------- 700*b50261e2SCy Schubert# Perform func_basename and func_dirname in a single function 701*b50261e2SCy Schubert# call: 702*b50261e2SCy Schubert# dirname: Compute the dirname of FILE. If nonempty, 703*b50261e2SCy Schubert# add APPEND to the result, otherwise set result 704*b50261e2SCy Schubert# to NONDIR_REPLACEMENT. 705*b50261e2SCy Schubert# value returned in "$func_dirname_result" 706*b50261e2SCy Schubert# basename: Compute filename of FILE. 707*b50261e2SCy Schubert# value retuned in "$func_basename_result" 708*b50261e2SCy Schubert# For efficiency, we do not delegate to the functions above but instead 709*b50261e2SCy Schubert# duplicate the functionality here. 710*b50261e2SCy Schuberteval 'func_dirname_and_basename () 711*b50261e2SCy Schubert{ 712*b50261e2SCy Schubert $debug_cmd 713*b50261e2SCy Schubert 714*b50261e2SCy Schubert '"$_b"' 715*b50261e2SCy Schubert '"$_d"' 716*b50261e2SCy Schubert}' 717*b50261e2SCy Schubert 718*b50261e2SCy Schubert 719*b50261e2SCy Schubert# func_echo ARG... 720*b50261e2SCy Schubert# ---------------- 721*b50261e2SCy Schubert# Echo program name prefixed message. 722*b50261e2SCy Schubertfunc_echo () 723*b50261e2SCy Schubert{ 724*b50261e2SCy Schubert $debug_cmd 725*b50261e2SCy Schubert 726*b50261e2SCy Schubert _G_message=$* 727*b50261e2SCy Schubert 728*b50261e2SCy Schubert func_echo_IFS=$IFS 729*b50261e2SCy Schubert IFS=$nl 730*b50261e2SCy Schubert for _G_line in $_G_message; do 731*b50261e2SCy Schubert IFS=$func_echo_IFS 732*b50261e2SCy Schubert $ECHO "$progname: $_G_line" 733*b50261e2SCy Schubert done 734*b50261e2SCy Schubert IFS=$func_echo_IFS 735*b50261e2SCy Schubert} 736*b50261e2SCy Schubert 737*b50261e2SCy Schubert 738*b50261e2SCy Schubert# func_echo_all ARG... 739*b50261e2SCy Schubert# -------------------- 740*b50261e2SCy Schubert# Invoke $ECHO with all args, space-separated. 741*b50261e2SCy Schubertfunc_echo_all () 742*b50261e2SCy Schubert{ 743*b50261e2SCy Schubert $ECHO "$*" 744*b50261e2SCy Schubert} 745*b50261e2SCy Schubert 746*b50261e2SCy Schubert 747*b50261e2SCy Schubert# func_echo_infix_1 INFIX ARG... 748*b50261e2SCy Schubert# ------------------------------ 749*b50261e2SCy Schubert# Echo program name, followed by INFIX on the first line, with any 750*b50261e2SCy Schubert# additional lines not showing INFIX. 751*b50261e2SCy Schubertfunc_echo_infix_1 () 752*b50261e2SCy Schubert{ 753*b50261e2SCy Schubert $debug_cmd 754*b50261e2SCy Schubert 755*b50261e2SCy Schubert $require_term_colors 756*b50261e2SCy Schubert 757*b50261e2SCy Schubert _G_infix=$1; shift 758*b50261e2SCy Schubert _G_indent=$_G_infix 759*b50261e2SCy Schubert _G_prefix="$progname: $_G_infix: " 760*b50261e2SCy Schubert _G_message=$* 761*b50261e2SCy Schubert 762*b50261e2SCy Schubert # Strip color escape sequences before counting printable length 763*b50261e2SCy Schubert for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 764*b50261e2SCy Schubert do 765*b50261e2SCy Schubert test -n "$_G_tc" && { 766*b50261e2SCy Schubert _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 767*b50261e2SCy Schubert _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 768*b50261e2SCy Schubert } 769*b50261e2SCy Schubert done 770*b50261e2SCy Schubert _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 771*b50261e2SCy Schubert 772*b50261e2SCy Schubert func_echo_infix_1_IFS=$IFS 773*b50261e2SCy Schubert IFS=$nl 774*b50261e2SCy Schubert for _G_line in $_G_message; do 775*b50261e2SCy Schubert IFS=$func_echo_infix_1_IFS 776*b50261e2SCy Schubert $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 777*b50261e2SCy Schubert _G_prefix=$_G_indent 778*b50261e2SCy Schubert done 779*b50261e2SCy Schubert IFS=$func_echo_infix_1_IFS 780*b50261e2SCy Schubert} 781*b50261e2SCy Schubert 782*b50261e2SCy Schubert 783*b50261e2SCy Schubert# func_error ARG... 784*b50261e2SCy Schubert# ----------------- 785*b50261e2SCy Schubert# Echo program name prefixed message to standard error. 786*b50261e2SCy Schubertfunc_error () 787*b50261e2SCy Schubert{ 788*b50261e2SCy Schubert $debug_cmd 789*b50261e2SCy Schubert 790*b50261e2SCy Schubert $require_term_colors 791*b50261e2SCy Schubert 792*b50261e2SCy Schubert func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 793*b50261e2SCy Schubert} 794*b50261e2SCy Schubert 795*b50261e2SCy Schubert 796*b50261e2SCy Schubert# func_fatal_error ARG... 797*b50261e2SCy Schubert# ----------------------- 798*b50261e2SCy Schubert# Echo program name prefixed message to standard error, and exit. 799*b50261e2SCy Schubertfunc_fatal_error () 800*b50261e2SCy Schubert{ 801*b50261e2SCy Schubert $debug_cmd 802*b50261e2SCy Schubert 803*b50261e2SCy Schubert func_error "$*" 804*b50261e2SCy Schubert exit $EXIT_FAILURE 805*b50261e2SCy Schubert} 806*b50261e2SCy Schubert 807*b50261e2SCy Schubert 808*b50261e2SCy Schubert# func_grep EXPRESSION FILENAME 809*b50261e2SCy Schubert# ----------------------------- 810*b50261e2SCy Schubert# Check whether EXPRESSION matches any line of FILENAME, without output. 811*b50261e2SCy Schubertfunc_grep () 812*b50261e2SCy Schubert{ 813*b50261e2SCy Schubert $debug_cmd 814*b50261e2SCy Schubert 815*b50261e2SCy Schubert $GREP "$1" "$2" >/dev/null 2>&1 816*b50261e2SCy Schubert} 817*b50261e2SCy Schubert 818*b50261e2SCy Schubert 819*b50261e2SCy Schubert# func_len STRING 820*b50261e2SCy Schubert# --------------- 821*b50261e2SCy Schubert# Set func_len_result to the length of STRING. STRING may not 822*b50261e2SCy Schubert# start with a hyphen. 823*b50261e2SCy Schubert test -z "$_G_HAVE_XSI_OPS" \ 824*b50261e2SCy Schubert && (eval 'x=a/b/c; 825*b50261e2SCy Schubert test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 826*b50261e2SCy Schubert && _G_HAVE_XSI_OPS=yes 827*b50261e2SCy Schubert 828*b50261e2SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 829*b50261e2SCy Schubert eval 'func_len () 830*b50261e2SCy Schubert { 831*b50261e2SCy Schubert $debug_cmd 832*b50261e2SCy Schubert 833*b50261e2SCy Schubert func_len_result=${#1} 834*b50261e2SCy Schubert }' 835*b50261e2SCy Schubertelse 836*b50261e2SCy Schubert func_len () 837*b50261e2SCy Schubert { 838*b50261e2SCy Schubert $debug_cmd 839*b50261e2SCy Schubert 840*b50261e2SCy Schubert func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 841*b50261e2SCy Schubert } 842*b50261e2SCy Schubertfi 843*b50261e2SCy Schubert 844*b50261e2SCy Schubert 845*b50261e2SCy Schubert# func_mkdir_p DIRECTORY-PATH 846*b50261e2SCy Schubert# --------------------------- 847*b50261e2SCy Schubert# Make sure the entire path to DIRECTORY-PATH is available. 848*b50261e2SCy Schubertfunc_mkdir_p () 849*b50261e2SCy Schubert{ 850*b50261e2SCy Schubert $debug_cmd 851*b50261e2SCy Schubert 852*b50261e2SCy Schubert _G_directory_path=$1 853*b50261e2SCy Schubert _G_dir_list= 854*b50261e2SCy Schubert 855*b50261e2SCy Schubert if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 856*b50261e2SCy Schubert 857*b50261e2SCy Schubert # Protect directory names starting with '-' 858*b50261e2SCy Schubert case $_G_directory_path in 859*b50261e2SCy Schubert -*) _G_directory_path=./$_G_directory_path ;; 860*b50261e2SCy Schubert esac 861*b50261e2SCy Schubert 862*b50261e2SCy Schubert # While some portion of DIR does not yet exist... 863*b50261e2SCy Schubert while test ! -d "$_G_directory_path"; do 864*b50261e2SCy Schubert # ...make a list in topmost first order. Use a colon delimited 865*b50261e2SCy Schubert # list incase some portion of path contains whitespace. 866*b50261e2SCy Schubert _G_dir_list=$_G_directory_path:$_G_dir_list 867*b50261e2SCy Schubert 868*b50261e2SCy Schubert # If the last portion added has no slash in it, the list is done 869*b50261e2SCy Schubert case $_G_directory_path in */*) ;; *) break ;; esac 870*b50261e2SCy Schubert 871*b50261e2SCy Schubert # ...otherwise throw away the child directory and loop 872*b50261e2SCy Schubert _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 873*b50261e2SCy Schubert done 874*b50261e2SCy Schubert _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 875*b50261e2SCy Schubert 876*b50261e2SCy Schubert func_mkdir_p_IFS=$IFS; IFS=: 877*b50261e2SCy Schubert for _G_dir in $_G_dir_list; do 878*b50261e2SCy Schubert IFS=$func_mkdir_p_IFS 879*b50261e2SCy Schubert # mkdir can fail with a 'File exist' error if two processes 880*b50261e2SCy Schubert # try to create one of the directories concurrently. Don't 881*b50261e2SCy Schubert # stop in that case! 882*b50261e2SCy Schubert $MKDIR "$_G_dir" 2>/dev/null || : 883*b50261e2SCy Schubert done 884*b50261e2SCy Schubert IFS=$func_mkdir_p_IFS 885*b50261e2SCy Schubert 886*b50261e2SCy Schubert # Bail out if we (or some other process) failed to create a directory. 887*b50261e2SCy Schubert test -d "$_G_directory_path" || \ 888*b50261e2SCy Schubert func_fatal_error "Failed to create '$1'" 889*b50261e2SCy Schubert fi 890*b50261e2SCy Schubert} 891*b50261e2SCy Schubert 892*b50261e2SCy Schubert 893*b50261e2SCy Schubert# func_mktempdir [BASENAME] 894*b50261e2SCy Schubert# ------------------------- 895*b50261e2SCy Schubert# Make a temporary directory that won't clash with other running 896*b50261e2SCy Schubert# libtool processes, and avoids race conditions if possible. If 897*b50261e2SCy Schubert# given, BASENAME is the basename for that directory. 898*b50261e2SCy Schubertfunc_mktempdir () 899*b50261e2SCy Schubert{ 900*b50261e2SCy Schubert $debug_cmd 901*b50261e2SCy Schubert 902*b50261e2SCy Schubert _G_template=${TMPDIR-/tmp}/${1-$progname} 903*b50261e2SCy Schubert 904*b50261e2SCy Schubert if test : = "$opt_dry_run"; then 905*b50261e2SCy Schubert # Return a directory name, but don't create it in dry-run mode 906*b50261e2SCy Schubert _G_tmpdir=$_G_template-$$ 907*b50261e2SCy Schubert else 908*b50261e2SCy Schubert 909*b50261e2SCy Schubert # If mktemp works, use that first and foremost 910*b50261e2SCy Schubert _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 911*b50261e2SCy Schubert 912*b50261e2SCy Schubert if test ! -d "$_G_tmpdir"; then 913*b50261e2SCy Schubert # Failing that, at least try and use $RANDOM to avoid a race 914*b50261e2SCy Schubert _G_tmpdir=$_G_template-${RANDOM-0}$$ 915*b50261e2SCy Schubert 916*b50261e2SCy Schubert func_mktempdir_umask=`umask` 917*b50261e2SCy Schubert umask 0077 918*b50261e2SCy Schubert $MKDIR "$_G_tmpdir" 919*b50261e2SCy Schubert umask $func_mktempdir_umask 920*b50261e2SCy Schubert fi 921*b50261e2SCy Schubert 922*b50261e2SCy Schubert # If we're not in dry-run mode, bomb out on failure 923*b50261e2SCy Schubert test -d "$_G_tmpdir" || \ 924*b50261e2SCy Schubert func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 925*b50261e2SCy Schubert fi 926*b50261e2SCy Schubert 927*b50261e2SCy Schubert $ECHO "$_G_tmpdir" 928*b50261e2SCy Schubert} 929*b50261e2SCy Schubert 930*b50261e2SCy Schubert 931*b50261e2SCy Schubert# func_normal_abspath PATH 932*b50261e2SCy Schubert# ------------------------ 933*b50261e2SCy Schubert# Remove doubled-up and trailing slashes, "." path components, 934*b50261e2SCy Schubert# and cancel out any ".." path components in PATH after making 935*b50261e2SCy Schubert# it an absolute path. 936*b50261e2SCy Schubertfunc_normal_abspath () 937*b50261e2SCy Schubert{ 938*b50261e2SCy Schubert $debug_cmd 939*b50261e2SCy Schubert 940*b50261e2SCy Schubert # These SED scripts presuppose an absolute path with a trailing slash. 941*b50261e2SCy Schubert _G_pathcar='s|^/\([^/]*\).*$|\1|' 942*b50261e2SCy Schubert _G_pathcdr='s|^/[^/]*||' 943*b50261e2SCy Schubert _G_removedotparts=':dotsl 944*b50261e2SCy Schubert s|/\./|/|g 945*b50261e2SCy Schubert t dotsl 946*b50261e2SCy Schubert s|/\.$|/|' 947*b50261e2SCy Schubert _G_collapseslashes='s|/\{1,\}|/|g' 948*b50261e2SCy Schubert _G_finalslash='s|/*$|/|' 949*b50261e2SCy Schubert 950*b50261e2SCy Schubert # Start from root dir and reassemble the path. 951*b50261e2SCy Schubert func_normal_abspath_result= 952*b50261e2SCy Schubert func_normal_abspath_tpath=$1 953*b50261e2SCy Schubert func_normal_abspath_altnamespace= 954*b50261e2SCy Schubert case $func_normal_abspath_tpath in 955*b50261e2SCy Schubert "") 956*b50261e2SCy Schubert # Empty path, that just means $cwd. 957*b50261e2SCy Schubert func_stripname '' '/' "`pwd`" 958*b50261e2SCy Schubert func_normal_abspath_result=$func_stripname_result 959*b50261e2SCy Schubert return 960*b50261e2SCy Schubert ;; 961*b50261e2SCy Schubert # The next three entries are used to spot a run of precisely 962*b50261e2SCy Schubert # two leading slashes without using negated character classes; 963*b50261e2SCy Schubert # we take advantage of case's first-match behaviour. 964*b50261e2SCy Schubert ///*) 965*b50261e2SCy Schubert # Unusual form of absolute path, do nothing. 966*b50261e2SCy Schubert ;; 967*b50261e2SCy Schubert //*) 968*b50261e2SCy Schubert # Not necessarily an ordinary path; POSIX reserves leading '//' 969*b50261e2SCy Schubert # and for example Cygwin uses it to access remote file shares 970*b50261e2SCy Schubert # over CIFS/SMB, so we conserve a leading double slash if found. 971*b50261e2SCy Schubert func_normal_abspath_altnamespace=/ 972*b50261e2SCy Schubert ;; 973*b50261e2SCy Schubert /*) 974*b50261e2SCy Schubert # Absolute path, do nothing. 975*b50261e2SCy Schubert ;; 976*b50261e2SCy Schubert *) 977*b50261e2SCy Schubert # Relative path, prepend $cwd. 978*b50261e2SCy Schubert func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 979*b50261e2SCy Schubert ;; 980*b50261e2SCy Schubert esac 981*b50261e2SCy Schubert 982*b50261e2SCy Schubert # Cancel out all the simple stuff to save iterations. We also want 983*b50261e2SCy Schubert # the path to end with a slash for ease of parsing, so make sure 984*b50261e2SCy Schubert # there is one (and only one) here. 985*b50261e2SCy Schubert func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 986*b50261e2SCy Schubert -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 987*b50261e2SCy Schubert while :; do 988*b50261e2SCy Schubert # Processed it all yet? 989*b50261e2SCy Schubert if test / = "$func_normal_abspath_tpath"; then 990*b50261e2SCy Schubert # If we ascended to the root using ".." the result may be empty now. 991*b50261e2SCy Schubert if test -z "$func_normal_abspath_result"; then 992*b50261e2SCy Schubert func_normal_abspath_result=/ 993*b50261e2SCy Schubert fi 994*b50261e2SCy Schubert break 995*b50261e2SCy Schubert fi 996*b50261e2SCy Schubert func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 997*b50261e2SCy Schubert -e "$_G_pathcar"` 998*b50261e2SCy Schubert func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 999*b50261e2SCy Schubert -e "$_G_pathcdr"` 1000*b50261e2SCy Schubert # Figure out what to do with it 1001*b50261e2SCy Schubert case $func_normal_abspath_tcomponent in 1002*b50261e2SCy Schubert "") 1003*b50261e2SCy Schubert # Trailing empty path component, ignore it. 1004*b50261e2SCy Schubert ;; 1005*b50261e2SCy Schubert ..) 1006*b50261e2SCy Schubert # Parent dir; strip last assembled component from result. 1007*b50261e2SCy Schubert func_dirname "$func_normal_abspath_result" 1008*b50261e2SCy Schubert func_normal_abspath_result=$func_dirname_result 1009*b50261e2SCy Schubert ;; 1010*b50261e2SCy Schubert *) 1011*b50261e2SCy Schubert # Actual path component, append it. 1012*b50261e2SCy Schubert func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1013*b50261e2SCy Schubert ;; 1014*b50261e2SCy Schubert esac 1015*b50261e2SCy Schubert done 1016*b50261e2SCy Schubert # Restore leading double-slash if one was found on entry. 1017*b50261e2SCy Schubert func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1018*b50261e2SCy Schubert} 1019*b50261e2SCy Schubert 1020*b50261e2SCy Schubert 1021*b50261e2SCy Schubert# func_notquiet ARG... 1022*b50261e2SCy Schubert# -------------------- 1023*b50261e2SCy Schubert# Echo program name prefixed message only when not in quiet mode. 1024*b50261e2SCy Schubertfunc_notquiet () 1025*b50261e2SCy Schubert{ 1026*b50261e2SCy Schubert $debug_cmd 1027*b50261e2SCy Schubert 1028*b50261e2SCy Schubert $opt_quiet || func_echo ${1+"$@"} 1029*b50261e2SCy Schubert 1030*b50261e2SCy Schubert # A bug in bash halts the script if the last line of a function 1031*b50261e2SCy Schubert # fails when set -e is in force, so we need another command to 1032*b50261e2SCy Schubert # work around that: 1033*b50261e2SCy Schubert : 1034*b50261e2SCy Schubert} 1035*b50261e2SCy Schubert 1036*b50261e2SCy Schubert 1037*b50261e2SCy Schubert# func_relative_path SRCDIR DSTDIR 1038*b50261e2SCy Schubert# -------------------------------- 1039*b50261e2SCy Schubert# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1040*b50261e2SCy Schubertfunc_relative_path () 1041*b50261e2SCy Schubert{ 1042*b50261e2SCy Schubert $debug_cmd 1043*b50261e2SCy Schubert 1044*b50261e2SCy Schubert func_relative_path_result= 1045*b50261e2SCy Schubert func_normal_abspath "$1" 1046*b50261e2SCy Schubert func_relative_path_tlibdir=$func_normal_abspath_result 1047*b50261e2SCy Schubert func_normal_abspath "$2" 1048*b50261e2SCy Schubert func_relative_path_tbindir=$func_normal_abspath_result 1049*b50261e2SCy Schubert 1050*b50261e2SCy Schubert # Ascend the tree starting from libdir 1051*b50261e2SCy Schubert while :; do 1052*b50261e2SCy Schubert # check if we have found a prefix of bindir 1053*b50261e2SCy Schubert case $func_relative_path_tbindir in 1054*b50261e2SCy Schubert $func_relative_path_tlibdir) 1055*b50261e2SCy Schubert # found an exact match 1056*b50261e2SCy Schubert func_relative_path_tcancelled= 1057*b50261e2SCy Schubert break 1058*b50261e2SCy Schubert ;; 1059*b50261e2SCy Schubert $func_relative_path_tlibdir*) 1060*b50261e2SCy Schubert # found a matching prefix 1061*b50261e2SCy Schubert func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1062*b50261e2SCy Schubert func_relative_path_tcancelled=$func_stripname_result 1063*b50261e2SCy Schubert if test -z "$func_relative_path_result"; then 1064*b50261e2SCy Schubert func_relative_path_result=. 1065*b50261e2SCy Schubert fi 1066*b50261e2SCy Schubert break 1067*b50261e2SCy Schubert ;; 1068*b50261e2SCy Schubert *) 1069*b50261e2SCy Schubert func_dirname $func_relative_path_tlibdir 1070*b50261e2SCy Schubert func_relative_path_tlibdir=$func_dirname_result 1071*b50261e2SCy Schubert if test -z "$func_relative_path_tlibdir"; then 1072*b50261e2SCy Schubert # Have to descend all the way to the root! 1073*b50261e2SCy Schubert func_relative_path_result=../$func_relative_path_result 1074*b50261e2SCy Schubert func_relative_path_tcancelled=$func_relative_path_tbindir 1075*b50261e2SCy Schubert break 1076*b50261e2SCy Schubert fi 1077*b50261e2SCy Schubert func_relative_path_result=../$func_relative_path_result 1078*b50261e2SCy Schubert ;; 1079*b50261e2SCy Schubert esac 1080*b50261e2SCy Schubert done 1081*b50261e2SCy Schubert 1082*b50261e2SCy Schubert # Now calculate path; take care to avoid doubling-up slashes. 1083*b50261e2SCy Schubert func_stripname '' '/' "$func_relative_path_result" 1084*b50261e2SCy Schubert func_relative_path_result=$func_stripname_result 1085*b50261e2SCy Schubert func_stripname '/' '/' "$func_relative_path_tcancelled" 1086*b50261e2SCy Schubert if test -n "$func_stripname_result"; then 1087*b50261e2SCy Schubert func_append func_relative_path_result "/$func_stripname_result" 1088*b50261e2SCy Schubert fi 1089*b50261e2SCy Schubert 1090*b50261e2SCy Schubert # Normalisation. If bindir is libdir, return '.' else relative path. 1091*b50261e2SCy Schubert if test -n "$func_relative_path_result"; then 1092*b50261e2SCy Schubert func_stripname './' '' "$func_relative_path_result" 1093*b50261e2SCy Schubert func_relative_path_result=$func_stripname_result 1094*b50261e2SCy Schubert fi 1095*b50261e2SCy Schubert 1096*b50261e2SCy Schubert test -n "$func_relative_path_result" || func_relative_path_result=. 1097*b50261e2SCy Schubert 1098*b50261e2SCy Schubert : 1099*b50261e2SCy Schubert} 1100*b50261e2SCy Schubert 1101*b50261e2SCy Schubert 1102*b50261e2SCy Schubert# func_quote_portable EVAL ARG 1103*b50261e2SCy Schubert# ---------------------------- 1104*b50261e2SCy Schubert# Internal function to portably implement func_quote_arg. Note that we still 1105*b50261e2SCy Schubert# keep attention to performance here so we as much as possible try to avoid 1106*b50261e2SCy Schubert# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1107*b50261e2SCy Schubertfunc_quote_portable () 1108*b50261e2SCy Schubert{ 1109*b50261e2SCy Schubert $debug_cmd 1110*b50261e2SCy Schubert 1111*b50261e2SCy Schubert func_quote_portable_result=$2 1112*b50261e2SCy Schubert 1113*b50261e2SCy Schubert # one-time-loop (easy break) 1114*b50261e2SCy Schubert while true 1115*b50261e2SCy Schubert do 1116*b50261e2SCy Schubert if $1; then 1117*b50261e2SCy Schubert func_quote_portable_result=`$ECHO "$2" | $SED \ 1118*b50261e2SCy Schubert -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1119*b50261e2SCy Schubert break 1120*b50261e2SCy Schubert fi 1121*b50261e2SCy Schubert 1122*b50261e2SCy Schubert # Quote for eval. 1123*b50261e2SCy Schubert case $func_quote_portable_result in 1124*b50261e2SCy Schubert *[\\\`\"\$]*) 1125*b50261e2SCy Schubert case $func_quote_portable_result in 1126*b50261e2SCy Schubert *[\[\*\?]*) 1127*b50261e2SCy Schubert func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1128*b50261e2SCy Schubert | $SED "$sed_quote_subst"` 1129*b50261e2SCy Schubert break 1130*b50261e2SCy Schubert ;; 1131*b50261e2SCy Schubert esac 1132*b50261e2SCy Schubert 1133*b50261e2SCy Schubert func_quote_portable_old_IFS=$IFS 1134*b50261e2SCy Schubert for _G_char in '\' '`' '"' '$' 1135*b50261e2SCy Schubert do 1136*b50261e2SCy Schubert # STATE($1) PREV($2) SEPARATOR($3) 1137*b50261e2SCy Schubert set start "" "" 1138*b50261e2SCy Schubert func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1139*b50261e2SCy Schubert IFS=$_G_char 1140*b50261e2SCy Schubert for _G_part in $func_quote_portable_result 1141*b50261e2SCy Schubert do 1142*b50261e2SCy Schubert case $1 in 1143*b50261e2SCy Schubert quote) 1144*b50261e2SCy Schubert func_append func_quote_portable_result "$3$2" 1145*b50261e2SCy Schubert set quote "$_G_part" "\\$_G_char" 1146*b50261e2SCy Schubert ;; 1147*b50261e2SCy Schubert start) 1148*b50261e2SCy Schubert set first "" "" 1149*b50261e2SCy Schubert func_quote_portable_result= 1150*b50261e2SCy Schubert ;; 1151*b50261e2SCy Schubert first) 1152*b50261e2SCy Schubert set quote "$_G_part" "" 1153*b50261e2SCy Schubert ;; 1154*b50261e2SCy Schubert esac 1155*b50261e2SCy Schubert done 1156*b50261e2SCy Schubert done 1157*b50261e2SCy Schubert IFS=$func_quote_portable_old_IFS 1158*b50261e2SCy Schubert ;; 1159*b50261e2SCy Schubert *) ;; 1160*b50261e2SCy Schubert esac 1161*b50261e2SCy Schubert break 1162*b50261e2SCy Schubert done 1163*b50261e2SCy Schubert 1164*b50261e2SCy Schubert func_quote_portable_unquoted_result=$func_quote_portable_result 1165*b50261e2SCy Schubert case $func_quote_portable_result in 1166*b50261e2SCy Schubert # double-quote args containing shell metacharacters to delay 1167*b50261e2SCy Schubert # word splitting, command substitution and variable expansion 1168*b50261e2SCy Schubert # for a subsequent eval. 1169*b50261e2SCy Schubert # many bourne shells cannot handle close brackets correctly 1170*b50261e2SCy Schubert # in scan sets, so we specify it separately. 1171*b50261e2SCy Schubert *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1172*b50261e2SCy Schubert func_quote_portable_result=\"$func_quote_portable_result\" 1173*b50261e2SCy Schubert ;; 1174*b50261e2SCy Schubert esac 1175*b50261e2SCy Schubert} 1176*b50261e2SCy Schubert 1177*b50261e2SCy Schubert 1178*b50261e2SCy Schubert# func_quotefast_eval ARG 1179*b50261e2SCy Schubert# ----------------------- 1180*b50261e2SCy Schubert# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1181*b50261e2SCy Schubert# but optimized for speed. Result is stored in $func_quotefast_eval. 1182*b50261e2SCy Schubertif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1183*b50261e2SCy Schubert printf -v _GL_test_printf_tilde %q '~' 1184*b50261e2SCy Schubert if test '\~' = "$_GL_test_printf_tilde"; then 1185*b50261e2SCy Schubert func_quotefast_eval () 1186*b50261e2SCy Schubert { 1187*b50261e2SCy Schubert printf -v func_quotefast_eval_result %q "$1" 1188*b50261e2SCy Schubert } 1189*b50261e2SCy Schubert else 1190*b50261e2SCy Schubert # Broken older Bash implementations. Make those faster too if possible. 1191*b50261e2SCy Schubert func_quotefast_eval () 1192*b50261e2SCy Schubert { 1193*b50261e2SCy Schubert case $1 in 1194*b50261e2SCy Schubert '~'*) 1195*b50261e2SCy Schubert func_quote_portable false "$1" 1196*b50261e2SCy Schubert func_quotefast_eval_result=$func_quote_portable_result 1197*b50261e2SCy Schubert ;; 1198*b50261e2SCy Schubert *) 1199*b50261e2SCy Schubert printf -v func_quotefast_eval_result %q "$1" 1200*b50261e2SCy Schubert ;; 1201*b50261e2SCy Schubert esac 1202*b50261e2SCy Schubert } 1203*b50261e2SCy Schubert fi 1204*b50261e2SCy Schubertelse 1205*b50261e2SCy Schubert func_quotefast_eval () 1206*b50261e2SCy Schubert { 1207*b50261e2SCy Schubert func_quote_portable false "$1" 1208*b50261e2SCy Schubert func_quotefast_eval_result=$func_quote_portable_result 1209*b50261e2SCy Schubert } 1210*b50261e2SCy Schubertfi 1211*b50261e2SCy Schubert 1212*b50261e2SCy Schubert 1213*b50261e2SCy Schubert# func_quote_arg MODEs ARG 1214*b50261e2SCy Schubert# ------------------------ 1215*b50261e2SCy Schubert# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1216*b50261e2SCy Schubert# specifiers listed below separated by ',' character. This function returns two 1217*b50261e2SCy Schubert# values: 1218*b50261e2SCy Schubert# i) func_quote_arg_result 1219*b50261e2SCy Schubert# double-quoted (when needed), suitable for a subsequent eval 1220*b50261e2SCy Schubert# ii) func_quote_arg_unquoted_result 1221*b50261e2SCy Schubert# has all characters that are still active within double 1222*b50261e2SCy Schubert# quotes backslashified. Available only if 'unquoted' is specified. 1223*b50261e2SCy Schubert# 1224*b50261e2SCy Schubert# Available modes: 1225*b50261e2SCy Schubert# ---------------- 1226*b50261e2SCy Schubert# 'eval' (default) 1227*b50261e2SCy Schubert# - escape shell special characters 1228*b50261e2SCy Schubert# 'expand' 1229*b50261e2SCy Schubert# - the same as 'eval'; but do not quote variable references 1230*b50261e2SCy Schubert# 'pretty' 1231*b50261e2SCy Schubert# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1232*b50261e2SCy Schubert# be used later in func_quote to get output like: 'echo "a b"' instead 1233*b50261e2SCy Schubert# of 'echo a\ b'. This is slower than default on some shells. 1234*b50261e2SCy Schubert# 'unquoted' 1235*b50261e2SCy Schubert# - produce also $func_quote_arg_unquoted_result which does not contain 1236*b50261e2SCy Schubert# wrapping double-quotes. 1237*b50261e2SCy Schubert# 1238*b50261e2SCy Schubert# Examples for 'func_quote_arg pretty,unquoted string': 1239*b50261e2SCy Schubert# 1240*b50261e2SCy Schubert# string | *_result | *_unquoted_result 1241*b50261e2SCy Schubert# ------------+-----------------------+------------------- 1242*b50261e2SCy Schubert# " | \" | \" 1243*b50261e2SCy Schubert# a b | "a b" | a b 1244*b50261e2SCy Schubert# "a b" | "\"a b\"" | \"a b\" 1245*b50261e2SCy Schubert# * | "*" | * 1246*b50261e2SCy Schubert# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1247*b50261e2SCy Schubert# 1248*b50261e2SCy Schubert# Examples for 'func_quote_arg pretty,unquoted,expand string': 1249*b50261e2SCy Schubert# 1250*b50261e2SCy Schubert# string | *_result | *_unquoted_result 1251*b50261e2SCy Schubert# --------------+---------------------+-------------------- 1252*b50261e2SCy Schubert# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1253*b50261e2SCy Schubertfunc_quote_arg () 1254*b50261e2SCy Schubert{ 1255*b50261e2SCy Schubert _G_quote_expand=false 1256*b50261e2SCy Schubert case ,$1, in 1257*b50261e2SCy Schubert *,expand,*) 1258*b50261e2SCy Schubert _G_quote_expand=: 1259*b50261e2SCy Schubert ;; 1260*b50261e2SCy Schubert esac 1261*b50261e2SCy Schubert 1262*b50261e2SCy Schubert case ,$1, in 1263*b50261e2SCy Schubert *,pretty,*|*,expand,*|*,unquoted,*) 1264*b50261e2SCy Schubert func_quote_portable $_G_quote_expand "$2" 1265*b50261e2SCy Schubert func_quote_arg_result=$func_quote_portable_result 1266*b50261e2SCy Schubert func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1267*b50261e2SCy Schubert ;; 1268*b50261e2SCy Schubert *) 1269*b50261e2SCy Schubert # Faster quote-for-eval for some shells. 1270*b50261e2SCy Schubert func_quotefast_eval "$2" 1271*b50261e2SCy Schubert func_quote_arg_result=$func_quotefast_eval_result 1272*b50261e2SCy Schubert ;; 1273*b50261e2SCy Schubert esac 1274*b50261e2SCy Schubert} 1275*b50261e2SCy Schubert 1276*b50261e2SCy Schubert 1277*b50261e2SCy Schubert# func_quote MODEs ARGs... 1278*b50261e2SCy Schubert# ------------------------ 1279*b50261e2SCy Schubert# Quote all ARGs to be evaled later and join them into single command. See 1280*b50261e2SCy Schubert# func_quote_arg's description for more info. 1281*b50261e2SCy Schubertfunc_quote () 1282*b50261e2SCy Schubert{ 1283*b50261e2SCy Schubert $debug_cmd 1284*b50261e2SCy Schubert _G_func_quote_mode=$1 ; shift 1285*b50261e2SCy Schubert func_quote_result= 1286*b50261e2SCy Schubert while test 0 -lt $#; do 1287*b50261e2SCy Schubert func_quote_arg "$_G_func_quote_mode" "$1" 1288*b50261e2SCy Schubert if test -n "$func_quote_result"; then 1289*b50261e2SCy Schubert func_append func_quote_result " $func_quote_arg_result" 1290*b50261e2SCy Schubert else 1291*b50261e2SCy Schubert func_append func_quote_result "$func_quote_arg_result" 1292*b50261e2SCy Schubert fi 1293*b50261e2SCy Schubert shift 1294*b50261e2SCy Schubert done 1295*b50261e2SCy Schubert} 1296*b50261e2SCy Schubert 1297*b50261e2SCy Schubert 1298*b50261e2SCy Schubert# func_stripname PREFIX SUFFIX NAME 1299*b50261e2SCy Schubert# --------------------------------- 1300*b50261e2SCy Schubert# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1301*b50261e2SCy Schubert# PREFIX and SUFFIX must not contain globbing or regex special 1302*b50261e2SCy Schubert# characters, hashes, percent signs, but SUFFIX may contain a leading 1303*b50261e2SCy Schubert# dot (in which case that matches only a dot). 1304*b50261e2SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 1305*b50261e2SCy Schubert eval 'func_stripname () 1306*b50261e2SCy Schubert { 1307*b50261e2SCy Schubert $debug_cmd 1308*b50261e2SCy Schubert 1309*b50261e2SCy Schubert # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1310*b50261e2SCy Schubert # positional parameters, so assign one to ordinary variable first. 1311*b50261e2SCy Schubert func_stripname_result=$3 1312*b50261e2SCy Schubert func_stripname_result=${func_stripname_result#"$1"} 1313*b50261e2SCy Schubert func_stripname_result=${func_stripname_result%"$2"} 1314*b50261e2SCy Schubert }' 1315*b50261e2SCy Schubertelse 1316*b50261e2SCy Schubert func_stripname () 1317*b50261e2SCy Schubert { 1318*b50261e2SCy Schubert $debug_cmd 1319*b50261e2SCy Schubert 1320*b50261e2SCy Schubert case $2 in 1321*b50261e2SCy Schubert .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1322*b50261e2SCy Schubert *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1323*b50261e2SCy Schubert esac 1324*b50261e2SCy Schubert } 1325*b50261e2SCy Schubertfi 1326*b50261e2SCy Schubert 1327*b50261e2SCy Schubert 1328*b50261e2SCy Schubert# func_show_eval CMD [FAIL_EXP] 1329*b50261e2SCy Schubert# ----------------------------- 1330*b50261e2SCy Schubert# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1331*b50261e2SCy Schubert# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1332*b50261e2SCy Schubert# is given, then evaluate it. 1333*b50261e2SCy Schubertfunc_show_eval () 1334*b50261e2SCy Schubert{ 1335*b50261e2SCy Schubert $debug_cmd 1336*b50261e2SCy Schubert 1337*b50261e2SCy Schubert _G_cmd=$1 1338*b50261e2SCy Schubert _G_fail_exp=${2-':'} 1339*b50261e2SCy Schubert 1340*b50261e2SCy Schubert func_quote_arg pretty,expand "$_G_cmd" 1341*b50261e2SCy Schubert eval "func_notquiet $func_quote_arg_result" 1342*b50261e2SCy Schubert 1343*b50261e2SCy Schubert $opt_dry_run || { 1344*b50261e2SCy Schubert eval "$_G_cmd" 1345*b50261e2SCy Schubert _G_status=$? 1346*b50261e2SCy Schubert if test 0 -ne "$_G_status"; then 1347*b50261e2SCy Schubert eval "(exit $_G_status); $_G_fail_exp" 1348*b50261e2SCy Schubert fi 1349*b50261e2SCy Schubert } 1350*b50261e2SCy Schubert} 1351*b50261e2SCy Schubert 1352*b50261e2SCy Schubert 1353*b50261e2SCy Schubert# func_show_eval_locale CMD [FAIL_EXP] 1354*b50261e2SCy Schubert# ------------------------------------ 1355*b50261e2SCy Schubert# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1356*b50261e2SCy Schubert# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1357*b50261e2SCy Schubert# is given, then evaluate it. Use the saved locale for evaluation. 1358*b50261e2SCy Schubertfunc_show_eval_locale () 1359*b50261e2SCy Schubert{ 1360*b50261e2SCy Schubert $debug_cmd 1361*b50261e2SCy Schubert 1362*b50261e2SCy Schubert _G_cmd=$1 1363*b50261e2SCy Schubert _G_fail_exp=${2-':'} 1364*b50261e2SCy Schubert 1365*b50261e2SCy Schubert $opt_quiet || { 1366*b50261e2SCy Schubert func_quote_arg expand,pretty "$_G_cmd" 1367*b50261e2SCy Schubert eval "func_echo $func_quote_arg_result" 1368*b50261e2SCy Schubert } 1369*b50261e2SCy Schubert 1370*b50261e2SCy Schubert $opt_dry_run || { 1371*b50261e2SCy Schubert eval "$_G_user_locale 1372*b50261e2SCy Schubert $_G_cmd" 1373*b50261e2SCy Schubert _G_status=$? 1374*b50261e2SCy Schubert eval "$_G_safe_locale" 1375*b50261e2SCy Schubert if test 0 -ne "$_G_status"; then 1376*b50261e2SCy Schubert eval "(exit $_G_status); $_G_fail_exp" 1377*b50261e2SCy Schubert fi 1378*b50261e2SCy Schubert } 1379*b50261e2SCy Schubert} 1380*b50261e2SCy Schubert 1381*b50261e2SCy Schubert 1382*b50261e2SCy Schubert# func_tr_sh 1383*b50261e2SCy Schubert# ---------- 1384*b50261e2SCy Schubert# Turn $1 into a string suitable for a shell variable name. 1385*b50261e2SCy Schubert# Result is stored in $func_tr_sh_result. All characters 1386*b50261e2SCy Schubert# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1387*b50261e2SCy Schubert# if $1 begins with a digit, a '_' is prepended as well. 1388*b50261e2SCy Schubertfunc_tr_sh () 1389*b50261e2SCy Schubert{ 1390*b50261e2SCy Schubert $debug_cmd 1391*b50261e2SCy Schubert 1392*b50261e2SCy Schubert case $1 in 1393*b50261e2SCy Schubert [0-9]* | *[!a-zA-Z0-9_]*) 1394*b50261e2SCy Schubert func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1395*b50261e2SCy Schubert ;; 1396*b50261e2SCy Schubert * ) 1397*b50261e2SCy Schubert func_tr_sh_result=$1 1398*b50261e2SCy Schubert ;; 1399*b50261e2SCy Schubert esac 1400*b50261e2SCy Schubert} 1401*b50261e2SCy Schubert 1402*b50261e2SCy Schubert 1403*b50261e2SCy Schubert# func_verbose ARG... 1404*b50261e2SCy Schubert# ------------------- 1405*b50261e2SCy Schubert# Echo program name prefixed message in verbose mode only. 1406*b50261e2SCy Schubertfunc_verbose () 1407*b50261e2SCy Schubert{ 1408*b50261e2SCy Schubert $debug_cmd 1409*b50261e2SCy Schubert 1410*b50261e2SCy Schubert $opt_verbose && func_echo "$*" 1411*b50261e2SCy Schubert 1412*b50261e2SCy Schubert : 1413*b50261e2SCy Schubert} 1414*b50261e2SCy Schubert 1415*b50261e2SCy Schubert 1416*b50261e2SCy Schubert# func_warn_and_continue ARG... 1417*b50261e2SCy Schubert# ----------------------------- 1418*b50261e2SCy Schubert# Echo program name prefixed warning message to standard error. 1419*b50261e2SCy Schubertfunc_warn_and_continue () 1420*b50261e2SCy Schubert{ 1421*b50261e2SCy Schubert $debug_cmd 1422*b50261e2SCy Schubert 1423*b50261e2SCy Schubert $require_term_colors 1424*b50261e2SCy Schubert 1425*b50261e2SCy Schubert func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1426*b50261e2SCy Schubert} 1427*b50261e2SCy Schubert 1428*b50261e2SCy Schubert 1429*b50261e2SCy Schubert# func_warning CATEGORY ARG... 1430*b50261e2SCy Schubert# ---------------------------- 1431*b50261e2SCy Schubert# Echo program name prefixed warning message to standard error. Warning 1432*b50261e2SCy Schubert# messages can be filtered according to CATEGORY, where this function 1433*b50261e2SCy Schubert# elides messages where CATEGORY is not listed in the global variable 1434*b50261e2SCy Schubert# 'opt_warning_types'. 1435*b50261e2SCy Schubertfunc_warning () 1436*b50261e2SCy Schubert{ 1437*b50261e2SCy Schubert $debug_cmd 1438*b50261e2SCy Schubert 1439*b50261e2SCy Schubert # CATEGORY must be in the warning_categories list! 1440*b50261e2SCy Schubert case " $warning_categories " in 1441*b50261e2SCy Schubert *" $1 "*) ;; 1442*b50261e2SCy Schubert *) func_internal_error "invalid warning category '$1'" ;; 1443*b50261e2SCy Schubert esac 1444*b50261e2SCy Schubert 1445*b50261e2SCy Schubert _G_category=$1 1446*b50261e2SCy Schubert shift 1447*b50261e2SCy Schubert 1448*b50261e2SCy Schubert case " $opt_warning_types " in 1449*b50261e2SCy Schubert *" $_G_category "*) $warning_func ${1+"$@"} ;; 1450*b50261e2SCy Schubert esac 1451*b50261e2SCy Schubert} 1452*b50261e2SCy Schubert 1453*b50261e2SCy Schubert 1454*b50261e2SCy Schubert# func_sort_ver VER1 VER2 1455*b50261e2SCy Schubert# ----------------------- 1456*b50261e2SCy Schubert# 'sort -V' is not generally available. 1457*b50261e2SCy Schubert# Note this deviates from the version comparison in automake 1458*b50261e2SCy Schubert# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1459*b50261e2SCy Schubert# but this should suffice as we won't be specifying old 1460*b50261e2SCy Schubert# version formats or redundant trailing .0 in bootstrap.conf. 1461*b50261e2SCy Schubert# If we did want full compatibility then we should probably 1462*b50261e2SCy Schubert# use m4_version_compare from autoconf. 1463*b50261e2SCy Schubertfunc_sort_ver () 1464*b50261e2SCy Schubert{ 1465*b50261e2SCy Schubert $debug_cmd 1466*b50261e2SCy Schubert 1467*b50261e2SCy Schubert printf '%s\n%s\n' "$1" "$2" \ 1468*b50261e2SCy Schubert | 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 1469*b50261e2SCy Schubert} 1470*b50261e2SCy Schubert 1471*b50261e2SCy Schubert# func_lt_ver PREV CURR 1472*b50261e2SCy Schubert# --------------------- 1473*b50261e2SCy Schubert# Return true if PREV and CURR are in the correct order according to 1474*b50261e2SCy Schubert# func_sort_ver, otherwise false. Use it like this: 1475*b50261e2SCy Schubert# 1476*b50261e2SCy Schubert# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1477*b50261e2SCy Schubertfunc_lt_ver () 1478*b50261e2SCy Schubert{ 1479*b50261e2SCy Schubert $debug_cmd 1480*b50261e2SCy Schubert 1481*b50261e2SCy Schubert test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1482*b50261e2SCy Schubert} 1483*b50261e2SCy Schubert 1484*b50261e2SCy Schubert 1485*b50261e2SCy Schubert# Local variables: 1486*b50261e2SCy Schubert# mode: shell-script 1487*b50261e2SCy Schubert# sh-indentation: 2 1488*b50261e2SCy Schubert# eval: (add-hook 'before-save-hook 'time-stamp) 1489*b50261e2SCy Schubert# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1490*b50261e2SCy Schubert# time-stamp-time-zone: "UTC" 1491*b50261e2SCy Schubert# End: 1492*b50261e2SCy Schubert#! /bin/sh 1493*b50261e2SCy Schubert 1494*b50261e2SCy Schubert# A portable, pluggable option parser for Bourne shell. 1495*b50261e2SCy Schubert# Written by Gary V. Vaughan, 2010 1496*b50261e2SCy Schubert 1497*b50261e2SCy Schubert# This is free software. There is NO warranty; not even for 1498*b50261e2SCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1499*b50261e2SCy Schubert# 1500*b50261e2SCy Schubert# Copyright (C) 2010-2018 Bootstrap Authors 1501*b50261e2SCy Schubert# 1502*b50261e2SCy Schubert# This file is dual licensed under the terms of the MIT license 1503*b50261e2SCy Schubert# <https://opensource.org/license/MIT>, and GPL version 3 or later 1504*b50261e2SCy Schubert# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1505*b50261e2SCy Schubert# these licenses when using or redistributing this software or any of 1506*b50261e2SCy Schubert# the files within it. See the URLs above, or the file `LICENSE` 1507*b50261e2SCy Schubert# included in the Bootstrap distribution for the full license texts. 1508*b50261e2SCy Schubert 1509*b50261e2SCy Schubert# Please report bugs or propose patches to: 1510*b50261e2SCy Schubert# <https://github.com/gnulib-modules/bootstrap/issues> 1511*b50261e2SCy Schubert 1512*b50261e2SCy Schubert# Set a version string for this script. 1513*b50261e2SCy Schubertscriptversion=2018-07-24.06; # UTC 1514*b50261e2SCy Schubert 1515*b50261e2SCy Schubert 1516*b50261e2SCy Schubert## ------ ## 1517*b50261e2SCy Schubert## Usage. ## 1518*b50261e2SCy Schubert## ------ ## 1519*b50261e2SCy Schubert 1520*b50261e2SCy Schubert# This file is a library for parsing options in your shell scripts along 1521*b50261e2SCy Schubert# with assorted other useful supporting features that you can make use 1522*b50261e2SCy Schubert# of too. 1523*b50261e2SCy Schubert# 1524*b50261e2SCy Schubert# For the simplest scripts you might need only: 1525*b50261e2SCy Schubert# 1526*b50261e2SCy Schubert# #!/bin/sh 1527*b50261e2SCy Schubert# . relative/path/to/funclib.sh 1528*b50261e2SCy Schubert# . relative/path/to/options-parser 1529*b50261e2SCy Schubert# scriptversion=1.0 1530*b50261e2SCy Schubert# func_options ${1+"$@"} 1531*b50261e2SCy Schubert# eval set dummy "$func_options_result"; shift 1532*b50261e2SCy Schubert# ...rest of your script... 1533*b50261e2SCy Schubert# 1534*b50261e2SCy Schubert# In order for the '--version' option to work, you will need to have a 1535*b50261e2SCy Schubert# suitably formatted comment like the one at the top of this file 1536*b50261e2SCy Schubert# starting with '# Written by ' and ending with '# Copyright'. 1537*b50261e2SCy Schubert# 1538*b50261e2SCy Schubert# For '-h' and '--help' to work, you will also need a one line 1539*b50261e2SCy Schubert# description of your script's purpose in a comment directly above the 1540*b50261e2SCy Schubert# '# Written by ' line, like the one at the top of this file. 1541*b50261e2SCy Schubert# 1542*b50261e2SCy Schubert# The default options also support '--debug', which will turn on shell 1543*b50261e2SCy Schubert# execution tracing (see the comment above debug_cmd below for another 1544*b50261e2SCy Schubert# use), and '--verbose' and the func_verbose function to allow your script 1545*b50261e2SCy Schubert# to display verbose messages only when your user has specified 1546*b50261e2SCy Schubert# '--verbose'. 1547*b50261e2SCy Schubert# 1548*b50261e2SCy Schubert# After sourcing this file, you can plug in processing for additional 1549*b50261e2SCy Schubert# options by amending the variables from the 'Configuration' section 1550*b50261e2SCy Schubert# below, and following the instructions in the 'Option parsing' 1551*b50261e2SCy Schubert# section further down. 1552*b50261e2SCy Schubert 1553*b50261e2SCy Schubert## -------------- ## 1554*b50261e2SCy Schubert## Configuration. ## 1555*b50261e2SCy Schubert## -------------- ## 1556*b50261e2SCy Schubert 1557*b50261e2SCy Schubert# You should override these variables in your script after sourcing this 1558*b50261e2SCy Schubert# file so that they reflect the customisations you have added to the 1559*b50261e2SCy Schubert# option parser. 1560*b50261e2SCy Schubert 1561*b50261e2SCy Schubert# The usage line for option parsing errors and the start of '-h' and 1562*b50261e2SCy Schubert# '--help' output messages. You can embed shell variables for delayed 1563*b50261e2SCy Schubert# expansion at the time the message is displayed, but you will need to 1564*b50261e2SCy Schubert# quote other shell meta-characters carefully to prevent them being 1565*b50261e2SCy Schubert# expanded when the contents are evaled. 1566*b50261e2SCy Schubertusage='$progpath [OPTION]...' 1567*b50261e2SCy Schubert 1568*b50261e2SCy Schubert# Short help message in response to '-h' and '--help'. Add to this or 1569*b50261e2SCy Schubert# override it after sourcing this library to reflect the full set of 1570*b50261e2SCy Schubert# options your script accepts. 1571*b50261e2SCy Schubertusage_message="\ 1572*b50261e2SCy Schubert --debug enable verbose shell tracing 1573*b50261e2SCy Schubert -W, --warnings=CATEGORY 1574*b50261e2SCy Schubert report the warnings falling in CATEGORY [all] 1575*b50261e2SCy Schubert -v, --verbose verbosely report processing 1576*b50261e2SCy Schubert --version print version information and exit 1577*b50261e2SCy Schubert -h, --help print short or long help message and exit 1578*b50261e2SCy Schubert" 1579*b50261e2SCy Schubert 1580*b50261e2SCy Schubert# Additional text appended to 'usage_message' in response to '--help'. 1581*b50261e2SCy Schubertlong_help_message=" 1582*b50261e2SCy SchubertWarning categories include: 1583*b50261e2SCy Schubert 'all' show all warnings 1584*b50261e2SCy Schubert 'none' turn off all the warnings 1585*b50261e2SCy Schubert 'error' warnings are treated as fatal errors" 1586*b50261e2SCy Schubert 1587*b50261e2SCy Schubert# Help message printed before fatal option parsing errors. 1588*b50261e2SCy Schubertfatal_help="Try '\$progname --help' for more information." 1589*b50261e2SCy Schubert 1590*b50261e2SCy Schubert 1591*b50261e2SCy Schubert 1592*b50261e2SCy Schubert## ------------------------- ## 1593*b50261e2SCy Schubert## Hook function management. ## 1594*b50261e2SCy Schubert## ------------------------- ## 1595*b50261e2SCy Schubert 1596*b50261e2SCy Schubert# This section contains functions for adding, removing, and running hooks 1597*b50261e2SCy Schubert# in the main code. A hook is just a list of function names that can be 1598*b50261e2SCy Schubert# run in order later on. 1599*b50261e2SCy Schubert 1600*b50261e2SCy Schubert# func_hookable FUNC_NAME 1601*b50261e2SCy Schubert# ----------------------- 1602*b50261e2SCy Schubert# Declare that FUNC_NAME will run hooks added with 1603*b50261e2SCy Schubert# 'func_add_hook FUNC_NAME ...'. 1604*b50261e2SCy Schubertfunc_hookable () 1605*b50261e2SCy Schubert{ 1606*b50261e2SCy Schubert $debug_cmd 1607*b50261e2SCy Schubert 1608*b50261e2SCy Schubert func_append hookable_fns " $1" 1609*b50261e2SCy Schubert} 1610*b50261e2SCy Schubert 1611*b50261e2SCy Schubert 1612*b50261e2SCy Schubert# func_add_hook FUNC_NAME HOOK_FUNC 1613*b50261e2SCy Schubert# --------------------------------- 1614*b50261e2SCy Schubert# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1615*b50261e2SCy Schubert# first have been declared "hookable" by a call to 'func_hookable'. 1616*b50261e2SCy Schubertfunc_add_hook () 1617*b50261e2SCy Schubert{ 1618*b50261e2SCy Schubert $debug_cmd 1619*b50261e2SCy Schubert 1620*b50261e2SCy Schubert case " $hookable_fns " in 1621*b50261e2SCy Schubert *" $1 "*) ;; 1622*b50261e2SCy Schubert *) func_fatal_error "'$1' does not accept hook functions." ;; 1623*b50261e2SCy Schubert esac 1624*b50261e2SCy Schubert 1625*b50261e2SCy Schubert eval func_append ${1}_hooks '" $2"' 1626*b50261e2SCy Schubert} 1627*b50261e2SCy Schubert 1628*b50261e2SCy Schubert 1629*b50261e2SCy Schubert# func_remove_hook FUNC_NAME HOOK_FUNC 1630*b50261e2SCy Schubert# ------------------------------------ 1631*b50261e2SCy Schubert# Remove HOOK_FUNC from the list of hook functions to be called by 1632*b50261e2SCy Schubert# FUNC_NAME. 1633*b50261e2SCy Schubertfunc_remove_hook () 1634*b50261e2SCy Schubert{ 1635*b50261e2SCy Schubert $debug_cmd 1636*b50261e2SCy Schubert 1637*b50261e2SCy Schubert eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1638*b50261e2SCy Schubert} 1639*b50261e2SCy Schubert 1640*b50261e2SCy Schubert 1641*b50261e2SCy Schubert# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1642*b50261e2SCy Schubert# --------------------------------------------- 1643*b50261e2SCy Schubert# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1644*b50261e2SCy Schubert# *_result variable of FUNC_NAME_B. 1645*b50261e2SCy Schubertfunc_propagate_result () 1646*b50261e2SCy Schubert{ 1647*b50261e2SCy Schubert $debug_cmd 1648*b50261e2SCy Schubert 1649*b50261e2SCy Schubert func_propagate_result_result=: 1650*b50261e2SCy Schubert if eval "test \"\${${1}_result+set}\" = set" 1651*b50261e2SCy Schubert then 1652*b50261e2SCy Schubert eval "${2}_result=\$${1}_result" 1653*b50261e2SCy Schubert else 1654*b50261e2SCy Schubert func_propagate_result_result=false 1655*b50261e2SCy Schubert fi 1656*b50261e2SCy Schubert} 1657*b50261e2SCy Schubert 1658*b50261e2SCy Schubert 1659*b50261e2SCy Schubert# func_run_hooks FUNC_NAME [ARG]... 1660*b50261e2SCy Schubert# --------------------------------- 1661*b50261e2SCy Schubert# Run all hook functions registered to FUNC_NAME. 1662*b50261e2SCy Schubert# It's assumed that the list of hook functions contains nothing more 1663*b50261e2SCy Schubert# than a whitespace-delimited list of legal shell function names, and 1664*b50261e2SCy Schubert# no effort is wasted trying to catch shell meta-characters or preserve 1665*b50261e2SCy Schubert# whitespace. 1666*b50261e2SCy Schubertfunc_run_hooks () 1667*b50261e2SCy Schubert{ 1668*b50261e2SCy Schubert $debug_cmd 1669*b50261e2SCy Schubert 1670*b50261e2SCy Schubert case " $hookable_fns " in 1671*b50261e2SCy Schubert *" $1 "*) ;; 1672*b50261e2SCy Schubert *) func_fatal_error "'$1' does not support hook functions." ;; 1673*b50261e2SCy Schubert esac 1674*b50261e2SCy Schubert 1675*b50261e2SCy Schubert eval _G_hook_fns=\$$1_hooks; shift 1676*b50261e2SCy Schubert 1677*b50261e2SCy Schubert for _G_hook in $_G_hook_fns; do 1678*b50261e2SCy Schubert func_unset "${_G_hook}_result" 1679*b50261e2SCy Schubert eval $_G_hook '${1+"$@"}' 1680*b50261e2SCy Schubert func_propagate_result $_G_hook func_run_hooks 1681*b50261e2SCy Schubert if $func_propagate_result_result; then 1682*b50261e2SCy Schubert eval set dummy "$func_run_hooks_result"; shift 1683*b50261e2SCy Schubert fi 1684*b50261e2SCy Schubert done 1685*b50261e2SCy Schubert} 1686*b50261e2SCy Schubert 1687*b50261e2SCy Schubert 1688*b50261e2SCy Schubert 1689*b50261e2SCy Schubert## --------------- ## 1690*b50261e2SCy Schubert## Option parsing. ## 1691*b50261e2SCy Schubert## --------------- ## 1692*b50261e2SCy Schubert 1693*b50261e2SCy Schubert# In order to add your own option parsing hooks, you must accept the 1694*b50261e2SCy Schubert# full positional parameter list from your hook function. You may remove 1695*b50261e2SCy Schubert# or edit any options that you action, and then pass back the remaining 1696*b50261e2SCy Schubert# unprocessed options in '<hooked_function_name>_result', escaped 1697*b50261e2SCy Schubert# suitably for 'eval'. 1698*b50261e2SCy Schubert# 1699*b50261e2SCy Schubert# The '<hooked_function_name>_result' variable is automatically unset 1700*b50261e2SCy Schubert# before your hook gets called; for best performance, only set the 1701*b50261e2SCy Schubert# *_result variable when necessary (i.e. don't call the 'func_quote' 1702*b50261e2SCy Schubert# function unnecessarily because it can be an expensive operation on some 1703*b50261e2SCy Schubert# machines). 1704*b50261e2SCy Schubert# 1705*b50261e2SCy Schubert# Like this: 1706*b50261e2SCy Schubert# 1707*b50261e2SCy Schubert# my_options_prep () 1708*b50261e2SCy Schubert# { 1709*b50261e2SCy Schubert# $debug_cmd 1710*b50261e2SCy Schubert# 1711*b50261e2SCy Schubert# # Extend the existing usage message. 1712*b50261e2SCy Schubert# usage_message=$usage_message' 1713*b50261e2SCy Schubert# -s, --silent don'\''t print informational messages 1714*b50261e2SCy Schubert# ' 1715*b50261e2SCy Schubert# # No change in '$@' (ignored completely by this hook). Leave 1716*b50261e2SCy Schubert# # my_options_prep_result variable intact. 1717*b50261e2SCy Schubert# } 1718*b50261e2SCy Schubert# func_add_hook func_options_prep my_options_prep 1719*b50261e2SCy Schubert# 1720*b50261e2SCy Schubert# 1721*b50261e2SCy Schubert# my_silent_option () 1722*b50261e2SCy Schubert# { 1723*b50261e2SCy Schubert# $debug_cmd 1724*b50261e2SCy Schubert# 1725*b50261e2SCy Schubert# args_changed=false 1726*b50261e2SCy Schubert# 1727*b50261e2SCy Schubert# # Note that, for efficiency, we parse as many options as we can 1728*b50261e2SCy Schubert# # recognise in a loop before passing the remainder back to the 1729*b50261e2SCy Schubert# # caller on the first unrecognised argument we encounter. 1730*b50261e2SCy Schubert# while test $# -gt 0; do 1731*b50261e2SCy Schubert# opt=$1; shift 1732*b50261e2SCy Schubert# case $opt in 1733*b50261e2SCy Schubert# --silent|-s) opt_silent=: 1734*b50261e2SCy Schubert# args_changed=: 1735*b50261e2SCy Schubert# ;; 1736*b50261e2SCy Schubert# # Separate non-argument short options: 1737*b50261e2SCy Schubert# -s*) func_split_short_opt "$_G_opt" 1738*b50261e2SCy Schubert# set dummy "$func_split_short_opt_name" \ 1739*b50261e2SCy Schubert# "-$func_split_short_opt_arg" ${1+"$@"} 1740*b50261e2SCy Schubert# shift 1741*b50261e2SCy Schubert# args_changed=: 1742*b50261e2SCy Schubert# ;; 1743*b50261e2SCy Schubert# *) # Make sure the first unrecognised option "$_G_opt" 1744*b50261e2SCy Schubert# # is added back to "$@" in case we need it later, 1745*b50261e2SCy Schubert# # if $args_changed was set to 'true'. 1746*b50261e2SCy Schubert# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1747*b50261e2SCy Schubert# esac 1748*b50261e2SCy Schubert# done 1749*b50261e2SCy Schubert# 1750*b50261e2SCy Schubert# # Only call 'func_quote' here if we processed at least one argument. 1751*b50261e2SCy Schubert# if $args_changed; then 1752*b50261e2SCy Schubert# func_quote eval ${1+"$@"} 1753*b50261e2SCy Schubert# my_silent_option_result=$func_quote_result 1754*b50261e2SCy Schubert# fi 1755*b50261e2SCy Schubert# } 1756*b50261e2SCy Schubert# func_add_hook func_parse_options my_silent_option 1757*b50261e2SCy Schubert# 1758*b50261e2SCy Schubert# 1759*b50261e2SCy Schubert# my_option_validation () 1760*b50261e2SCy Schubert# { 1761*b50261e2SCy Schubert# $debug_cmd 1762*b50261e2SCy Schubert# 1763*b50261e2SCy Schubert# $opt_silent && $opt_verbose && func_fatal_help "\ 1764*b50261e2SCy Schubert# '--silent' and '--verbose' options are mutually exclusive." 1765*b50261e2SCy Schubert# } 1766*b50261e2SCy Schubert# func_add_hook func_validate_options my_option_validation 1767*b50261e2SCy Schubert# 1768*b50261e2SCy Schubert# You'll also need to manually amend $usage_message to reflect the extra 1769*b50261e2SCy Schubert# options you parse. It's preferable to append if you can, so that 1770*b50261e2SCy Schubert# multiple option parsing hooks can be added safely. 1771*b50261e2SCy Schubert 1772*b50261e2SCy Schubert 1773*b50261e2SCy Schubert# func_options_finish [ARG]... 1774*b50261e2SCy Schubert# ---------------------------- 1775*b50261e2SCy Schubert# Finishing the option parse loop (call 'func_options' hooks ATM). 1776*b50261e2SCy Schubertfunc_options_finish () 1777*b50261e2SCy Schubert{ 1778*b50261e2SCy Schubert $debug_cmd 1779*b50261e2SCy Schubert 1780*b50261e2SCy Schubert func_run_hooks func_options ${1+"$@"} 1781*b50261e2SCy Schubert func_propagate_result func_run_hooks func_options_finish 1782*b50261e2SCy Schubert} 1783*b50261e2SCy Schubert 1784*b50261e2SCy Schubert 1785*b50261e2SCy Schubert# func_options [ARG]... 1786*b50261e2SCy Schubert# --------------------- 1787*b50261e2SCy Schubert# All the functions called inside func_options are hookable. See the 1788*b50261e2SCy Schubert# individual implementations for details. 1789*b50261e2SCy Schubertfunc_hookable func_options 1790*b50261e2SCy Schubertfunc_options () 1791*b50261e2SCy Schubert{ 1792*b50261e2SCy Schubert $debug_cmd 1793*b50261e2SCy Schubert 1794*b50261e2SCy Schubert _G_options_quoted=false 1795*b50261e2SCy Schubert 1796*b50261e2SCy Schubert for my_func in options_prep parse_options validate_options options_finish 1797*b50261e2SCy Schubert do 1798*b50261e2SCy Schubert func_unset func_${my_func}_result 1799*b50261e2SCy Schubert func_unset func_run_hooks_result 1800*b50261e2SCy Schubert eval func_$my_func '${1+"$@"}' 1801*b50261e2SCy Schubert func_propagate_result func_$my_func func_options 1802*b50261e2SCy Schubert if $func_propagate_result_result; then 1803*b50261e2SCy Schubert eval set dummy "$func_options_result"; shift 1804*b50261e2SCy Schubert _G_options_quoted=: 1805*b50261e2SCy Schubert fi 1806*b50261e2SCy Schubert done 1807*b50261e2SCy Schubert 1808*b50261e2SCy Schubert $_G_options_quoted || { 1809*b50261e2SCy Schubert # As we (func_options) are top-level options-parser function and 1810*b50261e2SCy Schubert # nobody quoted "$@" for us yet, we need to do it explicitly for 1811*b50261e2SCy Schubert # caller. 1812*b50261e2SCy Schubert func_quote eval ${1+"$@"} 1813*b50261e2SCy Schubert func_options_result=$func_quote_result 1814*b50261e2SCy Schubert } 1815*b50261e2SCy Schubert} 1816*b50261e2SCy Schubert 1817*b50261e2SCy Schubert 1818*b50261e2SCy Schubert# func_options_prep [ARG]... 1819*b50261e2SCy Schubert# -------------------------- 1820*b50261e2SCy Schubert# All initialisations required before starting the option parse loop. 1821*b50261e2SCy Schubert# Note that when calling hook functions, we pass through the list of 1822*b50261e2SCy Schubert# positional parameters. If a hook function modifies that list, and 1823*b50261e2SCy Schubert# needs to propagate that back to rest of this script, then the complete 1824*b50261e2SCy Schubert# modified list must be put in 'func_run_hooks_result' before returning. 1825*b50261e2SCy Schubertfunc_hookable func_options_prep 1826*b50261e2SCy Schubertfunc_options_prep () 1827*b50261e2SCy Schubert{ 1828*b50261e2SCy Schubert $debug_cmd 1829*b50261e2SCy Schubert 1830*b50261e2SCy Schubert # Option defaults: 1831*b50261e2SCy Schubert opt_verbose=false 1832*b50261e2SCy Schubert opt_warning_types= 1833*b50261e2SCy Schubert 1834*b50261e2SCy Schubert func_run_hooks func_options_prep ${1+"$@"} 1835*b50261e2SCy Schubert func_propagate_result func_run_hooks func_options_prep 1836*b50261e2SCy Schubert} 1837*b50261e2SCy Schubert 1838*b50261e2SCy Schubert 1839*b50261e2SCy Schubert# func_parse_options [ARG]... 1840*b50261e2SCy Schubert# --------------------------- 1841*b50261e2SCy Schubert# The main option parsing loop. 1842*b50261e2SCy Schubertfunc_hookable func_parse_options 1843*b50261e2SCy Schubertfunc_parse_options () 1844*b50261e2SCy Schubert{ 1845*b50261e2SCy Schubert $debug_cmd 1846*b50261e2SCy Schubert 1847*b50261e2SCy Schubert _G_parse_options_requote=false 1848*b50261e2SCy Schubert # this just eases exit handling 1849*b50261e2SCy Schubert while test $# -gt 0; do 1850*b50261e2SCy Schubert # Defer to hook functions for initial option parsing, so they 1851*b50261e2SCy Schubert # get priority in the event of reusing an option name. 1852*b50261e2SCy Schubert func_run_hooks func_parse_options ${1+"$@"} 1853*b50261e2SCy Schubert func_propagate_result func_run_hooks func_parse_options 1854*b50261e2SCy Schubert if $func_propagate_result_result; then 1855*b50261e2SCy Schubert eval set dummy "$func_parse_options_result"; shift 1856*b50261e2SCy Schubert # Even though we may have changed "$@", we passed the "$@" array 1857*b50261e2SCy Schubert # down into the hook and it quoted it for us (because we are in 1858*b50261e2SCy Schubert # this if-branch). No need to quote it again. 1859*b50261e2SCy Schubert _G_parse_options_requote=false 1860*b50261e2SCy Schubert fi 1861*b50261e2SCy Schubert 1862*b50261e2SCy Schubert # Break out of the loop if we already parsed every option. 1863*b50261e2SCy Schubert test $# -gt 0 || break 1864*b50261e2SCy Schubert 1865*b50261e2SCy Schubert # We expect that one of the options parsed in this function matches 1866*b50261e2SCy Schubert # and thus we remove _G_opt from "$@" and need to re-quote. 1867*b50261e2SCy Schubert _G_match_parse_options=: 1868*b50261e2SCy Schubert _G_opt=$1 1869*b50261e2SCy Schubert shift 1870*b50261e2SCy Schubert case $_G_opt in 1871*b50261e2SCy Schubert --debug|-x) debug_cmd='set -x' 1872*b50261e2SCy Schubert func_echo "enabling shell trace mode" >&2 1873*b50261e2SCy Schubert $debug_cmd 1874*b50261e2SCy Schubert ;; 1875*b50261e2SCy Schubert 1876*b50261e2SCy Schubert --no-warnings|--no-warning|--no-warn) 1877*b50261e2SCy Schubert set dummy --warnings none ${1+"$@"} 1878*b50261e2SCy Schubert shift 1879*b50261e2SCy Schubert ;; 1880*b50261e2SCy Schubert 1881*b50261e2SCy Schubert --warnings|--warning|-W) 1882*b50261e2SCy Schubert if test $# = 0 && func_missing_arg $_G_opt; then 1883*b50261e2SCy Schubert _G_parse_options_requote=: 1884*b50261e2SCy Schubert break 1885*b50261e2SCy Schubert fi 1886*b50261e2SCy Schubert case " $warning_categories $1" in 1887*b50261e2SCy Schubert *" $1 "*) 1888*b50261e2SCy Schubert # trailing space prevents matching last $1 above 1889*b50261e2SCy Schubert func_append_uniq opt_warning_types " $1" 1890*b50261e2SCy Schubert ;; 1891*b50261e2SCy Schubert *all) 1892*b50261e2SCy Schubert opt_warning_types=$warning_categories 1893*b50261e2SCy Schubert ;; 1894*b50261e2SCy Schubert *none) 1895*b50261e2SCy Schubert opt_warning_types=none 1896*b50261e2SCy Schubert warning_func=: 1897*b50261e2SCy Schubert ;; 1898*b50261e2SCy Schubert *error) 1899*b50261e2SCy Schubert opt_warning_types=$warning_categories 1900*b50261e2SCy Schubert warning_func=func_fatal_error 1901*b50261e2SCy Schubert ;; 1902*b50261e2SCy Schubert *) 1903*b50261e2SCy Schubert func_fatal_error \ 1904*b50261e2SCy Schubert "unsupported warning category: '$1'" 1905*b50261e2SCy Schubert ;; 1906*b50261e2SCy Schubert esac 1907*b50261e2SCy Schubert shift 1908*b50261e2SCy Schubert ;; 1909*b50261e2SCy Schubert 1910*b50261e2SCy Schubert --verbose|-v) opt_verbose=: ;; 1911*b50261e2SCy Schubert --version) func_version ;; 1912*b50261e2SCy Schubert -\?|-h) func_usage ;; 1913*b50261e2SCy Schubert --help) func_help ;; 1914*b50261e2SCy Schubert 1915*b50261e2SCy Schubert # Separate optargs to long options (plugins may need this): 1916*b50261e2SCy Schubert --*=*) func_split_equals "$_G_opt" 1917*b50261e2SCy Schubert set dummy "$func_split_equals_lhs" \ 1918*b50261e2SCy Schubert "$func_split_equals_rhs" ${1+"$@"} 1919*b50261e2SCy Schubert shift 1920*b50261e2SCy Schubert ;; 1921*b50261e2SCy Schubert 1922*b50261e2SCy Schubert # Separate optargs to short options: 1923*b50261e2SCy Schubert -W*) 1924*b50261e2SCy Schubert func_split_short_opt "$_G_opt" 1925*b50261e2SCy Schubert set dummy "$func_split_short_opt_name" \ 1926*b50261e2SCy Schubert "$func_split_short_opt_arg" ${1+"$@"} 1927*b50261e2SCy Schubert shift 1928*b50261e2SCy Schubert ;; 1929*b50261e2SCy Schubert 1930*b50261e2SCy Schubert # Separate non-argument short options: 1931*b50261e2SCy Schubert -\?*|-h*|-v*|-x*) 1932*b50261e2SCy Schubert func_split_short_opt "$_G_opt" 1933*b50261e2SCy Schubert set dummy "$func_split_short_opt_name" \ 1934*b50261e2SCy Schubert "-$func_split_short_opt_arg" ${1+"$@"} 1935*b50261e2SCy Schubert shift 1936*b50261e2SCy Schubert ;; 1937*b50261e2SCy Schubert 1938*b50261e2SCy Schubert --) _G_parse_options_requote=: ; break ;; 1939*b50261e2SCy Schubert -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1940*b50261e2SCy Schubert *) set dummy "$_G_opt" ${1+"$@"}; shift 1941*b50261e2SCy Schubert _G_match_parse_options=false 1942*b50261e2SCy Schubert break 1943*b50261e2SCy Schubert ;; 1944*b50261e2SCy Schubert esac 1945*b50261e2SCy Schubert 1946*b50261e2SCy Schubert if $_G_match_parse_options; then 1947*b50261e2SCy Schubert _G_parse_options_requote=: 1948*b50261e2SCy Schubert fi 1949*b50261e2SCy Schubert done 1950*b50261e2SCy Schubert 1951*b50261e2SCy Schubert if $_G_parse_options_requote; then 1952*b50261e2SCy Schubert # save modified positional parameters for caller 1953*b50261e2SCy Schubert func_quote eval ${1+"$@"} 1954*b50261e2SCy Schubert func_parse_options_result=$func_quote_result 1955*b50261e2SCy Schubert fi 1956*b50261e2SCy Schubert} 1957*b50261e2SCy Schubert 1958*b50261e2SCy Schubert 1959*b50261e2SCy Schubert# func_validate_options [ARG]... 1960*b50261e2SCy Schubert# ------------------------------ 1961*b50261e2SCy Schubert# Perform any sanity checks on option settings and/or unconsumed 1962*b50261e2SCy Schubert# arguments. 1963*b50261e2SCy Schubertfunc_hookable func_validate_options 1964*b50261e2SCy Schubertfunc_validate_options () 1965*b50261e2SCy Schubert{ 1966*b50261e2SCy Schubert $debug_cmd 1967*b50261e2SCy Schubert 1968*b50261e2SCy Schubert # Display all warnings if -W was not given. 1969*b50261e2SCy Schubert test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1970*b50261e2SCy Schubert 1971*b50261e2SCy Schubert func_run_hooks func_validate_options ${1+"$@"} 1972*b50261e2SCy Schubert func_propagate_result func_run_hooks func_validate_options 1973*b50261e2SCy Schubert 1974*b50261e2SCy Schubert # Bail if the options were screwed! 1975*b50261e2SCy Schubert $exit_cmd $EXIT_FAILURE 1976*b50261e2SCy Schubert} 1977*b50261e2SCy Schubert 1978*b50261e2SCy Schubert 1979*b50261e2SCy Schubert 1980*b50261e2SCy Schubert## ----------------- ## 1981*b50261e2SCy Schubert## Helper functions. ## 1982*b50261e2SCy Schubert## ----------------- ## 1983*b50261e2SCy Schubert 1984*b50261e2SCy Schubert# This section contains the helper functions used by the rest of the 1985*b50261e2SCy Schubert# hookable option parser framework in ascii-betical order. 1986*b50261e2SCy Schubert 1987*b50261e2SCy Schubert 1988*b50261e2SCy Schubert# func_fatal_help ARG... 1989*b50261e2SCy Schubert# ---------------------- 1990*b50261e2SCy Schubert# Echo program name prefixed message to standard error, followed by 1991*b50261e2SCy Schubert# a help hint, and exit. 1992*b50261e2SCy Schubertfunc_fatal_help () 1993*b50261e2SCy Schubert{ 1994*b50261e2SCy Schubert $debug_cmd 1995*b50261e2SCy Schubert 1996*b50261e2SCy Schubert eval \$ECHO \""Usage: $usage"\" 1997*b50261e2SCy Schubert eval \$ECHO \""$fatal_help"\" 1998*b50261e2SCy Schubert func_error ${1+"$@"} 1999*b50261e2SCy Schubert exit $EXIT_FAILURE 2000*b50261e2SCy Schubert} 2001*b50261e2SCy Schubert 2002*b50261e2SCy Schubert 2003*b50261e2SCy Schubert# func_help 2004*b50261e2SCy Schubert# --------- 2005*b50261e2SCy Schubert# Echo long help message to standard output and exit. 2006*b50261e2SCy Schubertfunc_help () 2007*b50261e2SCy Schubert{ 2008*b50261e2SCy Schubert $debug_cmd 2009*b50261e2SCy Schubert 2010*b50261e2SCy Schubert func_usage_message 2011*b50261e2SCy Schubert $ECHO "$long_help_message" 2012*b50261e2SCy Schubert exit 0 2013*b50261e2SCy Schubert} 2014*b50261e2SCy Schubert 2015*b50261e2SCy Schubert 2016*b50261e2SCy Schubert# func_missing_arg ARGNAME 2017*b50261e2SCy Schubert# ------------------------ 2018*b50261e2SCy Schubert# Echo program name prefixed message to standard error and set global 2019*b50261e2SCy Schubert# exit_cmd. 2020*b50261e2SCy Schubertfunc_missing_arg () 2021*b50261e2SCy Schubert{ 2022*b50261e2SCy Schubert $debug_cmd 2023*b50261e2SCy Schubert 2024*b50261e2SCy Schubert func_error "Missing argument for '$1'." 2025*b50261e2SCy Schubert exit_cmd=exit 2026*b50261e2SCy Schubert} 2027*b50261e2SCy Schubert 2028*b50261e2SCy Schubert 2029*b50261e2SCy Schubert# func_split_equals STRING 2030*b50261e2SCy Schubert# ------------------------ 2031*b50261e2SCy Schubert# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2032*b50261e2SCy Schubert# after splitting STRING at the '=' sign. 2033*b50261e2SCy Schuberttest -z "$_G_HAVE_XSI_OPS" \ 2034*b50261e2SCy Schubert && (eval 'x=a/b/c; 2035*b50261e2SCy Schubert test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2036*b50261e2SCy Schubert && _G_HAVE_XSI_OPS=yes 2037*b50261e2SCy Schubert 2038*b50261e2SCy Schubertif test yes = "$_G_HAVE_XSI_OPS" 2039*b50261e2SCy Schubertthen 2040*b50261e2SCy Schubert # This is an XSI compatible shell, allowing a faster implementation... 2041*b50261e2SCy Schubert eval 'func_split_equals () 2042*b50261e2SCy Schubert { 2043*b50261e2SCy Schubert $debug_cmd 2044*b50261e2SCy Schubert 2045*b50261e2SCy Schubert func_split_equals_lhs=${1%%=*} 2046*b50261e2SCy Schubert func_split_equals_rhs=${1#*=} 2047*b50261e2SCy Schubert if test "x$func_split_equals_lhs" = "x$1"; then 2048*b50261e2SCy Schubert func_split_equals_rhs= 2049*b50261e2SCy Schubert fi 2050*b50261e2SCy Schubert }' 2051*b50261e2SCy Schubertelse 2052*b50261e2SCy Schubert # ...otherwise fall back to using expr, which is often a shell builtin. 2053*b50261e2SCy Schubert func_split_equals () 2054*b50261e2SCy Schubert { 2055*b50261e2SCy Schubert $debug_cmd 2056*b50261e2SCy Schubert 2057*b50261e2SCy Schubert func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2058*b50261e2SCy Schubert func_split_equals_rhs= 2059*b50261e2SCy Schubert test "x$func_split_equals_lhs" = "x$1" \ 2060*b50261e2SCy Schubert || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2061*b50261e2SCy Schubert } 2062*b50261e2SCy Schubertfi #func_split_equals 2063*b50261e2SCy Schubert 2064*b50261e2SCy Schubert 2065*b50261e2SCy Schubert# func_split_short_opt SHORTOPT 2066*b50261e2SCy Schubert# ----------------------------- 2067*b50261e2SCy Schubert# Set func_split_short_opt_name and func_split_short_opt_arg shell 2068*b50261e2SCy Schubert# variables after splitting SHORTOPT after the 2nd character. 2069*b50261e2SCy Schubertif test yes = "$_G_HAVE_XSI_OPS" 2070*b50261e2SCy Schubertthen 2071*b50261e2SCy Schubert # This is an XSI compatible shell, allowing a faster implementation... 2072*b50261e2SCy Schubert eval 'func_split_short_opt () 2073*b50261e2SCy Schubert { 2074*b50261e2SCy Schubert $debug_cmd 2075*b50261e2SCy Schubert 2076*b50261e2SCy Schubert func_split_short_opt_arg=${1#??} 2077*b50261e2SCy Schubert func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2078*b50261e2SCy Schubert }' 2079*b50261e2SCy Schubertelse 2080*b50261e2SCy Schubert # ...otherwise fall back to using expr, which is often a shell builtin. 2081*b50261e2SCy Schubert func_split_short_opt () 2082*b50261e2SCy Schubert { 2083*b50261e2SCy Schubert $debug_cmd 2084*b50261e2SCy Schubert 2085*b50261e2SCy Schubert func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 2086*b50261e2SCy Schubert func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2087*b50261e2SCy Schubert } 2088*b50261e2SCy Schubertfi #func_split_short_opt 2089*b50261e2SCy Schubert 2090*b50261e2SCy Schubert 2091*b50261e2SCy Schubert# func_usage 2092*b50261e2SCy Schubert# ---------- 2093*b50261e2SCy Schubert# Echo short help message to standard output and exit. 2094*b50261e2SCy Schubertfunc_usage () 2095*b50261e2SCy Schubert{ 2096*b50261e2SCy Schubert $debug_cmd 2097*b50261e2SCy Schubert 2098*b50261e2SCy Schubert func_usage_message 2099*b50261e2SCy Schubert $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2100*b50261e2SCy Schubert exit 0 2101*b50261e2SCy Schubert} 2102*b50261e2SCy Schubert 2103*b50261e2SCy Schubert 2104*b50261e2SCy Schubert# func_usage_message 2105*b50261e2SCy Schubert# ------------------ 2106*b50261e2SCy Schubert# Echo short help message to standard output. 2107*b50261e2SCy Schubertfunc_usage_message () 2108*b50261e2SCy Schubert{ 2109*b50261e2SCy Schubert $debug_cmd 2110*b50261e2SCy Schubert 2111*b50261e2SCy Schubert eval \$ECHO \""Usage: $usage"\" 2112*b50261e2SCy Schubert echo 2113*b50261e2SCy Schubert $SED -n 's|^# || 2114*b50261e2SCy Schubert /^Written by/{ 2115*b50261e2SCy Schubert x;p;x 2116*b50261e2SCy Schubert } 2117*b50261e2SCy Schubert h 2118*b50261e2SCy Schubert /^Written by/q' < "$progpath" 2119*b50261e2SCy Schubert echo 2120*b50261e2SCy Schubert eval \$ECHO \""$usage_message"\" 2121*b50261e2SCy Schubert} 2122*b50261e2SCy Schubert 2123*b50261e2SCy Schubert 2124*b50261e2SCy Schubert# func_version 2125*b50261e2SCy Schubert# ------------ 2126*b50261e2SCy Schubert# Echo version message to standard output and exit. 2127*b50261e2SCy Schubert# The version message is extracted from the calling file's header 2128*b50261e2SCy Schubert# comments, with leading '# ' stripped: 2129*b50261e2SCy Schubert# 1. First display the progname and version 2130*b50261e2SCy Schubert# 2. Followed by the header comment line matching /^# Written by / 2131*b50261e2SCy Schubert# 3. Then a blank line followed by the first following line matching 2132*b50261e2SCy Schubert# /^# Copyright / 2133*b50261e2SCy Schubert# 4. Immediately followed by any lines between the previous matches, 2134*b50261e2SCy Schubert# except lines preceding the intervening completely blank line. 2135*b50261e2SCy Schubert# For example, see the header comments of this file. 2136*b50261e2SCy Schubertfunc_version () 2137*b50261e2SCy Schubert{ 2138*b50261e2SCy Schubert $debug_cmd 2139*b50261e2SCy Schubert 2140*b50261e2SCy Schubert printf '%s\n' "$progname $scriptversion" 2141*b50261e2SCy Schubert $SED -n ' 2142*b50261e2SCy Schubert /^# Written by /!b 2143*b50261e2SCy Schubert s|^# ||; p; n 2144*b50261e2SCy Schubert 2145*b50261e2SCy Schubert :fwd2blnk 2146*b50261e2SCy Schubert /./ { 2147*b50261e2SCy Schubert n 2148*b50261e2SCy Schubert b fwd2blnk 2149*b50261e2SCy Schubert } 2150*b50261e2SCy Schubert p; n 2151*b50261e2SCy Schubert 2152*b50261e2SCy Schubert :holdwrnt 2153*b50261e2SCy Schubert s|^# || 2154*b50261e2SCy Schubert s|^# *$|| 2155*b50261e2SCy Schubert /^Copyright /!{ 2156*b50261e2SCy Schubert /./H 2157*b50261e2SCy Schubert n 2158*b50261e2SCy Schubert b holdwrnt 2159*b50261e2SCy Schubert } 2160*b50261e2SCy Schubert 2161*b50261e2SCy Schubert s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2162*b50261e2SCy Schubert G 2163*b50261e2SCy Schubert s|\(\n\)\n*|\1|g 2164*b50261e2SCy Schubert p; q' < "$progpath" 2165*b50261e2SCy Schubert 2166*b50261e2SCy Schubert exit $? 2167*b50261e2SCy Schubert} 2168*b50261e2SCy Schubert 2169*b50261e2SCy Schubert 2170*b50261e2SCy Schubert# Local variables: 2171*b50261e2SCy Schubert# mode: shell-script 2172*b50261e2SCy Schubert# sh-indentation: 2 2173*b50261e2SCy Schubert# eval: (add-hook 'before-save-hook 'time-stamp) 2174*b50261e2SCy Schubert# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2175*b50261e2SCy Schubert# time-stamp-time-zone: "UTC" 2176*b50261e2SCy Schubert# End: 2177*b50261e2SCy Schubert 2178*b50261e2SCy Schubert# Set a version string. 2179*b50261e2SCy Schubertscriptversion='(GNU libtool) 2.4.6.42-b88ce-dirty' 2180*b50261e2SCy Schubert 2181*b50261e2SCy Schubert 2182*b50261e2SCy Schubert# func_echo ARG... 2183*b50261e2SCy Schubert# ---------------- 2184*b50261e2SCy Schubert# Libtool also displays the current mode in messages, so override 2185*b50261e2SCy Schubert# funclib.sh func_echo with this custom definition. 2186*b50261e2SCy Schubertfunc_echo () 2187*b50261e2SCy Schubert{ 2188*b50261e2SCy Schubert $debug_cmd 2189*b50261e2SCy Schubert 2190*b50261e2SCy Schubert _G_message=$* 2191*b50261e2SCy Schubert 2192*b50261e2SCy Schubert func_echo_IFS=$IFS 2193*b50261e2SCy Schubert IFS=$nl 2194*b50261e2SCy Schubert for _G_line in $_G_message; do 2195*b50261e2SCy Schubert IFS=$func_echo_IFS 2196*b50261e2SCy Schubert $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2197*b50261e2SCy Schubert done 2198*b50261e2SCy Schubert IFS=$func_echo_IFS 2199*b50261e2SCy Schubert} 2200*b50261e2SCy Schubert 2201*b50261e2SCy Schubert 2202*b50261e2SCy Schubert# func_warning ARG... 2203*b50261e2SCy Schubert# ------------------- 2204*b50261e2SCy Schubert# Libtool warnings are not categorized, so override funclib.sh 2205*b50261e2SCy Schubert# func_warning with this simpler definition. 2206*b50261e2SCy Schubertfunc_warning () 2207*b50261e2SCy Schubert{ 2208*b50261e2SCy Schubert $debug_cmd 2209*b50261e2SCy Schubert 2210*b50261e2SCy Schubert $warning_func ${1+"$@"} 2211*b50261e2SCy Schubert} 2212*b50261e2SCy Schubert 2213*b50261e2SCy Schubert 2214*b50261e2SCy Schubert## ---------------- ## 2215*b50261e2SCy Schubert## Options parsing. ## 2216*b50261e2SCy Schubert## ---------------- ## 2217*b50261e2SCy Schubert 2218*b50261e2SCy Schubert# Hook in the functions to make sure our own options are parsed during 2219*b50261e2SCy Schubert# the option parsing loop. 2220*b50261e2SCy Schubert 2221*b50261e2SCy Schubertusage='$progpath [OPTION]... [MODE-ARG]...' 2222*b50261e2SCy Schubert 2223*b50261e2SCy Schubert# Short help message in response to '-h'. 2224*b50261e2SCy Schubertusage_message="Options: 2225*b50261e2SCy Schubert --config show all configuration variables 2226*b50261e2SCy Schubert --debug enable verbose shell tracing 2227*b50261e2SCy Schubert -n, --dry-run display commands without modifying any files 2228*b50261e2SCy Schubert --features display basic configuration information and exit 2229*b50261e2SCy Schubert --mode=MODE use operation mode MODE 2230*b50261e2SCy Schubert --no-warnings equivalent to '-Wnone' 2231*b50261e2SCy Schubert --preserve-dup-deps don't remove duplicate dependency libraries 2232*b50261e2SCy Schubert --quiet, --silent don't print informational messages 2233*b50261e2SCy Schubert --tag=TAG use configuration variables from tag TAG 2234*b50261e2SCy Schubert -v, --verbose print more informational messages than default 2235*b50261e2SCy Schubert --version print version information 2236*b50261e2SCy Schubert -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2237*b50261e2SCy Schubert -h, --help, --help-all print short, long, or detailed help message 2238*b50261e2SCy Schubert" 2239*b50261e2SCy Schubert 2240*b50261e2SCy Schubert# Additional text appended to 'usage_message' in response to '--help'. 2241*b50261e2SCy Schubertfunc_help () 2242*b50261e2SCy Schubert{ 2243*b50261e2SCy Schubert $debug_cmd 2244*b50261e2SCy Schubert 2245*b50261e2SCy Schubert func_usage_message 2246*b50261e2SCy Schubert $ECHO "$long_help_message 2247*b50261e2SCy Schubert 2248*b50261e2SCy SchubertMODE must be one of the following: 2249*b50261e2SCy Schubert 2250*b50261e2SCy Schubert clean remove files from the build directory 2251*b50261e2SCy Schubert compile compile a source file into a libtool object 2252*b50261e2SCy Schubert execute automatically set library path, then run a program 2253*b50261e2SCy Schubert finish complete the installation of libtool libraries 2254*b50261e2SCy Schubert install install libraries or executables 2255*b50261e2SCy Schubert link create a library or an executable 2256*b50261e2SCy Schubert uninstall remove libraries from an installed directory 2257*b50261e2SCy Schubert 2258*b50261e2SCy SchubertMODE-ARGS vary depending on the MODE. When passed as first option, 2259*b50261e2SCy Schubert'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2260*b50261e2SCy SchubertTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2261*b50261e2SCy Schubert 2262*b50261e2SCy SchubertWhen reporting a bug, please describe a test case to reproduce it and 2263*b50261e2SCy Schubertinclude the following information: 2264*b50261e2SCy Schubert 2265*b50261e2SCy Schubert host-triplet: $host 2266*b50261e2SCy Schubert shell: $SHELL 2267*b50261e2SCy Schubert compiler: $LTCC 2268*b50261e2SCy Schubert compiler flags: $LTCFLAGS 2269*b50261e2SCy Schubert linker: $LD (gnu? $with_gnu_ld) 2270*b50261e2SCy Schubert version: $progname (GNU libtool) 2.4.6.42-b88ce-dirty 2271*b50261e2SCy Schubert automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2272*b50261e2SCy Schubert autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2273*b50261e2SCy Schubert 2274*b50261e2SCy SchubertReport bugs to <bug-libtool@gnu.org>. 2275*b50261e2SCy SchubertGNU libtool home page: <http://www.gnu.org/s/libtool/>. 2276*b50261e2SCy SchubertGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2277*b50261e2SCy Schubert exit 0 2278*b50261e2SCy Schubert} 2279*b50261e2SCy Schubert 2280*b50261e2SCy Schubert 2281*b50261e2SCy Schubert# func_lo2o OBJECT-NAME 2282*b50261e2SCy Schubert# --------------------- 2283*b50261e2SCy Schubert# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2284*b50261e2SCy Schubert# object suffix. 2285*b50261e2SCy Schubert 2286*b50261e2SCy Schubertlo2o=s/\\.lo\$/.$objext/ 2287*b50261e2SCy Schuberto2lo=s/\\.$objext\$/.lo/ 2288*b50261e2SCy Schubert 2289*b50261e2SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 2290*b50261e2SCy Schubert eval 'func_lo2o () 2291*b50261e2SCy Schubert { 2292*b50261e2SCy Schubert case $1 in 2293*b50261e2SCy Schubert *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2294*b50261e2SCy Schubert * ) func_lo2o_result=$1 ;; 2295*b50261e2SCy Schubert esac 2296*b50261e2SCy Schubert }' 2297*b50261e2SCy Schubert 2298*b50261e2SCy Schubert # func_xform LIBOBJ-OR-SOURCE 2299*b50261e2SCy Schubert # --------------------------- 2300*b50261e2SCy Schubert # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2301*b50261e2SCy Schubert # suffix to a '.lo' libtool-object suffix. 2302*b50261e2SCy Schubert eval 'func_xform () 2303*b50261e2SCy Schubert { 2304*b50261e2SCy Schubert func_xform_result=${1%.*}.lo 2305*b50261e2SCy Schubert }' 2306*b50261e2SCy Schubertelse 2307*b50261e2SCy Schubert # ...otherwise fall back to using sed. 2308*b50261e2SCy Schubert func_lo2o () 2309*b50261e2SCy Schubert { 2310*b50261e2SCy Schubert func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2311*b50261e2SCy Schubert } 2312*b50261e2SCy Schubert 2313*b50261e2SCy Schubert func_xform () 2314*b50261e2SCy Schubert { 2315*b50261e2SCy Schubert func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2316*b50261e2SCy Schubert } 2317*b50261e2SCy Schubertfi 2318*b50261e2SCy Schubert 2319*b50261e2SCy Schubert 2320*b50261e2SCy Schubert# func_fatal_configuration ARG... 2321*b50261e2SCy Schubert# ------------------------------- 2322*b50261e2SCy Schubert# Echo program name prefixed message to standard error, followed by 2323*b50261e2SCy Schubert# a configuration failure hint, and exit. 2324*b50261e2SCy Schubertfunc_fatal_configuration () 2325*b50261e2SCy Schubert{ 2326*b50261e2SCy Schubert func_fatal_error ${1+"$@"} \ 2327*b50261e2SCy Schubert "See the $PACKAGE documentation for more information." \ 2328*b50261e2SCy Schubert "Fatal configuration error." 2329*b50261e2SCy Schubert} 2330*b50261e2SCy Schubert 2331*b50261e2SCy Schubert 2332*b50261e2SCy Schubert# func_config 2333*b50261e2SCy Schubert# ----------- 2334*b50261e2SCy Schubert# Display the configuration for all the tags in this script. 2335*b50261e2SCy Schubertfunc_config () 2336*b50261e2SCy Schubert{ 2337*b50261e2SCy Schubert re_begincf='^# ### BEGIN LIBTOOL' 2338*b50261e2SCy Schubert re_endcf='^# ### END LIBTOOL' 2339*b50261e2SCy Schubert 2340*b50261e2SCy Schubert # Default configuration. 2341*b50261e2SCy Schubert $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2342*b50261e2SCy Schubert 2343*b50261e2SCy Schubert # Now print the configurations for the tags. 2344*b50261e2SCy Schubert for tagname in $taglist; do 2345*b50261e2SCy Schubert $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2346*b50261e2SCy Schubert done 2347*b50261e2SCy Schubert 2348*b50261e2SCy Schubert exit $? 2349*b50261e2SCy Schubert} 2350*b50261e2SCy Schubert 2351*b50261e2SCy Schubert 2352*b50261e2SCy Schubert# func_features 2353*b50261e2SCy Schubert# ------------- 2354*b50261e2SCy Schubert# Display the features supported by this script. 2355*b50261e2SCy Schubertfunc_features () 2356*b50261e2SCy Schubert{ 2357*b50261e2SCy Schubert echo "host: $host" 2358*b50261e2SCy Schubert if test yes = "$build_libtool_libs"; then 2359*b50261e2SCy Schubert echo "enable shared libraries" 2360*b50261e2SCy Schubert else 2361*b50261e2SCy Schubert echo "disable shared libraries" 2362*b50261e2SCy Schubert fi 2363*b50261e2SCy Schubert if test yes = "$build_old_libs"; then 2364*b50261e2SCy Schubert echo "enable static libraries" 2365*b50261e2SCy Schubert else 2366*b50261e2SCy Schubert echo "disable static libraries" 2367*b50261e2SCy Schubert fi 2368*b50261e2SCy Schubert 2369*b50261e2SCy Schubert exit $? 2370*b50261e2SCy Schubert} 2371*b50261e2SCy Schubert 2372*b50261e2SCy Schubert 2373*b50261e2SCy Schubert# func_enable_tag TAGNAME 2374*b50261e2SCy Schubert# ----------------------- 2375*b50261e2SCy Schubert# Verify that TAGNAME is valid, and either flag an error and exit, or 2376*b50261e2SCy Schubert# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2377*b50261e2SCy Schubert# variable here. 2378*b50261e2SCy Schubertfunc_enable_tag () 2379*b50261e2SCy Schubert{ 2380*b50261e2SCy Schubert # Global variable: 2381*b50261e2SCy Schubert tagname=$1 2382*b50261e2SCy Schubert 2383*b50261e2SCy Schubert re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2384*b50261e2SCy Schubert re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2385*b50261e2SCy Schubert sed_extractcf=/$re_begincf/,/$re_endcf/p 2386*b50261e2SCy Schubert 2387*b50261e2SCy Schubert # Validate tagname. 2388*b50261e2SCy Schubert case $tagname in 2389*b50261e2SCy Schubert *[!-_A-Za-z0-9,/]*) 2390*b50261e2SCy Schubert func_fatal_error "invalid tag name: $tagname" 2391*b50261e2SCy Schubert ;; 2392*b50261e2SCy Schubert esac 2393*b50261e2SCy Schubert 2394*b50261e2SCy Schubert # Don't test for the "default" C tag, as we know it's 2395*b50261e2SCy Schubert # there but not specially marked. 2396*b50261e2SCy Schubert case $tagname in 2397*b50261e2SCy Schubert CC) ;; 2398*b50261e2SCy Schubert *) 2399*b50261e2SCy Schubert if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2400*b50261e2SCy Schubert taglist="$taglist $tagname" 2401*b50261e2SCy Schubert 2402*b50261e2SCy Schubert # Evaluate the configuration. Be careful to quote the path 2403*b50261e2SCy Schubert # and the sed script, to avoid splitting on whitespace, but 2404*b50261e2SCy Schubert # also don't use non-portable quotes within backquotes within 2405*b50261e2SCy Schubert # quotes we have to do it in 2 steps: 2406*b50261e2SCy Schubert extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2407*b50261e2SCy Schubert eval "$extractedcf" 2408*b50261e2SCy Schubert else 2409*b50261e2SCy Schubert func_error "ignoring unknown tag $tagname" 2410*b50261e2SCy Schubert fi 2411*b50261e2SCy Schubert ;; 2412*b50261e2SCy Schubert esac 2413*b50261e2SCy Schubert} 2414*b50261e2SCy Schubert 2415*b50261e2SCy Schubert 2416*b50261e2SCy Schubert# func_check_version_match 2417*b50261e2SCy Schubert# ------------------------ 2418*b50261e2SCy Schubert# Ensure that we are using m4 macros, and libtool script from the same 2419*b50261e2SCy Schubert# release of libtool. 2420*b50261e2SCy Schubertfunc_check_version_match () 2421*b50261e2SCy Schubert{ 2422*b50261e2SCy Schubert if test "$package_revision" != "$macro_revision"; then 2423*b50261e2SCy Schubert if test "$VERSION" != "$macro_version"; then 2424*b50261e2SCy Schubert if test -z "$macro_version"; then 2425*b50261e2SCy Schubert cat >&2 <<_LT_EOF 2426*b50261e2SCy Schubert$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2427*b50261e2SCy Schubert$progname: definition of this LT_INIT comes from an older release. 2428*b50261e2SCy Schubert$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2429*b50261e2SCy Schubert$progname: and run autoconf again. 2430*b50261e2SCy Schubert_LT_EOF 2431*b50261e2SCy Schubert else 2432*b50261e2SCy Schubert cat >&2 <<_LT_EOF 2433*b50261e2SCy Schubert$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2434*b50261e2SCy Schubert$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2435*b50261e2SCy Schubert$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2436*b50261e2SCy Schubert$progname: and run autoconf again. 2437*b50261e2SCy Schubert_LT_EOF 2438*b50261e2SCy Schubert fi 2439*b50261e2SCy Schubert else 2440*b50261e2SCy Schubert cat >&2 <<_LT_EOF 2441*b50261e2SCy Schubert$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2442*b50261e2SCy Schubert$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2443*b50261e2SCy Schubert$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2444*b50261e2SCy Schubert$progname: of $PACKAGE $VERSION and run autoconf again. 2445*b50261e2SCy Schubert_LT_EOF 2446*b50261e2SCy Schubert fi 2447*b50261e2SCy Schubert 2448*b50261e2SCy Schubert exit $EXIT_MISMATCH 2449*b50261e2SCy Schubert fi 2450*b50261e2SCy Schubert} 2451*b50261e2SCy Schubert 2452*b50261e2SCy Schubert 2453*b50261e2SCy Schubert# libtool_options_prep [ARG]... 2454*b50261e2SCy Schubert# ----------------------------- 2455*b50261e2SCy Schubert# Preparation for options parsed by libtool. 2456*b50261e2SCy Schubertlibtool_options_prep () 2457*b50261e2SCy Schubert{ 2458*b50261e2SCy Schubert $debug_mode 2459*b50261e2SCy Schubert 2460*b50261e2SCy Schubert # Option defaults: 2461*b50261e2SCy Schubert opt_config=false 2462*b50261e2SCy Schubert opt_dlopen= 2463*b50261e2SCy Schubert opt_dry_run=false 2464*b50261e2SCy Schubert opt_help=false 2465*b50261e2SCy Schubert opt_mode= 2466*b50261e2SCy Schubert opt_preserve_dup_deps=false 2467*b50261e2SCy Schubert opt_quiet=false 2468*b50261e2SCy Schubert 2469*b50261e2SCy Schubert nonopt= 2470*b50261e2SCy Schubert preserve_args= 2471*b50261e2SCy Schubert 2472*b50261e2SCy Schubert _G_rc_lt_options_prep=: 2473*b50261e2SCy Schubert 2474*b50261e2SCy Schubert # Shorthand for --mode=foo, only valid as the first argument 2475*b50261e2SCy Schubert case $1 in 2476*b50261e2SCy Schubert clean|clea|cle|cl) 2477*b50261e2SCy Schubert shift; set dummy --mode clean ${1+"$@"}; shift 2478*b50261e2SCy Schubert ;; 2479*b50261e2SCy Schubert compile|compil|compi|comp|com|co|c) 2480*b50261e2SCy Schubert shift; set dummy --mode compile ${1+"$@"}; shift 2481*b50261e2SCy Schubert ;; 2482*b50261e2SCy Schubert execute|execut|execu|exec|exe|ex|e) 2483*b50261e2SCy Schubert shift; set dummy --mode execute ${1+"$@"}; shift 2484*b50261e2SCy Schubert ;; 2485*b50261e2SCy Schubert finish|finis|fini|fin|fi|f) 2486*b50261e2SCy Schubert shift; set dummy --mode finish ${1+"$@"}; shift 2487*b50261e2SCy Schubert ;; 2488*b50261e2SCy Schubert install|instal|insta|inst|ins|in|i) 2489*b50261e2SCy Schubert shift; set dummy --mode install ${1+"$@"}; shift 2490*b50261e2SCy Schubert ;; 2491*b50261e2SCy Schubert link|lin|li|l) 2492*b50261e2SCy Schubert shift; set dummy --mode link ${1+"$@"}; shift 2493*b50261e2SCy Schubert ;; 2494*b50261e2SCy Schubert uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2495*b50261e2SCy Schubert shift; set dummy --mode uninstall ${1+"$@"}; shift 2496*b50261e2SCy Schubert ;; 2497*b50261e2SCy Schubert *) 2498*b50261e2SCy Schubert _G_rc_lt_options_prep=false 2499*b50261e2SCy Schubert ;; 2500*b50261e2SCy Schubert esac 2501*b50261e2SCy Schubert 2502*b50261e2SCy Schubert if $_G_rc_lt_options_prep; then 2503*b50261e2SCy Schubert # Pass back the list of options. 2504*b50261e2SCy Schubert func_quote eval ${1+"$@"} 2505*b50261e2SCy Schubert libtool_options_prep_result=$func_quote_result 2506*b50261e2SCy Schubert fi 2507*b50261e2SCy Schubert} 2508*b50261e2SCy Schubertfunc_add_hook func_options_prep libtool_options_prep 2509*b50261e2SCy Schubert 2510*b50261e2SCy Schubert 2511*b50261e2SCy Schubert# libtool_parse_options [ARG]... 2512*b50261e2SCy Schubert# --------------------------------- 2513*b50261e2SCy Schubert# Provide handling for libtool specific options. 2514*b50261e2SCy Schubertlibtool_parse_options () 2515*b50261e2SCy Schubert{ 2516*b50261e2SCy Schubert $debug_cmd 2517*b50261e2SCy Schubert 2518*b50261e2SCy Schubert _G_rc_lt_parse_options=false 2519*b50261e2SCy Schubert 2520*b50261e2SCy Schubert # Perform our own loop to consume as many options as possible in 2521*b50261e2SCy Schubert # each iteration. 2522*b50261e2SCy Schubert while test $# -gt 0; do 2523*b50261e2SCy Schubert _G_match_lt_parse_options=: 2524*b50261e2SCy Schubert _G_opt=$1 2525*b50261e2SCy Schubert shift 2526*b50261e2SCy Schubert case $_G_opt in 2527*b50261e2SCy Schubert --dry-run|--dryrun|-n) 2528*b50261e2SCy Schubert opt_dry_run=: 2529*b50261e2SCy Schubert ;; 2530*b50261e2SCy Schubert 2531*b50261e2SCy Schubert --config) func_config ;; 2532*b50261e2SCy Schubert 2533*b50261e2SCy Schubert --dlopen|-dlopen) 2534*b50261e2SCy Schubert opt_dlopen="${opt_dlopen+$opt_dlopen 2535*b50261e2SCy Schubert}$1" 2536*b50261e2SCy Schubert shift 2537*b50261e2SCy Schubert ;; 2538*b50261e2SCy Schubert 2539*b50261e2SCy Schubert --preserve-dup-deps) 2540*b50261e2SCy Schubert opt_preserve_dup_deps=: ;; 2541*b50261e2SCy Schubert 2542*b50261e2SCy Schubert --features) func_features ;; 2543*b50261e2SCy Schubert 2544*b50261e2SCy Schubert --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2545*b50261e2SCy Schubert 2546*b50261e2SCy Schubert --help) opt_help=: ;; 2547*b50261e2SCy Schubert 2548*b50261e2SCy Schubert --help-all) opt_help=': help-all' ;; 2549*b50261e2SCy Schubert 2550*b50261e2SCy Schubert --mode) test $# = 0 && func_missing_arg $_G_opt && break 2551*b50261e2SCy Schubert opt_mode=$1 2552*b50261e2SCy Schubert case $1 in 2553*b50261e2SCy Schubert # Valid mode arguments: 2554*b50261e2SCy Schubert clean|compile|execute|finish|install|link|relink|uninstall) ;; 2555*b50261e2SCy Schubert 2556*b50261e2SCy Schubert # Catch anything else as an error 2557*b50261e2SCy Schubert *) func_error "invalid argument for $_G_opt" 2558*b50261e2SCy Schubert exit_cmd=exit 2559*b50261e2SCy Schubert break 2560*b50261e2SCy Schubert ;; 2561*b50261e2SCy Schubert esac 2562*b50261e2SCy Schubert shift 2563*b50261e2SCy Schubert ;; 2564*b50261e2SCy Schubert 2565*b50261e2SCy Schubert --no-silent|--no-quiet) 2566*b50261e2SCy Schubert opt_quiet=false 2567*b50261e2SCy Schubert func_append preserve_args " $_G_opt" 2568*b50261e2SCy Schubert ;; 2569*b50261e2SCy Schubert 2570*b50261e2SCy Schubert --no-warnings|--no-warning|--no-warn) 2571*b50261e2SCy Schubert opt_warning=false 2572*b50261e2SCy Schubert func_append preserve_args " $_G_opt" 2573*b50261e2SCy Schubert ;; 2574*b50261e2SCy Schubert 2575*b50261e2SCy Schubert --no-verbose) 2576*b50261e2SCy Schubert opt_verbose=false 2577*b50261e2SCy Schubert func_append preserve_args " $_G_opt" 2578*b50261e2SCy Schubert ;; 2579*b50261e2SCy Schubert 2580*b50261e2SCy Schubert --silent|--quiet) 2581*b50261e2SCy Schubert opt_quiet=: 2582*b50261e2SCy Schubert opt_verbose=false 2583*b50261e2SCy Schubert func_append preserve_args " $_G_opt" 2584*b50261e2SCy Schubert ;; 2585*b50261e2SCy Schubert 2586*b50261e2SCy Schubert --tag) test $# = 0 && func_missing_arg $_G_opt && break 2587*b50261e2SCy Schubert opt_tag=$1 2588*b50261e2SCy Schubert func_append preserve_args " $_G_opt $1" 2589*b50261e2SCy Schubert func_enable_tag "$1" 2590*b50261e2SCy Schubert shift 2591*b50261e2SCy Schubert ;; 2592*b50261e2SCy Schubert 2593*b50261e2SCy Schubert --verbose|-v) opt_quiet=false 2594*b50261e2SCy Schubert opt_verbose=: 2595*b50261e2SCy Schubert func_append preserve_args " $_G_opt" 2596*b50261e2SCy Schubert ;; 2597*b50261e2SCy Schubert 2598*b50261e2SCy Schubert # An option not handled by this hook function: 2599*b50261e2SCy Schubert *) set dummy "$_G_opt" ${1+"$@"} ; shift 2600*b50261e2SCy Schubert _G_match_lt_parse_options=false 2601*b50261e2SCy Schubert break 2602*b50261e2SCy Schubert ;; 2603*b50261e2SCy Schubert esac 2604*b50261e2SCy Schubert $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2605*b50261e2SCy Schubert done 2606*b50261e2SCy Schubert 2607*b50261e2SCy Schubert if $_G_rc_lt_parse_options; then 2608*b50261e2SCy Schubert # save modified positional parameters for caller 2609*b50261e2SCy Schubert func_quote eval ${1+"$@"} 2610*b50261e2SCy Schubert libtool_parse_options_result=$func_quote_result 2611*b50261e2SCy Schubert fi 2612*b50261e2SCy Schubert} 2613*b50261e2SCy Schubertfunc_add_hook func_parse_options libtool_parse_options 2614*b50261e2SCy Schubert 2615*b50261e2SCy Schubert 2616*b50261e2SCy Schubert 2617*b50261e2SCy Schubert# libtool_validate_options [ARG]... 2618*b50261e2SCy Schubert# --------------------------------- 2619*b50261e2SCy Schubert# Perform any sanity checks on option settings and/or unconsumed 2620*b50261e2SCy Schubert# arguments. 2621*b50261e2SCy Schubertlibtool_validate_options () 2622*b50261e2SCy Schubert{ 2623*b50261e2SCy Schubert # save first non-option argument 2624*b50261e2SCy Schubert if test 0 -lt $#; then 2625*b50261e2SCy Schubert nonopt=$1 2626*b50261e2SCy Schubert shift 2627*b50261e2SCy Schubert fi 2628*b50261e2SCy Schubert 2629*b50261e2SCy Schubert # preserve --debug 2630*b50261e2SCy Schubert test : = "$debug_cmd" || func_append preserve_args " --debug" 2631*b50261e2SCy Schubert 2632*b50261e2SCy Schubert case $host in 2633*b50261e2SCy Schubert # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2634*b50261e2SCy Schubert # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2635*b50261e2SCy Schubert *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2636*b50261e2SCy Schubert # don't eliminate duplications in $postdeps and $predeps 2637*b50261e2SCy Schubert opt_duplicate_compiler_generated_deps=: 2638*b50261e2SCy Schubert ;; 2639*b50261e2SCy Schubert *) 2640*b50261e2SCy Schubert opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2641*b50261e2SCy Schubert ;; 2642*b50261e2SCy Schubert esac 2643*b50261e2SCy Schubert 2644*b50261e2SCy Schubert $opt_help || { 2645*b50261e2SCy Schubert # Sanity checks first: 2646*b50261e2SCy Schubert func_check_version_match 2647*b50261e2SCy Schubert 2648*b50261e2SCy Schubert test yes != "$build_libtool_libs" \ 2649*b50261e2SCy Schubert && test yes != "$build_old_libs" \ 2650*b50261e2SCy Schubert && func_fatal_configuration "not configured to build any kind of library" 2651*b50261e2SCy Schubert 2652*b50261e2SCy Schubert # Darwin sucks 2653*b50261e2SCy Schubert eval std_shrext=\"$shrext_cmds\" 2654*b50261e2SCy Schubert 2655*b50261e2SCy Schubert # Only execute mode is allowed to have -dlopen flags. 2656*b50261e2SCy Schubert if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2657*b50261e2SCy Schubert func_error "unrecognized option '-dlopen'" 2658*b50261e2SCy Schubert $ECHO "$help" 1>&2 2659*b50261e2SCy Schubert exit $EXIT_FAILURE 2660*b50261e2SCy Schubert fi 2661*b50261e2SCy Schubert 2662*b50261e2SCy Schubert # Change the help message to a mode-specific one. 2663*b50261e2SCy Schubert generic_help=$help 2664*b50261e2SCy Schubert help="Try '$progname --help --mode=$opt_mode' for more information." 2665*b50261e2SCy Schubert } 2666*b50261e2SCy Schubert 2667*b50261e2SCy Schubert # Pass back the unparsed argument list 2668*b50261e2SCy Schubert func_quote eval ${1+"$@"} 2669*b50261e2SCy Schubert libtool_validate_options_result=$func_quote_result 2670*b50261e2SCy Schubert} 2671*b50261e2SCy Schubertfunc_add_hook func_validate_options libtool_validate_options 2672*b50261e2SCy Schubert 2673*b50261e2SCy Schubert 2674*b50261e2SCy Schubert# Process options as early as possible so that --help and --version 2675*b50261e2SCy Schubert# can return quickly. 2676*b50261e2SCy Schubertfunc_options ${1+"$@"} 2677*b50261e2SCy Schuberteval set dummy "$func_options_result"; shift 2678*b50261e2SCy Schubert 2679*b50261e2SCy Schubert 2680*b50261e2SCy Schubert 2681*b50261e2SCy Schubert## ----------- ## 2682*b50261e2SCy Schubert## Main. ## 2683*b50261e2SCy Schubert## ----------- ## 2684*b50261e2SCy Schubert 2685*b50261e2SCy Schubertmagic='%%%MAGIC variable%%%' 2686*b50261e2SCy Schubertmagic_exe='%%%MAGIC EXE variable%%%' 2687*b50261e2SCy Schubert 2688*b50261e2SCy Schubert# Global variables. 2689*b50261e2SCy Schubertextracted_archives= 2690*b50261e2SCy Schubertextracted_serial=0 2691*b50261e2SCy Schubert 2692*b50261e2SCy Schubert# If this variable is set in any of the actions, the command in it 2693*b50261e2SCy Schubert# will be execed at the end. This prevents here-documents from being 2694*b50261e2SCy Schubert# left over by shells. 2695*b50261e2SCy Schubertexec_cmd= 2696*b50261e2SCy Schubert 2697*b50261e2SCy Schubert 2698*b50261e2SCy Schubert# A function that is used when there is no print builtin or printf. 2699*b50261e2SCy Schubertfunc_fallback_echo () 2700*b50261e2SCy Schubert{ 2701*b50261e2SCy Schubert eval 'cat <<_LTECHO_EOF 2702*b50261e2SCy Schubert$1 2703*b50261e2SCy Schubert_LTECHO_EOF' 2704*b50261e2SCy Schubert} 2705*b50261e2SCy Schubert 2706*b50261e2SCy Schubert# func_generated_by_libtool 2707*b50261e2SCy Schubert# True iff stdin has been generated by Libtool. This function is only 2708*b50261e2SCy Schubert# a basic sanity check; it will hardly flush out determined imposters. 2709*b50261e2SCy Schubertfunc_generated_by_libtool_p () 2710*b50261e2SCy Schubert{ 2711*b50261e2SCy Schubert $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2712*b50261e2SCy Schubert} 2713*b50261e2SCy Schubert 2714*b50261e2SCy Schubert# func_lalib_p file 2715*b50261e2SCy Schubert# True iff FILE is a libtool '.la' library or '.lo' object file. 2716*b50261e2SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2717*b50261e2SCy Schubert# determined imposters. 2718*b50261e2SCy Schubertfunc_lalib_p () 2719*b50261e2SCy Schubert{ 2720*b50261e2SCy Schubert test -f "$1" && 2721*b50261e2SCy Schubert $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2722*b50261e2SCy Schubert} 2723*b50261e2SCy Schubert 2724*b50261e2SCy Schubert# func_lalib_unsafe_p file 2725*b50261e2SCy Schubert# True iff FILE is a libtool '.la' library or '.lo' object file. 2726*b50261e2SCy Schubert# This function implements the same check as func_lalib_p without 2727*b50261e2SCy Schubert# resorting to external programs. To this end, it redirects stdin and 2728*b50261e2SCy Schubert# closes it afterwards, without saving the original file descriptor. 2729*b50261e2SCy Schubert# As a safety measure, use it only where a negative result would be 2730*b50261e2SCy Schubert# fatal anyway. Works if 'file' does not exist. 2731*b50261e2SCy Schubertfunc_lalib_unsafe_p () 2732*b50261e2SCy Schubert{ 2733*b50261e2SCy Schubert lalib_p=no 2734*b50261e2SCy Schubert if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2735*b50261e2SCy Schubert for lalib_p_l in 1 2 3 4 2736*b50261e2SCy Schubert do 2737*b50261e2SCy Schubert read lalib_p_line 2738*b50261e2SCy Schubert case $lalib_p_line in 2739*b50261e2SCy Schubert \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2740*b50261e2SCy Schubert esac 2741*b50261e2SCy Schubert done 2742*b50261e2SCy Schubert exec 0<&5 5<&- 2743*b50261e2SCy Schubert fi 2744*b50261e2SCy Schubert test yes = "$lalib_p" 2745*b50261e2SCy Schubert} 2746*b50261e2SCy Schubert 2747*b50261e2SCy Schubert# func_ltwrapper_script_p file 2748*b50261e2SCy Schubert# True iff FILE is a libtool wrapper script 2749*b50261e2SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2750*b50261e2SCy Schubert# determined imposters. 2751*b50261e2SCy Schubertfunc_ltwrapper_script_p () 2752*b50261e2SCy Schubert{ 2753*b50261e2SCy Schubert test -f "$1" && 2754*b50261e2SCy Schubert $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2755*b50261e2SCy Schubert} 2756*b50261e2SCy Schubert 2757*b50261e2SCy Schubert# func_ltwrapper_executable_p file 2758*b50261e2SCy Schubert# True iff FILE is a libtool wrapper executable 2759*b50261e2SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2760*b50261e2SCy Schubert# determined imposters. 2761*b50261e2SCy Schubertfunc_ltwrapper_executable_p () 2762*b50261e2SCy Schubert{ 2763*b50261e2SCy Schubert func_ltwrapper_exec_suffix= 2764*b50261e2SCy Schubert case $1 in 2765*b50261e2SCy Schubert *.exe) ;; 2766*b50261e2SCy Schubert *) func_ltwrapper_exec_suffix=.exe ;; 2767*b50261e2SCy Schubert esac 2768*b50261e2SCy Schubert $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2769*b50261e2SCy Schubert} 2770*b50261e2SCy Schubert 2771*b50261e2SCy Schubert# func_ltwrapper_scriptname file 2772*b50261e2SCy Schubert# Assumes file is an ltwrapper_executable 2773*b50261e2SCy Schubert# uses $file to determine the appropriate filename for a 2774*b50261e2SCy Schubert# temporary ltwrapper_script. 2775*b50261e2SCy Schubertfunc_ltwrapper_scriptname () 2776*b50261e2SCy Schubert{ 2777*b50261e2SCy Schubert func_dirname_and_basename "$1" "" "." 2778*b50261e2SCy Schubert func_stripname '' '.exe' "$func_basename_result" 2779*b50261e2SCy Schubert func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2780*b50261e2SCy Schubert} 2781*b50261e2SCy Schubert 2782*b50261e2SCy Schubert# func_ltwrapper_p file 2783*b50261e2SCy Schubert# True iff FILE is a libtool wrapper script or wrapper executable 2784*b50261e2SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2785*b50261e2SCy Schubert# determined imposters. 2786*b50261e2SCy Schubertfunc_ltwrapper_p () 2787*b50261e2SCy Schubert{ 2788*b50261e2SCy Schubert func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2789*b50261e2SCy Schubert} 2790*b50261e2SCy Schubert 2791*b50261e2SCy Schubert 2792*b50261e2SCy Schubert# func_execute_cmds commands fail_cmd 2793*b50261e2SCy Schubert# Execute tilde-delimited COMMANDS. 2794*b50261e2SCy Schubert# If FAIL_CMD is given, eval that upon failure. 2795*b50261e2SCy Schubert# FAIL_CMD may read-access the current command in variable CMD! 2796*b50261e2SCy Schubertfunc_execute_cmds () 2797*b50261e2SCy Schubert{ 2798*b50261e2SCy Schubert $debug_cmd 2799*b50261e2SCy Schubert 2800*b50261e2SCy Schubert save_ifs=$IFS; IFS='~' 2801*b50261e2SCy Schubert for cmd in $1; do 2802*b50261e2SCy Schubert IFS=$sp$nl 2803*b50261e2SCy Schubert eval cmd=\"$cmd\" 2804*b50261e2SCy Schubert IFS=$save_ifs 2805*b50261e2SCy Schubert func_show_eval "$cmd" "${2-:}" 2806*b50261e2SCy Schubert done 2807*b50261e2SCy Schubert IFS=$save_ifs 2808*b50261e2SCy Schubert} 2809*b50261e2SCy Schubert 2810*b50261e2SCy Schubert 2811*b50261e2SCy Schubert# func_source file 2812*b50261e2SCy Schubert# Source FILE, adding directory component if necessary. 2813*b50261e2SCy Schubert# Note that it is not necessary on cygwin/mingw to append a dot to 2814*b50261e2SCy Schubert# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2815*b50261e2SCy Schubert# behavior happens only for exec(3), not for open(2)! Also, sourcing 2816*b50261e2SCy Schubert# 'FILE.' does not work on cygwin managed mounts. 2817*b50261e2SCy Schubertfunc_source () 2818*b50261e2SCy Schubert{ 2819*b50261e2SCy Schubert $debug_cmd 2820*b50261e2SCy Schubert 2821*b50261e2SCy Schubert case $1 in 2822*b50261e2SCy Schubert */* | *\\*) . "$1" ;; 2823*b50261e2SCy Schubert *) . "./$1" ;; 2824*b50261e2SCy Schubert esac 2825*b50261e2SCy Schubert} 2826*b50261e2SCy Schubert 2827*b50261e2SCy Schubert 2828*b50261e2SCy Schubert# func_resolve_sysroot PATH 2829*b50261e2SCy Schubert# Replace a leading = in PATH with a sysroot. Store the result into 2830*b50261e2SCy Schubert# func_resolve_sysroot_result 2831*b50261e2SCy Schubertfunc_resolve_sysroot () 2832*b50261e2SCy Schubert{ 2833*b50261e2SCy Schubert func_resolve_sysroot_result=$1 2834*b50261e2SCy Schubert case $func_resolve_sysroot_result in 2835*b50261e2SCy Schubert =*) 2836*b50261e2SCy Schubert func_stripname '=' '' "$func_resolve_sysroot_result" 2837*b50261e2SCy Schubert func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2838*b50261e2SCy Schubert ;; 2839*b50261e2SCy Schubert esac 2840*b50261e2SCy Schubert} 2841*b50261e2SCy Schubert 2842*b50261e2SCy Schubert# func_replace_sysroot PATH 2843*b50261e2SCy Schubert# If PATH begins with the sysroot, replace it with = and 2844*b50261e2SCy Schubert# store the result into func_replace_sysroot_result. 2845*b50261e2SCy Schubertfunc_replace_sysroot () 2846*b50261e2SCy Schubert{ 2847*b50261e2SCy Schubert case $lt_sysroot:$1 in 2848*b50261e2SCy Schubert ?*:"$lt_sysroot"*) 2849*b50261e2SCy Schubert func_stripname "$lt_sysroot" '' "$1" 2850*b50261e2SCy Schubert func_replace_sysroot_result='='$func_stripname_result 2851*b50261e2SCy Schubert ;; 2852*b50261e2SCy Schubert *) 2853*b50261e2SCy Schubert # Including no sysroot. 2854*b50261e2SCy Schubert func_replace_sysroot_result=$1 2855*b50261e2SCy Schubert ;; 2856*b50261e2SCy Schubert esac 2857*b50261e2SCy Schubert} 2858*b50261e2SCy Schubert 2859*b50261e2SCy Schubert# func_infer_tag arg 2860*b50261e2SCy Schubert# Infer tagged configuration to use if any are available and 2861*b50261e2SCy Schubert# if one wasn't chosen via the "--tag" command line option. 2862*b50261e2SCy Schubert# Only attempt this if the compiler in the base compile 2863*b50261e2SCy Schubert# command doesn't match the default compiler. 2864*b50261e2SCy Schubert# arg is usually of the form 'gcc ...' 2865*b50261e2SCy Schubertfunc_infer_tag () 2866*b50261e2SCy Schubert{ 2867*b50261e2SCy Schubert $debug_cmd 2868*b50261e2SCy Schubert 2869*b50261e2SCy Schubert if test -n "$available_tags" && test -z "$tagname"; then 2870*b50261e2SCy Schubert CC_quoted= 2871*b50261e2SCy Schubert for arg in $CC; do 2872*b50261e2SCy Schubert func_append_quoted CC_quoted "$arg" 2873*b50261e2SCy Schubert done 2874*b50261e2SCy Schubert CC_expanded=`func_echo_all $CC` 2875*b50261e2SCy Schubert CC_quoted_expanded=`func_echo_all $CC_quoted` 2876*b50261e2SCy Schubert case $@ in 2877*b50261e2SCy Schubert # Blanks in the command may have been stripped by the calling shell, 2878*b50261e2SCy Schubert # but not from the CC environment variable when configure was run. 2879*b50261e2SCy Schubert " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2880*b50261e2SCy Schubert " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2881*b50261e2SCy Schubert # Blanks at the start of $base_compile will cause this to fail 2882*b50261e2SCy Schubert # if we don't check for them as well. 2883*b50261e2SCy Schubert *) 2884*b50261e2SCy Schubert for z in $available_tags; do 2885*b50261e2SCy Schubert if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2886*b50261e2SCy Schubert # Evaluate the configuration. 2887*b50261e2SCy Schubert eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2888*b50261e2SCy Schubert CC_quoted= 2889*b50261e2SCy Schubert for arg in $CC; do 2890*b50261e2SCy Schubert # Double-quote args containing other shell metacharacters. 2891*b50261e2SCy Schubert func_append_quoted CC_quoted "$arg" 2892*b50261e2SCy Schubert done 2893*b50261e2SCy Schubert CC_expanded=`func_echo_all $CC` 2894*b50261e2SCy Schubert CC_quoted_expanded=`func_echo_all $CC_quoted` 2895*b50261e2SCy Schubert case "$@ " in 2896*b50261e2SCy Schubert " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2897*b50261e2SCy Schubert " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2898*b50261e2SCy Schubert # The compiler in the base compile command matches 2899*b50261e2SCy Schubert # the one in the tagged configuration. 2900*b50261e2SCy Schubert # Assume this is the tagged configuration we want. 2901*b50261e2SCy Schubert tagname=$z 2902*b50261e2SCy Schubert break 2903*b50261e2SCy Schubert ;; 2904*b50261e2SCy Schubert esac 2905*b50261e2SCy Schubert fi 2906*b50261e2SCy Schubert done 2907*b50261e2SCy Schubert # If $tagname still isn't set, then no tagged configuration 2908*b50261e2SCy Schubert # was found and let the user know that the "--tag" command 2909*b50261e2SCy Schubert # line option must be used. 2910*b50261e2SCy Schubert if test -z "$tagname"; then 2911*b50261e2SCy Schubert func_echo "unable to infer tagged configuration" 2912*b50261e2SCy Schubert func_fatal_error "specify a tag with '--tag'" 2913*b50261e2SCy Schubert# else 2914*b50261e2SCy Schubert# func_verbose "using $tagname tagged configuration" 2915*b50261e2SCy Schubert fi 2916*b50261e2SCy Schubert ;; 2917*b50261e2SCy Schubert esac 2918*b50261e2SCy Schubert fi 2919*b50261e2SCy Schubert} 2920*b50261e2SCy Schubert 2921*b50261e2SCy Schubert 2922*b50261e2SCy Schubert 2923*b50261e2SCy Schubert# func_write_libtool_object output_name pic_name nonpic_name 2924*b50261e2SCy Schubert# Create a libtool object file (analogous to a ".la" file), 2925*b50261e2SCy Schubert# but don't create it if we're doing a dry run. 2926*b50261e2SCy Schubertfunc_write_libtool_object () 2927*b50261e2SCy Schubert{ 2928*b50261e2SCy Schubert write_libobj=$1 2929*b50261e2SCy Schubert if test yes = "$build_libtool_libs"; then 2930*b50261e2SCy Schubert write_lobj=\'$2\' 2931*b50261e2SCy Schubert else 2932*b50261e2SCy Schubert write_lobj=none 2933*b50261e2SCy Schubert fi 2934*b50261e2SCy Schubert 2935*b50261e2SCy Schubert if test yes = "$build_old_libs"; then 2936*b50261e2SCy Schubert write_oldobj=\'$3\' 2937*b50261e2SCy Schubert else 2938*b50261e2SCy Schubert write_oldobj=none 2939*b50261e2SCy Schubert fi 2940*b50261e2SCy Schubert 2941*b50261e2SCy Schubert $opt_dry_run || { 2942*b50261e2SCy Schubert cat >${write_libobj}T <<EOF 2943*b50261e2SCy Schubert# $write_libobj - a libtool object file 2944*b50261e2SCy Schubert# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2945*b50261e2SCy Schubert# 2946*b50261e2SCy Schubert# Please DO NOT delete this file! 2947*b50261e2SCy Schubert# It is necessary for linking the library. 2948*b50261e2SCy Schubert 2949*b50261e2SCy Schubert# Name of the PIC object. 2950*b50261e2SCy Schubertpic_object=$write_lobj 2951*b50261e2SCy Schubert 2952*b50261e2SCy Schubert# Name of the non-PIC object 2953*b50261e2SCy Schubertnon_pic_object=$write_oldobj 2954*b50261e2SCy Schubert 2955*b50261e2SCy SchubertEOF 2956*b50261e2SCy Schubert $MV "${write_libobj}T" "$write_libobj" 2957*b50261e2SCy Schubert } 2958*b50261e2SCy Schubert} 2959*b50261e2SCy Schubert 2960*b50261e2SCy Schubert 2961*b50261e2SCy Schubert################################################## 2962*b50261e2SCy Schubert# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2963*b50261e2SCy Schubert################################################## 2964*b50261e2SCy Schubert 2965*b50261e2SCy Schubert# func_convert_core_file_wine_to_w32 ARG 2966*b50261e2SCy Schubert# Helper function used by file name conversion functions when $build is *nix, 2967*b50261e2SCy Schubert# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2968*b50261e2SCy Schubert# correctly configured wine environment available, with the winepath program 2969*b50261e2SCy Schubert# in $build's $PATH. 2970*b50261e2SCy Schubert# 2971*b50261e2SCy Schubert# ARG is the $build file name to be converted to w32 format. 2972*b50261e2SCy Schubert# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2973*b50261e2SCy Schubert# be empty on error (or when ARG is empty) 2974*b50261e2SCy Schubertfunc_convert_core_file_wine_to_w32 () 2975*b50261e2SCy Schubert{ 2976*b50261e2SCy Schubert $debug_cmd 2977*b50261e2SCy Schubert 2978*b50261e2SCy Schubert func_convert_core_file_wine_to_w32_result=$1 2979*b50261e2SCy Schubert if test -n "$1"; then 2980*b50261e2SCy Schubert # Unfortunately, winepath does not exit with a non-zero error code, so we 2981*b50261e2SCy Schubert # are forced to check the contents of stdout. On the other hand, if the 2982*b50261e2SCy Schubert # command is not found, the shell will set an exit code of 127 and print 2983*b50261e2SCy Schubert # *an error message* to stdout. So we must check for both error code of 2984*b50261e2SCy Schubert # zero AND non-empty stdout, which explains the odd construction: 2985*b50261e2SCy Schubert func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2986*b50261e2SCy Schubert if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2987*b50261e2SCy Schubert func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2988*b50261e2SCy Schubert $SED -e "$sed_naive_backslashify"` 2989*b50261e2SCy Schubert else 2990*b50261e2SCy Schubert func_convert_core_file_wine_to_w32_result= 2991*b50261e2SCy Schubert fi 2992*b50261e2SCy Schubert fi 2993*b50261e2SCy Schubert} 2994*b50261e2SCy Schubert# end: func_convert_core_file_wine_to_w32 2995*b50261e2SCy Schubert 2996*b50261e2SCy Schubert 2997*b50261e2SCy Schubert# func_convert_core_path_wine_to_w32 ARG 2998*b50261e2SCy Schubert# Helper function used by path conversion functions when $build is *nix, and 2999*b50261e2SCy Schubert# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3000*b50261e2SCy Schubert# configured wine environment available, with the winepath program in $build's 3001*b50261e2SCy Schubert# $PATH. Assumes ARG has no leading or trailing path separator characters. 3002*b50261e2SCy Schubert# 3003*b50261e2SCy Schubert# ARG is path to be converted from $build format to win32. 3004*b50261e2SCy Schubert# Result is available in $func_convert_core_path_wine_to_w32_result. 3005*b50261e2SCy Schubert# Unconvertible file (directory) names in ARG are skipped; if no directory names 3006*b50261e2SCy Schubert# are convertible, then the result may be empty. 3007*b50261e2SCy Schubertfunc_convert_core_path_wine_to_w32 () 3008*b50261e2SCy Schubert{ 3009*b50261e2SCy Schubert $debug_cmd 3010*b50261e2SCy Schubert 3011*b50261e2SCy Schubert # unfortunately, winepath doesn't convert paths, only file names 3012*b50261e2SCy Schubert func_convert_core_path_wine_to_w32_result= 3013*b50261e2SCy Schubert if test -n "$1"; then 3014*b50261e2SCy Schubert oldIFS=$IFS 3015*b50261e2SCy Schubert IFS=: 3016*b50261e2SCy Schubert for func_convert_core_path_wine_to_w32_f in $1; do 3017*b50261e2SCy Schubert IFS=$oldIFS 3018*b50261e2SCy Schubert func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3019*b50261e2SCy Schubert if test -n "$func_convert_core_file_wine_to_w32_result"; then 3020*b50261e2SCy Schubert if test -z "$func_convert_core_path_wine_to_w32_result"; then 3021*b50261e2SCy Schubert func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3022*b50261e2SCy Schubert else 3023*b50261e2SCy Schubert func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3024*b50261e2SCy Schubert fi 3025*b50261e2SCy Schubert fi 3026*b50261e2SCy Schubert done 3027*b50261e2SCy Schubert IFS=$oldIFS 3028*b50261e2SCy Schubert fi 3029*b50261e2SCy Schubert} 3030*b50261e2SCy Schubert# end: func_convert_core_path_wine_to_w32 3031*b50261e2SCy Schubert 3032*b50261e2SCy Schubert 3033*b50261e2SCy Schubert# func_cygpath ARGS... 3034*b50261e2SCy Schubert# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3035*b50261e2SCy Schubert# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3036*b50261e2SCy Schubert# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3037*b50261e2SCy Schubert# (2), returns the Cygwin file name or path in func_cygpath_result (input 3038*b50261e2SCy Schubert# file name or path is assumed to be in w32 format, as previously converted 3039*b50261e2SCy Schubert# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3040*b50261e2SCy Schubert# or path in func_cygpath_result (input file name or path is assumed to be in 3041*b50261e2SCy Schubert# Cygwin format). Returns an empty string on error. 3042*b50261e2SCy Schubert# 3043*b50261e2SCy Schubert# ARGS are passed to cygpath, with the last one being the file name or path to 3044*b50261e2SCy Schubert# be converted. 3045*b50261e2SCy Schubert# 3046*b50261e2SCy Schubert# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3047*b50261e2SCy Schubert# environment variable; do not put it in $PATH. 3048*b50261e2SCy Schubertfunc_cygpath () 3049*b50261e2SCy Schubert{ 3050*b50261e2SCy Schubert $debug_cmd 3051*b50261e2SCy Schubert 3052*b50261e2SCy Schubert if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3053*b50261e2SCy Schubert func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3054*b50261e2SCy Schubert if test "$?" -ne 0; then 3055*b50261e2SCy Schubert # on failure, ensure result is empty 3056*b50261e2SCy Schubert func_cygpath_result= 3057*b50261e2SCy Schubert fi 3058*b50261e2SCy Schubert else 3059*b50261e2SCy Schubert func_cygpath_result= 3060*b50261e2SCy Schubert func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3061*b50261e2SCy Schubert fi 3062*b50261e2SCy Schubert} 3063*b50261e2SCy Schubert#end: func_cygpath 3064*b50261e2SCy Schubert 3065*b50261e2SCy Schubert 3066*b50261e2SCy Schubert# func_convert_core_msys_to_w32 ARG 3067*b50261e2SCy Schubert# Convert file name or path ARG from MSYS format to w32 format. Return 3068*b50261e2SCy Schubert# result in func_convert_core_msys_to_w32_result. 3069*b50261e2SCy Schubertfunc_convert_core_msys_to_w32 () 3070*b50261e2SCy Schubert{ 3071*b50261e2SCy Schubert $debug_cmd 3072*b50261e2SCy Schubert 3073*b50261e2SCy Schubert # awkward: cmd appends spaces to result 3074*b50261e2SCy Schubert func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3075*b50261e2SCy Schubert $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3076*b50261e2SCy Schubert} 3077*b50261e2SCy Schubert#end: func_convert_core_msys_to_w32 3078*b50261e2SCy Schubert 3079*b50261e2SCy Schubert 3080*b50261e2SCy Schubert# func_convert_file_check ARG1 ARG2 3081*b50261e2SCy Schubert# Verify that ARG1 (a file name in $build format) was converted to $host 3082*b50261e2SCy Schubert# format in ARG2. Otherwise, emit an error message, but continue (resetting 3083*b50261e2SCy Schubert# func_to_host_file_result to ARG1). 3084*b50261e2SCy Schubertfunc_convert_file_check () 3085*b50261e2SCy Schubert{ 3086*b50261e2SCy Schubert $debug_cmd 3087*b50261e2SCy Schubert 3088*b50261e2SCy Schubert if test -z "$2" && test -n "$1"; then 3089*b50261e2SCy Schubert func_error "Could not determine host file name corresponding to" 3090*b50261e2SCy Schubert func_error " '$1'" 3091*b50261e2SCy Schubert func_error "Continuing, but uninstalled executables may not work." 3092*b50261e2SCy Schubert # Fallback: 3093*b50261e2SCy Schubert func_to_host_file_result=$1 3094*b50261e2SCy Schubert fi 3095*b50261e2SCy Schubert} 3096*b50261e2SCy Schubert# end func_convert_file_check 3097*b50261e2SCy Schubert 3098*b50261e2SCy Schubert 3099*b50261e2SCy Schubert# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3100*b50261e2SCy Schubert# Verify that FROM_PATH (a path in $build format) was converted to $host 3101*b50261e2SCy Schubert# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3102*b50261e2SCy Schubert# func_to_host_file_result to a simplistic fallback value (see below). 3103*b50261e2SCy Schubertfunc_convert_path_check () 3104*b50261e2SCy Schubert{ 3105*b50261e2SCy Schubert $debug_cmd 3106*b50261e2SCy Schubert 3107*b50261e2SCy Schubert if test -z "$4" && test -n "$3"; then 3108*b50261e2SCy Schubert func_error "Could not determine the host path corresponding to" 3109*b50261e2SCy Schubert func_error " '$3'" 3110*b50261e2SCy Schubert func_error "Continuing, but uninstalled executables may not work." 3111*b50261e2SCy Schubert # Fallback. This is a deliberately simplistic "conversion" and 3112*b50261e2SCy Schubert # should not be "improved". See libtool.info. 3113*b50261e2SCy Schubert if test "x$1" != "x$2"; then 3114*b50261e2SCy Schubert lt_replace_pathsep_chars="s|$1|$2|g" 3115*b50261e2SCy Schubert func_to_host_path_result=`echo "$3" | 3116*b50261e2SCy Schubert $SED -e "$lt_replace_pathsep_chars"` 3117*b50261e2SCy Schubert else 3118*b50261e2SCy Schubert func_to_host_path_result=$3 3119*b50261e2SCy Schubert fi 3120*b50261e2SCy Schubert fi 3121*b50261e2SCy Schubert} 3122*b50261e2SCy Schubert# end func_convert_path_check 3123*b50261e2SCy Schubert 3124*b50261e2SCy Schubert 3125*b50261e2SCy Schubert# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3126*b50261e2SCy Schubert# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3127*b50261e2SCy Schubert# and appending REPL if ORIG matches BACKPAT. 3128*b50261e2SCy Schubertfunc_convert_path_front_back_pathsep () 3129*b50261e2SCy Schubert{ 3130*b50261e2SCy Schubert $debug_cmd 3131*b50261e2SCy Schubert 3132*b50261e2SCy Schubert case $4 in 3133*b50261e2SCy Schubert $1 ) func_to_host_path_result=$3$func_to_host_path_result 3134*b50261e2SCy Schubert ;; 3135*b50261e2SCy Schubert esac 3136*b50261e2SCy Schubert case $4 in 3137*b50261e2SCy Schubert $2 ) func_append func_to_host_path_result "$3" 3138*b50261e2SCy Schubert ;; 3139*b50261e2SCy Schubert esac 3140*b50261e2SCy Schubert} 3141*b50261e2SCy Schubert# end func_convert_path_front_back_pathsep 3142*b50261e2SCy Schubert 3143*b50261e2SCy Schubert 3144*b50261e2SCy Schubert################################################## 3145*b50261e2SCy Schubert# $build to $host FILE NAME CONVERSION FUNCTIONS # 3146*b50261e2SCy Schubert################################################## 3147*b50261e2SCy Schubert# invoked via '$to_host_file_cmd ARG' 3148*b50261e2SCy Schubert# 3149*b50261e2SCy Schubert# In each case, ARG is the path to be converted from $build to $host format. 3150*b50261e2SCy Schubert# Result will be available in $func_to_host_file_result. 3151*b50261e2SCy Schubert 3152*b50261e2SCy Schubert 3153*b50261e2SCy Schubert# func_to_host_file ARG 3154*b50261e2SCy Schubert# Converts the file name ARG from $build format to $host format. Return result 3155*b50261e2SCy Schubert# in func_to_host_file_result. 3156*b50261e2SCy Schubertfunc_to_host_file () 3157*b50261e2SCy Schubert{ 3158*b50261e2SCy Schubert $debug_cmd 3159*b50261e2SCy Schubert 3160*b50261e2SCy Schubert $to_host_file_cmd "$1" 3161*b50261e2SCy Schubert} 3162*b50261e2SCy Schubert# end func_to_host_file 3163*b50261e2SCy Schubert 3164*b50261e2SCy Schubert 3165*b50261e2SCy Schubert# func_to_tool_file ARG LAZY 3166*b50261e2SCy Schubert# converts the file name ARG from $build format to toolchain format. Return 3167*b50261e2SCy Schubert# result in func_to_tool_file_result. If the conversion in use is listed 3168*b50261e2SCy Schubert# in (the comma separated) LAZY, no conversion takes place. 3169*b50261e2SCy Schubertfunc_to_tool_file () 3170*b50261e2SCy Schubert{ 3171*b50261e2SCy Schubert $debug_cmd 3172*b50261e2SCy Schubert 3173*b50261e2SCy Schubert case ,$2, in 3174*b50261e2SCy Schubert *,"$to_tool_file_cmd",*) 3175*b50261e2SCy Schubert func_to_tool_file_result=$1 3176*b50261e2SCy Schubert ;; 3177*b50261e2SCy Schubert *) 3178*b50261e2SCy Schubert $to_tool_file_cmd "$1" 3179*b50261e2SCy Schubert func_to_tool_file_result=$func_to_host_file_result 3180*b50261e2SCy Schubert ;; 3181*b50261e2SCy Schubert esac 3182*b50261e2SCy Schubert} 3183*b50261e2SCy Schubert# end func_to_tool_file 3184*b50261e2SCy Schubert 3185*b50261e2SCy Schubert 3186*b50261e2SCy Schubert# func_convert_file_noop ARG 3187*b50261e2SCy Schubert# Copy ARG to func_to_host_file_result. 3188*b50261e2SCy Schubertfunc_convert_file_noop () 3189*b50261e2SCy Schubert{ 3190*b50261e2SCy Schubert func_to_host_file_result=$1 3191*b50261e2SCy Schubert} 3192*b50261e2SCy Schubert# end func_convert_file_noop 3193*b50261e2SCy Schubert 3194*b50261e2SCy Schubert 3195*b50261e2SCy Schubert# func_convert_file_msys_to_w32 ARG 3196*b50261e2SCy Schubert# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3197*b50261e2SCy Schubert# conversion to w32 is not available inside the cwrapper. Returns result in 3198*b50261e2SCy Schubert# func_to_host_file_result. 3199*b50261e2SCy Schubertfunc_convert_file_msys_to_w32 () 3200*b50261e2SCy Schubert{ 3201*b50261e2SCy Schubert $debug_cmd 3202*b50261e2SCy Schubert 3203*b50261e2SCy Schubert func_to_host_file_result=$1 3204*b50261e2SCy Schubert if test -n "$1"; then 3205*b50261e2SCy Schubert func_convert_core_msys_to_w32 "$1" 3206*b50261e2SCy Schubert func_to_host_file_result=$func_convert_core_msys_to_w32_result 3207*b50261e2SCy Schubert fi 3208*b50261e2SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3209*b50261e2SCy Schubert} 3210*b50261e2SCy Schubert# end func_convert_file_msys_to_w32 3211*b50261e2SCy Schubert 3212*b50261e2SCy Schubert 3213*b50261e2SCy Schubert# func_convert_file_cygwin_to_w32 ARG 3214*b50261e2SCy Schubert# Convert file name ARG from Cygwin to w32 format. Returns result in 3215*b50261e2SCy Schubert# func_to_host_file_result. 3216*b50261e2SCy Schubertfunc_convert_file_cygwin_to_w32 () 3217*b50261e2SCy Schubert{ 3218*b50261e2SCy Schubert $debug_cmd 3219*b50261e2SCy Schubert 3220*b50261e2SCy Schubert func_to_host_file_result=$1 3221*b50261e2SCy Schubert if test -n "$1"; then 3222*b50261e2SCy Schubert # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3223*b50261e2SCy Schubert # LT_CYGPATH in this case. 3224*b50261e2SCy Schubert func_to_host_file_result=`cygpath -m "$1"` 3225*b50261e2SCy Schubert fi 3226*b50261e2SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3227*b50261e2SCy Schubert} 3228*b50261e2SCy Schubert# end func_convert_file_cygwin_to_w32 3229*b50261e2SCy Schubert 3230*b50261e2SCy Schubert 3231*b50261e2SCy Schubert# func_convert_file_nix_to_w32 ARG 3232*b50261e2SCy Schubert# Convert file name ARG from *nix to w32 format. Requires a wine environment 3233*b50261e2SCy Schubert# and a working winepath. Returns result in func_to_host_file_result. 3234*b50261e2SCy Schubertfunc_convert_file_nix_to_w32 () 3235*b50261e2SCy Schubert{ 3236*b50261e2SCy Schubert $debug_cmd 3237*b50261e2SCy Schubert 3238*b50261e2SCy Schubert func_to_host_file_result=$1 3239*b50261e2SCy Schubert if test -n "$1"; then 3240*b50261e2SCy Schubert func_convert_core_file_wine_to_w32 "$1" 3241*b50261e2SCy Schubert func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3242*b50261e2SCy Schubert fi 3243*b50261e2SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3244*b50261e2SCy Schubert} 3245*b50261e2SCy Schubert# end func_convert_file_nix_to_w32 3246*b50261e2SCy Schubert 3247*b50261e2SCy Schubert 3248*b50261e2SCy Schubert# func_convert_file_msys_to_cygwin ARG 3249*b50261e2SCy Schubert# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3250*b50261e2SCy Schubert# Returns result in func_to_host_file_result. 3251*b50261e2SCy Schubertfunc_convert_file_msys_to_cygwin () 3252*b50261e2SCy Schubert{ 3253*b50261e2SCy Schubert $debug_cmd 3254*b50261e2SCy Schubert 3255*b50261e2SCy Schubert func_to_host_file_result=$1 3256*b50261e2SCy Schubert if test -n "$1"; then 3257*b50261e2SCy Schubert func_convert_core_msys_to_w32 "$1" 3258*b50261e2SCy Schubert func_cygpath -u "$func_convert_core_msys_to_w32_result" 3259*b50261e2SCy Schubert func_to_host_file_result=$func_cygpath_result 3260*b50261e2SCy Schubert fi 3261*b50261e2SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3262*b50261e2SCy Schubert} 3263*b50261e2SCy Schubert# end func_convert_file_msys_to_cygwin 3264*b50261e2SCy Schubert 3265*b50261e2SCy Schubert 3266*b50261e2SCy Schubert# func_convert_file_nix_to_cygwin ARG 3267*b50261e2SCy Schubert# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3268*b50261e2SCy Schubert# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3269*b50261e2SCy Schubert# in func_to_host_file_result. 3270*b50261e2SCy Schubertfunc_convert_file_nix_to_cygwin () 3271*b50261e2SCy Schubert{ 3272*b50261e2SCy Schubert $debug_cmd 3273*b50261e2SCy Schubert 3274*b50261e2SCy Schubert func_to_host_file_result=$1 3275*b50261e2SCy Schubert if test -n "$1"; then 3276*b50261e2SCy Schubert # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3277*b50261e2SCy Schubert func_convert_core_file_wine_to_w32 "$1" 3278*b50261e2SCy Schubert func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3279*b50261e2SCy Schubert func_to_host_file_result=$func_cygpath_result 3280*b50261e2SCy Schubert fi 3281*b50261e2SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3282*b50261e2SCy Schubert} 3283*b50261e2SCy Schubert# end func_convert_file_nix_to_cygwin 3284*b50261e2SCy Schubert 3285*b50261e2SCy Schubert 3286*b50261e2SCy Schubert############################################# 3287*b50261e2SCy Schubert# $build to $host PATH CONVERSION FUNCTIONS # 3288*b50261e2SCy Schubert############################################# 3289*b50261e2SCy Schubert# invoked via '$to_host_path_cmd ARG' 3290*b50261e2SCy Schubert# 3291*b50261e2SCy Schubert# In each case, ARG is the path to be converted from $build to $host format. 3292*b50261e2SCy Schubert# The result will be available in $func_to_host_path_result. 3293*b50261e2SCy Schubert# 3294*b50261e2SCy Schubert# Path separators are also converted from $build format to $host format. If 3295*b50261e2SCy Schubert# ARG begins or ends with a path separator character, it is preserved (but 3296*b50261e2SCy Schubert# converted to $host format) on output. 3297*b50261e2SCy Schubert# 3298*b50261e2SCy Schubert# All path conversion functions are named using the following convention: 3299*b50261e2SCy Schubert# file name conversion function : func_convert_file_X_to_Y () 3300*b50261e2SCy Schubert# path conversion function : func_convert_path_X_to_Y () 3301*b50261e2SCy Schubert# where, for any given $build/$host combination the 'X_to_Y' value is the 3302*b50261e2SCy Schubert# same. If conversion functions are added for new $build/$host combinations, 3303*b50261e2SCy Schubert# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3304*b50261e2SCy Schubert# will break. 3305*b50261e2SCy Schubert 3306*b50261e2SCy Schubert 3307*b50261e2SCy Schubert# func_init_to_host_path_cmd 3308*b50261e2SCy Schubert# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3309*b50261e2SCy Schubert# appropriate value, based on the value of $to_host_file_cmd. 3310*b50261e2SCy Schubertto_host_path_cmd= 3311*b50261e2SCy Schubertfunc_init_to_host_path_cmd () 3312*b50261e2SCy Schubert{ 3313*b50261e2SCy Schubert $debug_cmd 3314*b50261e2SCy Schubert 3315*b50261e2SCy Schubert if test -z "$to_host_path_cmd"; then 3316*b50261e2SCy Schubert func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3317*b50261e2SCy Schubert to_host_path_cmd=func_convert_path_$func_stripname_result 3318*b50261e2SCy Schubert fi 3319*b50261e2SCy Schubert} 3320*b50261e2SCy Schubert 3321*b50261e2SCy Schubert 3322*b50261e2SCy Schubert# func_to_host_path ARG 3323*b50261e2SCy Schubert# Converts the path ARG from $build format to $host format. Return result 3324*b50261e2SCy Schubert# in func_to_host_path_result. 3325*b50261e2SCy Schubertfunc_to_host_path () 3326*b50261e2SCy Schubert{ 3327*b50261e2SCy Schubert $debug_cmd 3328*b50261e2SCy Schubert 3329*b50261e2SCy Schubert func_init_to_host_path_cmd 3330*b50261e2SCy Schubert $to_host_path_cmd "$1" 3331*b50261e2SCy Schubert} 3332*b50261e2SCy Schubert# end func_to_host_path 3333*b50261e2SCy Schubert 3334*b50261e2SCy Schubert 3335*b50261e2SCy Schubert# func_convert_path_noop ARG 3336*b50261e2SCy Schubert# Copy ARG to func_to_host_path_result. 3337*b50261e2SCy Schubertfunc_convert_path_noop () 3338*b50261e2SCy Schubert{ 3339*b50261e2SCy Schubert func_to_host_path_result=$1 3340*b50261e2SCy Schubert} 3341*b50261e2SCy Schubert# end func_convert_path_noop 3342*b50261e2SCy Schubert 3343*b50261e2SCy Schubert 3344*b50261e2SCy Schubert# func_convert_path_msys_to_w32 ARG 3345*b50261e2SCy Schubert# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3346*b50261e2SCy Schubert# conversion to w32 is not available inside the cwrapper. Returns result in 3347*b50261e2SCy Schubert# func_to_host_path_result. 3348*b50261e2SCy Schubertfunc_convert_path_msys_to_w32 () 3349*b50261e2SCy Schubert{ 3350*b50261e2SCy Schubert $debug_cmd 3351*b50261e2SCy Schubert 3352*b50261e2SCy Schubert func_to_host_path_result=$1 3353*b50261e2SCy Schubert if test -n "$1"; then 3354*b50261e2SCy Schubert # Remove leading and trailing path separator characters from ARG. MSYS 3355*b50261e2SCy Schubert # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3356*b50261e2SCy Schubert # and winepath ignores them completely. 3357*b50261e2SCy Schubert func_stripname : : "$1" 3358*b50261e2SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3359*b50261e2SCy Schubert func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3360*b50261e2SCy Schubert func_to_host_path_result=$func_convert_core_msys_to_w32_result 3361*b50261e2SCy Schubert func_convert_path_check : ";" \ 3362*b50261e2SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3363*b50261e2SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3364*b50261e2SCy Schubert fi 3365*b50261e2SCy Schubert} 3366*b50261e2SCy Schubert# end func_convert_path_msys_to_w32 3367*b50261e2SCy Schubert 3368*b50261e2SCy Schubert 3369*b50261e2SCy Schubert# func_convert_path_cygwin_to_w32 ARG 3370*b50261e2SCy Schubert# Convert path ARG from Cygwin to w32 format. Returns result in 3371*b50261e2SCy Schubert# func_to_host_file_result. 3372*b50261e2SCy Schubertfunc_convert_path_cygwin_to_w32 () 3373*b50261e2SCy Schubert{ 3374*b50261e2SCy Schubert $debug_cmd 3375*b50261e2SCy Schubert 3376*b50261e2SCy Schubert func_to_host_path_result=$1 3377*b50261e2SCy Schubert if test -n "$1"; then 3378*b50261e2SCy Schubert # See func_convert_path_msys_to_w32: 3379*b50261e2SCy Schubert func_stripname : : "$1" 3380*b50261e2SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3381*b50261e2SCy Schubert func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3382*b50261e2SCy Schubert func_convert_path_check : ";" \ 3383*b50261e2SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3384*b50261e2SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3385*b50261e2SCy Schubert fi 3386*b50261e2SCy Schubert} 3387*b50261e2SCy Schubert# end func_convert_path_cygwin_to_w32 3388*b50261e2SCy Schubert 3389*b50261e2SCy Schubert 3390*b50261e2SCy Schubert# func_convert_path_nix_to_w32 ARG 3391*b50261e2SCy Schubert# Convert path ARG from *nix to w32 format. Requires a wine environment and 3392*b50261e2SCy Schubert# a working winepath. Returns result in func_to_host_file_result. 3393*b50261e2SCy Schubertfunc_convert_path_nix_to_w32 () 3394*b50261e2SCy Schubert{ 3395*b50261e2SCy Schubert $debug_cmd 3396*b50261e2SCy Schubert 3397*b50261e2SCy Schubert func_to_host_path_result=$1 3398*b50261e2SCy Schubert if test -n "$1"; then 3399*b50261e2SCy Schubert # See func_convert_path_msys_to_w32: 3400*b50261e2SCy Schubert func_stripname : : "$1" 3401*b50261e2SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3402*b50261e2SCy Schubert func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3403*b50261e2SCy Schubert func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3404*b50261e2SCy Schubert func_convert_path_check : ";" \ 3405*b50261e2SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3406*b50261e2SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3407*b50261e2SCy Schubert fi 3408*b50261e2SCy Schubert} 3409*b50261e2SCy Schubert# end func_convert_path_nix_to_w32 3410*b50261e2SCy Schubert 3411*b50261e2SCy Schubert 3412*b50261e2SCy Schubert# func_convert_path_msys_to_cygwin ARG 3413*b50261e2SCy Schubert# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3414*b50261e2SCy Schubert# Returns result in func_to_host_file_result. 3415*b50261e2SCy Schubertfunc_convert_path_msys_to_cygwin () 3416*b50261e2SCy Schubert{ 3417*b50261e2SCy Schubert $debug_cmd 3418*b50261e2SCy Schubert 3419*b50261e2SCy Schubert func_to_host_path_result=$1 3420*b50261e2SCy Schubert if test -n "$1"; then 3421*b50261e2SCy Schubert # See func_convert_path_msys_to_w32: 3422*b50261e2SCy Schubert func_stripname : : "$1" 3423*b50261e2SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3424*b50261e2SCy Schubert func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3425*b50261e2SCy Schubert func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3426*b50261e2SCy Schubert func_to_host_path_result=$func_cygpath_result 3427*b50261e2SCy Schubert func_convert_path_check : : \ 3428*b50261e2SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3429*b50261e2SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3430*b50261e2SCy Schubert fi 3431*b50261e2SCy Schubert} 3432*b50261e2SCy Schubert# end func_convert_path_msys_to_cygwin 3433*b50261e2SCy Schubert 3434*b50261e2SCy Schubert 3435*b50261e2SCy Schubert# func_convert_path_nix_to_cygwin ARG 3436*b50261e2SCy Schubert# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3437*b50261e2SCy Schubert# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3438*b50261e2SCy Schubert# func_to_host_file_result. 3439*b50261e2SCy Schubertfunc_convert_path_nix_to_cygwin () 3440*b50261e2SCy Schubert{ 3441*b50261e2SCy Schubert $debug_cmd 3442*b50261e2SCy Schubert 3443*b50261e2SCy Schubert func_to_host_path_result=$1 3444*b50261e2SCy Schubert if test -n "$1"; then 3445*b50261e2SCy Schubert # Remove leading and trailing path separator characters from 3446*b50261e2SCy Schubert # ARG. msys behavior is inconsistent here, cygpath turns them 3447*b50261e2SCy Schubert # into '.;' and ';.', and winepath ignores them completely. 3448*b50261e2SCy Schubert func_stripname : : "$1" 3449*b50261e2SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3450*b50261e2SCy Schubert func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3451*b50261e2SCy Schubert func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3452*b50261e2SCy Schubert func_to_host_path_result=$func_cygpath_result 3453*b50261e2SCy Schubert func_convert_path_check : : \ 3454*b50261e2SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3455*b50261e2SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3456*b50261e2SCy Schubert fi 3457*b50261e2SCy Schubert} 3458*b50261e2SCy Schubert# end func_convert_path_nix_to_cygwin 3459*b50261e2SCy Schubert 3460*b50261e2SCy Schubert 3461*b50261e2SCy Schubert# func_dll_def_p FILE 3462*b50261e2SCy Schubert# True iff FILE is a Windows DLL '.def' file. 3463*b50261e2SCy Schubert# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3464*b50261e2SCy Schubertfunc_dll_def_p () 3465*b50261e2SCy Schubert{ 3466*b50261e2SCy Schubert $debug_cmd 3467*b50261e2SCy Schubert 3468*b50261e2SCy Schubert func_dll_def_p_tmp=`$SED -n \ 3469*b50261e2SCy Schubert -e 's/^[ ]*//' \ 3470*b50261e2SCy Schubert -e '/^\(;.*\)*$/d' \ 3471*b50261e2SCy Schubert -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3472*b50261e2SCy Schubert -e q \ 3473*b50261e2SCy Schubert "$1"` 3474*b50261e2SCy Schubert test DEF = "$func_dll_def_p_tmp" 3475*b50261e2SCy Schubert} 3476*b50261e2SCy Schubert 3477*b50261e2SCy Schubert 3478*b50261e2SCy Schubert# func_mode_compile arg... 3479*b50261e2SCy Schubertfunc_mode_compile () 3480*b50261e2SCy Schubert{ 3481*b50261e2SCy Schubert $debug_cmd 3482*b50261e2SCy Schubert 3483*b50261e2SCy Schubert # Get the compilation command and the source file. 3484*b50261e2SCy Schubert base_compile= 3485*b50261e2SCy Schubert srcfile=$nonopt # always keep a non-empty value in "srcfile" 3486*b50261e2SCy Schubert suppress_opt=yes 3487*b50261e2SCy Schubert suppress_output= 3488*b50261e2SCy Schubert arg_mode=normal 3489*b50261e2SCy Schubert libobj= 3490*b50261e2SCy Schubert later= 3491*b50261e2SCy Schubert pie_flag= 3492*b50261e2SCy Schubert 3493*b50261e2SCy Schubert for arg 3494*b50261e2SCy Schubert do 3495*b50261e2SCy Schubert case $arg_mode in 3496*b50261e2SCy Schubert arg ) 3497*b50261e2SCy Schubert # do not "continue". Instead, add this to base_compile 3498*b50261e2SCy Schubert lastarg=$arg 3499*b50261e2SCy Schubert arg_mode=normal 3500*b50261e2SCy Schubert ;; 3501*b50261e2SCy Schubert 3502*b50261e2SCy Schubert target ) 3503*b50261e2SCy Schubert libobj=$arg 3504*b50261e2SCy Schubert arg_mode=normal 3505*b50261e2SCy Schubert continue 3506*b50261e2SCy Schubert ;; 3507*b50261e2SCy Schubert 3508*b50261e2SCy Schubert normal ) 3509*b50261e2SCy Schubert # Accept any command-line options. 3510*b50261e2SCy Schubert case $arg in 3511*b50261e2SCy Schubert -o) 3512*b50261e2SCy Schubert test -n "$libobj" && \ 3513*b50261e2SCy Schubert func_fatal_error "you cannot specify '-o' more than once" 3514*b50261e2SCy Schubert arg_mode=target 3515*b50261e2SCy Schubert continue 3516*b50261e2SCy Schubert ;; 3517*b50261e2SCy Schubert 3518*b50261e2SCy Schubert -pie | -fpie | -fPIE) 3519*b50261e2SCy Schubert func_append pie_flag " $arg" 3520*b50261e2SCy Schubert continue 3521*b50261e2SCy Schubert ;; 3522*b50261e2SCy Schubert 3523*b50261e2SCy Schubert -shared | -static | -prefer-pic | -prefer-non-pic) 3524*b50261e2SCy Schubert func_append later " $arg" 3525*b50261e2SCy Schubert continue 3526*b50261e2SCy Schubert ;; 3527*b50261e2SCy Schubert 3528*b50261e2SCy Schubert -no-suppress) 3529*b50261e2SCy Schubert suppress_opt=no 3530*b50261e2SCy Schubert continue 3531*b50261e2SCy Schubert ;; 3532*b50261e2SCy Schubert 3533*b50261e2SCy Schubert -Xcompiler) 3534*b50261e2SCy Schubert arg_mode=arg # the next one goes into the "base_compile" arg list 3535*b50261e2SCy Schubert continue # The current "srcfile" will either be retained or 3536*b50261e2SCy Schubert ;; # replaced later. I would guess that would be a bug. 3537*b50261e2SCy Schubert 3538*b50261e2SCy Schubert -Wc,*) 3539*b50261e2SCy Schubert func_stripname '-Wc,' '' "$arg" 3540*b50261e2SCy Schubert args=$func_stripname_result 3541*b50261e2SCy Schubert lastarg= 3542*b50261e2SCy Schubert save_ifs=$IFS; IFS=, 3543*b50261e2SCy Schubert for arg in $args; do 3544*b50261e2SCy Schubert IFS=$save_ifs 3545*b50261e2SCy Schubert func_append_quoted lastarg "$arg" 3546*b50261e2SCy Schubert done 3547*b50261e2SCy Schubert IFS=$save_ifs 3548*b50261e2SCy Schubert func_stripname ' ' '' "$lastarg" 3549*b50261e2SCy Schubert lastarg=$func_stripname_result 3550*b50261e2SCy Schubert 3551*b50261e2SCy Schubert # Add the arguments to base_compile. 3552*b50261e2SCy Schubert func_append base_compile " $lastarg" 3553*b50261e2SCy Schubert continue 3554*b50261e2SCy Schubert ;; 3555*b50261e2SCy Schubert 3556*b50261e2SCy Schubert *) 3557*b50261e2SCy Schubert # Accept the current argument as the source file. 3558*b50261e2SCy Schubert # The previous "srcfile" becomes the current argument. 3559*b50261e2SCy Schubert # 3560*b50261e2SCy Schubert lastarg=$srcfile 3561*b50261e2SCy Schubert srcfile=$arg 3562*b50261e2SCy Schubert ;; 3563*b50261e2SCy Schubert esac # case $arg 3564*b50261e2SCy Schubert ;; 3565*b50261e2SCy Schubert esac # case $arg_mode 3566*b50261e2SCy Schubert 3567*b50261e2SCy Schubert # Aesthetically quote the previous argument. 3568*b50261e2SCy Schubert func_append_quoted base_compile "$lastarg" 3569*b50261e2SCy Schubert done # for arg 3570*b50261e2SCy Schubert 3571*b50261e2SCy Schubert case $arg_mode in 3572*b50261e2SCy Schubert arg) 3573*b50261e2SCy Schubert func_fatal_error "you must specify an argument for -Xcompile" 3574*b50261e2SCy Schubert ;; 3575*b50261e2SCy Schubert target) 3576*b50261e2SCy Schubert func_fatal_error "you must specify a target with '-o'" 3577*b50261e2SCy Schubert ;; 3578*b50261e2SCy Schubert *) 3579*b50261e2SCy Schubert # Get the name of the library object. 3580*b50261e2SCy Schubert test -z "$libobj" && { 3581*b50261e2SCy Schubert func_basename "$srcfile" 3582*b50261e2SCy Schubert libobj=$func_basename_result 3583*b50261e2SCy Schubert } 3584*b50261e2SCy Schubert ;; 3585*b50261e2SCy Schubert esac 3586*b50261e2SCy Schubert 3587*b50261e2SCy Schubert # Recognize several different file suffixes. 3588*b50261e2SCy Schubert # If the user specifies -o file.o, it is replaced with file.lo 3589*b50261e2SCy Schubert case $libobj in 3590*b50261e2SCy Schubert *.[cCFSifmso] | \ 3591*b50261e2SCy Schubert *.ada | *.adb | *.ads | *.asm | \ 3592*b50261e2SCy Schubert *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3593*b50261e2SCy Schubert *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3594*b50261e2SCy Schubert func_xform "$libobj" 3595*b50261e2SCy Schubert libobj=$func_xform_result 3596*b50261e2SCy Schubert ;; 3597*b50261e2SCy Schubert esac 3598*b50261e2SCy Schubert 3599*b50261e2SCy Schubert case $libobj in 3600*b50261e2SCy Schubert *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3601*b50261e2SCy Schubert *) 3602*b50261e2SCy Schubert func_fatal_error "cannot determine name of library object from '$libobj'" 3603*b50261e2SCy Schubert ;; 3604*b50261e2SCy Schubert esac 3605*b50261e2SCy Schubert 3606*b50261e2SCy Schubert func_infer_tag $base_compile 3607*b50261e2SCy Schubert 3608*b50261e2SCy Schubert for arg in $later; do 3609*b50261e2SCy Schubert case $arg in 3610*b50261e2SCy Schubert -shared) 3611*b50261e2SCy Schubert test yes = "$build_libtool_libs" \ 3612*b50261e2SCy Schubert || func_fatal_configuration "cannot build a shared library" 3613*b50261e2SCy Schubert build_old_libs=no 3614*b50261e2SCy Schubert continue 3615*b50261e2SCy Schubert ;; 3616*b50261e2SCy Schubert 3617*b50261e2SCy Schubert -static) 3618*b50261e2SCy Schubert build_libtool_libs=no 3619*b50261e2SCy Schubert build_old_libs=yes 3620*b50261e2SCy Schubert continue 3621*b50261e2SCy Schubert ;; 3622*b50261e2SCy Schubert 3623*b50261e2SCy Schubert -prefer-pic) 3624*b50261e2SCy Schubert pic_mode=yes 3625*b50261e2SCy Schubert continue 3626*b50261e2SCy Schubert ;; 3627*b50261e2SCy Schubert 3628*b50261e2SCy Schubert -prefer-non-pic) 3629*b50261e2SCy Schubert pic_mode=no 3630*b50261e2SCy Schubert continue 3631*b50261e2SCy Schubert ;; 3632*b50261e2SCy Schubert esac 3633*b50261e2SCy Schubert done 3634*b50261e2SCy Schubert 3635*b50261e2SCy Schubert func_quote_arg pretty "$libobj" 3636*b50261e2SCy Schubert test "X$libobj" != "X$func_quote_arg_result" \ 3637*b50261e2SCy Schubert && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3638*b50261e2SCy Schubert && func_warning "libobj name '$libobj' may not contain shell special characters." 3639*b50261e2SCy Schubert func_dirname_and_basename "$obj" "/" "" 3640*b50261e2SCy Schubert objname=$func_basename_result 3641*b50261e2SCy Schubert xdir=$func_dirname_result 3642*b50261e2SCy Schubert lobj=$xdir$objdir/$objname 3643*b50261e2SCy Schubert 3644*b50261e2SCy Schubert test -z "$base_compile" && \ 3645*b50261e2SCy Schubert func_fatal_help "you must specify a compilation command" 3646*b50261e2SCy Schubert 3647*b50261e2SCy Schubert # Delete any leftover library objects. 3648*b50261e2SCy Schubert if test yes = "$build_old_libs"; then 3649*b50261e2SCy Schubert removelist="$obj $lobj $libobj ${libobj}T" 3650*b50261e2SCy Schubert else 3651*b50261e2SCy Schubert removelist="$lobj $libobj ${libobj}T" 3652*b50261e2SCy Schubert fi 3653*b50261e2SCy Schubert 3654*b50261e2SCy Schubert # On Cygwin there's no "real" PIC flag so we must build both object types 3655*b50261e2SCy Schubert case $host_os in 3656*b50261e2SCy Schubert cygwin* | mingw* | pw32* | os2* | cegcc*) 3657*b50261e2SCy Schubert pic_mode=default 3658*b50261e2SCy Schubert ;; 3659*b50261e2SCy Schubert esac 3660*b50261e2SCy Schubert if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3661*b50261e2SCy Schubert # non-PIC code in shared libraries is not supported 3662*b50261e2SCy Schubert pic_mode=default 3663*b50261e2SCy Schubert fi 3664*b50261e2SCy Schubert 3665*b50261e2SCy Schubert # Calculate the filename of the output object if compiler does 3666*b50261e2SCy Schubert # not support -o with -c 3667*b50261e2SCy Schubert if test no = "$compiler_c_o"; then 3668*b50261e2SCy Schubert output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3669*b50261e2SCy Schubert lockfile=$output_obj.lock 3670*b50261e2SCy Schubert else 3671*b50261e2SCy Schubert output_obj= 3672*b50261e2SCy Schubert need_locks=no 3673*b50261e2SCy Schubert lockfile= 3674*b50261e2SCy Schubert fi 3675*b50261e2SCy Schubert 3676*b50261e2SCy Schubert # Lock this critical section if it is needed 3677*b50261e2SCy Schubert # We use this script file to make the link, it avoids creating a new file 3678*b50261e2SCy Schubert if test yes = "$need_locks"; then 3679*b50261e2SCy Schubert until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3680*b50261e2SCy Schubert func_echo "Waiting for $lockfile to be removed" 3681*b50261e2SCy Schubert sleep 2 3682*b50261e2SCy Schubert done 3683*b50261e2SCy Schubert elif test warn = "$need_locks"; then 3684*b50261e2SCy Schubert if test -f "$lockfile"; then 3685*b50261e2SCy Schubert $ECHO "\ 3686*b50261e2SCy Schubert*** ERROR, $lockfile exists and contains: 3687*b50261e2SCy Schubert`cat $lockfile 2>/dev/null` 3688*b50261e2SCy Schubert 3689*b50261e2SCy SchubertThis indicates that another process is trying to use the same 3690*b50261e2SCy Schuberttemporary object file, and libtool could not work around it because 3691*b50261e2SCy Schubertyour compiler does not support '-c' and '-o' together. If you 3692*b50261e2SCy Schubertrepeat this compilation, it may succeed, by chance, but you had better 3693*b50261e2SCy Schubertavoid parallel builds (make -j) in this platform, or get a better 3694*b50261e2SCy Schubertcompiler." 3695*b50261e2SCy Schubert 3696*b50261e2SCy Schubert $opt_dry_run || $RM $removelist 3697*b50261e2SCy Schubert exit $EXIT_FAILURE 3698*b50261e2SCy Schubert fi 3699*b50261e2SCy Schubert func_append removelist " $output_obj" 3700*b50261e2SCy Schubert $ECHO "$srcfile" > "$lockfile" 3701*b50261e2SCy Schubert fi 3702*b50261e2SCy Schubert 3703*b50261e2SCy Schubert $opt_dry_run || $RM $removelist 3704*b50261e2SCy Schubert func_append removelist " $lockfile" 3705*b50261e2SCy Schubert trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3706*b50261e2SCy Schubert 3707*b50261e2SCy Schubert func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3708*b50261e2SCy Schubert srcfile=$func_to_tool_file_result 3709*b50261e2SCy Schubert func_quote_arg pretty "$srcfile" 3710*b50261e2SCy Schubert qsrcfile=$func_quote_arg_result 3711*b50261e2SCy Schubert 3712*b50261e2SCy Schubert # Only build a PIC object if we are building libtool libraries. 3713*b50261e2SCy Schubert if test yes = "$build_libtool_libs"; then 3714*b50261e2SCy Schubert # Without this assignment, base_compile gets emptied. 3715*b50261e2SCy Schubert fbsd_hideous_sh_bug=$base_compile 3716*b50261e2SCy Schubert 3717*b50261e2SCy Schubert if test no != "$pic_mode"; then 3718*b50261e2SCy Schubert command="$base_compile $qsrcfile $pic_flag" 3719*b50261e2SCy Schubert else 3720*b50261e2SCy Schubert # Don't build PIC code 3721*b50261e2SCy Schubert command="$base_compile $qsrcfile" 3722*b50261e2SCy Schubert fi 3723*b50261e2SCy Schubert 3724*b50261e2SCy Schubert func_mkdir_p "$xdir$objdir" 3725*b50261e2SCy Schubert 3726*b50261e2SCy Schubert if test -z "$output_obj"; then 3727*b50261e2SCy Schubert # Place PIC objects in $objdir 3728*b50261e2SCy Schubert func_append command " -o $lobj" 3729*b50261e2SCy Schubert fi 3730*b50261e2SCy Schubert 3731*b50261e2SCy Schubert func_show_eval_locale "$command" \ 3732*b50261e2SCy Schubert 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3733*b50261e2SCy Schubert 3734*b50261e2SCy Schubert if test warn = "$need_locks" && 3735*b50261e2SCy Schubert test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3736*b50261e2SCy Schubert $ECHO "\ 3737*b50261e2SCy Schubert*** ERROR, $lockfile contains: 3738*b50261e2SCy Schubert`cat $lockfile 2>/dev/null` 3739*b50261e2SCy Schubert 3740*b50261e2SCy Schubertbut it should contain: 3741*b50261e2SCy Schubert$srcfile 3742*b50261e2SCy Schubert 3743*b50261e2SCy SchubertThis indicates that another process is trying to use the same 3744*b50261e2SCy Schuberttemporary object file, and libtool could not work around it because 3745*b50261e2SCy Schubertyour compiler does not support '-c' and '-o' together. If you 3746*b50261e2SCy Schubertrepeat this compilation, it may succeed, by chance, but you had better 3747*b50261e2SCy Schubertavoid parallel builds (make -j) in this platform, or get a better 3748*b50261e2SCy Schubertcompiler." 3749*b50261e2SCy Schubert 3750*b50261e2SCy Schubert $opt_dry_run || $RM $removelist 3751*b50261e2SCy Schubert exit $EXIT_FAILURE 3752*b50261e2SCy Schubert fi 3753*b50261e2SCy Schubert 3754*b50261e2SCy Schubert # Just move the object if needed, then go on to compile the next one 3755*b50261e2SCy Schubert if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3756*b50261e2SCy Schubert func_show_eval '$MV "$output_obj" "$lobj"' \ 3757*b50261e2SCy Schubert 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3758*b50261e2SCy Schubert fi 3759*b50261e2SCy Schubert 3760*b50261e2SCy Schubert # Allow error messages only from the first compilation. 3761*b50261e2SCy Schubert if test yes = "$suppress_opt"; then 3762*b50261e2SCy Schubert suppress_output=' >/dev/null 2>&1' 3763*b50261e2SCy Schubert fi 3764*b50261e2SCy Schubert fi 3765*b50261e2SCy Schubert 3766*b50261e2SCy Schubert # Only build a position-dependent object if we build old libraries. 3767*b50261e2SCy Schubert if test yes = "$build_old_libs"; then 3768*b50261e2SCy Schubert if test yes != "$pic_mode"; then 3769*b50261e2SCy Schubert # Don't build PIC code 3770*b50261e2SCy Schubert command="$base_compile $qsrcfile$pie_flag" 3771*b50261e2SCy Schubert else 3772*b50261e2SCy Schubert command="$base_compile $qsrcfile $pic_flag" 3773*b50261e2SCy Schubert fi 3774*b50261e2SCy Schubert if test yes = "$compiler_c_o"; then 3775*b50261e2SCy Schubert func_append command " -o $obj" 3776*b50261e2SCy Schubert fi 3777*b50261e2SCy Schubert 3778*b50261e2SCy Schubert # Suppress compiler output if we already did a PIC compilation. 3779*b50261e2SCy Schubert func_append command "$suppress_output" 3780*b50261e2SCy Schubert func_show_eval_locale "$command" \ 3781*b50261e2SCy Schubert '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3782*b50261e2SCy Schubert 3783*b50261e2SCy Schubert if test warn = "$need_locks" && 3784*b50261e2SCy Schubert test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3785*b50261e2SCy Schubert $ECHO "\ 3786*b50261e2SCy Schubert*** ERROR, $lockfile contains: 3787*b50261e2SCy Schubert`cat $lockfile 2>/dev/null` 3788*b50261e2SCy Schubert 3789*b50261e2SCy Schubertbut it should contain: 3790*b50261e2SCy Schubert$srcfile 3791*b50261e2SCy Schubert 3792*b50261e2SCy SchubertThis indicates that another process is trying to use the same 3793*b50261e2SCy Schuberttemporary object file, and libtool could not work around it because 3794*b50261e2SCy Schubertyour compiler does not support '-c' and '-o' together. If you 3795*b50261e2SCy Schubertrepeat this compilation, it may succeed, by chance, but you had better 3796*b50261e2SCy Schubertavoid parallel builds (make -j) in this platform, or get a better 3797*b50261e2SCy Schubertcompiler." 3798*b50261e2SCy Schubert 3799*b50261e2SCy Schubert $opt_dry_run || $RM $removelist 3800*b50261e2SCy Schubert exit $EXIT_FAILURE 3801*b50261e2SCy Schubert fi 3802*b50261e2SCy Schubert 3803*b50261e2SCy Schubert # Just move the object if needed 3804*b50261e2SCy Schubert if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3805*b50261e2SCy Schubert func_show_eval '$MV "$output_obj" "$obj"' \ 3806*b50261e2SCy Schubert 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3807*b50261e2SCy Schubert fi 3808*b50261e2SCy Schubert fi 3809*b50261e2SCy Schubert 3810*b50261e2SCy Schubert $opt_dry_run || { 3811*b50261e2SCy Schubert func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3812*b50261e2SCy Schubert 3813*b50261e2SCy Schubert # Unlock the critical section if it was locked 3814*b50261e2SCy Schubert if test no != "$need_locks"; then 3815*b50261e2SCy Schubert removelist=$lockfile 3816*b50261e2SCy Schubert $RM "$lockfile" 3817*b50261e2SCy Schubert fi 3818*b50261e2SCy Schubert } 3819*b50261e2SCy Schubert 3820*b50261e2SCy Schubert exit $EXIT_SUCCESS 3821*b50261e2SCy Schubert} 3822*b50261e2SCy Schubert 3823*b50261e2SCy Schubert$opt_help || { 3824*b50261e2SCy Schubert test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3825*b50261e2SCy Schubert} 3826*b50261e2SCy Schubert 3827*b50261e2SCy Schubertfunc_mode_help () 3828*b50261e2SCy Schubert{ 3829*b50261e2SCy Schubert # We need to display help for each of the modes. 3830*b50261e2SCy Schubert case $opt_mode in 3831*b50261e2SCy Schubert "") 3832*b50261e2SCy Schubert # Generic help is extracted from the usage comments 3833*b50261e2SCy Schubert # at the start of this file. 3834*b50261e2SCy Schubert func_help 3835*b50261e2SCy Schubert ;; 3836*b50261e2SCy Schubert 3837*b50261e2SCy Schubert clean) 3838*b50261e2SCy Schubert $ECHO \ 3839*b50261e2SCy Schubert"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3840*b50261e2SCy Schubert 3841*b50261e2SCy SchubertRemove files from the build directory. 3842*b50261e2SCy Schubert 3843*b50261e2SCy SchubertRM is the name of the program to use to delete files associated with each FILE 3844*b50261e2SCy Schubert(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3845*b50261e2SCy Schubertto RM. 3846*b50261e2SCy Schubert 3847*b50261e2SCy SchubertIf FILE is a libtool library, object or program, all the files associated 3848*b50261e2SCy Schubertwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3849*b50261e2SCy Schubert ;; 3850*b50261e2SCy Schubert 3851*b50261e2SCy Schubert compile) 3852*b50261e2SCy Schubert $ECHO \ 3853*b50261e2SCy Schubert"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3854*b50261e2SCy Schubert 3855*b50261e2SCy SchubertCompile a source file into a libtool library object. 3856*b50261e2SCy Schubert 3857*b50261e2SCy SchubertThis mode accepts the following additional options: 3858*b50261e2SCy Schubert 3859*b50261e2SCy Schubert -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3860*b50261e2SCy Schubert -no-suppress do not suppress compiler output for multiple passes 3861*b50261e2SCy Schubert -prefer-pic try to build PIC objects only 3862*b50261e2SCy Schubert -prefer-non-pic try to build non-PIC objects only 3863*b50261e2SCy Schubert -shared do not build a '.o' file suitable for static linking 3864*b50261e2SCy Schubert -static only build a '.o' file suitable for static linking 3865*b50261e2SCy Schubert -Wc,FLAG pass FLAG directly to the compiler 3866*b50261e2SCy Schubert 3867*b50261e2SCy SchubertCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3868*b50261e2SCy Schubertfrom the given SOURCEFILE. 3869*b50261e2SCy Schubert 3870*b50261e2SCy SchubertThe output file name is determined by removing the directory component from 3871*b50261e2SCy SchubertSOURCEFILE, then substituting the C source code suffix '.c' with the 3872*b50261e2SCy Schubertlibrary object suffix, '.lo'." 3873*b50261e2SCy Schubert ;; 3874*b50261e2SCy Schubert 3875*b50261e2SCy Schubert execute) 3876*b50261e2SCy Schubert $ECHO \ 3877*b50261e2SCy Schubert"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3878*b50261e2SCy Schubert 3879*b50261e2SCy SchubertAutomatically set library path, then run a program. 3880*b50261e2SCy Schubert 3881*b50261e2SCy SchubertThis mode accepts the following additional options: 3882*b50261e2SCy Schubert 3883*b50261e2SCy Schubert -dlopen FILE add the directory containing FILE to the library path 3884*b50261e2SCy Schubert 3885*b50261e2SCy SchubertThis mode sets the library path environment variable according to '-dlopen' 3886*b50261e2SCy Schubertflags. 3887*b50261e2SCy Schubert 3888*b50261e2SCy SchubertIf any of the ARGS are libtool executable wrappers, then they are translated 3889*b50261e2SCy Schubertinto their corresponding uninstalled binary, and any of their required library 3890*b50261e2SCy Schubertdirectories are added to the library path. 3891*b50261e2SCy Schubert 3892*b50261e2SCy SchubertThen, COMMAND is executed, with ARGS as arguments." 3893*b50261e2SCy Schubert ;; 3894*b50261e2SCy Schubert 3895*b50261e2SCy Schubert finish) 3896*b50261e2SCy Schubert $ECHO \ 3897*b50261e2SCy Schubert"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3898*b50261e2SCy Schubert 3899*b50261e2SCy SchubertComplete the installation of libtool libraries. 3900*b50261e2SCy Schubert 3901*b50261e2SCy SchubertEach LIBDIR is a directory that contains libtool libraries. 3902*b50261e2SCy Schubert 3903*b50261e2SCy SchubertThe commands that this mode executes may require superuser privileges. Use 3904*b50261e2SCy Schubertthe '--dry-run' option if you just want to see what would be executed." 3905*b50261e2SCy Schubert ;; 3906*b50261e2SCy Schubert 3907*b50261e2SCy Schubert install) 3908*b50261e2SCy Schubert $ECHO \ 3909*b50261e2SCy Schubert"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3910*b50261e2SCy Schubert 3911*b50261e2SCy SchubertInstall executables or libraries. 3912*b50261e2SCy Schubert 3913*b50261e2SCy SchubertINSTALL-COMMAND is the installation command. The first component should be 3914*b50261e2SCy Schuberteither the 'install' or 'cp' program. 3915*b50261e2SCy Schubert 3916*b50261e2SCy SchubertThe following components of INSTALL-COMMAND are treated specially: 3917*b50261e2SCy Schubert 3918*b50261e2SCy Schubert -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3919*b50261e2SCy Schubert 3920*b50261e2SCy SchubertThe rest of the components are interpreted as arguments to that command (only 3921*b50261e2SCy SchubertBSD-compatible install options are recognized)." 3922*b50261e2SCy Schubert ;; 3923*b50261e2SCy Schubert 3924*b50261e2SCy Schubert link) 3925*b50261e2SCy Schubert $ECHO \ 3926*b50261e2SCy Schubert"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3927*b50261e2SCy Schubert 3928*b50261e2SCy SchubertLink object files or libraries together to form another library, or to 3929*b50261e2SCy Schubertcreate an executable program. 3930*b50261e2SCy Schubert 3931*b50261e2SCy SchubertLINK-COMMAND is a command using the C compiler that you would use to create 3932*b50261e2SCy Schuberta program from several object files. 3933*b50261e2SCy Schubert 3934*b50261e2SCy SchubertThe following components of LINK-COMMAND are treated specially: 3935*b50261e2SCy Schubert 3936*b50261e2SCy Schubert -all-static do not do any dynamic linking at all 3937*b50261e2SCy Schubert -avoid-version do not add a version suffix if possible 3938*b50261e2SCy Schubert -bindir BINDIR specify path to binaries directory (for systems where 3939*b50261e2SCy Schubert libraries must be found in the PATH setting at runtime) 3940*b50261e2SCy Schubert -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3941*b50261e2SCy Schubert -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3942*b50261e2SCy Schubert -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3943*b50261e2SCy Schubert -export-symbols SYMFILE 3944*b50261e2SCy Schubert try to export only the symbols listed in SYMFILE 3945*b50261e2SCy Schubert -export-symbols-regex REGEX 3946*b50261e2SCy Schubert try to export only the symbols matching REGEX 3947*b50261e2SCy Schubert -LLIBDIR search LIBDIR for required installed libraries 3948*b50261e2SCy Schubert -lNAME OUTPUT-FILE requires the installed library libNAME 3949*b50261e2SCy Schubert -module build a library that can dlopened 3950*b50261e2SCy Schubert -no-fast-install disable the fast-install mode 3951*b50261e2SCy Schubert -no-install link a not-installable executable 3952*b50261e2SCy Schubert -no-undefined declare that a library does not refer to external symbols 3953*b50261e2SCy Schubert -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3954*b50261e2SCy Schubert -objectlist FILE use a list of object files found in FILE to specify objects 3955*b50261e2SCy Schubert -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3956*b50261e2SCy Schubert -precious-files-regex REGEX 3957*b50261e2SCy Schubert don't remove output files matching REGEX 3958*b50261e2SCy Schubert -release RELEASE specify package release information 3959*b50261e2SCy Schubert -rpath LIBDIR the created library will eventually be installed in LIBDIR 3960*b50261e2SCy Schubert -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3961*b50261e2SCy Schubert -shared only do dynamic linking of libtool libraries 3962*b50261e2SCy Schubert -shrext SUFFIX override the standard shared library file extension 3963*b50261e2SCy Schubert -static do not do any dynamic linking of uninstalled libtool libraries 3964*b50261e2SCy Schubert -static-libtool-libs 3965*b50261e2SCy Schubert do not do any dynamic linking of libtool libraries 3966*b50261e2SCy Schubert -version-info CURRENT[:REVISION[:AGE]] 3967*b50261e2SCy Schubert specify library version info [each variable defaults to 0] 3968*b50261e2SCy Schubert -weak LIBNAME declare that the target provides the LIBNAME interface 3969*b50261e2SCy Schubert -Wc,FLAG 3970*b50261e2SCy Schubert -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3971*b50261e2SCy Schubert -Wl,FLAG 3972*b50261e2SCy Schubert -Xlinker FLAG pass linker-specific FLAG directly to the linker 3973*b50261e2SCy Schubert -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3974*b50261e2SCy Schubert 3975*b50261e2SCy SchubertAll other options (arguments beginning with '-') are ignored. 3976*b50261e2SCy Schubert 3977*b50261e2SCy SchubertEvery other argument is treated as a filename. Files ending in '.la' are 3978*b50261e2SCy Schuberttreated as uninstalled libtool libraries, other files are standard or library 3979*b50261e2SCy Schubertobject files. 3980*b50261e2SCy Schubert 3981*b50261e2SCy SchubertIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3982*b50261e2SCy Schubertonly library objects ('.lo' files) may be specified, and '-rpath' is 3983*b50261e2SCy Schubertrequired, except when creating a convenience library. 3984*b50261e2SCy Schubert 3985*b50261e2SCy SchubertIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3986*b50261e2SCy Schubertusing 'ar' and 'ranlib', or on Windows using 'lib'. 3987*b50261e2SCy Schubert 3988*b50261e2SCy SchubertIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3989*b50261e2SCy Schubertis created, otherwise an executable program is created." 3990*b50261e2SCy Schubert ;; 3991*b50261e2SCy Schubert 3992*b50261e2SCy Schubert uninstall) 3993*b50261e2SCy Schubert $ECHO \ 3994*b50261e2SCy Schubert"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3995*b50261e2SCy Schubert 3996*b50261e2SCy SchubertRemove libraries from an installation directory. 3997*b50261e2SCy Schubert 3998*b50261e2SCy SchubertRM is the name of the program to use to delete files associated with each FILE 3999*b50261e2SCy Schubert(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4000*b50261e2SCy Schubertto RM. 4001*b50261e2SCy Schubert 4002*b50261e2SCy SchubertIf FILE is a libtool library, all the files associated with it are deleted. 4003*b50261e2SCy SchubertOtherwise, only FILE itself is deleted using RM." 4004*b50261e2SCy Schubert ;; 4005*b50261e2SCy Schubert 4006*b50261e2SCy Schubert *) 4007*b50261e2SCy Schubert func_fatal_help "invalid operation mode '$opt_mode'" 4008*b50261e2SCy Schubert ;; 4009*b50261e2SCy Schubert esac 4010*b50261e2SCy Schubert 4011*b50261e2SCy Schubert echo 4012*b50261e2SCy Schubert $ECHO "Try '$progname --help' for more information about other modes." 4013*b50261e2SCy Schubert} 4014*b50261e2SCy Schubert 4015*b50261e2SCy Schubert# Now that we've collected a possible --mode arg, show help if necessary 4016*b50261e2SCy Schubertif $opt_help; then 4017*b50261e2SCy Schubert if test : = "$opt_help"; then 4018*b50261e2SCy Schubert func_mode_help 4019*b50261e2SCy Schubert else 4020*b50261e2SCy Schubert { 4021*b50261e2SCy Schubert func_help noexit 4022*b50261e2SCy Schubert for opt_mode in compile link execute install finish uninstall clean; do 4023*b50261e2SCy Schubert func_mode_help 4024*b50261e2SCy Schubert done 4025*b50261e2SCy Schubert } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4026*b50261e2SCy Schubert { 4027*b50261e2SCy Schubert func_help noexit 4028*b50261e2SCy Schubert for opt_mode in compile link execute install finish uninstall clean; do 4029*b50261e2SCy Schubert echo 4030*b50261e2SCy Schubert func_mode_help 4031*b50261e2SCy Schubert done 4032*b50261e2SCy Schubert } | 4033*b50261e2SCy Schubert $SED '1d 4034*b50261e2SCy Schubert /^When reporting/,/^Report/{ 4035*b50261e2SCy Schubert H 4036*b50261e2SCy Schubert d 4037*b50261e2SCy Schubert } 4038*b50261e2SCy Schubert $x 4039*b50261e2SCy Schubert /information about other modes/d 4040*b50261e2SCy Schubert /more detailed .*MODE/d 4041*b50261e2SCy Schubert s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4042*b50261e2SCy Schubert fi 4043*b50261e2SCy Schubert exit $? 4044*b50261e2SCy Schubertfi 4045*b50261e2SCy Schubert 4046*b50261e2SCy Schubert 4047*b50261e2SCy Schubert# func_mode_execute arg... 4048*b50261e2SCy Schubertfunc_mode_execute () 4049*b50261e2SCy Schubert{ 4050*b50261e2SCy Schubert $debug_cmd 4051*b50261e2SCy Schubert 4052*b50261e2SCy Schubert # The first argument is the command name. 4053*b50261e2SCy Schubert cmd=$nonopt 4054*b50261e2SCy Schubert test -z "$cmd" && \ 4055*b50261e2SCy Schubert func_fatal_help "you must specify a COMMAND" 4056*b50261e2SCy Schubert 4057*b50261e2SCy Schubert # Handle -dlopen flags immediately. 4058*b50261e2SCy Schubert for file in $opt_dlopen; do 4059*b50261e2SCy Schubert test -f "$file" \ 4060*b50261e2SCy Schubert || func_fatal_help "'$file' is not a file" 4061*b50261e2SCy Schubert 4062*b50261e2SCy Schubert dir= 4063*b50261e2SCy Schubert case $file in 4064*b50261e2SCy Schubert *.la) 4065*b50261e2SCy Schubert func_resolve_sysroot "$file" 4066*b50261e2SCy Schubert file=$func_resolve_sysroot_result 4067*b50261e2SCy Schubert 4068*b50261e2SCy Schubert # Check to see that this really is a libtool archive. 4069*b50261e2SCy Schubert func_lalib_unsafe_p "$file" \ 4070*b50261e2SCy Schubert || func_fatal_help "'$lib' is not a valid libtool archive" 4071*b50261e2SCy Schubert 4072*b50261e2SCy Schubert # Read the libtool library. 4073*b50261e2SCy Schubert dlname= 4074*b50261e2SCy Schubert library_names= 4075*b50261e2SCy Schubert func_source "$file" 4076*b50261e2SCy Schubert 4077*b50261e2SCy Schubert # Skip this library if it cannot be dlopened. 4078*b50261e2SCy Schubert if test -z "$dlname"; then 4079*b50261e2SCy Schubert # Warn if it was a shared library. 4080*b50261e2SCy Schubert test -n "$library_names" && \ 4081*b50261e2SCy Schubert func_warning "'$file' was not linked with '-export-dynamic'" 4082*b50261e2SCy Schubert continue 4083*b50261e2SCy Schubert fi 4084*b50261e2SCy Schubert 4085*b50261e2SCy Schubert func_dirname "$file" "" "." 4086*b50261e2SCy Schubert dir=$func_dirname_result 4087*b50261e2SCy Schubert 4088*b50261e2SCy Schubert if test -f "$dir/$objdir/$dlname"; then 4089*b50261e2SCy Schubert func_append dir "/$objdir" 4090*b50261e2SCy Schubert else 4091*b50261e2SCy Schubert if test ! -f "$dir/$dlname"; then 4092*b50261e2SCy Schubert func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4093*b50261e2SCy Schubert fi 4094*b50261e2SCy Schubert fi 4095*b50261e2SCy Schubert ;; 4096*b50261e2SCy Schubert 4097*b50261e2SCy Schubert *.lo) 4098*b50261e2SCy Schubert # Just add the directory containing the .lo file. 4099*b50261e2SCy Schubert func_dirname "$file" "" "." 4100*b50261e2SCy Schubert dir=$func_dirname_result 4101*b50261e2SCy Schubert ;; 4102*b50261e2SCy Schubert 4103*b50261e2SCy Schubert *) 4104*b50261e2SCy Schubert func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4105*b50261e2SCy Schubert continue 4106*b50261e2SCy Schubert ;; 4107*b50261e2SCy Schubert esac 4108*b50261e2SCy Schubert 4109*b50261e2SCy Schubert # Get the absolute pathname. 4110*b50261e2SCy Schubert absdir=`cd "$dir" && pwd` 4111*b50261e2SCy Schubert test -n "$absdir" && dir=$absdir 4112*b50261e2SCy Schubert 4113*b50261e2SCy Schubert # Now add the directory to shlibpath_var. 4114*b50261e2SCy Schubert if eval "test -z \"\$$shlibpath_var\""; then 4115*b50261e2SCy Schubert eval "$shlibpath_var=\"\$dir\"" 4116*b50261e2SCy Schubert else 4117*b50261e2SCy Schubert eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4118*b50261e2SCy Schubert fi 4119*b50261e2SCy Schubert done 4120*b50261e2SCy Schubert 4121*b50261e2SCy Schubert # This variable tells wrapper scripts just to set shlibpath_var 4122*b50261e2SCy Schubert # rather than running their programs. 4123*b50261e2SCy Schubert libtool_execute_magic=$magic 4124*b50261e2SCy Schubert 4125*b50261e2SCy Schubert # Check if any of the arguments is a wrapper script. 4126*b50261e2SCy Schubert args= 4127*b50261e2SCy Schubert for file 4128*b50261e2SCy Schubert do 4129*b50261e2SCy Schubert case $file in 4130*b50261e2SCy Schubert -* | *.la | *.lo ) ;; 4131*b50261e2SCy Schubert *) 4132*b50261e2SCy Schubert # Do a test to see if this is really a libtool program. 4133*b50261e2SCy Schubert if func_ltwrapper_script_p "$file"; then 4134*b50261e2SCy Schubert func_source "$file" 4135*b50261e2SCy Schubert # Transform arg to wrapped name. 4136*b50261e2SCy Schubert file=$progdir/$program 4137*b50261e2SCy Schubert elif func_ltwrapper_executable_p "$file"; then 4138*b50261e2SCy Schubert func_ltwrapper_scriptname "$file" 4139*b50261e2SCy Schubert func_source "$func_ltwrapper_scriptname_result" 4140*b50261e2SCy Schubert # Transform arg to wrapped name. 4141*b50261e2SCy Schubert file=$progdir/$program 4142*b50261e2SCy Schubert fi 4143*b50261e2SCy Schubert ;; 4144*b50261e2SCy Schubert esac 4145*b50261e2SCy Schubert # Quote arguments (to preserve shell metacharacters). 4146*b50261e2SCy Schubert func_append_quoted args "$file" 4147*b50261e2SCy Schubert done 4148*b50261e2SCy Schubert 4149*b50261e2SCy Schubert if $opt_dry_run; then 4150*b50261e2SCy Schubert # Display what would be done. 4151*b50261e2SCy Schubert if test -n "$shlibpath_var"; then 4152*b50261e2SCy Schubert eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4153*b50261e2SCy Schubert echo "export $shlibpath_var" 4154*b50261e2SCy Schubert fi 4155*b50261e2SCy Schubert $ECHO "$cmd$args" 4156*b50261e2SCy Schubert exit $EXIT_SUCCESS 4157*b50261e2SCy Schubert else 4158*b50261e2SCy Schubert if test -n "$shlibpath_var"; then 4159*b50261e2SCy Schubert # Export the shlibpath_var. 4160*b50261e2SCy Schubert eval "export $shlibpath_var" 4161*b50261e2SCy Schubert fi 4162*b50261e2SCy Schubert 4163*b50261e2SCy Schubert # Restore saved environment variables 4164*b50261e2SCy Schubert for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4165*b50261e2SCy Schubert do 4166*b50261e2SCy Schubert eval "if test \"\${save_$lt_var+set}\" = set; then 4167*b50261e2SCy Schubert $lt_var=\$save_$lt_var; export $lt_var 4168*b50261e2SCy Schubert else 4169*b50261e2SCy Schubert $lt_unset $lt_var 4170*b50261e2SCy Schubert fi" 4171*b50261e2SCy Schubert done 4172*b50261e2SCy Schubert 4173*b50261e2SCy Schubert # Now prepare to actually exec the command. 4174*b50261e2SCy Schubert exec_cmd=\$cmd$args 4175*b50261e2SCy Schubert fi 4176*b50261e2SCy Schubert} 4177*b50261e2SCy Schubert 4178*b50261e2SCy Schuberttest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4179*b50261e2SCy Schubert 4180*b50261e2SCy Schubert 4181*b50261e2SCy Schubert# func_mode_finish arg... 4182*b50261e2SCy Schubertfunc_mode_finish () 4183*b50261e2SCy Schubert{ 4184*b50261e2SCy Schubert $debug_cmd 4185*b50261e2SCy Schubert 4186*b50261e2SCy Schubert libs= 4187*b50261e2SCy Schubert libdirs= 4188*b50261e2SCy Schubert admincmds= 4189*b50261e2SCy Schubert 4190*b50261e2SCy Schubert for opt in "$nonopt" ${1+"$@"} 4191*b50261e2SCy Schubert do 4192*b50261e2SCy Schubert if test -d "$opt"; then 4193*b50261e2SCy Schubert func_append libdirs " $opt" 4194*b50261e2SCy Schubert 4195*b50261e2SCy Schubert elif test -f "$opt"; then 4196*b50261e2SCy Schubert if func_lalib_unsafe_p "$opt"; then 4197*b50261e2SCy Schubert func_append libs " $opt" 4198*b50261e2SCy Schubert else 4199*b50261e2SCy Schubert func_warning "'$opt' is not a valid libtool archive" 4200*b50261e2SCy Schubert fi 4201*b50261e2SCy Schubert 4202*b50261e2SCy Schubert else 4203*b50261e2SCy Schubert func_fatal_error "invalid argument '$opt'" 4204*b50261e2SCy Schubert fi 4205*b50261e2SCy Schubert done 4206*b50261e2SCy Schubert 4207*b50261e2SCy Schubert if test -n "$libs"; then 4208*b50261e2SCy Schubert if test -n "$lt_sysroot"; then 4209*b50261e2SCy Schubert sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4210*b50261e2SCy Schubert sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4211*b50261e2SCy Schubert else 4212*b50261e2SCy Schubert sysroot_cmd= 4213*b50261e2SCy Schubert fi 4214*b50261e2SCy Schubert 4215*b50261e2SCy Schubert # Remove sysroot references 4216*b50261e2SCy Schubert if $opt_dry_run; then 4217*b50261e2SCy Schubert for lib in $libs; do 4218*b50261e2SCy Schubert echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4219*b50261e2SCy Schubert done 4220*b50261e2SCy Schubert else 4221*b50261e2SCy Schubert tmpdir=`func_mktempdir` 4222*b50261e2SCy Schubert for lib in $libs; do 4223*b50261e2SCy Schubert $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4224*b50261e2SCy Schubert > $tmpdir/tmp-la 4225*b50261e2SCy Schubert mv -f $tmpdir/tmp-la $lib 4226*b50261e2SCy Schubert done 4227*b50261e2SCy Schubert ${RM}r "$tmpdir" 4228*b50261e2SCy Schubert fi 4229*b50261e2SCy Schubert fi 4230*b50261e2SCy Schubert 4231*b50261e2SCy Schubert if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4232*b50261e2SCy Schubert for libdir in $libdirs; do 4233*b50261e2SCy Schubert if test -n "$finish_cmds"; then 4234*b50261e2SCy Schubert # Do each command in the finish commands. 4235*b50261e2SCy Schubert func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4236*b50261e2SCy Schubert'"$cmd"'"' 4237*b50261e2SCy Schubert fi 4238*b50261e2SCy Schubert if test -n "$finish_eval"; then 4239*b50261e2SCy Schubert # Do the single finish_eval. 4240*b50261e2SCy Schubert eval cmds=\"$finish_eval\" 4241*b50261e2SCy Schubert $opt_dry_run || eval "$cmds" || func_append admincmds " 4242*b50261e2SCy Schubert $cmds" 4243*b50261e2SCy Schubert fi 4244*b50261e2SCy Schubert done 4245*b50261e2SCy Schubert fi 4246*b50261e2SCy Schubert 4247*b50261e2SCy Schubert # Exit here if they wanted silent mode. 4248*b50261e2SCy Schubert $opt_quiet && exit $EXIT_SUCCESS 4249*b50261e2SCy Schubert 4250*b50261e2SCy Schubert if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4251*b50261e2SCy Schubert echo "----------------------------------------------------------------------" 4252*b50261e2SCy Schubert echo "Libraries have been installed in:" 4253*b50261e2SCy Schubert for libdir in $libdirs; do 4254*b50261e2SCy Schubert $ECHO " $libdir" 4255*b50261e2SCy Schubert done 4256*b50261e2SCy Schubert echo 4257*b50261e2SCy Schubert echo "If you ever happen to want to link against installed libraries" 4258*b50261e2SCy Schubert echo "in a given directory, LIBDIR, you must either use libtool, and" 4259*b50261e2SCy Schubert echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4260*b50261e2SCy Schubert echo "flag during linking and do at least one of the following:" 4261*b50261e2SCy Schubert if test -n "$shlibpath_var"; then 4262*b50261e2SCy Schubert echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4263*b50261e2SCy Schubert echo " during execution" 4264*b50261e2SCy Schubert fi 4265*b50261e2SCy Schubert if test -n "$runpath_var"; then 4266*b50261e2SCy Schubert echo " - add LIBDIR to the '$runpath_var' environment variable" 4267*b50261e2SCy Schubert echo " during linking" 4268*b50261e2SCy Schubert fi 4269*b50261e2SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 4270*b50261e2SCy Schubert libdir=LIBDIR 4271*b50261e2SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 4272*b50261e2SCy Schubert 4273*b50261e2SCy Schubert $ECHO " - use the '$flag' linker flag" 4274*b50261e2SCy Schubert fi 4275*b50261e2SCy Schubert if test -n "$admincmds"; then 4276*b50261e2SCy Schubert $ECHO " - have your system administrator run these commands:$admincmds" 4277*b50261e2SCy Schubert fi 4278*b50261e2SCy Schubert if test -f /etc/ld.so.conf; then 4279*b50261e2SCy Schubert echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4280*b50261e2SCy Schubert fi 4281*b50261e2SCy Schubert echo 4282*b50261e2SCy Schubert 4283*b50261e2SCy Schubert echo "See any operating system documentation about shared libraries for" 4284*b50261e2SCy Schubert case $host in 4285*b50261e2SCy Schubert solaris2.[6789]|solaris2.1[0-9]) 4286*b50261e2SCy Schubert echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4287*b50261e2SCy Schubert echo "pages." 4288*b50261e2SCy Schubert ;; 4289*b50261e2SCy Schubert *) 4290*b50261e2SCy Schubert echo "more information, such as the ld(1) and ld.so(8) manual pages." 4291*b50261e2SCy Schubert ;; 4292*b50261e2SCy Schubert esac 4293*b50261e2SCy Schubert echo "----------------------------------------------------------------------" 4294*b50261e2SCy Schubert fi 4295*b50261e2SCy Schubert exit $EXIT_SUCCESS 4296*b50261e2SCy Schubert} 4297*b50261e2SCy Schubert 4298*b50261e2SCy Schuberttest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4299*b50261e2SCy Schubert 4300*b50261e2SCy Schubert 4301*b50261e2SCy Schubert# func_mode_install arg... 4302*b50261e2SCy Schubertfunc_mode_install () 4303*b50261e2SCy Schubert{ 4304*b50261e2SCy Schubert $debug_cmd 4305*b50261e2SCy Schubert 4306*b50261e2SCy Schubert # There may be an optional sh(1) argument at the beginning of 4307*b50261e2SCy Schubert # install_prog (especially on Windows NT). 4308*b50261e2SCy Schubert if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4309*b50261e2SCy Schubert # Allow the use of GNU shtool's install command. 4310*b50261e2SCy Schubert case $nonopt in *shtool*) :;; *) false;; esac 4311*b50261e2SCy Schubert then 4312*b50261e2SCy Schubert # Aesthetically quote it. 4313*b50261e2SCy Schubert func_quote_arg pretty "$nonopt" 4314*b50261e2SCy Schubert install_prog="$func_quote_arg_result " 4315*b50261e2SCy Schubert arg=$1 4316*b50261e2SCy Schubert shift 4317*b50261e2SCy Schubert else 4318*b50261e2SCy Schubert install_prog= 4319*b50261e2SCy Schubert arg=$nonopt 4320*b50261e2SCy Schubert fi 4321*b50261e2SCy Schubert 4322*b50261e2SCy Schubert # The real first argument should be the name of the installation program. 4323*b50261e2SCy Schubert # Aesthetically quote it. 4324*b50261e2SCy Schubert func_quote_arg pretty "$arg" 4325*b50261e2SCy Schubert func_append install_prog "$func_quote_arg_result" 4326*b50261e2SCy Schubert install_shared_prog=$install_prog 4327*b50261e2SCy Schubert case " $install_prog " in 4328*b50261e2SCy Schubert *[\\\ /]cp\ *) install_cp=: ;; 4329*b50261e2SCy Schubert *) install_cp=false ;; 4330*b50261e2SCy Schubert esac 4331*b50261e2SCy Schubert 4332*b50261e2SCy Schubert # We need to accept at least all the BSD install flags. 4333*b50261e2SCy Schubert dest= 4334*b50261e2SCy Schubert files= 4335*b50261e2SCy Schubert opts= 4336*b50261e2SCy Schubert prev= 4337*b50261e2SCy Schubert install_type= 4338*b50261e2SCy Schubert isdir=false 4339*b50261e2SCy Schubert stripme= 4340*b50261e2SCy Schubert no_mode=: 4341*b50261e2SCy Schubert for arg 4342*b50261e2SCy Schubert do 4343*b50261e2SCy Schubert arg2= 4344*b50261e2SCy Schubert if test -n "$dest"; then 4345*b50261e2SCy Schubert func_append files " $dest" 4346*b50261e2SCy Schubert dest=$arg 4347*b50261e2SCy Schubert continue 4348*b50261e2SCy Schubert fi 4349*b50261e2SCy Schubert 4350*b50261e2SCy Schubert case $arg in 4351*b50261e2SCy Schubert -d) isdir=: ;; 4352*b50261e2SCy Schubert -f) 4353*b50261e2SCy Schubert if $install_cp; then :; else 4354*b50261e2SCy Schubert prev=$arg 4355*b50261e2SCy Schubert fi 4356*b50261e2SCy Schubert ;; 4357*b50261e2SCy Schubert -g | -m | -o) 4358*b50261e2SCy Schubert prev=$arg 4359*b50261e2SCy Schubert ;; 4360*b50261e2SCy Schubert -s) 4361*b50261e2SCy Schubert stripme=" -s" 4362*b50261e2SCy Schubert continue 4363*b50261e2SCy Schubert ;; 4364*b50261e2SCy Schubert -*) 4365*b50261e2SCy Schubert ;; 4366*b50261e2SCy Schubert *) 4367*b50261e2SCy Schubert # If the previous option needed an argument, then skip it. 4368*b50261e2SCy Schubert if test -n "$prev"; then 4369*b50261e2SCy Schubert if test X-m = "X$prev" && test -n "$install_override_mode"; then 4370*b50261e2SCy Schubert arg2=$install_override_mode 4371*b50261e2SCy Schubert no_mode=false 4372*b50261e2SCy Schubert fi 4373*b50261e2SCy Schubert prev= 4374*b50261e2SCy Schubert else 4375*b50261e2SCy Schubert dest=$arg 4376*b50261e2SCy Schubert continue 4377*b50261e2SCy Schubert fi 4378*b50261e2SCy Schubert ;; 4379*b50261e2SCy Schubert esac 4380*b50261e2SCy Schubert 4381*b50261e2SCy Schubert # Aesthetically quote the argument. 4382*b50261e2SCy Schubert func_quote_arg pretty "$arg" 4383*b50261e2SCy Schubert func_append install_prog " $func_quote_arg_result" 4384*b50261e2SCy Schubert if test -n "$arg2"; then 4385*b50261e2SCy Schubert func_quote_arg pretty "$arg2" 4386*b50261e2SCy Schubert fi 4387*b50261e2SCy Schubert func_append install_shared_prog " $func_quote_arg_result" 4388*b50261e2SCy Schubert done 4389*b50261e2SCy Schubert 4390*b50261e2SCy Schubert test -z "$install_prog" && \ 4391*b50261e2SCy Schubert func_fatal_help "you must specify an install program" 4392*b50261e2SCy Schubert 4393*b50261e2SCy Schubert test -n "$prev" && \ 4394*b50261e2SCy Schubert func_fatal_help "the '$prev' option requires an argument" 4395*b50261e2SCy Schubert 4396*b50261e2SCy Schubert if test -n "$install_override_mode" && $no_mode; then 4397*b50261e2SCy Schubert if $install_cp; then :; else 4398*b50261e2SCy Schubert func_quote_arg pretty "$install_override_mode" 4399*b50261e2SCy Schubert func_append install_shared_prog " -m $func_quote_arg_result" 4400*b50261e2SCy Schubert fi 4401*b50261e2SCy Schubert fi 4402*b50261e2SCy Schubert 4403*b50261e2SCy Schubert if test -z "$files"; then 4404*b50261e2SCy Schubert if test -z "$dest"; then 4405*b50261e2SCy Schubert func_fatal_help "no file or destination specified" 4406*b50261e2SCy Schubert else 4407*b50261e2SCy Schubert func_fatal_help "you must specify a destination" 4408*b50261e2SCy Schubert fi 4409*b50261e2SCy Schubert fi 4410*b50261e2SCy Schubert 4411*b50261e2SCy Schubert # Strip any trailing slash from the destination. 4412*b50261e2SCy Schubert func_stripname '' '/' "$dest" 4413*b50261e2SCy Schubert dest=$func_stripname_result 4414*b50261e2SCy Schubert 4415*b50261e2SCy Schubert # Check to see that the destination is a directory. 4416*b50261e2SCy Schubert test -d "$dest" && isdir=: 4417*b50261e2SCy Schubert if $isdir; then 4418*b50261e2SCy Schubert destdir=$dest 4419*b50261e2SCy Schubert destname= 4420*b50261e2SCy Schubert else 4421*b50261e2SCy Schubert func_dirname_and_basename "$dest" "" "." 4422*b50261e2SCy Schubert destdir=$func_dirname_result 4423*b50261e2SCy Schubert destname=$func_basename_result 4424*b50261e2SCy Schubert 4425*b50261e2SCy Schubert # Not a directory, so check to see that there is only one file specified. 4426*b50261e2SCy Schubert set dummy $files; shift 4427*b50261e2SCy Schubert test "$#" -gt 1 && \ 4428*b50261e2SCy Schubert func_fatal_help "'$dest' is not a directory" 4429*b50261e2SCy Schubert fi 4430*b50261e2SCy Schubert case $destdir in 4431*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 4432*b50261e2SCy Schubert *) 4433*b50261e2SCy Schubert for file in $files; do 4434*b50261e2SCy Schubert case $file in 4435*b50261e2SCy Schubert *.lo) ;; 4436*b50261e2SCy Schubert *) 4437*b50261e2SCy Schubert func_fatal_help "'$destdir' must be an absolute directory name" 4438*b50261e2SCy Schubert ;; 4439*b50261e2SCy Schubert esac 4440*b50261e2SCy Schubert done 4441*b50261e2SCy Schubert ;; 4442*b50261e2SCy Schubert esac 4443*b50261e2SCy Schubert 4444*b50261e2SCy Schubert # This variable tells wrapper scripts just to set variables rather 4445*b50261e2SCy Schubert # than running their programs. 4446*b50261e2SCy Schubert libtool_install_magic=$magic 4447*b50261e2SCy Schubert 4448*b50261e2SCy Schubert staticlibs= 4449*b50261e2SCy Schubert future_libdirs= 4450*b50261e2SCy Schubert current_libdirs= 4451*b50261e2SCy Schubert for file in $files; do 4452*b50261e2SCy Schubert 4453*b50261e2SCy Schubert # Do each installation. 4454*b50261e2SCy Schubert case $file in 4455*b50261e2SCy Schubert *.$libext) 4456*b50261e2SCy Schubert # Do the static libraries later. 4457*b50261e2SCy Schubert func_append staticlibs " $file" 4458*b50261e2SCy Schubert ;; 4459*b50261e2SCy Schubert 4460*b50261e2SCy Schubert *.la) 4461*b50261e2SCy Schubert func_resolve_sysroot "$file" 4462*b50261e2SCy Schubert file=$func_resolve_sysroot_result 4463*b50261e2SCy Schubert 4464*b50261e2SCy Schubert # Check to see that this really is a libtool archive. 4465*b50261e2SCy Schubert func_lalib_unsafe_p "$file" \ 4466*b50261e2SCy Schubert || func_fatal_help "'$file' is not a valid libtool archive" 4467*b50261e2SCy Schubert 4468*b50261e2SCy Schubert library_names= 4469*b50261e2SCy Schubert old_library= 4470*b50261e2SCy Schubert relink_command= 4471*b50261e2SCy Schubert func_source "$file" 4472*b50261e2SCy Schubert 4473*b50261e2SCy Schubert # Add the libdir to current_libdirs if it is the destination. 4474*b50261e2SCy Schubert if test "X$destdir" = "X$libdir"; then 4475*b50261e2SCy Schubert case "$current_libdirs " in 4476*b50261e2SCy Schubert *" $libdir "*) ;; 4477*b50261e2SCy Schubert *) func_append current_libdirs " $libdir" ;; 4478*b50261e2SCy Schubert esac 4479*b50261e2SCy Schubert else 4480*b50261e2SCy Schubert # Note the libdir as a future libdir. 4481*b50261e2SCy Schubert case "$future_libdirs " in 4482*b50261e2SCy Schubert *" $libdir "*) ;; 4483*b50261e2SCy Schubert *) func_append future_libdirs " $libdir" ;; 4484*b50261e2SCy Schubert esac 4485*b50261e2SCy Schubert fi 4486*b50261e2SCy Schubert 4487*b50261e2SCy Schubert func_dirname "$file" "/" "" 4488*b50261e2SCy Schubert dir=$func_dirname_result 4489*b50261e2SCy Schubert func_append dir "$objdir" 4490*b50261e2SCy Schubert 4491*b50261e2SCy Schubert if test -n "$relink_command"; then 4492*b50261e2SCy Schubert # Determine the prefix the user has applied to our future dir. 4493*b50261e2SCy Schubert inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4494*b50261e2SCy Schubert 4495*b50261e2SCy Schubert # Don't allow the user to place us outside of our expected 4496*b50261e2SCy Schubert # location b/c this prevents finding dependent libraries that 4497*b50261e2SCy Schubert # are installed to the same prefix. 4498*b50261e2SCy Schubert # At present, this check doesn't affect windows .dll's that 4499*b50261e2SCy Schubert # are installed into $libdir/../bin (currently, that works fine) 4500*b50261e2SCy Schubert # but it's something to keep an eye on. 4501*b50261e2SCy Schubert test "$inst_prefix_dir" = "$destdir" && \ 4502*b50261e2SCy Schubert func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4503*b50261e2SCy Schubert 4504*b50261e2SCy Schubert if test -n "$inst_prefix_dir"; then 4505*b50261e2SCy Schubert # Stick the inst_prefix_dir data into the link command. 4506*b50261e2SCy Schubert relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4507*b50261e2SCy Schubert else 4508*b50261e2SCy Schubert relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4509*b50261e2SCy Schubert fi 4510*b50261e2SCy Schubert 4511*b50261e2SCy Schubert func_warning "relinking '$file'" 4512*b50261e2SCy Schubert func_show_eval "$relink_command" \ 4513*b50261e2SCy Schubert 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4514*b50261e2SCy Schubert fi 4515*b50261e2SCy Schubert 4516*b50261e2SCy Schubert # See the names of the shared library. 4517*b50261e2SCy Schubert set dummy $library_names; shift 4518*b50261e2SCy Schubert if test -n "$1"; then 4519*b50261e2SCy Schubert realname=$1 4520*b50261e2SCy Schubert shift 4521*b50261e2SCy Schubert 4522*b50261e2SCy Schubert srcname=$realname 4523*b50261e2SCy Schubert test -n "$relink_command" && srcname=${realname}T 4524*b50261e2SCy Schubert 4525*b50261e2SCy Schubert # Install the shared library and build the symlinks. 4526*b50261e2SCy Schubert func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4527*b50261e2SCy Schubert 'exit $?' 4528*b50261e2SCy Schubert tstripme=$stripme 4529*b50261e2SCy Schubert case $host_os in 4530*b50261e2SCy Schubert cygwin* | mingw* | pw32* | cegcc*) 4531*b50261e2SCy Schubert case $realname in 4532*b50261e2SCy Schubert *.dll.a) 4533*b50261e2SCy Schubert tstripme= 4534*b50261e2SCy Schubert ;; 4535*b50261e2SCy Schubert esac 4536*b50261e2SCy Schubert ;; 4537*b50261e2SCy Schubert os2*) 4538*b50261e2SCy Schubert case $realname in 4539*b50261e2SCy Schubert *_dll.a) 4540*b50261e2SCy Schubert tstripme= 4541*b50261e2SCy Schubert ;; 4542*b50261e2SCy Schubert esac 4543*b50261e2SCy Schubert ;; 4544*b50261e2SCy Schubert esac 4545*b50261e2SCy Schubert if test -n "$tstripme" && test -n "$striplib"; then 4546*b50261e2SCy Schubert func_show_eval "$striplib $destdir/$realname" 'exit $?' 4547*b50261e2SCy Schubert fi 4548*b50261e2SCy Schubert 4549*b50261e2SCy Schubert if test "$#" -gt 0; then 4550*b50261e2SCy Schubert # Delete the old symlinks, and create new ones. 4551*b50261e2SCy Schubert # Try 'ln -sf' first, because the 'ln' binary might depend on 4552*b50261e2SCy Schubert # the symlink we replace! Solaris /bin/ln does not understand -f, 4553*b50261e2SCy Schubert # so we also need to try rm && ln -s. 4554*b50261e2SCy Schubert for linkname 4555*b50261e2SCy Schubert do 4556*b50261e2SCy Schubert test "$linkname" != "$realname" \ 4557*b50261e2SCy Schubert && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4558*b50261e2SCy Schubert done 4559*b50261e2SCy Schubert fi 4560*b50261e2SCy Schubert 4561*b50261e2SCy Schubert # Do each command in the postinstall commands. 4562*b50261e2SCy Schubert lib=$destdir/$realname 4563*b50261e2SCy Schubert func_execute_cmds "$postinstall_cmds" 'exit $?' 4564*b50261e2SCy Schubert fi 4565*b50261e2SCy Schubert 4566*b50261e2SCy Schubert # Install the pseudo-library for information purposes. 4567*b50261e2SCy Schubert func_basename "$file" 4568*b50261e2SCy Schubert name=$func_basename_result 4569*b50261e2SCy Schubert instname=$dir/${name}i 4570*b50261e2SCy Schubert func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4571*b50261e2SCy Schubert 4572*b50261e2SCy Schubert # Maybe install the static library, too. 4573*b50261e2SCy Schubert test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4574*b50261e2SCy Schubert ;; 4575*b50261e2SCy Schubert 4576*b50261e2SCy Schubert *.lo) 4577*b50261e2SCy Schubert # Install (i.e. copy) a libtool object. 4578*b50261e2SCy Schubert 4579*b50261e2SCy Schubert # Figure out destination file name, if it wasn't already specified. 4580*b50261e2SCy Schubert if test -n "$destname"; then 4581*b50261e2SCy Schubert destfile=$destdir/$destname 4582*b50261e2SCy Schubert else 4583*b50261e2SCy Schubert func_basename "$file" 4584*b50261e2SCy Schubert destfile=$func_basename_result 4585*b50261e2SCy Schubert destfile=$destdir/$destfile 4586*b50261e2SCy Schubert fi 4587*b50261e2SCy Schubert 4588*b50261e2SCy Schubert # Deduce the name of the destination old-style object file. 4589*b50261e2SCy Schubert case $destfile in 4590*b50261e2SCy Schubert *.lo) 4591*b50261e2SCy Schubert func_lo2o "$destfile" 4592*b50261e2SCy Schubert staticdest=$func_lo2o_result 4593*b50261e2SCy Schubert ;; 4594*b50261e2SCy Schubert *.$objext) 4595*b50261e2SCy Schubert staticdest=$destfile 4596*b50261e2SCy Schubert destfile= 4597*b50261e2SCy Schubert ;; 4598*b50261e2SCy Schubert *) 4599*b50261e2SCy Schubert func_fatal_help "cannot copy a libtool object to '$destfile'" 4600*b50261e2SCy Schubert ;; 4601*b50261e2SCy Schubert esac 4602*b50261e2SCy Schubert 4603*b50261e2SCy Schubert # Install the libtool object if requested. 4604*b50261e2SCy Schubert test -n "$destfile" && \ 4605*b50261e2SCy Schubert func_show_eval "$install_prog $file $destfile" 'exit $?' 4606*b50261e2SCy Schubert 4607*b50261e2SCy Schubert # Install the old object if enabled. 4608*b50261e2SCy Schubert if test yes = "$build_old_libs"; then 4609*b50261e2SCy Schubert # Deduce the name of the old-style object file. 4610*b50261e2SCy Schubert func_lo2o "$file" 4611*b50261e2SCy Schubert staticobj=$func_lo2o_result 4612*b50261e2SCy Schubert func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4613*b50261e2SCy Schubert fi 4614*b50261e2SCy Schubert exit $EXIT_SUCCESS 4615*b50261e2SCy Schubert ;; 4616*b50261e2SCy Schubert 4617*b50261e2SCy Schubert *) 4618*b50261e2SCy Schubert # Figure out destination file name, if it wasn't already specified. 4619*b50261e2SCy Schubert if test -n "$destname"; then 4620*b50261e2SCy Schubert destfile=$destdir/$destname 4621*b50261e2SCy Schubert else 4622*b50261e2SCy Schubert func_basename "$file" 4623*b50261e2SCy Schubert destfile=$func_basename_result 4624*b50261e2SCy Schubert destfile=$destdir/$destfile 4625*b50261e2SCy Schubert fi 4626*b50261e2SCy Schubert 4627*b50261e2SCy Schubert # If the file is missing, and there is a .exe on the end, strip it 4628*b50261e2SCy Schubert # because it is most likely a libtool script we actually want to 4629*b50261e2SCy Schubert # install 4630*b50261e2SCy Schubert stripped_ext= 4631*b50261e2SCy Schubert case $file in 4632*b50261e2SCy Schubert *.exe) 4633*b50261e2SCy Schubert if test ! -f "$file"; then 4634*b50261e2SCy Schubert func_stripname '' '.exe' "$file" 4635*b50261e2SCy Schubert file=$func_stripname_result 4636*b50261e2SCy Schubert stripped_ext=.exe 4637*b50261e2SCy Schubert fi 4638*b50261e2SCy Schubert ;; 4639*b50261e2SCy Schubert esac 4640*b50261e2SCy Schubert 4641*b50261e2SCy Schubert # Do a test to see if this is really a libtool program. 4642*b50261e2SCy Schubert case $host in 4643*b50261e2SCy Schubert *cygwin* | *mingw*) 4644*b50261e2SCy Schubert if func_ltwrapper_executable_p "$file"; then 4645*b50261e2SCy Schubert func_ltwrapper_scriptname "$file" 4646*b50261e2SCy Schubert wrapper=$func_ltwrapper_scriptname_result 4647*b50261e2SCy Schubert else 4648*b50261e2SCy Schubert func_stripname '' '.exe' "$file" 4649*b50261e2SCy Schubert wrapper=$func_stripname_result 4650*b50261e2SCy Schubert fi 4651*b50261e2SCy Schubert ;; 4652*b50261e2SCy Schubert *) 4653*b50261e2SCy Schubert wrapper=$file 4654*b50261e2SCy Schubert ;; 4655*b50261e2SCy Schubert esac 4656*b50261e2SCy Schubert if func_ltwrapper_script_p "$wrapper"; then 4657*b50261e2SCy Schubert notinst_deplibs= 4658*b50261e2SCy Schubert relink_command= 4659*b50261e2SCy Schubert 4660*b50261e2SCy Schubert func_source "$wrapper" 4661*b50261e2SCy Schubert 4662*b50261e2SCy Schubert # Check the variables that should have been set. 4663*b50261e2SCy Schubert test -z "$generated_by_libtool_version" && \ 4664*b50261e2SCy Schubert func_fatal_error "invalid libtool wrapper script '$wrapper'" 4665*b50261e2SCy Schubert 4666*b50261e2SCy Schubert finalize=: 4667*b50261e2SCy Schubert for lib in $notinst_deplibs; do 4668*b50261e2SCy Schubert # Check to see that each library is installed. 4669*b50261e2SCy Schubert libdir= 4670*b50261e2SCy Schubert if test -f "$lib"; then 4671*b50261e2SCy Schubert func_source "$lib" 4672*b50261e2SCy Schubert fi 4673*b50261e2SCy Schubert libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4674*b50261e2SCy Schubert if test -n "$libdir" && test ! -f "$libfile"; then 4675*b50261e2SCy Schubert func_warning "'$lib' has not been installed in '$libdir'" 4676*b50261e2SCy Schubert finalize=false 4677*b50261e2SCy Schubert fi 4678*b50261e2SCy Schubert done 4679*b50261e2SCy Schubert 4680*b50261e2SCy Schubert relink_command= 4681*b50261e2SCy Schubert func_source "$wrapper" 4682*b50261e2SCy Schubert 4683*b50261e2SCy Schubert outputname= 4684*b50261e2SCy Schubert if test no = "$fast_install" && test -n "$relink_command"; then 4685*b50261e2SCy Schubert $opt_dry_run || { 4686*b50261e2SCy Schubert if $finalize; then 4687*b50261e2SCy Schubert tmpdir=`func_mktempdir` 4688*b50261e2SCy Schubert func_basename "$file$stripped_ext" 4689*b50261e2SCy Schubert file=$func_basename_result 4690*b50261e2SCy Schubert outputname=$tmpdir/$file 4691*b50261e2SCy Schubert # Replace the output file specification. 4692*b50261e2SCy Schubert relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4693*b50261e2SCy Schubert 4694*b50261e2SCy Schubert $opt_quiet || { 4695*b50261e2SCy Schubert func_quote_arg expand,pretty "$relink_command" 4696*b50261e2SCy Schubert eval "func_echo $func_quote_arg_result" 4697*b50261e2SCy Schubert } 4698*b50261e2SCy Schubert if eval "$relink_command"; then : 4699*b50261e2SCy Schubert else 4700*b50261e2SCy Schubert func_error "error: relink '$file' with the above command before installing it" 4701*b50261e2SCy Schubert $opt_dry_run || ${RM}r "$tmpdir" 4702*b50261e2SCy Schubert continue 4703*b50261e2SCy Schubert fi 4704*b50261e2SCy Schubert file=$outputname 4705*b50261e2SCy Schubert else 4706*b50261e2SCy Schubert func_warning "cannot relink '$file'" 4707*b50261e2SCy Schubert fi 4708*b50261e2SCy Schubert } 4709*b50261e2SCy Schubert else 4710*b50261e2SCy Schubert # Install the binary that we compiled earlier. 4711*b50261e2SCy Schubert file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4712*b50261e2SCy Schubert fi 4713*b50261e2SCy Schubert fi 4714*b50261e2SCy Schubert 4715*b50261e2SCy Schubert # remove .exe since cygwin /usr/bin/install will append another 4716*b50261e2SCy Schubert # one anyway 4717*b50261e2SCy Schubert case $install_prog,$host in 4718*b50261e2SCy Schubert */usr/bin/install*,*cygwin*) 4719*b50261e2SCy Schubert case $file:$destfile in 4720*b50261e2SCy Schubert *.exe:*.exe) 4721*b50261e2SCy Schubert # this is ok 4722*b50261e2SCy Schubert ;; 4723*b50261e2SCy Schubert *.exe:*) 4724*b50261e2SCy Schubert destfile=$destfile.exe 4725*b50261e2SCy Schubert ;; 4726*b50261e2SCy Schubert *:*.exe) 4727*b50261e2SCy Schubert func_stripname '' '.exe' "$destfile" 4728*b50261e2SCy Schubert destfile=$func_stripname_result 4729*b50261e2SCy Schubert ;; 4730*b50261e2SCy Schubert esac 4731*b50261e2SCy Schubert ;; 4732*b50261e2SCy Schubert esac 4733*b50261e2SCy Schubert func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4734*b50261e2SCy Schubert $opt_dry_run || if test -n "$outputname"; then 4735*b50261e2SCy Schubert ${RM}r "$tmpdir" 4736*b50261e2SCy Schubert fi 4737*b50261e2SCy Schubert ;; 4738*b50261e2SCy Schubert esac 4739*b50261e2SCy Schubert done 4740*b50261e2SCy Schubert 4741*b50261e2SCy Schubert for file in $staticlibs; do 4742*b50261e2SCy Schubert func_basename "$file" 4743*b50261e2SCy Schubert name=$func_basename_result 4744*b50261e2SCy Schubert 4745*b50261e2SCy Schubert # Set up the ranlib parameters. 4746*b50261e2SCy Schubert oldlib=$destdir/$name 4747*b50261e2SCy Schubert func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4748*b50261e2SCy Schubert tool_oldlib=$func_to_tool_file_result 4749*b50261e2SCy Schubert 4750*b50261e2SCy Schubert func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4751*b50261e2SCy Schubert 4752*b50261e2SCy Schubert if test -n "$stripme" && test -n "$old_striplib"; then 4753*b50261e2SCy Schubert func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4754*b50261e2SCy Schubert fi 4755*b50261e2SCy Schubert 4756*b50261e2SCy Schubert # Do each command in the postinstall commands. 4757*b50261e2SCy Schubert func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4758*b50261e2SCy Schubert done 4759*b50261e2SCy Schubert 4760*b50261e2SCy Schubert test -n "$future_libdirs" && \ 4761*b50261e2SCy Schubert func_warning "remember to run '$progname --finish$future_libdirs'" 4762*b50261e2SCy Schubert 4763*b50261e2SCy Schubert if test -n "$current_libdirs"; then 4764*b50261e2SCy Schubert # Maybe just do a dry run. 4765*b50261e2SCy Schubert $opt_dry_run && current_libdirs=" -n$current_libdirs" 4766*b50261e2SCy Schubert exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4767*b50261e2SCy Schubert else 4768*b50261e2SCy Schubert exit $EXIT_SUCCESS 4769*b50261e2SCy Schubert fi 4770*b50261e2SCy Schubert} 4771*b50261e2SCy Schubert 4772*b50261e2SCy Schuberttest install = "$opt_mode" && func_mode_install ${1+"$@"} 4773*b50261e2SCy Schubert 4774*b50261e2SCy Schubert 4775*b50261e2SCy Schubert# func_generate_dlsyms outputname originator pic_p 4776*b50261e2SCy Schubert# Extract symbols from dlprefiles and create ${outputname}S.o with 4777*b50261e2SCy Schubert# a dlpreopen symbol table. 4778*b50261e2SCy Schubertfunc_generate_dlsyms () 4779*b50261e2SCy Schubert{ 4780*b50261e2SCy Schubert $debug_cmd 4781*b50261e2SCy Schubert 4782*b50261e2SCy Schubert my_outputname=$1 4783*b50261e2SCy Schubert my_originator=$2 4784*b50261e2SCy Schubert my_pic_p=${3-false} 4785*b50261e2SCy Schubert my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4786*b50261e2SCy Schubert my_dlsyms= 4787*b50261e2SCy Schubert 4788*b50261e2SCy Schubert if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4789*b50261e2SCy Schubert if test -n "$NM" && test -n "$global_symbol_pipe"; then 4790*b50261e2SCy Schubert my_dlsyms=${my_outputname}S.c 4791*b50261e2SCy Schubert else 4792*b50261e2SCy Schubert func_error "not configured to extract global symbols from dlpreopened files" 4793*b50261e2SCy Schubert fi 4794*b50261e2SCy Schubert fi 4795*b50261e2SCy Schubert 4796*b50261e2SCy Schubert if test -n "$my_dlsyms"; then 4797*b50261e2SCy Schubert case $my_dlsyms in 4798*b50261e2SCy Schubert "") ;; 4799*b50261e2SCy Schubert *.c) 4800*b50261e2SCy Schubert # Discover the nlist of each of the dlfiles. 4801*b50261e2SCy Schubert nlist=$output_objdir/$my_outputname.nm 4802*b50261e2SCy Schubert 4803*b50261e2SCy Schubert func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4804*b50261e2SCy Schubert 4805*b50261e2SCy Schubert # Parse the name list into a source file. 4806*b50261e2SCy Schubert func_verbose "creating $output_objdir/$my_dlsyms" 4807*b50261e2SCy Schubert 4808*b50261e2SCy Schubert $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4809*b50261e2SCy Schubert/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4810*b50261e2SCy Schubert/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4811*b50261e2SCy Schubert 4812*b50261e2SCy Schubert#ifdef __cplusplus 4813*b50261e2SCy Schubertextern \"C\" { 4814*b50261e2SCy Schubert#endif 4815*b50261e2SCy Schubert 4816*b50261e2SCy Schubert#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4817*b50261e2SCy Schubert#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4818*b50261e2SCy Schubert#endif 4819*b50261e2SCy Schubert 4820*b50261e2SCy Schubert/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4821*b50261e2SCy Schubert#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4822*b50261e2SCy Schubert/* DATA imports from DLLs on WIN32 can't be const, because runtime 4823*b50261e2SCy Schubert relocations are performed -- see ld's documentation on pseudo-relocs. */ 4824*b50261e2SCy Schubert# define LT_DLSYM_CONST 4825*b50261e2SCy Schubert#elif defined __osf__ 4826*b50261e2SCy Schubert/* This system does not cope well with relocations in const data. */ 4827*b50261e2SCy Schubert# define LT_DLSYM_CONST 4828*b50261e2SCy Schubert#else 4829*b50261e2SCy Schubert# define LT_DLSYM_CONST const 4830*b50261e2SCy Schubert#endif 4831*b50261e2SCy Schubert 4832*b50261e2SCy Schubert#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4833*b50261e2SCy Schubert 4834*b50261e2SCy Schubert/* External symbol declarations for the compiler. */\ 4835*b50261e2SCy Schubert" 4836*b50261e2SCy Schubert 4837*b50261e2SCy Schubert if test yes = "$dlself"; then 4838*b50261e2SCy Schubert func_verbose "generating symbol list for '$output'" 4839*b50261e2SCy Schubert 4840*b50261e2SCy Schubert $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4841*b50261e2SCy Schubert 4842*b50261e2SCy Schubert # Add our own program objects to the symbol list. 4843*b50261e2SCy Schubert progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4844*b50261e2SCy Schubert for progfile in $progfiles; do 4845*b50261e2SCy Schubert func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4846*b50261e2SCy Schubert func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4847*b50261e2SCy Schubert $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4848*b50261e2SCy Schubert done 4849*b50261e2SCy Schubert 4850*b50261e2SCy Schubert if test -n "$exclude_expsyms"; then 4851*b50261e2SCy Schubert $opt_dry_run || { 4852*b50261e2SCy Schubert eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4853*b50261e2SCy Schubert eval '$MV "$nlist"T "$nlist"' 4854*b50261e2SCy Schubert } 4855*b50261e2SCy Schubert fi 4856*b50261e2SCy Schubert 4857*b50261e2SCy Schubert if test -n "$export_symbols_regex"; then 4858*b50261e2SCy Schubert $opt_dry_run || { 4859*b50261e2SCy Schubert eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4860*b50261e2SCy Schubert eval '$MV "$nlist"T "$nlist"' 4861*b50261e2SCy Schubert } 4862*b50261e2SCy Schubert fi 4863*b50261e2SCy Schubert 4864*b50261e2SCy Schubert # Prepare the list of exported symbols 4865*b50261e2SCy Schubert if test -z "$export_symbols"; then 4866*b50261e2SCy Schubert export_symbols=$output_objdir/$outputname.exp 4867*b50261e2SCy Schubert $opt_dry_run || { 4868*b50261e2SCy Schubert $RM $export_symbols 4869*b50261e2SCy Schubert eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4870*b50261e2SCy Schubert case $host in 4871*b50261e2SCy Schubert *cygwin* | *mingw* | *cegcc* ) 4872*b50261e2SCy Schubert eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4873*b50261e2SCy Schubert eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4874*b50261e2SCy Schubert ;; 4875*b50261e2SCy Schubert esac 4876*b50261e2SCy Schubert } 4877*b50261e2SCy Schubert else 4878*b50261e2SCy Schubert $opt_dry_run || { 4879*b50261e2SCy Schubert eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4880*b50261e2SCy Schubert eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4881*b50261e2SCy Schubert eval '$MV "$nlist"T "$nlist"' 4882*b50261e2SCy Schubert case $host in 4883*b50261e2SCy Schubert *cygwin* | *mingw* | *cegcc* ) 4884*b50261e2SCy Schubert eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4885*b50261e2SCy Schubert eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4886*b50261e2SCy Schubert ;; 4887*b50261e2SCy Schubert esac 4888*b50261e2SCy Schubert } 4889*b50261e2SCy Schubert fi 4890*b50261e2SCy Schubert fi 4891*b50261e2SCy Schubert 4892*b50261e2SCy Schubert for dlprefile in $dlprefiles; do 4893*b50261e2SCy Schubert func_verbose "extracting global C symbols from '$dlprefile'" 4894*b50261e2SCy Schubert func_basename "$dlprefile" 4895*b50261e2SCy Schubert name=$func_basename_result 4896*b50261e2SCy Schubert case $host in 4897*b50261e2SCy Schubert *cygwin* | *mingw* | *cegcc* ) 4898*b50261e2SCy Schubert # if an import library, we need to obtain dlname 4899*b50261e2SCy Schubert if func_win32_import_lib_p "$dlprefile"; then 4900*b50261e2SCy Schubert func_tr_sh "$dlprefile" 4901*b50261e2SCy Schubert eval "curr_lafile=\$libfile_$func_tr_sh_result" 4902*b50261e2SCy Schubert dlprefile_dlbasename= 4903*b50261e2SCy Schubert if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4904*b50261e2SCy Schubert # Use subshell, to avoid clobbering current variable values 4905*b50261e2SCy Schubert dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4906*b50261e2SCy Schubert if test -n "$dlprefile_dlname"; then 4907*b50261e2SCy Schubert func_basename "$dlprefile_dlname" 4908*b50261e2SCy Schubert dlprefile_dlbasename=$func_basename_result 4909*b50261e2SCy Schubert else 4910*b50261e2SCy Schubert # no lafile. user explicitly requested -dlpreopen <import library>. 4911*b50261e2SCy Schubert $sharedlib_from_linklib_cmd "$dlprefile" 4912*b50261e2SCy Schubert dlprefile_dlbasename=$sharedlib_from_linklib_result 4913*b50261e2SCy Schubert fi 4914*b50261e2SCy Schubert fi 4915*b50261e2SCy Schubert $opt_dry_run || { 4916*b50261e2SCy Schubert if test -n "$dlprefile_dlbasename"; then 4917*b50261e2SCy Schubert eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4918*b50261e2SCy Schubert else 4919*b50261e2SCy Schubert func_warning "Could not compute DLL name from $name" 4920*b50261e2SCy Schubert eval '$ECHO ": $name " >> "$nlist"' 4921*b50261e2SCy Schubert fi 4922*b50261e2SCy Schubert func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4923*b50261e2SCy Schubert eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4924*b50261e2SCy Schubert $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4925*b50261e2SCy Schubert } 4926*b50261e2SCy Schubert else # not an import lib 4927*b50261e2SCy Schubert $opt_dry_run || { 4928*b50261e2SCy Schubert eval '$ECHO ": $name " >> "$nlist"' 4929*b50261e2SCy Schubert func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4930*b50261e2SCy Schubert eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4931*b50261e2SCy Schubert } 4932*b50261e2SCy Schubert fi 4933*b50261e2SCy Schubert ;; 4934*b50261e2SCy Schubert *) 4935*b50261e2SCy Schubert $opt_dry_run || { 4936*b50261e2SCy Schubert eval '$ECHO ": $name " >> "$nlist"' 4937*b50261e2SCy Schubert func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4938*b50261e2SCy Schubert eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4939*b50261e2SCy Schubert } 4940*b50261e2SCy Schubert ;; 4941*b50261e2SCy Schubert esac 4942*b50261e2SCy Schubert done 4943*b50261e2SCy Schubert 4944*b50261e2SCy Schubert $opt_dry_run || { 4945*b50261e2SCy Schubert # Make sure we have at least an empty file. 4946*b50261e2SCy Schubert test -f "$nlist" || : > "$nlist" 4947*b50261e2SCy Schubert 4948*b50261e2SCy Schubert if test -n "$exclude_expsyms"; then 4949*b50261e2SCy Schubert $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4950*b50261e2SCy Schubert $MV "$nlist"T "$nlist" 4951*b50261e2SCy Schubert fi 4952*b50261e2SCy Schubert 4953*b50261e2SCy Schubert # Try sorting and uniquifying the output. 4954*b50261e2SCy Schubert if $GREP -v "^: " < "$nlist" | 4955*b50261e2SCy Schubert if sort -k 3 </dev/null >/dev/null 2>&1; then 4956*b50261e2SCy Schubert sort -k 3 4957*b50261e2SCy Schubert else 4958*b50261e2SCy Schubert sort +2 4959*b50261e2SCy Schubert fi | 4960*b50261e2SCy Schubert uniq > "$nlist"S; then 4961*b50261e2SCy Schubert : 4962*b50261e2SCy Schubert else 4963*b50261e2SCy Schubert $GREP -v "^: " < "$nlist" > "$nlist"S 4964*b50261e2SCy Schubert fi 4965*b50261e2SCy Schubert 4966*b50261e2SCy Schubert if test -f "$nlist"S; then 4967*b50261e2SCy Schubert eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4968*b50261e2SCy Schubert else 4969*b50261e2SCy Schubert echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4970*b50261e2SCy Schubert fi 4971*b50261e2SCy Schubert 4972*b50261e2SCy Schubert func_show_eval '$RM "${nlist}I"' 4973*b50261e2SCy Schubert if test -n "$global_symbol_to_import"; then 4974*b50261e2SCy Schubert eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4975*b50261e2SCy Schubert fi 4976*b50261e2SCy Schubert 4977*b50261e2SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4978*b50261e2SCy Schubert 4979*b50261e2SCy Schubert/* The mapping between symbol names and symbols. */ 4980*b50261e2SCy Schuberttypedef struct { 4981*b50261e2SCy Schubert const char *name; 4982*b50261e2SCy Schubert void *address; 4983*b50261e2SCy Schubert} lt_dlsymlist; 4984*b50261e2SCy Schubertextern LT_DLSYM_CONST lt_dlsymlist 4985*b50261e2SCy Schubertlt_${my_prefix}_LTX_preloaded_symbols[];\ 4986*b50261e2SCy Schubert" 4987*b50261e2SCy Schubert 4988*b50261e2SCy Schubert if test -s "$nlist"I; then 4989*b50261e2SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4990*b50261e2SCy Schubertstatic void lt_syminit(void) 4991*b50261e2SCy Schubert{ 4992*b50261e2SCy Schubert LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4993*b50261e2SCy Schubert for (; symbol->name; ++symbol) 4994*b50261e2SCy Schubert {" 4995*b50261e2SCy Schubert $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4996*b50261e2SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4997*b50261e2SCy Schubert } 4998*b50261e2SCy Schubert}" 4999*b50261e2SCy Schubert fi 5000*b50261e2SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 5001*b50261e2SCy SchubertLT_DLSYM_CONST lt_dlsymlist 5002*b50261e2SCy Schubertlt_${my_prefix}_LTX_preloaded_symbols[] = 5003*b50261e2SCy Schubert{ {\"$my_originator\", (void *) 0}," 5004*b50261e2SCy Schubert 5005*b50261e2SCy Schubert if test -s "$nlist"I; then 5006*b50261e2SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 5007*b50261e2SCy Schubert {\"@INIT@\", (void *) <_syminit}," 5008*b50261e2SCy Schubert fi 5009*b50261e2SCy Schubert 5010*b50261e2SCy Schubert case $need_lib_prefix in 5011*b50261e2SCy Schubert no) 5012*b50261e2SCy Schubert eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5013*b50261e2SCy Schubert ;; 5014*b50261e2SCy Schubert *) 5015*b50261e2SCy Schubert eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5016*b50261e2SCy Schubert ;; 5017*b50261e2SCy Schubert esac 5018*b50261e2SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 5019*b50261e2SCy Schubert {0, (void *) 0} 5020*b50261e2SCy Schubert}; 5021*b50261e2SCy Schubert 5022*b50261e2SCy Schubert/* This works around a problem in FreeBSD linker */ 5023*b50261e2SCy Schubert#ifdef FREEBSD_WORKAROUND 5024*b50261e2SCy Schubertstatic const void *lt_preloaded_setup() { 5025*b50261e2SCy Schubert return lt_${my_prefix}_LTX_preloaded_symbols; 5026*b50261e2SCy Schubert} 5027*b50261e2SCy Schubert#endif 5028*b50261e2SCy Schubert 5029*b50261e2SCy Schubert#ifdef __cplusplus 5030*b50261e2SCy Schubert} 5031*b50261e2SCy Schubert#endif\ 5032*b50261e2SCy Schubert" 5033*b50261e2SCy Schubert } # !$opt_dry_run 5034*b50261e2SCy Schubert 5035*b50261e2SCy Schubert pic_flag_for_symtable= 5036*b50261e2SCy Schubert case "$compile_command " in 5037*b50261e2SCy Schubert *" -static "*) ;; 5038*b50261e2SCy Schubert *) 5039*b50261e2SCy Schubert case $host in 5040*b50261e2SCy Schubert # compiling the symbol table file with pic_flag works around 5041*b50261e2SCy Schubert # a FreeBSD bug that causes programs to crash when -lm is 5042*b50261e2SCy Schubert # linked before any other PIC object. But we must not use 5043*b50261e2SCy Schubert # pic_flag when linking with -static. The problem exists in 5044*b50261e2SCy Schubert # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5045*b50261e2SCy Schubert *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5046*b50261e2SCy Schubert pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5047*b50261e2SCy Schubert *-*-hpux*) 5048*b50261e2SCy Schubert pic_flag_for_symtable=" $pic_flag" ;; 5049*b50261e2SCy Schubert *) 5050*b50261e2SCy Schubert $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5051*b50261e2SCy Schubert ;; 5052*b50261e2SCy Schubert esac 5053*b50261e2SCy Schubert ;; 5054*b50261e2SCy Schubert esac 5055*b50261e2SCy Schubert symtab_cflags= 5056*b50261e2SCy Schubert for arg in $LTCFLAGS; do 5057*b50261e2SCy Schubert case $arg in 5058*b50261e2SCy Schubert -pie | -fpie | -fPIE) ;; 5059*b50261e2SCy Schubert *) func_append symtab_cflags " $arg" ;; 5060*b50261e2SCy Schubert esac 5061*b50261e2SCy Schubert done 5062*b50261e2SCy Schubert 5063*b50261e2SCy Schubert # Now compile the dynamic symbol file. 5064*b50261e2SCy Schubert func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5065*b50261e2SCy Schubert 5066*b50261e2SCy Schubert # Clean up the generated files. 5067*b50261e2SCy Schubert func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5068*b50261e2SCy Schubert 5069*b50261e2SCy Schubert # Transform the symbol file into the correct name. 5070*b50261e2SCy Schubert symfileobj=$output_objdir/${my_outputname}S.$objext 5071*b50261e2SCy Schubert case $host in 5072*b50261e2SCy Schubert *cygwin* | *mingw* | *cegcc* ) 5073*b50261e2SCy Schubert if test -f "$output_objdir/$my_outputname.def"; then 5074*b50261e2SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5075*b50261e2SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5076*b50261e2SCy Schubert else 5077*b50261e2SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5078*b50261e2SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5079*b50261e2SCy Schubert fi 5080*b50261e2SCy Schubert ;; 5081*b50261e2SCy Schubert *) 5082*b50261e2SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5083*b50261e2SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5084*b50261e2SCy Schubert ;; 5085*b50261e2SCy Schubert esac 5086*b50261e2SCy Schubert ;; 5087*b50261e2SCy Schubert *) 5088*b50261e2SCy Schubert func_fatal_error "unknown suffix for '$my_dlsyms'" 5089*b50261e2SCy Schubert ;; 5090*b50261e2SCy Schubert esac 5091*b50261e2SCy Schubert else 5092*b50261e2SCy Schubert # We keep going just in case the user didn't refer to 5093*b50261e2SCy Schubert # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5094*b50261e2SCy Schubert # really was required. 5095*b50261e2SCy Schubert 5096*b50261e2SCy Schubert # Nullify the symbol file. 5097*b50261e2SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5098*b50261e2SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5099*b50261e2SCy Schubert fi 5100*b50261e2SCy Schubert} 5101*b50261e2SCy Schubert 5102*b50261e2SCy Schubert# func_cygming_gnu_implib_p ARG 5103*b50261e2SCy Schubert# This predicate returns with zero status (TRUE) if 5104*b50261e2SCy Schubert# ARG is a GNU/binutils-style import library. Returns 5105*b50261e2SCy Schubert# with nonzero status (FALSE) otherwise. 5106*b50261e2SCy Schubertfunc_cygming_gnu_implib_p () 5107*b50261e2SCy Schubert{ 5108*b50261e2SCy Schubert $debug_cmd 5109*b50261e2SCy Schubert 5110*b50261e2SCy Schubert func_to_tool_file "$1" func_convert_file_msys_to_w32 5111*b50261e2SCy Schubert 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)$'` 5112*b50261e2SCy Schubert test -n "$func_cygming_gnu_implib_tmp" 5113*b50261e2SCy Schubert} 5114*b50261e2SCy Schubert 5115*b50261e2SCy Schubert# func_cygming_ms_implib_p ARG 5116*b50261e2SCy Schubert# This predicate returns with zero status (TRUE) if 5117*b50261e2SCy Schubert# ARG is an MS-style import library. Returns 5118*b50261e2SCy Schubert# with nonzero status (FALSE) otherwise. 5119*b50261e2SCy Schubertfunc_cygming_ms_implib_p () 5120*b50261e2SCy Schubert{ 5121*b50261e2SCy Schubert $debug_cmd 5122*b50261e2SCy Schubert 5123*b50261e2SCy Schubert func_to_tool_file "$1" func_convert_file_msys_to_w32 5124*b50261e2SCy Schubert func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5125*b50261e2SCy Schubert test -n "$func_cygming_ms_implib_tmp" 5126*b50261e2SCy Schubert} 5127*b50261e2SCy Schubert 5128*b50261e2SCy Schubert# func_win32_libid arg 5129*b50261e2SCy Schubert# return the library type of file 'arg' 5130*b50261e2SCy Schubert# 5131*b50261e2SCy Schubert# Need a lot of goo to handle *both* DLLs and import libs 5132*b50261e2SCy Schubert# Has to be a shell function in order to 'eat' the argument 5133*b50261e2SCy Schubert# that is supplied when $file_magic_command is called. 5134*b50261e2SCy Schubert# Despite the name, also deal with 64 bit binaries. 5135*b50261e2SCy Schubertfunc_win32_libid () 5136*b50261e2SCy Schubert{ 5137*b50261e2SCy Schubert $debug_cmd 5138*b50261e2SCy Schubert 5139*b50261e2SCy Schubert win32_libid_type=unknown 5140*b50261e2SCy Schubert win32_fileres=`file -L $1 2>/dev/null` 5141*b50261e2SCy Schubert case $win32_fileres in 5142*b50261e2SCy Schubert *ar\ archive\ import\ library*) # definitely import 5143*b50261e2SCy Schubert win32_libid_type="x86 archive import" 5144*b50261e2SCy Schubert ;; 5145*b50261e2SCy Schubert *ar\ archive*) # could be an import, or static 5146*b50261e2SCy Schubert # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5147*b50261e2SCy Schubert if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5148*b50261e2SCy Schubert $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5149*b50261e2SCy Schubert case $nm_interface in 5150*b50261e2SCy Schubert "MS dumpbin") 5151*b50261e2SCy Schubert if func_cygming_ms_implib_p "$1" || 5152*b50261e2SCy Schubert func_cygming_gnu_implib_p "$1" 5153*b50261e2SCy Schubert then 5154*b50261e2SCy Schubert win32_nmres=import 5155*b50261e2SCy Schubert else 5156*b50261e2SCy Schubert win32_nmres= 5157*b50261e2SCy Schubert fi 5158*b50261e2SCy Schubert ;; 5159*b50261e2SCy Schubert *) 5160*b50261e2SCy Schubert func_to_tool_file "$1" func_convert_file_msys_to_w32 5161*b50261e2SCy Schubert win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5162*b50261e2SCy Schubert $SED -n -e ' 5163*b50261e2SCy Schubert 1,100{ 5164*b50261e2SCy Schubert / I /{ 5165*b50261e2SCy Schubert s|.*|import| 5166*b50261e2SCy Schubert p 5167*b50261e2SCy Schubert q 5168*b50261e2SCy Schubert } 5169*b50261e2SCy Schubert }'` 5170*b50261e2SCy Schubert ;; 5171*b50261e2SCy Schubert esac 5172*b50261e2SCy Schubert case $win32_nmres in 5173*b50261e2SCy Schubert import*) win32_libid_type="x86 archive import";; 5174*b50261e2SCy Schubert *) win32_libid_type="x86 archive static";; 5175*b50261e2SCy Schubert esac 5176*b50261e2SCy Schubert fi 5177*b50261e2SCy Schubert ;; 5178*b50261e2SCy Schubert *DLL*) 5179*b50261e2SCy Schubert win32_libid_type="x86 DLL" 5180*b50261e2SCy Schubert ;; 5181*b50261e2SCy Schubert *executable*) # but shell scripts are "executable" too... 5182*b50261e2SCy Schubert case $win32_fileres in 5183*b50261e2SCy Schubert *MS\ Windows\ PE\ Intel*) 5184*b50261e2SCy Schubert win32_libid_type="x86 DLL" 5185*b50261e2SCy Schubert ;; 5186*b50261e2SCy Schubert esac 5187*b50261e2SCy Schubert ;; 5188*b50261e2SCy Schubert esac 5189*b50261e2SCy Schubert $ECHO "$win32_libid_type" 5190*b50261e2SCy Schubert} 5191*b50261e2SCy Schubert 5192*b50261e2SCy Schubert# func_cygming_dll_for_implib ARG 5193*b50261e2SCy Schubert# 5194*b50261e2SCy Schubert# Platform-specific function to extract the 5195*b50261e2SCy Schubert# name of the DLL associated with the specified 5196*b50261e2SCy Schubert# import library ARG. 5197*b50261e2SCy Schubert# Invoked by eval'ing the libtool variable 5198*b50261e2SCy Schubert# $sharedlib_from_linklib_cmd 5199*b50261e2SCy Schubert# Result is available in the variable 5200*b50261e2SCy Schubert# $sharedlib_from_linklib_result 5201*b50261e2SCy Schubertfunc_cygming_dll_for_implib () 5202*b50261e2SCy Schubert{ 5203*b50261e2SCy Schubert $debug_cmd 5204*b50261e2SCy Schubert 5205*b50261e2SCy Schubert sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5206*b50261e2SCy Schubert} 5207*b50261e2SCy Schubert 5208*b50261e2SCy Schubert# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5209*b50261e2SCy Schubert# 5210*b50261e2SCy Schubert# The is the core of a fallback implementation of a 5211*b50261e2SCy Schubert# platform-specific function to extract the name of the 5212*b50261e2SCy Schubert# DLL associated with the specified import library LIBNAME. 5213*b50261e2SCy Schubert# 5214*b50261e2SCy Schubert# SECTION_NAME is either .idata$6 or .idata$7, depending 5215*b50261e2SCy Schubert# on the platform and compiler that created the implib. 5216*b50261e2SCy Schubert# 5217*b50261e2SCy Schubert# Echos the name of the DLL associated with the 5218*b50261e2SCy Schubert# specified import library. 5219*b50261e2SCy Schubertfunc_cygming_dll_for_implib_fallback_core () 5220*b50261e2SCy Schubert{ 5221*b50261e2SCy Schubert $debug_cmd 5222*b50261e2SCy Schubert 5223*b50261e2SCy Schubert match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5224*b50261e2SCy Schubert $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5225*b50261e2SCy Schubert $SED '/^Contents of section '"$match_literal"':/{ 5226*b50261e2SCy Schubert # Place marker at beginning of archive member dllname section 5227*b50261e2SCy Schubert s/.*/====MARK====/ 5228*b50261e2SCy Schubert p 5229*b50261e2SCy Schubert d 5230*b50261e2SCy Schubert } 5231*b50261e2SCy Schubert # These lines can sometimes be longer than 43 characters, but 5232*b50261e2SCy Schubert # are always uninteresting 5233*b50261e2SCy Schubert /:[ ]*file format pe[i]\{,1\}-/d 5234*b50261e2SCy Schubert /^In archive [^:]*:/d 5235*b50261e2SCy Schubert # Ensure marker is printed 5236*b50261e2SCy Schubert /^====MARK====/p 5237*b50261e2SCy Schubert # Remove all lines with less than 43 characters 5238*b50261e2SCy Schubert /^.\{43\}/!d 5239*b50261e2SCy Schubert # From remaining lines, remove first 43 characters 5240*b50261e2SCy Schubert s/^.\{43\}//' | 5241*b50261e2SCy Schubert $SED -n ' 5242*b50261e2SCy Schubert # Join marker and all lines until next marker into a single line 5243*b50261e2SCy Schubert /^====MARK====/ b para 5244*b50261e2SCy Schubert H 5245*b50261e2SCy Schubert $ b para 5246*b50261e2SCy Schubert b 5247*b50261e2SCy Schubert :para 5248*b50261e2SCy Schubert x 5249*b50261e2SCy Schubert s/\n//g 5250*b50261e2SCy Schubert # Remove the marker 5251*b50261e2SCy Schubert s/^====MARK====// 5252*b50261e2SCy Schubert # Remove trailing dots and whitespace 5253*b50261e2SCy Schubert s/[\. \t]*$// 5254*b50261e2SCy Schubert # Print 5255*b50261e2SCy Schubert /./p' | 5256*b50261e2SCy Schubert # we now have a list, one entry per line, of the stringified 5257*b50261e2SCy Schubert # contents of the appropriate section of all members of the 5258*b50261e2SCy Schubert # archive that possess that section. Heuristic: eliminate 5259*b50261e2SCy Schubert # all those that have a first or second character that is 5260*b50261e2SCy Schubert # a '.' (that is, objdump's representation of an unprintable 5261*b50261e2SCy Schubert # character.) This should work for all archives with less than 5262*b50261e2SCy Schubert # 0x302f exports -- but will fail for DLLs whose name actually 5263*b50261e2SCy Schubert # begins with a literal '.' or a single character followed by 5264*b50261e2SCy Schubert # a '.'. 5265*b50261e2SCy Schubert # 5266*b50261e2SCy Schubert # Of those that remain, print the first one. 5267*b50261e2SCy Schubert $SED -e '/^\./d;/^.\./d;q' 5268*b50261e2SCy Schubert} 5269*b50261e2SCy Schubert 5270*b50261e2SCy Schubert# func_cygming_dll_for_implib_fallback ARG 5271*b50261e2SCy Schubert# Platform-specific function to extract the 5272*b50261e2SCy Schubert# name of the DLL associated with the specified 5273*b50261e2SCy Schubert# import library ARG. 5274*b50261e2SCy Schubert# 5275*b50261e2SCy Schubert# This fallback implementation is for use when $DLLTOOL 5276*b50261e2SCy Schubert# does not support the --identify-strict option. 5277*b50261e2SCy Schubert# Invoked by eval'ing the libtool variable 5278*b50261e2SCy Schubert# $sharedlib_from_linklib_cmd 5279*b50261e2SCy Schubert# Result is available in the variable 5280*b50261e2SCy Schubert# $sharedlib_from_linklib_result 5281*b50261e2SCy Schubertfunc_cygming_dll_for_implib_fallback () 5282*b50261e2SCy Schubert{ 5283*b50261e2SCy Schubert $debug_cmd 5284*b50261e2SCy Schubert 5285*b50261e2SCy Schubert if func_cygming_gnu_implib_p "$1"; then 5286*b50261e2SCy Schubert # binutils import library 5287*b50261e2SCy Schubert sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5288*b50261e2SCy Schubert elif func_cygming_ms_implib_p "$1"; then 5289*b50261e2SCy Schubert # ms-generated import library 5290*b50261e2SCy Schubert sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5291*b50261e2SCy Schubert else 5292*b50261e2SCy Schubert # unknown 5293*b50261e2SCy Schubert sharedlib_from_linklib_result= 5294*b50261e2SCy Schubert fi 5295*b50261e2SCy Schubert} 5296*b50261e2SCy Schubert 5297*b50261e2SCy Schubert 5298*b50261e2SCy Schubert# func_extract_an_archive dir oldlib 5299*b50261e2SCy Schubertfunc_extract_an_archive () 5300*b50261e2SCy Schubert{ 5301*b50261e2SCy Schubert $debug_cmd 5302*b50261e2SCy Schubert 5303*b50261e2SCy Schubert f_ex_an_ar_dir=$1; shift 5304*b50261e2SCy Schubert f_ex_an_ar_oldlib=$1 5305*b50261e2SCy Schubert if test yes = "$lock_old_archive_extraction"; then 5306*b50261e2SCy Schubert lockfile=$f_ex_an_ar_oldlib.lock 5307*b50261e2SCy Schubert until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5308*b50261e2SCy Schubert func_echo "Waiting for $lockfile to be removed" 5309*b50261e2SCy Schubert sleep 2 5310*b50261e2SCy Schubert done 5311*b50261e2SCy Schubert fi 5312*b50261e2SCy Schubert func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5313*b50261e2SCy Schubert 'stat=$?; rm -f "$lockfile"; exit $stat' 5314*b50261e2SCy Schubert if test yes = "$lock_old_archive_extraction"; then 5315*b50261e2SCy Schubert $opt_dry_run || rm -f "$lockfile" 5316*b50261e2SCy Schubert fi 5317*b50261e2SCy Schubert if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5318*b50261e2SCy Schubert : 5319*b50261e2SCy Schubert else 5320*b50261e2SCy Schubert func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5321*b50261e2SCy Schubert fi 5322*b50261e2SCy Schubert} 5323*b50261e2SCy Schubert 5324*b50261e2SCy Schubert 5325*b50261e2SCy Schubert# func_extract_archives gentop oldlib ... 5326*b50261e2SCy Schubertfunc_extract_archives () 5327*b50261e2SCy Schubert{ 5328*b50261e2SCy Schubert $debug_cmd 5329*b50261e2SCy Schubert 5330*b50261e2SCy Schubert my_gentop=$1; shift 5331*b50261e2SCy Schubert my_oldlibs=${1+"$@"} 5332*b50261e2SCy Schubert my_oldobjs= 5333*b50261e2SCy Schubert my_xlib= 5334*b50261e2SCy Schubert my_xabs= 5335*b50261e2SCy Schubert my_xdir= 5336*b50261e2SCy Schubert 5337*b50261e2SCy Schubert for my_xlib in $my_oldlibs; do 5338*b50261e2SCy Schubert # Extract the objects. 5339*b50261e2SCy Schubert case $my_xlib in 5340*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5341*b50261e2SCy Schubert *) my_xabs=`pwd`"/$my_xlib" ;; 5342*b50261e2SCy Schubert esac 5343*b50261e2SCy Schubert func_basename "$my_xlib" 5344*b50261e2SCy Schubert my_xlib=$func_basename_result 5345*b50261e2SCy Schubert my_xlib_u=$my_xlib 5346*b50261e2SCy Schubert while :; do 5347*b50261e2SCy Schubert case " $extracted_archives " in 5348*b50261e2SCy Schubert *" $my_xlib_u "*) 5349*b50261e2SCy Schubert func_arith $extracted_serial + 1 5350*b50261e2SCy Schubert extracted_serial=$func_arith_result 5351*b50261e2SCy Schubert my_xlib_u=lt$extracted_serial-$my_xlib ;; 5352*b50261e2SCy Schubert *) break ;; 5353*b50261e2SCy Schubert esac 5354*b50261e2SCy Schubert done 5355*b50261e2SCy Schubert extracted_archives="$extracted_archives $my_xlib_u" 5356*b50261e2SCy Schubert my_xdir=$my_gentop/$my_xlib_u 5357*b50261e2SCy Schubert 5358*b50261e2SCy Schubert func_mkdir_p "$my_xdir" 5359*b50261e2SCy Schubert 5360*b50261e2SCy Schubert case $host in 5361*b50261e2SCy Schubert *-darwin*) 5362*b50261e2SCy Schubert func_verbose "Extracting $my_xabs" 5363*b50261e2SCy Schubert # Do not bother doing anything if just a dry run 5364*b50261e2SCy Schubert $opt_dry_run || { 5365*b50261e2SCy Schubert darwin_orig_dir=`pwd` 5366*b50261e2SCy Schubert cd $my_xdir || exit $? 5367*b50261e2SCy Schubert darwin_archive=$my_xabs 5368*b50261e2SCy Schubert darwin_curdir=`pwd` 5369*b50261e2SCy Schubert func_basename "$darwin_archive" 5370*b50261e2SCy Schubert darwin_base_archive=$func_basename_result 5371*b50261e2SCy Schubert darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5372*b50261e2SCy Schubert if test -n "$darwin_arches"; then 5373*b50261e2SCy Schubert darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5374*b50261e2SCy Schubert darwin_arch= 5375*b50261e2SCy Schubert func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5376*b50261e2SCy Schubert for darwin_arch in $darwin_arches; do 5377*b50261e2SCy Schubert func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5378*b50261e2SCy Schubert $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5379*b50261e2SCy Schubert cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5380*b50261e2SCy Schubert func_extract_an_archive "`pwd`" "$darwin_base_archive" 5381*b50261e2SCy Schubert cd "$darwin_curdir" 5382*b50261e2SCy Schubert $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5383*b50261e2SCy Schubert done # $darwin_arches 5384*b50261e2SCy Schubert ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5385*b50261e2SCy Schubert darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5386*b50261e2SCy Schubert darwin_file= 5387*b50261e2SCy Schubert darwin_files= 5388*b50261e2SCy Schubert for darwin_file in $darwin_filelist; do 5389*b50261e2SCy Schubert darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5390*b50261e2SCy Schubert $LIPO -create -output "$darwin_file" $darwin_files 5391*b50261e2SCy Schubert done # $darwin_filelist 5392*b50261e2SCy Schubert $RM -rf unfat-$$ 5393*b50261e2SCy Schubert cd "$darwin_orig_dir" 5394*b50261e2SCy Schubert else 5395*b50261e2SCy Schubert cd $darwin_orig_dir 5396*b50261e2SCy Schubert func_extract_an_archive "$my_xdir" "$my_xabs" 5397*b50261e2SCy Schubert fi # $darwin_arches 5398*b50261e2SCy Schubert } # !$opt_dry_run 5399*b50261e2SCy Schubert ;; 5400*b50261e2SCy Schubert *) 5401*b50261e2SCy Schubert func_extract_an_archive "$my_xdir" "$my_xabs" 5402*b50261e2SCy Schubert ;; 5403*b50261e2SCy Schubert esac 5404*b50261e2SCy Schubert my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5405*b50261e2SCy Schubert done 5406*b50261e2SCy Schubert 5407*b50261e2SCy Schubert func_extract_archives_result=$my_oldobjs 5408*b50261e2SCy Schubert} 5409*b50261e2SCy Schubert 5410*b50261e2SCy Schubert 5411*b50261e2SCy Schubert# func_emit_wrapper [arg=no] 5412*b50261e2SCy Schubert# 5413*b50261e2SCy Schubert# Emit a libtool wrapper script on stdout. 5414*b50261e2SCy Schubert# Don't directly open a file because we may want to 5415*b50261e2SCy Schubert# incorporate the script contents within a cygwin/mingw 5416*b50261e2SCy Schubert# wrapper executable. Must ONLY be called from within 5417*b50261e2SCy Schubert# func_mode_link because it depends on a number of variables 5418*b50261e2SCy Schubert# set therein. 5419*b50261e2SCy Schubert# 5420*b50261e2SCy Schubert# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5421*b50261e2SCy Schubert# variable will take. If 'yes', then the emitted script 5422*b50261e2SCy Schubert# will assume that the directory where it is stored is 5423*b50261e2SCy Schubert# the $objdir directory. This is a cygwin/mingw-specific 5424*b50261e2SCy Schubert# behavior. 5425*b50261e2SCy Schubertfunc_emit_wrapper () 5426*b50261e2SCy Schubert{ 5427*b50261e2SCy Schubert func_emit_wrapper_arg1=${1-no} 5428*b50261e2SCy Schubert 5429*b50261e2SCy Schubert $ECHO "\ 5430*b50261e2SCy Schubert#! $SHELL 5431*b50261e2SCy Schubert 5432*b50261e2SCy Schubert# $output - temporary wrapper script for $objdir/$outputname 5433*b50261e2SCy Schubert# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5434*b50261e2SCy Schubert# 5435*b50261e2SCy Schubert# The $output program cannot be directly executed until all the libtool 5436*b50261e2SCy Schubert# libraries that it depends on are installed. 5437*b50261e2SCy Schubert# 5438*b50261e2SCy Schubert# This wrapper script should never be moved out of the build directory. 5439*b50261e2SCy Schubert# If it is, it will not operate correctly. 5440*b50261e2SCy Schubert 5441*b50261e2SCy Schubert# Sed substitution that helps us do robust quoting. It backslashifies 5442*b50261e2SCy Schubert# metacharacters that are still active within double-quoted strings. 5443*b50261e2SCy Schubertsed_quote_subst='$sed_quote_subst' 5444*b50261e2SCy Schubert 5445*b50261e2SCy Schubert# Be Bourne compatible 5446*b50261e2SCy Schubertif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5447*b50261e2SCy Schubert emulate sh 5448*b50261e2SCy Schubert NULLCMD=: 5449*b50261e2SCy Schubert # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5450*b50261e2SCy Schubert # is contrary to our usage. Disable this feature. 5451*b50261e2SCy Schubert alias -g '\${1+\"\$@\"}'='\"\$@\"' 5452*b50261e2SCy Schubert setopt NO_GLOB_SUBST 5453*b50261e2SCy Schubertelse 5454*b50261e2SCy Schubert case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5455*b50261e2SCy Schubertfi 5456*b50261e2SCy SchubertBIN_SH=xpg4; export BIN_SH # for Tru64 5457*b50261e2SCy SchubertDUALCASE=1; export DUALCASE # for MKS sh 5458*b50261e2SCy Schubert 5459*b50261e2SCy Schubert# The HP-UX ksh and POSIX shell print the target directory to stdout 5460*b50261e2SCy Schubert# if CDPATH is set. 5461*b50261e2SCy Schubert(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5462*b50261e2SCy Schubert 5463*b50261e2SCy Schubertrelink_command=\"$relink_command\" 5464*b50261e2SCy Schubert 5465*b50261e2SCy Schubert# This environment variable determines our operation mode. 5466*b50261e2SCy Schubertif test \"\$libtool_install_magic\" = \"$magic\"; then 5467*b50261e2SCy Schubert # install mode needs the following variables: 5468*b50261e2SCy Schubert generated_by_libtool_version='$macro_version' 5469*b50261e2SCy Schubert notinst_deplibs='$notinst_deplibs' 5470*b50261e2SCy Schubertelse 5471*b50261e2SCy Schubert # When we are sourced in execute mode, \$file and \$ECHO are already set. 5472*b50261e2SCy Schubert if test \"\$libtool_execute_magic\" != \"$magic\"; then 5473*b50261e2SCy Schubert file=\"\$0\"" 5474*b50261e2SCy Schubert 5475*b50261e2SCy Schubert func_quote_arg pretty "$ECHO" 5476*b50261e2SCy Schubert qECHO=$func_quote_arg_result 5477*b50261e2SCy Schubert $ECHO "\ 5478*b50261e2SCy Schubert 5479*b50261e2SCy Schubert# A function that is used when there is no print builtin or printf. 5480*b50261e2SCy Schubertfunc_fallback_echo () 5481*b50261e2SCy Schubert{ 5482*b50261e2SCy Schubert eval 'cat <<_LTECHO_EOF 5483*b50261e2SCy Schubert\$1 5484*b50261e2SCy Schubert_LTECHO_EOF' 5485*b50261e2SCy Schubert} 5486*b50261e2SCy Schubert ECHO=$qECHO 5487*b50261e2SCy Schubert fi 5488*b50261e2SCy Schubert 5489*b50261e2SCy Schubert# Very basic option parsing. These options are (a) specific to 5490*b50261e2SCy Schubert# the libtool wrapper, (b) are identical between the wrapper 5491*b50261e2SCy Schubert# /script/ and the wrapper /executable/ that is used only on 5492*b50261e2SCy Schubert# windows platforms, and (c) all begin with the string "--lt-" 5493*b50261e2SCy Schubert# (application programs are unlikely to have options that match 5494*b50261e2SCy Schubert# this pattern). 5495*b50261e2SCy Schubert# 5496*b50261e2SCy Schubert# There are only two supported options: --lt-debug and 5497*b50261e2SCy Schubert# --lt-dump-script. There is, deliberately, no --lt-help. 5498*b50261e2SCy Schubert# 5499*b50261e2SCy Schubert# The first argument to this parsing function should be the 5500*b50261e2SCy Schubert# script's $0 value, followed by "$@". 5501*b50261e2SCy Schubertlt_option_debug= 5502*b50261e2SCy Schubertfunc_parse_lt_options () 5503*b50261e2SCy Schubert{ 5504*b50261e2SCy Schubert lt_script_arg0=\$0 5505*b50261e2SCy Schubert shift 5506*b50261e2SCy Schubert for lt_opt 5507*b50261e2SCy Schubert do 5508*b50261e2SCy Schubert case \"\$lt_opt\" in 5509*b50261e2SCy Schubert --lt-debug) lt_option_debug=1 ;; 5510*b50261e2SCy Schubert --lt-dump-script) 5511*b50261e2SCy Schubert lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5512*b50261e2SCy Schubert test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5513*b50261e2SCy Schubert lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5514*b50261e2SCy Schubert cat \"\$lt_dump_D/\$lt_dump_F\" 5515*b50261e2SCy Schubert exit 0 5516*b50261e2SCy Schubert ;; 5517*b50261e2SCy Schubert --lt-*) 5518*b50261e2SCy Schubert \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5519*b50261e2SCy Schubert exit 1 5520*b50261e2SCy Schubert ;; 5521*b50261e2SCy Schubert esac 5522*b50261e2SCy Schubert done 5523*b50261e2SCy Schubert 5524*b50261e2SCy Schubert # Print the debug banner immediately: 5525*b50261e2SCy Schubert if test -n \"\$lt_option_debug\"; then 5526*b50261e2SCy Schubert echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5527*b50261e2SCy Schubert fi 5528*b50261e2SCy Schubert} 5529*b50261e2SCy Schubert 5530*b50261e2SCy Schubert# Used when --lt-debug. Prints its arguments to stdout 5531*b50261e2SCy Schubert# (redirection is the responsibility of the caller) 5532*b50261e2SCy Schubertfunc_lt_dump_args () 5533*b50261e2SCy Schubert{ 5534*b50261e2SCy Schubert lt_dump_args_N=1; 5535*b50261e2SCy Schubert for lt_arg 5536*b50261e2SCy Schubert do 5537*b50261e2SCy Schubert \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5538*b50261e2SCy Schubert lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5539*b50261e2SCy Schubert done 5540*b50261e2SCy Schubert} 5541*b50261e2SCy Schubert 5542*b50261e2SCy Schubert# Core function for launching the target application 5543*b50261e2SCy Schubertfunc_exec_program_core () 5544*b50261e2SCy Schubert{ 5545*b50261e2SCy Schubert" 5546*b50261e2SCy Schubert case $host in 5547*b50261e2SCy Schubert # Backslashes separate directories on plain windows 5548*b50261e2SCy Schubert *-*-mingw | *-*-os2* | *-cegcc*) 5549*b50261e2SCy Schubert $ECHO "\ 5550*b50261e2SCy Schubert if test -n \"\$lt_option_debug\"; then 5551*b50261e2SCy Schubert \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5552*b50261e2SCy Schubert func_lt_dump_args \${1+\"\$@\"} 1>&2 5553*b50261e2SCy Schubert fi 5554*b50261e2SCy Schubert exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5555*b50261e2SCy Schubert" 5556*b50261e2SCy Schubert ;; 5557*b50261e2SCy Schubert 5558*b50261e2SCy Schubert *) 5559*b50261e2SCy Schubert $ECHO "\ 5560*b50261e2SCy Schubert if test -n \"\$lt_option_debug\"; then 5561*b50261e2SCy Schubert \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5562*b50261e2SCy Schubert func_lt_dump_args \${1+\"\$@\"} 1>&2 5563*b50261e2SCy Schubert fi 5564*b50261e2SCy Schubert exec \"\$progdir/\$program\" \${1+\"\$@\"} 5565*b50261e2SCy Schubert" 5566*b50261e2SCy Schubert ;; 5567*b50261e2SCy Schubert esac 5568*b50261e2SCy Schubert $ECHO "\ 5569*b50261e2SCy Schubert \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5570*b50261e2SCy Schubert exit 1 5571*b50261e2SCy Schubert} 5572*b50261e2SCy Schubert 5573*b50261e2SCy Schubert# A function to encapsulate launching the target application 5574*b50261e2SCy Schubert# Strips options in the --lt-* namespace from \$@ and 5575*b50261e2SCy Schubert# launches target application with the remaining arguments. 5576*b50261e2SCy Schubertfunc_exec_program () 5577*b50261e2SCy Schubert{ 5578*b50261e2SCy Schubert case \" \$* \" in 5579*b50261e2SCy Schubert *\\ --lt-*) 5580*b50261e2SCy Schubert for lt_wr_arg 5581*b50261e2SCy Schubert do 5582*b50261e2SCy Schubert case \$lt_wr_arg in 5583*b50261e2SCy Schubert --lt-*) ;; 5584*b50261e2SCy Schubert *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5585*b50261e2SCy Schubert esac 5586*b50261e2SCy Schubert shift 5587*b50261e2SCy Schubert done ;; 5588*b50261e2SCy Schubert esac 5589*b50261e2SCy Schubert func_exec_program_core \${1+\"\$@\"} 5590*b50261e2SCy Schubert} 5591*b50261e2SCy Schubert 5592*b50261e2SCy Schubert # Parse options 5593*b50261e2SCy Schubert func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5594*b50261e2SCy Schubert 5595*b50261e2SCy Schubert # Find the directory that this script lives in. 5596*b50261e2SCy Schubert thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5597*b50261e2SCy Schubert test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5598*b50261e2SCy Schubert 5599*b50261e2SCy Schubert # Follow symbolic links until we get to the real thisdir. 5600*b50261e2SCy Schubert file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5601*b50261e2SCy Schubert while test -n \"\$file\"; do 5602*b50261e2SCy Schubert destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5603*b50261e2SCy Schubert 5604*b50261e2SCy Schubert # If there was a directory component, then change thisdir. 5605*b50261e2SCy Schubert if test \"x\$destdir\" != \"x\$file\"; then 5606*b50261e2SCy Schubert case \"\$destdir\" in 5607*b50261e2SCy Schubert [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5608*b50261e2SCy Schubert *) thisdir=\"\$thisdir/\$destdir\" ;; 5609*b50261e2SCy Schubert esac 5610*b50261e2SCy Schubert fi 5611*b50261e2SCy Schubert 5612*b50261e2SCy Schubert file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5613*b50261e2SCy Schubert file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5614*b50261e2SCy Schubert done 5615*b50261e2SCy Schubert 5616*b50261e2SCy Schubert # Usually 'no', except on cygwin/mingw when embedded into 5617*b50261e2SCy Schubert # the cwrapper. 5618*b50261e2SCy Schubert WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5619*b50261e2SCy Schubert if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5620*b50261e2SCy Schubert # special case for '.' 5621*b50261e2SCy Schubert if test \"\$thisdir\" = \".\"; then 5622*b50261e2SCy Schubert thisdir=\`pwd\` 5623*b50261e2SCy Schubert fi 5624*b50261e2SCy Schubert # remove .libs from thisdir 5625*b50261e2SCy Schubert case \"\$thisdir\" in 5626*b50261e2SCy Schubert *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5627*b50261e2SCy Schubert $objdir ) thisdir=. ;; 5628*b50261e2SCy Schubert esac 5629*b50261e2SCy Schubert fi 5630*b50261e2SCy Schubert 5631*b50261e2SCy Schubert # Try to get the absolute directory name. 5632*b50261e2SCy Schubert absdir=\`cd \"\$thisdir\" && pwd\` 5633*b50261e2SCy Schubert test -n \"\$absdir\" && thisdir=\"\$absdir\" 5634*b50261e2SCy Schubert" 5635*b50261e2SCy Schubert 5636*b50261e2SCy Schubert if test yes = "$fast_install"; then 5637*b50261e2SCy Schubert $ECHO "\ 5638*b50261e2SCy Schubert program=lt-'$outputname'$exeext 5639*b50261e2SCy Schubert progdir=\"\$thisdir/$objdir\" 5640*b50261e2SCy Schubert 5641*b50261e2SCy Schubert if test ! -f \"\$progdir/\$program\" || 5642*b50261e2SCy Schubert { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5643*b50261e2SCy Schubert test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5644*b50261e2SCy Schubert 5645*b50261e2SCy Schubert file=\"\$\$-\$program\" 5646*b50261e2SCy Schubert 5647*b50261e2SCy Schubert if test ! -d \"\$progdir\"; then 5648*b50261e2SCy Schubert $MKDIR \"\$progdir\" 5649*b50261e2SCy Schubert else 5650*b50261e2SCy Schubert $RM \"\$progdir/\$file\" 5651*b50261e2SCy Schubert fi" 5652*b50261e2SCy Schubert 5653*b50261e2SCy Schubert $ECHO "\ 5654*b50261e2SCy Schubert 5655*b50261e2SCy Schubert # relink executable if necessary 5656*b50261e2SCy Schubert if test -n \"\$relink_command\"; then 5657*b50261e2SCy Schubert if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5658*b50261e2SCy Schubert else 5659*b50261e2SCy Schubert \$ECHO \"\$relink_command_output\" >&2 5660*b50261e2SCy Schubert $RM \"\$progdir/\$file\" 5661*b50261e2SCy Schubert exit 1 5662*b50261e2SCy Schubert fi 5663*b50261e2SCy Schubert fi 5664*b50261e2SCy Schubert 5665*b50261e2SCy Schubert $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5666*b50261e2SCy Schubert { $RM \"\$progdir/\$program\"; 5667*b50261e2SCy Schubert $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5668*b50261e2SCy Schubert $RM \"\$progdir/\$file\" 5669*b50261e2SCy Schubert fi" 5670*b50261e2SCy Schubert else 5671*b50261e2SCy Schubert $ECHO "\ 5672*b50261e2SCy Schubert program='$outputname' 5673*b50261e2SCy Schubert progdir=\"\$thisdir/$objdir\" 5674*b50261e2SCy Schubert" 5675*b50261e2SCy Schubert fi 5676*b50261e2SCy Schubert 5677*b50261e2SCy Schubert $ECHO "\ 5678*b50261e2SCy Schubert 5679*b50261e2SCy Schubert if test -f \"\$progdir/\$program\"; then" 5680*b50261e2SCy Schubert 5681*b50261e2SCy Schubert # fixup the dll searchpath if we need to. 5682*b50261e2SCy Schubert # 5683*b50261e2SCy Schubert # Fix the DLL searchpath if we need to. Do this before prepending 5684*b50261e2SCy Schubert # to shlibpath, because on Windows, both are PATH and uninstalled 5685*b50261e2SCy Schubert # libraries must come first. 5686*b50261e2SCy Schubert if test -n "$dllsearchpath"; then 5687*b50261e2SCy Schubert $ECHO "\ 5688*b50261e2SCy Schubert # Add the dll search path components to the executable PATH 5689*b50261e2SCy Schubert PATH=$dllsearchpath:\$PATH 5690*b50261e2SCy Schubert" 5691*b50261e2SCy Schubert fi 5692*b50261e2SCy Schubert 5693*b50261e2SCy Schubert # Export our shlibpath_var if we have one. 5694*b50261e2SCy Schubert if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5695*b50261e2SCy Schubert $ECHO "\ 5696*b50261e2SCy Schubert # Add our own library path to $shlibpath_var 5697*b50261e2SCy Schubert $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5698*b50261e2SCy Schubert 5699*b50261e2SCy Schubert # Some systems cannot cope with colon-terminated $shlibpath_var 5700*b50261e2SCy Schubert # The second colon is a workaround for a bug in BeOS R4 sed 5701*b50261e2SCy Schubert $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5702*b50261e2SCy Schubert 5703*b50261e2SCy Schubert export $shlibpath_var 5704*b50261e2SCy Schubert" 5705*b50261e2SCy Schubert fi 5706*b50261e2SCy Schubert 5707*b50261e2SCy Schubert $ECHO "\ 5708*b50261e2SCy Schubert if test \"\$libtool_execute_magic\" != \"$magic\"; then 5709*b50261e2SCy Schubert # Run the actual program with our arguments. 5710*b50261e2SCy Schubert func_exec_program \${1+\"\$@\"} 5711*b50261e2SCy Schubert fi 5712*b50261e2SCy Schubert else 5713*b50261e2SCy Schubert # The program doesn't exist. 5714*b50261e2SCy Schubert \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5715*b50261e2SCy Schubert \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5716*b50261e2SCy Schubert \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5717*b50261e2SCy Schubert exit 1 5718*b50261e2SCy Schubert fi 5719*b50261e2SCy Schubertfi\ 5720*b50261e2SCy Schubert" 5721*b50261e2SCy Schubert} 5722*b50261e2SCy Schubert 5723*b50261e2SCy Schubert 5724*b50261e2SCy Schubert# func_emit_cwrapperexe_src 5725*b50261e2SCy Schubert# emit the source code for a wrapper executable on stdout 5726*b50261e2SCy Schubert# Must ONLY be called from within func_mode_link because 5727*b50261e2SCy Schubert# it depends on a number of variable set therein. 5728*b50261e2SCy Schubertfunc_emit_cwrapperexe_src () 5729*b50261e2SCy Schubert{ 5730*b50261e2SCy Schubert cat <<EOF 5731*b50261e2SCy Schubert 5732*b50261e2SCy Schubert/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5733*b50261e2SCy Schubert Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5734*b50261e2SCy Schubert 5735*b50261e2SCy Schubert The $output program cannot be directly executed until all the libtool 5736*b50261e2SCy Schubert libraries that it depends on are installed. 5737*b50261e2SCy Schubert 5738*b50261e2SCy Schubert This wrapper executable should never be moved out of the build directory. 5739*b50261e2SCy Schubert If it is, it will not operate correctly. 5740*b50261e2SCy Schubert*/ 5741*b50261e2SCy SchubertEOF 5742*b50261e2SCy Schubert cat <<"EOF" 5743*b50261e2SCy Schubert#ifdef _MSC_VER 5744*b50261e2SCy Schubert# define _CRT_SECURE_NO_DEPRECATE 1 5745*b50261e2SCy Schubert#endif 5746*b50261e2SCy Schubert#include <stdio.h> 5747*b50261e2SCy Schubert#include <stdlib.h> 5748*b50261e2SCy Schubert#ifdef _MSC_VER 5749*b50261e2SCy Schubert# include <direct.h> 5750*b50261e2SCy Schubert# include <process.h> 5751*b50261e2SCy Schubert# include <io.h> 5752*b50261e2SCy Schubert#else 5753*b50261e2SCy Schubert# include <unistd.h> 5754*b50261e2SCy Schubert# include <stdint.h> 5755*b50261e2SCy Schubert# ifdef __CYGWIN__ 5756*b50261e2SCy Schubert# include <io.h> 5757*b50261e2SCy Schubert# endif 5758*b50261e2SCy Schubert#endif 5759*b50261e2SCy Schubert#include <malloc.h> 5760*b50261e2SCy Schubert#include <stdarg.h> 5761*b50261e2SCy Schubert#include <assert.h> 5762*b50261e2SCy Schubert#include <string.h> 5763*b50261e2SCy Schubert#include <ctype.h> 5764*b50261e2SCy Schubert#include <errno.h> 5765*b50261e2SCy Schubert#include <fcntl.h> 5766*b50261e2SCy Schubert#include <sys/stat.h> 5767*b50261e2SCy Schubert 5768*b50261e2SCy Schubert#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5769*b50261e2SCy Schubert 5770*b50261e2SCy Schubert/* declarations of non-ANSI functions */ 5771*b50261e2SCy Schubert#if defined __MINGW32__ 5772*b50261e2SCy Schubert# ifdef __STRICT_ANSI__ 5773*b50261e2SCy Schubertint _putenv (const char *); 5774*b50261e2SCy Schubert# endif 5775*b50261e2SCy Schubert#elif defined __CYGWIN__ 5776*b50261e2SCy Schubert# ifdef __STRICT_ANSI__ 5777*b50261e2SCy Schubertchar *realpath (const char *, char *); 5778*b50261e2SCy Schubertint putenv (char *); 5779*b50261e2SCy Schubertint setenv (const char *, const char *, int); 5780*b50261e2SCy Schubert# endif 5781*b50261e2SCy Schubert/* #elif defined other_platform || defined ... */ 5782*b50261e2SCy Schubert#endif 5783*b50261e2SCy Schubert 5784*b50261e2SCy Schubert/* portability defines, excluding path handling macros */ 5785*b50261e2SCy Schubert#if defined _MSC_VER 5786*b50261e2SCy Schubert# define setmode _setmode 5787*b50261e2SCy Schubert# define stat _stat 5788*b50261e2SCy Schubert# define chmod _chmod 5789*b50261e2SCy Schubert# define getcwd _getcwd 5790*b50261e2SCy Schubert# define putenv _putenv 5791*b50261e2SCy Schubert# define S_IXUSR _S_IEXEC 5792*b50261e2SCy Schubert#elif defined __MINGW32__ 5793*b50261e2SCy Schubert# define setmode _setmode 5794*b50261e2SCy Schubert# define stat _stat 5795*b50261e2SCy Schubert# define chmod _chmod 5796*b50261e2SCy Schubert# define getcwd _getcwd 5797*b50261e2SCy Schubert# define putenv _putenv 5798*b50261e2SCy Schubert#elif defined __CYGWIN__ 5799*b50261e2SCy Schubert# define HAVE_SETENV 5800*b50261e2SCy Schubert# define FOPEN_WB "wb" 5801*b50261e2SCy Schubert/* #elif defined other platforms ... */ 5802*b50261e2SCy Schubert#endif 5803*b50261e2SCy Schubert 5804*b50261e2SCy Schubert#if defined PATH_MAX 5805*b50261e2SCy Schubert# define LT_PATHMAX PATH_MAX 5806*b50261e2SCy Schubert#elif defined MAXPATHLEN 5807*b50261e2SCy Schubert# define LT_PATHMAX MAXPATHLEN 5808*b50261e2SCy Schubert#else 5809*b50261e2SCy Schubert# define LT_PATHMAX 1024 5810*b50261e2SCy Schubert#endif 5811*b50261e2SCy Schubert 5812*b50261e2SCy Schubert#ifndef S_IXOTH 5813*b50261e2SCy Schubert# define S_IXOTH 0 5814*b50261e2SCy Schubert#endif 5815*b50261e2SCy Schubert#ifndef S_IXGRP 5816*b50261e2SCy Schubert# define S_IXGRP 0 5817*b50261e2SCy Schubert#endif 5818*b50261e2SCy Schubert 5819*b50261e2SCy Schubert/* path handling portability macros */ 5820*b50261e2SCy Schubert#ifndef DIR_SEPARATOR 5821*b50261e2SCy Schubert# define DIR_SEPARATOR '/' 5822*b50261e2SCy Schubert# define PATH_SEPARATOR ':' 5823*b50261e2SCy Schubert#endif 5824*b50261e2SCy Schubert 5825*b50261e2SCy Schubert#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5826*b50261e2SCy Schubert defined __OS2__ 5827*b50261e2SCy Schubert# define HAVE_DOS_BASED_FILE_SYSTEM 5828*b50261e2SCy Schubert# define FOPEN_WB "wb" 5829*b50261e2SCy Schubert# ifndef DIR_SEPARATOR_2 5830*b50261e2SCy Schubert# define DIR_SEPARATOR_2 '\\' 5831*b50261e2SCy Schubert# endif 5832*b50261e2SCy Schubert# ifndef PATH_SEPARATOR_2 5833*b50261e2SCy Schubert# define PATH_SEPARATOR_2 ';' 5834*b50261e2SCy Schubert# endif 5835*b50261e2SCy Schubert#endif 5836*b50261e2SCy Schubert 5837*b50261e2SCy Schubert#ifndef DIR_SEPARATOR_2 5838*b50261e2SCy Schubert# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5839*b50261e2SCy Schubert#else /* DIR_SEPARATOR_2 */ 5840*b50261e2SCy Schubert# define IS_DIR_SEPARATOR(ch) \ 5841*b50261e2SCy Schubert (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5842*b50261e2SCy Schubert#endif /* DIR_SEPARATOR_2 */ 5843*b50261e2SCy Schubert 5844*b50261e2SCy Schubert#ifndef PATH_SEPARATOR_2 5845*b50261e2SCy Schubert# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5846*b50261e2SCy Schubert#else /* PATH_SEPARATOR_2 */ 5847*b50261e2SCy Schubert# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5848*b50261e2SCy Schubert#endif /* PATH_SEPARATOR_2 */ 5849*b50261e2SCy Schubert 5850*b50261e2SCy Schubert#ifndef FOPEN_WB 5851*b50261e2SCy Schubert# define FOPEN_WB "w" 5852*b50261e2SCy Schubert#endif 5853*b50261e2SCy Schubert#ifndef _O_BINARY 5854*b50261e2SCy Schubert# define _O_BINARY 0 5855*b50261e2SCy Schubert#endif 5856*b50261e2SCy Schubert 5857*b50261e2SCy Schubert#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5858*b50261e2SCy Schubert#define XFREE(stale) do { \ 5859*b50261e2SCy Schubert if (stale) { free (stale); stale = 0; } \ 5860*b50261e2SCy Schubert} while (0) 5861*b50261e2SCy Schubert 5862*b50261e2SCy Schubert#if defined LT_DEBUGWRAPPER 5863*b50261e2SCy Schubertstatic int lt_debug = 1; 5864*b50261e2SCy Schubert#else 5865*b50261e2SCy Schubertstatic int lt_debug = 0; 5866*b50261e2SCy Schubert#endif 5867*b50261e2SCy Schubert 5868*b50261e2SCy Schubertconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5869*b50261e2SCy Schubert 5870*b50261e2SCy Schubertvoid *xmalloc (size_t num); 5871*b50261e2SCy Schubertchar *xstrdup (const char *string); 5872*b50261e2SCy Schubertconst char *base_name (const char *name); 5873*b50261e2SCy Schubertchar *find_executable (const char *wrapper); 5874*b50261e2SCy Schubertchar *chase_symlinks (const char *pathspec); 5875*b50261e2SCy Schubertint make_executable (const char *path); 5876*b50261e2SCy Schubertint check_executable (const char *path); 5877*b50261e2SCy Schubertchar *strendzap (char *str, const char *pat); 5878*b50261e2SCy Schubertvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5879*b50261e2SCy Schubertvoid lt_fatal (const char *file, int line, const char *message, ...); 5880*b50261e2SCy Schubertstatic const char *nonnull (const char *s); 5881*b50261e2SCy Schubertstatic const char *nonempty (const char *s); 5882*b50261e2SCy Schubertvoid lt_setenv (const char *name, const char *value); 5883*b50261e2SCy Schubertchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5884*b50261e2SCy Schubertvoid lt_update_exe_path (const char *name, const char *value); 5885*b50261e2SCy Schubertvoid lt_update_lib_path (const char *name, const char *value); 5886*b50261e2SCy Schubertchar **prepare_spawn (char **argv); 5887*b50261e2SCy Schubertvoid lt_dump_script (FILE *f); 5888*b50261e2SCy SchubertEOF 5889*b50261e2SCy Schubert 5890*b50261e2SCy Schubert cat <<EOF 5891*b50261e2SCy Schubert#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5892*b50261e2SCy Schubert# define externally_visible volatile 5893*b50261e2SCy Schubert#else 5894*b50261e2SCy Schubert# define externally_visible __attribute__((externally_visible)) volatile 5895*b50261e2SCy Schubert#endif 5896*b50261e2SCy Schubertexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5897*b50261e2SCy Schubertconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5898*b50261e2SCy SchubertEOF 5899*b50261e2SCy Schubert 5900*b50261e2SCy Schubert if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5901*b50261e2SCy Schubert func_to_host_path "$temp_rpath" 5902*b50261e2SCy Schubert cat <<EOF 5903*b50261e2SCy Schubertconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5904*b50261e2SCy SchubertEOF 5905*b50261e2SCy Schubert else 5906*b50261e2SCy Schubert cat <<"EOF" 5907*b50261e2SCy Schubertconst char * LIB_PATH_VALUE = ""; 5908*b50261e2SCy SchubertEOF 5909*b50261e2SCy Schubert fi 5910*b50261e2SCy Schubert 5911*b50261e2SCy Schubert if test -n "$dllsearchpath"; then 5912*b50261e2SCy Schubert func_to_host_path "$dllsearchpath:" 5913*b50261e2SCy Schubert cat <<EOF 5914*b50261e2SCy Schubertconst char * EXE_PATH_VARNAME = "PATH"; 5915*b50261e2SCy Schubertconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5916*b50261e2SCy SchubertEOF 5917*b50261e2SCy Schubert else 5918*b50261e2SCy Schubert cat <<"EOF" 5919*b50261e2SCy Schubertconst char * EXE_PATH_VARNAME = ""; 5920*b50261e2SCy Schubertconst char * EXE_PATH_VALUE = ""; 5921*b50261e2SCy SchubertEOF 5922*b50261e2SCy Schubert fi 5923*b50261e2SCy Schubert 5924*b50261e2SCy Schubert if test yes = "$fast_install"; then 5925*b50261e2SCy Schubert cat <<EOF 5926*b50261e2SCy Schubertconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5927*b50261e2SCy SchubertEOF 5928*b50261e2SCy Schubert else 5929*b50261e2SCy Schubert cat <<EOF 5930*b50261e2SCy Schubertconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5931*b50261e2SCy SchubertEOF 5932*b50261e2SCy Schubert fi 5933*b50261e2SCy Schubert 5934*b50261e2SCy Schubert 5935*b50261e2SCy Schubert cat <<"EOF" 5936*b50261e2SCy Schubert 5937*b50261e2SCy Schubert#define LTWRAPPER_OPTION_PREFIX "--lt-" 5938*b50261e2SCy Schubert 5939*b50261e2SCy Schubertstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5940*b50261e2SCy Schubertstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5941*b50261e2SCy Schubertstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5942*b50261e2SCy Schubert 5943*b50261e2SCy Schubertint 5944*b50261e2SCy Schubertmain (int argc, char *argv[]) 5945*b50261e2SCy Schubert{ 5946*b50261e2SCy Schubert char **newargz; 5947*b50261e2SCy Schubert int newargc; 5948*b50261e2SCy Schubert char *tmp_pathspec; 5949*b50261e2SCy Schubert char *actual_cwrapper_path; 5950*b50261e2SCy Schubert char *actual_cwrapper_name; 5951*b50261e2SCy Schubert char *target_name; 5952*b50261e2SCy Schubert char *lt_argv_zero; 5953*b50261e2SCy Schubert int rval = 127; 5954*b50261e2SCy Schubert 5955*b50261e2SCy Schubert int i; 5956*b50261e2SCy Schubert 5957*b50261e2SCy Schubert program_name = (char *) xstrdup (base_name (argv[0])); 5958*b50261e2SCy Schubert newargz = XMALLOC (char *, (size_t) argc + 1); 5959*b50261e2SCy Schubert 5960*b50261e2SCy Schubert /* very simple arg parsing; don't want to rely on getopt 5961*b50261e2SCy Schubert * also, copy all non cwrapper options to newargz, except 5962*b50261e2SCy Schubert * argz[0], which is handled differently 5963*b50261e2SCy Schubert */ 5964*b50261e2SCy Schubert newargc=0; 5965*b50261e2SCy Schubert for (i = 1; i < argc; i++) 5966*b50261e2SCy Schubert { 5967*b50261e2SCy Schubert if (STREQ (argv[i], dumpscript_opt)) 5968*b50261e2SCy Schubert { 5969*b50261e2SCy SchubertEOF 5970*b50261e2SCy Schubert case $host in 5971*b50261e2SCy Schubert *mingw* | *cygwin* ) 5972*b50261e2SCy Schubert # make stdout use "unix" line endings 5973*b50261e2SCy Schubert echo " setmode(1,_O_BINARY);" 5974*b50261e2SCy Schubert ;; 5975*b50261e2SCy Schubert esac 5976*b50261e2SCy Schubert 5977*b50261e2SCy Schubert cat <<"EOF" 5978*b50261e2SCy Schubert lt_dump_script (stdout); 5979*b50261e2SCy Schubert return 0; 5980*b50261e2SCy Schubert } 5981*b50261e2SCy Schubert if (STREQ (argv[i], debug_opt)) 5982*b50261e2SCy Schubert { 5983*b50261e2SCy Schubert lt_debug = 1; 5984*b50261e2SCy Schubert continue; 5985*b50261e2SCy Schubert } 5986*b50261e2SCy Schubert if (STREQ (argv[i], ltwrapper_option_prefix)) 5987*b50261e2SCy Schubert { 5988*b50261e2SCy Schubert /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5989*b50261e2SCy Schubert namespace, but it is not one of the ones we know about and 5990*b50261e2SCy Schubert have already dealt with, above (inluding dump-script), then 5991*b50261e2SCy Schubert report an error. Otherwise, targets might begin to believe 5992*b50261e2SCy Schubert they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5993*b50261e2SCy Schubert namespace. The first time any user complains about this, we'll 5994*b50261e2SCy Schubert need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5995*b50261e2SCy Schubert or a configure.ac-settable value. 5996*b50261e2SCy Schubert */ 5997*b50261e2SCy Schubert lt_fatal (__FILE__, __LINE__, 5998*b50261e2SCy Schubert "unrecognized %s option: '%s'", 5999*b50261e2SCy Schubert ltwrapper_option_prefix, argv[i]); 6000*b50261e2SCy Schubert } 6001*b50261e2SCy Schubert /* otherwise ... */ 6002*b50261e2SCy Schubert newargz[++newargc] = xstrdup (argv[i]); 6003*b50261e2SCy Schubert } 6004*b50261e2SCy Schubert newargz[++newargc] = NULL; 6005*b50261e2SCy Schubert 6006*b50261e2SCy SchubertEOF 6007*b50261e2SCy Schubert cat <<EOF 6008*b50261e2SCy Schubert /* The GNU banner must be the first non-error debug message */ 6009*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6010*b50261e2SCy SchubertEOF 6011*b50261e2SCy Schubert cat <<"EOF" 6012*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6013*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6014*b50261e2SCy Schubert 6015*b50261e2SCy Schubert tmp_pathspec = find_executable (argv[0]); 6016*b50261e2SCy Schubert if (tmp_pathspec == NULL) 6017*b50261e2SCy Schubert lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6018*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6019*b50261e2SCy Schubert "(main) found exe (before symlink chase) at: %s\n", 6020*b50261e2SCy Schubert tmp_pathspec); 6021*b50261e2SCy Schubert 6022*b50261e2SCy Schubert actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6023*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6024*b50261e2SCy Schubert "(main) found exe (after symlink chase) at: %s\n", 6025*b50261e2SCy Schubert actual_cwrapper_path); 6026*b50261e2SCy Schubert XFREE (tmp_pathspec); 6027*b50261e2SCy Schubert 6028*b50261e2SCy Schubert actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6029*b50261e2SCy Schubert strendzap (actual_cwrapper_path, actual_cwrapper_name); 6030*b50261e2SCy Schubert 6031*b50261e2SCy Schubert /* wrapper name transforms */ 6032*b50261e2SCy Schubert strendzap (actual_cwrapper_name, ".exe"); 6033*b50261e2SCy Schubert tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6034*b50261e2SCy Schubert XFREE (actual_cwrapper_name); 6035*b50261e2SCy Schubert actual_cwrapper_name = tmp_pathspec; 6036*b50261e2SCy Schubert tmp_pathspec = 0; 6037*b50261e2SCy Schubert 6038*b50261e2SCy Schubert /* target_name transforms -- use actual target program name; might have lt- prefix */ 6039*b50261e2SCy Schubert target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6040*b50261e2SCy Schubert strendzap (target_name, ".exe"); 6041*b50261e2SCy Schubert tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6042*b50261e2SCy Schubert XFREE (target_name); 6043*b50261e2SCy Schubert target_name = tmp_pathspec; 6044*b50261e2SCy Schubert tmp_pathspec = 0; 6045*b50261e2SCy Schubert 6046*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6047*b50261e2SCy Schubert "(main) libtool target name: %s\n", 6048*b50261e2SCy Schubert target_name); 6049*b50261e2SCy SchubertEOF 6050*b50261e2SCy Schubert 6051*b50261e2SCy Schubert cat <<EOF 6052*b50261e2SCy Schubert newargz[0] = 6053*b50261e2SCy Schubert XMALLOC (char, (strlen (actual_cwrapper_path) + 6054*b50261e2SCy Schubert strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6055*b50261e2SCy Schubert strcpy (newargz[0], actual_cwrapper_path); 6056*b50261e2SCy Schubert strcat (newargz[0], "$objdir"); 6057*b50261e2SCy Schubert strcat (newargz[0], "/"); 6058*b50261e2SCy SchubertEOF 6059*b50261e2SCy Schubert 6060*b50261e2SCy Schubert cat <<"EOF" 6061*b50261e2SCy Schubert /* stop here, and copy so we don't have to do this twice */ 6062*b50261e2SCy Schubert tmp_pathspec = xstrdup (newargz[0]); 6063*b50261e2SCy Schubert 6064*b50261e2SCy Schubert /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6065*b50261e2SCy Schubert strcat (newargz[0], actual_cwrapper_name); 6066*b50261e2SCy Schubert 6067*b50261e2SCy Schubert /* DO want the lt- prefix here if it exists, so use target_name */ 6068*b50261e2SCy Schubert lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6069*b50261e2SCy Schubert XFREE (tmp_pathspec); 6070*b50261e2SCy Schubert tmp_pathspec = NULL; 6071*b50261e2SCy SchubertEOF 6072*b50261e2SCy Schubert 6073*b50261e2SCy Schubert case $host_os in 6074*b50261e2SCy Schubert mingw*) 6075*b50261e2SCy Schubert cat <<"EOF" 6076*b50261e2SCy Schubert { 6077*b50261e2SCy Schubert char* p; 6078*b50261e2SCy Schubert while ((p = strchr (newargz[0], '\\')) != NULL) 6079*b50261e2SCy Schubert { 6080*b50261e2SCy Schubert *p = '/'; 6081*b50261e2SCy Schubert } 6082*b50261e2SCy Schubert while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6083*b50261e2SCy Schubert { 6084*b50261e2SCy Schubert *p = '/'; 6085*b50261e2SCy Schubert } 6086*b50261e2SCy Schubert } 6087*b50261e2SCy SchubertEOF 6088*b50261e2SCy Schubert ;; 6089*b50261e2SCy Schubert esac 6090*b50261e2SCy Schubert 6091*b50261e2SCy Schubert cat <<"EOF" 6092*b50261e2SCy Schubert XFREE (target_name); 6093*b50261e2SCy Schubert XFREE (actual_cwrapper_path); 6094*b50261e2SCy Schubert XFREE (actual_cwrapper_name); 6095*b50261e2SCy Schubert 6096*b50261e2SCy Schubert lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6097*b50261e2SCy Schubert lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6098*b50261e2SCy Schubert /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6099*b50261e2SCy Schubert be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6100*b50261e2SCy Schubert because on Windows, both *_VARNAMEs are PATH but uninstalled 6101*b50261e2SCy Schubert libraries must come first. */ 6102*b50261e2SCy Schubert lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6103*b50261e2SCy Schubert lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6104*b50261e2SCy Schubert 6105*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6106*b50261e2SCy Schubert nonnull (lt_argv_zero)); 6107*b50261e2SCy Schubert for (i = 0; i < newargc; i++) 6108*b50261e2SCy Schubert { 6109*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6110*b50261e2SCy Schubert i, nonnull (newargz[i])); 6111*b50261e2SCy Schubert } 6112*b50261e2SCy Schubert 6113*b50261e2SCy SchubertEOF 6114*b50261e2SCy Schubert 6115*b50261e2SCy Schubert case $host_os in 6116*b50261e2SCy Schubert mingw*) 6117*b50261e2SCy Schubert cat <<"EOF" 6118*b50261e2SCy Schubert /* execv doesn't actually work on mingw as expected on unix */ 6119*b50261e2SCy Schubert newargz = prepare_spawn (newargz); 6120*b50261e2SCy Schubert rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6121*b50261e2SCy Schubert if (rval == -1) 6122*b50261e2SCy Schubert { 6123*b50261e2SCy Schubert /* failed to start process */ 6124*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6125*b50261e2SCy Schubert "(main) failed to launch target \"%s\": %s\n", 6126*b50261e2SCy Schubert lt_argv_zero, nonnull (strerror (errno))); 6127*b50261e2SCy Schubert return 127; 6128*b50261e2SCy Schubert } 6129*b50261e2SCy Schubert return rval; 6130*b50261e2SCy SchubertEOF 6131*b50261e2SCy Schubert ;; 6132*b50261e2SCy Schubert *) 6133*b50261e2SCy Schubert cat <<"EOF" 6134*b50261e2SCy Schubert execv (lt_argv_zero, newargz); 6135*b50261e2SCy Schubert return rval; /* =127, but avoids unused variable warning */ 6136*b50261e2SCy SchubertEOF 6137*b50261e2SCy Schubert ;; 6138*b50261e2SCy Schubert esac 6139*b50261e2SCy Schubert 6140*b50261e2SCy Schubert cat <<"EOF" 6141*b50261e2SCy Schubert} 6142*b50261e2SCy Schubert 6143*b50261e2SCy Schubertvoid * 6144*b50261e2SCy Schubertxmalloc (size_t num) 6145*b50261e2SCy Schubert{ 6146*b50261e2SCy Schubert void *p = (void *) malloc (num); 6147*b50261e2SCy Schubert if (!p) 6148*b50261e2SCy Schubert lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6149*b50261e2SCy Schubert 6150*b50261e2SCy Schubert return p; 6151*b50261e2SCy Schubert} 6152*b50261e2SCy Schubert 6153*b50261e2SCy Schubertchar * 6154*b50261e2SCy Schubertxstrdup (const char *string) 6155*b50261e2SCy Schubert{ 6156*b50261e2SCy Schubert return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6157*b50261e2SCy Schubert string) : NULL; 6158*b50261e2SCy Schubert} 6159*b50261e2SCy Schubert 6160*b50261e2SCy Schubertconst char * 6161*b50261e2SCy Schubertbase_name (const char *name) 6162*b50261e2SCy Schubert{ 6163*b50261e2SCy Schubert const char *base; 6164*b50261e2SCy Schubert 6165*b50261e2SCy Schubert#if defined HAVE_DOS_BASED_FILE_SYSTEM 6166*b50261e2SCy Schubert /* Skip over the disk name in MSDOS pathnames. */ 6167*b50261e2SCy Schubert if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6168*b50261e2SCy Schubert name += 2; 6169*b50261e2SCy Schubert#endif 6170*b50261e2SCy Schubert 6171*b50261e2SCy Schubert for (base = name; *name; name++) 6172*b50261e2SCy Schubert if (IS_DIR_SEPARATOR (*name)) 6173*b50261e2SCy Schubert base = name + 1; 6174*b50261e2SCy Schubert return base; 6175*b50261e2SCy Schubert} 6176*b50261e2SCy Schubert 6177*b50261e2SCy Schubertint 6178*b50261e2SCy Schubertcheck_executable (const char *path) 6179*b50261e2SCy Schubert{ 6180*b50261e2SCy Schubert struct stat st; 6181*b50261e2SCy Schubert 6182*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6183*b50261e2SCy Schubert nonempty (path)); 6184*b50261e2SCy Schubert if ((!path) || (!*path)) 6185*b50261e2SCy Schubert return 0; 6186*b50261e2SCy Schubert 6187*b50261e2SCy Schubert if ((stat (path, &st) >= 0) 6188*b50261e2SCy Schubert && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6189*b50261e2SCy Schubert return 1; 6190*b50261e2SCy Schubert else 6191*b50261e2SCy Schubert return 0; 6192*b50261e2SCy Schubert} 6193*b50261e2SCy Schubert 6194*b50261e2SCy Schubertint 6195*b50261e2SCy Schubertmake_executable (const char *path) 6196*b50261e2SCy Schubert{ 6197*b50261e2SCy Schubert int rval = 0; 6198*b50261e2SCy Schubert struct stat st; 6199*b50261e2SCy Schubert 6200*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6201*b50261e2SCy Schubert nonempty (path)); 6202*b50261e2SCy Schubert if ((!path) || (!*path)) 6203*b50261e2SCy Schubert return 0; 6204*b50261e2SCy Schubert 6205*b50261e2SCy Schubert if (stat (path, &st) >= 0) 6206*b50261e2SCy Schubert { 6207*b50261e2SCy Schubert rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6208*b50261e2SCy Schubert } 6209*b50261e2SCy Schubert return rval; 6210*b50261e2SCy Schubert} 6211*b50261e2SCy Schubert 6212*b50261e2SCy Schubert/* Searches for the full path of the wrapper. Returns 6213*b50261e2SCy Schubert newly allocated full path name if found, NULL otherwise 6214*b50261e2SCy Schubert Does not chase symlinks, even on platforms that support them. 6215*b50261e2SCy Schubert*/ 6216*b50261e2SCy Schubertchar * 6217*b50261e2SCy Schubertfind_executable (const char *wrapper) 6218*b50261e2SCy Schubert{ 6219*b50261e2SCy Schubert int has_slash = 0; 6220*b50261e2SCy Schubert const char *p; 6221*b50261e2SCy Schubert const char *p_next; 6222*b50261e2SCy Schubert /* static buffer for getcwd */ 6223*b50261e2SCy Schubert char tmp[LT_PATHMAX + 1]; 6224*b50261e2SCy Schubert size_t tmp_len; 6225*b50261e2SCy Schubert char *concat_name; 6226*b50261e2SCy Schubert 6227*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6228*b50261e2SCy Schubert nonempty (wrapper)); 6229*b50261e2SCy Schubert 6230*b50261e2SCy Schubert if ((wrapper == NULL) || (*wrapper == '\0')) 6231*b50261e2SCy Schubert return NULL; 6232*b50261e2SCy Schubert 6233*b50261e2SCy Schubert /* Absolute path? */ 6234*b50261e2SCy Schubert#if defined HAVE_DOS_BASED_FILE_SYSTEM 6235*b50261e2SCy Schubert if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6236*b50261e2SCy Schubert { 6237*b50261e2SCy Schubert concat_name = xstrdup (wrapper); 6238*b50261e2SCy Schubert if (check_executable (concat_name)) 6239*b50261e2SCy Schubert return concat_name; 6240*b50261e2SCy Schubert XFREE (concat_name); 6241*b50261e2SCy Schubert } 6242*b50261e2SCy Schubert else 6243*b50261e2SCy Schubert { 6244*b50261e2SCy Schubert#endif 6245*b50261e2SCy Schubert if (IS_DIR_SEPARATOR (wrapper[0])) 6246*b50261e2SCy Schubert { 6247*b50261e2SCy Schubert concat_name = xstrdup (wrapper); 6248*b50261e2SCy Schubert if (check_executable (concat_name)) 6249*b50261e2SCy Schubert return concat_name; 6250*b50261e2SCy Schubert XFREE (concat_name); 6251*b50261e2SCy Schubert } 6252*b50261e2SCy Schubert#if defined HAVE_DOS_BASED_FILE_SYSTEM 6253*b50261e2SCy Schubert } 6254*b50261e2SCy Schubert#endif 6255*b50261e2SCy Schubert 6256*b50261e2SCy Schubert for (p = wrapper; *p; p++) 6257*b50261e2SCy Schubert if (*p == '/') 6258*b50261e2SCy Schubert { 6259*b50261e2SCy Schubert has_slash = 1; 6260*b50261e2SCy Schubert break; 6261*b50261e2SCy Schubert } 6262*b50261e2SCy Schubert if (!has_slash) 6263*b50261e2SCy Schubert { 6264*b50261e2SCy Schubert /* no slashes; search PATH */ 6265*b50261e2SCy Schubert const char *path = getenv ("PATH"); 6266*b50261e2SCy Schubert if (path != NULL) 6267*b50261e2SCy Schubert { 6268*b50261e2SCy Schubert for (p = path; *p; p = p_next) 6269*b50261e2SCy Schubert { 6270*b50261e2SCy Schubert const char *q; 6271*b50261e2SCy Schubert size_t p_len; 6272*b50261e2SCy Schubert for (q = p; *q; q++) 6273*b50261e2SCy Schubert if (IS_PATH_SEPARATOR (*q)) 6274*b50261e2SCy Schubert break; 6275*b50261e2SCy Schubert p_len = (size_t) (q - p); 6276*b50261e2SCy Schubert p_next = (*q == '\0' ? q : q + 1); 6277*b50261e2SCy Schubert if (p_len == 0) 6278*b50261e2SCy Schubert { 6279*b50261e2SCy Schubert /* empty path: current directory */ 6280*b50261e2SCy Schubert if (getcwd (tmp, LT_PATHMAX) == NULL) 6281*b50261e2SCy Schubert lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6282*b50261e2SCy Schubert nonnull (strerror (errno))); 6283*b50261e2SCy Schubert tmp_len = strlen (tmp); 6284*b50261e2SCy Schubert concat_name = 6285*b50261e2SCy Schubert XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6286*b50261e2SCy Schubert memcpy (concat_name, tmp, tmp_len); 6287*b50261e2SCy Schubert concat_name[tmp_len] = '/'; 6288*b50261e2SCy Schubert strcpy (concat_name + tmp_len + 1, wrapper); 6289*b50261e2SCy Schubert } 6290*b50261e2SCy Schubert else 6291*b50261e2SCy Schubert { 6292*b50261e2SCy Schubert concat_name = 6293*b50261e2SCy Schubert XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6294*b50261e2SCy Schubert memcpy (concat_name, p, p_len); 6295*b50261e2SCy Schubert concat_name[p_len] = '/'; 6296*b50261e2SCy Schubert strcpy (concat_name + p_len + 1, wrapper); 6297*b50261e2SCy Schubert } 6298*b50261e2SCy Schubert if (check_executable (concat_name)) 6299*b50261e2SCy Schubert return concat_name; 6300*b50261e2SCy Schubert XFREE (concat_name); 6301*b50261e2SCy Schubert } 6302*b50261e2SCy Schubert } 6303*b50261e2SCy Schubert /* not found in PATH; assume curdir */ 6304*b50261e2SCy Schubert } 6305*b50261e2SCy Schubert /* Relative path | not found in path: prepend cwd */ 6306*b50261e2SCy Schubert if (getcwd (tmp, LT_PATHMAX) == NULL) 6307*b50261e2SCy Schubert lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6308*b50261e2SCy Schubert nonnull (strerror (errno))); 6309*b50261e2SCy Schubert tmp_len = strlen (tmp); 6310*b50261e2SCy Schubert concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6311*b50261e2SCy Schubert memcpy (concat_name, tmp, tmp_len); 6312*b50261e2SCy Schubert concat_name[tmp_len] = '/'; 6313*b50261e2SCy Schubert strcpy (concat_name + tmp_len + 1, wrapper); 6314*b50261e2SCy Schubert 6315*b50261e2SCy Schubert if (check_executable (concat_name)) 6316*b50261e2SCy Schubert return concat_name; 6317*b50261e2SCy Schubert XFREE (concat_name); 6318*b50261e2SCy Schubert return NULL; 6319*b50261e2SCy Schubert} 6320*b50261e2SCy Schubert 6321*b50261e2SCy Schubertchar * 6322*b50261e2SCy Schubertchase_symlinks (const char *pathspec) 6323*b50261e2SCy Schubert{ 6324*b50261e2SCy Schubert#ifndef S_ISLNK 6325*b50261e2SCy Schubert return xstrdup (pathspec); 6326*b50261e2SCy Schubert#else 6327*b50261e2SCy Schubert char buf[LT_PATHMAX]; 6328*b50261e2SCy Schubert struct stat s; 6329*b50261e2SCy Schubert char *tmp_pathspec = xstrdup (pathspec); 6330*b50261e2SCy Schubert char *p; 6331*b50261e2SCy Schubert int has_symlinks = 0; 6332*b50261e2SCy Schubert while (strlen (tmp_pathspec) && !has_symlinks) 6333*b50261e2SCy Schubert { 6334*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6335*b50261e2SCy Schubert "checking path component for symlinks: %s\n", 6336*b50261e2SCy Schubert tmp_pathspec); 6337*b50261e2SCy Schubert if (lstat (tmp_pathspec, &s) == 0) 6338*b50261e2SCy Schubert { 6339*b50261e2SCy Schubert if (S_ISLNK (s.st_mode) != 0) 6340*b50261e2SCy Schubert { 6341*b50261e2SCy Schubert has_symlinks = 1; 6342*b50261e2SCy Schubert break; 6343*b50261e2SCy Schubert } 6344*b50261e2SCy Schubert 6345*b50261e2SCy Schubert /* search backwards for last DIR_SEPARATOR */ 6346*b50261e2SCy Schubert p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6347*b50261e2SCy Schubert while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6348*b50261e2SCy Schubert p--; 6349*b50261e2SCy Schubert if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6350*b50261e2SCy Schubert { 6351*b50261e2SCy Schubert /* no more DIR_SEPARATORS left */ 6352*b50261e2SCy Schubert break; 6353*b50261e2SCy Schubert } 6354*b50261e2SCy Schubert *p = '\0'; 6355*b50261e2SCy Schubert } 6356*b50261e2SCy Schubert else 6357*b50261e2SCy Schubert { 6358*b50261e2SCy Schubert lt_fatal (__FILE__, __LINE__, 6359*b50261e2SCy Schubert "error accessing file \"%s\": %s", 6360*b50261e2SCy Schubert tmp_pathspec, nonnull (strerror (errno))); 6361*b50261e2SCy Schubert } 6362*b50261e2SCy Schubert } 6363*b50261e2SCy Schubert XFREE (tmp_pathspec); 6364*b50261e2SCy Schubert 6365*b50261e2SCy Schubert if (!has_symlinks) 6366*b50261e2SCy Schubert { 6367*b50261e2SCy Schubert return xstrdup (pathspec); 6368*b50261e2SCy Schubert } 6369*b50261e2SCy Schubert 6370*b50261e2SCy Schubert tmp_pathspec = realpath (pathspec, buf); 6371*b50261e2SCy Schubert if (tmp_pathspec == 0) 6372*b50261e2SCy Schubert { 6373*b50261e2SCy Schubert lt_fatal (__FILE__, __LINE__, 6374*b50261e2SCy Schubert "could not follow symlinks for %s", pathspec); 6375*b50261e2SCy Schubert } 6376*b50261e2SCy Schubert return xstrdup (tmp_pathspec); 6377*b50261e2SCy Schubert#endif 6378*b50261e2SCy Schubert} 6379*b50261e2SCy Schubert 6380*b50261e2SCy Schubertchar * 6381*b50261e2SCy Schubertstrendzap (char *str, const char *pat) 6382*b50261e2SCy Schubert{ 6383*b50261e2SCy Schubert size_t len, patlen; 6384*b50261e2SCy Schubert 6385*b50261e2SCy Schubert assert (str != NULL); 6386*b50261e2SCy Schubert assert (pat != NULL); 6387*b50261e2SCy Schubert 6388*b50261e2SCy Schubert len = strlen (str); 6389*b50261e2SCy Schubert patlen = strlen (pat); 6390*b50261e2SCy Schubert 6391*b50261e2SCy Schubert if (patlen <= len) 6392*b50261e2SCy Schubert { 6393*b50261e2SCy Schubert str += len - patlen; 6394*b50261e2SCy Schubert if (STREQ (str, pat)) 6395*b50261e2SCy Schubert *str = '\0'; 6396*b50261e2SCy Schubert } 6397*b50261e2SCy Schubert return str; 6398*b50261e2SCy Schubert} 6399*b50261e2SCy Schubert 6400*b50261e2SCy Schubertvoid 6401*b50261e2SCy Schubertlt_debugprintf (const char *file, int line, const char *fmt, ...) 6402*b50261e2SCy Schubert{ 6403*b50261e2SCy Schubert va_list args; 6404*b50261e2SCy Schubert if (lt_debug) 6405*b50261e2SCy Schubert { 6406*b50261e2SCy Schubert (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6407*b50261e2SCy Schubert va_start (args, fmt); 6408*b50261e2SCy Schubert (void) vfprintf (stderr, fmt, args); 6409*b50261e2SCy Schubert va_end (args); 6410*b50261e2SCy Schubert } 6411*b50261e2SCy Schubert} 6412*b50261e2SCy Schubert 6413*b50261e2SCy Schubertstatic void 6414*b50261e2SCy Schubertlt_error_core (int exit_status, const char *file, 6415*b50261e2SCy Schubert int line, const char *mode, 6416*b50261e2SCy Schubert const char *message, va_list ap) 6417*b50261e2SCy Schubert{ 6418*b50261e2SCy Schubert fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6419*b50261e2SCy Schubert vfprintf (stderr, message, ap); 6420*b50261e2SCy Schubert fprintf (stderr, ".\n"); 6421*b50261e2SCy Schubert 6422*b50261e2SCy Schubert if (exit_status >= 0) 6423*b50261e2SCy Schubert exit (exit_status); 6424*b50261e2SCy Schubert} 6425*b50261e2SCy Schubert 6426*b50261e2SCy Schubertvoid 6427*b50261e2SCy Schubertlt_fatal (const char *file, int line, const char *message, ...) 6428*b50261e2SCy Schubert{ 6429*b50261e2SCy Schubert va_list ap; 6430*b50261e2SCy Schubert va_start (ap, message); 6431*b50261e2SCy Schubert lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6432*b50261e2SCy Schubert va_end (ap); 6433*b50261e2SCy Schubert} 6434*b50261e2SCy Schubert 6435*b50261e2SCy Schubertstatic const char * 6436*b50261e2SCy Schubertnonnull (const char *s) 6437*b50261e2SCy Schubert{ 6438*b50261e2SCy Schubert return s ? s : "(null)"; 6439*b50261e2SCy Schubert} 6440*b50261e2SCy Schubert 6441*b50261e2SCy Schubertstatic const char * 6442*b50261e2SCy Schubertnonempty (const char *s) 6443*b50261e2SCy Schubert{ 6444*b50261e2SCy Schubert return (s && !*s) ? "(empty)" : nonnull (s); 6445*b50261e2SCy Schubert} 6446*b50261e2SCy Schubert 6447*b50261e2SCy Schubertvoid 6448*b50261e2SCy Schubertlt_setenv (const char *name, const char *value) 6449*b50261e2SCy Schubert{ 6450*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6451*b50261e2SCy Schubert "(lt_setenv) setting '%s' to '%s'\n", 6452*b50261e2SCy Schubert nonnull (name), nonnull (value)); 6453*b50261e2SCy Schubert { 6454*b50261e2SCy Schubert#ifdef HAVE_SETENV 6455*b50261e2SCy Schubert /* always make a copy, for consistency with !HAVE_SETENV */ 6456*b50261e2SCy Schubert char *str = xstrdup (value); 6457*b50261e2SCy Schubert setenv (name, str, 1); 6458*b50261e2SCy Schubert#else 6459*b50261e2SCy Schubert size_t len = strlen (name) + 1 + strlen (value) + 1; 6460*b50261e2SCy Schubert char *str = XMALLOC (char, len); 6461*b50261e2SCy Schubert sprintf (str, "%s=%s", name, value); 6462*b50261e2SCy Schubert if (putenv (str) != EXIT_SUCCESS) 6463*b50261e2SCy Schubert { 6464*b50261e2SCy Schubert XFREE (str); 6465*b50261e2SCy Schubert } 6466*b50261e2SCy Schubert#endif 6467*b50261e2SCy Schubert } 6468*b50261e2SCy Schubert} 6469*b50261e2SCy Schubert 6470*b50261e2SCy Schubertchar * 6471*b50261e2SCy Schubertlt_extend_str (const char *orig_value, const char *add, int to_end) 6472*b50261e2SCy Schubert{ 6473*b50261e2SCy Schubert char *new_value; 6474*b50261e2SCy Schubert if (orig_value && *orig_value) 6475*b50261e2SCy Schubert { 6476*b50261e2SCy Schubert size_t orig_value_len = strlen (orig_value); 6477*b50261e2SCy Schubert size_t add_len = strlen (add); 6478*b50261e2SCy Schubert new_value = XMALLOC (char, add_len + orig_value_len + 1); 6479*b50261e2SCy Schubert if (to_end) 6480*b50261e2SCy Schubert { 6481*b50261e2SCy Schubert strcpy (new_value, orig_value); 6482*b50261e2SCy Schubert strcpy (new_value + orig_value_len, add); 6483*b50261e2SCy Schubert } 6484*b50261e2SCy Schubert else 6485*b50261e2SCy Schubert { 6486*b50261e2SCy Schubert strcpy (new_value, add); 6487*b50261e2SCy Schubert strcpy (new_value + add_len, orig_value); 6488*b50261e2SCy Schubert } 6489*b50261e2SCy Schubert } 6490*b50261e2SCy Schubert else 6491*b50261e2SCy Schubert { 6492*b50261e2SCy Schubert new_value = xstrdup (add); 6493*b50261e2SCy Schubert } 6494*b50261e2SCy Schubert return new_value; 6495*b50261e2SCy Schubert} 6496*b50261e2SCy Schubert 6497*b50261e2SCy Schubertvoid 6498*b50261e2SCy Schubertlt_update_exe_path (const char *name, const char *value) 6499*b50261e2SCy Schubert{ 6500*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6501*b50261e2SCy Schubert "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6502*b50261e2SCy Schubert nonnull (name), nonnull (value)); 6503*b50261e2SCy Schubert 6504*b50261e2SCy Schubert if (name && *name && value && *value) 6505*b50261e2SCy Schubert { 6506*b50261e2SCy Schubert char *new_value = lt_extend_str (getenv (name), value, 0); 6507*b50261e2SCy Schubert /* some systems can't cope with a ':'-terminated path #' */ 6508*b50261e2SCy Schubert size_t len = strlen (new_value); 6509*b50261e2SCy Schubert while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6510*b50261e2SCy Schubert { 6511*b50261e2SCy Schubert new_value[--len] = '\0'; 6512*b50261e2SCy Schubert } 6513*b50261e2SCy Schubert lt_setenv (name, new_value); 6514*b50261e2SCy Schubert XFREE (new_value); 6515*b50261e2SCy Schubert } 6516*b50261e2SCy Schubert} 6517*b50261e2SCy Schubert 6518*b50261e2SCy Schubertvoid 6519*b50261e2SCy Schubertlt_update_lib_path (const char *name, const char *value) 6520*b50261e2SCy Schubert{ 6521*b50261e2SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6522*b50261e2SCy Schubert "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6523*b50261e2SCy Schubert nonnull (name), nonnull (value)); 6524*b50261e2SCy Schubert 6525*b50261e2SCy Schubert if (name && *name && value && *value) 6526*b50261e2SCy Schubert { 6527*b50261e2SCy Schubert char *new_value = lt_extend_str (getenv (name), value, 0); 6528*b50261e2SCy Schubert lt_setenv (name, new_value); 6529*b50261e2SCy Schubert XFREE (new_value); 6530*b50261e2SCy Schubert } 6531*b50261e2SCy Schubert} 6532*b50261e2SCy Schubert 6533*b50261e2SCy SchubertEOF 6534*b50261e2SCy Schubert case $host_os in 6535*b50261e2SCy Schubert mingw*) 6536*b50261e2SCy Schubert cat <<"EOF" 6537*b50261e2SCy Schubert 6538*b50261e2SCy Schubert/* Prepares an argument vector before calling spawn(). 6539*b50261e2SCy Schubert Note that spawn() does not by itself call the command interpreter 6540*b50261e2SCy Schubert (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6541*b50261e2SCy Schubert ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6542*b50261e2SCy Schubert GetVersionEx(&v); 6543*b50261e2SCy Schubert v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6544*b50261e2SCy Schubert }) ? "cmd.exe" : "command.com"). 6545*b50261e2SCy Schubert Instead it simply concatenates the arguments, separated by ' ', and calls 6546*b50261e2SCy Schubert CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6547*b50261e2SCy Schubert interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6548*b50261e2SCy Schubert special way: 6549*b50261e2SCy Schubert - Space and tab are interpreted as delimiters. They are not treated as 6550*b50261e2SCy Schubert delimiters if they are surrounded by double quotes: "...". 6551*b50261e2SCy Schubert - Unescaped double quotes are removed from the input. Their only effect is 6552*b50261e2SCy Schubert that within double quotes, space and tab are treated like normal 6553*b50261e2SCy Schubert characters. 6554*b50261e2SCy Schubert - Backslashes not followed by double quotes are not special. 6555*b50261e2SCy Schubert - But 2*n+1 backslashes followed by a double quote become 6556*b50261e2SCy Schubert n backslashes followed by a double quote (n >= 0): 6557*b50261e2SCy Schubert \" -> " 6558*b50261e2SCy Schubert \\\" -> \" 6559*b50261e2SCy Schubert \\\\\" -> \\" 6560*b50261e2SCy Schubert */ 6561*b50261e2SCy Schubert#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" 6562*b50261e2SCy Schubert#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" 6563*b50261e2SCy Schubertchar ** 6564*b50261e2SCy Schubertprepare_spawn (char **argv) 6565*b50261e2SCy Schubert{ 6566*b50261e2SCy Schubert size_t argc; 6567*b50261e2SCy Schubert char **new_argv; 6568*b50261e2SCy Schubert size_t i; 6569*b50261e2SCy Schubert 6570*b50261e2SCy Schubert /* Count number of arguments. */ 6571*b50261e2SCy Schubert for (argc = 0; argv[argc] != NULL; argc++) 6572*b50261e2SCy Schubert ; 6573*b50261e2SCy Schubert 6574*b50261e2SCy Schubert /* Allocate new argument vector. */ 6575*b50261e2SCy Schubert new_argv = XMALLOC (char *, argc + 1); 6576*b50261e2SCy Schubert 6577*b50261e2SCy Schubert /* Put quoted arguments into the new argument vector. */ 6578*b50261e2SCy Schubert for (i = 0; i < argc; i++) 6579*b50261e2SCy Schubert { 6580*b50261e2SCy Schubert const char *string = argv[i]; 6581*b50261e2SCy Schubert 6582*b50261e2SCy Schubert if (string[0] == '\0') 6583*b50261e2SCy Schubert new_argv[i] = xstrdup ("\"\""); 6584*b50261e2SCy Schubert else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6585*b50261e2SCy Schubert { 6586*b50261e2SCy Schubert int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6587*b50261e2SCy Schubert size_t length; 6588*b50261e2SCy Schubert unsigned int backslashes; 6589*b50261e2SCy Schubert const char *s; 6590*b50261e2SCy Schubert char *quoted_string; 6591*b50261e2SCy Schubert char *p; 6592*b50261e2SCy Schubert 6593*b50261e2SCy Schubert length = 0; 6594*b50261e2SCy Schubert backslashes = 0; 6595*b50261e2SCy Schubert if (quote_around) 6596*b50261e2SCy Schubert length++; 6597*b50261e2SCy Schubert for (s = string; *s != '\0'; s++) 6598*b50261e2SCy Schubert { 6599*b50261e2SCy Schubert char c = *s; 6600*b50261e2SCy Schubert if (c == '"') 6601*b50261e2SCy Schubert length += backslashes + 1; 6602*b50261e2SCy Schubert length++; 6603*b50261e2SCy Schubert if (c == '\\') 6604*b50261e2SCy Schubert backslashes++; 6605*b50261e2SCy Schubert else 6606*b50261e2SCy Schubert backslashes = 0; 6607*b50261e2SCy Schubert } 6608*b50261e2SCy Schubert if (quote_around) 6609*b50261e2SCy Schubert length += backslashes + 1; 6610*b50261e2SCy Schubert 6611*b50261e2SCy Schubert quoted_string = XMALLOC (char, length + 1); 6612*b50261e2SCy Schubert 6613*b50261e2SCy Schubert p = quoted_string; 6614*b50261e2SCy Schubert backslashes = 0; 6615*b50261e2SCy Schubert if (quote_around) 6616*b50261e2SCy Schubert *p++ = '"'; 6617*b50261e2SCy Schubert for (s = string; *s != '\0'; s++) 6618*b50261e2SCy Schubert { 6619*b50261e2SCy Schubert char c = *s; 6620*b50261e2SCy Schubert if (c == '"') 6621*b50261e2SCy Schubert { 6622*b50261e2SCy Schubert unsigned int j; 6623*b50261e2SCy Schubert for (j = backslashes + 1; j > 0; j--) 6624*b50261e2SCy Schubert *p++ = '\\'; 6625*b50261e2SCy Schubert } 6626*b50261e2SCy Schubert *p++ = c; 6627*b50261e2SCy Schubert if (c == '\\') 6628*b50261e2SCy Schubert backslashes++; 6629*b50261e2SCy Schubert else 6630*b50261e2SCy Schubert backslashes = 0; 6631*b50261e2SCy Schubert } 6632*b50261e2SCy Schubert if (quote_around) 6633*b50261e2SCy Schubert { 6634*b50261e2SCy Schubert unsigned int j; 6635*b50261e2SCy Schubert for (j = backslashes; j > 0; j--) 6636*b50261e2SCy Schubert *p++ = '\\'; 6637*b50261e2SCy Schubert *p++ = '"'; 6638*b50261e2SCy Schubert } 6639*b50261e2SCy Schubert *p = '\0'; 6640*b50261e2SCy Schubert 6641*b50261e2SCy Schubert new_argv[i] = quoted_string; 6642*b50261e2SCy Schubert } 6643*b50261e2SCy Schubert else 6644*b50261e2SCy Schubert new_argv[i] = (char *) string; 6645*b50261e2SCy Schubert } 6646*b50261e2SCy Schubert new_argv[argc] = NULL; 6647*b50261e2SCy Schubert 6648*b50261e2SCy Schubert return new_argv; 6649*b50261e2SCy Schubert} 6650*b50261e2SCy SchubertEOF 6651*b50261e2SCy Schubert ;; 6652*b50261e2SCy Schubert esac 6653*b50261e2SCy Schubert 6654*b50261e2SCy Schubert cat <<"EOF" 6655*b50261e2SCy Schubertvoid lt_dump_script (FILE* f) 6656*b50261e2SCy Schubert{ 6657*b50261e2SCy SchubertEOF 6658*b50261e2SCy Schubert func_emit_wrapper yes | 6659*b50261e2SCy Schubert $SED -n -e ' 6660*b50261e2SCy Schuberts/^\(.\{79\}\)\(..*\)/\1\ 6661*b50261e2SCy Schubert\2/ 6662*b50261e2SCy Schuberth 6663*b50261e2SCy Schuberts/\([\\"]\)/\\\1/g 6664*b50261e2SCy Schuberts/$/\\n/ 6665*b50261e2SCy Schuberts/\([^\n]*\).*/ fputs ("\1", f);/p 6666*b50261e2SCy Schubertg 6667*b50261e2SCy SchubertD' 6668*b50261e2SCy Schubert cat <<"EOF" 6669*b50261e2SCy Schubert} 6670*b50261e2SCy SchubertEOF 6671*b50261e2SCy Schubert} 6672*b50261e2SCy Schubert# end: func_emit_cwrapperexe_src 6673*b50261e2SCy Schubert 6674*b50261e2SCy Schubert# func_win32_import_lib_p ARG 6675*b50261e2SCy Schubert# True if ARG is an import lib, as indicated by $file_magic_cmd 6676*b50261e2SCy Schubertfunc_win32_import_lib_p () 6677*b50261e2SCy Schubert{ 6678*b50261e2SCy Schubert $debug_cmd 6679*b50261e2SCy Schubert 6680*b50261e2SCy Schubert case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6681*b50261e2SCy Schubert *import*) : ;; 6682*b50261e2SCy Schubert *) false ;; 6683*b50261e2SCy Schubert esac 6684*b50261e2SCy Schubert} 6685*b50261e2SCy Schubert 6686*b50261e2SCy Schubert# func_suncc_cstd_abi 6687*b50261e2SCy Schubert# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6688*b50261e2SCy Schubert# Several compiler flags select an ABI that is incompatible with the 6689*b50261e2SCy Schubert# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6690*b50261e2SCy Schubertfunc_suncc_cstd_abi () 6691*b50261e2SCy Schubert{ 6692*b50261e2SCy Schubert $debug_cmd 6693*b50261e2SCy Schubert 6694*b50261e2SCy Schubert case " $compile_command " in 6695*b50261e2SCy Schubert *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6696*b50261e2SCy Schubert suncc_use_cstd_abi=no 6697*b50261e2SCy Schubert ;; 6698*b50261e2SCy Schubert *) 6699*b50261e2SCy Schubert suncc_use_cstd_abi=yes 6700*b50261e2SCy Schubert ;; 6701*b50261e2SCy Schubert esac 6702*b50261e2SCy Schubert} 6703*b50261e2SCy Schubert 6704*b50261e2SCy Schubert# func_mode_link arg... 6705*b50261e2SCy Schubertfunc_mode_link () 6706*b50261e2SCy Schubert{ 6707*b50261e2SCy Schubert $debug_cmd 6708*b50261e2SCy Schubert 6709*b50261e2SCy Schubert case $host in 6710*b50261e2SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6711*b50261e2SCy Schubert # It is impossible to link a dll without this setting, and 6712*b50261e2SCy Schubert # we shouldn't force the makefile maintainer to figure out 6713*b50261e2SCy Schubert # what system we are compiling for in order to pass an extra 6714*b50261e2SCy Schubert # flag for every libtool invocation. 6715*b50261e2SCy Schubert # allow_undefined=no 6716*b50261e2SCy Schubert 6717*b50261e2SCy Schubert # FIXME: Unfortunately, there are problems with the above when trying 6718*b50261e2SCy Schubert # to make a dll that has undefined symbols, in which case not 6719*b50261e2SCy Schubert # even a static library is built. For now, we need to specify 6720*b50261e2SCy Schubert # -no-undefined on the libtool link line when we can be certain 6721*b50261e2SCy Schubert # that all symbols are satisfied, otherwise we get a static library. 6722*b50261e2SCy Schubert allow_undefined=yes 6723*b50261e2SCy Schubert ;; 6724*b50261e2SCy Schubert *) 6725*b50261e2SCy Schubert allow_undefined=yes 6726*b50261e2SCy Schubert ;; 6727*b50261e2SCy Schubert esac 6728*b50261e2SCy Schubert libtool_args=$nonopt 6729*b50261e2SCy Schubert base_compile="$nonopt $@" 6730*b50261e2SCy Schubert compile_command=$nonopt 6731*b50261e2SCy Schubert finalize_command=$nonopt 6732*b50261e2SCy Schubert 6733*b50261e2SCy Schubert compile_rpath= 6734*b50261e2SCy Schubert finalize_rpath= 6735*b50261e2SCy Schubert compile_shlibpath= 6736*b50261e2SCy Schubert finalize_shlibpath= 6737*b50261e2SCy Schubert convenience= 6738*b50261e2SCy Schubert old_convenience= 6739*b50261e2SCy Schubert deplibs= 6740*b50261e2SCy Schubert old_deplibs= 6741*b50261e2SCy Schubert compiler_flags= 6742*b50261e2SCy Schubert linker_flags= 6743*b50261e2SCy Schubert dllsearchpath= 6744*b50261e2SCy Schubert lib_search_path=`pwd` 6745*b50261e2SCy Schubert inst_prefix_dir= 6746*b50261e2SCy Schubert new_inherited_linker_flags= 6747*b50261e2SCy Schubert 6748*b50261e2SCy Schubert avoid_version=no 6749*b50261e2SCy Schubert bindir= 6750*b50261e2SCy Schubert dlfiles= 6751*b50261e2SCy Schubert dlprefiles= 6752*b50261e2SCy Schubert dlself=no 6753*b50261e2SCy Schubert export_dynamic=no 6754*b50261e2SCy Schubert export_symbols= 6755*b50261e2SCy Schubert export_symbols_regex= 6756*b50261e2SCy Schubert generated= 6757*b50261e2SCy Schubert libobjs= 6758*b50261e2SCy Schubert ltlibs= 6759*b50261e2SCy Schubert module=no 6760*b50261e2SCy Schubert no_install=no 6761*b50261e2SCy Schubert objs= 6762*b50261e2SCy Schubert os2dllname= 6763*b50261e2SCy Schubert non_pic_objects= 6764*b50261e2SCy Schubert precious_files_regex= 6765*b50261e2SCy Schubert prefer_static_libs=no 6766*b50261e2SCy Schubert preload=false 6767*b50261e2SCy Schubert prev= 6768*b50261e2SCy Schubert prevarg= 6769*b50261e2SCy Schubert release= 6770*b50261e2SCy Schubert rpath= 6771*b50261e2SCy Schubert xrpath= 6772*b50261e2SCy Schubert perm_rpath= 6773*b50261e2SCy Schubert temp_rpath= 6774*b50261e2SCy Schubert thread_safe=no 6775*b50261e2SCy Schubert vinfo= 6776*b50261e2SCy Schubert vinfo_number=no 6777*b50261e2SCy Schubert weak_libs= 6778*b50261e2SCy Schubert single_module=$wl-single_module 6779*b50261e2SCy Schubert func_infer_tag $base_compile 6780*b50261e2SCy Schubert 6781*b50261e2SCy Schubert # We need to know -static, to get the right output filenames. 6782*b50261e2SCy Schubert for arg 6783*b50261e2SCy Schubert do 6784*b50261e2SCy Schubert case $arg in 6785*b50261e2SCy Schubert -shared) 6786*b50261e2SCy Schubert test yes != "$build_libtool_libs" \ 6787*b50261e2SCy Schubert && func_fatal_configuration "cannot build a shared library" 6788*b50261e2SCy Schubert build_old_libs=no 6789*b50261e2SCy Schubert break 6790*b50261e2SCy Schubert ;; 6791*b50261e2SCy Schubert -all-static | -static | -static-libtool-libs) 6792*b50261e2SCy Schubert case $arg in 6793*b50261e2SCy Schubert -all-static) 6794*b50261e2SCy Schubert if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6795*b50261e2SCy Schubert func_warning "complete static linking is impossible in this configuration" 6796*b50261e2SCy Schubert fi 6797*b50261e2SCy Schubert if test -n "$link_static_flag"; then 6798*b50261e2SCy Schubert dlopen_self=$dlopen_self_static 6799*b50261e2SCy Schubert fi 6800*b50261e2SCy Schubert prefer_static_libs=yes 6801*b50261e2SCy Schubert ;; 6802*b50261e2SCy Schubert -static) 6803*b50261e2SCy Schubert if test -z "$pic_flag" && test -n "$link_static_flag"; then 6804*b50261e2SCy Schubert dlopen_self=$dlopen_self_static 6805*b50261e2SCy Schubert fi 6806*b50261e2SCy Schubert prefer_static_libs=built 6807*b50261e2SCy Schubert ;; 6808*b50261e2SCy Schubert -static-libtool-libs) 6809*b50261e2SCy Schubert if test -z "$pic_flag" && test -n "$link_static_flag"; then 6810*b50261e2SCy Schubert dlopen_self=$dlopen_self_static 6811*b50261e2SCy Schubert fi 6812*b50261e2SCy Schubert prefer_static_libs=yes 6813*b50261e2SCy Schubert ;; 6814*b50261e2SCy Schubert esac 6815*b50261e2SCy Schubert build_libtool_libs=no 6816*b50261e2SCy Schubert build_old_libs=yes 6817*b50261e2SCy Schubert break 6818*b50261e2SCy Schubert ;; 6819*b50261e2SCy Schubert esac 6820*b50261e2SCy Schubert done 6821*b50261e2SCy Schubert 6822*b50261e2SCy Schubert # See if our shared archives depend on static archives. 6823*b50261e2SCy Schubert test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6824*b50261e2SCy Schubert 6825*b50261e2SCy Schubert # Go through the arguments, transforming them on the way. 6826*b50261e2SCy Schubert while test "$#" -gt 0; do 6827*b50261e2SCy Schubert arg=$1 6828*b50261e2SCy Schubert shift 6829*b50261e2SCy Schubert func_quote_arg pretty,unquoted "$arg" 6830*b50261e2SCy Schubert qarg=$func_quote_arg_unquoted_result 6831*b50261e2SCy Schubert func_append libtool_args " $func_quote_arg_result" 6832*b50261e2SCy Schubert 6833*b50261e2SCy Schubert # If the previous option needs an argument, assign it. 6834*b50261e2SCy Schubert if test -n "$prev"; then 6835*b50261e2SCy Schubert case $prev in 6836*b50261e2SCy Schubert output) 6837*b50261e2SCy Schubert func_append compile_command " @OUTPUT@" 6838*b50261e2SCy Schubert func_append finalize_command " @OUTPUT@" 6839*b50261e2SCy Schubert ;; 6840*b50261e2SCy Schubert esac 6841*b50261e2SCy Schubert 6842*b50261e2SCy Schubert case $prev in 6843*b50261e2SCy Schubert bindir) 6844*b50261e2SCy Schubert bindir=$arg 6845*b50261e2SCy Schubert prev= 6846*b50261e2SCy Schubert continue 6847*b50261e2SCy Schubert ;; 6848*b50261e2SCy Schubert dlfiles|dlprefiles) 6849*b50261e2SCy Schubert $preload || { 6850*b50261e2SCy Schubert # Add the symbol object into the linking commands. 6851*b50261e2SCy Schubert func_append compile_command " @SYMFILE@" 6852*b50261e2SCy Schubert func_append finalize_command " @SYMFILE@" 6853*b50261e2SCy Schubert preload=: 6854*b50261e2SCy Schubert } 6855*b50261e2SCy Schubert case $arg in 6856*b50261e2SCy Schubert *.la | *.lo) ;; # We handle these cases below. 6857*b50261e2SCy Schubert force) 6858*b50261e2SCy Schubert if test no = "$dlself"; then 6859*b50261e2SCy Schubert dlself=needless 6860*b50261e2SCy Schubert export_dynamic=yes 6861*b50261e2SCy Schubert fi 6862*b50261e2SCy Schubert prev= 6863*b50261e2SCy Schubert continue 6864*b50261e2SCy Schubert ;; 6865*b50261e2SCy Schubert self) 6866*b50261e2SCy Schubert if test dlprefiles = "$prev"; then 6867*b50261e2SCy Schubert dlself=yes 6868*b50261e2SCy Schubert elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6869*b50261e2SCy Schubert dlself=yes 6870*b50261e2SCy Schubert else 6871*b50261e2SCy Schubert dlself=needless 6872*b50261e2SCy Schubert export_dynamic=yes 6873*b50261e2SCy Schubert fi 6874*b50261e2SCy Schubert prev= 6875*b50261e2SCy Schubert continue 6876*b50261e2SCy Schubert ;; 6877*b50261e2SCy Schubert *) 6878*b50261e2SCy Schubert if test dlfiles = "$prev"; then 6879*b50261e2SCy Schubert func_append dlfiles " $arg" 6880*b50261e2SCy Schubert else 6881*b50261e2SCy Schubert func_append dlprefiles " $arg" 6882*b50261e2SCy Schubert fi 6883*b50261e2SCy Schubert prev= 6884*b50261e2SCy Schubert continue 6885*b50261e2SCy Schubert ;; 6886*b50261e2SCy Schubert esac 6887*b50261e2SCy Schubert ;; 6888*b50261e2SCy Schubert expsyms) 6889*b50261e2SCy Schubert export_symbols=$arg 6890*b50261e2SCy Schubert test -f "$arg" \ 6891*b50261e2SCy Schubert || func_fatal_error "symbol file '$arg' does not exist" 6892*b50261e2SCy Schubert prev= 6893*b50261e2SCy Schubert continue 6894*b50261e2SCy Schubert ;; 6895*b50261e2SCy Schubert expsyms_regex) 6896*b50261e2SCy Schubert export_symbols_regex=$arg 6897*b50261e2SCy Schubert prev= 6898*b50261e2SCy Schubert continue 6899*b50261e2SCy Schubert ;; 6900*b50261e2SCy Schubert framework) 6901*b50261e2SCy Schubert case $host in 6902*b50261e2SCy Schubert *-*-darwin*) 6903*b50261e2SCy Schubert case "$deplibs " in 6904*b50261e2SCy Schubert *" $qarg.ltframework "*) ;; 6905*b50261e2SCy Schubert *) func_append deplibs " $qarg.ltframework" # this is fixed later 6906*b50261e2SCy Schubert ;; 6907*b50261e2SCy Schubert esac 6908*b50261e2SCy Schubert ;; 6909*b50261e2SCy Schubert esac 6910*b50261e2SCy Schubert prev= 6911*b50261e2SCy Schubert continue 6912*b50261e2SCy Schubert ;; 6913*b50261e2SCy Schubert inst_prefix) 6914*b50261e2SCy Schubert inst_prefix_dir=$arg 6915*b50261e2SCy Schubert prev= 6916*b50261e2SCy Schubert continue 6917*b50261e2SCy Schubert ;; 6918*b50261e2SCy Schubert mllvm) 6919*b50261e2SCy Schubert # Clang does not use LLVM to link, so we can simply discard any 6920*b50261e2SCy Schubert # '-mllvm $arg' options when doing the link step. 6921*b50261e2SCy Schubert prev= 6922*b50261e2SCy Schubert continue 6923*b50261e2SCy Schubert ;; 6924*b50261e2SCy Schubert objectlist) 6925*b50261e2SCy Schubert if test -f "$arg"; then 6926*b50261e2SCy Schubert save_arg=$arg 6927*b50261e2SCy Schubert moreargs= 6928*b50261e2SCy Schubert for fil in `cat "$save_arg"` 6929*b50261e2SCy Schubert do 6930*b50261e2SCy Schubert# func_append moreargs " $fil" 6931*b50261e2SCy Schubert arg=$fil 6932*b50261e2SCy Schubert # A libtool-controlled object. 6933*b50261e2SCy Schubert 6934*b50261e2SCy Schubert # Check to see that this really is a libtool object. 6935*b50261e2SCy Schubert if func_lalib_unsafe_p "$arg"; then 6936*b50261e2SCy Schubert pic_object= 6937*b50261e2SCy Schubert non_pic_object= 6938*b50261e2SCy Schubert 6939*b50261e2SCy Schubert # Read the .lo file 6940*b50261e2SCy Schubert func_source "$arg" 6941*b50261e2SCy Schubert 6942*b50261e2SCy Schubert if test -z "$pic_object" || 6943*b50261e2SCy Schubert test -z "$non_pic_object" || 6944*b50261e2SCy Schubert test none = "$pic_object" && 6945*b50261e2SCy Schubert test none = "$non_pic_object"; then 6946*b50261e2SCy Schubert func_fatal_error "cannot find name of object for '$arg'" 6947*b50261e2SCy Schubert fi 6948*b50261e2SCy Schubert 6949*b50261e2SCy Schubert # Extract subdirectory from the argument. 6950*b50261e2SCy Schubert func_dirname "$arg" "/" "" 6951*b50261e2SCy Schubert xdir=$func_dirname_result 6952*b50261e2SCy Schubert 6953*b50261e2SCy Schubert if test none != "$pic_object"; then 6954*b50261e2SCy Schubert # Prepend the subdirectory the object is found in. 6955*b50261e2SCy Schubert pic_object=$xdir$pic_object 6956*b50261e2SCy Schubert 6957*b50261e2SCy Schubert if test dlfiles = "$prev"; then 6958*b50261e2SCy Schubert if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6959*b50261e2SCy Schubert func_append dlfiles " $pic_object" 6960*b50261e2SCy Schubert prev= 6961*b50261e2SCy Schubert continue 6962*b50261e2SCy Schubert else 6963*b50261e2SCy Schubert # If libtool objects are unsupported, then we need to preload. 6964*b50261e2SCy Schubert prev=dlprefiles 6965*b50261e2SCy Schubert fi 6966*b50261e2SCy Schubert fi 6967*b50261e2SCy Schubert 6968*b50261e2SCy Schubert # CHECK ME: I think I busted this. -Ossama 6969*b50261e2SCy Schubert if test dlprefiles = "$prev"; then 6970*b50261e2SCy Schubert # Preload the old-style object. 6971*b50261e2SCy Schubert func_append dlprefiles " $pic_object" 6972*b50261e2SCy Schubert prev= 6973*b50261e2SCy Schubert fi 6974*b50261e2SCy Schubert 6975*b50261e2SCy Schubert # A PIC object. 6976*b50261e2SCy Schubert func_append libobjs " $pic_object" 6977*b50261e2SCy Schubert arg=$pic_object 6978*b50261e2SCy Schubert fi 6979*b50261e2SCy Schubert 6980*b50261e2SCy Schubert # Non-PIC object. 6981*b50261e2SCy Schubert if test none != "$non_pic_object"; then 6982*b50261e2SCy Schubert # Prepend the subdirectory the object is found in. 6983*b50261e2SCy Schubert non_pic_object=$xdir$non_pic_object 6984*b50261e2SCy Schubert 6985*b50261e2SCy Schubert # A standard non-PIC object 6986*b50261e2SCy Schubert func_append non_pic_objects " $non_pic_object" 6987*b50261e2SCy Schubert if test -z "$pic_object" || test none = "$pic_object"; then 6988*b50261e2SCy Schubert arg=$non_pic_object 6989*b50261e2SCy Schubert fi 6990*b50261e2SCy Schubert else 6991*b50261e2SCy Schubert # If the PIC object exists, use it instead. 6992*b50261e2SCy Schubert # $xdir was prepended to $pic_object above. 6993*b50261e2SCy Schubert non_pic_object=$pic_object 6994*b50261e2SCy Schubert func_append non_pic_objects " $non_pic_object" 6995*b50261e2SCy Schubert fi 6996*b50261e2SCy Schubert else 6997*b50261e2SCy Schubert # Only an error if not doing a dry-run. 6998*b50261e2SCy Schubert if $opt_dry_run; then 6999*b50261e2SCy Schubert # Extract subdirectory from the argument. 7000*b50261e2SCy Schubert func_dirname "$arg" "/" "" 7001*b50261e2SCy Schubert xdir=$func_dirname_result 7002*b50261e2SCy Schubert 7003*b50261e2SCy Schubert func_lo2o "$arg" 7004*b50261e2SCy Schubert pic_object=$xdir$objdir/$func_lo2o_result 7005*b50261e2SCy Schubert non_pic_object=$xdir$func_lo2o_result 7006*b50261e2SCy Schubert func_append libobjs " $pic_object" 7007*b50261e2SCy Schubert func_append non_pic_objects " $non_pic_object" 7008*b50261e2SCy Schubert else 7009*b50261e2SCy Schubert func_fatal_error "'$arg' is not a valid libtool object" 7010*b50261e2SCy Schubert fi 7011*b50261e2SCy Schubert fi 7012*b50261e2SCy Schubert done 7013*b50261e2SCy Schubert else 7014*b50261e2SCy Schubert func_fatal_error "link input file '$arg' does not exist" 7015*b50261e2SCy Schubert fi 7016*b50261e2SCy Schubert arg=$save_arg 7017*b50261e2SCy Schubert prev= 7018*b50261e2SCy Schubert continue 7019*b50261e2SCy Schubert ;; 7020*b50261e2SCy Schubert os2dllname) 7021*b50261e2SCy Schubert os2dllname=$arg 7022*b50261e2SCy Schubert prev= 7023*b50261e2SCy Schubert continue 7024*b50261e2SCy Schubert ;; 7025*b50261e2SCy Schubert precious_regex) 7026*b50261e2SCy Schubert precious_files_regex=$arg 7027*b50261e2SCy Schubert prev= 7028*b50261e2SCy Schubert continue 7029*b50261e2SCy Schubert ;; 7030*b50261e2SCy Schubert release) 7031*b50261e2SCy Schubert release=-$arg 7032*b50261e2SCy Schubert prev= 7033*b50261e2SCy Schubert continue 7034*b50261e2SCy Schubert ;; 7035*b50261e2SCy Schubert rpath | xrpath) 7036*b50261e2SCy Schubert # We need an absolute path. 7037*b50261e2SCy Schubert case $arg in 7038*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 7039*b50261e2SCy Schubert *) 7040*b50261e2SCy Schubert func_fatal_error "only absolute run-paths are allowed" 7041*b50261e2SCy Schubert ;; 7042*b50261e2SCy Schubert esac 7043*b50261e2SCy Schubert if test rpath = "$prev"; then 7044*b50261e2SCy Schubert case "$rpath " in 7045*b50261e2SCy Schubert *" $arg "*) ;; 7046*b50261e2SCy Schubert *) func_append rpath " $arg" ;; 7047*b50261e2SCy Schubert esac 7048*b50261e2SCy Schubert else 7049*b50261e2SCy Schubert case "$xrpath " in 7050*b50261e2SCy Schubert *" $arg "*) ;; 7051*b50261e2SCy Schubert *) func_append xrpath " $arg" ;; 7052*b50261e2SCy Schubert esac 7053*b50261e2SCy Schubert fi 7054*b50261e2SCy Schubert prev= 7055*b50261e2SCy Schubert continue 7056*b50261e2SCy Schubert ;; 7057*b50261e2SCy Schubert shrext) 7058*b50261e2SCy Schubert shrext_cmds=$arg 7059*b50261e2SCy Schubert prev= 7060*b50261e2SCy Schubert continue 7061*b50261e2SCy Schubert ;; 7062*b50261e2SCy Schubert weak) 7063*b50261e2SCy Schubert func_append weak_libs " $arg" 7064*b50261e2SCy Schubert prev= 7065*b50261e2SCy Schubert continue 7066*b50261e2SCy Schubert ;; 7067*b50261e2SCy Schubert xcclinker) 7068*b50261e2SCy Schubert func_append linker_flags " $qarg" 7069*b50261e2SCy Schubert func_append compiler_flags " $qarg" 7070*b50261e2SCy Schubert prev= 7071*b50261e2SCy Schubert func_append compile_command " $qarg" 7072*b50261e2SCy Schubert func_append finalize_command " $qarg" 7073*b50261e2SCy Schubert continue 7074*b50261e2SCy Schubert ;; 7075*b50261e2SCy Schubert xcompiler) 7076*b50261e2SCy Schubert func_append compiler_flags " $qarg" 7077*b50261e2SCy Schubert prev= 7078*b50261e2SCy Schubert func_append compile_command " $qarg" 7079*b50261e2SCy Schubert func_append finalize_command " $qarg" 7080*b50261e2SCy Schubert continue 7081*b50261e2SCy Schubert ;; 7082*b50261e2SCy Schubert xlinker) 7083*b50261e2SCy Schubert func_append linker_flags " $qarg" 7084*b50261e2SCy Schubert func_append compiler_flags " $wl$qarg" 7085*b50261e2SCy Schubert prev= 7086*b50261e2SCy Schubert func_append compile_command " $wl$qarg" 7087*b50261e2SCy Schubert func_append finalize_command " $wl$qarg" 7088*b50261e2SCy Schubert continue 7089*b50261e2SCy Schubert ;; 7090*b50261e2SCy Schubert *) 7091*b50261e2SCy Schubert eval "$prev=\"\$arg\"" 7092*b50261e2SCy Schubert prev= 7093*b50261e2SCy Schubert continue 7094*b50261e2SCy Schubert ;; 7095*b50261e2SCy Schubert esac 7096*b50261e2SCy Schubert fi # test -n "$prev" 7097*b50261e2SCy Schubert 7098*b50261e2SCy Schubert prevarg=$arg 7099*b50261e2SCy Schubert 7100*b50261e2SCy Schubert case $arg in 7101*b50261e2SCy Schubert -all-static) 7102*b50261e2SCy Schubert if test -n "$link_static_flag"; then 7103*b50261e2SCy Schubert # See comment for -static flag below, for more details. 7104*b50261e2SCy Schubert func_append compile_command " $link_static_flag" 7105*b50261e2SCy Schubert func_append finalize_command " $link_static_flag" 7106*b50261e2SCy Schubert fi 7107*b50261e2SCy Schubert continue 7108*b50261e2SCy Schubert ;; 7109*b50261e2SCy Schubert 7110*b50261e2SCy Schubert -allow-undefined) 7111*b50261e2SCy Schubert # FIXME: remove this flag sometime in the future. 7112*b50261e2SCy Schubert func_fatal_error "'-allow-undefined' must not be used because it is the default" 7113*b50261e2SCy Schubert ;; 7114*b50261e2SCy Schubert 7115*b50261e2SCy Schubert -avoid-version) 7116*b50261e2SCy Schubert avoid_version=yes 7117*b50261e2SCy Schubert continue 7118*b50261e2SCy Schubert ;; 7119*b50261e2SCy Schubert 7120*b50261e2SCy Schubert -bindir) 7121*b50261e2SCy Schubert prev=bindir 7122*b50261e2SCy Schubert continue 7123*b50261e2SCy Schubert ;; 7124*b50261e2SCy Schubert 7125*b50261e2SCy Schubert -dlopen) 7126*b50261e2SCy Schubert prev=dlfiles 7127*b50261e2SCy Schubert continue 7128*b50261e2SCy Schubert ;; 7129*b50261e2SCy Schubert 7130*b50261e2SCy Schubert -dlpreopen) 7131*b50261e2SCy Schubert prev=dlprefiles 7132*b50261e2SCy Schubert continue 7133*b50261e2SCy Schubert ;; 7134*b50261e2SCy Schubert 7135*b50261e2SCy Schubert -export-dynamic) 7136*b50261e2SCy Schubert export_dynamic=yes 7137*b50261e2SCy Schubert continue 7138*b50261e2SCy Schubert ;; 7139*b50261e2SCy Schubert 7140*b50261e2SCy Schubert -export-symbols | -export-symbols-regex) 7141*b50261e2SCy Schubert if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7142*b50261e2SCy Schubert func_fatal_error "more than one -exported-symbols argument is not allowed" 7143*b50261e2SCy Schubert fi 7144*b50261e2SCy Schubert if test X-export-symbols = "X$arg"; then 7145*b50261e2SCy Schubert prev=expsyms 7146*b50261e2SCy Schubert else 7147*b50261e2SCy Schubert prev=expsyms_regex 7148*b50261e2SCy Schubert fi 7149*b50261e2SCy Schubert continue 7150*b50261e2SCy Schubert ;; 7151*b50261e2SCy Schubert 7152*b50261e2SCy Schubert -framework) 7153*b50261e2SCy Schubert prev=framework 7154*b50261e2SCy Schubert continue 7155*b50261e2SCy Schubert ;; 7156*b50261e2SCy Schubert 7157*b50261e2SCy Schubert -inst-prefix-dir) 7158*b50261e2SCy Schubert prev=inst_prefix 7159*b50261e2SCy Schubert continue 7160*b50261e2SCy Schubert ;; 7161*b50261e2SCy Schubert 7162*b50261e2SCy Schubert # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7163*b50261e2SCy Schubert # so, if we see these flags be careful not to treat them like -L 7164*b50261e2SCy Schubert -L[A-Z][A-Z]*:*) 7165*b50261e2SCy Schubert case $with_gcc/$host in 7166*b50261e2SCy Schubert no/*-*-irix* | /*-*-irix*) 7167*b50261e2SCy Schubert func_append compile_command " $arg" 7168*b50261e2SCy Schubert func_append finalize_command " $arg" 7169*b50261e2SCy Schubert ;; 7170*b50261e2SCy Schubert esac 7171*b50261e2SCy Schubert continue 7172*b50261e2SCy Schubert ;; 7173*b50261e2SCy Schubert 7174*b50261e2SCy Schubert -L*) 7175*b50261e2SCy Schubert func_stripname "-L" '' "$arg" 7176*b50261e2SCy Schubert if test -z "$func_stripname_result"; then 7177*b50261e2SCy Schubert if test "$#" -gt 0; then 7178*b50261e2SCy Schubert func_fatal_error "require no space between '-L' and '$1'" 7179*b50261e2SCy Schubert else 7180*b50261e2SCy Schubert func_fatal_error "need path for '-L' option" 7181*b50261e2SCy Schubert fi 7182*b50261e2SCy Schubert fi 7183*b50261e2SCy Schubert func_resolve_sysroot "$func_stripname_result" 7184*b50261e2SCy Schubert dir=$func_resolve_sysroot_result 7185*b50261e2SCy Schubert # We need an absolute path. 7186*b50261e2SCy Schubert case $dir in 7187*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 7188*b50261e2SCy Schubert *) 7189*b50261e2SCy Schubert absdir=`cd "$dir" && pwd` 7190*b50261e2SCy Schubert test -z "$absdir" && \ 7191*b50261e2SCy Schubert func_fatal_error "cannot determine absolute directory name of '$dir'" 7192*b50261e2SCy Schubert dir=$absdir 7193*b50261e2SCy Schubert ;; 7194*b50261e2SCy Schubert esac 7195*b50261e2SCy Schubert case "$deplibs " in 7196*b50261e2SCy Schubert *" -L$dir "* | *" $arg "*) 7197*b50261e2SCy Schubert # Will only happen for absolute or sysroot arguments 7198*b50261e2SCy Schubert ;; 7199*b50261e2SCy Schubert *) 7200*b50261e2SCy Schubert # Preserve sysroot, but never include relative directories 7201*b50261e2SCy Schubert case $dir in 7202*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7203*b50261e2SCy Schubert *) func_append deplibs " -L$dir" ;; 7204*b50261e2SCy Schubert esac 7205*b50261e2SCy Schubert func_append lib_search_path " $dir" 7206*b50261e2SCy Schubert ;; 7207*b50261e2SCy Schubert esac 7208*b50261e2SCy Schubert case $host in 7209*b50261e2SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7210*b50261e2SCy Schubert testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7211*b50261e2SCy Schubert case :$dllsearchpath: in 7212*b50261e2SCy Schubert *":$dir:"*) ;; 7213*b50261e2SCy Schubert ::) dllsearchpath=$dir;; 7214*b50261e2SCy Schubert *) func_append dllsearchpath ":$dir";; 7215*b50261e2SCy Schubert esac 7216*b50261e2SCy Schubert case :$dllsearchpath: in 7217*b50261e2SCy Schubert *":$testbindir:"*) ;; 7218*b50261e2SCy Schubert ::) dllsearchpath=$testbindir;; 7219*b50261e2SCy Schubert *) func_append dllsearchpath ":$testbindir";; 7220*b50261e2SCy Schubert esac 7221*b50261e2SCy Schubert ;; 7222*b50261e2SCy Schubert esac 7223*b50261e2SCy Schubert continue 7224*b50261e2SCy Schubert ;; 7225*b50261e2SCy Schubert 7226*b50261e2SCy Schubert -l*) 7227*b50261e2SCy Schubert if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7228*b50261e2SCy Schubert case $host in 7229*b50261e2SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7230*b50261e2SCy Schubert # These systems don't actually have a C or math library (as such) 7231*b50261e2SCy Schubert continue 7232*b50261e2SCy Schubert ;; 7233*b50261e2SCy Schubert *-*-os2*) 7234*b50261e2SCy Schubert # These systems don't actually have a C library (as such) 7235*b50261e2SCy Schubert test X-lc = "X$arg" && continue 7236*b50261e2SCy Schubert ;; 7237*b50261e2SCy Schubert *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7238*b50261e2SCy Schubert # Do not include libc due to us having libc/libc_r. 7239*b50261e2SCy Schubert test X-lc = "X$arg" && continue 7240*b50261e2SCy Schubert ;; 7241*b50261e2SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 7242*b50261e2SCy Schubert # Rhapsody C and math libraries are in the System framework 7243*b50261e2SCy Schubert func_append deplibs " System.ltframework" 7244*b50261e2SCy Schubert continue 7245*b50261e2SCy Schubert ;; 7246*b50261e2SCy Schubert *-*-sco3.2v5* | *-*-sco5v6*) 7247*b50261e2SCy Schubert # Causes problems with __ctype 7248*b50261e2SCy Schubert test X-lc = "X$arg" && continue 7249*b50261e2SCy Schubert ;; 7250*b50261e2SCy Schubert *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7251*b50261e2SCy Schubert # Compiler inserts libc in the correct place for threads to work 7252*b50261e2SCy Schubert test X-lc = "X$arg" && continue 7253*b50261e2SCy Schubert ;; 7254*b50261e2SCy Schubert esac 7255*b50261e2SCy Schubert elif test X-lc_r = "X$arg"; then 7256*b50261e2SCy Schubert case $host in 7257*b50261e2SCy Schubert *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7258*b50261e2SCy Schubert # Do not include libc_r directly, use -pthread flag. 7259*b50261e2SCy Schubert continue 7260*b50261e2SCy Schubert ;; 7261*b50261e2SCy Schubert esac 7262*b50261e2SCy Schubert fi 7263*b50261e2SCy Schubert func_append deplibs " $arg" 7264*b50261e2SCy Schubert continue 7265*b50261e2SCy Schubert ;; 7266*b50261e2SCy Schubert 7267*b50261e2SCy Schubert -mllvm) 7268*b50261e2SCy Schubert prev=mllvm 7269*b50261e2SCy Schubert continue 7270*b50261e2SCy Schubert ;; 7271*b50261e2SCy Schubert 7272*b50261e2SCy Schubert -module) 7273*b50261e2SCy Schubert module=yes 7274*b50261e2SCy Schubert continue 7275*b50261e2SCy Schubert ;; 7276*b50261e2SCy Schubert 7277*b50261e2SCy Schubert # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7278*b50261e2SCy Schubert # classes, name mangling, and exception handling. 7279*b50261e2SCy Schubert # Darwin uses the -arch flag to determine output architecture. 7280*b50261e2SCy Schubert -model|-arch|-isysroot|--sysroot) 7281*b50261e2SCy Schubert func_append compiler_flags " $arg" 7282*b50261e2SCy Schubert func_append compile_command " $arg" 7283*b50261e2SCy Schubert func_append finalize_command " $arg" 7284*b50261e2SCy Schubert prev=xcompiler 7285*b50261e2SCy Schubert continue 7286*b50261e2SCy Schubert ;; 7287*b50261e2SCy Schubert 7288*b50261e2SCy Schubert -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7289*b50261e2SCy Schubert |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7290*b50261e2SCy Schubert func_append compiler_flags " $arg" 7291*b50261e2SCy Schubert func_append compile_command " $arg" 7292*b50261e2SCy Schubert func_append finalize_command " $arg" 7293*b50261e2SCy Schubert case "$new_inherited_linker_flags " in 7294*b50261e2SCy Schubert *" $arg "*) ;; 7295*b50261e2SCy Schubert * ) func_append new_inherited_linker_flags " $arg" ;; 7296*b50261e2SCy Schubert esac 7297*b50261e2SCy Schubert continue 7298*b50261e2SCy Schubert ;; 7299*b50261e2SCy Schubert 7300*b50261e2SCy Schubert -multi_module) 7301*b50261e2SCy Schubert single_module=$wl-multi_module 7302*b50261e2SCy Schubert continue 7303*b50261e2SCy Schubert ;; 7304*b50261e2SCy Schubert 7305*b50261e2SCy Schubert -no-fast-install) 7306*b50261e2SCy Schubert fast_install=no 7307*b50261e2SCy Schubert continue 7308*b50261e2SCy Schubert ;; 7309*b50261e2SCy Schubert 7310*b50261e2SCy Schubert -no-install) 7311*b50261e2SCy Schubert case $host in 7312*b50261e2SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7313*b50261e2SCy Schubert # The PATH hackery in wrapper scripts is required on Windows 7314*b50261e2SCy Schubert # and Darwin in order for the loader to find any dlls it needs. 7315*b50261e2SCy Schubert func_warning "'-no-install' is ignored for $host" 7316*b50261e2SCy Schubert func_warning "assuming '-no-fast-install' instead" 7317*b50261e2SCy Schubert fast_install=no 7318*b50261e2SCy Schubert ;; 7319*b50261e2SCy Schubert *) no_install=yes ;; 7320*b50261e2SCy Schubert esac 7321*b50261e2SCy Schubert continue 7322*b50261e2SCy Schubert ;; 7323*b50261e2SCy Schubert 7324*b50261e2SCy Schubert -no-undefined) 7325*b50261e2SCy Schubert allow_undefined=no 7326*b50261e2SCy Schubert continue 7327*b50261e2SCy Schubert ;; 7328*b50261e2SCy Schubert 7329*b50261e2SCy Schubert -objectlist) 7330*b50261e2SCy Schubert prev=objectlist 7331*b50261e2SCy Schubert continue 7332*b50261e2SCy Schubert ;; 7333*b50261e2SCy Schubert 7334*b50261e2SCy Schubert -os2dllname) 7335*b50261e2SCy Schubert prev=os2dllname 7336*b50261e2SCy Schubert continue 7337*b50261e2SCy Schubert ;; 7338*b50261e2SCy Schubert 7339*b50261e2SCy Schubert -o) prev=output ;; 7340*b50261e2SCy Schubert 7341*b50261e2SCy Schubert -precious-files-regex) 7342*b50261e2SCy Schubert prev=precious_regex 7343*b50261e2SCy Schubert continue 7344*b50261e2SCy Schubert ;; 7345*b50261e2SCy Schubert 7346*b50261e2SCy Schubert -release) 7347*b50261e2SCy Schubert prev=release 7348*b50261e2SCy Schubert continue 7349*b50261e2SCy Schubert ;; 7350*b50261e2SCy Schubert 7351*b50261e2SCy Schubert -rpath) 7352*b50261e2SCy Schubert prev=rpath 7353*b50261e2SCy Schubert continue 7354*b50261e2SCy Schubert ;; 7355*b50261e2SCy Schubert 7356*b50261e2SCy Schubert -R) 7357*b50261e2SCy Schubert prev=xrpath 7358*b50261e2SCy Schubert continue 7359*b50261e2SCy Schubert ;; 7360*b50261e2SCy Schubert 7361*b50261e2SCy Schubert -R*) 7362*b50261e2SCy Schubert func_stripname '-R' '' "$arg" 7363*b50261e2SCy Schubert dir=$func_stripname_result 7364*b50261e2SCy Schubert # We need an absolute path. 7365*b50261e2SCy Schubert case $dir in 7366*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 7367*b50261e2SCy Schubert =*) 7368*b50261e2SCy Schubert func_stripname '=' '' "$dir" 7369*b50261e2SCy Schubert dir=$lt_sysroot$func_stripname_result 7370*b50261e2SCy Schubert ;; 7371*b50261e2SCy Schubert *) 7372*b50261e2SCy Schubert func_fatal_error "only absolute run-paths are allowed" 7373*b50261e2SCy Schubert ;; 7374*b50261e2SCy Schubert esac 7375*b50261e2SCy Schubert case "$xrpath " in 7376*b50261e2SCy Schubert *" $dir "*) ;; 7377*b50261e2SCy Schubert *) func_append xrpath " $dir" ;; 7378*b50261e2SCy Schubert esac 7379*b50261e2SCy Schubert continue 7380*b50261e2SCy Schubert ;; 7381*b50261e2SCy Schubert 7382*b50261e2SCy Schubert -shared) 7383*b50261e2SCy Schubert # The effects of -shared are defined in a previous loop. 7384*b50261e2SCy Schubert continue 7385*b50261e2SCy Schubert ;; 7386*b50261e2SCy Schubert 7387*b50261e2SCy Schubert -shrext) 7388*b50261e2SCy Schubert prev=shrext 7389*b50261e2SCy Schubert continue 7390*b50261e2SCy Schubert ;; 7391*b50261e2SCy Schubert 7392*b50261e2SCy Schubert -static | -static-libtool-libs) 7393*b50261e2SCy Schubert # The effects of -static are defined in a previous loop. 7394*b50261e2SCy Schubert # We used to do the same as -all-static on platforms that 7395*b50261e2SCy Schubert # didn't have a PIC flag, but the assumption that the effects 7396*b50261e2SCy Schubert # would be equivalent was wrong. It would break on at least 7397*b50261e2SCy Schubert # Digital Unix and AIX. 7398*b50261e2SCy Schubert continue 7399*b50261e2SCy Schubert ;; 7400*b50261e2SCy Schubert 7401*b50261e2SCy Schubert -thread-safe) 7402*b50261e2SCy Schubert thread_safe=yes 7403*b50261e2SCy Schubert continue 7404*b50261e2SCy Schubert ;; 7405*b50261e2SCy Schubert 7406*b50261e2SCy Schubert -version-info) 7407*b50261e2SCy Schubert prev=vinfo 7408*b50261e2SCy Schubert continue 7409*b50261e2SCy Schubert ;; 7410*b50261e2SCy Schubert 7411*b50261e2SCy Schubert -version-number) 7412*b50261e2SCy Schubert prev=vinfo 7413*b50261e2SCy Schubert vinfo_number=yes 7414*b50261e2SCy Schubert continue 7415*b50261e2SCy Schubert ;; 7416*b50261e2SCy Schubert 7417*b50261e2SCy Schubert -weak) 7418*b50261e2SCy Schubert prev=weak 7419*b50261e2SCy Schubert continue 7420*b50261e2SCy Schubert ;; 7421*b50261e2SCy Schubert 7422*b50261e2SCy Schubert -Wc,*) 7423*b50261e2SCy Schubert func_stripname '-Wc,' '' "$arg" 7424*b50261e2SCy Schubert args=$func_stripname_result 7425*b50261e2SCy Schubert arg= 7426*b50261e2SCy Schubert save_ifs=$IFS; IFS=, 7427*b50261e2SCy Schubert for flag in $args; do 7428*b50261e2SCy Schubert IFS=$save_ifs 7429*b50261e2SCy Schubert func_quote_arg pretty "$flag" 7430*b50261e2SCy Schubert func_append arg " $func_quote_arg_result" 7431*b50261e2SCy Schubert func_append compiler_flags " $func_quote_arg_result" 7432*b50261e2SCy Schubert done 7433*b50261e2SCy Schubert IFS=$save_ifs 7434*b50261e2SCy Schubert func_stripname ' ' '' "$arg" 7435*b50261e2SCy Schubert arg=$func_stripname_result 7436*b50261e2SCy Schubert ;; 7437*b50261e2SCy Schubert 7438*b50261e2SCy Schubert -Wl,*) 7439*b50261e2SCy Schubert func_stripname '-Wl,' '' "$arg" 7440*b50261e2SCy Schubert args=$func_stripname_result 7441*b50261e2SCy Schubert arg= 7442*b50261e2SCy Schubert save_ifs=$IFS; IFS=, 7443*b50261e2SCy Schubert for flag in $args; do 7444*b50261e2SCy Schubert IFS=$save_ifs 7445*b50261e2SCy Schubert func_quote_arg pretty "$flag" 7446*b50261e2SCy Schubert func_append arg " $wl$func_quote_arg_result" 7447*b50261e2SCy Schubert func_append compiler_flags " $wl$func_quote_arg_result" 7448*b50261e2SCy Schubert func_append linker_flags " $func_quote_arg_result" 7449*b50261e2SCy Schubert done 7450*b50261e2SCy Schubert IFS=$save_ifs 7451*b50261e2SCy Schubert func_stripname ' ' '' "$arg" 7452*b50261e2SCy Schubert arg=$func_stripname_result 7453*b50261e2SCy Schubert ;; 7454*b50261e2SCy Schubert 7455*b50261e2SCy Schubert -Xcompiler) 7456*b50261e2SCy Schubert prev=xcompiler 7457*b50261e2SCy Schubert continue 7458*b50261e2SCy Schubert ;; 7459*b50261e2SCy Schubert 7460*b50261e2SCy Schubert -Xlinker) 7461*b50261e2SCy Schubert prev=xlinker 7462*b50261e2SCy Schubert continue 7463*b50261e2SCy Schubert ;; 7464*b50261e2SCy Schubert 7465*b50261e2SCy Schubert -XCClinker) 7466*b50261e2SCy Schubert prev=xcclinker 7467*b50261e2SCy Schubert continue 7468*b50261e2SCy Schubert ;; 7469*b50261e2SCy Schubert 7470*b50261e2SCy Schubert # -msg_* for osf cc 7471*b50261e2SCy Schubert -msg_*) 7472*b50261e2SCy Schubert func_quote_arg pretty "$arg" 7473*b50261e2SCy Schubert arg=$func_quote_arg_result 7474*b50261e2SCy Schubert ;; 7475*b50261e2SCy Schubert 7476*b50261e2SCy Schubert # Flags to be passed through unchanged, with rationale: 7477*b50261e2SCy Schubert # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7478*b50261e2SCy Schubert # -r[0-9][0-9]* specify processor for the SGI compiler 7479*b50261e2SCy Schubert # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7480*b50261e2SCy Schubert # +DA*, +DD* enable 64-bit mode for the HP compiler 7481*b50261e2SCy Schubert # -q* compiler args for the IBM compiler 7482*b50261e2SCy Schubert # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7483*b50261e2SCy Schubert # -F/path path to uninstalled frameworks, gcc on darwin 7484*b50261e2SCy Schubert # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7485*b50261e2SCy Schubert # -fstack-protector* stack protector flags for GCC 7486*b50261e2SCy Schubert # @file GCC response files 7487*b50261e2SCy Schubert # -tp=* Portland pgcc target processor selection 7488*b50261e2SCy Schubert # --sysroot=* for sysroot support 7489*b50261e2SCy Schubert # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7490*b50261e2SCy Schubert # -specs=* GCC specs files 7491*b50261e2SCy Schubert # -stdlib=* select c++ std lib with clang 7492*b50261e2SCy Schubert # -fsanitize=* Clang/GCC memory and address sanitizer 7493*b50261e2SCy Schubert # -fuse-ld=* Linker select flags for GCC 7494*b50261e2SCy Schubert -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7495*b50261e2SCy Schubert -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7496*b50261e2SCy Schubert -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7497*b50261e2SCy Schubert -specs=*|-fsanitize=*|-fuse-ld=*) 7498*b50261e2SCy Schubert func_quote_arg pretty "$arg" 7499*b50261e2SCy Schubert arg=$func_quote_arg_result 7500*b50261e2SCy Schubert func_append compile_command " $arg" 7501*b50261e2SCy Schubert func_append finalize_command " $arg" 7502*b50261e2SCy Schubert func_append compiler_flags " $arg" 7503*b50261e2SCy Schubert continue 7504*b50261e2SCy Schubert ;; 7505*b50261e2SCy Schubert 7506*b50261e2SCy Schubert -Z*) 7507*b50261e2SCy Schubert if test os2 = "`expr $host : '.*\(os2\)'`"; then 7508*b50261e2SCy Schubert # OS/2 uses -Zxxx to specify OS/2-specific options 7509*b50261e2SCy Schubert compiler_flags="$compiler_flags $arg" 7510*b50261e2SCy Schubert func_append compile_command " $arg" 7511*b50261e2SCy Schubert func_append finalize_command " $arg" 7512*b50261e2SCy Schubert case $arg in 7513*b50261e2SCy Schubert -Zlinker | -Zstack) 7514*b50261e2SCy Schubert prev=xcompiler 7515*b50261e2SCy Schubert ;; 7516*b50261e2SCy Schubert esac 7517*b50261e2SCy Schubert continue 7518*b50261e2SCy Schubert else 7519*b50261e2SCy Schubert # Otherwise treat like 'Some other compiler flag' below 7520*b50261e2SCy Schubert func_quote_arg pretty "$arg" 7521*b50261e2SCy Schubert arg=$func_quote_arg_result 7522*b50261e2SCy Schubert fi 7523*b50261e2SCy Schubert ;; 7524*b50261e2SCy Schubert 7525*b50261e2SCy Schubert # Some other compiler flag. 7526*b50261e2SCy Schubert -* | +*) 7527*b50261e2SCy Schubert func_quote_arg pretty "$arg" 7528*b50261e2SCy Schubert arg=$func_quote_arg_result 7529*b50261e2SCy Schubert ;; 7530*b50261e2SCy Schubert 7531*b50261e2SCy Schubert *.$objext) 7532*b50261e2SCy Schubert # A standard object. 7533*b50261e2SCy Schubert func_append objs " $arg" 7534*b50261e2SCy Schubert ;; 7535*b50261e2SCy Schubert 7536*b50261e2SCy Schubert *.lo) 7537*b50261e2SCy Schubert # A libtool-controlled object. 7538*b50261e2SCy Schubert 7539*b50261e2SCy Schubert # Check to see that this really is a libtool object. 7540*b50261e2SCy Schubert if func_lalib_unsafe_p "$arg"; then 7541*b50261e2SCy Schubert pic_object= 7542*b50261e2SCy Schubert non_pic_object= 7543*b50261e2SCy Schubert 7544*b50261e2SCy Schubert # Read the .lo file 7545*b50261e2SCy Schubert func_source "$arg" 7546*b50261e2SCy Schubert 7547*b50261e2SCy Schubert if test -z "$pic_object" || 7548*b50261e2SCy Schubert test -z "$non_pic_object" || 7549*b50261e2SCy Schubert test none = "$pic_object" && 7550*b50261e2SCy Schubert test none = "$non_pic_object"; then 7551*b50261e2SCy Schubert func_fatal_error "cannot find name of object for '$arg'" 7552*b50261e2SCy Schubert fi 7553*b50261e2SCy Schubert 7554*b50261e2SCy Schubert # Extract subdirectory from the argument. 7555*b50261e2SCy Schubert func_dirname "$arg" "/" "" 7556*b50261e2SCy Schubert xdir=$func_dirname_result 7557*b50261e2SCy Schubert 7558*b50261e2SCy Schubert test none = "$pic_object" || { 7559*b50261e2SCy Schubert # Prepend the subdirectory the object is found in. 7560*b50261e2SCy Schubert pic_object=$xdir$pic_object 7561*b50261e2SCy Schubert 7562*b50261e2SCy Schubert if test dlfiles = "$prev"; then 7563*b50261e2SCy Schubert if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7564*b50261e2SCy Schubert func_append dlfiles " $pic_object" 7565*b50261e2SCy Schubert prev= 7566*b50261e2SCy Schubert continue 7567*b50261e2SCy Schubert else 7568*b50261e2SCy Schubert # If libtool objects are unsupported, then we need to preload. 7569*b50261e2SCy Schubert prev=dlprefiles 7570*b50261e2SCy Schubert fi 7571*b50261e2SCy Schubert fi 7572*b50261e2SCy Schubert 7573*b50261e2SCy Schubert # CHECK ME: I think I busted this. -Ossama 7574*b50261e2SCy Schubert if test dlprefiles = "$prev"; then 7575*b50261e2SCy Schubert # Preload the old-style object. 7576*b50261e2SCy Schubert func_append dlprefiles " $pic_object" 7577*b50261e2SCy Schubert prev= 7578*b50261e2SCy Schubert fi 7579*b50261e2SCy Schubert 7580*b50261e2SCy Schubert # A PIC object. 7581*b50261e2SCy Schubert func_append libobjs " $pic_object" 7582*b50261e2SCy Schubert arg=$pic_object 7583*b50261e2SCy Schubert } 7584*b50261e2SCy Schubert 7585*b50261e2SCy Schubert # Non-PIC object. 7586*b50261e2SCy Schubert if test none != "$non_pic_object"; then 7587*b50261e2SCy Schubert # Prepend the subdirectory the object is found in. 7588*b50261e2SCy Schubert non_pic_object=$xdir$non_pic_object 7589*b50261e2SCy Schubert 7590*b50261e2SCy Schubert # A standard non-PIC object 7591*b50261e2SCy Schubert func_append non_pic_objects " $non_pic_object" 7592*b50261e2SCy Schubert if test -z "$pic_object" || test none = "$pic_object"; then 7593*b50261e2SCy Schubert arg=$non_pic_object 7594*b50261e2SCy Schubert fi 7595*b50261e2SCy Schubert else 7596*b50261e2SCy Schubert # If the PIC object exists, use it instead. 7597*b50261e2SCy Schubert # $xdir was prepended to $pic_object above. 7598*b50261e2SCy Schubert non_pic_object=$pic_object 7599*b50261e2SCy Schubert func_append non_pic_objects " $non_pic_object" 7600*b50261e2SCy Schubert fi 7601*b50261e2SCy Schubert else 7602*b50261e2SCy Schubert # Only an error if not doing a dry-run. 7603*b50261e2SCy Schubert if $opt_dry_run; then 7604*b50261e2SCy Schubert # Extract subdirectory from the argument. 7605*b50261e2SCy Schubert func_dirname "$arg" "/" "" 7606*b50261e2SCy Schubert xdir=$func_dirname_result 7607*b50261e2SCy Schubert 7608*b50261e2SCy Schubert func_lo2o "$arg" 7609*b50261e2SCy Schubert pic_object=$xdir$objdir/$func_lo2o_result 7610*b50261e2SCy Schubert non_pic_object=$xdir$func_lo2o_result 7611*b50261e2SCy Schubert func_append libobjs " $pic_object" 7612*b50261e2SCy Schubert func_append non_pic_objects " $non_pic_object" 7613*b50261e2SCy Schubert else 7614*b50261e2SCy Schubert func_fatal_error "'$arg' is not a valid libtool object" 7615*b50261e2SCy Schubert fi 7616*b50261e2SCy Schubert fi 7617*b50261e2SCy Schubert ;; 7618*b50261e2SCy Schubert 7619*b50261e2SCy Schubert *.$libext) 7620*b50261e2SCy Schubert # An archive. 7621*b50261e2SCy Schubert func_append deplibs " $arg" 7622*b50261e2SCy Schubert func_append old_deplibs " $arg" 7623*b50261e2SCy Schubert continue 7624*b50261e2SCy Schubert ;; 7625*b50261e2SCy Schubert 7626*b50261e2SCy Schubert *.la) 7627*b50261e2SCy Schubert # A libtool-controlled library. 7628*b50261e2SCy Schubert 7629*b50261e2SCy Schubert func_resolve_sysroot "$arg" 7630*b50261e2SCy Schubert if test dlfiles = "$prev"; then 7631*b50261e2SCy Schubert # This library was specified with -dlopen. 7632*b50261e2SCy Schubert func_append dlfiles " $func_resolve_sysroot_result" 7633*b50261e2SCy Schubert prev= 7634*b50261e2SCy Schubert elif test dlprefiles = "$prev"; then 7635*b50261e2SCy Schubert # The library was specified with -dlpreopen. 7636*b50261e2SCy Schubert func_append dlprefiles " $func_resolve_sysroot_result" 7637*b50261e2SCy Schubert prev= 7638*b50261e2SCy Schubert else 7639*b50261e2SCy Schubert func_append deplibs " $func_resolve_sysroot_result" 7640*b50261e2SCy Schubert fi 7641*b50261e2SCy Schubert continue 7642*b50261e2SCy Schubert ;; 7643*b50261e2SCy Schubert 7644*b50261e2SCy Schubert # Some other compiler argument. 7645*b50261e2SCy Schubert *) 7646*b50261e2SCy Schubert # Unknown arguments in both finalize_command and compile_command need 7647*b50261e2SCy Schubert # to be aesthetically quoted because they are evaled later. 7648*b50261e2SCy Schubert func_quote_arg pretty "$arg" 7649*b50261e2SCy Schubert arg=$func_quote_arg_result 7650*b50261e2SCy Schubert ;; 7651*b50261e2SCy Schubert esac # arg 7652*b50261e2SCy Schubert 7653*b50261e2SCy Schubert # Now actually substitute the argument into the commands. 7654*b50261e2SCy Schubert if test -n "$arg"; then 7655*b50261e2SCy Schubert func_append compile_command " $arg" 7656*b50261e2SCy Schubert func_append finalize_command " $arg" 7657*b50261e2SCy Schubert fi 7658*b50261e2SCy Schubert done # argument parsing loop 7659*b50261e2SCy Schubert 7660*b50261e2SCy Schubert test -n "$prev" && \ 7661*b50261e2SCy Schubert func_fatal_help "the '$prevarg' option requires an argument" 7662*b50261e2SCy Schubert 7663*b50261e2SCy Schubert if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7664*b50261e2SCy Schubert eval arg=\"$export_dynamic_flag_spec\" 7665*b50261e2SCy Schubert func_append compile_command " $arg" 7666*b50261e2SCy Schubert func_append finalize_command " $arg" 7667*b50261e2SCy Schubert fi 7668*b50261e2SCy Schubert 7669*b50261e2SCy Schubert oldlibs= 7670*b50261e2SCy Schubert # calculate the name of the file, without its directory 7671*b50261e2SCy Schubert func_basename "$output" 7672*b50261e2SCy Schubert outputname=$func_basename_result 7673*b50261e2SCy Schubert libobjs_save=$libobjs 7674*b50261e2SCy Schubert 7675*b50261e2SCy Schubert if test -n "$shlibpath_var"; then 7676*b50261e2SCy Schubert # get the directories listed in $shlibpath_var 7677*b50261e2SCy Schubert eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7678*b50261e2SCy Schubert else 7679*b50261e2SCy Schubert shlib_search_path= 7680*b50261e2SCy Schubert fi 7681*b50261e2SCy Schubert eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7682*b50261e2SCy Schubert eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7683*b50261e2SCy Schubert 7684*b50261e2SCy Schubert # Definition is injected by LT_CONFIG during libtool generation. 7685*b50261e2SCy Schubert func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7686*b50261e2SCy Schubert 7687*b50261e2SCy Schubert func_dirname "$output" "/" "" 7688*b50261e2SCy Schubert output_objdir=$func_dirname_result$objdir 7689*b50261e2SCy Schubert func_to_tool_file "$output_objdir/" 7690*b50261e2SCy Schubert tool_output_objdir=$func_to_tool_file_result 7691*b50261e2SCy Schubert # Create the object directory. 7692*b50261e2SCy Schubert func_mkdir_p "$output_objdir" 7693*b50261e2SCy Schubert 7694*b50261e2SCy Schubert # Determine the type of output 7695*b50261e2SCy Schubert case $output in 7696*b50261e2SCy Schubert "") 7697*b50261e2SCy Schubert func_fatal_help "you must specify an output file" 7698*b50261e2SCy Schubert ;; 7699*b50261e2SCy Schubert *.$libext) linkmode=oldlib ;; 7700*b50261e2SCy Schubert *.lo | *.$objext) linkmode=obj ;; 7701*b50261e2SCy Schubert *.la) linkmode=lib ;; 7702*b50261e2SCy Schubert *) linkmode=prog ;; # Anything else should be a program. 7703*b50261e2SCy Schubert esac 7704*b50261e2SCy Schubert 7705*b50261e2SCy Schubert specialdeplibs= 7706*b50261e2SCy Schubert 7707*b50261e2SCy Schubert libs= 7708*b50261e2SCy Schubert # Find all interdependent deplibs by searching for libraries 7709*b50261e2SCy Schubert # that are linked more than once (e.g. -la -lb -la) 7710*b50261e2SCy Schubert for deplib in $deplibs; do 7711*b50261e2SCy Schubert if $opt_preserve_dup_deps; then 7712*b50261e2SCy Schubert case "$libs " in 7713*b50261e2SCy Schubert *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7714*b50261e2SCy Schubert esac 7715*b50261e2SCy Schubert fi 7716*b50261e2SCy Schubert func_append libs " $deplib" 7717*b50261e2SCy Schubert done 7718*b50261e2SCy Schubert 7719*b50261e2SCy Schubert if test lib = "$linkmode"; then 7720*b50261e2SCy Schubert libs="$predeps $libs $compiler_lib_search_path $postdeps" 7721*b50261e2SCy Schubert 7722*b50261e2SCy Schubert # Compute libraries that are listed more than once in $predeps 7723*b50261e2SCy Schubert # $postdeps and mark them as special (i.e., whose duplicates are 7724*b50261e2SCy Schubert # not to be eliminated). 7725*b50261e2SCy Schubert pre_post_deps= 7726*b50261e2SCy Schubert if $opt_duplicate_compiler_generated_deps; then 7727*b50261e2SCy Schubert for pre_post_dep in $predeps $postdeps; do 7728*b50261e2SCy Schubert case "$pre_post_deps " in 7729*b50261e2SCy Schubert *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7730*b50261e2SCy Schubert esac 7731*b50261e2SCy Schubert func_append pre_post_deps " $pre_post_dep" 7732*b50261e2SCy Schubert done 7733*b50261e2SCy Schubert fi 7734*b50261e2SCy Schubert pre_post_deps= 7735*b50261e2SCy Schubert fi 7736*b50261e2SCy Schubert 7737*b50261e2SCy Schubert deplibs= 7738*b50261e2SCy Schubert newdependency_libs= 7739*b50261e2SCy Schubert newlib_search_path= 7740*b50261e2SCy Schubert need_relink=no # whether we're linking any uninstalled libtool libraries 7741*b50261e2SCy Schubert notinst_deplibs= # not-installed libtool libraries 7742*b50261e2SCy Schubert notinst_path= # paths that contain not-installed libtool libraries 7743*b50261e2SCy Schubert 7744*b50261e2SCy Schubert case $linkmode in 7745*b50261e2SCy Schubert lib) 7746*b50261e2SCy Schubert passes="conv dlpreopen link" 7747*b50261e2SCy Schubert for file in $dlfiles $dlprefiles; do 7748*b50261e2SCy Schubert case $file in 7749*b50261e2SCy Schubert *.la) ;; 7750*b50261e2SCy Schubert *) 7751*b50261e2SCy Schubert func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7752*b50261e2SCy Schubert ;; 7753*b50261e2SCy Schubert esac 7754*b50261e2SCy Schubert done 7755*b50261e2SCy Schubert ;; 7756*b50261e2SCy Schubert prog) 7757*b50261e2SCy Schubert compile_deplibs= 7758*b50261e2SCy Schubert finalize_deplibs= 7759*b50261e2SCy Schubert alldeplibs=false 7760*b50261e2SCy Schubert newdlfiles= 7761*b50261e2SCy Schubert newdlprefiles= 7762*b50261e2SCy Schubert passes="conv scan dlopen dlpreopen link" 7763*b50261e2SCy Schubert ;; 7764*b50261e2SCy Schubert *) passes="conv" 7765*b50261e2SCy Schubert ;; 7766*b50261e2SCy Schubert esac 7767*b50261e2SCy Schubert 7768*b50261e2SCy Schubert for pass in $passes; do 7769*b50261e2SCy Schubert # The preopen pass in lib mode reverses $deplibs; put it back here 7770*b50261e2SCy Schubert # so that -L comes before libs that need it for instance... 7771*b50261e2SCy Schubert if test lib,link = "$linkmode,$pass"; then 7772*b50261e2SCy Schubert ## FIXME: Find the place where the list is rebuilt in the wrong 7773*b50261e2SCy Schubert ## order, and fix it there properly 7774*b50261e2SCy Schubert tmp_deplibs= 7775*b50261e2SCy Schubert for deplib in $deplibs; do 7776*b50261e2SCy Schubert tmp_deplibs="$deplib $tmp_deplibs" 7777*b50261e2SCy Schubert done 7778*b50261e2SCy Schubert deplibs=$tmp_deplibs 7779*b50261e2SCy Schubert fi 7780*b50261e2SCy Schubert 7781*b50261e2SCy Schubert if test lib,link = "$linkmode,$pass" || 7782*b50261e2SCy Schubert test prog,scan = "$linkmode,$pass"; then 7783*b50261e2SCy Schubert libs=$deplibs 7784*b50261e2SCy Schubert deplibs= 7785*b50261e2SCy Schubert fi 7786*b50261e2SCy Schubert if test prog = "$linkmode"; then 7787*b50261e2SCy Schubert case $pass in 7788*b50261e2SCy Schubert dlopen) libs=$dlfiles ;; 7789*b50261e2SCy Schubert dlpreopen) libs=$dlprefiles ;; 7790*b50261e2SCy Schubert link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7791*b50261e2SCy Schubert esac 7792*b50261e2SCy Schubert fi 7793*b50261e2SCy Schubert if test lib,dlpreopen = "$linkmode,$pass"; then 7794*b50261e2SCy Schubert # Collect and forward deplibs of preopened libtool libs 7795*b50261e2SCy Schubert for lib in $dlprefiles; do 7796*b50261e2SCy Schubert # Ignore non-libtool-libs 7797*b50261e2SCy Schubert dependency_libs= 7798*b50261e2SCy Schubert func_resolve_sysroot "$lib" 7799*b50261e2SCy Schubert case $lib in 7800*b50261e2SCy Schubert *.la) func_source "$func_resolve_sysroot_result" ;; 7801*b50261e2SCy Schubert esac 7802*b50261e2SCy Schubert 7803*b50261e2SCy Schubert # Collect preopened libtool deplibs, except any this library 7804*b50261e2SCy Schubert # has declared as weak libs 7805*b50261e2SCy Schubert for deplib in $dependency_libs; do 7806*b50261e2SCy Schubert func_basename "$deplib" 7807*b50261e2SCy Schubert deplib_base=$func_basename_result 7808*b50261e2SCy Schubert case " $weak_libs " in 7809*b50261e2SCy Schubert *" $deplib_base "*) ;; 7810*b50261e2SCy Schubert *) func_append deplibs " $deplib" ;; 7811*b50261e2SCy Schubert esac 7812*b50261e2SCy Schubert done 7813*b50261e2SCy Schubert done 7814*b50261e2SCy Schubert libs=$dlprefiles 7815*b50261e2SCy Schubert fi 7816*b50261e2SCy Schubert if test dlopen = "$pass"; then 7817*b50261e2SCy Schubert # Collect dlpreopened libraries 7818*b50261e2SCy Schubert save_deplibs=$deplibs 7819*b50261e2SCy Schubert deplibs= 7820*b50261e2SCy Schubert fi 7821*b50261e2SCy Schubert 7822*b50261e2SCy Schubert for deplib in $libs; do 7823*b50261e2SCy Schubert lib= 7824*b50261e2SCy Schubert found=false 7825*b50261e2SCy Schubert case $deplib in 7826*b50261e2SCy Schubert -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7827*b50261e2SCy Schubert |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7828*b50261e2SCy Schubert if test prog,link = "$linkmode,$pass"; then 7829*b50261e2SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7830*b50261e2SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7831*b50261e2SCy Schubert else 7832*b50261e2SCy Schubert func_append compiler_flags " $deplib" 7833*b50261e2SCy Schubert if test lib = "$linkmode"; then 7834*b50261e2SCy Schubert case "$new_inherited_linker_flags " in 7835*b50261e2SCy Schubert *" $deplib "*) ;; 7836*b50261e2SCy Schubert * ) func_append new_inherited_linker_flags " $deplib" ;; 7837*b50261e2SCy Schubert esac 7838*b50261e2SCy Schubert fi 7839*b50261e2SCy Schubert fi 7840*b50261e2SCy Schubert continue 7841*b50261e2SCy Schubert ;; 7842*b50261e2SCy Schubert -l*) 7843*b50261e2SCy Schubert if test lib != "$linkmode" && test prog != "$linkmode"; then 7844*b50261e2SCy Schubert func_warning "'-l' is ignored for archives/objects" 7845*b50261e2SCy Schubert continue 7846*b50261e2SCy Schubert fi 7847*b50261e2SCy Schubert func_stripname '-l' '' "$deplib" 7848*b50261e2SCy Schubert name=$func_stripname_result 7849*b50261e2SCy Schubert if test lib = "$linkmode"; then 7850*b50261e2SCy Schubert searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7851*b50261e2SCy Schubert else 7852*b50261e2SCy Schubert searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7853*b50261e2SCy Schubert fi 7854*b50261e2SCy Schubert for searchdir in $searchdirs; do 7855*b50261e2SCy Schubert for search_ext in .la $std_shrext .so .a; do 7856*b50261e2SCy Schubert # Search the libtool library 7857*b50261e2SCy Schubert lib=$searchdir/lib$name$search_ext 7858*b50261e2SCy Schubert if test -f "$lib"; then 7859*b50261e2SCy Schubert if test .la = "$search_ext"; then 7860*b50261e2SCy Schubert found=: 7861*b50261e2SCy Schubert else 7862*b50261e2SCy Schubert found=false 7863*b50261e2SCy Schubert fi 7864*b50261e2SCy Schubert break 2 7865*b50261e2SCy Schubert fi 7866*b50261e2SCy Schubert done 7867*b50261e2SCy Schubert done 7868*b50261e2SCy Schubert if $found; then 7869*b50261e2SCy Schubert # deplib is a libtool library 7870*b50261e2SCy Schubert # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7871*b50261e2SCy Schubert # We need to do some special things here, and not later. 7872*b50261e2SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7873*b50261e2SCy Schubert case " $predeps $postdeps " in 7874*b50261e2SCy Schubert *" $deplib "*) 7875*b50261e2SCy Schubert if func_lalib_p "$lib"; then 7876*b50261e2SCy Schubert library_names= 7877*b50261e2SCy Schubert old_library= 7878*b50261e2SCy Schubert func_source "$lib" 7879*b50261e2SCy Schubert for l in $old_library $library_names; do 7880*b50261e2SCy Schubert ll=$l 7881*b50261e2SCy Schubert done 7882*b50261e2SCy Schubert if test "X$ll" = "X$old_library"; then # only static version available 7883*b50261e2SCy Schubert found=false 7884*b50261e2SCy Schubert func_dirname "$lib" "" "." 7885*b50261e2SCy Schubert ladir=$func_dirname_result 7886*b50261e2SCy Schubert lib=$ladir/$old_library 7887*b50261e2SCy Schubert if test prog,link = "$linkmode,$pass"; then 7888*b50261e2SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7889*b50261e2SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7890*b50261e2SCy Schubert else 7891*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7892*b50261e2SCy Schubert test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7893*b50261e2SCy Schubert fi 7894*b50261e2SCy Schubert continue 7895*b50261e2SCy Schubert fi 7896*b50261e2SCy Schubert fi 7897*b50261e2SCy Schubert ;; 7898*b50261e2SCy Schubert *) ;; 7899*b50261e2SCy Schubert esac 7900*b50261e2SCy Schubert fi 7901*b50261e2SCy Schubert else 7902*b50261e2SCy Schubert # deplib doesn't seem to be a libtool library 7903*b50261e2SCy Schubert if test prog,link = "$linkmode,$pass"; then 7904*b50261e2SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7905*b50261e2SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7906*b50261e2SCy Schubert else 7907*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7908*b50261e2SCy Schubert test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7909*b50261e2SCy Schubert fi 7910*b50261e2SCy Schubert continue 7911*b50261e2SCy Schubert fi 7912*b50261e2SCy Schubert ;; # -l 7913*b50261e2SCy Schubert *.ltframework) 7914*b50261e2SCy Schubert if test prog,link = "$linkmode,$pass"; then 7915*b50261e2SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7916*b50261e2SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7917*b50261e2SCy Schubert else 7918*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7919*b50261e2SCy Schubert if test lib = "$linkmode"; then 7920*b50261e2SCy Schubert case "$new_inherited_linker_flags " in 7921*b50261e2SCy Schubert *" $deplib "*) ;; 7922*b50261e2SCy Schubert * ) func_append new_inherited_linker_flags " $deplib" ;; 7923*b50261e2SCy Schubert esac 7924*b50261e2SCy Schubert fi 7925*b50261e2SCy Schubert fi 7926*b50261e2SCy Schubert continue 7927*b50261e2SCy Schubert ;; 7928*b50261e2SCy Schubert -L*) 7929*b50261e2SCy Schubert case $linkmode in 7930*b50261e2SCy Schubert lib) 7931*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7932*b50261e2SCy Schubert test conv = "$pass" && continue 7933*b50261e2SCy Schubert newdependency_libs="$deplib $newdependency_libs" 7934*b50261e2SCy Schubert func_stripname '-L' '' "$deplib" 7935*b50261e2SCy Schubert func_resolve_sysroot "$func_stripname_result" 7936*b50261e2SCy Schubert func_append newlib_search_path " $func_resolve_sysroot_result" 7937*b50261e2SCy Schubert ;; 7938*b50261e2SCy Schubert prog) 7939*b50261e2SCy Schubert if test conv = "$pass"; then 7940*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7941*b50261e2SCy Schubert continue 7942*b50261e2SCy Schubert fi 7943*b50261e2SCy Schubert if test scan = "$pass"; then 7944*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7945*b50261e2SCy Schubert else 7946*b50261e2SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7947*b50261e2SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7948*b50261e2SCy Schubert fi 7949*b50261e2SCy Schubert func_stripname '-L' '' "$deplib" 7950*b50261e2SCy Schubert func_resolve_sysroot "$func_stripname_result" 7951*b50261e2SCy Schubert func_append newlib_search_path " $func_resolve_sysroot_result" 7952*b50261e2SCy Schubert ;; 7953*b50261e2SCy Schubert *) 7954*b50261e2SCy Schubert func_warning "'-L' is ignored for archives/objects" 7955*b50261e2SCy Schubert ;; 7956*b50261e2SCy Schubert esac # linkmode 7957*b50261e2SCy Schubert continue 7958*b50261e2SCy Schubert ;; # -L 7959*b50261e2SCy Schubert -R*) 7960*b50261e2SCy Schubert if test link = "$pass"; then 7961*b50261e2SCy Schubert func_stripname '-R' '' "$deplib" 7962*b50261e2SCy Schubert func_resolve_sysroot "$func_stripname_result" 7963*b50261e2SCy Schubert dir=$func_resolve_sysroot_result 7964*b50261e2SCy Schubert # Make sure the xrpath contains only unique directories. 7965*b50261e2SCy Schubert case "$xrpath " in 7966*b50261e2SCy Schubert *" $dir "*) ;; 7967*b50261e2SCy Schubert *) func_append xrpath " $dir" ;; 7968*b50261e2SCy Schubert esac 7969*b50261e2SCy Schubert fi 7970*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7971*b50261e2SCy Schubert continue 7972*b50261e2SCy Schubert ;; 7973*b50261e2SCy Schubert *.la) 7974*b50261e2SCy Schubert func_resolve_sysroot "$deplib" 7975*b50261e2SCy Schubert lib=$func_resolve_sysroot_result 7976*b50261e2SCy Schubert ;; 7977*b50261e2SCy Schubert *.$libext) 7978*b50261e2SCy Schubert if test conv = "$pass"; then 7979*b50261e2SCy Schubert deplibs="$deplib $deplibs" 7980*b50261e2SCy Schubert continue 7981*b50261e2SCy Schubert fi 7982*b50261e2SCy Schubert case $linkmode in 7983*b50261e2SCy Schubert lib) 7984*b50261e2SCy Schubert # Linking convenience modules into shared libraries is allowed, 7985*b50261e2SCy Schubert # but linking other static libraries is non-portable. 7986*b50261e2SCy Schubert case " $dlpreconveniencelibs " in 7987*b50261e2SCy Schubert *" $deplib "*) ;; 7988*b50261e2SCy Schubert *) 7989*b50261e2SCy Schubert valid_a_lib=false 7990*b50261e2SCy Schubert case $deplibs_check_method in 7991*b50261e2SCy Schubert match_pattern*) 7992*b50261e2SCy Schubert set dummy $deplibs_check_method; shift 7993*b50261e2SCy Schubert match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7994*b50261e2SCy Schubert if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7995*b50261e2SCy Schubert | $EGREP "$match_pattern_regex" > /dev/null; then 7996*b50261e2SCy Schubert valid_a_lib=: 7997*b50261e2SCy Schubert fi 7998*b50261e2SCy Schubert ;; 7999*b50261e2SCy Schubert pass_all) 8000*b50261e2SCy Schubert valid_a_lib=: 8001*b50261e2SCy Schubert ;; 8002*b50261e2SCy Schubert esac 8003*b50261e2SCy Schubert if $valid_a_lib; then 8004*b50261e2SCy Schubert echo 8005*b50261e2SCy Schubert $ECHO "*** Warning: Linking the shared library $output against the" 8006*b50261e2SCy Schubert $ECHO "*** static library $deplib is not portable!" 8007*b50261e2SCy Schubert deplibs="$deplib $deplibs" 8008*b50261e2SCy Schubert else 8009*b50261e2SCy Schubert echo 8010*b50261e2SCy Schubert $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8011*b50261e2SCy Schubert echo "*** I have the capability to make that library automatically link in when" 8012*b50261e2SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 8013*b50261e2SCy Schubert echo "*** shared version of the library, which you do not appear to have" 8014*b50261e2SCy Schubert echo "*** because the file extensions .$libext of this argument makes me believe" 8015*b50261e2SCy Schubert echo "*** that it is just a static archive that I should not use here." 8016*b50261e2SCy Schubert fi 8017*b50261e2SCy Schubert ;; 8018*b50261e2SCy Schubert esac 8019*b50261e2SCy Schubert continue 8020*b50261e2SCy Schubert ;; 8021*b50261e2SCy Schubert prog) 8022*b50261e2SCy Schubert if test link != "$pass"; then 8023*b50261e2SCy Schubert deplibs="$deplib $deplibs" 8024*b50261e2SCy Schubert else 8025*b50261e2SCy Schubert compile_deplibs="$deplib $compile_deplibs" 8026*b50261e2SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 8027*b50261e2SCy Schubert fi 8028*b50261e2SCy Schubert continue 8029*b50261e2SCy Schubert ;; 8030*b50261e2SCy Schubert esac # linkmode 8031*b50261e2SCy Schubert ;; # *.$libext 8032*b50261e2SCy Schubert *.lo | *.$objext) 8033*b50261e2SCy Schubert if test conv = "$pass"; then 8034*b50261e2SCy Schubert deplibs="$deplib $deplibs" 8035*b50261e2SCy Schubert elif test prog = "$linkmode"; then 8036*b50261e2SCy Schubert if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8037*b50261e2SCy Schubert # If there is no dlopen support or we're linking statically, 8038*b50261e2SCy Schubert # we need to preload. 8039*b50261e2SCy Schubert func_append newdlprefiles " $deplib" 8040*b50261e2SCy Schubert compile_deplibs="$deplib $compile_deplibs" 8041*b50261e2SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 8042*b50261e2SCy Schubert else 8043*b50261e2SCy Schubert func_append newdlfiles " $deplib" 8044*b50261e2SCy Schubert fi 8045*b50261e2SCy Schubert fi 8046*b50261e2SCy Schubert continue 8047*b50261e2SCy Schubert ;; 8048*b50261e2SCy Schubert %DEPLIBS%) 8049*b50261e2SCy Schubert alldeplibs=: 8050*b50261e2SCy Schubert continue 8051*b50261e2SCy Schubert ;; 8052*b50261e2SCy Schubert esac # case $deplib 8053*b50261e2SCy Schubert 8054*b50261e2SCy Schubert $found || test -f "$lib" \ 8055*b50261e2SCy Schubert || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8056*b50261e2SCy Schubert 8057*b50261e2SCy Schubert # Check to see that this really is a libtool archive. 8058*b50261e2SCy Schubert func_lalib_unsafe_p "$lib" \ 8059*b50261e2SCy Schubert || func_fatal_error "'$lib' is not a valid libtool archive" 8060*b50261e2SCy Schubert 8061*b50261e2SCy Schubert func_dirname "$lib" "" "." 8062*b50261e2SCy Schubert ladir=$func_dirname_result 8063*b50261e2SCy Schubert 8064*b50261e2SCy Schubert dlname= 8065*b50261e2SCy Schubert dlopen= 8066*b50261e2SCy Schubert dlpreopen= 8067*b50261e2SCy Schubert libdir= 8068*b50261e2SCy Schubert library_names= 8069*b50261e2SCy Schubert old_library= 8070*b50261e2SCy Schubert inherited_linker_flags= 8071*b50261e2SCy Schubert # If the library was installed with an old release of libtool, 8072*b50261e2SCy Schubert # it will not redefine variables installed, or shouldnotlink 8073*b50261e2SCy Schubert installed=yes 8074*b50261e2SCy Schubert shouldnotlink=no 8075*b50261e2SCy Schubert avoidtemprpath= 8076*b50261e2SCy Schubert 8077*b50261e2SCy Schubert 8078*b50261e2SCy Schubert # Read the .la file 8079*b50261e2SCy Schubert func_source "$lib" 8080*b50261e2SCy Schubert 8081*b50261e2SCy Schubert # Convert "-framework foo" to "foo.ltframework" 8082*b50261e2SCy Schubert if test -n "$inherited_linker_flags"; then 8083*b50261e2SCy Schubert tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8084*b50261e2SCy Schubert for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8085*b50261e2SCy Schubert case " $new_inherited_linker_flags " in 8086*b50261e2SCy Schubert *" $tmp_inherited_linker_flag "*) ;; 8087*b50261e2SCy Schubert *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8088*b50261e2SCy Schubert esac 8089*b50261e2SCy Schubert done 8090*b50261e2SCy Schubert fi 8091*b50261e2SCy Schubert dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8092*b50261e2SCy Schubert if test lib,link = "$linkmode,$pass" || 8093*b50261e2SCy Schubert test prog,scan = "$linkmode,$pass" || 8094*b50261e2SCy Schubert { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8095*b50261e2SCy Schubert test -n "$dlopen" && func_append dlfiles " $dlopen" 8096*b50261e2SCy Schubert test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8097*b50261e2SCy Schubert fi 8098*b50261e2SCy Schubert 8099*b50261e2SCy Schubert if test conv = "$pass"; then 8100*b50261e2SCy Schubert # Only check for convenience libraries 8101*b50261e2SCy Schubert deplibs="$lib $deplibs" 8102*b50261e2SCy Schubert if test -z "$libdir"; then 8103*b50261e2SCy Schubert if test -z "$old_library"; then 8104*b50261e2SCy Schubert func_fatal_error "cannot find name of link library for '$lib'" 8105*b50261e2SCy Schubert fi 8106*b50261e2SCy Schubert # It is a libtool convenience library, so add in its objects. 8107*b50261e2SCy Schubert func_append convenience " $ladir/$objdir/$old_library" 8108*b50261e2SCy Schubert func_append old_convenience " $ladir/$objdir/$old_library" 8109*b50261e2SCy Schubert elif test prog != "$linkmode" && test lib != "$linkmode"; then 8110*b50261e2SCy Schubert func_fatal_error "'$lib' is not a convenience library" 8111*b50261e2SCy Schubert fi 8112*b50261e2SCy Schubert tmp_libs= 8113*b50261e2SCy Schubert for deplib in $dependency_libs; do 8114*b50261e2SCy Schubert deplibs="$deplib $deplibs" 8115*b50261e2SCy Schubert if $opt_preserve_dup_deps; then 8116*b50261e2SCy Schubert case "$tmp_libs " in 8117*b50261e2SCy Schubert *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8118*b50261e2SCy Schubert esac 8119*b50261e2SCy Schubert fi 8120*b50261e2SCy Schubert func_append tmp_libs " $deplib" 8121*b50261e2SCy Schubert done 8122*b50261e2SCy Schubert continue 8123*b50261e2SCy Schubert fi # $pass = conv 8124*b50261e2SCy Schubert 8125*b50261e2SCy Schubert 8126*b50261e2SCy Schubert # Get the name of the library we link against. 8127*b50261e2SCy Schubert linklib= 8128*b50261e2SCy Schubert if test -n "$old_library" && 8129*b50261e2SCy Schubert { test yes = "$prefer_static_libs" || 8130*b50261e2SCy Schubert test built,no = "$prefer_static_libs,$installed"; }; then 8131*b50261e2SCy Schubert linklib=$old_library 8132*b50261e2SCy Schubert else 8133*b50261e2SCy Schubert for l in $old_library $library_names; do 8134*b50261e2SCy Schubert linklib=$l 8135*b50261e2SCy Schubert done 8136*b50261e2SCy Schubert fi 8137*b50261e2SCy Schubert if test -z "$linklib"; then 8138*b50261e2SCy Schubert func_fatal_error "cannot find name of link library for '$lib'" 8139*b50261e2SCy Schubert fi 8140*b50261e2SCy Schubert 8141*b50261e2SCy Schubert # This library was specified with -dlopen. 8142*b50261e2SCy Schubert if test dlopen = "$pass"; then 8143*b50261e2SCy Schubert test -z "$libdir" \ 8144*b50261e2SCy Schubert && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8145*b50261e2SCy Schubert if test -z "$dlname" || 8146*b50261e2SCy Schubert test yes != "$dlopen_support" || 8147*b50261e2SCy Schubert test no = "$build_libtool_libs" 8148*b50261e2SCy Schubert then 8149*b50261e2SCy Schubert # If there is no dlname, no dlopen support or we're linking 8150*b50261e2SCy Schubert # statically, we need to preload. We also need to preload any 8151*b50261e2SCy Schubert # dependent libraries so libltdl's deplib preloader doesn't 8152*b50261e2SCy Schubert # bomb out in the load deplibs phase. 8153*b50261e2SCy Schubert func_append dlprefiles " $lib $dependency_libs" 8154*b50261e2SCy Schubert else 8155*b50261e2SCy Schubert func_append newdlfiles " $lib" 8156*b50261e2SCy Schubert fi 8157*b50261e2SCy Schubert continue 8158*b50261e2SCy Schubert fi # $pass = dlopen 8159*b50261e2SCy Schubert 8160*b50261e2SCy Schubert # We need an absolute path. 8161*b50261e2SCy Schubert case $ladir in 8162*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8163*b50261e2SCy Schubert *) 8164*b50261e2SCy Schubert abs_ladir=`cd "$ladir" && pwd` 8165*b50261e2SCy Schubert if test -z "$abs_ladir"; then 8166*b50261e2SCy Schubert func_warning "cannot determine absolute directory name of '$ladir'" 8167*b50261e2SCy Schubert func_warning "passing it literally to the linker, although it might fail" 8168*b50261e2SCy Schubert abs_ladir=$ladir 8169*b50261e2SCy Schubert fi 8170*b50261e2SCy Schubert ;; 8171*b50261e2SCy Schubert esac 8172*b50261e2SCy Schubert func_basename "$lib" 8173*b50261e2SCy Schubert laname=$func_basename_result 8174*b50261e2SCy Schubert 8175*b50261e2SCy Schubert # Find the relevant object directory and library name. 8176*b50261e2SCy Schubert if test yes = "$installed"; then 8177*b50261e2SCy Schubert if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8178*b50261e2SCy Schubert func_warning "library '$lib' was moved." 8179*b50261e2SCy Schubert dir=$ladir 8180*b50261e2SCy Schubert absdir=$abs_ladir 8181*b50261e2SCy Schubert libdir=$abs_ladir 8182*b50261e2SCy Schubert else 8183*b50261e2SCy Schubert dir=$lt_sysroot$libdir 8184*b50261e2SCy Schubert absdir=$lt_sysroot$libdir 8185*b50261e2SCy Schubert fi 8186*b50261e2SCy Schubert test yes = "$hardcode_automatic" && avoidtemprpath=yes 8187*b50261e2SCy Schubert else 8188*b50261e2SCy Schubert if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8189*b50261e2SCy Schubert dir=$ladir 8190*b50261e2SCy Schubert absdir=$abs_ladir 8191*b50261e2SCy Schubert # Remove this search path later 8192*b50261e2SCy Schubert func_append notinst_path " $abs_ladir" 8193*b50261e2SCy Schubert else 8194*b50261e2SCy Schubert dir=$ladir/$objdir 8195*b50261e2SCy Schubert absdir=$abs_ladir/$objdir 8196*b50261e2SCy Schubert # Remove this search path later 8197*b50261e2SCy Schubert func_append notinst_path " $abs_ladir" 8198*b50261e2SCy Schubert fi 8199*b50261e2SCy Schubert fi # $installed = yes 8200*b50261e2SCy Schubert func_stripname 'lib' '.la' "$laname" 8201*b50261e2SCy Schubert name=$func_stripname_result 8202*b50261e2SCy Schubert 8203*b50261e2SCy Schubert # This library was specified with -dlpreopen. 8204*b50261e2SCy Schubert if test dlpreopen = "$pass"; then 8205*b50261e2SCy Schubert if test -z "$libdir" && test prog = "$linkmode"; then 8206*b50261e2SCy Schubert func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8207*b50261e2SCy Schubert fi 8208*b50261e2SCy Schubert case $host in 8209*b50261e2SCy Schubert # special handling for platforms with PE-DLLs. 8210*b50261e2SCy Schubert *cygwin* | *mingw* | *cegcc* ) 8211*b50261e2SCy Schubert # Linker will automatically link against shared library if both 8212*b50261e2SCy Schubert # static and shared are present. Therefore, ensure we extract 8213*b50261e2SCy Schubert # symbols from the import library if a shared library is present 8214*b50261e2SCy Schubert # (otherwise, the dlopen module name will be incorrect). We do 8215*b50261e2SCy Schubert # this by putting the import library name into $newdlprefiles. 8216*b50261e2SCy Schubert # We recover the dlopen module name by 'saving' the la file 8217*b50261e2SCy Schubert # name in a special purpose variable, and (later) extracting the 8218*b50261e2SCy Schubert # dlname from the la file. 8219*b50261e2SCy Schubert if test -n "$dlname"; then 8220*b50261e2SCy Schubert func_tr_sh "$dir/$linklib" 8221*b50261e2SCy Schubert eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8222*b50261e2SCy Schubert func_append newdlprefiles " $dir/$linklib" 8223*b50261e2SCy Schubert else 8224*b50261e2SCy Schubert func_append newdlprefiles " $dir/$old_library" 8225*b50261e2SCy Schubert # Keep a list of preopened convenience libraries to check 8226*b50261e2SCy Schubert # that they are being used correctly in the link pass. 8227*b50261e2SCy Schubert test -z "$libdir" && \ 8228*b50261e2SCy Schubert func_append dlpreconveniencelibs " $dir/$old_library" 8229*b50261e2SCy Schubert fi 8230*b50261e2SCy Schubert ;; 8231*b50261e2SCy Schubert * ) 8232*b50261e2SCy Schubert # Prefer using a static library (so that no silly _DYNAMIC symbols 8233*b50261e2SCy Schubert # are required to link). 8234*b50261e2SCy Schubert if test -n "$old_library"; then 8235*b50261e2SCy Schubert func_append newdlprefiles " $dir/$old_library" 8236*b50261e2SCy Schubert # Keep a list of preopened convenience libraries to check 8237*b50261e2SCy Schubert # that they are being used correctly in the link pass. 8238*b50261e2SCy Schubert test -z "$libdir" && \ 8239*b50261e2SCy Schubert func_append dlpreconveniencelibs " $dir/$old_library" 8240*b50261e2SCy Schubert # Otherwise, use the dlname, so that lt_dlopen finds it. 8241*b50261e2SCy Schubert elif test -n "$dlname"; then 8242*b50261e2SCy Schubert func_append newdlprefiles " $dir/$dlname" 8243*b50261e2SCy Schubert else 8244*b50261e2SCy Schubert func_append newdlprefiles " $dir/$linklib" 8245*b50261e2SCy Schubert fi 8246*b50261e2SCy Schubert ;; 8247*b50261e2SCy Schubert esac 8248*b50261e2SCy Schubert fi # $pass = dlpreopen 8249*b50261e2SCy Schubert 8250*b50261e2SCy Schubert if test -z "$libdir"; then 8251*b50261e2SCy Schubert # Link the convenience library 8252*b50261e2SCy Schubert if test lib = "$linkmode"; then 8253*b50261e2SCy Schubert deplibs="$dir/$old_library $deplibs" 8254*b50261e2SCy Schubert elif test prog,link = "$linkmode,$pass"; then 8255*b50261e2SCy Schubert compile_deplibs="$dir/$old_library $compile_deplibs" 8256*b50261e2SCy Schubert finalize_deplibs="$dir/$old_library $finalize_deplibs" 8257*b50261e2SCy Schubert else 8258*b50261e2SCy Schubert deplibs="$lib $deplibs" # used for prog,scan pass 8259*b50261e2SCy Schubert fi 8260*b50261e2SCy Schubert continue 8261*b50261e2SCy Schubert fi 8262*b50261e2SCy Schubert 8263*b50261e2SCy Schubert 8264*b50261e2SCy Schubert if test prog = "$linkmode" && test link != "$pass"; then 8265*b50261e2SCy Schubert func_append newlib_search_path " $ladir" 8266*b50261e2SCy Schubert deplibs="$lib $deplibs" 8267*b50261e2SCy Schubert 8268*b50261e2SCy Schubert linkalldeplibs=false 8269*b50261e2SCy Schubert if test no != "$link_all_deplibs" || test -z "$library_names" || 8270*b50261e2SCy Schubert test no = "$build_libtool_libs"; then 8271*b50261e2SCy Schubert linkalldeplibs=: 8272*b50261e2SCy Schubert fi 8273*b50261e2SCy Schubert 8274*b50261e2SCy Schubert tmp_libs= 8275*b50261e2SCy Schubert for deplib in $dependency_libs; do 8276*b50261e2SCy Schubert case $deplib in 8277*b50261e2SCy Schubert -L*) func_stripname '-L' '' "$deplib" 8278*b50261e2SCy Schubert func_resolve_sysroot "$func_stripname_result" 8279*b50261e2SCy Schubert func_append newlib_search_path " $func_resolve_sysroot_result" 8280*b50261e2SCy Schubert ;; 8281*b50261e2SCy Schubert esac 8282*b50261e2SCy Schubert # Need to link against all dependency_libs? 8283*b50261e2SCy Schubert if $linkalldeplibs; then 8284*b50261e2SCy Schubert deplibs="$deplib $deplibs" 8285*b50261e2SCy Schubert else 8286*b50261e2SCy Schubert # Need to hardcode shared library paths 8287*b50261e2SCy Schubert # or/and link against static libraries 8288*b50261e2SCy Schubert newdependency_libs="$deplib $newdependency_libs" 8289*b50261e2SCy Schubert fi 8290*b50261e2SCy Schubert if $opt_preserve_dup_deps; then 8291*b50261e2SCy Schubert case "$tmp_libs " in 8292*b50261e2SCy Schubert *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8293*b50261e2SCy Schubert esac 8294*b50261e2SCy Schubert fi 8295*b50261e2SCy Schubert func_append tmp_libs " $deplib" 8296*b50261e2SCy Schubert done # for deplib 8297*b50261e2SCy Schubert continue 8298*b50261e2SCy Schubert fi # $linkmode = prog... 8299*b50261e2SCy Schubert 8300*b50261e2SCy Schubert if test prog,link = "$linkmode,$pass"; then 8301*b50261e2SCy Schubert if test -n "$library_names" && 8302*b50261e2SCy Schubert { { test no = "$prefer_static_libs" || 8303*b50261e2SCy Schubert test built,yes = "$prefer_static_libs,$installed"; } || 8304*b50261e2SCy Schubert test -z "$old_library"; }; then 8305*b50261e2SCy Schubert # We need to hardcode the library path 8306*b50261e2SCy Schubert if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8307*b50261e2SCy Schubert # Make sure the rpath contains only unique directories. 8308*b50261e2SCy Schubert case $temp_rpath: in 8309*b50261e2SCy Schubert *"$absdir:"*) ;; 8310*b50261e2SCy Schubert *) func_append temp_rpath "$absdir:" ;; 8311*b50261e2SCy Schubert esac 8312*b50261e2SCy Schubert fi 8313*b50261e2SCy Schubert 8314*b50261e2SCy Schubert # Hardcode the library path. 8315*b50261e2SCy Schubert # Skip directories that are in the system default run-time 8316*b50261e2SCy Schubert # search path. 8317*b50261e2SCy Schubert case " $sys_lib_dlsearch_path " in 8318*b50261e2SCy Schubert *" $absdir "*) ;; 8319*b50261e2SCy Schubert *) 8320*b50261e2SCy Schubert case "$compile_rpath " in 8321*b50261e2SCy Schubert *" $absdir "*) ;; 8322*b50261e2SCy Schubert *) func_append compile_rpath " $absdir" ;; 8323*b50261e2SCy Schubert esac 8324*b50261e2SCy Schubert ;; 8325*b50261e2SCy Schubert esac 8326*b50261e2SCy Schubert case " $sys_lib_dlsearch_path " in 8327*b50261e2SCy Schubert *" $libdir "*) ;; 8328*b50261e2SCy Schubert *) 8329*b50261e2SCy Schubert case "$finalize_rpath " in 8330*b50261e2SCy Schubert *" $libdir "*) ;; 8331*b50261e2SCy Schubert *) func_append finalize_rpath " $libdir" ;; 8332*b50261e2SCy Schubert esac 8333*b50261e2SCy Schubert ;; 8334*b50261e2SCy Schubert esac 8335*b50261e2SCy Schubert fi # $linkmode,$pass = prog,link... 8336*b50261e2SCy Schubert 8337*b50261e2SCy Schubert if $alldeplibs && 8338*b50261e2SCy Schubert { test pass_all = "$deplibs_check_method" || 8339*b50261e2SCy Schubert { test yes = "$build_libtool_libs" && 8340*b50261e2SCy Schubert test -n "$library_names"; }; }; then 8341*b50261e2SCy Schubert # We only need to search for static libraries 8342*b50261e2SCy Schubert continue 8343*b50261e2SCy Schubert fi 8344*b50261e2SCy Schubert fi 8345*b50261e2SCy Schubert 8346*b50261e2SCy Schubert link_static=no # Whether the deplib will be linked statically 8347*b50261e2SCy Schubert use_static_libs=$prefer_static_libs 8348*b50261e2SCy Schubert if test built = "$use_static_libs" && test yes = "$installed"; then 8349*b50261e2SCy Schubert use_static_libs=no 8350*b50261e2SCy Schubert fi 8351*b50261e2SCy Schubert if test -n "$library_names" && 8352*b50261e2SCy Schubert { test no = "$use_static_libs" || test -z "$old_library"; }; then 8353*b50261e2SCy Schubert case $host in 8354*b50261e2SCy Schubert *cygwin* | *mingw* | *cegcc* | *os2*) 8355*b50261e2SCy Schubert # No point in relinking DLLs because paths are not encoded 8356*b50261e2SCy Schubert func_append notinst_deplibs " $lib" 8357*b50261e2SCy Schubert need_relink=no 8358*b50261e2SCy Schubert ;; 8359*b50261e2SCy Schubert *) 8360*b50261e2SCy Schubert if test no = "$installed"; then 8361*b50261e2SCy Schubert func_append notinst_deplibs " $lib" 8362*b50261e2SCy Schubert need_relink=yes 8363*b50261e2SCy Schubert fi 8364*b50261e2SCy Schubert ;; 8365*b50261e2SCy Schubert esac 8366*b50261e2SCy Schubert # This is a shared library 8367*b50261e2SCy Schubert 8368*b50261e2SCy Schubert # Warn about portability, can't link against -module's on some 8369*b50261e2SCy Schubert # systems (darwin). Don't bleat about dlopened modules though! 8370*b50261e2SCy Schubert dlopenmodule= 8371*b50261e2SCy Schubert for dlpremoduletest in $dlprefiles; do 8372*b50261e2SCy Schubert if test "X$dlpremoduletest" = "X$lib"; then 8373*b50261e2SCy Schubert dlopenmodule=$dlpremoduletest 8374*b50261e2SCy Schubert break 8375*b50261e2SCy Schubert fi 8376*b50261e2SCy Schubert done 8377*b50261e2SCy Schubert if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8378*b50261e2SCy Schubert echo 8379*b50261e2SCy Schubert if test prog = "$linkmode"; then 8380*b50261e2SCy Schubert $ECHO "*** Warning: Linking the executable $output against the loadable module" 8381*b50261e2SCy Schubert else 8382*b50261e2SCy Schubert $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8383*b50261e2SCy Schubert fi 8384*b50261e2SCy Schubert $ECHO "*** $linklib is not portable!" 8385*b50261e2SCy Schubert fi 8386*b50261e2SCy Schubert if test lib = "$linkmode" && 8387*b50261e2SCy Schubert test yes = "$hardcode_into_libs"; then 8388*b50261e2SCy Schubert # Hardcode the library path. 8389*b50261e2SCy Schubert # Skip directories that are in the system default run-time 8390*b50261e2SCy Schubert # search path. 8391*b50261e2SCy Schubert case " $sys_lib_dlsearch_path " in 8392*b50261e2SCy Schubert *" $absdir "*) ;; 8393*b50261e2SCy Schubert *) 8394*b50261e2SCy Schubert case "$compile_rpath " in 8395*b50261e2SCy Schubert *" $absdir "*) ;; 8396*b50261e2SCy Schubert *) func_append compile_rpath " $absdir" ;; 8397*b50261e2SCy Schubert esac 8398*b50261e2SCy Schubert ;; 8399*b50261e2SCy Schubert esac 8400*b50261e2SCy Schubert case " $sys_lib_dlsearch_path " in 8401*b50261e2SCy Schubert *" $libdir "*) ;; 8402*b50261e2SCy Schubert *) 8403*b50261e2SCy Schubert case "$finalize_rpath " in 8404*b50261e2SCy Schubert *" $libdir "*) ;; 8405*b50261e2SCy Schubert *) func_append finalize_rpath " $libdir" ;; 8406*b50261e2SCy Schubert esac 8407*b50261e2SCy Schubert ;; 8408*b50261e2SCy Schubert esac 8409*b50261e2SCy Schubert fi 8410*b50261e2SCy Schubert 8411*b50261e2SCy Schubert if test -n "$old_archive_from_expsyms_cmds"; then 8412*b50261e2SCy Schubert # figure out the soname 8413*b50261e2SCy Schubert set dummy $library_names 8414*b50261e2SCy Schubert shift 8415*b50261e2SCy Schubert realname=$1 8416*b50261e2SCy Schubert shift 8417*b50261e2SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 8418*b50261e2SCy Schubert # use dlname if we got it. it's perfectly good, no? 8419*b50261e2SCy Schubert if test -n "$dlname"; then 8420*b50261e2SCy Schubert soname=$dlname 8421*b50261e2SCy Schubert elif test -n "$soname_spec"; then 8422*b50261e2SCy Schubert # bleh windows 8423*b50261e2SCy Schubert case $host in 8424*b50261e2SCy Schubert *cygwin* | mingw* | *cegcc* | *os2*) 8425*b50261e2SCy Schubert func_arith $current - $age 8426*b50261e2SCy Schubert major=$func_arith_result 8427*b50261e2SCy Schubert versuffix=-$major 8428*b50261e2SCy Schubert ;; 8429*b50261e2SCy Schubert esac 8430*b50261e2SCy Schubert eval soname=\"$soname_spec\" 8431*b50261e2SCy Schubert else 8432*b50261e2SCy Schubert soname=$realname 8433*b50261e2SCy Schubert fi 8434*b50261e2SCy Schubert 8435*b50261e2SCy Schubert # Make a new name for the extract_expsyms_cmds to use 8436*b50261e2SCy Schubert soroot=$soname 8437*b50261e2SCy Schubert func_basename "$soroot" 8438*b50261e2SCy Schubert soname=$func_basename_result 8439*b50261e2SCy Schubert func_stripname 'lib' '.dll' "$soname" 8440*b50261e2SCy Schubert newlib=libimp-$func_stripname_result.a 8441*b50261e2SCy Schubert 8442*b50261e2SCy Schubert # If the library has no export list, then create one now 8443*b50261e2SCy Schubert if test -f "$output_objdir/$soname-def"; then : 8444*b50261e2SCy Schubert else 8445*b50261e2SCy Schubert func_verbose "extracting exported symbol list from '$soname'" 8446*b50261e2SCy Schubert func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8447*b50261e2SCy Schubert fi 8448*b50261e2SCy Schubert 8449*b50261e2SCy Schubert # Create $newlib 8450*b50261e2SCy Schubert if test -f "$output_objdir/$newlib"; then :; else 8451*b50261e2SCy Schubert func_verbose "generating import library for '$soname'" 8452*b50261e2SCy Schubert func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8453*b50261e2SCy Schubert fi 8454*b50261e2SCy Schubert # make sure the library variables are pointing to the new library 8455*b50261e2SCy Schubert dir=$output_objdir 8456*b50261e2SCy Schubert linklib=$newlib 8457*b50261e2SCy Schubert fi # test -n "$old_archive_from_expsyms_cmds" 8458*b50261e2SCy Schubert 8459*b50261e2SCy Schubert if test prog = "$linkmode" || test relink != "$opt_mode"; then 8460*b50261e2SCy Schubert add_shlibpath= 8461*b50261e2SCy Schubert add_dir= 8462*b50261e2SCy Schubert add= 8463*b50261e2SCy Schubert lib_linked=yes 8464*b50261e2SCy Schubert case $hardcode_action in 8465*b50261e2SCy Schubert immediate | unsupported) 8466*b50261e2SCy Schubert if test no = "$hardcode_direct"; then 8467*b50261e2SCy Schubert add=$dir/$linklib 8468*b50261e2SCy Schubert case $host in 8469*b50261e2SCy Schubert *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8470*b50261e2SCy Schubert *-*-sysv4*uw2*) add_dir=-L$dir ;; 8471*b50261e2SCy Schubert *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8472*b50261e2SCy Schubert *-*-unixware7*) add_dir=-L$dir ;; 8473*b50261e2SCy Schubert *-*-darwin* ) 8474*b50261e2SCy Schubert # if the lib is a (non-dlopened) module then we cannot 8475*b50261e2SCy Schubert # link against it, someone is ignoring the earlier warnings 8476*b50261e2SCy Schubert if /usr/bin/file -L $add 2> /dev/null | 8477*b50261e2SCy Schubert $GREP ": [^:]* bundle" >/dev/null; then 8478*b50261e2SCy Schubert if test "X$dlopenmodule" != "X$lib"; then 8479*b50261e2SCy Schubert $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8480*b50261e2SCy Schubert if test -z "$old_library"; then 8481*b50261e2SCy Schubert echo 8482*b50261e2SCy Schubert echo "*** And there doesn't seem to be a static archive available" 8483*b50261e2SCy Schubert echo "*** The link will probably fail, sorry" 8484*b50261e2SCy Schubert else 8485*b50261e2SCy Schubert add=$dir/$old_library 8486*b50261e2SCy Schubert fi 8487*b50261e2SCy Schubert elif test -n "$old_library"; then 8488*b50261e2SCy Schubert add=$dir/$old_library 8489*b50261e2SCy Schubert fi 8490*b50261e2SCy Schubert fi 8491*b50261e2SCy Schubert esac 8492*b50261e2SCy Schubert elif test no = "$hardcode_minus_L"; then 8493*b50261e2SCy Schubert case $host in 8494*b50261e2SCy Schubert *-*-sunos*) add_shlibpath=$dir ;; 8495*b50261e2SCy Schubert esac 8496*b50261e2SCy Schubert add_dir=-L$dir 8497*b50261e2SCy Schubert add=-l$name 8498*b50261e2SCy Schubert elif test no = "$hardcode_shlibpath_var"; then 8499*b50261e2SCy Schubert add_shlibpath=$dir 8500*b50261e2SCy Schubert add=-l$name 8501*b50261e2SCy Schubert else 8502*b50261e2SCy Schubert lib_linked=no 8503*b50261e2SCy Schubert fi 8504*b50261e2SCy Schubert ;; 8505*b50261e2SCy Schubert relink) 8506*b50261e2SCy Schubert if test yes = "$hardcode_direct" && 8507*b50261e2SCy Schubert test no = "$hardcode_direct_absolute"; then 8508*b50261e2SCy Schubert add=$dir/$linklib 8509*b50261e2SCy Schubert elif test yes = "$hardcode_minus_L"; then 8510*b50261e2SCy Schubert add_dir=-L$absdir 8511*b50261e2SCy Schubert # Try looking first in the location we're being installed to. 8512*b50261e2SCy Schubert if test -n "$inst_prefix_dir"; then 8513*b50261e2SCy Schubert case $libdir in 8514*b50261e2SCy Schubert [\\/]*) 8515*b50261e2SCy Schubert func_append add_dir " -L$inst_prefix_dir$libdir" 8516*b50261e2SCy Schubert ;; 8517*b50261e2SCy Schubert esac 8518*b50261e2SCy Schubert fi 8519*b50261e2SCy Schubert add=-l$name 8520*b50261e2SCy Schubert elif test yes = "$hardcode_shlibpath_var"; then 8521*b50261e2SCy Schubert add_shlibpath=$dir 8522*b50261e2SCy Schubert add=-l$name 8523*b50261e2SCy Schubert else 8524*b50261e2SCy Schubert lib_linked=no 8525*b50261e2SCy Schubert fi 8526*b50261e2SCy Schubert ;; 8527*b50261e2SCy Schubert *) lib_linked=no ;; 8528*b50261e2SCy Schubert esac 8529*b50261e2SCy Schubert 8530*b50261e2SCy Schubert if test yes != "$lib_linked"; then 8531*b50261e2SCy Schubert func_fatal_configuration "unsupported hardcode properties" 8532*b50261e2SCy Schubert fi 8533*b50261e2SCy Schubert 8534*b50261e2SCy Schubert if test -n "$add_shlibpath"; then 8535*b50261e2SCy Schubert case :$compile_shlibpath: in 8536*b50261e2SCy Schubert *":$add_shlibpath:"*) ;; 8537*b50261e2SCy Schubert *) func_append compile_shlibpath "$add_shlibpath:" ;; 8538*b50261e2SCy Schubert esac 8539*b50261e2SCy Schubert fi 8540*b50261e2SCy Schubert if test prog = "$linkmode"; then 8541*b50261e2SCy Schubert test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8542*b50261e2SCy Schubert test -n "$add" && compile_deplibs="$add $compile_deplibs" 8543*b50261e2SCy Schubert else 8544*b50261e2SCy Schubert test -n "$add_dir" && deplibs="$add_dir $deplibs" 8545*b50261e2SCy Schubert test -n "$add" && deplibs="$add $deplibs" 8546*b50261e2SCy Schubert if test yes != "$hardcode_direct" && 8547*b50261e2SCy Schubert test yes != "$hardcode_minus_L" && 8548*b50261e2SCy Schubert test yes = "$hardcode_shlibpath_var"; then 8549*b50261e2SCy Schubert case :$finalize_shlibpath: in 8550*b50261e2SCy Schubert *":$libdir:"*) ;; 8551*b50261e2SCy Schubert *) func_append finalize_shlibpath "$libdir:" ;; 8552*b50261e2SCy Schubert esac 8553*b50261e2SCy Schubert fi 8554*b50261e2SCy Schubert fi 8555*b50261e2SCy Schubert fi 8556*b50261e2SCy Schubert 8557*b50261e2SCy Schubert if test prog = "$linkmode" || test relink = "$opt_mode"; then 8558*b50261e2SCy Schubert add_shlibpath= 8559*b50261e2SCy Schubert add_dir= 8560*b50261e2SCy Schubert add= 8561*b50261e2SCy Schubert # Finalize command for both is simple: just hardcode it. 8562*b50261e2SCy Schubert if test yes = "$hardcode_direct" && 8563*b50261e2SCy Schubert test no = "$hardcode_direct_absolute"; then 8564*b50261e2SCy Schubert add=$libdir/$linklib 8565*b50261e2SCy Schubert elif test yes = "$hardcode_minus_L"; then 8566*b50261e2SCy Schubert add_dir=-L$libdir 8567*b50261e2SCy Schubert add=-l$name 8568*b50261e2SCy Schubert elif test yes = "$hardcode_shlibpath_var"; then 8569*b50261e2SCy Schubert case :$finalize_shlibpath: in 8570*b50261e2SCy Schubert *":$libdir:"*) ;; 8571*b50261e2SCy Schubert *) func_append finalize_shlibpath "$libdir:" ;; 8572*b50261e2SCy Schubert esac 8573*b50261e2SCy Schubert add=-l$name 8574*b50261e2SCy Schubert elif test yes = "$hardcode_automatic"; then 8575*b50261e2SCy Schubert if test -n "$inst_prefix_dir" && 8576*b50261e2SCy Schubert test -f "$inst_prefix_dir$libdir/$linklib"; then 8577*b50261e2SCy Schubert add=$inst_prefix_dir$libdir/$linklib 8578*b50261e2SCy Schubert else 8579*b50261e2SCy Schubert add=$libdir/$linklib 8580*b50261e2SCy Schubert fi 8581*b50261e2SCy Schubert else 8582*b50261e2SCy Schubert # We cannot seem to hardcode it, guess we'll fake it. 8583*b50261e2SCy Schubert add_dir=-L$libdir 8584*b50261e2SCy Schubert # Try looking first in the location we're being installed to. 8585*b50261e2SCy Schubert if test -n "$inst_prefix_dir"; then 8586*b50261e2SCy Schubert case $libdir in 8587*b50261e2SCy Schubert [\\/]*) 8588*b50261e2SCy Schubert func_append add_dir " -L$inst_prefix_dir$libdir" 8589*b50261e2SCy Schubert ;; 8590*b50261e2SCy Schubert esac 8591*b50261e2SCy Schubert fi 8592*b50261e2SCy Schubert add=-l$name 8593*b50261e2SCy Schubert fi 8594*b50261e2SCy Schubert 8595*b50261e2SCy Schubert if test prog = "$linkmode"; then 8596*b50261e2SCy Schubert test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8597*b50261e2SCy Schubert test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8598*b50261e2SCy Schubert else 8599*b50261e2SCy Schubert test -n "$add_dir" && deplibs="$add_dir $deplibs" 8600*b50261e2SCy Schubert test -n "$add" && deplibs="$add $deplibs" 8601*b50261e2SCy Schubert fi 8602*b50261e2SCy Schubert fi 8603*b50261e2SCy Schubert elif test prog = "$linkmode"; then 8604*b50261e2SCy Schubert # Here we assume that one of hardcode_direct or hardcode_minus_L 8605*b50261e2SCy Schubert # is not unsupported. This is valid on all known static and 8606*b50261e2SCy Schubert # shared platforms. 8607*b50261e2SCy Schubert if test unsupported != "$hardcode_direct"; then 8608*b50261e2SCy Schubert test -n "$old_library" && linklib=$old_library 8609*b50261e2SCy Schubert compile_deplibs="$dir/$linklib $compile_deplibs" 8610*b50261e2SCy Schubert finalize_deplibs="$dir/$linklib $finalize_deplibs" 8611*b50261e2SCy Schubert else 8612*b50261e2SCy Schubert compile_deplibs="-l$name -L$dir $compile_deplibs" 8613*b50261e2SCy Schubert finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8614*b50261e2SCy Schubert fi 8615*b50261e2SCy Schubert elif test yes = "$build_libtool_libs"; then 8616*b50261e2SCy Schubert # Not a shared library 8617*b50261e2SCy Schubert if test pass_all != "$deplibs_check_method"; then 8618*b50261e2SCy Schubert # We're trying link a shared library against a static one 8619*b50261e2SCy Schubert # but the system doesn't support it. 8620*b50261e2SCy Schubert 8621*b50261e2SCy Schubert # Just print a warning and add the library to dependency_libs so 8622*b50261e2SCy Schubert # that the program can be linked against the static library. 8623*b50261e2SCy Schubert echo 8624*b50261e2SCy Schubert $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8625*b50261e2SCy Schubert echo "*** I have the capability to make that library automatically link in when" 8626*b50261e2SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 8627*b50261e2SCy Schubert echo "*** shared version of the library, which you do not appear to have." 8628*b50261e2SCy Schubert if test yes = "$module"; then 8629*b50261e2SCy Schubert echo "*** But as you try to build a module library, libtool will still create " 8630*b50261e2SCy Schubert echo "*** a static module, that should work as long as the dlopening application" 8631*b50261e2SCy Schubert echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8632*b50261e2SCy Schubert if test -z "$global_symbol_pipe"; then 8633*b50261e2SCy Schubert echo 8634*b50261e2SCy Schubert echo "*** However, this would only work if libtool was able to extract symbol" 8635*b50261e2SCy Schubert echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8636*b50261e2SCy Schubert echo "*** not find such a program. So, this module is probably useless." 8637*b50261e2SCy Schubert echo "*** 'nm' from GNU binutils and a full rebuild may help." 8638*b50261e2SCy Schubert fi 8639*b50261e2SCy Schubert if test no = "$build_old_libs"; then 8640*b50261e2SCy Schubert build_libtool_libs=module 8641*b50261e2SCy Schubert build_old_libs=yes 8642*b50261e2SCy Schubert else 8643*b50261e2SCy Schubert build_libtool_libs=no 8644*b50261e2SCy Schubert fi 8645*b50261e2SCy Schubert fi 8646*b50261e2SCy Schubert else 8647*b50261e2SCy Schubert deplibs="$dir/$old_library $deplibs" 8648*b50261e2SCy Schubert link_static=yes 8649*b50261e2SCy Schubert fi 8650*b50261e2SCy Schubert fi # link shared/static library? 8651*b50261e2SCy Schubert 8652*b50261e2SCy Schubert if test lib = "$linkmode"; then 8653*b50261e2SCy Schubert if test -n "$dependency_libs" && 8654*b50261e2SCy Schubert { test yes != "$hardcode_into_libs" || 8655*b50261e2SCy Schubert test yes = "$build_old_libs" || 8656*b50261e2SCy Schubert test yes = "$link_static"; }; then 8657*b50261e2SCy Schubert # Extract -R from dependency_libs 8658*b50261e2SCy Schubert temp_deplibs= 8659*b50261e2SCy Schubert for libdir in $dependency_libs; do 8660*b50261e2SCy Schubert case $libdir in 8661*b50261e2SCy Schubert -R*) func_stripname '-R' '' "$libdir" 8662*b50261e2SCy Schubert temp_xrpath=$func_stripname_result 8663*b50261e2SCy Schubert case " $xrpath " in 8664*b50261e2SCy Schubert *" $temp_xrpath "*) ;; 8665*b50261e2SCy Schubert *) func_append xrpath " $temp_xrpath";; 8666*b50261e2SCy Schubert esac;; 8667*b50261e2SCy Schubert *) func_append temp_deplibs " $libdir";; 8668*b50261e2SCy Schubert esac 8669*b50261e2SCy Schubert done 8670*b50261e2SCy Schubert dependency_libs=$temp_deplibs 8671*b50261e2SCy Schubert fi 8672*b50261e2SCy Schubert 8673*b50261e2SCy Schubert func_append newlib_search_path " $absdir" 8674*b50261e2SCy Schubert # Link against this library 8675*b50261e2SCy Schubert test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8676*b50261e2SCy Schubert # ... and its dependency_libs 8677*b50261e2SCy Schubert tmp_libs= 8678*b50261e2SCy Schubert for deplib in $dependency_libs; do 8679*b50261e2SCy Schubert newdependency_libs="$deplib $newdependency_libs" 8680*b50261e2SCy Schubert case $deplib in 8681*b50261e2SCy Schubert -L*) func_stripname '-L' '' "$deplib" 8682*b50261e2SCy Schubert func_resolve_sysroot "$func_stripname_result";; 8683*b50261e2SCy Schubert *) func_resolve_sysroot "$deplib" ;; 8684*b50261e2SCy Schubert esac 8685*b50261e2SCy Schubert if $opt_preserve_dup_deps; then 8686*b50261e2SCy Schubert case "$tmp_libs " in 8687*b50261e2SCy Schubert *" $func_resolve_sysroot_result "*) 8688*b50261e2SCy Schubert func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8689*b50261e2SCy Schubert esac 8690*b50261e2SCy Schubert fi 8691*b50261e2SCy Schubert func_append tmp_libs " $func_resolve_sysroot_result" 8692*b50261e2SCy Schubert done 8693*b50261e2SCy Schubert 8694*b50261e2SCy Schubert if test no != "$link_all_deplibs"; then 8695*b50261e2SCy Schubert # Add the search paths of all dependency libraries 8696*b50261e2SCy Schubert for deplib in $dependency_libs; do 8697*b50261e2SCy Schubert path= 8698*b50261e2SCy Schubert case $deplib in 8699*b50261e2SCy Schubert -L*) path=$deplib ;; 8700*b50261e2SCy Schubert *.la) 8701*b50261e2SCy Schubert func_resolve_sysroot "$deplib" 8702*b50261e2SCy Schubert deplib=$func_resolve_sysroot_result 8703*b50261e2SCy Schubert func_dirname "$deplib" "" "." 8704*b50261e2SCy Schubert dir=$func_dirname_result 8705*b50261e2SCy Schubert # We need an absolute path. 8706*b50261e2SCy Schubert case $dir in 8707*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8708*b50261e2SCy Schubert *) 8709*b50261e2SCy Schubert absdir=`cd "$dir" && pwd` 8710*b50261e2SCy Schubert if test -z "$absdir"; then 8711*b50261e2SCy Schubert func_warning "cannot determine absolute directory name of '$dir'" 8712*b50261e2SCy Schubert absdir=$dir 8713*b50261e2SCy Schubert fi 8714*b50261e2SCy Schubert ;; 8715*b50261e2SCy Schubert esac 8716*b50261e2SCy Schubert if $GREP "^installed=no" $deplib > /dev/null; then 8717*b50261e2SCy Schubert case $host in 8718*b50261e2SCy Schubert *-*-darwin*) 8719*b50261e2SCy Schubert depdepl= 8720*b50261e2SCy Schubert eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8721*b50261e2SCy Schubert if test -n "$deplibrary_names"; then 8722*b50261e2SCy Schubert for tmp in $deplibrary_names; do 8723*b50261e2SCy Schubert depdepl=$tmp 8724*b50261e2SCy Schubert done 8725*b50261e2SCy Schubert if test -f "$absdir/$objdir/$depdepl"; then 8726*b50261e2SCy Schubert depdepl=$absdir/$objdir/$depdepl 8727*b50261e2SCy Schubert darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8728*b50261e2SCy Schubert if test -z "$darwin_install_name"; then 8729*b50261e2SCy Schubert darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8730*b50261e2SCy Schubert fi 8731*b50261e2SCy Schubert func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8732*b50261e2SCy Schubert func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8733*b50261e2SCy Schubert path= 8734*b50261e2SCy Schubert fi 8735*b50261e2SCy Schubert fi 8736*b50261e2SCy Schubert ;; 8737*b50261e2SCy Schubert *) 8738*b50261e2SCy Schubert path=-L$absdir/$objdir 8739*b50261e2SCy Schubert ;; 8740*b50261e2SCy Schubert esac 8741*b50261e2SCy Schubert else 8742*b50261e2SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8743*b50261e2SCy Schubert test -z "$libdir" && \ 8744*b50261e2SCy Schubert func_fatal_error "'$deplib' is not a valid libtool archive" 8745*b50261e2SCy Schubert test "$absdir" != "$libdir" && \ 8746*b50261e2SCy Schubert func_warning "'$deplib' seems to be moved" 8747*b50261e2SCy Schubert 8748*b50261e2SCy Schubert path=-L$absdir 8749*b50261e2SCy Schubert fi 8750*b50261e2SCy Schubert ;; 8751*b50261e2SCy Schubert esac 8752*b50261e2SCy Schubert case " $deplibs " in 8753*b50261e2SCy Schubert *" $path "*) ;; 8754*b50261e2SCy Schubert *) deplibs="$path $deplibs" ;; 8755*b50261e2SCy Schubert esac 8756*b50261e2SCy Schubert done 8757*b50261e2SCy Schubert fi # link_all_deplibs != no 8758*b50261e2SCy Schubert fi # linkmode = lib 8759*b50261e2SCy Schubert done # for deplib in $libs 8760*b50261e2SCy Schubert if test link = "$pass"; then 8761*b50261e2SCy Schubert if test prog = "$linkmode"; then 8762*b50261e2SCy Schubert compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8763*b50261e2SCy Schubert finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8764*b50261e2SCy Schubert else 8765*b50261e2SCy Schubert compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8766*b50261e2SCy Schubert fi 8767*b50261e2SCy Schubert fi 8768*b50261e2SCy Schubert dependency_libs=$newdependency_libs 8769*b50261e2SCy Schubert if test dlpreopen = "$pass"; then 8770*b50261e2SCy Schubert # Link the dlpreopened libraries before other libraries 8771*b50261e2SCy Schubert for deplib in $save_deplibs; do 8772*b50261e2SCy Schubert deplibs="$deplib $deplibs" 8773*b50261e2SCy Schubert done 8774*b50261e2SCy Schubert fi 8775*b50261e2SCy Schubert if test dlopen != "$pass"; then 8776*b50261e2SCy Schubert test conv = "$pass" || { 8777*b50261e2SCy Schubert # Make sure lib_search_path contains only unique directories. 8778*b50261e2SCy Schubert lib_search_path= 8779*b50261e2SCy Schubert for dir in $newlib_search_path; do 8780*b50261e2SCy Schubert case "$lib_search_path " in 8781*b50261e2SCy Schubert *" $dir "*) ;; 8782*b50261e2SCy Schubert *) func_append lib_search_path " $dir" ;; 8783*b50261e2SCy Schubert esac 8784*b50261e2SCy Schubert done 8785*b50261e2SCy Schubert newlib_search_path= 8786*b50261e2SCy Schubert } 8787*b50261e2SCy Schubert 8788*b50261e2SCy Schubert if test prog,link = "$linkmode,$pass"; then 8789*b50261e2SCy Schubert vars="compile_deplibs finalize_deplibs" 8790*b50261e2SCy Schubert else 8791*b50261e2SCy Schubert vars=deplibs 8792*b50261e2SCy Schubert fi 8793*b50261e2SCy Schubert for var in $vars dependency_libs; do 8794*b50261e2SCy Schubert # Add libraries to $var in reverse order 8795*b50261e2SCy Schubert eval tmp_libs=\"\$$var\" 8796*b50261e2SCy Schubert new_libs= 8797*b50261e2SCy Schubert for deplib in $tmp_libs; do 8798*b50261e2SCy Schubert # FIXME: Pedantically, this is the right thing to do, so 8799*b50261e2SCy Schubert # that some nasty dependency loop isn't accidentally 8800*b50261e2SCy Schubert # broken: 8801*b50261e2SCy Schubert #new_libs="$deplib $new_libs" 8802*b50261e2SCy Schubert # Pragmatically, this seems to cause very few problems in 8803*b50261e2SCy Schubert # practice: 8804*b50261e2SCy Schubert case $deplib in 8805*b50261e2SCy Schubert -L*) new_libs="$deplib $new_libs" ;; 8806*b50261e2SCy Schubert -R*) ;; 8807*b50261e2SCy Schubert *) 8808*b50261e2SCy Schubert # And here is the reason: when a library appears more 8809*b50261e2SCy Schubert # than once as an explicit dependence of a library, or 8810*b50261e2SCy Schubert # is implicitly linked in more than once by the 8811*b50261e2SCy Schubert # compiler, it is considered special, and multiple 8812*b50261e2SCy Schubert # occurrences thereof are not removed. Compare this 8813*b50261e2SCy Schubert # with having the same library being listed as a 8814*b50261e2SCy Schubert # dependency of multiple other libraries: in this case, 8815*b50261e2SCy Schubert # we know (pedantically, we assume) the library does not 8816*b50261e2SCy Schubert # need to be listed more than once, so we keep only the 8817*b50261e2SCy Schubert # last copy. This is not always right, but it is rare 8818*b50261e2SCy Schubert # enough that we require users that really mean to play 8819*b50261e2SCy Schubert # such unportable linking tricks to link the library 8820*b50261e2SCy Schubert # using -Wl,-lname, so that libtool does not consider it 8821*b50261e2SCy Schubert # for duplicate removal. 8822*b50261e2SCy Schubert case " $specialdeplibs " in 8823*b50261e2SCy Schubert *" $deplib "*) new_libs="$deplib $new_libs" ;; 8824*b50261e2SCy Schubert *) 8825*b50261e2SCy Schubert case " $new_libs " in 8826*b50261e2SCy Schubert *" $deplib "*) ;; 8827*b50261e2SCy Schubert *) new_libs="$deplib $new_libs" ;; 8828*b50261e2SCy Schubert esac 8829*b50261e2SCy Schubert ;; 8830*b50261e2SCy Schubert esac 8831*b50261e2SCy Schubert ;; 8832*b50261e2SCy Schubert esac 8833*b50261e2SCy Schubert done 8834*b50261e2SCy Schubert tmp_libs= 8835*b50261e2SCy Schubert for deplib in $new_libs; do 8836*b50261e2SCy Schubert case $deplib in 8837*b50261e2SCy Schubert -L*) 8838*b50261e2SCy Schubert case " $tmp_libs " in 8839*b50261e2SCy Schubert *" $deplib "*) ;; 8840*b50261e2SCy Schubert *) func_append tmp_libs " $deplib" ;; 8841*b50261e2SCy Schubert esac 8842*b50261e2SCy Schubert ;; 8843*b50261e2SCy Schubert *) func_append tmp_libs " $deplib" ;; 8844*b50261e2SCy Schubert esac 8845*b50261e2SCy Schubert done 8846*b50261e2SCy Schubert eval $var=\"$tmp_libs\" 8847*b50261e2SCy Schubert done # for var 8848*b50261e2SCy Schubert fi 8849*b50261e2SCy Schubert 8850*b50261e2SCy Schubert # Add Sun CC postdeps if required: 8851*b50261e2SCy Schubert test CXX = "$tagname" && { 8852*b50261e2SCy Schubert case $host_os in 8853*b50261e2SCy Schubert linux*) 8854*b50261e2SCy Schubert case `$CC -V 2>&1 | sed 5q` in 8855*b50261e2SCy Schubert *Sun\ C*) # Sun C++ 5.9 8856*b50261e2SCy Schubert func_suncc_cstd_abi 8857*b50261e2SCy Schubert 8858*b50261e2SCy Schubert if test no != "$suncc_use_cstd_abi"; then 8859*b50261e2SCy Schubert func_append postdeps ' -library=Cstd -library=Crun' 8860*b50261e2SCy Schubert fi 8861*b50261e2SCy Schubert ;; 8862*b50261e2SCy Schubert esac 8863*b50261e2SCy Schubert ;; 8864*b50261e2SCy Schubert 8865*b50261e2SCy Schubert solaris*) 8866*b50261e2SCy Schubert func_cc_basename "$CC" 8867*b50261e2SCy Schubert case $func_cc_basename_result in 8868*b50261e2SCy Schubert CC* | sunCC*) 8869*b50261e2SCy Schubert func_suncc_cstd_abi 8870*b50261e2SCy Schubert 8871*b50261e2SCy Schubert if test no != "$suncc_use_cstd_abi"; then 8872*b50261e2SCy Schubert func_append postdeps ' -library=Cstd -library=Crun' 8873*b50261e2SCy Schubert fi 8874*b50261e2SCy Schubert ;; 8875*b50261e2SCy Schubert esac 8876*b50261e2SCy Schubert ;; 8877*b50261e2SCy Schubert esac 8878*b50261e2SCy Schubert } 8879*b50261e2SCy Schubert 8880*b50261e2SCy Schubert # Last step: remove runtime libs from dependency_libs 8881*b50261e2SCy Schubert # (they stay in deplibs) 8882*b50261e2SCy Schubert tmp_libs= 8883*b50261e2SCy Schubert for i in $dependency_libs; do 8884*b50261e2SCy Schubert case " $predeps $postdeps $compiler_lib_search_path " in 8885*b50261e2SCy Schubert *" $i "*) 8886*b50261e2SCy Schubert i= 8887*b50261e2SCy Schubert ;; 8888*b50261e2SCy Schubert esac 8889*b50261e2SCy Schubert if test -n "$i"; then 8890*b50261e2SCy Schubert func_append tmp_libs " $i" 8891*b50261e2SCy Schubert fi 8892*b50261e2SCy Schubert done 8893*b50261e2SCy Schubert dependency_libs=$tmp_libs 8894*b50261e2SCy Schubert done # for pass 8895*b50261e2SCy Schubert if test prog = "$linkmode"; then 8896*b50261e2SCy Schubert dlfiles=$newdlfiles 8897*b50261e2SCy Schubert fi 8898*b50261e2SCy Schubert if test prog = "$linkmode" || test lib = "$linkmode"; then 8899*b50261e2SCy Schubert dlprefiles=$newdlprefiles 8900*b50261e2SCy Schubert fi 8901*b50261e2SCy Schubert 8902*b50261e2SCy Schubert case $linkmode in 8903*b50261e2SCy Schubert oldlib) 8904*b50261e2SCy Schubert if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8905*b50261e2SCy Schubert func_warning "'-dlopen' is ignored for archives" 8906*b50261e2SCy Schubert fi 8907*b50261e2SCy Schubert 8908*b50261e2SCy Schubert case " $deplibs" in 8909*b50261e2SCy Schubert *\ -l* | *\ -L*) 8910*b50261e2SCy Schubert func_warning "'-l' and '-L' are ignored for archives" ;; 8911*b50261e2SCy Schubert esac 8912*b50261e2SCy Schubert 8913*b50261e2SCy Schubert test -n "$rpath" && \ 8914*b50261e2SCy Schubert func_warning "'-rpath' is ignored for archives" 8915*b50261e2SCy Schubert 8916*b50261e2SCy Schubert test -n "$xrpath" && \ 8917*b50261e2SCy Schubert func_warning "'-R' is ignored for archives" 8918*b50261e2SCy Schubert 8919*b50261e2SCy Schubert test -n "$vinfo" && \ 8920*b50261e2SCy Schubert func_warning "'-version-info/-version-number' is ignored for archives" 8921*b50261e2SCy Schubert 8922*b50261e2SCy Schubert test -n "$release" && \ 8923*b50261e2SCy Schubert func_warning "'-release' is ignored for archives" 8924*b50261e2SCy Schubert 8925*b50261e2SCy Schubert test -n "$export_symbols$export_symbols_regex" && \ 8926*b50261e2SCy Schubert func_warning "'-export-symbols' is ignored for archives" 8927*b50261e2SCy Schubert 8928*b50261e2SCy Schubert # Now set the variables for building old libraries. 8929*b50261e2SCy Schubert build_libtool_libs=no 8930*b50261e2SCy Schubert oldlibs=$output 8931*b50261e2SCy Schubert func_append objs "$old_deplibs" 8932*b50261e2SCy Schubert ;; 8933*b50261e2SCy Schubert 8934*b50261e2SCy Schubert lib) 8935*b50261e2SCy Schubert # Make sure we only generate libraries of the form 'libNAME.la'. 8936*b50261e2SCy Schubert case $outputname in 8937*b50261e2SCy Schubert lib*) 8938*b50261e2SCy Schubert func_stripname 'lib' '.la' "$outputname" 8939*b50261e2SCy Schubert name=$func_stripname_result 8940*b50261e2SCy Schubert eval shared_ext=\"$shrext_cmds\" 8941*b50261e2SCy Schubert eval libname=\"$libname_spec\" 8942*b50261e2SCy Schubert ;; 8943*b50261e2SCy Schubert *) 8944*b50261e2SCy Schubert test no = "$module" \ 8945*b50261e2SCy Schubert && func_fatal_help "libtool library '$output' must begin with 'lib'" 8946*b50261e2SCy Schubert 8947*b50261e2SCy Schubert if test no != "$need_lib_prefix"; then 8948*b50261e2SCy Schubert # Add the "lib" prefix for modules if required 8949*b50261e2SCy Schubert func_stripname '' '.la' "$outputname" 8950*b50261e2SCy Schubert name=$func_stripname_result 8951*b50261e2SCy Schubert eval shared_ext=\"$shrext_cmds\" 8952*b50261e2SCy Schubert eval libname=\"$libname_spec\" 8953*b50261e2SCy Schubert else 8954*b50261e2SCy Schubert func_stripname '' '.la' "$outputname" 8955*b50261e2SCy Schubert libname=$func_stripname_result 8956*b50261e2SCy Schubert fi 8957*b50261e2SCy Schubert ;; 8958*b50261e2SCy Schubert esac 8959*b50261e2SCy Schubert 8960*b50261e2SCy Schubert if test -n "$objs"; then 8961*b50261e2SCy Schubert if test pass_all != "$deplibs_check_method"; then 8962*b50261e2SCy Schubert func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8963*b50261e2SCy Schubert else 8964*b50261e2SCy Schubert echo 8965*b50261e2SCy Schubert $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8966*b50261e2SCy Schubert $ECHO "*** objects $objs is not portable!" 8967*b50261e2SCy Schubert func_append libobjs " $objs" 8968*b50261e2SCy Schubert fi 8969*b50261e2SCy Schubert fi 8970*b50261e2SCy Schubert 8971*b50261e2SCy Schubert test no = "$dlself" \ 8972*b50261e2SCy Schubert || func_warning "'-dlopen self' is ignored for libtool libraries" 8973*b50261e2SCy Schubert 8974*b50261e2SCy Schubert set dummy $rpath 8975*b50261e2SCy Schubert shift 8976*b50261e2SCy Schubert test 1 -lt "$#" \ 8977*b50261e2SCy Schubert && func_warning "ignoring multiple '-rpath's for a libtool library" 8978*b50261e2SCy Schubert 8979*b50261e2SCy Schubert install_libdir=$1 8980*b50261e2SCy Schubert 8981*b50261e2SCy Schubert oldlibs= 8982*b50261e2SCy Schubert if test -z "$rpath"; then 8983*b50261e2SCy Schubert if test yes = "$build_libtool_libs"; then 8984*b50261e2SCy Schubert # Building a libtool convenience library. 8985*b50261e2SCy Schubert # Some compilers have problems with a '.al' extension so 8986*b50261e2SCy Schubert # convenience libraries should have the same extension an 8987*b50261e2SCy Schubert # archive normally would. 8988*b50261e2SCy Schubert oldlibs="$output_objdir/$libname.$libext $oldlibs" 8989*b50261e2SCy Schubert build_libtool_libs=convenience 8990*b50261e2SCy Schubert build_old_libs=yes 8991*b50261e2SCy Schubert fi 8992*b50261e2SCy Schubert 8993*b50261e2SCy Schubert test -n "$vinfo" && \ 8994*b50261e2SCy Schubert func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8995*b50261e2SCy Schubert 8996*b50261e2SCy Schubert test -n "$release" && \ 8997*b50261e2SCy Schubert func_warning "'-release' is ignored for convenience libraries" 8998*b50261e2SCy Schubert else 8999*b50261e2SCy Schubert 9000*b50261e2SCy Schubert # Parse the version information argument. 9001*b50261e2SCy Schubert save_ifs=$IFS; IFS=: 9002*b50261e2SCy Schubert set dummy $vinfo 0 0 0 9003*b50261e2SCy Schubert shift 9004*b50261e2SCy Schubert IFS=$save_ifs 9005*b50261e2SCy Schubert 9006*b50261e2SCy Schubert test -n "$7" && \ 9007*b50261e2SCy Schubert func_fatal_help "too many parameters to '-version-info'" 9008*b50261e2SCy Schubert 9009*b50261e2SCy Schubert # convert absolute version numbers to libtool ages 9010*b50261e2SCy Schubert # this retains compatibility with .la files and attempts 9011*b50261e2SCy Schubert # to make the code below a bit more comprehensible 9012*b50261e2SCy Schubert 9013*b50261e2SCy Schubert case $vinfo_number in 9014*b50261e2SCy Schubert yes) 9015*b50261e2SCy Schubert number_major=$1 9016*b50261e2SCy Schubert number_minor=$2 9017*b50261e2SCy Schubert number_revision=$3 9018*b50261e2SCy Schubert # 9019*b50261e2SCy Schubert # There are really only two kinds -- those that 9020*b50261e2SCy Schubert # use the current revision as the major version 9021*b50261e2SCy Schubert # and those that subtract age and use age as 9022*b50261e2SCy Schubert # a minor version. But, then there is irix 9023*b50261e2SCy Schubert # that has an extra 1 added just for fun 9024*b50261e2SCy Schubert # 9025*b50261e2SCy Schubert case $version_type in 9026*b50261e2SCy Schubert # correct linux to gnu/linux during the next big refactor 9027*b50261e2SCy Schubert darwin|freebsd-elf|linux|osf|windows|none) 9028*b50261e2SCy Schubert func_arith $number_major + $number_minor 9029*b50261e2SCy Schubert current=$func_arith_result 9030*b50261e2SCy Schubert age=$number_minor 9031*b50261e2SCy Schubert revision=$number_revision 9032*b50261e2SCy Schubert ;; 9033*b50261e2SCy Schubert freebsd-aout|qnx|sunos) 9034*b50261e2SCy Schubert current=$number_major 9035*b50261e2SCy Schubert revision=$number_minor 9036*b50261e2SCy Schubert age=0 9037*b50261e2SCy Schubert ;; 9038*b50261e2SCy Schubert irix|nonstopux) 9039*b50261e2SCy Schubert func_arith $number_major + $number_minor 9040*b50261e2SCy Schubert current=$func_arith_result 9041*b50261e2SCy Schubert age=$number_minor 9042*b50261e2SCy Schubert revision=$number_minor 9043*b50261e2SCy Schubert lt_irix_increment=no 9044*b50261e2SCy Schubert ;; 9045*b50261e2SCy Schubert esac 9046*b50261e2SCy Schubert ;; 9047*b50261e2SCy Schubert no) 9048*b50261e2SCy Schubert current=$1 9049*b50261e2SCy Schubert revision=$2 9050*b50261e2SCy Schubert age=$3 9051*b50261e2SCy Schubert ;; 9052*b50261e2SCy Schubert esac 9053*b50261e2SCy Schubert 9054*b50261e2SCy Schubert # Check that each of the things are valid numbers. 9055*b50261e2SCy Schubert case $current in 9056*b50261e2SCy Schubert 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]) ;; 9057*b50261e2SCy Schubert *) 9058*b50261e2SCy Schubert func_error "CURRENT '$current' must be a nonnegative integer" 9059*b50261e2SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 9060*b50261e2SCy Schubert ;; 9061*b50261e2SCy Schubert esac 9062*b50261e2SCy Schubert 9063*b50261e2SCy Schubert case $revision in 9064*b50261e2SCy Schubert 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]) ;; 9065*b50261e2SCy Schubert *) 9066*b50261e2SCy Schubert func_error "REVISION '$revision' must be a nonnegative integer" 9067*b50261e2SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 9068*b50261e2SCy Schubert ;; 9069*b50261e2SCy Schubert esac 9070*b50261e2SCy Schubert 9071*b50261e2SCy Schubert case $age in 9072*b50261e2SCy Schubert 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]) ;; 9073*b50261e2SCy Schubert *) 9074*b50261e2SCy Schubert func_error "AGE '$age' must be a nonnegative integer" 9075*b50261e2SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 9076*b50261e2SCy Schubert ;; 9077*b50261e2SCy Schubert esac 9078*b50261e2SCy Schubert 9079*b50261e2SCy Schubert if test "$age" -gt "$current"; then 9080*b50261e2SCy Schubert func_error "AGE '$age' is greater than the current interface number '$current'" 9081*b50261e2SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 9082*b50261e2SCy Schubert fi 9083*b50261e2SCy Schubert 9084*b50261e2SCy Schubert # Calculate the version variables. 9085*b50261e2SCy Schubert major= 9086*b50261e2SCy Schubert versuffix= 9087*b50261e2SCy Schubert verstring= 9088*b50261e2SCy Schubert case $version_type in 9089*b50261e2SCy Schubert none) ;; 9090*b50261e2SCy Schubert 9091*b50261e2SCy Schubert darwin) 9092*b50261e2SCy Schubert # Like Linux, but with the current version available in 9093*b50261e2SCy Schubert # verstring for coding it into the library header 9094*b50261e2SCy Schubert func_arith $current - $age 9095*b50261e2SCy Schubert major=.$func_arith_result 9096*b50261e2SCy Schubert versuffix=$major.$age.$revision 9097*b50261e2SCy Schubert # Darwin ld doesn't like 0 for these options... 9098*b50261e2SCy Schubert func_arith $current + 1 9099*b50261e2SCy Schubert minor_current=$func_arith_result 9100*b50261e2SCy Schubert xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9101*b50261e2SCy Schubert verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9102*b50261e2SCy Schubert # On Darwin other compilers 9103*b50261e2SCy Schubert case $CC in 9104*b50261e2SCy Schubert nagfor*) 9105*b50261e2SCy Schubert verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9106*b50261e2SCy Schubert ;; 9107*b50261e2SCy Schubert *) 9108*b50261e2SCy Schubert verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9109*b50261e2SCy Schubert ;; 9110*b50261e2SCy Schubert esac 9111*b50261e2SCy Schubert ;; 9112*b50261e2SCy Schubert 9113*b50261e2SCy Schubert freebsd-aout) 9114*b50261e2SCy Schubert major=.$current 9115*b50261e2SCy Schubert versuffix=.$current.$revision 9116*b50261e2SCy Schubert ;; 9117*b50261e2SCy Schubert 9118*b50261e2SCy Schubert freebsd-elf) 9119*b50261e2SCy Schubert func_arith $current - $age 9120*b50261e2SCy Schubert major=.$func_arith_result 9121*b50261e2SCy Schubert versuffix=$major.$age.$revision 9122*b50261e2SCy Schubert ;; 9123*b50261e2SCy Schubert 9124*b50261e2SCy Schubert irix | nonstopux) 9125*b50261e2SCy Schubert if test no = "$lt_irix_increment"; then 9126*b50261e2SCy Schubert func_arith $current - $age 9127*b50261e2SCy Schubert else 9128*b50261e2SCy Schubert func_arith $current - $age + 1 9129*b50261e2SCy Schubert fi 9130*b50261e2SCy Schubert major=$func_arith_result 9131*b50261e2SCy Schubert 9132*b50261e2SCy Schubert case $version_type in 9133*b50261e2SCy Schubert nonstopux) verstring_prefix=nonstopux ;; 9134*b50261e2SCy Schubert *) verstring_prefix=sgi ;; 9135*b50261e2SCy Schubert esac 9136*b50261e2SCy Schubert verstring=$verstring_prefix$major.$revision 9137*b50261e2SCy Schubert 9138*b50261e2SCy Schubert # Add in all the interfaces that we are compatible with. 9139*b50261e2SCy Schubert loop=$revision 9140*b50261e2SCy Schubert while test 0 -ne "$loop"; do 9141*b50261e2SCy Schubert func_arith $revision - $loop 9142*b50261e2SCy Schubert iface=$func_arith_result 9143*b50261e2SCy Schubert func_arith $loop - 1 9144*b50261e2SCy Schubert loop=$func_arith_result 9145*b50261e2SCy Schubert verstring=$verstring_prefix$major.$iface:$verstring 9146*b50261e2SCy Schubert done 9147*b50261e2SCy Schubert 9148*b50261e2SCy Schubert # Before this point, $major must not contain '.'. 9149*b50261e2SCy Schubert major=.$major 9150*b50261e2SCy Schubert versuffix=$major.$revision 9151*b50261e2SCy Schubert ;; 9152*b50261e2SCy Schubert 9153*b50261e2SCy Schubert linux) # correct to gnu/linux during the next big refactor 9154*b50261e2SCy Schubert func_arith $current - $age 9155*b50261e2SCy Schubert major=.$func_arith_result 9156*b50261e2SCy Schubert versuffix=$major.$age.$revision 9157*b50261e2SCy Schubert ;; 9158*b50261e2SCy Schubert 9159*b50261e2SCy Schubert osf) 9160*b50261e2SCy Schubert func_arith $current - $age 9161*b50261e2SCy Schubert major=.$func_arith_result 9162*b50261e2SCy Schubert versuffix=.$current.$age.$revision 9163*b50261e2SCy Schubert verstring=$current.$age.$revision 9164*b50261e2SCy Schubert 9165*b50261e2SCy Schubert # Add in all the interfaces that we are compatible with. 9166*b50261e2SCy Schubert loop=$age 9167*b50261e2SCy Schubert while test 0 -ne "$loop"; do 9168*b50261e2SCy Schubert func_arith $current - $loop 9169*b50261e2SCy Schubert iface=$func_arith_result 9170*b50261e2SCy Schubert func_arith $loop - 1 9171*b50261e2SCy Schubert loop=$func_arith_result 9172*b50261e2SCy Schubert verstring=$verstring:$iface.0 9173*b50261e2SCy Schubert done 9174*b50261e2SCy Schubert 9175*b50261e2SCy Schubert # Make executables depend on our current version. 9176*b50261e2SCy Schubert func_append verstring ":$current.0" 9177*b50261e2SCy Schubert ;; 9178*b50261e2SCy Schubert 9179*b50261e2SCy Schubert qnx) 9180*b50261e2SCy Schubert major=.$current 9181*b50261e2SCy Schubert versuffix=.$current 9182*b50261e2SCy Schubert ;; 9183*b50261e2SCy Schubert 9184*b50261e2SCy Schubert sco) 9185*b50261e2SCy Schubert major=.$current 9186*b50261e2SCy Schubert versuffix=.$current 9187*b50261e2SCy Schubert ;; 9188*b50261e2SCy Schubert 9189*b50261e2SCy Schubert sunos) 9190*b50261e2SCy Schubert major=.$current 9191*b50261e2SCy Schubert versuffix=.$current.$revision 9192*b50261e2SCy Schubert ;; 9193*b50261e2SCy Schubert 9194*b50261e2SCy Schubert windows) 9195*b50261e2SCy Schubert # Use '-' rather than '.', since we only want one 9196*b50261e2SCy Schubert # extension on DOS 8.3 file systems. 9197*b50261e2SCy Schubert func_arith $current - $age 9198*b50261e2SCy Schubert major=$func_arith_result 9199*b50261e2SCy Schubert versuffix=-$major 9200*b50261e2SCy Schubert ;; 9201*b50261e2SCy Schubert 9202*b50261e2SCy Schubert *) 9203*b50261e2SCy Schubert func_fatal_configuration "unknown library version type '$version_type'" 9204*b50261e2SCy Schubert ;; 9205*b50261e2SCy Schubert esac 9206*b50261e2SCy Schubert 9207*b50261e2SCy Schubert # Clear the version info if we defaulted, and they specified a release. 9208*b50261e2SCy Schubert if test -z "$vinfo" && test -n "$release"; then 9209*b50261e2SCy Schubert major= 9210*b50261e2SCy Schubert case $version_type in 9211*b50261e2SCy Schubert darwin) 9212*b50261e2SCy Schubert # we can't check for "0.0" in archive_cmds due to quoting 9213*b50261e2SCy Schubert # problems, so we reset it completely 9214*b50261e2SCy Schubert verstring= 9215*b50261e2SCy Schubert ;; 9216*b50261e2SCy Schubert *) 9217*b50261e2SCy Schubert verstring=0.0 9218*b50261e2SCy Schubert ;; 9219*b50261e2SCy Schubert esac 9220*b50261e2SCy Schubert if test no = "$need_version"; then 9221*b50261e2SCy Schubert versuffix= 9222*b50261e2SCy Schubert else 9223*b50261e2SCy Schubert versuffix=.0.0 9224*b50261e2SCy Schubert fi 9225*b50261e2SCy Schubert fi 9226*b50261e2SCy Schubert 9227*b50261e2SCy Schubert # Remove version info from name if versioning should be avoided 9228*b50261e2SCy Schubert if test yes,no = "$avoid_version,$need_version"; then 9229*b50261e2SCy Schubert major= 9230*b50261e2SCy Schubert versuffix= 9231*b50261e2SCy Schubert verstring= 9232*b50261e2SCy Schubert fi 9233*b50261e2SCy Schubert 9234*b50261e2SCy Schubert # Check to see if the archive will have undefined symbols. 9235*b50261e2SCy Schubert if test yes = "$allow_undefined"; then 9236*b50261e2SCy Schubert if test unsupported = "$allow_undefined_flag"; then 9237*b50261e2SCy Schubert if test yes = "$build_old_libs"; then 9238*b50261e2SCy Schubert func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9239*b50261e2SCy Schubert build_libtool_libs=no 9240*b50261e2SCy Schubert else 9241*b50261e2SCy Schubert func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9242*b50261e2SCy Schubert fi 9243*b50261e2SCy Schubert fi 9244*b50261e2SCy Schubert else 9245*b50261e2SCy Schubert # Don't allow undefined symbols. 9246*b50261e2SCy Schubert allow_undefined_flag=$no_undefined_flag 9247*b50261e2SCy Schubert fi 9248*b50261e2SCy Schubert 9249*b50261e2SCy Schubert fi 9250*b50261e2SCy Schubert 9251*b50261e2SCy Schubert func_generate_dlsyms "$libname" "$libname" : 9252*b50261e2SCy Schubert func_append libobjs " $symfileobj" 9253*b50261e2SCy Schubert test " " = "$libobjs" && libobjs= 9254*b50261e2SCy Schubert 9255*b50261e2SCy Schubert if test relink != "$opt_mode"; then 9256*b50261e2SCy Schubert # Remove our outputs, but don't remove object files since they 9257*b50261e2SCy Schubert # may have been created when compiling PIC objects. 9258*b50261e2SCy Schubert removelist= 9259*b50261e2SCy Schubert tempremovelist=`$ECHO "$output_objdir/*"` 9260*b50261e2SCy Schubert for p in $tempremovelist; do 9261*b50261e2SCy Schubert case $p in 9262*b50261e2SCy Schubert *.$objext | *.gcno) 9263*b50261e2SCy Schubert ;; 9264*b50261e2SCy Schubert $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9265*b50261e2SCy Schubert if test -n "$precious_files_regex"; then 9266*b50261e2SCy Schubert if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9267*b50261e2SCy Schubert then 9268*b50261e2SCy Schubert continue 9269*b50261e2SCy Schubert fi 9270*b50261e2SCy Schubert fi 9271*b50261e2SCy Schubert func_append removelist " $p" 9272*b50261e2SCy Schubert ;; 9273*b50261e2SCy Schubert *) ;; 9274*b50261e2SCy Schubert esac 9275*b50261e2SCy Schubert done 9276*b50261e2SCy Schubert test -n "$removelist" && \ 9277*b50261e2SCy Schubert func_show_eval "${RM}r \$removelist" 9278*b50261e2SCy Schubert fi 9279*b50261e2SCy Schubert 9280*b50261e2SCy Schubert # Now set the variables for building old libraries. 9281*b50261e2SCy Schubert if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9282*b50261e2SCy Schubert func_append oldlibs " $output_objdir/$libname.$libext" 9283*b50261e2SCy Schubert 9284*b50261e2SCy Schubert # Transform .lo files to .o files. 9285*b50261e2SCy Schubert oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9286*b50261e2SCy Schubert fi 9287*b50261e2SCy Schubert 9288*b50261e2SCy Schubert # Eliminate all temporary directories. 9289*b50261e2SCy Schubert #for path in $notinst_path; do 9290*b50261e2SCy Schubert # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9291*b50261e2SCy Schubert # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9292*b50261e2SCy Schubert # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9293*b50261e2SCy Schubert #done 9294*b50261e2SCy Schubert 9295*b50261e2SCy Schubert if test -n "$xrpath"; then 9296*b50261e2SCy Schubert # If the user specified any rpath flags, then add them. 9297*b50261e2SCy Schubert temp_xrpath= 9298*b50261e2SCy Schubert for libdir in $xrpath; do 9299*b50261e2SCy Schubert func_replace_sysroot "$libdir" 9300*b50261e2SCy Schubert func_append temp_xrpath " -R$func_replace_sysroot_result" 9301*b50261e2SCy Schubert case "$finalize_rpath " in 9302*b50261e2SCy Schubert *" $libdir "*) ;; 9303*b50261e2SCy Schubert *) func_append finalize_rpath " $libdir" ;; 9304*b50261e2SCy Schubert esac 9305*b50261e2SCy Schubert done 9306*b50261e2SCy Schubert if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9307*b50261e2SCy Schubert dependency_libs="$temp_xrpath $dependency_libs" 9308*b50261e2SCy Schubert fi 9309*b50261e2SCy Schubert fi 9310*b50261e2SCy Schubert 9311*b50261e2SCy Schubert # Make sure dlfiles contains only unique files that won't be dlpreopened 9312*b50261e2SCy Schubert old_dlfiles=$dlfiles 9313*b50261e2SCy Schubert dlfiles= 9314*b50261e2SCy Schubert for lib in $old_dlfiles; do 9315*b50261e2SCy Schubert case " $dlprefiles $dlfiles " in 9316*b50261e2SCy Schubert *" $lib "*) ;; 9317*b50261e2SCy Schubert *) func_append dlfiles " $lib" ;; 9318*b50261e2SCy Schubert esac 9319*b50261e2SCy Schubert done 9320*b50261e2SCy Schubert 9321*b50261e2SCy Schubert # Make sure dlprefiles contains only unique files 9322*b50261e2SCy Schubert old_dlprefiles=$dlprefiles 9323*b50261e2SCy Schubert dlprefiles= 9324*b50261e2SCy Schubert for lib in $old_dlprefiles; do 9325*b50261e2SCy Schubert case "$dlprefiles " in 9326*b50261e2SCy Schubert *" $lib "*) ;; 9327*b50261e2SCy Schubert *) func_append dlprefiles " $lib" ;; 9328*b50261e2SCy Schubert esac 9329*b50261e2SCy Schubert done 9330*b50261e2SCy Schubert 9331*b50261e2SCy Schubert if test yes = "$build_libtool_libs"; then 9332*b50261e2SCy Schubert if test -n "$rpath"; then 9333*b50261e2SCy Schubert case $host in 9334*b50261e2SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9335*b50261e2SCy Schubert # these systems don't actually have a c library (as such)! 9336*b50261e2SCy Schubert ;; 9337*b50261e2SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 9338*b50261e2SCy Schubert # Rhapsody C library is in the System framework 9339*b50261e2SCy Schubert func_append deplibs " System.ltframework" 9340*b50261e2SCy Schubert ;; 9341*b50261e2SCy Schubert *-*-netbsd*) 9342*b50261e2SCy Schubert # Don't link with libc until the a.out ld.so is fixed. 9343*b50261e2SCy Schubert ;; 9344*b50261e2SCy Schubert *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9345*b50261e2SCy Schubert # Do not include libc due to us having libc/libc_r. 9346*b50261e2SCy Schubert ;; 9347*b50261e2SCy Schubert *-*-sco3.2v5* | *-*-sco5v6*) 9348*b50261e2SCy Schubert # Causes problems with __ctype 9349*b50261e2SCy Schubert ;; 9350*b50261e2SCy Schubert *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9351*b50261e2SCy Schubert # Compiler inserts libc in the correct place for threads to work 9352*b50261e2SCy Schubert ;; 9353*b50261e2SCy Schubert *) 9354*b50261e2SCy Schubert # Add libc to deplibs on all other systems if necessary. 9355*b50261e2SCy Schubert if test yes = "$build_libtool_need_lc"; then 9356*b50261e2SCy Schubert func_append deplibs " -lc" 9357*b50261e2SCy Schubert fi 9358*b50261e2SCy Schubert ;; 9359*b50261e2SCy Schubert esac 9360*b50261e2SCy Schubert fi 9361*b50261e2SCy Schubert 9362*b50261e2SCy Schubert # Transform deplibs into only deplibs that can be linked in shared. 9363*b50261e2SCy Schubert name_save=$name 9364*b50261e2SCy Schubert libname_save=$libname 9365*b50261e2SCy Schubert release_save=$release 9366*b50261e2SCy Schubert versuffix_save=$versuffix 9367*b50261e2SCy Schubert major_save=$major 9368*b50261e2SCy Schubert # I'm not sure if I'm treating the release correctly. I think 9369*b50261e2SCy Schubert # release should show up in the -l (ie -lgmp5) so we don't want to 9370*b50261e2SCy Schubert # add it in twice. Is that correct? 9371*b50261e2SCy Schubert release= 9372*b50261e2SCy Schubert versuffix= 9373*b50261e2SCy Schubert major= 9374*b50261e2SCy Schubert newdeplibs= 9375*b50261e2SCy Schubert droppeddeps=no 9376*b50261e2SCy Schubert case $deplibs_check_method in 9377*b50261e2SCy Schubert pass_all) 9378*b50261e2SCy Schubert # Don't check for shared/static. Everything works. 9379*b50261e2SCy Schubert # This might be a little naive. We might want to check 9380*b50261e2SCy Schubert # whether the library exists or not. But this is on 9381*b50261e2SCy Schubert # osf3 & osf4 and I'm not really sure... Just 9382*b50261e2SCy Schubert # implementing what was already the behavior. 9383*b50261e2SCy Schubert newdeplibs=$deplibs 9384*b50261e2SCy Schubert ;; 9385*b50261e2SCy Schubert test_compile) 9386*b50261e2SCy Schubert # This code stresses the "libraries are programs" paradigm to its 9387*b50261e2SCy Schubert # limits. Maybe even breaks it. We compile a program, linking it 9388*b50261e2SCy Schubert # against the deplibs as a proxy for the library. Then we can check 9389*b50261e2SCy Schubert # whether they linked in statically or dynamically with ldd. 9390*b50261e2SCy Schubert $opt_dry_run || $RM conftest.c 9391*b50261e2SCy Schubert cat > conftest.c <<EOF 9392*b50261e2SCy Schubert int main() { return 0; } 9393*b50261e2SCy SchubertEOF 9394*b50261e2SCy Schubert $opt_dry_run || $RM conftest 9395*b50261e2SCy Schubert if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9396*b50261e2SCy Schubert ldd_output=`ldd conftest` 9397*b50261e2SCy Schubert for i in $deplibs; do 9398*b50261e2SCy Schubert case $i in 9399*b50261e2SCy Schubert -l*) 9400*b50261e2SCy Schubert func_stripname -l '' "$i" 9401*b50261e2SCy Schubert name=$func_stripname_result 9402*b50261e2SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9403*b50261e2SCy Schubert case " $predeps $postdeps " in 9404*b50261e2SCy Schubert *" $i "*) 9405*b50261e2SCy Schubert func_append newdeplibs " $i" 9406*b50261e2SCy Schubert i= 9407*b50261e2SCy Schubert ;; 9408*b50261e2SCy Schubert esac 9409*b50261e2SCy Schubert fi 9410*b50261e2SCy Schubert if test -n "$i"; then 9411*b50261e2SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9412*b50261e2SCy Schubert deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9413*b50261e2SCy Schubert set dummy $deplib_matches; shift 9414*b50261e2SCy Schubert deplib_match=$1 9415*b50261e2SCy Schubert if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9416*b50261e2SCy Schubert func_append newdeplibs " $i" 9417*b50261e2SCy Schubert else 9418*b50261e2SCy Schubert droppeddeps=yes 9419*b50261e2SCy Schubert echo 9420*b50261e2SCy Schubert $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9421*b50261e2SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9422*b50261e2SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9423*b50261e2SCy Schubert echo "*** shared version of the library, which I believe you do not have" 9424*b50261e2SCy Schubert echo "*** because a test_compile did reveal that the linker did not use it for" 9425*b50261e2SCy Schubert echo "*** its dynamic dependency list that programs get resolved with at runtime." 9426*b50261e2SCy Schubert fi 9427*b50261e2SCy Schubert fi 9428*b50261e2SCy Schubert ;; 9429*b50261e2SCy Schubert *) 9430*b50261e2SCy Schubert func_append newdeplibs " $i" 9431*b50261e2SCy Schubert ;; 9432*b50261e2SCy Schubert esac 9433*b50261e2SCy Schubert done 9434*b50261e2SCy Schubert else 9435*b50261e2SCy Schubert # Error occurred in the first compile. Let's try to salvage 9436*b50261e2SCy Schubert # the situation: Compile a separate program for each library. 9437*b50261e2SCy Schubert for i in $deplibs; do 9438*b50261e2SCy Schubert case $i in 9439*b50261e2SCy Schubert -l*) 9440*b50261e2SCy Schubert func_stripname -l '' "$i" 9441*b50261e2SCy Schubert name=$func_stripname_result 9442*b50261e2SCy Schubert $opt_dry_run || $RM conftest 9443*b50261e2SCy Schubert if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9444*b50261e2SCy Schubert ldd_output=`ldd conftest` 9445*b50261e2SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9446*b50261e2SCy Schubert case " $predeps $postdeps " in 9447*b50261e2SCy Schubert *" $i "*) 9448*b50261e2SCy Schubert func_append newdeplibs " $i" 9449*b50261e2SCy Schubert i= 9450*b50261e2SCy Schubert ;; 9451*b50261e2SCy Schubert esac 9452*b50261e2SCy Schubert fi 9453*b50261e2SCy Schubert if test -n "$i"; then 9454*b50261e2SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9455*b50261e2SCy Schubert deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9456*b50261e2SCy Schubert set dummy $deplib_matches; shift 9457*b50261e2SCy Schubert deplib_match=$1 9458*b50261e2SCy Schubert if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9459*b50261e2SCy Schubert func_append newdeplibs " $i" 9460*b50261e2SCy Schubert else 9461*b50261e2SCy Schubert droppeddeps=yes 9462*b50261e2SCy Schubert echo 9463*b50261e2SCy Schubert $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9464*b50261e2SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9465*b50261e2SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9466*b50261e2SCy Schubert echo "*** shared version of the library, which you do not appear to have" 9467*b50261e2SCy Schubert echo "*** because a test_compile did reveal that the linker did not use this one" 9468*b50261e2SCy Schubert echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9469*b50261e2SCy Schubert fi 9470*b50261e2SCy Schubert fi 9471*b50261e2SCy Schubert else 9472*b50261e2SCy Schubert droppeddeps=yes 9473*b50261e2SCy Schubert echo 9474*b50261e2SCy Schubert $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9475*b50261e2SCy Schubert echo "*** make it link in! You will probably need to install it or some" 9476*b50261e2SCy Schubert echo "*** library that it depends on before this library will be fully" 9477*b50261e2SCy Schubert echo "*** functional. Installing it before continuing would be even better." 9478*b50261e2SCy Schubert fi 9479*b50261e2SCy Schubert ;; 9480*b50261e2SCy Schubert *) 9481*b50261e2SCy Schubert func_append newdeplibs " $i" 9482*b50261e2SCy Schubert ;; 9483*b50261e2SCy Schubert esac 9484*b50261e2SCy Schubert done 9485*b50261e2SCy Schubert fi 9486*b50261e2SCy Schubert ;; 9487*b50261e2SCy Schubert file_magic*) 9488*b50261e2SCy Schubert set dummy $deplibs_check_method; shift 9489*b50261e2SCy Schubert file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9490*b50261e2SCy Schubert for a_deplib in $deplibs; do 9491*b50261e2SCy Schubert case $a_deplib in 9492*b50261e2SCy Schubert -l*) 9493*b50261e2SCy Schubert func_stripname -l '' "$a_deplib" 9494*b50261e2SCy Schubert name=$func_stripname_result 9495*b50261e2SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9496*b50261e2SCy Schubert case " $predeps $postdeps " in 9497*b50261e2SCy Schubert *" $a_deplib "*) 9498*b50261e2SCy Schubert func_append newdeplibs " $a_deplib" 9499*b50261e2SCy Schubert a_deplib= 9500*b50261e2SCy Schubert ;; 9501*b50261e2SCy Schubert esac 9502*b50261e2SCy Schubert fi 9503*b50261e2SCy Schubert if test -n "$a_deplib"; then 9504*b50261e2SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9505*b50261e2SCy Schubert if test -n "$file_magic_glob"; then 9506*b50261e2SCy Schubert libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9507*b50261e2SCy Schubert else 9508*b50261e2SCy Schubert libnameglob=$libname 9509*b50261e2SCy Schubert fi 9510*b50261e2SCy Schubert test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9511*b50261e2SCy Schubert for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9512*b50261e2SCy Schubert if test yes = "$want_nocaseglob"; then 9513*b50261e2SCy Schubert shopt -s nocaseglob 9514*b50261e2SCy Schubert potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9515*b50261e2SCy Schubert $nocaseglob 9516*b50261e2SCy Schubert else 9517*b50261e2SCy Schubert potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9518*b50261e2SCy Schubert fi 9519*b50261e2SCy Schubert for potent_lib in $potential_libs; do 9520*b50261e2SCy Schubert # Follow soft links. 9521*b50261e2SCy Schubert if ls -lLd "$potent_lib" 2>/dev/null | 9522*b50261e2SCy Schubert $GREP " -> " >/dev/null; then 9523*b50261e2SCy Schubert continue 9524*b50261e2SCy Schubert fi 9525*b50261e2SCy Schubert # The statement above tries to avoid entering an 9526*b50261e2SCy Schubert # endless loop below, in case of cyclic links. 9527*b50261e2SCy Schubert # We might still enter an endless loop, since a link 9528*b50261e2SCy Schubert # loop can be closed while we follow links, 9529*b50261e2SCy Schubert # but so what? 9530*b50261e2SCy Schubert potlib=$potent_lib 9531*b50261e2SCy Schubert while test -h "$potlib" 2>/dev/null; do 9532*b50261e2SCy Schubert potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9533*b50261e2SCy Schubert case $potliblink in 9534*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9535*b50261e2SCy Schubert *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9536*b50261e2SCy Schubert esac 9537*b50261e2SCy Schubert done 9538*b50261e2SCy Schubert if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9539*b50261e2SCy Schubert $SED -e 10q | 9540*b50261e2SCy Schubert $EGREP "$file_magic_regex" > /dev/null; then 9541*b50261e2SCy Schubert func_append newdeplibs " $a_deplib" 9542*b50261e2SCy Schubert a_deplib= 9543*b50261e2SCy Schubert break 2 9544*b50261e2SCy Schubert fi 9545*b50261e2SCy Schubert done 9546*b50261e2SCy Schubert done 9547*b50261e2SCy Schubert fi 9548*b50261e2SCy Schubert if test -n "$a_deplib"; then 9549*b50261e2SCy Schubert droppeddeps=yes 9550*b50261e2SCy Schubert echo 9551*b50261e2SCy Schubert $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9552*b50261e2SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9553*b50261e2SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9554*b50261e2SCy Schubert echo "*** shared version of the library, which you do not appear to have" 9555*b50261e2SCy Schubert echo "*** because I did check the linker path looking for a file starting" 9556*b50261e2SCy Schubert if test -z "$potlib"; then 9557*b50261e2SCy Schubert $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9558*b50261e2SCy Schubert else 9559*b50261e2SCy Schubert $ECHO "*** with $libname and none of the candidates passed a file format test" 9560*b50261e2SCy Schubert $ECHO "*** using a file magic. Last file checked: $potlib" 9561*b50261e2SCy Schubert fi 9562*b50261e2SCy Schubert fi 9563*b50261e2SCy Schubert ;; 9564*b50261e2SCy Schubert *) 9565*b50261e2SCy Schubert # Add a -L argument. 9566*b50261e2SCy Schubert func_append newdeplibs " $a_deplib" 9567*b50261e2SCy Schubert ;; 9568*b50261e2SCy Schubert esac 9569*b50261e2SCy Schubert done # Gone through all deplibs. 9570*b50261e2SCy Schubert ;; 9571*b50261e2SCy Schubert match_pattern*) 9572*b50261e2SCy Schubert set dummy $deplibs_check_method; shift 9573*b50261e2SCy Schubert match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9574*b50261e2SCy Schubert for a_deplib in $deplibs; do 9575*b50261e2SCy Schubert case $a_deplib in 9576*b50261e2SCy Schubert -l*) 9577*b50261e2SCy Schubert func_stripname -l '' "$a_deplib" 9578*b50261e2SCy Schubert name=$func_stripname_result 9579*b50261e2SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9580*b50261e2SCy Schubert case " $predeps $postdeps " in 9581*b50261e2SCy Schubert *" $a_deplib "*) 9582*b50261e2SCy Schubert func_append newdeplibs " $a_deplib" 9583*b50261e2SCy Schubert a_deplib= 9584*b50261e2SCy Schubert ;; 9585*b50261e2SCy Schubert esac 9586*b50261e2SCy Schubert fi 9587*b50261e2SCy Schubert if test -n "$a_deplib"; then 9588*b50261e2SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9589*b50261e2SCy Schubert for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9590*b50261e2SCy Schubert potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9591*b50261e2SCy Schubert for potent_lib in $potential_libs; do 9592*b50261e2SCy Schubert potlib=$potent_lib # see symlink-check above in file_magic test 9593*b50261e2SCy Schubert if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9594*b50261e2SCy Schubert $EGREP "$match_pattern_regex" > /dev/null; then 9595*b50261e2SCy Schubert func_append newdeplibs " $a_deplib" 9596*b50261e2SCy Schubert a_deplib= 9597*b50261e2SCy Schubert break 2 9598*b50261e2SCy Schubert fi 9599*b50261e2SCy Schubert done 9600*b50261e2SCy Schubert done 9601*b50261e2SCy Schubert fi 9602*b50261e2SCy Schubert if test -n "$a_deplib"; then 9603*b50261e2SCy Schubert droppeddeps=yes 9604*b50261e2SCy Schubert echo 9605*b50261e2SCy Schubert $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9606*b50261e2SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9607*b50261e2SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9608*b50261e2SCy Schubert echo "*** shared version of the library, which you do not appear to have" 9609*b50261e2SCy Schubert echo "*** because I did check the linker path looking for a file starting" 9610*b50261e2SCy Schubert if test -z "$potlib"; then 9611*b50261e2SCy Schubert $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9612*b50261e2SCy Schubert else 9613*b50261e2SCy Schubert $ECHO "*** with $libname and none of the candidates passed a file format test" 9614*b50261e2SCy Schubert $ECHO "*** using a regex pattern. Last file checked: $potlib" 9615*b50261e2SCy Schubert fi 9616*b50261e2SCy Schubert fi 9617*b50261e2SCy Schubert ;; 9618*b50261e2SCy Schubert *) 9619*b50261e2SCy Schubert # Add a -L argument. 9620*b50261e2SCy Schubert func_append newdeplibs " $a_deplib" 9621*b50261e2SCy Schubert ;; 9622*b50261e2SCy Schubert esac 9623*b50261e2SCy Schubert done # Gone through all deplibs. 9624*b50261e2SCy Schubert ;; 9625*b50261e2SCy Schubert none | unknown | *) 9626*b50261e2SCy Schubert newdeplibs= 9627*b50261e2SCy Schubert tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9628*b50261e2SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9629*b50261e2SCy Schubert for i in $predeps $postdeps; do 9630*b50261e2SCy Schubert # can't use Xsed below, because $i might contain '/' 9631*b50261e2SCy Schubert tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9632*b50261e2SCy Schubert done 9633*b50261e2SCy Schubert fi 9634*b50261e2SCy Schubert case $tmp_deplibs in 9635*b50261e2SCy Schubert *[!\ \ ]*) 9636*b50261e2SCy Schubert echo 9637*b50261e2SCy Schubert if test none = "$deplibs_check_method"; then 9638*b50261e2SCy Schubert echo "*** Warning: inter-library dependencies are not supported in this platform." 9639*b50261e2SCy Schubert else 9640*b50261e2SCy Schubert echo "*** Warning: inter-library dependencies are not known to be supported." 9641*b50261e2SCy Schubert fi 9642*b50261e2SCy Schubert echo "*** All declared inter-library dependencies are being dropped." 9643*b50261e2SCy Schubert droppeddeps=yes 9644*b50261e2SCy Schubert ;; 9645*b50261e2SCy Schubert esac 9646*b50261e2SCy Schubert ;; 9647*b50261e2SCy Schubert esac 9648*b50261e2SCy Schubert versuffix=$versuffix_save 9649*b50261e2SCy Schubert major=$major_save 9650*b50261e2SCy Schubert release=$release_save 9651*b50261e2SCy Schubert libname=$libname_save 9652*b50261e2SCy Schubert name=$name_save 9653*b50261e2SCy Schubert 9654*b50261e2SCy Schubert case $host in 9655*b50261e2SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 9656*b50261e2SCy Schubert # On Rhapsody replace the C library with the System framework 9657*b50261e2SCy Schubert newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9658*b50261e2SCy Schubert ;; 9659*b50261e2SCy Schubert esac 9660*b50261e2SCy Schubert 9661*b50261e2SCy Schubert if test yes = "$droppeddeps"; then 9662*b50261e2SCy Schubert if test yes = "$module"; then 9663*b50261e2SCy Schubert echo 9664*b50261e2SCy Schubert echo "*** Warning: libtool could not satisfy all declared inter-library" 9665*b50261e2SCy Schubert $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9666*b50261e2SCy Schubert echo "*** a static module, that should work as long as the dlopening" 9667*b50261e2SCy Schubert echo "*** application is linked with the -dlopen flag." 9668*b50261e2SCy Schubert if test -z "$global_symbol_pipe"; then 9669*b50261e2SCy Schubert echo 9670*b50261e2SCy Schubert echo "*** However, this would only work if libtool was able to extract symbol" 9671*b50261e2SCy Schubert echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9672*b50261e2SCy Schubert echo "*** not find such a program. So, this module is probably useless." 9673*b50261e2SCy Schubert echo "*** 'nm' from GNU binutils and a full rebuild may help." 9674*b50261e2SCy Schubert fi 9675*b50261e2SCy Schubert if test no = "$build_old_libs"; then 9676*b50261e2SCy Schubert oldlibs=$output_objdir/$libname.$libext 9677*b50261e2SCy Schubert build_libtool_libs=module 9678*b50261e2SCy Schubert build_old_libs=yes 9679*b50261e2SCy Schubert else 9680*b50261e2SCy Schubert build_libtool_libs=no 9681*b50261e2SCy Schubert fi 9682*b50261e2SCy Schubert else 9683*b50261e2SCy Schubert echo "*** The inter-library dependencies that have been dropped here will be" 9684*b50261e2SCy Schubert echo "*** automatically added whenever a program is linked with this library" 9685*b50261e2SCy Schubert echo "*** or is declared to -dlopen it." 9686*b50261e2SCy Schubert 9687*b50261e2SCy Schubert if test no = "$allow_undefined"; then 9688*b50261e2SCy Schubert echo 9689*b50261e2SCy Schubert echo "*** Since this library must not contain undefined symbols," 9690*b50261e2SCy Schubert echo "*** because either the platform does not support them or" 9691*b50261e2SCy Schubert echo "*** it was explicitly requested with -no-undefined," 9692*b50261e2SCy Schubert echo "*** libtool will only create a static version of it." 9693*b50261e2SCy Schubert if test no = "$build_old_libs"; then 9694*b50261e2SCy Schubert oldlibs=$output_objdir/$libname.$libext 9695*b50261e2SCy Schubert build_libtool_libs=module 9696*b50261e2SCy Schubert build_old_libs=yes 9697*b50261e2SCy Schubert else 9698*b50261e2SCy Schubert build_libtool_libs=no 9699*b50261e2SCy Schubert fi 9700*b50261e2SCy Schubert fi 9701*b50261e2SCy Schubert fi 9702*b50261e2SCy Schubert fi 9703*b50261e2SCy Schubert # Done checking deplibs! 9704*b50261e2SCy Schubert deplibs=$newdeplibs 9705*b50261e2SCy Schubert fi 9706*b50261e2SCy Schubert # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9707*b50261e2SCy Schubert case $host in 9708*b50261e2SCy Schubert *-*-darwin*) 9709*b50261e2SCy Schubert newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9710*b50261e2SCy Schubert new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9711*b50261e2SCy Schubert deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9712*b50261e2SCy Schubert ;; 9713*b50261e2SCy Schubert esac 9714*b50261e2SCy Schubert 9715*b50261e2SCy Schubert # move library search paths that coincide with paths to not yet 9716*b50261e2SCy Schubert # installed libraries to the beginning of the library search list 9717*b50261e2SCy Schubert new_libs= 9718*b50261e2SCy Schubert for path in $notinst_path; do 9719*b50261e2SCy Schubert case " $new_libs " in 9720*b50261e2SCy Schubert *" -L$path/$objdir "*) ;; 9721*b50261e2SCy Schubert *) 9722*b50261e2SCy Schubert case " $deplibs " in 9723*b50261e2SCy Schubert *" -L$path/$objdir "*) 9724*b50261e2SCy Schubert func_append new_libs " -L$path/$objdir" ;; 9725*b50261e2SCy Schubert esac 9726*b50261e2SCy Schubert ;; 9727*b50261e2SCy Schubert esac 9728*b50261e2SCy Schubert done 9729*b50261e2SCy Schubert for deplib in $deplibs; do 9730*b50261e2SCy Schubert case $deplib in 9731*b50261e2SCy Schubert -L*) 9732*b50261e2SCy Schubert case " $new_libs " in 9733*b50261e2SCy Schubert *" $deplib "*) ;; 9734*b50261e2SCy Schubert *) func_append new_libs " $deplib" ;; 9735*b50261e2SCy Schubert esac 9736*b50261e2SCy Schubert ;; 9737*b50261e2SCy Schubert *) func_append new_libs " $deplib" ;; 9738*b50261e2SCy Schubert esac 9739*b50261e2SCy Schubert done 9740*b50261e2SCy Schubert deplibs=$new_libs 9741*b50261e2SCy Schubert 9742*b50261e2SCy Schubert # All the library-specific variables (install_libdir is set above). 9743*b50261e2SCy Schubert library_names= 9744*b50261e2SCy Schubert old_library= 9745*b50261e2SCy Schubert dlname= 9746*b50261e2SCy Schubert 9747*b50261e2SCy Schubert # Test again, we may have decided not to build it any more 9748*b50261e2SCy Schubert if test yes = "$build_libtool_libs"; then 9749*b50261e2SCy Schubert # Remove $wl instances when linking with ld. 9750*b50261e2SCy Schubert # FIXME: should test the right _cmds variable. 9751*b50261e2SCy Schubert case $archive_cmds in 9752*b50261e2SCy Schubert *\$LD\ *) wl= ;; 9753*b50261e2SCy Schubert esac 9754*b50261e2SCy Schubert if test yes = "$hardcode_into_libs"; then 9755*b50261e2SCy Schubert # Hardcode the library paths 9756*b50261e2SCy Schubert hardcode_libdirs= 9757*b50261e2SCy Schubert dep_rpath= 9758*b50261e2SCy Schubert rpath=$finalize_rpath 9759*b50261e2SCy Schubert test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9760*b50261e2SCy Schubert for libdir in $rpath; do 9761*b50261e2SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 9762*b50261e2SCy Schubert if test -n "$hardcode_libdir_separator"; then 9763*b50261e2SCy Schubert func_replace_sysroot "$libdir" 9764*b50261e2SCy Schubert libdir=$func_replace_sysroot_result 9765*b50261e2SCy Schubert if test -z "$hardcode_libdirs"; then 9766*b50261e2SCy Schubert hardcode_libdirs=$libdir 9767*b50261e2SCy Schubert else 9768*b50261e2SCy Schubert # Just accumulate the unique libdirs. 9769*b50261e2SCy Schubert case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9770*b50261e2SCy Schubert *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9771*b50261e2SCy Schubert ;; 9772*b50261e2SCy Schubert *) 9773*b50261e2SCy Schubert func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9774*b50261e2SCy Schubert ;; 9775*b50261e2SCy Schubert esac 9776*b50261e2SCy Schubert fi 9777*b50261e2SCy Schubert else 9778*b50261e2SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 9779*b50261e2SCy Schubert func_append dep_rpath " $flag" 9780*b50261e2SCy Schubert fi 9781*b50261e2SCy Schubert elif test -n "$runpath_var"; then 9782*b50261e2SCy Schubert case "$perm_rpath " in 9783*b50261e2SCy Schubert *" $libdir "*) ;; 9784*b50261e2SCy Schubert *) func_append perm_rpath " $libdir" ;; 9785*b50261e2SCy Schubert esac 9786*b50261e2SCy Schubert fi 9787*b50261e2SCy Schubert done 9788*b50261e2SCy Schubert # Substitute the hardcoded libdirs into the rpath. 9789*b50261e2SCy Schubert if test -n "$hardcode_libdir_separator" && 9790*b50261e2SCy Schubert test -n "$hardcode_libdirs"; then 9791*b50261e2SCy Schubert libdir=$hardcode_libdirs 9792*b50261e2SCy Schubert eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9793*b50261e2SCy Schubert fi 9794*b50261e2SCy Schubert if test -n "$runpath_var" && test -n "$perm_rpath"; then 9795*b50261e2SCy Schubert # We should set the runpath_var. 9796*b50261e2SCy Schubert rpath= 9797*b50261e2SCy Schubert for dir in $perm_rpath; do 9798*b50261e2SCy Schubert func_append rpath "$dir:" 9799*b50261e2SCy Schubert done 9800*b50261e2SCy Schubert eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9801*b50261e2SCy Schubert fi 9802*b50261e2SCy Schubert test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9803*b50261e2SCy Schubert fi 9804*b50261e2SCy Schubert 9805*b50261e2SCy Schubert shlibpath=$finalize_shlibpath 9806*b50261e2SCy Schubert test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9807*b50261e2SCy Schubert if test -n "$shlibpath"; then 9808*b50261e2SCy Schubert eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9809*b50261e2SCy Schubert fi 9810*b50261e2SCy Schubert 9811*b50261e2SCy Schubert # Get the real and link names of the library. 9812*b50261e2SCy Schubert eval shared_ext=\"$shrext_cmds\" 9813*b50261e2SCy Schubert eval library_names=\"$library_names_spec\" 9814*b50261e2SCy Schubert set dummy $library_names 9815*b50261e2SCy Schubert shift 9816*b50261e2SCy Schubert realname=$1 9817*b50261e2SCy Schubert shift 9818*b50261e2SCy Schubert 9819*b50261e2SCy Schubert if test -n "$soname_spec"; then 9820*b50261e2SCy Schubert eval soname=\"$soname_spec\" 9821*b50261e2SCy Schubert else 9822*b50261e2SCy Schubert soname=$realname 9823*b50261e2SCy Schubert fi 9824*b50261e2SCy Schubert if test -z "$dlname"; then 9825*b50261e2SCy Schubert dlname=$soname 9826*b50261e2SCy Schubert fi 9827*b50261e2SCy Schubert 9828*b50261e2SCy Schubert lib=$output_objdir/$realname 9829*b50261e2SCy Schubert linknames= 9830*b50261e2SCy Schubert for link 9831*b50261e2SCy Schubert do 9832*b50261e2SCy Schubert func_append linknames " $link" 9833*b50261e2SCy Schubert done 9834*b50261e2SCy Schubert 9835*b50261e2SCy Schubert # Use standard objects if they are pic 9836*b50261e2SCy Schubert test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9837*b50261e2SCy Schubert test "X$libobjs" = "X " && libobjs= 9838*b50261e2SCy Schubert 9839*b50261e2SCy Schubert delfiles= 9840*b50261e2SCy Schubert if test -n "$export_symbols" && test -n "$include_expsyms"; then 9841*b50261e2SCy Schubert $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9842*b50261e2SCy Schubert export_symbols=$output_objdir/$libname.uexp 9843*b50261e2SCy Schubert func_append delfiles " $export_symbols" 9844*b50261e2SCy Schubert fi 9845*b50261e2SCy Schubert 9846*b50261e2SCy Schubert orig_export_symbols= 9847*b50261e2SCy Schubert case $host_os in 9848*b50261e2SCy Schubert cygwin* | mingw* | cegcc*) 9849*b50261e2SCy Schubert if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9850*b50261e2SCy Schubert # exporting using user supplied symfile 9851*b50261e2SCy Schubert func_dll_def_p "$export_symbols" || { 9852*b50261e2SCy Schubert # and it's NOT already a .def file. Must figure out 9853*b50261e2SCy Schubert # which of the given symbols are data symbols and tag 9854*b50261e2SCy Schubert # them as such. So, trigger use of export_symbols_cmds. 9855*b50261e2SCy Schubert # export_symbols gets reassigned inside the "prepare 9856*b50261e2SCy Schubert # the list of exported symbols" if statement, so the 9857*b50261e2SCy Schubert # include_expsyms logic still works. 9858*b50261e2SCy Schubert orig_export_symbols=$export_symbols 9859*b50261e2SCy Schubert export_symbols= 9860*b50261e2SCy Schubert always_export_symbols=yes 9861*b50261e2SCy Schubert } 9862*b50261e2SCy Schubert fi 9863*b50261e2SCy Schubert ;; 9864*b50261e2SCy Schubert esac 9865*b50261e2SCy Schubert 9866*b50261e2SCy Schubert # Prepare the list of exported symbols 9867*b50261e2SCy Schubert if test -z "$export_symbols"; then 9868*b50261e2SCy Schubert if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9869*b50261e2SCy Schubert func_verbose "generating symbol list for '$libname.la'" 9870*b50261e2SCy Schubert export_symbols=$output_objdir/$libname.exp 9871*b50261e2SCy Schubert $opt_dry_run || $RM $export_symbols 9872*b50261e2SCy Schubert cmds=$export_symbols_cmds 9873*b50261e2SCy Schubert save_ifs=$IFS; IFS='~' 9874*b50261e2SCy Schubert for cmd1 in $cmds; do 9875*b50261e2SCy Schubert IFS=$save_ifs 9876*b50261e2SCy Schubert # Take the normal branch if the nm_file_list_spec branch 9877*b50261e2SCy Schubert # doesn't work or if tool conversion is not needed. 9878*b50261e2SCy Schubert case $nm_file_list_spec~$to_tool_file_cmd in 9879*b50261e2SCy Schubert *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9880*b50261e2SCy Schubert try_normal_branch=yes 9881*b50261e2SCy Schubert eval cmd=\"$cmd1\" 9882*b50261e2SCy Schubert func_len " $cmd" 9883*b50261e2SCy Schubert len=$func_len_result 9884*b50261e2SCy Schubert ;; 9885*b50261e2SCy Schubert *) 9886*b50261e2SCy Schubert try_normal_branch=no 9887*b50261e2SCy Schubert ;; 9888*b50261e2SCy Schubert esac 9889*b50261e2SCy Schubert if test yes = "$try_normal_branch" \ 9890*b50261e2SCy Schubert && { test "$len" -lt "$max_cmd_len" \ 9891*b50261e2SCy Schubert || test "$max_cmd_len" -le -1; } 9892*b50261e2SCy Schubert then 9893*b50261e2SCy Schubert func_show_eval "$cmd" 'exit $?' 9894*b50261e2SCy Schubert skipped_export=false 9895*b50261e2SCy Schubert elif test -n "$nm_file_list_spec"; then 9896*b50261e2SCy Schubert func_basename "$output" 9897*b50261e2SCy Schubert output_la=$func_basename_result 9898*b50261e2SCy Schubert save_libobjs=$libobjs 9899*b50261e2SCy Schubert save_output=$output 9900*b50261e2SCy Schubert output=$output_objdir/$output_la.nm 9901*b50261e2SCy Schubert func_to_tool_file "$output" 9902*b50261e2SCy Schubert libobjs=$nm_file_list_spec$func_to_tool_file_result 9903*b50261e2SCy Schubert func_append delfiles " $output" 9904*b50261e2SCy Schubert func_verbose "creating $NM input file list: $output" 9905*b50261e2SCy Schubert for obj in $save_libobjs; do 9906*b50261e2SCy Schubert func_to_tool_file "$obj" 9907*b50261e2SCy Schubert $ECHO "$func_to_tool_file_result" 9908*b50261e2SCy Schubert done > "$output" 9909*b50261e2SCy Schubert eval cmd=\"$cmd1\" 9910*b50261e2SCy Schubert func_show_eval "$cmd" 'exit $?' 9911*b50261e2SCy Schubert output=$save_output 9912*b50261e2SCy Schubert libobjs=$save_libobjs 9913*b50261e2SCy Schubert skipped_export=false 9914*b50261e2SCy Schubert else 9915*b50261e2SCy Schubert # The command line is too long to execute in one step. 9916*b50261e2SCy Schubert func_verbose "using reloadable object file for export list..." 9917*b50261e2SCy Schubert skipped_export=: 9918*b50261e2SCy Schubert # Break out early, otherwise skipped_export may be 9919*b50261e2SCy Schubert # set to false by a later but shorter cmd. 9920*b50261e2SCy Schubert break 9921*b50261e2SCy Schubert fi 9922*b50261e2SCy Schubert done 9923*b50261e2SCy Schubert IFS=$save_ifs 9924*b50261e2SCy Schubert if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9925*b50261e2SCy Schubert func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9926*b50261e2SCy Schubert func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9927*b50261e2SCy Schubert fi 9928*b50261e2SCy Schubert fi 9929*b50261e2SCy Schubert fi 9930*b50261e2SCy Schubert 9931*b50261e2SCy Schubert if test -n "$export_symbols" && test -n "$include_expsyms"; then 9932*b50261e2SCy Schubert tmp_export_symbols=$export_symbols 9933*b50261e2SCy Schubert test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9934*b50261e2SCy Schubert $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9935*b50261e2SCy Schubert fi 9936*b50261e2SCy Schubert 9937*b50261e2SCy Schubert if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9938*b50261e2SCy Schubert # The given exports_symbols file has to be filtered, so filter it. 9939*b50261e2SCy Schubert func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9940*b50261e2SCy Schubert # FIXME: $output_objdir/$libname.filter potentially contains lots of 9941*b50261e2SCy Schubert # 's' commands, which not all seds can handle. GNU sed should be fine 9942*b50261e2SCy Schubert # though. Also, the filter scales superlinearly with the number of 9943*b50261e2SCy Schubert # global variables. join(1) would be nice here, but unfortunately 9944*b50261e2SCy Schubert # isn't a blessed tool. 9945*b50261e2SCy Schubert $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9946*b50261e2SCy Schubert func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9947*b50261e2SCy Schubert export_symbols=$output_objdir/$libname.def 9948*b50261e2SCy Schubert $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9949*b50261e2SCy Schubert fi 9950*b50261e2SCy Schubert 9951*b50261e2SCy Schubert tmp_deplibs= 9952*b50261e2SCy Schubert for test_deplib in $deplibs; do 9953*b50261e2SCy Schubert case " $convenience " in 9954*b50261e2SCy Schubert *" $test_deplib "*) ;; 9955*b50261e2SCy Schubert *) 9956*b50261e2SCy Schubert func_append tmp_deplibs " $test_deplib" 9957*b50261e2SCy Schubert ;; 9958*b50261e2SCy Schubert esac 9959*b50261e2SCy Schubert done 9960*b50261e2SCy Schubert deplibs=$tmp_deplibs 9961*b50261e2SCy Schubert 9962*b50261e2SCy Schubert if test -n "$convenience"; then 9963*b50261e2SCy Schubert if test -n "$whole_archive_flag_spec" && 9964*b50261e2SCy Schubert test yes = "$compiler_needs_object" && 9965*b50261e2SCy Schubert test -z "$libobjs"; then 9966*b50261e2SCy Schubert # extract the archives, so we have objects to list. 9967*b50261e2SCy Schubert # TODO: could optimize this to just extract one archive. 9968*b50261e2SCy Schubert whole_archive_flag_spec= 9969*b50261e2SCy Schubert fi 9970*b50261e2SCy Schubert if test -n "$whole_archive_flag_spec"; then 9971*b50261e2SCy Schubert save_libobjs=$libobjs 9972*b50261e2SCy Schubert eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9973*b50261e2SCy Schubert test "X$libobjs" = "X " && libobjs= 9974*b50261e2SCy Schubert else 9975*b50261e2SCy Schubert gentop=$output_objdir/${outputname}x 9976*b50261e2SCy Schubert func_append generated " $gentop" 9977*b50261e2SCy Schubert 9978*b50261e2SCy Schubert func_extract_archives $gentop $convenience 9979*b50261e2SCy Schubert func_append libobjs " $func_extract_archives_result" 9980*b50261e2SCy Schubert test "X$libobjs" = "X " && libobjs= 9981*b50261e2SCy Schubert fi 9982*b50261e2SCy Schubert fi 9983*b50261e2SCy Schubert 9984*b50261e2SCy Schubert if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9985*b50261e2SCy Schubert eval flag=\"$thread_safe_flag_spec\" 9986*b50261e2SCy Schubert func_append linker_flags " $flag" 9987*b50261e2SCy Schubert fi 9988*b50261e2SCy Schubert 9989*b50261e2SCy Schubert # Make a backup of the uninstalled library when relinking 9990*b50261e2SCy Schubert if test relink = "$opt_mode"; then 9991*b50261e2SCy Schubert $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9992*b50261e2SCy Schubert fi 9993*b50261e2SCy Schubert 9994*b50261e2SCy Schubert # Do each of the archive commands. 9995*b50261e2SCy Schubert if test yes = "$module" && test -n "$module_cmds"; then 9996*b50261e2SCy Schubert if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9997*b50261e2SCy Schubert eval test_cmds=\"$module_expsym_cmds\" 9998*b50261e2SCy Schubert cmds=$module_expsym_cmds 9999*b50261e2SCy Schubert else 10000*b50261e2SCy Schubert eval test_cmds=\"$module_cmds\" 10001*b50261e2SCy Schubert cmds=$module_cmds 10002*b50261e2SCy Schubert fi 10003*b50261e2SCy Schubert else 10004*b50261e2SCy Schubert if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10005*b50261e2SCy Schubert eval test_cmds=\"$archive_expsym_cmds\" 10006*b50261e2SCy Schubert cmds=$archive_expsym_cmds 10007*b50261e2SCy Schubert else 10008*b50261e2SCy Schubert eval test_cmds=\"$archive_cmds\" 10009*b50261e2SCy Schubert cmds=$archive_cmds 10010*b50261e2SCy Schubert fi 10011*b50261e2SCy Schubert fi 10012*b50261e2SCy Schubert 10013*b50261e2SCy Schubert if test : != "$skipped_export" && 10014*b50261e2SCy Schubert func_len " $test_cmds" && 10015*b50261e2SCy Schubert len=$func_len_result && 10016*b50261e2SCy Schubert test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10017*b50261e2SCy Schubert : 10018*b50261e2SCy Schubert else 10019*b50261e2SCy Schubert # The command line is too long to link in one step, link piecewise 10020*b50261e2SCy Schubert # or, if using GNU ld and skipped_export is not :, use a linker 10021*b50261e2SCy Schubert # script. 10022*b50261e2SCy Schubert 10023*b50261e2SCy Schubert # Save the value of $output and $libobjs because we want to 10024*b50261e2SCy Schubert # use them later. If we have whole_archive_flag_spec, we 10025*b50261e2SCy Schubert # want to use save_libobjs as it was before 10026*b50261e2SCy Schubert # whole_archive_flag_spec was expanded, because we can't 10027*b50261e2SCy Schubert # assume the linker understands whole_archive_flag_spec. 10028*b50261e2SCy Schubert # This may have to be revisited, in case too many 10029*b50261e2SCy Schubert # convenience libraries get linked in and end up exceeding 10030*b50261e2SCy Schubert # the spec. 10031*b50261e2SCy Schubert if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10032*b50261e2SCy Schubert save_libobjs=$libobjs 10033*b50261e2SCy Schubert fi 10034*b50261e2SCy Schubert save_output=$output 10035*b50261e2SCy Schubert func_basename "$output" 10036*b50261e2SCy Schubert output_la=$func_basename_result 10037*b50261e2SCy Schubert 10038*b50261e2SCy Schubert # Clear the reloadable object creation command queue and 10039*b50261e2SCy Schubert # initialize k to one. 10040*b50261e2SCy Schubert test_cmds= 10041*b50261e2SCy Schubert concat_cmds= 10042*b50261e2SCy Schubert objlist= 10043*b50261e2SCy Schubert last_robj= 10044*b50261e2SCy Schubert k=1 10045*b50261e2SCy Schubert 10046*b50261e2SCy Schubert if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10047*b50261e2SCy Schubert output=$output_objdir/$output_la.lnkscript 10048*b50261e2SCy Schubert func_verbose "creating GNU ld script: $output" 10049*b50261e2SCy Schubert echo 'INPUT (' > $output 10050*b50261e2SCy Schubert for obj in $save_libobjs 10051*b50261e2SCy Schubert do 10052*b50261e2SCy Schubert func_to_tool_file "$obj" 10053*b50261e2SCy Schubert $ECHO "$func_to_tool_file_result" >> $output 10054*b50261e2SCy Schubert done 10055*b50261e2SCy Schubert echo ')' >> $output 10056*b50261e2SCy Schubert func_append delfiles " $output" 10057*b50261e2SCy Schubert func_to_tool_file "$output" 10058*b50261e2SCy Schubert output=$func_to_tool_file_result 10059*b50261e2SCy Schubert elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10060*b50261e2SCy Schubert output=$output_objdir/$output_la.lnk 10061*b50261e2SCy Schubert func_verbose "creating linker input file list: $output" 10062*b50261e2SCy Schubert : > $output 10063*b50261e2SCy Schubert set x $save_libobjs 10064*b50261e2SCy Schubert shift 10065*b50261e2SCy Schubert firstobj= 10066*b50261e2SCy Schubert if test yes = "$compiler_needs_object"; then 10067*b50261e2SCy Schubert firstobj="$1 " 10068*b50261e2SCy Schubert shift 10069*b50261e2SCy Schubert fi 10070*b50261e2SCy Schubert for obj 10071*b50261e2SCy Schubert do 10072*b50261e2SCy Schubert func_to_tool_file "$obj" 10073*b50261e2SCy Schubert $ECHO "$func_to_tool_file_result" >> $output 10074*b50261e2SCy Schubert done 10075*b50261e2SCy Schubert func_append delfiles " $output" 10076*b50261e2SCy Schubert func_to_tool_file "$output" 10077*b50261e2SCy Schubert output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10078*b50261e2SCy Schubert else 10079*b50261e2SCy Schubert if test -n "$save_libobjs"; then 10080*b50261e2SCy Schubert func_verbose "creating reloadable object files..." 10081*b50261e2SCy Schubert output=$output_objdir/$output_la-$k.$objext 10082*b50261e2SCy Schubert eval test_cmds=\"$reload_cmds\" 10083*b50261e2SCy Schubert func_len " $test_cmds" 10084*b50261e2SCy Schubert len0=$func_len_result 10085*b50261e2SCy Schubert len=$len0 10086*b50261e2SCy Schubert 10087*b50261e2SCy Schubert # Loop over the list of objects to be linked. 10088*b50261e2SCy Schubert for obj in $save_libobjs 10089*b50261e2SCy Schubert do 10090*b50261e2SCy Schubert func_len " $obj" 10091*b50261e2SCy Schubert func_arith $len + $func_len_result 10092*b50261e2SCy Schubert len=$func_arith_result 10093*b50261e2SCy Schubert if test -z "$objlist" || 10094*b50261e2SCy Schubert test "$len" -lt "$max_cmd_len"; then 10095*b50261e2SCy Schubert func_append objlist " $obj" 10096*b50261e2SCy Schubert else 10097*b50261e2SCy Schubert # The command $test_cmds is almost too long, add a 10098*b50261e2SCy Schubert # command to the queue. 10099*b50261e2SCy Schubert if test 1 -eq "$k"; then 10100*b50261e2SCy Schubert # The first file doesn't have a previous command to add. 10101*b50261e2SCy Schubert reload_objs=$objlist 10102*b50261e2SCy Schubert eval concat_cmds=\"$reload_cmds\" 10103*b50261e2SCy Schubert else 10104*b50261e2SCy Schubert # All subsequent reloadable object files will link in 10105*b50261e2SCy Schubert # the last one created. 10106*b50261e2SCy Schubert reload_objs="$objlist $last_robj" 10107*b50261e2SCy Schubert eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10108*b50261e2SCy Schubert fi 10109*b50261e2SCy Schubert last_robj=$output_objdir/$output_la-$k.$objext 10110*b50261e2SCy Schubert func_arith $k + 1 10111*b50261e2SCy Schubert k=$func_arith_result 10112*b50261e2SCy Schubert output=$output_objdir/$output_la-$k.$objext 10113*b50261e2SCy Schubert objlist=" $obj" 10114*b50261e2SCy Schubert func_len " $last_robj" 10115*b50261e2SCy Schubert func_arith $len0 + $func_len_result 10116*b50261e2SCy Schubert len=$func_arith_result 10117*b50261e2SCy Schubert fi 10118*b50261e2SCy Schubert done 10119*b50261e2SCy Schubert # Handle the remaining objects by creating one last 10120*b50261e2SCy Schubert # reloadable object file. All subsequent reloadable object 10121*b50261e2SCy Schubert # files will link in the last one created. 10122*b50261e2SCy Schubert test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10123*b50261e2SCy Schubert reload_objs="$objlist $last_robj" 10124*b50261e2SCy Schubert eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10125*b50261e2SCy Schubert if test -n "$last_robj"; then 10126*b50261e2SCy Schubert eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10127*b50261e2SCy Schubert fi 10128*b50261e2SCy Schubert func_append delfiles " $output" 10129*b50261e2SCy Schubert 10130*b50261e2SCy Schubert else 10131*b50261e2SCy Schubert output= 10132*b50261e2SCy Schubert fi 10133*b50261e2SCy Schubert 10134*b50261e2SCy Schubert ${skipped_export-false} && { 10135*b50261e2SCy Schubert func_verbose "generating symbol list for '$libname.la'" 10136*b50261e2SCy Schubert export_symbols=$output_objdir/$libname.exp 10137*b50261e2SCy Schubert $opt_dry_run || $RM $export_symbols 10138*b50261e2SCy Schubert libobjs=$output 10139*b50261e2SCy Schubert # Append the command to create the export file. 10140*b50261e2SCy Schubert test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10141*b50261e2SCy Schubert eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10142*b50261e2SCy Schubert if test -n "$last_robj"; then 10143*b50261e2SCy Schubert eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10144*b50261e2SCy Schubert fi 10145*b50261e2SCy Schubert } 10146*b50261e2SCy Schubert 10147*b50261e2SCy Schubert test -n "$save_libobjs" && 10148*b50261e2SCy Schubert func_verbose "creating a temporary reloadable object file: $output" 10149*b50261e2SCy Schubert 10150*b50261e2SCy Schubert # Loop through the commands generated above and execute them. 10151*b50261e2SCy Schubert save_ifs=$IFS; IFS='~' 10152*b50261e2SCy Schubert for cmd in $concat_cmds; do 10153*b50261e2SCy Schubert IFS=$save_ifs 10154*b50261e2SCy Schubert $opt_quiet || { 10155*b50261e2SCy Schubert func_quote_arg expand,pretty "$cmd" 10156*b50261e2SCy Schubert eval "func_echo $func_quote_arg_result" 10157*b50261e2SCy Schubert } 10158*b50261e2SCy Schubert $opt_dry_run || eval "$cmd" || { 10159*b50261e2SCy Schubert lt_exit=$? 10160*b50261e2SCy Schubert 10161*b50261e2SCy Schubert # Restore the uninstalled library and exit 10162*b50261e2SCy Schubert if test relink = "$opt_mode"; then 10163*b50261e2SCy Schubert ( cd "$output_objdir" && \ 10164*b50261e2SCy Schubert $RM "${realname}T" && \ 10165*b50261e2SCy Schubert $MV "${realname}U" "$realname" ) 10166*b50261e2SCy Schubert fi 10167*b50261e2SCy Schubert 10168*b50261e2SCy Schubert exit $lt_exit 10169*b50261e2SCy Schubert } 10170*b50261e2SCy Schubert done 10171*b50261e2SCy Schubert IFS=$save_ifs 10172*b50261e2SCy Schubert 10173*b50261e2SCy Schubert if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10174*b50261e2SCy Schubert func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10175*b50261e2SCy Schubert func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10176*b50261e2SCy Schubert fi 10177*b50261e2SCy Schubert fi 10178*b50261e2SCy Schubert 10179*b50261e2SCy Schubert ${skipped_export-false} && { 10180*b50261e2SCy Schubert if test -n "$export_symbols" && test -n "$include_expsyms"; then 10181*b50261e2SCy Schubert tmp_export_symbols=$export_symbols 10182*b50261e2SCy Schubert test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10183*b50261e2SCy Schubert $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10184*b50261e2SCy Schubert fi 10185*b50261e2SCy Schubert 10186*b50261e2SCy Schubert if test -n "$orig_export_symbols"; then 10187*b50261e2SCy Schubert # The given exports_symbols file has to be filtered, so filter it. 10188*b50261e2SCy Schubert func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10189*b50261e2SCy Schubert # FIXME: $output_objdir/$libname.filter potentially contains lots of 10190*b50261e2SCy Schubert # 's' commands, which not all seds can handle. GNU sed should be fine 10191*b50261e2SCy Schubert # though. Also, the filter scales superlinearly with the number of 10192*b50261e2SCy Schubert # global variables. join(1) would be nice here, but unfortunately 10193*b50261e2SCy Schubert # isn't a blessed tool. 10194*b50261e2SCy Schubert $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10195*b50261e2SCy Schubert func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10196*b50261e2SCy Schubert export_symbols=$output_objdir/$libname.def 10197*b50261e2SCy Schubert $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10198*b50261e2SCy Schubert fi 10199*b50261e2SCy Schubert } 10200*b50261e2SCy Schubert 10201*b50261e2SCy Schubert libobjs=$output 10202*b50261e2SCy Schubert # Restore the value of output. 10203*b50261e2SCy Schubert output=$save_output 10204*b50261e2SCy Schubert 10205*b50261e2SCy Schubert if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10206*b50261e2SCy Schubert eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10207*b50261e2SCy Schubert test "X$libobjs" = "X " && libobjs= 10208*b50261e2SCy Schubert fi 10209*b50261e2SCy Schubert # Expand the library linking commands again to reset the 10210*b50261e2SCy Schubert # value of $libobjs for piecewise linking. 10211*b50261e2SCy Schubert 10212*b50261e2SCy Schubert # Do each of the archive commands. 10213*b50261e2SCy Schubert if test yes = "$module" && test -n "$module_cmds"; then 10214*b50261e2SCy Schubert if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10215*b50261e2SCy Schubert cmds=$module_expsym_cmds 10216*b50261e2SCy Schubert else 10217*b50261e2SCy Schubert cmds=$module_cmds 10218*b50261e2SCy Schubert fi 10219*b50261e2SCy Schubert else 10220*b50261e2SCy Schubert if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10221*b50261e2SCy Schubert cmds=$archive_expsym_cmds 10222*b50261e2SCy Schubert else 10223*b50261e2SCy Schubert cmds=$archive_cmds 10224*b50261e2SCy Schubert fi 10225*b50261e2SCy Schubert fi 10226*b50261e2SCy Schubert fi 10227*b50261e2SCy Schubert 10228*b50261e2SCy Schubert if test -n "$delfiles"; then 10229*b50261e2SCy Schubert # Append the command to remove temporary files to $cmds. 10230*b50261e2SCy Schubert eval cmds=\"\$cmds~\$RM $delfiles\" 10231*b50261e2SCy Schubert fi 10232*b50261e2SCy Schubert 10233*b50261e2SCy Schubert # Add any objects from preloaded convenience libraries 10234*b50261e2SCy Schubert if test -n "$dlprefiles"; then 10235*b50261e2SCy Schubert gentop=$output_objdir/${outputname}x 10236*b50261e2SCy Schubert func_append generated " $gentop" 10237*b50261e2SCy Schubert 10238*b50261e2SCy Schubert func_extract_archives $gentop $dlprefiles 10239*b50261e2SCy Schubert func_append libobjs " $func_extract_archives_result" 10240*b50261e2SCy Schubert test "X$libobjs" = "X " && libobjs= 10241*b50261e2SCy Schubert fi 10242*b50261e2SCy Schubert 10243*b50261e2SCy Schubert save_ifs=$IFS; IFS='~' 10244*b50261e2SCy Schubert for cmd in $cmds; do 10245*b50261e2SCy Schubert IFS=$sp$nl 10246*b50261e2SCy Schubert eval cmd=\"$cmd\" 10247*b50261e2SCy Schubert IFS=$save_ifs 10248*b50261e2SCy Schubert $opt_quiet || { 10249*b50261e2SCy Schubert func_quote_arg expand,pretty "$cmd" 10250*b50261e2SCy Schubert eval "func_echo $func_quote_arg_result" 10251*b50261e2SCy Schubert } 10252*b50261e2SCy Schubert $opt_dry_run || eval "$cmd" || { 10253*b50261e2SCy Schubert lt_exit=$? 10254*b50261e2SCy Schubert 10255*b50261e2SCy Schubert # Restore the uninstalled library and exit 10256*b50261e2SCy Schubert if test relink = "$opt_mode"; then 10257*b50261e2SCy Schubert ( cd "$output_objdir" && \ 10258*b50261e2SCy Schubert $RM "${realname}T" && \ 10259*b50261e2SCy Schubert $MV "${realname}U" "$realname" ) 10260*b50261e2SCy Schubert fi 10261*b50261e2SCy Schubert 10262*b50261e2SCy Schubert exit $lt_exit 10263*b50261e2SCy Schubert } 10264*b50261e2SCy Schubert done 10265*b50261e2SCy Schubert IFS=$save_ifs 10266*b50261e2SCy Schubert 10267*b50261e2SCy Schubert # Restore the uninstalled library and exit 10268*b50261e2SCy Schubert if test relink = "$opt_mode"; then 10269*b50261e2SCy Schubert $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10270*b50261e2SCy Schubert 10271*b50261e2SCy Schubert if test -n "$convenience"; then 10272*b50261e2SCy Schubert if test -z "$whole_archive_flag_spec"; then 10273*b50261e2SCy Schubert func_show_eval '${RM}r "$gentop"' 10274*b50261e2SCy Schubert fi 10275*b50261e2SCy Schubert fi 10276*b50261e2SCy Schubert 10277*b50261e2SCy Schubert exit $EXIT_SUCCESS 10278*b50261e2SCy Schubert fi 10279*b50261e2SCy Schubert 10280*b50261e2SCy Schubert # Create links to the real library. 10281*b50261e2SCy Schubert for linkname in $linknames; do 10282*b50261e2SCy Schubert if test "$realname" != "$linkname"; then 10283*b50261e2SCy Schubert func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10284*b50261e2SCy Schubert fi 10285*b50261e2SCy Schubert done 10286*b50261e2SCy Schubert 10287*b50261e2SCy Schubert # If -module or -export-dynamic was specified, set the dlname. 10288*b50261e2SCy Schubert if test yes = "$module" || test yes = "$export_dynamic"; then 10289*b50261e2SCy Schubert # On all known operating systems, these are identical. 10290*b50261e2SCy Schubert dlname=$soname 10291*b50261e2SCy Schubert fi 10292*b50261e2SCy Schubert fi 10293*b50261e2SCy Schubert ;; 10294*b50261e2SCy Schubert 10295*b50261e2SCy Schubert obj) 10296*b50261e2SCy Schubert if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10297*b50261e2SCy Schubert func_warning "'-dlopen' is ignored for objects" 10298*b50261e2SCy Schubert fi 10299*b50261e2SCy Schubert 10300*b50261e2SCy Schubert case " $deplibs" in 10301*b50261e2SCy Schubert *\ -l* | *\ -L*) 10302*b50261e2SCy Schubert func_warning "'-l' and '-L' are ignored for objects" ;; 10303*b50261e2SCy Schubert esac 10304*b50261e2SCy Schubert 10305*b50261e2SCy Schubert test -n "$rpath" && \ 10306*b50261e2SCy Schubert func_warning "'-rpath' is ignored for objects" 10307*b50261e2SCy Schubert 10308*b50261e2SCy Schubert test -n "$xrpath" && \ 10309*b50261e2SCy Schubert func_warning "'-R' is ignored for objects" 10310*b50261e2SCy Schubert 10311*b50261e2SCy Schubert test -n "$vinfo" && \ 10312*b50261e2SCy Schubert func_warning "'-version-info' is ignored for objects" 10313*b50261e2SCy Schubert 10314*b50261e2SCy Schubert test -n "$release" && \ 10315*b50261e2SCy Schubert func_warning "'-release' is ignored for objects" 10316*b50261e2SCy Schubert 10317*b50261e2SCy Schubert case $output in 10318*b50261e2SCy Schubert *.lo) 10319*b50261e2SCy Schubert test -n "$objs$old_deplibs" && \ 10320*b50261e2SCy Schubert func_fatal_error "cannot build library object '$output' from non-libtool objects" 10321*b50261e2SCy Schubert 10322*b50261e2SCy Schubert libobj=$output 10323*b50261e2SCy Schubert func_lo2o "$libobj" 10324*b50261e2SCy Schubert obj=$func_lo2o_result 10325*b50261e2SCy Schubert ;; 10326*b50261e2SCy Schubert *) 10327*b50261e2SCy Schubert libobj= 10328*b50261e2SCy Schubert obj=$output 10329*b50261e2SCy Schubert ;; 10330*b50261e2SCy Schubert esac 10331*b50261e2SCy Schubert 10332*b50261e2SCy Schubert # Delete the old objects. 10333*b50261e2SCy Schubert $opt_dry_run || $RM $obj $libobj 10334*b50261e2SCy Schubert 10335*b50261e2SCy Schubert # Objects from convenience libraries. This assumes 10336*b50261e2SCy Schubert # single-version convenience libraries. Whenever we create 10337*b50261e2SCy Schubert # different ones for PIC/non-PIC, this we'll have to duplicate 10338*b50261e2SCy Schubert # the extraction. 10339*b50261e2SCy Schubert reload_conv_objs= 10340*b50261e2SCy Schubert gentop= 10341*b50261e2SCy Schubert # if reload_cmds runs $LD directly, get rid of -Wl from 10342*b50261e2SCy Schubert # whole_archive_flag_spec and hope we can get by with turning comma 10343*b50261e2SCy Schubert # into space. 10344*b50261e2SCy Schubert case $reload_cmds in 10345*b50261e2SCy Schubert *\$LD[\ \$]*) wl= ;; 10346*b50261e2SCy Schubert esac 10347*b50261e2SCy Schubert if test -n "$convenience"; then 10348*b50261e2SCy Schubert if test -n "$whole_archive_flag_spec"; then 10349*b50261e2SCy Schubert eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10350*b50261e2SCy Schubert test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10351*b50261e2SCy Schubert reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10352*b50261e2SCy Schubert else 10353*b50261e2SCy Schubert gentop=$output_objdir/${obj}x 10354*b50261e2SCy Schubert func_append generated " $gentop" 10355*b50261e2SCy Schubert 10356*b50261e2SCy Schubert func_extract_archives $gentop $convenience 10357*b50261e2SCy Schubert reload_conv_objs="$reload_objs $func_extract_archives_result" 10358*b50261e2SCy Schubert fi 10359*b50261e2SCy Schubert fi 10360*b50261e2SCy Schubert 10361*b50261e2SCy Schubert # If we're not building shared, we need to use non_pic_objs 10362*b50261e2SCy Schubert test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10363*b50261e2SCy Schubert 10364*b50261e2SCy Schubert # Create the old-style object. 10365*b50261e2SCy Schubert reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10366*b50261e2SCy Schubert 10367*b50261e2SCy Schubert output=$obj 10368*b50261e2SCy Schubert func_execute_cmds "$reload_cmds" 'exit $?' 10369*b50261e2SCy Schubert 10370*b50261e2SCy Schubert # Exit if we aren't doing a library object file. 10371*b50261e2SCy Schubert if test -z "$libobj"; then 10372*b50261e2SCy Schubert if test -n "$gentop"; then 10373*b50261e2SCy Schubert func_show_eval '${RM}r "$gentop"' 10374*b50261e2SCy Schubert fi 10375*b50261e2SCy Schubert 10376*b50261e2SCy Schubert exit $EXIT_SUCCESS 10377*b50261e2SCy Schubert fi 10378*b50261e2SCy Schubert 10379*b50261e2SCy Schubert test yes = "$build_libtool_libs" || { 10380*b50261e2SCy Schubert if test -n "$gentop"; then 10381*b50261e2SCy Schubert func_show_eval '${RM}r "$gentop"' 10382*b50261e2SCy Schubert fi 10383*b50261e2SCy Schubert 10384*b50261e2SCy Schubert # Create an invalid libtool object if no PIC, so that we don't 10385*b50261e2SCy Schubert # accidentally link it into a program. 10386*b50261e2SCy Schubert # $show "echo timestamp > $libobj" 10387*b50261e2SCy Schubert # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10388*b50261e2SCy Schubert exit $EXIT_SUCCESS 10389*b50261e2SCy Schubert } 10390*b50261e2SCy Schubert 10391*b50261e2SCy Schubert if test -n "$pic_flag" || test default != "$pic_mode"; then 10392*b50261e2SCy Schubert # Only do commands if we really have different PIC objects. 10393*b50261e2SCy Schubert reload_objs="$libobjs $reload_conv_objs" 10394*b50261e2SCy Schubert output=$libobj 10395*b50261e2SCy Schubert func_execute_cmds "$reload_cmds" 'exit $?' 10396*b50261e2SCy Schubert fi 10397*b50261e2SCy Schubert 10398*b50261e2SCy Schubert if test -n "$gentop"; then 10399*b50261e2SCy Schubert func_show_eval '${RM}r "$gentop"' 10400*b50261e2SCy Schubert fi 10401*b50261e2SCy Schubert 10402*b50261e2SCy Schubert exit $EXIT_SUCCESS 10403*b50261e2SCy Schubert ;; 10404*b50261e2SCy Schubert 10405*b50261e2SCy Schubert prog) 10406*b50261e2SCy Schubert case $host in 10407*b50261e2SCy Schubert *cygwin*) func_stripname '' '.exe' "$output" 10408*b50261e2SCy Schubert output=$func_stripname_result.exe;; 10409*b50261e2SCy Schubert esac 10410*b50261e2SCy Schubert test -n "$vinfo" && \ 10411*b50261e2SCy Schubert func_warning "'-version-info' is ignored for programs" 10412*b50261e2SCy Schubert 10413*b50261e2SCy Schubert test -n "$release" && \ 10414*b50261e2SCy Schubert func_warning "'-release' is ignored for programs" 10415*b50261e2SCy Schubert 10416*b50261e2SCy Schubert $preload \ 10417*b50261e2SCy Schubert && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10418*b50261e2SCy Schubert && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10419*b50261e2SCy Schubert 10420*b50261e2SCy Schubert case $host in 10421*b50261e2SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 10422*b50261e2SCy Schubert # On Rhapsody replace the C library is the System framework 10423*b50261e2SCy Schubert compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10424*b50261e2SCy Schubert finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10425*b50261e2SCy Schubert ;; 10426*b50261e2SCy Schubert esac 10427*b50261e2SCy Schubert 10428*b50261e2SCy Schubert case $host in 10429*b50261e2SCy Schubert *-*-darwin*) 10430*b50261e2SCy Schubert # Don't allow lazy linking, it breaks C++ global constructors 10431*b50261e2SCy Schubert # But is supposedly fixed on 10.4 or later (yay!). 10432*b50261e2SCy Schubert if test CXX = "$tagname"; then 10433*b50261e2SCy Schubert case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10434*b50261e2SCy Schubert 10.[0123]) 10435*b50261e2SCy Schubert func_append compile_command " $wl-bind_at_load" 10436*b50261e2SCy Schubert func_append finalize_command " $wl-bind_at_load" 10437*b50261e2SCy Schubert ;; 10438*b50261e2SCy Schubert esac 10439*b50261e2SCy Schubert fi 10440*b50261e2SCy Schubert # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10441*b50261e2SCy Schubert compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10442*b50261e2SCy Schubert finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10443*b50261e2SCy Schubert ;; 10444*b50261e2SCy Schubert esac 10445*b50261e2SCy Schubert 10446*b50261e2SCy Schubert 10447*b50261e2SCy Schubert # move library search paths that coincide with paths to not yet 10448*b50261e2SCy Schubert # installed libraries to the beginning of the library search list 10449*b50261e2SCy Schubert new_libs= 10450*b50261e2SCy Schubert for path in $notinst_path; do 10451*b50261e2SCy Schubert case " $new_libs " in 10452*b50261e2SCy Schubert *" -L$path/$objdir "*) ;; 10453*b50261e2SCy Schubert *) 10454*b50261e2SCy Schubert case " $compile_deplibs " in 10455*b50261e2SCy Schubert *" -L$path/$objdir "*) 10456*b50261e2SCy Schubert func_append new_libs " -L$path/$objdir" ;; 10457*b50261e2SCy Schubert esac 10458*b50261e2SCy Schubert ;; 10459*b50261e2SCy Schubert esac 10460*b50261e2SCy Schubert done 10461*b50261e2SCy Schubert for deplib in $compile_deplibs; do 10462*b50261e2SCy Schubert case $deplib in 10463*b50261e2SCy Schubert -L*) 10464*b50261e2SCy Schubert case " $new_libs " in 10465*b50261e2SCy Schubert *" $deplib "*) ;; 10466*b50261e2SCy Schubert *) func_append new_libs " $deplib" ;; 10467*b50261e2SCy Schubert esac 10468*b50261e2SCy Schubert ;; 10469*b50261e2SCy Schubert *) func_append new_libs " $deplib" ;; 10470*b50261e2SCy Schubert esac 10471*b50261e2SCy Schubert done 10472*b50261e2SCy Schubert compile_deplibs=$new_libs 10473*b50261e2SCy Schubert 10474*b50261e2SCy Schubert 10475*b50261e2SCy Schubert func_append compile_command " $compile_deplibs" 10476*b50261e2SCy Schubert func_append finalize_command " $finalize_deplibs" 10477*b50261e2SCy Schubert 10478*b50261e2SCy Schubert if test -n "$rpath$xrpath"; then 10479*b50261e2SCy Schubert # If the user specified any rpath flags, then add them. 10480*b50261e2SCy Schubert for libdir in $rpath $xrpath; do 10481*b50261e2SCy Schubert # This is the magic to use -rpath. 10482*b50261e2SCy Schubert case "$finalize_rpath " in 10483*b50261e2SCy Schubert *" $libdir "*) ;; 10484*b50261e2SCy Schubert *) func_append finalize_rpath " $libdir" ;; 10485*b50261e2SCy Schubert esac 10486*b50261e2SCy Schubert done 10487*b50261e2SCy Schubert fi 10488*b50261e2SCy Schubert 10489*b50261e2SCy Schubert # Now hardcode the library paths 10490*b50261e2SCy Schubert rpath= 10491*b50261e2SCy Schubert hardcode_libdirs= 10492*b50261e2SCy Schubert for libdir in $compile_rpath $finalize_rpath; do 10493*b50261e2SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 10494*b50261e2SCy Schubert if test -n "$hardcode_libdir_separator"; then 10495*b50261e2SCy Schubert if test -z "$hardcode_libdirs"; then 10496*b50261e2SCy Schubert hardcode_libdirs=$libdir 10497*b50261e2SCy Schubert else 10498*b50261e2SCy Schubert # Just accumulate the unique libdirs. 10499*b50261e2SCy Schubert case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10500*b50261e2SCy Schubert *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10501*b50261e2SCy Schubert ;; 10502*b50261e2SCy Schubert *) 10503*b50261e2SCy Schubert func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10504*b50261e2SCy Schubert ;; 10505*b50261e2SCy Schubert esac 10506*b50261e2SCy Schubert fi 10507*b50261e2SCy Schubert else 10508*b50261e2SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 10509*b50261e2SCy Schubert func_append rpath " $flag" 10510*b50261e2SCy Schubert fi 10511*b50261e2SCy Schubert elif test -n "$runpath_var"; then 10512*b50261e2SCy Schubert case "$perm_rpath " in 10513*b50261e2SCy Schubert *" $libdir "*) ;; 10514*b50261e2SCy Schubert *) func_append perm_rpath " $libdir" ;; 10515*b50261e2SCy Schubert esac 10516*b50261e2SCy Schubert fi 10517*b50261e2SCy Schubert case $host in 10518*b50261e2SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10519*b50261e2SCy Schubert testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10520*b50261e2SCy Schubert case :$dllsearchpath: in 10521*b50261e2SCy Schubert *":$libdir:"*) ;; 10522*b50261e2SCy Schubert ::) dllsearchpath=$libdir;; 10523*b50261e2SCy Schubert *) func_append dllsearchpath ":$libdir";; 10524*b50261e2SCy Schubert esac 10525*b50261e2SCy Schubert case :$dllsearchpath: in 10526*b50261e2SCy Schubert *":$testbindir:"*) ;; 10527*b50261e2SCy Schubert ::) dllsearchpath=$testbindir;; 10528*b50261e2SCy Schubert *) func_append dllsearchpath ":$testbindir";; 10529*b50261e2SCy Schubert esac 10530*b50261e2SCy Schubert ;; 10531*b50261e2SCy Schubert esac 10532*b50261e2SCy Schubert done 10533*b50261e2SCy Schubert # Substitute the hardcoded libdirs into the rpath. 10534*b50261e2SCy Schubert if test -n "$hardcode_libdir_separator" && 10535*b50261e2SCy Schubert test -n "$hardcode_libdirs"; then 10536*b50261e2SCy Schubert libdir=$hardcode_libdirs 10537*b50261e2SCy Schubert eval rpath=\" $hardcode_libdir_flag_spec\" 10538*b50261e2SCy Schubert fi 10539*b50261e2SCy Schubert compile_rpath=$rpath 10540*b50261e2SCy Schubert 10541*b50261e2SCy Schubert rpath= 10542*b50261e2SCy Schubert hardcode_libdirs= 10543*b50261e2SCy Schubert for libdir in $finalize_rpath; do 10544*b50261e2SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 10545*b50261e2SCy Schubert if test -n "$hardcode_libdir_separator"; then 10546*b50261e2SCy Schubert if test -z "$hardcode_libdirs"; then 10547*b50261e2SCy Schubert hardcode_libdirs=$libdir 10548*b50261e2SCy Schubert else 10549*b50261e2SCy Schubert # Just accumulate the unique libdirs. 10550*b50261e2SCy Schubert case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10551*b50261e2SCy Schubert *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10552*b50261e2SCy Schubert ;; 10553*b50261e2SCy Schubert *) 10554*b50261e2SCy Schubert func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10555*b50261e2SCy Schubert ;; 10556*b50261e2SCy Schubert esac 10557*b50261e2SCy Schubert fi 10558*b50261e2SCy Schubert else 10559*b50261e2SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 10560*b50261e2SCy Schubert func_append rpath " $flag" 10561*b50261e2SCy Schubert fi 10562*b50261e2SCy Schubert elif test -n "$runpath_var"; then 10563*b50261e2SCy Schubert case "$finalize_perm_rpath " in 10564*b50261e2SCy Schubert *" $libdir "*) ;; 10565*b50261e2SCy Schubert *) func_append finalize_perm_rpath " $libdir" ;; 10566*b50261e2SCy Schubert esac 10567*b50261e2SCy Schubert fi 10568*b50261e2SCy Schubert done 10569*b50261e2SCy Schubert # Substitute the hardcoded libdirs into the rpath. 10570*b50261e2SCy Schubert if test -n "$hardcode_libdir_separator" && 10571*b50261e2SCy Schubert test -n "$hardcode_libdirs"; then 10572*b50261e2SCy Schubert libdir=$hardcode_libdirs 10573*b50261e2SCy Schubert eval rpath=\" $hardcode_libdir_flag_spec\" 10574*b50261e2SCy Schubert fi 10575*b50261e2SCy Schubert finalize_rpath=$rpath 10576*b50261e2SCy Schubert 10577*b50261e2SCy Schubert if test -n "$libobjs" && test yes = "$build_old_libs"; then 10578*b50261e2SCy Schubert # Transform all the library objects into standard objects. 10579*b50261e2SCy Schubert compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10580*b50261e2SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10581*b50261e2SCy Schubert fi 10582*b50261e2SCy Schubert 10583*b50261e2SCy Schubert func_generate_dlsyms "$outputname" "@PROGRAM@" false 10584*b50261e2SCy Schubert 10585*b50261e2SCy Schubert # template prelinking step 10586*b50261e2SCy Schubert if test -n "$prelink_cmds"; then 10587*b50261e2SCy Schubert func_execute_cmds "$prelink_cmds" 'exit $?' 10588*b50261e2SCy Schubert fi 10589*b50261e2SCy Schubert 10590*b50261e2SCy Schubert wrappers_required=: 10591*b50261e2SCy Schubert case $host in 10592*b50261e2SCy Schubert *cegcc* | *mingw32ce*) 10593*b50261e2SCy Schubert # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10594*b50261e2SCy Schubert wrappers_required=false 10595*b50261e2SCy Schubert ;; 10596*b50261e2SCy Schubert *cygwin* | *mingw* ) 10597*b50261e2SCy Schubert test yes = "$build_libtool_libs" || wrappers_required=false 10598*b50261e2SCy Schubert ;; 10599*b50261e2SCy Schubert *) 10600*b50261e2SCy Schubert if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10601*b50261e2SCy Schubert wrappers_required=false 10602*b50261e2SCy Schubert fi 10603*b50261e2SCy Schubert ;; 10604*b50261e2SCy Schubert esac 10605*b50261e2SCy Schubert $wrappers_required || { 10606*b50261e2SCy Schubert # Replace the output file specification. 10607*b50261e2SCy Schubert compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10608*b50261e2SCy Schubert link_command=$compile_command$compile_rpath 10609*b50261e2SCy Schubert 10610*b50261e2SCy Schubert # We have no uninstalled library dependencies, so finalize right now. 10611*b50261e2SCy Schubert exit_status=0 10612*b50261e2SCy Schubert func_show_eval "$link_command" 'exit_status=$?' 10613*b50261e2SCy Schubert 10614*b50261e2SCy Schubert if test -n "$postlink_cmds"; then 10615*b50261e2SCy Schubert func_to_tool_file "$output" 10616*b50261e2SCy Schubert postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10617*b50261e2SCy Schubert func_execute_cmds "$postlink_cmds" 'exit $?' 10618*b50261e2SCy Schubert fi 10619*b50261e2SCy Schubert 10620*b50261e2SCy Schubert # Delete the generated files. 10621*b50261e2SCy Schubert if test -f "$output_objdir/${outputname}S.$objext"; then 10622*b50261e2SCy Schubert func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10623*b50261e2SCy Schubert fi 10624*b50261e2SCy Schubert 10625*b50261e2SCy Schubert exit $exit_status 10626*b50261e2SCy Schubert } 10627*b50261e2SCy Schubert 10628*b50261e2SCy Schubert if test -n "$compile_shlibpath$finalize_shlibpath"; then 10629*b50261e2SCy Schubert compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10630*b50261e2SCy Schubert fi 10631*b50261e2SCy Schubert if test -n "$finalize_shlibpath"; then 10632*b50261e2SCy Schubert finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10633*b50261e2SCy Schubert fi 10634*b50261e2SCy Schubert 10635*b50261e2SCy Schubert compile_var= 10636*b50261e2SCy Schubert finalize_var= 10637*b50261e2SCy Schubert if test -n "$runpath_var"; then 10638*b50261e2SCy Schubert if test -n "$perm_rpath"; then 10639*b50261e2SCy Schubert # We should set the runpath_var. 10640*b50261e2SCy Schubert rpath= 10641*b50261e2SCy Schubert for dir in $perm_rpath; do 10642*b50261e2SCy Schubert func_append rpath "$dir:" 10643*b50261e2SCy Schubert done 10644*b50261e2SCy Schubert compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10645*b50261e2SCy Schubert fi 10646*b50261e2SCy Schubert if test -n "$finalize_perm_rpath"; then 10647*b50261e2SCy Schubert # We should set the runpath_var. 10648*b50261e2SCy Schubert rpath= 10649*b50261e2SCy Schubert for dir in $finalize_perm_rpath; do 10650*b50261e2SCy Schubert func_append rpath "$dir:" 10651*b50261e2SCy Schubert done 10652*b50261e2SCy Schubert finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10653*b50261e2SCy Schubert fi 10654*b50261e2SCy Schubert fi 10655*b50261e2SCy Schubert 10656*b50261e2SCy Schubert if test yes = "$no_install"; then 10657*b50261e2SCy Schubert # We don't need to create a wrapper script. 10658*b50261e2SCy Schubert link_command=$compile_var$compile_command$compile_rpath 10659*b50261e2SCy Schubert # Replace the output file specification. 10660*b50261e2SCy Schubert link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10661*b50261e2SCy Schubert # Delete the old output file. 10662*b50261e2SCy Schubert $opt_dry_run || $RM $output 10663*b50261e2SCy Schubert # Link the executable and exit 10664*b50261e2SCy Schubert func_show_eval "$link_command" 'exit $?' 10665*b50261e2SCy Schubert 10666*b50261e2SCy Schubert if test -n "$postlink_cmds"; then 10667*b50261e2SCy Schubert func_to_tool_file "$output" 10668*b50261e2SCy Schubert postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10669*b50261e2SCy Schubert func_execute_cmds "$postlink_cmds" 'exit $?' 10670*b50261e2SCy Schubert fi 10671*b50261e2SCy Schubert 10672*b50261e2SCy Schubert exit $EXIT_SUCCESS 10673*b50261e2SCy Schubert fi 10674*b50261e2SCy Schubert 10675*b50261e2SCy Schubert case $hardcode_action,$fast_install in 10676*b50261e2SCy Schubert relink,*) 10677*b50261e2SCy Schubert # Fast installation is not supported 10678*b50261e2SCy Schubert link_command=$compile_var$compile_command$compile_rpath 10679*b50261e2SCy Schubert relink_command=$finalize_var$finalize_command$finalize_rpath 10680*b50261e2SCy Schubert 10681*b50261e2SCy Schubert func_warning "this platform does not like uninstalled shared libraries" 10682*b50261e2SCy Schubert func_warning "'$output' will be relinked during installation" 10683*b50261e2SCy Schubert ;; 10684*b50261e2SCy Schubert *,yes) 10685*b50261e2SCy Schubert link_command=$finalize_var$compile_command$finalize_rpath 10686*b50261e2SCy Schubert relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10687*b50261e2SCy Schubert ;; 10688*b50261e2SCy Schubert *,no) 10689*b50261e2SCy Schubert link_command=$compile_var$compile_command$compile_rpath 10690*b50261e2SCy Schubert relink_command=$finalize_var$finalize_command$finalize_rpath 10691*b50261e2SCy Schubert ;; 10692*b50261e2SCy Schubert *,needless) 10693*b50261e2SCy Schubert link_command=$finalize_var$compile_command$finalize_rpath 10694*b50261e2SCy Schubert relink_command= 10695*b50261e2SCy Schubert ;; 10696*b50261e2SCy Schubert esac 10697*b50261e2SCy Schubert 10698*b50261e2SCy Schubert # Replace the output file specification. 10699*b50261e2SCy Schubert link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10700*b50261e2SCy Schubert 10701*b50261e2SCy Schubert # Delete the old output files. 10702*b50261e2SCy Schubert $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10703*b50261e2SCy Schubert 10704*b50261e2SCy Schubert func_show_eval "$link_command" 'exit $?' 10705*b50261e2SCy Schubert 10706*b50261e2SCy Schubert if test -n "$postlink_cmds"; then 10707*b50261e2SCy Schubert func_to_tool_file "$output_objdir/$outputname" 10708*b50261e2SCy Schubert 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'` 10709*b50261e2SCy Schubert func_execute_cmds "$postlink_cmds" 'exit $?' 10710*b50261e2SCy Schubert fi 10711*b50261e2SCy Schubert 10712*b50261e2SCy Schubert # Now create the wrapper script. 10713*b50261e2SCy Schubert func_verbose "creating $output" 10714*b50261e2SCy Schubert 10715*b50261e2SCy Schubert # Quote the relink command for shipping. 10716*b50261e2SCy Schubert if test -n "$relink_command"; then 10717*b50261e2SCy Schubert # Preserve any variables that may affect compiler behavior 10718*b50261e2SCy Schubert for var in $variables_saved_for_relink; do 10719*b50261e2SCy Schubert if eval test -z \"\${$var+set}\"; then 10720*b50261e2SCy Schubert relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10721*b50261e2SCy Schubert elif eval var_value=\$$var; test -z "$var_value"; then 10722*b50261e2SCy Schubert relink_command="$var=; export $var; $relink_command" 10723*b50261e2SCy Schubert else 10724*b50261e2SCy Schubert func_quote_arg pretty "$var_value" 10725*b50261e2SCy Schubert relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10726*b50261e2SCy Schubert fi 10727*b50261e2SCy Schubert done 10728*b50261e2SCy Schubert func_quote eval cd "`pwd`" 10729*b50261e2SCy Schubert func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10730*b50261e2SCy Schubert relink_command=$func_quote_arg_unquoted_result 10731*b50261e2SCy Schubert fi 10732*b50261e2SCy Schubert 10733*b50261e2SCy Schubert # Only actually do things if not in dry run mode. 10734*b50261e2SCy Schubert $opt_dry_run || { 10735*b50261e2SCy Schubert # win32 will think the script is a binary if it has 10736*b50261e2SCy Schubert # a .exe suffix, so we strip it off here. 10737*b50261e2SCy Schubert case $output in 10738*b50261e2SCy Schubert *.exe) func_stripname '' '.exe' "$output" 10739*b50261e2SCy Schubert output=$func_stripname_result ;; 10740*b50261e2SCy Schubert esac 10741*b50261e2SCy Schubert # test for cygwin because mv fails w/o .exe extensions 10742*b50261e2SCy Schubert case $host in 10743*b50261e2SCy Schubert *cygwin*) 10744*b50261e2SCy Schubert exeext=.exe 10745*b50261e2SCy Schubert func_stripname '' '.exe' "$outputname" 10746*b50261e2SCy Schubert outputname=$func_stripname_result ;; 10747*b50261e2SCy Schubert *) exeext= ;; 10748*b50261e2SCy Schubert esac 10749*b50261e2SCy Schubert case $host in 10750*b50261e2SCy Schubert *cygwin* | *mingw* ) 10751*b50261e2SCy Schubert func_dirname_and_basename "$output" "" "." 10752*b50261e2SCy Schubert output_name=$func_basename_result 10753*b50261e2SCy Schubert output_path=$func_dirname_result 10754*b50261e2SCy Schubert cwrappersource=$output_path/$objdir/lt-$output_name.c 10755*b50261e2SCy Schubert cwrapper=$output_path/$output_name.exe 10756*b50261e2SCy Schubert $RM $cwrappersource $cwrapper 10757*b50261e2SCy Schubert trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10758*b50261e2SCy Schubert 10759*b50261e2SCy Schubert func_emit_cwrapperexe_src > $cwrappersource 10760*b50261e2SCy Schubert 10761*b50261e2SCy Schubert # The wrapper executable is built using the $host compiler, 10762*b50261e2SCy Schubert # because it contains $host paths and files. If cross- 10763*b50261e2SCy Schubert # compiling, it, like the target executable, must be 10764*b50261e2SCy Schubert # executed on the $host or under an emulation environment. 10765*b50261e2SCy Schubert $opt_dry_run || { 10766*b50261e2SCy Schubert $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10767*b50261e2SCy Schubert $STRIP $cwrapper 10768*b50261e2SCy Schubert } 10769*b50261e2SCy Schubert 10770*b50261e2SCy Schubert # Now, create the wrapper script for func_source use: 10771*b50261e2SCy Schubert func_ltwrapper_scriptname $cwrapper 10772*b50261e2SCy Schubert $RM $func_ltwrapper_scriptname_result 10773*b50261e2SCy Schubert trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10774*b50261e2SCy Schubert $opt_dry_run || { 10775*b50261e2SCy Schubert # note: this script will not be executed, so do not chmod. 10776*b50261e2SCy Schubert if test "x$build" = "x$host"; then 10777*b50261e2SCy Schubert $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10778*b50261e2SCy Schubert else 10779*b50261e2SCy Schubert func_emit_wrapper no > $func_ltwrapper_scriptname_result 10780*b50261e2SCy Schubert fi 10781*b50261e2SCy Schubert } 10782*b50261e2SCy Schubert ;; 10783*b50261e2SCy Schubert * ) 10784*b50261e2SCy Schubert $RM $output 10785*b50261e2SCy Schubert trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10786*b50261e2SCy Schubert 10787*b50261e2SCy Schubert func_emit_wrapper no > $output 10788*b50261e2SCy Schubert chmod +x $output 10789*b50261e2SCy Schubert ;; 10790*b50261e2SCy Schubert esac 10791*b50261e2SCy Schubert } 10792*b50261e2SCy Schubert exit $EXIT_SUCCESS 10793*b50261e2SCy Schubert ;; 10794*b50261e2SCy Schubert esac 10795*b50261e2SCy Schubert 10796*b50261e2SCy Schubert # See if we need to build an old-fashioned archive. 10797*b50261e2SCy Schubert for oldlib in $oldlibs; do 10798*b50261e2SCy Schubert 10799*b50261e2SCy Schubert case $build_libtool_libs in 10800*b50261e2SCy Schubert convenience) 10801*b50261e2SCy Schubert oldobjs="$libobjs_save $symfileobj" 10802*b50261e2SCy Schubert addlibs=$convenience 10803*b50261e2SCy Schubert build_libtool_libs=no 10804*b50261e2SCy Schubert ;; 10805*b50261e2SCy Schubert module) 10806*b50261e2SCy Schubert oldobjs=$libobjs_save 10807*b50261e2SCy Schubert addlibs=$old_convenience 10808*b50261e2SCy Schubert build_libtool_libs=no 10809*b50261e2SCy Schubert ;; 10810*b50261e2SCy Schubert *) 10811*b50261e2SCy Schubert oldobjs="$old_deplibs $non_pic_objects" 10812*b50261e2SCy Schubert $preload && test -f "$symfileobj" \ 10813*b50261e2SCy Schubert && func_append oldobjs " $symfileobj" 10814*b50261e2SCy Schubert addlibs=$old_convenience 10815*b50261e2SCy Schubert ;; 10816*b50261e2SCy Schubert esac 10817*b50261e2SCy Schubert 10818*b50261e2SCy Schubert if test -n "$addlibs"; then 10819*b50261e2SCy Schubert gentop=$output_objdir/${outputname}x 10820*b50261e2SCy Schubert func_append generated " $gentop" 10821*b50261e2SCy Schubert 10822*b50261e2SCy Schubert func_extract_archives $gentop $addlibs 10823*b50261e2SCy Schubert func_append oldobjs " $func_extract_archives_result" 10824*b50261e2SCy Schubert fi 10825*b50261e2SCy Schubert 10826*b50261e2SCy Schubert # Do each command in the archive commands. 10827*b50261e2SCy Schubert if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10828*b50261e2SCy Schubert cmds=$old_archive_from_new_cmds 10829*b50261e2SCy Schubert else 10830*b50261e2SCy Schubert 10831*b50261e2SCy Schubert # Add any objects from preloaded convenience libraries 10832*b50261e2SCy Schubert if test -n "$dlprefiles"; then 10833*b50261e2SCy Schubert gentop=$output_objdir/${outputname}x 10834*b50261e2SCy Schubert func_append generated " $gentop" 10835*b50261e2SCy Schubert 10836*b50261e2SCy Schubert func_extract_archives $gentop $dlprefiles 10837*b50261e2SCy Schubert func_append oldobjs " $func_extract_archives_result" 10838*b50261e2SCy Schubert fi 10839*b50261e2SCy Schubert 10840*b50261e2SCy Schubert # POSIX demands no paths to be encoded in archives. We have 10841*b50261e2SCy Schubert # to avoid creating archives with duplicate basenames if we 10842*b50261e2SCy Schubert # might have to extract them afterwards, e.g., when creating a 10843*b50261e2SCy Schubert # static archive out of a convenience library, or when linking 10844*b50261e2SCy Schubert # the entirety of a libtool archive into another (currently 10845*b50261e2SCy Schubert # not supported by libtool). 10846*b50261e2SCy Schubert if (for obj in $oldobjs 10847*b50261e2SCy Schubert do 10848*b50261e2SCy Schubert func_basename "$obj" 10849*b50261e2SCy Schubert $ECHO "$func_basename_result" 10850*b50261e2SCy Schubert done | sort | sort -uc >/dev/null 2>&1); then 10851*b50261e2SCy Schubert : 10852*b50261e2SCy Schubert else 10853*b50261e2SCy Schubert echo "copying selected object files to avoid basename conflicts..." 10854*b50261e2SCy Schubert gentop=$output_objdir/${outputname}x 10855*b50261e2SCy Schubert func_append generated " $gentop" 10856*b50261e2SCy Schubert func_mkdir_p "$gentop" 10857*b50261e2SCy Schubert save_oldobjs=$oldobjs 10858*b50261e2SCy Schubert oldobjs= 10859*b50261e2SCy Schubert counter=1 10860*b50261e2SCy Schubert for obj in $save_oldobjs 10861*b50261e2SCy Schubert do 10862*b50261e2SCy Schubert func_basename "$obj" 10863*b50261e2SCy Schubert objbase=$func_basename_result 10864*b50261e2SCy Schubert case " $oldobjs " in 10865*b50261e2SCy Schubert " ") oldobjs=$obj ;; 10866*b50261e2SCy Schubert *[\ /]"$objbase "*) 10867*b50261e2SCy Schubert while :; do 10868*b50261e2SCy Schubert # Make sure we don't pick an alternate name that also 10869*b50261e2SCy Schubert # overlaps. 10870*b50261e2SCy Schubert newobj=lt$counter-$objbase 10871*b50261e2SCy Schubert func_arith $counter + 1 10872*b50261e2SCy Schubert counter=$func_arith_result 10873*b50261e2SCy Schubert case " $oldobjs " in 10874*b50261e2SCy Schubert *[\ /]"$newobj "*) ;; 10875*b50261e2SCy Schubert *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10876*b50261e2SCy Schubert esac 10877*b50261e2SCy Schubert done 10878*b50261e2SCy Schubert func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10879*b50261e2SCy Schubert func_append oldobjs " $gentop/$newobj" 10880*b50261e2SCy Schubert ;; 10881*b50261e2SCy Schubert *) func_append oldobjs " $obj" ;; 10882*b50261e2SCy Schubert esac 10883*b50261e2SCy Schubert done 10884*b50261e2SCy Schubert fi 10885*b50261e2SCy Schubert func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10886*b50261e2SCy Schubert tool_oldlib=$func_to_tool_file_result 10887*b50261e2SCy Schubert eval cmds=\"$old_archive_cmds\" 10888*b50261e2SCy Schubert 10889*b50261e2SCy Schubert func_len " $cmds" 10890*b50261e2SCy Schubert len=$func_len_result 10891*b50261e2SCy Schubert if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10892*b50261e2SCy Schubert cmds=$old_archive_cmds 10893*b50261e2SCy Schubert elif test -n "$archiver_list_spec"; then 10894*b50261e2SCy Schubert func_verbose "using command file archive linking..." 10895*b50261e2SCy Schubert for obj in $oldobjs 10896*b50261e2SCy Schubert do 10897*b50261e2SCy Schubert func_to_tool_file "$obj" 10898*b50261e2SCy Schubert $ECHO "$func_to_tool_file_result" 10899*b50261e2SCy Schubert done > $output_objdir/$libname.libcmd 10900*b50261e2SCy Schubert func_to_tool_file "$output_objdir/$libname.libcmd" 10901*b50261e2SCy Schubert oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10902*b50261e2SCy Schubert cmds=$old_archive_cmds 10903*b50261e2SCy Schubert else 10904*b50261e2SCy Schubert # the command line is too long to link in one step, link in parts 10905*b50261e2SCy Schubert func_verbose "using piecewise archive linking..." 10906*b50261e2SCy Schubert save_RANLIB=$RANLIB 10907*b50261e2SCy Schubert RANLIB=: 10908*b50261e2SCy Schubert objlist= 10909*b50261e2SCy Schubert concat_cmds= 10910*b50261e2SCy Schubert save_oldobjs=$oldobjs 10911*b50261e2SCy Schubert oldobjs= 10912*b50261e2SCy Schubert # Is there a better way of finding the last object in the list? 10913*b50261e2SCy Schubert for obj in $save_oldobjs 10914*b50261e2SCy Schubert do 10915*b50261e2SCy Schubert last_oldobj=$obj 10916*b50261e2SCy Schubert done 10917*b50261e2SCy Schubert eval test_cmds=\"$old_archive_cmds\" 10918*b50261e2SCy Schubert func_len " $test_cmds" 10919*b50261e2SCy Schubert len0=$func_len_result 10920*b50261e2SCy Schubert len=$len0 10921*b50261e2SCy Schubert for obj in $save_oldobjs 10922*b50261e2SCy Schubert do 10923*b50261e2SCy Schubert func_len " $obj" 10924*b50261e2SCy Schubert func_arith $len + $func_len_result 10925*b50261e2SCy Schubert len=$func_arith_result 10926*b50261e2SCy Schubert func_append objlist " $obj" 10927*b50261e2SCy Schubert if test "$len" -lt "$max_cmd_len"; then 10928*b50261e2SCy Schubert : 10929*b50261e2SCy Schubert else 10930*b50261e2SCy Schubert # the above command should be used before it gets too long 10931*b50261e2SCy Schubert oldobjs=$objlist 10932*b50261e2SCy Schubert if test "$obj" = "$last_oldobj"; then 10933*b50261e2SCy Schubert RANLIB=$save_RANLIB 10934*b50261e2SCy Schubert fi 10935*b50261e2SCy Schubert test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10936*b50261e2SCy Schubert eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10937*b50261e2SCy Schubert objlist= 10938*b50261e2SCy Schubert len=$len0 10939*b50261e2SCy Schubert fi 10940*b50261e2SCy Schubert done 10941*b50261e2SCy Schubert RANLIB=$save_RANLIB 10942*b50261e2SCy Schubert oldobjs=$objlist 10943*b50261e2SCy Schubert if test -z "$oldobjs"; then 10944*b50261e2SCy Schubert eval cmds=\"\$concat_cmds\" 10945*b50261e2SCy Schubert else 10946*b50261e2SCy Schubert eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10947*b50261e2SCy Schubert fi 10948*b50261e2SCy Schubert fi 10949*b50261e2SCy Schubert fi 10950*b50261e2SCy Schubert func_execute_cmds "$cmds" 'exit $?' 10951*b50261e2SCy Schubert done 10952*b50261e2SCy Schubert 10953*b50261e2SCy Schubert test -n "$generated" && \ 10954*b50261e2SCy Schubert func_show_eval "${RM}r$generated" 10955*b50261e2SCy Schubert 10956*b50261e2SCy Schubert # Now create the libtool archive. 10957*b50261e2SCy Schubert case $output in 10958*b50261e2SCy Schubert *.la) 10959*b50261e2SCy Schubert old_library= 10960*b50261e2SCy Schubert test yes = "$build_old_libs" && old_library=$libname.$libext 10961*b50261e2SCy Schubert func_verbose "creating $output" 10962*b50261e2SCy Schubert 10963*b50261e2SCy Schubert # Preserve any variables that may affect compiler behavior 10964*b50261e2SCy Schubert for var in $variables_saved_for_relink; do 10965*b50261e2SCy Schubert if eval test -z \"\${$var+set}\"; then 10966*b50261e2SCy Schubert relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10967*b50261e2SCy Schubert elif eval var_value=\$$var; test -z "$var_value"; then 10968*b50261e2SCy Schubert relink_command="$var=; export $var; $relink_command" 10969*b50261e2SCy Schubert else 10970*b50261e2SCy Schubert func_quote_arg pretty,unquoted "$var_value" 10971*b50261e2SCy Schubert relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 10972*b50261e2SCy Schubert fi 10973*b50261e2SCy Schubert done 10974*b50261e2SCy Schubert # Quote the link command for shipping. 10975*b50261e2SCy Schubert func_quote eval cd "`pwd`" 10976*b50261e2SCy Schubert relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10977*b50261e2SCy Schubert func_quote_arg pretty,unquoted "$relink_command" 10978*b50261e2SCy Schubert relink_command=$func_quote_arg_unquoted_result 10979*b50261e2SCy Schubert if test yes = "$hardcode_automatic"; then 10980*b50261e2SCy Schubert relink_command= 10981*b50261e2SCy Schubert fi 10982*b50261e2SCy Schubert 10983*b50261e2SCy Schubert # Only create the output if not a dry run. 10984*b50261e2SCy Schubert $opt_dry_run || { 10985*b50261e2SCy Schubert for installed in no yes; do 10986*b50261e2SCy Schubert if test yes = "$installed"; then 10987*b50261e2SCy Schubert if test -z "$install_libdir"; then 10988*b50261e2SCy Schubert break 10989*b50261e2SCy Schubert fi 10990*b50261e2SCy Schubert output=$output_objdir/${outputname}i 10991*b50261e2SCy Schubert # Replace all uninstalled libtool libraries with the installed ones 10992*b50261e2SCy Schubert newdependency_libs= 10993*b50261e2SCy Schubert for deplib in $dependency_libs; do 10994*b50261e2SCy Schubert case $deplib in 10995*b50261e2SCy Schubert *.la) 10996*b50261e2SCy Schubert func_basename "$deplib" 10997*b50261e2SCy Schubert name=$func_basename_result 10998*b50261e2SCy Schubert func_resolve_sysroot "$deplib" 10999*b50261e2SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11000*b50261e2SCy Schubert test -z "$libdir" && \ 11001*b50261e2SCy Schubert func_fatal_error "'$deplib' is not a valid libtool archive" 11002*b50261e2SCy Schubert func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11003*b50261e2SCy Schubert ;; 11004*b50261e2SCy Schubert -L*) 11005*b50261e2SCy Schubert func_stripname -L '' "$deplib" 11006*b50261e2SCy Schubert func_replace_sysroot "$func_stripname_result" 11007*b50261e2SCy Schubert func_append newdependency_libs " -L$func_replace_sysroot_result" 11008*b50261e2SCy Schubert ;; 11009*b50261e2SCy Schubert -R*) 11010*b50261e2SCy Schubert func_stripname -R '' "$deplib" 11011*b50261e2SCy Schubert func_replace_sysroot "$func_stripname_result" 11012*b50261e2SCy Schubert func_append newdependency_libs " -R$func_replace_sysroot_result" 11013*b50261e2SCy Schubert ;; 11014*b50261e2SCy Schubert *) func_append newdependency_libs " $deplib" ;; 11015*b50261e2SCy Schubert esac 11016*b50261e2SCy Schubert done 11017*b50261e2SCy Schubert dependency_libs=$newdependency_libs 11018*b50261e2SCy Schubert newdlfiles= 11019*b50261e2SCy Schubert 11020*b50261e2SCy Schubert for lib in $dlfiles; do 11021*b50261e2SCy Schubert case $lib in 11022*b50261e2SCy Schubert *.la) 11023*b50261e2SCy Schubert func_basename "$lib" 11024*b50261e2SCy Schubert name=$func_basename_result 11025*b50261e2SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11026*b50261e2SCy Schubert test -z "$libdir" && \ 11027*b50261e2SCy Schubert func_fatal_error "'$lib' is not a valid libtool archive" 11028*b50261e2SCy Schubert func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11029*b50261e2SCy Schubert ;; 11030*b50261e2SCy Schubert *) func_append newdlfiles " $lib" ;; 11031*b50261e2SCy Schubert esac 11032*b50261e2SCy Schubert done 11033*b50261e2SCy Schubert dlfiles=$newdlfiles 11034*b50261e2SCy Schubert newdlprefiles= 11035*b50261e2SCy Schubert for lib in $dlprefiles; do 11036*b50261e2SCy Schubert case $lib in 11037*b50261e2SCy Schubert *.la) 11038*b50261e2SCy Schubert # Only pass preopened files to the pseudo-archive (for 11039*b50261e2SCy Schubert # eventual linking with the app. that links it) if we 11040*b50261e2SCy Schubert # didn't already link the preopened objects directly into 11041*b50261e2SCy Schubert # the library: 11042*b50261e2SCy Schubert func_basename "$lib" 11043*b50261e2SCy Schubert name=$func_basename_result 11044*b50261e2SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11045*b50261e2SCy Schubert test -z "$libdir" && \ 11046*b50261e2SCy Schubert func_fatal_error "'$lib' is not a valid libtool archive" 11047*b50261e2SCy Schubert func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11048*b50261e2SCy Schubert ;; 11049*b50261e2SCy Schubert esac 11050*b50261e2SCy Schubert done 11051*b50261e2SCy Schubert dlprefiles=$newdlprefiles 11052*b50261e2SCy Schubert else 11053*b50261e2SCy Schubert newdlfiles= 11054*b50261e2SCy Schubert for lib in $dlfiles; do 11055*b50261e2SCy Schubert case $lib in 11056*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11057*b50261e2SCy Schubert *) abs=`pwd`"/$lib" ;; 11058*b50261e2SCy Schubert esac 11059*b50261e2SCy Schubert func_append newdlfiles " $abs" 11060*b50261e2SCy Schubert done 11061*b50261e2SCy Schubert dlfiles=$newdlfiles 11062*b50261e2SCy Schubert newdlprefiles= 11063*b50261e2SCy Schubert for lib in $dlprefiles; do 11064*b50261e2SCy Schubert case $lib in 11065*b50261e2SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11066*b50261e2SCy Schubert *) abs=`pwd`"/$lib" ;; 11067*b50261e2SCy Schubert esac 11068*b50261e2SCy Schubert func_append newdlprefiles " $abs" 11069*b50261e2SCy Schubert done 11070*b50261e2SCy Schubert dlprefiles=$newdlprefiles 11071*b50261e2SCy Schubert fi 11072*b50261e2SCy Schubert $RM $output 11073*b50261e2SCy Schubert # place dlname in correct position for cygwin 11074*b50261e2SCy Schubert # In fact, it would be nice if we could use this code for all target 11075*b50261e2SCy Schubert # systems that can't hard-code library paths into their executables 11076*b50261e2SCy Schubert # and that have no shared library path variable independent of PATH, 11077*b50261e2SCy Schubert # but it turns out we can't easily determine that from inspecting 11078*b50261e2SCy Schubert # libtool variables, so we have to hard-code the OSs to which it 11079*b50261e2SCy Schubert # applies here; at the moment, that means platforms that use the PE 11080*b50261e2SCy Schubert # object format with DLL files. See the long comment at the top of 11081*b50261e2SCy Schubert # tests/bindir.at for full details. 11082*b50261e2SCy Schubert tdlname=$dlname 11083*b50261e2SCy Schubert case $host,$output,$installed,$module,$dlname in 11084*b50261e2SCy Schubert *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11085*b50261e2SCy Schubert # If a -bindir argument was supplied, place the dll there. 11086*b50261e2SCy Schubert if test -n "$bindir"; then 11087*b50261e2SCy Schubert func_relative_path "$install_libdir" "$bindir" 11088*b50261e2SCy Schubert tdlname=$func_relative_path_result/$dlname 11089*b50261e2SCy Schubert else 11090*b50261e2SCy Schubert # Otherwise fall back on heuristic. 11091*b50261e2SCy Schubert tdlname=../bin/$dlname 11092*b50261e2SCy Schubert fi 11093*b50261e2SCy Schubert ;; 11094*b50261e2SCy Schubert esac 11095*b50261e2SCy Schubert $ECHO > $output "\ 11096*b50261e2SCy Schubert# $outputname - a libtool library file 11097*b50261e2SCy Schubert# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11098*b50261e2SCy Schubert# 11099*b50261e2SCy Schubert# Please DO NOT delete this file! 11100*b50261e2SCy Schubert# It is necessary for linking the library. 11101*b50261e2SCy Schubert 11102*b50261e2SCy Schubert# The name that we can dlopen(3). 11103*b50261e2SCy Schubertdlname='$tdlname' 11104*b50261e2SCy Schubert 11105*b50261e2SCy Schubert# Names of this library. 11106*b50261e2SCy Schubertlibrary_names='$library_names' 11107*b50261e2SCy Schubert 11108*b50261e2SCy Schubert# The name of the static archive. 11109*b50261e2SCy Schubertold_library='$old_library' 11110*b50261e2SCy Schubert 11111*b50261e2SCy Schubert# Linker flags that cannot go in dependency_libs. 11112*b50261e2SCy Schubertinherited_linker_flags='$new_inherited_linker_flags' 11113*b50261e2SCy Schubert 11114*b50261e2SCy Schubert# Libraries that this one depends upon. 11115*b50261e2SCy Schubertdependency_libs='$dependency_libs' 11116*b50261e2SCy Schubert 11117*b50261e2SCy Schubert# Names of additional weak libraries provided by this library 11118*b50261e2SCy Schubertweak_library_names='$weak_libs' 11119*b50261e2SCy Schubert 11120*b50261e2SCy Schubert# Version information for $libname. 11121*b50261e2SCy Schubertcurrent=$current 11122*b50261e2SCy Schubertage=$age 11123*b50261e2SCy Schubertrevision=$revision 11124*b50261e2SCy Schubert 11125*b50261e2SCy Schubert# Is this an already installed library? 11126*b50261e2SCy Schubertinstalled=$installed 11127*b50261e2SCy Schubert 11128*b50261e2SCy Schubert# Should we warn about portability when linking against -modules? 11129*b50261e2SCy Schubertshouldnotlink=$module 11130*b50261e2SCy Schubert 11131*b50261e2SCy Schubert# Files to dlopen/dlpreopen 11132*b50261e2SCy Schubertdlopen='$dlfiles' 11133*b50261e2SCy Schubertdlpreopen='$dlprefiles' 11134*b50261e2SCy Schubert 11135*b50261e2SCy Schubert# Directory that this library needs to be installed in: 11136*b50261e2SCy Schubertlibdir='$install_libdir'" 11137*b50261e2SCy Schubert if test no,yes = "$installed,$need_relink"; then 11138*b50261e2SCy Schubert $ECHO >> $output "\ 11139*b50261e2SCy Schubertrelink_command=\"$relink_command\"" 11140*b50261e2SCy Schubert fi 11141*b50261e2SCy Schubert done 11142*b50261e2SCy Schubert } 11143*b50261e2SCy Schubert 11144*b50261e2SCy Schubert # Do a symbolic link so that the libtool archive can be found in 11145*b50261e2SCy Schubert # LD_LIBRARY_PATH before the program is installed. 11146*b50261e2SCy Schubert func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11147*b50261e2SCy Schubert ;; 11148*b50261e2SCy Schubert esac 11149*b50261e2SCy Schubert exit $EXIT_SUCCESS 11150*b50261e2SCy Schubert} 11151*b50261e2SCy Schubert 11152*b50261e2SCy Schubertif test link = "$opt_mode" || test relink = "$opt_mode"; then 11153*b50261e2SCy Schubert func_mode_link ${1+"$@"} 11154*b50261e2SCy Schubertfi 11155*b50261e2SCy Schubert 11156*b50261e2SCy Schubert 11157*b50261e2SCy Schubert# func_mode_uninstall arg... 11158*b50261e2SCy Schubertfunc_mode_uninstall () 11159*b50261e2SCy Schubert{ 11160*b50261e2SCy Schubert $debug_cmd 11161*b50261e2SCy Schubert 11162*b50261e2SCy Schubert RM=$nonopt 11163*b50261e2SCy Schubert files= 11164*b50261e2SCy Schubert rmforce=false 11165*b50261e2SCy Schubert exit_status=0 11166*b50261e2SCy Schubert 11167*b50261e2SCy Schubert # This variable tells wrapper scripts just to set variables rather 11168*b50261e2SCy Schubert # than running their programs. 11169*b50261e2SCy Schubert libtool_install_magic=$magic 11170*b50261e2SCy Schubert 11171*b50261e2SCy Schubert for arg 11172*b50261e2SCy Schubert do 11173*b50261e2SCy Schubert case $arg in 11174*b50261e2SCy Schubert -f) func_append RM " $arg"; rmforce=: ;; 11175*b50261e2SCy Schubert -*) func_append RM " $arg" ;; 11176*b50261e2SCy Schubert *) func_append files " $arg" ;; 11177*b50261e2SCy Schubert esac 11178*b50261e2SCy Schubert done 11179*b50261e2SCy Schubert 11180*b50261e2SCy Schubert test -z "$RM" && \ 11181*b50261e2SCy Schubert func_fatal_help "you must specify an RM program" 11182*b50261e2SCy Schubert 11183*b50261e2SCy Schubert rmdirs= 11184*b50261e2SCy Schubert 11185*b50261e2SCy Schubert for file in $files; do 11186*b50261e2SCy Schubert func_dirname "$file" "" "." 11187*b50261e2SCy Schubert dir=$func_dirname_result 11188*b50261e2SCy Schubert if test . = "$dir"; then 11189*b50261e2SCy Schubert odir=$objdir 11190*b50261e2SCy Schubert else 11191*b50261e2SCy Schubert odir=$dir/$objdir 11192*b50261e2SCy Schubert fi 11193*b50261e2SCy Schubert func_basename "$file" 11194*b50261e2SCy Schubert name=$func_basename_result 11195*b50261e2SCy Schubert test uninstall = "$opt_mode" && odir=$dir 11196*b50261e2SCy Schubert 11197*b50261e2SCy Schubert # Remember odir for removal later, being careful to avoid duplicates 11198*b50261e2SCy Schubert if test clean = "$opt_mode"; then 11199*b50261e2SCy Schubert case " $rmdirs " in 11200*b50261e2SCy Schubert *" $odir "*) ;; 11201*b50261e2SCy Schubert *) func_append rmdirs " $odir" ;; 11202*b50261e2SCy Schubert esac 11203*b50261e2SCy Schubert fi 11204*b50261e2SCy Schubert 11205*b50261e2SCy Schubert # Don't error if the file doesn't exist and rm -f was used. 11206*b50261e2SCy Schubert if { test -L "$file"; } >/dev/null 2>&1 || 11207*b50261e2SCy Schubert { test -h "$file"; } >/dev/null 2>&1 || 11208*b50261e2SCy Schubert test -f "$file"; then 11209*b50261e2SCy Schubert : 11210*b50261e2SCy Schubert elif test -d "$file"; then 11211*b50261e2SCy Schubert exit_status=1 11212*b50261e2SCy Schubert continue 11213*b50261e2SCy Schubert elif $rmforce; then 11214*b50261e2SCy Schubert continue 11215*b50261e2SCy Schubert fi 11216*b50261e2SCy Schubert 11217*b50261e2SCy Schubert rmfiles=$file 11218*b50261e2SCy Schubert 11219*b50261e2SCy Schubert case $name in 11220*b50261e2SCy Schubert *.la) 11221*b50261e2SCy Schubert # Possibly a libtool archive, so verify it. 11222*b50261e2SCy Schubert if func_lalib_p "$file"; then 11223*b50261e2SCy Schubert func_source $dir/$name 11224*b50261e2SCy Schubert 11225*b50261e2SCy Schubert # Delete the libtool libraries and symlinks. 11226*b50261e2SCy Schubert for n in $library_names; do 11227*b50261e2SCy Schubert func_append rmfiles " $odir/$n" 11228*b50261e2SCy Schubert done 11229*b50261e2SCy Schubert test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11230*b50261e2SCy Schubert 11231*b50261e2SCy Schubert case $opt_mode in 11232*b50261e2SCy Schubert clean) 11233*b50261e2SCy Schubert case " $library_names " in 11234*b50261e2SCy Schubert *" $dlname "*) ;; 11235*b50261e2SCy Schubert *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11236*b50261e2SCy Schubert esac 11237*b50261e2SCy Schubert test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11238*b50261e2SCy Schubert ;; 11239*b50261e2SCy Schubert uninstall) 11240*b50261e2SCy Schubert if test -n "$library_names"; then 11241*b50261e2SCy Schubert # Do each command in the postuninstall commands. 11242*b50261e2SCy Schubert func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11243*b50261e2SCy Schubert fi 11244*b50261e2SCy Schubert 11245*b50261e2SCy Schubert if test -n "$old_library"; then 11246*b50261e2SCy Schubert # Do each command in the old_postuninstall commands. 11247*b50261e2SCy Schubert func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11248*b50261e2SCy Schubert fi 11249*b50261e2SCy Schubert # FIXME: should reinstall the best remaining shared library. 11250*b50261e2SCy Schubert ;; 11251*b50261e2SCy Schubert esac 11252*b50261e2SCy Schubert fi 11253*b50261e2SCy Schubert ;; 11254*b50261e2SCy Schubert 11255*b50261e2SCy Schubert *.lo) 11256*b50261e2SCy Schubert # Possibly a libtool object, so verify it. 11257*b50261e2SCy Schubert if func_lalib_p "$file"; then 11258*b50261e2SCy Schubert 11259*b50261e2SCy Schubert # Read the .lo file 11260*b50261e2SCy Schubert func_source $dir/$name 11261*b50261e2SCy Schubert 11262*b50261e2SCy Schubert # Add PIC object to the list of files to remove. 11263*b50261e2SCy Schubert if test -n "$pic_object" && test none != "$pic_object"; then 11264*b50261e2SCy Schubert func_append rmfiles " $dir/$pic_object" 11265*b50261e2SCy Schubert fi 11266*b50261e2SCy Schubert 11267*b50261e2SCy Schubert # Add non-PIC object to the list of files to remove. 11268*b50261e2SCy Schubert if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11269*b50261e2SCy Schubert func_append rmfiles " $dir/$non_pic_object" 11270*b50261e2SCy Schubert fi 11271*b50261e2SCy Schubert fi 11272*b50261e2SCy Schubert ;; 11273*b50261e2SCy Schubert 11274*b50261e2SCy Schubert *) 11275*b50261e2SCy Schubert if test clean = "$opt_mode"; then 11276*b50261e2SCy Schubert noexename=$name 11277*b50261e2SCy Schubert case $file in 11278*b50261e2SCy Schubert *.exe) 11279*b50261e2SCy Schubert func_stripname '' '.exe' "$file" 11280*b50261e2SCy Schubert file=$func_stripname_result 11281*b50261e2SCy Schubert func_stripname '' '.exe' "$name" 11282*b50261e2SCy Schubert noexename=$func_stripname_result 11283*b50261e2SCy Schubert # $file with .exe has already been added to rmfiles, 11284*b50261e2SCy Schubert # add $file without .exe 11285*b50261e2SCy Schubert func_append rmfiles " $file" 11286*b50261e2SCy Schubert ;; 11287*b50261e2SCy Schubert esac 11288*b50261e2SCy Schubert # Do a test to see if this is a libtool program. 11289*b50261e2SCy Schubert if func_ltwrapper_p "$file"; then 11290*b50261e2SCy Schubert if func_ltwrapper_executable_p "$file"; then 11291*b50261e2SCy Schubert func_ltwrapper_scriptname "$file" 11292*b50261e2SCy Schubert relink_command= 11293*b50261e2SCy Schubert func_source $func_ltwrapper_scriptname_result 11294*b50261e2SCy Schubert func_append rmfiles " $func_ltwrapper_scriptname_result" 11295*b50261e2SCy Schubert else 11296*b50261e2SCy Schubert relink_command= 11297*b50261e2SCy Schubert func_source $dir/$noexename 11298*b50261e2SCy Schubert fi 11299*b50261e2SCy Schubert 11300*b50261e2SCy Schubert # note $name still contains .exe if it was in $file originally 11301*b50261e2SCy Schubert # as does the version of $file that was added into $rmfiles 11302*b50261e2SCy Schubert func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11303*b50261e2SCy Schubert if test yes = "$fast_install" && test -n "$relink_command"; then 11304*b50261e2SCy Schubert func_append rmfiles " $odir/lt-$name" 11305*b50261e2SCy Schubert fi 11306*b50261e2SCy Schubert if test "X$noexename" != "X$name"; then 11307*b50261e2SCy Schubert func_append rmfiles " $odir/lt-$noexename.c" 11308*b50261e2SCy Schubert fi 11309*b50261e2SCy Schubert fi 11310*b50261e2SCy Schubert fi 11311*b50261e2SCy Schubert ;; 11312*b50261e2SCy Schubert esac 11313*b50261e2SCy Schubert func_show_eval "$RM $rmfiles" 'exit_status=1' 11314*b50261e2SCy Schubert done 11315*b50261e2SCy Schubert 11316*b50261e2SCy Schubert # Try to remove the $objdir's in the directories where we deleted files 11317*b50261e2SCy Schubert for dir in $rmdirs; do 11318*b50261e2SCy Schubert if test -d "$dir"; then 11319*b50261e2SCy Schubert func_show_eval "rmdir $dir >/dev/null 2>&1" 11320*b50261e2SCy Schubert fi 11321*b50261e2SCy Schubert done 11322*b50261e2SCy Schubert 11323*b50261e2SCy Schubert exit $exit_status 11324*b50261e2SCy Schubert} 11325*b50261e2SCy Schubert 11326*b50261e2SCy Schubertif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11327*b50261e2SCy Schubert func_mode_uninstall ${1+"$@"} 11328*b50261e2SCy Schubertfi 11329*b50261e2SCy Schubert 11330*b50261e2SCy Schuberttest -z "$opt_mode" && { 11331*b50261e2SCy Schubert help=$generic_help 11332*b50261e2SCy Schubert func_fatal_help "you must specify a MODE" 11333*b50261e2SCy Schubert} 11334*b50261e2SCy Schubert 11335*b50261e2SCy Schuberttest -z "$exec_cmd" && \ 11336*b50261e2SCy Schubert func_fatal_help "invalid operation mode '$opt_mode'" 11337*b50261e2SCy Schubert 11338*b50261e2SCy Schubertif test -n "$exec_cmd"; then 11339*b50261e2SCy Schubert eval exec "$exec_cmd" 11340*b50261e2SCy Schubert exit $EXIT_FAILURE 11341*b50261e2SCy Schubertfi 11342*b50261e2SCy Schubert 11343*b50261e2SCy Schubertexit $exit_status 11344*b50261e2SCy Schubert 11345*b50261e2SCy Schubert 11346*b50261e2SCy Schubert# The TAGs below are defined such that we never get into a situation 11347*b50261e2SCy Schubert# where we disable both kinds of libraries. Given conflicting 11348*b50261e2SCy Schubert# choices, we go for a static library, that is the most portable, 11349*b50261e2SCy Schubert# since we can't tell whether shared libraries were disabled because 11350*b50261e2SCy Schubert# the user asked for that or because the platform doesn't support 11351*b50261e2SCy Schubert# them. This is particularly important on AIX, because we don't 11352*b50261e2SCy Schubert# support having both static and shared libraries enabled at the same 11353*b50261e2SCy Schubert# time on that platform, so we default to a shared-only configuration. 11354*b50261e2SCy Schubert# If a disable-shared tag is given, we'll fallback to a static-only 11355*b50261e2SCy Schubert# configuration. But we'll never go from static-only to shared-only. 11356*b50261e2SCy Schubert 11357*b50261e2SCy Schubert# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11358*b50261e2SCy Schubertbuild_libtool_libs=no 11359*b50261e2SCy Schubertbuild_old_libs=yes 11360*b50261e2SCy Schubert# ### END LIBTOOL TAG CONFIG: disable-shared 11361*b50261e2SCy Schubert 11362*b50261e2SCy Schubert# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11363*b50261e2SCy Schubertbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11364*b50261e2SCy Schubert# ### END LIBTOOL TAG CONFIG: disable-static 11365*b50261e2SCy Schubert 11366*b50261e2SCy Schubert# Local Variables: 11367*b50261e2SCy Schubert# mode:shell-script 11368*b50261e2SCy Schubert# sh-indentation:2 11369*b50261e2SCy Schubert# End: 11370