1*a466cc55SCy Schubert#! /bin/sh 2*a466cc55SCy Schubert## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3*a466cc55SCy Schubert## by inline-source v2014-01-03.01 4*a466cc55SCy Schubert 5*a466cc55SCy Schubert# libtool (GNU libtool) 2.4.6 6*a466cc55SCy Schubert# Provide generalized library-building support services. 7*a466cc55SCy Schubert# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8*a466cc55SCy Schubert 9*a466cc55SCy Schubert# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10*a466cc55SCy Schubert# This is free software; see the source for copying conditions. There is NO 11*a466cc55SCy Schubert# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12*a466cc55SCy Schubert 13*a466cc55SCy Schubert# GNU Libtool is free software; you can redistribute it and/or modify 14*a466cc55SCy Schubert# it under the terms of the GNU General Public License as published by 15*a466cc55SCy Schubert# the Free Software Foundation; either version 2 of the License, or 16*a466cc55SCy Schubert# (at your option) any later version. 17*a466cc55SCy Schubert# 18*a466cc55SCy Schubert# As a special exception to the GNU General Public License, 19*a466cc55SCy Schubert# if you distribute this file as part of a program or library that 20*a466cc55SCy Schubert# is built using GNU Libtool, you may include this file under the 21*a466cc55SCy Schubert# same distribution terms that you use for the rest of that program. 22*a466cc55SCy Schubert# 23*a466cc55SCy Schubert# GNU Libtool is distributed in the hope that it will be useful, but 24*a466cc55SCy Schubert# WITHOUT ANY WARRANTY; without even the implied warranty of 25*a466cc55SCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26*a466cc55SCy Schubert# General Public License for more details. 27*a466cc55SCy Schubert# 28*a466cc55SCy Schubert# You should have received a copy of the GNU General Public License 29*a466cc55SCy Schubert# along with this program. If not, see <http://www.gnu.org/licenses/>. 30*a466cc55SCy Schubert 31*a466cc55SCy Schubert 32*a466cc55SCy SchubertPROGRAM=libtool 33*a466cc55SCy SchubertPACKAGE=libtool 34*a466cc55SCy SchubertVERSION=2.4.6 35*a466cc55SCy Schubertpackage_revision=2.4.6 36*a466cc55SCy Schubert 37*a466cc55SCy Schubert 38*a466cc55SCy Schubert## ------ ## 39*a466cc55SCy Schubert## Usage. ## 40*a466cc55SCy Schubert## ------ ## 41*a466cc55SCy Schubert 42*a466cc55SCy Schubert# Run './libtool --help' for help with using this script from the 43*a466cc55SCy Schubert# command line. 44*a466cc55SCy Schubert 45*a466cc55SCy Schubert 46*a466cc55SCy Schubert## ------------------------------- ## 47*a466cc55SCy Schubert## User overridable command paths. ## 48*a466cc55SCy Schubert## ------------------------------- ## 49*a466cc55SCy Schubert 50*a466cc55SCy Schubert# After configure completes, it has a better idea of some of the 51*a466cc55SCy Schubert# shell tools we need than the defaults used by the functions shared 52*a466cc55SCy Schubert# with bootstrap, so set those here where they can still be over- 53*a466cc55SCy Schubert# ridden by the user, but otherwise take precedence. 54*a466cc55SCy Schubert 55*a466cc55SCy Schubert: ${AUTOCONF="autoconf"} 56*a466cc55SCy Schubert: ${AUTOMAKE="automake"} 57*a466cc55SCy Schubert 58*a466cc55SCy Schubert 59*a466cc55SCy Schubert## -------------------------- ## 60*a466cc55SCy Schubert## Source external libraries. ## 61*a466cc55SCy Schubert## -------------------------- ## 62*a466cc55SCy Schubert 63*a466cc55SCy Schubert# Much of our low-level functionality needs to be sourced from external 64*a466cc55SCy Schubert# libraries, which are installed to $pkgauxdir. 65*a466cc55SCy Schubert 66*a466cc55SCy Schubert# Set a version string for this script. 67*a466cc55SCy Schubertscriptversion=2015-01-20.17; # UTC 68*a466cc55SCy Schubert 69*a466cc55SCy Schubert# General shell script boiler plate, and helper functions. 70*a466cc55SCy Schubert# Written by Gary V. Vaughan, 2004 71*a466cc55SCy Schubert 72*a466cc55SCy Schubert# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73*a466cc55SCy Schubert# This is free software; see the source for copying conditions. There is NO 74*a466cc55SCy Schubert# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75*a466cc55SCy Schubert 76*a466cc55SCy Schubert# This program is free software; you can redistribute it and/or modify 77*a466cc55SCy Schubert# it under the terms of the GNU General Public License as published by 78*a466cc55SCy Schubert# the Free Software Foundation; either version 3 of the License, or 79*a466cc55SCy Schubert# (at your option) any later version. 80*a466cc55SCy Schubert 81*a466cc55SCy Schubert# As a special exception to the GNU General Public License, if you distribute 82*a466cc55SCy Schubert# this file as part of a program or library that is built using GNU Libtool, 83*a466cc55SCy Schubert# you may include this file under the same distribution terms that you use 84*a466cc55SCy Schubert# for the rest of that program. 85*a466cc55SCy Schubert 86*a466cc55SCy Schubert# This program is distributed in the hope that it will be useful, 87*a466cc55SCy Schubert# but WITHOUT ANY WARRANTY; without even the implied warranty of 88*a466cc55SCy Schubert# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89*a466cc55SCy Schubert# General Public License for more details. 90*a466cc55SCy Schubert 91*a466cc55SCy Schubert# You should have received a copy of the GNU General Public License 92*a466cc55SCy Schubert# along with this program. If not, see <http://www.gnu.org/licenses/>. 93*a466cc55SCy Schubert 94*a466cc55SCy Schubert# Please report bugs or propose patches to gary@gnu.org. 95*a466cc55SCy Schubert 96*a466cc55SCy Schubert 97*a466cc55SCy Schubert## ------ ## 98*a466cc55SCy Schubert## Usage. ## 99*a466cc55SCy Schubert## ------ ## 100*a466cc55SCy Schubert 101*a466cc55SCy Schubert# Evaluate this file near the top of your script to gain access to 102*a466cc55SCy Schubert# the functions and variables defined here: 103*a466cc55SCy Schubert# 104*a466cc55SCy Schubert# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105*a466cc55SCy Schubert# 106*a466cc55SCy Schubert# If you need to override any of the default environment variable 107*a466cc55SCy Schubert# settings, do that before evaluating this file. 108*a466cc55SCy Schubert 109*a466cc55SCy Schubert 110*a466cc55SCy Schubert## -------------------- ## 111*a466cc55SCy Schubert## Shell normalisation. ## 112*a466cc55SCy Schubert## -------------------- ## 113*a466cc55SCy Schubert 114*a466cc55SCy Schubert# Some shells need a little help to be as Bourne compatible as possible. 115*a466cc55SCy Schubert# Before doing anything else, make sure all that help has been provided! 116*a466cc55SCy Schubert 117*a466cc55SCy SchubertDUALCASE=1; export DUALCASE # for MKS sh 118*a466cc55SCy Schubertif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119*a466cc55SCy Schubert emulate sh 120*a466cc55SCy Schubert NULLCMD=: 121*a466cc55SCy Schubert # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122*a466cc55SCy Schubert # is contrary to our usage. Disable this feature. 123*a466cc55SCy Schubert alias -g '${1+"$@"}'='"$@"' 124*a466cc55SCy Schubert setopt NO_GLOB_SUBST 125*a466cc55SCy Schubertelse 126*a466cc55SCy Schubert case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127*a466cc55SCy Schubertfi 128*a466cc55SCy Schubert 129*a466cc55SCy Schubert# NLS nuisances: We save the old values in case they are required later. 130*a466cc55SCy Schubert_G_user_locale= 131*a466cc55SCy Schubert_G_safe_locale= 132*a466cc55SCy Schubertfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133*a466cc55SCy Schubertdo 134*a466cc55SCy Schubert eval "if test set = \"\${$_G_var+set}\"; then 135*a466cc55SCy Schubert save_$_G_var=\$$_G_var 136*a466cc55SCy Schubert $_G_var=C 137*a466cc55SCy Schubert export $_G_var 138*a466cc55SCy Schubert _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139*a466cc55SCy Schubert _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140*a466cc55SCy Schubert fi" 141*a466cc55SCy Schubertdone 142*a466cc55SCy Schubert 143*a466cc55SCy Schubert# CDPATH. 144*a466cc55SCy Schubert(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145*a466cc55SCy Schubert 146*a466cc55SCy Schubert# Make sure IFS has a sensible default 147*a466cc55SCy Schubertsp=' ' 148*a466cc55SCy Schubertnl=' 149*a466cc55SCy Schubert' 150*a466cc55SCy SchubertIFS="$sp $nl" 151*a466cc55SCy Schubert 152*a466cc55SCy Schubert# There are apparently some retarded systems that use ';' as a PATH separator! 153*a466cc55SCy Schubertif test "${PATH_SEPARATOR+set}" != set; then 154*a466cc55SCy Schubert PATH_SEPARATOR=: 155*a466cc55SCy Schubert (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156*a466cc55SCy Schubert (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157*a466cc55SCy Schubert PATH_SEPARATOR=';' 158*a466cc55SCy Schubert } 159*a466cc55SCy Schubertfi 160*a466cc55SCy Schubert 161*a466cc55SCy Schubert 162*a466cc55SCy Schubert 163*a466cc55SCy Schubert## ------------------------- ## 164*a466cc55SCy Schubert## Locate command utilities. ## 165*a466cc55SCy Schubert## ------------------------- ## 166*a466cc55SCy Schubert 167*a466cc55SCy Schubert 168*a466cc55SCy Schubert# func_executable_p FILE 169*a466cc55SCy Schubert# ---------------------- 170*a466cc55SCy Schubert# Check that FILE is an executable regular file. 171*a466cc55SCy Schubertfunc_executable_p () 172*a466cc55SCy Schubert{ 173*a466cc55SCy Schubert test -f "$1" && test -x "$1" 174*a466cc55SCy Schubert} 175*a466cc55SCy Schubert 176*a466cc55SCy Schubert 177*a466cc55SCy Schubert# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178*a466cc55SCy Schubert# -------------------------------------------- 179*a466cc55SCy Schubert# Search for either a program that responds to --version with output 180*a466cc55SCy Schubert# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181*a466cc55SCy Schubert# trying all the directories in PATH with each of the elements of 182*a466cc55SCy Schubert# PROGS_LIST. 183*a466cc55SCy Schubert# 184*a466cc55SCy Schubert# CHECK_FUNC should accept the path to a candidate program, and 185*a466cc55SCy Schubert# set $func_check_prog_result if it truncates its output less than 186*a466cc55SCy Schubert# $_G_path_prog_max characters. 187*a466cc55SCy Schubertfunc_path_progs () 188*a466cc55SCy Schubert{ 189*a466cc55SCy Schubert _G_progs_list=$1 190*a466cc55SCy Schubert _G_check_func=$2 191*a466cc55SCy Schubert _G_PATH=${3-"$PATH"} 192*a466cc55SCy Schubert 193*a466cc55SCy Schubert _G_path_prog_max=0 194*a466cc55SCy Schubert _G_path_prog_found=false 195*a466cc55SCy Schubert _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196*a466cc55SCy Schubert for _G_dir in $_G_PATH; do 197*a466cc55SCy Schubert IFS=$_G_save_IFS 198*a466cc55SCy Schubert test -z "$_G_dir" && _G_dir=. 199*a466cc55SCy Schubert for _G_prog_name in $_G_progs_list; do 200*a466cc55SCy Schubert for _exeext in '' .EXE; do 201*a466cc55SCy Schubert _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202*a466cc55SCy Schubert func_executable_p "$_G_path_prog" || continue 203*a466cc55SCy Schubert case `"$_G_path_prog" --version 2>&1` in 204*a466cc55SCy Schubert *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205*a466cc55SCy Schubert *) $_G_check_func $_G_path_prog 206*a466cc55SCy Schubert func_path_progs_result=$func_check_prog_result 207*a466cc55SCy Schubert ;; 208*a466cc55SCy Schubert esac 209*a466cc55SCy Schubert $_G_path_prog_found && break 3 210*a466cc55SCy Schubert done 211*a466cc55SCy Schubert done 212*a466cc55SCy Schubert done 213*a466cc55SCy Schubert IFS=$_G_save_IFS 214*a466cc55SCy Schubert test -z "$func_path_progs_result" && { 215*a466cc55SCy Schubert echo "no acceptable sed could be found in \$PATH" >&2 216*a466cc55SCy Schubert exit 1 217*a466cc55SCy Schubert } 218*a466cc55SCy Schubert} 219*a466cc55SCy Schubert 220*a466cc55SCy Schubert 221*a466cc55SCy Schubert# We want to be able to use the functions in this file before configure 222*a466cc55SCy Schubert# has figured out where the best binaries are kept, which means we have 223*a466cc55SCy Schubert# to search for them ourselves - except when the results are already set 224*a466cc55SCy Schubert# where we skip the searches. 225*a466cc55SCy Schubert 226*a466cc55SCy Schubert# Unless the user overrides by setting SED, search the path for either GNU 227*a466cc55SCy Schubert# sed, or the sed that truncates its output the least. 228*a466cc55SCy Schuberttest -z "$SED" && { 229*a466cc55SCy Schubert _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230*a466cc55SCy Schubert for _G_i in 1 2 3 4 5 6 7; do 231*a466cc55SCy Schubert _G_sed_script=$_G_sed_script$nl$_G_sed_script 232*a466cc55SCy Schubert done 233*a466cc55SCy Schubert echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234*a466cc55SCy Schubert _G_sed_script= 235*a466cc55SCy Schubert 236*a466cc55SCy Schubert func_check_prog_sed () 237*a466cc55SCy Schubert { 238*a466cc55SCy Schubert _G_path_prog=$1 239*a466cc55SCy Schubert 240*a466cc55SCy Schubert _G_count=0 241*a466cc55SCy Schubert printf 0123456789 >conftest.in 242*a466cc55SCy Schubert while : 243*a466cc55SCy Schubert do 244*a466cc55SCy Schubert cat conftest.in conftest.in >conftest.tmp 245*a466cc55SCy Schubert mv conftest.tmp conftest.in 246*a466cc55SCy Schubert cp conftest.in conftest.nl 247*a466cc55SCy Schubert echo '' >> conftest.nl 248*a466cc55SCy Schubert "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249*a466cc55SCy Schubert diff conftest.out conftest.nl >/dev/null 2>&1 || break 250*a466cc55SCy Schubert _G_count=`expr $_G_count + 1` 251*a466cc55SCy Schubert if test "$_G_count" -gt "$_G_path_prog_max"; then 252*a466cc55SCy Schubert # Best one so far, save it but keep looking for a better one 253*a466cc55SCy Schubert func_check_prog_result=$_G_path_prog 254*a466cc55SCy Schubert _G_path_prog_max=$_G_count 255*a466cc55SCy Schubert fi 256*a466cc55SCy Schubert # 10*(2^10) chars as input seems more than enough 257*a466cc55SCy Schubert test 10 -lt "$_G_count" && break 258*a466cc55SCy Schubert done 259*a466cc55SCy Schubert rm -f conftest.in conftest.tmp conftest.nl conftest.out 260*a466cc55SCy Schubert } 261*a466cc55SCy Schubert 262*a466cc55SCy Schubert func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263*a466cc55SCy Schubert rm -f conftest.sed 264*a466cc55SCy Schubert SED=$func_path_progs_result 265*a466cc55SCy Schubert} 266*a466cc55SCy Schubert 267*a466cc55SCy Schubert 268*a466cc55SCy Schubert# Unless the user overrides by setting GREP, search the path for either GNU 269*a466cc55SCy Schubert# grep, or the grep that truncates its output the least. 270*a466cc55SCy Schuberttest -z "$GREP" && { 271*a466cc55SCy Schubert func_check_prog_grep () 272*a466cc55SCy Schubert { 273*a466cc55SCy Schubert _G_path_prog=$1 274*a466cc55SCy Schubert 275*a466cc55SCy Schubert _G_count=0 276*a466cc55SCy Schubert _G_path_prog_max=0 277*a466cc55SCy Schubert printf 0123456789 >conftest.in 278*a466cc55SCy Schubert while : 279*a466cc55SCy Schubert do 280*a466cc55SCy Schubert cat conftest.in conftest.in >conftest.tmp 281*a466cc55SCy Schubert mv conftest.tmp conftest.in 282*a466cc55SCy Schubert cp conftest.in conftest.nl 283*a466cc55SCy Schubert echo 'GREP' >> conftest.nl 284*a466cc55SCy Schubert "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285*a466cc55SCy Schubert diff conftest.out conftest.nl >/dev/null 2>&1 || break 286*a466cc55SCy Schubert _G_count=`expr $_G_count + 1` 287*a466cc55SCy Schubert if test "$_G_count" -gt "$_G_path_prog_max"; then 288*a466cc55SCy Schubert # Best one so far, save it but keep looking for a better one 289*a466cc55SCy Schubert func_check_prog_result=$_G_path_prog 290*a466cc55SCy Schubert _G_path_prog_max=$_G_count 291*a466cc55SCy Schubert fi 292*a466cc55SCy Schubert # 10*(2^10) chars as input seems more than enough 293*a466cc55SCy Schubert test 10 -lt "$_G_count" && break 294*a466cc55SCy Schubert done 295*a466cc55SCy Schubert rm -f conftest.in conftest.tmp conftest.nl conftest.out 296*a466cc55SCy Schubert } 297*a466cc55SCy Schubert 298*a466cc55SCy Schubert func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299*a466cc55SCy Schubert GREP=$func_path_progs_result 300*a466cc55SCy Schubert} 301*a466cc55SCy Schubert 302*a466cc55SCy Schubert 303*a466cc55SCy Schubert## ------------------------------- ## 304*a466cc55SCy Schubert## User overridable command paths. ## 305*a466cc55SCy Schubert## ------------------------------- ## 306*a466cc55SCy Schubert 307*a466cc55SCy Schubert# All uppercase variable names are used for environment variables. These 308*a466cc55SCy Schubert# variables can be overridden by the user before calling a script that 309*a466cc55SCy Schubert# uses them if a suitable command of that name is not already available 310*a466cc55SCy Schubert# in the command search PATH. 311*a466cc55SCy Schubert 312*a466cc55SCy Schubert: ${CP="cp -f"} 313*a466cc55SCy Schubert: ${ECHO="printf %s\n"} 314*a466cc55SCy Schubert: ${EGREP="$GREP -E"} 315*a466cc55SCy Schubert: ${FGREP="$GREP -F"} 316*a466cc55SCy Schubert: ${LN_S="ln -s"} 317*a466cc55SCy Schubert: ${MAKE="make"} 318*a466cc55SCy Schubert: ${MKDIR="mkdir"} 319*a466cc55SCy Schubert: ${MV="mv -f"} 320*a466cc55SCy Schubert: ${RM="rm -f"} 321*a466cc55SCy Schubert: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322*a466cc55SCy Schubert 323*a466cc55SCy Schubert 324*a466cc55SCy Schubert## -------------------- ## 325*a466cc55SCy Schubert## Useful sed snippets. ## 326*a466cc55SCy Schubert## -------------------- ## 327*a466cc55SCy Schubert 328*a466cc55SCy Schubertsed_dirname='s|/[^/]*$||' 329*a466cc55SCy Schubertsed_basename='s|^.*/||' 330*a466cc55SCy Schubert 331*a466cc55SCy Schubert# Sed substitution that helps us do robust quoting. It backslashifies 332*a466cc55SCy Schubert# metacharacters that are still active within double-quoted strings. 333*a466cc55SCy Schubertsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334*a466cc55SCy Schubert 335*a466cc55SCy Schubert# Same as above, but do not quote variable references. 336*a466cc55SCy Schubertsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337*a466cc55SCy Schubert 338*a466cc55SCy Schubert# Sed substitution that turns a string into a regex matching for the 339*a466cc55SCy Schubert# string literally. 340*a466cc55SCy Schubertsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341*a466cc55SCy Schubert 342*a466cc55SCy Schubert# Sed substitution that converts a w32 file name or path 343*a466cc55SCy Schubert# that contains forward slashes, into one that contains 344*a466cc55SCy Schubert# (escaped) backslashes. A very naive implementation. 345*a466cc55SCy Schubertsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346*a466cc55SCy Schubert 347*a466cc55SCy Schubert# Re-'\' parameter expansions in output of sed_double_quote_subst that 348*a466cc55SCy Schubert# were '\'-ed in input to the same. If an odd number of '\' preceded a 349*a466cc55SCy Schubert# '$' in input to sed_double_quote_subst, that '$' was protected from 350*a466cc55SCy Schubert# expansion. Since each input '\' is now two '\'s, look for any number 351*a466cc55SCy Schubert# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352*a466cc55SCy Schubert_G_bs='\\' 353*a466cc55SCy Schubert_G_bs2='\\\\' 354*a466cc55SCy Schubert_G_bs4='\\\\\\\\' 355*a466cc55SCy Schubert_G_dollar='\$' 356*a466cc55SCy Schubertsed_double_backslash="\ 357*a466cc55SCy Schubert s/$_G_bs4/&\\ 358*a466cc55SCy Schubert/g 359*a466cc55SCy Schubert s/^$_G_bs2$_G_dollar/$_G_bs&/ 360*a466cc55SCy Schubert s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361*a466cc55SCy Schubert s/\n//g" 362*a466cc55SCy Schubert 363*a466cc55SCy Schubert 364*a466cc55SCy Schubert## ----------------- ## 365*a466cc55SCy Schubert## Global variables. ## 366*a466cc55SCy Schubert## ----------------- ## 367*a466cc55SCy Schubert 368*a466cc55SCy Schubert# Except for the global variables explicitly listed below, the following 369*a466cc55SCy Schubert# functions in the '^func_' namespace, and the '^require_' namespace 370*a466cc55SCy Schubert# variables initialised in the 'Resource management' section, sourcing 371*a466cc55SCy Schubert# this file will not pollute your global namespace with anything 372*a466cc55SCy Schubert# else. There's no portable way to scope variables in Bourne shell 373*a466cc55SCy Schubert# though, so actually running these functions will sometimes place 374*a466cc55SCy Schubert# results into a variable named after the function, and often use 375*a466cc55SCy Schubert# temporary variables in the '^_G_' namespace. If you are careful to 376*a466cc55SCy Schubert# avoid using those namespaces casually in your sourcing script, things 377*a466cc55SCy Schubert# should continue to work as you expect. And, of course, you can freely 378*a466cc55SCy Schubert# overwrite any of the functions or variables defined here before 379*a466cc55SCy Schubert# calling anything to customize them. 380*a466cc55SCy Schubert 381*a466cc55SCy SchubertEXIT_SUCCESS=0 382*a466cc55SCy SchubertEXIT_FAILURE=1 383*a466cc55SCy SchubertEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384*a466cc55SCy SchubertEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385*a466cc55SCy Schubert 386*a466cc55SCy Schubert# Allow overriding, eg assuming that you follow the convention of 387*a466cc55SCy Schubert# putting '$debug_cmd' at the start of all your functions, you can get 388*a466cc55SCy Schubert# bash to show function call trace with: 389*a466cc55SCy Schubert# 390*a466cc55SCy Schubert# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391*a466cc55SCy Schubertdebug_cmd=${debug_cmd-":"} 392*a466cc55SCy Schubertexit_cmd=: 393*a466cc55SCy Schubert 394*a466cc55SCy Schubert# By convention, finish your script with: 395*a466cc55SCy Schubert# 396*a466cc55SCy Schubert# exit $exit_status 397*a466cc55SCy Schubert# 398*a466cc55SCy Schubert# so that you can set exit_status to non-zero if you want to indicate 399*a466cc55SCy Schubert# something went wrong during execution without actually bailing out at 400*a466cc55SCy Schubert# the point of failure. 401*a466cc55SCy Schubertexit_status=$EXIT_SUCCESS 402*a466cc55SCy Schubert 403*a466cc55SCy Schubert# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404*a466cc55SCy Schubert# is ksh but when the shell is invoked as "sh" and the current value of 405*a466cc55SCy Schubert# the _XPG environment variable is not equal to 1 (one), the special 406*a466cc55SCy Schubert# positional parameter $0, within a function call, is the name of the 407*a466cc55SCy Schubert# function. 408*a466cc55SCy Schubertprogpath=$0 409*a466cc55SCy Schubert 410*a466cc55SCy Schubert# The name of this program. 411*a466cc55SCy Schubertprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412*a466cc55SCy Schubert 413*a466cc55SCy Schubert# Make sure we have an absolute progpath for reexecution: 414*a466cc55SCy Schubertcase $progpath in 415*a466cc55SCy Schubert [\\/]*|[A-Za-z]:\\*) ;; 416*a466cc55SCy Schubert *[\\/]*) 417*a466cc55SCy Schubert progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418*a466cc55SCy Schubert progdir=`cd "$progdir" && pwd` 419*a466cc55SCy Schubert progpath=$progdir/$progname 420*a466cc55SCy Schubert ;; 421*a466cc55SCy Schubert *) 422*a466cc55SCy Schubert _G_IFS=$IFS 423*a466cc55SCy Schubert IFS=${PATH_SEPARATOR-:} 424*a466cc55SCy Schubert for progdir in $PATH; do 425*a466cc55SCy Schubert IFS=$_G_IFS 426*a466cc55SCy Schubert test -x "$progdir/$progname" && break 427*a466cc55SCy Schubert done 428*a466cc55SCy Schubert IFS=$_G_IFS 429*a466cc55SCy Schubert test -n "$progdir" || progdir=`pwd` 430*a466cc55SCy Schubert progpath=$progdir/$progname 431*a466cc55SCy Schubert ;; 432*a466cc55SCy Schubertesac 433*a466cc55SCy Schubert 434*a466cc55SCy Schubert 435*a466cc55SCy Schubert## ----------------- ## 436*a466cc55SCy Schubert## Standard options. ## 437*a466cc55SCy Schubert## ----------------- ## 438*a466cc55SCy Schubert 439*a466cc55SCy Schubert# The following options affect the operation of the functions defined 440*a466cc55SCy Schubert# below, and should be set appropriately depending on run-time para- 441*a466cc55SCy Schubert# meters passed on the command line. 442*a466cc55SCy Schubert 443*a466cc55SCy Schubertopt_dry_run=false 444*a466cc55SCy Schubertopt_quiet=false 445*a466cc55SCy Schubertopt_verbose=false 446*a466cc55SCy Schubert 447*a466cc55SCy Schubert# Categories 'all' and 'none' are always available. Append any others 448*a466cc55SCy Schubert# you will pass as the first argument to func_warning from your own 449*a466cc55SCy Schubert# code. 450*a466cc55SCy Schubertwarning_categories= 451*a466cc55SCy Schubert 452*a466cc55SCy Schubert# By default, display warnings according to 'opt_warning_types'. Set 453*a466cc55SCy Schubert# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454*a466cc55SCy Schubert# treat the next displayed warning as a fatal error. 455*a466cc55SCy Schubertwarning_func=func_warn_and_continue 456*a466cc55SCy Schubert 457*a466cc55SCy Schubert# Set to 'all' to display all warnings, 'none' to suppress all 458*a466cc55SCy Schubert# warnings, or a space delimited list of some subset of 459*a466cc55SCy Schubert# 'warning_categories' to display only the listed warnings. 460*a466cc55SCy Schubertopt_warning_types=all 461*a466cc55SCy Schubert 462*a466cc55SCy Schubert 463*a466cc55SCy Schubert## -------------------- ## 464*a466cc55SCy Schubert## Resource management. ## 465*a466cc55SCy Schubert## -------------------- ## 466*a466cc55SCy Schubert 467*a466cc55SCy Schubert# This section contains definitions for functions that each ensure a 468*a466cc55SCy Schubert# particular resource (a file, or a non-empty configuration variable for 469*a466cc55SCy Schubert# example) is available, and if appropriate to extract default values 470*a466cc55SCy Schubert# from pertinent package files. Call them using their associated 471*a466cc55SCy Schubert# 'require_*' variable to ensure that they are executed, at most, once. 472*a466cc55SCy Schubert# 473*a466cc55SCy Schubert# It's entirely deliberate that calling these functions can set 474*a466cc55SCy Schubert# variables that don't obey the namespace limitations obeyed by the rest 475*a466cc55SCy Schubert# of this file, in order that that they be as useful as possible to 476*a466cc55SCy Schubert# callers. 477*a466cc55SCy Schubert 478*a466cc55SCy Schubert 479*a466cc55SCy Schubert# require_term_colors 480*a466cc55SCy Schubert# ------------------- 481*a466cc55SCy Schubert# Allow display of bold text on terminals that support it. 482*a466cc55SCy Schubertrequire_term_colors=func_require_term_colors 483*a466cc55SCy Schubertfunc_require_term_colors () 484*a466cc55SCy Schubert{ 485*a466cc55SCy Schubert $debug_cmd 486*a466cc55SCy Schubert 487*a466cc55SCy Schubert test -t 1 && { 488*a466cc55SCy Schubert # COLORTERM and USE_ANSI_COLORS environment variables take 489*a466cc55SCy Schubert # precedence, because most terminfo databases neglect to describe 490*a466cc55SCy Schubert # whether color sequences are supported. 491*a466cc55SCy Schubert test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492*a466cc55SCy Schubert 493*a466cc55SCy Schubert if test 1 = "$USE_ANSI_COLORS"; then 494*a466cc55SCy Schubert # Standard ANSI escape sequences 495*a466cc55SCy Schubert tc_reset='[0m' 496*a466cc55SCy Schubert tc_bold='[1m'; tc_standout='[7m' 497*a466cc55SCy Schubert tc_red='[31m'; tc_green='[32m' 498*a466cc55SCy Schubert tc_blue='[34m'; tc_cyan='[36m' 499*a466cc55SCy Schubert else 500*a466cc55SCy Schubert # Otherwise trust the terminfo database after all. 501*a466cc55SCy Schubert test -n "`tput sgr0 2>/dev/null`" && { 502*a466cc55SCy Schubert tc_reset=`tput sgr0` 503*a466cc55SCy Schubert test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504*a466cc55SCy Schubert tc_standout=$tc_bold 505*a466cc55SCy Schubert test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506*a466cc55SCy Schubert test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507*a466cc55SCy Schubert test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508*a466cc55SCy Schubert test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509*a466cc55SCy Schubert test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510*a466cc55SCy Schubert } 511*a466cc55SCy Schubert fi 512*a466cc55SCy Schubert } 513*a466cc55SCy Schubert 514*a466cc55SCy Schubert require_term_colors=: 515*a466cc55SCy Schubert} 516*a466cc55SCy Schubert 517*a466cc55SCy Schubert 518*a466cc55SCy Schubert## ----------------- ## 519*a466cc55SCy Schubert## Function library. ## 520*a466cc55SCy Schubert## ----------------- ## 521*a466cc55SCy Schubert 522*a466cc55SCy Schubert# This section contains a variety of useful functions to call in your 523*a466cc55SCy Schubert# scripts. Take note of the portable wrappers for features provided by 524*a466cc55SCy Schubert# some modern shells, which will fall back to slower equivalents on 525*a466cc55SCy Schubert# less featureful shells. 526*a466cc55SCy Schubert 527*a466cc55SCy Schubert 528*a466cc55SCy Schubert# func_append VAR VALUE 529*a466cc55SCy Schubert# --------------------- 530*a466cc55SCy Schubert# Append VALUE onto the existing contents of VAR. 531*a466cc55SCy Schubert 532*a466cc55SCy Schubert # We should try to minimise forks, especially on Windows where they are 533*a466cc55SCy Schubert # unreasonably slow, so skip the feature probes when bash or zsh are 534*a466cc55SCy Schubert # being used: 535*a466cc55SCy Schubert if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536*a466cc55SCy Schubert : ${_G_HAVE_ARITH_OP="yes"} 537*a466cc55SCy Schubert : ${_G_HAVE_XSI_OPS="yes"} 538*a466cc55SCy Schubert # The += operator was introduced in bash 3.1 539*a466cc55SCy Schubert case $BASH_VERSION in 540*a466cc55SCy Schubert [12].* | 3.0 | 3.0*) ;; 541*a466cc55SCy Schubert *) 542*a466cc55SCy Schubert : ${_G_HAVE_PLUSEQ_OP="yes"} 543*a466cc55SCy Schubert ;; 544*a466cc55SCy Schubert esac 545*a466cc55SCy Schubert fi 546*a466cc55SCy Schubert 547*a466cc55SCy Schubert # _G_HAVE_PLUSEQ_OP 548*a466cc55SCy Schubert # Can be empty, in which case the shell is probed, "yes" if += is 549*a466cc55SCy Schubert # useable or anything else if it does not work. 550*a466cc55SCy Schubert test -z "$_G_HAVE_PLUSEQ_OP" \ 551*a466cc55SCy Schubert && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552*a466cc55SCy Schubert && _G_HAVE_PLUSEQ_OP=yes 553*a466cc55SCy Schubert 554*a466cc55SCy Schubertif test yes = "$_G_HAVE_PLUSEQ_OP" 555*a466cc55SCy Schubertthen 556*a466cc55SCy Schubert # This is an XSI compatible shell, allowing a faster implementation... 557*a466cc55SCy Schubert eval 'func_append () 558*a466cc55SCy Schubert { 559*a466cc55SCy Schubert $debug_cmd 560*a466cc55SCy Schubert 561*a466cc55SCy Schubert eval "$1+=\$2" 562*a466cc55SCy Schubert }' 563*a466cc55SCy Schubertelse 564*a466cc55SCy Schubert # ...otherwise fall back to using expr, which is often a shell builtin. 565*a466cc55SCy Schubert func_append () 566*a466cc55SCy Schubert { 567*a466cc55SCy Schubert $debug_cmd 568*a466cc55SCy Schubert 569*a466cc55SCy Schubert eval "$1=\$$1\$2" 570*a466cc55SCy Schubert } 571*a466cc55SCy Schubertfi 572*a466cc55SCy Schubert 573*a466cc55SCy Schubert 574*a466cc55SCy Schubert# func_append_quoted VAR VALUE 575*a466cc55SCy Schubert# ---------------------------- 576*a466cc55SCy Schubert# Quote VALUE and append to the end of shell variable VAR, separated 577*a466cc55SCy Schubert# by a space. 578*a466cc55SCy Schubertif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579*a466cc55SCy Schubert eval 'func_append_quoted () 580*a466cc55SCy Schubert { 581*a466cc55SCy Schubert $debug_cmd 582*a466cc55SCy Schubert 583*a466cc55SCy Schubert func_quote_for_eval "$2" 584*a466cc55SCy Schubert eval "$1+=\\ \$func_quote_for_eval_result" 585*a466cc55SCy Schubert }' 586*a466cc55SCy Schubertelse 587*a466cc55SCy Schubert func_append_quoted () 588*a466cc55SCy Schubert { 589*a466cc55SCy Schubert $debug_cmd 590*a466cc55SCy Schubert 591*a466cc55SCy Schubert func_quote_for_eval "$2" 592*a466cc55SCy Schubert eval "$1=\$$1\\ \$func_quote_for_eval_result" 593*a466cc55SCy Schubert } 594*a466cc55SCy Schubertfi 595*a466cc55SCy Schubert 596*a466cc55SCy Schubert 597*a466cc55SCy Schubert# func_append_uniq VAR VALUE 598*a466cc55SCy Schubert# -------------------------- 599*a466cc55SCy Schubert# Append unique VALUE onto the existing contents of VAR, assuming 600*a466cc55SCy Schubert# entries are delimited by the first character of VALUE. For example: 601*a466cc55SCy Schubert# 602*a466cc55SCy Schubert# func_append_uniq options " --another-option option-argument" 603*a466cc55SCy Schubert# 604*a466cc55SCy Schubert# will only append to $options if " --another-option option-argument " 605*a466cc55SCy Schubert# is not already present somewhere in $options already (note spaces at 606*a466cc55SCy Schubert# each end implied by leading space in second argument). 607*a466cc55SCy Schubertfunc_append_uniq () 608*a466cc55SCy Schubert{ 609*a466cc55SCy Schubert $debug_cmd 610*a466cc55SCy Schubert 611*a466cc55SCy Schubert eval _G_current_value='`$ECHO $'$1'`' 612*a466cc55SCy Schubert _G_delim=`expr "$2" : '\(.\)'` 613*a466cc55SCy Schubert 614*a466cc55SCy Schubert case $_G_delim$_G_current_value$_G_delim in 615*a466cc55SCy Schubert *"$2$_G_delim"*) ;; 616*a466cc55SCy Schubert *) func_append "$@" ;; 617*a466cc55SCy Schubert esac 618*a466cc55SCy Schubert} 619*a466cc55SCy Schubert 620*a466cc55SCy Schubert 621*a466cc55SCy Schubert# func_arith TERM... 622*a466cc55SCy Schubert# ------------------ 623*a466cc55SCy Schubert# Set func_arith_result to the result of evaluating TERMs. 624*a466cc55SCy Schubert test -z "$_G_HAVE_ARITH_OP" \ 625*a466cc55SCy Schubert && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626*a466cc55SCy Schubert && _G_HAVE_ARITH_OP=yes 627*a466cc55SCy Schubert 628*a466cc55SCy Schubertif test yes = "$_G_HAVE_ARITH_OP"; then 629*a466cc55SCy Schubert eval 'func_arith () 630*a466cc55SCy Schubert { 631*a466cc55SCy Schubert $debug_cmd 632*a466cc55SCy Schubert 633*a466cc55SCy Schubert func_arith_result=$(( $* )) 634*a466cc55SCy Schubert }' 635*a466cc55SCy Schubertelse 636*a466cc55SCy Schubert func_arith () 637*a466cc55SCy Schubert { 638*a466cc55SCy Schubert $debug_cmd 639*a466cc55SCy Schubert 640*a466cc55SCy Schubert func_arith_result=`expr "$@"` 641*a466cc55SCy Schubert } 642*a466cc55SCy Schubertfi 643*a466cc55SCy Schubert 644*a466cc55SCy Schubert 645*a466cc55SCy Schubert# func_basename FILE 646*a466cc55SCy Schubert# ------------------ 647*a466cc55SCy Schubert# Set func_basename_result to FILE with everything up to and including 648*a466cc55SCy Schubert# the last / stripped. 649*a466cc55SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 650*a466cc55SCy Schubert # If this shell supports suffix pattern removal, then use it to avoid 651*a466cc55SCy Schubert # forking. Hide the definitions single quotes in case the shell chokes 652*a466cc55SCy Schubert # on unsupported syntax... 653*a466cc55SCy Schubert _b='func_basename_result=${1##*/}' 654*a466cc55SCy Schubert _d='case $1 in 655*a466cc55SCy Schubert */*) func_dirname_result=${1%/*}$2 ;; 656*a466cc55SCy Schubert * ) func_dirname_result=$3 ;; 657*a466cc55SCy Schubert esac' 658*a466cc55SCy Schubert 659*a466cc55SCy Schubertelse 660*a466cc55SCy Schubert # ...otherwise fall back to using sed. 661*a466cc55SCy Schubert _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662*a466cc55SCy Schubert _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663*a466cc55SCy Schubert if test "X$func_dirname_result" = "X$1"; then 664*a466cc55SCy Schubert func_dirname_result=$3 665*a466cc55SCy Schubert else 666*a466cc55SCy Schubert func_append func_dirname_result "$2" 667*a466cc55SCy Schubert fi' 668*a466cc55SCy Schubertfi 669*a466cc55SCy Schubert 670*a466cc55SCy Schuberteval 'func_basename () 671*a466cc55SCy Schubert{ 672*a466cc55SCy Schubert $debug_cmd 673*a466cc55SCy Schubert 674*a466cc55SCy Schubert '"$_b"' 675*a466cc55SCy Schubert}' 676*a466cc55SCy Schubert 677*a466cc55SCy Schubert 678*a466cc55SCy Schubert# func_dirname FILE APPEND NONDIR_REPLACEMENT 679*a466cc55SCy Schubert# ------------------------------------------- 680*a466cc55SCy Schubert# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681*a466cc55SCy Schubert# otherwise set result to NONDIR_REPLACEMENT. 682*a466cc55SCy Schuberteval 'func_dirname () 683*a466cc55SCy Schubert{ 684*a466cc55SCy Schubert $debug_cmd 685*a466cc55SCy Schubert 686*a466cc55SCy Schubert '"$_d"' 687*a466cc55SCy Schubert}' 688*a466cc55SCy Schubert 689*a466cc55SCy Schubert 690*a466cc55SCy Schubert# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691*a466cc55SCy Schubert# -------------------------------------------------------- 692*a466cc55SCy Schubert# Perform func_basename and func_dirname in a single function 693*a466cc55SCy Schubert# call: 694*a466cc55SCy Schubert# dirname: Compute the dirname of FILE. If nonempty, 695*a466cc55SCy Schubert# add APPEND to the result, otherwise set result 696*a466cc55SCy Schubert# to NONDIR_REPLACEMENT. 697*a466cc55SCy Schubert# value returned in "$func_dirname_result" 698*a466cc55SCy Schubert# basename: Compute filename of FILE. 699*a466cc55SCy Schubert# value retuned in "$func_basename_result" 700*a466cc55SCy Schubert# For efficiency, we do not delegate to the functions above but instead 701*a466cc55SCy Schubert# duplicate the functionality here. 702*a466cc55SCy Schuberteval 'func_dirname_and_basename () 703*a466cc55SCy Schubert{ 704*a466cc55SCy Schubert $debug_cmd 705*a466cc55SCy Schubert 706*a466cc55SCy Schubert '"$_b"' 707*a466cc55SCy Schubert '"$_d"' 708*a466cc55SCy Schubert}' 709*a466cc55SCy Schubert 710*a466cc55SCy Schubert 711*a466cc55SCy Schubert# func_echo ARG... 712*a466cc55SCy Schubert# ---------------- 713*a466cc55SCy Schubert# Echo program name prefixed message. 714*a466cc55SCy Schubertfunc_echo () 715*a466cc55SCy Schubert{ 716*a466cc55SCy Schubert $debug_cmd 717*a466cc55SCy Schubert 718*a466cc55SCy Schubert _G_message=$* 719*a466cc55SCy Schubert 720*a466cc55SCy Schubert func_echo_IFS=$IFS 721*a466cc55SCy Schubert IFS=$nl 722*a466cc55SCy Schubert for _G_line in $_G_message; do 723*a466cc55SCy Schubert IFS=$func_echo_IFS 724*a466cc55SCy Schubert $ECHO "$progname: $_G_line" 725*a466cc55SCy Schubert done 726*a466cc55SCy Schubert IFS=$func_echo_IFS 727*a466cc55SCy Schubert} 728*a466cc55SCy Schubert 729*a466cc55SCy Schubert 730*a466cc55SCy Schubert# func_echo_all ARG... 731*a466cc55SCy Schubert# -------------------- 732*a466cc55SCy Schubert# Invoke $ECHO with all args, space-separated. 733*a466cc55SCy Schubertfunc_echo_all () 734*a466cc55SCy Schubert{ 735*a466cc55SCy Schubert $ECHO "$*" 736*a466cc55SCy Schubert} 737*a466cc55SCy Schubert 738*a466cc55SCy Schubert 739*a466cc55SCy Schubert# func_echo_infix_1 INFIX ARG... 740*a466cc55SCy Schubert# ------------------------------ 741*a466cc55SCy Schubert# Echo program name, followed by INFIX on the first line, with any 742*a466cc55SCy Schubert# additional lines not showing INFIX. 743*a466cc55SCy Schubertfunc_echo_infix_1 () 744*a466cc55SCy Schubert{ 745*a466cc55SCy Schubert $debug_cmd 746*a466cc55SCy Schubert 747*a466cc55SCy Schubert $require_term_colors 748*a466cc55SCy Schubert 749*a466cc55SCy Schubert _G_infix=$1; shift 750*a466cc55SCy Schubert _G_indent=$_G_infix 751*a466cc55SCy Schubert _G_prefix="$progname: $_G_infix: " 752*a466cc55SCy Schubert _G_message=$* 753*a466cc55SCy Schubert 754*a466cc55SCy Schubert # Strip color escape sequences before counting printable length 755*a466cc55SCy Schubert for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756*a466cc55SCy Schubert do 757*a466cc55SCy Schubert test -n "$_G_tc" && { 758*a466cc55SCy Schubert _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759*a466cc55SCy Schubert _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760*a466cc55SCy Schubert } 761*a466cc55SCy Schubert done 762*a466cc55SCy Schubert _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763*a466cc55SCy Schubert 764*a466cc55SCy Schubert func_echo_infix_1_IFS=$IFS 765*a466cc55SCy Schubert IFS=$nl 766*a466cc55SCy Schubert for _G_line in $_G_message; do 767*a466cc55SCy Schubert IFS=$func_echo_infix_1_IFS 768*a466cc55SCy Schubert $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769*a466cc55SCy Schubert _G_prefix=$_G_indent 770*a466cc55SCy Schubert done 771*a466cc55SCy Schubert IFS=$func_echo_infix_1_IFS 772*a466cc55SCy Schubert} 773*a466cc55SCy Schubert 774*a466cc55SCy Schubert 775*a466cc55SCy Schubert# func_error ARG... 776*a466cc55SCy Schubert# ----------------- 777*a466cc55SCy Schubert# Echo program name prefixed message to standard error. 778*a466cc55SCy Schubertfunc_error () 779*a466cc55SCy Schubert{ 780*a466cc55SCy Schubert $debug_cmd 781*a466cc55SCy Schubert 782*a466cc55SCy Schubert $require_term_colors 783*a466cc55SCy Schubert 784*a466cc55SCy Schubert func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785*a466cc55SCy Schubert} 786*a466cc55SCy Schubert 787*a466cc55SCy Schubert 788*a466cc55SCy Schubert# func_fatal_error ARG... 789*a466cc55SCy Schubert# ----------------------- 790*a466cc55SCy Schubert# Echo program name prefixed message to standard error, and exit. 791*a466cc55SCy Schubertfunc_fatal_error () 792*a466cc55SCy Schubert{ 793*a466cc55SCy Schubert $debug_cmd 794*a466cc55SCy Schubert 795*a466cc55SCy Schubert func_error "$*" 796*a466cc55SCy Schubert exit $EXIT_FAILURE 797*a466cc55SCy Schubert} 798*a466cc55SCy Schubert 799*a466cc55SCy Schubert 800*a466cc55SCy Schubert# func_grep EXPRESSION FILENAME 801*a466cc55SCy Schubert# ----------------------------- 802*a466cc55SCy Schubert# Check whether EXPRESSION matches any line of FILENAME, without output. 803*a466cc55SCy Schubertfunc_grep () 804*a466cc55SCy Schubert{ 805*a466cc55SCy Schubert $debug_cmd 806*a466cc55SCy Schubert 807*a466cc55SCy Schubert $GREP "$1" "$2" >/dev/null 2>&1 808*a466cc55SCy Schubert} 809*a466cc55SCy Schubert 810*a466cc55SCy Schubert 811*a466cc55SCy Schubert# func_len STRING 812*a466cc55SCy Schubert# --------------- 813*a466cc55SCy Schubert# Set func_len_result to the length of STRING. STRING may not 814*a466cc55SCy Schubert# start with a hyphen. 815*a466cc55SCy Schubert test -z "$_G_HAVE_XSI_OPS" \ 816*a466cc55SCy Schubert && (eval 'x=a/b/c; 817*a466cc55SCy Schubert test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818*a466cc55SCy Schubert && _G_HAVE_XSI_OPS=yes 819*a466cc55SCy Schubert 820*a466cc55SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 821*a466cc55SCy Schubert eval 'func_len () 822*a466cc55SCy Schubert { 823*a466cc55SCy Schubert $debug_cmd 824*a466cc55SCy Schubert 825*a466cc55SCy Schubert func_len_result=${#1} 826*a466cc55SCy Schubert }' 827*a466cc55SCy Schubertelse 828*a466cc55SCy Schubert func_len () 829*a466cc55SCy Schubert { 830*a466cc55SCy Schubert $debug_cmd 831*a466cc55SCy Schubert 832*a466cc55SCy Schubert func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833*a466cc55SCy Schubert } 834*a466cc55SCy Schubertfi 835*a466cc55SCy Schubert 836*a466cc55SCy Schubert 837*a466cc55SCy Schubert# func_mkdir_p DIRECTORY-PATH 838*a466cc55SCy Schubert# --------------------------- 839*a466cc55SCy Schubert# Make sure the entire path to DIRECTORY-PATH is available. 840*a466cc55SCy Schubertfunc_mkdir_p () 841*a466cc55SCy Schubert{ 842*a466cc55SCy Schubert $debug_cmd 843*a466cc55SCy Schubert 844*a466cc55SCy Schubert _G_directory_path=$1 845*a466cc55SCy Schubert _G_dir_list= 846*a466cc55SCy Schubert 847*a466cc55SCy Schubert if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848*a466cc55SCy Schubert 849*a466cc55SCy Schubert # Protect directory names starting with '-' 850*a466cc55SCy Schubert case $_G_directory_path in 851*a466cc55SCy Schubert -*) _G_directory_path=./$_G_directory_path ;; 852*a466cc55SCy Schubert esac 853*a466cc55SCy Schubert 854*a466cc55SCy Schubert # While some portion of DIR does not yet exist... 855*a466cc55SCy Schubert while test ! -d "$_G_directory_path"; do 856*a466cc55SCy Schubert # ...make a list in topmost first order. Use a colon delimited 857*a466cc55SCy Schubert # list incase some portion of path contains whitespace. 858*a466cc55SCy Schubert _G_dir_list=$_G_directory_path:$_G_dir_list 859*a466cc55SCy Schubert 860*a466cc55SCy Schubert # If the last portion added has no slash in it, the list is done 861*a466cc55SCy Schubert case $_G_directory_path in */*) ;; *) break ;; esac 862*a466cc55SCy Schubert 863*a466cc55SCy Schubert # ...otherwise throw away the child directory and loop 864*a466cc55SCy Schubert _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865*a466cc55SCy Schubert done 866*a466cc55SCy Schubert _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867*a466cc55SCy Schubert 868*a466cc55SCy Schubert func_mkdir_p_IFS=$IFS; IFS=: 869*a466cc55SCy Schubert for _G_dir in $_G_dir_list; do 870*a466cc55SCy Schubert IFS=$func_mkdir_p_IFS 871*a466cc55SCy Schubert # mkdir can fail with a 'File exist' error if two processes 872*a466cc55SCy Schubert # try to create one of the directories concurrently. Don't 873*a466cc55SCy Schubert # stop in that case! 874*a466cc55SCy Schubert $MKDIR "$_G_dir" 2>/dev/null || : 875*a466cc55SCy Schubert done 876*a466cc55SCy Schubert IFS=$func_mkdir_p_IFS 877*a466cc55SCy Schubert 878*a466cc55SCy Schubert # Bail out if we (or some other process) failed to create a directory. 879*a466cc55SCy Schubert test -d "$_G_directory_path" || \ 880*a466cc55SCy Schubert func_fatal_error "Failed to create '$1'" 881*a466cc55SCy Schubert fi 882*a466cc55SCy Schubert} 883*a466cc55SCy Schubert 884*a466cc55SCy Schubert 885*a466cc55SCy Schubert# func_mktempdir [BASENAME] 886*a466cc55SCy Schubert# ------------------------- 887*a466cc55SCy Schubert# Make a temporary directory that won't clash with other running 888*a466cc55SCy Schubert# libtool processes, and avoids race conditions if possible. If 889*a466cc55SCy Schubert# given, BASENAME is the basename for that directory. 890*a466cc55SCy Schubertfunc_mktempdir () 891*a466cc55SCy Schubert{ 892*a466cc55SCy Schubert $debug_cmd 893*a466cc55SCy Schubert 894*a466cc55SCy Schubert _G_template=${TMPDIR-/tmp}/${1-$progname} 895*a466cc55SCy Schubert 896*a466cc55SCy Schubert if test : = "$opt_dry_run"; then 897*a466cc55SCy Schubert # Return a directory name, but don't create it in dry-run mode 898*a466cc55SCy Schubert _G_tmpdir=$_G_template-$$ 899*a466cc55SCy Schubert else 900*a466cc55SCy Schubert 901*a466cc55SCy Schubert # If mktemp works, use that first and foremost 902*a466cc55SCy Schubert _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903*a466cc55SCy Schubert 904*a466cc55SCy Schubert if test ! -d "$_G_tmpdir"; then 905*a466cc55SCy Schubert # Failing that, at least try and use $RANDOM to avoid a race 906*a466cc55SCy Schubert _G_tmpdir=$_G_template-${RANDOM-0}$$ 907*a466cc55SCy Schubert 908*a466cc55SCy Schubert func_mktempdir_umask=`umask` 909*a466cc55SCy Schubert umask 0077 910*a466cc55SCy Schubert $MKDIR "$_G_tmpdir" 911*a466cc55SCy Schubert umask $func_mktempdir_umask 912*a466cc55SCy Schubert fi 913*a466cc55SCy Schubert 914*a466cc55SCy Schubert # If we're not in dry-run mode, bomb out on failure 915*a466cc55SCy Schubert test -d "$_G_tmpdir" || \ 916*a466cc55SCy Schubert func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917*a466cc55SCy Schubert fi 918*a466cc55SCy Schubert 919*a466cc55SCy Schubert $ECHO "$_G_tmpdir" 920*a466cc55SCy Schubert} 921*a466cc55SCy Schubert 922*a466cc55SCy Schubert 923*a466cc55SCy Schubert# func_normal_abspath PATH 924*a466cc55SCy Schubert# ------------------------ 925*a466cc55SCy Schubert# Remove doubled-up and trailing slashes, "." path components, 926*a466cc55SCy Schubert# and cancel out any ".." path components in PATH after making 927*a466cc55SCy Schubert# it an absolute path. 928*a466cc55SCy Schubertfunc_normal_abspath () 929*a466cc55SCy Schubert{ 930*a466cc55SCy Schubert $debug_cmd 931*a466cc55SCy Schubert 932*a466cc55SCy Schubert # These SED scripts presuppose an absolute path with a trailing slash. 933*a466cc55SCy Schubert _G_pathcar='s|^/\([^/]*\).*$|\1|' 934*a466cc55SCy Schubert _G_pathcdr='s|^/[^/]*||' 935*a466cc55SCy Schubert _G_removedotparts=':dotsl 936*a466cc55SCy Schubert s|/\./|/|g 937*a466cc55SCy Schubert t dotsl 938*a466cc55SCy Schubert s|/\.$|/|' 939*a466cc55SCy Schubert _G_collapseslashes='s|/\{1,\}|/|g' 940*a466cc55SCy Schubert _G_finalslash='s|/*$|/|' 941*a466cc55SCy Schubert 942*a466cc55SCy Schubert # Start from root dir and reassemble the path. 943*a466cc55SCy Schubert func_normal_abspath_result= 944*a466cc55SCy Schubert func_normal_abspath_tpath=$1 945*a466cc55SCy Schubert func_normal_abspath_altnamespace= 946*a466cc55SCy Schubert case $func_normal_abspath_tpath in 947*a466cc55SCy Schubert "") 948*a466cc55SCy Schubert # Empty path, that just means $cwd. 949*a466cc55SCy Schubert func_stripname '' '/' "`pwd`" 950*a466cc55SCy Schubert func_normal_abspath_result=$func_stripname_result 951*a466cc55SCy Schubert return 952*a466cc55SCy Schubert ;; 953*a466cc55SCy Schubert # The next three entries are used to spot a run of precisely 954*a466cc55SCy Schubert # two leading slashes without using negated character classes; 955*a466cc55SCy Schubert # we take advantage of case's first-match behaviour. 956*a466cc55SCy Schubert ///*) 957*a466cc55SCy Schubert # Unusual form of absolute path, do nothing. 958*a466cc55SCy Schubert ;; 959*a466cc55SCy Schubert //*) 960*a466cc55SCy Schubert # Not necessarily an ordinary path; POSIX reserves leading '//' 961*a466cc55SCy Schubert # and for example Cygwin uses it to access remote file shares 962*a466cc55SCy Schubert # over CIFS/SMB, so we conserve a leading double slash if found. 963*a466cc55SCy Schubert func_normal_abspath_altnamespace=/ 964*a466cc55SCy Schubert ;; 965*a466cc55SCy Schubert /*) 966*a466cc55SCy Schubert # Absolute path, do nothing. 967*a466cc55SCy Schubert ;; 968*a466cc55SCy Schubert *) 969*a466cc55SCy Schubert # Relative path, prepend $cwd. 970*a466cc55SCy Schubert func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971*a466cc55SCy Schubert ;; 972*a466cc55SCy Schubert esac 973*a466cc55SCy Schubert 974*a466cc55SCy Schubert # Cancel out all the simple stuff to save iterations. We also want 975*a466cc55SCy Schubert # the path to end with a slash for ease of parsing, so make sure 976*a466cc55SCy Schubert # there is one (and only one) here. 977*a466cc55SCy Schubert func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978*a466cc55SCy Schubert -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979*a466cc55SCy Schubert while :; do 980*a466cc55SCy Schubert # Processed it all yet? 981*a466cc55SCy Schubert if test / = "$func_normal_abspath_tpath"; then 982*a466cc55SCy Schubert # If we ascended to the root using ".." the result may be empty now. 983*a466cc55SCy Schubert if test -z "$func_normal_abspath_result"; then 984*a466cc55SCy Schubert func_normal_abspath_result=/ 985*a466cc55SCy Schubert fi 986*a466cc55SCy Schubert break 987*a466cc55SCy Schubert fi 988*a466cc55SCy Schubert func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989*a466cc55SCy Schubert -e "$_G_pathcar"` 990*a466cc55SCy Schubert func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991*a466cc55SCy Schubert -e "$_G_pathcdr"` 992*a466cc55SCy Schubert # Figure out what to do with it 993*a466cc55SCy Schubert case $func_normal_abspath_tcomponent in 994*a466cc55SCy Schubert "") 995*a466cc55SCy Schubert # Trailing empty path component, ignore it. 996*a466cc55SCy Schubert ;; 997*a466cc55SCy Schubert ..) 998*a466cc55SCy Schubert # Parent dir; strip last assembled component from result. 999*a466cc55SCy Schubert func_dirname "$func_normal_abspath_result" 1000*a466cc55SCy Schubert func_normal_abspath_result=$func_dirname_result 1001*a466cc55SCy Schubert ;; 1002*a466cc55SCy Schubert *) 1003*a466cc55SCy Schubert # Actual path component, append it. 1004*a466cc55SCy Schubert func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005*a466cc55SCy Schubert ;; 1006*a466cc55SCy Schubert esac 1007*a466cc55SCy Schubert done 1008*a466cc55SCy Schubert # Restore leading double-slash if one was found on entry. 1009*a466cc55SCy Schubert func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010*a466cc55SCy Schubert} 1011*a466cc55SCy Schubert 1012*a466cc55SCy Schubert 1013*a466cc55SCy Schubert# func_notquiet ARG... 1014*a466cc55SCy Schubert# -------------------- 1015*a466cc55SCy Schubert# Echo program name prefixed message only when not in quiet mode. 1016*a466cc55SCy Schubertfunc_notquiet () 1017*a466cc55SCy Schubert{ 1018*a466cc55SCy Schubert $debug_cmd 1019*a466cc55SCy Schubert 1020*a466cc55SCy Schubert $opt_quiet || func_echo ${1+"$@"} 1021*a466cc55SCy Schubert 1022*a466cc55SCy Schubert # A bug in bash halts the script if the last line of a function 1023*a466cc55SCy Schubert # fails when set -e is in force, so we need another command to 1024*a466cc55SCy Schubert # work around that: 1025*a466cc55SCy Schubert : 1026*a466cc55SCy Schubert} 1027*a466cc55SCy Schubert 1028*a466cc55SCy Schubert 1029*a466cc55SCy Schubert# func_relative_path SRCDIR DSTDIR 1030*a466cc55SCy Schubert# -------------------------------- 1031*a466cc55SCy Schubert# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032*a466cc55SCy Schubertfunc_relative_path () 1033*a466cc55SCy Schubert{ 1034*a466cc55SCy Schubert $debug_cmd 1035*a466cc55SCy Schubert 1036*a466cc55SCy Schubert func_relative_path_result= 1037*a466cc55SCy Schubert func_normal_abspath "$1" 1038*a466cc55SCy Schubert func_relative_path_tlibdir=$func_normal_abspath_result 1039*a466cc55SCy Schubert func_normal_abspath "$2" 1040*a466cc55SCy Schubert func_relative_path_tbindir=$func_normal_abspath_result 1041*a466cc55SCy Schubert 1042*a466cc55SCy Schubert # Ascend the tree starting from libdir 1043*a466cc55SCy Schubert while :; do 1044*a466cc55SCy Schubert # check if we have found a prefix of bindir 1045*a466cc55SCy Schubert case $func_relative_path_tbindir in 1046*a466cc55SCy Schubert $func_relative_path_tlibdir) 1047*a466cc55SCy Schubert # found an exact match 1048*a466cc55SCy Schubert func_relative_path_tcancelled= 1049*a466cc55SCy Schubert break 1050*a466cc55SCy Schubert ;; 1051*a466cc55SCy Schubert $func_relative_path_tlibdir*) 1052*a466cc55SCy Schubert # found a matching prefix 1053*a466cc55SCy Schubert func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054*a466cc55SCy Schubert func_relative_path_tcancelled=$func_stripname_result 1055*a466cc55SCy Schubert if test -z "$func_relative_path_result"; then 1056*a466cc55SCy Schubert func_relative_path_result=. 1057*a466cc55SCy Schubert fi 1058*a466cc55SCy Schubert break 1059*a466cc55SCy Schubert ;; 1060*a466cc55SCy Schubert *) 1061*a466cc55SCy Schubert func_dirname $func_relative_path_tlibdir 1062*a466cc55SCy Schubert func_relative_path_tlibdir=$func_dirname_result 1063*a466cc55SCy Schubert if test -z "$func_relative_path_tlibdir"; then 1064*a466cc55SCy Schubert # Have to descend all the way to the root! 1065*a466cc55SCy Schubert func_relative_path_result=../$func_relative_path_result 1066*a466cc55SCy Schubert func_relative_path_tcancelled=$func_relative_path_tbindir 1067*a466cc55SCy Schubert break 1068*a466cc55SCy Schubert fi 1069*a466cc55SCy Schubert func_relative_path_result=../$func_relative_path_result 1070*a466cc55SCy Schubert ;; 1071*a466cc55SCy Schubert esac 1072*a466cc55SCy Schubert done 1073*a466cc55SCy Schubert 1074*a466cc55SCy Schubert # Now calculate path; take care to avoid doubling-up slashes. 1075*a466cc55SCy Schubert func_stripname '' '/' "$func_relative_path_result" 1076*a466cc55SCy Schubert func_relative_path_result=$func_stripname_result 1077*a466cc55SCy Schubert func_stripname '/' '/' "$func_relative_path_tcancelled" 1078*a466cc55SCy Schubert if test -n "$func_stripname_result"; then 1079*a466cc55SCy Schubert func_append func_relative_path_result "/$func_stripname_result" 1080*a466cc55SCy Schubert fi 1081*a466cc55SCy Schubert 1082*a466cc55SCy Schubert # Normalisation. If bindir is libdir, return '.' else relative path. 1083*a466cc55SCy Schubert if test -n "$func_relative_path_result"; then 1084*a466cc55SCy Schubert func_stripname './' '' "$func_relative_path_result" 1085*a466cc55SCy Schubert func_relative_path_result=$func_stripname_result 1086*a466cc55SCy Schubert fi 1087*a466cc55SCy Schubert 1088*a466cc55SCy Schubert test -n "$func_relative_path_result" || func_relative_path_result=. 1089*a466cc55SCy Schubert 1090*a466cc55SCy Schubert : 1091*a466cc55SCy Schubert} 1092*a466cc55SCy Schubert 1093*a466cc55SCy Schubert 1094*a466cc55SCy Schubert# func_quote_for_eval ARG... 1095*a466cc55SCy Schubert# -------------------------- 1096*a466cc55SCy Schubert# Aesthetically quote ARGs to be evaled later. 1097*a466cc55SCy Schubert# This function returns two values: 1098*a466cc55SCy Schubert# i) func_quote_for_eval_result 1099*a466cc55SCy Schubert# double-quoted, suitable for a subsequent eval 1100*a466cc55SCy Schubert# ii) func_quote_for_eval_unquoted_result 1101*a466cc55SCy Schubert# has all characters that are still active within double 1102*a466cc55SCy Schubert# quotes backslashified. 1103*a466cc55SCy Schubertfunc_quote_for_eval () 1104*a466cc55SCy Schubert{ 1105*a466cc55SCy Schubert $debug_cmd 1106*a466cc55SCy Schubert 1107*a466cc55SCy Schubert func_quote_for_eval_unquoted_result= 1108*a466cc55SCy Schubert func_quote_for_eval_result= 1109*a466cc55SCy Schubert while test 0 -lt $#; do 1110*a466cc55SCy Schubert case $1 in 1111*a466cc55SCy Schubert *[\\\`\"\$]*) 1112*a466cc55SCy Schubert _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113*a466cc55SCy Schubert *) 1114*a466cc55SCy Schubert _G_unquoted_arg=$1 ;; 1115*a466cc55SCy Schubert esac 1116*a466cc55SCy Schubert if test -n "$func_quote_for_eval_unquoted_result"; then 1117*a466cc55SCy Schubert func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118*a466cc55SCy Schubert else 1119*a466cc55SCy Schubert func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120*a466cc55SCy Schubert fi 1121*a466cc55SCy Schubert 1122*a466cc55SCy Schubert case $_G_unquoted_arg in 1123*a466cc55SCy Schubert # Double-quote args containing shell metacharacters to delay 1124*a466cc55SCy Schubert # word splitting, command substitution and variable expansion 1125*a466cc55SCy Schubert # for a subsequent eval. 1126*a466cc55SCy Schubert # Many Bourne shells cannot handle close brackets correctly 1127*a466cc55SCy Schubert # in scan sets, so we specify it separately. 1128*a466cc55SCy Schubert *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129*a466cc55SCy Schubert _G_quoted_arg=\"$_G_unquoted_arg\" 1130*a466cc55SCy Schubert ;; 1131*a466cc55SCy Schubert *) 1132*a466cc55SCy Schubert _G_quoted_arg=$_G_unquoted_arg 1133*a466cc55SCy Schubert ;; 1134*a466cc55SCy Schubert esac 1135*a466cc55SCy Schubert 1136*a466cc55SCy Schubert if test -n "$func_quote_for_eval_result"; then 1137*a466cc55SCy Schubert func_append func_quote_for_eval_result " $_G_quoted_arg" 1138*a466cc55SCy Schubert else 1139*a466cc55SCy Schubert func_append func_quote_for_eval_result "$_G_quoted_arg" 1140*a466cc55SCy Schubert fi 1141*a466cc55SCy Schubert shift 1142*a466cc55SCy Schubert done 1143*a466cc55SCy Schubert} 1144*a466cc55SCy Schubert 1145*a466cc55SCy Schubert 1146*a466cc55SCy Schubert# func_quote_for_expand ARG 1147*a466cc55SCy Schubert# ------------------------- 1148*a466cc55SCy Schubert# Aesthetically quote ARG to be evaled later; same as above, 1149*a466cc55SCy Schubert# but do not quote variable references. 1150*a466cc55SCy Schubertfunc_quote_for_expand () 1151*a466cc55SCy Schubert{ 1152*a466cc55SCy Schubert $debug_cmd 1153*a466cc55SCy Schubert 1154*a466cc55SCy Schubert case $1 in 1155*a466cc55SCy Schubert *[\\\`\"]*) 1156*a466cc55SCy Schubert _G_arg=`$ECHO "$1" | $SED \ 1157*a466cc55SCy Schubert -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158*a466cc55SCy Schubert *) 1159*a466cc55SCy Schubert _G_arg=$1 ;; 1160*a466cc55SCy Schubert esac 1161*a466cc55SCy Schubert 1162*a466cc55SCy Schubert case $_G_arg in 1163*a466cc55SCy Schubert # Double-quote args containing shell metacharacters to delay 1164*a466cc55SCy Schubert # word splitting and command substitution for a subsequent eval. 1165*a466cc55SCy Schubert # Many Bourne shells cannot handle close brackets correctly 1166*a466cc55SCy Schubert # in scan sets, so we specify it separately. 1167*a466cc55SCy Schubert *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168*a466cc55SCy Schubert _G_arg=\"$_G_arg\" 1169*a466cc55SCy Schubert ;; 1170*a466cc55SCy Schubert esac 1171*a466cc55SCy Schubert 1172*a466cc55SCy Schubert func_quote_for_expand_result=$_G_arg 1173*a466cc55SCy Schubert} 1174*a466cc55SCy Schubert 1175*a466cc55SCy Schubert 1176*a466cc55SCy Schubert# func_stripname PREFIX SUFFIX NAME 1177*a466cc55SCy Schubert# --------------------------------- 1178*a466cc55SCy Schubert# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179*a466cc55SCy Schubert# PREFIX and SUFFIX must not contain globbing or regex special 1180*a466cc55SCy Schubert# characters, hashes, percent signs, but SUFFIX may contain a leading 1181*a466cc55SCy Schubert# dot (in which case that matches only a dot). 1182*a466cc55SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 1183*a466cc55SCy Schubert eval 'func_stripname () 1184*a466cc55SCy Schubert { 1185*a466cc55SCy Schubert $debug_cmd 1186*a466cc55SCy Schubert 1187*a466cc55SCy Schubert # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188*a466cc55SCy Schubert # positional parameters, so assign one to ordinary variable first. 1189*a466cc55SCy Schubert func_stripname_result=$3 1190*a466cc55SCy Schubert func_stripname_result=${func_stripname_result#"$1"} 1191*a466cc55SCy Schubert func_stripname_result=${func_stripname_result%"$2"} 1192*a466cc55SCy Schubert }' 1193*a466cc55SCy Schubertelse 1194*a466cc55SCy Schubert func_stripname () 1195*a466cc55SCy Schubert { 1196*a466cc55SCy Schubert $debug_cmd 1197*a466cc55SCy Schubert 1198*a466cc55SCy Schubert case $2 in 1199*a466cc55SCy Schubert .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200*a466cc55SCy Schubert *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201*a466cc55SCy Schubert esac 1202*a466cc55SCy Schubert } 1203*a466cc55SCy Schubertfi 1204*a466cc55SCy Schubert 1205*a466cc55SCy Schubert 1206*a466cc55SCy Schubert# func_show_eval CMD [FAIL_EXP] 1207*a466cc55SCy Schubert# ----------------------------- 1208*a466cc55SCy Schubert# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209*a466cc55SCy Schubert# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210*a466cc55SCy Schubert# is given, then evaluate it. 1211*a466cc55SCy Schubertfunc_show_eval () 1212*a466cc55SCy Schubert{ 1213*a466cc55SCy Schubert $debug_cmd 1214*a466cc55SCy Schubert 1215*a466cc55SCy Schubert _G_cmd=$1 1216*a466cc55SCy Schubert _G_fail_exp=${2-':'} 1217*a466cc55SCy Schubert 1218*a466cc55SCy Schubert func_quote_for_expand "$_G_cmd" 1219*a466cc55SCy Schubert eval "func_notquiet $func_quote_for_expand_result" 1220*a466cc55SCy Schubert 1221*a466cc55SCy Schubert $opt_dry_run || { 1222*a466cc55SCy Schubert eval "$_G_cmd" 1223*a466cc55SCy Schubert _G_status=$? 1224*a466cc55SCy Schubert if test 0 -ne "$_G_status"; then 1225*a466cc55SCy Schubert eval "(exit $_G_status); $_G_fail_exp" 1226*a466cc55SCy Schubert fi 1227*a466cc55SCy Schubert } 1228*a466cc55SCy Schubert} 1229*a466cc55SCy Schubert 1230*a466cc55SCy Schubert 1231*a466cc55SCy Schubert# func_show_eval_locale CMD [FAIL_EXP] 1232*a466cc55SCy Schubert# ------------------------------------ 1233*a466cc55SCy Schubert# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234*a466cc55SCy Schubert# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235*a466cc55SCy Schubert# is given, then evaluate it. Use the saved locale for evaluation. 1236*a466cc55SCy Schubertfunc_show_eval_locale () 1237*a466cc55SCy Schubert{ 1238*a466cc55SCy Schubert $debug_cmd 1239*a466cc55SCy Schubert 1240*a466cc55SCy Schubert _G_cmd=$1 1241*a466cc55SCy Schubert _G_fail_exp=${2-':'} 1242*a466cc55SCy Schubert 1243*a466cc55SCy Schubert $opt_quiet || { 1244*a466cc55SCy Schubert func_quote_for_expand "$_G_cmd" 1245*a466cc55SCy Schubert eval "func_echo $func_quote_for_expand_result" 1246*a466cc55SCy Schubert } 1247*a466cc55SCy Schubert 1248*a466cc55SCy Schubert $opt_dry_run || { 1249*a466cc55SCy Schubert eval "$_G_user_locale 1250*a466cc55SCy Schubert $_G_cmd" 1251*a466cc55SCy Schubert _G_status=$? 1252*a466cc55SCy Schubert eval "$_G_safe_locale" 1253*a466cc55SCy Schubert if test 0 -ne "$_G_status"; then 1254*a466cc55SCy Schubert eval "(exit $_G_status); $_G_fail_exp" 1255*a466cc55SCy Schubert fi 1256*a466cc55SCy Schubert } 1257*a466cc55SCy Schubert} 1258*a466cc55SCy Schubert 1259*a466cc55SCy Schubert 1260*a466cc55SCy Schubert# func_tr_sh 1261*a466cc55SCy Schubert# ---------- 1262*a466cc55SCy Schubert# Turn $1 into a string suitable for a shell variable name. 1263*a466cc55SCy Schubert# Result is stored in $func_tr_sh_result. All characters 1264*a466cc55SCy Schubert# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265*a466cc55SCy Schubert# if $1 begins with a digit, a '_' is prepended as well. 1266*a466cc55SCy Schubertfunc_tr_sh () 1267*a466cc55SCy Schubert{ 1268*a466cc55SCy Schubert $debug_cmd 1269*a466cc55SCy Schubert 1270*a466cc55SCy Schubert case $1 in 1271*a466cc55SCy Schubert [0-9]* | *[!a-zA-Z0-9_]*) 1272*a466cc55SCy Schubert func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273*a466cc55SCy Schubert ;; 1274*a466cc55SCy Schubert * ) 1275*a466cc55SCy Schubert func_tr_sh_result=$1 1276*a466cc55SCy Schubert ;; 1277*a466cc55SCy Schubert esac 1278*a466cc55SCy Schubert} 1279*a466cc55SCy Schubert 1280*a466cc55SCy Schubert 1281*a466cc55SCy Schubert# func_verbose ARG... 1282*a466cc55SCy Schubert# ------------------- 1283*a466cc55SCy Schubert# Echo program name prefixed message in verbose mode only. 1284*a466cc55SCy Schubertfunc_verbose () 1285*a466cc55SCy Schubert{ 1286*a466cc55SCy Schubert $debug_cmd 1287*a466cc55SCy Schubert 1288*a466cc55SCy Schubert $opt_verbose && func_echo "$*" 1289*a466cc55SCy Schubert 1290*a466cc55SCy Schubert : 1291*a466cc55SCy Schubert} 1292*a466cc55SCy Schubert 1293*a466cc55SCy Schubert 1294*a466cc55SCy Schubert# func_warn_and_continue ARG... 1295*a466cc55SCy Schubert# ----------------------------- 1296*a466cc55SCy Schubert# Echo program name prefixed warning message to standard error. 1297*a466cc55SCy Schubertfunc_warn_and_continue () 1298*a466cc55SCy Schubert{ 1299*a466cc55SCy Schubert $debug_cmd 1300*a466cc55SCy Schubert 1301*a466cc55SCy Schubert $require_term_colors 1302*a466cc55SCy Schubert 1303*a466cc55SCy Schubert func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304*a466cc55SCy Schubert} 1305*a466cc55SCy Schubert 1306*a466cc55SCy Schubert 1307*a466cc55SCy Schubert# func_warning CATEGORY ARG... 1308*a466cc55SCy Schubert# ---------------------------- 1309*a466cc55SCy Schubert# Echo program name prefixed warning message to standard error. Warning 1310*a466cc55SCy Schubert# messages can be filtered according to CATEGORY, where this function 1311*a466cc55SCy Schubert# elides messages where CATEGORY is not listed in the global variable 1312*a466cc55SCy Schubert# 'opt_warning_types'. 1313*a466cc55SCy Schubertfunc_warning () 1314*a466cc55SCy Schubert{ 1315*a466cc55SCy Schubert $debug_cmd 1316*a466cc55SCy Schubert 1317*a466cc55SCy Schubert # CATEGORY must be in the warning_categories list! 1318*a466cc55SCy Schubert case " $warning_categories " in 1319*a466cc55SCy Schubert *" $1 "*) ;; 1320*a466cc55SCy Schubert *) func_internal_error "invalid warning category '$1'" ;; 1321*a466cc55SCy Schubert esac 1322*a466cc55SCy Schubert 1323*a466cc55SCy Schubert _G_category=$1 1324*a466cc55SCy Schubert shift 1325*a466cc55SCy Schubert 1326*a466cc55SCy Schubert case " $opt_warning_types " in 1327*a466cc55SCy Schubert *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328*a466cc55SCy Schubert esac 1329*a466cc55SCy Schubert} 1330*a466cc55SCy Schubert 1331*a466cc55SCy Schubert 1332*a466cc55SCy Schubert# func_sort_ver VER1 VER2 1333*a466cc55SCy Schubert# ----------------------- 1334*a466cc55SCy Schubert# 'sort -V' is not generally available. 1335*a466cc55SCy Schubert# Note this deviates from the version comparison in automake 1336*a466cc55SCy Schubert# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337*a466cc55SCy Schubert# but this should suffice as we won't be specifying old 1338*a466cc55SCy Schubert# version formats or redundant trailing .0 in bootstrap.conf. 1339*a466cc55SCy Schubert# If we did want full compatibility then we should probably 1340*a466cc55SCy Schubert# use m4_version_compare from autoconf. 1341*a466cc55SCy Schubertfunc_sort_ver () 1342*a466cc55SCy Schubert{ 1343*a466cc55SCy Schubert $debug_cmd 1344*a466cc55SCy Schubert 1345*a466cc55SCy Schubert printf '%s\n%s\n' "$1" "$2" \ 1346*a466cc55SCy 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 1347*a466cc55SCy Schubert} 1348*a466cc55SCy Schubert 1349*a466cc55SCy Schubert# func_lt_ver PREV CURR 1350*a466cc55SCy Schubert# --------------------- 1351*a466cc55SCy Schubert# Return true if PREV and CURR are in the correct order according to 1352*a466cc55SCy Schubert# func_sort_ver, otherwise false. Use it like this: 1353*a466cc55SCy Schubert# 1354*a466cc55SCy Schubert# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355*a466cc55SCy Schubertfunc_lt_ver () 1356*a466cc55SCy Schubert{ 1357*a466cc55SCy Schubert $debug_cmd 1358*a466cc55SCy Schubert 1359*a466cc55SCy Schubert test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360*a466cc55SCy Schubert} 1361*a466cc55SCy Schubert 1362*a466cc55SCy Schubert 1363*a466cc55SCy Schubert# Local variables: 1364*a466cc55SCy Schubert# mode: shell-script 1365*a466cc55SCy Schubert# sh-indentation: 2 1366*a466cc55SCy Schubert# eval: (add-hook 'before-save-hook 'time-stamp) 1367*a466cc55SCy Schubert# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368*a466cc55SCy Schubert# time-stamp-time-zone: "UTC" 1369*a466cc55SCy Schubert# End: 1370*a466cc55SCy Schubert#! /bin/sh 1371*a466cc55SCy Schubert 1372*a466cc55SCy Schubert# Set a version string for this script. 1373*a466cc55SCy Schubertscriptversion=2014-01-07.03; # UTC 1374*a466cc55SCy Schubert 1375*a466cc55SCy Schubert# A portable, pluggable option parser for Bourne shell. 1376*a466cc55SCy Schubert# Written by Gary V. Vaughan, 2010 1377*a466cc55SCy Schubert 1378*a466cc55SCy Schubert# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379*a466cc55SCy Schubert# This is free software; see the source for copying conditions. There is NO 1380*a466cc55SCy Schubert# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381*a466cc55SCy Schubert 1382*a466cc55SCy Schubert# This program is free software: you can redistribute it and/or modify 1383*a466cc55SCy Schubert# it under the terms of the GNU General Public License as published by 1384*a466cc55SCy Schubert# the Free Software Foundation, either version 3 of the License, or 1385*a466cc55SCy Schubert# (at your option) any later version. 1386*a466cc55SCy Schubert 1387*a466cc55SCy Schubert# This program is distributed in the hope that it will be useful, 1388*a466cc55SCy Schubert# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389*a466cc55SCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390*a466cc55SCy Schubert# GNU General Public License for more details. 1391*a466cc55SCy Schubert 1392*a466cc55SCy Schubert# You should have received a copy of the GNU General Public License 1393*a466cc55SCy Schubert# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394*a466cc55SCy Schubert 1395*a466cc55SCy Schubert# Please report bugs or propose patches to gary@gnu.org. 1396*a466cc55SCy Schubert 1397*a466cc55SCy Schubert 1398*a466cc55SCy Schubert## ------ ## 1399*a466cc55SCy Schubert## Usage. ## 1400*a466cc55SCy Schubert## ------ ## 1401*a466cc55SCy Schubert 1402*a466cc55SCy Schubert# This file is a library for parsing options in your shell scripts along 1403*a466cc55SCy Schubert# with assorted other useful supporting features that you can make use 1404*a466cc55SCy Schubert# of too. 1405*a466cc55SCy Schubert# 1406*a466cc55SCy Schubert# For the simplest scripts you might need only: 1407*a466cc55SCy Schubert# 1408*a466cc55SCy Schubert# #!/bin/sh 1409*a466cc55SCy Schubert# . relative/path/to/funclib.sh 1410*a466cc55SCy Schubert# . relative/path/to/options-parser 1411*a466cc55SCy Schubert# scriptversion=1.0 1412*a466cc55SCy Schubert# func_options ${1+"$@"} 1413*a466cc55SCy Schubert# eval set dummy "$func_options_result"; shift 1414*a466cc55SCy Schubert# ...rest of your script... 1415*a466cc55SCy Schubert# 1416*a466cc55SCy Schubert# In order for the '--version' option to work, you will need to have a 1417*a466cc55SCy Schubert# suitably formatted comment like the one at the top of this file 1418*a466cc55SCy Schubert# starting with '# Written by ' and ending with '# warranty; '. 1419*a466cc55SCy Schubert# 1420*a466cc55SCy Schubert# For '-h' and '--help' to work, you will also need a one line 1421*a466cc55SCy Schubert# description of your script's purpose in a comment directly above the 1422*a466cc55SCy Schubert# '# Written by ' line, like the one at the top of this file. 1423*a466cc55SCy Schubert# 1424*a466cc55SCy Schubert# The default options also support '--debug', which will turn on shell 1425*a466cc55SCy Schubert# execution tracing (see the comment above debug_cmd below for another 1426*a466cc55SCy Schubert# use), and '--verbose' and the func_verbose function to allow your script 1427*a466cc55SCy Schubert# to display verbose messages only when your user has specified 1428*a466cc55SCy Schubert# '--verbose'. 1429*a466cc55SCy Schubert# 1430*a466cc55SCy Schubert# After sourcing this file, you can plug processing for additional 1431*a466cc55SCy Schubert# options by amending the variables from the 'Configuration' section 1432*a466cc55SCy Schubert# below, and following the instructions in the 'Option parsing' 1433*a466cc55SCy Schubert# section further down. 1434*a466cc55SCy Schubert 1435*a466cc55SCy Schubert## -------------- ## 1436*a466cc55SCy Schubert## Configuration. ## 1437*a466cc55SCy Schubert## -------------- ## 1438*a466cc55SCy Schubert 1439*a466cc55SCy Schubert# You should override these variables in your script after sourcing this 1440*a466cc55SCy Schubert# file so that they reflect the customisations you have added to the 1441*a466cc55SCy Schubert# option parser. 1442*a466cc55SCy Schubert 1443*a466cc55SCy Schubert# The usage line for option parsing errors and the start of '-h' and 1444*a466cc55SCy Schubert# '--help' output messages. You can embed shell variables for delayed 1445*a466cc55SCy Schubert# expansion at the time the message is displayed, but you will need to 1446*a466cc55SCy Schubert# quote other shell meta-characters carefully to prevent them being 1447*a466cc55SCy Schubert# expanded when the contents are evaled. 1448*a466cc55SCy Schubertusage='$progpath [OPTION]...' 1449*a466cc55SCy Schubert 1450*a466cc55SCy Schubert# Short help message in response to '-h' and '--help'. Add to this or 1451*a466cc55SCy Schubert# override it after sourcing this library to reflect the full set of 1452*a466cc55SCy Schubert# options your script accepts. 1453*a466cc55SCy Schubertusage_message="\ 1454*a466cc55SCy Schubert --debug enable verbose shell tracing 1455*a466cc55SCy Schubert -W, --warnings=CATEGORY 1456*a466cc55SCy Schubert report the warnings falling in CATEGORY [all] 1457*a466cc55SCy Schubert -v, --verbose verbosely report processing 1458*a466cc55SCy Schubert --version print version information and exit 1459*a466cc55SCy Schubert -h, --help print short or long help message and exit 1460*a466cc55SCy Schubert" 1461*a466cc55SCy Schubert 1462*a466cc55SCy Schubert# Additional text appended to 'usage_message' in response to '--help'. 1463*a466cc55SCy Schubertlong_help_message=" 1464*a466cc55SCy SchubertWarning categories include: 1465*a466cc55SCy Schubert 'all' show all warnings 1466*a466cc55SCy Schubert 'none' turn off all the warnings 1467*a466cc55SCy Schubert 'error' warnings are treated as fatal errors" 1468*a466cc55SCy Schubert 1469*a466cc55SCy Schubert# Help message printed before fatal option parsing errors. 1470*a466cc55SCy Schubertfatal_help="Try '\$progname --help' for more information." 1471*a466cc55SCy Schubert 1472*a466cc55SCy Schubert 1473*a466cc55SCy Schubert 1474*a466cc55SCy Schubert## ------------------------- ## 1475*a466cc55SCy Schubert## Hook function management. ## 1476*a466cc55SCy Schubert## ------------------------- ## 1477*a466cc55SCy Schubert 1478*a466cc55SCy Schubert# This section contains functions for adding, removing, and running hooks 1479*a466cc55SCy Schubert# to the main code. A hook is just a named list of of function, that can 1480*a466cc55SCy Schubert# be run in order later on. 1481*a466cc55SCy Schubert 1482*a466cc55SCy Schubert# func_hookable FUNC_NAME 1483*a466cc55SCy Schubert# ----------------------- 1484*a466cc55SCy Schubert# Declare that FUNC_NAME will run hooks added with 1485*a466cc55SCy Schubert# 'func_add_hook FUNC_NAME ...'. 1486*a466cc55SCy Schubertfunc_hookable () 1487*a466cc55SCy Schubert{ 1488*a466cc55SCy Schubert $debug_cmd 1489*a466cc55SCy Schubert 1490*a466cc55SCy Schubert func_append hookable_fns " $1" 1491*a466cc55SCy Schubert} 1492*a466cc55SCy Schubert 1493*a466cc55SCy Schubert 1494*a466cc55SCy Schubert# func_add_hook FUNC_NAME HOOK_FUNC 1495*a466cc55SCy Schubert# --------------------------------- 1496*a466cc55SCy Schubert# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497*a466cc55SCy Schubert# first have been declared "hookable" by a call to 'func_hookable'. 1498*a466cc55SCy Schubertfunc_add_hook () 1499*a466cc55SCy Schubert{ 1500*a466cc55SCy Schubert $debug_cmd 1501*a466cc55SCy Schubert 1502*a466cc55SCy Schubert case " $hookable_fns " in 1503*a466cc55SCy Schubert *" $1 "*) ;; 1504*a466cc55SCy Schubert *) func_fatal_error "'$1' does not accept hook functions." ;; 1505*a466cc55SCy Schubert esac 1506*a466cc55SCy Schubert 1507*a466cc55SCy Schubert eval func_append ${1}_hooks '" $2"' 1508*a466cc55SCy Schubert} 1509*a466cc55SCy Schubert 1510*a466cc55SCy Schubert 1511*a466cc55SCy Schubert# func_remove_hook FUNC_NAME HOOK_FUNC 1512*a466cc55SCy Schubert# ------------------------------------ 1513*a466cc55SCy Schubert# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514*a466cc55SCy Schubertfunc_remove_hook () 1515*a466cc55SCy Schubert{ 1516*a466cc55SCy Schubert $debug_cmd 1517*a466cc55SCy Schubert 1518*a466cc55SCy Schubert eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519*a466cc55SCy Schubert} 1520*a466cc55SCy Schubert 1521*a466cc55SCy Schubert 1522*a466cc55SCy Schubert# func_run_hooks FUNC_NAME [ARG]... 1523*a466cc55SCy Schubert# --------------------------------- 1524*a466cc55SCy Schubert# Run all hook functions registered to FUNC_NAME. 1525*a466cc55SCy Schubert# It is assumed that the list of hook functions contains nothing more 1526*a466cc55SCy Schubert# than a whitespace-delimited list of legal shell function names, and 1527*a466cc55SCy Schubert# no effort is wasted trying to catch shell meta-characters or preserve 1528*a466cc55SCy Schubert# whitespace. 1529*a466cc55SCy Schubertfunc_run_hooks () 1530*a466cc55SCy Schubert{ 1531*a466cc55SCy Schubert $debug_cmd 1532*a466cc55SCy Schubert 1533*a466cc55SCy Schubert case " $hookable_fns " in 1534*a466cc55SCy Schubert *" $1 "*) ;; 1535*a466cc55SCy Schubert *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536*a466cc55SCy Schubert esac 1537*a466cc55SCy Schubert 1538*a466cc55SCy Schubert eval _G_hook_fns=\$$1_hooks; shift 1539*a466cc55SCy Schubert 1540*a466cc55SCy Schubert for _G_hook in $_G_hook_fns; do 1541*a466cc55SCy Schubert eval $_G_hook '"$@"' 1542*a466cc55SCy Schubert 1543*a466cc55SCy Schubert # store returned options list back into positional 1544*a466cc55SCy Schubert # parameters for next 'cmd' execution. 1545*a466cc55SCy Schubert eval _G_hook_result=\$${_G_hook}_result 1546*a466cc55SCy Schubert eval set dummy "$_G_hook_result"; shift 1547*a466cc55SCy Schubert done 1548*a466cc55SCy Schubert 1549*a466cc55SCy Schubert func_quote_for_eval ${1+"$@"} 1550*a466cc55SCy Schubert func_run_hooks_result=$func_quote_for_eval_result 1551*a466cc55SCy Schubert} 1552*a466cc55SCy Schubert 1553*a466cc55SCy Schubert 1554*a466cc55SCy Schubert 1555*a466cc55SCy Schubert## --------------- ## 1556*a466cc55SCy Schubert## Option parsing. ## 1557*a466cc55SCy Schubert## --------------- ## 1558*a466cc55SCy Schubert 1559*a466cc55SCy Schubert# In order to add your own option parsing hooks, you must accept the 1560*a466cc55SCy Schubert# full positional parameter list in your hook function, remove any 1561*a466cc55SCy Schubert# options that you action, and then pass back the remaining unprocessed 1562*a466cc55SCy Schubert# options in '<hooked_function_name>_result', escaped suitably for 1563*a466cc55SCy Schubert# 'eval'. Like this: 1564*a466cc55SCy Schubert# 1565*a466cc55SCy Schubert# my_options_prep () 1566*a466cc55SCy Schubert# { 1567*a466cc55SCy Schubert# $debug_cmd 1568*a466cc55SCy Schubert# 1569*a466cc55SCy Schubert# # Extend the existing usage message. 1570*a466cc55SCy Schubert# usage_message=$usage_message' 1571*a466cc55SCy Schubert# -s, --silent don'\''t print informational messages 1572*a466cc55SCy Schubert# ' 1573*a466cc55SCy Schubert# 1574*a466cc55SCy Schubert# func_quote_for_eval ${1+"$@"} 1575*a466cc55SCy Schubert# my_options_prep_result=$func_quote_for_eval_result 1576*a466cc55SCy Schubert# } 1577*a466cc55SCy Schubert# func_add_hook func_options_prep my_options_prep 1578*a466cc55SCy Schubert# 1579*a466cc55SCy Schubert# 1580*a466cc55SCy Schubert# my_silent_option () 1581*a466cc55SCy Schubert# { 1582*a466cc55SCy Schubert# $debug_cmd 1583*a466cc55SCy Schubert# 1584*a466cc55SCy Schubert# # Note that for efficiency, we parse as many options as we can 1585*a466cc55SCy Schubert# # recognise in a loop before passing the remainder back to the 1586*a466cc55SCy Schubert# # caller on the first unrecognised argument we encounter. 1587*a466cc55SCy Schubert# while test $# -gt 0; do 1588*a466cc55SCy Schubert# opt=$1; shift 1589*a466cc55SCy Schubert# case $opt in 1590*a466cc55SCy Schubert# --silent|-s) opt_silent=: ;; 1591*a466cc55SCy Schubert# # Separate non-argument short options: 1592*a466cc55SCy Schubert# -s*) func_split_short_opt "$_G_opt" 1593*a466cc55SCy Schubert# set dummy "$func_split_short_opt_name" \ 1594*a466cc55SCy Schubert# "-$func_split_short_opt_arg" ${1+"$@"} 1595*a466cc55SCy Schubert# shift 1596*a466cc55SCy Schubert# ;; 1597*a466cc55SCy Schubert# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598*a466cc55SCy Schubert# esac 1599*a466cc55SCy Schubert# done 1600*a466cc55SCy Schubert# 1601*a466cc55SCy Schubert# func_quote_for_eval ${1+"$@"} 1602*a466cc55SCy Schubert# my_silent_option_result=$func_quote_for_eval_result 1603*a466cc55SCy Schubert# } 1604*a466cc55SCy Schubert# func_add_hook func_parse_options my_silent_option 1605*a466cc55SCy Schubert# 1606*a466cc55SCy Schubert# 1607*a466cc55SCy Schubert# my_option_validation () 1608*a466cc55SCy Schubert# { 1609*a466cc55SCy Schubert# $debug_cmd 1610*a466cc55SCy Schubert# 1611*a466cc55SCy Schubert# $opt_silent && $opt_verbose && func_fatal_help "\ 1612*a466cc55SCy Schubert# '--silent' and '--verbose' options are mutually exclusive." 1613*a466cc55SCy Schubert# 1614*a466cc55SCy Schubert# func_quote_for_eval ${1+"$@"} 1615*a466cc55SCy Schubert# my_option_validation_result=$func_quote_for_eval_result 1616*a466cc55SCy Schubert# } 1617*a466cc55SCy Schubert# func_add_hook func_validate_options my_option_validation 1618*a466cc55SCy Schubert# 1619*a466cc55SCy Schubert# You'll alse need to manually amend $usage_message to reflect the extra 1620*a466cc55SCy Schubert# options you parse. It's preferable to append if you can, so that 1621*a466cc55SCy Schubert# multiple option parsing hooks can be added safely. 1622*a466cc55SCy Schubert 1623*a466cc55SCy Schubert 1624*a466cc55SCy Schubert# func_options [ARG]... 1625*a466cc55SCy Schubert# --------------------- 1626*a466cc55SCy Schubert# All the functions called inside func_options are hookable. See the 1627*a466cc55SCy Schubert# individual implementations for details. 1628*a466cc55SCy Schubertfunc_hookable func_options 1629*a466cc55SCy Schubertfunc_options () 1630*a466cc55SCy Schubert{ 1631*a466cc55SCy Schubert $debug_cmd 1632*a466cc55SCy Schubert 1633*a466cc55SCy Schubert func_options_prep ${1+"$@"} 1634*a466cc55SCy Schubert eval func_parse_options \ 1635*a466cc55SCy Schubert ${func_options_prep_result+"$func_options_prep_result"} 1636*a466cc55SCy Schubert eval func_validate_options \ 1637*a466cc55SCy Schubert ${func_parse_options_result+"$func_parse_options_result"} 1638*a466cc55SCy Schubert 1639*a466cc55SCy Schubert eval func_run_hooks func_options \ 1640*a466cc55SCy Schubert ${func_validate_options_result+"$func_validate_options_result"} 1641*a466cc55SCy Schubert 1642*a466cc55SCy Schubert # save modified positional parameters for caller 1643*a466cc55SCy Schubert func_options_result=$func_run_hooks_result 1644*a466cc55SCy Schubert} 1645*a466cc55SCy Schubert 1646*a466cc55SCy Schubert 1647*a466cc55SCy Schubert# func_options_prep [ARG]... 1648*a466cc55SCy Schubert# -------------------------- 1649*a466cc55SCy Schubert# All initialisations required before starting the option parse loop. 1650*a466cc55SCy Schubert# Note that when calling hook functions, we pass through the list of 1651*a466cc55SCy Schubert# positional parameters. If a hook function modifies that list, and 1652*a466cc55SCy Schubert# needs to propogate that back to rest of this script, then the complete 1653*a466cc55SCy Schubert# modified list must be put in 'func_run_hooks_result' before 1654*a466cc55SCy Schubert# returning. 1655*a466cc55SCy Schubertfunc_hookable func_options_prep 1656*a466cc55SCy Schubertfunc_options_prep () 1657*a466cc55SCy Schubert{ 1658*a466cc55SCy Schubert $debug_cmd 1659*a466cc55SCy Schubert 1660*a466cc55SCy Schubert # Option defaults: 1661*a466cc55SCy Schubert opt_verbose=false 1662*a466cc55SCy Schubert opt_warning_types= 1663*a466cc55SCy Schubert 1664*a466cc55SCy Schubert func_run_hooks func_options_prep ${1+"$@"} 1665*a466cc55SCy Schubert 1666*a466cc55SCy Schubert # save modified positional parameters for caller 1667*a466cc55SCy Schubert func_options_prep_result=$func_run_hooks_result 1668*a466cc55SCy Schubert} 1669*a466cc55SCy Schubert 1670*a466cc55SCy Schubert 1671*a466cc55SCy Schubert# func_parse_options [ARG]... 1672*a466cc55SCy Schubert# --------------------------- 1673*a466cc55SCy Schubert# The main option parsing loop. 1674*a466cc55SCy Schubertfunc_hookable func_parse_options 1675*a466cc55SCy Schubertfunc_parse_options () 1676*a466cc55SCy Schubert{ 1677*a466cc55SCy Schubert $debug_cmd 1678*a466cc55SCy Schubert 1679*a466cc55SCy Schubert func_parse_options_result= 1680*a466cc55SCy Schubert 1681*a466cc55SCy Schubert # this just eases exit handling 1682*a466cc55SCy Schubert while test $# -gt 0; do 1683*a466cc55SCy Schubert # Defer to hook functions for initial option parsing, so they 1684*a466cc55SCy Schubert # get priority in the event of reusing an option name. 1685*a466cc55SCy Schubert func_run_hooks func_parse_options ${1+"$@"} 1686*a466cc55SCy Schubert 1687*a466cc55SCy Schubert # Adjust func_parse_options positional parameters to match 1688*a466cc55SCy Schubert eval set dummy "$func_run_hooks_result"; shift 1689*a466cc55SCy Schubert 1690*a466cc55SCy Schubert # Break out of the loop if we already parsed every option. 1691*a466cc55SCy Schubert test $# -gt 0 || break 1692*a466cc55SCy Schubert 1693*a466cc55SCy Schubert _G_opt=$1 1694*a466cc55SCy Schubert shift 1695*a466cc55SCy Schubert case $_G_opt in 1696*a466cc55SCy Schubert --debug|-x) debug_cmd='set -x' 1697*a466cc55SCy Schubert func_echo "enabling shell trace mode" 1698*a466cc55SCy Schubert $debug_cmd 1699*a466cc55SCy Schubert ;; 1700*a466cc55SCy Schubert 1701*a466cc55SCy Schubert --no-warnings|--no-warning|--no-warn) 1702*a466cc55SCy Schubert set dummy --warnings none ${1+"$@"} 1703*a466cc55SCy Schubert shift 1704*a466cc55SCy Schubert ;; 1705*a466cc55SCy Schubert 1706*a466cc55SCy Schubert --warnings|--warning|-W) 1707*a466cc55SCy Schubert test $# = 0 && func_missing_arg $_G_opt && break 1708*a466cc55SCy Schubert case " $warning_categories $1" in 1709*a466cc55SCy Schubert *" $1 "*) 1710*a466cc55SCy Schubert # trailing space prevents matching last $1 above 1711*a466cc55SCy Schubert func_append_uniq opt_warning_types " $1" 1712*a466cc55SCy Schubert ;; 1713*a466cc55SCy Schubert *all) 1714*a466cc55SCy Schubert opt_warning_types=$warning_categories 1715*a466cc55SCy Schubert ;; 1716*a466cc55SCy Schubert *none) 1717*a466cc55SCy Schubert opt_warning_types=none 1718*a466cc55SCy Schubert warning_func=: 1719*a466cc55SCy Schubert ;; 1720*a466cc55SCy Schubert *error) 1721*a466cc55SCy Schubert opt_warning_types=$warning_categories 1722*a466cc55SCy Schubert warning_func=func_fatal_error 1723*a466cc55SCy Schubert ;; 1724*a466cc55SCy Schubert *) 1725*a466cc55SCy Schubert func_fatal_error \ 1726*a466cc55SCy Schubert "unsupported warning category: '$1'" 1727*a466cc55SCy Schubert ;; 1728*a466cc55SCy Schubert esac 1729*a466cc55SCy Schubert shift 1730*a466cc55SCy Schubert ;; 1731*a466cc55SCy Schubert 1732*a466cc55SCy Schubert --verbose|-v) opt_verbose=: ;; 1733*a466cc55SCy Schubert --version) func_version ;; 1734*a466cc55SCy Schubert -\?|-h) func_usage ;; 1735*a466cc55SCy Schubert --help) func_help ;; 1736*a466cc55SCy Schubert 1737*a466cc55SCy Schubert # Separate optargs to long options (plugins may need this): 1738*a466cc55SCy Schubert --*=*) func_split_equals "$_G_opt" 1739*a466cc55SCy Schubert set dummy "$func_split_equals_lhs" \ 1740*a466cc55SCy Schubert "$func_split_equals_rhs" ${1+"$@"} 1741*a466cc55SCy Schubert shift 1742*a466cc55SCy Schubert ;; 1743*a466cc55SCy Schubert 1744*a466cc55SCy Schubert # Separate optargs to short options: 1745*a466cc55SCy Schubert -W*) 1746*a466cc55SCy Schubert func_split_short_opt "$_G_opt" 1747*a466cc55SCy Schubert set dummy "$func_split_short_opt_name" \ 1748*a466cc55SCy Schubert "$func_split_short_opt_arg" ${1+"$@"} 1749*a466cc55SCy Schubert shift 1750*a466cc55SCy Schubert ;; 1751*a466cc55SCy Schubert 1752*a466cc55SCy Schubert # Separate non-argument short options: 1753*a466cc55SCy Schubert -\?*|-h*|-v*|-x*) 1754*a466cc55SCy Schubert func_split_short_opt "$_G_opt" 1755*a466cc55SCy Schubert set dummy "$func_split_short_opt_name" \ 1756*a466cc55SCy Schubert "-$func_split_short_opt_arg" ${1+"$@"} 1757*a466cc55SCy Schubert shift 1758*a466cc55SCy Schubert ;; 1759*a466cc55SCy Schubert 1760*a466cc55SCy Schubert --) break ;; 1761*a466cc55SCy Schubert -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762*a466cc55SCy Schubert *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763*a466cc55SCy Schubert esac 1764*a466cc55SCy Schubert done 1765*a466cc55SCy Schubert 1766*a466cc55SCy Schubert # save modified positional parameters for caller 1767*a466cc55SCy Schubert func_quote_for_eval ${1+"$@"} 1768*a466cc55SCy Schubert func_parse_options_result=$func_quote_for_eval_result 1769*a466cc55SCy Schubert} 1770*a466cc55SCy Schubert 1771*a466cc55SCy Schubert 1772*a466cc55SCy Schubert# func_validate_options [ARG]... 1773*a466cc55SCy Schubert# ------------------------------ 1774*a466cc55SCy Schubert# Perform any sanity checks on option settings and/or unconsumed 1775*a466cc55SCy Schubert# arguments. 1776*a466cc55SCy Schubertfunc_hookable func_validate_options 1777*a466cc55SCy Schubertfunc_validate_options () 1778*a466cc55SCy Schubert{ 1779*a466cc55SCy Schubert $debug_cmd 1780*a466cc55SCy Schubert 1781*a466cc55SCy Schubert # Display all warnings if -W was not given. 1782*a466cc55SCy Schubert test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783*a466cc55SCy Schubert 1784*a466cc55SCy Schubert func_run_hooks func_validate_options ${1+"$@"} 1785*a466cc55SCy Schubert 1786*a466cc55SCy Schubert # Bail if the options were screwed! 1787*a466cc55SCy Schubert $exit_cmd $EXIT_FAILURE 1788*a466cc55SCy Schubert 1789*a466cc55SCy Schubert # save modified positional parameters for caller 1790*a466cc55SCy Schubert func_validate_options_result=$func_run_hooks_result 1791*a466cc55SCy Schubert} 1792*a466cc55SCy Schubert 1793*a466cc55SCy Schubert 1794*a466cc55SCy Schubert 1795*a466cc55SCy Schubert## ----------------- ## 1796*a466cc55SCy Schubert## Helper functions. ## 1797*a466cc55SCy Schubert## ----------------- ## 1798*a466cc55SCy Schubert 1799*a466cc55SCy Schubert# This section contains the helper functions used by the rest of the 1800*a466cc55SCy Schubert# hookable option parser framework in ascii-betical order. 1801*a466cc55SCy Schubert 1802*a466cc55SCy Schubert 1803*a466cc55SCy Schubert# func_fatal_help ARG... 1804*a466cc55SCy Schubert# ---------------------- 1805*a466cc55SCy Schubert# Echo program name prefixed message to standard error, followed by 1806*a466cc55SCy Schubert# a help hint, and exit. 1807*a466cc55SCy Schubertfunc_fatal_help () 1808*a466cc55SCy Schubert{ 1809*a466cc55SCy Schubert $debug_cmd 1810*a466cc55SCy Schubert 1811*a466cc55SCy Schubert eval \$ECHO \""Usage: $usage"\" 1812*a466cc55SCy Schubert eval \$ECHO \""$fatal_help"\" 1813*a466cc55SCy Schubert func_error ${1+"$@"} 1814*a466cc55SCy Schubert exit $EXIT_FAILURE 1815*a466cc55SCy Schubert} 1816*a466cc55SCy Schubert 1817*a466cc55SCy Schubert 1818*a466cc55SCy Schubert# func_help 1819*a466cc55SCy Schubert# --------- 1820*a466cc55SCy Schubert# Echo long help message to standard output and exit. 1821*a466cc55SCy Schubertfunc_help () 1822*a466cc55SCy Schubert{ 1823*a466cc55SCy Schubert $debug_cmd 1824*a466cc55SCy Schubert 1825*a466cc55SCy Schubert func_usage_message 1826*a466cc55SCy Schubert $ECHO "$long_help_message" 1827*a466cc55SCy Schubert exit 0 1828*a466cc55SCy Schubert} 1829*a466cc55SCy Schubert 1830*a466cc55SCy Schubert 1831*a466cc55SCy Schubert# func_missing_arg ARGNAME 1832*a466cc55SCy Schubert# ------------------------ 1833*a466cc55SCy Schubert# Echo program name prefixed message to standard error and set global 1834*a466cc55SCy Schubert# exit_cmd. 1835*a466cc55SCy Schubertfunc_missing_arg () 1836*a466cc55SCy Schubert{ 1837*a466cc55SCy Schubert $debug_cmd 1838*a466cc55SCy Schubert 1839*a466cc55SCy Schubert func_error "Missing argument for '$1'." 1840*a466cc55SCy Schubert exit_cmd=exit 1841*a466cc55SCy Schubert} 1842*a466cc55SCy Schubert 1843*a466cc55SCy Schubert 1844*a466cc55SCy Schubert# func_split_equals STRING 1845*a466cc55SCy Schubert# ------------------------ 1846*a466cc55SCy Schubert# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847*a466cc55SCy Schubert# splitting STRING at the '=' sign. 1848*a466cc55SCy Schuberttest -z "$_G_HAVE_XSI_OPS" \ 1849*a466cc55SCy Schubert && (eval 'x=a/b/c; 1850*a466cc55SCy Schubert test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851*a466cc55SCy Schubert && _G_HAVE_XSI_OPS=yes 1852*a466cc55SCy Schubert 1853*a466cc55SCy Schubertif test yes = "$_G_HAVE_XSI_OPS" 1854*a466cc55SCy Schubertthen 1855*a466cc55SCy Schubert # This is an XSI compatible shell, allowing a faster implementation... 1856*a466cc55SCy Schubert eval 'func_split_equals () 1857*a466cc55SCy Schubert { 1858*a466cc55SCy Schubert $debug_cmd 1859*a466cc55SCy Schubert 1860*a466cc55SCy Schubert func_split_equals_lhs=${1%%=*} 1861*a466cc55SCy Schubert func_split_equals_rhs=${1#*=} 1862*a466cc55SCy Schubert test "x$func_split_equals_lhs" = "x$1" \ 1863*a466cc55SCy Schubert && func_split_equals_rhs= 1864*a466cc55SCy Schubert }' 1865*a466cc55SCy Schubertelse 1866*a466cc55SCy Schubert # ...otherwise fall back to using expr, which is often a shell builtin. 1867*a466cc55SCy Schubert func_split_equals () 1868*a466cc55SCy Schubert { 1869*a466cc55SCy Schubert $debug_cmd 1870*a466cc55SCy Schubert 1871*a466cc55SCy Schubert func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872*a466cc55SCy Schubert func_split_equals_rhs= 1873*a466cc55SCy Schubert test "x$func_split_equals_lhs" = "x$1" \ 1874*a466cc55SCy Schubert || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875*a466cc55SCy Schubert } 1876*a466cc55SCy Schubertfi #func_split_equals 1877*a466cc55SCy Schubert 1878*a466cc55SCy Schubert 1879*a466cc55SCy Schubert# func_split_short_opt SHORTOPT 1880*a466cc55SCy Schubert# ----------------------------- 1881*a466cc55SCy Schubert# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882*a466cc55SCy Schubert# variables after splitting SHORTOPT after the 2nd character. 1883*a466cc55SCy Schubertif test yes = "$_G_HAVE_XSI_OPS" 1884*a466cc55SCy Schubertthen 1885*a466cc55SCy Schubert # This is an XSI compatible shell, allowing a faster implementation... 1886*a466cc55SCy Schubert eval 'func_split_short_opt () 1887*a466cc55SCy Schubert { 1888*a466cc55SCy Schubert $debug_cmd 1889*a466cc55SCy Schubert 1890*a466cc55SCy Schubert func_split_short_opt_arg=${1#??} 1891*a466cc55SCy Schubert func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892*a466cc55SCy Schubert }' 1893*a466cc55SCy Schubertelse 1894*a466cc55SCy Schubert # ...otherwise fall back to using expr, which is often a shell builtin. 1895*a466cc55SCy Schubert func_split_short_opt () 1896*a466cc55SCy Schubert { 1897*a466cc55SCy Schubert $debug_cmd 1898*a466cc55SCy Schubert 1899*a466cc55SCy Schubert func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900*a466cc55SCy Schubert func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901*a466cc55SCy Schubert } 1902*a466cc55SCy Schubertfi #func_split_short_opt 1903*a466cc55SCy Schubert 1904*a466cc55SCy Schubert 1905*a466cc55SCy Schubert# func_usage 1906*a466cc55SCy Schubert# ---------- 1907*a466cc55SCy Schubert# Echo short help message to standard output and exit. 1908*a466cc55SCy Schubertfunc_usage () 1909*a466cc55SCy Schubert{ 1910*a466cc55SCy Schubert $debug_cmd 1911*a466cc55SCy Schubert 1912*a466cc55SCy Schubert func_usage_message 1913*a466cc55SCy Schubert $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914*a466cc55SCy Schubert exit 0 1915*a466cc55SCy Schubert} 1916*a466cc55SCy Schubert 1917*a466cc55SCy Schubert 1918*a466cc55SCy Schubert# func_usage_message 1919*a466cc55SCy Schubert# ------------------ 1920*a466cc55SCy Schubert# Echo short help message to standard output. 1921*a466cc55SCy Schubertfunc_usage_message () 1922*a466cc55SCy Schubert{ 1923*a466cc55SCy Schubert $debug_cmd 1924*a466cc55SCy Schubert 1925*a466cc55SCy Schubert eval \$ECHO \""Usage: $usage"\" 1926*a466cc55SCy Schubert echo 1927*a466cc55SCy Schubert $SED -n 's|^# || 1928*a466cc55SCy Schubert /^Written by/{ 1929*a466cc55SCy Schubert x;p;x 1930*a466cc55SCy Schubert } 1931*a466cc55SCy Schubert h 1932*a466cc55SCy Schubert /^Written by/q' < "$progpath" 1933*a466cc55SCy Schubert echo 1934*a466cc55SCy Schubert eval \$ECHO \""$usage_message"\" 1935*a466cc55SCy Schubert} 1936*a466cc55SCy Schubert 1937*a466cc55SCy Schubert 1938*a466cc55SCy Schubert# func_version 1939*a466cc55SCy Schubert# ------------ 1940*a466cc55SCy Schubert# Echo version message to standard output and exit. 1941*a466cc55SCy Schubertfunc_version () 1942*a466cc55SCy Schubert{ 1943*a466cc55SCy Schubert $debug_cmd 1944*a466cc55SCy Schubert 1945*a466cc55SCy Schubert printf '%s\n' "$progname $scriptversion" 1946*a466cc55SCy Schubert $SED -n ' 1947*a466cc55SCy Schubert /(C)/!b go 1948*a466cc55SCy Schubert :more 1949*a466cc55SCy Schubert /\./!{ 1950*a466cc55SCy Schubert N 1951*a466cc55SCy Schubert s|\n# | | 1952*a466cc55SCy Schubert b more 1953*a466cc55SCy Schubert } 1954*a466cc55SCy Schubert :go 1955*a466cc55SCy Schubert /^# Written by /,/# warranty; / { 1956*a466cc55SCy Schubert s|^# || 1957*a466cc55SCy Schubert s|^# *$|| 1958*a466cc55SCy Schubert s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959*a466cc55SCy Schubert p 1960*a466cc55SCy Schubert } 1961*a466cc55SCy Schubert /^# Written by / { 1962*a466cc55SCy Schubert s|^# || 1963*a466cc55SCy Schubert p 1964*a466cc55SCy Schubert } 1965*a466cc55SCy Schubert /^warranty; /q' < "$progpath" 1966*a466cc55SCy Schubert 1967*a466cc55SCy Schubert exit $? 1968*a466cc55SCy Schubert} 1969*a466cc55SCy Schubert 1970*a466cc55SCy Schubert 1971*a466cc55SCy Schubert# Local variables: 1972*a466cc55SCy Schubert# mode: shell-script 1973*a466cc55SCy Schubert# sh-indentation: 2 1974*a466cc55SCy Schubert# eval: (add-hook 'before-save-hook 'time-stamp) 1975*a466cc55SCy Schubert# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976*a466cc55SCy Schubert# time-stamp-time-zone: "UTC" 1977*a466cc55SCy Schubert# End: 1978*a466cc55SCy Schubert 1979*a466cc55SCy Schubert# Set a version string. 1980*a466cc55SCy Schubertscriptversion='(GNU libtool) 2.4.6' 1981*a466cc55SCy Schubert 1982*a466cc55SCy Schubert 1983*a466cc55SCy Schubert# func_echo ARG... 1984*a466cc55SCy Schubert# ---------------- 1985*a466cc55SCy Schubert# Libtool also displays the current mode in messages, so override 1986*a466cc55SCy Schubert# funclib.sh func_echo with this custom definition. 1987*a466cc55SCy Schubertfunc_echo () 1988*a466cc55SCy Schubert{ 1989*a466cc55SCy Schubert $debug_cmd 1990*a466cc55SCy Schubert 1991*a466cc55SCy Schubert _G_message=$* 1992*a466cc55SCy Schubert 1993*a466cc55SCy Schubert func_echo_IFS=$IFS 1994*a466cc55SCy Schubert IFS=$nl 1995*a466cc55SCy Schubert for _G_line in $_G_message; do 1996*a466cc55SCy Schubert IFS=$func_echo_IFS 1997*a466cc55SCy Schubert $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998*a466cc55SCy Schubert done 1999*a466cc55SCy Schubert IFS=$func_echo_IFS 2000*a466cc55SCy Schubert} 2001*a466cc55SCy Schubert 2002*a466cc55SCy Schubert 2003*a466cc55SCy Schubert# func_warning ARG... 2004*a466cc55SCy Schubert# ------------------- 2005*a466cc55SCy Schubert# Libtool warnings are not categorized, so override funclib.sh 2006*a466cc55SCy Schubert# func_warning with this simpler definition. 2007*a466cc55SCy Schubertfunc_warning () 2008*a466cc55SCy Schubert{ 2009*a466cc55SCy Schubert $debug_cmd 2010*a466cc55SCy Schubert 2011*a466cc55SCy Schubert $warning_func ${1+"$@"} 2012*a466cc55SCy Schubert} 2013*a466cc55SCy Schubert 2014*a466cc55SCy Schubert 2015*a466cc55SCy Schubert## ---------------- ## 2016*a466cc55SCy Schubert## Options parsing. ## 2017*a466cc55SCy Schubert## ---------------- ## 2018*a466cc55SCy Schubert 2019*a466cc55SCy Schubert# Hook in the functions to make sure our own options are parsed during 2020*a466cc55SCy Schubert# the option parsing loop. 2021*a466cc55SCy Schubert 2022*a466cc55SCy Schubertusage='$progpath [OPTION]... [MODE-ARG]...' 2023*a466cc55SCy Schubert 2024*a466cc55SCy Schubert# Short help message in response to '-h'. 2025*a466cc55SCy Schubertusage_message="Options: 2026*a466cc55SCy Schubert --config show all configuration variables 2027*a466cc55SCy Schubert --debug enable verbose shell tracing 2028*a466cc55SCy Schubert -n, --dry-run display commands without modifying any files 2029*a466cc55SCy Schubert --features display basic configuration information and exit 2030*a466cc55SCy Schubert --mode=MODE use operation mode MODE 2031*a466cc55SCy Schubert --no-warnings equivalent to '-Wnone' 2032*a466cc55SCy Schubert --preserve-dup-deps don't remove duplicate dependency libraries 2033*a466cc55SCy Schubert --quiet, --silent don't print informational messages 2034*a466cc55SCy Schubert --tag=TAG use configuration variables from tag TAG 2035*a466cc55SCy Schubert -v, --verbose print more informational messages than default 2036*a466cc55SCy Schubert --version print version information 2037*a466cc55SCy Schubert -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038*a466cc55SCy Schubert -h, --help, --help-all print short, long, or detailed help message 2039*a466cc55SCy Schubert" 2040*a466cc55SCy Schubert 2041*a466cc55SCy Schubert# Additional text appended to 'usage_message' in response to '--help'. 2042*a466cc55SCy Schubertfunc_help () 2043*a466cc55SCy Schubert{ 2044*a466cc55SCy Schubert $debug_cmd 2045*a466cc55SCy Schubert 2046*a466cc55SCy Schubert func_usage_message 2047*a466cc55SCy Schubert $ECHO "$long_help_message 2048*a466cc55SCy Schubert 2049*a466cc55SCy SchubertMODE must be one of the following: 2050*a466cc55SCy Schubert 2051*a466cc55SCy Schubert clean remove files from the build directory 2052*a466cc55SCy Schubert compile compile a source file into a libtool object 2053*a466cc55SCy Schubert execute automatically set library path, then run a program 2054*a466cc55SCy Schubert finish complete the installation of libtool libraries 2055*a466cc55SCy Schubert install install libraries or executables 2056*a466cc55SCy Schubert link create a library or an executable 2057*a466cc55SCy Schubert uninstall remove libraries from an installed directory 2058*a466cc55SCy Schubert 2059*a466cc55SCy SchubertMODE-ARGS vary depending on the MODE. When passed as first option, 2060*a466cc55SCy Schubert'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061*a466cc55SCy SchubertTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062*a466cc55SCy Schubert 2063*a466cc55SCy SchubertWhen reporting a bug, please describe a test case to reproduce it and 2064*a466cc55SCy Schubertinclude the following information: 2065*a466cc55SCy Schubert 2066*a466cc55SCy Schubert host-triplet: $host 2067*a466cc55SCy Schubert shell: $SHELL 2068*a466cc55SCy Schubert compiler: $LTCC 2069*a466cc55SCy Schubert compiler flags: $LTCFLAGS 2070*a466cc55SCy Schubert linker: $LD (gnu? $with_gnu_ld) 2071*a466cc55SCy Schubert version: $progname (GNU libtool) 2.4.6 2072*a466cc55SCy Schubert automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073*a466cc55SCy Schubert autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074*a466cc55SCy Schubert 2075*a466cc55SCy SchubertReport bugs to <bug-libtool@gnu.org>. 2076*a466cc55SCy SchubertGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077*a466cc55SCy SchubertGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078*a466cc55SCy Schubert exit 0 2079*a466cc55SCy Schubert} 2080*a466cc55SCy Schubert 2081*a466cc55SCy Schubert 2082*a466cc55SCy Schubert# func_lo2o OBJECT-NAME 2083*a466cc55SCy Schubert# --------------------- 2084*a466cc55SCy Schubert# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085*a466cc55SCy Schubert# object suffix. 2086*a466cc55SCy Schubert 2087*a466cc55SCy Schubertlo2o=s/\\.lo\$/.$objext/ 2088*a466cc55SCy Schuberto2lo=s/\\.$objext\$/.lo/ 2089*a466cc55SCy Schubert 2090*a466cc55SCy Schubertif test yes = "$_G_HAVE_XSI_OPS"; then 2091*a466cc55SCy Schubert eval 'func_lo2o () 2092*a466cc55SCy Schubert { 2093*a466cc55SCy Schubert case $1 in 2094*a466cc55SCy Schubert *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095*a466cc55SCy Schubert * ) func_lo2o_result=$1 ;; 2096*a466cc55SCy Schubert esac 2097*a466cc55SCy Schubert }' 2098*a466cc55SCy Schubert 2099*a466cc55SCy Schubert # func_xform LIBOBJ-OR-SOURCE 2100*a466cc55SCy Schubert # --------------------------- 2101*a466cc55SCy Schubert # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102*a466cc55SCy Schubert # suffix to a '.lo' libtool-object suffix. 2103*a466cc55SCy Schubert eval 'func_xform () 2104*a466cc55SCy Schubert { 2105*a466cc55SCy Schubert func_xform_result=${1%.*}.lo 2106*a466cc55SCy Schubert }' 2107*a466cc55SCy Schubertelse 2108*a466cc55SCy Schubert # ...otherwise fall back to using sed. 2109*a466cc55SCy Schubert func_lo2o () 2110*a466cc55SCy Schubert { 2111*a466cc55SCy Schubert func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112*a466cc55SCy Schubert } 2113*a466cc55SCy Schubert 2114*a466cc55SCy Schubert func_xform () 2115*a466cc55SCy Schubert { 2116*a466cc55SCy Schubert func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117*a466cc55SCy Schubert } 2118*a466cc55SCy Schubertfi 2119*a466cc55SCy Schubert 2120*a466cc55SCy Schubert 2121*a466cc55SCy Schubert# func_fatal_configuration ARG... 2122*a466cc55SCy Schubert# ------------------------------- 2123*a466cc55SCy Schubert# Echo program name prefixed message to standard error, followed by 2124*a466cc55SCy Schubert# a configuration failure hint, and exit. 2125*a466cc55SCy Schubertfunc_fatal_configuration () 2126*a466cc55SCy Schubert{ 2127*a466cc55SCy Schubert func__fatal_error ${1+"$@"} \ 2128*a466cc55SCy Schubert "See the $PACKAGE documentation for more information." \ 2129*a466cc55SCy Schubert "Fatal configuration error." 2130*a466cc55SCy Schubert} 2131*a466cc55SCy Schubert 2132*a466cc55SCy Schubert 2133*a466cc55SCy Schubert# func_config 2134*a466cc55SCy Schubert# ----------- 2135*a466cc55SCy Schubert# Display the configuration for all the tags in this script. 2136*a466cc55SCy Schubertfunc_config () 2137*a466cc55SCy Schubert{ 2138*a466cc55SCy Schubert re_begincf='^# ### BEGIN LIBTOOL' 2139*a466cc55SCy Schubert re_endcf='^# ### END LIBTOOL' 2140*a466cc55SCy Schubert 2141*a466cc55SCy Schubert # Default configuration. 2142*a466cc55SCy Schubert $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143*a466cc55SCy Schubert 2144*a466cc55SCy Schubert # Now print the configurations for the tags. 2145*a466cc55SCy Schubert for tagname in $taglist; do 2146*a466cc55SCy Schubert $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147*a466cc55SCy Schubert done 2148*a466cc55SCy Schubert 2149*a466cc55SCy Schubert exit $? 2150*a466cc55SCy Schubert} 2151*a466cc55SCy Schubert 2152*a466cc55SCy Schubert 2153*a466cc55SCy Schubert# func_features 2154*a466cc55SCy Schubert# ------------- 2155*a466cc55SCy Schubert# Display the features supported by this script. 2156*a466cc55SCy Schubertfunc_features () 2157*a466cc55SCy Schubert{ 2158*a466cc55SCy Schubert echo "host: $host" 2159*a466cc55SCy Schubert if test yes = "$build_libtool_libs"; then 2160*a466cc55SCy Schubert echo "enable shared libraries" 2161*a466cc55SCy Schubert else 2162*a466cc55SCy Schubert echo "disable shared libraries" 2163*a466cc55SCy Schubert fi 2164*a466cc55SCy Schubert if test yes = "$build_old_libs"; then 2165*a466cc55SCy Schubert echo "enable static libraries" 2166*a466cc55SCy Schubert else 2167*a466cc55SCy Schubert echo "disable static libraries" 2168*a466cc55SCy Schubert fi 2169*a466cc55SCy Schubert 2170*a466cc55SCy Schubert exit $? 2171*a466cc55SCy Schubert} 2172*a466cc55SCy Schubert 2173*a466cc55SCy Schubert 2174*a466cc55SCy Schubert# func_enable_tag TAGNAME 2175*a466cc55SCy Schubert# ----------------------- 2176*a466cc55SCy Schubert# Verify that TAGNAME is valid, and either flag an error and exit, or 2177*a466cc55SCy Schubert# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178*a466cc55SCy Schubert# variable here. 2179*a466cc55SCy Schubertfunc_enable_tag () 2180*a466cc55SCy Schubert{ 2181*a466cc55SCy Schubert # Global variable: 2182*a466cc55SCy Schubert tagname=$1 2183*a466cc55SCy Schubert 2184*a466cc55SCy Schubert re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185*a466cc55SCy Schubert re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186*a466cc55SCy Schubert sed_extractcf=/$re_begincf/,/$re_endcf/p 2187*a466cc55SCy Schubert 2188*a466cc55SCy Schubert # Validate tagname. 2189*a466cc55SCy Schubert case $tagname in 2190*a466cc55SCy Schubert *[!-_A-Za-z0-9,/]*) 2191*a466cc55SCy Schubert func_fatal_error "invalid tag name: $tagname" 2192*a466cc55SCy Schubert ;; 2193*a466cc55SCy Schubert esac 2194*a466cc55SCy Schubert 2195*a466cc55SCy Schubert # Don't test for the "default" C tag, as we know it's 2196*a466cc55SCy Schubert # there but not specially marked. 2197*a466cc55SCy Schubert case $tagname in 2198*a466cc55SCy Schubert CC) ;; 2199*a466cc55SCy Schubert *) 2200*a466cc55SCy Schubert if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201*a466cc55SCy Schubert taglist="$taglist $tagname" 2202*a466cc55SCy Schubert 2203*a466cc55SCy Schubert # Evaluate the configuration. Be careful to quote the path 2204*a466cc55SCy Schubert # and the sed script, to avoid splitting on whitespace, but 2205*a466cc55SCy Schubert # also don't use non-portable quotes within backquotes within 2206*a466cc55SCy Schubert # quotes we have to do it in 2 steps: 2207*a466cc55SCy Schubert extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208*a466cc55SCy Schubert eval "$extractedcf" 2209*a466cc55SCy Schubert else 2210*a466cc55SCy Schubert func_error "ignoring unknown tag $tagname" 2211*a466cc55SCy Schubert fi 2212*a466cc55SCy Schubert ;; 2213*a466cc55SCy Schubert esac 2214*a466cc55SCy Schubert} 2215*a466cc55SCy Schubert 2216*a466cc55SCy Schubert 2217*a466cc55SCy Schubert# func_check_version_match 2218*a466cc55SCy Schubert# ------------------------ 2219*a466cc55SCy Schubert# Ensure that we are using m4 macros, and libtool script from the same 2220*a466cc55SCy Schubert# release of libtool. 2221*a466cc55SCy Schubertfunc_check_version_match () 2222*a466cc55SCy Schubert{ 2223*a466cc55SCy Schubert if test "$package_revision" != "$macro_revision"; then 2224*a466cc55SCy Schubert if test "$VERSION" != "$macro_version"; then 2225*a466cc55SCy Schubert if test -z "$macro_version"; then 2226*a466cc55SCy Schubert cat >&2 <<_LT_EOF 2227*a466cc55SCy Schubert$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228*a466cc55SCy Schubert$progname: definition of this LT_INIT comes from an older release. 2229*a466cc55SCy Schubert$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230*a466cc55SCy Schubert$progname: and run autoconf again. 2231*a466cc55SCy Schubert_LT_EOF 2232*a466cc55SCy Schubert else 2233*a466cc55SCy Schubert cat >&2 <<_LT_EOF 2234*a466cc55SCy Schubert$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235*a466cc55SCy Schubert$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236*a466cc55SCy Schubert$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237*a466cc55SCy Schubert$progname: and run autoconf again. 2238*a466cc55SCy Schubert_LT_EOF 2239*a466cc55SCy Schubert fi 2240*a466cc55SCy Schubert else 2241*a466cc55SCy Schubert cat >&2 <<_LT_EOF 2242*a466cc55SCy Schubert$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243*a466cc55SCy Schubert$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244*a466cc55SCy Schubert$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245*a466cc55SCy Schubert$progname: of $PACKAGE $VERSION and run autoconf again. 2246*a466cc55SCy Schubert_LT_EOF 2247*a466cc55SCy Schubert fi 2248*a466cc55SCy Schubert 2249*a466cc55SCy Schubert exit $EXIT_MISMATCH 2250*a466cc55SCy Schubert fi 2251*a466cc55SCy Schubert} 2252*a466cc55SCy Schubert 2253*a466cc55SCy Schubert 2254*a466cc55SCy Schubert# libtool_options_prep [ARG]... 2255*a466cc55SCy Schubert# ----------------------------- 2256*a466cc55SCy Schubert# Preparation for options parsed by libtool. 2257*a466cc55SCy Schubertlibtool_options_prep () 2258*a466cc55SCy Schubert{ 2259*a466cc55SCy Schubert $debug_mode 2260*a466cc55SCy Schubert 2261*a466cc55SCy Schubert # Option defaults: 2262*a466cc55SCy Schubert opt_config=false 2263*a466cc55SCy Schubert opt_dlopen= 2264*a466cc55SCy Schubert opt_dry_run=false 2265*a466cc55SCy Schubert opt_help=false 2266*a466cc55SCy Schubert opt_mode= 2267*a466cc55SCy Schubert opt_preserve_dup_deps=false 2268*a466cc55SCy Schubert opt_quiet=false 2269*a466cc55SCy Schubert 2270*a466cc55SCy Schubert nonopt= 2271*a466cc55SCy Schubert preserve_args= 2272*a466cc55SCy Schubert 2273*a466cc55SCy Schubert # Shorthand for --mode=foo, only valid as the first argument 2274*a466cc55SCy Schubert case $1 in 2275*a466cc55SCy Schubert clean|clea|cle|cl) 2276*a466cc55SCy Schubert shift; set dummy --mode clean ${1+"$@"}; shift 2277*a466cc55SCy Schubert ;; 2278*a466cc55SCy Schubert compile|compil|compi|comp|com|co|c) 2279*a466cc55SCy Schubert shift; set dummy --mode compile ${1+"$@"}; shift 2280*a466cc55SCy Schubert ;; 2281*a466cc55SCy Schubert execute|execut|execu|exec|exe|ex|e) 2282*a466cc55SCy Schubert shift; set dummy --mode execute ${1+"$@"}; shift 2283*a466cc55SCy Schubert ;; 2284*a466cc55SCy Schubert finish|finis|fini|fin|fi|f) 2285*a466cc55SCy Schubert shift; set dummy --mode finish ${1+"$@"}; shift 2286*a466cc55SCy Schubert ;; 2287*a466cc55SCy Schubert install|instal|insta|inst|ins|in|i) 2288*a466cc55SCy Schubert shift; set dummy --mode install ${1+"$@"}; shift 2289*a466cc55SCy Schubert ;; 2290*a466cc55SCy Schubert link|lin|li|l) 2291*a466cc55SCy Schubert shift; set dummy --mode link ${1+"$@"}; shift 2292*a466cc55SCy Schubert ;; 2293*a466cc55SCy Schubert uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294*a466cc55SCy Schubert shift; set dummy --mode uninstall ${1+"$@"}; shift 2295*a466cc55SCy Schubert ;; 2296*a466cc55SCy Schubert esac 2297*a466cc55SCy Schubert 2298*a466cc55SCy Schubert # Pass back the list of options. 2299*a466cc55SCy Schubert func_quote_for_eval ${1+"$@"} 2300*a466cc55SCy Schubert libtool_options_prep_result=$func_quote_for_eval_result 2301*a466cc55SCy Schubert} 2302*a466cc55SCy Schubertfunc_add_hook func_options_prep libtool_options_prep 2303*a466cc55SCy Schubert 2304*a466cc55SCy Schubert 2305*a466cc55SCy Schubert# libtool_parse_options [ARG]... 2306*a466cc55SCy Schubert# --------------------------------- 2307*a466cc55SCy Schubert# Provide handling for libtool specific options. 2308*a466cc55SCy Schubertlibtool_parse_options () 2309*a466cc55SCy Schubert{ 2310*a466cc55SCy Schubert $debug_cmd 2311*a466cc55SCy Schubert 2312*a466cc55SCy Schubert # Perform our own loop to consume as many options as possible in 2313*a466cc55SCy Schubert # each iteration. 2314*a466cc55SCy Schubert while test $# -gt 0; do 2315*a466cc55SCy Schubert _G_opt=$1 2316*a466cc55SCy Schubert shift 2317*a466cc55SCy Schubert case $_G_opt in 2318*a466cc55SCy Schubert --dry-run|--dryrun|-n) 2319*a466cc55SCy Schubert opt_dry_run=: 2320*a466cc55SCy Schubert ;; 2321*a466cc55SCy Schubert 2322*a466cc55SCy Schubert --config) func_config ;; 2323*a466cc55SCy Schubert 2324*a466cc55SCy Schubert --dlopen|-dlopen) 2325*a466cc55SCy Schubert opt_dlopen="${opt_dlopen+$opt_dlopen 2326*a466cc55SCy Schubert}$1" 2327*a466cc55SCy Schubert shift 2328*a466cc55SCy Schubert ;; 2329*a466cc55SCy Schubert 2330*a466cc55SCy Schubert --preserve-dup-deps) 2331*a466cc55SCy Schubert opt_preserve_dup_deps=: ;; 2332*a466cc55SCy Schubert 2333*a466cc55SCy Schubert --features) func_features ;; 2334*a466cc55SCy Schubert 2335*a466cc55SCy Schubert --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336*a466cc55SCy Schubert 2337*a466cc55SCy Schubert --help) opt_help=: ;; 2338*a466cc55SCy Schubert 2339*a466cc55SCy Schubert --help-all) opt_help=': help-all' ;; 2340*a466cc55SCy Schubert 2341*a466cc55SCy Schubert --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342*a466cc55SCy Schubert opt_mode=$1 2343*a466cc55SCy Schubert case $1 in 2344*a466cc55SCy Schubert # Valid mode arguments: 2345*a466cc55SCy Schubert clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346*a466cc55SCy Schubert 2347*a466cc55SCy Schubert # Catch anything else as an error 2348*a466cc55SCy Schubert *) func_error "invalid argument for $_G_opt" 2349*a466cc55SCy Schubert exit_cmd=exit 2350*a466cc55SCy Schubert break 2351*a466cc55SCy Schubert ;; 2352*a466cc55SCy Schubert esac 2353*a466cc55SCy Schubert shift 2354*a466cc55SCy Schubert ;; 2355*a466cc55SCy Schubert 2356*a466cc55SCy Schubert --no-silent|--no-quiet) 2357*a466cc55SCy Schubert opt_quiet=false 2358*a466cc55SCy Schubert func_append preserve_args " $_G_opt" 2359*a466cc55SCy Schubert ;; 2360*a466cc55SCy Schubert 2361*a466cc55SCy Schubert --no-warnings|--no-warning|--no-warn) 2362*a466cc55SCy Schubert opt_warning=false 2363*a466cc55SCy Schubert func_append preserve_args " $_G_opt" 2364*a466cc55SCy Schubert ;; 2365*a466cc55SCy Schubert 2366*a466cc55SCy Schubert --no-verbose) 2367*a466cc55SCy Schubert opt_verbose=false 2368*a466cc55SCy Schubert func_append preserve_args " $_G_opt" 2369*a466cc55SCy Schubert ;; 2370*a466cc55SCy Schubert 2371*a466cc55SCy Schubert --silent|--quiet) 2372*a466cc55SCy Schubert opt_quiet=: 2373*a466cc55SCy Schubert opt_verbose=false 2374*a466cc55SCy Schubert func_append preserve_args " $_G_opt" 2375*a466cc55SCy Schubert ;; 2376*a466cc55SCy Schubert 2377*a466cc55SCy Schubert --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378*a466cc55SCy Schubert opt_tag=$1 2379*a466cc55SCy Schubert func_append preserve_args " $_G_opt $1" 2380*a466cc55SCy Schubert func_enable_tag "$1" 2381*a466cc55SCy Schubert shift 2382*a466cc55SCy Schubert ;; 2383*a466cc55SCy Schubert 2384*a466cc55SCy Schubert --verbose|-v) opt_quiet=false 2385*a466cc55SCy Schubert opt_verbose=: 2386*a466cc55SCy Schubert func_append preserve_args " $_G_opt" 2387*a466cc55SCy Schubert ;; 2388*a466cc55SCy Schubert 2389*a466cc55SCy Schubert # An option not handled by this hook function: 2390*a466cc55SCy Schubert *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391*a466cc55SCy Schubert esac 2392*a466cc55SCy Schubert done 2393*a466cc55SCy Schubert 2394*a466cc55SCy Schubert 2395*a466cc55SCy Schubert # save modified positional parameters for caller 2396*a466cc55SCy Schubert func_quote_for_eval ${1+"$@"} 2397*a466cc55SCy Schubert libtool_parse_options_result=$func_quote_for_eval_result 2398*a466cc55SCy Schubert} 2399*a466cc55SCy Schubertfunc_add_hook func_parse_options libtool_parse_options 2400*a466cc55SCy Schubert 2401*a466cc55SCy Schubert 2402*a466cc55SCy Schubert 2403*a466cc55SCy Schubert# libtool_validate_options [ARG]... 2404*a466cc55SCy Schubert# --------------------------------- 2405*a466cc55SCy Schubert# Perform any sanity checks on option settings and/or unconsumed 2406*a466cc55SCy Schubert# arguments. 2407*a466cc55SCy Schubertlibtool_validate_options () 2408*a466cc55SCy Schubert{ 2409*a466cc55SCy Schubert # save first non-option argument 2410*a466cc55SCy Schubert if test 0 -lt $#; then 2411*a466cc55SCy Schubert nonopt=$1 2412*a466cc55SCy Schubert shift 2413*a466cc55SCy Schubert fi 2414*a466cc55SCy Schubert 2415*a466cc55SCy Schubert # preserve --debug 2416*a466cc55SCy Schubert test : = "$debug_cmd" || func_append preserve_args " --debug" 2417*a466cc55SCy Schubert 2418*a466cc55SCy Schubert case $host in 2419*a466cc55SCy Schubert # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420*a466cc55SCy Schubert # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421*a466cc55SCy Schubert *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422*a466cc55SCy Schubert # don't eliminate duplications in $postdeps and $predeps 2423*a466cc55SCy Schubert opt_duplicate_compiler_generated_deps=: 2424*a466cc55SCy Schubert ;; 2425*a466cc55SCy Schubert *) 2426*a466cc55SCy Schubert opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427*a466cc55SCy Schubert ;; 2428*a466cc55SCy Schubert esac 2429*a466cc55SCy Schubert 2430*a466cc55SCy Schubert $opt_help || { 2431*a466cc55SCy Schubert # Sanity checks first: 2432*a466cc55SCy Schubert func_check_version_match 2433*a466cc55SCy Schubert 2434*a466cc55SCy Schubert test yes != "$build_libtool_libs" \ 2435*a466cc55SCy Schubert && test yes != "$build_old_libs" \ 2436*a466cc55SCy Schubert && func_fatal_configuration "not configured to build any kind of library" 2437*a466cc55SCy Schubert 2438*a466cc55SCy Schubert # Darwin sucks 2439*a466cc55SCy Schubert eval std_shrext=\"$shrext_cmds\" 2440*a466cc55SCy Schubert 2441*a466cc55SCy Schubert # Only execute mode is allowed to have -dlopen flags. 2442*a466cc55SCy Schubert if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443*a466cc55SCy Schubert func_error "unrecognized option '-dlopen'" 2444*a466cc55SCy Schubert $ECHO "$help" 1>&2 2445*a466cc55SCy Schubert exit $EXIT_FAILURE 2446*a466cc55SCy Schubert fi 2447*a466cc55SCy Schubert 2448*a466cc55SCy Schubert # Change the help message to a mode-specific one. 2449*a466cc55SCy Schubert generic_help=$help 2450*a466cc55SCy Schubert help="Try '$progname --help --mode=$opt_mode' for more information." 2451*a466cc55SCy Schubert } 2452*a466cc55SCy Schubert 2453*a466cc55SCy Schubert # Pass back the unparsed argument list 2454*a466cc55SCy Schubert func_quote_for_eval ${1+"$@"} 2455*a466cc55SCy Schubert libtool_validate_options_result=$func_quote_for_eval_result 2456*a466cc55SCy Schubert} 2457*a466cc55SCy Schubertfunc_add_hook func_validate_options libtool_validate_options 2458*a466cc55SCy Schubert 2459*a466cc55SCy Schubert 2460*a466cc55SCy Schubert# Process options as early as possible so that --help and --version 2461*a466cc55SCy Schubert# can return quickly. 2462*a466cc55SCy Schubertfunc_options ${1+"$@"} 2463*a466cc55SCy Schuberteval set dummy "$func_options_result"; shift 2464*a466cc55SCy Schubert 2465*a466cc55SCy Schubert 2466*a466cc55SCy Schubert 2467*a466cc55SCy Schubert## ----------- ## 2468*a466cc55SCy Schubert## Main. ## 2469*a466cc55SCy Schubert## ----------- ## 2470*a466cc55SCy Schubert 2471*a466cc55SCy Schubertmagic='%%%MAGIC variable%%%' 2472*a466cc55SCy Schubertmagic_exe='%%%MAGIC EXE variable%%%' 2473*a466cc55SCy Schubert 2474*a466cc55SCy Schubert# Global variables. 2475*a466cc55SCy Schubertextracted_archives= 2476*a466cc55SCy Schubertextracted_serial=0 2477*a466cc55SCy Schubert 2478*a466cc55SCy Schubert# If this variable is set in any of the actions, the command in it 2479*a466cc55SCy Schubert# will be execed at the end. This prevents here-documents from being 2480*a466cc55SCy Schubert# left over by shells. 2481*a466cc55SCy Schubertexec_cmd= 2482*a466cc55SCy Schubert 2483*a466cc55SCy Schubert 2484*a466cc55SCy Schubert# A function that is used when there is no print builtin or printf. 2485*a466cc55SCy Schubertfunc_fallback_echo () 2486*a466cc55SCy Schubert{ 2487*a466cc55SCy Schubert eval 'cat <<_LTECHO_EOF 2488*a466cc55SCy Schubert$1 2489*a466cc55SCy Schubert_LTECHO_EOF' 2490*a466cc55SCy Schubert} 2491*a466cc55SCy Schubert 2492*a466cc55SCy Schubert# func_generated_by_libtool 2493*a466cc55SCy Schubert# True iff stdin has been generated by Libtool. This function is only 2494*a466cc55SCy Schubert# a basic sanity check; it will hardly flush out determined imposters. 2495*a466cc55SCy Schubertfunc_generated_by_libtool_p () 2496*a466cc55SCy Schubert{ 2497*a466cc55SCy Schubert $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498*a466cc55SCy Schubert} 2499*a466cc55SCy Schubert 2500*a466cc55SCy Schubert# func_lalib_p file 2501*a466cc55SCy Schubert# True iff FILE is a libtool '.la' library or '.lo' object file. 2502*a466cc55SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2503*a466cc55SCy Schubert# determined imposters. 2504*a466cc55SCy Schubertfunc_lalib_p () 2505*a466cc55SCy Schubert{ 2506*a466cc55SCy Schubert test -f "$1" && 2507*a466cc55SCy Schubert $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508*a466cc55SCy Schubert} 2509*a466cc55SCy Schubert 2510*a466cc55SCy Schubert# func_lalib_unsafe_p file 2511*a466cc55SCy Schubert# True iff FILE is a libtool '.la' library or '.lo' object file. 2512*a466cc55SCy Schubert# This function implements the same check as func_lalib_p without 2513*a466cc55SCy Schubert# resorting to external programs. To this end, it redirects stdin and 2514*a466cc55SCy Schubert# closes it afterwards, without saving the original file descriptor. 2515*a466cc55SCy Schubert# As a safety measure, use it only where a negative result would be 2516*a466cc55SCy Schubert# fatal anyway. Works if 'file' does not exist. 2517*a466cc55SCy Schubertfunc_lalib_unsafe_p () 2518*a466cc55SCy Schubert{ 2519*a466cc55SCy Schubert lalib_p=no 2520*a466cc55SCy Schubert if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521*a466cc55SCy Schubert for lalib_p_l in 1 2 3 4 2522*a466cc55SCy Schubert do 2523*a466cc55SCy Schubert read lalib_p_line 2524*a466cc55SCy Schubert case $lalib_p_line in 2525*a466cc55SCy Schubert \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526*a466cc55SCy Schubert esac 2527*a466cc55SCy Schubert done 2528*a466cc55SCy Schubert exec 0<&5 5<&- 2529*a466cc55SCy Schubert fi 2530*a466cc55SCy Schubert test yes = "$lalib_p" 2531*a466cc55SCy Schubert} 2532*a466cc55SCy Schubert 2533*a466cc55SCy Schubert# func_ltwrapper_script_p file 2534*a466cc55SCy Schubert# True iff FILE is a libtool wrapper script 2535*a466cc55SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2536*a466cc55SCy Schubert# determined imposters. 2537*a466cc55SCy Schubertfunc_ltwrapper_script_p () 2538*a466cc55SCy Schubert{ 2539*a466cc55SCy Schubert test -f "$1" && 2540*a466cc55SCy Schubert $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541*a466cc55SCy Schubert} 2542*a466cc55SCy Schubert 2543*a466cc55SCy Schubert# func_ltwrapper_executable_p file 2544*a466cc55SCy Schubert# True iff FILE is a libtool wrapper executable 2545*a466cc55SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2546*a466cc55SCy Schubert# determined imposters. 2547*a466cc55SCy Schubertfunc_ltwrapper_executable_p () 2548*a466cc55SCy Schubert{ 2549*a466cc55SCy Schubert func_ltwrapper_exec_suffix= 2550*a466cc55SCy Schubert case $1 in 2551*a466cc55SCy Schubert *.exe) ;; 2552*a466cc55SCy Schubert *) func_ltwrapper_exec_suffix=.exe ;; 2553*a466cc55SCy Schubert esac 2554*a466cc55SCy Schubert $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555*a466cc55SCy Schubert} 2556*a466cc55SCy Schubert 2557*a466cc55SCy Schubert# func_ltwrapper_scriptname file 2558*a466cc55SCy Schubert# Assumes file is an ltwrapper_executable 2559*a466cc55SCy Schubert# uses $file to determine the appropriate filename for a 2560*a466cc55SCy Schubert# temporary ltwrapper_script. 2561*a466cc55SCy Schubertfunc_ltwrapper_scriptname () 2562*a466cc55SCy Schubert{ 2563*a466cc55SCy Schubert func_dirname_and_basename "$1" "" "." 2564*a466cc55SCy Schubert func_stripname '' '.exe' "$func_basename_result" 2565*a466cc55SCy Schubert func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566*a466cc55SCy Schubert} 2567*a466cc55SCy Schubert 2568*a466cc55SCy Schubert# func_ltwrapper_p file 2569*a466cc55SCy Schubert# True iff FILE is a libtool wrapper script or wrapper executable 2570*a466cc55SCy Schubert# This function is only a basic sanity check; it will hardly flush out 2571*a466cc55SCy Schubert# determined imposters. 2572*a466cc55SCy Schubertfunc_ltwrapper_p () 2573*a466cc55SCy Schubert{ 2574*a466cc55SCy Schubert func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575*a466cc55SCy Schubert} 2576*a466cc55SCy Schubert 2577*a466cc55SCy Schubert 2578*a466cc55SCy Schubert# func_execute_cmds commands fail_cmd 2579*a466cc55SCy Schubert# Execute tilde-delimited COMMANDS. 2580*a466cc55SCy Schubert# If FAIL_CMD is given, eval that upon failure. 2581*a466cc55SCy Schubert# FAIL_CMD may read-access the current command in variable CMD! 2582*a466cc55SCy Schubertfunc_execute_cmds () 2583*a466cc55SCy Schubert{ 2584*a466cc55SCy Schubert $debug_cmd 2585*a466cc55SCy Schubert 2586*a466cc55SCy Schubert save_ifs=$IFS; IFS='~' 2587*a466cc55SCy Schubert for cmd in $1; do 2588*a466cc55SCy Schubert IFS=$sp$nl 2589*a466cc55SCy Schubert eval cmd=\"$cmd\" 2590*a466cc55SCy Schubert IFS=$save_ifs 2591*a466cc55SCy Schubert func_show_eval "$cmd" "${2-:}" 2592*a466cc55SCy Schubert done 2593*a466cc55SCy Schubert IFS=$save_ifs 2594*a466cc55SCy Schubert} 2595*a466cc55SCy Schubert 2596*a466cc55SCy Schubert 2597*a466cc55SCy Schubert# func_source file 2598*a466cc55SCy Schubert# Source FILE, adding directory component if necessary. 2599*a466cc55SCy Schubert# Note that it is not necessary on cygwin/mingw to append a dot to 2600*a466cc55SCy Schubert# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601*a466cc55SCy Schubert# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602*a466cc55SCy Schubert# 'FILE.' does not work on cygwin managed mounts. 2603*a466cc55SCy Schubertfunc_source () 2604*a466cc55SCy Schubert{ 2605*a466cc55SCy Schubert $debug_cmd 2606*a466cc55SCy Schubert 2607*a466cc55SCy Schubert case $1 in 2608*a466cc55SCy Schubert */* | *\\*) . "$1" ;; 2609*a466cc55SCy Schubert *) . "./$1" ;; 2610*a466cc55SCy Schubert esac 2611*a466cc55SCy Schubert} 2612*a466cc55SCy Schubert 2613*a466cc55SCy Schubert 2614*a466cc55SCy Schubert# func_resolve_sysroot PATH 2615*a466cc55SCy Schubert# Replace a leading = in PATH with a sysroot. Store the result into 2616*a466cc55SCy Schubert# func_resolve_sysroot_result 2617*a466cc55SCy Schubertfunc_resolve_sysroot () 2618*a466cc55SCy Schubert{ 2619*a466cc55SCy Schubert func_resolve_sysroot_result=$1 2620*a466cc55SCy Schubert case $func_resolve_sysroot_result in 2621*a466cc55SCy Schubert =*) 2622*a466cc55SCy Schubert func_stripname '=' '' "$func_resolve_sysroot_result" 2623*a466cc55SCy Schubert func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624*a466cc55SCy Schubert ;; 2625*a466cc55SCy Schubert esac 2626*a466cc55SCy Schubert} 2627*a466cc55SCy Schubert 2628*a466cc55SCy Schubert# func_replace_sysroot PATH 2629*a466cc55SCy Schubert# If PATH begins with the sysroot, replace it with = and 2630*a466cc55SCy Schubert# store the result into func_replace_sysroot_result. 2631*a466cc55SCy Schubertfunc_replace_sysroot () 2632*a466cc55SCy Schubert{ 2633*a466cc55SCy Schubert case $lt_sysroot:$1 in 2634*a466cc55SCy Schubert ?*:"$lt_sysroot"*) 2635*a466cc55SCy Schubert func_stripname "$lt_sysroot" '' "$1" 2636*a466cc55SCy Schubert func_replace_sysroot_result='='$func_stripname_result 2637*a466cc55SCy Schubert ;; 2638*a466cc55SCy Schubert *) 2639*a466cc55SCy Schubert # Including no sysroot. 2640*a466cc55SCy Schubert func_replace_sysroot_result=$1 2641*a466cc55SCy Schubert ;; 2642*a466cc55SCy Schubert esac 2643*a466cc55SCy Schubert} 2644*a466cc55SCy Schubert 2645*a466cc55SCy Schubert# func_infer_tag arg 2646*a466cc55SCy Schubert# Infer tagged configuration to use if any are available and 2647*a466cc55SCy Schubert# if one wasn't chosen via the "--tag" command line option. 2648*a466cc55SCy Schubert# Only attempt this if the compiler in the base compile 2649*a466cc55SCy Schubert# command doesn't match the default compiler. 2650*a466cc55SCy Schubert# arg is usually of the form 'gcc ...' 2651*a466cc55SCy Schubertfunc_infer_tag () 2652*a466cc55SCy Schubert{ 2653*a466cc55SCy Schubert $debug_cmd 2654*a466cc55SCy Schubert 2655*a466cc55SCy Schubert if test -n "$available_tags" && test -z "$tagname"; then 2656*a466cc55SCy Schubert CC_quoted= 2657*a466cc55SCy Schubert for arg in $CC; do 2658*a466cc55SCy Schubert func_append_quoted CC_quoted "$arg" 2659*a466cc55SCy Schubert done 2660*a466cc55SCy Schubert CC_expanded=`func_echo_all $CC` 2661*a466cc55SCy Schubert CC_quoted_expanded=`func_echo_all $CC_quoted` 2662*a466cc55SCy Schubert case $@ in 2663*a466cc55SCy Schubert # Blanks in the command may have been stripped by the calling shell, 2664*a466cc55SCy Schubert # but not from the CC environment variable when configure was run. 2665*a466cc55SCy Schubert " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666*a466cc55SCy Schubert " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667*a466cc55SCy Schubert # Blanks at the start of $base_compile will cause this to fail 2668*a466cc55SCy Schubert # if we don't check for them as well. 2669*a466cc55SCy Schubert *) 2670*a466cc55SCy Schubert for z in $available_tags; do 2671*a466cc55SCy Schubert if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672*a466cc55SCy Schubert # Evaluate the configuration. 2673*a466cc55SCy Schubert eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674*a466cc55SCy Schubert CC_quoted= 2675*a466cc55SCy Schubert for arg in $CC; do 2676*a466cc55SCy Schubert # Double-quote args containing other shell metacharacters. 2677*a466cc55SCy Schubert func_append_quoted CC_quoted "$arg" 2678*a466cc55SCy Schubert done 2679*a466cc55SCy Schubert CC_expanded=`func_echo_all $CC` 2680*a466cc55SCy Schubert CC_quoted_expanded=`func_echo_all $CC_quoted` 2681*a466cc55SCy Schubert case "$@ " in 2682*a466cc55SCy Schubert " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683*a466cc55SCy Schubert " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684*a466cc55SCy Schubert # The compiler in the base compile command matches 2685*a466cc55SCy Schubert # the one in the tagged configuration. 2686*a466cc55SCy Schubert # Assume this is the tagged configuration we want. 2687*a466cc55SCy Schubert tagname=$z 2688*a466cc55SCy Schubert break 2689*a466cc55SCy Schubert ;; 2690*a466cc55SCy Schubert esac 2691*a466cc55SCy Schubert fi 2692*a466cc55SCy Schubert done 2693*a466cc55SCy Schubert # If $tagname still isn't set, then no tagged configuration 2694*a466cc55SCy Schubert # was found and let the user know that the "--tag" command 2695*a466cc55SCy Schubert # line option must be used. 2696*a466cc55SCy Schubert if test -z "$tagname"; then 2697*a466cc55SCy Schubert func_echo "unable to infer tagged configuration" 2698*a466cc55SCy Schubert func_fatal_error "specify a tag with '--tag'" 2699*a466cc55SCy Schubert# else 2700*a466cc55SCy Schubert# func_verbose "using $tagname tagged configuration" 2701*a466cc55SCy Schubert fi 2702*a466cc55SCy Schubert ;; 2703*a466cc55SCy Schubert esac 2704*a466cc55SCy Schubert fi 2705*a466cc55SCy Schubert} 2706*a466cc55SCy Schubert 2707*a466cc55SCy Schubert 2708*a466cc55SCy Schubert 2709*a466cc55SCy Schubert# func_write_libtool_object output_name pic_name nonpic_name 2710*a466cc55SCy Schubert# Create a libtool object file (analogous to a ".la" file), 2711*a466cc55SCy Schubert# but don't create it if we're doing a dry run. 2712*a466cc55SCy Schubertfunc_write_libtool_object () 2713*a466cc55SCy Schubert{ 2714*a466cc55SCy Schubert write_libobj=$1 2715*a466cc55SCy Schubert if test yes = "$build_libtool_libs"; then 2716*a466cc55SCy Schubert write_lobj=\'$2\' 2717*a466cc55SCy Schubert else 2718*a466cc55SCy Schubert write_lobj=none 2719*a466cc55SCy Schubert fi 2720*a466cc55SCy Schubert 2721*a466cc55SCy Schubert if test yes = "$build_old_libs"; then 2722*a466cc55SCy Schubert write_oldobj=\'$3\' 2723*a466cc55SCy Schubert else 2724*a466cc55SCy Schubert write_oldobj=none 2725*a466cc55SCy Schubert fi 2726*a466cc55SCy Schubert 2727*a466cc55SCy Schubert $opt_dry_run || { 2728*a466cc55SCy Schubert cat >${write_libobj}T <<EOF 2729*a466cc55SCy Schubert# $write_libobj - a libtool object file 2730*a466cc55SCy Schubert# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731*a466cc55SCy Schubert# 2732*a466cc55SCy Schubert# Please DO NOT delete this file! 2733*a466cc55SCy Schubert# It is necessary for linking the library. 2734*a466cc55SCy Schubert 2735*a466cc55SCy Schubert# Name of the PIC object. 2736*a466cc55SCy Schubertpic_object=$write_lobj 2737*a466cc55SCy Schubert 2738*a466cc55SCy Schubert# Name of the non-PIC object 2739*a466cc55SCy Schubertnon_pic_object=$write_oldobj 2740*a466cc55SCy Schubert 2741*a466cc55SCy SchubertEOF 2742*a466cc55SCy Schubert $MV "${write_libobj}T" "$write_libobj" 2743*a466cc55SCy Schubert } 2744*a466cc55SCy Schubert} 2745*a466cc55SCy Schubert 2746*a466cc55SCy Schubert 2747*a466cc55SCy Schubert################################################## 2748*a466cc55SCy Schubert# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749*a466cc55SCy Schubert################################################## 2750*a466cc55SCy Schubert 2751*a466cc55SCy Schubert# func_convert_core_file_wine_to_w32 ARG 2752*a466cc55SCy Schubert# Helper function used by file name conversion functions when $build is *nix, 2753*a466cc55SCy Schubert# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754*a466cc55SCy Schubert# correctly configured wine environment available, with the winepath program 2755*a466cc55SCy Schubert# in $build's $PATH. 2756*a466cc55SCy Schubert# 2757*a466cc55SCy Schubert# ARG is the $build file name to be converted to w32 format. 2758*a466cc55SCy Schubert# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759*a466cc55SCy Schubert# be empty on error (or when ARG is empty) 2760*a466cc55SCy Schubertfunc_convert_core_file_wine_to_w32 () 2761*a466cc55SCy Schubert{ 2762*a466cc55SCy Schubert $debug_cmd 2763*a466cc55SCy Schubert 2764*a466cc55SCy Schubert func_convert_core_file_wine_to_w32_result=$1 2765*a466cc55SCy Schubert if test -n "$1"; then 2766*a466cc55SCy Schubert # Unfortunately, winepath does not exit with a non-zero error code, so we 2767*a466cc55SCy Schubert # are forced to check the contents of stdout. On the other hand, if the 2768*a466cc55SCy Schubert # command is not found, the shell will set an exit code of 127 and print 2769*a466cc55SCy Schubert # *an error message* to stdout. So we must check for both error code of 2770*a466cc55SCy Schubert # zero AND non-empty stdout, which explains the odd construction: 2771*a466cc55SCy Schubert func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772*a466cc55SCy Schubert if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773*a466cc55SCy Schubert func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774*a466cc55SCy Schubert $SED -e "$sed_naive_backslashify"` 2775*a466cc55SCy Schubert else 2776*a466cc55SCy Schubert func_convert_core_file_wine_to_w32_result= 2777*a466cc55SCy Schubert fi 2778*a466cc55SCy Schubert fi 2779*a466cc55SCy Schubert} 2780*a466cc55SCy Schubert# end: func_convert_core_file_wine_to_w32 2781*a466cc55SCy Schubert 2782*a466cc55SCy Schubert 2783*a466cc55SCy Schubert# func_convert_core_path_wine_to_w32 ARG 2784*a466cc55SCy Schubert# Helper function used by path conversion functions when $build is *nix, and 2785*a466cc55SCy Schubert# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786*a466cc55SCy Schubert# configured wine environment available, with the winepath program in $build's 2787*a466cc55SCy Schubert# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788*a466cc55SCy Schubert# 2789*a466cc55SCy Schubert# ARG is path to be converted from $build format to win32. 2790*a466cc55SCy Schubert# Result is available in $func_convert_core_path_wine_to_w32_result. 2791*a466cc55SCy Schubert# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792*a466cc55SCy Schubert# are convertible, then the result may be empty. 2793*a466cc55SCy Schubertfunc_convert_core_path_wine_to_w32 () 2794*a466cc55SCy Schubert{ 2795*a466cc55SCy Schubert $debug_cmd 2796*a466cc55SCy Schubert 2797*a466cc55SCy Schubert # unfortunately, winepath doesn't convert paths, only file names 2798*a466cc55SCy Schubert func_convert_core_path_wine_to_w32_result= 2799*a466cc55SCy Schubert if test -n "$1"; then 2800*a466cc55SCy Schubert oldIFS=$IFS 2801*a466cc55SCy Schubert IFS=: 2802*a466cc55SCy Schubert for func_convert_core_path_wine_to_w32_f in $1; do 2803*a466cc55SCy Schubert IFS=$oldIFS 2804*a466cc55SCy Schubert func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805*a466cc55SCy Schubert if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806*a466cc55SCy Schubert if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807*a466cc55SCy Schubert func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808*a466cc55SCy Schubert else 2809*a466cc55SCy Schubert func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810*a466cc55SCy Schubert fi 2811*a466cc55SCy Schubert fi 2812*a466cc55SCy Schubert done 2813*a466cc55SCy Schubert IFS=$oldIFS 2814*a466cc55SCy Schubert fi 2815*a466cc55SCy Schubert} 2816*a466cc55SCy Schubert# end: func_convert_core_path_wine_to_w32 2817*a466cc55SCy Schubert 2818*a466cc55SCy Schubert 2819*a466cc55SCy Schubert# func_cygpath ARGS... 2820*a466cc55SCy Schubert# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821*a466cc55SCy Schubert# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822*a466cc55SCy Schubert# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823*a466cc55SCy Schubert# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824*a466cc55SCy Schubert# file name or path is assumed to be in w32 format, as previously converted 2825*a466cc55SCy Schubert# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826*a466cc55SCy Schubert# or path in func_cygpath_result (input file name or path is assumed to be in 2827*a466cc55SCy Schubert# Cygwin format). Returns an empty string on error. 2828*a466cc55SCy Schubert# 2829*a466cc55SCy Schubert# ARGS are passed to cygpath, with the last one being the file name or path to 2830*a466cc55SCy Schubert# be converted. 2831*a466cc55SCy Schubert# 2832*a466cc55SCy Schubert# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833*a466cc55SCy Schubert# environment variable; do not put it in $PATH. 2834*a466cc55SCy Schubertfunc_cygpath () 2835*a466cc55SCy Schubert{ 2836*a466cc55SCy Schubert $debug_cmd 2837*a466cc55SCy Schubert 2838*a466cc55SCy Schubert if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839*a466cc55SCy Schubert func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840*a466cc55SCy Schubert if test "$?" -ne 0; then 2841*a466cc55SCy Schubert # on failure, ensure result is empty 2842*a466cc55SCy Schubert func_cygpath_result= 2843*a466cc55SCy Schubert fi 2844*a466cc55SCy Schubert else 2845*a466cc55SCy Schubert func_cygpath_result= 2846*a466cc55SCy Schubert func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847*a466cc55SCy Schubert fi 2848*a466cc55SCy Schubert} 2849*a466cc55SCy Schubert#end: func_cygpath 2850*a466cc55SCy Schubert 2851*a466cc55SCy Schubert 2852*a466cc55SCy Schubert# func_convert_core_msys_to_w32 ARG 2853*a466cc55SCy Schubert# Convert file name or path ARG from MSYS format to w32 format. Return 2854*a466cc55SCy Schubert# result in func_convert_core_msys_to_w32_result. 2855*a466cc55SCy Schubertfunc_convert_core_msys_to_w32 () 2856*a466cc55SCy Schubert{ 2857*a466cc55SCy Schubert $debug_cmd 2858*a466cc55SCy Schubert 2859*a466cc55SCy Schubert # awkward: cmd appends spaces to result 2860*a466cc55SCy Schubert func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861*a466cc55SCy Schubert $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862*a466cc55SCy Schubert} 2863*a466cc55SCy Schubert#end: func_convert_core_msys_to_w32 2864*a466cc55SCy Schubert 2865*a466cc55SCy Schubert 2866*a466cc55SCy Schubert# func_convert_file_check ARG1 ARG2 2867*a466cc55SCy Schubert# Verify that ARG1 (a file name in $build format) was converted to $host 2868*a466cc55SCy Schubert# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869*a466cc55SCy Schubert# func_to_host_file_result to ARG1). 2870*a466cc55SCy Schubertfunc_convert_file_check () 2871*a466cc55SCy Schubert{ 2872*a466cc55SCy Schubert $debug_cmd 2873*a466cc55SCy Schubert 2874*a466cc55SCy Schubert if test -z "$2" && test -n "$1"; then 2875*a466cc55SCy Schubert func_error "Could not determine host file name corresponding to" 2876*a466cc55SCy Schubert func_error " '$1'" 2877*a466cc55SCy Schubert func_error "Continuing, but uninstalled executables may not work." 2878*a466cc55SCy Schubert # Fallback: 2879*a466cc55SCy Schubert func_to_host_file_result=$1 2880*a466cc55SCy Schubert fi 2881*a466cc55SCy Schubert} 2882*a466cc55SCy Schubert# end func_convert_file_check 2883*a466cc55SCy Schubert 2884*a466cc55SCy Schubert 2885*a466cc55SCy Schubert# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886*a466cc55SCy Schubert# Verify that FROM_PATH (a path in $build format) was converted to $host 2887*a466cc55SCy Schubert# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888*a466cc55SCy Schubert# func_to_host_file_result to a simplistic fallback value (see below). 2889*a466cc55SCy Schubertfunc_convert_path_check () 2890*a466cc55SCy Schubert{ 2891*a466cc55SCy Schubert $debug_cmd 2892*a466cc55SCy Schubert 2893*a466cc55SCy Schubert if test -z "$4" && test -n "$3"; then 2894*a466cc55SCy Schubert func_error "Could not determine the host path corresponding to" 2895*a466cc55SCy Schubert func_error " '$3'" 2896*a466cc55SCy Schubert func_error "Continuing, but uninstalled executables may not work." 2897*a466cc55SCy Schubert # Fallback. This is a deliberately simplistic "conversion" and 2898*a466cc55SCy Schubert # should not be "improved". See libtool.info. 2899*a466cc55SCy Schubert if test "x$1" != "x$2"; then 2900*a466cc55SCy Schubert lt_replace_pathsep_chars="s|$1|$2|g" 2901*a466cc55SCy Schubert func_to_host_path_result=`echo "$3" | 2902*a466cc55SCy Schubert $SED -e "$lt_replace_pathsep_chars"` 2903*a466cc55SCy Schubert else 2904*a466cc55SCy Schubert func_to_host_path_result=$3 2905*a466cc55SCy Schubert fi 2906*a466cc55SCy Schubert fi 2907*a466cc55SCy Schubert} 2908*a466cc55SCy Schubert# end func_convert_path_check 2909*a466cc55SCy Schubert 2910*a466cc55SCy Schubert 2911*a466cc55SCy Schubert# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912*a466cc55SCy Schubert# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913*a466cc55SCy Schubert# and appending REPL if ORIG matches BACKPAT. 2914*a466cc55SCy Schubertfunc_convert_path_front_back_pathsep () 2915*a466cc55SCy Schubert{ 2916*a466cc55SCy Schubert $debug_cmd 2917*a466cc55SCy Schubert 2918*a466cc55SCy Schubert case $4 in 2919*a466cc55SCy Schubert $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920*a466cc55SCy Schubert ;; 2921*a466cc55SCy Schubert esac 2922*a466cc55SCy Schubert case $4 in 2923*a466cc55SCy Schubert $2 ) func_append func_to_host_path_result "$3" 2924*a466cc55SCy Schubert ;; 2925*a466cc55SCy Schubert esac 2926*a466cc55SCy Schubert} 2927*a466cc55SCy Schubert# end func_convert_path_front_back_pathsep 2928*a466cc55SCy Schubert 2929*a466cc55SCy Schubert 2930*a466cc55SCy Schubert################################################## 2931*a466cc55SCy Schubert# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932*a466cc55SCy Schubert################################################## 2933*a466cc55SCy Schubert# invoked via '$to_host_file_cmd ARG' 2934*a466cc55SCy Schubert# 2935*a466cc55SCy Schubert# In each case, ARG is the path to be converted from $build to $host format. 2936*a466cc55SCy Schubert# Result will be available in $func_to_host_file_result. 2937*a466cc55SCy Schubert 2938*a466cc55SCy Schubert 2939*a466cc55SCy Schubert# func_to_host_file ARG 2940*a466cc55SCy Schubert# Converts the file name ARG from $build format to $host format. Return result 2941*a466cc55SCy Schubert# in func_to_host_file_result. 2942*a466cc55SCy Schubertfunc_to_host_file () 2943*a466cc55SCy Schubert{ 2944*a466cc55SCy Schubert $debug_cmd 2945*a466cc55SCy Schubert 2946*a466cc55SCy Schubert $to_host_file_cmd "$1" 2947*a466cc55SCy Schubert} 2948*a466cc55SCy Schubert# end func_to_host_file 2949*a466cc55SCy Schubert 2950*a466cc55SCy Schubert 2951*a466cc55SCy Schubert# func_to_tool_file ARG LAZY 2952*a466cc55SCy Schubert# converts the file name ARG from $build format to toolchain format. Return 2953*a466cc55SCy Schubert# result in func_to_tool_file_result. If the conversion in use is listed 2954*a466cc55SCy Schubert# in (the comma separated) LAZY, no conversion takes place. 2955*a466cc55SCy Schubertfunc_to_tool_file () 2956*a466cc55SCy Schubert{ 2957*a466cc55SCy Schubert $debug_cmd 2958*a466cc55SCy Schubert 2959*a466cc55SCy Schubert case ,$2, in 2960*a466cc55SCy Schubert *,"$to_tool_file_cmd",*) 2961*a466cc55SCy Schubert func_to_tool_file_result=$1 2962*a466cc55SCy Schubert ;; 2963*a466cc55SCy Schubert *) 2964*a466cc55SCy Schubert $to_tool_file_cmd "$1" 2965*a466cc55SCy Schubert func_to_tool_file_result=$func_to_host_file_result 2966*a466cc55SCy Schubert ;; 2967*a466cc55SCy Schubert esac 2968*a466cc55SCy Schubert} 2969*a466cc55SCy Schubert# end func_to_tool_file 2970*a466cc55SCy Schubert 2971*a466cc55SCy Schubert 2972*a466cc55SCy Schubert# func_convert_file_noop ARG 2973*a466cc55SCy Schubert# Copy ARG to func_to_host_file_result. 2974*a466cc55SCy Schubertfunc_convert_file_noop () 2975*a466cc55SCy Schubert{ 2976*a466cc55SCy Schubert func_to_host_file_result=$1 2977*a466cc55SCy Schubert} 2978*a466cc55SCy Schubert# end func_convert_file_noop 2979*a466cc55SCy Schubert 2980*a466cc55SCy Schubert 2981*a466cc55SCy Schubert# func_convert_file_msys_to_w32 ARG 2982*a466cc55SCy Schubert# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983*a466cc55SCy Schubert# conversion to w32 is not available inside the cwrapper. Returns result in 2984*a466cc55SCy Schubert# func_to_host_file_result. 2985*a466cc55SCy Schubertfunc_convert_file_msys_to_w32 () 2986*a466cc55SCy Schubert{ 2987*a466cc55SCy Schubert $debug_cmd 2988*a466cc55SCy Schubert 2989*a466cc55SCy Schubert func_to_host_file_result=$1 2990*a466cc55SCy Schubert if test -n "$1"; then 2991*a466cc55SCy Schubert func_convert_core_msys_to_w32 "$1" 2992*a466cc55SCy Schubert func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993*a466cc55SCy Schubert fi 2994*a466cc55SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 2995*a466cc55SCy Schubert} 2996*a466cc55SCy Schubert# end func_convert_file_msys_to_w32 2997*a466cc55SCy Schubert 2998*a466cc55SCy Schubert 2999*a466cc55SCy Schubert# func_convert_file_cygwin_to_w32 ARG 3000*a466cc55SCy Schubert# Convert file name ARG from Cygwin to w32 format. Returns result in 3001*a466cc55SCy Schubert# func_to_host_file_result. 3002*a466cc55SCy Schubertfunc_convert_file_cygwin_to_w32 () 3003*a466cc55SCy Schubert{ 3004*a466cc55SCy Schubert $debug_cmd 3005*a466cc55SCy Schubert 3006*a466cc55SCy Schubert func_to_host_file_result=$1 3007*a466cc55SCy Schubert if test -n "$1"; then 3008*a466cc55SCy Schubert # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009*a466cc55SCy Schubert # LT_CYGPATH in this case. 3010*a466cc55SCy Schubert func_to_host_file_result=`cygpath -m "$1"` 3011*a466cc55SCy Schubert fi 3012*a466cc55SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3013*a466cc55SCy Schubert} 3014*a466cc55SCy Schubert# end func_convert_file_cygwin_to_w32 3015*a466cc55SCy Schubert 3016*a466cc55SCy Schubert 3017*a466cc55SCy Schubert# func_convert_file_nix_to_w32 ARG 3018*a466cc55SCy Schubert# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019*a466cc55SCy Schubert# and a working winepath. Returns result in func_to_host_file_result. 3020*a466cc55SCy Schubertfunc_convert_file_nix_to_w32 () 3021*a466cc55SCy Schubert{ 3022*a466cc55SCy Schubert $debug_cmd 3023*a466cc55SCy Schubert 3024*a466cc55SCy Schubert func_to_host_file_result=$1 3025*a466cc55SCy Schubert if test -n "$1"; then 3026*a466cc55SCy Schubert func_convert_core_file_wine_to_w32 "$1" 3027*a466cc55SCy Schubert func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028*a466cc55SCy Schubert fi 3029*a466cc55SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3030*a466cc55SCy Schubert} 3031*a466cc55SCy Schubert# end func_convert_file_nix_to_w32 3032*a466cc55SCy Schubert 3033*a466cc55SCy Schubert 3034*a466cc55SCy Schubert# func_convert_file_msys_to_cygwin ARG 3035*a466cc55SCy Schubert# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036*a466cc55SCy Schubert# Returns result in func_to_host_file_result. 3037*a466cc55SCy Schubertfunc_convert_file_msys_to_cygwin () 3038*a466cc55SCy Schubert{ 3039*a466cc55SCy Schubert $debug_cmd 3040*a466cc55SCy Schubert 3041*a466cc55SCy Schubert func_to_host_file_result=$1 3042*a466cc55SCy Schubert if test -n "$1"; then 3043*a466cc55SCy Schubert func_convert_core_msys_to_w32 "$1" 3044*a466cc55SCy Schubert func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045*a466cc55SCy Schubert func_to_host_file_result=$func_cygpath_result 3046*a466cc55SCy Schubert fi 3047*a466cc55SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3048*a466cc55SCy Schubert} 3049*a466cc55SCy Schubert# end func_convert_file_msys_to_cygwin 3050*a466cc55SCy Schubert 3051*a466cc55SCy Schubert 3052*a466cc55SCy Schubert# func_convert_file_nix_to_cygwin ARG 3053*a466cc55SCy Schubert# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054*a466cc55SCy Schubert# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055*a466cc55SCy Schubert# in func_to_host_file_result. 3056*a466cc55SCy Schubertfunc_convert_file_nix_to_cygwin () 3057*a466cc55SCy Schubert{ 3058*a466cc55SCy Schubert $debug_cmd 3059*a466cc55SCy Schubert 3060*a466cc55SCy Schubert func_to_host_file_result=$1 3061*a466cc55SCy Schubert if test -n "$1"; then 3062*a466cc55SCy Schubert # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063*a466cc55SCy Schubert func_convert_core_file_wine_to_w32 "$1" 3064*a466cc55SCy Schubert func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065*a466cc55SCy Schubert func_to_host_file_result=$func_cygpath_result 3066*a466cc55SCy Schubert fi 3067*a466cc55SCy Schubert func_convert_file_check "$1" "$func_to_host_file_result" 3068*a466cc55SCy Schubert} 3069*a466cc55SCy Schubert# end func_convert_file_nix_to_cygwin 3070*a466cc55SCy Schubert 3071*a466cc55SCy Schubert 3072*a466cc55SCy Schubert############################################# 3073*a466cc55SCy Schubert# $build to $host PATH CONVERSION FUNCTIONS # 3074*a466cc55SCy Schubert############################################# 3075*a466cc55SCy Schubert# invoked via '$to_host_path_cmd ARG' 3076*a466cc55SCy Schubert# 3077*a466cc55SCy Schubert# In each case, ARG is the path to be converted from $build to $host format. 3078*a466cc55SCy Schubert# The result will be available in $func_to_host_path_result. 3079*a466cc55SCy Schubert# 3080*a466cc55SCy Schubert# Path separators are also converted from $build format to $host format. If 3081*a466cc55SCy Schubert# ARG begins or ends with a path separator character, it is preserved (but 3082*a466cc55SCy Schubert# converted to $host format) on output. 3083*a466cc55SCy Schubert# 3084*a466cc55SCy Schubert# All path conversion functions are named using the following convention: 3085*a466cc55SCy Schubert# file name conversion function : func_convert_file_X_to_Y () 3086*a466cc55SCy Schubert# path conversion function : func_convert_path_X_to_Y () 3087*a466cc55SCy Schubert# where, for any given $build/$host combination the 'X_to_Y' value is the 3088*a466cc55SCy Schubert# same. If conversion functions are added for new $build/$host combinations, 3089*a466cc55SCy Schubert# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090*a466cc55SCy Schubert# will break. 3091*a466cc55SCy Schubert 3092*a466cc55SCy Schubert 3093*a466cc55SCy Schubert# func_init_to_host_path_cmd 3094*a466cc55SCy Schubert# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095*a466cc55SCy Schubert# appropriate value, based on the value of $to_host_file_cmd. 3096*a466cc55SCy Schubertto_host_path_cmd= 3097*a466cc55SCy Schubertfunc_init_to_host_path_cmd () 3098*a466cc55SCy Schubert{ 3099*a466cc55SCy Schubert $debug_cmd 3100*a466cc55SCy Schubert 3101*a466cc55SCy Schubert if test -z "$to_host_path_cmd"; then 3102*a466cc55SCy Schubert func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103*a466cc55SCy Schubert to_host_path_cmd=func_convert_path_$func_stripname_result 3104*a466cc55SCy Schubert fi 3105*a466cc55SCy Schubert} 3106*a466cc55SCy Schubert 3107*a466cc55SCy Schubert 3108*a466cc55SCy Schubert# func_to_host_path ARG 3109*a466cc55SCy Schubert# Converts the path ARG from $build format to $host format. Return result 3110*a466cc55SCy Schubert# in func_to_host_path_result. 3111*a466cc55SCy Schubertfunc_to_host_path () 3112*a466cc55SCy Schubert{ 3113*a466cc55SCy Schubert $debug_cmd 3114*a466cc55SCy Schubert 3115*a466cc55SCy Schubert func_init_to_host_path_cmd 3116*a466cc55SCy Schubert $to_host_path_cmd "$1" 3117*a466cc55SCy Schubert} 3118*a466cc55SCy Schubert# end func_to_host_path 3119*a466cc55SCy Schubert 3120*a466cc55SCy Schubert 3121*a466cc55SCy Schubert# func_convert_path_noop ARG 3122*a466cc55SCy Schubert# Copy ARG to func_to_host_path_result. 3123*a466cc55SCy Schubertfunc_convert_path_noop () 3124*a466cc55SCy Schubert{ 3125*a466cc55SCy Schubert func_to_host_path_result=$1 3126*a466cc55SCy Schubert} 3127*a466cc55SCy Schubert# end func_convert_path_noop 3128*a466cc55SCy Schubert 3129*a466cc55SCy Schubert 3130*a466cc55SCy Schubert# func_convert_path_msys_to_w32 ARG 3131*a466cc55SCy Schubert# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132*a466cc55SCy Schubert# conversion to w32 is not available inside the cwrapper. Returns result in 3133*a466cc55SCy Schubert# func_to_host_path_result. 3134*a466cc55SCy Schubertfunc_convert_path_msys_to_w32 () 3135*a466cc55SCy Schubert{ 3136*a466cc55SCy Schubert $debug_cmd 3137*a466cc55SCy Schubert 3138*a466cc55SCy Schubert func_to_host_path_result=$1 3139*a466cc55SCy Schubert if test -n "$1"; then 3140*a466cc55SCy Schubert # Remove leading and trailing path separator characters from ARG. MSYS 3141*a466cc55SCy Schubert # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142*a466cc55SCy Schubert # and winepath ignores them completely. 3143*a466cc55SCy Schubert func_stripname : : "$1" 3144*a466cc55SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3145*a466cc55SCy Schubert func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146*a466cc55SCy Schubert func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147*a466cc55SCy Schubert func_convert_path_check : ";" \ 3148*a466cc55SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149*a466cc55SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150*a466cc55SCy Schubert fi 3151*a466cc55SCy Schubert} 3152*a466cc55SCy Schubert# end func_convert_path_msys_to_w32 3153*a466cc55SCy Schubert 3154*a466cc55SCy Schubert 3155*a466cc55SCy Schubert# func_convert_path_cygwin_to_w32 ARG 3156*a466cc55SCy Schubert# Convert path ARG from Cygwin to w32 format. Returns result in 3157*a466cc55SCy Schubert# func_to_host_file_result. 3158*a466cc55SCy Schubertfunc_convert_path_cygwin_to_w32 () 3159*a466cc55SCy Schubert{ 3160*a466cc55SCy Schubert $debug_cmd 3161*a466cc55SCy Schubert 3162*a466cc55SCy Schubert func_to_host_path_result=$1 3163*a466cc55SCy Schubert if test -n "$1"; then 3164*a466cc55SCy Schubert # See func_convert_path_msys_to_w32: 3165*a466cc55SCy Schubert func_stripname : : "$1" 3166*a466cc55SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3167*a466cc55SCy Schubert func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168*a466cc55SCy Schubert func_convert_path_check : ";" \ 3169*a466cc55SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170*a466cc55SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171*a466cc55SCy Schubert fi 3172*a466cc55SCy Schubert} 3173*a466cc55SCy Schubert# end func_convert_path_cygwin_to_w32 3174*a466cc55SCy Schubert 3175*a466cc55SCy Schubert 3176*a466cc55SCy Schubert# func_convert_path_nix_to_w32 ARG 3177*a466cc55SCy Schubert# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178*a466cc55SCy Schubert# a working winepath. Returns result in func_to_host_file_result. 3179*a466cc55SCy Schubertfunc_convert_path_nix_to_w32 () 3180*a466cc55SCy Schubert{ 3181*a466cc55SCy Schubert $debug_cmd 3182*a466cc55SCy Schubert 3183*a466cc55SCy Schubert func_to_host_path_result=$1 3184*a466cc55SCy Schubert if test -n "$1"; then 3185*a466cc55SCy Schubert # See func_convert_path_msys_to_w32: 3186*a466cc55SCy Schubert func_stripname : : "$1" 3187*a466cc55SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3188*a466cc55SCy Schubert func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189*a466cc55SCy Schubert func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190*a466cc55SCy Schubert func_convert_path_check : ";" \ 3191*a466cc55SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192*a466cc55SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193*a466cc55SCy Schubert fi 3194*a466cc55SCy Schubert} 3195*a466cc55SCy Schubert# end func_convert_path_nix_to_w32 3196*a466cc55SCy Schubert 3197*a466cc55SCy Schubert 3198*a466cc55SCy Schubert# func_convert_path_msys_to_cygwin ARG 3199*a466cc55SCy Schubert# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200*a466cc55SCy Schubert# Returns result in func_to_host_file_result. 3201*a466cc55SCy Schubertfunc_convert_path_msys_to_cygwin () 3202*a466cc55SCy Schubert{ 3203*a466cc55SCy Schubert $debug_cmd 3204*a466cc55SCy Schubert 3205*a466cc55SCy Schubert func_to_host_path_result=$1 3206*a466cc55SCy Schubert if test -n "$1"; then 3207*a466cc55SCy Schubert # See func_convert_path_msys_to_w32: 3208*a466cc55SCy Schubert func_stripname : : "$1" 3209*a466cc55SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3210*a466cc55SCy Schubert func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211*a466cc55SCy Schubert func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212*a466cc55SCy Schubert func_to_host_path_result=$func_cygpath_result 3213*a466cc55SCy Schubert func_convert_path_check : : \ 3214*a466cc55SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215*a466cc55SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216*a466cc55SCy Schubert fi 3217*a466cc55SCy Schubert} 3218*a466cc55SCy Schubert# end func_convert_path_msys_to_cygwin 3219*a466cc55SCy Schubert 3220*a466cc55SCy Schubert 3221*a466cc55SCy Schubert# func_convert_path_nix_to_cygwin ARG 3222*a466cc55SCy Schubert# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223*a466cc55SCy Schubert# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224*a466cc55SCy Schubert# func_to_host_file_result. 3225*a466cc55SCy Schubertfunc_convert_path_nix_to_cygwin () 3226*a466cc55SCy Schubert{ 3227*a466cc55SCy Schubert $debug_cmd 3228*a466cc55SCy Schubert 3229*a466cc55SCy Schubert func_to_host_path_result=$1 3230*a466cc55SCy Schubert if test -n "$1"; then 3231*a466cc55SCy Schubert # Remove leading and trailing path separator characters from 3232*a466cc55SCy Schubert # ARG. msys behavior is inconsistent here, cygpath turns them 3233*a466cc55SCy Schubert # into '.;' and ';.', and winepath ignores them completely. 3234*a466cc55SCy Schubert func_stripname : : "$1" 3235*a466cc55SCy Schubert func_to_host_path_tmp1=$func_stripname_result 3236*a466cc55SCy Schubert func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237*a466cc55SCy Schubert func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238*a466cc55SCy Schubert func_to_host_path_result=$func_cygpath_result 3239*a466cc55SCy Schubert func_convert_path_check : : \ 3240*a466cc55SCy Schubert "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241*a466cc55SCy Schubert func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242*a466cc55SCy Schubert fi 3243*a466cc55SCy Schubert} 3244*a466cc55SCy Schubert# end func_convert_path_nix_to_cygwin 3245*a466cc55SCy Schubert 3246*a466cc55SCy Schubert 3247*a466cc55SCy Schubert# func_dll_def_p FILE 3248*a466cc55SCy Schubert# True iff FILE is a Windows DLL '.def' file. 3249*a466cc55SCy Schubert# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250*a466cc55SCy Schubertfunc_dll_def_p () 3251*a466cc55SCy Schubert{ 3252*a466cc55SCy Schubert $debug_cmd 3253*a466cc55SCy Schubert 3254*a466cc55SCy Schubert func_dll_def_p_tmp=`$SED -n \ 3255*a466cc55SCy Schubert -e 's/^[ ]*//' \ 3256*a466cc55SCy Schubert -e '/^\(;.*\)*$/d' \ 3257*a466cc55SCy Schubert -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258*a466cc55SCy Schubert -e q \ 3259*a466cc55SCy Schubert "$1"` 3260*a466cc55SCy Schubert test DEF = "$func_dll_def_p_tmp" 3261*a466cc55SCy Schubert} 3262*a466cc55SCy Schubert 3263*a466cc55SCy Schubert 3264*a466cc55SCy Schubert# func_mode_compile arg... 3265*a466cc55SCy Schubertfunc_mode_compile () 3266*a466cc55SCy Schubert{ 3267*a466cc55SCy Schubert $debug_cmd 3268*a466cc55SCy Schubert 3269*a466cc55SCy Schubert # Get the compilation command and the source file. 3270*a466cc55SCy Schubert base_compile= 3271*a466cc55SCy Schubert srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272*a466cc55SCy Schubert suppress_opt=yes 3273*a466cc55SCy Schubert suppress_output= 3274*a466cc55SCy Schubert arg_mode=normal 3275*a466cc55SCy Schubert libobj= 3276*a466cc55SCy Schubert later= 3277*a466cc55SCy Schubert pie_flag= 3278*a466cc55SCy Schubert 3279*a466cc55SCy Schubert for arg 3280*a466cc55SCy Schubert do 3281*a466cc55SCy Schubert case $arg_mode in 3282*a466cc55SCy Schubert arg ) 3283*a466cc55SCy Schubert # do not "continue". Instead, add this to base_compile 3284*a466cc55SCy Schubert lastarg=$arg 3285*a466cc55SCy Schubert arg_mode=normal 3286*a466cc55SCy Schubert ;; 3287*a466cc55SCy Schubert 3288*a466cc55SCy Schubert target ) 3289*a466cc55SCy Schubert libobj=$arg 3290*a466cc55SCy Schubert arg_mode=normal 3291*a466cc55SCy Schubert continue 3292*a466cc55SCy Schubert ;; 3293*a466cc55SCy Schubert 3294*a466cc55SCy Schubert normal ) 3295*a466cc55SCy Schubert # Accept any command-line options. 3296*a466cc55SCy Schubert case $arg in 3297*a466cc55SCy Schubert -o) 3298*a466cc55SCy Schubert test -n "$libobj" && \ 3299*a466cc55SCy Schubert func_fatal_error "you cannot specify '-o' more than once" 3300*a466cc55SCy Schubert arg_mode=target 3301*a466cc55SCy Schubert continue 3302*a466cc55SCy Schubert ;; 3303*a466cc55SCy Schubert 3304*a466cc55SCy Schubert -pie | -fpie | -fPIE) 3305*a466cc55SCy Schubert func_append pie_flag " $arg" 3306*a466cc55SCy Schubert continue 3307*a466cc55SCy Schubert ;; 3308*a466cc55SCy Schubert 3309*a466cc55SCy Schubert -shared | -static | -prefer-pic | -prefer-non-pic) 3310*a466cc55SCy Schubert func_append later " $arg" 3311*a466cc55SCy Schubert continue 3312*a466cc55SCy Schubert ;; 3313*a466cc55SCy Schubert 3314*a466cc55SCy Schubert -no-suppress) 3315*a466cc55SCy Schubert suppress_opt=no 3316*a466cc55SCy Schubert continue 3317*a466cc55SCy Schubert ;; 3318*a466cc55SCy Schubert 3319*a466cc55SCy Schubert -Xcompiler) 3320*a466cc55SCy Schubert arg_mode=arg # the next one goes into the "base_compile" arg list 3321*a466cc55SCy Schubert continue # The current "srcfile" will either be retained or 3322*a466cc55SCy Schubert ;; # replaced later. I would guess that would be a bug. 3323*a466cc55SCy Schubert 3324*a466cc55SCy Schubert -Wc,*) 3325*a466cc55SCy Schubert func_stripname '-Wc,' '' "$arg" 3326*a466cc55SCy Schubert args=$func_stripname_result 3327*a466cc55SCy Schubert lastarg= 3328*a466cc55SCy Schubert save_ifs=$IFS; IFS=, 3329*a466cc55SCy Schubert for arg in $args; do 3330*a466cc55SCy Schubert IFS=$save_ifs 3331*a466cc55SCy Schubert func_append_quoted lastarg "$arg" 3332*a466cc55SCy Schubert done 3333*a466cc55SCy Schubert IFS=$save_ifs 3334*a466cc55SCy Schubert func_stripname ' ' '' "$lastarg" 3335*a466cc55SCy Schubert lastarg=$func_stripname_result 3336*a466cc55SCy Schubert 3337*a466cc55SCy Schubert # Add the arguments to base_compile. 3338*a466cc55SCy Schubert func_append base_compile " $lastarg" 3339*a466cc55SCy Schubert continue 3340*a466cc55SCy Schubert ;; 3341*a466cc55SCy Schubert 3342*a466cc55SCy Schubert *) 3343*a466cc55SCy Schubert # Accept the current argument as the source file. 3344*a466cc55SCy Schubert # The previous "srcfile" becomes the current argument. 3345*a466cc55SCy Schubert # 3346*a466cc55SCy Schubert lastarg=$srcfile 3347*a466cc55SCy Schubert srcfile=$arg 3348*a466cc55SCy Schubert ;; 3349*a466cc55SCy Schubert esac # case $arg 3350*a466cc55SCy Schubert ;; 3351*a466cc55SCy Schubert esac # case $arg_mode 3352*a466cc55SCy Schubert 3353*a466cc55SCy Schubert # Aesthetically quote the previous argument. 3354*a466cc55SCy Schubert func_append_quoted base_compile "$lastarg" 3355*a466cc55SCy Schubert done # for arg 3356*a466cc55SCy Schubert 3357*a466cc55SCy Schubert case $arg_mode in 3358*a466cc55SCy Schubert arg) 3359*a466cc55SCy Schubert func_fatal_error "you must specify an argument for -Xcompile" 3360*a466cc55SCy Schubert ;; 3361*a466cc55SCy Schubert target) 3362*a466cc55SCy Schubert func_fatal_error "you must specify a target with '-o'" 3363*a466cc55SCy Schubert ;; 3364*a466cc55SCy Schubert *) 3365*a466cc55SCy Schubert # Get the name of the library object. 3366*a466cc55SCy Schubert test -z "$libobj" && { 3367*a466cc55SCy Schubert func_basename "$srcfile" 3368*a466cc55SCy Schubert libobj=$func_basename_result 3369*a466cc55SCy Schubert } 3370*a466cc55SCy Schubert ;; 3371*a466cc55SCy Schubert esac 3372*a466cc55SCy Schubert 3373*a466cc55SCy Schubert # Recognize several different file suffixes. 3374*a466cc55SCy Schubert # If the user specifies -o file.o, it is replaced with file.lo 3375*a466cc55SCy Schubert case $libobj in 3376*a466cc55SCy Schubert *.[cCFSifmso] | \ 3377*a466cc55SCy Schubert *.ada | *.adb | *.ads | *.asm | \ 3378*a466cc55SCy Schubert *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379*a466cc55SCy Schubert *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380*a466cc55SCy Schubert func_xform "$libobj" 3381*a466cc55SCy Schubert libobj=$func_xform_result 3382*a466cc55SCy Schubert ;; 3383*a466cc55SCy Schubert esac 3384*a466cc55SCy Schubert 3385*a466cc55SCy Schubert case $libobj in 3386*a466cc55SCy Schubert *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387*a466cc55SCy Schubert *) 3388*a466cc55SCy Schubert func_fatal_error "cannot determine name of library object from '$libobj'" 3389*a466cc55SCy Schubert ;; 3390*a466cc55SCy Schubert esac 3391*a466cc55SCy Schubert 3392*a466cc55SCy Schubert func_infer_tag $base_compile 3393*a466cc55SCy Schubert 3394*a466cc55SCy Schubert for arg in $later; do 3395*a466cc55SCy Schubert case $arg in 3396*a466cc55SCy Schubert -shared) 3397*a466cc55SCy Schubert test yes = "$build_libtool_libs" \ 3398*a466cc55SCy Schubert || func_fatal_configuration "cannot build a shared library" 3399*a466cc55SCy Schubert build_old_libs=no 3400*a466cc55SCy Schubert continue 3401*a466cc55SCy Schubert ;; 3402*a466cc55SCy Schubert 3403*a466cc55SCy Schubert -static) 3404*a466cc55SCy Schubert build_libtool_libs=no 3405*a466cc55SCy Schubert build_old_libs=yes 3406*a466cc55SCy Schubert continue 3407*a466cc55SCy Schubert ;; 3408*a466cc55SCy Schubert 3409*a466cc55SCy Schubert -prefer-pic) 3410*a466cc55SCy Schubert pic_mode=yes 3411*a466cc55SCy Schubert continue 3412*a466cc55SCy Schubert ;; 3413*a466cc55SCy Schubert 3414*a466cc55SCy Schubert -prefer-non-pic) 3415*a466cc55SCy Schubert pic_mode=no 3416*a466cc55SCy Schubert continue 3417*a466cc55SCy Schubert ;; 3418*a466cc55SCy Schubert esac 3419*a466cc55SCy Schubert done 3420*a466cc55SCy Schubert 3421*a466cc55SCy Schubert func_quote_for_eval "$libobj" 3422*a466cc55SCy Schubert test "X$libobj" != "X$func_quote_for_eval_result" \ 3423*a466cc55SCy Schubert && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424*a466cc55SCy Schubert && func_warning "libobj name '$libobj' may not contain shell special characters." 3425*a466cc55SCy Schubert func_dirname_and_basename "$obj" "/" "" 3426*a466cc55SCy Schubert objname=$func_basename_result 3427*a466cc55SCy Schubert xdir=$func_dirname_result 3428*a466cc55SCy Schubert lobj=$xdir$objdir/$objname 3429*a466cc55SCy Schubert 3430*a466cc55SCy Schubert test -z "$base_compile" && \ 3431*a466cc55SCy Schubert func_fatal_help "you must specify a compilation command" 3432*a466cc55SCy Schubert 3433*a466cc55SCy Schubert # Delete any leftover library objects. 3434*a466cc55SCy Schubert if test yes = "$build_old_libs"; then 3435*a466cc55SCy Schubert removelist="$obj $lobj $libobj ${libobj}T" 3436*a466cc55SCy Schubert else 3437*a466cc55SCy Schubert removelist="$lobj $libobj ${libobj}T" 3438*a466cc55SCy Schubert fi 3439*a466cc55SCy Schubert 3440*a466cc55SCy Schubert # On Cygwin there's no "real" PIC flag so we must build both object types 3441*a466cc55SCy Schubert case $host_os in 3442*a466cc55SCy Schubert cygwin* | mingw* | pw32* | os2* | cegcc*) 3443*a466cc55SCy Schubert pic_mode=default 3444*a466cc55SCy Schubert ;; 3445*a466cc55SCy Schubert esac 3446*a466cc55SCy Schubert if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447*a466cc55SCy Schubert # non-PIC code in shared libraries is not supported 3448*a466cc55SCy Schubert pic_mode=default 3449*a466cc55SCy Schubert fi 3450*a466cc55SCy Schubert 3451*a466cc55SCy Schubert # Calculate the filename of the output object if compiler does 3452*a466cc55SCy Schubert # not support -o with -c 3453*a466cc55SCy Schubert if test no = "$compiler_c_o"; then 3454*a466cc55SCy Schubert output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455*a466cc55SCy Schubert lockfile=$output_obj.lock 3456*a466cc55SCy Schubert else 3457*a466cc55SCy Schubert output_obj= 3458*a466cc55SCy Schubert need_locks=no 3459*a466cc55SCy Schubert lockfile= 3460*a466cc55SCy Schubert fi 3461*a466cc55SCy Schubert 3462*a466cc55SCy Schubert # Lock this critical section if it is needed 3463*a466cc55SCy Schubert # We use this script file to make the link, it avoids creating a new file 3464*a466cc55SCy Schubert if test yes = "$need_locks"; then 3465*a466cc55SCy Schubert until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466*a466cc55SCy Schubert func_echo "Waiting for $lockfile to be removed" 3467*a466cc55SCy Schubert sleep 2 3468*a466cc55SCy Schubert done 3469*a466cc55SCy Schubert elif test warn = "$need_locks"; then 3470*a466cc55SCy Schubert if test -f "$lockfile"; then 3471*a466cc55SCy Schubert $ECHO "\ 3472*a466cc55SCy Schubert*** ERROR, $lockfile exists and contains: 3473*a466cc55SCy Schubert`cat $lockfile 2>/dev/null` 3474*a466cc55SCy Schubert 3475*a466cc55SCy SchubertThis indicates that another process is trying to use the same 3476*a466cc55SCy Schuberttemporary object file, and libtool could not work around it because 3477*a466cc55SCy Schubertyour compiler does not support '-c' and '-o' together. If you 3478*a466cc55SCy Schubertrepeat this compilation, it may succeed, by chance, but you had better 3479*a466cc55SCy Schubertavoid parallel builds (make -j) in this platform, or get a better 3480*a466cc55SCy Schubertcompiler." 3481*a466cc55SCy Schubert 3482*a466cc55SCy Schubert $opt_dry_run || $RM $removelist 3483*a466cc55SCy Schubert exit $EXIT_FAILURE 3484*a466cc55SCy Schubert fi 3485*a466cc55SCy Schubert func_append removelist " $output_obj" 3486*a466cc55SCy Schubert $ECHO "$srcfile" > "$lockfile" 3487*a466cc55SCy Schubert fi 3488*a466cc55SCy Schubert 3489*a466cc55SCy Schubert $opt_dry_run || $RM $removelist 3490*a466cc55SCy Schubert func_append removelist " $lockfile" 3491*a466cc55SCy Schubert trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492*a466cc55SCy Schubert 3493*a466cc55SCy Schubert func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494*a466cc55SCy Schubert srcfile=$func_to_tool_file_result 3495*a466cc55SCy Schubert func_quote_for_eval "$srcfile" 3496*a466cc55SCy Schubert qsrcfile=$func_quote_for_eval_result 3497*a466cc55SCy Schubert 3498*a466cc55SCy Schubert # Only build a PIC object if we are building libtool libraries. 3499*a466cc55SCy Schubert if test yes = "$build_libtool_libs"; then 3500*a466cc55SCy Schubert # Without this assignment, base_compile gets emptied. 3501*a466cc55SCy Schubert fbsd_hideous_sh_bug=$base_compile 3502*a466cc55SCy Schubert 3503*a466cc55SCy Schubert if test no != "$pic_mode"; then 3504*a466cc55SCy Schubert command="$base_compile $qsrcfile $pic_flag" 3505*a466cc55SCy Schubert else 3506*a466cc55SCy Schubert # Don't build PIC code 3507*a466cc55SCy Schubert command="$base_compile $qsrcfile" 3508*a466cc55SCy Schubert fi 3509*a466cc55SCy Schubert 3510*a466cc55SCy Schubert func_mkdir_p "$xdir$objdir" 3511*a466cc55SCy Schubert 3512*a466cc55SCy Schubert if test -z "$output_obj"; then 3513*a466cc55SCy Schubert # Place PIC objects in $objdir 3514*a466cc55SCy Schubert func_append command " -o $lobj" 3515*a466cc55SCy Schubert fi 3516*a466cc55SCy Schubert 3517*a466cc55SCy Schubert func_show_eval_locale "$command" \ 3518*a466cc55SCy Schubert 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519*a466cc55SCy Schubert 3520*a466cc55SCy Schubert if test warn = "$need_locks" && 3521*a466cc55SCy Schubert test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522*a466cc55SCy Schubert $ECHO "\ 3523*a466cc55SCy Schubert*** ERROR, $lockfile contains: 3524*a466cc55SCy Schubert`cat $lockfile 2>/dev/null` 3525*a466cc55SCy Schubert 3526*a466cc55SCy Schubertbut it should contain: 3527*a466cc55SCy Schubert$srcfile 3528*a466cc55SCy Schubert 3529*a466cc55SCy SchubertThis indicates that another process is trying to use the same 3530*a466cc55SCy Schuberttemporary object file, and libtool could not work around it because 3531*a466cc55SCy Schubertyour compiler does not support '-c' and '-o' together. If you 3532*a466cc55SCy Schubertrepeat this compilation, it may succeed, by chance, but you had better 3533*a466cc55SCy Schubertavoid parallel builds (make -j) in this platform, or get a better 3534*a466cc55SCy Schubertcompiler." 3535*a466cc55SCy Schubert 3536*a466cc55SCy Schubert $opt_dry_run || $RM $removelist 3537*a466cc55SCy Schubert exit $EXIT_FAILURE 3538*a466cc55SCy Schubert fi 3539*a466cc55SCy Schubert 3540*a466cc55SCy Schubert # Just move the object if needed, then go on to compile the next one 3541*a466cc55SCy Schubert if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542*a466cc55SCy Schubert func_show_eval '$MV "$output_obj" "$lobj"' \ 3543*a466cc55SCy Schubert 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544*a466cc55SCy Schubert fi 3545*a466cc55SCy Schubert 3546*a466cc55SCy Schubert # Allow error messages only from the first compilation. 3547*a466cc55SCy Schubert if test yes = "$suppress_opt"; then 3548*a466cc55SCy Schubert suppress_output=' >/dev/null 2>&1' 3549*a466cc55SCy Schubert fi 3550*a466cc55SCy Schubert fi 3551*a466cc55SCy Schubert 3552*a466cc55SCy Schubert # Only build a position-dependent object if we build old libraries. 3553*a466cc55SCy Schubert if test yes = "$build_old_libs"; then 3554*a466cc55SCy Schubert if test yes != "$pic_mode"; then 3555*a466cc55SCy Schubert # Don't build PIC code 3556*a466cc55SCy Schubert command="$base_compile $qsrcfile$pie_flag" 3557*a466cc55SCy Schubert else 3558*a466cc55SCy Schubert command="$base_compile $qsrcfile $pic_flag" 3559*a466cc55SCy Schubert fi 3560*a466cc55SCy Schubert if test yes = "$compiler_c_o"; then 3561*a466cc55SCy Schubert func_append command " -o $obj" 3562*a466cc55SCy Schubert fi 3563*a466cc55SCy Schubert 3564*a466cc55SCy Schubert # Suppress compiler output if we already did a PIC compilation. 3565*a466cc55SCy Schubert func_append command "$suppress_output" 3566*a466cc55SCy Schubert func_show_eval_locale "$command" \ 3567*a466cc55SCy Schubert '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568*a466cc55SCy Schubert 3569*a466cc55SCy Schubert if test warn = "$need_locks" && 3570*a466cc55SCy Schubert test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571*a466cc55SCy Schubert $ECHO "\ 3572*a466cc55SCy Schubert*** ERROR, $lockfile contains: 3573*a466cc55SCy Schubert`cat $lockfile 2>/dev/null` 3574*a466cc55SCy Schubert 3575*a466cc55SCy Schubertbut it should contain: 3576*a466cc55SCy Schubert$srcfile 3577*a466cc55SCy Schubert 3578*a466cc55SCy SchubertThis indicates that another process is trying to use the same 3579*a466cc55SCy Schuberttemporary object file, and libtool could not work around it because 3580*a466cc55SCy Schubertyour compiler does not support '-c' and '-o' together. If you 3581*a466cc55SCy Schubertrepeat this compilation, it may succeed, by chance, but you had better 3582*a466cc55SCy Schubertavoid parallel builds (make -j) in this platform, or get a better 3583*a466cc55SCy Schubertcompiler." 3584*a466cc55SCy Schubert 3585*a466cc55SCy Schubert $opt_dry_run || $RM $removelist 3586*a466cc55SCy Schubert exit $EXIT_FAILURE 3587*a466cc55SCy Schubert fi 3588*a466cc55SCy Schubert 3589*a466cc55SCy Schubert # Just move the object if needed 3590*a466cc55SCy Schubert if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591*a466cc55SCy Schubert func_show_eval '$MV "$output_obj" "$obj"' \ 3592*a466cc55SCy Schubert 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593*a466cc55SCy Schubert fi 3594*a466cc55SCy Schubert fi 3595*a466cc55SCy Schubert 3596*a466cc55SCy Schubert $opt_dry_run || { 3597*a466cc55SCy Schubert func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598*a466cc55SCy Schubert 3599*a466cc55SCy Schubert # Unlock the critical section if it was locked 3600*a466cc55SCy Schubert if test no != "$need_locks"; then 3601*a466cc55SCy Schubert removelist=$lockfile 3602*a466cc55SCy Schubert $RM "$lockfile" 3603*a466cc55SCy Schubert fi 3604*a466cc55SCy Schubert } 3605*a466cc55SCy Schubert 3606*a466cc55SCy Schubert exit $EXIT_SUCCESS 3607*a466cc55SCy Schubert} 3608*a466cc55SCy Schubert 3609*a466cc55SCy Schubert$opt_help || { 3610*a466cc55SCy Schubert test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611*a466cc55SCy Schubert} 3612*a466cc55SCy Schubert 3613*a466cc55SCy Schubertfunc_mode_help () 3614*a466cc55SCy Schubert{ 3615*a466cc55SCy Schubert # We need to display help for each of the modes. 3616*a466cc55SCy Schubert case $opt_mode in 3617*a466cc55SCy Schubert "") 3618*a466cc55SCy Schubert # Generic help is extracted from the usage comments 3619*a466cc55SCy Schubert # at the start of this file. 3620*a466cc55SCy Schubert func_help 3621*a466cc55SCy Schubert ;; 3622*a466cc55SCy Schubert 3623*a466cc55SCy Schubert clean) 3624*a466cc55SCy Schubert $ECHO \ 3625*a466cc55SCy Schubert"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626*a466cc55SCy Schubert 3627*a466cc55SCy SchubertRemove files from the build directory. 3628*a466cc55SCy Schubert 3629*a466cc55SCy SchubertRM is the name of the program to use to delete files associated with each FILE 3630*a466cc55SCy Schubert(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631*a466cc55SCy Schubertto RM. 3632*a466cc55SCy Schubert 3633*a466cc55SCy SchubertIf FILE is a libtool library, object or program, all the files associated 3634*a466cc55SCy Schubertwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635*a466cc55SCy Schubert ;; 3636*a466cc55SCy Schubert 3637*a466cc55SCy Schubert compile) 3638*a466cc55SCy Schubert $ECHO \ 3639*a466cc55SCy Schubert"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640*a466cc55SCy Schubert 3641*a466cc55SCy SchubertCompile a source file into a libtool library object. 3642*a466cc55SCy Schubert 3643*a466cc55SCy SchubertThis mode accepts the following additional options: 3644*a466cc55SCy Schubert 3645*a466cc55SCy Schubert -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646*a466cc55SCy Schubert -no-suppress do not suppress compiler output for multiple passes 3647*a466cc55SCy Schubert -prefer-pic try to build PIC objects only 3648*a466cc55SCy Schubert -prefer-non-pic try to build non-PIC objects only 3649*a466cc55SCy Schubert -shared do not build a '.o' file suitable for static linking 3650*a466cc55SCy Schubert -static only build a '.o' file suitable for static linking 3651*a466cc55SCy Schubert -Wc,FLAG pass FLAG directly to the compiler 3652*a466cc55SCy Schubert 3653*a466cc55SCy SchubertCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654*a466cc55SCy Schubertfrom the given SOURCEFILE. 3655*a466cc55SCy Schubert 3656*a466cc55SCy SchubertThe output file name is determined by removing the directory component from 3657*a466cc55SCy SchubertSOURCEFILE, then substituting the C source code suffix '.c' with the 3658*a466cc55SCy Schubertlibrary object suffix, '.lo'." 3659*a466cc55SCy Schubert ;; 3660*a466cc55SCy Schubert 3661*a466cc55SCy Schubert execute) 3662*a466cc55SCy Schubert $ECHO \ 3663*a466cc55SCy Schubert"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664*a466cc55SCy Schubert 3665*a466cc55SCy SchubertAutomatically set library path, then run a program. 3666*a466cc55SCy Schubert 3667*a466cc55SCy SchubertThis mode accepts the following additional options: 3668*a466cc55SCy Schubert 3669*a466cc55SCy Schubert -dlopen FILE add the directory containing FILE to the library path 3670*a466cc55SCy Schubert 3671*a466cc55SCy SchubertThis mode sets the library path environment variable according to '-dlopen' 3672*a466cc55SCy Schubertflags. 3673*a466cc55SCy Schubert 3674*a466cc55SCy SchubertIf any of the ARGS are libtool executable wrappers, then they are translated 3675*a466cc55SCy Schubertinto their corresponding uninstalled binary, and any of their required library 3676*a466cc55SCy Schubertdirectories are added to the library path. 3677*a466cc55SCy Schubert 3678*a466cc55SCy SchubertThen, COMMAND is executed, with ARGS as arguments." 3679*a466cc55SCy Schubert ;; 3680*a466cc55SCy Schubert 3681*a466cc55SCy Schubert finish) 3682*a466cc55SCy Schubert $ECHO \ 3683*a466cc55SCy Schubert"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684*a466cc55SCy Schubert 3685*a466cc55SCy SchubertComplete the installation of libtool libraries. 3686*a466cc55SCy Schubert 3687*a466cc55SCy SchubertEach LIBDIR is a directory that contains libtool libraries. 3688*a466cc55SCy Schubert 3689*a466cc55SCy SchubertThe commands that this mode executes may require superuser privileges. Use 3690*a466cc55SCy Schubertthe '--dry-run' option if you just want to see what would be executed." 3691*a466cc55SCy Schubert ;; 3692*a466cc55SCy Schubert 3693*a466cc55SCy Schubert install) 3694*a466cc55SCy Schubert $ECHO \ 3695*a466cc55SCy Schubert"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696*a466cc55SCy Schubert 3697*a466cc55SCy SchubertInstall executables or libraries. 3698*a466cc55SCy Schubert 3699*a466cc55SCy SchubertINSTALL-COMMAND is the installation command. The first component should be 3700*a466cc55SCy Schuberteither the 'install' or 'cp' program. 3701*a466cc55SCy Schubert 3702*a466cc55SCy SchubertThe following components of INSTALL-COMMAND are treated specially: 3703*a466cc55SCy Schubert 3704*a466cc55SCy Schubert -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705*a466cc55SCy Schubert 3706*a466cc55SCy SchubertThe rest of the components are interpreted as arguments to that command (only 3707*a466cc55SCy SchubertBSD-compatible install options are recognized)." 3708*a466cc55SCy Schubert ;; 3709*a466cc55SCy Schubert 3710*a466cc55SCy Schubert link) 3711*a466cc55SCy Schubert $ECHO \ 3712*a466cc55SCy Schubert"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713*a466cc55SCy Schubert 3714*a466cc55SCy SchubertLink object files or libraries together to form another library, or to 3715*a466cc55SCy Schubertcreate an executable program. 3716*a466cc55SCy Schubert 3717*a466cc55SCy SchubertLINK-COMMAND is a command using the C compiler that you would use to create 3718*a466cc55SCy Schuberta program from several object files. 3719*a466cc55SCy Schubert 3720*a466cc55SCy SchubertThe following components of LINK-COMMAND are treated specially: 3721*a466cc55SCy Schubert 3722*a466cc55SCy Schubert -all-static do not do any dynamic linking at all 3723*a466cc55SCy Schubert -avoid-version do not add a version suffix if possible 3724*a466cc55SCy Schubert -bindir BINDIR specify path to binaries directory (for systems where 3725*a466cc55SCy Schubert libraries must be found in the PATH setting at runtime) 3726*a466cc55SCy Schubert -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727*a466cc55SCy Schubert -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728*a466cc55SCy Schubert -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729*a466cc55SCy Schubert -export-symbols SYMFILE 3730*a466cc55SCy Schubert try to export only the symbols listed in SYMFILE 3731*a466cc55SCy Schubert -export-symbols-regex REGEX 3732*a466cc55SCy Schubert try to export only the symbols matching REGEX 3733*a466cc55SCy Schubert -LLIBDIR search LIBDIR for required installed libraries 3734*a466cc55SCy Schubert -lNAME OUTPUT-FILE requires the installed library libNAME 3735*a466cc55SCy Schubert -module build a library that can dlopened 3736*a466cc55SCy Schubert -no-fast-install disable the fast-install mode 3737*a466cc55SCy Schubert -no-install link a not-installable executable 3738*a466cc55SCy Schubert -no-undefined declare that a library does not refer to external symbols 3739*a466cc55SCy Schubert -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740*a466cc55SCy Schubert -objectlist FILE use a list of object files found in FILE to specify objects 3741*a466cc55SCy Schubert -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742*a466cc55SCy Schubert -precious-files-regex REGEX 3743*a466cc55SCy Schubert don't remove output files matching REGEX 3744*a466cc55SCy Schubert -release RELEASE specify package release information 3745*a466cc55SCy Schubert -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746*a466cc55SCy Schubert -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747*a466cc55SCy Schubert -shared only do dynamic linking of libtool libraries 3748*a466cc55SCy Schubert -shrext SUFFIX override the standard shared library file extension 3749*a466cc55SCy Schubert -static do not do any dynamic linking of uninstalled libtool libraries 3750*a466cc55SCy Schubert -static-libtool-libs 3751*a466cc55SCy Schubert do not do any dynamic linking of libtool libraries 3752*a466cc55SCy Schubert -version-info CURRENT[:REVISION[:AGE]] 3753*a466cc55SCy Schubert specify library version info [each variable defaults to 0] 3754*a466cc55SCy Schubert -weak LIBNAME declare that the target provides the LIBNAME interface 3755*a466cc55SCy Schubert -Wc,FLAG 3756*a466cc55SCy Schubert -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757*a466cc55SCy Schubert -Wl,FLAG 3758*a466cc55SCy Schubert -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759*a466cc55SCy Schubert -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760*a466cc55SCy Schubert 3761*a466cc55SCy SchubertAll other options (arguments beginning with '-') are ignored. 3762*a466cc55SCy Schubert 3763*a466cc55SCy SchubertEvery other argument is treated as a filename. Files ending in '.la' are 3764*a466cc55SCy Schuberttreated as uninstalled libtool libraries, other files are standard or library 3765*a466cc55SCy Schubertobject files. 3766*a466cc55SCy Schubert 3767*a466cc55SCy SchubertIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768*a466cc55SCy Schubertonly library objects ('.lo' files) may be specified, and '-rpath' is 3769*a466cc55SCy Schubertrequired, except when creating a convenience library. 3770*a466cc55SCy Schubert 3771*a466cc55SCy SchubertIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772*a466cc55SCy Schubertusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773*a466cc55SCy Schubert 3774*a466cc55SCy SchubertIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775*a466cc55SCy Schubertis created, otherwise an executable program is created." 3776*a466cc55SCy Schubert ;; 3777*a466cc55SCy Schubert 3778*a466cc55SCy Schubert uninstall) 3779*a466cc55SCy Schubert $ECHO \ 3780*a466cc55SCy Schubert"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781*a466cc55SCy Schubert 3782*a466cc55SCy SchubertRemove libraries from an installation directory. 3783*a466cc55SCy Schubert 3784*a466cc55SCy SchubertRM is the name of the program to use to delete files associated with each FILE 3785*a466cc55SCy Schubert(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786*a466cc55SCy Schubertto RM. 3787*a466cc55SCy Schubert 3788*a466cc55SCy SchubertIf FILE is a libtool library, all the files associated with it are deleted. 3789*a466cc55SCy SchubertOtherwise, only FILE itself is deleted using RM." 3790*a466cc55SCy Schubert ;; 3791*a466cc55SCy Schubert 3792*a466cc55SCy Schubert *) 3793*a466cc55SCy Schubert func_fatal_help "invalid operation mode '$opt_mode'" 3794*a466cc55SCy Schubert ;; 3795*a466cc55SCy Schubert esac 3796*a466cc55SCy Schubert 3797*a466cc55SCy Schubert echo 3798*a466cc55SCy Schubert $ECHO "Try '$progname --help' for more information about other modes." 3799*a466cc55SCy Schubert} 3800*a466cc55SCy Schubert 3801*a466cc55SCy Schubert# Now that we've collected a possible --mode arg, show help if necessary 3802*a466cc55SCy Schubertif $opt_help; then 3803*a466cc55SCy Schubert if test : = "$opt_help"; then 3804*a466cc55SCy Schubert func_mode_help 3805*a466cc55SCy Schubert else 3806*a466cc55SCy Schubert { 3807*a466cc55SCy Schubert func_help noexit 3808*a466cc55SCy Schubert for opt_mode in compile link execute install finish uninstall clean; do 3809*a466cc55SCy Schubert func_mode_help 3810*a466cc55SCy Schubert done 3811*a466cc55SCy Schubert } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812*a466cc55SCy Schubert { 3813*a466cc55SCy Schubert func_help noexit 3814*a466cc55SCy Schubert for opt_mode in compile link execute install finish uninstall clean; do 3815*a466cc55SCy Schubert echo 3816*a466cc55SCy Schubert func_mode_help 3817*a466cc55SCy Schubert done 3818*a466cc55SCy Schubert } | 3819*a466cc55SCy Schubert $SED '1d 3820*a466cc55SCy Schubert /^When reporting/,/^Report/{ 3821*a466cc55SCy Schubert H 3822*a466cc55SCy Schubert d 3823*a466cc55SCy Schubert } 3824*a466cc55SCy Schubert $x 3825*a466cc55SCy Schubert /information about other modes/d 3826*a466cc55SCy Schubert /more detailed .*MODE/d 3827*a466cc55SCy Schubert s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828*a466cc55SCy Schubert fi 3829*a466cc55SCy Schubert exit $? 3830*a466cc55SCy Schubertfi 3831*a466cc55SCy Schubert 3832*a466cc55SCy Schubert 3833*a466cc55SCy Schubert# func_mode_execute arg... 3834*a466cc55SCy Schubertfunc_mode_execute () 3835*a466cc55SCy Schubert{ 3836*a466cc55SCy Schubert $debug_cmd 3837*a466cc55SCy Schubert 3838*a466cc55SCy Schubert # The first argument is the command name. 3839*a466cc55SCy Schubert cmd=$nonopt 3840*a466cc55SCy Schubert test -z "$cmd" && \ 3841*a466cc55SCy Schubert func_fatal_help "you must specify a COMMAND" 3842*a466cc55SCy Schubert 3843*a466cc55SCy Schubert # Handle -dlopen flags immediately. 3844*a466cc55SCy Schubert for file in $opt_dlopen; do 3845*a466cc55SCy Schubert test -f "$file" \ 3846*a466cc55SCy Schubert || func_fatal_help "'$file' is not a file" 3847*a466cc55SCy Schubert 3848*a466cc55SCy Schubert dir= 3849*a466cc55SCy Schubert case $file in 3850*a466cc55SCy Schubert *.la) 3851*a466cc55SCy Schubert func_resolve_sysroot "$file" 3852*a466cc55SCy Schubert file=$func_resolve_sysroot_result 3853*a466cc55SCy Schubert 3854*a466cc55SCy Schubert # Check to see that this really is a libtool archive. 3855*a466cc55SCy Schubert func_lalib_unsafe_p "$file" \ 3856*a466cc55SCy Schubert || func_fatal_help "'$lib' is not a valid libtool archive" 3857*a466cc55SCy Schubert 3858*a466cc55SCy Schubert # Read the libtool library. 3859*a466cc55SCy Schubert dlname= 3860*a466cc55SCy Schubert library_names= 3861*a466cc55SCy Schubert func_source "$file" 3862*a466cc55SCy Schubert 3863*a466cc55SCy Schubert # Skip this library if it cannot be dlopened. 3864*a466cc55SCy Schubert if test -z "$dlname"; then 3865*a466cc55SCy Schubert # Warn if it was a shared library. 3866*a466cc55SCy Schubert test -n "$library_names" && \ 3867*a466cc55SCy Schubert func_warning "'$file' was not linked with '-export-dynamic'" 3868*a466cc55SCy Schubert continue 3869*a466cc55SCy Schubert fi 3870*a466cc55SCy Schubert 3871*a466cc55SCy Schubert func_dirname "$file" "" "." 3872*a466cc55SCy Schubert dir=$func_dirname_result 3873*a466cc55SCy Schubert 3874*a466cc55SCy Schubert if test -f "$dir/$objdir/$dlname"; then 3875*a466cc55SCy Schubert func_append dir "/$objdir" 3876*a466cc55SCy Schubert else 3877*a466cc55SCy Schubert if test ! -f "$dir/$dlname"; then 3878*a466cc55SCy Schubert func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879*a466cc55SCy Schubert fi 3880*a466cc55SCy Schubert fi 3881*a466cc55SCy Schubert ;; 3882*a466cc55SCy Schubert 3883*a466cc55SCy Schubert *.lo) 3884*a466cc55SCy Schubert # Just add the directory containing the .lo file. 3885*a466cc55SCy Schubert func_dirname "$file" "" "." 3886*a466cc55SCy Schubert dir=$func_dirname_result 3887*a466cc55SCy Schubert ;; 3888*a466cc55SCy Schubert 3889*a466cc55SCy Schubert *) 3890*a466cc55SCy Schubert func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891*a466cc55SCy Schubert continue 3892*a466cc55SCy Schubert ;; 3893*a466cc55SCy Schubert esac 3894*a466cc55SCy Schubert 3895*a466cc55SCy Schubert # Get the absolute pathname. 3896*a466cc55SCy Schubert absdir=`cd "$dir" && pwd` 3897*a466cc55SCy Schubert test -n "$absdir" && dir=$absdir 3898*a466cc55SCy Schubert 3899*a466cc55SCy Schubert # Now add the directory to shlibpath_var. 3900*a466cc55SCy Schubert if eval "test -z \"\$$shlibpath_var\""; then 3901*a466cc55SCy Schubert eval "$shlibpath_var=\"\$dir\"" 3902*a466cc55SCy Schubert else 3903*a466cc55SCy Schubert eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904*a466cc55SCy Schubert fi 3905*a466cc55SCy Schubert done 3906*a466cc55SCy Schubert 3907*a466cc55SCy Schubert # This variable tells wrapper scripts just to set shlibpath_var 3908*a466cc55SCy Schubert # rather than running their programs. 3909*a466cc55SCy Schubert libtool_execute_magic=$magic 3910*a466cc55SCy Schubert 3911*a466cc55SCy Schubert # Check if any of the arguments is a wrapper script. 3912*a466cc55SCy Schubert args= 3913*a466cc55SCy Schubert for file 3914*a466cc55SCy Schubert do 3915*a466cc55SCy Schubert case $file in 3916*a466cc55SCy Schubert -* | *.la | *.lo ) ;; 3917*a466cc55SCy Schubert *) 3918*a466cc55SCy Schubert # Do a test to see if this is really a libtool program. 3919*a466cc55SCy Schubert if func_ltwrapper_script_p "$file"; then 3920*a466cc55SCy Schubert func_source "$file" 3921*a466cc55SCy Schubert # Transform arg to wrapped name. 3922*a466cc55SCy Schubert file=$progdir/$program 3923*a466cc55SCy Schubert elif func_ltwrapper_executable_p "$file"; then 3924*a466cc55SCy Schubert func_ltwrapper_scriptname "$file" 3925*a466cc55SCy Schubert func_source "$func_ltwrapper_scriptname_result" 3926*a466cc55SCy Schubert # Transform arg to wrapped name. 3927*a466cc55SCy Schubert file=$progdir/$program 3928*a466cc55SCy Schubert fi 3929*a466cc55SCy Schubert ;; 3930*a466cc55SCy Schubert esac 3931*a466cc55SCy Schubert # Quote arguments (to preserve shell metacharacters). 3932*a466cc55SCy Schubert func_append_quoted args "$file" 3933*a466cc55SCy Schubert done 3934*a466cc55SCy Schubert 3935*a466cc55SCy Schubert if $opt_dry_run; then 3936*a466cc55SCy Schubert # Display what would be done. 3937*a466cc55SCy Schubert if test -n "$shlibpath_var"; then 3938*a466cc55SCy Schubert eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939*a466cc55SCy Schubert echo "export $shlibpath_var" 3940*a466cc55SCy Schubert fi 3941*a466cc55SCy Schubert $ECHO "$cmd$args" 3942*a466cc55SCy Schubert exit $EXIT_SUCCESS 3943*a466cc55SCy Schubert else 3944*a466cc55SCy Schubert if test -n "$shlibpath_var"; then 3945*a466cc55SCy Schubert # Export the shlibpath_var. 3946*a466cc55SCy Schubert eval "export $shlibpath_var" 3947*a466cc55SCy Schubert fi 3948*a466cc55SCy Schubert 3949*a466cc55SCy Schubert # Restore saved environment variables 3950*a466cc55SCy Schubert for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951*a466cc55SCy Schubert do 3952*a466cc55SCy Schubert eval "if test \"\${save_$lt_var+set}\" = set; then 3953*a466cc55SCy Schubert $lt_var=\$save_$lt_var; export $lt_var 3954*a466cc55SCy Schubert else 3955*a466cc55SCy Schubert $lt_unset $lt_var 3956*a466cc55SCy Schubert fi" 3957*a466cc55SCy Schubert done 3958*a466cc55SCy Schubert 3959*a466cc55SCy Schubert # Now prepare to actually exec the command. 3960*a466cc55SCy Schubert exec_cmd=\$cmd$args 3961*a466cc55SCy Schubert fi 3962*a466cc55SCy Schubert} 3963*a466cc55SCy Schubert 3964*a466cc55SCy Schuberttest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965*a466cc55SCy Schubert 3966*a466cc55SCy Schubert 3967*a466cc55SCy Schubert# func_mode_finish arg... 3968*a466cc55SCy Schubertfunc_mode_finish () 3969*a466cc55SCy Schubert{ 3970*a466cc55SCy Schubert $debug_cmd 3971*a466cc55SCy Schubert 3972*a466cc55SCy Schubert libs= 3973*a466cc55SCy Schubert libdirs= 3974*a466cc55SCy Schubert admincmds= 3975*a466cc55SCy Schubert 3976*a466cc55SCy Schubert for opt in "$nonopt" ${1+"$@"} 3977*a466cc55SCy Schubert do 3978*a466cc55SCy Schubert if test -d "$opt"; then 3979*a466cc55SCy Schubert func_append libdirs " $opt" 3980*a466cc55SCy Schubert 3981*a466cc55SCy Schubert elif test -f "$opt"; then 3982*a466cc55SCy Schubert if func_lalib_unsafe_p "$opt"; then 3983*a466cc55SCy Schubert func_append libs " $opt" 3984*a466cc55SCy Schubert else 3985*a466cc55SCy Schubert func_warning "'$opt' is not a valid libtool archive" 3986*a466cc55SCy Schubert fi 3987*a466cc55SCy Schubert 3988*a466cc55SCy Schubert else 3989*a466cc55SCy Schubert func_fatal_error "invalid argument '$opt'" 3990*a466cc55SCy Schubert fi 3991*a466cc55SCy Schubert done 3992*a466cc55SCy Schubert 3993*a466cc55SCy Schubert if test -n "$libs"; then 3994*a466cc55SCy Schubert if test -n "$lt_sysroot"; then 3995*a466cc55SCy Schubert sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996*a466cc55SCy Schubert sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997*a466cc55SCy Schubert else 3998*a466cc55SCy Schubert sysroot_cmd= 3999*a466cc55SCy Schubert fi 4000*a466cc55SCy Schubert 4001*a466cc55SCy Schubert # Remove sysroot references 4002*a466cc55SCy Schubert if $opt_dry_run; then 4003*a466cc55SCy Schubert for lib in $libs; do 4004*a466cc55SCy Schubert echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005*a466cc55SCy Schubert done 4006*a466cc55SCy Schubert else 4007*a466cc55SCy Schubert tmpdir=`func_mktempdir` 4008*a466cc55SCy Schubert for lib in $libs; do 4009*a466cc55SCy Schubert $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010*a466cc55SCy Schubert > $tmpdir/tmp-la 4011*a466cc55SCy Schubert mv -f $tmpdir/tmp-la $lib 4012*a466cc55SCy Schubert done 4013*a466cc55SCy Schubert ${RM}r "$tmpdir" 4014*a466cc55SCy Schubert fi 4015*a466cc55SCy Schubert fi 4016*a466cc55SCy Schubert 4017*a466cc55SCy Schubert if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018*a466cc55SCy Schubert for libdir in $libdirs; do 4019*a466cc55SCy Schubert if test -n "$finish_cmds"; then 4020*a466cc55SCy Schubert # Do each command in the finish commands. 4021*a466cc55SCy Schubert func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022*a466cc55SCy Schubert'"$cmd"'"' 4023*a466cc55SCy Schubert fi 4024*a466cc55SCy Schubert if test -n "$finish_eval"; then 4025*a466cc55SCy Schubert # Do the single finish_eval. 4026*a466cc55SCy Schubert eval cmds=\"$finish_eval\" 4027*a466cc55SCy Schubert $opt_dry_run || eval "$cmds" || func_append admincmds " 4028*a466cc55SCy Schubert $cmds" 4029*a466cc55SCy Schubert fi 4030*a466cc55SCy Schubert done 4031*a466cc55SCy Schubert fi 4032*a466cc55SCy Schubert 4033*a466cc55SCy Schubert # Exit here if they wanted silent mode. 4034*a466cc55SCy Schubert $opt_quiet && exit $EXIT_SUCCESS 4035*a466cc55SCy Schubert 4036*a466cc55SCy Schubert if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037*a466cc55SCy Schubert echo "----------------------------------------------------------------------" 4038*a466cc55SCy Schubert echo "Libraries have been installed in:" 4039*a466cc55SCy Schubert for libdir in $libdirs; do 4040*a466cc55SCy Schubert $ECHO " $libdir" 4041*a466cc55SCy Schubert done 4042*a466cc55SCy Schubert echo 4043*a466cc55SCy Schubert echo "If you ever happen to want to link against installed libraries" 4044*a466cc55SCy Schubert echo "in a given directory, LIBDIR, you must either use libtool, and" 4045*a466cc55SCy Schubert echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046*a466cc55SCy Schubert echo "flag during linking and do at least one of the following:" 4047*a466cc55SCy Schubert if test -n "$shlibpath_var"; then 4048*a466cc55SCy Schubert echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049*a466cc55SCy Schubert echo " during execution" 4050*a466cc55SCy Schubert fi 4051*a466cc55SCy Schubert if test -n "$runpath_var"; then 4052*a466cc55SCy Schubert echo " - add LIBDIR to the '$runpath_var' environment variable" 4053*a466cc55SCy Schubert echo " during linking" 4054*a466cc55SCy Schubert fi 4055*a466cc55SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 4056*a466cc55SCy Schubert libdir=LIBDIR 4057*a466cc55SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 4058*a466cc55SCy Schubert 4059*a466cc55SCy Schubert $ECHO " - use the '$flag' linker flag" 4060*a466cc55SCy Schubert fi 4061*a466cc55SCy Schubert if test -n "$admincmds"; then 4062*a466cc55SCy Schubert $ECHO " - have your system administrator run these commands:$admincmds" 4063*a466cc55SCy Schubert fi 4064*a466cc55SCy Schubert if test -f /etc/ld.so.conf; then 4065*a466cc55SCy Schubert echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066*a466cc55SCy Schubert fi 4067*a466cc55SCy Schubert echo 4068*a466cc55SCy Schubert 4069*a466cc55SCy Schubert echo "See any operating system documentation about shared libraries for" 4070*a466cc55SCy Schubert case $host in 4071*a466cc55SCy Schubert solaris2.[6789]|solaris2.1[0-9]) 4072*a466cc55SCy Schubert echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073*a466cc55SCy Schubert echo "pages." 4074*a466cc55SCy Schubert ;; 4075*a466cc55SCy Schubert *) 4076*a466cc55SCy Schubert echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077*a466cc55SCy Schubert ;; 4078*a466cc55SCy Schubert esac 4079*a466cc55SCy Schubert echo "----------------------------------------------------------------------" 4080*a466cc55SCy Schubert fi 4081*a466cc55SCy Schubert exit $EXIT_SUCCESS 4082*a466cc55SCy Schubert} 4083*a466cc55SCy Schubert 4084*a466cc55SCy Schuberttest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085*a466cc55SCy Schubert 4086*a466cc55SCy Schubert 4087*a466cc55SCy Schubert# func_mode_install arg... 4088*a466cc55SCy Schubertfunc_mode_install () 4089*a466cc55SCy Schubert{ 4090*a466cc55SCy Schubert $debug_cmd 4091*a466cc55SCy Schubert 4092*a466cc55SCy Schubert # There may be an optional sh(1) argument at the beginning of 4093*a466cc55SCy Schubert # install_prog (especially on Windows NT). 4094*a466cc55SCy Schubert if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095*a466cc55SCy Schubert # Allow the use of GNU shtool's install command. 4096*a466cc55SCy Schubert case $nonopt in *shtool*) :;; *) false;; esac 4097*a466cc55SCy Schubert then 4098*a466cc55SCy Schubert # Aesthetically quote it. 4099*a466cc55SCy Schubert func_quote_for_eval "$nonopt" 4100*a466cc55SCy Schubert install_prog="$func_quote_for_eval_result " 4101*a466cc55SCy Schubert arg=$1 4102*a466cc55SCy Schubert shift 4103*a466cc55SCy Schubert else 4104*a466cc55SCy Schubert install_prog= 4105*a466cc55SCy Schubert arg=$nonopt 4106*a466cc55SCy Schubert fi 4107*a466cc55SCy Schubert 4108*a466cc55SCy Schubert # The real first argument should be the name of the installation program. 4109*a466cc55SCy Schubert # Aesthetically quote it. 4110*a466cc55SCy Schubert func_quote_for_eval "$arg" 4111*a466cc55SCy Schubert func_append install_prog "$func_quote_for_eval_result" 4112*a466cc55SCy Schubert install_shared_prog=$install_prog 4113*a466cc55SCy Schubert case " $install_prog " in 4114*a466cc55SCy Schubert *[\\\ /]cp\ *) install_cp=: ;; 4115*a466cc55SCy Schubert *) install_cp=false ;; 4116*a466cc55SCy Schubert esac 4117*a466cc55SCy Schubert 4118*a466cc55SCy Schubert # We need to accept at least all the BSD install flags. 4119*a466cc55SCy Schubert dest= 4120*a466cc55SCy Schubert files= 4121*a466cc55SCy Schubert opts= 4122*a466cc55SCy Schubert prev= 4123*a466cc55SCy Schubert install_type= 4124*a466cc55SCy Schubert isdir=false 4125*a466cc55SCy Schubert stripme= 4126*a466cc55SCy Schubert no_mode=: 4127*a466cc55SCy Schubert for arg 4128*a466cc55SCy Schubert do 4129*a466cc55SCy Schubert arg2= 4130*a466cc55SCy Schubert if test -n "$dest"; then 4131*a466cc55SCy Schubert func_append files " $dest" 4132*a466cc55SCy Schubert dest=$arg 4133*a466cc55SCy Schubert continue 4134*a466cc55SCy Schubert fi 4135*a466cc55SCy Schubert 4136*a466cc55SCy Schubert case $arg in 4137*a466cc55SCy Schubert -d) isdir=: ;; 4138*a466cc55SCy Schubert -f) 4139*a466cc55SCy Schubert if $install_cp; then :; else 4140*a466cc55SCy Schubert prev=$arg 4141*a466cc55SCy Schubert fi 4142*a466cc55SCy Schubert ;; 4143*a466cc55SCy Schubert -g | -m | -o) 4144*a466cc55SCy Schubert prev=$arg 4145*a466cc55SCy Schubert ;; 4146*a466cc55SCy Schubert -s) 4147*a466cc55SCy Schubert stripme=" -s" 4148*a466cc55SCy Schubert continue 4149*a466cc55SCy Schubert ;; 4150*a466cc55SCy Schubert -*) 4151*a466cc55SCy Schubert ;; 4152*a466cc55SCy Schubert *) 4153*a466cc55SCy Schubert # If the previous option needed an argument, then skip it. 4154*a466cc55SCy Schubert if test -n "$prev"; then 4155*a466cc55SCy Schubert if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156*a466cc55SCy Schubert arg2=$install_override_mode 4157*a466cc55SCy Schubert no_mode=false 4158*a466cc55SCy Schubert fi 4159*a466cc55SCy Schubert prev= 4160*a466cc55SCy Schubert else 4161*a466cc55SCy Schubert dest=$arg 4162*a466cc55SCy Schubert continue 4163*a466cc55SCy Schubert fi 4164*a466cc55SCy Schubert ;; 4165*a466cc55SCy Schubert esac 4166*a466cc55SCy Schubert 4167*a466cc55SCy Schubert # Aesthetically quote the argument. 4168*a466cc55SCy Schubert func_quote_for_eval "$arg" 4169*a466cc55SCy Schubert func_append install_prog " $func_quote_for_eval_result" 4170*a466cc55SCy Schubert if test -n "$arg2"; then 4171*a466cc55SCy Schubert func_quote_for_eval "$arg2" 4172*a466cc55SCy Schubert fi 4173*a466cc55SCy Schubert func_append install_shared_prog " $func_quote_for_eval_result" 4174*a466cc55SCy Schubert done 4175*a466cc55SCy Schubert 4176*a466cc55SCy Schubert test -z "$install_prog" && \ 4177*a466cc55SCy Schubert func_fatal_help "you must specify an install program" 4178*a466cc55SCy Schubert 4179*a466cc55SCy Schubert test -n "$prev" && \ 4180*a466cc55SCy Schubert func_fatal_help "the '$prev' option requires an argument" 4181*a466cc55SCy Schubert 4182*a466cc55SCy Schubert if test -n "$install_override_mode" && $no_mode; then 4183*a466cc55SCy Schubert if $install_cp; then :; else 4184*a466cc55SCy Schubert func_quote_for_eval "$install_override_mode" 4185*a466cc55SCy Schubert func_append install_shared_prog " -m $func_quote_for_eval_result" 4186*a466cc55SCy Schubert fi 4187*a466cc55SCy Schubert fi 4188*a466cc55SCy Schubert 4189*a466cc55SCy Schubert if test -z "$files"; then 4190*a466cc55SCy Schubert if test -z "$dest"; then 4191*a466cc55SCy Schubert func_fatal_help "no file or destination specified" 4192*a466cc55SCy Schubert else 4193*a466cc55SCy Schubert func_fatal_help "you must specify a destination" 4194*a466cc55SCy Schubert fi 4195*a466cc55SCy Schubert fi 4196*a466cc55SCy Schubert 4197*a466cc55SCy Schubert # Strip any trailing slash from the destination. 4198*a466cc55SCy Schubert func_stripname '' '/' "$dest" 4199*a466cc55SCy Schubert dest=$func_stripname_result 4200*a466cc55SCy Schubert 4201*a466cc55SCy Schubert # Check to see that the destination is a directory. 4202*a466cc55SCy Schubert test -d "$dest" && isdir=: 4203*a466cc55SCy Schubert if $isdir; then 4204*a466cc55SCy Schubert destdir=$dest 4205*a466cc55SCy Schubert destname= 4206*a466cc55SCy Schubert else 4207*a466cc55SCy Schubert func_dirname_and_basename "$dest" "" "." 4208*a466cc55SCy Schubert destdir=$func_dirname_result 4209*a466cc55SCy Schubert destname=$func_basename_result 4210*a466cc55SCy Schubert 4211*a466cc55SCy Schubert # Not a directory, so check to see that there is only one file specified. 4212*a466cc55SCy Schubert set dummy $files; shift 4213*a466cc55SCy Schubert test "$#" -gt 1 && \ 4214*a466cc55SCy Schubert func_fatal_help "'$dest' is not a directory" 4215*a466cc55SCy Schubert fi 4216*a466cc55SCy Schubert case $destdir in 4217*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 4218*a466cc55SCy Schubert *) 4219*a466cc55SCy Schubert for file in $files; do 4220*a466cc55SCy Schubert case $file in 4221*a466cc55SCy Schubert *.lo) ;; 4222*a466cc55SCy Schubert *) 4223*a466cc55SCy Schubert func_fatal_help "'$destdir' must be an absolute directory name" 4224*a466cc55SCy Schubert ;; 4225*a466cc55SCy Schubert esac 4226*a466cc55SCy Schubert done 4227*a466cc55SCy Schubert ;; 4228*a466cc55SCy Schubert esac 4229*a466cc55SCy Schubert 4230*a466cc55SCy Schubert # This variable tells wrapper scripts just to set variables rather 4231*a466cc55SCy Schubert # than running their programs. 4232*a466cc55SCy Schubert libtool_install_magic=$magic 4233*a466cc55SCy Schubert 4234*a466cc55SCy Schubert staticlibs= 4235*a466cc55SCy Schubert future_libdirs= 4236*a466cc55SCy Schubert current_libdirs= 4237*a466cc55SCy Schubert for file in $files; do 4238*a466cc55SCy Schubert 4239*a466cc55SCy Schubert # Do each installation. 4240*a466cc55SCy Schubert case $file in 4241*a466cc55SCy Schubert *.$libext) 4242*a466cc55SCy Schubert # Do the static libraries later. 4243*a466cc55SCy Schubert func_append staticlibs " $file" 4244*a466cc55SCy Schubert ;; 4245*a466cc55SCy Schubert 4246*a466cc55SCy Schubert *.la) 4247*a466cc55SCy Schubert func_resolve_sysroot "$file" 4248*a466cc55SCy Schubert file=$func_resolve_sysroot_result 4249*a466cc55SCy Schubert 4250*a466cc55SCy Schubert # Check to see that this really is a libtool archive. 4251*a466cc55SCy Schubert func_lalib_unsafe_p "$file" \ 4252*a466cc55SCy Schubert || func_fatal_help "'$file' is not a valid libtool archive" 4253*a466cc55SCy Schubert 4254*a466cc55SCy Schubert library_names= 4255*a466cc55SCy Schubert old_library= 4256*a466cc55SCy Schubert relink_command= 4257*a466cc55SCy Schubert func_source "$file" 4258*a466cc55SCy Schubert 4259*a466cc55SCy Schubert # Add the libdir to current_libdirs if it is the destination. 4260*a466cc55SCy Schubert if test "X$destdir" = "X$libdir"; then 4261*a466cc55SCy Schubert case "$current_libdirs " in 4262*a466cc55SCy Schubert *" $libdir "*) ;; 4263*a466cc55SCy Schubert *) func_append current_libdirs " $libdir" ;; 4264*a466cc55SCy Schubert esac 4265*a466cc55SCy Schubert else 4266*a466cc55SCy Schubert # Note the libdir as a future libdir. 4267*a466cc55SCy Schubert case "$future_libdirs " in 4268*a466cc55SCy Schubert *" $libdir "*) ;; 4269*a466cc55SCy Schubert *) func_append future_libdirs " $libdir" ;; 4270*a466cc55SCy Schubert esac 4271*a466cc55SCy Schubert fi 4272*a466cc55SCy Schubert 4273*a466cc55SCy Schubert func_dirname "$file" "/" "" 4274*a466cc55SCy Schubert dir=$func_dirname_result 4275*a466cc55SCy Schubert func_append dir "$objdir" 4276*a466cc55SCy Schubert 4277*a466cc55SCy Schubert if test -n "$relink_command"; then 4278*a466cc55SCy Schubert # Determine the prefix the user has applied to our future dir. 4279*a466cc55SCy Schubert inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280*a466cc55SCy Schubert 4281*a466cc55SCy Schubert # Don't allow the user to place us outside of our expected 4282*a466cc55SCy Schubert # location b/c this prevents finding dependent libraries that 4283*a466cc55SCy Schubert # are installed to the same prefix. 4284*a466cc55SCy Schubert # At present, this check doesn't affect windows .dll's that 4285*a466cc55SCy Schubert # are installed into $libdir/../bin (currently, that works fine) 4286*a466cc55SCy Schubert # but it's something to keep an eye on. 4287*a466cc55SCy Schubert test "$inst_prefix_dir" = "$destdir" && \ 4288*a466cc55SCy Schubert func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289*a466cc55SCy Schubert 4290*a466cc55SCy Schubert if test -n "$inst_prefix_dir"; then 4291*a466cc55SCy Schubert # Stick the inst_prefix_dir data into the link command. 4292*a466cc55SCy Schubert relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293*a466cc55SCy Schubert else 4294*a466cc55SCy Schubert relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295*a466cc55SCy Schubert fi 4296*a466cc55SCy Schubert 4297*a466cc55SCy Schubert func_warning "relinking '$file'" 4298*a466cc55SCy Schubert func_show_eval "$relink_command" \ 4299*a466cc55SCy Schubert 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300*a466cc55SCy Schubert fi 4301*a466cc55SCy Schubert 4302*a466cc55SCy Schubert # See the names of the shared library. 4303*a466cc55SCy Schubert set dummy $library_names; shift 4304*a466cc55SCy Schubert if test -n "$1"; then 4305*a466cc55SCy Schubert realname=$1 4306*a466cc55SCy Schubert shift 4307*a466cc55SCy Schubert 4308*a466cc55SCy Schubert srcname=$realname 4309*a466cc55SCy Schubert test -n "$relink_command" && srcname=${realname}T 4310*a466cc55SCy Schubert 4311*a466cc55SCy Schubert # Install the shared library and build the symlinks. 4312*a466cc55SCy Schubert func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313*a466cc55SCy Schubert 'exit $?' 4314*a466cc55SCy Schubert tstripme=$stripme 4315*a466cc55SCy Schubert case $host_os in 4316*a466cc55SCy Schubert cygwin* | mingw* | pw32* | cegcc*) 4317*a466cc55SCy Schubert case $realname in 4318*a466cc55SCy Schubert *.dll.a) 4319*a466cc55SCy Schubert tstripme= 4320*a466cc55SCy Schubert ;; 4321*a466cc55SCy Schubert esac 4322*a466cc55SCy Schubert ;; 4323*a466cc55SCy Schubert os2*) 4324*a466cc55SCy Schubert case $realname in 4325*a466cc55SCy Schubert *_dll.a) 4326*a466cc55SCy Schubert tstripme= 4327*a466cc55SCy Schubert ;; 4328*a466cc55SCy Schubert esac 4329*a466cc55SCy Schubert ;; 4330*a466cc55SCy Schubert esac 4331*a466cc55SCy Schubert if test -n "$tstripme" && test -n "$striplib"; then 4332*a466cc55SCy Schubert func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333*a466cc55SCy Schubert fi 4334*a466cc55SCy Schubert 4335*a466cc55SCy Schubert if test "$#" -gt 0; then 4336*a466cc55SCy Schubert # Delete the old symlinks, and create new ones. 4337*a466cc55SCy Schubert # Try 'ln -sf' first, because the 'ln' binary might depend on 4338*a466cc55SCy Schubert # the symlink we replace! Solaris /bin/ln does not understand -f, 4339*a466cc55SCy Schubert # so we also need to try rm && ln -s. 4340*a466cc55SCy Schubert for linkname 4341*a466cc55SCy Schubert do 4342*a466cc55SCy Schubert test "$linkname" != "$realname" \ 4343*a466cc55SCy Schubert && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344*a466cc55SCy Schubert done 4345*a466cc55SCy Schubert fi 4346*a466cc55SCy Schubert 4347*a466cc55SCy Schubert # Do each command in the postinstall commands. 4348*a466cc55SCy Schubert lib=$destdir/$realname 4349*a466cc55SCy Schubert func_execute_cmds "$postinstall_cmds" 'exit $?' 4350*a466cc55SCy Schubert fi 4351*a466cc55SCy Schubert 4352*a466cc55SCy Schubert # Install the pseudo-library for information purposes. 4353*a466cc55SCy Schubert func_basename "$file" 4354*a466cc55SCy Schubert name=$func_basename_result 4355*a466cc55SCy Schubert instname=$dir/${name}i 4356*a466cc55SCy Schubert func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357*a466cc55SCy Schubert 4358*a466cc55SCy Schubert # Maybe install the static library, too. 4359*a466cc55SCy Schubert test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360*a466cc55SCy Schubert ;; 4361*a466cc55SCy Schubert 4362*a466cc55SCy Schubert *.lo) 4363*a466cc55SCy Schubert # Install (i.e. copy) a libtool object. 4364*a466cc55SCy Schubert 4365*a466cc55SCy Schubert # Figure out destination file name, if it wasn't already specified. 4366*a466cc55SCy Schubert if test -n "$destname"; then 4367*a466cc55SCy Schubert destfile=$destdir/$destname 4368*a466cc55SCy Schubert else 4369*a466cc55SCy Schubert func_basename "$file" 4370*a466cc55SCy Schubert destfile=$func_basename_result 4371*a466cc55SCy Schubert destfile=$destdir/$destfile 4372*a466cc55SCy Schubert fi 4373*a466cc55SCy Schubert 4374*a466cc55SCy Schubert # Deduce the name of the destination old-style object file. 4375*a466cc55SCy Schubert case $destfile in 4376*a466cc55SCy Schubert *.lo) 4377*a466cc55SCy Schubert func_lo2o "$destfile" 4378*a466cc55SCy Schubert staticdest=$func_lo2o_result 4379*a466cc55SCy Schubert ;; 4380*a466cc55SCy Schubert *.$objext) 4381*a466cc55SCy Schubert staticdest=$destfile 4382*a466cc55SCy Schubert destfile= 4383*a466cc55SCy Schubert ;; 4384*a466cc55SCy Schubert *) 4385*a466cc55SCy Schubert func_fatal_help "cannot copy a libtool object to '$destfile'" 4386*a466cc55SCy Schubert ;; 4387*a466cc55SCy Schubert esac 4388*a466cc55SCy Schubert 4389*a466cc55SCy Schubert # Install the libtool object if requested. 4390*a466cc55SCy Schubert test -n "$destfile" && \ 4391*a466cc55SCy Schubert func_show_eval "$install_prog $file $destfile" 'exit $?' 4392*a466cc55SCy Schubert 4393*a466cc55SCy Schubert # Install the old object if enabled. 4394*a466cc55SCy Schubert if test yes = "$build_old_libs"; then 4395*a466cc55SCy Schubert # Deduce the name of the old-style object file. 4396*a466cc55SCy Schubert func_lo2o "$file" 4397*a466cc55SCy Schubert staticobj=$func_lo2o_result 4398*a466cc55SCy Schubert func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399*a466cc55SCy Schubert fi 4400*a466cc55SCy Schubert exit $EXIT_SUCCESS 4401*a466cc55SCy Schubert ;; 4402*a466cc55SCy Schubert 4403*a466cc55SCy Schubert *) 4404*a466cc55SCy Schubert # Figure out destination file name, if it wasn't already specified. 4405*a466cc55SCy Schubert if test -n "$destname"; then 4406*a466cc55SCy Schubert destfile=$destdir/$destname 4407*a466cc55SCy Schubert else 4408*a466cc55SCy Schubert func_basename "$file" 4409*a466cc55SCy Schubert destfile=$func_basename_result 4410*a466cc55SCy Schubert destfile=$destdir/$destfile 4411*a466cc55SCy Schubert fi 4412*a466cc55SCy Schubert 4413*a466cc55SCy Schubert # If the file is missing, and there is a .exe on the end, strip it 4414*a466cc55SCy Schubert # because it is most likely a libtool script we actually want to 4415*a466cc55SCy Schubert # install 4416*a466cc55SCy Schubert stripped_ext= 4417*a466cc55SCy Schubert case $file in 4418*a466cc55SCy Schubert *.exe) 4419*a466cc55SCy Schubert if test ! -f "$file"; then 4420*a466cc55SCy Schubert func_stripname '' '.exe' "$file" 4421*a466cc55SCy Schubert file=$func_stripname_result 4422*a466cc55SCy Schubert stripped_ext=.exe 4423*a466cc55SCy Schubert fi 4424*a466cc55SCy Schubert ;; 4425*a466cc55SCy Schubert esac 4426*a466cc55SCy Schubert 4427*a466cc55SCy Schubert # Do a test to see if this is really a libtool program. 4428*a466cc55SCy Schubert case $host in 4429*a466cc55SCy Schubert *cygwin* | *mingw*) 4430*a466cc55SCy Schubert if func_ltwrapper_executable_p "$file"; then 4431*a466cc55SCy Schubert func_ltwrapper_scriptname "$file" 4432*a466cc55SCy Schubert wrapper=$func_ltwrapper_scriptname_result 4433*a466cc55SCy Schubert else 4434*a466cc55SCy Schubert func_stripname '' '.exe' "$file" 4435*a466cc55SCy Schubert wrapper=$func_stripname_result 4436*a466cc55SCy Schubert fi 4437*a466cc55SCy Schubert ;; 4438*a466cc55SCy Schubert *) 4439*a466cc55SCy Schubert wrapper=$file 4440*a466cc55SCy Schubert ;; 4441*a466cc55SCy Schubert esac 4442*a466cc55SCy Schubert if func_ltwrapper_script_p "$wrapper"; then 4443*a466cc55SCy Schubert notinst_deplibs= 4444*a466cc55SCy Schubert relink_command= 4445*a466cc55SCy Schubert 4446*a466cc55SCy Schubert func_source "$wrapper" 4447*a466cc55SCy Schubert 4448*a466cc55SCy Schubert # Check the variables that should have been set. 4449*a466cc55SCy Schubert test -z "$generated_by_libtool_version" && \ 4450*a466cc55SCy Schubert func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451*a466cc55SCy Schubert 4452*a466cc55SCy Schubert finalize=: 4453*a466cc55SCy Schubert for lib in $notinst_deplibs; do 4454*a466cc55SCy Schubert # Check to see that each library is installed. 4455*a466cc55SCy Schubert libdir= 4456*a466cc55SCy Schubert if test -f "$lib"; then 4457*a466cc55SCy Schubert func_source "$lib" 4458*a466cc55SCy Schubert fi 4459*a466cc55SCy Schubert libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460*a466cc55SCy Schubert if test -n "$libdir" && test ! -f "$libfile"; then 4461*a466cc55SCy Schubert func_warning "'$lib' has not been installed in '$libdir'" 4462*a466cc55SCy Schubert finalize=false 4463*a466cc55SCy Schubert fi 4464*a466cc55SCy Schubert done 4465*a466cc55SCy Schubert 4466*a466cc55SCy Schubert relink_command= 4467*a466cc55SCy Schubert func_source "$wrapper" 4468*a466cc55SCy Schubert 4469*a466cc55SCy Schubert outputname= 4470*a466cc55SCy Schubert if test no = "$fast_install" && test -n "$relink_command"; then 4471*a466cc55SCy Schubert $opt_dry_run || { 4472*a466cc55SCy Schubert if $finalize; then 4473*a466cc55SCy Schubert tmpdir=`func_mktempdir` 4474*a466cc55SCy Schubert func_basename "$file$stripped_ext" 4475*a466cc55SCy Schubert file=$func_basename_result 4476*a466cc55SCy Schubert outputname=$tmpdir/$file 4477*a466cc55SCy Schubert # Replace the output file specification. 4478*a466cc55SCy Schubert relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479*a466cc55SCy Schubert 4480*a466cc55SCy Schubert $opt_quiet || { 4481*a466cc55SCy Schubert func_quote_for_expand "$relink_command" 4482*a466cc55SCy Schubert eval "func_echo $func_quote_for_expand_result" 4483*a466cc55SCy Schubert } 4484*a466cc55SCy Schubert if eval "$relink_command"; then : 4485*a466cc55SCy Schubert else 4486*a466cc55SCy Schubert func_error "error: relink '$file' with the above command before installing it" 4487*a466cc55SCy Schubert $opt_dry_run || ${RM}r "$tmpdir" 4488*a466cc55SCy Schubert continue 4489*a466cc55SCy Schubert fi 4490*a466cc55SCy Schubert file=$outputname 4491*a466cc55SCy Schubert else 4492*a466cc55SCy Schubert func_warning "cannot relink '$file'" 4493*a466cc55SCy Schubert fi 4494*a466cc55SCy Schubert } 4495*a466cc55SCy Schubert else 4496*a466cc55SCy Schubert # Install the binary that we compiled earlier. 4497*a466cc55SCy Schubert file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498*a466cc55SCy Schubert fi 4499*a466cc55SCy Schubert fi 4500*a466cc55SCy Schubert 4501*a466cc55SCy Schubert # remove .exe since cygwin /usr/bin/install will append another 4502*a466cc55SCy Schubert # one anyway 4503*a466cc55SCy Schubert case $install_prog,$host in 4504*a466cc55SCy Schubert */usr/bin/install*,*cygwin*) 4505*a466cc55SCy Schubert case $file:$destfile in 4506*a466cc55SCy Schubert *.exe:*.exe) 4507*a466cc55SCy Schubert # this is ok 4508*a466cc55SCy Schubert ;; 4509*a466cc55SCy Schubert *.exe:*) 4510*a466cc55SCy Schubert destfile=$destfile.exe 4511*a466cc55SCy Schubert ;; 4512*a466cc55SCy Schubert *:*.exe) 4513*a466cc55SCy Schubert func_stripname '' '.exe' "$destfile" 4514*a466cc55SCy Schubert destfile=$func_stripname_result 4515*a466cc55SCy Schubert ;; 4516*a466cc55SCy Schubert esac 4517*a466cc55SCy Schubert ;; 4518*a466cc55SCy Schubert esac 4519*a466cc55SCy Schubert func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520*a466cc55SCy Schubert $opt_dry_run || if test -n "$outputname"; then 4521*a466cc55SCy Schubert ${RM}r "$tmpdir" 4522*a466cc55SCy Schubert fi 4523*a466cc55SCy Schubert ;; 4524*a466cc55SCy Schubert esac 4525*a466cc55SCy Schubert done 4526*a466cc55SCy Schubert 4527*a466cc55SCy Schubert for file in $staticlibs; do 4528*a466cc55SCy Schubert func_basename "$file" 4529*a466cc55SCy Schubert name=$func_basename_result 4530*a466cc55SCy Schubert 4531*a466cc55SCy Schubert # Set up the ranlib parameters. 4532*a466cc55SCy Schubert oldlib=$destdir/$name 4533*a466cc55SCy Schubert func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534*a466cc55SCy Schubert tool_oldlib=$func_to_tool_file_result 4535*a466cc55SCy Schubert 4536*a466cc55SCy Schubert func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537*a466cc55SCy Schubert 4538*a466cc55SCy Schubert if test -n "$stripme" && test -n "$old_striplib"; then 4539*a466cc55SCy Schubert func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540*a466cc55SCy Schubert fi 4541*a466cc55SCy Schubert 4542*a466cc55SCy Schubert # Do each command in the postinstall commands. 4543*a466cc55SCy Schubert func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544*a466cc55SCy Schubert done 4545*a466cc55SCy Schubert 4546*a466cc55SCy Schubert test -n "$future_libdirs" && \ 4547*a466cc55SCy Schubert func_warning "remember to run '$progname --finish$future_libdirs'" 4548*a466cc55SCy Schubert 4549*a466cc55SCy Schubert if test -n "$current_libdirs"; then 4550*a466cc55SCy Schubert # Maybe just do a dry run. 4551*a466cc55SCy Schubert $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552*a466cc55SCy Schubert exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553*a466cc55SCy Schubert else 4554*a466cc55SCy Schubert exit $EXIT_SUCCESS 4555*a466cc55SCy Schubert fi 4556*a466cc55SCy Schubert} 4557*a466cc55SCy Schubert 4558*a466cc55SCy Schuberttest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559*a466cc55SCy Schubert 4560*a466cc55SCy Schubert 4561*a466cc55SCy Schubert# func_generate_dlsyms outputname originator pic_p 4562*a466cc55SCy Schubert# Extract symbols from dlprefiles and create ${outputname}S.o with 4563*a466cc55SCy Schubert# a dlpreopen symbol table. 4564*a466cc55SCy Schubertfunc_generate_dlsyms () 4565*a466cc55SCy Schubert{ 4566*a466cc55SCy Schubert $debug_cmd 4567*a466cc55SCy Schubert 4568*a466cc55SCy Schubert my_outputname=$1 4569*a466cc55SCy Schubert my_originator=$2 4570*a466cc55SCy Schubert my_pic_p=${3-false} 4571*a466cc55SCy Schubert my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572*a466cc55SCy Schubert my_dlsyms= 4573*a466cc55SCy Schubert 4574*a466cc55SCy Schubert if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575*a466cc55SCy Schubert if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576*a466cc55SCy Schubert my_dlsyms=${my_outputname}S.c 4577*a466cc55SCy Schubert else 4578*a466cc55SCy Schubert func_error "not configured to extract global symbols from dlpreopened files" 4579*a466cc55SCy Schubert fi 4580*a466cc55SCy Schubert fi 4581*a466cc55SCy Schubert 4582*a466cc55SCy Schubert if test -n "$my_dlsyms"; then 4583*a466cc55SCy Schubert case $my_dlsyms in 4584*a466cc55SCy Schubert "") ;; 4585*a466cc55SCy Schubert *.c) 4586*a466cc55SCy Schubert # Discover the nlist of each of the dlfiles. 4587*a466cc55SCy Schubert nlist=$output_objdir/$my_outputname.nm 4588*a466cc55SCy Schubert 4589*a466cc55SCy Schubert func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590*a466cc55SCy Schubert 4591*a466cc55SCy Schubert # Parse the name list into a source file. 4592*a466cc55SCy Schubert func_verbose "creating $output_objdir/$my_dlsyms" 4593*a466cc55SCy Schubert 4594*a466cc55SCy Schubert $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595*a466cc55SCy Schubert/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596*a466cc55SCy Schubert/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597*a466cc55SCy Schubert 4598*a466cc55SCy Schubert#ifdef __cplusplus 4599*a466cc55SCy Schubertextern \"C\" { 4600*a466cc55SCy Schubert#endif 4601*a466cc55SCy Schubert 4602*a466cc55SCy Schubert#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603*a466cc55SCy Schubert#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604*a466cc55SCy Schubert#endif 4605*a466cc55SCy Schubert 4606*a466cc55SCy Schubert/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607*a466cc55SCy Schubert#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608*a466cc55SCy Schubert/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609*a466cc55SCy Schubert relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610*a466cc55SCy Schubert# define LT_DLSYM_CONST 4611*a466cc55SCy Schubert#elif defined __osf__ 4612*a466cc55SCy Schubert/* This system does not cope well with relocations in const data. */ 4613*a466cc55SCy Schubert# define LT_DLSYM_CONST 4614*a466cc55SCy Schubert#else 4615*a466cc55SCy Schubert# define LT_DLSYM_CONST const 4616*a466cc55SCy Schubert#endif 4617*a466cc55SCy Schubert 4618*a466cc55SCy Schubert#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619*a466cc55SCy Schubert 4620*a466cc55SCy Schubert/* External symbol declarations for the compiler. */\ 4621*a466cc55SCy Schubert" 4622*a466cc55SCy Schubert 4623*a466cc55SCy Schubert if test yes = "$dlself"; then 4624*a466cc55SCy Schubert func_verbose "generating symbol list for '$output'" 4625*a466cc55SCy Schubert 4626*a466cc55SCy Schubert $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627*a466cc55SCy Schubert 4628*a466cc55SCy Schubert # Add our own program objects to the symbol list. 4629*a466cc55SCy Schubert progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630*a466cc55SCy Schubert for progfile in $progfiles; do 4631*a466cc55SCy Schubert func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632*a466cc55SCy Schubert func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633*a466cc55SCy Schubert $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634*a466cc55SCy Schubert done 4635*a466cc55SCy Schubert 4636*a466cc55SCy Schubert if test -n "$exclude_expsyms"; then 4637*a466cc55SCy Schubert $opt_dry_run || { 4638*a466cc55SCy Schubert eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639*a466cc55SCy Schubert eval '$MV "$nlist"T "$nlist"' 4640*a466cc55SCy Schubert } 4641*a466cc55SCy Schubert fi 4642*a466cc55SCy Schubert 4643*a466cc55SCy Schubert if test -n "$export_symbols_regex"; then 4644*a466cc55SCy Schubert $opt_dry_run || { 4645*a466cc55SCy Schubert eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646*a466cc55SCy Schubert eval '$MV "$nlist"T "$nlist"' 4647*a466cc55SCy Schubert } 4648*a466cc55SCy Schubert fi 4649*a466cc55SCy Schubert 4650*a466cc55SCy Schubert # Prepare the list of exported symbols 4651*a466cc55SCy Schubert if test -z "$export_symbols"; then 4652*a466cc55SCy Schubert export_symbols=$output_objdir/$outputname.exp 4653*a466cc55SCy Schubert $opt_dry_run || { 4654*a466cc55SCy Schubert $RM $export_symbols 4655*a466cc55SCy Schubert eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656*a466cc55SCy Schubert case $host in 4657*a466cc55SCy Schubert *cygwin* | *mingw* | *cegcc* ) 4658*a466cc55SCy Schubert eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659*a466cc55SCy Schubert eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660*a466cc55SCy Schubert ;; 4661*a466cc55SCy Schubert esac 4662*a466cc55SCy Schubert } 4663*a466cc55SCy Schubert else 4664*a466cc55SCy Schubert $opt_dry_run || { 4665*a466cc55SCy Schubert eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666*a466cc55SCy Schubert eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667*a466cc55SCy Schubert eval '$MV "$nlist"T "$nlist"' 4668*a466cc55SCy Schubert case $host in 4669*a466cc55SCy Schubert *cygwin* | *mingw* | *cegcc* ) 4670*a466cc55SCy Schubert eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671*a466cc55SCy Schubert eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672*a466cc55SCy Schubert ;; 4673*a466cc55SCy Schubert esac 4674*a466cc55SCy Schubert } 4675*a466cc55SCy Schubert fi 4676*a466cc55SCy Schubert fi 4677*a466cc55SCy Schubert 4678*a466cc55SCy Schubert for dlprefile in $dlprefiles; do 4679*a466cc55SCy Schubert func_verbose "extracting global C symbols from '$dlprefile'" 4680*a466cc55SCy Schubert func_basename "$dlprefile" 4681*a466cc55SCy Schubert name=$func_basename_result 4682*a466cc55SCy Schubert case $host in 4683*a466cc55SCy Schubert *cygwin* | *mingw* | *cegcc* ) 4684*a466cc55SCy Schubert # if an import library, we need to obtain dlname 4685*a466cc55SCy Schubert if func_win32_import_lib_p "$dlprefile"; then 4686*a466cc55SCy Schubert func_tr_sh "$dlprefile" 4687*a466cc55SCy Schubert eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688*a466cc55SCy Schubert dlprefile_dlbasename= 4689*a466cc55SCy Schubert if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690*a466cc55SCy Schubert # Use subshell, to avoid clobbering current variable values 4691*a466cc55SCy Schubert dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692*a466cc55SCy Schubert if test -n "$dlprefile_dlname"; then 4693*a466cc55SCy Schubert func_basename "$dlprefile_dlname" 4694*a466cc55SCy Schubert dlprefile_dlbasename=$func_basename_result 4695*a466cc55SCy Schubert else 4696*a466cc55SCy Schubert # no lafile. user explicitly requested -dlpreopen <import library>. 4697*a466cc55SCy Schubert $sharedlib_from_linklib_cmd "$dlprefile" 4698*a466cc55SCy Schubert dlprefile_dlbasename=$sharedlib_from_linklib_result 4699*a466cc55SCy Schubert fi 4700*a466cc55SCy Schubert fi 4701*a466cc55SCy Schubert $opt_dry_run || { 4702*a466cc55SCy Schubert if test -n "$dlprefile_dlbasename"; then 4703*a466cc55SCy Schubert eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704*a466cc55SCy Schubert else 4705*a466cc55SCy Schubert func_warning "Could not compute DLL name from $name" 4706*a466cc55SCy Schubert eval '$ECHO ": $name " >> "$nlist"' 4707*a466cc55SCy Schubert fi 4708*a466cc55SCy Schubert func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709*a466cc55SCy Schubert eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710*a466cc55SCy Schubert $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711*a466cc55SCy Schubert } 4712*a466cc55SCy Schubert else # not an import lib 4713*a466cc55SCy Schubert $opt_dry_run || { 4714*a466cc55SCy Schubert eval '$ECHO ": $name " >> "$nlist"' 4715*a466cc55SCy Schubert func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716*a466cc55SCy Schubert eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717*a466cc55SCy Schubert } 4718*a466cc55SCy Schubert fi 4719*a466cc55SCy Schubert ;; 4720*a466cc55SCy Schubert *) 4721*a466cc55SCy Schubert $opt_dry_run || { 4722*a466cc55SCy Schubert eval '$ECHO ": $name " >> "$nlist"' 4723*a466cc55SCy Schubert func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724*a466cc55SCy Schubert eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725*a466cc55SCy Schubert } 4726*a466cc55SCy Schubert ;; 4727*a466cc55SCy Schubert esac 4728*a466cc55SCy Schubert done 4729*a466cc55SCy Schubert 4730*a466cc55SCy Schubert $opt_dry_run || { 4731*a466cc55SCy Schubert # Make sure we have at least an empty file. 4732*a466cc55SCy Schubert test -f "$nlist" || : > "$nlist" 4733*a466cc55SCy Schubert 4734*a466cc55SCy Schubert if test -n "$exclude_expsyms"; then 4735*a466cc55SCy Schubert $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736*a466cc55SCy Schubert $MV "$nlist"T "$nlist" 4737*a466cc55SCy Schubert fi 4738*a466cc55SCy Schubert 4739*a466cc55SCy Schubert # Try sorting and uniquifying the output. 4740*a466cc55SCy Schubert if $GREP -v "^: " < "$nlist" | 4741*a466cc55SCy Schubert if sort -k 3 </dev/null >/dev/null 2>&1; then 4742*a466cc55SCy Schubert sort -k 3 4743*a466cc55SCy Schubert else 4744*a466cc55SCy Schubert sort +2 4745*a466cc55SCy Schubert fi | 4746*a466cc55SCy Schubert uniq > "$nlist"S; then 4747*a466cc55SCy Schubert : 4748*a466cc55SCy Schubert else 4749*a466cc55SCy Schubert $GREP -v "^: " < "$nlist" > "$nlist"S 4750*a466cc55SCy Schubert fi 4751*a466cc55SCy Schubert 4752*a466cc55SCy Schubert if test -f "$nlist"S; then 4753*a466cc55SCy Schubert eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754*a466cc55SCy Schubert else 4755*a466cc55SCy Schubert echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756*a466cc55SCy Schubert fi 4757*a466cc55SCy Schubert 4758*a466cc55SCy Schubert func_show_eval '$RM "${nlist}I"' 4759*a466cc55SCy Schubert if test -n "$global_symbol_to_import"; then 4760*a466cc55SCy Schubert eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761*a466cc55SCy Schubert fi 4762*a466cc55SCy Schubert 4763*a466cc55SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4764*a466cc55SCy Schubert 4765*a466cc55SCy Schubert/* The mapping between symbol names and symbols. */ 4766*a466cc55SCy Schuberttypedef struct { 4767*a466cc55SCy Schubert const char *name; 4768*a466cc55SCy Schubert void *address; 4769*a466cc55SCy Schubert} lt_dlsymlist; 4770*a466cc55SCy Schubertextern LT_DLSYM_CONST lt_dlsymlist 4771*a466cc55SCy Schubertlt_${my_prefix}_LTX_preloaded_symbols[];\ 4772*a466cc55SCy Schubert" 4773*a466cc55SCy Schubert 4774*a466cc55SCy Schubert if test -s "$nlist"I; then 4775*a466cc55SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4776*a466cc55SCy Schubertstatic void lt_syminit(void) 4777*a466cc55SCy Schubert{ 4778*a466cc55SCy Schubert LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779*a466cc55SCy Schubert for (; symbol->name; ++symbol) 4780*a466cc55SCy Schubert {" 4781*a466cc55SCy Schubert $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782*a466cc55SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4783*a466cc55SCy Schubert } 4784*a466cc55SCy Schubert}" 4785*a466cc55SCy Schubert fi 4786*a466cc55SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4787*a466cc55SCy SchubertLT_DLSYM_CONST lt_dlsymlist 4788*a466cc55SCy Schubertlt_${my_prefix}_LTX_preloaded_symbols[] = 4789*a466cc55SCy Schubert{ {\"$my_originator\", (void *) 0}," 4790*a466cc55SCy Schubert 4791*a466cc55SCy Schubert if test -s "$nlist"I; then 4792*a466cc55SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4793*a466cc55SCy Schubert {\"@INIT@\", (void *) <_syminit}," 4794*a466cc55SCy Schubert fi 4795*a466cc55SCy Schubert 4796*a466cc55SCy Schubert case $need_lib_prefix in 4797*a466cc55SCy Schubert no) 4798*a466cc55SCy Schubert eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799*a466cc55SCy Schubert ;; 4800*a466cc55SCy Schubert *) 4801*a466cc55SCy Schubert eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802*a466cc55SCy Schubert ;; 4803*a466cc55SCy Schubert esac 4804*a466cc55SCy Schubert echo >> "$output_objdir/$my_dlsyms" "\ 4805*a466cc55SCy Schubert {0, (void *) 0} 4806*a466cc55SCy Schubert}; 4807*a466cc55SCy Schubert 4808*a466cc55SCy Schubert/* This works around a problem in FreeBSD linker */ 4809*a466cc55SCy Schubert#ifdef FREEBSD_WORKAROUND 4810*a466cc55SCy Schubertstatic const void *lt_preloaded_setup() { 4811*a466cc55SCy Schubert return lt_${my_prefix}_LTX_preloaded_symbols; 4812*a466cc55SCy Schubert} 4813*a466cc55SCy Schubert#endif 4814*a466cc55SCy Schubert 4815*a466cc55SCy Schubert#ifdef __cplusplus 4816*a466cc55SCy Schubert} 4817*a466cc55SCy Schubert#endif\ 4818*a466cc55SCy Schubert" 4819*a466cc55SCy Schubert } # !$opt_dry_run 4820*a466cc55SCy Schubert 4821*a466cc55SCy Schubert pic_flag_for_symtable= 4822*a466cc55SCy Schubert case "$compile_command " in 4823*a466cc55SCy Schubert *" -static "*) ;; 4824*a466cc55SCy Schubert *) 4825*a466cc55SCy Schubert case $host in 4826*a466cc55SCy Schubert # compiling the symbol table file with pic_flag works around 4827*a466cc55SCy Schubert # a FreeBSD bug that causes programs to crash when -lm is 4828*a466cc55SCy Schubert # linked before any other PIC object. But we must not use 4829*a466cc55SCy Schubert # pic_flag when linking with -static. The problem exists in 4830*a466cc55SCy Schubert # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831*a466cc55SCy Schubert *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832*a466cc55SCy Schubert pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833*a466cc55SCy Schubert *-*-hpux*) 4834*a466cc55SCy Schubert pic_flag_for_symtable=" $pic_flag" ;; 4835*a466cc55SCy Schubert *) 4836*a466cc55SCy Schubert $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837*a466cc55SCy Schubert ;; 4838*a466cc55SCy Schubert esac 4839*a466cc55SCy Schubert ;; 4840*a466cc55SCy Schubert esac 4841*a466cc55SCy Schubert symtab_cflags= 4842*a466cc55SCy Schubert for arg in $LTCFLAGS; do 4843*a466cc55SCy Schubert case $arg in 4844*a466cc55SCy Schubert -pie | -fpie | -fPIE) ;; 4845*a466cc55SCy Schubert *) func_append symtab_cflags " $arg" ;; 4846*a466cc55SCy Schubert esac 4847*a466cc55SCy Schubert done 4848*a466cc55SCy Schubert 4849*a466cc55SCy Schubert # Now compile the dynamic symbol file. 4850*a466cc55SCy Schubert func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851*a466cc55SCy Schubert 4852*a466cc55SCy Schubert # Clean up the generated files. 4853*a466cc55SCy Schubert func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854*a466cc55SCy Schubert 4855*a466cc55SCy Schubert # Transform the symbol file into the correct name. 4856*a466cc55SCy Schubert symfileobj=$output_objdir/${my_outputname}S.$objext 4857*a466cc55SCy Schubert case $host in 4858*a466cc55SCy Schubert *cygwin* | *mingw* | *cegcc* ) 4859*a466cc55SCy Schubert if test -f "$output_objdir/$my_outputname.def"; then 4860*a466cc55SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861*a466cc55SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862*a466cc55SCy Schubert else 4863*a466cc55SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864*a466cc55SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865*a466cc55SCy Schubert fi 4866*a466cc55SCy Schubert ;; 4867*a466cc55SCy Schubert *) 4868*a466cc55SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869*a466cc55SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870*a466cc55SCy Schubert ;; 4871*a466cc55SCy Schubert esac 4872*a466cc55SCy Schubert ;; 4873*a466cc55SCy Schubert *) 4874*a466cc55SCy Schubert func_fatal_error "unknown suffix for '$my_dlsyms'" 4875*a466cc55SCy Schubert ;; 4876*a466cc55SCy Schubert esac 4877*a466cc55SCy Schubert else 4878*a466cc55SCy Schubert # We keep going just in case the user didn't refer to 4879*a466cc55SCy Schubert # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880*a466cc55SCy Schubert # really was required. 4881*a466cc55SCy Schubert 4882*a466cc55SCy Schubert # Nullify the symbol file. 4883*a466cc55SCy Schubert compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884*a466cc55SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885*a466cc55SCy Schubert fi 4886*a466cc55SCy Schubert} 4887*a466cc55SCy Schubert 4888*a466cc55SCy Schubert# func_cygming_gnu_implib_p ARG 4889*a466cc55SCy Schubert# This predicate returns with zero status (TRUE) if 4890*a466cc55SCy Schubert# ARG is a GNU/binutils-style import library. Returns 4891*a466cc55SCy Schubert# with nonzero status (FALSE) otherwise. 4892*a466cc55SCy Schubertfunc_cygming_gnu_implib_p () 4893*a466cc55SCy Schubert{ 4894*a466cc55SCy Schubert $debug_cmd 4895*a466cc55SCy Schubert 4896*a466cc55SCy Schubert func_to_tool_file "$1" func_convert_file_msys_to_w32 4897*a466cc55SCy 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)$'` 4898*a466cc55SCy Schubert test -n "$func_cygming_gnu_implib_tmp" 4899*a466cc55SCy Schubert} 4900*a466cc55SCy Schubert 4901*a466cc55SCy Schubert# func_cygming_ms_implib_p ARG 4902*a466cc55SCy Schubert# This predicate returns with zero status (TRUE) if 4903*a466cc55SCy Schubert# ARG is an MS-style import library. Returns 4904*a466cc55SCy Schubert# with nonzero status (FALSE) otherwise. 4905*a466cc55SCy Schubertfunc_cygming_ms_implib_p () 4906*a466cc55SCy Schubert{ 4907*a466cc55SCy Schubert $debug_cmd 4908*a466cc55SCy Schubert 4909*a466cc55SCy Schubert func_to_tool_file "$1" func_convert_file_msys_to_w32 4910*a466cc55SCy Schubert func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911*a466cc55SCy Schubert test -n "$func_cygming_ms_implib_tmp" 4912*a466cc55SCy Schubert} 4913*a466cc55SCy Schubert 4914*a466cc55SCy Schubert# func_win32_libid arg 4915*a466cc55SCy Schubert# return the library type of file 'arg' 4916*a466cc55SCy Schubert# 4917*a466cc55SCy Schubert# Need a lot of goo to handle *both* DLLs and import libs 4918*a466cc55SCy Schubert# Has to be a shell function in order to 'eat' the argument 4919*a466cc55SCy Schubert# that is supplied when $file_magic_command is called. 4920*a466cc55SCy Schubert# Despite the name, also deal with 64 bit binaries. 4921*a466cc55SCy Schubertfunc_win32_libid () 4922*a466cc55SCy Schubert{ 4923*a466cc55SCy Schubert $debug_cmd 4924*a466cc55SCy Schubert 4925*a466cc55SCy Schubert win32_libid_type=unknown 4926*a466cc55SCy Schubert win32_fileres=`file -L $1 2>/dev/null` 4927*a466cc55SCy Schubert case $win32_fileres in 4928*a466cc55SCy Schubert *ar\ archive\ import\ library*) # definitely import 4929*a466cc55SCy Schubert win32_libid_type="x86 archive import" 4930*a466cc55SCy Schubert ;; 4931*a466cc55SCy Schubert *ar\ archive*) # could be an import, or static 4932*a466cc55SCy Schubert # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933*a466cc55SCy Schubert if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934*a466cc55SCy Schubert $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935*a466cc55SCy Schubert case $nm_interface in 4936*a466cc55SCy Schubert "MS dumpbin") 4937*a466cc55SCy Schubert if func_cygming_ms_implib_p "$1" || 4938*a466cc55SCy Schubert func_cygming_gnu_implib_p "$1" 4939*a466cc55SCy Schubert then 4940*a466cc55SCy Schubert win32_nmres=import 4941*a466cc55SCy Schubert else 4942*a466cc55SCy Schubert win32_nmres= 4943*a466cc55SCy Schubert fi 4944*a466cc55SCy Schubert ;; 4945*a466cc55SCy Schubert *) 4946*a466cc55SCy Schubert func_to_tool_file "$1" func_convert_file_msys_to_w32 4947*a466cc55SCy Schubert win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948*a466cc55SCy Schubert $SED -n -e ' 4949*a466cc55SCy Schubert 1,100{ 4950*a466cc55SCy Schubert / I /{ 4951*a466cc55SCy Schubert s|.*|import| 4952*a466cc55SCy Schubert p 4953*a466cc55SCy Schubert q 4954*a466cc55SCy Schubert } 4955*a466cc55SCy Schubert }'` 4956*a466cc55SCy Schubert ;; 4957*a466cc55SCy Schubert esac 4958*a466cc55SCy Schubert case $win32_nmres in 4959*a466cc55SCy Schubert import*) win32_libid_type="x86 archive import";; 4960*a466cc55SCy Schubert *) win32_libid_type="x86 archive static";; 4961*a466cc55SCy Schubert esac 4962*a466cc55SCy Schubert fi 4963*a466cc55SCy Schubert ;; 4964*a466cc55SCy Schubert *DLL*) 4965*a466cc55SCy Schubert win32_libid_type="x86 DLL" 4966*a466cc55SCy Schubert ;; 4967*a466cc55SCy Schubert *executable*) # but shell scripts are "executable" too... 4968*a466cc55SCy Schubert case $win32_fileres in 4969*a466cc55SCy Schubert *MS\ Windows\ PE\ Intel*) 4970*a466cc55SCy Schubert win32_libid_type="x86 DLL" 4971*a466cc55SCy Schubert ;; 4972*a466cc55SCy Schubert esac 4973*a466cc55SCy Schubert ;; 4974*a466cc55SCy Schubert esac 4975*a466cc55SCy Schubert $ECHO "$win32_libid_type" 4976*a466cc55SCy Schubert} 4977*a466cc55SCy Schubert 4978*a466cc55SCy Schubert# func_cygming_dll_for_implib ARG 4979*a466cc55SCy Schubert# 4980*a466cc55SCy Schubert# Platform-specific function to extract the 4981*a466cc55SCy Schubert# name of the DLL associated with the specified 4982*a466cc55SCy Schubert# import library ARG. 4983*a466cc55SCy Schubert# Invoked by eval'ing the libtool variable 4984*a466cc55SCy Schubert# $sharedlib_from_linklib_cmd 4985*a466cc55SCy Schubert# Result is available in the variable 4986*a466cc55SCy Schubert# $sharedlib_from_linklib_result 4987*a466cc55SCy Schubertfunc_cygming_dll_for_implib () 4988*a466cc55SCy Schubert{ 4989*a466cc55SCy Schubert $debug_cmd 4990*a466cc55SCy Schubert 4991*a466cc55SCy Schubert sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992*a466cc55SCy Schubert} 4993*a466cc55SCy Schubert 4994*a466cc55SCy Schubert# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995*a466cc55SCy Schubert# 4996*a466cc55SCy Schubert# The is the core of a fallback implementation of a 4997*a466cc55SCy Schubert# platform-specific function to extract the name of the 4998*a466cc55SCy Schubert# DLL associated with the specified import library LIBNAME. 4999*a466cc55SCy Schubert# 5000*a466cc55SCy Schubert# SECTION_NAME is either .idata$6 or .idata$7, depending 5001*a466cc55SCy Schubert# on the platform and compiler that created the implib. 5002*a466cc55SCy Schubert# 5003*a466cc55SCy Schubert# Echos the name of the DLL associated with the 5004*a466cc55SCy Schubert# specified import library. 5005*a466cc55SCy Schubertfunc_cygming_dll_for_implib_fallback_core () 5006*a466cc55SCy Schubert{ 5007*a466cc55SCy Schubert $debug_cmd 5008*a466cc55SCy Schubert 5009*a466cc55SCy Schubert match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010*a466cc55SCy Schubert $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011*a466cc55SCy Schubert $SED '/^Contents of section '"$match_literal"':/{ 5012*a466cc55SCy Schubert # Place marker at beginning of archive member dllname section 5013*a466cc55SCy Schubert s/.*/====MARK====/ 5014*a466cc55SCy Schubert p 5015*a466cc55SCy Schubert d 5016*a466cc55SCy Schubert } 5017*a466cc55SCy Schubert # These lines can sometimes be longer than 43 characters, but 5018*a466cc55SCy Schubert # are always uninteresting 5019*a466cc55SCy Schubert /:[ ]*file format pe[i]\{,1\}-/d 5020*a466cc55SCy Schubert /^In archive [^:]*:/d 5021*a466cc55SCy Schubert # Ensure marker is printed 5022*a466cc55SCy Schubert /^====MARK====/p 5023*a466cc55SCy Schubert # Remove all lines with less than 43 characters 5024*a466cc55SCy Schubert /^.\{43\}/!d 5025*a466cc55SCy Schubert # From remaining lines, remove first 43 characters 5026*a466cc55SCy Schubert s/^.\{43\}//' | 5027*a466cc55SCy Schubert $SED -n ' 5028*a466cc55SCy Schubert # Join marker and all lines until next marker into a single line 5029*a466cc55SCy Schubert /^====MARK====/ b para 5030*a466cc55SCy Schubert H 5031*a466cc55SCy Schubert $ b para 5032*a466cc55SCy Schubert b 5033*a466cc55SCy Schubert :para 5034*a466cc55SCy Schubert x 5035*a466cc55SCy Schubert s/\n//g 5036*a466cc55SCy Schubert # Remove the marker 5037*a466cc55SCy Schubert s/^====MARK====// 5038*a466cc55SCy Schubert # Remove trailing dots and whitespace 5039*a466cc55SCy Schubert s/[\. \t]*$// 5040*a466cc55SCy Schubert # Print 5041*a466cc55SCy Schubert /./p' | 5042*a466cc55SCy Schubert # we now have a list, one entry per line, of the stringified 5043*a466cc55SCy Schubert # contents of the appropriate section of all members of the 5044*a466cc55SCy Schubert # archive that possess that section. Heuristic: eliminate 5045*a466cc55SCy Schubert # all those that have a first or second character that is 5046*a466cc55SCy Schubert # a '.' (that is, objdump's representation of an unprintable 5047*a466cc55SCy Schubert # character.) This should work for all archives with less than 5048*a466cc55SCy Schubert # 0x302f exports -- but will fail for DLLs whose name actually 5049*a466cc55SCy Schubert # begins with a literal '.' or a single character followed by 5050*a466cc55SCy Schubert # a '.'. 5051*a466cc55SCy Schubert # 5052*a466cc55SCy Schubert # Of those that remain, print the first one. 5053*a466cc55SCy Schubert $SED -e '/^\./d;/^.\./d;q' 5054*a466cc55SCy Schubert} 5055*a466cc55SCy Schubert 5056*a466cc55SCy Schubert# func_cygming_dll_for_implib_fallback ARG 5057*a466cc55SCy Schubert# Platform-specific function to extract the 5058*a466cc55SCy Schubert# name of the DLL associated with the specified 5059*a466cc55SCy Schubert# import library ARG. 5060*a466cc55SCy Schubert# 5061*a466cc55SCy Schubert# This fallback implementation is for use when $DLLTOOL 5062*a466cc55SCy Schubert# does not support the --identify-strict option. 5063*a466cc55SCy Schubert# Invoked by eval'ing the libtool variable 5064*a466cc55SCy Schubert# $sharedlib_from_linklib_cmd 5065*a466cc55SCy Schubert# Result is available in the variable 5066*a466cc55SCy Schubert# $sharedlib_from_linklib_result 5067*a466cc55SCy Schubertfunc_cygming_dll_for_implib_fallback () 5068*a466cc55SCy Schubert{ 5069*a466cc55SCy Schubert $debug_cmd 5070*a466cc55SCy Schubert 5071*a466cc55SCy Schubert if func_cygming_gnu_implib_p "$1"; then 5072*a466cc55SCy Schubert # binutils import library 5073*a466cc55SCy Schubert sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074*a466cc55SCy Schubert elif func_cygming_ms_implib_p "$1"; then 5075*a466cc55SCy Schubert # ms-generated import library 5076*a466cc55SCy Schubert sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077*a466cc55SCy Schubert else 5078*a466cc55SCy Schubert # unknown 5079*a466cc55SCy Schubert sharedlib_from_linklib_result= 5080*a466cc55SCy Schubert fi 5081*a466cc55SCy Schubert} 5082*a466cc55SCy Schubert 5083*a466cc55SCy Schubert 5084*a466cc55SCy Schubert# func_extract_an_archive dir oldlib 5085*a466cc55SCy Schubertfunc_extract_an_archive () 5086*a466cc55SCy Schubert{ 5087*a466cc55SCy Schubert $debug_cmd 5088*a466cc55SCy Schubert 5089*a466cc55SCy Schubert f_ex_an_ar_dir=$1; shift 5090*a466cc55SCy Schubert f_ex_an_ar_oldlib=$1 5091*a466cc55SCy Schubert if test yes = "$lock_old_archive_extraction"; then 5092*a466cc55SCy Schubert lockfile=$f_ex_an_ar_oldlib.lock 5093*a466cc55SCy Schubert until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094*a466cc55SCy Schubert func_echo "Waiting for $lockfile to be removed" 5095*a466cc55SCy Schubert sleep 2 5096*a466cc55SCy Schubert done 5097*a466cc55SCy Schubert fi 5098*a466cc55SCy Schubert func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099*a466cc55SCy Schubert 'stat=$?; rm -f "$lockfile"; exit $stat' 5100*a466cc55SCy Schubert if test yes = "$lock_old_archive_extraction"; then 5101*a466cc55SCy Schubert $opt_dry_run || rm -f "$lockfile" 5102*a466cc55SCy Schubert fi 5103*a466cc55SCy Schubert if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104*a466cc55SCy Schubert : 5105*a466cc55SCy Schubert else 5106*a466cc55SCy Schubert func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107*a466cc55SCy Schubert fi 5108*a466cc55SCy Schubert} 5109*a466cc55SCy Schubert 5110*a466cc55SCy Schubert 5111*a466cc55SCy Schubert# func_extract_archives gentop oldlib ... 5112*a466cc55SCy Schubertfunc_extract_archives () 5113*a466cc55SCy Schubert{ 5114*a466cc55SCy Schubert $debug_cmd 5115*a466cc55SCy Schubert 5116*a466cc55SCy Schubert my_gentop=$1; shift 5117*a466cc55SCy Schubert my_oldlibs=${1+"$@"} 5118*a466cc55SCy Schubert my_oldobjs= 5119*a466cc55SCy Schubert my_xlib= 5120*a466cc55SCy Schubert my_xabs= 5121*a466cc55SCy Schubert my_xdir= 5122*a466cc55SCy Schubert 5123*a466cc55SCy Schubert for my_xlib in $my_oldlibs; do 5124*a466cc55SCy Schubert # Extract the objects. 5125*a466cc55SCy Schubert case $my_xlib in 5126*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127*a466cc55SCy Schubert *) my_xabs=`pwd`"/$my_xlib" ;; 5128*a466cc55SCy Schubert esac 5129*a466cc55SCy Schubert func_basename "$my_xlib" 5130*a466cc55SCy Schubert my_xlib=$func_basename_result 5131*a466cc55SCy Schubert my_xlib_u=$my_xlib 5132*a466cc55SCy Schubert while :; do 5133*a466cc55SCy Schubert case " $extracted_archives " in 5134*a466cc55SCy Schubert *" $my_xlib_u "*) 5135*a466cc55SCy Schubert func_arith $extracted_serial + 1 5136*a466cc55SCy Schubert extracted_serial=$func_arith_result 5137*a466cc55SCy Schubert my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138*a466cc55SCy Schubert *) break ;; 5139*a466cc55SCy Schubert esac 5140*a466cc55SCy Schubert done 5141*a466cc55SCy Schubert extracted_archives="$extracted_archives $my_xlib_u" 5142*a466cc55SCy Schubert my_xdir=$my_gentop/$my_xlib_u 5143*a466cc55SCy Schubert 5144*a466cc55SCy Schubert func_mkdir_p "$my_xdir" 5145*a466cc55SCy Schubert 5146*a466cc55SCy Schubert case $host in 5147*a466cc55SCy Schubert *-darwin*) 5148*a466cc55SCy Schubert func_verbose "Extracting $my_xabs" 5149*a466cc55SCy Schubert # Do not bother doing anything if just a dry run 5150*a466cc55SCy Schubert $opt_dry_run || { 5151*a466cc55SCy Schubert darwin_orig_dir=`pwd` 5152*a466cc55SCy Schubert cd $my_xdir || exit $? 5153*a466cc55SCy Schubert darwin_archive=$my_xabs 5154*a466cc55SCy Schubert darwin_curdir=`pwd` 5155*a466cc55SCy Schubert func_basename "$darwin_archive" 5156*a466cc55SCy Schubert darwin_base_archive=$func_basename_result 5157*a466cc55SCy Schubert darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158*a466cc55SCy Schubert if test -n "$darwin_arches"; then 5159*a466cc55SCy Schubert darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160*a466cc55SCy Schubert darwin_arch= 5161*a466cc55SCy Schubert func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162*a466cc55SCy Schubert for darwin_arch in $darwin_arches; do 5163*a466cc55SCy Schubert func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164*a466cc55SCy Schubert $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165*a466cc55SCy Schubert cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166*a466cc55SCy Schubert func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167*a466cc55SCy Schubert cd "$darwin_curdir" 5168*a466cc55SCy Schubert $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169*a466cc55SCy Schubert done # $darwin_arches 5170*a466cc55SCy Schubert ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171*a466cc55SCy Schubert darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172*a466cc55SCy Schubert darwin_file= 5173*a466cc55SCy Schubert darwin_files= 5174*a466cc55SCy Schubert for darwin_file in $darwin_filelist; do 5175*a466cc55SCy Schubert darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176*a466cc55SCy Schubert $LIPO -create -output "$darwin_file" $darwin_files 5177*a466cc55SCy Schubert done # $darwin_filelist 5178*a466cc55SCy Schubert $RM -rf unfat-$$ 5179*a466cc55SCy Schubert cd "$darwin_orig_dir" 5180*a466cc55SCy Schubert else 5181*a466cc55SCy Schubert cd $darwin_orig_dir 5182*a466cc55SCy Schubert func_extract_an_archive "$my_xdir" "$my_xabs" 5183*a466cc55SCy Schubert fi # $darwin_arches 5184*a466cc55SCy Schubert } # !$opt_dry_run 5185*a466cc55SCy Schubert ;; 5186*a466cc55SCy Schubert *) 5187*a466cc55SCy Schubert func_extract_an_archive "$my_xdir" "$my_xabs" 5188*a466cc55SCy Schubert ;; 5189*a466cc55SCy Schubert esac 5190*a466cc55SCy Schubert my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191*a466cc55SCy Schubert done 5192*a466cc55SCy Schubert 5193*a466cc55SCy Schubert func_extract_archives_result=$my_oldobjs 5194*a466cc55SCy Schubert} 5195*a466cc55SCy Schubert 5196*a466cc55SCy Schubert 5197*a466cc55SCy Schubert# func_emit_wrapper [arg=no] 5198*a466cc55SCy Schubert# 5199*a466cc55SCy Schubert# Emit a libtool wrapper script on stdout. 5200*a466cc55SCy Schubert# Don't directly open a file because we may want to 5201*a466cc55SCy Schubert# incorporate the script contents within a cygwin/mingw 5202*a466cc55SCy Schubert# wrapper executable. Must ONLY be called from within 5203*a466cc55SCy Schubert# func_mode_link because it depends on a number of variables 5204*a466cc55SCy Schubert# set therein. 5205*a466cc55SCy Schubert# 5206*a466cc55SCy Schubert# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207*a466cc55SCy Schubert# variable will take. If 'yes', then the emitted script 5208*a466cc55SCy Schubert# will assume that the directory where it is stored is 5209*a466cc55SCy Schubert# the $objdir directory. This is a cygwin/mingw-specific 5210*a466cc55SCy Schubert# behavior. 5211*a466cc55SCy Schubertfunc_emit_wrapper () 5212*a466cc55SCy Schubert{ 5213*a466cc55SCy Schubert func_emit_wrapper_arg1=${1-no} 5214*a466cc55SCy Schubert 5215*a466cc55SCy Schubert $ECHO "\ 5216*a466cc55SCy Schubert#! $SHELL 5217*a466cc55SCy Schubert 5218*a466cc55SCy Schubert# $output - temporary wrapper script for $objdir/$outputname 5219*a466cc55SCy Schubert# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220*a466cc55SCy Schubert# 5221*a466cc55SCy Schubert# The $output program cannot be directly executed until all the libtool 5222*a466cc55SCy Schubert# libraries that it depends on are installed. 5223*a466cc55SCy Schubert# 5224*a466cc55SCy Schubert# This wrapper script should never be moved out of the build directory. 5225*a466cc55SCy Schubert# If it is, it will not operate correctly. 5226*a466cc55SCy Schubert 5227*a466cc55SCy Schubert# Sed substitution that helps us do robust quoting. It backslashifies 5228*a466cc55SCy Schubert# metacharacters that are still active within double-quoted strings. 5229*a466cc55SCy Schubertsed_quote_subst='$sed_quote_subst' 5230*a466cc55SCy Schubert 5231*a466cc55SCy Schubert# Be Bourne compatible 5232*a466cc55SCy Schubertif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233*a466cc55SCy Schubert emulate sh 5234*a466cc55SCy Schubert NULLCMD=: 5235*a466cc55SCy Schubert # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236*a466cc55SCy Schubert # is contrary to our usage. Disable this feature. 5237*a466cc55SCy Schubert alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238*a466cc55SCy Schubert setopt NO_GLOB_SUBST 5239*a466cc55SCy Schubertelse 5240*a466cc55SCy Schubert case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241*a466cc55SCy Schubertfi 5242*a466cc55SCy SchubertBIN_SH=xpg4; export BIN_SH # for Tru64 5243*a466cc55SCy SchubertDUALCASE=1; export DUALCASE # for MKS sh 5244*a466cc55SCy Schubert 5245*a466cc55SCy Schubert# The HP-UX ksh and POSIX shell print the target directory to stdout 5246*a466cc55SCy Schubert# if CDPATH is set. 5247*a466cc55SCy Schubert(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248*a466cc55SCy Schubert 5249*a466cc55SCy Schubertrelink_command=\"$relink_command\" 5250*a466cc55SCy Schubert 5251*a466cc55SCy Schubert# This environment variable determines our operation mode. 5252*a466cc55SCy Schubertif test \"\$libtool_install_magic\" = \"$magic\"; then 5253*a466cc55SCy Schubert # install mode needs the following variables: 5254*a466cc55SCy Schubert generated_by_libtool_version='$macro_version' 5255*a466cc55SCy Schubert notinst_deplibs='$notinst_deplibs' 5256*a466cc55SCy Schubertelse 5257*a466cc55SCy Schubert # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258*a466cc55SCy Schubert if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259*a466cc55SCy Schubert file=\"\$0\"" 5260*a466cc55SCy Schubert 5261*a466cc55SCy Schubert qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262*a466cc55SCy Schubert $ECHO "\ 5263*a466cc55SCy Schubert 5264*a466cc55SCy Schubert# A function that is used when there is no print builtin or printf. 5265*a466cc55SCy Schubertfunc_fallback_echo () 5266*a466cc55SCy Schubert{ 5267*a466cc55SCy Schubert eval 'cat <<_LTECHO_EOF 5268*a466cc55SCy Schubert\$1 5269*a466cc55SCy Schubert_LTECHO_EOF' 5270*a466cc55SCy Schubert} 5271*a466cc55SCy Schubert ECHO=\"$qECHO\" 5272*a466cc55SCy Schubert fi 5273*a466cc55SCy Schubert 5274*a466cc55SCy Schubert# Very basic option parsing. These options are (a) specific to 5275*a466cc55SCy Schubert# the libtool wrapper, (b) are identical between the wrapper 5276*a466cc55SCy Schubert# /script/ and the wrapper /executable/ that is used only on 5277*a466cc55SCy Schubert# windows platforms, and (c) all begin with the string "--lt-" 5278*a466cc55SCy Schubert# (application programs are unlikely to have options that match 5279*a466cc55SCy Schubert# this pattern). 5280*a466cc55SCy Schubert# 5281*a466cc55SCy Schubert# There are only two supported options: --lt-debug and 5282*a466cc55SCy Schubert# --lt-dump-script. There is, deliberately, no --lt-help. 5283*a466cc55SCy Schubert# 5284*a466cc55SCy Schubert# The first argument to this parsing function should be the 5285*a466cc55SCy Schubert# script's $0 value, followed by "$@". 5286*a466cc55SCy Schubertlt_option_debug= 5287*a466cc55SCy Schubertfunc_parse_lt_options () 5288*a466cc55SCy Schubert{ 5289*a466cc55SCy Schubert lt_script_arg0=\$0 5290*a466cc55SCy Schubert shift 5291*a466cc55SCy Schubert for lt_opt 5292*a466cc55SCy Schubert do 5293*a466cc55SCy Schubert case \"\$lt_opt\" in 5294*a466cc55SCy Schubert --lt-debug) lt_option_debug=1 ;; 5295*a466cc55SCy Schubert --lt-dump-script) 5296*a466cc55SCy Schubert lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297*a466cc55SCy Schubert test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298*a466cc55SCy Schubert lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299*a466cc55SCy Schubert cat \"\$lt_dump_D/\$lt_dump_F\" 5300*a466cc55SCy Schubert exit 0 5301*a466cc55SCy Schubert ;; 5302*a466cc55SCy Schubert --lt-*) 5303*a466cc55SCy Schubert \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304*a466cc55SCy Schubert exit 1 5305*a466cc55SCy Schubert ;; 5306*a466cc55SCy Schubert esac 5307*a466cc55SCy Schubert done 5308*a466cc55SCy Schubert 5309*a466cc55SCy Schubert # Print the debug banner immediately: 5310*a466cc55SCy Schubert if test -n \"\$lt_option_debug\"; then 5311*a466cc55SCy Schubert echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312*a466cc55SCy Schubert fi 5313*a466cc55SCy Schubert} 5314*a466cc55SCy Schubert 5315*a466cc55SCy Schubert# Used when --lt-debug. Prints its arguments to stdout 5316*a466cc55SCy Schubert# (redirection is the responsibility of the caller) 5317*a466cc55SCy Schubertfunc_lt_dump_args () 5318*a466cc55SCy Schubert{ 5319*a466cc55SCy Schubert lt_dump_args_N=1; 5320*a466cc55SCy Schubert for lt_arg 5321*a466cc55SCy Schubert do 5322*a466cc55SCy Schubert \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323*a466cc55SCy Schubert lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324*a466cc55SCy Schubert done 5325*a466cc55SCy Schubert} 5326*a466cc55SCy Schubert 5327*a466cc55SCy Schubert# Core function for launching the target application 5328*a466cc55SCy Schubertfunc_exec_program_core () 5329*a466cc55SCy Schubert{ 5330*a466cc55SCy Schubert" 5331*a466cc55SCy Schubert case $host in 5332*a466cc55SCy Schubert # Backslashes separate directories on plain windows 5333*a466cc55SCy Schubert *-*-mingw | *-*-os2* | *-cegcc*) 5334*a466cc55SCy Schubert $ECHO "\ 5335*a466cc55SCy Schubert if test -n \"\$lt_option_debug\"; then 5336*a466cc55SCy Schubert \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337*a466cc55SCy Schubert func_lt_dump_args \${1+\"\$@\"} 1>&2 5338*a466cc55SCy Schubert fi 5339*a466cc55SCy Schubert exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340*a466cc55SCy Schubert" 5341*a466cc55SCy Schubert ;; 5342*a466cc55SCy Schubert 5343*a466cc55SCy Schubert *) 5344*a466cc55SCy Schubert $ECHO "\ 5345*a466cc55SCy Schubert if test -n \"\$lt_option_debug\"; then 5346*a466cc55SCy Schubert \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347*a466cc55SCy Schubert func_lt_dump_args \${1+\"\$@\"} 1>&2 5348*a466cc55SCy Schubert fi 5349*a466cc55SCy Schubert exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350*a466cc55SCy Schubert" 5351*a466cc55SCy Schubert ;; 5352*a466cc55SCy Schubert esac 5353*a466cc55SCy Schubert $ECHO "\ 5354*a466cc55SCy Schubert \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355*a466cc55SCy Schubert exit 1 5356*a466cc55SCy Schubert} 5357*a466cc55SCy Schubert 5358*a466cc55SCy Schubert# A function to encapsulate launching the target application 5359*a466cc55SCy Schubert# Strips options in the --lt-* namespace from \$@ and 5360*a466cc55SCy Schubert# launches target application with the remaining arguments. 5361*a466cc55SCy Schubertfunc_exec_program () 5362*a466cc55SCy Schubert{ 5363*a466cc55SCy Schubert case \" \$* \" in 5364*a466cc55SCy Schubert *\\ --lt-*) 5365*a466cc55SCy Schubert for lt_wr_arg 5366*a466cc55SCy Schubert do 5367*a466cc55SCy Schubert case \$lt_wr_arg in 5368*a466cc55SCy Schubert --lt-*) ;; 5369*a466cc55SCy Schubert *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370*a466cc55SCy Schubert esac 5371*a466cc55SCy Schubert shift 5372*a466cc55SCy Schubert done ;; 5373*a466cc55SCy Schubert esac 5374*a466cc55SCy Schubert func_exec_program_core \${1+\"\$@\"} 5375*a466cc55SCy Schubert} 5376*a466cc55SCy Schubert 5377*a466cc55SCy Schubert # Parse options 5378*a466cc55SCy Schubert func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379*a466cc55SCy Schubert 5380*a466cc55SCy Schubert # Find the directory that this script lives in. 5381*a466cc55SCy Schubert thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382*a466cc55SCy Schubert test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383*a466cc55SCy Schubert 5384*a466cc55SCy Schubert # Follow symbolic links until we get to the real thisdir. 5385*a466cc55SCy Schubert file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386*a466cc55SCy Schubert while test -n \"\$file\"; do 5387*a466cc55SCy Schubert destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388*a466cc55SCy Schubert 5389*a466cc55SCy Schubert # If there was a directory component, then change thisdir. 5390*a466cc55SCy Schubert if test \"x\$destdir\" != \"x\$file\"; then 5391*a466cc55SCy Schubert case \"\$destdir\" in 5392*a466cc55SCy Schubert [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393*a466cc55SCy Schubert *) thisdir=\"\$thisdir/\$destdir\" ;; 5394*a466cc55SCy Schubert esac 5395*a466cc55SCy Schubert fi 5396*a466cc55SCy Schubert 5397*a466cc55SCy Schubert file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398*a466cc55SCy Schubert file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399*a466cc55SCy Schubert done 5400*a466cc55SCy Schubert 5401*a466cc55SCy Schubert # Usually 'no', except on cygwin/mingw when embedded into 5402*a466cc55SCy Schubert # the cwrapper. 5403*a466cc55SCy Schubert WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404*a466cc55SCy Schubert if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405*a466cc55SCy Schubert # special case for '.' 5406*a466cc55SCy Schubert if test \"\$thisdir\" = \".\"; then 5407*a466cc55SCy Schubert thisdir=\`pwd\` 5408*a466cc55SCy Schubert fi 5409*a466cc55SCy Schubert # remove .libs from thisdir 5410*a466cc55SCy Schubert case \"\$thisdir\" in 5411*a466cc55SCy Schubert *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412*a466cc55SCy Schubert $objdir ) thisdir=. ;; 5413*a466cc55SCy Schubert esac 5414*a466cc55SCy Schubert fi 5415*a466cc55SCy Schubert 5416*a466cc55SCy Schubert # Try to get the absolute directory name. 5417*a466cc55SCy Schubert absdir=\`cd \"\$thisdir\" && pwd\` 5418*a466cc55SCy Schubert test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419*a466cc55SCy Schubert" 5420*a466cc55SCy Schubert 5421*a466cc55SCy Schubert if test yes = "$fast_install"; then 5422*a466cc55SCy Schubert $ECHO "\ 5423*a466cc55SCy Schubert program=lt-'$outputname'$exeext 5424*a466cc55SCy Schubert progdir=\"\$thisdir/$objdir\" 5425*a466cc55SCy Schubert 5426*a466cc55SCy Schubert if test ! -f \"\$progdir/\$program\" || 5427*a466cc55SCy Schubert { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428*a466cc55SCy Schubert test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429*a466cc55SCy Schubert 5430*a466cc55SCy Schubert file=\"\$\$-\$program\" 5431*a466cc55SCy Schubert 5432*a466cc55SCy Schubert if test ! -d \"\$progdir\"; then 5433*a466cc55SCy Schubert $MKDIR \"\$progdir\" 5434*a466cc55SCy Schubert else 5435*a466cc55SCy Schubert $RM \"\$progdir/\$file\" 5436*a466cc55SCy Schubert fi" 5437*a466cc55SCy Schubert 5438*a466cc55SCy Schubert $ECHO "\ 5439*a466cc55SCy Schubert 5440*a466cc55SCy Schubert # relink executable if necessary 5441*a466cc55SCy Schubert if test -n \"\$relink_command\"; then 5442*a466cc55SCy Schubert if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443*a466cc55SCy Schubert else 5444*a466cc55SCy Schubert \$ECHO \"\$relink_command_output\" >&2 5445*a466cc55SCy Schubert $RM \"\$progdir/\$file\" 5446*a466cc55SCy Schubert exit 1 5447*a466cc55SCy Schubert fi 5448*a466cc55SCy Schubert fi 5449*a466cc55SCy Schubert 5450*a466cc55SCy Schubert $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451*a466cc55SCy Schubert { $RM \"\$progdir/\$program\"; 5452*a466cc55SCy Schubert $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453*a466cc55SCy Schubert $RM \"\$progdir/\$file\" 5454*a466cc55SCy Schubert fi" 5455*a466cc55SCy Schubert else 5456*a466cc55SCy Schubert $ECHO "\ 5457*a466cc55SCy Schubert program='$outputname' 5458*a466cc55SCy Schubert progdir=\"\$thisdir/$objdir\" 5459*a466cc55SCy Schubert" 5460*a466cc55SCy Schubert fi 5461*a466cc55SCy Schubert 5462*a466cc55SCy Schubert $ECHO "\ 5463*a466cc55SCy Schubert 5464*a466cc55SCy Schubert if test -f \"\$progdir/\$program\"; then" 5465*a466cc55SCy Schubert 5466*a466cc55SCy Schubert # fixup the dll searchpath if we need to. 5467*a466cc55SCy Schubert # 5468*a466cc55SCy Schubert # Fix the DLL searchpath if we need to. Do this before prepending 5469*a466cc55SCy Schubert # to shlibpath, because on Windows, both are PATH and uninstalled 5470*a466cc55SCy Schubert # libraries must come first. 5471*a466cc55SCy Schubert if test -n "$dllsearchpath"; then 5472*a466cc55SCy Schubert $ECHO "\ 5473*a466cc55SCy Schubert # Add the dll search path components to the executable PATH 5474*a466cc55SCy Schubert PATH=$dllsearchpath:\$PATH 5475*a466cc55SCy Schubert" 5476*a466cc55SCy Schubert fi 5477*a466cc55SCy Schubert 5478*a466cc55SCy Schubert # Export our shlibpath_var if we have one. 5479*a466cc55SCy Schubert if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480*a466cc55SCy Schubert $ECHO "\ 5481*a466cc55SCy Schubert # Add our own library path to $shlibpath_var 5482*a466cc55SCy Schubert $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483*a466cc55SCy Schubert 5484*a466cc55SCy Schubert # Some systems cannot cope with colon-terminated $shlibpath_var 5485*a466cc55SCy Schubert # The second colon is a workaround for a bug in BeOS R4 sed 5486*a466cc55SCy Schubert $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487*a466cc55SCy Schubert 5488*a466cc55SCy Schubert export $shlibpath_var 5489*a466cc55SCy Schubert" 5490*a466cc55SCy Schubert fi 5491*a466cc55SCy Schubert 5492*a466cc55SCy Schubert $ECHO "\ 5493*a466cc55SCy Schubert if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494*a466cc55SCy Schubert # Run the actual program with our arguments. 5495*a466cc55SCy Schubert func_exec_program \${1+\"\$@\"} 5496*a466cc55SCy Schubert fi 5497*a466cc55SCy Schubert else 5498*a466cc55SCy Schubert # The program doesn't exist. 5499*a466cc55SCy Schubert \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500*a466cc55SCy Schubert \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501*a466cc55SCy Schubert \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502*a466cc55SCy Schubert exit 1 5503*a466cc55SCy Schubert fi 5504*a466cc55SCy Schubertfi\ 5505*a466cc55SCy Schubert" 5506*a466cc55SCy Schubert} 5507*a466cc55SCy Schubert 5508*a466cc55SCy Schubert 5509*a466cc55SCy Schubert# func_emit_cwrapperexe_src 5510*a466cc55SCy Schubert# emit the source code for a wrapper executable on stdout 5511*a466cc55SCy Schubert# Must ONLY be called from within func_mode_link because 5512*a466cc55SCy Schubert# it depends on a number of variable set therein. 5513*a466cc55SCy Schubertfunc_emit_cwrapperexe_src () 5514*a466cc55SCy Schubert{ 5515*a466cc55SCy Schubert cat <<EOF 5516*a466cc55SCy Schubert 5517*a466cc55SCy Schubert/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518*a466cc55SCy Schubert Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519*a466cc55SCy Schubert 5520*a466cc55SCy Schubert The $output program cannot be directly executed until all the libtool 5521*a466cc55SCy Schubert libraries that it depends on are installed. 5522*a466cc55SCy Schubert 5523*a466cc55SCy Schubert This wrapper executable should never be moved out of the build directory. 5524*a466cc55SCy Schubert If it is, it will not operate correctly. 5525*a466cc55SCy Schubert*/ 5526*a466cc55SCy SchubertEOF 5527*a466cc55SCy Schubert cat <<"EOF" 5528*a466cc55SCy Schubert#ifdef _MSC_VER 5529*a466cc55SCy Schubert# define _CRT_SECURE_NO_DEPRECATE 1 5530*a466cc55SCy Schubert#endif 5531*a466cc55SCy Schubert#include <stdio.h> 5532*a466cc55SCy Schubert#include <stdlib.h> 5533*a466cc55SCy Schubert#ifdef _MSC_VER 5534*a466cc55SCy Schubert# include <direct.h> 5535*a466cc55SCy Schubert# include <process.h> 5536*a466cc55SCy Schubert# include <io.h> 5537*a466cc55SCy Schubert#else 5538*a466cc55SCy Schubert# include <unistd.h> 5539*a466cc55SCy Schubert# include <stdint.h> 5540*a466cc55SCy Schubert# ifdef __CYGWIN__ 5541*a466cc55SCy Schubert# include <io.h> 5542*a466cc55SCy Schubert# endif 5543*a466cc55SCy Schubert#endif 5544*a466cc55SCy Schubert#include <malloc.h> 5545*a466cc55SCy Schubert#include <stdarg.h> 5546*a466cc55SCy Schubert#include <assert.h> 5547*a466cc55SCy Schubert#include <string.h> 5548*a466cc55SCy Schubert#include <ctype.h> 5549*a466cc55SCy Schubert#include <errno.h> 5550*a466cc55SCy Schubert#include <fcntl.h> 5551*a466cc55SCy Schubert#include <sys/stat.h> 5552*a466cc55SCy Schubert 5553*a466cc55SCy Schubert#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554*a466cc55SCy Schubert 5555*a466cc55SCy Schubert/* declarations of non-ANSI functions */ 5556*a466cc55SCy Schubert#if defined __MINGW32__ 5557*a466cc55SCy Schubert# ifdef __STRICT_ANSI__ 5558*a466cc55SCy Schubertint _putenv (const char *); 5559*a466cc55SCy Schubert# endif 5560*a466cc55SCy Schubert#elif defined __CYGWIN__ 5561*a466cc55SCy Schubert# ifdef __STRICT_ANSI__ 5562*a466cc55SCy Schubertchar *realpath (const char *, char *); 5563*a466cc55SCy Schubertint putenv (char *); 5564*a466cc55SCy Schubertint setenv (const char *, const char *, int); 5565*a466cc55SCy Schubert# endif 5566*a466cc55SCy Schubert/* #elif defined other_platform || defined ... */ 5567*a466cc55SCy Schubert#endif 5568*a466cc55SCy Schubert 5569*a466cc55SCy Schubert/* portability defines, excluding path handling macros */ 5570*a466cc55SCy Schubert#if defined _MSC_VER 5571*a466cc55SCy Schubert# define setmode _setmode 5572*a466cc55SCy Schubert# define stat _stat 5573*a466cc55SCy Schubert# define chmod _chmod 5574*a466cc55SCy Schubert# define getcwd _getcwd 5575*a466cc55SCy Schubert# define putenv _putenv 5576*a466cc55SCy Schubert# define S_IXUSR _S_IEXEC 5577*a466cc55SCy Schubert#elif defined __MINGW32__ 5578*a466cc55SCy Schubert# define setmode _setmode 5579*a466cc55SCy Schubert# define stat _stat 5580*a466cc55SCy Schubert# define chmod _chmod 5581*a466cc55SCy Schubert# define getcwd _getcwd 5582*a466cc55SCy Schubert# define putenv _putenv 5583*a466cc55SCy Schubert#elif defined __CYGWIN__ 5584*a466cc55SCy Schubert# define HAVE_SETENV 5585*a466cc55SCy Schubert# define FOPEN_WB "wb" 5586*a466cc55SCy Schubert/* #elif defined other platforms ... */ 5587*a466cc55SCy Schubert#endif 5588*a466cc55SCy Schubert 5589*a466cc55SCy Schubert#if defined PATH_MAX 5590*a466cc55SCy Schubert# define LT_PATHMAX PATH_MAX 5591*a466cc55SCy Schubert#elif defined MAXPATHLEN 5592*a466cc55SCy Schubert# define LT_PATHMAX MAXPATHLEN 5593*a466cc55SCy Schubert#else 5594*a466cc55SCy Schubert# define LT_PATHMAX 1024 5595*a466cc55SCy Schubert#endif 5596*a466cc55SCy Schubert 5597*a466cc55SCy Schubert#ifndef S_IXOTH 5598*a466cc55SCy Schubert# define S_IXOTH 0 5599*a466cc55SCy Schubert#endif 5600*a466cc55SCy Schubert#ifndef S_IXGRP 5601*a466cc55SCy Schubert# define S_IXGRP 0 5602*a466cc55SCy Schubert#endif 5603*a466cc55SCy Schubert 5604*a466cc55SCy Schubert/* path handling portability macros */ 5605*a466cc55SCy Schubert#ifndef DIR_SEPARATOR 5606*a466cc55SCy Schubert# define DIR_SEPARATOR '/' 5607*a466cc55SCy Schubert# define PATH_SEPARATOR ':' 5608*a466cc55SCy Schubert#endif 5609*a466cc55SCy Schubert 5610*a466cc55SCy Schubert#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611*a466cc55SCy Schubert defined __OS2__ 5612*a466cc55SCy Schubert# define HAVE_DOS_BASED_FILE_SYSTEM 5613*a466cc55SCy Schubert# define FOPEN_WB "wb" 5614*a466cc55SCy Schubert# ifndef DIR_SEPARATOR_2 5615*a466cc55SCy Schubert# define DIR_SEPARATOR_2 '\\' 5616*a466cc55SCy Schubert# endif 5617*a466cc55SCy Schubert# ifndef PATH_SEPARATOR_2 5618*a466cc55SCy Schubert# define PATH_SEPARATOR_2 ';' 5619*a466cc55SCy Schubert# endif 5620*a466cc55SCy Schubert#endif 5621*a466cc55SCy Schubert 5622*a466cc55SCy Schubert#ifndef DIR_SEPARATOR_2 5623*a466cc55SCy Schubert# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624*a466cc55SCy Schubert#else /* DIR_SEPARATOR_2 */ 5625*a466cc55SCy Schubert# define IS_DIR_SEPARATOR(ch) \ 5626*a466cc55SCy Schubert (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627*a466cc55SCy Schubert#endif /* DIR_SEPARATOR_2 */ 5628*a466cc55SCy Schubert 5629*a466cc55SCy Schubert#ifndef PATH_SEPARATOR_2 5630*a466cc55SCy Schubert# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631*a466cc55SCy Schubert#else /* PATH_SEPARATOR_2 */ 5632*a466cc55SCy Schubert# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633*a466cc55SCy Schubert#endif /* PATH_SEPARATOR_2 */ 5634*a466cc55SCy Schubert 5635*a466cc55SCy Schubert#ifndef FOPEN_WB 5636*a466cc55SCy Schubert# define FOPEN_WB "w" 5637*a466cc55SCy Schubert#endif 5638*a466cc55SCy Schubert#ifndef _O_BINARY 5639*a466cc55SCy Schubert# define _O_BINARY 0 5640*a466cc55SCy Schubert#endif 5641*a466cc55SCy Schubert 5642*a466cc55SCy Schubert#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643*a466cc55SCy Schubert#define XFREE(stale) do { \ 5644*a466cc55SCy Schubert if (stale) { free (stale); stale = 0; } \ 5645*a466cc55SCy Schubert} while (0) 5646*a466cc55SCy Schubert 5647*a466cc55SCy Schubert#if defined LT_DEBUGWRAPPER 5648*a466cc55SCy Schubertstatic int lt_debug = 1; 5649*a466cc55SCy Schubert#else 5650*a466cc55SCy Schubertstatic int lt_debug = 0; 5651*a466cc55SCy Schubert#endif 5652*a466cc55SCy Schubert 5653*a466cc55SCy Schubertconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654*a466cc55SCy Schubert 5655*a466cc55SCy Schubertvoid *xmalloc (size_t num); 5656*a466cc55SCy Schubertchar *xstrdup (const char *string); 5657*a466cc55SCy Schubertconst char *base_name (const char *name); 5658*a466cc55SCy Schubertchar *find_executable (const char *wrapper); 5659*a466cc55SCy Schubertchar *chase_symlinks (const char *pathspec); 5660*a466cc55SCy Schubertint make_executable (const char *path); 5661*a466cc55SCy Schubertint check_executable (const char *path); 5662*a466cc55SCy Schubertchar *strendzap (char *str, const char *pat); 5663*a466cc55SCy Schubertvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664*a466cc55SCy Schubertvoid lt_fatal (const char *file, int line, const char *message, ...); 5665*a466cc55SCy Schubertstatic const char *nonnull (const char *s); 5666*a466cc55SCy Schubertstatic const char *nonempty (const char *s); 5667*a466cc55SCy Schubertvoid lt_setenv (const char *name, const char *value); 5668*a466cc55SCy Schubertchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669*a466cc55SCy Schubertvoid lt_update_exe_path (const char *name, const char *value); 5670*a466cc55SCy Schubertvoid lt_update_lib_path (const char *name, const char *value); 5671*a466cc55SCy Schubertchar **prepare_spawn (char **argv); 5672*a466cc55SCy Schubertvoid lt_dump_script (FILE *f); 5673*a466cc55SCy SchubertEOF 5674*a466cc55SCy Schubert 5675*a466cc55SCy Schubert cat <<EOF 5676*a466cc55SCy Schubert#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677*a466cc55SCy Schubert# define externally_visible volatile 5678*a466cc55SCy Schubert#else 5679*a466cc55SCy Schubert# define externally_visible __attribute__((externally_visible)) volatile 5680*a466cc55SCy Schubert#endif 5681*a466cc55SCy Schubertexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682*a466cc55SCy Schubertconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683*a466cc55SCy SchubertEOF 5684*a466cc55SCy Schubert 5685*a466cc55SCy Schubert if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686*a466cc55SCy Schubert func_to_host_path "$temp_rpath" 5687*a466cc55SCy Schubert cat <<EOF 5688*a466cc55SCy Schubertconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689*a466cc55SCy SchubertEOF 5690*a466cc55SCy Schubert else 5691*a466cc55SCy Schubert cat <<"EOF" 5692*a466cc55SCy Schubertconst char * LIB_PATH_VALUE = ""; 5693*a466cc55SCy SchubertEOF 5694*a466cc55SCy Schubert fi 5695*a466cc55SCy Schubert 5696*a466cc55SCy Schubert if test -n "$dllsearchpath"; then 5697*a466cc55SCy Schubert func_to_host_path "$dllsearchpath:" 5698*a466cc55SCy Schubert cat <<EOF 5699*a466cc55SCy Schubertconst char * EXE_PATH_VARNAME = "PATH"; 5700*a466cc55SCy Schubertconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701*a466cc55SCy SchubertEOF 5702*a466cc55SCy Schubert else 5703*a466cc55SCy Schubert cat <<"EOF" 5704*a466cc55SCy Schubertconst char * EXE_PATH_VARNAME = ""; 5705*a466cc55SCy Schubertconst char * EXE_PATH_VALUE = ""; 5706*a466cc55SCy SchubertEOF 5707*a466cc55SCy Schubert fi 5708*a466cc55SCy Schubert 5709*a466cc55SCy Schubert if test yes = "$fast_install"; then 5710*a466cc55SCy Schubert cat <<EOF 5711*a466cc55SCy Schubertconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712*a466cc55SCy SchubertEOF 5713*a466cc55SCy Schubert else 5714*a466cc55SCy Schubert cat <<EOF 5715*a466cc55SCy Schubertconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716*a466cc55SCy SchubertEOF 5717*a466cc55SCy Schubert fi 5718*a466cc55SCy Schubert 5719*a466cc55SCy Schubert 5720*a466cc55SCy Schubert cat <<"EOF" 5721*a466cc55SCy Schubert 5722*a466cc55SCy Schubert#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723*a466cc55SCy Schubert 5724*a466cc55SCy Schubertstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725*a466cc55SCy Schubertstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726*a466cc55SCy Schubertstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727*a466cc55SCy Schubert 5728*a466cc55SCy Schubertint 5729*a466cc55SCy Schubertmain (int argc, char *argv[]) 5730*a466cc55SCy Schubert{ 5731*a466cc55SCy Schubert char **newargz; 5732*a466cc55SCy Schubert int newargc; 5733*a466cc55SCy Schubert char *tmp_pathspec; 5734*a466cc55SCy Schubert char *actual_cwrapper_path; 5735*a466cc55SCy Schubert char *actual_cwrapper_name; 5736*a466cc55SCy Schubert char *target_name; 5737*a466cc55SCy Schubert char *lt_argv_zero; 5738*a466cc55SCy Schubert int rval = 127; 5739*a466cc55SCy Schubert 5740*a466cc55SCy Schubert int i; 5741*a466cc55SCy Schubert 5742*a466cc55SCy Schubert program_name = (char *) xstrdup (base_name (argv[0])); 5743*a466cc55SCy Schubert newargz = XMALLOC (char *, (size_t) argc + 1); 5744*a466cc55SCy Schubert 5745*a466cc55SCy Schubert /* very simple arg parsing; don't want to rely on getopt 5746*a466cc55SCy Schubert * also, copy all non cwrapper options to newargz, except 5747*a466cc55SCy Schubert * argz[0], which is handled differently 5748*a466cc55SCy Schubert */ 5749*a466cc55SCy Schubert newargc=0; 5750*a466cc55SCy Schubert for (i = 1; i < argc; i++) 5751*a466cc55SCy Schubert { 5752*a466cc55SCy Schubert if (STREQ (argv[i], dumpscript_opt)) 5753*a466cc55SCy Schubert { 5754*a466cc55SCy SchubertEOF 5755*a466cc55SCy Schubert case $host in 5756*a466cc55SCy Schubert *mingw* | *cygwin* ) 5757*a466cc55SCy Schubert # make stdout use "unix" line endings 5758*a466cc55SCy Schubert echo " setmode(1,_O_BINARY);" 5759*a466cc55SCy Schubert ;; 5760*a466cc55SCy Schubert esac 5761*a466cc55SCy Schubert 5762*a466cc55SCy Schubert cat <<"EOF" 5763*a466cc55SCy Schubert lt_dump_script (stdout); 5764*a466cc55SCy Schubert return 0; 5765*a466cc55SCy Schubert } 5766*a466cc55SCy Schubert if (STREQ (argv[i], debug_opt)) 5767*a466cc55SCy Schubert { 5768*a466cc55SCy Schubert lt_debug = 1; 5769*a466cc55SCy Schubert continue; 5770*a466cc55SCy Schubert } 5771*a466cc55SCy Schubert if (STREQ (argv[i], ltwrapper_option_prefix)) 5772*a466cc55SCy Schubert { 5773*a466cc55SCy Schubert /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774*a466cc55SCy Schubert namespace, but it is not one of the ones we know about and 5775*a466cc55SCy Schubert have already dealt with, above (inluding dump-script), then 5776*a466cc55SCy Schubert report an error. Otherwise, targets might begin to believe 5777*a466cc55SCy Schubert they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778*a466cc55SCy Schubert namespace. The first time any user complains about this, we'll 5779*a466cc55SCy Schubert need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780*a466cc55SCy Schubert or a configure.ac-settable value. 5781*a466cc55SCy Schubert */ 5782*a466cc55SCy Schubert lt_fatal (__FILE__, __LINE__, 5783*a466cc55SCy Schubert "unrecognized %s option: '%s'", 5784*a466cc55SCy Schubert ltwrapper_option_prefix, argv[i]); 5785*a466cc55SCy Schubert } 5786*a466cc55SCy Schubert /* otherwise ... */ 5787*a466cc55SCy Schubert newargz[++newargc] = xstrdup (argv[i]); 5788*a466cc55SCy Schubert } 5789*a466cc55SCy Schubert newargz[++newargc] = NULL; 5790*a466cc55SCy Schubert 5791*a466cc55SCy SchubertEOF 5792*a466cc55SCy Schubert cat <<EOF 5793*a466cc55SCy Schubert /* The GNU banner must be the first non-error debug message */ 5794*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795*a466cc55SCy SchubertEOF 5796*a466cc55SCy Schubert cat <<"EOF" 5797*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799*a466cc55SCy Schubert 5800*a466cc55SCy Schubert tmp_pathspec = find_executable (argv[0]); 5801*a466cc55SCy Schubert if (tmp_pathspec == NULL) 5802*a466cc55SCy Schubert lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 5804*a466cc55SCy Schubert "(main) found exe (before symlink chase) at: %s\n", 5805*a466cc55SCy Schubert tmp_pathspec); 5806*a466cc55SCy Schubert 5807*a466cc55SCy Schubert actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 5809*a466cc55SCy Schubert "(main) found exe (after symlink chase) at: %s\n", 5810*a466cc55SCy Schubert actual_cwrapper_path); 5811*a466cc55SCy Schubert XFREE (tmp_pathspec); 5812*a466cc55SCy Schubert 5813*a466cc55SCy Schubert actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814*a466cc55SCy Schubert strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815*a466cc55SCy Schubert 5816*a466cc55SCy Schubert /* wrapper name transforms */ 5817*a466cc55SCy Schubert strendzap (actual_cwrapper_name, ".exe"); 5818*a466cc55SCy Schubert tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819*a466cc55SCy Schubert XFREE (actual_cwrapper_name); 5820*a466cc55SCy Schubert actual_cwrapper_name = tmp_pathspec; 5821*a466cc55SCy Schubert tmp_pathspec = 0; 5822*a466cc55SCy Schubert 5823*a466cc55SCy Schubert /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824*a466cc55SCy Schubert target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825*a466cc55SCy Schubert strendzap (target_name, ".exe"); 5826*a466cc55SCy Schubert tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827*a466cc55SCy Schubert XFREE (target_name); 5828*a466cc55SCy Schubert target_name = tmp_pathspec; 5829*a466cc55SCy Schubert tmp_pathspec = 0; 5830*a466cc55SCy Schubert 5831*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 5832*a466cc55SCy Schubert "(main) libtool target name: %s\n", 5833*a466cc55SCy Schubert target_name); 5834*a466cc55SCy SchubertEOF 5835*a466cc55SCy Schubert 5836*a466cc55SCy Schubert cat <<EOF 5837*a466cc55SCy Schubert newargz[0] = 5838*a466cc55SCy Schubert XMALLOC (char, (strlen (actual_cwrapper_path) + 5839*a466cc55SCy Schubert strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840*a466cc55SCy Schubert strcpy (newargz[0], actual_cwrapper_path); 5841*a466cc55SCy Schubert strcat (newargz[0], "$objdir"); 5842*a466cc55SCy Schubert strcat (newargz[0], "/"); 5843*a466cc55SCy SchubertEOF 5844*a466cc55SCy Schubert 5845*a466cc55SCy Schubert cat <<"EOF" 5846*a466cc55SCy Schubert /* stop here, and copy so we don't have to do this twice */ 5847*a466cc55SCy Schubert tmp_pathspec = xstrdup (newargz[0]); 5848*a466cc55SCy Schubert 5849*a466cc55SCy Schubert /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850*a466cc55SCy Schubert strcat (newargz[0], actual_cwrapper_name); 5851*a466cc55SCy Schubert 5852*a466cc55SCy Schubert /* DO want the lt- prefix here if it exists, so use target_name */ 5853*a466cc55SCy Schubert lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854*a466cc55SCy Schubert XFREE (tmp_pathspec); 5855*a466cc55SCy Schubert tmp_pathspec = NULL; 5856*a466cc55SCy SchubertEOF 5857*a466cc55SCy Schubert 5858*a466cc55SCy Schubert case $host_os in 5859*a466cc55SCy Schubert mingw*) 5860*a466cc55SCy Schubert cat <<"EOF" 5861*a466cc55SCy Schubert { 5862*a466cc55SCy Schubert char* p; 5863*a466cc55SCy Schubert while ((p = strchr (newargz[0], '\\')) != NULL) 5864*a466cc55SCy Schubert { 5865*a466cc55SCy Schubert *p = '/'; 5866*a466cc55SCy Schubert } 5867*a466cc55SCy Schubert while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868*a466cc55SCy Schubert { 5869*a466cc55SCy Schubert *p = '/'; 5870*a466cc55SCy Schubert } 5871*a466cc55SCy Schubert } 5872*a466cc55SCy SchubertEOF 5873*a466cc55SCy Schubert ;; 5874*a466cc55SCy Schubert esac 5875*a466cc55SCy Schubert 5876*a466cc55SCy Schubert cat <<"EOF" 5877*a466cc55SCy Schubert XFREE (target_name); 5878*a466cc55SCy Schubert XFREE (actual_cwrapper_path); 5879*a466cc55SCy Schubert XFREE (actual_cwrapper_name); 5880*a466cc55SCy Schubert 5881*a466cc55SCy Schubert lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882*a466cc55SCy Schubert lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883*a466cc55SCy Schubert /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884*a466cc55SCy Schubert be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885*a466cc55SCy Schubert because on Windows, both *_VARNAMEs are PATH but uninstalled 5886*a466cc55SCy Schubert libraries must come first. */ 5887*a466cc55SCy Schubert lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888*a466cc55SCy Schubert lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889*a466cc55SCy Schubert 5890*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891*a466cc55SCy Schubert nonnull (lt_argv_zero)); 5892*a466cc55SCy Schubert for (i = 0; i < newargc; i++) 5893*a466cc55SCy Schubert { 5894*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895*a466cc55SCy Schubert i, nonnull (newargz[i])); 5896*a466cc55SCy Schubert } 5897*a466cc55SCy Schubert 5898*a466cc55SCy SchubertEOF 5899*a466cc55SCy Schubert 5900*a466cc55SCy Schubert case $host_os in 5901*a466cc55SCy Schubert mingw*) 5902*a466cc55SCy Schubert cat <<"EOF" 5903*a466cc55SCy Schubert /* execv doesn't actually work on mingw as expected on unix */ 5904*a466cc55SCy Schubert newargz = prepare_spawn (newargz); 5905*a466cc55SCy Schubert rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906*a466cc55SCy Schubert if (rval == -1) 5907*a466cc55SCy Schubert { 5908*a466cc55SCy Schubert /* failed to start process */ 5909*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 5910*a466cc55SCy Schubert "(main) failed to launch target \"%s\": %s\n", 5911*a466cc55SCy Schubert lt_argv_zero, nonnull (strerror (errno))); 5912*a466cc55SCy Schubert return 127; 5913*a466cc55SCy Schubert } 5914*a466cc55SCy Schubert return rval; 5915*a466cc55SCy SchubertEOF 5916*a466cc55SCy Schubert ;; 5917*a466cc55SCy Schubert *) 5918*a466cc55SCy Schubert cat <<"EOF" 5919*a466cc55SCy Schubert execv (lt_argv_zero, newargz); 5920*a466cc55SCy Schubert return rval; /* =127, but avoids unused variable warning */ 5921*a466cc55SCy SchubertEOF 5922*a466cc55SCy Schubert ;; 5923*a466cc55SCy Schubert esac 5924*a466cc55SCy Schubert 5925*a466cc55SCy Schubert cat <<"EOF" 5926*a466cc55SCy Schubert} 5927*a466cc55SCy Schubert 5928*a466cc55SCy Schubertvoid * 5929*a466cc55SCy Schubertxmalloc (size_t num) 5930*a466cc55SCy Schubert{ 5931*a466cc55SCy Schubert void *p = (void *) malloc (num); 5932*a466cc55SCy Schubert if (!p) 5933*a466cc55SCy Schubert lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934*a466cc55SCy Schubert 5935*a466cc55SCy Schubert return p; 5936*a466cc55SCy Schubert} 5937*a466cc55SCy Schubert 5938*a466cc55SCy Schubertchar * 5939*a466cc55SCy Schubertxstrdup (const char *string) 5940*a466cc55SCy Schubert{ 5941*a466cc55SCy Schubert return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942*a466cc55SCy Schubert string) : NULL; 5943*a466cc55SCy Schubert} 5944*a466cc55SCy Schubert 5945*a466cc55SCy Schubertconst char * 5946*a466cc55SCy Schubertbase_name (const char *name) 5947*a466cc55SCy Schubert{ 5948*a466cc55SCy Schubert const char *base; 5949*a466cc55SCy Schubert 5950*a466cc55SCy Schubert#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951*a466cc55SCy Schubert /* Skip over the disk name in MSDOS pathnames. */ 5952*a466cc55SCy Schubert if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953*a466cc55SCy Schubert name += 2; 5954*a466cc55SCy Schubert#endif 5955*a466cc55SCy Schubert 5956*a466cc55SCy Schubert for (base = name; *name; name++) 5957*a466cc55SCy Schubert if (IS_DIR_SEPARATOR (*name)) 5958*a466cc55SCy Schubert base = name + 1; 5959*a466cc55SCy Schubert return base; 5960*a466cc55SCy Schubert} 5961*a466cc55SCy Schubert 5962*a466cc55SCy Schubertint 5963*a466cc55SCy Schubertcheck_executable (const char *path) 5964*a466cc55SCy Schubert{ 5965*a466cc55SCy Schubert struct stat st; 5966*a466cc55SCy Schubert 5967*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968*a466cc55SCy Schubert nonempty (path)); 5969*a466cc55SCy Schubert if ((!path) || (!*path)) 5970*a466cc55SCy Schubert return 0; 5971*a466cc55SCy Schubert 5972*a466cc55SCy Schubert if ((stat (path, &st) >= 0) 5973*a466cc55SCy Schubert && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974*a466cc55SCy Schubert return 1; 5975*a466cc55SCy Schubert else 5976*a466cc55SCy Schubert return 0; 5977*a466cc55SCy Schubert} 5978*a466cc55SCy Schubert 5979*a466cc55SCy Schubertint 5980*a466cc55SCy Schubertmake_executable (const char *path) 5981*a466cc55SCy Schubert{ 5982*a466cc55SCy Schubert int rval = 0; 5983*a466cc55SCy Schubert struct stat st; 5984*a466cc55SCy Schubert 5985*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986*a466cc55SCy Schubert nonempty (path)); 5987*a466cc55SCy Schubert if ((!path) || (!*path)) 5988*a466cc55SCy Schubert return 0; 5989*a466cc55SCy Schubert 5990*a466cc55SCy Schubert if (stat (path, &st) >= 0) 5991*a466cc55SCy Schubert { 5992*a466cc55SCy Schubert rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993*a466cc55SCy Schubert } 5994*a466cc55SCy Schubert return rval; 5995*a466cc55SCy Schubert} 5996*a466cc55SCy Schubert 5997*a466cc55SCy Schubert/* Searches for the full path of the wrapper. Returns 5998*a466cc55SCy Schubert newly allocated full path name if found, NULL otherwise 5999*a466cc55SCy Schubert Does not chase symlinks, even on platforms that support them. 6000*a466cc55SCy Schubert*/ 6001*a466cc55SCy Schubertchar * 6002*a466cc55SCy Schubertfind_executable (const char *wrapper) 6003*a466cc55SCy Schubert{ 6004*a466cc55SCy Schubert int has_slash = 0; 6005*a466cc55SCy Schubert const char *p; 6006*a466cc55SCy Schubert const char *p_next; 6007*a466cc55SCy Schubert /* static buffer for getcwd */ 6008*a466cc55SCy Schubert char tmp[LT_PATHMAX + 1]; 6009*a466cc55SCy Schubert size_t tmp_len; 6010*a466cc55SCy Schubert char *concat_name; 6011*a466cc55SCy Schubert 6012*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013*a466cc55SCy Schubert nonempty (wrapper)); 6014*a466cc55SCy Schubert 6015*a466cc55SCy Schubert if ((wrapper == NULL) || (*wrapper == '\0')) 6016*a466cc55SCy Schubert return NULL; 6017*a466cc55SCy Schubert 6018*a466cc55SCy Schubert /* Absolute path? */ 6019*a466cc55SCy Schubert#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020*a466cc55SCy Schubert if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021*a466cc55SCy Schubert { 6022*a466cc55SCy Schubert concat_name = xstrdup (wrapper); 6023*a466cc55SCy Schubert if (check_executable (concat_name)) 6024*a466cc55SCy Schubert return concat_name; 6025*a466cc55SCy Schubert XFREE (concat_name); 6026*a466cc55SCy Schubert } 6027*a466cc55SCy Schubert else 6028*a466cc55SCy Schubert { 6029*a466cc55SCy Schubert#endif 6030*a466cc55SCy Schubert if (IS_DIR_SEPARATOR (wrapper[0])) 6031*a466cc55SCy Schubert { 6032*a466cc55SCy Schubert concat_name = xstrdup (wrapper); 6033*a466cc55SCy Schubert if (check_executable (concat_name)) 6034*a466cc55SCy Schubert return concat_name; 6035*a466cc55SCy Schubert XFREE (concat_name); 6036*a466cc55SCy Schubert } 6037*a466cc55SCy Schubert#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038*a466cc55SCy Schubert } 6039*a466cc55SCy Schubert#endif 6040*a466cc55SCy Schubert 6041*a466cc55SCy Schubert for (p = wrapper; *p; p++) 6042*a466cc55SCy Schubert if (*p == '/') 6043*a466cc55SCy Schubert { 6044*a466cc55SCy Schubert has_slash = 1; 6045*a466cc55SCy Schubert break; 6046*a466cc55SCy Schubert } 6047*a466cc55SCy Schubert if (!has_slash) 6048*a466cc55SCy Schubert { 6049*a466cc55SCy Schubert /* no slashes; search PATH */ 6050*a466cc55SCy Schubert const char *path = getenv ("PATH"); 6051*a466cc55SCy Schubert if (path != NULL) 6052*a466cc55SCy Schubert { 6053*a466cc55SCy Schubert for (p = path; *p; p = p_next) 6054*a466cc55SCy Schubert { 6055*a466cc55SCy Schubert const char *q; 6056*a466cc55SCy Schubert size_t p_len; 6057*a466cc55SCy Schubert for (q = p; *q; q++) 6058*a466cc55SCy Schubert if (IS_PATH_SEPARATOR (*q)) 6059*a466cc55SCy Schubert break; 6060*a466cc55SCy Schubert p_len = (size_t) (q - p); 6061*a466cc55SCy Schubert p_next = (*q == '\0' ? q : q + 1); 6062*a466cc55SCy Schubert if (p_len == 0) 6063*a466cc55SCy Schubert { 6064*a466cc55SCy Schubert /* empty path: current directory */ 6065*a466cc55SCy Schubert if (getcwd (tmp, LT_PATHMAX) == NULL) 6066*a466cc55SCy Schubert lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067*a466cc55SCy Schubert nonnull (strerror (errno))); 6068*a466cc55SCy Schubert tmp_len = strlen (tmp); 6069*a466cc55SCy Schubert concat_name = 6070*a466cc55SCy Schubert XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071*a466cc55SCy Schubert memcpy (concat_name, tmp, tmp_len); 6072*a466cc55SCy Schubert concat_name[tmp_len] = '/'; 6073*a466cc55SCy Schubert strcpy (concat_name + tmp_len + 1, wrapper); 6074*a466cc55SCy Schubert } 6075*a466cc55SCy Schubert else 6076*a466cc55SCy Schubert { 6077*a466cc55SCy Schubert concat_name = 6078*a466cc55SCy Schubert XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079*a466cc55SCy Schubert memcpy (concat_name, p, p_len); 6080*a466cc55SCy Schubert concat_name[p_len] = '/'; 6081*a466cc55SCy Schubert strcpy (concat_name + p_len + 1, wrapper); 6082*a466cc55SCy Schubert } 6083*a466cc55SCy Schubert if (check_executable (concat_name)) 6084*a466cc55SCy Schubert return concat_name; 6085*a466cc55SCy Schubert XFREE (concat_name); 6086*a466cc55SCy Schubert } 6087*a466cc55SCy Schubert } 6088*a466cc55SCy Schubert /* not found in PATH; assume curdir */ 6089*a466cc55SCy Schubert } 6090*a466cc55SCy Schubert /* Relative path | not found in path: prepend cwd */ 6091*a466cc55SCy Schubert if (getcwd (tmp, LT_PATHMAX) == NULL) 6092*a466cc55SCy Schubert lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093*a466cc55SCy Schubert nonnull (strerror (errno))); 6094*a466cc55SCy Schubert tmp_len = strlen (tmp); 6095*a466cc55SCy Schubert concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096*a466cc55SCy Schubert memcpy (concat_name, tmp, tmp_len); 6097*a466cc55SCy Schubert concat_name[tmp_len] = '/'; 6098*a466cc55SCy Schubert strcpy (concat_name + tmp_len + 1, wrapper); 6099*a466cc55SCy Schubert 6100*a466cc55SCy Schubert if (check_executable (concat_name)) 6101*a466cc55SCy Schubert return concat_name; 6102*a466cc55SCy Schubert XFREE (concat_name); 6103*a466cc55SCy Schubert return NULL; 6104*a466cc55SCy Schubert} 6105*a466cc55SCy Schubert 6106*a466cc55SCy Schubertchar * 6107*a466cc55SCy Schubertchase_symlinks (const char *pathspec) 6108*a466cc55SCy Schubert{ 6109*a466cc55SCy Schubert#ifndef S_ISLNK 6110*a466cc55SCy Schubert return xstrdup (pathspec); 6111*a466cc55SCy Schubert#else 6112*a466cc55SCy Schubert char buf[LT_PATHMAX]; 6113*a466cc55SCy Schubert struct stat s; 6114*a466cc55SCy Schubert char *tmp_pathspec = xstrdup (pathspec); 6115*a466cc55SCy Schubert char *p; 6116*a466cc55SCy Schubert int has_symlinks = 0; 6117*a466cc55SCy Schubert while (strlen (tmp_pathspec) && !has_symlinks) 6118*a466cc55SCy Schubert { 6119*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6120*a466cc55SCy Schubert "checking path component for symlinks: %s\n", 6121*a466cc55SCy Schubert tmp_pathspec); 6122*a466cc55SCy Schubert if (lstat (tmp_pathspec, &s) == 0) 6123*a466cc55SCy Schubert { 6124*a466cc55SCy Schubert if (S_ISLNK (s.st_mode) != 0) 6125*a466cc55SCy Schubert { 6126*a466cc55SCy Schubert has_symlinks = 1; 6127*a466cc55SCy Schubert break; 6128*a466cc55SCy Schubert } 6129*a466cc55SCy Schubert 6130*a466cc55SCy Schubert /* search backwards for last DIR_SEPARATOR */ 6131*a466cc55SCy Schubert p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132*a466cc55SCy Schubert while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133*a466cc55SCy Schubert p--; 6134*a466cc55SCy Schubert if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135*a466cc55SCy Schubert { 6136*a466cc55SCy Schubert /* no more DIR_SEPARATORS left */ 6137*a466cc55SCy Schubert break; 6138*a466cc55SCy Schubert } 6139*a466cc55SCy Schubert *p = '\0'; 6140*a466cc55SCy Schubert } 6141*a466cc55SCy Schubert else 6142*a466cc55SCy Schubert { 6143*a466cc55SCy Schubert lt_fatal (__FILE__, __LINE__, 6144*a466cc55SCy Schubert "error accessing file \"%s\": %s", 6145*a466cc55SCy Schubert tmp_pathspec, nonnull (strerror (errno))); 6146*a466cc55SCy Schubert } 6147*a466cc55SCy Schubert } 6148*a466cc55SCy Schubert XFREE (tmp_pathspec); 6149*a466cc55SCy Schubert 6150*a466cc55SCy Schubert if (!has_symlinks) 6151*a466cc55SCy Schubert { 6152*a466cc55SCy Schubert return xstrdup (pathspec); 6153*a466cc55SCy Schubert } 6154*a466cc55SCy Schubert 6155*a466cc55SCy Schubert tmp_pathspec = realpath (pathspec, buf); 6156*a466cc55SCy Schubert if (tmp_pathspec == 0) 6157*a466cc55SCy Schubert { 6158*a466cc55SCy Schubert lt_fatal (__FILE__, __LINE__, 6159*a466cc55SCy Schubert "could not follow symlinks for %s", pathspec); 6160*a466cc55SCy Schubert } 6161*a466cc55SCy Schubert return xstrdup (tmp_pathspec); 6162*a466cc55SCy Schubert#endif 6163*a466cc55SCy Schubert} 6164*a466cc55SCy Schubert 6165*a466cc55SCy Schubertchar * 6166*a466cc55SCy Schubertstrendzap (char *str, const char *pat) 6167*a466cc55SCy Schubert{ 6168*a466cc55SCy Schubert size_t len, patlen; 6169*a466cc55SCy Schubert 6170*a466cc55SCy Schubert assert (str != NULL); 6171*a466cc55SCy Schubert assert (pat != NULL); 6172*a466cc55SCy Schubert 6173*a466cc55SCy Schubert len = strlen (str); 6174*a466cc55SCy Schubert patlen = strlen (pat); 6175*a466cc55SCy Schubert 6176*a466cc55SCy Schubert if (patlen <= len) 6177*a466cc55SCy Schubert { 6178*a466cc55SCy Schubert str += len - patlen; 6179*a466cc55SCy Schubert if (STREQ (str, pat)) 6180*a466cc55SCy Schubert *str = '\0'; 6181*a466cc55SCy Schubert } 6182*a466cc55SCy Schubert return str; 6183*a466cc55SCy Schubert} 6184*a466cc55SCy Schubert 6185*a466cc55SCy Schubertvoid 6186*a466cc55SCy Schubertlt_debugprintf (const char *file, int line, const char *fmt, ...) 6187*a466cc55SCy Schubert{ 6188*a466cc55SCy Schubert va_list args; 6189*a466cc55SCy Schubert if (lt_debug) 6190*a466cc55SCy Schubert { 6191*a466cc55SCy Schubert (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192*a466cc55SCy Schubert va_start (args, fmt); 6193*a466cc55SCy Schubert (void) vfprintf (stderr, fmt, args); 6194*a466cc55SCy Schubert va_end (args); 6195*a466cc55SCy Schubert } 6196*a466cc55SCy Schubert} 6197*a466cc55SCy Schubert 6198*a466cc55SCy Schubertstatic void 6199*a466cc55SCy Schubertlt_error_core (int exit_status, const char *file, 6200*a466cc55SCy Schubert int line, const char *mode, 6201*a466cc55SCy Schubert const char *message, va_list ap) 6202*a466cc55SCy Schubert{ 6203*a466cc55SCy Schubert fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204*a466cc55SCy Schubert vfprintf (stderr, message, ap); 6205*a466cc55SCy Schubert fprintf (stderr, ".\n"); 6206*a466cc55SCy Schubert 6207*a466cc55SCy Schubert if (exit_status >= 0) 6208*a466cc55SCy Schubert exit (exit_status); 6209*a466cc55SCy Schubert} 6210*a466cc55SCy Schubert 6211*a466cc55SCy Schubertvoid 6212*a466cc55SCy Schubertlt_fatal (const char *file, int line, const char *message, ...) 6213*a466cc55SCy Schubert{ 6214*a466cc55SCy Schubert va_list ap; 6215*a466cc55SCy Schubert va_start (ap, message); 6216*a466cc55SCy Schubert lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217*a466cc55SCy Schubert va_end (ap); 6218*a466cc55SCy Schubert} 6219*a466cc55SCy Schubert 6220*a466cc55SCy Schubertstatic const char * 6221*a466cc55SCy Schubertnonnull (const char *s) 6222*a466cc55SCy Schubert{ 6223*a466cc55SCy Schubert return s ? s : "(null)"; 6224*a466cc55SCy Schubert} 6225*a466cc55SCy Schubert 6226*a466cc55SCy Schubertstatic const char * 6227*a466cc55SCy Schubertnonempty (const char *s) 6228*a466cc55SCy Schubert{ 6229*a466cc55SCy Schubert return (s && !*s) ? "(empty)" : nonnull (s); 6230*a466cc55SCy Schubert} 6231*a466cc55SCy Schubert 6232*a466cc55SCy Schubertvoid 6233*a466cc55SCy Schubertlt_setenv (const char *name, const char *value) 6234*a466cc55SCy Schubert{ 6235*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6236*a466cc55SCy Schubert "(lt_setenv) setting '%s' to '%s'\n", 6237*a466cc55SCy Schubert nonnull (name), nonnull (value)); 6238*a466cc55SCy Schubert { 6239*a466cc55SCy Schubert#ifdef HAVE_SETENV 6240*a466cc55SCy Schubert /* always make a copy, for consistency with !HAVE_SETENV */ 6241*a466cc55SCy Schubert char *str = xstrdup (value); 6242*a466cc55SCy Schubert setenv (name, str, 1); 6243*a466cc55SCy Schubert#else 6244*a466cc55SCy Schubert size_t len = strlen (name) + 1 + strlen (value) + 1; 6245*a466cc55SCy Schubert char *str = XMALLOC (char, len); 6246*a466cc55SCy Schubert sprintf (str, "%s=%s", name, value); 6247*a466cc55SCy Schubert if (putenv (str) != EXIT_SUCCESS) 6248*a466cc55SCy Schubert { 6249*a466cc55SCy Schubert XFREE (str); 6250*a466cc55SCy Schubert } 6251*a466cc55SCy Schubert#endif 6252*a466cc55SCy Schubert } 6253*a466cc55SCy Schubert} 6254*a466cc55SCy Schubert 6255*a466cc55SCy Schubertchar * 6256*a466cc55SCy Schubertlt_extend_str (const char *orig_value, const char *add, int to_end) 6257*a466cc55SCy Schubert{ 6258*a466cc55SCy Schubert char *new_value; 6259*a466cc55SCy Schubert if (orig_value && *orig_value) 6260*a466cc55SCy Schubert { 6261*a466cc55SCy Schubert size_t orig_value_len = strlen (orig_value); 6262*a466cc55SCy Schubert size_t add_len = strlen (add); 6263*a466cc55SCy Schubert new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264*a466cc55SCy Schubert if (to_end) 6265*a466cc55SCy Schubert { 6266*a466cc55SCy Schubert strcpy (new_value, orig_value); 6267*a466cc55SCy Schubert strcpy (new_value + orig_value_len, add); 6268*a466cc55SCy Schubert } 6269*a466cc55SCy Schubert else 6270*a466cc55SCy Schubert { 6271*a466cc55SCy Schubert strcpy (new_value, add); 6272*a466cc55SCy Schubert strcpy (new_value + add_len, orig_value); 6273*a466cc55SCy Schubert } 6274*a466cc55SCy Schubert } 6275*a466cc55SCy Schubert else 6276*a466cc55SCy Schubert { 6277*a466cc55SCy Schubert new_value = xstrdup (add); 6278*a466cc55SCy Schubert } 6279*a466cc55SCy Schubert return new_value; 6280*a466cc55SCy Schubert} 6281*a466cc55SCy Schubert 6282*a466cc55SCy Schubertvoid 6283*a466cc55SCy Schubertlt_update_exe_path (const char *name, const char *value) 6284*a466cc55SCy Schubert{ 6285*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6286*a466cc55SCy Schubert "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287*a466cc55SCy Schubert nonnull (name), nonnull (value)); 6288*a466cc55SCy Schubert 6289*a466cc55SCy Schubert if (name && *name && value && *value) 6290*a466cc55SCy Schubert { 6291*a466cc55SCy Schubert char *new_value = lt_extend_str (getenv (name), value, 0); 6292*a466cc55SCy Schubert /* some systems can't cope with a ':'-terminated path #' */ 6293*a466cc55SCy Schubert size_t len = strlen (new_value); 6294*a466cc55SCy Schubert while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295*a466cc55SCy Schubert { 6296*a466cc55SCy Schubert new_value[--len] = '\0'; 6297*a466cc55SCy Schubert } 6298*a466cc55SCy Schubert lt_setenv (name, new_value); 6299*a466cc55SCy Schubert XFREE (new_value); 6300*a466cc55SCy Schubert } 6301*a466cc55SCy Schubert} 6302*a466cc55SCy Schubert 6303*a466cc55SCy Schubertvoid 6304*a466cc55SCy Schubertlt_update_lib_path (const char *name, const char *value) 6305*a466cc55SCy Schubert{ 6306*a466cc55SCy Schubert lt_debugprintf (__FILE__, __LINE__, 6307*a466cc55SCy Schubert "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308*a466cc55SCy Schubert nonnull (name), nonnull (value)); 6309*a466cc55SCy Schubert 6310*a466cc55SCy Schubert if (name && *name && value && *value) 6311*a466cc55SCy Schubert { 6312*a466cc55SCy Schubert char *new_value = lt_extend_str (getenv (name), value, 0); 6313*a466cc55SCy Schubert lt_setenv (name, new_value); 6314*a466cc55SCy Schubert XFREE (new_value); 6315*a466cc55SCy Schubert } 6316*a466cc55SCy Schubert} 6317*a466cc55SCy Schubert 6318*a466cc55SCy SchubertEOF 6319*a466cc55SCy Schubert case $host_os in 6320*a466cc55SCy Schubert mingw*) 6321*a466cc55SCy Schubert cat <<"EOF" 6322*a466cc55SCy Schubert 6323*a466cc55SCy Schubert/* Prepares an argument vector before calling spawn(). 6324*a466cc55SCy Schubert Note that spawn() does not by itself call the command interpreter 6325*a466cc55SCy Schubert (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326*a466cc55SCy Schubert ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327*a466cc55SCy Schubert GetVersionEx(&v); 6328*a466cc55SCy Schubert v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329*a466cc55SCy Schubert }) ? "cmd.exe" : "command.com"). 6330*a466cc55SCy Schubert Instead it simply concatenates the arguments, separated by ' ', and calls 6331*a466cc55SCy Schubert CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332*a466cc55SCy Schubert interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333*a466cc55SCy Schubert special way: 6334*a466cc55SCy Schubert - Space and tab are interpreted as delimiters. They are not treated as 6335*a466cc55SCy Schubert delimiters if they are surrounded by double quotes: "...". 6336*a466cc55SCy Schubert - Unescaped double quotes are removed from the input. Their only effect is 6337*a466cc55SCy Schubert that within double quotes, space and tab are treated like normal 6338*a466cc55SCy Schubert characters. 6339*a466cc55SCy Schubert - Backslashes not followed by double quotes are not special. 6340*a466cc55SCy Schubert - But 2*n+1 backslashes followed by a double quote become 6341*a466cc55SCy Schubert n backslashes followed by a double quote (n >= 0): 6342*a466cc55SCy Schubert \" -> " 6343*a466cc55SCy Schubert \\\" -> \" 6344*a466cc55SCy Schubert \\\\\" -> \\" 6345*a466cc55SCy Schubert */ 6346*a466cc55SCy 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" 6347*a466cc55SCy 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" 6348*a466cc55SCy Schubertchar ** 6349*a466cc55SCy Schubertprepare_spawn (char **argv) 6350*a466cc55SCy Schubert{ 6351*a466cc55SCy Schubert size_t argc; 6352*a466cc55SCy Schubert char **new_argv; 6353*a466cc55SCy Schubert size_t i; 6354*a466cc55SCy Schubert 6355*a466cc55SCy Schubert /* Count number of arguments. */ 6356*a466cc55SCy Schubert for (argc = 0; argv[argc] != NULL; argc++) 6357*a466cc55SCy Schubert ; 6358*a466cc55SCy Schubert 6359*a466cc55SCy Schubert /* Allocate new argument vector. */ 6360*a466cc55SCy Schubert new_argv = XMALLOC (char *, argc + 1); 6361*a466cc55SCy Schubert 6362*a466cc55SCy Schubert /* Put quoted arguments into the new argument vector. */ 6363*a466cc55SCy Schubert for (i = 0; i < argc; i++) 6364*a466cc55SCy Schubert { 6365*a466cc55SCy Schubert const char *string = argv[i]; 6366*a466cc55SCy Schubert 6367*a466cc55SCy Schubert if (string[0] == '\0') 6368*a466cc55SCy Schubert new_argv[i] = xstrdup ("\"\""); 6369*a466cc55SCy Schubert else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370*a466cc55SCy Schubert { 6371*a466cc55SCy Schubert int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372*a466cc55SCy Schubert size_t length; 6373*a466cc55SCy Schubert unsigned int backslashes; 6374*a466cc55SCy Schubert const char *s; 6375*a466cc55SCy Schubert char *quoted_string; 6376*a466cc55SCy Schubert char *p; 6377*a466cc55SCy Schubert 6378*a466cc55SCy Schubert length = 0; 6379*a466cc55SCy Schubert backslashes = 0; 6380*a466cc55SCy Schubert if (quote_around) 6381*a466cc55SCy Schubert length++; 6382*a466cc55SCy Schubert for (s = string; *s != '\0'; s++) 6383*a466cc55SCy Schubert { 6384*a466cc55SCy Schubert char c = *s; 6385*a466cc55SCy Schubert if (c == '"') 6386*a466cc55SCy Schubert length += backslashes + 1; 6387*a466cc55SCy Schubert length++; 6388*a466cc55SCy Schubert if (c == '\\') 6389*a466cc55SCy Schubert backslashes++; 6390*a466cc55SCy Schubert else 6391*a466cc55SCy Schubert backslashes = 0; 6392*a466cc55SCy Schubert } 6393*a466cc55SCy Schubert if (quote_around) 6394*a466cc55SCy Schubert length += backslashes + 1; 6395*a466cc55SCy Schubert 6396*a466cc55SCy Schubert quoted_string = XMALLOC (char, length + 1); 6397*a466cc55SCy Schubert 6398*a466cc55SCy Schubert p = quoted_string; 6399*a466cc55SCy Schubert backslashes = 0; 6400*a466cc55SCy Schubert if (quote_around) 6401*a466cc55SCy Schubert *p++ = '"'; 6402*a466cc55SCy Schubert for (s = string; *s != '\0'; s++) 6403*a466cc55SCy Schubert { 6404*a466cc55SCy Schubert char c = *s; 6405*a466cc55SCy Schubert if (c == '"') 6406*a466cc55SCy Schubert { 6407*a466cc55SCy Schubert unsigned int j; 6408*a466cc55SCy Schubert for (j = backslashes + 1; j > 0; j--) 6409*a466cc55SCy Schubert *p++ = '\\'; 6410*a466cc55SCy Schubert } 6411*a466cc55SCy Schubert *p++ = c; 6412*a466cc55SCy Schubert if (c == '\\') 6413*a466cc55SCy Schubert backslashes++; 6414*a466cc55SCy Schubert else 6415*a466cc55SCy Schubert backslashes = 0; 6416*a466cc55SCy Schubert } 6417*a466cc55SCy Schubert if (quote_around) 6418*a466cc55SCy Schubert { 6419*a466cc55SCy Schubert unsigned int j; 6420*a466cc55SCy Schubert for (j = backslashes; j > 0; j--) 6421*a466cc55SCy Schubert *p++ = '\\'; 6422*a466cc55SCy Schubert *p++ = '"'; 6423*a466cc55SCy Schubert } 6424*a466cc55SCy Schubert *p = '\0'; 6425*a466cc55SCy Schubert 6426*a466cc55SCy Schubert new_argv[i] = quoted_string; 6427*a466cc55SCy Schubert } 6428*a466cc55SCy Schubert else 6429*a466cc55SCy Schubert new_argv[i] = (char *) string; 6430*a466cc55SCy Schubert } 6431*a466cc55SCy Schubert new_argv[argc] = NULL; 6432*a466cc55SCy Schubert 6433*a466cc55SCy Schubert return new_argv; 6434*a466cc55SCy Schubert} 6435*a466cc55SCy SchubertEOF 6436*a466cc55SCy Schubert ;; 6437*a466cc55SCy Schubert esac 6438*a466cc55SCy Schubert 6439*a466cc55SCy Schubert cat <<"EOF" 6440*a466cc55SCy Schubertvoid lt_dump_script (FILE* f) 6441*a466cc55SCy Schubert{ 6442*a466cc55SCy SchubertEOF 6443*a466cc55SCy Schubert func_emit_wrapper yes | 6444*a466cc55SCy Schubert $SED -n -e ' 6445*a466cc55SCy Schuberts/^\(.\{79\}\)\(..*\)/\1\ 6446*a466cc55SCy Schubert\2/ 6447*a466cc55SCy Schuberth 6448*a466cc55SCy Schuberts/\([\\"]\)/\\\1/g 6449*a466cc55SCy Schuberts/$/\\n/ 6450*a466cc55SCy Schuberts/\([^\n]*\).*/ fputs ("\1", f);/p 6451*a466cc55SCy Schubertg 6452*a466cc55SCy SchubertD' 6453*a466cc55SCy Schubert cat <<"EOF" 6454*a466cc55SCy Schubert} 6455*a466cc55SCy SchubertEOF 6456*a466cc55SCy Schubert} 6457*a466cc55SCy Schubert# end: func_emit_cwrapperexe_src 6458*a466cc55SCy Schubert 6459*a466cc55SCy Schubert# func_win32_import_lib_p ARG 6460*a466cc55SCy Schubert# True if ARG is an import lib, as indicated by $file_magic_cmd 6461*a466cc55SCy Schubertfunc_win32_import_lib_p () 6462*a466cc55SCy Schubert{ 6463*a466cc55SCy Schubert $debug_cmd 6464*a466cc55SCy Schubert 6465*a466cc55SCy Schubert case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466*a466cc55SCy Schubert *import*) : ;; 6467*a466cc55SCy Schubert *) false ;; 6468*a466cc55SCy Schubert esac 6469*a466cc55SCy Schubert} 6470*a466cc55SCy Schubert 6471*a466cc55SCy Schubert# func_suncc_cstd_abi 6472*a466cc55SCy Schubert# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473*a466cc55SCy Schubert# Several compiler flags select an ABI that is incompatible with the 6474*a466cc55SCy Schubert# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475*a466cc55SCy Schubertfunc_suncc_cstd_abi () 6476*a466cc55SCy Schubert{ 6477*a466cc55SCy Schubert $debug_cmd 6478*a466cc55SCy Schubert 6479*a466cc55SCy Schubert case " $compile_command " in 6480*a466cc55SCy Schubert *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481*a466cc55SCy Schubert suncc_use_cstd_abi=no 6482*a466cc55SCy Schubert ;; 6483*a466cc55SCy Schubert *) 6484*a466cc55SCy Schubert suncc_use_cstd_abi=yes 6485*a466cc55SCy Schubert ;; 6486*a466cc55SCy Schubert esac 6487*a466cc55SCy Schubert} 6488*a466cc55SCy Schubert 6489*a466cc55SCy Schubert# func_mode_link arg... 6490*a466cc55SCy Schubertfunc_mode_link () 6491*a466cc55SCy Schubert{ 6492*a466cc55SCy Schubert $debug_cmd 6493*a466cc55SCy Schubert 6494*a466cc55SCy Schubert case $host in 6495*a466cc55SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496*a466cc55SCy Schubert # It is impossible to link a dll without this setting, and 6497*a466cc55SCy Schubert # we shouldn't force the makefile maintainer to figure out 6498*a466cc55SCy Schubert # what system we are compiling for in order to pass an extra 6499*a466cc55SCy Schubert # flag for every libtool invocation. 6500*a466cc55SCy Schubert # allow_undefined=no 6501*a466cc55SCy Schubert 6502*a466cc55SCy Schubert # FIXME: Unfortunately, there are problems with the above when trying 6503*a466cc55SCy Schubert # to make a dll that has undefined symbols, in which case not 6504*a466cc55SCy Schubert # even a static library is built. For now, we need to specify 6505*a466cc55SCy Schubert # -no-undefined on the libtool link line when we can be certain 6506*a466cc55SCy Schubert # that all symbols are satisfied, otherwise we get a static library. 6507*a466cc55SCy Schubert allow_undefined=yes 6508*a466cc55SCy Schubert ;; 6509*a466cc55SCy Schubert *) 6510*a466cc55SCy Schubert allow_undefined=yes 6511*a466cc55SCy Schubert ;; 6512*a466cc55SCy Schubert esac 6513*a466cc55SCy Schubert libtool_args=$nonopt 6514*a466cc55SCy Schubert base_compile="$nonopt $@" 6515*a466cc55SCy Schubert compile_command=$nonopt 6516*a466cc55SCy Schubert finalize_command=$nonopt 6517*a466cc55SCy Schubert 6518*a466cc55SCy Schubert compile_rpath= 6519*a466cc55SCy Schubert finalize_rpath= 6520*a466cc55SCy Schubert compile_shlibpath= 6521*a466cc55SCy Schubert finalize_shlibpath= 6522*a466cc55SCy Schubert convenience= 6523*a466cc55SCy Schubert old_convenience= 6524*a466cc55SCy Schubert deplibs= 6525*a466cc55SCy Schubert old_deplibs= 6526*a466cc55SCy Schubert compiler_flags= 6527*a466cc55SCy Schubert linker_flags= 6528*a466cc55SCy Schubert dllsearchpath= 6529*a466cc55SCy Schubert lib_search_path=`pwd` 6530*a466cc55SCy Schubert inst_prefix_dir= 6531*a466cc55SCy Schubert new_inherited_linker_flags= 6532*a466cc55SCy Schubert 6533*a466cc55SCy Schubert avoid_version=no 6534*a466cc55SCy Schubert bindir= 6535*a466cc55SCy Schubert dlfiles= 6536*a466cc55SCy Schubert dlprefiles= 6537*a466cc55SCy Schubert dlself=no 6538*a466cc55SCy Schubert export_dynamic=no 6539*a466cc55SCy Schubert export_symbols= 6540*a466cc55SCy Schubert export_symbols_regex= 6541*a466cc55SCy Schubert generated= 6542*a466cc55SCy Schubert libobjs= 6543*a466cc55SCy Schubert ltlibs= 6544*a466cc55SCy Schubert module=no 6545*a466cc55SCy Schubert no_install=no 6546*a466cc55SCy Schubert objs= 6547*a466cc55SCy Schubert os2dllname= 6548*a466cc55SCy Schubert non_pic_objects= 6549*a466cc55SCy Schubert precious_files_regex= 6550*a466cc55SCy Schubert prefer_static_libs=no 6551*a466cc55SCy Schubert preload=false 6552*a466cc55SCy Schubert prev= 6553*a466cc55SCy Schubert prevarg= 6554*a466cc55SCy Schubert release= 6555*a466cc55SCy Schubert rpath= 6556*a466cc55SCy Schubert xrpath= 6557*a466cc55SCy Schubert perm_rpath= 6558*a466cc55SCy Schubert temp_rpath= 6559*a466cc55SCy Schubert thread_safe=no 6560*a466cc55SCy Schubert vinfo= 6561*a466cc55SCy Schubert vinfo_number=no 6562*a466cc55SCy Schubert weak_libs= 6563*a466cc55SCy Schubert single_module=$wl-single_module 6564*a466cc55SCy Schubert func_infer_tag $base_compile 6565*a466cc55SCy Schubert 6566*a466cc55SCy Schubert # We need to know -static, to get the right output filenames. 6567*a466cc55SCy Schubert for arg 6568*a466cc55SCy Schubert do 6569*a466cc55SCy Schubert case $arg in 6570*a466cc55SCy Schubert -shared) 6571*a466cc55SCy Schubert test yes != "$build_libtool_libs" \ 6572*a466cc55SCy Schubert && func_fatal_configuration "cannot build a shared library" 6573*a466cc55SCy Schubert build_old_libs=no 6574*a466cc55SCy Schubert break 6575*a466cc55SCy Schubert ;; 6576*a466cc55SCy Schubert -all-static | -static | -static-libtool-libs) 6577*a466cc55SCy Schubert case $arg in 6578*a466cc55SCy Schubert -all-static) 6579*a466cc55SCy Schubert if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580*a466cc55SCy Schubert func_warning "complete static linking is impossible in this configuration" 6581*a466cc55SCy Schubert fi 6582*a466cc55SCy Schubert if test -n "$link_static_flag"; then 6583*a466cc55SCy Schubert dlopen_self=$dlopen_self_static 6584*a466cc55SCy Schubert fi 6585*a466cc55SCy Schubert prefer_static_libs=yes 6586*a466cc55SCy Schubert ;; 6587*a466cc55SCy Schubert -static) 6588*a466cc55SCy Schubert if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589*a466cc55SCy Schubert dlopen_self=$dlopen_self_static 6590*a466cc55SCy Schubert fi 6591*a466cc55SCy Schubert prefer_static_libs=built 6592*a466cc55SCy Schubert ;; 6593*a466cc55SCy Schubert -static-libtool-libs) 6594*a466cc55SCy Schubert if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595*a466cc55SCy Schubert dlopen_self=$dlopen_self_static 6596*a466cc55SCy Schubert fi 6597*a466cc55SCy Schubert prefer_static_libs=yes 6598*a466cc55SCy Schubert ;; 6599*a466cc55SCy Schubert esac 6600*a466cc55SCy Schubert build_libtool_libs=no 6601*a466cc55SCy Schubert build_old_libs=yes 6602*a466cc55SCy Schubert break 6603*a466cc55SCy Schubert ;; 6604*a466cc55SCy Schubert esac 6605*a466cc55SCy Schubert done 6606*a466cc55SCy Schubert 6607*a466cc55SCy Schubert # See if our shared archives depend on static archives. 6608*a466cc55SCy Schubert test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609*a466cc55SCy Schubert 6610*a466cc55SCy Schubert # Go through the arguments, transforming them on the way. 6611*a466cc55SCy Schubert while test "$#" -gt 0; do 6612*a466cc55SCy Schubert arg=$1 6613*a466cc55SCy Schubert shift 6614*a466cc55SCy Schubert func_quote_for_eval "$arg" 6615*a466cc55SCy Schubert qarg=$func_quote_for_eval_unquoted_result 6616*a466cc55SCy Schubert func_append libtool_args " $func_quote_for_eval_result" 6617*a466cc55SCy Schubert 6618*a466cc55SCy Schubert # If the previous option needs an argument, assign it. 6619*a466cc55SCy Schubert if test -n "$prev"; then 6620*a466cc55SCy Schubert case $prev in 6621*a466cc55SCy Schubert output) 6622*a466cc55SCy Schubert func_append compile_command " @OUTPUT@" 6623*a466cc55SCy Schubert func_append finalize_command " @OUTPUT@" 6624*a466cc55SCy Schubert ;; 6625*a466cc55SCy Schubert esac 6626*a466cc55SCy Schubert 6627*a466cc55SCy Schubert case $prev in 6628*a466cc55SCy Schubert bindir) 6629*a466cc55SCy Schubert bindir=$arg 6630*a466cc55SCy Schubert prev= 6631*a466cc55SCy Schubert continue 6632*a466cc55SCy Schubert ;; 6633*a466cc55SCy Schubert dlfiles|dlprefiles) 6634*a466cc55SCy Schubert $preload || { 6635*a466cc55SCy Schubert # Add the symbol object into the linking commands. 6636*a466cc55SCy Schubert func_append compile_command " @SYMFILE@" 6637*a466cc55SCy Schubert func_append finalize_command " @SYMFILE@" 6638*a466cc55SCy Schubert preload=: 6639*a466cc55SCy Schubert } 6640*a466cc55SCy Schubert case $arg in 6641*a466cc55SCy Schubert *.la | *.lo) ;; # We handle these cases below. 6642*a466cc55SCy Schubert force) 6643*a466cc55SCy Schubert if test no = "$dlself"; then 6644*a466cc55SCy Schubert dlself=needless 6645*a466cc55SCy Schubert export_dynamic=yes 6646*a466cc55SCy Schubert fi 6647*a466cc55SCy Schubert prev= 6648*a466cc55SCy Schubert continue 6649*a466cc55SCy Schubert ;; 6650*a466cc55SCy Schubert self) 6651*a466cc55SCy Schubert if test dlprefiles = "$prev"; then 6652*a466cc55SCy Schubert dlself=yes 6653*a466cc55SCy Schubert elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654*a466cc55SCy Schubert dlself=yes 6655*a466cc55SCy Schubert else 6656*a466cc55SCy Schubert dlself=needless 6657*a466cc55SCy Schubert export_dynamic=yes 6658*a466cc55SCy Schubert fi 6659*a466cc55SCy Schubert prev= 6660*a466cc55SCy Schubert continue 6661*a466cc55SCy Schubert ;; 6662*a466cc55SCy Schubert *) 6663*a466cc55SCy Schubert if test dlfiles = "$prev"; then 6664*a466cc55SCy Schubert func_append dlfiles " $arg" 6665*a466cc55SCy Schubert else 6666*a466cc55SCy Schubert func_append dlprefiles " $arg" 6667*a466cc55SCy Schubert fi 6668*a466cc55SCy Schubert prev= 6669*a466cc55SCy Schubert continue 6670*a466cc55SCy Schubert ;; 6671*a466cc55SCy Schubert esac 6672*a466cc55SCy Schubert ;; 6673*a466cc55SCy Schubert expsyms) 6674*a466cc55SCy Schubert export_symbols=$arg 6675*a466cc55SCy Schubert test -f "$arg" \ 6676*a466cc55SCy Schubert || func_fatal_error "symbol file '$arg' does not exist" 6677*a466cc55SCy Schubert prev= 6678*a466cc55SCy Schubert continue 6679*a466cc55SCy Schubert ;; 6680*a466cc55SCy Schubert expsyms_regex) 6681*a466cc55SCy Schubert export_symbols_regex=$arg 6682*a466cc55SCy Schubert prev= 6683*a466cc55SCy Schubert continue 6684*a466cc55SCy Schubert ;; 6685*a466cc55SCy Schubert framework) 6686*a466cc55SCy Schubert case $host in 6687*a466cc55SCy Schubert *-*-darwin*) 6688*a466cc55SCy Schubert case "$deplibs " in 6689*a466cc55SCy Schubert *" $qarg.ltframework "*) ;; 6690*a466cc55SCy Schubert *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691*a466cc55SCy Schubert ;; 6692*a466cc55SCy Schubert esac 6693*a466cc55SCy Schubert ;; 6694*a466cc55SCy Schubert esac 6695*a466cc55SCy Schubert prev= 6696*a466cc55SCy Schubert continue 6697*a466cc55SCy Schubert ;; 6698*a466cc55SCy Schubert inst_prefix) 6699*a466cc55SCy Schubert inst_prefix_dir=$arg 6700*a466cc55SCy Schubert prev= 6701*a466cc55SCy Schubert continue 6702*a466cc55SCy Schubert ;; 6703*a466cc55SCy Schubert mllvm) 6704*a466cc55SCy Schubert # Clang does not use LLVM to link, so we can simply discard any 6705*a466cc55SCy Schubert # '-mllvm $arg' options when doing the link step. 6706*a466cc55SCy Schubert prev= 6707*a466cc55SCy Schubert continue 6708*a466cc55SCy Schubert ;; 6709*a466cc55SCy Schubert objectlist) 6710*a466cc55SCy Schubert if test -f "$arg"; then 6711*a466cc55SCy Schubert save_arg=$arg 6712*a466cc55SCy Schubert moreargs= 6713*a466cc55SCy Schubert for fil in `cat "$save_arg"` 6714*a466cc55SCy Schubert do 6715*a466cc55SCy Schubert# func_append moreargs " $fil" 6716*a466cc55SCy Schubert arg=$fil 6717*a466cc55SCy Schubert # A libtool-controlled object. 6718*a466cc55SCy Schubert 6719*a466cc55SCy Schubert # Check to see that this really is a libtool object. 6720*a466cc55SCy Schubert if func_lalib_unsafe_p "$arg"; then 6721*a466cc55SCy Schubert pic_object= 6722*a466cc55SCy Schubert non_pic_object= 6723*a466cc55SCy Schubert 6724*a466cc55SCy Schubert # Read the .lo file 6725*a466cc55SCy Schubert func_source "$arg" 6726*a466cc55SCy Schubert 6727*a466cc55SCy Schubert if test -z "$pic_object" || 6728*a466cc55SCy Schubert test -z "$non_pic_object" || 6729*a466cc55SCy Schubert test none = "$pic_object" && 6730*a466cc55SCy Schubert test none = "$non_pic_object"; then 6731*a466cc55SCy Schubert func_fatal_error "cannot find name of object for '$arg'" 6732*a466cc55SCy Schubert fi 6733*a466cc55SCy Schubert 6734*a466cc55SCy Schubert # Extract subdirectory from the argument. 6735*a466cc55SCy Schubert func_dirname "$arg" "/" "" 6736*a466cc55SCy Schubert xdir=$func_dirname_result 6737*a466cc55SCy Schubert 6738*a466cc55SCy Schubert if test none != "$pic_object"; then 6739*a466cc55SCy Schubert # Prepend the subdirectory the object is found in. 6740*a466cc55SCy Schubert pic_object=$xdir$pic_object 6741*a466cc55SCy Schubert 6742*a466cc55SCy Schubert if test dlfiles = "$prev"; then 6743*a466cc55SCy Schubert if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744*a466cc55SCy Schubert func_append dlfiles " $pic_object" 6745*a466cc55SCy Schubert prev= 6746*a466cc55SCy Schubert continue 6747*a466cc55SCy Schubert else 6748*a466cc55SCy Schubert # If libtool objects are unsupported, then we need to preload. 6749*a466cc55SCy Schubert prev=dlprefiles 6750*a466cc55SCy Schubert fi 6751*a466cc55SCy Schubert fi 6752*a466cc55SCy Schubert 6753*a466cc55SCy Schubert # CHECK ME: I think I busted this. -Ossama 6754*a466cc55SCy Schubert if test dlprefiles = "$prev"; then 6755*a466cc55SCy Schubert # Preload the old-style object. 6756*a466cc55SCy Schubert func_append dlprefiles " $pic_object" 6757*a466cc55SCy Schubert prev= 6758*a466cc55SCy Schubert fi 6759*a466cc55SCy Schubert 6760*a466cc55SCy Schubert # A PIC object. 6761*a466cc55SCy Schubert func_append libobjs " $pic_object" 6762*a466cc55SCy Schubert arg=$pic_object 6763*a466cc55SCy Schubert fi 6764*a466cc55SCy Schubert 6765*a466cc55SCy Schubert # Non-PIC object. 6766*a466cc55SCy Schubert if test none != "$non_pic_object"; then 6767*a466cc55SCy Schubert # Prepend the subdirectory the object is found in. 6768*a466cc55SCy Schubert non_pic_object=$xdir$non_pic_object 6769*a466cc55SCy Schubert 6770*a466cc55SCy Schubert # A standard non-PIC object 6771*a466cc55SCy Schubert func_append non_pic_objects " $non_pic_object" 6772*a466cc55SCy Schubert if test -z "$pic_object" || test none = "$pic_object"; then 6773*a466cc55SCy Schubert arg=$non_pic_object 6774*a466cc55SCy Schubert fi 6775*a466cc55SCy Schubert else 6776*a466cc55SCy Schubert # If the PIC object exists, use it instead. 6777*a466cc55SCy Schubert # $xdir was prepended to $pic_object above. 6778*a466cc55SCy Schubert non_pic_object=$pic_object 6779*a466cc55SCy Schubert func_append non_pic_objects " $non_pic_object" 6780*a466cc55SCy Schubert fi 6781*a466cc55SCy Schubert else 6782*a466cc55SCy Schubert # Only an error if not doing a dry-run. 6783*a466cc55SCy Schubert if $opt_dry_run; then 6784*a466cc55SCy Schubert # Extract subdirectory from the argument. 6785*a466cc55SCy Schubert func_dirname "$arg" "/" "" 6786*a466cc55SCy Schubert xdir=$func_dirname_result 6787*a466cc55SCy Schubert 6788*a466cc55SCy Schubert func_lo2o "$arg" 6789*a466cc55SCy Schubert pic_object=$xdir$objdir/$func_lo2o_result 6790*a466cc55SCy Schubert non_pic_object=$xdir$func_lo2o_result 6791*a466cc55SCy Schubert func_append libobjs " $pic_object" 6792*a466cc55SCy Schubert func_append non_pic_objects " $non_pic_object" 6793*a466cc55SCy Schubert else 6794*a466cc55SCy Schubert func_fatal_error "'$arg' is not a valid libtool object" 6795*a466cc55SCy Schubert fi 6796*a466cc55SCy Schubert fi 6797*a466cc55SCy Schubert done 6798*a466cc55SCy Schubert else 6799*a466cc55SCy Schubert func_fatal_error "link input file '$arg' does not exist" 6800*a466cc55SCy Schubert fi 6801*a466cc55SCy Schubert arg=$save_arg 6802*a466cc55SCy Schubert prev= 6803*a466cc55SCy Schubert continue 6804*a466cc55SCy Schubert ;; 6805*a466cc55SCy Schubert os2dllname) 6806*a466cc55SCy Schubert os2dllname=$arg 6807*a466cc55SCy Schubert prev= 6808*a466cc55SCy Schubert continue 6809*a466cc55SCy Schubert ;; 6810*a466cc55SCy Schubert precious_regex) 6811*a466cc55SCy Schubert precious_files_regex=$arg 6812*a466cc55SCy Schubert prev= 6813*a466cc55SCy Schubert continue 6814*a466cc55SCy Schubert ;; 6815*a466cc55SCy Schubert release) 6816*a466cc55SCy Schubert release=-$arg 6817*a466cc55SCy Schubert prev= 6818*a466cc55SCy Schubert continue 6819*a466cc55SCy Schubert ;; 6820*a466cc55SCy Schubert rpath | xrpath) 6821*a466cc55SCy Schubert # We need an absolute path. 6822*a466cc55SCy Schubert case $arg in 6823*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 6824*a466cc55SCy Schubert *) 6825*a466cc55SCy Schubert func_fatal_error "only absolute run-paths are allowed" 6826*a466cc55SCy Schubert ;; 6827*a466cc55SCy Schubert esac 6828*a466cc55SCy Schubert if test rpath = "$prev"; then 6829*a466cc55SCy Schubert case "$rpath " in 6830*a466cc55SCy Schubert *" $arg "*) ;; 6831*a466cc55SCy Schubert *) func_append rpath " $arg" ;; 6832*a466cc55SCy Schubert esac 6833*a466cc55SCy Schubert else 6834*a466cc55SCy Schubert case "$xrpath " in 6835*a466cc55SCy Schubert *" $arg "*) ;; 6836*a466cc55SCy Schubert *) func_append xrpath " $arg" ;; 6837*a466cc55SCy Schubert esac 6838*a466cc55SCy Schubert fi 6839*a466cc55SCy Schubert prev= 6840*a466cc55SCy Schubert continue 6841*a466cc55SCy Schubert ;; 6842*a466cc55SCy Schubert shrext) 6843*a466cc55SCy Schubert shrext_cmds=$arg 6844*a466cc55SCy Schubert prev= 6845*a466cc55SCy Schubert continue 6846*a466cc55SCy Schubert ;; 6847*a466cc55SCy Schubert weak) 6848*a466cc55SCy Schubert func_append weak_libs " $arg" 6849*a466cc55SCy Schubert prev= 6850*a466cc55SCy Schubert continue 6851*a466cc55SCy Schubert ;; 6852*a466cc55SCy Schubert xcclinker) 6853*a466cc55SCy Schubert func_append linker_flags " $qarg" 6854*a466cc55SCy Schubert func_append compiler_flags " $qarg" 6855*a466cc55SCy Schubert prev= 6856*a466cc55SCy Schubert func_append compile_command " $qarg" 6857*a466cc55SCy Schubert func_append finalize_command " $qarg" 6858*a466cc55SCy Schubert continue 6859*a466cc55SCy Schubert ;; 6860*a466cc55SCy Schubert xcompiler) 6861*a466cc55SCy Schubert func_append compiler_flags " $qarg" 6862*a466cc55SCy Schubert prev= 6863*a466cc55SCy Schubert func_append compile_command " $qarg" 6864*a466cc55SCy Schubert func_append finalize_command " $qarg" 6865*a466cc55SCy Schubert continue 6866*a466cc55SCy Schubert ;; 6867*a466cc55SCy Schubert xlinker) 6868*a466cc55SCy Schubert func_append linker_flags " $qarg" 6869*a466cc55SCy Schubert func_append compiler_flags " $wl$qarg" 6870*a466cc55SCy Schubert prev= 6871*a466cc55SCy Schubert func_append compile_command " $wl$qarg" 6872*a466cc55SCy Schubert func_append finalize_command " $wl$qarg" 6873*a466cc55SCy Schubert continue 6874*a466cc55SCy Schubert ;; 6875*a466cc55SCy Schubert *) 6876*a466cc55SCy Schubert eval "$prev=\"\$arg\"" 6877*a466cc55SCy Schubert prev= 6878*a466cc55SCy Schubert continue 6879*a466cc55SCy Schubert ;; 6880*a466cc55SCy Schubert esac 6881*a466cc55SCy Schubert fi # test -n "$prev" 6882*a466cc55SCy Schubert 6883*a466cc55SCy Schubert prevarg=$arg 6884*a466cc55SCy Schubert 6885*a466cc55SCy Schubert case $arg in 6886*a466cc55SCy Schubert -all-static) 6887*a466cc55SCy Schubert if test -n "$link_static_flag"; then 6888*a466cc55SCy Schubert # See comment for -static flag below, for more details. 6889*a466cc55SCy Schubert func_append compile_command " $link_static_flag" 6890*a466cc55SCy Schubert func_append finalize_command " $link_static_flag" 6891*a466cc55SCy Schubert fi 6892*a466cc55SCy Schubert continue 6893*a466cc55SCy Schubert ;; 6894*a466cc55SCy Schubert 6895*a466cc55SCy Schubert -allow-undefined) 6896*a466cc55SCy Schubert # FIXME: remove this flag sometime in the future. 6897*a466cc55SCy Schubert func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898*a466cc55SCy Schubert ;; 6899*a466cc55SCy Schubert 6900*a466cc55SCy Schubert -avoid-version) 6901*a466cc55SCy Schubert avoid_version=yes 6902*a466cc55SCy Schubert continue 6903*a466cc55SCy Schubert ;; 6904*a466cc55SCy Schubert 6905*a466cc55SCy Schubert -bindir) 6906*a466cc55SCy Schubert prev=bindir 6907*a466cc55SCy Schubert continue 6908*a466cc55SCy Schubert ;; 6909*a466cc55SCy Schubert 6910*a466cc55SCy Schubert -dlopen) 6911*a466cc55SCy Schubert prev=dlfiles 6912*a466cc55SCy Schubert continue 6913*a466cc55SCy Schubert ;; 6914*a466cc55SCy Schubert 6915*a466cc55SCy Schubert -dlpreopen) 6916*a466cc55SCy Schubert prev=dlprefiles 6917*a466cc55SCy Schubert continue 6918*a466cc55SCy Schubert ;; 6919*a466cc55SCy Schubert 6920*a466cc55SCy Schubert -export-dynamic) 6921*a466cc55SCy Schubert export_dynamic=yes 6922*a466cc55SCy Schubert continue 6923*a466cc55SCy Schubert ;; 6924*a466cc55SCy Schubert 6925*a466cc55SCy Schubert -export-symbols | -export-symbols-regex) 6926*a466cc55SCy Schubert if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927*a466cc55SCy Schubert func_fatal_error "more than one -exported-symbols argument is not allowed" 6928*a466cc55SCy Schubert fi 6929*a466cc55SCy Schubert if test X-export-symbols = "X$arg"; then 6930*a466cc55SCy Schubert prev=expsyms 6931*a466cc55SCy Schubert else 6932*a466cc55SCy Schubert prev=expsyms_regex 6933*a466cc55SCy Schubert fi 6934*a466cc55SCy Schubert continue 6935*a466cc55SCy Schubert ;; 6936*a466cc55SCy Schubert 6937*a466cc55SCy Schubert -framework) 6938*a466cc55SCy Schubert prev=framework 6939*a466cc55SCy Schubert continue 6940*a466cc55SCy Schubert ;; 6941*a466cc55SCy Schubert 6942*a466cc55SCy Schubert -inst-prefix-dir) 6943*a466cc55SCy Schubert prev=inst_prefix 6944*a466cc55SCy Schubert continue 6945*a466cc55SCy Schubert ;; 6946*a466cc55SCy Schubert 6947*a466cc55SCy Schubert # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948*a466cc55SCy Schubert # so, if we see these flags be careful not to treat them like -L 6949*a466cc55SCy Schubert -L[A-Z][A-Z]*:*) 6950*a466cc55SCy Schubert case $with_gcc/$host in 6951*a466cc55SCy Schubert no/*-*-irix* | /*-*-irix*) 6952*a466cc55SCy Schubert func_append compile_command " $arg" 6953*a466cc55SCy Schubert func_append finalize_command " $arg" 6954*a466cc55SCy Schubert ;; 6955*a466cc55SCy Schubert esac 6956*a466cc55SCy Schubert continue 6957*a466cc55SCy Schubert ;; 6958*a466cc55SCy Schubert 6959*a466cc55SCy Schubert -L*) 6960*a466cc55SCy Schubert func_stripname "-L" '' "$arg" 6961*a466cc55SCy Schubert if test -z "$func_stripname_result"; then 6962*a466cc55SCy Schubert if test "$#" -gt 0; then 6963*a466cc55SCy Schubert func_fatal_error "require no space between '-L' and '$1'" 6964*a466cc55SCy Schubert else 6965*a466cc55SCy Schubert func_fatal_error "need path for '-L' option" 6966*a466cc55SCy Schubert fi 6967*a466cc55SCy Schubert fi 6968*a466cc55SCy Schubert func_resolve_sysroot "$func_stripname_result" 6969*a466cc55SCy Schubert dir=$func_resolve_sysroot_result 6970*a466cc55SCy Schubert # We need an absolute path. 6971*a466cc55SCy Schubert case $dir in 6972*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 6973*a466cc55SCy Schubert *) 6974*a466cc55SCy Schubert absdir=`cd "$dir" && pwd` 6975*a466cc55SCy Schubert test -z "$absdir" && \ 6976*a466cc55SCy Schubert func_fatal_error "cannot determine absolute directory name of '$dir'" 6977*a466cc55SCy Schubert dir=$absdir 6978*a466cc55SCy Schubert ;; 6979*a466cc55SCy Schubert esac 6980*a466cc55SCy Schubert case "$deplibs " in 6981*a466cc55SCy Schubert *" -L$dir "* | *" $arg "*) 6982*a466cc55SCy Schubert # Will only happen for absolute or sysroot arguments 6983*a466cc55SCy Schubert ;; 6984*a466cc55SCy Schubert *) 6985*a466cc55SCy Schubert # Preserve sysroot, but never include relative directories 6986*a466cc55SCy Schubert case $dir in 6987*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988*a466cc55SCy Schubert *) func_append deplibs " -L$dir" ;; 6989*a466cc55SCy Schubert esac 6990*a466cc55SCy Schubert func_append lib_search_path " $dir" 6991*a466cc55SCy Schubert ;; 6992*a466cc55SCy Schubert esac 6993*a466cc55SCy Schubert case $host in 6994*a466cc55SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995*a466cc55SCy Schubert testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996*a466cc55SCy Schubert case :$dllsearchpath: in 6997*a466cc55SCy Schubert *":$dir:"*) ;; 6998*a466cc55SCy Schubert ::) dllsearchpath=$dir;; 6999*a466cc55SCy Schubert *) func_append dllsearchpath ":$dir";; 7000*a466cc55SCy Schubert esac 7001*a466cc55SCy Schubert case :$dllsearchpath: in 7002*a466cc55SCy Schubert *":$testbindir:"*) ;; 7003*a466cc55SCy Schubert ::) dllsearchpath=$testbindir;; 7004*a466cc55SCy Schubert *) func_append dllsearchpath ":$testbindir";; 7005*a466cc55SCy Schubert esac 7006*a466cc55SCy Schubert ;; 7007*a466cc55SCy Schubert esac 7008*a466cc55SCy Schubert continue 7009*a466cc55SCy Schubert ;; 7010*a466cc55SCy Schubert 7011*a466cc55SCy Schubert -l*) 7012*a466cc55SCy Schubert if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013*a466cc55SCy Schubert case $host in 7014*a466cc55SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015*a466cc55SCy Schubert # These systems don't actually have a C or math library (as such) 7016*a466cc55SCy Schubert continue 7017*a466cc55SCy Schubert ;; 7018*a466cc55SCy Schubert *-*-os2*) 7019*a466cc55SCy Schubert # These systems don't actually have a C library (as such) 7020*a466cc55SCy Schubert test X-lc = "X$arg" && continue 7021*a466cc55SCy Schubert ;; 7022*a466cc55SCy Schubert *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023*a466cc55SCy Schubert # Do not include libc due to us having libc/libc_r. 7024*a466cc55SCy Schubert test X-lc = "X$arg" && continue 7025*a466cc55SCy Schubert ;; 7026*a466cc55SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 7027*a466cc55SCy Schubert # Rhapsody C and math libraries are in the System framework 7028*a466cc55SCy Schubert func_append deplibs " System.ltframework" 7029*a466cc55SCy Schubert continue 7030*a466cc55SCy Schubert ;; 7031*a466cc55SCy Schubert *-*-sco3.2v5* | *-*-sco5v6*) 7032*a466cc55SCy Schubert # Causes problems with __ctype 7033*a466cc55SCy Schubert test X-lc = "X$arg" && continue 7034*a466cc55SCy Schubert ;; 7035*a466cc55SCy Schubert *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036*a466cc55SCy Schubert # Compiler inserts libc in the correct place for threads to work 7037*a466cc55SCy Schubert test X-lc = "X$arg" && continue 7038*a466cc55SCy Schubert ;; 7039*a466cc55SCy Schubert esac 7040*a466cc55SCy Schubert elif test X-lc_r = "X$arg"; then 7041*a466cc55SCy Schubert case $host in 7042*a466cc55SCy Schubert *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043*a466cc55SCy Schubert # Do not include libc_r directly, use -pthread flag. 7044*a466cc55SCy Schubert continue 7045*a466cc55SCy Schubert ;; 7046*a466cc55SCy Schubert esac 7047*a466cc55SCy Schubert fi 7048*a466cc55SCy Schubert func_append deplibs " $arg" 7049*a466cc55SCy Schubert continue 7050*a466cc55SCy Schubert ;; 7051*a466cc55SCy Schubert 7052*a466cc55SCy Schubert -mllvm) 7053*a466cc55SCy Schubert prev=mllvm 7054*a466cc55SCy Schubert continue 7055*a466cc55SCy Schubert ;; 7056*a466cc55SCy Schubert 7057*a466cc55SCy Schubert -module) 7058*a466cc55SCy Schubert module=yes 7059*a466cc55SCy Schubert continue 7060*a466cc55SCy Schubert ;; 7061*a466cc55SCy Schubert 7062*a466cc55SCy Schubert # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063*a466cc55SCy Schubert # classes, name mangling, and exception handling. 7064*a466cc55SCy Schubert # Darwin uses the -arch flag to determine output architecture. 7065*a466cc55SCy Schubert -model|-arch|-isysroot|--sysroot) 7066*a466cc55SCy Schubert func_append compiler_flags " $arg" 7067*a466cc55SCy Schubert func_append compile_command " $arg" 7068*a466cc55SCy Schubert func_append finalize_command " $arg" 7069*a466cc55SCy Schubert prev=xcompiler 7070*a466cc55SCy Schubert continue 7071*a466cc55SCy Schubert ;; 7072*a466cc55SCy Schubert 7073*a466cc55SCy Schubert -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074*a466cc55SCy Schubert |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075*a466cc55SCy Schubert func_append compiler_flags " $arg" 7076*a466cc55SCy Schubert func_append compile_command " $arg" 7077*a466cc55SCy Schubert func_append finalize_command " $arg" 7078*a466cc55SCy Schubert case "$new_inherited_linker_flags " in 7079*a466cc55SCy Schubert *" $arg "*) ;; 7080*a466cc55SCy Schubert * ) func_append new_inherited_linker_flags " $arg" ;; 7081*a466cc55SCy Schubert esac 7082*a466cc55SCy Schubert continue 7083*a466cc55SCy Schubert ;; 7084*a466cc55SCy Schubert 7085*a466cc55SCy Schubert -multi_module) 7086*a466cc55SCy Schubert single_module=$wl-multi_module 7087*a466cc55SCy Schubert continue 7088*a466cc55SCy Schubert ;; 7089*a466cc55SCy Schubert 7090*a466cc55SCy Schubert -no-fast-install) 7091*a466cc55SCy Schubert fast_install=no 7092*a466cc55SCy Schubert continue 7093*a466cc55SCy Schubert ;; 7094*a466cc55SCy Schubert 7095*a466cc55SCy Schubert -no-install) 7096*a466cc55SCy Schubert case $host in 7097*a466cc55SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098*a466cc55SCy Schubert # The PATH hackery in wrapper scripts is required on Windows 7099*a466cc55SCy Schubert # and Darwin in order for the loader to find any dlls it needs. 7100*a466cc55SCy Schubert func_warning "'-no-install' is ignored for $host" 7101*a466cc55SCy Schubert func_warning "assuming '-no-fast-install' instead" 7102*a466cc55SCy Schubert fast_install=no 7103*a466cc55SCy Schubert ;; 7104*a466cc55SCy Schubert *) no_install=yes ;; 7105*a466cc55SCy Schubert esac 7106*a466cc55SCy Schubert continue 7107*a466cc55SCy Schubert ;; 7108*a466cc55SCy Schubert 7109*a466cc55SCy Schubert -no-undefined) 7110*a466cc55SCy Schubert allow_undefined=no 7111*a466cc55SCy Schubert continue 7112*a466cc55SCy Schubert ;; 7113*a466cc55SCy Schubert 7114*a466cc55SCy Schubert -objectlist) 7115*a466cc55SCy Schubert prev=objectlist 7116*a466cc55SCy Schubert continue 7117*a466cc55SCy Schubert ;; 7118*a466cc55SCy Schubert 7119*a466cc55SCy Schubert -os2dllname) 7120*a466cc55SCy Schubert prev=os2dllname 7121*a466cc55SCy Schubert continue 7122*a466cc55SCy Schubert ;; 7123*a466cc55SCy Schubert 7124*a466cc55SCy Schubert -o) prev=output ;; 7125*a466cc55SCy Schubert 7126*a466cc55SCy Schubert -precious-files-regex) 7127*a466cc55SCy Schubert prev=precious_regex 7128*a466cc55SCy Schubert continue 7129*a466cc55SCy Schubert ;; 7130*a466cc55SCy Schubert 7131*a466cc55SCy Schubert -release) 7132*a466cc55SCy Schubert prev=release 7133*a466cc55SCy Schubert continue 7134*a466cc55SCy Schubert ;; 7135*a466cc55SCy Schubert 7136*a466cc55SCy Schubert -rpath) 7137*a466cc55SCy Schubert prev=rpath 7138*a466cc55SCy Schubert continue 7139*a466cc55SCy Schubert ;; 7140*a466cc55SCy Schubert 7141*a466cc55SCy Schubert -R) 7142*a466cc55SCy Schubert prev=xrpath 7143*a466cc55SCy Schubert continue 7144*a466cc55SCy Schubert ;; 7145*a466cc55SCy Schubert 7146*a466cc55SCy Schubert -R*) 7147*a466cc55SCy Schubert func_stripname '-R' '' "$arg" 7148*a466cc55SCy Schubert dir=$func_stripname_result 7149*a466cc55SCy Schubert # We need an absolute path. 7150*a466cc55SCy Schubert case $dir in 7151*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) ;; 7152*a466cc55SCy Schubert =*) 7153*a466cc55SCy Schubert func_stripname '=' '' "$dir" 7154*a466cc55SCy Schubert dir=$lt_sysroot$func_stripname_result 7155*a466cc55SCy Schubert ;; 7156*a466cc55SCy Schubert *) 7157*a466cc55SCy Schubert func_fatal_error "only absolute run-paths are allowed" 7158*a466cc55SCy Schubert ;; 7159*a466cc55SCy Schubert esac 7160*a466cc55SCy Schubert case "$xrpath " in 7161*a466cc55SCy Schubert *" $dir "*) ;; 7162*a466cc55SCy Schubert *) func_append xrpath " $dir" ;; 7163*a466cc55SCy Schubert esac 7164*a466cc55SCy Schubert continue 7165*a466cc55SCy Schubert ;; 7166*a466cc55SCy Schubert 7167*a466cc55SCy Schubert -shared) 7168*a466cc55SCy Schubert # The effects of -shared are defined in a previous loop. 7169*a466cc55SCy Schubert continue 7170*a466cc55SCy Schubert ;; 7171*a466cc55SCy Schubert 7172*a466cc55SCy Schubert -shrext) 7173*a466cc55SCy Schubert prev=shrext 7174*a466cc55SCy Schubert continue 7175*a466cc55SCy Schubert ;; 7176*a466cc55SCy Schubert 7177*a466cc55SCy Schubert -static | -static-libtool-libs) 7178*a466cc55SCy Schubert # The effects of -static are defined in a previous loop. 7179*a466cc55SCy Schubert # We used to do the same as -all-static on platforms that 7180*a466cc55SCy Schubert # didn't have a PIC flag, but the assumption that the effects 7181*a466cc55SCy Schubert # would be equivalent was wrong. It would break on at least 7182*a466cc55SCy Schubert # Digital Unix and AIX. 7183*a466cc55SCy Schubert continue 7184*a466cc55SCy Schubert ;; 7185*a466cc55SCy Schubert 7186*a466cc55SCy Schubert -thread-safe) 7187*a466cc55SCy Schubert thread_safe=yes 7188*a466cc55SCy Schubert continue 7189*a466cc55SCy Schubert ;; 7190*a466cc55SCy Schubert 7191*a466cc55SCy Schubert -version-info) 7192*a466cc55SCy Schubert prev=vinfo 7193*a466cc55SCy Schubert continue 7194*a466cc55SCy Schubert ;; 7195*a466cc55SCy Schubert 7196*a466cc55SCy Schubert -version-number) 7197*a466cc55SCy Schubert prev=vinfo 7198*a466cc55SCy Schubert vinfo_number=yes 7199*a466cc55SCy Schubert continue 7200*a466cc55SCy Schubert ;; 7201*a466cc55SCy Schubert 7202*a466cc55SCy Schubert -weak) 7203*a466cc55SCy Schubert prev=weak 7204*a466cc55SCy Schubert continue 7205*a466cc55SCy Schubert ;; 7206*a466cc55SCy Schubert 7207*a466cc55SCy Schubert -Wc,*) 7208*a466cc55SCy Schubert func_stripname '-Wc,' '' "$arg" 7209*a466cc55SCy Schubert args=$func_stripname_result 7210*a466cc55SCy Schubert arg= 7211*a466cc55SCy Schubert save_ifs=$IFS; IFS=, 7212*a466cc55SCy Schubert for flag in $args; do 7213*a466cc55SCy Schubert IFS=$save_ifs 7214*a466cc55SCy Schubert func_quote_for_eval "$flag" 7215*a466cc55SCy Schubert func_append arg " $func_quote_for_eval_result" 7216*a466cc55SCy Schubert func_append compiler_flags " $func_quote_for_eval_result" 7217*a466cc55SCy Schubert done 7218*a466cc55SCy Schubert IFS=$save_ifs 7219*a466cc55SCy Schubert func_stripname ' ' '' "$arg" 7220*a466cc55SCy Schubert arg=$func_stripname_result 7221*a466cc55SCy Schubert ;; 7222*a466cc55SCy Schubert 7223*a466cc55SCy Schubert -Wl,*) 7224*a466cc55SCy Schubert func_stripname '-Wl,' '' "$arg" 7225*a466cc55SCy Schubert args=$func_stripname_result 7226*a466cc55SCy Schubert arg= 7227*a466cc55SCy Schubert save_ifs=$IFS; IFS=, 7228*a466cc55SCy Schubert for flag in $args; do 7229*a466cc55SCy Schubert IFS=$save_ifs 7230*a466cc55SCy Schubert func_quote_for_eval "$flag" 7231*a466cc55SCy Schubert func_append arg " $wl$func_quote_for_eval_result" 7232*a466cc55SCy Schubert func_append compiler_flags " $wl$func_quote_for_eval_result" 7233*a466cc55SCy Schubert func_append linker_flags " $func_quote_for_eval_result" 7234*a466cc55SCy Schubert done 7235*a466cc55SCy Schubert IFS=$save_ifs 7236*a466cc55SCy Schubert func_stripname ' ' '' "$arg" 7237*a466cc55SCy Schubert arg=$func_stripname_result 7238*a466cc55SCy Schubert ;; 7239*a466cc55SCy Schubert 7240*a466cc55SCy Schubert -Xcompiler) 7241*a466cc55SCy Schubert prev=xcompiler 7242*a466cc55SCy Schubert continue 7243*a466cc55SCy Schubert ;; 7244*a466cc55SCy Schubert 7245*a466cc55SCy Schubert -Xlinker) 7246*a466cc55SCy Schubert prev=xlinker 7247*a466cc55SCy Schubert continue 7248*a466cc55SCy Schubert ;; 7249*a466cc55SCy Schubert 7250*a466cc55SCy Schubert -XCClinker) 7251*a466cc55SCy Schubert prev=xcclinker 7252*a466cc55SCy Schubert continue 7253*a466cc55SCy Schubert ;; 7254*a466cc55SCy Schubert 7255*a466cc55SCy Schubert # -msg_* for osf cc 7256*a466cc55SCy Schubert -msg_*) 7257*a466cc55SCy Schubert func_quote_for_eval "$arg" 7258*a466cc55SCy Schubert arg=$func_quote_for_eval_result 7259*a466cc55SCy Schubert ;; 7260*a466cc55SCy Schubert 7261*a466cc55SCy Schubert # Flags to be passed through unchanged, with rationale: 7262*a466cc55SCy Schubert # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263*a466cc55SCy Schubert # -r[0-9][0-9]* specify processor for the SGI compiler 7264*a466cc55SCy Schubert # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265*a466cc55SCy Schubert # +DA*, +DD* enable 64-bit mode for the HP compiler 7266*a466cc55SCy Schubert # -q* compiler args for the IBM compiler 7267*a466cc55SCy Schubert # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268*a466cc55SCy Schubert # -F/path path to uninstalled frameworks, gcc on darwin 7269*a466cc55SCy Schubert # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270*a466cc55SCy Schubert # -fstack-protector* stack protector flags for GCC 7271*a466cc55SCy Schubert # @file GCC response files 7272*a466cc55SCy Schubert # -tp=* Portland pgcc target processor selection 7273*a466cc55SCy Schubert # --sysroot=* for sysroot support 7274*a466cc55SCy Schubert # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275*a466cc55SCy Schubert # -stdlib=* select c++ std lib with clang 7276*a466cc55SCy Schubert -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277*a466cc55SCy Schubert -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7278*a466cc55SCy Schubert -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279*a466cc55SCy Schubert func_quote_for_eval "$arg" 7280*a466cc55SCy Schubert arg=$func_quote_for_eval_result 7281*a466cc55SCy Schubert func_append compile_command " $arg" 7282*a466cc55SCy Schubert func_append finalize_command " $arg" 7283*a466cc55SCy Schubert func_append compiler_flags " $arg" 7284*a466cc55SCy Schubert continue 7285*a466cc55SCy Schubert ;; 7286*a466cc55SCy Schubert 7287*a466cc55SCy Schubert -Z*) 7288*a466cc55SCy Schubert if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289*a466cc55SCy Schubert # OS/2 uses -Zxxx to specify OS/2-specific options 7290*a466cc55SCy Schubert compiler_flags="$compiler_flags $arg" 7291*a466cc55SCy Schubert func_append compile_command " $arg" 7292*a466cc55SCy Schubert func_append finalize_command " $arg" 7293*a466cc55SCy Schubert case $arg in 7294*a466cc55SCy Schubert -Zlinker | -Zstack) 7295*a466cc55SCy Schubert prev=xcompiler 7296*a466cc55SCy Schubert ;; 7297*a466cc55SCy Schubert esac 7298*a466cc55SCy Schubert continue 7299*a466cc55SCy Schubert else 7300*a466cc55SCy Schubert # Otherwise treat like 'Some other compiler flag' below 7301*a466cc55SCy Schubert func_quote_for_eval "$arg" 7302*a466cc55SCy Schubert arg=$func_quote_for_eval_result 7303*a466cc55SCy Schubert fi 7304*a466cc55SCy Schubert ;; 7305*a466cc55SCy Schubert 7306*a466cc55SCy Schubert # Some other compiler flag. 7307*a466cc55SCy Schubert -* | +*) 7308*a466cc55SCy Schubert func_quote_for_eval "$arg" 7309*a466cc55SCy Schubert arg=$func_quote_for_eval_result 7310*a466cc55SCy Schubert ;; 7311*a466cc55SCy Schubert 7312*a466cc55SCy Schubert *.$objext) 7313*a466cc55SCy Schubert # A standard object. 7314*a466cc55SCy Schubert func_append objs " $arg" 7315*a466cc55SCy Schubert ;; 7316*a466cc55SCy Schubert 7317*a466cc55SCy Schubert *.lo) 7318*a466cc55SCy Schubert # A libtool-controlled object. 7319*a466cc55SCy Schubert 7320*a466cc55SCy Schubert # Check to see that this really is a libtool object. 7321*a466cc55SCy Schubert if func_lalib_unsafe_p "$arg"; then 7322*a466cc55SCy Schubert pic_object= 7323*a466cc55SCy Schubert non_pic_object= 7324*a466cc55SCy Schubert 7325*a466cc55SCy Schubert # Read the .lo file 7326*a466cc55SCy Schubert func_source "$arg" 7327*a466cc55SCy Schubert 7328*a466cc55SCy Schubert if test -z "$pic_object" || 7329*a466cc55SCy Schubert test -z "$non_pic_object" || 7330*a466cc55SCy Schubert test none = "$pic_object" && 7331*a466cc55SCy Schubert test none = "$non_pic_object"; then 7332*a466cc55SCy Schubert func_fatal_error "cannot find name of object for '$arg'" 7333*a466cc55SCy Schubert fi 7334*a466cc55SCy Schubert 7335*a466cc55SCy Schubert # Extract subdirectory from the argument. 7336*a466cc55SCy Schubert func_dirname "$arg" "/" "" 7337*a466cc55SCy Schubert xdir=$func_dirname_result 7338*a466cc55SCy Schubert 7339*a466cc55SCy Schubert test none = "$pic_object" || { 7340*a466cc55SCy Schubert # Prepend the subdirectory the object is found in. 7341*a466cc55SCy Schubert pic_object=$xdir$pic_object 7342*a466cc55SCy Schubert 7343*a466cc55SCy Schubert if test dlfiles = "$prev"; then 7344*a466cc55SCy Schubert if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345*a466cc55SCy Schubert func_append dlfiles " $pic_object" 7346*a466cc55SCy Schubert prev= 7347*a466cc55SCy Schubert continue 7348*a466cc55SCy Schubert else 7349*a466cc55SCy Schubert # If libtool objects are unsupported, then we need to preload. 7350*a466cc55SCy Schubert prev=dlprefiles 7351*a466cc55SCy Schubert fi 7352*a466cc55SCy Schubert fi 7353*a466cc55SCy Schubert 7354*a466cc55SCy Schubert # CHECK ME: I think I busted this. -Ossama 7355*a466cc55SCy Schubert if test dlprefiles = "$prev"; then 7356*a466cc55SCy Schubert # Preload the old-style object. 7357*a466cc55SCy Schubert func_append dlprefiles " $pic_object" 7358*a466cc55SCy Schubert prev= 7359*a466cc55SCy Schubert fi 7360*a466cc55SCy Schubert 7361*a466cc55SCy Schubert # A PIC object. 7362*a466cc55SCy Schubert func_append libobjs " $pic_object" 7363*a466cc55SCy Schubert arg=$pic_object 7364*a466cc55SCy Schubert } 7365*a466cc55SCy Schubert 7366*a466cc55SCy Schubert # Non-PIC object. 7367*a466cc55SCy Schubert if test none != "$non_pic_object"; then 7368*a466cc55SCy Schubert # Prepend the subdirectory the object is found in. 7369*a466cc55SCy Schubert non_pic_object=$xdir$non_pic_object 7370*a466cc55SCy Schubert 7371*a466cc55SCy Schubert # A standard non-PIC object 7372*a466cc55SCy Schubert func_append non_pic_objects " $non_pic_object" 7373*a466cc55SCy Schubert if test -z "$pic_object" || test none = "$pic_object"; then 7374*a466cc55SCy Schubert arg=$non_pic_object 7375*a466cc55SCy Schubert fi 7376*a466cc55SCy Schubert else 7377*a466cc55SCy Schubert # If the PIC object exists, use it instead. 7378*a466cc55SCy Schubert # $xdir was prepended to $pic_object above. 7379*a466cc55SCy Schubert non_pic_object=$pic_object 7380*a466cc55SCy Schubert func_append non_pic_objects " $non_pic_object" 7381*a466cc55SCy Schubert fi 7382*a466cc55SCy Schubert else 7383*a466cc55SCy Schubert # Only an error if not doing a dry-run. 7384*a466cc55SCy Schubert if $opt_dry_run; then 7385*a466cc55SCy Schubert # Extract subdirectory from the argument. 7386*a466cc55SCy Schubert func_dirname "$arg" "/" "" 7387*a466cc55SCy Schubert xdir=$func_dirname_result 7388*a466cc55SCy Schubert 7389*a466cc55SCy Schubert func_lo2o "$arg" 7390*a466cc55SCy Schubert pic_object=$xdir$objdir/$func_lo2o_result 7391*a466cc55SCy Schubert non_pic_object=$xdir$func_lo2o_result 7392*a466cc55SCy Schubert func_append libobjs " $pic_object" 7393*a466cc55SCy Schubert func_append non_pic_objects " $non_pic_object" 7394*a466cc55SCy Schubert else 7395*a466cc55SCy Schubert func_fatal_error "'$arg' is not a valid libtool object" 7396*a466cc55SCy Schubert fi 7397*a466cc55SCy Schubert fi 7398*a466cc55SCy Schubert ;; 7399*a466cc55SCy Schubert 7400*a466cc55SCy Schubert *.$libext) 7401*a466cc55SCy Schubert # An archive. 7402*a466cc55SCy Schubert func_append deplibs " $arg" 7403*a466cc55SCy Schubert func_append old_deplibs " $arg" 7404*a466cc55SCy Schubert continue 7405*a466cc55SCy Schubert ;; 7406*a466cc55SCy Schubert 7407*a466cc55SCy Schubert *.la) 7408*a466cc55SCy Schubert # A libtool-controlled library. 7409*a466cc55SCy Schubert 7410*a466cc55SCy Schubert func_resolve_sysroot "$arg" 7411*a466cc55SCy Schubert if test dlfiles = "$prev"; then 7412*a466cc55SCy Schubert # This library was specified with -dlopen. 7413*a466cc55SCy Schubert func_append dlfiles " $func_resolve_sysroot_result" 7414*a466cc55SCy Schubert prev= 7415*a466cc55SCy Schubert elif test dlprefiles = "$prev"; then 7416*a466cc55SCy Schubert # The library was specified with -dlpreopen. 7417*a466cc55SCy Schubert func_append dlprefiles " $func_resolve_sysroot_result" 7418*a466cc55SCy Schubert prev= 7419*a466cc55SCy Schubert else 7420*a466cc55SCy Schubert func_append deplibs " $func_resolve_sysroot_result" 7421*a466cc55SCy Schubert fi 7422*a466cc55SCy Schubert continue 7423*a466cc55SCy Schubert ;; 7424*a466cc55SCy Schubert 7425*a466cc55SCy Schubert # Some other compiler argument. 7426*a466cc55SCy Schubert *) 7427*a466cc55SCy Schubert # Unknown arguments in both finalize_command and compile_command need 7428*a466cc55SCy Schubert # to be aesthetically quoted because they are evaled later. 7429*a466cc55SCy Schubert func_quote_for_eval "$arg" 7430*a466cc55SCy Schubert arg=$func_quote_for_eval_result 7431*a466cc55SCy Schubert ;; 7432*a466cc55SCy Schubert esac # arg 7433*a466cc55SCy Schubert 7434*a466cc55SCy Schubert # Now actually substitute the argument into the commands. 7435*a466cc55SCy Schubert if test -n "$arg"; then 7436*a466cc55SCy Schubert func_append compile_command " $arg" 7437*a466cc55SCy Schubert func_append finalize_command " $arg" 7438*a466cc55SCy Schubert fi 7439*a466cc55SCy Schubert done # argument parsing loop 7440*a466cc55SCy Schubert 7441*a466cc55SCy Schubert test -n "$prev" && \ 7442*a466cc55SCy Schubert func_fatal_help "the '$prevarg' option requires an argument" 7443*a466cc55SCy Schubert 7444*a466cc55SCy Schubert if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445*a466cc55SCy Schubert eval arg=\"$export_dynamic_flag_spec\" 7446*a466cc55SCy Schubert func_append compile_command " $arg" 7447*a466cc55SCy Schubert func_append finalize_command " $arg" 7448*a466cc55SCy Schubert fi 7449*a466cc55SCy Schubert 7450*a466cc55SCy Schubert oldlibs= 7451*a466cc55SCy Schubert # calculate the name of the file, without its directory 7452*a466cc55SCy Schubert func_basename "$output" 7453*a466cc55SCy Schubert outputname=$func_basename_result 7454*a466cc55SCy Schubert libobjs_save=$libobjs 7455*a466cc55SCy Schubert 7456*a466cc55SCy Schubert if test -n "$shlibpath_var"; then 7457*a466cc55SCy Schubert # get the directories listed in $shlibpath_var 7458*a466cc55SCy Schubert eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459*a466cc55SCy Schubert else 7460*a466cc55SCy Schubert shlib_search_path= 7461*a466cc55SCy Schubert fi 7462*a466cc55SCy Schubert eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463*a466cc55SCy Schubert eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464*a466cc55SCy Schubert 7465*a466cc55SCy Schubert # Definition is injected by LT_CONFIG during libtool generation. 7466*a466cc55SCy Schubert func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467*a466cc55SCy Schubert 7468*a466cc55SCy Schubert func_dirname "$output" "/" "" 7469*a466cc55SCy Schubert output_objdir=$func_dirname_result$objdir 7470*a466cc55SCy Schubert func_to_tool_file "$output_objdir/" 7471*a466cc55SCy Schubert tool_output_objdir=$func_to_tool_file_result 7472*a466cc55SCy Schubert # Create the object directory. 7473*a466cc55SCy Schubert func_mkdir_p "$output_objdir" 7474*a466cc55SCy Schubert 7475*a466cc55SCy Schubert # Determine the type of output 7476*a466cc55SCy Schubert case $output in 7477*a466cc55SCy Schubert "") 7478*a466cc55SCy Schubert func_fatal_help "you must specify an output file" 7479*a466cc55SCy Schubert ;; 7480*a466cc55SCy Schubert *.$libext) linkmode=oldlib ;; 7481*a466cc55SCy Schubert *.lo | *.$objext) linkmode=obj ;; 7482*a466cc55SCy Schubert *.la) linkmode=lib ;; 7483*a466cc55SCy Schubert *) linkmode=prog ;; # Anything else should be a program. 7484*a466cc55SCy Schubert esac 7485*a466cc55SCy Schubert 7486*a466cc55SCy Schubert specialdeplibs= 7487*a466cc55SCy Schubert 7488*a466cc55SCy Schubert libs= 7489*a466cc55SCy Schubert # Find all interdependent deplibs by searching for libraries 7490*a466cc55SCy Schubert # that are linked more than once (e.g. -la -lb -la) 7491*a466cc55SCy Schubert for deplib in $deplibs; do 7492*a466cc55SCy Schubert if $opt_preserve_dup_deps; then 7493*a466cc55SCy Schubert case "$libs " in 7494*a466cc55SCy Schubert *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495*a466cc55SCy Schubert esac 7496*a466cc55SCy Schubert fi 7497*a466cc55SCy Schubert func_append libs " $deplib" 7498*a466cc55SCy Schubert done 7499*a466cc55SCy Schubert 7500*a466cc55SCy Schubert if test lib = "$linkmode"; then 7501*a466cc55SCy Schubert libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502*a466cc55SCy Schubert 7503*a466cc55SCy Schubert # Compute libraries that are listed more than once in $predeps 7504*a466cc55SCy Schubert # $postdeps and mark them as special (i.e., whose duplicates are 7505*a466cc55SCy Schubert # not to be eliminated). 7506*a466cc55SCy Schubert pre_post_deps= 7507*a466cc55SCy Schubert if $opt_duplicate_compiler_generated_deps; then 7508*a466cc55SCy Schubert for pre_post_dep in $predeps $postdeps; do 7509*a466cc55SCy Schubert case "$pre_post_deps " in 7510*a466cc55SCy Schubert *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511*a466cc55SCy Schubert esac 7512*a466cc55SCy Schubert func_append pre_post_deps " $pre_post_dep" 7513*a466cc55SCy Schubert done 7514*a466cc55SCy Schubert fi 7515*a466cc55SCy Schubert pre_post_deps= 7516*a466cc55SCy Schubert fi 7517*a466cc55SCy Schubert 7518*a466cc55SCy Schubert deplibs= 7519*a466cc55SCy Schubert newdependency_libs= 7520*a466cc55SCy Schubert newlib_search_path= 7521*a466cc55SCy Schubert need_relink=no # whether we're linking any uninstalled libtool libraries 7522*a466cc55SCy Schubert notinst_deplibs= # not-installed libtool libraries 7523*a466cc55SCy Schubert notinst_path= # paths that contain not-installed libtool libraries 7524*a466cc55SCy Schubert 7525*a466cc55SCy Schubert case $linkmode in 7526*a466cc55SCy Schubert lib) 7527*a466cc55SCy Schubert passes="conv dlpreopen link" 7528*a466cc55SCy Schubert for file in $dlfiles $dlprefiles; do 7529*a466cc55SCy Schubert case $file in 7530*a466cc55SCy Schubert *.la) ;; 7531*a466cc55SCy Schubert *) 7532*a466cc55SCy Schubert func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533*a466cc55SCy Schubert ;; 7534*a466cc55SCy Schubert esac 7535*a466cc55SCy Schubert done 7536*a466cc55SCy Schubert ;; 7537*a466cc55SCy Schubert prog) 7538*a466cc55SCy Schubert compile_deplibs= 7539*a466cc55SCy Schubert finalize_deplibs= 7540*a466cc55SCy Schubert alldeplibs=false 7541*a466cc55SCy Schubert newdlfiles= 7542*a466cc55SCy Schubert newdlprefiles= 7543*a466cc55SCy Schubert passes="conv scan dlopen dlpreopen link" 7544*a466cc55SCy Schubert ;; 7545*a466cc55SCy Schubert *) passes="conv" 7546*a466cc55SCy Schubert ;; 7547*a466cc55SCy Schubert esac 7548*a466cc55SCy Schubert 7549*a466cc55SCy Schubert for pass in $passes; do 7550*a466cc55SCy Schubert # The preopen pass in lib mode reverses $deplibs; put it back here 7551*a466cc55SCy Schubert # so that -L comes before libs that need it for instance... 7552*a466cc55SCy Schubert if test lib,link = "$linkmode,$pass"; then 7553*a466cc55SCy Schubert ## FIXME: Find the place where the list is rebuilt in the wrong 7554*a466cc55SCy Schubert ## order, and fix it there properly 7555*a466cc55SCy Schubert tmp_deplibs= 7556*a466cc55SCy Schubert for deplib in $deplibs; do 7557*a466cc55SCy Schubert tmp_deplibs="$deplib $tmp_deplibs" 7558*a466cc55SCy Schubert done 7559*a466cc55SCy Schubert deplibs=$tmp_deplibs 7560*a466cc55SCy Schubert fi 7561*a466cc55SCy Schubert 7562*a466cc55SCy Schubert if test lib,link = "$linkmode,$pass" || 7563*a466cc55SCy Schubert test prog,scan = "$linkmode,$pass"; then 7564*a466cc55SCy Schubert libs=$deplibs 7565*a466cc55SCy Schubert deplibs= 7566*a466cc55SCy Schubert fi 7567*a466cc55SCy Schubert if test prog = "$linkmode"; then 7568*a466cc55SCy Schubert case $pass in 7569*a466cc55SCy Schubert dlopen) libs=$dlfiles ;; 7570*a466cc55SCy Schubert dlpreopen) libs=$dlprefiles ;; 7571*a466cc55SCy Schubert link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572*a466cc55SCy Schubert esac 7573*a466cc55SCy Schubert fi 7574*a466cc55SCy Schubert if test lib,dlpreopen = "$linkmode,$pass"; then 7575*a466cc55SCy Schubert # Collect and forward deplibs of preopened libtool libs 7576*a466cc55SCy Schubert for lib in $dlprefiles; do 7577*a466cc55SCy Schubert # Ignore non-libtool-libs 7578*a466cc55SCy Schubert dependency_libs= 7579*a466cc55SCy Schubert func_resolve_sysroot "$lib" 7580*a466cc55SCy Schubert case $lib in 7581*a466cc55SCy Schubert *.la) func_source "$func_resolve_sysroot_result" ;; 7582*a466cc55SCy Schubert esac 7583*a466cc55SCy Schubert 7584*a466cc55SCy Schubert # Collect preopened libtool deplibs, except any this library 7585*a466cc55SCy Schubert # has declared as weak libs 7586*a466cc55SCy Schubert for deplib in $dependency_libs; do 7587*a466cc55SCy Schubert func_basename "$deplib" 7588*a466cc55SCy Schubert deplib_base=$func_basename_result 7589*a466cc55SCy Schubert case " $weak_libs " in 7590*a466cc55SCy Schubert *" $deplib_base "*) ;; 7591*a466cc55SCy Schubert *) func_append deplibs " $deplib" ;; 7592*a466cc55SCy Schubert esac 7593*a466cc55SCy Schubert done 7594*a466cc55SCy Schubert done 7595*a466cc55SCy Schubert libs=$dlprefiles 7596*a466cc55SCy Schubert fi 7597*a466cc55SCy Schubert if test dlopen = "$pass"; then 7598*a466cc55SCy Schubert # Collect dlpreopened libraries 7599*a466cc55SCy Schubert save_deplibs=$deplibs 7600*a466cc55SCy Schubert deplibs= 7601*a466cc55SCy Schubert fi 7602*a466cc55SCy Schubert 7603*a466cc55SCy Schubert for deplib in $libs; do 7604*a466cc55SCy Schubert lib= 7605*a466cc55SCy Schubert found=false 7606*a466cc55SCy Schubert case $deplib in 7607*a466cc55SCy Schubert -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608*a466cc55SCy Schubert |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609*a466cc55SCy Schubert if test prog,link = "$linkmode,$pass"; then 7610*a466cc55SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7611*a466cc55SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7612*a466cc55SCy Schubert else 7613*a466cc55SCy Schubert func_append compiler_flags " $deplib" 7614*a466cc55SCy Schubert if test lib = "$linkmode"; then 7615*a466cc55SCy Schubert case "$new_inherited_linker_flags " in 7616*a466cc55SCy Schubert *" $deplib "*) ;; 7617*a466cc55SCy Schubert * ) func_append new_inherited_linker_flags " $deplib" ;; 7618*a466cc55SCy Schubert esac 7619*a466cc55SCy Schubert fi 7620*a466cc55SCy Schubert fi 7621*a466cc55SCy Schubert continue 7622*a466cc55SCy Schubert ;; 7623*a466cc55SCy Schubert -l*) 7624*a466cc55SCy Schubert if test lib != "$linkmode" && test prog != "$linkmode"; then 7625*a466cc55SCy Schubert func_warning "'-l' is ignored for archives/objects" 7626*a466cc55SCy Schubert continue 7627*a466cc55SCy Schubert fi 7628*a466cc55SCy Schubert func_stripname '-l' '' "$deplib" 7629*a466cc55SCy Schubert name=$func_stripname_result 7630*a466cc55SCy Schubert if test lib = "$linkmode"; then 7631*a466cc55SCy Schubert searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632*a466cc55SCy Schubert else 7633*a466cc55SCy Schubert searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634*a466cc55SCy Schubert fi 7635*a466cc55SCy Schubert for searchdir in $searchdirs; do 7636*a466cc55SCy Schubert for search_ext in .la $std_shrext .so .a; do 7637*a466cc55SCy Schubert # Search the libtool library 7638*a466cc55SCy Schubert lib=$searchdir/lib$name$search_ext 7639*a466cc55SCy Schubert if test -f "$lib"; then 7640*a466cc55SCy Schubert if test .la = "$search_ext"; then 7641*a466cc55SCy Schubert found=: 7642*a466cc55SCy Schubert else 7643*a466cc55SCy Schubert found=false 7644*a466cc55SCy Schubert fi 7645*a466cc55SCy Schubert break 2 7646*a466cc55SCy Schubert fi 7647*a466cc55SCy Schubert done 7648*a466cc55SCy Schubert done 7649*a466cc55SCy Schubert if $found; then 7650*a466cc55SCy Schubert # deplib is a libtool library 7651*a466cc55SCy Schubert # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652*a466cc55SCy Schubert # We need to do some special things here, and not later. 7653*a466cc55SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654*a466cc55SCy Schubert case " $predeps $postdeps " in 7655*a466cc55SCy Schubert *" $deplib "*) 7656*a466cc55SCy Schubert if func_lalib_p "$lib"; then 7657*a466cc55SCy Schubert library_names= 7658*a466cc55SCy Schubert old_library= 7659*a466cc55SCy Schubert func_source "$lib" 7660*a466cc55SCy Schubert for l in $old_library $library_names; do 7661*a466cc55SCy Schubert ll=$l 7662*a466cc55SCy Schubert done 7663*a466cc55SCy Schubert if test "X$ll" = "X$old_library"; then # only static version available 7664*a466cc55SCy Schubert found=false 7665*a466cc55SCy Schubert func_dirname "$lib" "" "." 7666*a466cc55SCy Schubert ladir=$func_dirname_result 7667*a466cc55SCy Schubert lib=$ladir/$old_library 7668*a466cc55SCy Schubert if test prog,link = "$linkmode,$pass"; then 7669*a466cc55SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7670*a466cc55SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7671*a466cc55SCy Schubert else 7672*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7673*a466cc55SCy Schubert test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674*a466cc55SCy Schubert fi 7675*a466cc55SCy Schubert continue 7676*a466cc55SCy Schubert fi 7677*a466cc55SCy Schubert fi 7678*a466cc55SCy Schubert ;; 7679*a466cc55SCy Schubert *) ;; 7680*a466cc55SCy Schubert esac 7681*a466cc55SCy Schubert fi 7682*a466cc55SCy Schubert else 7683*a466cc55SCy Schubert # deplib doesn't seem to be a libtool library 7684*a466cc55SCy Schubert if test prog,link = "$linkmode,$pass"; then 7685*a466cc55SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7686*a466cc55SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7687*a466cc55SCy Schubert else 7688*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7689*a466cc55SCy Schubert test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690*a466cc55SCy Schubert fi 7691*a466cc55SCy Schubert continue 7692*a466cc55SCy Schubert fi 7693*a466cc55SCy Schubert ;; # -l 7694*a466cc55SCy Schubert *.ltframework) 7695*a466cc55SCy Schubert if test prog,link = "$linkmode,$pass"; then 7696*a466cc55SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7697*a466cc55SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7698*a466cc55SCy Schubert else 7699*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7700*a466cc55SCy Schubert if test lib = "$linkmode"; then 7701*a466cc55SCy Schubert case "$new_inherited_linker_flags " in 7702*a466cc55SCy Schubert *" $deplib "*) ;; 7703*a466cc55SCy Schubert * ) func_append new_inherited_linker_flags " $deplib" ;; 7704*a466cc55SCy Schubert esac 7705*a466cc55SCy Schubert fi 7706*a466cc55SCy Schubert fi 7707*a466cc55SCy Schubert continue 7708*a466cc55SCy Schubert ;; 7709*a466cc55SCy Schubert -L*) 7710*a466cc55SCy Schubert case $linkmode in 7711*a466cc55SCy Schubert lib) 7712*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7713*a466cc55SCy Schubert test conv = "$pass" && continue 7714*a466cc55SCy Schubert newdependency_libs="$deplib $newdependency_libs" 7715*a466cc55SCy Schubert func_stripname '-L' '' "$deplib" 7716*a466cc55SCy Schubert func_resolve_sysroot "$func_stripname_result" 7717*a466cc55SCy Schubert func_append newlib_search_path " $func_resolve_sysroot_result" 7718*a466cc55SCy Schubert ;; 7719*a466cc55SCy Schubert prog) 7720*a466cc55SCy Schubert if test conv = "$pass"; then 7721*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7722*a466cc55SCy Schubert continue 7723*a466cc55SCy Schubert fi 7724*a466cc55SCy Schubert if test scan = "$pass"; then 7725*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7726*a466cc55SCy Schubert else 7727*a466cc55SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7728*a466cc55SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7729*a466cc55SCy Schubert fi 7730*a466cc55SCy Schubert func_stripname '-L' '' "$deplib" 7731*a466cc55SCy Schubert func_resolve_sysroot "$func_stripname_result" 7732*a466cc55SCy Schubert func_append newlib_search_path " $func_resolve_sysroot_result" 7733*a466cc55SCy Schubert ;; 7734*a466cc55SCy Schubert *) 7735*a466cc55SCy Schubert func_warning "'-L' is ignored for archives/objects" 7736*a466cc55SCy Schubert ;; 7737*a466cc55SCy Schubert esac # linkmode 7738*a466cc55SCy Schubert continue 7739*a466cc55SCy Schubert ;; # -L 7740*a466cc55SCy Schubert -R*) 7741*a466cc55SCy Schubert if test link = "$pass"; then 7742*a466cc55SCy Schubert func_stripname '-R' '' "$deplib" 7743*a466cc55SCy Schubert func_resolve_sysroot "$func_stripname_result" 7744*a466cc55SCy Schubert dir=$func_resolve_sysroot_result 7745*a466cc55SCy Schubert # Make sure the xrpath contains only unique directories. 7746*a466cc55SCy Schubert case "$xrpath " in 7747*a466cc55SCy Schubert *" $dir "*) ;; 7748*a466cc55SCy Schubert *) func_append xrpath " $dir" ;; 7749*a466cc55SCy Schubert esac 7750*a466cc55SCy Schubert fi 7751*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7752*a466cc55SCy Schubert continue 7753*a466cc55SCy Schubert ;; 7754*a466cc55SCy Schubert *.la) 7755*a466cc55SCy Schubert func_resolve_sysroot "$deplib" 7756*a466cc55SCy Schubert lib=$func_resolve_sysroot_result 7757*a466cc55SCy Schubert ;; 7758*a466cc55SCy Schubert *.$libext) 7759*a466cc55SCy Schubert if test conv = "$pass"; then 7760*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7761*a466cc55SCy Schubert continue 7762*a466cc55SCy Schubert fi 7763*a466cc55SCy Schubert case $linkmode in 7764*a466cc55SCy Schubert lib) 7765*a466cc55SCy Schubert # Linking convenience modules into shared libraries is allowed, 7766*a466cc55SCy Schubert # but linking other static libraries is non-portable. 7767*a466cc55SCy Schubert case " $dlpreconveniencelibs " in 7768*a466cc55SCy Schubert *" $deplib "*) ;; 7769*a466cc55SCy Schubert *) 7770*a466cc55SCy Schubert valid_a_lib=false 7771*a466cc55SCy Schubert case $deplibs_check_method in 7772*a466cc55SCy Schubert match_pattern*) 7773*a466cc55SCy Schubert set dummy $deplibs_check_method; shift 7774*a466cc55SCy Schubert match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775*a466cc55SCy Schubert if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776*a466cc55SCy Schubert | $EGREP "$match_pattern_regex" > /dev/null; then 7777*a466cc55SCy Schubert valid_a_lib=: 7778*a466cc55SCy Schubert fi 7779*a466cc55SCy Schubert ;; 7780*a466cc55SCy Schubert pass_all) 7781*a466cc55SCy Schubert valid_a_lib=: 7782*a466cc55SCy Schubert ;; 7783*a466cc55SCy Schubert esac 7784*a466cc55SCy Schubert if $valid_a_lib; then 7785*a466cc55SCy Schubert echo 7786*a466cc55SCy Schubert $ECHO "*** Warning: Linking the shared library $output against the" 7787*a466cc55SCy Schubert $ECHO "*** static library $deplib is not portable!" 7788*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7789*a466cc55SCy Schubert else 7790*a466cc55SCy Schubert echo 7791*a466cc55SCy Schubert $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792*a466cc55SCy Schubert echo "*** I have the capability to make that library automatically link in when" 7793*a466cc55SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 7794*a466cc55SCy Schubert echo "*** shared version of the library, which you do not appear to have" 7795*a466cc55SCy Schubert echo "*** because the file extensions .$libext of this argument makes me believe" 7796*a466cc55SCy Schubert echo "*** that it is just a static archive that I should not use here." 7797*a466cc55SCy Schubert fi 7798*a466cc55SCy Schubert ;; 7799*a466cc55SCy Schubert esac 7800*a466cc55SCy Schubert continue 7801*a466cc55SCy Schubert ;; 7802*a466cc55SCy Schubert prog) 7803*a466cc55SCy Schubert if test link != "$pass"; then 7804*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7805*a466cc55SCy Schubert else 7806*a466cc55SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7807*a466cc55SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7808*a466cc55SCy Schubert fi 7809*a466cc55SCy Schubert continue 7810*a466cc55SCy Schubert ;; 7811*a466cc55SCy Schubert esac # linkmode 7812*a466cc55SCy Schubert ;; # *.$libext 7813*a466cc55SCy Schubert *.lo | *.$objext) 7814*a466cc55SCy Schubert if test conv = "$pass"; then 7815*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7816*a466cc55SCy Schubert elif test prog = "$linkmode"; then 7817*a466cc55SCy Schubert if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818*a466cc55SCy Schubert # If there is no dlopen support or we're linking statically, 7819*a466cc55SCy Schubert # we need to preload. 7820*a466cc55SCy Schubert func_append newdlprefiles " $deplib" 7821*a466cc55SCy Schubert compile_deplibs="$deplib $compile_deplibs" 7822*a466cc55SCy Schubert finalize_deplibs="$deplib $finalize_deplibs" 7823*a466cc55SCy Schubert else 7824*a466cc55SCy Schubert func_append newdlfiles " $deplib" 7825*a466cc55SCy Schubert fi 7826*a466cc55SCy Schubert fi 7827*a466cc55SCy Schubert continue 7828*a466cc55SCy Schubert ;; 7829*a466cc55SCy Schubert %DEPLIBS%) 7830*a466cc55SCy Schubert alldeplibs=: 7831*a466cc55SCy Schubert continue 7832*a466cc55SCy Schubert ;; 7833*a466cc55SCy Schubert esac # case $deplib 7834*a466cc55SCy Schubert 7835*a466cc55SCy Schubert $found || test -f "$lib" \ 7836*a466cc55SCy Schubert || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837*a466cc55SCy Schubert 7838*a466cc55SCy Schubert # Check to see that this really is a libtool archive. 7839*a466cc55SCy Schubert func_lalib_unsafe_p "$lib" \ 7840*a466cc55SCy Schubert || func_fatal_error "'$lib' is not a valid libtool archive" 7841*a466cc55SCy Schubert 7842*a466cc55SCy Schubert func_dirname "$lib" "" "." 7843*a466cc55SCy Schubert ladir=$func_dirname_result 7844*a466cc55SCy Schubert 7845*a466cc55SCy Schubert dlname= 7846*a466cc55SCy Schubert dlopen= 7847*a466cc55SCy Schubert dlpreopen= 7848*a466cc55SCy Schubert libdir= 7849*a466cc55SCy Schubert library_names= 7850*a466cc55SCy Schubert old_library= 7851*a466cc55SCy Schubert inherited_linker_flags= 7852*a466cc55SCy Schubert # If the library was installed with an old release of libtool, 7853*a466cc55SCy Schubert # it will not redefine variables installed, or shouldnotlink 7854*a466cc55SCy Schubert installed=yes 7855*a466cc55SCy Schubert shouldnotlink=no 7856*a466cc55SCy Schubert avoidtemprpath= 7857*a466cc55SCy Schubert 7858*a466cc55SCy Schubert 7859*a466cc55SCy Schubert # Read the .la file 7860*a466cc55SCy Schubert func_source "$lib" 7861*a466cc55SCy Schubert 7862*a466cc55SCy Schubert # Convert "-framework foo" to "foo.ltframework" 7863*a466cc55SCy Schubert if test -n "$inherited_linker_flags"; then 7864*a466cc55SCy Schubert tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865*a466cc55SCy Schubert for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866*a466cc55SCy Schubert case " $new_inherited_linker_flags " in 7867*a466cc55SCy Schubert *" $tmp_inherited_linker_flag "*) ;; 7868*a466cc55SCy Schubert *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869*a466cc55SCy Schubert esac 7870*a466cc55SCy Schubert done 7871*a466cc55SCy Schubert fi 7872*a466cc55SCy Schubert dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873*a466cc55SCy Schubert if test lib,link = "$linkmode,$pass" || 7874*a466cc55SCy Schubert test prog,scan = "$linkmode,$pass" || 7875*a466cc55SCy Schubert { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876*a466cc55SCy Schubert test -n "$dlopen" && func_append dlfiles " $dlopen" 7877*a466cc55SCy Schubert test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878*a466cc55SCy Schubert fi 7879*a466cc55SCy Schubert 7880*a466cc55SCy Schubert if test conv = "$pass"; then 7881*a466cc55SCy Schubert # Only check for convenience libraries 7882*a466cc55SCy Schubert deplibs="$lib $deplibs" 7883*a466cc55SCy Schubert if test -z "$libdir"; then 7884*a466cc55SCy Schubert if test -z "$old_library"; then 7885*a466cc55SCy Schubert func_fatal_error "cannot find name of link library for '$lib'" 7886*a466cc55SCy Schubert fi 7887*a466cc55SCy Schubert # It is a libtool convenience library, so add in its objects. 7888*a466cc55SCy Schubert func_append convenience " $ladir/$objdir/$old_library" 7889*a466cc55SCy Schubert func_append old_convenience " $ladir/$objdir/$old_library" 7890*a466cc55SCy Schubert elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891*a466cc55SCy Schubert func_fatal_error "'$lib' is not a convenience library" 7892*a466cc55SCy Schubert fi 7893*a466cc55SCy Schubert tmp_libs= 7894*a466cc55SCy Schubert for deplib in $dependency_libs; do 7895*a466cc55SCy Schubert deplibs="$deplib $deplibs" 7896*a466cc55SCy Schubert if $opt_preserve_dup_deps; then 7897*a466cc55SCy Schubert case "$tmp_libs " in 7898*a466cc55SCy Schubert *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899*a466cc55SCy Schubert esac 7900*a466cc55SCy Schubert fi 7901*a466cc55SCy Schubert func_append tmp_libs " $deplib" 7902*a466cc55SCy Schubert done 7903*a466cc55SCy Schubert continue 7904*a466cc55SCy Schubert fi # $pass = conv 7905*a466cc55SCy Schubert 7906*a466cc55SCy Schubert 7907*a466cc55SCy Schubert # Get the name of the library we link against. 7908*a466cc55SCy Schubert linklib= 7909*a466cc55SCy Schubert if test -n "$old_library" && 7910*a466cc55SCy Schubert { test yes = "$prefer_static_libs" || 7911*a466cc55SCy Schubert test built,no = "$prefer_static_libs,$installed"; }; then 7912*a466cc55SCy Schubert linklib=$old_library 7913*a466cc55SCy Schubert else 7914*a466cc55SCy Schubert for l in $old_library $library_names; do 7915*a466cc55SCy Schubert linklib=$l 7916*a466cc55SCy Schubert done 7917*a466cc55SCy Schubert fi 7918*a466cc55SCy Schubert if test -z "$linklib"; then 7919*a466cc55SCy Schubert func_fatal_error "cannot find name of link library for '$lib'" 7920*a466cc55SCy Schubert fi 7921*a466cc55SCy Schubert 7922*a466cc55SCy Schubert # This library was specified with -dlopen. 7923*a466cc55SCy Schubert if test dlopen = "$pass"; then 7924*a466cc55SCy Schubert test -z "$libdir" \ 7925*a466cc55SCy Schubert && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926*a466cc55SCy Schubert if test -z "$dlname" || 7927*a466cc55SCy Schubert test yes != "$dlopen_support" || 7928*a466cc55SCy Schubert test no = "$build_libtool_libs" 7929*a466cc55SCy Schubert then 7930*a466cc55SCy Schubert # If there is no dlname, no dlopen support or we're linking 7931*a466cc55SCy Schubert # statically, we need to preload. We also need to preload any 7932*a466cc55SCy Schubert # dependent libraries so libltdl's deplib preloader doesn't 7933*a466cc55SCy Schubert # bomb out in the load deplibs phase. 7934*a466cc55SCy Schubert func_append dlprefiles " $lib $dependency_libs" 7935*a466cc55SCy Schubert else 7936*a466cc55SCy Schubert func_append newdlfiles " $lib" 7937*a466cc55SCy Schubert fi 7938*a466cc55SCy Schubert continue 7939*a466cc55SCy Schubert fi # $pass = dlopen 7940*a466cc55SCy Schubert 7941*a466cc55SCy Schubert # We need an absolute path. 7942*a466cc55SCy Schubert case $ladir in 7943*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944*a466cc55SCy Schubert *) 7945*a466cc55SCy Schubert abs_ladir=`cd "$ladir" && pwd` 7946*a466cc55SCy Schubert if test -z "$abs_ladir"; then 7947*a466cc55SCy Schubert func_warning "cannot determine absolute directory name of '$ladir'" 7948*a466cc55SCy Schubert func_warning "passing it literally to the linker, although it might fail" 7949*a466cc55SCy Schubert abs_ladir=$ladir 7950*a466cc55SCy Schubert fi 7951*a466cc55SCy Schubert ;; 7952*a466cc55SCy Schubert esac 7953*a466cc55SCy Schubert func_basename "$lib" 7954*a466cc55SCy Schubert laname=$func_basename_result 7955*a466cc55SCy Schubert 7956*a466cc55SCy Schubert # Find the relevant object directory and library name. 7957*a466cc55SCy Schubert if test yes = "$installed"; then 7958*a466cc55SCy Schubert if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959*a466cc55SCy Schubert func_warning "library '$lib' was moved." 7960*a466cc55SCy Schubert dir=$ladir 7961*a466cc55SCy Schubert absdir=$abs_ladir 7962*a466cc55SCy Schubert libdir=$abs_ladir 7963*a466cc55SCy Schubert else 7964*a466cc55SCy Schubert dir=$lt_sysroot$libdir 7965*a466cc55SCy Schubert absdir=$lt_sysroot$libdir 7966*a466cc55SCy Schubert fi 7967*a466cc55SCy Schubert test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968*a466cc55SCy Schubert else 7969*a466cc55SCy Schubert if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970*a466cc55SCy Schubert dir=$ladir 7971*a466cc55SCy Schubert absdir=$abs_ladir 7972*a466cc55SCy Schubert # Remove this search path later 7973*a466cc55SCy Schubert func_append notinst_path " $abs_ladir" 7974*a466cc55SCy Schubert else 7975*a466cc55SCy Schubert dir=$ladir/$objdir 7976*a466cc55SCy Schubert absdir=$abs_ladir/$objdir 7977*a466cc55SCy Schubert # Remove this search path later 7978*a466cc55SCy Schubert func_append notinst_path " $abs_ladir" 7979*a466cc55SCy Schubert fi 7980*a466cc55SCy Schubert fi # $installed = yes 7981*a466cc55SCy Schubert func_stripname 'lib' '.la' "$laname" 7982*a466cc55SCy Schubert name=$func_stripname_result 7983*a466cc55SCy Schubert 7984*a466cc55SCy Schubert # This library was specified with -dlpreopen. 7985*a466cc55SCy Schubert if test dlpreopen = "$pass"; then 7986*a466cc55SCy Schubert if test -z "$libdir" && test prog = "$linkmode"; then 7987*a466cc55SCy Schubert func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988*a466cc55SCy Schubert fi 7989*a466cc55SCy Schubert case $host in 7990*a466cc55SCy Schubert # special handling for platforms with PE-DLLs. 7991*a466cc55SCy Schubert *cygwin* | *mingw* | *cegcc* ) 7992*a466cc55SCy Schubert # Linker will automatically link against shared library if both 7993*a466cc55SCy Schubert # static and shared are present. Therefore, ensure we extract 7994*a466cc55SCy Schubert # symbols from the import library if a shared library is present 7995*a466cc55SCy Schubert # (otherwise, the dlopen module name will be incorrect). We do 7996*a466cc55SCy Schubert # this by putting the import library name into $newdlprefiles. 7997*a466cc55SCy Schubert # We recover the dlopen module name by 'saving' the la file 7998*a466cc55SCy Schubert # name in a special purpose variable, and (later) extracting the 7999*a466cc55SCy Schubert # dlname from the la file. 8000*a466cc55SCy Schubert if test -n "$dlname"; then 8001*a466cc55SCy Schubert func_tr_sh "$dir/$linklib" 8002*a466cc55SCy Schubert eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003*a466cc55SCy Schubert func_append newdlprefiles " $dir/$linklib" 8004*a466cc55SCy Schubert else 8005*a466cc55SCy Schubert func_append newdlprefiles " $dir/$old_library" 8006*a466cc55SCy Schubert # Keep a list of preopened convenience libraries to check 8007*a466cc55SCy Schubert # that they are being used correctly in the link pass. 8008*a466cc55SCy Schubert test -z "$libdir" && \ 8009*a466cc55SCy Schubert func_append dlpreconveniencelibs " $dir/$old_library" 8010*a466cc55SCy Schubert fi 8011*a466cc55SCy Schubert ;; 8012*a466cc55SCy Schubert * ) 8013*a466cc55SCy Schubert # Prefer using a static library (so that no silly _DYNAMIC symbols 8014*a466cc55SCy Schubert # are required to link). 8015*a466cc55SCy Schubert if test -n "$old_library"; then 8016*a466cc55SCy Schubert func_append newdlprefiles " $dir/$old_library" 8017*a466cc55SCy Schubert # Keep a list of preopened convenience libraries to check 8018*a466cc55SCy Schubert # that they are being used correctly in the link pass. 8019*a466cc55SCy Schubert test -z "$libdir" && \ 8020*a466cc55SCy Schubert func_append dlpreconveniencelibs " $dir/$old_library" 8021*a466cc55SCy Schubert # Otherwise, use the dlname, so that lt_dlopen finds it. 8022*a466cc55SCy Schubert elif test -n "$dlname"; then 8023*a466cc55SCy Schubert func_append newdlprefiles " $dir/$dlname" 8024*a466cc55SCy Schubert else 8025*a466cc55SCy Schubert func_append newdlprefiles " $dir/$linklib" 8026*a466cc55SCy Schubert fi 8027*a466cc55SCy Schubert ;; 8028*a466cc55SCy Schubert esac 8029*a466cc55SCy Schubert fi # $pass = dlpreopen 8030*a466cc55SCy Schubert 8031*a466cc55SCy Schubert if test -z "$libdir"; then 8032*a466cc55SCy Schubert # Link the convenience library 8033*a466cc55SCy Schubert if test lib = "$linkmode"; then 8034*a466cc55SCy Schubert deplibs="$dir/$old_library $deplibs" 8035*a466cc55SCy Schubert elif test prog,link = "$linkmode,$pass"; then 8036*a466cc55SCy Schubert compile_deplibs="$dir/$old_library $compile_deplibs" 8037*a466cc55SCy Schubert finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038*a466cc55SCy Schubert else 8039*a466cc55SCy Schubert deplibs="$lib $deplibs" # used for prog,scan pass 8040*a466cc55SCy Schubert fi 8041*a466cc55SCy Schubert continue 8042*a466cc55SCy Schubert fi 8043*a466cc55SCy Schubert 8044*a466cc55SCy Schubert 8045*a466cc55SCy Schubert if test prog = "$linkmode" && test link != "$pass"; then 8046*a466cc55SCy Schubert func_append newlib_search_path " $ladir" 8047*a466cc55SCy Schubert deplibs="$lib $deplibs" 8048*a466cc55SCy Schubert 8049*a466cc55SCy Schubert linkalldeplibs=false 8050*a466cc55SCy Schubert if test no != "$link_all_deplibs" || test -z "$library_names" || 8051*a466cc55SCy Schubert test no = "$build_libtool_libs"; then 8052*a466cc55SCy Schubert linkalldeplibs=: 8053*a466cc55SCy Schubert fi 8054*a466cc55SCy Schubert 8055*a466cc55SCy Schubert tmp_libs= 8056*a466cc55SCy Schubert for deplib in $dependency_libs; do 8057*a466cc55SCy Schubert case $deplib in 8058*a466cc55SCy Schubert -L*) func_stripname '-L' '' "$deplib" 8059*a466cc55SCy Schubert func_resolve_sysroot "$func_stripname_result" 8060*a466cc55SCy Schubert func_append newlib_search_path " $func_resolve_sysroot_result" 8061*a466cc55SCy Schubert ;; 8062*a466cc55SCy Schubert esac 8063*a466cc55SCy Schubert # Need to link against all dependency_libs? 8064*a466cc55SCy Schubert if $linkalldeplibs; then 8065*a466cc55SCy Schubert deplibs="$deplib $deplibs" 8066*a466cc55SCy Schubert else 8067*a466cc55SCy Schubert # Need to hardcode shared library paths 8068*a466cc55SCy Schubert # or/and link against static libraries 8069*a466cc55SCy Schubert newdependency_libs="$deplib $newdependency_libs" 8070*a466cc55SCy Schubert fi 8071*a466cc55SCy Schubert if $opt_preserve_dup_deps; then 8072*a466cc55SCy Schubert case "$tmp_libs " in 8073*a466cc55SCy Schubert *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074*a466cc55SCy Schubert esac 8075*a466cc55SCy Schubert fi 8076*a466cc55SCy Schubert func_append tmp_libs " $deplib" 8077*a466cc55SCy Schubert done # for deplib 8078*a466cc55SCy Schubert continue 8079*a466cc55SCy Schubert fi # $linkmode = prog... 8080*a466cc55SCy Schubert 8081*a466cc55SCy Schubert if test prog,link = "$linkmode,$pass"; then 8082*a466cc55SCy Schubert if test -n "$library_names" && 8083*a466cc55SCy Schubert { { test no = "$prefer_static_libs" || 8084*a466cc55SCy Schubert test built,yes = "$prefer_static_libs,$installed"; } || 8085*a466cc55SCy Schubert test -z "$old_library"; }; then 8086*a466cc55SCy Schubert # We need to hardcode the library path 8087*a466cc55SCy Schubert if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088*a466cc55SCy Schubert # Make sure the rpath contains only unique directories. 8089*a466cc55SCy Schubert case $temp_rpath: in 8090*a466cc55SCy Schubert *"$absdir:"*) ;; 8091*a466cc55SCy Schubert *) func_append temp_rpath "$absdir:" ;; 8092*a466cc55SCy Schubert esac 8093*a466cc55SCy Schubert fi 8094*a466cc55SCy Schubert 8095*a466cc55SCy Schubert # Hardcode the library path. 8096*a466cc55SCy Schubert # Skip directories that are in the system default run-time 8097*a466cc55SCy Schubert # search path. 8098*a466cc55SCy Schubert case " $sys_lib_dlsearch_path " in 8099*a466cc55SCy Schubert *" $absdir "*) ;; 8100*a466cc55SCy Schubert *) 8101*a466cc55SCy Schubert case "$compile_rpath " in 8102*a466cc55SCy Schubert *" $absdir "*) ;; 8103*a466cc55SCy Schubert *) func_append compile_rpath " $absdir" ;; 8104*a466cc55SCy Schubert esac 8105*a466cc55SCy Schubert ;; 8106*a466cc55SCy Schubert esac 8107*a466cc55SCy Schubert case " $sys_lib_dlsearch_path " in 8108*a466cc55SCy Schubert *" $libdir "*) ;; 8109*a466cc55SCy Schubert *) 8110*a466cc55SCy Schubert case "$finalize_rpath " in 8111*a466cc55SCy Schubert *" $libdir "*) ;; 8112*a466cc55SCy Schubert *) func_append finalize_rpath " $libdir" ;; 8113*a466cc55SCy Schubert esac 8114*a466cc55SCy Schubert ;; 8115*a466cc55SCy Schubert esac 8116*a466cc55SCy Schubert fi # $linkmode,$pass = prog,link... 8117*a466cc55SCy Schubert 8118*a466cc55SCy Schubert if $alldeplibs && 8119*a466cc55SCy Schubert { test pass_all = "$deplibs_check_method" || 8120*a466cc55SCy Schubert { test yes = "$build_libtool_libs" && 8121*a466cc55SCy Schubert test -n "$library_names"; }; }; then 8122*a466cc55SCy Schubert # We only need to search for static libraries 8123*a466cc55SCy Schubert continue 8124*a466cc55SCy Schubert fi 8125*a466cc55SCy Schubert fi 8126*a466cc55SCy Schubert 8127*a466cc55SCy Schubert link_static=no # Whether the deplib will be linked statically 8128*a466cc55SCy Schubert use_static_libs=$prefer_static_libs 8129*a466cc55SCy Schubert if test built = "$use_static_libs" && test yes = "$installed"; then 8130*a466cc55SCy Schubert use_static_libs=no 8131*a466cc55SCy Schubert fi 8132*a466cc55SCy Schubert if test -n "$library_names" && 8133*a466cc55SCy Schubert { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134*a466cc55SCy Schubert case $host in 8135*a466cc55SCy Schubert *cygwin* | *mingw* | *cegcc* | *os2*) 8136*a466cc55SCy Schubert # No point in relinking DLLs because paths are not encoded 8137*a466cc55SCy Schubert func_append notinst_deplibs " $lib" 8138*a466cc55SCy Schubert need_relink=no 8139*a466cc55SCy Schubert ;; 8140*a466cc55SCy Schubert *) 8141*a466cc55SCy Schubert if test no = "$installed"; then 8142*a466cc55SCy Schubert func_append notinst_deplibs " $lib" 8143*a466cc55SCy Schubert need_relink=yes 8144*a466cc55SCy Schubert fi 8145*a466cc55SCy Schubert ;; 8146*a466cc55SCy Schubert esac 8147*a466cc55SCy Schubert # This is a shared library 8148*a466cc55SCy Schubert 8149*a466cc55SCy Schubert # Warn about portability, can't link against -module's on some 8150*a466cc55SCy Schubert # systems (darwin). Don't bleat about dlopened modules though! 8151*a466cc55SCy Schubert dlopenmodule= 8152*a466cc55SCy Schubert for dlpremoduletest in $dlprefiles; do 8153*a466cc55SCy Schubert if test "X$dlpremoduletest" = "X$lib"; then 8154*a466cc55SCy Schubert dlopenmodule=$dlpremoduletest 8155*a466cc55SCy Schubert break 8156*a466cc55SCy Schubert fi 8157*a466cc55SCy Schubert done 8158*a466cc55SCy Schubert if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159*a466cc55SCy Schubert echo 8160*a466cc55SCy Schubert if test prog = "$linkmode"; then 8161*a466cc55SCy Schubert $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162*a466cc55SCy Schubert else 8163*a466cc55SCy Schubert $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164*a466cc55SCy Schubert fi 8165*a466cc55SCy Schubert $ECHO "*** $linklib is not portable!" 8166*a466cc55SCy Schubert fi 8167*a466cc55SCy Schubert if test lib = "$linkmode" && 8168*a466cc55SCy Schubert test yes = "$hardcode_into_libs"; then 8169*a466cc55SCy Schubert # Hardcode the library path. 8170*a466cc55SCy Schubert # Skip directories that are in the system default run-time 8171*a466cc55SCy Schubert # search path. 8172*a466cc55SCy Schubert case " $sys_lib_dlsearch_path " in 8173*a466cc55SCy Schubert *" $absdir "*) ;; 8174*a466cc55SCy Schubert *) 8175*a466cc55SCy Schubert case "$compile_rpath " in 8176*a466cc55SCy Schubert *" $absdir "*) ;; 8177*a466cc55SCy Schubert *) func_append compile_rpath " $absdir" ;; 8178*a466cc55SCy Schubert esac 8179*a466cc55SCy Schubert ;; 8180*a466cc55SCy Schubert esac 8181*a466cc55SCy Schubert case " $sys_lib_dlsearch_path " in 8182*a466cc55SCy Schubert *" $libdir "*) ;; 8183*a466cc55SCy Schubert *) 8184*a466cc55SCy Schubert case "$finalize_rpath " in 8185*a466cc55SCy Schubert *" $libdir "*) ;; 8186*a466cc55SCy Schubert *) func_append finalize_rpath " $libdir" ;; 8187*a466cc55SCy Schubert esac 8188*a466cc55SCy Schubert ;; 8189*a466cc55SCy Schubert esac 8190*a466cc55SCy Schubert fi 8191*a466cc55SCy Schubert 8192*a466cc55SCy Schubert if test -n "$old_archive_from_expsyms_cmds"; then 8193*a466cc55SCy Schubert # figure out the soname 8194*a466cc55SCy Schubert set dummy $library_names 8195*a466cc55SCy Schubert shift 8196*a466cc55SCy Schubert realname=$1 8197*a466cc55SCy Schubert shift 8198*a466cc55SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 8199*a466cc55SCy Schubert # use dlname if we got it. it's perfectly good, no? 8200*a466cc55SCy Schubert if test -n "$dlname"; then 8201*a466cc55SCy Schubert soname=$dlname 8202*a466cc55SCy Schubert elif test -n "$soname_spec"; then 8203*a466cc55SCy Schubert # bleh windows 8204*a466cc55SCy Schubert case $host in 8205*a466cc55SCy Schubert *cygwin* | mingw* | *cegcc* | *os2*) 8206*a466cc55SCy Schubert func_arith $current - $age 8207*a466cc55SCy Schubert major=$func_arith_result 8208*a466cc55SCy Schubert versuffix=-$major 8209*a466cc55SCy Schubert ;; 8210*a466cc55SCy Schubert esac 8211*a466cc55SCy Schubert eval soname=\"$soname_spec\" 8212*a466cc55SCy Schubert else 8213*a466cc55SCy Schubert soname=$realname 8214*a466cc55SCy Schubert fi 8215*a466cc55SCy Schubert 8216*a466cc55SCy Schubert # Make a new name for the extract_expsyms_cmds to use 8217*a466cc55SCy Schubert soroot=$soname 8218*a466cc55SCy Schubert func_basename "$soroot" 8219*a466cc55SCy Schubert soname=$func_basename_result 8220*a466cc55SCy Schubert func_stripname 'lib' '.dll' "$soname" 8221*a466cc55SCy Schubert newlib=libimp-$func_stripname_result.a 8222*a466cc55SCy Schubert 8223*a466cc55SCy Schubert # If the library has no export list, then create one now 8224*a466cc55SCy Schubert if test -f "$output_objdir/$soname-def"; then : 8225*a466cc55SCy Schubert else 8226*a466cc55SCy Schubert func_verbose "extracting exported symbol list from '$soname'" 8227*a466cc55SCy Schubert func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228*a466cc55SCy Schubert fi 8229*a466cc55SCy Schubert 8230*a466cc55SCy Schubert # Create $newlib 8231*a466cc55SCy Schubert if test -f "$output_objdir/$newlib"; then :; else 8232*a466cc55SCy Schubert func_verbose "generating import library for '$soname'" 8233*a466cc55SCy Schubert func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234*a466cc55SCy Schubert fi 8235*a466cc55SCy Schubert # make sure the library variables are pointing to the new library 8236*a466cc55SCy Schubert dir=$output_objdir 8237*a466cc55SCy Schubert linklib=$newlib 8238*a466cc55SCy Schubert fi # test -n "$old_archive_from_expsyms_cmds" 8239*a466cc55SCy Schubert 8240*a466cc55SCy Schubert if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241*a466cc55SCy Schubert add_shlibpath= 8242*a466cc55SCy Schubert add_dir= 8243*a466cc55SCy Schubert add= 8244*a466cc55SCy Schubert lib_linked=yes 8245*a466cc55SCy Schubert case $hardcode_action in 8246*a466cc55SCy Schubert immediate | unsupported) 8247*a466cc55SCy Schubert if test no = "$hardcode_direct"; then 8248*a466cc55SCy Schubert add=$dir/$linklib 8249*a466cc55SCy Schubert case $host in 8250*a466cc55SCy Schubert *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251*a466cc55SCy Schubert *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252*a466cc55SCy Schubert *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253*a466cc55SCy Schubert *-*-unixware7*) add_dir=-L$dir ;; 8254*a466cc55SCy Schubert *-*-darwin* ) 8255*a466cc55SCy Schubert # if the lib is a (non-dlopened) module then we cannot 8256*a466cc55SCy Schubert # link against it, someone is ignoring the earlier warnings 8257*a466cc55SCy Schubert if /usr/bin/file -L $add 2> /dev/null | 8258*a466cc55SCy Schubert $GREP ": [^:]* bundle" >/dev/null; then 8259*a466cc55SCy Schubert if test "X$dlopenmodule" != "X$lib"; then 8260*a466cc55SCy Schubert $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261*a466cc55SCy Schubert if test -z "$old_library"; then 8262*a466cc55SCy Schubert echo 8263*a466cc55SCy Schubert echo "*** And there doesn't seem to be a static archive available" 8264*a466cc55SCy Schubert echo "*** The link will probably fail, sorry" 8265*a466cc55SCy Schubert else 8266*a466cc55SCy Schubert add=$dir/$old_library 8267*a466cc55SCy Schubert fi 8268*a466cc55SCy Schubert elif test -n "$old_library"; then 8269*a466cc55SCy Schubert add=$dir/$old_library 8270*a466cc55SCy Schubert fi 8271*a466cc55SCy Schubert fi 8272*a466cc55SCy Schubert esac 8273*a466cc55SCy Schubert elif test no = "$hardcode_minus_L"; then 8274*a466cc55SCy Schubert case $host in 8275*a466cc55SCy Schubert *-*-sunos*) add_shlibpath=$dir ;; 8276*a466cc55SCy Schubert esac 8277*a466cc55SCy Schubert add_dir=-L$dir 8278*a466cc55SCy Schubert add=-l$name 8279*a466cc55SCy Schubert elif test no = "$hardcode_shlibpath_var"; then 8280*a466cc55SCy Schubert add_shlibpath=$dir 8281*a466cc55SCy Schubert add=-l$name 8282*a466cc55SCy Schubert else 8283*a466cc55SCy Schubert lib_linked=no 8284*a466cc55SCy Schubert fi 8285*a466cc55SCy Schubert ;; 8286*a466cc55SCy Schubert relink) 8287*a466cc55SCy Schubert if test yes = "$hardcode_direct" && 8288*a466cc55SCy Schubert test no = "$hardcode_direct_absolute"; then 8289*a466cc55SCy Schubert add=$dir/$linklib 8290*a466cc55SCy Schubert elif test yes = "$hardcode_minus_L"; then 8291*a466cc55SCy Schubert add_dir=-L$absdir 8292*a466cc55SCy Schubert # Try looking first in the location we're being installed to. 8293*a466cc55SCy Schubert if test -n "$inst_prefix_dir"; then 8294*a466cc55SCy Schubert case $libdir in 8295*a466cc55SCy Schubert [\\/]*) 8296*a466cc55SCy Schubert func_append add_dir " -L$inst_prefix_dir$libdir" 8297*a466cc55SCy Schubert ;; 8298*a466cc55SCy Schubert esac 8299*a466cc55SCy Schubert fi 8300*a466cc55SCy Schubert add=-l$name 8301*a466cc55SCy Schubert elif test yes = "$hardcode_shlibpath_var"; then 8302*a466cc55SCy Schubert add_shlibpath=$dir 8303*a466cc55SCy Schubert add=-l$name 8304*a466cc55SCy Schubert else 8305*a466cc55SCy Schubert lib_linked=no 8306*a466cc55SCy Schubert fi 8307*a466cc55SCy Schubert ;; 8308*a466cc55SCy Schubert *) lib_linked=no ;; 8309*a466cc55SCy Schubert esac 8310*a466cc55SCy Schubert 8311*a466cc55SCy Schubert if test yes != "$lib_linked"; then 8312*a466cc55SCy Schubert func_fatal_configuration "unsupported hardcode properties" 8313*a466cc55SCy Schubert fi 8314*a466cc55SCy Schubert 8315*a466cc55SCy Schubert if test -n "$add_shlibpath"; then 8316*a466cc55SCy Schubert case :$compile_shlibpath: in 8317*a466cc55SCy Schubert *":$add_shlibpath:"*) ;; 8318*a466cc55SCy Schubert *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319*a466cc55SCy Schubert esac 8320*a466cc55SCy Schubert fi 8321*a466cc55SCy Schubert if test prog = "$linkmode"; then 8322*a466cc55SCy Schubert test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323*a466cc55SCy Schubert test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324*a466cc55SCy Schubert else 8325*a466cc55SCy Schubert test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326*a466cc55SCy Schubert test -n "$add" && deplibs="$add $deplibs" 8327*a466cc55SCy Schubert if test yes != "$hardcode_direct" && 8328*a466cc55SCy Schubert test yes != "$hardcode_minus_L" && 8329*a466cc55SCy Schubert test yes = "$hardcode_shlibpath_var"; then 8330*a466cc55SCy Schubert case :$finalize_shlibpath: in 8331*a466cc55SCy Schubert *":$libdir:"*) ;; 8332*a466cc55SCy Schubert *) func_append finalize_shlibpath "$libdir:" ;; 8333*a466cc55SCy Schubert esac 8334*a466cc55SCy Schubert fi 8335*a466cc55SCy Schubert fi 8336*a466cc55SCy Schubert fi 8337*a466cc55SCy Schubert 8338*a466cc55SCy Schubert if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339*a466cc55SCy Schubert add_shlibpath= 8340*a466cc55SCy Schubert add_dir= 8341*a466cc55SCy Schubert add= 8342*a466cc55SCy Schubert # Finalize command for both is simple: just hardcode it. 8343*a466cc55SCy Schubert if test yes = "$hardcode_direct" && 8344*a466cc55SCy Schubert test no = "$hardcode_direct_absolute"; then 8345*a466cc55SCy Schubert add=$libdir/$linklib 8346*a466cc55SCy Schubert elif test yes = "$hardcode_minus_L"; then 8347*a466cc55SCy Schubert add_dir=-L$libdir 8348*a466cc55SCy Schubert add=-l$name 8349*a466cc55SCy Schubert elif test yes = "$hardcode_shlibpath_var"; then 8350*a466cc55SCy Schubert case :$finalize_shlibpath: in 8351*a466cc55SCy Schubert *":$libdir:"*) ;; 8352*a466cc55SCy Schubert *) func_append finalize_shlibpath "$libdir:" ;; 8353*a466cc55SCy Schubert esac 8354*a466cc55SCy Schubert add=-l$name 8355*a466cc55SCy Schubert elif test yes = "$hardcode_automatic"; then 8356*a466cc55SCy Schubert if test -n "$inst_prefix_dir" && 8357*a466cc55SCy Schubert test -f "$inst_prefix_dir$libdir/$linklib"; then 8358*a466cc55SCy Schubert add=$inst_prefix_dir$libdir/$linklib 8359*a466cc55SCy Schubert else 8360*a466cc55SCy Schubert add=$libdir/$linklib 8361*a466cc55SCy Schubert fi 8362*a466cc55SCy Schubert else 8363*a466cc55SCy Schubert # We cannot seem to hardcode it, guess we'll fake it. 8364*a466cc55SCy Schubert add_dir=-L$libdir 8365*a466cc55SCy Schubert # Try looking first in the location we're being installed to. 8366*a466cc55SCy Schubert if test -n "$inst_prefix_dir"; then 8367*a466cc55SCy Schubert case $libdir in 8368*a466cc55SCy Schubert [\\/]*) 8369*a466cc55SCy Schubert func_append add_dir " -L$inst_prefix_dir$libdir" 8370*a466cc55SCy Schubert ;; 8371*a466cc55SCy Schubert esac 8372*a466cc55SCy Schubert fi 8373*a466cc55SCy Schubert add=-l$name 8374*a466cc55SCy Schubert fi 8375*a466cc55SCy Schubert 8376*a466cc55SCy Schubert if test prog = "$linkmode"; then 8377*a466cc55SCy Schubert test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378*a466cc55SCy Schubert test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379*a466cc55SCy Schubert else 8380*a466cc55SCy Schubert test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381*a466cc55SCy Schubert test -n "$add" && deplibs="$add $deplibs" 8382*a466cc55SCy Schubert fi 8383*a466cc55SCy Schubert fi 8384*a466cc55SCy Schubert elif test prog = "$linkmode"; then 8385*a466cc55SCy Schubert # Here we assume that one of hardcode_direct or hardcode_minus_L 8386*a466cc55SCy Schubert # is not unsupported. This is valid on all known static and 8387*a466cc55SCy Schubert # shared platforms. 8388*a466cc55SCy Schubert if test unsupported != "$hardcode_direct"; then 8389*a466cc55SCy Schubert test -n "$old_library" && linklib=$old_library 8390*a466cc55SCy Schubert compile_deplibs="$dir/$linklib $compile_deplibs" 8391*a466cc55SCy Schubert finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392*a466cc55SCy Schubert else 8393*a466cc55SCy Schubert compile_deplibs="-l$name -L$dir $compile_deplibs" 8394*a466cc55SCy Schubert finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395*a466cc55SCy Schubert fi 8396*a466cc55SCy Schubert elif test yes = "$build_libtool_libs"; then 8397*a466cc55SCy Schubert # Not a shared library 8398*a466cc55SCy Schubert if test pass_all != "$deplibs_check_method"; then 8399*a466cc55SCy Schubert # We're trying link a shared library against a static one 8400*a466cc55SCy Schubert # but the system doesn't support it. 8401*a466cc55SCy Schubert 8402*a466cc55SCy Schubert # Just print a warning and add the library to dependency_libs so 8403*a466cc55SCy Schubert # that the program can be linked against the static library. 8404*a466cc55SCy Schubert echo 8405*a466cc55SCy Schubert $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406*a466cc55SCy Schubert echo "*** I have the capability to make that library automatically link in when" 8407*a466cc55SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 8408*a466cc55SCy Schubert echo "*** shared version of the library, which you do not appear to have." 8409*a466cc55SCy Schubert if test yes = "$module"; then 8410*a466cc55SCy Schubert echo "*** But as you try to build a module library, libtool will still create " 8411*a466cc55SCy Schubert echo "*** a static module, that should work as long as the dlopening application" 8412*a466cc55SCy Schubert echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413*a466cc55SCy Schubert if test -z "$global_symbol_pipe"; then 8414*a466cc55SCy Schubert echo 8415*a466cc55SCy Schubert echo "*** However, this would only work if libtool was able to extract symbol" 8416*a466cc55SCy Schubert echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417*a466cc55SCy Schubert echo "*** not find such a program. So, this module is probably useless." 8418*a466cc55SCy Schubert echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419*a466cc55SCy Schubert fi 8420*a466cc55SCy Schubert if test no = "$build_old_libs"; then 8421*a466cc55SCy Schubert build_libtool_libs=module 8422*a466cc55SCy Schubert build_old_libs=yes 8423*a466cc55SCy Schubert else 8424*a466cc55SCy Schubert build_libtool_libs=no 8425*a466cc55SCy Schubert fi 8426*a466cc55SCy Schubert fi 8427*a466cc55SCy Schubert else 8428*a466cc55SCy Schubert deplibs="$dir/$old_library $deplibs" 8429*a466cc55SCy Schubert link_static=yes 8430*a466cc55SCy Schubert fi 8431*a466cc55SCy Schubert fi # link shared/static library? 8432*a466cc55SCy Schubert 8433*a466cc55SCy Schubert if test lib = "$linkmode"; then 8434*a466cc55SCy Schubert if test -n "$dependency_libs" && 8435*a466cc55SCy Schubert { test yes != "$hardcode_into_libs" || 8436*a466cc55SCy Schubert test yes = "$build_old_libs" || 8437*a466cc55SCy Schubert test yes = "$link_static"; }; then 8438*a466cc55SCy Schubert # Extract -R from dependency_libs 8439*a466cc55SCy Schubert temp_deplibs= 8440*a466cc55SCy Schubert for libdir in $dependency_libs; do 8441*a466cc55SCy Schubert case $libdir in 8442*a466cc55SCy Schubert -R*) func_stripname '-R' '' "$libdir" 8443*a466cc55SCy Schubert temp_xrpath=$func_stripname_result 8444*a466cc55SCy Schubert case " $xrpath " in 8445*a466cc55SCy Schubert *" $temp_xrpath "*) ;; 8446*a466cc55SCy Schubert *) func_append xrpath " $temp_xrpath";; 8447*a466cc55SCy Schubert esac;; 8448*a466cc55SCy Schubert *) func_append temp_deplibs " $libdir";; 8449*a466cc55SCy Schubert esac 8450*a466cc55SCy Schubert done 8451*a466cc55SCy Schubert dependency_libs=$temp_deplibs 8452*a466cc55SCy Schubert fi 8453*a466cc55SCy Schubert 8454*a466cc55SCy Schubert func_append newlib_search_path " $absdir" 8455*a466cc55SCy Schubert # Link against this library 8456*a466cc55SCy Schubert test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457*a466cc55SCy Schubert # ... and its dependency_libs 8458*a466cc55SCy Schubert tmp_libs= 8459*a466cc55SCy Schubert for deplib in $dependency_libs; do 8460*a466cc55SCy Schubert newdependency_libs="$deplib $newdependency_libs" 8461*a466cc55SCy Schubert case $deplib in 8462*a466cc55SCy Schubert -L*) func_stripname '-L' '' "$deplib" 8463*a466cc55SCy Schubert func_resolve_sysroot "$func_stripname_result";; 8464*a466cc55SCy Schubert *) func_resolve_sysroot "$deplib" ;; 8465*a466cc55SCy Schubert esac 8466*a466cc55SCy Schubert if $opt_preserve_dup_deps; then 8467*a466cc55SCy Schubert case "$tmp_libs " in 8468*a466cc55SCy Schubert *" $func_resolve_sysroot_result "*) 8469*a466cc55SCy Schubert func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470*a466cc55SCy Schubert esac 8471*a466cc55SCy Schubert fi 8472*a466cc55SCy Schubert func_append tmp_libs " $func_resolve_sysroot_result" 8473*a466cc55SCy Schubert done 8474*a466cc55SCy Schubert 8475*a466cc55SCy Schubert if test no != "$link_all_deplibs"; then 8476*a466cc55SCy Schubert # Add the search paths of all dependency libraries 8477*a466cc55SCy Schubert for deplib in $dependency_libs; do 8478*a466cc55SCy Schubert path= 8479*a466cc55SCy Schubert case $deplib in 8480*a466cc55SCy Schubert -L*) path=$deplib ;; 8481*a466cc55SCy Schubert *.la) 8482*a466cc55SCy Schubert func_resolve_sysroot "$deplib" 8483*a466cc55SCy Schubert deplib=$func_resolve_sysroot_result 8484*a466cc55SCy Schubert func_dirname "$deplib" "" "." 8485*a466cc55SCy Schubert dir=$func_dirname_result 8486*a466cc55SCy Schubert # We need an absolute path. 8487*a466cc55SCy Schubert case $dir in 8488*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489*a466cc55SCy Schubert *) 8490*a466cc55SCy Schubert absdir=`cd "$dir" && pwd` 8491*a466cc55SCy Schubert if test -z "$absdir"; then 8492*a466cc55SCy Schubert func_warning "cannot determine absolute directory name of '$dir'" 8493*a466cc55SCy Schubert absdir=$dir 8494*a466cc55SCy Schubert fi 8495*a466cc55SCy Schubert ;; 8496*a466cc55SCy Schubert esac 8497*a466cc55SCy Schubert if $GREP "^installed=no" $deplib > /dev/null; then 8498*a466cc55SCy Schubert case $host in 8499*a466cc55SCy Schubert *-*-darwin*) 8500*a466cc55SCy Schubert depdepl= 8501*a466cc55SCy Schubert eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502*a466cc55SCy Schubert if test -n "$deplibrary_names"; then 8503*a466cc55SCy Schubert for tmp in $deplibrary_names; do 8504*a466cc55SCy Schubert depdepl=$tmp 8505*a466cc55SCy Schubert done 8506*a466cc55SCy Schubert if test -f "$absdir/$objdir/$depdepl"; then 8507*a466cc55SCy Schubert depdepl=$absdir/$objdir/$depdepl 8508*a466cc55SCy Schubert darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509*a466cc55SCy Schubert if test -z "$darwin_install_name"; then 8510*a466cc55SCy Schubert darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511*a466cc55SCy Schubert fi 8512*a466cc55SCy Schubert func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513*a466cc55SCy Schubert func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514*a466cc55SCy Schubert path= 8515*a466cc55SCy Schubert fi 8516*a466cc55SCy Schubert fi 8517*a466cc55SCy Schubert ;; 8518*a466cc55SCy Schubert *) 8519*a466cc55SCy Schubert path=-L$absdir/$objdir 8520*a466cc55SCy Schubert ;; 8521*a466cc55SCy Schubert esac 8522*a466cc55SCy Schubert else 8523*a466cc55SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524*a466cc55SCy Schubert test -z "$libdir" && \ 8525*a466cc55SCy Schubert func_fatal_error "'$deplib' is not a valid libtool archive" 8526*a466cc55SCy Schubert test "$absdir" != "$libdir" && \ 8527*a466cc55SCy Schubert func_warning "'$deplib' seems to be moved" 8528*a466cc55SCy Schubert 8529*a466cc55SCy Schubert path=-L$absdir 8530*a466cc55SCy Schubert fi 8531*a466cc55SCy Schubert ;; 8532*a466cc55SCy Schubert esac 8533*a466cc55SCy Schubert case " $deplibs " in 8534*a466cc55SCy Schubert *" $path "*) ;; 8535*a466cc55SCy Schubert *) deplibs="$path $deplibs" ;; 8536*a466cc55SCy Schubert esac 8537*a466cc55SCy Schubert done 8538*a466cc55SCy Schubert fi # link_all_deplibs != no 8539*a466cc55SCy Schubert fi # linkmode = lib 8540*a466cc55SCy Schubert done # for deplib in $libs 8541*a466cc55SCy Schubert if test link = "$pass"; then 8542*a466cc55SCy Schubert if test prog = "$linkmode"; then 8543*a466cc55SCy Schubert compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544*a466cc55SCy Schubert finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545*a466cc55SCy Schubert else 8546*a466cc55SCy Schubert compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547*a466cc55SCy Schubert fi 8548*a466cc55SCy Schubert fi 8549*a466cc55SCy Schubert dependency_libs=$newdependency_libs 8550*a466cc55SCy Schubert if test dlpreopen = "$pass"; then 8551*a466cc55SCy Schubert # Link the dlpreopened libraries before other libraries 8552*a466cc55SCy Schubert for deplib in $save_deplibs; do 8553*a466cc55SCy Schubert deplibs="$deplib $deplibs" 8554*a466cc55SCy Schubert done 8555*a466cc55SCy Schubert fi 8556*a466cc55SCy Schubert if test dlopen != "$pass"; then 8557*a466cc55SCy Schubert test conv = "$pass" || { 8558*a466cc55SCy Schubert # Make sure lib_search_path contains only unique directories. 8559*a466cc55SCy Schubert lib_search_path= 8560*a466cc55SCy Schubert for dir in $newlib_search_path; do 8561*a466cc55SCy Schubert case "$lib_search_path " in 8562*a466cc55SCy Schubert *" $dir "*) ;; 8563*a466cc55SCy Schubert *) func_append lib_search_path " $dir" ;; 8564*a466cc55SCy Schubert esac 8565*a466cc55SCy Schubert done 8566*a466cc55SCy Schubert newlib_search_path= 8567*a466cc55SCy Schubert } 8568*a466cc55SCy Schubert 8569*a466cc55SCy Schubert if test prog,link = "$linkmode,$pass"; then 8570*a466cc55SCy Schubert vars="compile_deplibs finalize_deplibs" 8571*a466cc55SCy Schubert else 8572*a466cc55SCy Schubert vars=deplibs 8573*a466cc55SCy Schubert fi 8574*a466cc55SCy Schubert for var in $vars dependency_libs; do 8575*a466cc55SCy Schubert # Add libraries to $var in reverse order 8576*a466cc55SCy Schubert eval tmp_libs=\"\$$var\" 8577*a466cc55SCy Schubert new_libs= 8578*a466cc55SCy Schubert for deplib in $tmp_libs; do 8579*a466cc55SCy Schubert # FIXME: Pedantically, this is the right thing to do, so 8580*a466cc55SCy Schubert # that some nasty dependency loop isn't accidentally 8581*a466cc55SCy Schubert # broken: 8582*a466cc55SCy Schubert #new_libs="$deplib $new_libs" 8583*a466cc55SCy Schubert # Pragmatically, this seems to cause very few problems in 8584*a466cc55SCy Schubert # practice: 8585*a466cc55SCy Schubert case $deplib in 8586*a466cc55SCy Schubert -L*) new_libs="$deplib $new_libs" ;; 8587*a466cc55SCy Schubert -R*) ;; 8588*a466cc55SCy Schubert *) 8589*a466cc55SCy Schubert # And here is the reason: when a library appears more 8590*a466cc55SCy Schubert # than once as an explicit dependence of a library, or 8591*a466cc55SCy Schubert # is implicitly linked in more than once by the 8592*a466cc55SCy Schubert # compiler, it is considered special, and multiple 8593*a466cc55SCy Schubert # occurrences thereof are not removed. Compare this 8594*a466cc55SCy Schubert # with having the same library being listed as a 8595*a466cc55SCy Schubert # dependency of multiple other libraries: in this case, 8596*a466cc55SCy Schubert # we know (pedantically, we assume) the library does not 8597*a466cc55SCy Schubert # need to be listed more than once, so we keep only the 8598*a466cc55SCy Schubert # last copy. This is not always right, but it is rare 8599*a466cc55SCy Schubert # enough that we require users that really mean to play 8600*a466cc55SCy Schubert # such unportable linking tricks to link the library 8601*a466cc55SCy Schubert # using -Wl,-lname, so that libtool does not consider it 8602*a466cc55SCy Schubert # for duplicate removal. 8603*a466cc55SCy Schubert case " $specialdeplibs " in 8604*a466cc55SCy Schubert *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605*a466cc55SCy Schubert *) 8606*a466cc55SCy Schubert case " $new_libs " in 8607*a466cc55SCy Schubert *" $deplib "*) ;; 8608*a466cc55SCy Schubert *) new_libs="$deplib $new_libs" ;; 8609*a466cc55SCy Schubert esac 8610*a466cc55SCy Schubert ;; 8611*a466cc55SCy Schubert esac 8612*a466cc55SCy Schubert ;; 8613*a466cc55SCy Schubert esac 8614*a466cc55SCy Schubert done 8615*a466cc55SCy Schubert tmp_libs= 8616*a466cc55SCy Schubert for deplib in $new_libs; do 8617*a466cc55SCy Schubert case $deplib in 8618*a466cc55SCy Schubert -L*) 8619*a466cc55SCy Schubert case " $tmp_libs " in 8620*a466cc55SCy Schubert *" $deplib "*) ;; 8621*a466cc55SCy Schubert *) func_append tmp_libs " $deplib" ;; 8622*a466cc55SCy Schubert esac 8623*a466cc55SCy Schubert ;; 8624*a466cc55SCy Schubert *) func_append tmp_libs " $deplib" ;; 8625*a466cc55SCy Schubert esac 8626*a466cc55SCy Schubert done 8627*a466cc55SCy Schubert eval $var=\"$tmp_libs\" 8628*a466cc55SCy Schubert done # for var 8629*a466cc55SCy Schubert fi 8630*a466cc55SCy Schubert 8631*a466cc55SCy Schubert # Add Sun CC postdeps if required: 8632*a466cc55SCy Schubert test CXX = "$tagname" && { 8633*a466cc55SCy Schubert case $host_os in 8634*a466cc55SCy Schubert linux*) 8635*a466cc55SCy Schubert case `$CC -V 2>&1 | sed 5q` in 8636*a466cc55SCy Schubert *Sun\ C*) # Sun C++ 5.9 8637*a466cc55SCy Schubert func_suncc_cstd_abi 8638*a466cc55SCy Schubert 8639*a466cc55SCy Schubert if test no != "$suncc_use_cstd_abi"; then 8640*a466cc55SCy Schubert func_append postdeps ' -library=Cstd -library=Crun' 8641*a466cc55SCy Schubert fi 8642*a466cc55SCy Schubert ;; 8643*a466cc55SCy Schubert esac 8644*a466cc55SCy Schubert ;; 8645*a466cc55SCy Schubert 8646*a466cc55SCy Schubert solaris*) 8647*a466cc55SCy Schubert func_cc_basename "$CC" 8648*a466cc55SCy Schubert case $func_cc_basename_result in 8649*a466cc55SCy Schubert CC* | sunCC*) 8650*a466cc55SCy Schubert func_suncc_cstd_abi 8651*a466cc55SCy Schubert 8652*a466cc55SCy Schubert if test no != "$suncc_use_cstd_abi"; then 8653*a466cc55SCy Schubert func_append postdeps ' -library=Cstd -library=Crun' 8654*a466cc55SCy Schubert fi 8655*a466cc55SCy Schubert ;; 8656*a466cc55SCy Schubert esac 8657*a466cc55SCy Schubert ;; 8658*a466cc55SCy Schubert esac 8659*a466cc55SCy Schubert } 8660*a466cc55SCy Schubert 8661*a466cc55SCy Schubert # Last step: remove runtime libs from dependency_libs 8662*a466cc55SCy Schubert # (they stay in deplibs) 8663*a466cc55SCy Schubert tmp_libs= 8664*a466cc55SCy Schubert for i in $dependency_libs; do 8665*a466cc55SCy Schubert case " $predeps $postdeps $compiler_lib_search_path " in 8666*a466cc55SCy Schubert *" $i "*) 8667*a466cc55SCy Schubert i= 8668*a466cc55SCy Schubert ;; 8669*a466cc55SCy Schubert esac 8670*a466cc55SCy Schubert if test -n "$i"; then 8671*a466cc55SCy Schubert func_append tmp_libs " $i" 8672*a466cc55SCy Schubert fi 8673*a466cc55SCy Schubert done 8674*a466cc55SCy Schubert dependency_libs=$tmp_libs 8675*a466cc55SCy Schubert done # for pass 8676*a466cc55SCy Schubert if test prog = "$linkmode"; then 8677*a466cc55SCy Schubert dlfiles=$newdlfiles 8678*a466cc55SCy Schubert fi 8679*a466cc55SCy Schubert if test prog = "$linkmode" || test lib = "$linkmode"; then 8680*a466cc55SCy Schubert dlprefiles=$newdlprefiles 8681*a466cc55SCy Schubert fi 8682*a466cc55SCy Schubert 8683*a466cc55SCy Schubert case $linkmode in 8684*a466cc55SCy Schubert oldlib) 8685*a466cc55SCy Schubert if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686*a466cc55SCy Schubert func_warning "'-dlopen' is ignored for archives" 8687*a466cc55SCy Schubert fi 8688*a466cc55SCy Schubert 8689*a466cc55SCy Schubert case " $deplibs" in 8690*a466cc55SCy Schubert *\ -l* | *\ -L*) 8691*a466cc55SCy Schubert func_warning "'-l' and '-L' are ignored for archives" ;; 8692*a466cc55SCy Schubert esac 8693*a466cc55SCy Schubert 8694*a466cc55SCy Schubert test -n "$rpath" && \ 8695*a466cc55SCy Schubert func_warning "'-rpath' is ignored for archives" 8696*a466cc55SCy Schubert 8697*a466cc55SCy Schubert test -n "$xrpath" && \ 8698*a466cc55SCy Schubert func_warning "'-R' is ignored for archives" 8699*a466cc55SCy Schubert 8700*a466cc55SCy Schubert test -n "$vinfo" && \ 8701*a466cc55SCy Schubert func_warning "'-version-info/-version-number' is ignored for archives" 8702*a466cc55SCy Schubert 8703*a466cc55SCy Schubert test -n "$release" && \ 8704*a466cc55SCy Schubert func_warning "'-release' is ignored for archives" 8705*a466cc55SCy Schubert 8706*a466cc55SCy Schubert test -n "$export_symbols$export_symbols_regex" && \ 8707*a466cc55SCy Schubert func_warning "'-export-symbols' is ignored for archives" 8708*a466cc55SCy Schubert 8709*a466cc55SCy Schubert # Now set the variables for building old libraries. 8710*a466cc55SCy Schubert build_libtool_libs=no 8711*a466cc55SCy Schubert oldlibs=$output 8712*a466cc55SCy Schubert func_append objs "$old_deplibs" 8713*a466cc55SCy Schubert ;; 8714*a466cc55SCy Schubert 8715*a466cc55SCy Schubert lib) 8716*a466cc55SCy Schubert # Make sure we only generate libraries of the form 'libNAME.la'. 8717*a466cc55SCy Schubert case $outputname in 8718*a466cc55SCy Schubert lib*) 8719*a466cc55SCy Schubert func_stripname 'lib' '.la' "$outputname" 8720*a466cc55SCy Schubert name=$func_stripname_result 8721*a466cc55SCy Schubert eval shared_ext=\"$shrext_cmds\" 8722*a466cc55SCy Schubert eval libname=\"$libname_spec\" 8723*a466cc55SCy Schubert ;; 8724*a466cc55SCy Schubert *) 8725*a466cc55SCy Schubert test no = "$module" \ 8726*a466cc55SCy Schubert && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727*a466cc55SCy Schubert 8728*a466cc55SCy Schubert if test no != "$need_lib_prefix"; then 8729*a466cc55SCy Schubert # Add the "lib" prefix for modules if required 8730*a466cc55SCy Schubert func_stripname '' '.la' "$outputname" 8731*a466cc55SCy Schubert name=$func_stripname_result 8732*a466cc55SCy Schubert eval shared_ext=\"$shrext_cmds\" 8733*a466cc55SCy Schubert eval libname=\"$libname_spec\" 8734*a466cc55SCy Schubert else 8735*a466cc55SCy Schubert func_stripname '' '.la' "$outputname" 8736*a466cc55SCy Schubert libname=$func_stripname_result 8737*a466cc55SCy Schubert fi 8738*a466cc55SCy Schubert ;; 8739*a466cc55SCy Schubert esac 8740*a466cc55SCy Schubert 8741*a466cc55SCy Schubert if test -n "$objs"; then 8742*a466cc55SCy Schubert if test pass_all != "$deplibs_check_method"; then 8743*a466cc55SCy Schubert func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744*a466cc55SCy Schubert else 8745*a466cc55SCy Schubert echo 8746*a466cc55SCy Schubert $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747*a466cc55SCy Schubert $ECHO "*** objects $objs is not portable!" 8748*a466cc55SCy Schubert func_append libobjs " $objs" 8749*a466cc55SCy Schubert fi 8750*a466cc55SCy Schubert fi 8751*a466cc55SCy Schubert 8752*a466cc55SCy Schubert test no = "$dlself" \ 8753*a466cc55SCy Schubert || func_warning "'-dlopen self' is ignored for libtool libraries" 8754*a466cc55SCy Schubert 8755*a466cc55SCy Schubert set dummy $rpath 8756*a466cc55SCy Schubert shift 8757*a466cc55SCy Schubert test 1 -lt "$#" \ 8758*a466cc55SCy Schubert && func_warning "ignoring multiple '-rpath's for a libtool library" 8759*a466cc55SCy Schubert 8760*a466cc55SCy Schubert install_libdir=$1 8761*a466cc55SCy Schubert 8762*a466cc55SCy Schubert oldlibs= 8763*a466cc55SCy Schubert if test -z "$rpath"; then 8764*a466cc55SCy Schubert if test yes = "$build_libtool_libs"; then 8765*a466cc55SCy Schubert # Building a libtool convenience library. 8766*a466cc55SCy Schubert # Some compilers have problems with a '.al' extension so 8767*a466cc55SCy Schubert # convenience libraries should have the same extension an 8768*a466cc55SCy Schubert # archive normally would. 8769*a466cc55SCy Schubert oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770*a466cc55SCy Schubert build_libtool_libs=convenience 8771*a466cc55SCy Schubert build_old_libs=yes 8772*a466cc55SCy Schubert fi 8773*a466cc55SCy Schubert 8774*a466cc55SCy Schubert test -n "$vinfo" && \ 8775*a466cc55SCy Schubert func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776*a466cc55SCy Schubert 8777*a466cc55SCy Schubert test -n "$release" && \ 8778*a466cc55SCy Schubert func_warning "'-release' is ignored for convenience libraries" 8779*a466cc55SCy Schubert else 8780*a466cc55SCy Schubert 8781*a466cc55SCy Schubert # Parse the version information argument. 8782*a466cc55SCy Schubert save_ifs=$IFS; IFS=: 8783*a466cc55SCy Schubert set dummy $vinfo 0 0 0 8784*a466cc55SCy Schubert shift 8785*a466cc55SCy Schubert IFS=$save_ifs 8786*a466cc55SCy Schubert 8787*a466cc55SCy Schubert test -n "$7" && \ 8788*a466cc55SCy Schubert func_fatal_help "too many parameters to '-version-info'" 8789*a466cc55SCy Schubert 8790*a466cc55SCy Schubert # convert absolute version numbers to libtool ages 8791*a466cc55SCy Schubert # this retains compatibility with .la files and attempts 8792*a466cc55SCy Schubert # to make the code below a bit more comprehensible 8793*a466cc55SCy Schubert 8794*a466cc55SCy Schubert case $vinfo_number in 8795*a466cc55SCy Schubert yes) 8796*a466cc55SCy Schubert number_major=$1 8797*a466cc55SCy Schubert number_minor=$2 8798*a466cc55SCy Schubert number_revision=$3 8799*a466cc55SCy Schubert # 8800*a466cc55SCy Schubert # There are really only two kinds -- those that 8801*a466cc55SCy Schubert # use the current revision as the major version 8802*a466cc55SCy Schubert # and those that subtract age and use age as 8803*a466cc55SCy Schubert # a minor version. But, then there is irix 8804*a466cc55SCy Schubert # that has an extra 1 added just for fun 8805*a466cc55SCy Schubert # 8806*a466cc55SCy Schubert case $version_type in 8807*a466cc55SCy Schubert # correct linux to gnu/linux during the next big refactor 8808*a466cc55SCy Schubert darwin|freebsd-elf|linux|osf|windows|none) 8809*a466cc55SCy Schubert func_arith $number_major + $number_minor 8810*a466cc55SCy Schubert current=$func_arith_result 8811*a466cc55SCy Schubert age=$number_minor 8812*a466cc55SCy Schubert revision=$number_revision 8813*a466cc55SCy Schubert ;; 8814*a466cc55SCy Schubert freebsd-aout|qnx|sunos) 8815*a466cc55SCy Schubert current=$number_major 8816*a466cc55SCy Schubert revision=$number_minor 8817*a466cc55SCy Schubert age=0 8818*a466cc55SCy Schubert ;; 8819*a466cc55SCy Schubert irix|nonstopux) 8820*a466cc55SCy Schubert func_arith $number_major + $number_minor 8821*a466cc55SCy Schubert current=$func_arith_result 8822*a466cc55SCy Schubert age=$number_minor 8823*a466cc55SCy Schubert revision=$number_minor 8824*a466cc55SCy Schubert lt_irix_increment=no 8825*a466cc55SCy Schubert ;; 8826*a466cc55SCy Schubert esac 8827*a466cc55SCy Schubert ;; 8828*a466cc55SCy Schubert no) 8829*a466cc55SCy Schubert current=$1 8830*a466cc55SCy Schubert revision=$2 8831*a466cc55SCy Schubert age=$3 8832*a466cc55SCy Schubert ;; 8833*a466cc55SCy Schubert esac 8834*a466cc55SCy Schubert 8835*a466cc55SCy Schubert # Check that each of the things are valid numbers. 8836*a466cc55SCy Schubert case $current in 8837*a466cc55SCy 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]) ;; 8838*a466cc55SCy Schubert *) 8839*a466cc55SCy Schubert func_error "CURRENT '$current' must be a nonnegative integer" 8840*a466cc55SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 8841*a466cc55SCy Schubert ;; 8842*a466cc55SCy Schubert esac 8843*a466cc55SCy Schubert 8844*a466cc55SCy Schubert case $revision in 8845*a466cc55SCy 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]) ;; 8846*a466cc55SCy Schubert *) 8847*a466cc55SCy Schubert func_error "REVISION '$revision' must be a nonnegative integer" 8848*a466cc55SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 8849*a466cc55SCy Schubert ;; 8850*a466cc55SCy Schubert esac 8851*a466cc55SCy Schubert 8852*a466cc55SCy Schubert case $age in 8853*a466cc55SCy 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]) ;; 8854*a466cc55SCy Schubert *) 8855*a466cc55SCy Schubert func_error "AGE '$age' must be a nonnegative integer" 8856*a466cc55SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 8857*a466cc55SCy Schubert ;; 8858*a466cc55SCy Schubert esac 8859*a466cc55SCy Schubert 8860*a466cc55SCy Schubert if test "$age" -gt "$current"; then 8861*a466cc55SCy Schubert func_error "AGE '$age' is greater than the current interface number '$current'" 8862*a466cc55SCy Schubert func_fatal_error "'$vinfo' is not valid version information" 8863*a466cc55SCy Schubert fi 8864*a466cc55SCy Schubert 8865*a466cc55SCy Schubert # Calculate the version variables. 8866*a466cc55SCy Schubert major= 8867*a466cc55SCy Schubert versuffix= 8868*a466cc55SCy Schubert verstring= 8869*a466cc55SCy Schubert case $version_type in 8870*a466cc55SCy Schubert none) ;; 8871*a466cc55SCy Schubert 8872*a466cc55SCy Schubert darwin) 8873*a466cc55SCy Schubert # Like Linux, but with the current version available in 8874*a466cc55SCy Schubert # verstring for coding it into the library header 8875*a466cc55SCy Schubert func_arith $current - $age 8876*a466cc55SCy Schubert major=.$func_arith_result 8877*a466cc55SCy Schubert versuffix=$major.$age.$revision 8878*a466cc55SCy Schubert # Darwin ld doesn't like 0 for these options... 8879*a466cc55SCy Schubert func_arith $current + 1 8880*a466cc55SCy Schubert minor_current=$func_arith_result 8881*a466cc55SCy Schubert xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882*a466cc55SCy Schubert verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883*a466cc55SCy Schubert # On Darwin other compilers 8884*a466cc55SCy Schubert case $CC in 8885*a466cc55SCy Schubert nagfor*) 8886*a466cc55SCy Schubert verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887*a466cc55SCy Schubert ;; 8888*a466cc55SCy Schubert *) 8889*a466cc55SCy Schubert verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890*a466cc55SCy Schubert ;; 8891*a466cc55SCy Schubert esac 8892*a466cc55SCy Schubert ;; 8893*a466cc55SCy Schubert 8894*a466cc55SCy Schubert freebsd-aout) 8895*a466cc55SCy Schubert major=.$current 8896*a466cc55SCy Schubert versuffix=.$current.$revision 8897*a466cc55SCy Schubert ;; 8898*a466cc55SCy Schubert 8899*a466cc55SCy Schubert freebsd-elf) 8900*a466cc55SCy Schubert func_arith $current - $age 8901*a466cc55SCy Schubert major=.$func_arith_result 8902*a466cc55SCy Schubert versuffix=$major.$age.$revision 8903*a466cc55SCy Schubert ;; 8904*a466cc55SCy Schubert 8905*a466cc55SCy Schubert irix | nonstopux) 8906*a466cc55SCy Schubert if test no = "$lt_irix_increment"; then 8907*a466cc55SCy Schubert func_arith $current - $age 8908*a466cc55SCy Schubert else 8909*a466cc55SCy Schubert func_arith $current - $age + 1 8910*a466cc55SCy Schubert fi 8911*a466cc55SCy Schubert major=$func_arith_result 8912*a466cc55SCy Schubert 8913*a466cc55SCy Schubert case $version_type in 8914*a466cc55SCy Schubert nonstopux) verstring_prefix=nonstopux ;; 8915*a466cc55SCy Schubert *) verstring_prefix=sgi ;; 8916*a466cc55SCy Schubert esac 8917*a466cc55SCy Schubert verstring=$verstring_prefix$major.$revision 8918*a466cc55SCy Schubert 8919*a466cc55SCy Schubert # Add in all the interfaces that we are compatible with. 8920*a466cc55SCy Schubert loop=$revision 8921*a466cc55SCy Schubert while test 0 -ne "$loop"; do 8922*a466cc55SCy Schubert func_arith $revision - $loop 8923*a466cc55SCy Schubert iface=$func_arith_result 8924*a466cc55SCy Schubert func_arith $loop - 1 8925*a466cc55SCy Schubert loop=$func_arith_result 8926*a466cc55SCy Schubert verstring=$verstring_prefix$major.$iface:$verstring 8927*a466cc55SCy Schubert done 8928*a466cc55SCy Schubert 8929*a466cc55SCy Schubert # Before this point, $major must not contain '.'. 8930*a466cc55SCy Schubert major=.$major 8931*a466cc55SCy Schubert versuffix=$major.$revision 8932*a466cc55SCy Schubert ;; 8933*a466cc55SCy Schubert 8934*a466cc55SCy Schubert linux) # correct to gnu/linux during the next big refactor 8935*a466cc55SCy Schubert func_arith $current - $age 8936*a466cc55SCy Schubert major=.$func_arith_result 8937*a466cc55SCy Schubert versuffix=$major.$age.$revision 8938*a466cc55SCy Schubert ;; 8939*a466cc55SCy Schubert 8940*a466cc55SCy Schubert osf) 8941*a466cc55SCy Schubert func_arith $current - $age 8942*a466cc55SCy Schubert major=.$func_arith_result 8943*a466cc55SCy Schubert versuffix=.$current.$age.$revision 8944*a466cc55SCy Schubert verstring=$current.$age.$revision 8945*a466cc55SCy Schubert 8946*a466cc55SCy Schubert # Add in all the interfaces that we are compatible with. 8947*a466cc55SCy Schubert loop=$age 8948*a466cc55SCy Schubert while test 0 -ne "$loop"; do 8949*a466cc55SCy Schubert func_arith $current - $loop 8950*a466cc55SCy Schubert iface=$func_arith_result 8951*a466cc55SCy Schubert func_arith $loop - 1 8952*a466cc55SCy Schubert loop=$func_arith_result 8953*a466cc55SCy Schubert verstring=$verstring:$iface.0 8954*a466cc55SCy Schubert done 8955*a466cc55SCy Schubert 8956*a466cc55SCy Schubert # Make executables depend on our current version. 8957*a466cc55SCy Schubert func_append verstring ":$current.0" 8958*a466cc55SCy Schubert ;; 8959*a466cc55SCy Schubert 8960*a466cc55SCy Schubert qnx) 8961*a466cc55SCy Schubert major=.$current 8962*a466cc55SCy Schubert versuffix=.$current 8963*a466cc55SCy Schubert ;; 8964*a466cc55SCy Schubert 8965*a466cc55SCy Schubert sco) 8966*a466cc55SCy Schubert major=.$current 8967*a466cc55SCy Schubert versuffix=.$current 8968*a466cc55SCy Schubert ;; 8969*a466cc55SCy Schubert 8970*a466cc55SCy Schubert sunos) 8971*a466cc55SCy Schubert major=.$current 8972*a466cc55SCy Schubert versuffix=.$current.$revision 8973*a466cc55SCy Schubert ;; 8974*a466cc55SCy Schubert 8975*a466cc55SCy Schubert windows) 8976*a466cc55SCy Schubert # Use '-' rather than '.', since we only want one 8977*a466cc55SCy Schubert # extension on DOS 8.3 file systems. 8978*a466cc55SCy Schubert func_arith $current - $age 8979*a466cc55SCy Schubert major=$func_arith_result 8980*a466cc55SCy Schubert versuffix=-$major 8981*a466cc55SCy Schubert ;; 8982*a466cc55SCy Schubert 8983*a466cc55SCy Schubert *) 8984*a466cc55SCy Schubert func_fatal_configuration "unknown library version type '$version_type'" 8985*a466cc55SCy Schubert ;; 8986*a466cc55SCy Schubert esac 8987*a466cc55SCy Schubert 8988*a466cc55SCy Schubert # Clear the version info if we defaulted, and they specified a release. 8989*a466cc55SCy Schubert if test -z "$vinfo" && test -n "$release"; then 8990*a466cc55SCy Schubert major= 8991*a466cc55SCy Schubert case $version_type in 8992*a466cc55SCy Schubert darwin) 8993*a466cc55SCy Schubert # we can't check for "0.0" in archive_cmds due to quoting 8994*a466cc55SCy Schubert # problems, so we reset it completely 8995*a466cc55SCy Schubert verstring= 8996*a466cc55SCy Schubert ;; 8997*a466cc55SCy Schubert *) 8998*a466cc55SCy Schubert verstring=0.0 8999*a466cc55SCy Schubert ;; 9000*a466cc55SCy Schubert esac 9001*a466cc55SCy Schubert if test no = "$need_version"; then 9002*a466cc55SCy Schubert versuffix= 9003*a466cc55SCy Schubert else 9004*a466cc55SCy Schubert versuffix=.0.0 9005*a466cc55SCy Schubert fi 9006*a466cc55SCy Schubert fi 9007*a466cc55SCy Schubert 9008*a466cc55SCy Schubert # Remove version info from name if versioning should be avoided 9009*a466cc55SCy Schubert if test yes,no = "$avoid_version,$need_version"; then 9010*a466cc55SCy Schubert major= 9011*a466cc55SCy Schubert versuffix= 9012*a466cc55SCy Schubert verstring= 9013*a466cc55SCy Schubert fi 9014*a466cc55SCy Schubert 9015*a466cc55SCy Schubert # Check to see if the archive will have undefined symbols. 9016*a466cc55SCy Schubert if test yes = "$allow_undefined"; then 9017*a466cc55SCy Schubert if test unsupported = "$allow_undefined_flag"; then 9018*a466cc55SCy Schubert if test yes = "$build_old_libs"; then 9019*a466cc55SCy Schubert func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020*a466cc55SCy Schubert build_libtool_libs=no 9021*a466cc55SCy Schubert else 9022*a466cc55SCy Schubert func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023*a466cc55SCy Schubert fi 9024*a466cc55SCy Schubert fi 9025*a466cc55SCy Schubert else 9026*a466cc55SCy Schubert # Don't allow undefined symbols. 9027*a466cc55SCy Schubert allow_undefined_flag=$no_undefined_flag 9028*a466cc55SCy Schubert fi 9029*a466cc55SCy Schubert 9030*a466cc55SCy Schubert fi 9031*a466cc55SCy Schubert 9032*a466cc55SCy Schubert func_generate_dlsyms "$libname" "$libname" : 9033*a466cc55SCy Schubert func_append libobjs " $symfileobj" 9034*a466cc55SCy Schubert test " " = "$libobjs" && libobjs= 9035*a466cc55SCy Schubert 9036*a466cc55SCy Schubert if test relink != "$opt_mode"; then 9037*a466cc55SCy Schubert # Remove our outputs, but don't remove object files since they 9038*a466cc55SCy Schubert # may have been created when compiling PIC objects. 9039*a466cc55SCy Schubert removelist= 9040*a466cc55SCy Schubert tempremovelist=`$ECHO "$output_objdir/*"` 9041*a466cc55SCy Schubert for p in $tempremovelist; do 9042*a466cc55SCy Schubert case $p in 9043*a466cc55SCy Schubert *.$objext | *.gcno) 9044*a466cc55SCy Schubert ;; 9045*a466cc55SCy Schubert $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046*a466cc55SCy Schubert if test -n "$precious_files_regex"; then 9047*a466cc55SCy Schubert if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048*a466cc55SCy Schubert then 9049*a466cc55SCy Schubert continue 9050*a466cc55SCy Schubert fi 9051*a466cc55SCy Schubert fi 9052*a466cc55SCy Schubert func_append removelist " $p" 9053*a466cc55SCy Schubert ;; 9054*a466cc55SCy Schubert *) ;; 9055*a466cc55SCy Schubert esac 9056*a466cc55SCy Schubert done 9057*a466cc55SCy Schubert test -n "$removelist" && \ 9058*a466cc55SCy Schubert func_show_eval "${RM}r \$removelist" 9059*a466cc55SCy Schubert fi 9060*a466cc55SCy Schubert 9061*a466cc55SCy Schubert # Now set the variables for building old libraries. 9062*a466cc55SCy Schubert if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063*a466cc55SCy Schubert func_append oldlibs " $output_objdir/$libname.$libext" 9064*a466cc55SCy Schubert 9065*a466cc55SCy Schubert # Transform .lo files to .o files. 9066*a466cc55SCy Schubert oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067*a466cc55SCy Schubert fi 9068*a466cc55SCy Schubert 9069*a466cc55SCy Schubert # Eliminate all temporary directories. 9070*a466cc55SCy Schubert #for path in $notinst_path; do 9071*a466cc55SCy Schubert # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072*a466cc55SCy Schubert # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073*a466cc55SCy Schubert # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074*a466cc55SCy Schubert #done 9075*a466cc55SCy Schubert 9076*a466cc55SCy Schubert if test -n "$xrpath"; then 9077*a466cc55SCy Schubert # If the user specified any rpath flags, then add them. 9078*a466cc55SCy Schubert temp_xrpath= 9079*a466cc55SCy Schubert for libdir in $xrpath; do 9080*a466cc55SCy Schubert func_replace_sysroot "$libdir" 9081*a466cc55SCy Schubert func_append temp_xrpath " -R$func_replace_sysroot_result" 9082*a466cc55SCy Schubert case "$finalize_rpath " in 9083*a466cc55SCy Schubert *" $libdir "*) ;; 9084*a466cc55SCy Schubert *) func_append finalize_rpath " $libdir" ;; 9085*a466cc55SCy Schubert esac 9086*a466cc55SCy Schubert done 9087*a466cc55SCy Schubert if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088*a466cc55SCy Schubert dependency_libs="$temp_xrpath $dependency_libs" 9089*a466cc55SCy Schubert fi 9090*a466cc55SCy Schubert fi 9091*a466cc55SCy Schubert 9092*a466cc55SCy Schubert # Make sure dlfiles contains only unique files that won't be dlpreopened 9093*a466cc55SCy Schubert old_dlfiles=$dlfiles 9094*a466cc55SCy Schubert dlfiles= 9095*a466cc55SCy Schubert for lib in $old_dlfiles; do 9096*a466cc55SCy Schubert case " $dlprefiles $dlfiles " in 9097*a466cc55SCy Schubert *" $lib "*) ;; 9098*a466cc55SCy Schubert *) func_append dlfiles " $lib" ;; 9099*a466cc55SCy Schubert esac 9100*a466cc55SCy Schubert done 9101*a466cc55SCy Schubert 9102*a466cc55SCy Schubert # Make sure dlprefiles contains only unique files 9103*a466cc55SCy Schubert old_dlprefiles=$dlprefiles 9104*a466cc55SCy Schubert dlprefiles= 9105*a466cc55SCy Schubert for lib in $old_dlprefiles; do 9106*a466cc55SCy Schubert case "$dlprefiles " in 9107*a466cc55SCy Schubert *" $lib "*) ;; 9108*a466cc55SCy Schubert *) func_append dlprefiles " $lib" ;; 9109*a466cc55SCy Schubert esac 9110*a466cc55SCy Schubert done 9111*a466cc55SCy Schubert 9112*a466cc55SCy Schubert if test yes = "$build_libtool_libs"; then 9113*a466cc55SCy Schubert if test -n "$rpath"; then 9114*a466cc55SCy Schubert case $host in 9115*a466cc55SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116*a466cc55SCy Schubert # these systems don't actually have a c library (as such)! 9117*a466cc55SCy Schubert ;; 9118*a466cc55SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 9119*a466cc55SCy Schubert # Rhapsody C library is in the System framework 9120*a466cc55SCy Schubert func_append deplibs " System.ltframework" 9121*a466cc55SCy Schubert ;; 9122*a466cc55SCy Schubert *-*-netbsd*) 9123*a466cc55SCy Schubert # Don't link with libc until the a.out ld.so is fixed. 9124*a466cc55SCy Schubert ;; 9125*a466cc55SCy Schubert *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126*a466cc55SCy Schubert # Do not include libc due to us having libc/libc_r. 9127*a466cc55SCy Schubert ;; 9128*a466cc55SCy Schubert *-*-sco3.2v5* | *-*-sco5v6*) 9129*a466cc55SCy Schubert # Causes problems with __ctype 9130*a466cc55SCy Schubert ;; 9131*a466cc55SCy Schubert *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132*a466cc55SCy Schubert # Compiler inserts libc in the correct place for threads to work 9133*a466cc55SCy Schubert ;; 9134*a466cc55SCy Schubert *) 9135*a466cc55SCy Schubert # Add libc to deplibs on all other systems if necessary. 9136*a466cc55SCy Schubert if test yes = "$build_libtool_need_lc"; then 9137*a466cc55SCy Schubert func_append deplibs " -lc" 9138*a466cc55SCy Schubert fi 9139*a466cc55SCy Schubert ;; 9140*a466cc55SCy Schubert esac 9141*a466cc55SCy Schubert fi 9142*a466cc55SCy Schubert 9143*a466cc55SCy Schubert # Transform deplibs into only deplibs that can be linked in shared. 9144*a466cc55SCy Schubert name_save=$name 9145*a466cc55SCy Schubert libname_save=$libname 9146*a466cc55SCy Schubert release_save=$release 9147*a466cc55SCy Schubert versuffix_save=$versuffix 9148*a466cc55SCy Schubert major_save=$major 9149*a466cc55SCy Schubert # I'm not sure if I'm treating the release correctly. I think 9150*a466cc55SCy Schubert # release should show up in the -l (ie -lgmp5) so we don't want to 9151*a466cc55SCy Schubert # add it in twice. Is that correct? 9152*a466cc55SCy Schubert release= 9153*a466cc55SCy Schubert versuffix= 9154*a466cc55SCy Schubert major= 9155*a466cc55SCy Schubert newdeplibs= 9156*a466cc55SCy Schubert droppeddeps=no 9157*a466cc55SCy Schubert case $deplibs_check_method in 9158*a466cc55SCy Schubert pass_all) 9159*a466cc55SCy Schubert # Don't check for shared/static. Everything works. 9160*a466cc55SCy Schubert # This might be a little naive. We might want to check 9161*a466cc55SCy Schubert # whether the library exists or not. But this is on 9162*a466cc55SCy Schubert # osf3 & osf4 and I'm not really sure... Just 9163*a466cc55SCy Schubert # implementing what was already the behavior. 9164*a466cc55SCy Schubert newdeplibs=$deplibs 9165*a466cc55SCy Schubert ;; 9166*a466cc55SCy Schubert test_compile) 9167*a466cc55SCy Schubert # This code stresses the "libraries are programs" paradigm to its 9168*a466cc55SCy Schubert # limits. Maybe even breaks it. We compile a program, linking it 9169*a466cc55SCy Schubert # against the deplibs as a proxy for the library. Then we can check 9170*a466cc55SCy Schubert # whether they linked in statically or dynamically with ldd. 9171*a466cc55SCy Schubert $opt_dry_run || $RM conftest.c 9172*a466cc55SCy Schubert cat > conftest.c <<EOF 9173*a466cc55SCy Schubert int main() { return 0; } 9174*a466cc55SCy SchubertEOF 9175*a466cc55SCy Schubert $opt_dry_run || $RM conftest 9176*a466cc55SCy Schubert if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177*a466cc55SCy Schubert ldd_output=`ldd conftest` 9178*a466cc55SCy Schubert for i in $deplibs; do 9179*a466cc55SCy Schubert case $i in 9180*a466cc55SCy Schubert -l*) 9181*a466cc55SCy Schubert func_stripname -l '' "$i" 9182*a466cc55SCy Schubert name=$func_stripname_result 9183*a466cc55SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184*a466cc55SCy Schubert case " $predeps $postdeps " in 9185*a466cc55SCy Schubert *" $i "*) 9186*a466cc55SCy Schubert func_append newdeplibs " $i" 9187*a466cc55SCy Schubert i= 9188*a466cc55SCy Schubert ;; 9189*a466cc55SCy Schubert esac 9190*a466cc55SCy Schubert fi 9191*a466cc55SCy Schubert if test -n "$i"; then 9192*a466cc55SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9193*a466cc55SCy Schubert deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194*a466cc55SCy Schubert set dummy $deplib_matches; shift 9195*a466cc55SCy Schubert deplib_match=$1 9196*a466cc55SCy Schubert if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197*a466cc55SCy Schubert func_append newdeplibs " $i" 9198*a466cc55SCy Schubert else 9199*a466cc55SCy Schubert droppeddeps=yes 9200*a466cc55SCy Schubert echo 9201*a466cc55SCy Schubert $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202*a466cc55SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9203*a466cc55SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9204*a466cc55SCy Schubert echo "*** shared version of the library, which I believe you do not have" 9205*a466cc55SCy Schubert echo "*** because a test_compile did reveal that the linker did not use it for" 9206*a466cc55SCy Schubert echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207*a466cc55SCy Schubert fi 9208*a466cc55SCy Schubert fi 9209*a466cc55SCy Schubert ;; 9210*a466cc55SCy Schubert *) 9211*a466cc55SCy Schubert func_append newdeplibs " $i" 9212*a466cc55SCy Schubert ;; 9213*a466cc55SCy Schubert esac 9214*a466cc55SCy Schubert done 9215*a466cc55SCy Schubert else 9216*a466cc55SCy Schubert # Error occurred in the first compile. Let's try to salvage 9217*a466cc55SCy Schubert # the situation: Compile a separate program for each library. 9218*a466cc55SCy Schubert for i in $deplibs; do 9219*a466cc55SCy Schubert case $i in 9220*a466cc55SCy Schubert -l*) 9221*a466cc55SCy Schubert func_stripname -l '' "$i" 9222*a466cc55SCy Schubert name=$func_stripname_result 9223*a466cc55SCy Schubert $opt_dry_run || $RM conftest 9224*a466cc55SCy Schubert if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225*a466cc55SCy Schubert ldd_output=`ldd conftest` 9226*a466cc55SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227*a466cc55SCy Schubert case " $predeps $postdeps " in 9228*a466cc55SCy Schubert *" $i "*) 9229*a466cc55SCy Schubert func_append newdeplibs " $i" 9230*a466cc55SCy Schubert i= 9231*a466cc55SCy Schubert ;; 9232*a466cc55SCy Schubert esac 9233*a466cc55SCy Schubert fi 9234*a466cc55SCy Schubert if test -n "$i"; then 9235*a466cc55SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9236*a466cc55SCy Schubert deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237*a466cc55SCy Schubert set dummy $deplib_matches; shift 9238*a466cc55SCy Schubert deplib_match=$1 9239*a466cc55SCy Schubert if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240*a466cc55SCy Schubert func_append newdeplibs " $i" 9241*a466cc55SCy Schubert else 9242*a466cc55SCy Schubert droppeddeps=yes 9243*a466cc55SCy Schubert echo 9244*a466cc55SCy Schubert $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245*a466cc55SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9246*a466cc55SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9247*a466cc55SCy Schubert echo "*** shared version of the library, which you do not appear to have" 9248*a466cc55SCy Schubert echo "*** because a test_compile did reveal that the linker did not use this one" 9249*a466cc55SCy Schubert echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250*a466cc55SCy Schubert fi 9251*a466cc55SCy Schubert fi 9252*a466cc55SCy Schubert else 9253*a466cc55SCy Schubert droppeddeps=yes 9254*a466cc55SCy Schubert echo 9255*a466cc55SCy Schubert $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256*a466cc55SCy Schubert echo "*** make it link in! You will probably need to install it or some" 9257*a466cc55SCy Schubert echo "*** library that it depends on before this library will be fully" 9258*a466cc55SCy Schubert echo "*** functional. Installing it before continuing would be even better." 9259*a466cc55SCy Schubert fi 9260*a466cc55SCy Schubert ;; 9261*a466cc55SCy Schubert *) 9262*a466cc55SCy Schubert func_append newdeplibs " $i" 9263*a466cc55SCy Schubert ;; 9264*a466cc55SCy Schubert esac 9265*a466cc55SCy Schubert done 9266*a466cc55SCy Schubert fi 9267*a466cc55SCy Schubert ;; 9268*a466cc55SCy Schubert file_magic*) 9269*a466cc55SCy Schubert set dummy $deplibs_check_method; shift 9270*a466cc55SCy Schubert file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271*a466cc55SCy Schubert for a_deplib in $deplibs; do 9272*a466cc55SCy Schubert case $a_deplib in 9273*a466cc55SCy Schubert -l*) 9274*a466cc55SCy Schubert func_stripname -l '' "$a_deplib" 9275*a466cc55SCy Schubert name=$func_stripname_result 9276*a466cc55SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277*a466cc55SCy Schubert case " $predeps $postdeps " in 9278*a466cc55SCy Schubert *" $a_deplib "*) 9279*a466cc55SCy Schubert func_append newdeplibs " $a_deplib" 9280*a466cc55SCy Schubert a_deplib= 9281*a466cc55SCy Schubert ;; 9282*a466cc55SCy Schubert esac 9283*a466cc55SCy Schubert fi 9284*a466cc55SCy Schubert if test -n "$a_deplib"; then 9285*a466cc55SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9286*a466cc55SCy Schubert if test -n "$file_magic_glob"; then 9287*a466cc55SCy Schubert libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288*a466cc55SCy Schubert else 9289*a466cc55SCy Schubert libnameglob=$libname 9290*a466cc55SCy Schubert fi 9291*a466cc55SCy Schubert test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292*a466cc55SCy Schubert for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293*a466cc55SCy Schubert if test yes = "$want_nocaseglob"; then 9294*a466cc55SCy Schubert shopt -s nocaseglob 9295*a466cc55SCy Schubert potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296*a466cc55SCy Schubert $nocaseglob 9297*a466cc55SCy Schubert else 9298*a466cc55SCy Schubert potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299*a466cc55SCy Schubert fi 9300*a466cc55SCy Schubert for potent_lib in $potential_libs; do 9301*a466cc55SCy Schubert # Follow soft links. 9302*a466cc55SCy Schubert if ls -lLd "$potent_lib" 2>/dev/null | 9303*a466cc55SCy Schubert $GREP " -> " >/dev/null; then 9304*a466cc55SCy Schubert continue 9305*a466cc55SCy Schubert fi 9306*a466cc55SCy Schubert # The statement above tries to avoid entering an 9307*a466cc55SCy Schubert # endless loop below, in case of cyclic links. 9308*a466cc55SCy Schubert # We might still enter an endless loop, since a link 9309*a466cc55SCy Schubert # loop can be closed while we follow links, 9310*a466cc55SCy Schubert # but so what? 9311*a466cc55SCy Schubert potlib=$potent_lib 9312*a466cc55SCy Schubert while test -h "$potlib" 2>/dev/null; do 9313*a466cc55SCy Schubert potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314*a466cc55SCy Schubert case $potliblink in 9315*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316*a466cc55SCy Schubert *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317*a466cc55SCy Schubert esac 9318*a466cc55SCy Schubert done 9319*a466cc55SCy Schubert if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320*a466cc55SCy Schubert $SED -e 10q | 9321*a466cc55SCy Schubert $EGREP "$file_magic_regex" > /dev/null; then 9322*a466cc55SCy Schubert func_append newdeplibs " $a_deplib" 9323*a466cc55SCy Schubert a_deplib= 9324*a466cc55SCy Schubert break 2 9325*a466cc55SCy Schubert fi 9326*a466cc55SCy Schubert done 9327*a466cc55SCy Schubert done 9328*a466cc55SCy Schubert fi 9329*a466cc55SCy Schubert if test -n "$a_deplib"; then 9330*a466cc55SCy Schubert droppeddeps=yes 9331*a466cc55SCy Schubert echo 9332*a466cc55SCy Schubert $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333*a466cc55SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9334*a466cc55SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9335*a466cc55SCy Schubert echo "*** shared version of the library, which you do not appear to have" 9336*a466cc55SCy Schubert echo "*** because I did check the linker path looking for a file starting" 9337*a466cc55SCy Schubert if test -z "$potlib"; then 9338*a466cc55SCy Schubert $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339*a466cc55SCy Schubert else 9340*a466cc55SCy Schubert $ECHO "*** with $libname and none of the candidates passed a file format test" 9341*a466cc55SCy Schubert $ECHO "*** using a file magic. Last file checked: $potlib" 9342*a466cc55SCy Schubert fi 9343*a466cc55SCy Schubert fi 9344*a466cc55SCy Schubert ;; 9345*a466cc55SCy Schubert *) 9346*a466cc55SCy Schubert # Add a -L argument. 9347*a466cc55SCy Schubert func_append newdeplibs " $a_deplib" 9348*a466cc55SCy Schubert ;; 9349*a466cc55SCy Schubert esac 9350*a466cc55SCy Schubert done # Gone through all deplibs. 9351*a466cc55SCy Schubert ;; 9352*a466cc55SCy Schubert match_pattern*) 9353*a466cc55SCy Schubert set dummy $deplibs_check_method; shift 9354*a466cc55SCy Schubert match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355*a466cc55SCy Schubert for a_deplib in $deplibs; do 9356*a466cc55SCy Schubert case $a_deplib in 9357*a466cc55SCy Schubert -l*) 9358*a466cc55SCy Schubert func_stripname -l '' "$a_deplib" 9359*a466cc55SCy Schubert name=$func_stripname_result 9360*a466cc55SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361*a466cc55SCy Schubert case " $predeps $postdeps " in 9362*a466cc55SCy Schubert *" $a_deplib "*) 9363*a466cc55SCy Schubert func_append newdeplibs " $a_deplib" 9364*a466cc55SCy Schubert a_deplib= 9365*a466cc55SCy Schubert ;; 9366*a466cc55SCy Schubert esac 9367*a466cc55SCy Schubert fi 9368*a466cc55SCy Schubert if test -n "$a_deplib"; then 9369*a466cc55SCy Schubert libname=`eval "\\$ECHO \"$libname_spec\""` 9370*a466cc55SCy Schubert for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371*a466cc55SCy Schubert potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372*a466cc55SCy Schubert for potent_lib in $potential_libs; do 9373*a466cc55SCy Schubert potlib=$potent_lib # see symlink-check above in file_magic test 9374*a466cc55SCy Schubert if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375*a466cc55SCy Schubert $EGREP "$match_pattern_regex" > /dev/null; then 9376*a466cc55SCy Schubert func_append newdeplibs " $a_deplib" 9377*a466cc55SCy Schubert a_deplib= 9378*a466cc55SCy Schubert break 2 9379*a466cc55SCy Schubert fi 9380*a466cc55SCy Schubert done 9381*a466cc55SCy Schubert done 9382*a466cc55SCy Schubert fi 9383*a466cc55SCy Schubert if test -n "$a_deplib"; then 9384*a466cc55SCy Schubert droppeddeps=yes 9385*a466cc55SCy Schubert echo 9386*a466cc55SCy Schubert $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387*a466cc55SCy Schubert echo "*** I have the capability to make that library automatically link in when" 9388*a466cc55SCy Schubert echo "*** you link to this library. But I can only do this if you have a" 9389*a466cc55SCy Schubert echo "*** shared version of the library, which you do not appear to have" 9390*a466cc55SCy Schubert echo "*** because I did check the linker path looking for a file starting" 9391*a466cc55SCy Schubert if test -z "$potlib"; then 9392*a466cc55SCy Schubert $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393*a466cc55SCy Schubert else 9394*a466cc55SCy Schubert $ECHO "*** with $libname and none of the candidates passed a file format test" 9395*a466cc55SCy Schubert $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396*a466cc55SCy Schubert fi 9397*a466cc55SCy Schubert fi 9398*a466cc55SCy Schubert ;; 9399*a466cc55SCy Schubert *) 9400*a466cc55SCy Schubert # Add a -L argument. 9401*a466cc55SCy Schubert func_append newdeplibs " $a_deplib" 9402*a466cc55SCy Schubert ;; 9403*a466cc55SCy Schubert esac 9404*a466cc55SCy Schubert done # Gone through all deplibs. 9405*a466cc55SCy Schubert ;; 9406*a466cc55SCy Schubert none | unknown | *) 9407*a466cc55SCy Schubert newdeplibs= 9408*a466cc55SCy Schubert tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409*a466cc55SCy Schubert if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410*a466cc55SCy Schubert for i in $predeps $postdeps; do 9411*a466cc55SCy Schubert # can't use Xsed below, because $i might contain '/' 9412*a466cc55SCy Schubert tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413*a466cc55SCy Schubert done 9414*a466cc55SCy Schubert fi 9415*a466cc55SCy Schubert case $tmp_deplibs in 9416*a466cc55SCy Schubert *[!\ \ ]*) 9417*a466cc55SCy Schubert echo 9418*a466cc55SCy Schubert if test none = "$deplibs_check_method"; then 9419*a466cc55SCy Schubert echo "*** Warning: inter-library dependencies are not supported in this platform." 9420*a466cc55SCy Schubert else 9421*a466cc55SCy Schubert echo "*** Warning: inter-library dependencies are not known to be supported." 9422*a466cc55SCy Schubert fi 9423*a466cc55SCy Schubert echo "*** All declared inter-library dependencies are being dropped." 9424*a466cc55SCy Schubert droppeddeps=yes 9425*a466cc55SCy Schubert ;; 9426*a466cc55SCy Schubert esac 9427*a466cc55SCy Schubert ;; 9428*a466cc55SCy Schubert esac 9429*a466cc55SCy Schubert versuffix=$versuffix_save 9430*a466cc55SCy Schubert major=$major_save 9431*a466cc55SCy Schubert release=$release_save 9432*a466cc55SCy Schubert libname=$libname_save 9433*a466cc55SCy Schubert name=$name_save 9434*a466cc55SCy Schubert 9435*a466cc55SCy Schubert case $host in 9436*a466cc55SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 9437*a466cc55SCy Schubert # On Rhapsody replace the C library with the System framework 9438*a466cc55SCy Schubert newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439*a466cc55SCy Schubert ;; 9440*a466cc55SCy Schubert esac 9441*a466cc55SCy Schubert 9442*a466cc55SCy Schubert if test yes = "$droppeddeps"; then 9443*a466cc55SCy Schubert if test yes = "$module"; then 9444*a466cc55SCy Schubert echo 9445*a466cc55SCy Schubert echo "*** Warning: libtool could not satisfy all declared inter-library" 9446*a466cc55SCy Schubert $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447*a466cc55SCy Schubert echo "*** a static module, that should work as long as the dlopening" 9448*a466cc55SCy Schubert echo "*** application is linked with the -dlopen flag." 9449*a466cc55SCy Schubert if test -z "$global_symbol_pipe"; then 9450*a466cc55SCy Schubert echo 9451*a466cc55SCy Schubert echo "*** However, this would only work if libtool was able to extract symbol" 9452*a466cc55SCy Schubert echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453*a466cc55SCy Schubert echo "*** not find such a program. So, this module is probably useless." 9454*a466cc55SCy Schubert echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455*a466cc55SCy Schubert fi 9456*a466cc55SCy Schubert if test no = "$build_old_libs"; then 9457*a466cc55SCy Schubert oldlibs=$output_objdir/$libname.$libext 9458*a466cc55SCy Schubert build_libtool_libs=module 9459*a466cc55SCy Schubert build_old_libs=yes 9460*a466cc55SCy Schubert else 9461*a466cc55SCy Schubert build_libtool_libs=no 9462*a466cc55SCy Schubert fi 9463*a466cc55SCy Schubert else 9464*a466cc55SCy Schubert echo "*** The inter-library dependencies that have been dropped here will be" 9465*a466cc55SCy Schubert echo "*** automatically added whenever a program is linked with this library" 9466*a466cc55SCy Schubert echo "*** or is declared to -dlopen it." 9467*a466cc55SCy Schubert 9468*a466cc55SCy Schubert if test no = "$allow_undefined"; then 9469*a466cc55SCy Schubert echo 9470*a466cc55SCy Schubert echo "*** Since this library must not contain undefined symbols," 9471*a466cc55SCy Schubert echo "*** because either the platform does not support them or" 9472*a466cc55SCy Schubert echo "*** it was explicitly requested with -no-undefined," 9473*a466cc55SCy Schubert echo "*** libtool will only create a static version of it." 9474*a466cc55SCy Schubert if test no = "$build_old_libs"; then 9475*a466cc55SCy Schubert oldlibs=$output_objdir/$libname.$libext 9476*a466cc55SCy Schubert build_libtool_libs=module 9477*a466cc55SCy Schubert build_old_libs=yes 9478*a466cc55SCy Schubert else 9479*a466cc55SCy Schubert build_libtool_libs=no 9480*a466cc55SCy Schubert fi 9481*a466cc55SCy Schubert fi 9482*a466cc55SCy Schubert fi 9483*a466cc55SCy Schubert fi 9484*a466cc55SCy Schubert # Done checking deplibs! 9485*a466cc55SCy Schubert deplibs=$newdeplibs 9486*a466cc55SCy Schubert fi 9487*a466cc55SCy Schubert # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488*a466cc55SCy Schubert case $host in 9489*a466cc55SCy Schubert *-*-darwin*) 9490*a466cc55SCy Schubert newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491*a466cc55SCy Schubert new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492*a466cc55SCy Schubert deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493*a466cc55SCy Schubert ;; 9494*a466cc55SCy Schubert esac 9495*a466cc55SCy Schubert 9496*a466cc55SCy Schubert # move library search paths that coincide with paths to not yet 9497*a466cc55SCy Schubert # installed libraries to the beginning of the library search list 9498*a466cc55SCy Schubert new_libs= 9499*a466cc55SCy Schubert for path in $notinst_path; do 9500*a466cc55SCy Schubert case " $new_libs " in 9501*a466cc55SCy Schubert *" -L$path/$objdir "*) ;; 9502*a466cc55SCy Schubert *) 9503*a466cc55SCy Schubert case " $deplibs " in 9504*a466cc55SCy Schubert *" -L$path/$objdir "*) 9505*a466cc55SCy Schubert func_append new_libs " -L$path/$objdir" ;; 9506*a466cc55SCy Schubert esac 9507*a466cc55SCy Schubert ;; 9508*a466cc55SCy Schubert esac 9509*a466cc55SCy Schubert done 9510*a466cc55SCy Schubert for deplib in $deplibs; do 9511*a466cc55SCy Schubert case $deplib in 9512*a466cc55SCy Schubert -L*) 9513*a466cc55SCy Schubert case " $new_libs " in 9514*a466cc55SCy Schubert *" $deplib "*) ;; 9515*a466cc55SCy Schubert *) func_append new_libs " $deplib" ;; 9516*a466cc55SCy Schubert esac 9517*a466cc55SCy Schubert ;; 9518*a466cc55SCy Schubert *) func_append new_libs " $deplib" ;; 9519*a466cc55SCy Schubert esac 9520*a466cc55SCy Schubert done 9521*a466cc55SCy Schubert deplibs=$new_libs 9522*a466cc55SCy Schubert 9523*a466cc55SCy Schubert # All the library-specific variables (install_libdir is set above). 9524*a466cc55SCy Schubert library_names= 9525*a466cc55SCy Schubert old_library= 9526*a466cc55SCy Schubert dlname= 9527*a466cc55SCy Schubert 9528*a466cc55SCy Schubert # Test again, we may have decided not to build it any more 9529*a466cc55SCy Schubert if test yes = "$build_libtool_libs"; then 9530*a466cc55SCy Schubert # Remove $wl instances when linking with ld. 9531*a466cc55SCy Schubert # FIXME: should test the right _cmds variable. 9532*a466cc55SCy Schubert case $archive_cmds in 9533*a466cc55SCy Schubert *\$LD\ *) wl= ;; 9534*a466cc55SCy Schubert esac 9535*a466cc55SCy Schubert if test yes = "$hardcode_into_libs"; then 9536*a466cc55SCy Schubert # Hardcode the library paths 9537*a466cc55SCy Schubert hardcode_libdirs= 9538*a466cc55SCy Schubert dep_rpath= 9539*a466cc55SCy Schubert rpath=$finalize_rpath 9540*a466cc55SCy Schubert test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541*a466cc55SCy Schubert for libdir in $rpath; do 9542*a466cc55SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 9543*a466cc55SCy Schubert if test -n "$hardcode_libdir_separator"; then 9544*a466cc55SCy Schubert func_replace_sysroot "$libdir" 9545*a466cc55SCy Schubert libdir=$func_replace_sysroot_result 9546*a466cc55SCy Schubert if test -z "$hardcode_libdirs"; then 9547*a466cc55SCy Schubert hardcode_libdirs=$libdir 9548*a466cc55SCy Schubert else 9549*a466cc55SCy Schubert # Just accumulate the unique libdirs. 9550*a466cc55SCy Schubert case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551*a466cc55SCy Schubert *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552*a466cc55SCy Schubert ;; 9553*a466cc55SCy Schubert *) 9554*a466cc55SCy Schubert func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555*a466cc55SCy Schubert ;; 9556*a466cc55SCy Schubert esac 9557*a466cc55SCy Schubert fi 9558*a466cc55SCy Schubert else 9559*a466cc55SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 9560*a466cc55SCy Schubert func_append dep_rpath " $flag" 9561*a466cc55SCy Schubert fi 9562*a466cc55SCy Schubert elif test -n "$runpath_var"; then 9563*a466cc55SCy Schubert case "$perm_rpath " in 9564*a466cc55SCy Schubert *" $libdir "*) ;; 9565*a466cc55SCy Schubert *) func_append perm_rpath " $libdir" ;; 9566*a466cc55SCy Schubert esac 9567*a466cc55SCy Schubert fi 9568*a466cc55SCy Schubert done 9569*a466cc55SCy Schubert # Substitute the hardcoded libdirs into the rpath. 9570*a466cc55SCy Schubert if test -n "$hardcode_libdir_separator" && 9571*a466cc55SCy Schubert test -n "$hardcode_libdirs"; then 9572*a466cc55SCy Schubert libdir=$hardcode_libdirs 9573*a466cc55SCy Schubert eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574*a466cc55SCy Schubert fi 9575*a466cc55SCy Schubert if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576*a466cc55SCy Schubert # We should set the runpath_var. 9577*a466cc55SCy Schubert rpath= 9578*a466cc55SCy Schubert for dir in $perm_rpath; do 9579*a466cc55SCy Schubert func_append rpath "$dir:" 9580*a466cc55SCy Schubert done 9581*a466cc55SCy Schubert eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582*a466cc55SCy Schubert fi 9583*a466cc55SCy Schubert test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584*a466cc55SCy Schubert fi 9585*a466cc55SCy Schubert 9586*a466cc55SCy Schubert shlibpath=$finalize_shlibpath 9587*a466cc55SCy Schubert test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588*a466cc55SCy Schubert if test -n "$shlibpath"; then 9589*a466cc55SCy Schubert eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590*a466cc55SCy Schubert fi 9591*a466cc55SCy Schubert 9592*a466cc55SCy Schubert # Get the real and link names of the library. 9593*a466cc55SCy Schubert eval shared_ext=\"$shrext_cmds\" 9594*a466cc55SCy Schubert eval library_names=\"$library_names_spec\" 9595*a466cc55SCy Schubert set dummy $library_names 9596*a466cc55SCy Schubert shift 9597*a466cc55SCy Schubert realname=$1 9598*a466cc55SCy Schubert shift 9599*a466cc55SCy Schubert 9600*a466cc55SCy Schubert if test -n "$soname_spec"; then 9601*a466cc55SCy Schubert eval soname=\"$soname_spec\" 9602*a466cc55SCy Schubert else 9603*a466cc55SCy Schubert soname=$realname 9604*a466cc55SCy Schubert fi 9605*a466cc55SCy Schubert if test -z "$dlname"; then 9606*a466cc55SCy Schubert dlname=$soname 9607*a466cc55SCy Schubert fi 9608*a466cc55SCy Schubert 9609*a466cc55SCy Schubert lib=$output_objdir/$realname 9610*a466cc55SCy Schubert linknames= 9611*a466cc55SCy Schubert for link 9612*a466cc55SCy Schubert do 9613*a466cc55SCy Schubert func_append linknames " $link" 9614*a466cc55SCy Schubert done 9615*a466cc55SCy Schubert 9616*a466cc55SCy Schubert # Use standard objects if they are pic 9617*a466cc55SCy Schubert test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618*a466cc55SCy Schubert test "X$libobjs" = "X " && libobjs= 9619*a466cc55SCy Schubert 9620*a466cc55SCy Schubert delfiles= 9621*a466cc55SCy Schubert if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622*a466cc55SCy Schubert $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623*a466cc55SCy Schubert export_symbols=$output_objdir/$libname.uexp 9624*a466cc55SCy Schubert func_append delfiles " $export_symbols" 9625*a466cc55SCy Schubert fi 9626*a466cc55SCy Schubert 9627*a466cc55SCy Schubert orig_export_symbols= 9628*a466cc55SCy Schubert case $host_os in 9629*a466cc55SCy Schubert cygwin* | mingw* | cegcc*) 9630*a466cc55SCy Schubert if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631*a466cc55SCy Schubert # exporting using user supplied symfile 9632*a466cc55SCy Schubert func_dll_def_p "$export_symbols" || { 9633*a466cc55SCy Schubert # and it's NOT already a .def file. Must figure out 9634*a466cc55SCy Schubert # which of the given symbols are data symbols and tag 9635*a466cc55SCy Schubert # them as such. So, trigger use of export_symbols_cmds. 9636*a466cc55SCy Schubert # export_symbols gets reassigned inside the "prepare 9637*a466cc55SCy Schubert # the list of exported symbols" if statement, so the 9638*a466cc55SCy Schubert # include_expsyms logic still works. 9639*a466cc55SCy Schubert orig_export_symbols=$export_symbols 9640*a466cc55SCy Schubert export_symbols= 9641*a466cc55SCy Schubert always_export_symbols=yes 9642*a466cc55SCy Schubert } 9643*a466cc55SCy Schubert fi 9644*a466cc55SCy Schubert ;; 9645*a466cc55SCy Schubert esac 9646*a466cc55SCy Schubert 9647*a466cc55SCy Schubert # Prepare the list of exported symbols 9648*a466cc55SCy Schubert if test -z "$export_symbols"; then 9649*a466cc55SCy Schubert if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650*a466cc55SCy Schubert func_verbose "generating symbol list for '$libname.la'" 9651*a466cc55SCy Schubert export_symbols=$output_objdir/$libname.exp 9652*a466cc55SCy Schubert $opt_dry_run || $RM $export_symbols 9653*a466cc55SCy Schubert cmds=$export_symbols_cmds 9654*a466cc55SCy Schubert save_ifs=$IFS; IFS='~' 9655*a466cc55SCy Schubert for cmd1 in $cmds; do 9656*a466cc55SCy Schubert IFS=$save_ifs 9657*a466cc55SCy Schubert # Take the normal branch if the nm_file_list_spec branch 9658*a466cc55SCy Schubert # doesn't work or if tool conversion is not needed. 9659*a466cc55SCy Schubert case $nm_file_list_spec~$to_tool_file_cmd in 9660*a466cc55SCy Schubert *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661*a466cc55SCy Schubert try_normal_branch=yes 9662*a466cc55SCy Schubert eval cmd=\"$cmd1\" 9663*a466cc55SCy Schubert func_len " $cmd" 9664*a466cc55SCy Schubert len=$func_len_result 9665*a466cc55SCy Schubert ;; 9666*a466cc55SCy Schubert *) 9667*a466cc55SCy Schubert try_normal_branch=no 9668*a466cc55SCy Schubert ;; 9669*a466cc55SCy Schubert esac 9670*a466cc55SCy Schubert if test yes = "$try_normal_branch" \ 9671*a466cc55SCy Schubert && { test "$len" -lt "$max_cmd_len" \ 9672*a466cc55SCy Schubert || test "$max_cmd_len" -le -1; } 9673*a466cc55SCy Schubert then 9674*a466cc55SCy Schubert func_show_eval "$cmd" 'exit $?' 9675*a466cc55SCy Schubert skipped_export=false 9676*a466cc55SCy Schubert elif test -n "$nm_file_list_spec"; then 9677*a466cc55SCy Schubert func_basename "$output" 9678*a466cc55SCy Schubert output_la=$func_basename_result 9679*a466cc55SCy Schubert save_libobjs=$libobjs 9680*a466cc55SCy Schubert save_output=$output 9681*a466cc55SCy Schubert output=$output_objdir/$output_la.nm 9682*a466cc55SCy Schubert func_to_tool_file "$output" 9683*a466cc55SCy Schubert libobjs=$nm_file_list_spec$func_to_tool_file_result 9684*a466cc55SCy Schubert func_append delfiles " $output" 9685*a466cc55SCy Schubert func_verbose "creating $NM input file list: $output" 9686*a466cc55SCy Schubert for obj in $save_libobjs; do 9687*a466cc55SCy Schubert func_to_tool_file "$obj" 9688*a466cc55SCy Schubert $ECHO "$func_to_tool_file_result" 9689*a466cc55SCy Schubert done > "$output" 9690*a466cc55SCy Schubert eval cmd=\"$cmd1\" 9691*a466cc55SCy Schubert func_show_eval "$cmd" 'exit $?' 9692*a466cc55SCy Schubert output=$save_output 9693*a466cc55SCy Schubert libobjs=$save_libobjs 9694*a466cc55SCy Schubert skipped_export=false 9695*a466cc55SCy Schubert else 9696*a466cc55SCy Schubert # The command line is too long to execute in one step. 9697*a466cc55SCy Schubert func_verbose "using reloadable object file for export list..." 9698*a466cc55SCy Schubert skipped_export=: 9699*a466cc55SCy Schubert # Break out early, otherwise skipped_export may be 9700*a466cc55SCy Schubert # set to false by a later but shorter cmd. 9701*a466cc55SCy Schubert break 9702*a466cc55SCy Schubert fi 9703*a466cc55SCy Schubert done 9704*a466cc55SCy Schubert IFS=$save_ifs 9705*a466cc55SCy Schubert if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706*a466cc55SCy Schubert func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707*a466cc55SCy Schubert func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708*a466cc55SCy Schubert fi 9709*a466cc55SCy Schubert fi 9710*a466cc55SCy Schubert fi 9711*a466cc55SCy Schubert 9712*a466cc55SCy Schubert if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713*a466cc55SCy Schubert tmp_export_symbols=$export_symbols 9714*a466cc55SCy Schubert test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715*a466cc55SCy Schubert $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716*a466cc55SCy Schubert fi 9717*a466cc55SCy Schubert 9718*a466cc55SCy Schubert if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719*a466cc55SCy Schubert # The given exports_symbols file has to be filtered, so filter it. 9720*a466cc55SCy Schubert func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721*a466cc55SCy Schubert # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722*a466cc55SCy Schubert # 's' commands, which not all seds can handle. GNU sed should be fine 9723*a466cc55SCy Schubert # though. Also, the filter scales superlinearly with the number of 9724*a466cc55SCy Schubert # global variables. join(1) would be nice here, but unfortunately 9725*a466cc55SCy Schubert # isn't a blessed tool. 9726*a466cc55SCy Schubert $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727*a466cc55SCy Schubert func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728*a466cc55SCy Schubert export_symbols=$output_objdir/$libname.def 9729*a466cc55SCy Schubert $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730*a466cc55SCy Schubert fi 9731*a466cc55SCy Schubert 9732*a466cc55SCy Schubert tmp_deplibs= 9733*a466cc55SCy Schubert for test_deplib in $deplibs; do 9734*a466cc55SCy Schubert case " $convenience " in 9735*a466cc55SCy Schubert *" $test_deplib "*) ;; 9736*a466cc55SCy Schubert *) 9737*a466cc55SCy Schubert func_append tmp_deplibs " $test_deplib" 9738*a466cc55SCy Schubert ;; 9739*a466cc55SCy Schubert esac 9740*a466cc55SCy Schubert done 9741*a466cc55SCy Schubert deplibs=$tmp_deplibs 9742*a466cc55SCy Schubert 9743*a466cc55SCy Schubert if test -n "$convenience"; then 9744*a466cc55SCy Schubert if test -n "$whole_archive_flag_spec" && 9745*a466cc55SCy Schubert test yes = "$compiler_needs_object" && 9746*a466cc55SCy Schubert test -z "$libobjs"; then 9747*a466cc55SCy Schubert # extract the archives, so we have objects to list. 9748*a466cc55SCy Schubert # TODO: could optimize this to just extract one archive. 9749*a466cc55SCy Schubert whole_archive_flag_spec= 9750*a466cc55SCy Schubert fi 9751*a466cc55SCy Schubert if test -n "$whole_archive_flag_spec"; then 9752*a466cc55SCy Schubert save_libobjs=$libobjs 9753*a466cc55SCy Schubert eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754*a466cc55SCy Schubert test "X$libobjs" = "X " && libobjs= 9755*a466cc55SCy Schubert else 9756*a466cc55SCy Schubert gentop=$output_objdir/${outputname}x 9757*a466cc55SCy Schubert func_append generated " $gentop" 9758*a466cc55SCy Schubert 9759*a466cc55SCy Schubert func_extract_archives $gentop $convenience 9760*a466cc55SCy Schubert func_append libobjs " $func_extract_archives_result" 9761*a466cc55SCy Schubert test "X$libobjs" = "X " && libobjs= 9762*a466cc55SCy Schubert fi 9763*a466cc55SCy Schubert fi 9764*a466cc55SCy Schubert 9765*a466cc55SCy Schubert if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766*a466cc55SCy Schubert eval flag=\"$thread_safe_flag_spec\" 9767*a466cc55SCy Schubert func_append linker_flags " $flag" 9768*a466cc55SCy Schubert fi 9769*a466cc55SCy Schubert 9770*a466cc55SCy Schubert # Make a backup of the uninstalled library when relinking 9771*a466cc55SCy Schubert if test relink = "$opt_mode"; then 9772*a466cc55SCy Schubert $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773*a466cc55SCy Schubert fi 9774*a466cc55SCy Schubert 9775*a466cc55SCy Schubert # Do each of the archive commands. 9776*a466cc55SCy Schubert if test yes = "$module" && test -n "$module_cmds"; then 9777*a466cc55SCy Schubert if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778*a466cc55SCy Schubert eval test_cmds=\"$module_expsym_cmds\" 9779*a466cc55SCy Schubert cmds=$module_expsym_cmds 9780*a466cc55SCy Schubert else 9781*a466cc55SCy Schubert eval test_cmds=\"$module_cmds\" 9782*a466cc55SCy Schubert cmds=$module_cmds 9783*a466cc55SCy Schubert fi 9784*a466cc55SCy Schubert else 9785*a466cc55SCy Schubert if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786*a466cc55SCy Schubert eval test_cmds=\"$archive_expsym_cmds\" 9787*a466cc55SCy Schubert cmds=$archive_expsym_cmds 9788*a466cc55SCy Schubert else 9789*a466cc55SCy Schubert eval test_cmds=\"$archive_cmds\" 9790*a466cc55SCy Schubert cmds=$archive_cmds 9791*a466cc55SCy Schubert fi 9792*a466cc55SCy Schubert fi 9793*a466cc55SCy Schubert 9794*a466cc55SCy Schubert if test : != "$skipped_export" && 9795*a466cc55SCy Schubert func_len " $test_cmds" && 9796*a466cc55SCy Schubert len=$func_len_result && 9797*a466cc55SCy Schubert test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798*a466cc55SCy Schubert : 9799*a466cc55SCy Schubert else 9800*a466cc55SCy Schubert # The command line is too long to link in one step, link piecewise 9801*a466cc55SCy Schubert # or, if using GNU ld and skipped_export is not :, use a linker 9802*a466cc55SCy Schubert # script. 9803*a466cc55SCy Schubert 9804*a466cc55SCy Schubert # Save the value of $output and $libobjs because we want to 9805*a466cc55SCy Schubert # use them later. If we have whole_archive_flag_spec, we 9806*a466cc55SCy Schubert # want to use save_libobjs as it was before 9807*a466cc55SCy Schubert # whole_archive_flag_spec was expanded, because we can't 9808*a466cc55SCy Schubert # assume the linker understands whole_archive_flag_spec. 9809*a466cc55SCy Schubert # This may have to be revisited, in case too many 9810*a466cc55SCy Schubert # convenience libraries get linked in and end up exceeding 9811*a466cc55SCy Schubert # the spec. 9812*a466cc55SCy Schubert if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813*a466cc55SCy Schubert save_libobjs=$libobjs 9814*a466cc55SCy Schubert fi 9815*a466cc55SCy Schubert save_output=$output 9816*a466cc55SCy Schubert func_basename "$output" 9817*a466cc55SCy Schubert output_la=$func_basename_result 9818*a466cc55SCy Schubert 9819*a466cc55SCy Schubert # Clear the reloadable object creation command queue and 9820*a466cc55SCy Schubert # initialize k to one. 9821*a466cc55SCy Schubert test_cmds= 9822*a466cc55SCy Schubert concat_cmds= 9823*a466cc55SCy Schubert objlist= 9824*a466cc55SCy Schubert last_robj= 9825*a466cc55SCy Schubert k=1 9826*a466cc55SCy Schubert 9827*a466cc55SCy Schubert if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828*a466cc55SCy Schubert output=$output_objdir/$output_la.lnkscript 9829*a466cc55SCy Schubert func_verbose "creating GNU ld script: $output" 9830*a466cc55SCy Schubert echo 'INPUT (' > $output 9831*a466cc55SCy Schubert for obj in $save_libobjs 9832*a466cc55SCy Schubert do 9833*a466cc55SCy Schubert func_to_tool_file "$obj" 9834*a466cc55SCy Schubert $ECHO "$func_to_tool_file_result" >> $output 9835*a466cc55SCy Schubert done 9836*a466cc55SCy Schubert echo ')' >> $output 9837*a466cc55SCy Schubert func_append delfiles " $output" 9838*a466cc55SCy Schubert func_to_tool_file "$output" 9839*a466cc55SCy Schubert output=$func_to_tool_file_result 9840*a466cc55SCy Schubert elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841*a466cc55SCy Schubert output=$output_objdir/$output_la.lnk 9842*a466cc55SCy Schubert func_verbose "creating linker input file list: $output" 9843*a466cc55SCy Schubert : > $output 9844*a466cc55SCy Schubert set x $save_libobjs 9845*a466cc55SCy Schubert shift 9846*a466cc55SCy Schubert firstobj= 9847*a466cc55SCy Schubert if test yes = "$compiler_needs_object"; then 9848*a466cc55SCy Schubert firstobj="$1 " 9849*a466cc55SCy Schubert shift 9850*a466cc55SCy Schubert fi 9851*a466cc55SCy Schubert for obj 9852*a466cc55SCy Schubert do 9853*a466cc55SCy Schubert func_to_tool_file "$obj" 9854*a466cc55SCy Schubert $ECHO "$func_to_tool_file_result" >> $output 9855*a466cc55SCy Schubert done 9856*a466cc55SCy Schubert func_append delfiles " $output" 9857*a466cc55SCy Schubert func_to_tool_file "$output" 9858*a466cc55SCy Schubert output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859*a466cc55SCy Schubert else 9860*a466cc55SCy Schubert if test -n "$save_libobjs"; then 9861*a466cc55SCy Schubert func_verbose "creating reloadable object files..." 9862*a466cc55SCy Schubert output=$output_objdir/$output_la-$k.$objext 9863*a466cc55SCy Schubert eval test_cmds=\"$reload_cmds\" 9864*a466cc55SCy Schubert func_len " $test_cmds" 9865*a466cc55SCy Schubert len0=$func_len_result 9866*a466cc55SCy Schubert len=$len0 9867*a466cc55SCy Schubert 9868*a466cc55SCy Schubert # Loop over the list of objects to be linked. 9869*a466cc55SCy Schubert for obj in $save_libobjs 9870*a466cc55SCy Schubert do 9871*a466cc55SCy Schubert func_len " $obj" 9872*a466cc55SCy Schubert func_arith $len + $func_len_result 9873*a466cc55SCy Schubert len=$func_arith_result 9874*a466cc55SCy Schubert if test -z "$objlist" || 9875*a466cc55SCy Schubert test "$len" -lt "$max_cmd_len"; then 9876*a466cc55SCy Schubert func_append objlist " $obj" 9877*a466cc55SCy Schubert else 9878*a466cc55SCy Schubert # The command $test_cmds is almost too long, add a 9879*a466cc55SCy Schubert # command to the queue. 9880*a466cc55SCy Schubert if test 1 -eq "$k"; then 9881*a466cc55SCy Schubert # The first file doesn't have a previous command to add. 9882*a466cc55SCy Schubert reload_objs=$objlist 9883*a466cc55SCy Schubert eval concat_cmds=\"$reload_cmds\" 9884*a466cc55SCy Schubert else 9885*a466cc55SCy Schubert # All subsequent reloadable object files will link in 9886*a466cc55SCy Schubert # the last one created. 9887*a466cc55SCy Schubert reload_objs="$objlist $last_robj" 9888*a466cc55SCy Schubert eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889*a466cc55SCy Schubert fi 9890*a466cc55SCy Schubert last_robj=$output_objdir/$output_la-$k.$objext 9891*a466cc55SCy Schubert func_arith $k + 1 9892*a466cc55SCy Schubert k=$func_arith_result 9893*a466cc55SCy Schubert output=$output_objdir/$output_la-$k.$objext 9894*a466cc55SCy Schubert objlist=" $obj" 9895*a466cc55SCy Schubert func_len " $last_robj" 9896*a466cc55SCy Schubert func_arith $len0 + $func_len_result 9897*a466cc55SCy Schubert len=$func_arith_result 9898*a466cc55SCy Schubert fi 9899*a466cc55SCy Schubert done 9900*a466cc55SCy Schubert # Handle the remaining objects by creating one last 9901*a466cc55SCy Schubert # reloadable object file. All subsequent reloadable object 9902*a466cc55SCy Schubert # files will link in the last one created. 9903*a466cc55SCy Schubert test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904*a466cc55SCy Schubert reload_objs="$objlist $last_robj" 9905*a466cc55SCy Schubert eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906*a466cc55SCy Schubert if test -n "$last_robj"; then 9907*a466cc55SCy Schubert eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908*a466cc55SCy Schubert fi 9909*a466cc55SCy Schubert func_append delfiles " $output" 9910*a466cc55SCy Schubert 9911*a466cc55SCy Schubert else 9912*a466cc55SCy Schubert output= 9913*a466cc55SCy Schubert fi 9914*a466cc55SCy Schubert 9915*a466cc55SCy Schubert ${skipped_export-false} && { 9916*a466cc55SCy Schubert func_verbose "generating symbol list for '$libname.la'" 9917*a466cc55SCy Schubert export_symbols=$output_objdir/$libname.exp 9918*a466cc55SCy Schubert $opt_dry_run || $RM $export_symbols 9919*a466cc55SCy Schubert libobjs=$output 9920*a466cc55SCy Schubert # Append the command to create the export file. 9921*a466cc55SCy Schubert test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922*a466cc55SCy Schubert eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923*a466cc55SCy Schubert if test -n "$last_robj"; then 9924*a466cc55SCy Schubert eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925*a466cc55SCy Schubert fi 9926*a466cc55SCy Schubert } 9927*a466cc55SCy Schubert 9928*a466cc55SCy Schubert test -n "$save_libobjs" && 9929*a466cc55SCy Schubert func_verbose "creating a temporary reloadable object file: $output" 9930*a466cc55SCy Schubert 9931*a466cc55SCy Schubert # Loop through the commands generated above and execute them. 9932*a466cc55SCy Schubert save_ifs=$IFS; IFS='~' 9933*a466cc55SCy Schubert for cmd in $concat_cmds; do 9934*a466cc55SCy Schubert IFS=$save_ifs 9935*a466cc55SCy Schubert $opt_quiet || { 9936*a466cc55SCy Schubert func_quote_for_expand "$cmd" 9937*a466cc55SCy Schubert eval "func_echo $func_quote_for_expand_result" 9938*a466cc55SCy Schubert } 9939*a466cc55SCy Schubert $opt_dry_run || eval "$cmd" || { 9940*a466cc55SCy Schubert lt_exit=$? 9941*a466cc55SCy Schubert 9942*a466cc55SCy Schubert # Restore the uninstalled library and exit 9943*a466cc55SCy Schubert if test relink = "$opt_mode"; then 9944*a466cc55SCy Schubert ( cd "$output_objdir" && \ 9945*a466cc55SCy Schubert $RM "${realname}T" && \ 9946*a466cc55SCy Schubert $MV "${realname}U" "$realname" ) 9947*a466cc55SCy Schubert fi 9948*a466cc55SCy Schubert 9949*a466cc55SCy Schubert exit $lt_exit 9950*a466cc55SCy Schubert } 9951*a466cc55SCy Schubert done 9952*a466cc55SCy Schubert IFS=$save_ifs 9953*a466cc55SCy Schubert 9954*a466cc55SCy Schubert if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955*a466cc55SCy Schubert func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956*a466cc55SCy Schubert func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957*a466cc55SCy Schubert fi 9958*a466cc55SCy Schubert fi 9959*a466cc55SCy Schubert 9960*a466cc55SCy Schubert ${skipped_export-false} && { 9961*a466cc55SCy Schubert if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962*a466cc55SCy Schubert tmp_export_symbols=$export_symbols 9963*a466cc55SCy Schubert test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964*a466cc55SCy Schubert $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965*a466cc55SCy Schubert fi 9966*a466cc55SCy Schubert 9967*a466cc55SCy Schubert if test -n "$orig_export_symbols"; then 9968*a466cc55SCy Schubert # The given exports_symbols file has to be filtered, so filter it. 9969*a466cc55SCy Schubert func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970*a466cc55SCy Schubert # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971*a466cc55SCy Schubert # 's' commands, which not all seds can handle. GNU sed should be fine 9972*a466cc55SCy Schubert # though. Also, the filter scales superlinearly with the number of 9973*a466cc55SCy Schubert # global variables. join(1) would be nice here, but unfortunately 9974*a466cc55SCy Schubert # isn't a blessed tool. 9975*a466cc55SCy Schubert $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976*a466cc55SCy Schubert func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977*a466cc55SCy Schubert export_symbols=$output_objdir/$libname.def 9978*a466cc55SCy Schubert $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979*a466cc55SCy Schubert fi 9980*a466cc55SCy Schubert } 9981*a466cc55SCy Schubert 9982*a466cc55SCy Schubert libobjs=$output 9983*a466cc55SCy Schubert # Restore the value of output. 9984*a466cc55SCy Schubert output=$save_output 9985*a466cc55SCy Schubert 9986*a466cc55SCy Schubert if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987*a466cc55SCy Schubert eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988*a466cc55SCy Schubert test "X$libobjs" = "X " && libobjs= 9989*a466cc55SCy Schubert fi 9990*a466cc55SCy Schubert # Expand the library linking commands again to reset the 9991*a466cc55SCy Schubert # value of $libobjs for piecewise linking. 9992*a466cc55SCy Schubert 9993*a466cc55SCy Schubert # Do each of the archive commands. 9994*a466cc55SCy Schubert if test yes = "$module" && test -n "$module_cmds"; then 9995*a466cc55SCy Schubert if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996*a466cc55SCy Schubert cmds=$module_expsym_cmds 9997*a466cc55SCy Schubert else 9998*a466cc55SCy Schubert cmds=$module_cmds 9999*a466cc55SCy Schubert fi 10000*a466cc55SCy Schubert else 10001*a466cc55SCy Schubert if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002*a466cc55SCy Schubert cmds=$archive_expsym_cmds 10003*a466cc55SCy Schubert else 10004*a466cc55SCy Schubert cmds=$archive_cmds 10005*a466cc55SCy Schubert fi 10006*a466cc55SCy Schubert fi 10007*a466cc55SCy Schubert fi 10008*a466cc55SCy Schubert 10009*a466cc55SCy Schubert if test -n "$delfiles"; then 10010*a466cc55SCy Schubert # Append the command to remove temporary files to $cmds. 10011*a466cc55SCy Schubert eval cmds=\"\$cmds~\$RM $delfiles\" 10012*a466cc55SCy Schubert fi 10013*a466cc55SCy Schubert 10014*a466cc55SCy Schubert # Add any objects from preloaded convenience libraries 10015*a466cc55SCy Schubert if test -n "$dlprefiles"; then 10016*a466cc55SCy Schubert gentop=$output_objdir/${outputname}x 10017*a466cc55SCy Schubert func_append generated " $gentop" 10018*a466cc55SCy Schubert 10019*a466cc55SCy Schubert func_extract_archives $gentop $dlprefiles 10020*a466cc55SCy Schubert func_append libobjs " $func_extract_archives_result" 10021*a466cc55SCy Schubert test "X$libobjs" = "X " && libobjs= 10022*a466cc55SCy Schubert fi 10023*a466cc55SCy Schubert 10024*a466cc55SCy Schubert save_ifs=$IFS; IFS='~' 10025*a466cc55SCy Schubert for cmd in $cmds; do 10026*a466cc55SCy Schubert IFS=$sp$nl 10027*a466cc55SCy Schubert eval cmd=\"$cmd\" 10028*a466cc55SCy Schubert IFS=$save_ifs 10029*a466cc55SCy Schubert $opt_quiet || { 10030*a466cc55SCy Schubert func_quote_for_expand "$cmd" 10031*a466cc55SCy Schubert eval "func_echo $func_quote_for_expand_result" 10032*a466cc55SCy Schubert } 10033*a466cc55SCy Schubert $opt_dry_run || eval "$cmd" || { 10034*a466cc55SCy Schubert lt_exit=$? 10035*a466cc55SCy Schubert 10036*a466cc55SCy Schubert # Restore the uninstalled library and exit 10037*a466cc55SCy Schubert if test relink = "$opt_mode"; then 10038*a466cc55SCy Schubert ( cd "$output_objdir" && \ 10039*a466cc55SCy Schubert $RM "${realname}T" && \ 10040*a466cc55SCy Schubert $MV "${realname}U" "$realname" ) 10041*a466cc55SCy Schubert fi 10042*a466cc55SCy Schubert 10043*a466cc55SCy Schubert exit $lt_exit 10044*a466cc55SCy Schubert } 10045*a466cc55SCy Schubert done 10046*a466cc55SCy Schubert IFS=$save_ifs 10047*a466cc55SCy Schubert 10048*a466cc55SCy Schubert # Restore the uninstalled library and exit 10049*a466cc55SCy Schubert if test relink = "$opt_mode"; then 10050*a466cc55SCy Schubert $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051*a466cc55SCy Schubert 10052*a466cc55SCy Schubert if test -n "$convenience"; then 10053*a466cc55SCy Schubert if test -z "$whole_archive_flag_spec"; then 10054*a466cc55SCy Schubert func_show_eval '${RM}r "$gentop"' 10055*a466cc55SCy Schubert fi 10056*a466cc55SCy Schubert fi 10057*a466cc55SCy Schubert 10058*a466cc55SCy Schubert exit $EXIT_SUCCESS 10059*a466cc55SCy Schubert fi 10060*a466cc55SCy Schubert 10061*a466cc55SCy Schubert # Create links to the real library. 10062*a466cc55SCy Schubert for linkname in $linknames; do 10063*a466cc55SCy Schubert if test "$realname" != "$linkname"; then 10064*a466cc55SCy Schubert func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065*a466cc55SCy Schubert fi 10066*a466cc55SCy Schubert done 10067*a466cc55SCy Schubert 10068*a466cc55SCy Schubert # If -module or -export-dynamic was specified, set the dlname. 10069*a466cc55SCy Schubert if test yes = "$module" || test yes = "$export_dynamic"; then 10070*a466cc55SCy Schubert # On all known operating systems, these are identical. 10071*a466cc55SCy Schubert dlname=$soname 10072*a466cc55SCy Schubert fi 10073*a466cc55SCy Schubert fi 10074*a466cc55SCy Schubert ;; 10075*a466cc55SCy Schubert 10076*a466cc55SCy Schubert obj) 10077*a466cc55SCy Schubert if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078*a466cc55SCy Schubert func_warning "'-dlopen' is ignored for objects" 10079*a466cc55SCy Schubert fi 10080*a466cc55SCy Schubert 10081*a466cc55SCy Schubert case " $deplibs" in 10082*a466cc55SCy Schubert *\ -l* | *\ -L*) 10083*a466cc55SCy Schubert func_warning "'-l' and '-L' are ignored for objects" ;; 10084*a466cc55SCy Schubert esac 10085*a466cc55SCy Schubert 10086*a466cc55SCy Schubert test -n "$rpath" && \ 10087*a466cc55SCy Schubert func_warning "'-rpath' is ignored for objects" 10088*a466cc55SCy Schubert 10089*a466cc55SCy Schubert test -n "$xrpath" && \ 10090*a466cc55SCy Schubert func_warning "'-R' is ignored for objects" 10091*a466cc55SCy Schubert 10092*a466cc55SCy Schubert test -n "$vinfo" && \ 10093*a466cc55SCy Schubert func_warning "'-version-info' is ignored for objects" 10094*a466cc55SCy Schubert 10095*a466cc55SCy Schubert test -n "$release" && \ 10096*a466cc55SCy Schubert func_warning "'-release' is ignored for objects" 10097*a466cc55SCy Schubert 10098*a466cc55SCy Schubert case $output in 10099*a466cc55SCy Schubert *.lo) 10100*a466cc55SCy Schubert test -n "$objs$old_deplibs" && \ 10101*a466cc55SCy Schubert func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102*a466cc55SCy Schubert 10103*a466cc55SCy Schubert libobj=$output 10104*a466cc55SCy Schubert func_lo2o "$libobj" 10105*a466cc55SCy Schubert obj=$func_lo2o_result 10106*a466cc55SCy Schubert ;; 10107*a466cc55SCy Schubert *) 10108*a466cc55SCy Schubert libobj= 10109*a466cc55SCy Schubert obj=$output 10110*a466cc55SCy Schubert ;; 10111*a466cc55SCy Schubert esac 10112*a466cc55SCy Schubert 10113*a466cc55SCy Schubert # Delete the old objects. 10114*a466cc55SCy Schubert $opt_dry_run || $RM $obj $libobj 10115*a466cc55SCy Schubert 10116*a466cc55SCy Schubert # Objects from convenience libraries. This assumes 10117*a466cc55SCy Schubert # single-version convenience libraries. Whenever we create 10118*a466cc55SCy Schubert # different ones for PIC/non-PIC, this we'll have to duplicate 10119*a466cc55SCy Schubert # the extraction. 10120*a466cc55SCy Schubert reload_conv_objs= 10121*a466cc55SCy Schubert gentop= 10122*a466cc55SCy Schubert # if reload_cmds runs $LD directly, get rid of -Wl from 10123*a466cc55SCy Schubert # whole_archive_flag_spec and hope we can get by with turning comma 10124*a466cc55SCy Schubert # into space. 10125*a466cc55SCy Schubert case $reload_cmds in 10126*a466cc55SCy Schubert *\$LD[\ \$]*) wl= ;; 10127*a466cc55SCy Schubert esac 10128*a466cc55SCy Schubert if test -n "$convenience"; then 10129*a466cc55SCy Schubert if test -n "$whole_archive_flag_spec"; then 10130*a466cc55SCy Schubert eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131*a466cc55SCy Schubert test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132*a466cc55SCy Schubert reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133*a466cc55SCy Schubert else 10134*a466cc55SCy Schubert gentop=$output_objdir/${obj}x 10135*a466cc55SCy Schubert func_append generated " $gentop" 10136*a466cc55SCy Schubert 10137*a466cc55SCy Schubert func_extract_archives $gentop $convenience 10138*a466cc55SCy Schubert reload_conv_objs="$reload_objs $func_extract_archives_result" 10139*a466cc55SCy Schubert fi 10140*a466cc55SCy Schubert fi 10141*a466cc55SCy Schubert 10142*a466cc55SCy Schubert # If we're not building shared, we need to use non_pic_objs 10143*a466cc55SCy Schubert test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144*a466cc55SCy Schubert 10145*a466cc55SCy Schubert # Create the old-style object. 10146*a466cc55SCy Schubert reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147*a466cc55SCy Schubert 10148*a466cc55SCy Schubert output=$obj 10149*a466cc55SCy Schubert func_execute_cmds "$reload_cmds" 'exit $?' 10150*a466cc55SCy Schubert 10151*a466cc55SCy Schubert # Exit if we aren't doing a library object file. 10152*a466cc55SCy Schubert if test -z "$libobj"; then 10153*a466cc55SCy Schubert if test -n "$gentop"; then 10154*a466cc55SCy Schubert func_show_eval '${RM}r "$gentop"' 10155*a466cc55SCy Schubert fi 10156*a466cc55SCy Schubert 10157*a466cc55SCy Schubert exit $EXIT_SUCCESS 10158*a466cc55SCy Schubert fi 10159*a466cc55SCy Schubert 10160*a466cc55SCy Schubert test yes = "$build_libtool_libs" || { 10161*a466cc55SCy Schubert if test -n "$gentop"; then 10162*a466cc55SCy Schubert func_show_eval '${RM}r "$gentop"' 10163*a466cc55SCy Schubert fi 10164*a466cc55SCy Schubert 10165*a466cc55SCy Schubert # Create an invalid libtool object if no PIC, so that we don't 10166*a466cc55SCy Schubert # accidentally link it into a program. 10167*a466cc55SCy Schubert # $show "echo timestamp > $libobj" 10168*a466cc55SCy Schubert # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169*a466cc55SCy Schubert exit $EXIT_SUCCESS 10170*a466cc55SCy Schubert } 10171*a466cc55SCy Schubert 10172*a466cc55SCy Schubert if test -n "$pic_flag" || test default != "$pic_mode"; then 10173*a466cc55SCy Schubert # Only do commands if we really have different PIC objects. 10174*a466cc55SCy Schubert reload_objs="$libobjs $reload_conv_objs" 10175*a466cc55SCy Schubert output=$libobj 10176*a466cc55SCy Schubert func_execute_cmds "$reload_cmds" 'exit $?' 10177*a466cc55SCy Schubert fi 10178*a466cc55SCy Schubert 10179*a466cc55SCy Schubert if test -n "$gentop"; then 10180*a466cc55SCy Schubert func_show_eval '${RM}r "$gentop"' 10181*a466cc55SCy Schubert fi 10182*a466cc55SCy Schubert 10183*a466cc55SCy Schubert exit $EXIT_SUCCESS 10184*a466cc55SCy Schubert ;; 10185*a466cc55SCy Schubert 10186*a466cc55SCy Schubert prog) 10187*a466cc55SCy Schubert case $host in 10188*a466cc55SCy Schubert *cygwin*) func_stripname '' '.exe' "$output" 10189*a466cc55SCy Schubert output=$func_stripname_result.exe;; 10190*a466cc55SCy Schubert esac 10191*a466cc55SCy Schubert test -n "$vinfo" && \ 10192*a466cc55SCy Schubert func_warning "'-version-info' is ignored for programs" 10193*a466cc55SCy Schubert 10194*a466cc55SCy Schubert test -n "$release" && \ 10195*a466cc55SCy Schubert func_warning "'-release' is ignored for programs" 10196*a466cc55SCy Schubert 10197*a466cc55SCy Schubert $preload \ 10198*a466cc55SCy Schubert && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199*a466cc55SCy Schubert && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200*a466cc55SCy Schubert 10201*a466cc55SCy Schubert case $host in 10202*a466cc55SCy Schubert *-*-rhapsody* | *-*-darwin1.[012]) 10203*a466cc55SCy Schubert # On Rhapsody replace the C library is the System framework 10204*a466cc55SCy Schubert compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205*a466cc55SCy Schubert finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206*a466cc55SCy Schubert ;; 10207*a466cc55SCy Schubert esac 10208*a466cc55SCy Schubert 10209*a466cc55SCy Schubert case $host in 10210*a466cc55SCy Schubert *-*-darwin*) 10211*a466cc55SCy Schubert # Don't allow lazy linking, it breaks C++ global constructors 10212*a466cc55SCy Schubert # But is supposedly fixed on 10.4 or later (yay!). 10213*a466cc55SCy Schubert if test CXX = "$tagname"; then 10214*a466cc55SCy Schubert case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215*a466cc55SCy Schubert 10.[0123]) 10216*a466cc55SCy Schubert func_append compile_command " $wl-bind_at_load" 10217*a466cc55SCy Schubert func_append finalize_command " $wl-bind_at_load" 10218*a466cc55SCy Schubert ;; 10219*a466cc55SCy Schubert esac 10220*a466cc55SCy Schubert fi 10221*a466cc55SCy Schubert # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222*a466cc55SCy Schubert compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223*a466cc55SCy Schubert finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224*a466cc55SCy Schubert ;; 10225*a466cc55SCy Schubert esac 10226*a466cc55SCy Schubert 10227*a466cc55SCy Schubert 10228*a466cc55SCy Schubert # move library search paths that coincide with paths to not yet 10229*a466cc55SCy Schubert # installed libraries to the beginning of the library search list 10230*a466cc55SCy Schubert new_libs= 10231*a466cc55SCy Schubert for path in $notinst_path; do 10232*a466cc55SCy Schubert case " $new_libs " in 10233*a466cc55SCy Schubert *" -L$path/$objdir "*) ;; 10234*a466cc55SCy Schubert *) 10235*a466cc55SCy Schubert case " $compile_deplibs " in 10236*a466cc55SCy Schubert *" -L$path/$objdir "*) 10237*a466cc55SCy Schubert func_append new_libs " -L$path/$objdir" ;; 10238*a466cc55SCy Schubert esac 10239*a466cc55SCy Schubert ;; 10240*a466cc55SCy Schubert esac 10241*a466cc55SCy Schubert done 10242*a466cc55SCy Schubert for deplib in $compile_deplibs; do 10243*a466cc55SCy Schubert case $deplib in 10244*a466cc55SCy Schubert -L*) 10245*a466cc55SCy Schubert case " $new_libs " in 10246*a466cc55SCy Schubert *" $deplib "*) ;; 10247*a466cc55SCy Schubert *) func_append new_libs " $deplib" ;; 10248*a466cc55SCy Schubert esac 10249*a466cc55SCy Schubert ;; 10250*a466cc55SCy Schubert *) func_append new_libs " $deplib" ;; 10251*a466cc55SCy Schubert esac 10252*a466cc55SCy Schubert done 10253*a466cc55SCy Schubert compile_deplibs=$new_libs 10254*a466cc55SCy Schubert 10255*a466cc55SCy Schubert 10256*a466cc55SCy Schubert func_append compile_command " $compile_deplibs" 10257*a466cc55SCy Schubert func_append finalize_command " $finalize_deplibs" 10258*a466cc55SCy Schubert 10259*a466cc55SCy Schubert if test -n "$rpath$xrpath"; then 10260*a466cc55SCy Schubert # If the user specified any rpath flags, then add them. 10261*a466cc55SCy Schubert for libdir in $rpath $xrpath; do 10262*a466cc55SCy Schubert # This is the magic to use -rpath. 10263*a466cc55SCy Schubert case "$finalize_rpath " in 10264*a466cc55SCy Schubert *" $libdir "*) ;; 10265*a466cc55SCy Schubert *) func_append finalize_rpath " $libdir" ;; 10266*a466cc55SCy Schubert esac 10267*a466cc55SCy Schubert done 10268*a466cc55SCy Schubert fi 10269*a466cc55SCy Schubert 10270*a466cc55SCy Schubert # Now hardcode the library paths 10271*a466cc55SCy Schubert rpath= 10272*a466cc55SCy Schubert hardcode_libdirs= 10273*a466cc55SCy Schubert for libdir in $compile_rpath $finalize_rpath; do 10274*a466cc55SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 10275*a466cc55SCy Schubert if test -n "$hardcode_libdir_separator"; then 10276*a466cc55SCy Schubert if test -z "$hardcode_libdirs"; then 10277*a466cc55SCy Schubert hardcode_libdirs=$libdir 10278*a466cc55SCy Schubert else 10279*a466cc55SCy Schubert # Just accumulate the unique libdirs. 10280*a466cc55SCy Schubert case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281*a466cc55SCy Schubert *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282*a466cc55SCy Schubert ;; 10283*a466cc55SCy Schubert *) 10284*a466cc55SCy Schubert func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285*a466cc55SCy Schubert ;; 10286*a466cc55SCy Schubert esac 10287*a466cc55SCy Schubert fi 10288*a466cc55SCy Schubert else 10289*a466cc55SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 10290*a466cc55SCy Schubert func_append rpath " $flag" 10291*a466cc55SCy Schubert fi 10292*a466cc55SCy Schubert elif test -n "$runpath_var"; then 10293*a466cc55SCy Schubert case "$perm_rpath " in 10294*a466cc55SCy Schubert *" $libdir "*) ;; 10295*a466cc55SCy Schubert *) func_append perm_rpath " $libdir" ;; 10296*a466cc55SCy Schubert esac 10297*a466cc55SCy Schubert fi 10298*a466cc55SCy Schubert case $host in 10299*a466cc55SCy Schubert *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300*a466cc55SCy Schubert testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301*a466cc55SCy Schubert case :$dllsearchpath: in 10302*a466cc55SCy Schubert *":$libdir:"*) ;; 10303*a466cc55SCy Schubert ::) dllsearchpath=$libdir;; 10304*a466cc55SCy Schubert *) func_append dllsearchpath ":$libdir";; 10305*a466cc55SCy Schubert esac 10306*a466cc55SCy Schubert case :$dllsearchpath: in 10307*a466cc55SCy Schubert *":$testbindir:"*) ;; 10308*a466cc55SCy Schubert ::) dllsearchpath=$testbindir;; 10309*a466cc55SCy Schubert *) func_append dllsearchpath ":$testbindir";; 10310*a466cc55SCy Schubert esac 10311*a466cc55SCy Schubert ;; 10312*a466cc55SCy Schubert esac 10313*a466cc55SCy Schubert done 10314*a466cc55SCy Schubert # Substitute the hardcoded libdirs into the rpath. 10315*a466cc55SCy Schubert if test -n "$hardcode_libdir_separator" && 10316*a466cc55SCy Schubert test -n "$hardcode_libdirs"; then 10317*a466cc55SCy Schubert libdir=$hardcode_libdirs 10318*a466cc55SCy Schubert eval rpath=\" $hardcode_libdir_flag_spec\" 10319*a466cc55SCy Schubert fi 10320*a466cc55SCy Schubert compile_rpath=$rpath 10321*a466cc55SCy Schubert 10322*a466cc55SCy Schubert rpath= 10323*a466cc55SCy Schubert hardcode_libdirs= 10324*a466cc55SCy Schubert for libdir in $finalize_rpath; do 10325*a466cc55SCy Schubert if test -n "$hardcode_libdir_flag_spec"; then 10326*a466cc55SCy Schubert if test -n "$hardcode_libdir_separator"; then 10327*a466cc55SCy Schubert if test -z "$hardcode_libdirs"; then 10328*a466cc55SCy Schubert hardcode_libdirs=$libdir 10329*a466cc55SCy Schubert else 10330*a466cc55SCy Schubert # Just accumulate the unique libdirs. 10331*a466cc55SCy Schubert case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332*a466cc55SCy Schubert *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333*a466cc55SCy Schubert ;; 10334*a466cc55SCy Schubert *) 10335*a466cc55SCy Schubert func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336*a466cc55SCy Schubert ;; 10337*a466cc55SCy Schubert esac 10338*a466cc55SCy Schubert fi 10339*a466cc55SCy Schubert else 10340*a466cc55SCy Schubert eval flag=\"$hardcode_libdir_flag_spec\" 10341*a466cc55SCy Schubert func_append rpath " $flag" 10342*a466cc55SCy Schubert fi 10343*a466cc55SCy Schubert elif test -n "$runpath_var"; then 10344*a466cc55SCy Schubert case "$finalize_perm_rpath " in 10345*a466cc55SCy Schubert *" $libdir "*) ;; 10346*a466cc55SCy Schubert *) func_append finalize_perm_rpath " $libdir" ;; 10347*a466cc55SCy Schubert esac 10348*a466cc55SCy Schubert fi 10349*a466cc55SCy Schubert done 10350*a466cc55SCy Schubert # Substitute the hardcoded libdirs into the rpath. 10351*a466cc55SCy Schubert if test -n "$hardcode_libdir_separator" && 10352*a466cc55SCy Schubert test -n "$hardcode_libdirs"; then 10353*a466cc55SCy Schubert libdir=$hardcode_libdirs 10354*a466cc55SCy Schubert eval rpath=\" $hardcode_libdir_flag_spec\" 10355*a466cc55SCy Schubert fi 10356*a466cc55SCy Schubert finalize_rpath=$rpath 10357*a466cc55SCy Schubert 10358*a466cc55SCy Schubert if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359*a466cc55SCy Schubert # Transform all the library objects into standard objects. 10360*a466cc55SCy Schubert compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361*a466cc55SCy Schubert finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362*a466cc55SCy Schubert fi 10363*a466cc55SCy Schubert 10364*a466cc55SCy Schubert func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365*a466cc55SCy Schubert 10366*a466cc55SCy Schubert # template prelinking step 10367*a466cc55SCy Schubert if test -n "$prelink_cmds"; then 10368*a466cc55SCy Schubert func_execute_cmds "$prelink_cmds" 'exit $?' 10369*a466cc55SCy Schubert fi 10370*a466cc55SCy Schubert 10371*a466cc55SCy Schubert wrappers_required=: 10372*a466cc55SCy Schubert case $host in 10373*a466cc55SCy Schubert *cegcc* | *mingw32ce*) 10374*a466cc55SCy Schubert # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375*a466cc55SCy Schubert wrappers_required=false 10376*a466cc55SCy Schubert ;; 10377*a466cc55SCy Schubert *cygwin* | *mingw* ) 10378*a466cc55SCy Schubert test yes = "$build_libtool_libs" || wrappers_required=false 10379*a466cc55SCy Schubert ;; 10380*a466cc55SCy Schubert *) 10381*a466cc55SCy Schubert if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382*a466cc55SCy Schubert wrappers_required=false 10383*a466cc55SCy Schubert fi 10384*a466cc55SCy Schubert ;; 10385*a466cc55SCy Schubert esac 10386*a466cc55SCy Schubert $wrappers_required || { 10387*a466cc55SCy Schubert # Replace the output file specification. 10388*a466cc55SCy Schubert compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389*a466cc55SCy Schubert link_command=$compile_command$compile_rpath 10390*a466cc55SCy Schubert 10391*a466cc55SCy Schubert # We have no uninstalled library dependencies, so finalize right now. 10392*a466cc55SCy Schubert exit_status=0 10393*a466cc55SCy Schubert func_show_eval "$link_command" 'exit_status=$?' 10394*a466cc55SCy Schubert 10395*a466cc55SCy Schubert if test -n "$postlink_cmds"; then 10396*a466cc55SCy Schubert func_to_tool_file "$output" 10397*a466cc55SCy Schubert postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398*a466cc55SCy Schubert func_execute_cmds "$postlink_cmds" 'exit $?' 10399*a466cc55SCy Schubert fi 10400*a466cc55SCy Schubert 10401*a466cc55SCy Schubert # Delete the generated files. 10402*a466cc55SCy Schubert if test -f "$output_objdir/${outputname}S.$objext"; then 10403*a466cc55SCy Schubert func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404*a466cc55SCy Schubert fi 10405*a466cc55SCy Schubert 10406*a466cc55SCy Schubert exit $exit_status 10407*a466cc55SCy Schubert } 10408*a466cc55SCy Schubert 10409*a466cc55SCy Schubert if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410*a466cc55SCy Schubert compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411*a466cc55SCy Schubert fi 10412*a466cc55SCy Schubert if test -n "$finalize_shlibpath"; then 10413*a466cc55SCy Schubert finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414*a466cc55SCy Schubert fi 10415*a466cc55SCy Schubert 10416*a466cc55SCy Schubert compile_var= 10417*a466cc55SCy Schubert finalize_var= 10418*a466cc55SCy Schubert if test -n "$runpath_var"; then 10419*a466cc55SCy Schubert if test -n "$perm_rpath"; then 10420*a466cc55SCy Schubert # We should set the runpath_var. 10421*a466cc55SCy Schubert rpath= 10422*a466cc55SCy Schubert for dir in $perm_rpath; do 10423*a466cc55SCy Schubert func_append rpath "$dir:" 10424*a466cc55SCy Schubert done 10425*a466cc55SCy Schubert compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426*a466cc55SCy Schubert fi 10427*a466cc55SCy Schubert if test -n "$finalize_perm_rpath"; then 10428*a466cc55SCy Schubert # We should set the runpath_var. 10429*a466cc55SCy Schubert rpath= 10430*a466cc55SCy Schubert for dir in $finalize_perm_rpath; do 10431*a466cc55SCy Schubert func_append rpath "$dir:" 10432*a466cc55SCy Schubert done 10433*a466cc55SCy Schubert finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434*a466cc55SCy Schubert fi 10435*a466cc55SCy Schubert fi 10436*a466cc55SCy Schubert 10437*a466cc55SCy Schubert if test yes = "$no_install"; then 10438*a466cc55SCy Schubert # We don't need to create a wrapper script. 10439*a466cc55SCy Schubert link_command=$compile_var$compile_command$compile_rpath 10440*a466cc55SCy Schubert # Replace the output file specification. 10441*a466cc55SCy Schubert link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442*a466cc55SCy Schubert # Delete the old output file. 10443*a466cc55SCy Schubert $opt_dry_run || $RM $output 10444*a466cc55SCy Schubert # Link the executable and exit 10445*a466cc55SCy Schubert func_show_eval "$link_command" 'exit $?' 10446*a466cc55SCy Schubert 10447*a466cc55SCy Schubert if test -n "$postlink_cmds"; then 10448*a466cc55SCy Schubert func_to_tool_file "$output" 10449*a466cc55SCy Schubert postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450*a466cc55SCy Schubert func_execute_cmds "$postlink_cmds" 'exit $?' 10451*a466cc55SCy Schubert fi 10452*a466cc55SCy Schubert 10453*a466cc55SCy Schubert exit $EXIT_SUCCESS 10454*a466cc55SCy Schubert fi 10455*a466cc55SCy Schubert 10456*a466cc55SCy Schubert case $hardcode_action,$fast_install in 10457*a466cc55SCy Schubert relink,*) 10458*a466cc55SCy Schubert # Fast installation is not supported 10459*a466cc55SCy Schubert link_command=$compile_var$compile_command$compile_rpath 10460*a466cc55SCy Schubert relink_command=$finalize_var$finalize_command$finalize_rpath 10461*a466cc55SCy Schubert 10462*a466cc55SCy Schubert func_warning "this platform does not like uninstalled shared libraries" 10463*a466cc55SCy Schubert func_warning "'$output' will be relinked during installation" 10464*a466cc55SCy Schubert ;; 10465*a466cc55SCy Schubert *,yes) 10466*a466cc55SCy Schubert link_command=$finalize_var$compile_command$finalize_rpath 10467*a466cc55SCy Schubert relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468*a466cc55SCy Schubert ;; 10469*a466cc55SCy Schubert *,no) 10470*a466cc55SCy Schubert link_command=$compile_var$compile_command$compile_rpath 10471*a466cc55SCy Schubert relink_command=$finalize_var$finalize_command$finalize_rpath 10472*a466cc55SCy Schubert ;; 10473*a466cc55SCy Schubert *,needless) 10474*a466cc55SCy Schubert link_command=$finalize_var$compile_command$finalize_rpath 10475*a466cc55SCy Schubert relink_command= 10476*a466cc55SCy Schubert ;; 10477*a466cc55SCy Schubert esac 10478*a466cc55SCy Schubert 10479*a466cc55SCy Schubert # Replace the output file specification. 10480*a466cc55SCy Schubert link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481*a466cc55SCy Schubert 10482*a466cc55SCy Schubert # Delete the old output files. 10483*a466cc55SCy Schubert $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484*a466cc55SCy Schubert 10485*a466cc55SCy Schubert func_show_eval "$link_command" 'exit $?' 10486*a466cc55SCy Schubert 10487*a466cc55SCy Schubert if test -n "$postlink_cmds"; then 10488*a466cc55SCy Schubert func_to_tool_file "$output_objdir/$outputname" 10489*a466cc55SCy 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'` 10490*a466cc55SCy Schubert func_execute_cmds "$postlink_cmds" 'exit $?' 10491*a466cc55SCy Schubert fi 10492*a466cc55SCy Schubert 10493*a466cc55SCy Schubert # Now create the wrapper script. 10494*a466cc55SCy Schubert func_verbose "creating $output" 10495*a466cc55SCy Schubert 10496*a466cc55SCy Schubert # Quote the relink command for shipping. 10497*a466cc55SCy Schubert if test -n "$relink_command"; then 10498*a466cc55SCy Schubert # Preserve any variables that may affect compiler behavior 10499*a466cc55SCy Schubert for var in $variables_saved_for_relink; do 10500*a466cc55SCy Schubert if eval test -z \"\${$var+set}\"; then 10501*a466cc55SCy Schubert relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502*a466cc55SCy Schubert elif eval var_value=\$$var; test -z "$var_value"; then 10503*a466cc55SCy Schubert relink_command="$var=; export $var; $relink_command" 10504*a466cc55SCy Schubert else 10505*a466cc55SCy Schubert func_quote_for_eval "$var_value" 10506*a466cc55SCy Schubert relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507*a466cc55SCy Schubert fi 10508*a466cc55SCy Schubert done 10509*a466cc55SCy Schubert relink_command="(cd `pwd`; $relink_command)" 10510*a466cc55SCy Schubert relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511*a466cc55SCy Schubert fi 10512*a466cc55SCy Schubert 10513*a466cc55SCy Schubert # Only actually do things if not in dry run mode. 10514*a466cc55SCy Schubert $opt_dry_run || { 10515*a466cc55SCy Schubert # win32 will think the script is a binary if it has 10516*a466cc55SCy Schubert # a .exe suffix, so we strip it off here. 10517*a466cc55SCy Schubert case $output in 10518*a466cc55SCy Schubert *.exe) func_stripname '' '.exe' "$output" 10519*a466cc55SCy Schubert output=$func_stripname_result ;; 10520*a466cc55SCy Schubert esac 10521*a466cc55SCy Schubert # test for cygwin because mv fails w/o .exe extensions 10522*a466cc55SCy Schubert case $host in 10523*a466cc55SCy Schubert *cygwin*) 10524*a466cc55SCy Schubert exeext=.exe 10525*a466cc55SCy Schubert func_stripname '' '.exe' "$outputname" 10526*a466cc55SCy Schubert outputname=$func_stripname_result ;; 10527*a466cc55SCy Schubert *) exeext= ;; 10528*a466cc55SCy Schubert esac 10529*a466cc55SCy Schubert case $host in 10530*a466cc55SCy Schubert *cygwin* | *mingw* ) 10531*a466cc55SCy Schubert func_dirname_and_basename "$output" "" "." 10532*a466cc55SCy Schubert output_name=$func_basename_result 10533*a466cc55SCy Schubert output_path=$func_dirname_result 10534*a466cc55SCy Schubert cwrappersource=$output_path/$objdir/lt-$output_name.c 10535*a466cc55SCy Schubert cwrapper=$output_path/$output_name.exe 10536*a466cc55SCy Schubert $RM $cwrappersource $cwrapper 10537*a466cc55SCy Schubert trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538*a466cc55SCy Schubert 10539*a466cc55SCy Schubert func_emit_cwrapperexe_src > $cwrappersource 10540*a466cc55SCy Schubert 10541*a466cc55SCy Schubert # The wrapper executable is built using the $host compiler, 10542*a466cc55SCy Schubert # because it contains $host paths and files. If cross- 10543*a466cc55SCy Schubert # compiling, it, like the target executable, must be 10544*a466cc55SCy Schubert # executed on the $host or under an emulation environment. 10545*a466cc55SCy Schubert $opt_dry_run || { 10546*a466cc55SCy Schubert $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547*a466cc55SCy Schubert $STRIP $cwrapper 10548*a466cc55SCy Schubert } 10549*a466cc55SCy Schubert 10550*a466cc55SCy Schubert # Now, create the wrapper script for func_source use: 10551*a466cc55SCy Schubert func_ltwrapper_scriptname $cwrapper 10552*a466cc55SCy Schubert $RM $func_ltwrapper_scriptname_result 10553*a466cc55SCy Schubert trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554*a466cc55SCy Schubert $opt_dry_run || { 10555*a466cc55SCy Schubert # note: this script will not be executed, so do not chmod. 10556*a466cc55SCy Schubert if test "x$build" = "x$host"; then 10557*a466cc55SCy Schubert $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558*a466cc55SCy Schubert else 10559*a466cc55SCy Schubert func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560*a466cc55SCy Schubert fi 10561*a466cc55SCy Schubert } 10562*a466cc55SCy Schubert ;; 10563*a466cc55SCy Schubert * ) 10564*a466cc55SCy Schubert $RM $output 10565*a466cc55SCy Schubert trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566*a466cc55SCy Schubert 10567*a466cc55SCy Schubert func_emit_wrapper no > $output 10568*a466cc55SCy Schubert chmod +x $output 10569*a466cc55SCy Schubert ;; 10570*a466cc55SCy Schubert esac 10571*a466cc55SCy Schubert } 10572*a466cc55SCy Schubert exit $EXIT_SUCCESS 10573*a466cc55SCy Schubert ;; 10574*a466cc55SCy Schubert esac 10575*a466cc55SCy Schubert 10576*a466cc55SCy Schubert # See if we need to build an old-fashioned archive. 10577*a466cc55SCy Schubert for oldlib in $oldlibs; do 10578*a466cc55SCy Schubert 10579*a466cc55SCy Schubert case $build_libtool_libs in 10580*a466cc55SCy Schubert convenience) 10581*a466cc55SCy Schubert oldobjs="$libobjs_save $symfileobj" 10582*a466cc55SCy Schubert addlibs=$convenience 10583*a466cc55SCy Schubert build_libtool_libs=no 10584*a466cc55SCy Schubert ;; 10585*a466cc55SCy Schubert module) 10586*a466cc55SCy Schubert oldobjs=$libobjs_save 10587*a466cc55SCy Schubert addlibs=$old_convenience 10588*a466cc55SCy Schubert build_libtool_libs=no 10589*a466cc55SCy Schubert ;; 10590*a466cc55SCy Schubert *) 10591*a466cc55SCy Schubert oldobjs="$old_deplibs $non_pic_objects" 10592*a466cc55SCy Schubert $preload && test -f "$symfileobj" \ 10593*a466cc55SCy Schubert && func_append oldobjs " $symfileobj" 10594*a466cc55SCy Schubert addlibs=$old_convenience 10595*a466cc55SCy Schubert ;; 10596*a466cc55SCy Schubert esac 10597*a466cc55SCy Schubert 10598*a466cc55SCy Schubert if test -n "$addlibs"; then 10599*a466cc55SCy Schubert gentop=$output_objdir/${outputname}x 10600*a466cc55SCy Schubert func_append generated " $gentop" 10601*a466cc55SCy Schubert 10602*a466cc55SCy Schubert func_extract_archives $gentop $addlibs 10603*a466cc55SCy Schubert func_append oldobjs " $func_extract_archives_result" 10604*a466cc55SCy Schubert fi 10605*a466cc55SCy Schubert 10606*a466cc55SCy Schubert # Do each command in the archive commands. 10607*a466cc55SCy Schubert if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608*a466cc55SCy Schubert cmds=$old_archive_from_new_cmds 10609*a466cc55SCy Schubert else 10610*a466cc55SCy Schubert 10611*a466cc55SCy Schubert # Add any objects from preloaded convenience libraries 10612*a466cc55SCy Schubert if test -n "$dlprefiles"; then 10613*a466cc55SCy Schubert gentop=$output_objdir/${outputname}x 10614*a466cc55SCy Schubert func_append generated " $gentop" 10615*a466cc55SCy Schubert 10616*a466cc55SCy Schubert func_extract_archives $gentop $dlprefiles 10617*a466cc55SCy Schubert func_append oldobjs " $func_extract_archives_result" 10618*a466cc55SCy Schubert fi 10619*a466cc55SCy Schubert 10620*a466cc55SCy Schubert # POSIX demands no paths to be encoded in archives. We have 10621*a466cc55SCy Schubert # to avoid creating archives with duplicate basenames if we 10622*a466cc55SCy Schubert # might have to extract them afterwards, e.g., when creating a 10623*a466cc55SCy Schubert # static archive out of a convenience library, or when linking 10624*a466cc55SCy Schubert # the entirety of a libtool archive into another (currently 10625*a466cc55SCy Schubert # not supported by libtool). 10626*a466cc55SCy Schubert if (for obj in $oldobjs 10627*a466cc55SCy Schubert do 10628*a466cc55SCy Schubert func_basename "$obj" 10629*a466cc55SCy Schubert $ECHO "$func_basename_result" 10630*a466cc55SCy Schubert done | sort | sort -uc >/dev/null 2>&1); then 10631*a466cc55SCy Schubert : 10632*a466cc55SCy Schubert else 10633*a466cc55SCy Schubert echo "copying selected object files to avoid basename conflicts..." 10634*a466cc55SCy Schubert gentop=$output_objdir/${outputname}x 10635*a466cc55SCy Schubert func_append generated " $gentop" 10636*a466cc55SCy Schubert func_mkdir_p "$gentop" 10637*a466cc55SCy Schubert save_oldobjs=$oldobjs 10638*a466cc55SCy Schubert oldobjs= 10639*a466cc55SCy Schubert counter=1 10640*a466cc55SCy Schubert for obj in $save_oldobjs 10641*a466cc55SCy Schubert do 10642*a466cc55SCy Schubert func_basename "$obj" 10643*a466cc55SCy Schubert objbase=$func_basename_result 10644*a466cc55SCy Schubert case " $oldobjs " in 10645*a466cc55SCy Schubert " ") oldobjs=$obj ;; 10646*a466cc55SCy Schubert *[\ /]"$objbase "*) 10647*a466cc55SCy Schubert while :; do 10648*a466cc55SCy Schubert # Make sure we don't pick an alternate name that also 10649*a466cc55SCy Schubert # overlaps. 10650*a466cc55SCy Schubert newobj=lt$counter-$objbase 10651*a466cc55SCy Schubert func_arith $counter + 1 10652*a466cc55SCy Schubert counter=$func_arith_result 10653*a466cc55SCy Schubert case " $oldobjs " in 10654*a466cc55SCy Schubert *[\ /]"$newobj "*) ;; 10655*a466cc55SCy Schubert *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656*a466cc55SCy Schubert esac 10657*a466cc55SCy Schubert done 10658*a466cc55SCy Schubert func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659*a466cc55SCy Schubert func_append oldobjs " $gentop/$newobj" 10660*a466cc55SCy Schubert ;; 10661*a466cc55SCy Schubert *) func_append oldobjs " $obj" ;; 10662*a466cc55SCy Schubert esac 10663*a466cc55SCy Schubert done 10664*a466cc55SCy Schubert fi 10665*a466cc55SCy Schubert func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666*a466cc55SCy Schubert tool_oldlib=$func_to_tool_file_result 10667*a466cc55SCy Schubert eval cmds=\"$old_archive_cmds\" 10668*a466cc55SCy Schubert 10669*a466cc55SCy Schubert func_len " $cmds" 10670*a466cc55SCy Schubert len=$func_len_result 10671*a466cc55SCy Schubert if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672*a466cc55SCy Schubert cmds=$old_archive_cmds 10673*a466cc55SCy Schubert elif test -n "$archiver_list_spec"; then 10674*a466cc55SCy Schubert func_verbose "using command file archive linking..." 10675*a466cc55SCy Schubert for obj in $oldobjs 10676*a466cc55SCy Schubert do 10677*a466cc55SCy Schubert func_to_tool_file "$obj" 10678*a466cc55SCy Schubert $ECHO "$func_to_tool_file_result" 10679*a466cc55SCy Schubert done > $output_objdir/$libname.libcmd 10680*a466cc55SCy Schubert func_to_tool_file "$output_objdir/$libname.libcmd" 10681*a466cc55SCy Schubert oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682*a466cc55SCy Schubert cmds=$old_archive_cmds 10683*a466cc55SCy Schubert else 10684*a466cc55SCy Schubert # the command line is too long to link in one step, link in parts 10685*a466cc55SCy Schubert func_verbose "using piecewise archive linking..." 10686*a466cc55SCy Schubert save_RANLIB=$RANLIB 10687*a466cc55SCy Schubert RANLIB=: 10688*a466cc55SCy Schubert objlist= 10689*a466cc55SCy Schubert concat_cmds= 10690*a466cc55SCy Schubert save_oldobjs=$oldobjs 10691*a466cc55SCy Schubert oldobjs= 10692*a466cc55SCy Schubert # Is there a better way of finding the last object in the list? 10693*a466cc55SCy Schubert for obj in $save_oldobjs 10694*a466cc55SCy Schubert do 10695*a466cc55SCy Schubert last_oldobj=$obj 10696*a466cc55SCy Schubert done 10697*a466cc55SCy Schubert eval test_cmds=\"$old_archive_cmds\" 10698*a466cc55SCy Schubert func_len " $test_cmds" 10699*a466cc55SCy Schubert len0=$func_len_result 10700*a466cc55SCy Schubert len=$len0 10701*a466cc55SCy Schubert for obj in $save_oldobjs 10702*a466cc55SCy Schubert do 10703*a466cc55SCy Schubert func_len " $obj" 10704*a466cc55SCy Schubert func_arith $len + $func_len_result 10705*a466cc55SCy Schubert len=$func_arith_result 10706*a466cc55SCy Schubert func_append objlist " $obj" 10707*a466cc55SCy Schubert if test "$len" -lt "$max_cmd_len"; then 10708*a466cc55SCy Schubert : 10709*a466cc55SCy Schubert else 10710*a466cc55SCy Schubert # the above command should be used before it gets too long 10711*a466cc55SCy Schubert oldobjs=$objlist 10712*a466cc55SCy Schubert if test "$obj" = "$last_oldobj"; then 10713*a466cc55SCy Schubert RANLIB=$save_RANLIB 10714*a466cc55SCy Schubert fi 10715*a466cc55SCy Schubert test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716*a466cc55SCy Schubert eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717*a466cc55SCy Schubert objlist= 10718*a466cc55SCy Schubert len=$len0 10719*a466cc55SCy Schubert fi 10720*a466cc55SCy Schubert done 10721*a466cc55SCy Schubert RANLIB=$save_RANLIB 10722*a466cc55SCy Schubert oldobjs=$objlist 10723*a466cc55SCy Schubert if test -z "$oldobjs"; then 10724*a466cc55SCy Schubert eval cmds=\"\$concat_cmds\" 10725*a466cc55SCy Schubert else 10726*a466cc55SCy Schubert eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727*a466cc55SCy Schubert fi 10728*a466cc55SCy Schubert fi 10729*a466cc55SCy Schubert fi 10730*a466cc55SCy Schubert func_execute_cmds "$cmds" 'exit $?' 10731*a466cc55SCy Schubert done 10732*a466cc55SCy Schubert 10733*a466cc55SCy Schubert test -n "$generated" && \ 10734*a466cc55SCy Schubert func_show_eval "${RM}r$generated" 10735*a466cc55SCy Schubert 10736*a466cc55SCy Schubert # Now create the libtool archive. 10737*a466cc55SCy Schubert case $output in 10738*a466cc55SCy Schubert *.la) 10739*a466cc55SCy Schubert old_library= 10740*a466cc55SCy Schubert test yes = "$build_old_libs" && old_library=$libname.$libext 10741*a466cc55SCy Schubert func_verbose "creating $output" 10742*a466cc55SCy Schubert 10743*a466cc55SCy Schubert # Preserve any variables that may affect compiler behavior 10744*a466cc55SCy Schubert for var in $variables_saved_for_relink; do 10745*a466cc55SCy Schubert if eval test -z \"\${$var+set}\"; then 10746*a466cc55SCy Schubert relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747*a466cc55SCy Schubert elif eval var_value=\$$var; test -z "$var_value"; then 10748*a466cc55SCy Schubert relink_command="$var=; export $var; $relink_command" 10749*a466cc55SCy Schubert else 10750*a466cc55SCy Schubert func_quote_for_eval "$var_value" 10751*a466cc55SCy Schubert relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752*a466cc55SCy Schubert fi 10753*a466cc55SCy Schubert done 10754*a466cc55SCy Schubert # Quote the link command for shipping. 10755*a466cc55SCy Schubert relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10756*a466cc55SCy Schubert relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757*a466cc55SCy Schubert if test yes = "$hardcode_automatic"; then 10758*a466cc55SCy Schubert relink_command= 10759*a466cc55SCy Schubert fi 10760*a466cc55SCy Schubert 10761*a466cc55SCy Schubert # Only create the output if not a dry run. 10762*a466cc55SCy Schubert $opt_dry_run || { 10763*a466cc55SCy Schubert for installed in no yes; do 10764*a466cc55SCy Schubert if test yes = "$installed"; then 10765*a466cc55SCy Schubert if test -z "$install_libdir"; then 10766*a466cc55SCy Schubert break 10767*a466cc55SCy Schubert fi 10768*a466cc55SCy Schubert output=$output_objdir/${outputname}i 10769*a466cc55SCy Schubert # Replace all uninstalled libtool libraries with the installed ones 10770*a466cc55SCy Schubert newdependency_libs= 10771*a466cc55SCy Schubert for deplib in $dependency_libs; do 10772*a466cc55SCy Schubert case $deplib in 10773*a466cc55SCy Schubert *.la) 10774*a466cc55SCy Schubert func_basename "$deplib" 10775*a466cc55SCy Schubert name=$func_basename_result 10776*a466cc55SCy Schubert func_resolve_sysroot "$deplib" 10777*a466cc55SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778*a466cc55SCy Schubert test -z "$libdir" && \ 10779*a466cc55SCy Schubert func_fatal_error "'$deplib' is not a valid libtool archive" 10780*a466cc55SCy Schubert func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781*a466cc55SCy Schubert ;; 10782*a466cc55SCy Schubert -L*) 10783*a466cc55SCy Schubert func_stripname -L '' "$deplib" 10784*a466cc55SCy Schubert func_replace_sysroot "$func_stripname_result" 10785*a466cc55SCy Schubert func_append newdependency_libs " -L$func_replace_sysroot_result" 10786*a466cc55SCy Schubert ;; 10787*a466cc55SCy Schubert -R*) 10788*a466cc55SCy Schubert func_stripname -R '' "$deplib" 10789*a466cc55SCy Schubert func_replace_sysroot "$func_stripname_result" 10790*a466cc55SCy Schubert func_append newdependency_libs " -R$func_replace_sysroot_result" 10791*a466cc55SCy Schubert ;; 10792*a466cc55SCy Schubert *) func_append newdependency_libs " $deplib" ;; 10793*a466cc55SCy Schubert esac 10794*a466cc55SCy Schubert done 10795*a466cc55SCy Schubert dependency_libs=$newdependency_libs 10796*a466cc55SCy Schubert newdlfiles= 10797*a466cc55SCy Schubert 10798*a466cc55SCy Schubert for lib in $dlfiles; do 10799*a466cc55SCy Schubert case $lib in 10800*a466cc55SCy Schubert *.la) 10801*a466cc55SCy Schubert func_basename "$lib" 10802*a466cc55SCy Schubert name=$func_basename_result 10803*a466cc55SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804*a466cc55SCy Schubert test -z "$libdir" && \ 10805*a466cc55SCy Schubert func_fatal_error "'$lib' is not a valid libtool archive" 10806*a466cc55SCy Schubert func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807*a466cc55SCy Schubert ;; 10808*a466cc55SCy Schubert *) func_append newdlfiles " $lib" ;; 10809*a466cc55SCy Schubert esac 10810*a466cc55SCy Schubert done 10811*a466cc55SCy Schubert dlfiles=$newdlfiles 10812*a466cc55SCy Schubert newdlprefiles= 10813*a466cc55SCy Schubert for lib in $dlprefiles; do 10814*a466cc55SCy Schubert case $lib in 10815*a466cc55SCy Schubert *.la) 10816*a466cc55SCy Schubert # Only pass preopened files to the pseudo-archive (for 10817*a466cc55SCy Schubert # eventual linking with the app. that links it) if we 10818*a466cc55SCy Schubert # didn't already link the preopened objects directly into 10819*a466cc55SCy Schubert # the library: 10820*a466cc55SCy Schubert func_basename "$lib" 10821*a466cc55SCy Schubert name=$func_basename_result 10822*a466cc55SCy Schubert eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823*a466cc55SCy Schubert test -z "$libdir" && \ 10824*a466cc55SCy Schubert func_fatal_error "'$lib' is not a valid libtool archive" 10825*a466cc55SCy Schubert func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826*a466cc55SCy Schubert ;; 10827*a466cc55SCy Schubert esac 10828*a466cc55SCy Schubert done 10829*a466cc55SCy Schubert dlprefiles=$newdlprefiles 10830*a466cc55SCy Schubert else 10831*a466cc55SCy Schubert newdlfiles= 10832*a466cc55SCy Schubert for lib in $dlfiles; do 10833*a466cc55SCy Schubert case $lib in 10834*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835*a466cc55SCy Schubert *) abs=`pwd`"/$lib" ;; 10836*a466cc55SCy Schubert esac 10837*a466cc55SCy Schubert func_append newdlfiles " $abs" 10838*a466cc55SCy Schubert done 10839*a466cc55SCy Schubert dlfiles=$newdlfiles 10840*a466cc55SCy Schubert newdlprefiles= 10841*a466cc55SCy Schubert for lib in $dlprefiles; do 10842*a466cc55SCy Schubert case $lib in 10843*a466cc55SCy Schubert [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844*a466cc55SCy Schubert *) abs=`pwd`"/$lib" ;; 10845*a466cc55SCy Schubert esac 10846*a466cc55SCy Schubert func_append newdlprefiles " $abs" 10847*a466cc55SCy Schubert done 10848*a466cc55SCy Schubert dlprefiles=$newdlprefiles 10849*a466cc55SCy Schubert fi 10850*a466cc55SCy Schubert $RM $output 10851*a466cc55SCy Schubert # place dlname in correct position for cygwin 10852*a466cc55SCy Schubert # In fact, it would be nice if we could use this code for all target 10853*a466cc55SCy Schubert # systems that can't hard-code library paths into their executables 10854*a466cc55SCy Schubert # and that have no shared library path variable independent of PATH, 10855*a466cc55SCy Schubert # but it turns out we can't easily determine that from inspecting 10856*a466cc55SCy Schubert # libtool variables, so we have to hard-code the OSs to which it 10857*a466cc55SCy Schubert # applies here; at the moment, that means platforms that use the PE 10858*a466cc55SCy Schubert # object format with DLL files. See the long comment at the top of 10859*a466cc55SCy Schubert # tests/bindir.at for full details. 10860*a466cc55SCy Schubert tdlname=$dlname 10861*a466cc55SCy Schubert case $host,$output,$installed,$module,$dlname in 10862*a466cc55SCy Schubert *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863*a466cc55SCy Schubert # If a -bindir argument was supplied, place the dll there. 10864*a466cc55SCy Schubert if test -n "$bindir"; then 10865*a466cc55SCy Schubert func_relative_path "$install_libdir" "$bindir" 10866*a466cc55SCy Schubert tdlname=$func_relative_path_result/$dlname 10867*a466cc55SCy Schubert else 10868*a466cc55SCy Schubert # Otherwise fall back on heuristic. 10869*a466cc55SCy Schubert tdlname=../bin/$dlname 10870*a466cc55SCy Schubert fi 10871*a466cc55SCy Schubert ;; 10872*a466cc55SCy Schubert esac 10873*a466cc55SCy Schubert $ECHO > $output "\ 10874*a466cc55SCy Schubert# $outputname - a libtool library file 10875*a466cc55SCy Schubert# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876*a466cc55SCy Schubert# 10877*a466cc55SCy Schubert# Please DO NOT delete this file! 10878*a466cc55SCy Schubert# It is necessary for linking the library. 10879*a466cc55SCy Schubert 10880*a466cc55SCy Schubert# The name that we can dlopen(3). 10881*a466cc55SCy Schubertdlname='$tdlname' 10882*a466cc55SCy Schubert 10883*a466cc55SCy Schubert# Names of this library. 10884*a466cc55SCy Schubertlibrary_names='$library_names' 10885*a466cc55SCy Schubert 10886*a466cc55SCy Schubert# The name of the static archive. 10887*a466cc55SCy Schubertold_library='$old_library' 10888*a466cc55SCy Schubert 10889*a466cc55SCy Schubert# Linker flags that cannot go in dependency_libs. 10890*a466cc55SCy Schubertinherited_linker_flags='$new_inherited_linker_flags' 10891*a466cc55SCy Schubert 10892*a466cc55SCy Schubert# Libraries that this one depends upon. 10893*a466cc55SCy Schubertdependency_libs='$dependency_libs' 10894*a466cc55SCy Schubert 10895*a466cc55SCy Schubert# Names of additional weak libraries provided by this library 10896*a466cc55SCy Schubertweak_library_names='$weak_libs' 10897*a466cc55SCy Schubert 10898*a466cc55SCy Schubert# Version information for $libname. 10899*a466cc55SCy Schubertcurrent=$current 10900*a466cc55SCy Schubertage=$age 10901*a466cc55SCy Schubertrevision=$revision 10902*a466cc55SCy Schubert 10903*a466cc55SCy Schubert# Is this an already installed library? 10904*a466cc55SCy Schubertinstalled=$installed 10905*a466cc55SCy Schubert 10906*a466cc55SCy Schubert# Should we warn about portability when linking against -modules? 10907*a466cc55SCy Schubertshouldnotlink=$module 10908*a466cc55SCy Schubert 10909*a466cc55SCy Schubert# Files to dlopen/dlpreopen 10910*a466cc55SCy Schubertdlopen='$dlfiles' 10911*a466cc55SCy Schubertdlpreopen='$dlprefiles' 10912*a466cc55SCy Schubert 10913*a466cc55SCy Schubert# Directory that this library needs to be installed in: 10914*a466cc55SCy Schubertlibdir='$install_libdir'" 10915*a466cc55SCy Schubert if test no,yes = "$installed,$need_relink"; then 10916*a466cc55SCy Schubert $ECHO >> $output "\ 10917*a466cc55SCy Schubertrelink_command=\"$relink_command\"" 10918*a466cc55SCy Schubert fi 10919*a466cc55SCy Schubert done 10920*a466cc55SCy Schubert } 10921*a466cc55SCy Schubert 10922*a466cc55SCy Schubert # Do a symbolic link so that the libtool archive can be found in 10923*a466cc55SCy Schubert # LD_LIBRARY_PATH before the program is installed. 10924*a466cc55SCy Schubert func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925*a466cc55SCy Schubert ;; 10926*a466cc55SCy Schubert esac 10927*a466cc55SCy Schubert exit $EXIT_SUCCESS 10928*a466cc55SCy Schubert} 10929*a466cc55SCy Schubert 10930*a466cc55SCy Schubertif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931*a466cc55SCy Schubert func_mode_link ${1+"$@"} 10932*a466cc55SCy Schubertfi 10933*a466cc55SCy Schubert 10934*a466cc55SCy Schubert 10935*a466cc55SCy Schubert# func_mode_uninstall arg... 10936*a466cc55SCy Schubertfunc_mode_uninstall () 10937*a466cc55SCy Schubert{ 10938*a466cc55SCy Schubert $debug_cmd 10939*a466cc55SCy Schubert 10940*a466cc55SCy Schubert RM=$nonopt 10941*a466cc55SCy Schubert files= 10942*a466cc55SCy Schubert rmforce=false 10943*a466cc55SCy Schubert exit_status=0 10944*a466cc55SCy Schubert 10945*a466cc55SCy Schubert # This variable tells wrapper scripts just to set variables rather 10946*a466cc55SCy Schubert # than running their programs. 10947*a466cc55SCy Schubert libtool_install_magic=$magic 10948*a466cc55SCy Schubert 10949*a466cc55SCy Schubert for arg 10950*a466cc55SCy Schubert do 10951*a466cc55SCy Schubert case $arg in 10952*a466cc55SCy Schubert -f) func_append RM " $arg"; rmforce=: ;; 10953*a466cc55SCy Schubert -*) func_append RM " $arg" ;; 10954*a466cc55SCy Schubert *) func_append files " $arg" ;; 10955*a466cc55SCy Schubert esac 10956*a466cc55SCy Schubert done 10957*a466cc55SCy Schubert 10958*a466cc55SCy Schubert test -z "$RM" && \ 10959*a466cc55SCy Schubert func_fatal_help "you must specify an RM program" 10960*a466cc55SCy Schubert 10961*a466cc55SCy Schubert rmdirs= 10962*a466cc55SCy Schubert 10963*a466cc55SCy Schubert for file in $files; do 10964*a466cc55SCy Schubert func_dirname "$file" "" "." 10965*a466cc55SCy Schubert dir=$func_dirname_result 10966*a466cc55SCy Schubert if test . = "$dir"; then 10967*a466cc55SCy Schubert odir=$objdir 10968*a466cc55SCy Schubert else 10969*a466cc55SCy Schubert odir=$dir/$objdir 10970*a466cc55SCy Schubert fi 10971*a466cc55SCy Schubert func_basename "$file" 10972*a466cc55SCy Schubert name=$func_basename_result 10973*a466cc55SCy Schubert test uninstall = "$opt_mode" && odir=$dir 10974*a466cc55SCy Schubert 10975*a466cc55SCy Schubert # Remember odir for removal later, being careful to avoid duplicates 10976*a466cc55SCy Schubert if test clean = "$opt_mode"; then 10977*a466cc55SCy Schubert case " $rmdirs " in 10978*a466cc55SCy Schubert *" $odir "*) ;; 10979*a466cc55SCy Schubert *) func_append rmdirs " $odir" ;; 10980*a466cc55SCy Schubert esac 10981*a466cc55SCy Schubert fi 10982*a466cc55SCy Schubert 10983*a466cc55SCy Schubert # Don't error if the file doesn't exist and rm -f was used. 10984*a466cc55SCy Schubert if { test -L "$file"; } >/dev/null 2>&1 || 10985*a466cc55SCy Schubert { test -h "$file"; } >/dev/null 2>&1 || 10986*a466cc55SCy Schubert test -f "$file"; then 10987*a466cc55SCy Schubert : 10988*a466cc55SCy Schubert elif test -d "$file"; then 10989*a466cc55SCy Schubert exit_status=1 10990*a466cc55SCy Schubert continue 10991*a466cc55SCy Schubert elif $rmforce; then 10992*a466cc55SCy Schubert continue 10993*a466cc55SCy Schubert fi 10994*a466cc55SCy Schubert 10995*a466cc55SCy Schubert rmfiles=$file 10996*a466cc55SCy Schubert 10997*a466cc55SCy Schubert case $name in 10998*a466cc55SCy Schubert *.la) 10999*a466cc55SCy Schubert # Possibly a libtool archive, so verify it. 11000*a466cc55SCy Schubert if func_lalib_p "$file"; then 11001*a466cc55SCy Schubert func_source $dir/$name 11002*a466cc55SCy Schubert 11003*a466cc55SCy Schubert # Delete the libtool libraries and symlinks. 11004*a466cc55SCy Schubert for n in $library_names; do 11005*a466cc55SCy Schubert func_append rmfiles " $odir/$n" 11006*a466cc55SCy Schubert done 11007*a466cc55SCy Schubert test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008*a466cc55SCy Schubert 11009*a466cc55SCy Schubert case $opt_mode in 11010*a466cc55SCy Schubert clean) 11011*a466cc55SCy Schubert case " $library_names " in 11012*a466cc55SCy Schubert *" $dlname "*) ;; 11013*a466cc55SCy Schubert *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014*a466cc55SCy Schubert esac 11015*a466cc55SCy Schubert test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016*a466cc55SCy Schubert ;; 11017*a466cc55SCy Schubert uninstall) 11018*a466cc55SCy Schubert if test -n "$library_names"; then 11019*a466cc55SCy Schubert # Do each command in the postuninstall commands. 11020*a466cc55SCy Schubert func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021*a466cc55SCy Schubert fi 11022*a466cc55SCy Schubert 11023*a466cc55SCy Schubert if test -n "$old_library"; then 11024*a466cc55SCy Schubert # Do each command in the old_postuninstall commands. 11025*a466cc55SCy Schubert func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026*a466cc55SCy Schubert fi 11027*a466cc55SCy Schubert # FIXME: should reinstall the best remaining shared library. 11028*a466cc55SCy Schubert ;; 11029*a466cc55SCy Schubert esac 11030*a466cc55SCy Schubert fi 11031*a466cc55SCy Schubert ;; 11032*a466cc55SCy Schubert 11033*a466cc55SCy Schubert *.lo) 11034*a466cc55SCy Schubert # Possibly a libtool object, so verify it. 11035*a466cc55SCy Schubert if func_lalib_p "$file"; then 11036*a466cc55SCy Schubert 11037*a466cc55SCy Schubert # Read the .lo file 11038*a466cc55SCy Schubert func_source $dir/$name 11039*a466cc55SCy Schubert 11040*a466cc55SCy Schubert # Add PIC object to the list of files to remove. 11041*a466cc55SCy Schubert if test -n "$pic_object" && test none != "$pic_object"; then 11042*a466cc55SCy Schubert func_append rmfiles " $dir/$pic_object" 11043*a466cc55SCy Schubert fi 11044*a466cc55SCy Schubert 11045*a466cc55SCy Schubert # Add non-PIC object to the list of files to remove. 11046*a466cc55SCy Schubert if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047*a466cc55SCy Schubert func_append rmfiles " $dir/$non_pic_object" 11048*a466cc55SCy Schubert fi 11049*a466cc55SCy Schubert fi 11050*a466cc55SCy Schubert ;; 11051*a466cc55SCy Schubert 11052*a466cc55SCy Schubert *) 11053*a466cc55SCy Schubert if test clean = "$opt_mode"; then 11054*a466cc55SCy Schubert noexename=$name 11055*a466cc55SCy Schubert case $file in 11056*a466cc55SCy Schubert *.exe) 11057*a466cc55SCy Schubert func_stripname '' '.exe' "$file" 11058*a466cc55SCy Schubert file=$func_stripname_result 11059*a466cc55SCy Schubert func_stripname '' '.exe' "$name" 11060*a466cc55SCy Schubert noexename=$func_stripname_result 11061*a466cc55SCy Schubert # $file with .exe has already been added to rmfiles, 11062*a466cc55SCy Schubert # add $file without .exe 11063*a466cc55SCy Schubert func_append rmfiles " $file" 11064*a466cc55SCy Schubert ;; 11065*a466cc55SCy Schubert esac 11066*a466cc55SCy Schubert # Do a test to see if this is a libtool program. 11067*a466cc55SCy Schubert if func_ltwrapper_p "$file"; then 11068*a466cc55SCy Schubert if func_ltwrapper_executable_p "$file"; then 11069*a466cc55SCy Schubert func_ltwrapper_scriptname "$file" 11070*a466cc55SCy Schubert relink_command= 11071*a466cc55SCy Schubert func_source $func_ltwrapper_scriptname_result 11072*a466cc55SCy Schubert func_append rmfiles " $func_ltwrapper_scriptname_result" 11073*a466cc55SCy Schubert else 11074*a466cc55SCy Schubert relink_command= 11075*a466cc55SCy Schubert func_source $dir/$noexename 11076*a466cc55SCy Schubert fi 11077*a466cc55SCy Schubert 11078*a466cc55SCy Schubert # note $name still contains .exe if it was in $file originally 11079*a466cc55SCy Schubert # as does the version of $file that was added into $rmfiles 11080*a466cc55SCy Schubert func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081*a466cc55SCy Schubert if test yes = "$fast_install" && test -n "$relink_command"; then 11082*a466cc55SCy Schubert func_append rmfiles " $odir/lt-$name" 11083*a466cc55SCy Schubert fi 11084*a466cc55SCy Schubert if test "X$noexename" != "X$name"; then 11085*a466cc55SCy Schubert func_append rmfiles " $odir/lt-$noexename.c" 11086*a466cc55SCy Schubert fi 11087*a466cc55SCy Schubert fi 11088*a466cc55SCy Schubert fi 11089*a466cc55SCy Schubert ;; 11090*a466cc55SCy Schubert esac 11091*a466cc55SCy Schubert func_show_eval "$RM $rmfiles" 'exit_status=1' 11092*a466cc55SCy Schubert done 11093*a466cc55SCy Schubert 11094*a466cc55SCy Schubert # Try to remove the $objdir's in the directories where we deleted files 11095*a466cc55SCy Schubert for dir in $rmdirs; do 11096*a466cc55SCy Schubert if test -d "$dir"; then 11097*a466cc55SCy Schubert func_show_eval "rmdir $dir >/dev/null 2>&1" 11098*a466cc55SCy Schubert fi 11099*a466cc55SCy Schubert done 11100*a466cc55SCy Schubert 11101*a466cc55SCy Schubert exit $exit_status 11102*a466cc55SCy Schubert} 11103*a466cc55SCy Schubert 11104*a466cc55SCy Schubertif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105*a466cc55SCy Schubert func_mode_uninstall ${1+"$@"} 11106*a466cc55SCy Schubertfi 11107*a466cc55SCy Schubert 11108*a466cc55SCy Schuberttest -z "$opt_mode" && { 11109*a466cc55SCy Schubert help=$generic_help 11110*a466cc55SCy Schubert func_fatal_help "you must specify a MODE" 11111*a466cc55SCy Schubert} 11112*a466cc55SCy Schubert 11113*a466cc55SCy Schuberttest -z "$exec_cmd" && \ 11114*a466cc55SCy Schubert func_fatal_help "invalid operation mode '$opt_mode'" 11115*a466cc55SCy Schubert 11116*a466cc55SCy Schubertif test -n "$exec_cmd"; then 11117*a466cc55SCy Schubert eval exec "$exec_cmd" 11118*a466cc55SCy Schubert exit $EXIT_FAILURE 11119*a466cc55SCy Schubertfi 11120*a466cc55SCy Schubert 11121*a466cc55SCy Schubertexit $exit_status 11122*a466cc55SCy Schubert 11123*a466cc55SCy Schubert 11124*a466cc55SCy Schubert# The TAGs below are defined such that we never get into a situation 11125*a466cc55SCy Schubert# where we disable both kinds of libraries. Given conflicting 11126*a466cc55SCy Schubert# choices, we go for a static library, that is the most portable, 11127*a466cc55SCy Schubert# since we can't tell whether shared libraries were disabled because 11128*a466cc55SCy Schubert# the user asked for that or because the platform doesn't support 11129*a466cc55SCy Schubert# them. This is particularly important on AIX, because we don't 11130*a466cc55SCy Schubert# support having both static and shared libraries enabled at the same 11131*a466cc55SCy Schubert# time on that platform, so we default to a shared-only configuration. 11132*a466cc55SCy Schubert# If a disable-shared tag is given, we'll fallback to a static-only 11133*a466cc55SCy Schubert# configuration. But we'll never go from static-only to shared-only. 11134*a466cc55SCy Schubert 11135*a466cc55SCy Schubert# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136*a466cc55SCy Schubertbuild_libtool_libs=no 11137*a466cc55SCy Schubertbuild_old_libs=yes 11138*a466cc55SCy Schubert# ### END LIBTOOL TAG CONFIG: disable-shared 11139*a466cc55SCy Schubert 11140*a466cc55SCy Schubert# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141*a466cc55SCy Schubertbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142*a466cc55SCy Schubert# ### END LIBTOOL TAG CONFIG: disable-static 11143*a466cc55SCy Schubert 11144*a466cc55SCy Schubert# Local Variables: 11145*a466cc55SCy Schubert# mode:shell-script 11146*a466cc55SCy Schubert# sh-indentation:2 11147*a466cc55SCy Schubert# End: 11148