ltmain.sh revision e3d74329
1e3d74329Smrg#! /bin/sh 2e3d74329Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3e3d74329Smrg## by inline-source v2014-01-03.01 442a55b46Smrg 5e3d74329Smrg# libtool (GNU libtool) 2.4.6 6e3d74329Smrg# Provide generalized library-building support services. 742a55b46Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 842a55b46Smrg 9e3d74329Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 1042a55b46Smrg# This is free software; see the source for copying conditions. There is NO 1142a55b46Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1242a55b46Smrg 1342a55b46Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14c582b7e3Smrg# it under the terms of the GNU General Public License as published by 15c582b7e3Smrg# the Free Software Foundation; either version 2 of the License, or 16c582b7e3Smrg# (at your option) any later version. 17c582b7e3Smrg# 1842a55b46Smrg# As a special exception to the GNU General Public License, 1942a55b46Smrg# if you distribute this file as part of a program or library that 2042a55b46Smrg# is built using GNU Libtool, you may include this file under the 2142a55b46Smrg# same distribution terms that you use for the rest of that program. 2242a55b46Smrg# 2342a55b46Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24c582b7e3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25c582b7e3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26c582b7e3Smrg# General Public License for more details. 27c582b7e3Smrg# 28c582b7e3Smrg# You should have received a copy of the GNU General Public License 29e3d74329Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30c582b7e3Smrg 31c582b7e3Smrg 3242a55b46SmrgPROGRAM=libtool 33c582b7e3SmrgPACKAGE=libtool 34e3d74329SmrgVERSION=2.4.6 35e3d74329Smrgpackage_revision=2.4.6 36c582b7e3Smrg 37e3d74329Smrg 38e3d74329Smrg## ------ ## 39e3d74329Smrg## Usage. ## 40e3d74329Smrg## ------ ## 41e3d74329Smrg 42e3d74329Smrg# Run './libtool --help' for help with using this script from the 43e3d74329Smrg# command line. 44e3d74329Smrg 45e3d74329Smrg 46e3d74329Smrg## ------------------------------- ## 47e3d74329Smrg## User overridable command paths. ## 48e3d74329Smrg## ------------------------------- ## 49e3d74329Smrg 50e3d74329Smrg# After configure completes, it has a better idea of some of the 51e3d74329Smrg# shell tools we need than the defaults used by the functions shared 52e3d74329Smrg# with bootstrap, so set those here where they can still be over- 53e3d74329Smrg# ridden by the user, but otherwise take precedence. 54e3d74329Smrg 55e3d74329Smrg: ${AUTOCONF="autoconf"} 56e3d74329Smrg: ${AUTOMAKE="automake"} 57e3d74329Smrg 58e3d74329Smrg 59e3d74329Smrg## -------------------------- ## 60e3d74329Smrg## Source external libraries. ## 61e3d74329Smrg## -------------------------- ## 62e3d74329Smrg 63e3d74329Smrg# Much of our low-level functionality needs to be sourced from external 64e3d74329Smrg# libraries, which are installed to $pkgauxdir. 65e3d74329Smrg 66e3d74329Smrg# Set a version string for this script. 67e3d74329Smrgscriptversion=2015-01-20.17; # UTC 68e3d74329Smrg 69e3d74329Smrg# General shell script boiler plate, and helper functions. 70e3d74329Smrg# Written by Gary V. Vaughan, 2004 71e3d74329Smrg 72e3d74329Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73e3d74329Smrg# This is free software; see the source for copying conditions. There is NO 74e3d74329Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75e3d74329Smrg 76e3d74329Smrg# This program is free software; you can redistribute it and/or modify 77e3d74329Smrg# it under the terms of the GNU General Public License as published by 78e3d74329Smrg# the Free Software Foundation; either version 3 of the License, or 79e3d74329Smrg# (at your option) any later version. 80e3d74329Smrg 81e3d74329Smrg# As a special exception to the GNU General Public License, if you distribute 82e3d74329Smrg# this file as part of a program or library that is built using GNU Libtool, 83e3d74329Smrg# you may include this file under the same distribution terms that you use 84e3d74329Smrg# for the rest of that program. 85e3d74329Smrg 86e3d74329Smrg# This program is distributed in the hope that it will be useful, 87e3d74329Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88e3d74329Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89e3d74329Smrg# General Public License for more details. 90e3d74329Smrg 91e3d74329Smrg# You should have received a copy of the GNU General Public License 92e3d74329Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93e3d74329Smrg 94e3d74329Smrg# Please report bugs or propose patches to gary@gnu.org. 95e3d74329Smrg 96e3d74329Smrg 97e3d74329Smrg## ------ ## 98e3d74329Smrg## Usage. ## 99e3d74329Smrg## ------ ## 100e3d74329Smrg 101e3d74329Smrg# Evaluate this file near the top of your script to gain access to 102e3d74329Smrg# the functions and variables defined here: 103e3d74329Smrg# 104e3d74329Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105e3d74329Smrg# 106e3d74329Smrg# If you need to override any of the default environment variable 107e3d74329Smrg# settings, do that before evaluating this file. 108e3d74329Smrg 109e3d74329Smrg 110e3d74329Smrg## -------------------- ## 111e3d74329Smrg## Shell normalisation. ## 112e3d74329Smrg## -------------------- ## 113e3d74329Smrg 114e3d74329Smrg# Some shells need a little help to be as Bourne compatible as possible. 115e3d74329Smrg# Before doing anything else, make sure all that help has been provided! 116e3d74329Smrg 117e3d74329SmrgDUALCASE=1; export DUALCASE # for MKS sh 118e3d74329Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119c582b7e3Smrg emulate sh 120c582b7e3Smrg NULLCMD=: 121e3d74329Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122c582b7e3Smrg # is contrary to our usage. Disable this feature. 123c582b7e3Smrg alias -g '${1+"$@"}'='"$@"' 124c582b7e3Smrg setopt NO_GLOB_SUBST 125c582b7e3Smrgelse 126e3d74329Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127c582b7e3Smrgfi 128c582b7e3Smrg 129e3d74329Smrg# NLS nuisances: We save the old values in case they are required later. 130e3d74329Smrg_G_user_locale= 131e3d74329Smrg_G_safe_locale= 132e3d74329Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133c582b7e3Smrgdo 134e3d74329Smrg eval "if test set = \"\${$_G_var+set}\"; then 135e3d74329Smrg save_$_G_var=\$$_G_var 136e3d74329Smrg $_G_var=C 137e3d74329Smrg export $_G_var 138e3d74329Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139e3d74329Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140c582b7e3Smrg fi" 141c582b7e3Smrgdone 14242a55b46Smrg 143e3d74329Smrg# CDPATH. 144e3d74329Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145c582b7e3Smrg 146e3d74329Smrg# Make sure IFS has a sensible default 147e3d74329Smrgsp=' ' 148e3d74329Smrgnl=' 149e3d74329Smrg' 150e3d74329SmrgIFS="$sp $nl" 151e3d74329Smrg 152e3d74329Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 153e3d74329Smrgif test "${PATH_SEPARATOR+set}" != set; then 154e3d74329Smrg PATH_SEPARATOR=: 155e3d74329Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156e3d74329Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157e3d74329Smrg PATH_SEPARATOR=';' 158e3d74329Smrg } 159e3d74329Smrgfi 16042a55b46Smrg 16142a55b46Smrg 16242a55b46Smrg 163e3d74329Smrg## ------------------------- ## 164e3d74329Smrg## Locate command utilities. ## 165e3d74329Smrg## ------------------------- ## 166e3d74329Smrg 167e3d74329Smrg 168e3d74329Smrg# func_executable_p FILE 169e3d74329Smrg# ---------------------- 170e3d74329Smrg# Check that FILE is an executable regular file. 171e3d74329Smrgfunc_executable_p () 172e3d74329Smrg{ 173e3d74329Smrg test -f "$1" && test -x "$1" 174e3d74329Smrg} 175e3d74329Smrg 176e3d74329Smrg 177e3d74329Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178e3d74329Smrg# -------------------------------------------- 179e3d74329Smrg# Search for either a program that responds to --version with output 180e3d74329Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181e3d74329Smrg# trying all the directories in PATH with each of the elements of 182e3d74329Smrg# PROGS_LIST. 183e3d74329Smrg# 184e3d74329Smrg# CHECK_FUNC should accept the path to a candidate program, and 185e3d74329Smrg# set $func_check_prog_result if it truncates its output less than 186e3d74329Smrg# $_G_path_prog_max characters. 187e3d74329Smrgfunc_path_progs () 188e3d74329Smrg{ 189e3d74329Smrg _G_progs_list=$1 190e3d74329Smrg _G_check_func=$2 191e3d74329Smrg _G_PATH=${3-"$PATH"} 192e3d74329Smrg 193e3d74329Smrg _G_path_prog_max=0 194e3d74329Smrg _G_path_prog_found=false 195e3d74329Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196e3d74329Smrg for _G_dir in $_G_PATH; do 197e3d74329Smrg IFS=$_G_save_IFS 198e3d74329Smrg test -z "$_G_dir" && _G_dir=. 199e3d74329Smrg for _G_prog_name in $_G_progs_list; do 200e3d74329Smrg for _exeext in '' .EXE; do 201e3d74329Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202e3d74329Smrg func_executable_p "$_G_path_prog" || continue 203e3d74329Smrg case `"$_G_path_prog" --version 2>&1` in 204e3d74329Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205e3d74329Smrg *) $_G_check_func $_G_path_prog 206e3d74329Smrg func_path_progs_result=$func_check_prog_result 207e3d74329Smrg ;; 208e3d74329Smrg esac 209e3d74329Smrg $_G_path_prog_found && break 3 210e3d74329Smrg done 211e3d74329Smrg done 212e3d74329Smrg done 213e3d74329Smrg IFS=$_G_save_IFS 214e3d74329Smrg test -z "$func_path_progs_result" && { 215e3d74329Smrg echo "no acceptable sed could be found in \$PATH" >&2 216e3d74329Smrg exit 1 217e3d74329Smrg } 218e3d74329Smrg} 219e3d74329Smrg 220e3d74329Smrg 221e3d74329Smrg# We want to be able to use the functions in this file before configure 222e3d74329Smrg# has figured out where the best binaries are kept, which means we have 223e3d74329Smrg# to search for them ourselves - except when the results are already set 224e3d74329Smrg# where we skip the searches. 225e3d74329Smrg 226e3d74329Smrg# Unless the user overrides by setting SED, search the path for either GNU 227e3d74329Smrg# sed, or the sed that truncates its output the least. 228e3d74329Smrgtest -z "$SED" && { 229e3d74329Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230e3d74329Smrg for _G_i in 1 2 3 4 5 6 7; do 231e3d74329Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232e3d74329Smrg done 233e3d74329Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234e3d74329Smrg _G_sed_script= 235e3d74329Smrg 236e3d74329Smrg func_check_prog_sed () 237e3d74329Smrg { 238e3d74329Smrg _G_path_prog=$1 239e3d74329Smrg 240e3d74329Smrg _G_count=0 241e3d74329Smrg printf 0123456789 >conftest.in 242e3d74329Smrg while : 243e3d74329Smrg do 244e3d74329Smrg cat conftest.in conftest.in >conftest.tmp 245e3d74329Smrg mv conftest.tmp conftest.in 246e3d74329Smrg cp conftest.in conftest.nl 247e3d74329Smrg echo '' >> conftest.nl 248e3d74329Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249e3d74329Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250e3d74329Smrg _G_count=`expr $_G_count + 1` 251e3d74329Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252e3d74329Smrg # Best one so far, save it but keep looking for a better one 253e3d74329Smrg func_check_prog_result=$_G_path_prog 254e3d74329Smrg _G_path_prog_max=$_G_count 255e3d74329Smrg fi 256e3d74329Smrg # 10*(2^10) chars as input seems more than enough 257e3d74329Smrg test 10 -lt "$_G_count" && break 258e3d74329Smrg done 259e3d74329Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260e3d74329Smrg } 261e3d74329Smrg 262e3d74329Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263e3d74329Smrg rm -f conftest.sed 264e3d74329Smrg SED=$func_path_progs_result 265e3d74329Smrg} 266e3d74329Smrg 267e3d74329Smrg 268e3d74329Smrg# Unless the user overrides by setting GREP, search the path for either GNU 269e3d74329Smrg# grep, or the grep that truncates its output the least. 270e3d74329Smrgtest -z "$GREP" && { 271e3d74329Smrg func_check_prog_grep () 272e3d74329Smrg { 273e3d74329Smrg _G_path_prog=$1 274e3d74329Smrg 275e3d74329Smrg _G_count=0 276e3d74329Smrg _G_path_prog_max=0 277e3d74329Smrg printf 0123456789 >conftest.in 278e3d74329Smrg while : 279e3d74329Smrg do 280e3d74329Smrg cat conftest.in conftest.in >conftest.tmp 281e3d74329Smrg mv conftest.tmp conftest.in 282e3d74329Smrg cp conftest.in conftest.nl 283e3d74329Smrg echo 'GREP' >> conftest.nl 284e3d74329Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285e3d74329Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286e3d74329Smrg _G_count=`expr $_G_count + 1` 287e3d74329Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288e3d74329Smrg # Best one so far, save it but keep looking for a better one 289e3d74329Smrg func_check_prog_result=$_G_path_prog 290e3d74329Smrg _G_path_prog_max=$_G_count 291e3d74329Smrg fi 292e3d74329Smrg # 10*(2^10) chars as input seems more than enough 293e3d74329Smrg test 10 -lt "$_G_count" && break 294e3d74329Smrg done 295e3d74329Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296e3d74329Smrg } 297e3d74329Smrg 298e3d74329Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299e3d74329Smrg GREP=$func_path_progs_result 300e3d74329Smrg} 301e3d74329Smrg 302e3d74329Smrg 303e3d74329Smrg## ------------------------------- ## 304e3d74329Smrg## User overridable command paths. ## 305e3d74329Smrg## ------------------------------- ## 306e3d74329Smrg 307e3d74329Smrg# All uppercase variable names are used for environment variables. These 308e3d74329Smrg# variables can be overridden by the user before calling a script that 309e3d74329Smrg# uses them if a suitable command of that name is not already available 310e3d74329Smrg# in the command search PATH. 31142a55b46Smrg 31242a55b46Smrg: ${CP="cp -f"} 313e3d74329Smrg: ${ECHO="printf %s\n"} 314e3d74329Smrg: ${EGREP="$GREP -E"} 315e3d74329Smrg: ${FGREP="$GREP -F"} 316e3d74329Smrg: ${LN_S="ln -s"} 31742a55b46Smrg: ${MAKE="make"} 31842a55b46Smrg: ${MKDIR="mkdir"} 31942a55b46Smrg: ${MV="mv -f"} 32042a55b46Smrg: ${RM="rm -f"} 32142a55b46Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322c582b7e3Smrg 323c582b7e3Smrg 324e3d74329Smrg## -------------------- ## 325e3d74329Smrg## Useful sed snippets. ## 326e3d74329Smrg## -------------------- ## 32742a55b46Smrg 328e3d74329Smrgsed_dirname='s|/[^/]*$||' 329e3d74329Smrgsed_basename='s|^.*/||' 33042a55b46Smrg 331e3d74329Smrg# Sed substitution that helps us do robust quoting. It backslashifies 332e3d74329Smrg# metacharacters that are still active within double-quoted strings. 333e3d74329Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 33442a55b46Smrg 335e3d74329Smrg# Same as above, but do not quote variable references. 336e3d74329Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 33742a55b46Smrg 338e3d74329Smrg# Sed substitution that turns a string into a regex matching for the 339e3d74329Smrg# string literally. 340e3d74329Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 34142a55b46Smrg 342e3d74329Smrg# Sed substitution that converts a w32 file name or path 343e3d74329Smrg# that contains forward slashes, into one that contains 344e3d74329Smrg# (escaped) backslashes. A very naive implementation. 345e3d74329Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346e3d74329Smrg 347e3d74329Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348e3d74329Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349e3d74329Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350e3d74329Smrg# expansion. Since each input '\' is now two '\'s, look for any number 351e3d74329Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352e3d74329Smrg_G_bs='\\' 353e3d74329Smrg_G_bs2='\\\\' 354e3d74329Smrg_G_bs4='\\\\\\\\' 355e3d74329Smrg_G_dollar='\$' 356e3d74329Smrgsed_double_backslash="\ 357e3d74329Smrg s/$_G_bs4/&\\ 358e3d74329Smrg/g 359e3d74329Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360e3d74329Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361e3d74329Smrg s/\n//g" 36242a55b46Smrg 36342a55b46Smrg 364e3d74329Smrg## ----------------- ## 365e3d74329Smrg## Global variables. ## 366e3d74329Smrg## ----------------- ## 36742a55b46Smrg 368e3d74329Smrg# Except for the global variables explicitly listed below, the following 369e3d74329Smrg# functions in the '^func_' namespace, and the '^require_' namespace 370e3d74329Smrg# variables initialised in the 'Resource management' section, sourcing 371e3d74329Smrg# this file will not pollute your global namespace with anything 372e3d74329Smrg# else. There's no portable way to scope variables in Bourne shell 373e3d74329Smrg# though, so actually running these functions will sometimes place 374e3d74329Smrg# results into a variable named after the function, and often use 375e3d74329Smrg# temporary variables in the '^_G_' namespace. If you are careful to 376e3d74329Smrg# avoid using those namespaces casually in your sourcing script, things 377e3d74329Smrg# should continue to work as you expect. And, of course, you can freely 378e3d74329Smrg# overwrite any of the functions or variables defined here before 379e3d74329Smrg# calling anything to customize them. 38042a55b46Smrg 381e3d74329SmrgEXIT_SUCCESS=0 382e3d74329SmrgEXIT_FAILURE=1 383e3d74329SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384e3d74329SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38542a55b46Smrg 386e3d74329Smrg# Allow overriding, eg assuming that you follow the convention of 387e3d74329Smrg# putting '$debug_cmd' at the start of all your functions, you can get 388e3d74329Smrg# bash to show function call trace with: 389e3d74329Smrg# 390e3d74329Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391e3d74329Smrgdebug_cmd=${debug_cmd-":"} 392e3d74329Smrgexit_cmd=: 39342a55b46Smrg 394e3d74329Smrg# By convention, finish your script with: 395e3d74329Smrg# 396e3d74329Smrg# exit $exit_status 397e3d74329Smrg# 398e3d74329Smrg# so that you can set exit_status to non-zero if you want to indicate 399e3d74329Smrg# something went wrong during execution without actually bailing out at 400e3d74329Smrg# the point of failure. 401e3d74329Smrgexit_status=$EXIT_SUCCESS 40242a55b46Smrg 403e3d74329Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404e3d74329Smrg# is ksh but when the shell is invoked as "sh" and the current value of 405e3d74329Smrg# the _XPG environment variable is not equal to 1 (one), the special 406e3d74329Smrg# positional parameter $0, within a function call, is the name of the 407e3d74329Smrg# function. 408e3d74329Smrgprogpath=$0 40942a55b46Smrg 410e3d74329Smrg# The name of this program. 411e3d74329Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 41242a55b46Smrg 413e3d74329Smrg# Make sure we have an absolute progpath for reexecution: 41442a55b46Smrgcase $progpath in 41542a55b46Smrg [\\/]*|[A-Za-z]:\\*) ;; 41642a55b46Smrg *[\\/]*) 417e3d74329Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 41842a55b46Smrg progdir=`cd "$progdir" && pwd` 419e3d74329Smrg progpath=$progdir/$progname 42042a55b46Smrg ;; 42142a55b46Smrg *) 422e3d74329Smrg _G_IFS=$IFS 42342a55b46Smrg IFS=${PATH_SEPARATOR-:} 42442a55b46Smrg for progdir in $PATH; do 425e3d74329Smrg IFS=$_G_IFS 42642a55b46Smrg test -x "$progdir/$progname" && break 42742a55b46Smrg done 428e3d74329Smrg IFS=$_G_IFS 42942a55b46Smrg test -n "$progdir" || progdir=`pwd` 430e3d74329Smrg progpath=$progdir/$progname 43142a55b46Smrg ;; 43242a55b46Smrgesac 43342a55b46Smrg 43442a55b46Smrg 435e3d74329Smrg## ----------------- ## 436e3d74329Smrg## Standard options. ## 437e3d74329Smrg## ----------------- ## 43842a55b46Smrg 439e3d74329Smrg# The following options affect the operation of the functions defined 440e3d74329Smrg# below, and should be set appropriately depending on run-time para- 441e3d74329Smrg# meters passed on the command line. 44242a55b46Smrg 44342a55b46Smrgopt_dry_run=false 44442a55b46Smrgopt_quiet=false 44542a55b46Smrgopt_verbose=false 44642a55b46Smrg 447e3d74329Smrg# Categories 'all' and 'none' are always available. Append any others 448e3d74329Smrg# you will pass as the first argument to func_warning from your own 449e3d74329Smrg# code. 450e3d74329Smrgwarning_categories= 45142a55b46Smrg 452e3d74329Smrg# By default, display warnings according to 'opt_warning_types'. Set 453e3d74329Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454e3d74329Smrg# treat the next displayed warning as a fatal error. 455e3d74329Smrgwarning_func=func_warn_and_continue 45642a55b46Smrg 457e3d74329Smrg# Set to 'all' to display all warnings, 'none' to suppress all 458e3d74329Smrg# warnings, or a space delimited list of some subset of 459e3d74329Smrg# 'warning_categories' to display only the listed warnings. 460e3d74329Smrgopt_warning_types=all 46142a55b46Smrg 46242a55b46Smrg 463e3d74329Smrg## -------------------- ## 464e3d74329Smrg## Resource management. ## 465e3d74329Smrg## -------------------- ## 46642a55b46Smrg 467e3d74329Smrg# This section contains definitions for functions that each ensure a 468e3d74329Smrg# particular resource (a file, or a non-empty configuration variable for 469e3d74329Smrg# example) is available, and if appropriate to extract default values 470e3d74329Smrg# from pertinent package files. Call them using their associated 471e3d74329Smrg# 'require_*' variable to ensure that they are executed, at most, once. 472e3d74329Smrg# 473e3d74329Smrg# It's entirely deliberate that calling these functions can set 474e3d74329Smrg# variables that don't obey the namespace limitations obeyed by the rest 475e3d74329Smrg# of this file, in order that that they be as useful as possible to 476e3d74329Smrg# callers. 47742a55b46Smrg 47842a55b46Smrg 479e3d74329Smrg# require_term_colors 480e3d74329Smrg# ------------------- 481e3d74329Smrg# Allow display of bold text on terminals that support it. 482e3d74329Smrgrequire_term_colors=func_require_term_colors 483e3d74329Smrgfunc_require_term_colors () 48442a55b46Smrg{ 485e3d74329Smrg $debug_cmd 486e3d74329Smrg 487e3d74329Smrg test -t 1 && { 488e3d74329Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 489e3d74329Smrg # precedence, because most terminfo databases neglect to describe 490e3d74329Smrg # whether color sequences are supported. 491e3d74329Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492e3d74329Smrg 493e3d74329Smrg if test 1 = "$USE_ANSI_COLORS"; then 494e3d74329Smrg # Standard ANSI escape sequences 495e3d74329Smrg tc_reset='[0m' 496e3d74329Smrg tc_bold='[1m'; tc_standout='[7m' 497e3d74329Smrg tc_red='[31m'; tc_green='[32m' 498e3d74329Smrg tc_blue='[34m'; tc_cyan='[36m' 499e3d74329Smrg else 500e3d74329Smrg # Otherwise trust the terminfo database after all. 501e3d74329Smrg test -n "`tput sgr0 2>/dev/null`" && { 502e3d74329Smrg tc_reset=`tput sgr0` 503e3d74329Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504e3d74329Smrg tc_standout=$tc_bold 505e3d74329Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506e3d74329Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507e3d74329Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508e3d74329Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509e3d74329Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510e3d74329Smrg } 511e3d74329Smrg fi 512e3d74329Smrg } 51342a55b46Smrg 514e3d74329Smrg require_term_colors=: 51542a55b46Smrg} 51642a55b46Smrg 51742a55b46Smrg 518e3d74329Smrg## ----------------- ## 519e3d74329Smrg## Function library. ## 520e3d74329Smrg## ----------------- ## 521e3d74329Smrg 522e3d74329Smrg# This section contains a variety of useful functions to call in your 523e3d74329Smrg# scripts. Take note of the portable wrappers for features provided by 524e3d74329Smrg# some modern shells, which will fall back to slower equivalents on 525e3d74329Smrg# less featureful shells. 526e3d74329Smrg 527e3d74329Smrg 528e3d74329Smrg# func_append VAR VALUE 529e3d74329Smrg# --------------------- 530e3d74329Smrg# Append VALUE onto the existing contents of VAR. 531e3d74329Smrg 532e3d74329Smrg # We should try to minimise forks, especially on Windows where they are 533e3d74329Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 534e3d74329Smrg # being used: 535e3d74329Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536e3d74329Smrg : ${_G_HAVE_ARITH_OP="yes"} 537e3d74329Smrg : ${_G_HAVE_XSI_OPS="yes"} 538e3d74329Smrg # The += operator was introduced in bash 3.1 539e3d74329Smrg case $BASH_VERSION in 540e3d74329Smrg [12].* | 3.0 | 3.0*) ;; 541e3d74329Smrg *) 542e3d74329Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543e3d74329Smrg ;; 544e3d74329Smrg esac 545e3d74329Smrg fi 546e3d74329Smrg 547e3d74329Smrg # _G_HAVE_PLUSEQ_OP 548e3d74329Smrg # Can be empty, in which case the shell is probed, "yes" if += is 549e3d74329Smrg # useable or anything else if it does not work. 550e3d74329Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551e3d74329Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552e3d74329Smrg && _G_HAVE_PLUSEQ_OP=yes 553e3d74329Smrg 554e3d74329Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555e3d74329Smrgthen 556e3d74329Smrg # This is an XSI compatible shell, allowing a faster implementation... 557e3d74329Smrg eval 'func_append () 558e3d74329Smrg { 559e3d74329Smrg $debug_cmd 560e3d74329Smrg 561e3d74329Smrg eval "$1+=\$2" 562e3d74329Smrg }' 563e3d74329Smrgelse 564e3d74329Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 565e3d74329Smrg func_append () 566e3d74329Smrg { 567e3d74329Smrg $debug_cmd 568e3d74329Smrg 569e3d74329Smrg eval "$1=\$$1\$2" 570e3d74329Smrg } 571e3d74329Smrgfi 572e3d74329Smrg 573e3d74329Smrg 574e3d74329Smrg# func_append_quoted VAR VALUE 575e3d74329Smrg# ---------------------------- 576e3d74329Smrg# Quote VALUE and append to the end of shell variable VAR, separated 577e3d74329Smrg# by a space. 578e3d74329Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579e3d74329Smrg eval 'func_append_quoted () 580e3d74329Smrg { 581e3d74329Smrg $debug_cmd 582e3d74329Smrg 583e3d74329Smrg func_quote_for_eval "$2" 584e3d74329Smrg eval "$1+=\\ \$func_quote_for_eval_result" 585e3d74329Smrg }' 586e3d74329Smrgelse 587e3d74329Smrg func_append_quoted () 588e3d74329Smrg { 589e3d74329Smrg $debug_cmd 590e3d74329Smrg 591e3d74329Smrg func_quote_for_eval "$2" 592e3d74329Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593e3d74329Smrg } 594e3d74329Smrgfi 595e3d74329Smrg 596e3d74329Smrg 597e3d74329Smrg# func_append_uniq VAR VALUE 598e3d74329Smrg# -------------------------- 599e3d74329Smrg# Append unique VALUE onto the existing contents of VAR, assuming 600e3d74329Smrg# entries are delimited by the first character of VALUE. For example: 601e3d74329Smrg# 602e3d74329Smrg# func_append_uniq options " --another-option option-argument" 603e3d74329Smrg# 604e3d74329Smrg# will only append to $options if " --another-option option-argument " 605e3d74329Smrg# is not already present somewhere in $options already (note spaces at 606e3d74329Smrg# each end implied by leading space in second argument). 607e3d74329Smrgfunc_append_uniq () 608e3d74329Smrg{ 609e3d74329Smrg $debug_cmd 610e3d74329Smrg 611e3d74329Smrg eval _G_current_value='`$ECHO $'$1'`' 612e3d74329Smrg _G_delim=`expr "$2" : '\(.\)'` 613e3d74329Smrg 614e3d74329Smrg case $_G_delim$_G_current_value$_G_delim in 615e3d74329Smrg *"$2$_G_delim"*) ;; 616e3d74329Smrg *) func_append "$@" ;; 617e3d74329Smrg esac 618e3d74329Smrg} 619e3d74329Smrg 620e3d74329Smrg 621e3d74329Smrg# func_arith TERM... 622e3d74329Smrg# ------------------ 623e3d74329Smrg# Set func_arith_result to the result of evaluating TERMs. 624e3d74329Smrg test -z "$_G_HAVE_ARITH_OP" \ 625e3d74329Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626e3d74329Smrg && _G_HAVE_ARITH_OP=yes 627e3d74329Smrg 628e3d74329Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 629e3d74329Smrg eval 'func_arith () 630e3d74329Smrg { 631e3d74329Smrg $debug_cmd 632e3d74329Smrg 633e3d74329Smrg func_arith_result=$(( $* )) 634e3d74329Smrg }' 635e3d74329Smrgelse 636e3d74329Smrg func_arith () 637e3d74329Smrg { 638e3d74329Smrg $debug_cmd 639e3d74329Smrg 640e3d74329Smrg func_arith_result=`expr "$@"` 641e3d74329Smrg } 642e3d74329Smrgfi 643e3d74329Smrg 644e3d74329Smrg 645e3d74329Smrg# func_basename FILE 646e3d74329Smrg# ------------------ 647e3d74329Smrg# Set func_basename_result to FILE with everything up to and including 648e3d74329Smrg# the last / stripped. 649e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 650e3d74329Smrg # If this shell supports suffix pattern removal, then use it to avoid 651e3d74329Smrg # forking. Hide the definitions single quotes in case the shell chokes 652e3d74329Smrg # on unsupported syntax... 653e3d74329Smrg _b='func_basename_result=${1##*/}' 654e3d74329Smrg _d='case $1 in 655e3d74329Smrg */*) func_dirname_result=${1%/*}$2 ;; 656e3d74329Smrg * ) func_dirname_result=$3 ;; 657e3d74329Smrg esac' 658e3d74329Smrg 659e3d74329Smrgelse 660e3d74329Smrg # ...otherwise fall back to using sed. 661e3d74329Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662e3d74329Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663e3d74329Smrg if test "X$func_dirname_result" = "X$1"; then 664e3d74329Smrg func_dirname_result=$3 665e3d74329Smrg else 666e3d74329Smrg func_append func_dirname_result "$2" 667e3d74329Smrg fi' 668e3d74329Smrgfi 669e3d74329Smrg 670e3d74329Smrgeval 'func_basename () 671e3d74329Smrg{ 672e3d74329Smrg $debug_cmd 673e3d74329Smrg 674e3d74329Smrg '"$_b"' 675e3d74329Smrg}' 676e3d74329Smrg 677e3d74329Smrg 678e3d74329Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679e3d74329Smrg# ------------------------------------------- 680e3d74329Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681e3d74329Smrg# otherwise set result to NONDIR_REPLACEMENT. 682e3d74329Smrgeval 'func_dirname () 683e3d74329Smrg{ 684e3d74329Smrg $debug_cmd 685e3d74329Smrg 686e3d74329Smrg '"$_d"' 687e3d74329Smrg}' 688e3d74329Smrg 689e3d74329Smrg 690e3d74329Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691e3d74329Smrg# -------------------------------------------------------- 692e3d74329Smrg# Perform func_basename and func_dirname in a single function 693e3d74329Smrg# call: 694e3d74329Smrg# dirname: Compute the dirname of FILE. If nonempty, 695e3d74329Smrg# add APPEND to the result, otherwise set result 696e3d74329Smrg# to NONDIR_REPLACEMENT. 697e3d74329Smrg# value returned in "$func_dirname_result" 698e3d74329Smrg# basename: Compute filename of FILE. 699e3d74329Smrg# value retuned in "$func_basename_result" 700e3d74329Smrg# For efficiency, we do not delegate to the functions above but instead 701e3d74329Smrg# duplicate the functionality here. 702e3d74329Smrgeval 'func_dirname_and_basename () 703e3d74329Smrg{ 704e3d74329Smrg $debug_cmd 705e3d74329Smrg 706e3d74329Smrg '"$_b"' 707e3d74329Smrg '"$_d"' 708e3d74329Smrg}' 709e3d74329Smrg 710e3d74329Smrg 711e3d74329Smrg# func_echo ARG... 712e3d74329Smrg# ---------------- 713e3d74329Smrg# Echo program name prefixed message. 714e3d74329Smrgfunc_echo () 715e3d74329Smrg{ 716e3d74329Smrg $debug_cmd 717e3d74329Smrg 718e3d74329Smrg _G_message=$* 719e3d74329Smrg 720e3d74329Smrg func_echo_IFS=$IFS 721e3d74329Smrg IFS=$nl 722e3d74329Smrg for _G_line in $_G_message; do 723e3d74329Smrg IFS=$func_echo_IFS 724e3d74329Smrg $ECHO "$progname: $_G_line" 725e3d74329Smrg done 726e3d74329Smrg IFS=$func_echo_IFS 727e3d74329Smrg} 728e3d74329Smrg 729e3d74329Smrg 730e3d74329Smrg# func_echo_all ARG... 731e3d74329Smrg# -------------------- 732e3d74329Smrg# Invoke $ECHO with all args, space-separated. 733e3d74329Smrgfunc_echo_all () 734e3d74329Smrg{ 735e3d74329Smrg $ECHO "$*" 736e3d74329Smrg} 737e3d74329Smrg 738e3d74329Smrg 739e3d74329Smrg# func_echo_infix_1 INFIX ARG... 740e3d74329Smrg# ------------------------------ 741e3d74329Smrg# Echo program name, followed by INFIX on the first line, with any 742e3d74329Smrg# additional lines not showing INFIX. 743e3d74329Smrgfunc_echo_infix_1 () 744e3d74329Smrg{ 745e3d74329Smrg $debug_cmd 746e3d74329Smrg 747e3d74329Smrg $require_term_colors 748e3d74329Smrg 749e3d74329Smrg _G_infix=$1; shift 750e3d74329Smrg _G_indent=$_G_infix 751e3d74329Smrg _G_prefix="$progname: $_G_infix: " 752e3d74329Smrg _G_message=$* 753e3d74329Smrg 754e3d74329Smrg # Strip color escape sequences before counting printable length 755e3d74329Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756e3d74329Smrg do 757e3d74329Smrg test -n "$_G_tc" && { 758e3d74329Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759e3d74329Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760e3d74329Smrg } 761e3d74329Smrg done 762e3d74329Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763e3d74329Smrg 764e3d74329Smrg func_echo_infix_1_IFS=$IFS 765e3d74329Smrg IFS=$nl 766e3d74329Smrg for _G_line in $_G_message; do 767e3d74329Smrg IFS=$func_echo_infix_1_IFS 768e3d74329Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769e3d74329Smrg _G_prefix=$_G_indent 770e3d74329Smrg done 771e3d74329Smrg IFS=$func_echo_infix_1_IFS 772e3d74329Smrg} 773e3d74329Smrg 774e3d74329Smrg 775e3d74329Smrg# func_error ARG... 776e3d74329Smrg# ----------------- 777e3d74329Smrg# Echo program name prefixed message to standard error. 778e3d74329Smrgfunc_error () 779e3d74329Smrg{ 780e3d74329Smrg $debug_cmd 781e3d74329Smrg 782e3d74329Smrg $require_term_colors 783e3d74329Smrg 784e3d74329Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785e3d74329Smrg} 786e3d74329Smrg 787e3d74329Smrg 788e3d74329Smrg# func_fatal_error ARG... 789e3d74329Smrg# ----------------------- 790e3d74329Smrg# Echo program name prefixed message to standard error, and exit. 791e3d74329Smrgfunc_fatal_error () 792e3d74329Smrg{ 793e3d74329Smrg $debug_cmd 794e3d74329Smrg 795e3d74329Smrg func_error "$*" 796e3d74329Smrg exit $EXIT_FAILURE 797e3d74329Smrg} 798e3d74329Smrg 799e3d74329Smrg 800e3d74329Smrg# func_grep EXPRESSION FILENAME 801e3d74329Smrg# ----------------------------- 80242a55b46Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 80342a55b46Smrgfunc_grep () 80442a55b46Smrg{ 805e3d74329Smrg $debug_cmd 806e3d74329Smrg 80742a55b46Smrg $GREP "$1" "$2" >/dev/null 2>&1 80842a55b46Smrg} 80942a55b46Smrg 81042a55b46Smrg 811e3d74329Smrg# func_len STRING 812e3d74329Smrg# --------------- 813e3d74329Smrg# Set func_len_result to the length of STRING. STRING may not 814e3d74329Smrg# start with a hyphen. 815e3d74329Smrg test -z "$_G_HAVE_XSI_OPS" \ 816e3d74329Smrg && (eval 'x=a/b/c; 817e3d74329Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818e3d74329Smrg && _G_HAVE_XSI_OPS=yes 819e3d74329Smrg 820e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 821e3d74329Smrg eval 'func_len () 822e3d74329Smrg { 823e3d74329Smrg $debug_cmd 824e3d74329Smrg 825e3d74329Smrg func_len_result=${#1} 826e3d74329Smrg }' 827e3d74329Smrgelse 828e3d74329Smrg func_len () 829e3d74329Smrg { 830e3d74329Smrg $debug_cmd 831e3d74329Smrg 832e3d74329Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833e3d74329Smrg } 834e3d74329Smrgfi 835e3d74329Smrg 836e3d74329Smrg 837e3d74329Smrg# func_mkdir_p DIRECTORY-PATH 838e3d74329Smrg# --------------------------- 83942a55b46Smrg# Make sure the entire path to DIRECTORY-PATH is available. 84042a55b46Smrgfunc_mkdir_p () 84142a55b46Smrg{ 842e3d74329Smrg $debug_cmd 843e3d74329Smrg 844e3d74329Smrg _G_directory_path=$1 845e3d74329Smrg _G_dir_list= 84642a55b46Smrg 847e3d74329Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84842a55b46Smrg 849e3d74329Smrg # Protect directory names starting with '-' 850e3d74329Smrg case $_G_directory_path in 851e3d74329Smrg -*) _G_directory_path=./$_G_directory_path ;; 85242a55b46Smrg esac 85342a55b46Smrg 85442a55b46Smrg # While some portion of DIR does not yet exist... 855e3d74329Smrg while test ! -d "$_G_directory_path"; do 85642a55b46Smrg # ...make a list in topmost first order. Use a colon delimited 85742a55b46Smrg # list incase some portion of path contains whitespace. 858e3d74329Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 85942a55b46Smrg 86042a55b46Smrg # If the last portion added has no slash in it, the list is done 861e3d74329Smrg case $_G_directory_path in */*) ;; *) break ;; esac 86242a55b46Smrg 86342a55b46Smrg # ...otherwise throw away the child directory and loop 864e3d74329Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 86542a55b46Smrg done 866e3d74329Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 86742a55b46Smrg 868e3d74329Smrg func_mkdir_p_IFS=$IFS; IFS=: 869e3d74329Smrg for _G_dir in $_G_dir_list; do 870e3d74329Smrg IFS=$func_mkdir_p_IFS 871e3d74329Smrg # mkdir can fail with a 'File exist' error if two processes 87242a55b46Smrg # try to create one of the directories concurrently. Don't 87342a55b46Smrg # stop in that case! 874e3d74329Smrg $MKDIR "$_G_dir" 2>/dev/null || : 87542a55b46Smrg done 876e3d74329Smrg IFS=$func_mkdir_p_IFS 87742a55b46Smrg 87842a55b46Smrg # Bail out if we (or some other process) failed to create a directory. 879e3d74329Smrg test -d "$_G_directory_path" || \ 880e3d74329Smrg func_fatal_error "Failed to create '$1'" 88142a55b46Smrg fi 88242a55b46Smrg} 883c582b7e3Smrg 884c582b7e3Smrg 885e3d74329Smrg# func_mktempdir [BASENAME] 886e3d74329Smrg# ------------------------- 887c582b7e3Smrg# Make a temporary directory that won't clash with other running 888c582b7e3Smrg# libtool processes, and avoids race conditions if possible. If 889e3d74329Smrg# given, BASENAME is the basename for that directory. 890c582b7e3Smrgfunc_mktempdir () 891c582b7e3Smrg{ 892e3d74329Smrg $debug_cmd 893e3d74329Smrg 894e3d74329Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895c582b7e3Smrg 896e3d74329Smrg if test : = "$opt_dry_run"; then 897c582b7e3Smrg # Return a directory name, but don't create it in dry-run mode 898e3d74329Smrg _G_tmpdir=$_G_template-$$ 899c582b7e3Smrg else 900c582b7e3Smrg 901c582b7e3Smrg # If mktemp works, use that first and foremost 902e3d74329Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903c582b7e3Smrg 904e3d74329Smrg if test ! -d "$_G_tmpdir"; then 90542a55b46Smrg # Failing that, at least try and use $RANDOM to avoid a race 906e3d74329Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907c582b7e3Smrg 908e3d74329Smrg func_mktempdir_umask=`umask` 90942a55b46Smrg umask 0077 910e3d74329Smrg $MKDIR "$_G_tmpdir" 911e3d74329Smrg umask $func_mktempdir_umask 912c582b7e3Smrg fi 913c582b7e3Smrg 914c582b7e3Smrg # If we're not in dry-run mode, bomb out on failure 915e3d74329Smrg test -d "$_G_tmpdir" || \ 916e3d74329Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917c582b7e3Smrg fi 918c582b7e3Smrg 919e3d74329Smrg $ECHO "$_G_tmpdir" 920c582b7e3Smrg} 921c582b7e3Smrg 922c582b7e3Smrg 923e3d74329Smrg# func_normal_abspath PATH 924e3d74329Smrg# ------------------------ 925e3d74329Smrg# Remove doubled-up and trailing slashes, "." path components, 926e3d74329Smrg# and cancel out any ".." path components in PATH after making 927e3d74329Smrg# it an absolute path. 928e3d74329Smrgfunc_normal_abspath () 929c582b7e3Smrg{ 930e3d74329Smrg $debug_cmd 93142a55b46Smrg 932e3d74329Smrg # These SED scripts presuppose an absolute path with a trailing slash. 933e3d74329Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934e3d74329Smrg _G_pathcdr='s|^/[^/]*||' 935e3d74329Smrg _G_removedotparts=':dotsl 936e3d74329Smrg s|/\./|/|g 937e3d74329Smrg t dotsl 938e3d74329Smrg s|/\.$|/|' 939e3d74329Smrg _G_collapseslashes='s|/\{1,\}|/|g' 940e3d74329Smrg _G_finalslash='s|/*$|/|' 941e3d74329Smrg 942e3d74329Smrg # Start from root dir and reassemble the path. 943e3d74329Smrg func_normal_abspath_result= 944e3d74329Smrg func_normal_abspath_tpath=$1 945e3d74329Smrg func_normal_abspath_altnamespace= 946e3d74329Smrg case $func_normal_abspath_tpath in 947e3d74329Smrg "") 948e3d74329Smrg # Empty path, that just means $cwd. 949e3d74329Smrg func_stripname '' '/' "`pwd`" 950e3d74329Smrg func_normal_abspath_result=$func_stripname_result 951e3d74329Smrg return 952e3d74329Smrg ;; 953e3d74329Smrg # The next three entries are used to spot a run of precisely 954e3d74329Smrg # two leading slashes without using negated character classes; 955e3d74329Smrg # we take advantage of case's first-match behaviour. 956e3d74329Smrg ///*) 957e3d74329Smrg # Unusual form of absolute path, do nothing. 958e3d74329Smrg ;; 959e3d74329Smrg //*) 960e3d74329Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961e3d74329Smrg # and for example Cygwin uses it to access remote file shares 962e3d74329Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 963e3d74329Smrg func_normal_abspath_altnamespace=/ 964e3d74329Smrg ;; 965e3d74329Smrg /*) 966e3d74329Smrg # Absolute path, do nothing. 96742a55b46Smrg ;; 96842a55b46Smrg *) 969e3d74329Smrg # Relative path, prepend $cwd. 970e3d74329Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971e3d74329Smrg ;; 97242a55b46Smrg esac 973e3d74329Smrg 974e3d74329Smrg # Cancel out all the simple stuff to save iterations. We also want 975e3d74329Smrg # the path to end with a slash for ease of parsing, so make sure 976e3d74329Smrg # there is one (and only one) here. 977e3d74329Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978e3d74329Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979e3d74329Smrg while :; do 980e3d74329Smrg # Processed it all yet? 981e3d74329Smrg if test / = "$func_normal_abspath_tpath"; then 982e3d74329Smrg # If we ascended to the root using ".." the result may be empty now. 983e3d74329Smrg if test -z "$func_normal_abspath_result"; then 984e3d74329Smrg func_normal_abspath_result=/ 985e3d74329Smrg fi 986e3d74329Smrg break 987e3d74329Smrg fi 988e3d74329Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989e3d74329Smrg -e "$_G_pathcar"` 990e3d74329Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991e3d74329Smrg -e "$_G_pathcdr"` 992e3d74329Smrg # Figure out what to do with it 993e3d74329Smrg case $func_normal_abspath_tcomponent in 994e3d74329Smrg "") 995e3d74329Smrg # Trailing empty path component, ignore it. 996e3d74329Smrg ;; 997e3d74329Smrg ..) 998e3d74329Smrg # Parent dir; strip last assembled component from result. 999e3d74329Smrg func_dirname "$func_normal_abspath_result" 1000e3d74329Smrg func_normal_abspath_result=$func_dirname_result 1001e3d74329Smrg ;; 1002e3d74329Smrg *) 1003e3d74329Smrg # Actual path component, append it. 1004e3d74329Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005e3d74329Smrg ;; 1006e3d74329Smrg esac 1007e3d74329Smrg done 1008e3d74329Smrg # Restore leading double-slash if one was found on entry. 1009e3d74329Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010e3d74329Smrg} 1011e3d74329Smrg 1012e3d74329Smrg 1013e3d74329Smrg# func_notquiet ARG... 1014e3d74329Smrg# -------------------- 1015e3d74329Smrg# Echo program name prefixed message only when not in quiet mode. 1016e3d74329Smrgfunc_notquiet () 1017e3d74329Smrg{ 1018e3d74329Smrg $debug_cmd 1019e3d74329Smrg 1020e3d74329Smrg $opt_quiet || func_echo ${1+"$@"} 1021e3d74329Smrg 1022e3d74329Smrg # A bug in bash halts the script if the last line of a function 1023e3d74329Smrg # fails when set -e is in force, so we need another command to 1024e3d74329Smrg # work around that: 1025e3d74329Smrg : 1026e3d74329Smrg} 1027e3d74329Smrg 1028e3d74329Smrg 1029e3d74329Smrg# func_relative_path SRCDIR DSTDIR 1030e3d74329Smrg# -------------------------------- 1031e3d74329Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032e3d74329Smrgfunc_relative_path () 1033e3d74329Smrg{ 1034e3d74329Smrg $debug_cmd 1035e3d74329Smrg 1036e3d74329Smrg func_relative_path_result= 1037e3d74329Smrg func_normal_abspath "$1" 1038e3d74329Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1039e3d74329Smrg func_normal_abspath "$2" 1040e3d74329Smrg func_relative_path_tbindir=$func_normal_abspath_result 1041e3d74329Smrg 1042e3d74329Smrg # Ascend the tree starting from libdir 1043e3d74329Smrg while :; do 1044e3d74329Smrg # check if we have found a prefix of bindir 1045e3d74329Smrg case $func_relative_path_tbindir in 1046e3d74329Smrg $func_relative_path_tlibdir) 1047e3d74329Smrg # found an exact match 1048e3d74329Smrg func_relative_path_tcancelled= 1049e3d74329Smrg break 1050e3d74329Smrg ;; 1051e3d74329Smrg $func_relative_path_tlibdir*) 1052e3d74329Smrg # found a matching prefix 1053e3d74329Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054e3d74329Smrg func_relative_path_tcancelled=$func_stripname_result 1055e3d74329Smrg if test -z "$func_relative_path_result"; then 1056e3d74329Smrg func_relative_path_result=. 1057e3d74329Smrg fi 1058e3d74329Smrg break 1059e3d74329Smrg ;; 1060e3d74329Smrg *) 1061e3d74329Smrg func_dirname $func_relative_path_tlibdir 1062e3d74329Smrg func_relative_path_tlibdir=$func_dirname_result 1063e3d74329Smrg if test -z "$func_relative_path_tlibdir"; then 1064e3d74329Smrg # Have to descend all the way to the root! 1065e3d74329Smrg func_relative_path_result=../$func_relative_path_result 1066e3d74329Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067e3d74329Smrg break 1068e3d74329Smrg fi 1069e3d74329Smrg func_relative_path_result=../$func_relative_path_result 1070e3d74329Smrg ;; 1071e3d74329Smrg esac 1072e3d74329Smrg done 1073e3d74329Smrg 1074e3d74329Smrg # Now calculate path; take care to avoid doubling-up slashes. 1075e3d74329Smrg func_stripname '' '/' "$func_relative_path_result" 1076e3d74329Smrg func_relative_path_result=$func_stripname_result 1077e3d74329Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078e3d74329Smrg if test -n "$func_stripname_result"; then 1079e3d74329Smrg func_append func_relative_path_result "/$func_stripname_result" 1080e3d74329Smrg fi 1081e3d74329Smrg 1082e3d74329Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083e3d74329Smrg if test -n "$func_relative_path_result"; then 1084e3d74329Smrg func_stripname './' '' "$func_relative_path_result" 1085e3d74329Smrg func_relative_path_result=$func_stripname_result 1086e3d74329Smrg fi 1087e3d74329Smrg 1088e3d74329Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089e3d74329Smrg 1090e3d74329Smrg : 109142a55b46Smrg} 109242a55b46Smrg 109342a55b46Smrg 1094e3d74329Smrg# func_quote_for_eval ARG... 1095e3d74329Smrg# -------------------------- 1096e3d74329Smrg# Aesthetically quote ARGs to be evaled later. 1097e3d74329Smrg# This function returns two values: 1098e3d74329Smrg# i) func_quote_for_eval_result 1099e3d74329Smrg# double-quoted, suitable for a subsequent eval 1100e3d74329Smrg# ii) func_quote_for_eval_unquoted_result 1101e3d74329Smrg# has all characters that are still active within double 1102e3d74329Smrg# quotes backslashified. 1103e3d74329Smrgfunc_quote_for_eval () 1104e3d74329Smrg{ 1105e3d74329Smrg $debug_cmd 1106e3d74329Smrg 1107e3d74329Smrg func_quote_for_eval_unquoted_result= 1108e3d74329Smrg func_quote_for_eval_result= 1109e3d74329Smrg while test 0 -lt $#; do 1110e3d74329Smrg case $1 in 1111e3d74329Smrg *[\\\`\"\$]*) 1112e3d74329Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113e3d74329Smrg *) 1114e3d74329Smrg _G_unquoted_arg=$1 ;; 1115e3d74329Smrg esac 1116e3d74329Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 1117e3d74329Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118e3d74329Smrg else 1119e3d74329Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120e3d74329Smrg fi 1121e3d74329Smrg 1122e3d74329Smrg case $_G_unquoted_arg in 1123e3d74329Smrg # Double-quote args containing shell metacharacters to delay 1124e3d74329Smrg # word splitting, command substitution and variable expansion 1125e3d74329Smrg # for a subsequent eval. 1126e3d74329Smrg # Many Bourne shells cannot handle close brackets correctly 1127e3d74329Smrg # in scan sets, so we specify it separately. 1128e3d74329Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129e3d74329Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130e3d74329Smrg ;; 1131e3d74329Smrg *) 1132e3d74329Smrg _G_quoted_arg=$_G_unquoted_arg 1133e3d74329Smrg ;; 1134e3d74329Smrg esac 1135e3d74329Smrg 1136e3d74329Smrg if test -n "$func_quote_for_eval_result"; then 1137e3d74329Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1138e3d74329Smrg else 1139e3d74329Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1140e3d74329Smrg fi 1141e3d74329Smrg shift 1142e3d74329Smrg done 1143e3d74329Smrg} 1144e3d74329Smrg 1145e3d74329Smrg 1146e3d74329Smrg# func_quote_for_expand ARG 1147e3d74329Smrg# ------------------------- 114842a55b46Smrg# Aesthetically quote ARG to be evaled later; same as above, 114942a55b46Smrg# but do not quote variable references. 115042a55b46Smrgfunc_quote_for_expand () 115142a55b46Smrg{ 1152e3d74329Smrg $debug_cmd 1153e3d74329Smrg 115442a55b46Smrg case $1 in 115542a55b46Smrg *[\\\`\"]*) 1156e3d74329Smrg _G_arg=`$ECHO "$1" | $SED \ 1157e3d74329Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115842a55b46Smrg *) 1159e3d74329Smrg _G_arg=$1 ;; 116042a55b46Smrg esac 116142a55b46Smrg 1162e3d74329Smrg case $_G_arg in 116342a55b46Smrg # Double-quote args containing shell metacharacters to delay 116442a55b46Smrg # word splitting and command substitution for a subsequent eval. 116542a55b46Smrg # Many Bourne shells cannot handle close brackets correctly 116642a55b46Smrg # in scan sets, so we specify it separately. 116742a55b46Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168e3d74329Smrg _G_arg=\"$_G_arg\" 116942a55b46Smrg ;; 117042a55b46Smrg esac 117142a55b46Smrg 1172e3d74329Smrg func_quote_for_expand_result=$_G_arg 1173e3d74329Smrg} 1174e3d74329Smrg 1175e3d74329Smrg 1176e3d74329Smrg# func_stripname PREFIX SUFFIX NAME 1177e3d74329Smrg# --------------------------------- 1178e3d74329Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179e3d74329Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1180e3d74329Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181e3d74329Smrg# dot (in which case that matches only a dot). 1182e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183e3d74329Smrg eval 'func_stripname () 1184e3d74329Smrg { 1185e3d74329Smrg $debug_cmd 1186e3d74329Smrg 1187e3d74329Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188e3d74329Smrg # positional parameters, so assign one to ordinary variable first. 1189e3d74329Smrg func_stripname_result=$3 1190e3d74329Smrg func_stripname_result=${func_stripname_result#"$1"} 1191e3d74329Smrg func_stripname_result=${func_stripname_result%"$2"} 1192e3d74329Smrg }' 1193e3d74329Smrgelse 1194e3d74329Smrg func_stripname () 1195e3d74329Smrg { 1196e3d74329Smrg $debug_cmd 1197e3d74329Smrg 1198e3d74329Smrg case $2 in 1199e3d74329Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200e3d74329Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201e3d74329Smrg esac 1202e3d74329Smrg } 1203e3d74329Smrgfi 1204e3d74329Smrg 1205e3d74329Smrg 1206e3d74329Smrg# func_show_eval CMD [FAIL_EXP] 1207e3d74329Smrg# ----------------------------- 1208e3d74329Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209e3d74329Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210e3d74329Smrg# is given, then evaluate it. 1211e3d74329Smrgfunc_show_eval () 1212e3d74329Smrg{ 1213e3d74329Smrg $debug_cmd 1214e3d74329Smrg 1215e3d74329Smrg _G_cmd=$1 1216e3d74329Smrg _G_fail_exp=${2-':'} 1217e3d74329Smrg 1218e3d74329Smrg func_quote_for_expand "$_G_cmd" 1219e3d74329Smrg eval "func_notquiet $func_quote_for_expand_result" 1220e3d74329Smrg 1221e3d74329Smrg $opt_dry_run || { 1222e3d74329Smrg eval "$_G_cmd" 1223e3d74329Smrg _G_status=$? 1224e3d74329Smrg if test 0 -ne "$_G_status"; then 1225e3d74329Smrg eval "(exit $_G_status); $_G_fail_exp" 1226e3d74329Smrg fi 1227e3d74329Smrg } 1228e3d74329Smrg} 1229e3d74329Smrg 1230e3d74329Smrg 1231e3d74329Smrg# func_show_eval_locale CMD [FAIL_EXP] 1232e3d74329Smrg# ------------------------------------ 1233e3d74329Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234e3d74329Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235e3d74329Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1236e3d74329Smrgfunc_show_eval_locale () 1237e3d74329Smrg{ 1238e3d74329Smrg $debug_cmd 1239e3d74329Smrg 1240e3d74329Smrg _G_cmd=$1 1241e3d74329Smrg _G_fail_exp=${2-':'} 1242e3d74329Smrg 1243e3d74329Smrg $opt_quiet || { 1244e3d74329Smrg func_quote_for_expand "$_G_cmd" 1245e3d74329Smrg eval "func_echo $func_quote_for_expand_result" 1246e3d74329Smrg } 1247e3d74329Smrg 1248e3d74329Smrg $opt_dry_run || { 1249e3d74329Smrg eval "$_G_user_locale 1250e3d74329Smrg $_G_cmd" 1251e3d74329Smrg _G_status=$? 1252e3d74329Smrg eval "$_G_safe_locale" 1253e3d74329Smrg if test 0 -ne "$_G_status"; then 1254e3d74329Smrg eval "(exit $_G_status); $_G_fail_exp" 1255e3d74329Smrg fi 1256e3d74329Smrg } 1257e3d74329Smrg} 1258e3d74329Smrg 1259e3d74329Smrg 1260e3d74329Smrg# func_tr_sh 1261e3d74329Smrg# ---------- 1262e3d74329Smrg# Turn $1 into a string suitable for a shell variable name. 1263e3d74329Smrg# Result is stored in $func_tr_sh_result. All characters 1264e3d74329Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265e3d74329Smrg# if $1 begins with a digit, a '_' is prepended as well. 1266e3d74329Smrgfunc_tr_sh () 1267e3d74329Smrg{ 1268e3d74329Smrg $debug_cmd 1269e3d74329Smrg 1270e3d74329Smrg case $1 in 1271e3d74329Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1272e3d74329Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273e3d74329Smrg ;; 1274e3d74329Smrg * ) 1275e3d74329Smrg func_tr_sh_result=$1 1276e3d74329Smrg ;; 1277e3d74329Smrg esac 1278e3d74329Smrg} 1279e3d74329Smrg 1280e3d74329Smrg 1281e3d74329Smrg# func_verbose ARG... 1282e3d74329Smrg# ------------------- 1283e3d74329Smrg# Echo program name prefixed message in verbose mode only. 1284e3d74329Smrgfunc_verbose () 1285e3d74329Smrg{ 1286e3d74329Smrg $debug_cmd 1287e3d74329Smrg 1288e3d74329Smrg $opt_verbose && func_echo "$*" 1289e3d74329Smrg 1290e3d74329Smrg : 1291e3d74329Smrg} 1292e3d74329Smrg 1293e3d74329Smrg 1294e3d74329Smrg# func_warn_and_continue ARG... 1295e3d74329Smrg# ----------------------------- 1296e3d74329Smrg# Echo program name prefixed warning message to standard error. 1297e3d74329Smrgfunc_warn_and_continue () 1298e3d74329Smrg{ 1299e3d74329Smrg $debug_cmd 1300e3d74329Smrg 1301e3d74329Smrg $require_term_colors 1302e3d74329Smrg 1303e3d74329Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304e3d74329Smrg} 1305e3d74329Smrg 1306e3d74329Smrg 1307e3d74329Smrg# func_warning CATEGORY ARG... 1308e3d74329Smrg# ---------------------------- 1309e3d74329Smrg# Echo program name prefixed warning message to standard error. Warning 1310e3d74329Smrg# messages can be filtered according to CATEGORY, where this function 1311e3d74329Smrg# elides messages where CATEGORY is not listed in the global variable 1312e3d74329Smrg# 'opt_warning_types'. 1313e3d74329Smrgfunc_warning () 1314e3d74329Smrg{ 1315e3d74329Smrg $debug_cmd 1316e3d74329Smrg 1317e3d74329Smrg # CATEGORY must be in the warning_categories list! 1318e3d74329Smrg case " $warning_categories " in 1319e3d74329Smrg *" $1 "*) ;; 1320e3d74329Smrg *) func_internal_error "invalid warning category '$1'" ;; 1321e3d74329Smrg esac 1322e3d74329Smrg 1323e3d74329Smrg _G_category=$1 1324e3d74329Smrg shift 1325e3d74329Smrg 1326e3d74329Smrg case " $opt_warning_types " in 1327e3d74329Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328e3d74329Smrg esac 132942a55b46Smrg} 133042a55b46Smrg 133142a55b46Smrg 1332e3d74329Smrg# func_sort_ver VER1 VER2 1333e3d74329Smrg# ----------------------- 1334e3d74329Smrg# 'sort -V' is not generally available. 1335e3d74329Smrg# Note this deviates from the version comparison in automake 1336e3d74329Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337e3d74329Smrg# but this should suffice as we won't be specifying old 1338e3d74329Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1339e3d74329Smrg# If we did want full compatibility then we should probably 1340e3d74329Smrg# use m4_version_compare from autoconf. 1341e3d74329Smrgfunc_sort_ver () 1342e3d74329Smrg{ 1343e3d74329Smrg $debug_cmd 1344e3d74329Smrg 1345e3d74329Smrg printf '%s\n%s\n' "$1" "$2" \ 1346e3d74329Smrg | 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 1347e3d74329Smrg} 1348e3d74329Smrg 1349e3d74329Smrg# func_lt_ver PREV CURR 1350e3d74329Smrg# --------------------- 1351e3d74329Smrg# Return true if PREV and CURR are in the correct order according to 1352e3d74329Smrg# func_sort_ver, otherwise false. Use it like this: 1353e3d74329Smrg# 1354e3d74329Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355e3d74329Smrgfunc_lt_ver () 1356e3d74329Smrg{ 1357e3d74329Smrg $debug_cmd 1358e3d74329Smrg 1359e3d74329Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360e3d74329Smrg} 1361e3d74329Smrg 1362e3d74329Smrg 1363e3d74329Smrg# Local variables: 1364e3d74329Smrg# mode: shell-script 1365e3d74329Smrg# sh-indentation: 2 1366e3d74329Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367e3d74329Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368e3d74329Smrg# time-stamp-time-zone: "UTC" 1369e3d74329Smrg# End: 1370e3d74329Smrg#! /bin/sh 1371e3d74329Smrg 1372e3d74329Smrg# Set a version string for this script. 1373e3d74329Smrgscriptversion=2014-01-07.03; # UTC 1374e3d74329Smrg 1375e3d74329Smrg# A portable, pluggable option parser for Bourne shell. 1376e3d74329Smrg# Written by Gary V. Vaughan, 2010 1377e3d74329Smrg 1378e3d74329Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379e3d74329Smrg# This is free software; see the source for copying conditions. There is NO 1380e3d74329Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381e3d74329Smrg 1382e3d74329Smrg# This program is free software: you can redistribute it and/or modify 1383e3d74329Smrg# it under the terms of the GNU General Public License as published by 1384e3d74329Smrg# the Free Software Foundation, either version 3 of the License, or 1385e3d74329Smrg# (at your option) any later version. 1386e3d74329Smrg 1387e3d74329Smrg# This program is distributed in the hope that it will be useful, 1388e3d74329Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389e3d74329Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390e3d74329Smrg# GNU General Public License for more details. 1391e3d74329Smrg 1392e3d74329Smrg# You should have received a copy of the GNU General Public License 1393e3d74329Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394e3d74329Smrg 1395e3d74329Smrg# Please report bugs or propose patches to gary@gnu.org. 1396e3d74329Smrg 1397e3d74329Smrg 1398e3d74329Smrg## ------ ## 1399e3d74329Smrg## Usage. ## 1400e3d74329Smrg## ------ ## 1401e3d74329Smrg 1402e3d74329Smrg# This file is a library for parsing options in your shell scripts along 1403e3d74329Smrg# with assorted other useful supporting features that you can make use 1404e3d74329Smrg# of too. 1405e3d74329Smrg# 1406e3d74329Smrg# For the simplest scripts you might need only: 1407e3d74329Smrg# 1408e3d74329Smrg# #!/bin/sh 1409e3d74329Smrg# . relative/path/to/funclib.sh 1410e3d74329Smrg# . relative/path/to/options-parser 1411e3d74329Smrg# scriptversion=1.0 1412e3d74329Smrg# func_options ${1+"$@"} 1413e3d74329Smrg# eval set dummy "$func_options_result"; shift 1414e3d74329Smrg# ...rest of your script... 1415e3d74329Smrg# 1416e3d74329Smrg# In order for the '--version' option to work, you will need to have a 1417e3d74329Smrg# suitably formatted comment like the one at the top of this file 1418e3d74329Smrg# starting with '# Written by ' and ending with '# warranty; '. 1419e3d74329Smrg# 1420e3d74329Smrg# For '-h' and '--help' to work, you will also need a one line 1421e3d74329Smrg# description of your script's purpose in a comment directly above the 1422e3d74329Smrg# '# Written by ' line, like the one at the top of this file. 1423e3d74329Smrg# 1424e3d74329Smrg# The default options also support '--debug', which will turn on shell 1425e3d74329Smrg# execution tracing (see the comment above debug_cmd below for another 1426e3d74329Smrg# use), and '--verbose' and the func_verbose function to allow your script 1427e3d74329Smrg# to display verbose messages only when your user has specified 1428e3d74329Smrg# '--verbose'. 1429e3d74329Smrg# 1430e3d74329Smrg# After sourcing this file, you can plug processing for additional 1431e3d74329Smrg# options by amending the variables from the 'Configuration' section 1432e3d74329Smrg# below, and following the instructions in the 'Option parsing' 1433e3d74329Smrg# section further down. 1434e3d74329Smrg 1435e3d74329Smrg## -------------- ## 1436e3d74329Smrg## Configuration. ## 1437e3d74329Smrg## -------------- ## 1438e3d74329Smrg 1439e3d74329Smrg# You should override these variables in your script after sourcing this 1440e3d74329Smrg# file so that they reflect the customisations you have added to the 1441e3d74329Smrg# option parser. 1442e3d74329Smrg 1443e3d74329Smrg# The usage line for option parsing errors and the start of '-h' and 1444e3d74329Smrg# '--help' output messages. You can embed shell variables for delayed 1445e3d74329Smrg# expansion at the time the message is displayed, but you will need to 1446e3d74329Smrg# quote other shell meta-characters carefully to prevent them being 1447e3d74329Smrg# expanded when the contents are evaled. 1448e3d74329Smrgusage='$progpath [OPTION]...' 1449e3d74329Smrg 1450e3d74329Smrg# Short help message in response to '-h' and '--help'. Add to this or 1451e3d74329Smrg# override it after sourcing this library to reflect the full set of 1452e3d74329Smrg# options your script accepts. 1453e3d74329Smrgusage_message="\ 1454e3d74329Smrg --debug enable verbose shell tracing 1455e3d74329Smrg -W, --warnings=CATEGORY 1456e3d74329Smrg report the warnings falling in CATEGORY [all] 1457e3d74329Smrg -v, --verbose verbosely report processing 1458e3d74329Smrg --version print version information and exit 1459e3d74329Smrg -h, --help print short or long help message and exit 1460e3d74329Smrg" 1461e3d74329Smrg 1462e3d74329Smrg# Additional text appended to 'usage_message' in response to '--help'. 1463e3d74329Smrglong_help_message=" 1464e3d74329SmrgWarning categories include: 1465e3d74329Smrg 'all' show all warnings 1466e3d74329Smrg 'none' turn off all the warnings 1467e3d74329Smrg 'error' warnings are treated as fatal errors" 1468e3d74329Smrg 1469e3d74329Smrg# Help message printed before fatal option parsing errors. 1470e3d74329Smrgfatal_help="Try '\$progname --help' for more information." 1471e3d74329Smrg 1472e3d74329Smrg 1473e3d74329Smrg 1474e3d74329Smrg## ------------------------- ## 1475e3d74329Smrg## Hook function management. ## 1476e3d74329Smrg## ------------------------- ## 1477e3d74329Smrg 1478e3d74329Smrg# This section contains functions for adding, removing, and running hooks 1479e3d74329Smrg# to the main code. A hook is just a named list of of function, that can 1480e3d74329Smrg# be run in order later on. 1481e3d74329Smrg 1482e3d74329Smrg# func_hookable FUNC_NAME 1483e3d74329Smrg# ----------------------- 1484e3d74329Smrg# Declare that FUNC_NAME will run hooks added with 1485e3d74329Smrg# 'func_add_hook FUNC_NAME ...'. 1486e3d74329Smrgfunc_hookable () 1487e3d74329Smrg{ 1488e3d74329Smrg $debug_cmd 1489e3d74329Smrg 1490e3d74329Smrg func_append hookable_fns " $1" 1491e3d74329Smrg} 1492e3d74329Smrg 1493e3d74329Smrg 1494e3d74329Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1495e3d74329Smrg# --------------------------------- 1496e3d74329Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497e3d74329Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1498e3d74329Smrgfunc_add_hook () 1499e3d74329Smrg{ 1500e3d74329Smrg $debug_cmd 1501e3d74329Smrg 1502e3d74329Smrg case " $hookable_fns " in 1503e3d74329Smrg *" $1 "*) ;; 1504e3d74329Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505e3d74329Smrg esac 1506e3d74329Smrg 1507e3d74329Smrg eval func_append ${1}_hooks '" $2"' 1508e3d74329Smrg} 1509e3d74329Smrg 1510e3d74329Smrg 1511e3d74329Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512e3d74329Smrg# ------------------------------------ 1513e3d74329Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514e3d74329Smrgfunc_remove_hook () 1515e3d74329Smrg{ 1516e3d74329Smrg $debug_cmd 1517e3d74329Smrg 1518e3d74329Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519e3d74329Smrg} 1520e3d74329Smrg 1521e3d74329Smrg 1522e3d74329Smrg# func_run_hooks FUNC_NAME [ARG]... 1523e3d74329Smrg# --------------------------------- 1524e3d74329Smrg# Run all hook functions registered to FUNC_NAME. 1525e3d74329Smrg# It is assumed that the list of hook functions contains nothing more 1526e3d74329Smrg# than a whitespace-delimited list of legal shell function names, and 1527e3d74329Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1528e3d74329Smrg# whitespace. 1529e3d74329Smrgfunc_run_hooks () 1530e3d74329Smrg{ 1531e3d74329Smrg $debug_cmd 1532e3d74329Smrg 1533e3d74329Smrg case " $hookable_fns " in 1534e3d74329Smrg *" $1 "*) ;; 1535e3d74329Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536e3d74329Smrg esac 1537e3d74329Smrg 1538e3d74329Smrg eval _G_hook_fns=\$$1_hooks; shift 1539e3d74329Smrg 1540e3d74329Smrg for _G_hook in $_G_hook_fns; do 1541e3d74329Smrg eval $_G_hook '"$@"' 1542e3d74329Smrg 1543e3d74329Smrg # store returned options list back into positional 1544e3d74329Smrg # parameters for next 'cmd' execution. 1545e3d74329Smrg eval _G_hook_result=\$${_G_hook}_result 1546e3d74329Smrg eval set dummy "$_G_hook_result"; shift 1547e3d74329Smrg done 1548e3d74329Smrg 1549e3d74329Smrg func_quote_for_eval ${1+"$@"} 1550e3d74329Smrg func_run_hooks_result=$func_quote_for_eval_result 1551e3d74329Smrg} 1552e3d74329Smrg 1553e3d74329Smrg 1554e3d74329Smrg 1555e3d74329Smrg## --------------- ## 1556e3d74329Smrg## Option parsing. ## 1557e3d74329Smrg## --------------- ## 1558e3d74329Smrg 1559e3d74329Smrg# In order to add your own option parsing hooks, you must accept the 1560e3d74329Smrg# full positional parameter list in your hook function, remove any 1561e3d74329Smrg# options that you action, and then pass back the remaining unprocessed 1562e3d74329Smrg# options in '<hooked_function_name>_result', escaped suitably for 1563e3d74329Smrg# 'eval'. Like this: 1564e3d74329Smrg# 1565e3d74329Smrg# my_options_prep () 1566e3d74329Smrg# { 1567e3d74329Smrg# $debug_cmd 1568e3d74329Smrg# 1569e3d74329Smrg# # Extend the existing usage message. 1570e3d74329Smrg# usage_message=$usage_message' 1571e3d74329Smrg# -s, --silent don'\''t print informational messages 1572e3d74329Smrg# ' 1573e3d74329Smrg# 1574e3d74329Smrg# func_quote_for_eval ${1+"$@"} 1575e3d74329Smrg# my_options_prep_result=$func_quote_for_eval_result 1576e3d74329Smrg# } 1577e3d74329Smrg# func_add_hook func_options_prep my_options_prep 1578e3d74329Smrg# 1579e3d74329Smrg# 1580e3d74329Smrg# my_silent_option () 1581e3d74329Smrg# { 1582e3d74329Smrg# $debug_cmd 1583e3d74329Smrg# 1584e3d74329Smrg# # Note that for efficiency, we parse as many options as we can 1585e3d74329Smrg# # recognise in a loop before passing the remainder back to the 1586e3d74329Smrg# # caller on the first unrecognised argument we encounter. 1587e3d74329Smrg# while test $# -gt 0; do 1588e3d74329Smrg# opt=$1; shift 1589e3d74329Smrg# case $opt in 1590e3d74329Smrg# --silent|-s) opt_silent=: ;; 1591e3d74329Smrg# # Separate non-argument short options: 1592e3d74329Smrg# -s*) func_split_short_opt "$_G_opt" 1593e3d74329Smrg# set dummy "$func_split_short_opt_name" \ 1594e3d74329Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595e3d74329Smrg# shift 1596e3d74329Smrg# ;; 1597e3d74329Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598e3d74329Smrg# esac 1599e3d74329Smrg# done 1600e3d74329Smrg# 1601e3d74329Smrg# func_quote_for_eval ${1+"$@"} 1602e3d74329Smrg# my_silent_option_result=$func_quote_for_eval_result 1603e3d74329Smrg# } 1604e3d74329Smrg# func_add_hook func_parse_options my_silent_option 1605e3d74329Smrg# 1606e3d74329Smrg# 1607e3d74329Smrg# my_option_validation () 1608e3d74329Smrg# { 1609e3d74329Smrg# $debug_cmd 1610e3d74329Smrg# 1611e3d74329Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612e3d74329Smrg# '--silent' and '--verbose' options are mutually exclusive." 1613e3d74329Smrg# 1614e3d74329Smrg# func_quote_for_eval ${1+"$@"} 1615e3d74329Smrg# my_option_validation_result=$func_quote_for_eval_result 1616e3d74329Smrg# } 1617e3d74329Smrg# func_add_hook func_validate_options my_option_validation 1618e3d74329Smrg# 1619e3d74329Smrg# You'll alse need to manually amend $usage_message to reflect the extra 1620e3d74329Smrg# options you parse. It's preferable to append if you can, so that 1621e3d74329Smrg# multiple option parsing hooks can be added safely. 1622e3d74329Smrg 1623e3d74329Smrg 1624e3d74329Smrg# func_options [ARG]... 1625e3d74329Smrg# --------------------- 1626e3d74329Smrg# All the functions called inside func_options are hookable. See the 1627e3d74329Smrg# individual implementations for details. 1628e3d74329Smrgfunc_hookable func_options 1629e3d74329Smrgfunc_options () 163042a55b46Smrg{ 1631e3d74329Smrg $debug_cmd 163242a55b46Smrg 1633e3d74329Smrg func_options_prep ${1+"$@"} 1634e3d74329Smrg eval func_parse_options \ 1635e3d74329Smrg ${func_options_prep_result+"$func_options_prep_result"} 1636e3d74329Smrg eval func_validate_options \ 1637e3d74329Smrg ${func_parse_options_result+"$func_parse_options_result"} 163842a55b46Smrg 1639e3d74329Smrg eval func_run_hooks func_options \ 1640e3d74329Smrg ${func_validate_options_result+"$func_validate_options_result"} 1641e3d74329Smrg 1642e3d74329Smrg # save modified positional parameters for caller 1643e3d74329Smrg func_options_result=$func_run_hooks_result 164442a55b46Smrg} 164542a55b46Smrg 164642a55b46Smrg 1647e3d74329Smrg# func_options_prep [ARG]... 1648e3d74329Smrg# -------------------------- 1649e3d74329Smrg# All initialisations required before starting the option parse loop. 1650e3d74329Smrg# Note that when calling hook functions, we pass through the list of 1651e3d74329Smrg# positional parameters. If a hook function modifies that list, and 1652e3d74329Smrg# needs to propogate that back to rest of this script, then the complete 1653e3d74329Smrg# modified list must be put in 'func_run_hooks_result' before 1654e3d74329Smrg# returning. 1655e3d74329Smrgfunc_hookable func_options_prep 1656e3d74329Smrgfunc_options_prep () 165742a55b46Smrg{ 1658e3d74329Smrg $debug_cmd 165942a55b46Smrg 1660e3d74329Smrg # Option defaults: 1661e3d74329Smrg opt_verbose=false 1662e3d74329Smrg opt_warning_types= 166342a55b46Smrg 1664e3d74329Smrg func_run_hooks func_options_prep ${1+"$@"} 1665e3d74329Smrg 1666e3d74329Smrg # save modified positional parameters for caller 1667e3d74329Smrg func_options_prep_result=$func_run_hooks_result 166842a55b46Smrg} 166942a55b46Smrg 1670e3d74329Smrg 1671e3d74329Smrg# func_parse_options [ARG]... 1672e3d74329Smrg# --------------------------- 1673e3d74329Smrg# The main option parsing loop. 1674e3d74329Smrgfunc_hookable func_parse_options 1675e3d74329Smrgfunc_parse_options () 167642a55b46Smrg{ 1677e3d74329Smrg $debug_cmd 1678e3d74329Smrg 1679e3d74329Smrg func_parse_options_result= 1680e3d74329Smrg 1681e3d74329Smrg # this just eases exit handling 1682e3d74329Smrg while test $# -gt 0; do 1683e3d74329Smrg # Defer to hook functions for initial option parsing, so they 1684e3d74329Smrg # get priority in the event of reusing an option name. 1685e3d74329Smrg func_run_hooks func_parse_options ${1+"$@"} 1686e3d74329Smrg 1687e3d74329Smrg # Adjust func_parse_options positional parameters to match 1688e3d74329Smrg eval set dummy "$func_run_hooks_result"; shift 1689e3d74329Smrg 1690e3d74329Smrg # Break out of the loop if we already parsed every option. 1691e3d74329Smrg test $# -gt 0 || break 1692e3d74329Smrg 1693e3d74329Smrg _G_opt=$1 1694e3d74329Smrg shift 1695e3d74329Smrg case $_G_opt in 1696e3d74329Smrg --debug|-x) debug_cmd='set -x' 1697e3d74329Smrg func_echo "enabling shell trace mode" 1698e3d74329Smrg $debug_cmd 1699e3d74329Smrg ;; 1700e3d74329Smrg 1701e3d74329Smrg --no-warnings|--no-warning|--no-warn) 1702e3d74329Smrg set dummy --warnings none ${1+"$@"} 1703e3d74329Smrg shift 1704e3d74329Smrg ;; 1705e3d74329Smrg 1706e3d74329Smrg --warnings|--warning|-W) 1707e3d74329Smrg test $# = 0 && func_missing_arg $_G_opt && break 1708e3d74329Smrg case " $warning_categories $1" in 1709e3d74329Smrg *" $1 "*) 1710e3d74329Smrg # trailing space prevents matching last $1 above 1711e3d74329Smrg func_append_uniq opt_warning_types " $1" 1712e3d74329Smrg ;; 1713e3d74329Smrg *all) 1714e3d74329Smrg opt_warning_types=$warning_categories 1715e3d74329Smrg ;; 1716e3d74329Smrg *none) 1717e3d74329Smrg opt_warning_types=none 1718e3d74329Smrg warning_func=: 1719e3d74329Smrg ;; 1720e3d74329Smrg *error) 1721e3d74329Smrg opt_warning_types=$warning_categories 1722e3d74329Smrg warning_func=func_fatal_error 1723e3d74329Smrg ;; 1724e3d74329Smrg *) 1725e3d74329Smrg func_fatal_error \ 1726e3d74329Smrg "unsupported warning category: '$1'" 1727e3d74329Smrg ;; 1728e3d74329Smrg esac 1729e3d74329Smrg shift 1730e3d74329Smrg ;; 1731e3d74329Smrg 1732e3d74329Smrg --verbose|-v) opt_verbose=: ;; 1733e3d74329Smrg --version) func_version ;; 1734e3d74329Smrg -\?|-h) func_usage ;; 1735e3d74329Smrg --help) func_help ;; 1736e3d74329Smrg 1737e3d74329Smrg # Separate optargs to long options (plugins may need this): 1738e3d74329Smrg --*=*) func_split_equals "$_G_opt" 1739e3d74329Smrg set dummy "$func_split_equals_lhs" \ 1740e3d74329Smrg "$func_split_equals_rhs" ${1+"$@"} 1741e3d74329Smrg shift 1742e3d74329Smrg ;; 1743e3d74329Smrg 1744e3d74329Smrg # Separate optargs to short options: 1745e3d74329Smrg -W*) 1746e3d74329Smrg func_split_short_opt "$_G_opt" 1747e3d74329Smrg set dummy "$func_split_short_opt_name" \ 1748e3d74329Smrg "$func_split_short_opt_arg" ${1+"$@"} 1749e3d74329Smrg shift 1750e3d74329Smrg ;; 1751e3d74329Smrg 1752e3d74329Smrg # Separate non-argument short options: 1753e3d74329Smrg -\?*|-h*|-v*|-x*) 1754e3d74329Smrg func_split_short_opt "$_G_opt" 1755e3d74329Smrg set dummy "$func_split_short_opt_name" \ 1756e3d74329Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1757e3d74329Smrg shift 1758e3d74329Smrg ;; 1759e3d74329Smrg 1760e3d74329Smrg --) break ;; 1761e3d74329Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762e3d74329Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763e3d74329Smrg esac 1764e3d74329Smrg done 1765e3d74329Smrg 1766e3d74329Smrg # save modified positional parameters for caller 1767e3d74329Smrg func_quote_for_eval ${1+"$@"} 1768e3d74329Smrg func_parse_options_result=$func_quote_for_eval_result 1769c582b7e3Smrg} 1770c582b7e3Smrg 1771c582b7e3Smrg 1772e3d74329Smrg# func_validate_options [ARG]... 1773e3d74329Smrg# ------------------------------ 1774e3d74329Smrg# Perform any sanity checks on option settings and/or unconsumed 1775e3d74329Smrg# arguments. 1776e3d74329Smrgfunc_hookable func_validate_options 1777e3d74329Smrgfunc_validate_options () 1778c582b7e3Smrg{ 1779e3d74329Smrg $debug_cmd 178042a55b46Smrg 1781e3d74329Smrg # Display all warnings if -W was not given. 1782e3d74329Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783e3d74329Smrg 1784e3d74329Smrg func_run_hooks func_validate_options ${1+"$@"} 1785e3d74329Smrg 1786e3d74329Smrg # Bail if the options were screwed! 1787e3d74329Smrg $exit_cmd $EXIT_FAILURE 1788e3d74329Smrg 1789e3d74329Smrg # save modified positional parameters for caller 1790e3d74329Smrg func_validate_options_result=$func_run_hooks_result 1791c582b7e3Smrg} 1792c582b7e3Smrg 1793e3d74329Smrg 1794e3d74329Smrg 1795e3d74329Smrg## ----------------- ## 1796e3d74329Smrg## Helper functions. ## 1797e3d74329Smrg## ----------------- ## 1798e3d74329Smrg 1799e3d74329Smrg# This section contains the helper functions used by the rest of the 1800e3d74329Smrg# hookable option parser framework in ascii-betical order. 1801e3d74329Smrg 1802e3d74329Smrg 1803e3d74329Smrg# func_fatal_help ARG... 1804e3d74329Smrg# ---------------------- 1805e3d74329Smrg# Echo program name prefixed message to standard error, followed by 1806e3d74329Smrg# a help hint, and exit. 1807e3d74329Smrgfunc_fatal_help () 1808c582b7e3Smrg{ 1809e3d74329Smrg $debug_cmd 181042a55b46Smrg 1811e3d74329Smrg eval \$ECHO \""Usage: $usage"\" 1812e3d74329Smrg eval \$ECHO \""$fatal_help"\" 1813e3d74329Smrg func_error ${1+"$@"} 1814e3d74329Smrg exit $EXIT_FAILURE 1815c582b7e3Smrg} 1816c582b7e3Smrg 1817e3d74329Smrg 1818e3d74329Smrg# func_help 1819e3d74329Smrg# --------- 1820e3d74329Smrg# Echo long help message to standard output and exit. 182142a55b46Smrgfunc_help () 1822c582b7e3Smrg{ 1823e3d74329Smrg $debug_cmd 1824e3d74329Smrg 1825e3d74329Smrg func_usage_message 1826e3d74329Smrg $ECHO "$long_help_message" 1827e3d74329Smrg exit 0 182842a55b46Smrg} 1829c582b7e3Smrg 1830e3d74329Smrg 1831e3d74329Smrg# func_missing_arg ARGNAME 1832e3d74329Smrg# ------------------------ 183342a55b46Smrg# Echo program name prefixed message to standard error and set global 183442a55b46Smrg# exit_cmd. 183542a55b46Smrgfunc_missing_arg () 183642a55b46Smrg{ 1837e3d74329Smrg $debug_cmd 1838c582b7e3Smrg 1839e3d74329Smrg func_error "Missing argument for '$1'." 184042a55b46Smrg exit_cmd=exit 1841c582b7e3Smrg} 1842c582b7e3Smrg 1843c582b7e3Smrg 1844e3d74329Smrg# func_split_equals STRING 1845e3d74329Smrg# ------------------------ 1846e3d74329Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847e3d74329Smrg# splitting STRING at the '=' sign. 1848e3d74329Smrgtest -z "$_G_HAVE_XSI_OPS" \ 1849e3d74329Smrg && (eval 'x=a/b/c; 1850e3d74329Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851e3d74329Smrg && _G_HAVE_XSI_OPS=yes 1852e3d74329Smrg 1853e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS" 1854e3d74329Smrgthen 1855e3d74329Smrg # This is an XSI compatible shell, allowing a faster implementation... 1856e3d74329Smrg eval 'func_split_equals () 1857e3d74329Smrg { 1858e3d74329Smrg $debug_cmd 1859e3d74329Smrg 1860e3d74329Smrg func_split_equals_lhs=${1%%=*} 1861e3d74329Smrg func_split_equals_rhs=${1#*=} 1862e3d74329Smrg test "x$func_split_equals_lhs" = "x$1" \ 1863e3d74329Smrg && func_split_equals_rhs= 1864e3d74329Smrg }' 1865e3d74329Smrgelse 1866e3d74329Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867e3d74329Smrg func_split_equals () 1868e3d74329Smrg { 1869e3d74329Smrg $debug_cmd 1870e3d74329Smrg 1871e3d74329Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872e3d74329Smrg func_split_equals_rhs= 1873e3d74329Smrg test "x$func_split_equals_lhs" = "x$1" \ 1874e3d74329Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875e3d74329Smrg } 1876e3d74329Smrgfi #func_split_equals 1877e3d74329Smrg 1878e3d74329Smrg 1879e3d74329Smrg# func_split_short_opt SHORTOPT 1880e3d74329Smrg# ----------------------------- 188142a55b46Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 188242a55b46Smrg# variables after splitting SHORTOPT after the 2nd character. 1883e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS" 1884e3d74329Smrgthen 1885e3d74329Smrg # This is an XSI compatible shell, allowing a faster implementation... 1886e3d74329Smrg eval 'func_split_short_opt () 1887e3d74329Smrg { 1888e3d74329Smrg $debug_cmd 1889e3d74329Smrg 1890e3d74329Smrg func_split_short_opt_arg=${1#??} 1891e3d74329Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892e3d74329Smrg }' 1893e3d74329Smrgelse 1894e3d74329Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895e3d74329Smrg func_split_short_opt () 1896e3d74329Smrg { 1897e3d74329Smrg $debug_cmd 1898e3d74329Smrg 1899e3d74329Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900e3d74329Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901e3d74329Smrg } 1902e3d74329Smrgfi #func_split_short_opt 1903e3d74329Smrg 1904e3d74329Smrg 1905e3d74329Smrg# func_usage 1906e3d74329Smrg# ---------- 1907e3d74329Smrg# Echo short help message to standard output and exit. 1908e3d74329Smrgfunc_usage () 190942a55b46Smrg{ 1910e3d74329Smrg $debug_cmd 191142a55b46Smrg 1912e3d74329Smrg func_usage_message 1913e3d74329Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914e3d74329Smrg exit 0 1915e3d74329Smrg} 1916c582b7e3Smrg 1917c582b7e3Smrg 1918e3d74329Smrg# func_usage_message 1919e3d74329Smrg# ------------------ 1920e3d74329Smrg# Echo short help message to standard output. 1921e3d74329Smrgfunc_usage_message () 192242a55b46Smrg{ 1923e3d74329Smrg $debug_cmd 1924c582b7e3Smrg 1925e3d74329Smrg eval \$ECHO \""Usage: $usage"\" 1926e3d74329Smrg echo 1927e3d74329Smrg $SED -n 's|^# || 1928e3d74329Smrg /^Written by/{ 1929e3d74329Smrg x;p;x 1930e3d74329Smrg } 1931e3d74329Smrg h 1932e3d74329Smrg /^Written by/q' < "$progpath" 1933e3d74329Smrg echo 1934e3d74329Smrg eval \$ECHO \""$usage_message"\" 1935e3d74329Smrg} 1936c582b7e3Smrg 1937c582b7e3Smrg 1938e3d74329Smrg# func_version 1939e3d74329Smrg# ------------ 1940e3d74329Smrg# Echo version message to standard output and exit. 1941e3d74329Smrgfunc_version () 1942e3d74329Smrg{ 1943e3d74329Smrg $debug_cmd 1944c582b7e3Smrg 1945e3d74329Smrg printf '%s\n' "$progname $scriptversion" 1946e3d74329Smrg $SED -n ' 1947e3d74329Smrg /(C)/!b go 1948e3d74329Smrg :more 1949e3d74329Smrg /\./!{ 1950e3d74329Smrg N 1951e3d74329Smrg s|\n# | | 1952e3d74329Smrg b more 1953e3d74329Smrg } 1954e3d74329Smrg :go 1955e3d74329Smrg /^# Written by /,/# warranty; / { 1956e3d74329Smrg s|^# || 1957e3d74329Smrg s|^# *$|| 1958e3d74329Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959e3d74329Smrg p 1960e3d74329Smrg } 1961e3d74329Smrg /^# Written by / { 1962e3d74329Smrg s|^# || 1963e3d74329Smrg p 1964e3d74329Smrg } 1965e3d74329Smrg /^warranty; /q' < "$progpath" 1966c582b7e3Smrg 1967e3d74329Smrg exit $? 1968e3d74329Smrg} 1969c582b7e3Smrg 1970c582b7e3Smrg 1971e3d74329Smrg# Local variables: 1972e3d74329Smrg# mode: shell-script 1973e3d74329Smrg# sh-indentation: 2 1974e3d74329Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1975e3d74329Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976e3d74329Smrg# time-stamp-time-zone: "UTC" 1977e3d74329Smrg# End: 197842a55b46Smrg 1979e3d74329Smrg# Set a version string. 1980e3d74329Smrgscriptversion='(GNU libtool) 2.4.6' 198142a55b46Smrg 198242a55b46Smrg 1983e3d74329Smrg# func_echo ARG... 1984e3d74329Smrg# ---------------- 1985e3d74329Smrg# Libtool also displays the current mode in messages, so override 1986e3d74329Smrg# funclib.sh func_echo with this custom definition. 1987e3d74329Smrgfunc_echo () 198842a55b46Smrg{ 1989e3d74329Smrg $debug_cmd 199042a55b46Smrg 1991e3d74329Smrg _G_message=$* 1992e3d74329Smrg 1993e3d74329Smrg func_echo_IFS=$IFS 1994e3d74329Smrg IFS=$nl 1995e3d74329Smrg for _G_line in $_G_message; do 1996e3d74329Smrg IFS=$func_echo_IFS 1997e3d74329Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998e3d74329Smrg done 1999e3d74329Smrg IFS=$func_echo_IFS 2000e3d74329Smrg} 200142a55b46Smrg 200242a55b46Smrg 2003e3d74329Smrg# func_warning ARG... 2004e3d74329Smrg# ------------------- 2005e3d74329Smrg# Libtool warnings are not categorized, so override funclib.sh 2006e3d74329Smrg# func_warning with this simpler definition. 2007e3d74329Smrgfunc_warning () 200842a55b46Smrg{ 2009e3d74329Smrg $debug_cmd 2010e3d74329Smrg 2011e3d74329Smrg $warning_func ${1+"$@"} 2012e3d74329Smrg} 2013e3d74329Smrg 201442a55b46Smrg 2015e3d74329Smrg## ---------------- ## 2016e3d74329Smrg## Options parsing. ## 2017e3d74329Smrg## ---------------- ## 2018e3d74329Smrg 2019e3d74329Smrg# Hook in the functions to make sure our own options are parsed during 2020e3d74329Smrg# the option parsing loop. 2021e3d74329Smrg 2022e3d74329Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023e3d74329Smrg 2024e3d74329Smrg# Short help message in response to '-h'. 2025e3d74329Smrgusage_message="Options: 2026e3d74329Smrg --config show all configuration variables 2027e3d74329Smrg --debug enable verbose shell tracing 2028e3d74329Smrg -n, --dry-run display commands without modifying any files 2029e3d74329Smrg --features display basic configuration information and exit 2030e3d74329Smrg --mode=MODE use operation mode MODE 2031e3d74329Smrg --no-warnings equivalent to '-Wnone' 2032e3d74329Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2033e3d74329Smrg --quiet, --silent don't print informational messages 2034e3d74329Smrg --tag=TAG use configuration variables from tag TAG 2035e3d74329Smrg -v, --verbose print more informational messages than default 2036e3d74329Smrg --version print version information 2037e3d74329Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038e3d74329Smrg -h, --help, --help-all print short, long, or detailed help message 2039e3d74329Smrg" 204042a55b46Smrg 2041e3d74329Smrg# Additional text appended to 'usage_message' in response to '--help'. 2042e3d74329Smrgfunc_help () 204342a55b46Smrg{ 2044e3d74329Smrg $debug_cmd 2045e3d74329Smrg 2046e3d74329Smrg func_usage_message 2047e3d74329Smrg $ECHO "$long_help_message 2048e3d74329Smrg 2049e3d74329SmrgMODE must be one of the following: 2050e3d74329Smrg 2051e3d74329Smrg clean remove files from the build directory 2052e3d74329Smrg compile compile a source file into a libtool object 2053e3d74329Smrg execute automatically set library path, then run a program 2054e3d74329Smrg finish complete the installation of libtool libraries 2055e3d74329Smrg install install libraries or executables 2056e3d74329Smrg link create a library or an executable 2057e3d74329Smrg uninstall remove libraries from an installed directory 2058e3d74329Smrg 2059e3d74329SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060e3d74329Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061e3d74329SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062e3d74329Smrg 2063e3d74329SmrgWhen reporting a bug, please describe a test case to reproduce it and 2064e3d74329Smrginclude the following information: 2065e3d74329Smrg 2066e3d74329Smrg host-triplet: $host 2067e3d74329Smrg shell: $SHELL 2068e3d74329Smrg compiler: $LTCC 2069e3d74329Smrg compiler flags: $LTCFLAGS 2070e3d74329Smrg linker: $LD (gnu? $with_gnu_ld) 2071e3d74329Smrg version: $progname (GNU libtool) 2.4.6 2072e3d74329Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073e3d74329Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074e3d74329Smrg 2075e3d74329SmrgReport bugs to <bug-libtool@gnu.org>. 2076e3d74329SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077e3d74329SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078e3d74329Smrg exit 0 2079e3d74329Smrg} 208042a55b46Smrg 208142a55b46Smrg 2082e3d74329Smrg# func_lo2o OBJECT-NAME 2083e3d74329Smrg# --------------------- 2084e3d74329Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085e3d74329Smrg# object suffix. 208642a55b46Smrg 2087e3d74329Smrglo2o=s/\\.lo\$/.$objext/ 2088e3d74329Smrgo2lo=s/\\.$objext\$/.lo/ 208942a55b46Smrg 2090e3d74329Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091e3d74329Smrg eval 'func_lo2o () 2092e3d74329Smrg { 2093e3d74329Smrg case $1 in 2094e3d74329Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095e3d74329Smrg * ) func_lo2o_result=$1 ;; 2096e3d74329Smrg esac 2097e3d74329Smrg }' 2098e3d74329Smrg 2099e3d74329Smrg # func_xform LIBOBJ-OR-SOURCE 2100e3d74329Smrg # --------------------------- 2101e3d74329Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102e3d74329Smrg # suffix to a '.lo' libtool-object suffix. 2103e3d74329Smrg eval 'func_xform () 2104e3d74329Smrg { 2105e3d74329Smrg func_xform_result=${1%.*}.lo 2106e3d74329Smrg }' 2107e3d74329Smrgelse 2108e3d74329Smrg # ...otherwise fall back to using sed. 2109e3d74329Smrg func_lo2o () 2110e3d74329Smrg { 2111e3d74329Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112e3d74329Smrg } 2113e3d74329Smrg 2114e3d74329Smrg func_xform () 2115e3d74329Smrg { 2116e3d74329Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117e3d74329Smrg } 2118e3d74329Smrgfi 211942a55b46Smrg 212042a55b46Smrg 2121e3d74329Smrg# func_fatal_configuration ARG... 2122e3d74329Smrg# ------------------------------- 212342a55b46Smrg# Echo program name prefixed message to standard error, followed by 212442a55b46Smrg# a configuration failure hint, and exit. 212542a55b46Smrgfunc_fatal_configuration () 212642a55b46Smrg{ 2127e3d74329Smrg func__fatal_error ${1+"$@"} \ 2128e3d74329Smrg "See the $PACKAGE documentation for more information." \ 2129e3d74329Smrg "Fatal configuration error." 213042a55b46Smrg} 213142a55b46Smrg 213242a55b46Smrg 213342a55b46Smrg# func_config 2134e3d74329Smrg# ----------- 213542a55b46Smrg# Display the configuration for all the tags in this script. 213642a55b46Smrgfunc_config () 213742a55b46Smrg{ 213842a55b46Smrg re_begincf='^# ### BEGIN LIBTOOL' 213942a55b46Smrg re_endcf='^# ### END LIBTOOL' 214042a55b46Smrg 214142a55b46Smrg # Default configuration. 214242a55b46Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 214342a55b46Smrg 2144c582b7e3Smrg # Now print the configurations for the tags. 2145c582b7e3Smrg for tagname in $taglist; do 214642a55b46Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147c582b7e3Smrg done 2148c582b7e3Smrg 214942a55b46Smrg exit $? 215042a55b46Smrg} 2151c582b7e3Smrg 2152e3d74329Smrg 215342a55b46Smrg# func_features 2154e3d74329Smrg# ------------- 215542a55b46Smrg# Display the features supported by this script. 215642a55b46Smrgfunc_features () 215742a55b46Smrg{ 215842a55b46Smrg echo "host: $host" 2159e3d74329Smrg if test yes = "$build_libtool_libs"; then 216042a55b46Smrg echo "enable shared libraries" 2161c582b7e3Smrg else 216242a55b46Smrg echo "disable shared libraries" 2163c582b7e3Smrg fi 2164e3d74329Smrg if test yes = "$build_old_libs"; then 216542a55b46Smrg echo "enable static libraries" 2166c582b7e3Smrg else 216742a55b46Smrg echo "disable static libraries" 2168c582b7e3Smrg fi 2169c582b7e3Smrg 217042a55b46Smrg exit $? 217142a55b46Smrg} 2172c582b7e3Smrg 2173e3d74329Smrg 2174e3d74329Smrg# func_enable_tag TAGNAME 2175e3d74329Smrg# ----------------------- 217642a55b46Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 217742a55b46Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 217842a55b46Smrg# variable here. 217942a55b46Smrgfunc_enable_tag () 218042a55b46Smrg{ 2181e3d74329Smrg # Global variable: 2182e3d74329Smrg tagname=$1 2183c582b7e3Smrg 2184e3d74329Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185e3d74329Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186e3d74329Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187c582b7e3Smrg 2188e3d74329Smrg # Validate tagname. 2189e3d74329Smrg case $tagname in 2190e3d74329Smrg *[!-_A-Za-z0-9,/]*) 2191e3d74329Smrg func_fatal_error "invalid tag name: $tagname" 2192e3d74329Smrg ;; 2193e3d74329Smrg esac 2194c582b7e3Smrg 2195e3d74329Smrg # Don't test for the "default" C tag, as we know it's 2196e3d74329Smrg # there but not specially marked. 2197e3d74329Smrg case $tagname in 2198e3d74329Smrg CC) ;; 219942a55b46Smrg *) 2200e3d74329Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201e3d74329Smrg taglist="$taglist $tagname" 2202e3d74329Smrg 2203e3d74329Smrg # Evaluate the configuration. Be careful to quote the path 2204e3d74329Smrg # and the sed script, to avoid splitting on whitespace, but 2205e3d74329Smrg # also don't use non-portable quotes within backquotes within 2206e3d74329Smrg # quotes we have to do it in 2 steps: 2207e3d74329Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208e3d74329Smrg eval "$extractedcf" 2209e3d74329Smrg else 2210e3d74329Smrg func_error "ignoring unknown tag $tagname" 2211e3d74329Smrg fi 2212e3d74329Smrg ;; 2213e3d74329Smrg esac 221442a55b46Smrg} 2215c582b7e3Smrg 2216e3d74329Smrg 221742a55b46Smrg# func_check_version_match 2218e3d74329Smrg# ------------------------ 221942a55b46Smrg# Ensure that we are using m4 macros, and libtool script from the same 222042a55b46Smrg# release of libtool. 222142a55b46Smrgfunc_check_version_match () 222242a55b46Smrg{ 2223e3d74329Smrg if test "$package_revision" != "$macro_revision"; then 2224e3d74329Smrg if test "$VERSION" != "$macro_version"; then 2225e3d74329Smrg if test -z "$macro_version"; then 2226e3d74329Smrg cat >&2 <<_LT_EOF 222742a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 222842a55b46Smrg$progname: definition of this LT_INIT comes from an older release. 222942a55b46Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223042a55b46Smrg$progname: and run autoconf again. 223142a55b46Smrg_LT_EOF 2232e3d74329Smrg else 2233e3d74329Smrg cat >&2 <<_LT_EOF 223442a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 223542a55b46Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 223642a55b46Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223742a55b46Smrg$progname: and run autoconf again. 223842a55b46Smrg_LT_EOF 2239e3d74329Smrg fi 2240e3d74329Smrg else 2241e3d74329Smrg cat >&2 <<_LT_EOF 224242a55b46Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 224342a55b46Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 224442a55b46Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 224542a55b46Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 224642a55b46Smrg_LT_EOF 2247e3d74329Smrg fi 2248c582b7e3Smrg 2249e3d74329Smrg exit $EXIT_MISMATCH 2250e3d74329Smrg fi 225142a55b46Smrg} 2252c582b7e3Smrg 2253c582b7e3Smrg 2254e3d74329Smrg# libtool_options_prep [ARG]... 2255e3d74329Smrg# ----------------------------- 2256e3d74329Smrg# Preparation for options parsed by libtool. 2257e3d74329Smrglibtool_options_prep () 2258e3d74329Smrg{ 2259e3d74329Smrg $debug_mode 2260c582b7e3Smrg 2261e3d74329Smrg # Option defaults: 2262e3d74329Smrg opt_config=false 2263e3d74329Smrg opt_dlopen= 2264e3d74329Smrg opt_dry_run=false 2265e3d74329Smrg opt_help=false 2266e3d74329Smrg opt_mode= 2267e3d74329Smrg opt_preserve_dup_deps=false 2268e3d74329Smrg opt_quiet=false 2269c582b7e3Smrg 2270e3d74329Smrg nonopt= 2271e3d74329Smrg preserve_args= 2272c582b7e3Smrg 2273e3d74329Smrg # Shorthand for --mode=foo, only valid as the first argument 2274e3d74329Smrg case $1 in 2275e3d74329Smrg clean|clea|cle|cl) 2276e3d74329Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2277e3d74329Smrg ;; 2278e3d74329Smrg compile|compil|compi|comp|com|co|c) 2279e3d74329Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2280e3d74329Smrg ;; 2281e3d74329Smrg execute|execut|execu|exec|exe|ex|e) 2282e3d74329Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2283e3d74329Smrg ;; 2284e3d74329Smrg finish|finis|fini|fin|fi|f) 2285e3d74329Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2286e3d74329Smrg ;; 2287e3d74329Smrg install|instal|insta|inst|ins|in|i) 2288e3d74329Smrg shift; set dummy --mode install ${1+"$@"}; shift 2289e3d74329Smrg ;; 2290e3d74329Smrg link|lin|li|l) 2291e3d74329Smrg shift; set dummy --mode link ${1+"$@"}; shift 2292e3d74329Smrg ;; 2293e3d74329Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294e3d74329Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295e3d74329Smrg ;; 2296e3d74329Smrg esac 2297e3d74329Smrg 2298e3d74329Smrg # Pass back the list of options. 2299e3d74329Smrg func_quote_for_eval ${1+"$@"} 2300e3d74329Smrg libtool_options_prep_result=$func_quote_for_eval_result 2301e3d74329Smrg} 2302e3d74329Smrgfunc_add_hook func_options_prep libtool_options_prep 2303c582b7e3Smrg 230442a55b46Smrg 2305e3d74329Smrg# libtool_parse_options [ARG]... 2306e3d74329Smrg# --------------------------------- 2307e3d74329Smrg# Provide handling for libtool specific options. 2308e3d74329Smrglibtool_parse_options () 230942a55b46Smrg{ 2310e3d74329Smrg $debug_cmd 2311c582b7e3Smrg 2312e3d74329Smrg # Perform our own loop to consume as many options as possible in 2313e3d74329Smrg # each iteration. 2314e3d74329Smrg while test $# -gt 0; do 2315e3d74329Smrg _G_opt=$1 2316e3d74329Smrg shift 2317e3d74329Smrg case $_G_opt in 2318e3d74329Smrg --dry-run|--dryrun|-n) 2319e3d74329Smrg opt_dry_run=: 2320e3d74329Smrg ;; 2321e3d74329Smrg 2322e3d74329Smrg --config) func_config ;; 2323e3d74329Smrg 2324e3d74329Smrg --dlopen|-dlopen) 2325e3d74329Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326e3d74329Smrg}$1" 2327e3d74329Smrg shift 2328e3d74329Smrg ;; 2329e3d74329Smrg 2330e3d74329Smrg --preserve-dup-deps) 2331e3d74329Smrg opt_preserve_dup_deps=: ;; 2332e3d74329Smrg 2333e3d74329Smrg --features) func_features ;; 2334e3d74329Smrg 2335e3d74329Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336e3d74329Smrg 2337e3d74329Smrg --help) opt_help=: ;; 2338e3d74329Smrg 2339e3d74329Smrg --help-all) opt_help=': help-all' ;; 2340e3d74329Smrg 2341e3d74329Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342e3d74329Smrg opt_mode=$1 2343e3d74329Smrg case $1 in 2344e3d74329Smrg # Valid mode arguments: 2345e3d74329Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346e3d74329Smrg 2347e3d74329Smrg # Catch anything else as an error 2348e3d74329Smrg *) func_error "invalid argument for $_G_opt" 2349e3d74329Smrg exit_cmd=exit 2350e3d74329Smrg break 2351e3d74329Smrg ;; 2352e3d74329Smrg esac 2353e3d74329Smrg shift 2354e3d74329Smrg ;; 2355e3d74329Smrg 2356e3d74329Smrg --no-silent|--no-quiet) 2357e3d74329Smrg opt_quiet=false 2358e3d74329Smrg func_append preserve_args " $_G_opt" 2359e3d74329Smrg ;; 2360e3d74329Smrg 2361e3d74329Smrg --no-warnings|--no-warning|--no-warn) 2362e3d74329Smrg opt_warning=false 2363e3d74329Smrg func_append preserve_args " $_G_opt" 2364e3d74329Smrg ;; 2365e3d74329Smrg 2366e3d74329Smrg --no-verbose) 2367e3d74329Smrg opt_verbose=false 2368e3d74329Smrg func_append preserve_args " $_G_opt" 2369e3d74329Smrg ;; 2370e3d74329Smrg 2371e3d74329Smrg --silent|--quiet) 2372e3d74329Smrg opt_quiet=: 2373e3d74329Smrg opt_verbose=false 2374e3d74329Smrg func_append preserve_args " $_G_opt" 2375e3d74329Smrg ;; 2376e3d74329Smrg 2377e3d74329Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378e3d74329Smrg opt_tag=$1 2379e3d74329Smrg func_append preserve_args " $_G_opt $1" 2380e3d74329Smrg func_enable_tag "$1" 2381e3d74329Smrg shift 2382e3d74329Smrg ;; 2383e3d74329Smrg 2384e3d74329Smrg --verbose|-v) opt_quiet=false 2385e3d74329Smrg opt_verbose=: 2386e3d74329Smrg func_append preserve_args " $_G_opt" 2387e3d74329Smrg ;; 2388e3d74329Smrg 2389e3d74329Smrg # An option not handled by this hook function: 2390e3d74329Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391e3d74329Smrg esac 2392e3d74329Smrg done 239342a55b46Smrg 2394c582b7e3Smrg 2395e3d74329Smrg # save modified positional parameters for caller 2396e3d74329Smrg func_quote_for_eval ${1+"$@"} 2397e3d74329Smrg libtool_parse_options_result=$func_quote_for_eval_result 2398e3d74329Smrg} 2399e3d74329Smrgfunc_add_hook func_parse_options libtool_parse_options 2400c582b7e3Smrg 2401c582b7e3Smrg 2402c582b7e3Smrg 2403e3d74329Smrg# libtool_validate_options [ARG]... 2404e3d74329Smrg# --------------------------------- 2405e3d74329Smrg# Perform any sanity checks on option settings and/or unconsumed 2406e3d74329Smrg# arguments. 2407e3d74329Smrglibtool_validate_options () 2408e3d74329Smrg{ 2409e3d74329Smrg # save first non-option argument 2410e3d74329Smrg if test 0 -lt $#; then 2411e3d74329Smrg nonopt=$1 2412e3d74329Smrg shift 241342a55b46Smrg fi 2414c582b7e3Smrg 2415e3d74329Smrg # preserve --debug 2416e3d74329Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417c582b7e3Smrg 2418e3d74329Smrg case $host in 2419e3d74329Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420e3d74329Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421e3d74329Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422e3d74329Smrg # don't eliminate duplications in $postdeps and $predeps 2423e3d74329Smrg opt_duplicate_compiler_generated_deps=: 2424e3d74329Smrg ;; 2425e3d74329Smrg *) 2426e3d74329Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427e3d74329Smrg ;; 2428e3d74329Smrg esac 2429c582b7e3Smrg 2430e3d74329Smrg $opt_help || { 2431e3d74329Smrg # Sanity checks first: 2432e3d74329Smrg func_check_version_match 2433c582b7e3Smrg 2434e3d74329Smrg test yes != "$build_libtool_libs" \ 2435e3d74329Smrg && test yes != "$build_old_libs" \ 2436e3d74329Smrg && func_fatal_configuration "not configured to build any kind of library" 2437c582b7e3Smrg 2438e3d74329Smrg # Darwin sucks 2439e3d74329Smrg eval std_shrext=\"$shrext_cmds\" 2440e3d74329Smrg 2441e3d74329Smrg # Only execute mode is allowed to have -dlopen flags. 2442e3d74329Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443e3d74329Smrg func_error "unrecognized option '-dlopen'" 2444e3d74329Smrg $ECHO "$help" 1>&2 2445e3d74329Smrg exit $EXIT_FAILURE 2446e3d74329Smrg fi 2447e3d74329Smrg 2448e3d74329Smrg # Change the help message to a mode-specific one. 2449e3d74329Smrg generic_help=$help 2450e3d74329Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451e3d74329Smrg } 2452e3d74329Smrg 2453e3d74329Smrg # Pass back the unparsed argument list 2454e3d74329Smrg func_quote_for_eval ${1+"$@"} 2455e3d74329Smrg libtool_validate_options_result=$func_quote_for_eval_result 245642a55b46Smrg} 2457e3d74329Smrgfunc_add_hook func_validate_options libtool_validate_options 2458e3d74329Smrg 2459c582b7e3Smrg 2460e3d74329Smrg# Process options as early as possible so that --help and --version 2461e3d74329Smrg# can return quickly. 2462e3d74329Smrgfunc_options ${1+"$@"} 2463e3d74329Smrgeval set dummy "$func_options_result"; shift 2464c582b7e3Smrg 2465c582b7e3Smrg 2466c582b7e3Smrg 246742a55b46Smrg## ----------- ## 246842a55b46Smrg## Main. ## 246942a55b46Smrg## ----------- ## 2470c582b7e3Smrg 2471e3d74329Smrgmagic='%%%MAGIC variable%%%' 2472e3d74329Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2473e3d74329Smrg 2474e3d74329Smrg# Global variables. 2475e3d74329Smrgextracted_archives= 2476e3d74329Smrgextracted_serial=0 2477e3d74329Smrg 2478e3d74329Smrg# If this variable is set in any of the actions, the command in it 2479e3d74329Smrg# will be execed at the end. This prevents here-documents from being 2480e3d74329Smrg# left over by shells. 2481e3d74329Smrgexec_cmd= 2482e3d74329Smrg 2483e3d74329Smrg 2484e3d74329Smrg# A function that is used when there is no print builtin or printf. 2485e3d74329Smrgfunc_fallback_echo () 2486e3d74329Smrg{ 2487e3d74329Smrg eval 'cat <<_LTECHO_EOF 2488e3d74329Smrg$1 2489e3d74329Smrg_LTECHO_EOF' 2490e3d74329Smrg} 2491e3d74329Smrg 2492e3d74329Smrg# func_generated_by_libtool 2493e3d74329Smrg# True iff stdin has been generated by Libtool. This function is only 2494e3d74329Smrg# a basic sanity check; it will hardly flush out determined imposters. 2495e3d74329Smrgfunc_generated_by_libtool_p () 2496e3d74329Smrg{ 2497e3d74329Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498e3d74329Smrg} 2499e3d74329Smrg 250042a55b46Smrg# func_lalib_p file 2501e3d74329Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 250242a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 250342a55b46Smrg# determined imposters. 250442a55b46Smrgfunc_lalib_p () 250542a55b46Smrg{ 250642a55b46Smrg test -f "$1" && 2507e3d74329Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 250842a55b46Smrg} 2509c582b7e3Smrg 251042a55b46Smrg# func_lalib_unsafe_p file 2511e3d74329Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 251242a55b46Smrg# This function implements the same check as func_lalib_p without 251342a55b46Smrg# resorting to external programs. To this end, it redirects stdin and 251442a55b46Smrg# closes it afterwards, without saving the original file descriptor. 251542a55b46Smrg# As a safety measure, use it only where a negative result would be 2516e3d74329Smrg# fatal anyway. Works if 'file' does not exist. 251742a55b46Smrgfunc_lalib_unsafe_p () 251842a55b46Smrg{ 251942a55b46Smrg lalib_p=no 252042a55b46Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 252142a55b46Smrg for lalib_p_l in 1 2 3 4 252242a55b46Smrg do 252342a55b46Smrg read lalib_p_line 2524e3d74329Smrg case $lalib_p_line in 252542a55b46Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 252642a55b46Smrg esac 252742a55b46Smrg done 252842a55b46Smrg exec 0<&5 5<&- 252942a55b46Smrg fi 2530e3d74329Smrg test yes = "$lalib_p" 253142a55b46Smrg} 2532c582b7e3Smrg 253342a55b46Smrg# func_ltwrapper_script_p file 253442a55b46Smrg# True iff FILE is a libtool wrapper script 253542a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 253642a55b46Smrg# determined imposters. 253742a55b46Smrgfunc_ltwrapper_script_p () 253842a55b46Smrg{ 2539e3d74329Smrg test -f "$1" && 2540e3d74329Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 254142a55b46Smrg} 2542c582b7e3Smrg 254342a55b46Smrg# func_ltwrapper_executable_p file 254442a55b46Smrg# True iff FILE is a libtool wrapper executable 254542a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 254642a55b46Smrg# determined imposters. 254742a55b46Smrgfunc_ltwrapper_executable_p () 254842a55b46Smrg{ 254942a55b46Smrg func_ltwrapper_exec_suffix= 255042a55b46Smrg case $1 in 255142a55b46Smrg *.exe) ;; 255242a55b46Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553c582b7e3Smrg esac 255442a55b46Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 255542a55b46Smrg} 2556c582b7e3Smrg 255742a55b46Smrg# func_ltwrapper_scriptname file 255842a55b46Smrg# Assumes file is an ltwrapper_executable 255942a55b46Smrg# uses $file to determine the appropriate filename for a 256042a55b46Smrg# temporary ltwrapper_script. 256142a55b46Smrgfunc_ltwrapper_scriptname () 256242a55b46Smrg{ 256342a55b46Smrg func_dirname_and_basename "$1" "" "." 256442a55b46Smrg func_stripname '' '.exe' "$func_basename_result" 2565e3d74329Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 256642a55b46Smrg} 2567c582b7e3Smrg 256842a55b46Smrg# func_ltwrapper_p file 256942a55b46Smrg# True iff FILE is a libtool wrapper script or wrapper executable 257042a55b46Smrg# This function is only a basic sanity check; it will hardly flush out 257142a55b46Smrg# determined imposters. 257242a55b46Smrgfunc_ltwrapper_p () 257342a55b46Smrg{ 257442a55b46Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 257542a55b46Smrg} 2576c582b7e3Smrg 2577c582b7e3Smrg 257842a55b46Smrg# func_execute_cmds commands fail_cmd 257942a55b46Smrg# Execute tilde-delimited COMMANDS. 258042a55b46Smrg# If FAIL_CMD is given, eval that upon failure. 258142a55b46Smrg# FAIL_CMD may read-access the current command in variable CMD! 258242a55b46Smrgfunc_execute_cmds () 258342a55b46Smrg{ 2584e3d74329Smrg $debug_cmd 2585e3d74329Smrg 258642a55b46Smrg save_ifs=$IFS; IFS='~' 258742a55b46Smrg for cmd in $1; do 2588e3d74329Smrg IFS=$sp$nl 258942a55b46Smrg eval cmd=\"$cmd\" 2590e3d74329Smrg IFS=$save_ifs 259142a55b46Smrg func_show_eval "$cmd" "${2-:}" 2592c582b7e3Smrg done 259342a55b46Smrg IFS=$save_ifs 259442a55b46Smrg} 2595c582b7e3Smrg 2596c582b7e3Smrg 259742a55b46Smrg# func_source file 259842a55b46Smrg# Source FILE, adding directory component if necessary. 259942a55b46Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 260042a55b46Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 260142a55b46Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602e3d74329Smrg# 'FILE.' does not work on cygwin managed mounts. 260342a55b46Smrgfunc_source () 260442a55b46Smrg{ 2605e3d74329Smrg $debug_cmd 2606e3d74329Smrg 260742a55b46Smrg case $1 in 260842a55b46Smrg */* | *\\*) . "$1" ;; 260942a55b46Smrg *) . "./$1" ;; 261042a55b46Smrg esac 261142a55b46Smrg} 2612c582b7e3Smrg 2613c582b7e3Smrg 261442a55b46Smrg# func_resolve_sysroot PATH 261542a55b46Smrg# Replace a leading = in PATH with a sysroot. Store the result into 261642a55b46Smrg# func_resolve_sysroot_result 261742a55b46Smrgfunc_resolve_sysroot () 261842a55b46Smrg{ 261942a55b46Smrg func_resolve_sysroot_result=$1 262042a55b46Smrg case $func_resolve_sysroot_result in 262142a55b46Smrg =*) 262242a55b46Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 262342a55b46Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 262442a55b46Smrg ;; 262542a55b46Smrg esac 262642a55b46Smrg} 2627c582b7e3Smrg 262842a55b46Smrg# func_replace_sysroot PATH 262942a55b46Smrg# If PATH begins with the sysroot, replace it with = and 263042a55b46Smrg# store the result into func_replace_sysroot_result. 263142a55b46Smrgfunc_replace_sysroot () 263242a55b46Smrg{ 2633e3d74329Smrg case $lt_sysroot:$1 in 263442a55b46Smrg ?*:"$lt_sysroot"*) 263542a55b46Smrg func_stripname "$lt_sysroot" '' "$1" 2636e3d74329Smrg func_replace_sysroot_result='='$func_stripname_result 263742a55b46Smrg ;; 263842a55b46Smrg *) 263942a55b46Smrg # Including no sysroot. 264042a55b46Smrg func_replace_sysroot_result=$1 264142a55b46Smrg ;; 264242a55b46Smrg esac 264342a55b46Smrg} 2644c582b7e3Smrg 264542a55b46Smrg# func_infer_tag arg 264642a55b46Smrg# Infer tagged configuration to use if any are available and 264742a55b46Smrg# if one wasn't chosen via the "--tag" command line option. 264842a55b46Smrg# Only attempt this if the compiler in the base compile 264942a55b46Smrg# command doesn't match the default compiler. 265042a55b46Smrg# arg is usually of the form 'gcc ...' 265142a55b46Smrgfunc_infer_tag () 265242a55b46Smrg{ 2653e3d74329Smrg $debug_cmd 2654e3d74329Smrg 265542a55b46Smrg if test -n "$available_tags" && test -z "$tagname"; then 265642a55b46Smrg CC_quoted= 265742a55b46Smrg for arg in $CC; do 265842a55b46Smrg func_append_quoted CC_quoted "$arg" 265942a55b46Smrg done 266042a55b46Smrg CC_expanded=`func_echo_all $CC` 266142a55b46Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 266242a55b46Smrg case $@ in 266342a55b46Smrg # Blanks in the command may have been stripped by the calling shell, 266442a55b46Smrg # but not from the CC environment variable when configure was run. 266542a55b46Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266642a55b46Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 266742a55b46Smrg # Blanks at the start of $base_compile will cause this to fail 266842a55b46Smrg # if we don't check for them as well. 266942a55b46Smrg *) 267042a55b46Smrg for z in $available_tags; do 267142a55b46Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 267242a55b46Smrg # Evaluate the configuration. 2673e3d74329Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 267442a55b46Smrg CC_quoted= 267542a55b46Smrg for arg in $CC; do 267642a55b46Smrg # Double-quote args containing other shell metacharacters. 267742a55b46Smrg func_append_quoted CC_quoted "$arg" 267842a55b46Smrg done 267942a55b46Smrg CC_expanded=`func_echo_all $CC` 268042a55b46Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 268142a55b46Smrg case "$@ " in 268242a55b46Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268342a55b46Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 268442a55b46Smrg # The compiler in the base compile command matches 268542a55b46Smrg # the one in the tagged configuration. 268642a55b46Smrg # Assume this is the tagged configuration we want. 268742a55b46Smrg tagname=$z 268842a55b46Smrg break 268942a55b46Smrg ;; 269042a55b46Smrg esac 269142a55b46Smrg fi 269242a55b46Smrg done 269342a55b46Smrg # If $tagname still isn't set, then no tagged configuration 269442a55b46Smrg # was found and let the user know that the "--tag" command 269542a55b46Smrg # line option must be used. 269642a55b46Smrg if test -z "$tagname"; then 269742a55b46Smrg func_echo "unable to infer tagged configuration" 2698e3d74329Smrg func_fatal_error "specify a tag with '--tag'" 269942a55b46Smrg# else 270042a55b46Smrg# func_verbose "using $tagname tagged configuration" 270142a55b46Smrg fi 270242a55b46Smrg ;; 270342a55b46Smrg esac 2704c582b7e3Smrg fi 270542a55b46Smrg} 2706c582b7e3Smrg 2707c582b7e3Smrg 2708c582b7e3Smrg 270942a55b46Smrg# func_write_libtool_object output_name pic_name nonpic_name 271042a55b46Smrg# Create a libtool object file (analogous to a ".la" file), 271142a55b46Smrg# but don't create it if we're doing a dry run. 271242a55b46Smrgfunc_write_libtool_object () 271342a55b46Smrg{ 2714e3d74329Smrg write_libobj=$1 2715e3d74329Smrg if test yes = "$build_libtool_libs"; then 2716e3d74329Smrg write_lobj=\'$2\' 271742a55b46Smrg else 271842a55b46Smrg write_lobj=none 2719c582b7e3Smrg fi 2720c582b7e3Smrg 2721e3d74329Smrg if test yes = "$build_old_libs"; then 2722e3d74329Smrg write_oldobj=\'$3\' 272342a55b46Smrg else 272442a55b46Smrg write_oldobj=none 2725c582b7e3Smrg fi 2726c582b7e3Smrg 272742a55b46Smrg $opt_dry_run || { 272842a55b46Smrg cat >${write_libobj}T <<EOF 272942a55b46Smrg# $write_libobj - a libtool object file 2730e3d74329Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731c582b7e3Smrg# 2732c582b7e3Smrg# Please DO NOT delete this file! 2733c582b7e3Smrg# It is necessary for linking the library. 2734c582b7e3Smrg 2735c582b7e3Smrg# Name of the PIC object. 273642a55b46Smrgpic_object=$write_lobj 2737c582b7e3Smrg 273842a55b46Smrg# Name of the non-PIC object 273942a55b46Smrgnon_pic_object=$write_oldobj 2740c582b7e3Smrg 274142a55b46SmrgEOF 2742e3d74329Smrg $MV "${write_libobj}T" "$write_libobj" 274342a55b46Smrg } 274442a55b46Smrg} 2745c582b7e3Smrg 2746c582b7e3Smrg 274742a55b46Smrg################################################## 274842a55b46Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 274942a55b46Smrg################################################## 2750c582b7e3Smrg 275142a55b46Smrg# func_convert_core_file_wine_to_w32 ARG 275242a55b46Smrg# Helper function used by file name conversion functions when $build is *nix, 275342a55b46Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 275442a55b46Smrg# correctly configured wine environment available, with the winepath program 275542a55b46Smrg# in $build's $PATH. 275642a55b46Smrg# 275742a55b46Smrg# ARG is the $build file name to be converted to w32 format. 275842a55b46Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 275942a55b46Smrg# be empty on error (or when ARG is empty) 276042a55b46Smrgfunc_convert_core_file_wine_to_w32 () 276142a55b46Smrg{ 2762e3d74329Smrg $debug_cmd 2763e3d74329Smrg 2764e3d74329Smrg func_convert_core_file_wine_to_w32_result=$1 276542a55b46Smrg if test -n "$1"; then 276642a55b46Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 276742a55b46Smrg # are forced to check the contents of stdout. On the other hand, if the 276842a55b46Smrg # command is not found, the shell will set an exit code of 127 and print 276942a55b46Smrg # *an error message* to stdout. So we must check for both error code of 277042a55b46Smrg # zero AND non-empty stdout, which explains the odd construction: 277142a55b46Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772e3d74329Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 277342a55b46Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774e3d74329Smrg $SED -e "$sed_naive_backslashify"` 277542a55b46Smrg else 277642a55b46Smrg func_convert_core_file_wine_to_w32_result= 277742a55b46Smrg fi 277842a55b46Smrg fi 277942a55b46Smrg} 278042a55b46Smrg# end: func_convert_core_file_wine_to_w32 2781c582b7e3Smrg 278242a55b46Smrg 278342a55b46Smrg# func_convert_core_path_wine_to_w32 ARG 278442a55b46Smrg# Helper function used by path conversion functions when $build is *nix, and 278542a55b46Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 278642a55b46Smrg# configured wine environment available, with the winepath program in $build's 278742a55b46Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 278842a55b46Smrg# 278942a55b46Smrg# ARG is path to be converted from $build format to win32. 279042a55b46Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 279142a55b46Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 279242a55b46Smrg# are convertible, then the result may be empty. 279342a55b46Smrgfunc_convert_core_path_wine_to_w32 () 279442a55b46Smrg{ 2795e3d74329Smrg $debug_cmd 2796e3d74329Smrg 279742a55b46Smrg # unfortunately, winepath doesn't convert paths, only file names 2798e3d74329Smrg func_convert_core_path_wine_to_w32_result= 279942a55b46Smrg if test -n "$1"; then 280042a55b46Smrg oldIFS=$IFS 280142a55b46Smrg IFS=: 280242a55b46Smrg for func_convert_core_path_wine_to_w32_f in $1; do 280342a55b46Smrg IFS=$oldIFS 280442a55b46Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805e3d74329Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 280642a55b46Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807e3d74329Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 280842a55b46Smrg else 280942a55b46Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 281042a55b46Smrg fi 2811c582b7e3Smrg fi 281242a55b46Smrg done 281342a55b46Smrg IFS=$oldIFS 281442a55b46Smrg fi 281542a55b46Smrg} 281642a55b46Smrg# end: func_convert_core_path_wine_to_w32 281742a55b46Smrg 281842a55b46Smrg 281942a55b46Smrg# func_cygpath ARGS... 282042a55b46Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 282142a55b46Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 282242a55b46Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 282342a55b46Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 282442a55b46Smrg# file name or path is assumed to be in w32 format, as previously converted 282542a55b46Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 282642a55b46Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 282742a55b46Smrg# Cygwin format). Returns an empty string on error. 282842a55b46Smrg# 282942a55b46Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 283042a55b46Smrg# be converted. 283142a55b46Smrg# 283242a55b46Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 283342a55b46Smrg# environment variable; do not put it in $PATH. 283442a55b46Smrgfunc_cygpath () 283542a55b46Smrg{ 2836e3d74329Smrg $debug_cmd 2837e3d74329Smrg 283842a55b46Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 283942a55b46Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 284042a55b46Smrg if test "$?" -ne 0; then 284142a55b46Smrg # on failure, ensure result is empty 284242a55b46Smrg func_cygpath_result= 284342a55b46Smrg fi 284442a55b46Smrg else 284542a55b46Smrg func_cygpath_result= 2846e3d74329Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 284742a55b46Smrg fi 284842a55b46Smrg} 284942a55b46Smrg#end: func_cygpath 2850c582b7e3Smrg 2851c582b7e3Smrg 285242a55b46Smrg# func_convert_core_msys_to_w32 ARG 285342a55b46Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 285442a55b46Smrg# result in func_convert_core_msys_to_w32_result. 285542a55b46Smrgfunc_convert_core_msys_to_w32 () 285642a55b46Smrg{ 2857e3d74329Smrg $debug_cmd 2858e3d74329Smrg 285942a55b46Smrg # awkward: cmd appends spaces to result 286042a55b46Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861e3d74329Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 286242a55b46Smrg} 286342a55b46Smrg#end: func_convert_core_msys_to_w32 2864c582b7e3Smrg 2865c582b7e3Smrg 286642a55b46Smrg# func_convert_file_check ARG1 ARG2 286742a55b46Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 286842a55b46Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 286942a55b46Smrg# func_to_host_file_result to ARG1). 287042a55b46Smrgfunc_convert_file_check () 287142a55b46Smrg{ 2872e3d74329Smrg $debug_cmd 2873e3d74329Smrg 2874e3d74329Smrg if test -z "$2" && test -n "$1"; then 287542a55b46Smrg func_error "Could not determine host file name corresponding to" 2876e3d74329Smrg func_error " '$1'" 287742a55b46Smrg func_error "Continuing, but uninstalled executables may not work." 287842a55b46Smrg # Fallback: 2879e3d74329Smrg func_to_host_file_result=$1 288042a55b46Smrg fi 288142a55b46Smrg} 288242a55b46Smrg# end func_convert_file_check 2883c582b7e3Smrg 2884c582b7e3Smrg 288542a55b46Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 288642a55b46Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 288742a55b46Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 288842a55b46Smrg# func_to_host_file_result to a simplistic fallback value (see below). 288942a55b46Smrgfunc_convert_path_check () 289042a55b46Smrg{ 2891e3d74329Smrg $debug_cmd 2892e3d74329Smrg 289342a55b46Smrg if test -z "$4" && test -n "$3"; then 289442a55b46Smrg func_error "Could not determine the host path corresponding to" 2895e3d74329Smrg func_error " '$3'" 289642a55b46Smrg func_error "Continuing, but uninstalled executables may not work." 289742a55b46Smrg # Fallback. This is a deliberately simplistic "conversion" and 289842a55b46Smrg # should not be "improved". See libtool.info. 289942a55b46Smrg if test "x$1" != "x$2"; then 290042a55b46Smrg lt_replace_pathsep_chars="s|$1|$2|g" 290142a55b46Smrg func_to_host_path_result=`echo "$3" | 290242a55b46Smrg $SED -e "$lt_replace_pathsep_chars"` 290342a55b46Smrg else 2904e3d74329Smrg func_to_host_path_result=$3 290542a55b46Smrg fi 290642a55b46Smrg fi 290742a55b46Smrg} 290842a55b46Smrg# end func_convert_path_check 2909c582b7e3Smrg 2910c582b7e3Smrg 291142a55b46Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 291242a55b46Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 291342a55b46Smrg# and appending REPL if ORIG matches BACKPAT. 291442a55b46Smrgfunc_convert_path_front_back_pathsep () 291542a55b46Smrg{ 2916e3d74329Smrg $debug_cmd 2917e3d74329Smrg 291842a55b46Smrg case $4 in 2919e3d74329Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 292042a55b46Smrg ;; 292142a55b46Smrg esac 292242a55b46Smrg case $4 in 292342a55b46Smrg $2 ) func_append func_to_host_path_result "$3" 292442a55b46Smrg ;; 292542a55b46Smrg esac 292642a55b46Smrg} 292742a55b46Smrg# end func_convert_path_front_back_pathsep 2928c582b7e3Smrg 2929c582b7e3Smrg 293042a55b46Smrg################################################## 293142a55b46Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 293242a55b46Smrg################################################## 2933e3d74329Smrg# invoked via '$to_host_file_cmd ARG' 293442a55b46Smrg# 293542a55b46Smrg# In each case, ARG is the path to be converted from $build to $host format. 293642a55b46Smrg# Result will be available in $func_to_host_file_result. 2937c582b7e3Smrg 2938c582b7e3Smrg 293942a55b46Smrg# func_to_host_file ARG 294042a55b46Smrg# Converts the file name ARG from $build format to $host format. Return result 294142a55b46Smrg# in func_to_host_file_result. 294242a55b46Smrgfunc_to_host_file () 294342a55b46Smrg{ 2944e3d74329Smrg $debug_cmd 2945e3d74329Smrg 294642a55b46Smrg $to_host_file_cmd "$1" 294742a55b46Smrg} 294842a55b46Smrg# end func_to_host_file 2949c582b7e3Smrg 2950c582b7e3Smrg 295142a55b46Smrg# func_to_tool_file ARG LAZY 295242a55b46Smrg# converts the file name ARG from $build format to toolchain format. Return 295342a55b46Smrg# result in func_to_tool_file_result. If the conversion in use is listed 295442a55b46Smrg# in (the comma separated) LAZY, no conversion takes place. 295542a55b46Smrgfunc_to_tool_file () 295642a55b46Smrg{ 2957e3d74329Smrg $debug_cmd 2958e3d74329Smrg 295942a55b46Smrg case ,$2, in 296042a55b46Smrg *,"$to_tool_file_cmd",*) 296142a55b46Smrg func_to_tool_file_result=$1 296242a55b46Smrg ;; 296342a55b46Smrg *) 296442a55b46Smrg $to_tool_file_cmd "$1" 296542a55b46Smrg func_to_tool_file_result=$func_to_host_file_result 296642a55b46Smrg ;; 296742a55b46Smrg esac 296842a55b46Smrg} 296942a55b46Smrg# end func_to_tool_file 2970c582b7e3Smrg 2971c582b7e3Smrg 297242a55b46Smrg# func_convert_file_noop ARG 297342a55b46Smrg# Copy ARG to func_to_host_file_result. 297442a55b46Smrgfunc_convert_file_noop () 297542a55b46Smrg{ 2976e3d74329Smrg func_to_host_file_result=$1 297742a55b46Smrg} 297842a55b46Smrg# end func_convert_file_noop 2979c582b7e3Smrg 2980c582b7e3Smrg 298142a55b46Smrg# func_convert_file_msys_to_w32 ARG 298242a55b46Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 298342a55b46Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 298442a55b46Smrg# func_to_host_file_result. 298542a55b46Smrgfunc_convert_file_msys_to_w32 () 298642a55b46Smrg{ 2987e3d74329Smrg $debug_cmd 2988e3d74329Smrg 2989e3d74329Smrg func_to_host_file_result=$1 299042a55b46Smrg if test -n "$1"; then 299142a55b46Smrg func_convert_core_msys_to_w32 "$1" 2992e3d74329Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 299342a55b46Smrg fi 299442a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 299542a55b46Smrg} 299642a55b46Smrg# end func_convert_file_msys_to_w32 2997c582b7e3Smrg 2998c582b7e3Smrg 299942a55b46Smrg# func_convert_file_cygwin_to_w32 ARG 300042a55b46Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 300142a55b46Smrg# func_to_host_file_result. 300242a55b46Smrgfunc_convert_file_cygwin_to_w32 () 300342a55b46Smrg{ 3004e3d74329Smrg $debug_cmd 3005e3d74329Smrg 3006e3d74329Smrg func_to_host_file_result=$1 300742a55b46Smrg if test -n "$1"; then 300842a55b46Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 300942a55b46Smrg # LT_CYGPATH in this case. 301042a55b46Smrg func_to_host_file_result=`cygpath -m "$1"` 301142a55b46Smrg fi 301242a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 301342a55b46Smrg} 301442a55b46Smrg# end func_convert_file_cygwin_to_w32 3015c582b7e3Smrg 3016c582b7e3Smrg 301742a55b46Smrg# func_convert_file_nix_to_w32 ARG 301842a55b46Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 301942a55b46Smrg# and a working winepath. Returns result in func_to_host_file_result. 302042a55b46Smrgfunc_convert_file_nix_to_w32 () 302142a55b46Smrg{ 3022e3d74329Smrg $debug_cmd 3023e3d74329Smrg 3024e3d74329Smrg func_to_host_file_result=$1 302542a55b46Smrg if test -n "$1"; then 302642a55b46Smrg func_convert_core_file_wine_to_w32 "$1" 3027e3d74329Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 302842a55b46Smrg fi 302942a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 303042a55b46Smrg} 303142a55b46Smrg# end func_convert_file_nix_to_w32 3032c582b7e3Smrg 3033c582b7e3Smrg 303442a55b46Smrg# func_convert_file_msys_to_cygwin ARG 303542a55b46Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 303642a55b46Smrg# Returns result in func_to_host_file_result. 303742a55b46Smrgfunc_convert_file_msys_to_cygwin () 303842a55b46Smrg{ 3039e3d74329Smrg $debug_cmd 3040e3d74329Smrg 3041e3d74329Smrg func_to_host_file_result=$1 304242a55b46Smrg if test -n "$1"; then 304342a55b46Smrg func_convert_core_msys_to_w32 "$1" 304442a55b46Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045e3d74329Smrg func_to_host_file_result=$func_cygpath_result 304642a55b46Smrg fi 304742a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 304842a55b46Smrg} 304942a55b46Smrg# end func_convert_file_msys_to_cygwin 3050c582b7e3Smrg 3051c582b7e3Smrg 305242a55b46Smrg# func_convert_file_nix_to_cygwin ARG 305342a55b46Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 305442a55b46Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 305542a55b46Smrg# in func_to_host_file_result. 305642a55b46Smrgfunc_convert_file_nix_to_cygwin () 305742a55b46Smrg{ 3058e3d74329Smrg $debug_cmd 3059e3d74329Smrg 3060e3d74329Smrg func_to_host_file_result=$1 306142a55b46Smrg if test -n "$1"; then 306242a55b46Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 306342a55b46Smrg func_convert_core_file_wine_to_w32 "$1" 306442a55b46Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065e3d74329Smrg func_to_host_file_result=$func_cygpath_result 306642a55b46Smrg fi 306742a55b46Smrg func_convert_file_check "$1" "$func_to_host_file_result" 306842a55b46Smrg} 306942a55b46Smrg# end func_convert_file_nix_to_cygwin 3070c582b7e3Smrg 3071c582b7e3Smrg 307242a55b46Smrg############################################# 307342a55b46Smrg# $build to $host PATH CONVERSION FUNCTIONS # 307442a55b46Smrg############################################# 3075e3d74329Smrg# invoked via '$to_host_path_cmd ARG' 307642a55b46Smrg# 307742a55b46Smrg# In each case, ARG is the path to be converted from $build to $host format. 307842a55b46Smrg# The result will be available in $func_to_host_path_result. 307942a55b46Smrg# 308042a55b46Smrg# Path separators are also converted from $build format to $host format. If 308142a55b46Smrg# ARG begins or ends with a path separator character, it is preserved (but 308242a55b46Smrg# converted to $host format) on output. 308342a55b46Smrg# 308442a55b46Smrg# All path conversion functions are named using the following convention: 308542a55b46Smrg# file name conversion function : func_convert_file_X_to_Y () 308642a55b46Smrg# path conversion function : func_convert_path_X_to_Y () 308742a55b46Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 308842a55b46Smrg# same. If conversion functions are added for new $build/$host combinations, 308942a55b46Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 309042a55b46Smrg# will break. 309142a55b46Smrg 309242a55b46Smrg 309342a55b46Smrg# func_init_to_host_path_cmd 309442a55b46Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 309542a55b46Smrg# appropriate value, based on the value of $to_host_file_cmd. 309642a55b46Smrgto_host_path_cmd= 309742a55b46Smrgfunc_init_to_host_path_cmd () 309842a55b46Smrg{ 3099e3d74329Smrg $debug_cmd 3100e3d74329Smrg 310142a55b46Smrg if test -z "$to_host_path_cmd"; then 310242a55b46Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103e3d74329Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 310442a55b46Smrg fi 310542a55b46Smrg} 3106c582b7e3Smrg 3107c582b7e3Smrg 310842a55b46Smrg# func_to_host_path ARG 310942a55b46Smrg# Converts the path ARG from $build format to $host format. Return result 311042a55b46Smrg# in func_to_host_path_result. 311142a55b46Smrgfunc_to_host_path () 311242a55b46Smrg{ 3113e3d74329Smrg $debug_cmd 3114e3d74329Smrg 311542a55b46Smrg func_init_to_host_path_cmd 311642a55b46Smrg $to_host_path_cmd "$1" 311742a55b46Smrg} 311842a55b46Smrg# end func_to_host_path 3119c582b7e3Smrg 3120c582b7e3Smrg 312142a55b46Smrg# func_convert_path_noop ARG 312242a55b46Smrg# Copy ARG to func_to_host_path_result. 312342a55b46Smrgfunc_convert_path_noop () 312442a55b46Smrg{ 3125e3d74329Smrg func_to_host_path_result=$1 312642a55b46Smrg} 312742a55b46Smrg# end func_convert_path_noop 3128c582b7e3Smrg 3129c582b7e3Smrg 313042a55b46Smrg# func_convert_path_msys_to_w32 ARG 313142a55b46Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 313242a55b46Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 313342a55b46Smrg# func_to_host_path_result. 313442a55b46Smrgfunc_convert_path_msys_to_w32 () 313542a55b46Smrg{ 3136e3d74329Smrg $debug_cmd 3137e3d74329Smrg 3138e3d74329Smrg func_to_host_path_result=$1 313942a55b46Smrg if test -n "$1"; then 314042a55b46Smrg # Remove leading and trailing path separator characters from ARG. MSYS 314142a55b46Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 314242a55b46Smrg # and winepath ignores them completely. 314342a55b46Smrg func_stripname : : "$1" 314442a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 314542a55b46Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146e3d74329Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 314742a55b46Smrg func_convert_path_check : ";" \ 314842a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 314942a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 315042a55b46Smrg fi 315142a55b46Smrg} 315242a55b46Smrg# end func_convert_path_msys_to_w32 3153c582b7e3Smrg 3154c582b7e3Smrg 315542a55b46Smrg# func_convert_path_cygwin_to_w32 ARG 315642a55b46Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 315742a55b46Smrg# func_to_host_file_result. 315842a55b46Smrgfunc_convert_path_cygwin_to_w32 () 315942a55b46Smrg{ 3160e3d74329Smrg $debug_cmd 3161e3d74329Smrg 3162e3d74329Smrg func_to_host_path_result=$1 316342a55b46Smrg if test -n "$1"; then 316442a55b46Smrg # See func_convert_path_msys_to_w32: 316542a55b46Smrg func_stripname : : "$1" 316642a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 316742a55b46Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 316842a55b46Smrg func_convert_path_check : ";" \ 316942a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 317042a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 317142a55b46Smrg fi 317242a55b46Smrg} 317342a55b46Smrg# end func_convert_path_cygwin_to_w32 3174c582b7e3Smrg 3175c582b7e3Smrg 317642a55b46Smrg# func_convert_path_nix_to_w32 ARG 317742a55b46Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 317842a55b46Smrg# a working winepath. Returns result in func_to_host_file_result. 317942a55b46Smrgfunc_convert_path_nix_to_w32 () 318042a55b46Smrg{ 3181e3d74329Smrg $debug_cmd 3182e3d74329Smrg 3183e3d74329Smrg func_to_host_path_result=$1 318442a55b46Smrg if test -n "$1"; then 318542a55b46Smrg # See func_convert_path_msys_to_w32: 318642a55b46Smrg func_stripname : : "$1" 318742a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 318842a55b46Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189e3d74329Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 319042a55b46Smrg func_convert_path_check : ";" \ 319142a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 319242a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 319342a55b46Smrg fi 319442a55b46Smrg} 319542a55b46Smrg# end func_convert_path_nix_to_w32 3196c582b7e3Smrg 3197c582b7e3Smrg 319842a55b46Smrg# func_convert_path_msys_to_cygwin ARG 319942a55b46Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 320042a55b46Smrg# Returns result in func_to_host_file_result. 320142a55b46Smrgfunc_convert_path_msys_to_cygwin () 320242a55b46Smrg{ 3203e3d74329Smrg $debug_cmd 3204e3d74329Smrg 3205e3d74329Smrg func_to_host_path_result=$1 320642a55b46Smrg if test -n "$1"; then 320742a55b46Smrg # See func_convert_path_msys_to_w32: 320842a55b46Smrg func_stripname : : "$1" 320942a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 321042a55b46Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 321142a55b46Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212e3d74329Smrg func_to_host_path_result=$func_cygpath_result 321342a55b46Smrg func_convert_path_check : : \ 321442a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 321542a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 321642a55b46Smrg fi 321742a55b46Smrg} 321842a55b46Smrg# end func_convert_path_msys_to_cygwin 3219c582b7e3Smrg 3220c582b7e3Smrg 322142a55b46Smrg# func_convert_path_nix_to_cygwin ARG 322242a55b46Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 322342a55b46Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 322442a55b46Smrg# func_to_host_file_result. 322542a55b46Smrgfunc_convert_path_nix_to_cygwin () 322642a55b46Smrg{ 3227e3d74329Smrg $debug_cmd 3228e3d74329Smrg 3229e3d74329Smrg func_to_host_path_result=$1 323042a55b46Smrg if test -n "$1"; then 323142a55b46Smrg # Remove leading and trailing path separator characters from 323242a55b46Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 323342a55b46Smrg # into '.;' and ';.', and winepath ignores them completely. 323442a55b46Smrg func_stripname : : "$1" 323542a55b46Smrg func_to_host_path_tmp1=$func_stripname_result 323642a55b46Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323742a55b46Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238e3d74329Smrg func_to_host_path_result=$func_cygpath_result 323942a55b46Smrg func_convert_path_check : : \ 324042a55b46Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 324142a55b46Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 324242a55b46Smrg fi 324342a55b46Smrg} 324442a55b46Smrg# end func_convert_path_nix_to_cygwin 3245c582b7e3Smrg 3246c582b7e3Smrg 3247e3d74329Smrg# func_dll_def_p FILE 3248e3d74329Smrg# True iff FILE is a Windows DLL '.def' file. 3249e3d74329Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250e3d74329Smrgfunc_dll_def_p () 3251e3d74329Smrg{ 3252e3d74329Smrg $debug_cmd 3253e3d74329Smrg 3254e3d74329Smrg func_dll_def_p_tmp=`$SED -n \ 3255e3d74329Smrg -e 's/^[ ]*//' \ 3256e3d74329Smrg -e '/^\(;.*\)*$/d' \ 3257e3d74329Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258e3d74329Smrg -e q \ 3259e3d74329Smrg "$1"` 3260e3d74329Smrg test DEF = "$func_dll_def_p_tmp" 3261e3d74329Smrg} 3262e3d74329Smrg 3263e3d74329Smrg 326442a55b46Smrg# func_mode_compile arg... 326542a55b46Smrgfunc_mode_compile () 326642a55b46Smrg{ 3267e3d74329Smrg $debug_cmd 3268e3d74329Smrg 326942a55b46Smrg # Get the compilation command and the source file. 327042a55b46Smrg base_compile= 3271e3d74329Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 327242a55b46Smrg suppress_opt=yes 327342a55b46Smrg suppress_output= 327442a55b46Smrg arg_mode=normal 327542a55b46Smrg libobj= 327642a55b46Smrg later= 327742a55b46Smrg pie_flag= 327842a55b46Smrg 327942a55b46Smrg for arg 328042a55b46Smrg do 328142a55b46Smrg case $arg_mode in 328242a55b46Smrg arg ) 328342a55b46Smrg # do not "continue". Instead, add this to base_compile 3284e3d74329Smrg lastarg=$arg 328542a55b46Smrg arg_mode=normal 328642a55b46Smrg ;; 328742a55b46Smrg 328842a55b46Smrg target ) 3289e3d74329Smrg libobj=$arg 329042a55b46Smrg arg_mode=normal 329142a55b46Smrg continue 329242a55b46Smrg ;; 329342a55b46Smrg 329442a55b46Smrg normal ) 329542a55b46Smrg # Accept any command-line options. 329642a55b46Smrg case $arg in 329742a55b46Smrg -o) 329842a55b46Smrg test -n "$libobj" && \ 3299e3d74329Smrg func_fatal_error "you cannot specify '-o' more than once" 330042a55b46Smrg arg_mode=target 3301c582b7e3Smrg continue 3302c582b7e3Smrg ;; 330342a55b46Smrg 330442a55b46Smrg -pie | -fpie | -fPIE) 330542a55b46Smrg func_append pie_flag " $arg" 3306c582b7e3Smrg continue 3307c582b7e3Smrg ;; 330842a55b46Smrg 330942a55b46Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 331042a55b46Smrg func_append later " $arg" 3311c582b7e3Smrg continue 3312c582b7e3Smrg ;; 331342a55b46Smrg 331442a55b46Smrg -no-suppress) 331542a55b46Smrg suppress_opt=no 3316c582b7e3Smrg continue 3317c582b7e3Smrg ;; 3318c582b7e3Smrg 331942a55b46Smrg -Xcompiler) 332042a55b46Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 332142a55b46Smrg continue # The current "srcfile" will either be retained or 332242a55b46Smrg ;; # replaced later. I would guess that would be a bug. 3323c582b7e3Smrg 332442a55b46Smrg -Wc,*) 332542a55b46Smrg func_stripname '-Wc,' '' "$arg" 332642a55b46Smrg args=$func_stripname_result 332742a55b46Smrg lastarg= 3328e3d74329Smrg save_ifs=$IFS; IFS=, 332942a55b46Smrg for arg in $args; do 3330e3d74329Smrg IFS=$save_ifs 333142a55b46Smrg func_append_quoted lastarg "$arg" 333242a55b46Smrg done 3333e3d74329Smrg IFS=$save_ifs 333442a55b46Smrg func_stripname ' ' '' "$lastarg" 333542a55b46Smrg lastarg=$func_stripname_result 3336c582b7e3Smrg 333742a55b46Smrg # Add the arguments to base_compile. 333842a55b46Smrg func_append base_compile " $lastarg" 333942a55b46Smrg continue 334042a55b46Smrg ;; 3341c582b7e3Smrg 334242a55b46Smrg *) 334342a55b46Smrg # Accept the current argument as the source file. 334442a55b46Smrg # The previous "srcfile" becomes the current argument. 334542a55b46Smrg # 3346e3d74329Smrg lastarg=$srcfile 3347e3d74329Smrg srcfile=$arg 334842a55b46Smrg ;; 334942a55b46Smrg esac # case $arg 3350c582b7e3Smrg ;; 335142a55b46Smrg esac # case $arg_mode 3352c582b7e3Smrg 335342a55b46Smrg # Aesthetically quote the previous argument. 335442a55b46Smrg func_append_quoted base_compile "$lastarg" 335542a55b46Smrg done # for arg 3356c582b7e3Smrg 335742a55b46Smrg case $arg_mode in 335842a55b46Smrg arg) 335942a55b46Smrg func_fatal_error "you must specify an argument for -Xcompile" 336042a55b46Smrg ;; 336142a55b46Smrg target) 3362e3d74329Smrg func_fatal_error "you must specify a target with '-o'" 336342a55b46Smrg ;; 336442a55b46Smrg *) 336542a55b46Smrg # Get the name of the library object. 336642a55b46Smrg test -z "$libobj" && { 336742a55b46Smrg func_basename "$srcfile" 3368e3d74329Smrg libobj=$func_basename_result 336942a55b46Smrg } 337042a55b46Smrg ;; 337142a55b46Smrg esac 3372c582b7e3Smrg 337342a55b46Smrg # Recognize several different file suffixes. 337442a55b46Smrg # If the user specifies -o file.o, it is replaced with file.lo 337542a55b46Smrg case $libobj in 337642a55b46Smrg *.[cCFSifmso] | \ 337742a55b46Smrg *.ada | *.adb | *.ads | *.asm | \ 337842a55b46Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 337942a55b46Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 338042a55b46Smrg func_xform "$libobj" 338142a55b46Smrg libobj=$func_xform_result 338242a55b46Smrg ;; 338342a55b46Smrg esac 3384c582b7e3Smrg 338542a55b46Smrg case $libobj in 338642a55b46Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 338742a55b46Smrg *) 3388e3d74329Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 338942a55b46Smrg ;; 339042a55b46Smrg esac 3391c582b7e3Smrg 339242a55b46Smrg func_infer_tag $base_compile 3393c582b7e3Smrg 339442a55b46Smrg for arg in $later; do 339542a55b46Smrg case $arg in 339642a55b46Smrg -shared) 3397e3d74329Smrg test yes = "$build_libtool_libs" \ 3398e3d74329Smrg || func_fatal_configuration "cannot build a shared library" 339942a55b46Smrg build_old_libs=no 3400c582b7e3Smrg continue 3401c582b7e3Smrg ;; 3402c582b7e3Smrg 340342a55b46Smrg -static) 340442a55b46Smrg build_libtool_libs=no 340542a55b46Smrg build_old_libs=yes 3406c582b7e3Smrg continue 3407c582b7e3Smrg ;; 3408c582b7e3Smrg 340942a55b46Smrg -prefer-pic) 341042a55b46Smrg pic_mode=yes 3411c582b7e3Smrg continue 3412c582b7e3Smrg ;; 3413c582b7e3Smrg 341442a55b46Smrg -prefer-non-pic) 341542a55b46Smrg pic_mode=no 3416c582b7e3Smrg continue 3417c582b7e3Smrg ;; 341842a55b46Smrg esac 341942a55b46Smrg done 3420c582b7e3Smrg 342142a55b46Smrg func_quote_for_eval "$libobj" 342242a55b46Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 342342a55b46Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424e3d74329Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 342542a55b46Smrg func_dirname_and_basename "$obj" "/" "" 3426e3d74329Smrg objname=$func_basename_result 3427e3d74329Smrg xdir=$func_dirname_result 3428e3d74329Smrg lobj=$xdir$objdir/$objname 3429c582b7e3Smrg 343042a55b46Smrg test -z "$base_compile" && \ 343142a55b46Smrg func_fatal_help "you must specify a compilation command" 343219019ffeSmrg 343342a55b46Smrg # Delete any leftover library objects. 3434e3d74329Smrg if test yes = "$build_old_libs"; then 343542a55b46Smrg removelist="$obj $lobj $libobj ${libobj}T" 343642a55b46Smrg else 343742a55b46Smrg removelist="$lobj $libobj ${libobj}T" 343842a55b46Smrg fi 3439c582b7e3Smrg 344042a55b46Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 344142a55b46Smrg case $host_os in 344242a55b46Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 344342a55b46Smrg pic_mode=default 344442a55b46Smrg ;; 344542a55b46Smrg esac 3446e3d74329Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 344742a55b46Smrg # non-PIC code in shared libraries is not supported 344842a55b46Smrg pic_mode=default 344942a55b46Smrg fi 3450c582b7e3Smrg 345142a55b46Smrg # Calculate the filename of the output object if compiler does 345242a55b46Smrg # not support -o with -c 3453e3d74329Smrg if test no = "$compiler_c_o"; then 3454e3d74329Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455e3d74329Smrg lockfile=$output_obj.lock 345642a55b46Smrg else 345742a55b46Smrg output_obj= 345842a55b46Smrg need_locks=no 345942a55b46Smrg lockfile= 346042a55b46Smrg fi 3461c582b7e3Smrg 346242a55b46Smrg # Lock this critical section if it is needed 346342a55b46Smrg # We use this script file to make the link, it avoids creating a new file 3464e3d74329Smrg if test yes = "$need_locks"; then 346542a55b46Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 346642a55b46Smrg func_echo "Waiting for $lockfile to be removed" 346742a55b46Smrg sleep 2 346842a55b46Smrg done 3469e3d74329Smrg elif test warn = "$need_locks"; then 347042a55b46Smrg if test -f "$lockfile"; then 347142a55b46Smrg $ECHO "\ 347242a55b46Smrg*** ERROR, $lockfile exists and contains: 347342a55b46Smrg`cat $lockfile 2>/dev/null` 3474c582b7e3Smrg 347542a55b46SmrgThis indicates that another process is trying to use the same 347642a55b46Smrgtemporary object file, and libtool could not work around it because 3477e3d74329Smrgyour compiler does not support '-c' and '-o' together. If you 347842a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 347942a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 348042a55b46Smrgcompiler." 3481c582b7e3Smrg 348242a55b46Smrg $opt_dry_run || $RM $removelist 348342a55b46Smrg exit $EXIT_FAILURE 348442a55b46Smrg fi 348542a55b46Smrg func_append removelist " $output_obj" 348642a55b46Smrg $ECHO "$srcfile" > "$lockfile" 348742a55b46Smrg fi 3488c582b7e3Smrg 348942a55b46Smrg $opt_dry_run || $RM $removelist 349042a55b46Smrg func_append removelist " $lockfile" 349142a55b46Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492c582b7e3Smrg 349342a55b46Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 349442a55b46Smrg srcfile=$func_to_tool_file_result 349542a55b46Smrg func_quote_for_eval "$srcfile" 349642a55b46Smrg qsrcfile=$func_quote_for_eval_result 3497c582b7e3Smrg 349842a55b46Smrg # Only build a PIC object if we are building libtool libraries. 3499e3d74329Smrg if test yes = "$build_libtool_libs"; then 350042a55b46Smrg # Without this assignment, base_compile gets emptied. 350142a55b46Smrg fbsd_hideous_sh_bug=$base_compile 3502c582b7e3Smrg 3503e3d74329Smrg if test no != "$pic_mode"; then 350442a55b46Smrg command="$base_compile $qsrcfile $pic_flag" 350542a55b46Smrg else 350642a55b46Smrg # Don't build PIC code 350742a55b46Smrg command="$base_compile $qsrcfile" 350842a55b46Smrg fi 3509c582b7e3Smrg 351042a55b46Smrg func_mkdir_p "$xdir$objdir" 3511c582b7e3Smrg 351242a55b46Smrg if test -z "$output_obj"; then 351342a55b46Smrg # Place PIC objects in $objdir 351442a55b46Smrg func_append command " -o $lobj" 351542a55b46Smrg fi 3516c582b7e3Smrg 351742a55b46Smrg func_show_eval_locale "$command" \ 351842a55b46Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519c582b7e3Smrg 3520e3d74329Smrg if test warn = "$need_locks" && 352142a55b46Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 352242a55b46Smrg $ECHO "\ 352342a55b46Smrg*** ERROR, $lockfile contains: 352442a55b46Smrg`cat $lockfile 2>/dev/null` 3525c582b7e3Smrg 352642a55b46Smrgbut it should contain: 352742a55b46Smrg$srcfile 3528c582b7e3Smrg 352942a55b46SmrgThis indicates that another process is trying to use the same 353042a55b46Smrgtemporary object file, and libtool could not work around it because 3531e3d74329Smrgyour compiler does not support '-c' and '-o' together. If you 353242a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 353342a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 353442a55b46Smrgcompiler." 3535c582b7e3Smrg 353642a55b46Smrg $opt_dry_run || $RM $removelist 353742a55b46Smrg exit $EXIT_FAILURE 353842a55b46Smrg fi 3539c582b7e3Smrg 354042a55b46Smrg # Just move the object if needed, then go on to compile the next one 354142a55b46Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 354242a55b46Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 354342a55b46Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 354442a55b46Smrg fi 3545c582b7e3Smrg 354642a55b46Smrg # Allow error messages only from the first compilation. 3547e3d74329Smrg if test yes = "$suppress_opt"; then 354842a55b46Smrg suppress_output=' >/dev/null 2>&1' 354942a55b46Smrg fi 355042a55b46Smrg fi 3551c582b7e3Smrg 355242a55b46Smrg # Only build a position-dependent object if we build old libraries. 3553e3d74329Smrg if test yes = "$build_old_libs"; then 3554e3d74329Smrg if test yes != "$pic_mode"; then 355542a55b46Smrg # Don't build PIC code 355642a55b46Smrg command="$base_compile $qsrcfile$pie_flag" 355742a55b46Smrg else 355842a55b46Smrg command="$base_compile $qsrcfile $pic_flag" 355942a55b46Smrg fi 3560e3d74329Smrg if test yes = "$compiler_c_o"; then 356142a55b46Smrg func_append command " -o $obj" 356242a55b46Smrg fi 3563c582b7e3Smrg 356442a55b46Smrg # Suppress compiler output if we already did a PIC compilation. 356542a55b46Smrg func_append command "$suppress_output" 356642a55b46Smrg func_show_eval_locale "$command" \ 356742a55b46Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568c582b7e3Smrg 3569e3d74329Smrg if test warn = "$need_locks" && 357042a55b46Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 357142a55b46Smrg $ECHO "\ 357242a55b46Smrg*** ERROR, $lockfile contains: 357342a55b46Smrg`cat $lockfile 2>/dev/null` 3574c582b7e3Smrg 357542a55b46Smrgbut it should contain: 357642a55b46Smrg$srcfile 3577c582b7e3Smrg 357842a55b46SmrgThis indicates that another process is trying to use the same 357942a55b46Smrgtemporary object file, and libtool could not work around it because 3580e3d74329Smrgyour compiler does not support '-c' and '-o' together. If you 358142a55b46Smrgrepeat this compilation, it may succeed, by chance, but you had better 358242a55b46Smrgavoid parallel builds (make -j) in this platform, or get a better 358342a55b46Smrgcompiler." 3584c582b7e3Smrg 358542a55b46Smrg $opt_dry_run || $RM $removelist 358642a55b46Smrg exit $EXIT_FAILURE 358742a55b46Smrg fi 3588c582b7e3Smrg 358942a55b46Smrg # Just move the object if needed 359042a55b46Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 359142a55b46Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 359242a55b46Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 359342a55b46Smrg fi 359442a55b46Smrg fi 3595c582b7e3Smrg 359642a55b46Smrg $opt_dry_run || { 359742a55b46Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598c582b7e3Smrg 359942a55b46Smrg # Unlock the critical section if it was locked 3600e3d74329Smrg if test no != "$need_locks"; then 360142a55b46Smrg removelist=$lockfile 360242a55b46Smrg $RM "$lockfile" 360342a55b46Smrg fi 360442a55b46Smrg } 3605c582b7e3Smrg 360642a55b46Smrg exit $EXIT_SUCCESS 360742a55b46Smrg} 3608c582b7e3Smrg 360942a55b46Smrg$opt_help || { 3610e3d74329Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 361142a55b46Smrg} 3612c582b7e3Smrg 361342a55b46Smrgfunc_mode_help () 361442a55b46Smrg{ 361542a55b46Smrg # We need to display help for each of the modes. 361642a55b46Smrg case $opt_mode in 361742a55b46Smrg "") 361842a55b46Smrg # Generic help is extracted from the usage comments 361942a55b46Smrg # at the start of this file. 362042a55b46Smrg func_help 362142a55b46Smrg ;; 3622c582b7e3Smrg 362342a55b46Smrg clean) 362442a55b46Smrg $ECHO \ 362542a55b46Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626c582b7e3Smrg 362742a55b46SmrgRemove files from the build directory. 3628c582b7e3Smrg 362942a55b46SmrgRM is the name of the program to use to delete files associated with each FILE 3630e3d74329Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 363142a55b46Smrgto RM. 3632c582b7e3Smrg 363342a55b46SmrgIf FILE is a libtool library, object or program, all the files associated 363442a55b46Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 363542a55b46Smrg ;; 3636c582b7e3Smrg 363742a55b46Smrg compile) 363842a55b46Smrg $ECHO \ 363942a55b46Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640c582b7e3Smrg 364142a55b46SmrgCompile a source file into a libtool library object. 3642c582b7e3Smrg 364342a55b46SmrgThis mode accepts the following additional options: 3644c582b7e3Smrg 364542a55b46Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 364642a55b46Smrg -no-suppress do not suppress compiler output for multiple passes 364742a55b46Smrg -prefer-pic try to build PIC objects only 364842a55b46Smrg -prefer-non-pic try to build non-PIC objects only 3649e3d74329Smrg -shared do not build a '.o' file suitable for static linking 3650e3d74329Smrg -static only build a '.o' file suitable for static linking 365142a55b46Smrg -Wc,FLAG pass FLAG directly to the compiler 3652c582b7e3Smrg 3653e3d74329SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 365442a55b46Smrgfrom the given SOURCEFILE. 3655c582b7e3Smrg 365642a55b46SmrgThe output file name is determined by removing the directory component from 3657e3d74329SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658e3d74329Smrglibrary object suffix, '.lo'." 365942a55b46Smrg ;; 3660c582b7e3Smrg 366142a55b46Smrg execute) 366242a55b46Smrg $ECHO \ 366342a55b46Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664c582b7e3Smrg 366542a55b46SmrgAutomatically set library path, then run a program. 3666c582b7e3Smrg 366742a55b46SmrgThis mode accepts the following additional options: 3668c582b7e3Smrg 366942a55b46Smrg -dlopen FILE add the directory containing FILE to the library path 3670c582b7e3Smrg 3671e3d74329SmrgThis mode sets the library path environment variable according to '-dlopen' 367242a55b46Smrgflags. 3673c582b7e3Smrg 367442a55b46SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 367542a55b46Smrginto their corresponding uninstalled binary, and any of their required library 367642a55b46Smrgdirectories are added to the library path. 3677c582b7e3Smrg 367842a55b46SmrgThen, COMMAND is executed, with ARGS as arguments." 367942a55b46Smrg ;; 368042a55b46Smrg 368142a55b46Smrg finish) 368242a55b46Smrg $ECHO \ 368342a55b46Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 368442a55b46Smrg 368542a55b46SmrgComplete the installation of libtool libraries. 368642a55b46Smrg 368742a55b46SmrgEach LIBDIR is a directory that contains libtool libraries. 368842a55b46Smrg 368942a55b46SmrgThe commands that this mode executes may require superuser privileges. Use 3690e3d74329Smrgthe '--dry-run' option if you just want to see what would be executed." 369142a55b46Smrg ;; 369242a55b46Smrg 369342a55b46Smrg install) 369442a55b46Smrg $ECHO \ 369542a55b46Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 369642a55b46Smrg 369742a55b46SmrgInstall executables or libraries. 369842a55b46Smrg 369942a55b46SmrgINSTALL-COMMAND is the installation command. The first component should be 3700e3d74329Smrgeither the 'install' or 'cp' program. 370142a55b46Smrg 370242a55b46SmrgThe following components of INSTALL-COMMAND are treated specially: 370342a55b46Smrg 370442a55b46Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 370542a55b46Smrg 370642a55b46SmrgThe rest of the components are interpreted as arguments to that command (only 370742a55b46SmrgBSD-compatible install options are recognized)." 370842a55b46Smrg ;; 370942a55b46Smrg 371042a55b46Smrg link) 371142a55b46Smrg $ECHO \ 371242a55b46Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 371342a55b46Smrg 371442a55b46SmrgLink object files or libraries together to form another library, or to 371542a55b46Smrgcreate an executable program. 371642a55b46Smrg 371742a55b46SmrgLINK-COMMAND is a command using the C compiler that you would use to create 371842a55b46Smrga program from several object files. 371942a55b46Smrg 372042a55b46SmrgThe following components of LINK-COMMAND are treated specially: 372142a55b46Smrg 372242a55b46Smrg -all-static do not do any dynamic linking at all 372342a55b46Smrg -avoid-version do not add a version suffix if possible 372442a55b46Smrg -bindir BINDIR specify path to binaries directory (for systems where 372542a55b46Smrg libraries must be found in the PATH setting at runtime) 3726e3d74329Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 372742a55b46Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 372842a55b46Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 372942a55b46Smrg -export-symbols SYMFILE 373042a55b46Smrg try to export only the symbols listed in SYMFILE 373142a55b46Smrg -export-symbols-regex REGEX 373242a55b46Smrg try to export only the symbols matching REGEX 373342a55b46Smrg -LLIBDIR search LIBDIR for required installed libraries 373442a55b46Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 373542a55b46Smrg -module build a library that can dlopened 373642a55b46Smrg -no-fast-install disable the fast-install mode 373742a55b46Smrg -no-install link a not-installable executable 373842a55b46Smrg -no-undefined declare that a library does not refer to external symbols 373942a55b46Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740e3d74329Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3741e3d74329Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 374242a55b46Smrg -precious-files-regex REGEX 374342a55b46Smrg don't remove output files matching REGEX 374442a55b46Smrg -release RELEASE specify package release information 374542a55b46Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 374642a55b46Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 374742a55b46Smrg -shared only do dynamic linking of libtool libraries 374842a55b46Smrg -shrext SUFFIX override the standard shared library file extension 374942a55b46Smrg -static do not do any dynamic linking of uninstalled libtool libraries 375042a55b46Smrg -static-libtool-libs 375142a55b46Smrg do not do any dynamic linking of libtool libraries 375242a55b46Smrg -version-info CURRENT[:REVISION[:AGE]] 375342a55b46Smrg specify library version info [each variable defaults to 0] 375442a55b46Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 375542a55b46Smrg -Wc,FLAG 375642a55b46Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375742a55b46Smrg -Wl,FLAG 375842a55b46Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375942a55b46Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 376042a55b46Smrg 3761e3d74329SmrgAll other options (arguments beginning with '-') are ignored. 376242a55b46Smrg 3763e3d74329SmrgEvery other argument is treated as a filename. Files ending in '.la' are 376442a55b46Smrgtreated as uninstalled libtool libraries, other files are standard or library 376542a55b46Smrgobject files. 376642a55b46Smrg 3767e3d74329SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768e3d74329Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 376942a55b46Smrgrequired, except when creating a convenience library. 377042a55b46Smrg 3771e3d74329SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772e3d74329Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 377342a55b46Smrg 3774e3d74329SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 377542a55b46Smrgis created, otherwise an executable program is created." 377642a55b46Smrg ;; 377742a55b46Smrg 377842a55b46Smrg uninstall) 377942a55b46Smrg $ECHO \ 378042a55b46Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 378142a55b46Smrg 378242a55b46SmrgRemove libraries from an installation directory. 378342a55b46Smrg 378442a55b46SmrgRM is the name of the program to use to delete files associated with each FILE 3785e3d74329Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 378642a55b46Smrgto RM. 378742a55b46Smrg 378842a55b46SmrgIf FILE is a libtool library, all the files associated with it are deleted. 378942a55b46SmrgOtherwise, only FILE itself is deleted using RM." 379042a55b46Smrg ;; 379142a55b46Smrg 379242a55b46Smrg *) 3793e3d74329Smrg func_fatal_help "invalid operation mode '$opt_mode'" 379442a55b46Smrg ;; 3795c582b7e3Smrg esac 3796c582b7e3Smrg 379742a55b46Smrg echo 3798e3d74329Smrg $ECHO "Try '$progname --help' for more information about other modes." 379942a55b46Smrg} 3800c582b7e3Smrg 380142a55b46Smrg# Now that we've collected a possible --mode arg, show help if necessary 380242a55b46Smrgif $opt_help; then 3803e3d74329Smrg if test : = "$opt_help"; then 380442a55b46Smrg func_mode_help 380542a55b46Smrg else 380642a55b46Smrg { 380742a55b46Smrg func_help noexit 380842a55b46Smrg for opt_mode in compile link execute install finish uninstall clean; do 380942a55b46Smrg func_mode_help 381042a55b46Smrg done 3811e3d74329Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381242a55b46Smrg { 381342a55b46Smrg func_help noexit 381442a55b46Smrg for opt_mode in compile link execute install finish uninstall clean; do 381542a55b46Smrg echo 381642a55b46Smrg func_mode_help 381742a55b46Smrg done 381842a55b46Smrg } | 3819e3d74329Smrg $SED '1d 382042a55b46Smrg /^When reporting/,/^Report/{ 382142a55b46Smrg H 382242a55b46Smrg d 382342a55b46Smrg } 382442a55b46Smrg $x 382542a55b46Smrg /information about other modes/d 382642a55b46Smrg /more detailed .*MODE/d 382742a55b46Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382842a55b46Smrg fi 382942a55b46Smrg exit $? 383042a55b46Smrgfi 3831c582b7e3Smrg 3832c582b7e3Smrg 383342a55b46Smrg# func_mode_execute arg... 383442a55b46Smrgfunc_mode_execute () 383542a55b46Smrg{ 3836e3d74329Smrg $debug_cmd 3837e3d74329Smrg 383842a55b46Smrg # The first argument is the command name. 3839e3d74329Smrg cmd=$nonopt 384042a55b46Smrg test -z "$cmd" && \ 384142a55b46Smrg func_fatal_help "you must specify a COMMAND" 384242a55b46Smrg 384342a55b46Smrg # Handle -dlopen flags immediately. 384442a55b46Smrg for file in $opt_dlopen; do 384542a55b46Smrg test -f "$file" \ 3846e3d74329Smrg || func_fatal_help "'$file' is not a file" 384742a55b46Smrg 384842a55b46Smrg dir= 384942a55b46Smrg case $file in 385042a55b46Smrg *.la) 385142a55b46Smrg func_resolve_sysroot "$file" 385242a55b46Smrg file=$func_resolve_sysroot_result 385342a55b46Smrg 385442a55b46Smrg # Check to see that this really is a libtool archive. 385542a55b46Smrg func_lalib_unsafe_p "$file" \ 3856e3d74329Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 385742a55b46Smrg 385842a55b46Smrg # Read the libtool library. 385942a55b46Smrg dlname= 386042a55b46Smrg library_names= 386142a55b46Smrg func_source "$file" 386242a55b46Smrg 386342a55b46Smrg # Skip this library if it cannot be dlopened. 386442a55b46Smrg if test -z "$dlname"; then 386542a55b46Smrg # Warn if it was a shared library. 386642a55b46Smrg test -n "$library_names" && \ 3867e3d74329Smrg func_warning "'$file' was not linked with '-export-dynamic'" 386842a55b46Smrg continue 386942a55b46Smrg fi 387042a55b46Smrg 387142a55b46Smrg func_dirname "$file" "" "." 3872e3d74329Smrg dir=$func_dirname_result 387342a55b46Smrg 387442a55b46Smrg if test -f "$dir/$objdir/$dlname"; then 387542a55b46Smrg func_append dir "/$objdir" 387642a55b46Smrg else 387742a55b46Smrg if test ! -f "$dir/$dlname"; then 3878e3d74329Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 387942a55b46Smrg fi 388042a55b46Smrg fi 3881c582b7e3Smrg ;; 388242a55b46Smrg 388342a55b46Smrg *.lo) 388442a55b46Smrg # Just add the directory containing the .lo file. 388542a55b46Smrg func_dirname "$file" "" "." 3886e3d74329Smrg dir=$func_dirname_result 3887c582b7e3Smrg ;; 388842a55b46Smrg 388942a55b46Smrg *) 3890e3d74329Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 389142a55b46Smrg continue 3892c582b7e3Smrg ;; 389342a55b46Smrg esac 389442a55b46Smrg 389542a55b46Smrg # Get the absolute pathname. 389642a55b46Smrg absdir=`cd "$dir" && pwd` 3897e3d74329Smrg test -n "$absdir" && dir=$absdir 389842a55b46Smrg 389942a55b46Smrg # Now add the directory to shlibpath_var. 390042a55b46Smrg if eval "test -z \"\$$shlibpath_var\""; then 390142a55b46Smrg eval "$shlibpath_var=\"\$dir\"" 390242a55b46Smrg else 390342a55b46Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904c582b7e3Smrg fi 390542a55b46Smrg done 390642a55b46Smrg 390742a55b46Smrg # This variable tells wrapper scripts just to set shlibpath_var 390842a55b46Smrg # rather than running their programs. 3909e3d74329Smrg libtool_execute_magic=$magic 391042a55b46Smrg 391142a55b46Smrg # Check if any of the arguments is a wrapper script. 391242a55b46Smrg args= 391342a55b46Smrg for file 391442a55b46Smrg do 391542a55b46Smrg case $file in 391642a55b46Smrg -* | *.la | *.lo ) ;; 391742a55b46Smrg *) 391842a55b46Smrg # Do a test to see if this is really a libtool program. 391942a55b46Smrg if func_ltwrapper_script_p "$file"; then 392042a55b46Smrg func_source "$file" 392142a55b46Smrg # Transform arg to wrapped name. 3922e3d74329Smrg file=$progdir/$program 392342a55b46Smrg elif func_ltwrapper_executable_p "$file"; then 392442a55b46Smrg func_ltwrapper_scriptname "$file" 392542a55b46Smrg func_source "$func_ltwrapper_scriptname_result" 392642a55b46Smrg # Transform arg to wrapped name. 3927e3d74329Smrg file=$progdir/$program 392842a55b46Smrg fi 392942a55b46Smrg ;; 393042a55b46Smrg esac 393142a55b46Smrg # Quote arguments (to preserve shell metacharacters). 393242a55b46Smrg func_append_quoted args "$file" 393342a55b46Smrg done 393442a55b46Smrg 3935e3d74329Smrg if $opt_dry_run; then 3936e3d74329Smrg # Display what would be done. 3937e3d74329Smrg if test -n "$shlibpath_var"; then 3938e3d74329Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939e3d74329Smrg echo "export $shlibpath_var" 3940e3d74329Smrg fi 3941e3d74329Smrg $ECHO "$cmd$args" 3942e3d74329Smrg exit $EXIT_SUCCESS 3943e3d74329Smrg else 394442a55b46Smrg if test -n "$shlibpath_var"; then 394542a55b46Smrg # Export the shlibpath_var. 394642a55b46Smrg eval "export $shlibpath_var" 3947c582b7e3Smrg fi 394842a55b46Smrg 394942a55b46Smrg # Restore saved environment variables 395042a55b46Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 395142a55b46Smrg do 395242a55b46Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 395342a55b46Smrg $lt_var=\$save_$lt_var; export $lt_var 395442a55b46Smrg else 395542a55b46Smrg $lt_unset $lt_var 395642a55b46Smrg fi" 395742a55b46Smrg done 395842a55b46Smrg 395942a55b46Smrg # Now prepare to actually exec the command. 3960e3d74329Smrg exec_cmd=\$cmd$args 396142a55b46Smrg fi 396242a55b46Smrg} 3963c582b7e3Smrg 3964e3d74329Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965c582b7e3Smrg 3966c582b7e3Smrg 396742a55b46Smrg# func_mode_finish arg... 396842a55b46Smrgfunc_mode_finish () 396942a55b46Smrg{ 3970e3d74329Smrg $debug_cmd 3971e3d74329Smrg 397242a55b46Smrg libs= 397342a55b46Smrg libdirs= 397442a55b46Smrg admincmds= 3975c582b7e3Smrg 397642a55b46Smrg for opt in "$nonopt" ${1+"$@"} 397742a55b46Smrg do 397842a55b46Smrg if test -d "$opt"; then 397942a55b46Smrg func_append libdirs " $opt" 3980c582b7e3Smrg 398142a55b46Smrg elif test -f "$opt"; then 398242a55b46Smrg if func_lalib_unsafe_p "$opt"; then 398342a55b46Smrg func_append libs " $opt" 398442a55b46Smrg else 3985e3d74329Smrg func_warning "'$opt' is not a valid libtool archive" 3986c582b7e3Smrg fi 3987c582b7e3Smrg 398842a55b46Smrg else 3989e3d74329Smrg func_fatal_error "invalid argument '$opt'" 399042a55b46Smrg fi 399142a55b46Smrg done 3992c582b7e3Smrg 399342a55b46Smrg if test -n "$libs"; then 399442a55b46Smrg if test -n "$lt_sysroot"; then 399542a55b46Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 399642a55b46Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 399742a55b46Smrg else 399842a55b46Smrg sysroot_cmd= 399942a55b46Smrg fi 4000c582b7e3Smrg 400142a55b46Smrg # Remove sysroot references 400242a55b46Smrg if $opt_dry_run; then 400342a55b46Smrg for lib in $libs; do 4004e3d74329Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 400542a55b46Smrg done 400642a55b46Smrg else 400742a55b46Smrg tmpdir=`func_mktempdir` 400842a55b46Smrg for lib in $libs; do 4009e3d74329Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 401042a55b46Smrg > $tmpdir/tmp-la 401142a55b46Smrg mv -f $tmpdir/tmp-la $lib 4012c582b7e3Smrg done 401342a55b46Smrg ${RM}r "$tmpdir" 401442a55b46Smrg fi 401542a55b46Smrg fi 401642a55b46Smrg 401742a55b46Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 401842a55b46Smrg for libdir in $libdirs; do 401942a55b46Smrg if test -n "$finish_cmds"; then 402042a55b46Smrg # Do each command in the finish commands. 402142a55b46Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 402242a55b46Smrg'"$cmd"'"' 402342a55b46Smrg fi 402442a55b46Smrg if test -n "$finish_eval"; then 402542a55b46Smrg # Do the single finish_eval. 402642a55b46Smrg eval cmds=\"$finish_eval\" 402742a55b46Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 402842a55b46Smrg $cmds" 4029c582b7e3Smrg fi 403042a55b46Smrg done 403142a55b46Smrg fi 4032c582b7e3Smrg 403342a55b46Smrg # Exit here if they wanted silent mode. 4034e3d74329Smrg $opt_quiet && exit $EXIT_SUCCESS 4035c582b7e3Smrg 403642a55b46Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 403742a55b46Smrg echo "----------------------------------------------------------------------" 403842a55b46Smrg echo "Libraries have been installed in:" 403942a55b46Smrg for libdir in $libdirs; do 404042a55b46Smrg $ECHO " $libdir" 404142a55b46Smrg done 404242a55b46Smrg echo 404342a55b46Smrg echo "If you ever happen to want to link against installed libraries" 404442a55b46Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045e3d74329Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 404642a55b46Smrg echo "flag during linking and do at least one of the following:" 404742a55b46Smrg if test -n "$shlibpath_var"; then 4048e3d74329Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 404942a55b46Smrg echo " during execution" 405042a55b46Smrg fi 405142a55b46Smrg if test -n "$runpath_var"; then 4052e3d74329Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 405342a55b46Smrg echo " during linking" 405442a55b46Smrg fi 405542a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 405642a55b46Smrg libdir=LIBDIR 405742a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 405842a55b46Smrg 4059e3d74329Smrg $ECHO " - use the '$flag' linker flag" 406042a55b46Smrg fi 406142a55b46Smrg if test -n "$admincmds"; then 406242a55b46Smrg $ECHO " - have your system administrator run these commands:$admincmds" 406342a55b46Smrg fi 406442a55b46Smrg if test -f /etc/ld.so.conf; then 4065e3d74329Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 406642a55b46Smrg fi 406742a55b46Smrg echo 406842a55b46Smrg 406942a55b46Smrg echo "See any operating system documentation about shared libraries for" 407042a55b46Smrg case $host in 407142a55b46Smrg solaris2.[6789]|solaris2.1[0-9]) 407242a55b46Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 407342a55b46Smrg echo "pages." 407442a55b46Smrg ;; 4075c582b7e3Smrg *) 407642a55b46Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077c582b7e3Smrg ;; 407842a55b46Smrg esac 407942a55b46Smrg echo "----------------------------------------------------------------------" 408042a55b46Smrg fi 408142a55b46Smrg exit $EXIT_SUCCESS 408242a55b46Smrg} 4083c582b7e3Smrg 4084e3d74329Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085c582b7e3Smrg 4086c582b7e3Smrg 408742a55b46Smrg# func_mode_install arg... 408842a55b46Smrgfunc_mode_install () 408942a55b46Smrg{ 4090e3d74329Smrg $debug_cmd 4091e3d74329Smrg 409242a55b46Smrg # There may be an optional sh(1) argument at the beginning of 409342a55b46Smrg # install_prog (especially on Windows NT). 4094e3d74329Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 409542a55b46Smrg # Allow the use of GNU shtool's install command. 4096e3d74329Smrg case $nonopt in *shtool*) :;; *) false;; esac 4097e3d74329Smrg then 409842a55b46Smrg # Aesthetically quote it. 409942a55b46Smrg func_quote_for_eval "$nonopt" 410042a55b46Smrg install_prog="$func_quote_for_eval_result " 410142a55b46Smrg arg=$1 410242a55b46Smrg shift 410342a55b46Smrg else 410442a55b46Smrg install_prog= 410542a55b46Smrg arg=$nonopt 410642a55b46Smrg fi 410742a55b46Smrg 410842a55b46Smrg # The real first argument should be the name of the installation program. 410942a55b46Smrg # Aesthetically quote it. 411042a55b46Smrg func_quote_for_eval "$arg" 411142a55b46Smrg func_append install_prog "$func_quote_for_eval_result" 411242a55b46Smrg install_shared_prog=$install_prog 411342a55b46Smrg case " $install_prog " in 411442a55b46Smrg *[\\\ /]cp\ *) install_cp=: ;; 411542a55b46Smrg *) install_cp=false ;; 411642a55b46Smrg esac 411742a55b46Smrg 411842a55b46Smrg # We need to accept at least all the BSD install flags. 411942a55b46Smrg dest= 412042a55b46Smrg files= 412142a55b46Smrg opts= 412242a55b46Smrg prev= 412342a55b46Smrg install_type= 4124e3d74329Smrg isdir=false 412542a55b46Smrg stripme= 412642a55b46Smrg no_mode=: 412742a55b46Smrg for arg 412842a55b46Smrg do 412942a55b46Smrg arg2= 413042a55b46Smrg if test -n "$dest"; then 413142a55b46Smrg func_append files " $dest" 413242a55b46Smrg dest=$arg 413342a55b46Smrg continue 413442a55b46Smrg fi 413542a55b46Smrg 413642a55b46Smrg case $arg in 4137e3d74329Smrg -d) isdir=: ;; 413842a55b46Smrg -f) 413942a55b46Smrg if $install_cp; then :; else 414042a55b46Smrg prev=$arg 414142a55b46Smrg fi 414242a55b46Smrg ;; 414342a55b46Smrg -g | -m | -o) 414442a55b46Smrg prev=$arg 414542a55b46Smrg ;; 414642a55b46Smrg -s) 414742a55b46Smrg stripme=" -s" 414842a55b46Smrg continue 414942a55b46Smrg ;; 415042a55b46Smrg -*) 415142a55b46Smrg ;; 415242a55b46Smrg *) 415342a55b46Smrg # If the previous option needed an argument, then skip it. 415442a55b46Smrg if test -n "$prev"; then 4155e3d74329Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415642a55b46Smrg arg2=$install_override_mode 415742a55b46Smrg no_mode=false 4158c582b7e3Smrg fi 415942a55b46Smrg prev= 416042a55b46Smrg else 416142a55b46Smrg dest=$arg 4162c582b7e3Smrg continue 4163c582b7e3Smrg fi 416442a55b46Smrg ;; 416542a55b46Smrg esac 4166c582b7e3Smrg 416742a55b46Smrg # Aesthetically quote the argument. 416842a55b46Smrg func_quote_for_eval "$arg" 416942a55b46Smrg func_append install_prog " $func_quote_for_eval_result" 417042a55b46Smrg if test -n "$arg2"; then 417142a55b46Smrg func_quote_for_eval "$arg2" 417242a55b46Smrg fi 417342a55b46Smrg func_append install_shared_prog " $func_quote_for_eval_result" 417442a55b46Smrg done 4175c582b7e3Smrg 417642a55b46Smrg test -z "$install_prog" && \ 417742a55b46Smrg func_fatal_help "you must specify an install program" 4178c582b7e3Smrg 417942a55b46Smrg test -n "$prev" && \ 4180e3d74329Smrg func_fatal_help "the '$prev' option requires an argument" 4181c582b7e3Smrg 418242a55b46Smrg if test -n "$install_override_mode" && $no_mode; then 418342a55b46Smrg if $install_cp; then :; else 418442a55b46Smrg func_quote_for_eval "$install_override_mode" 418542a55b46Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418642a55b46Smrg fi 418742a55b46Smrg fi 4188c582b7e3Smrg 418942a55b46Smrg if test -z "$files"; then 419042a55b46Smrg if test -z "$dest"; then 419142a55b46Smrg func_fatal_help "no file or destination specified" 419242a55b46Smrg else 419342a55b46Smrg func_fatal_help "you must specify a destination" 419442a55b46Smrg fi 419542a55b46Smrg fi 4196c582b7e3Smrg 419742a55b46Smrg # Strip any trailing slash from the destination. 419842a55b46Smrg func_stripname '' '/' "$dest" 419942a55b46Smrg dest=$func_stripname_result 4200c582b7e3Smrg 420142a55b46Smrg # Check to see that the destination is a directory. 4202e3d74329Smrg test -d "$dest" && isdir=: 4203e3d74329Smrg if $isdir; then 4204e3d74329Smrg destdir=$dest 420542a55b46Smrg destname= 420642a55b46Smrg else 420742a55b46Smrg func_dirname_and_basename "$dest" "" "." 4208e3d74329Smrg destdir=$func_dirname_result 4209e3d74329Smrg destname=$func_basename_result 4210c582b7e3Smrg 421142a55b46Smrg # Not a directory, so check to see that there is only one file specified. 421242a55b46Smrg set dummy $files; shift 421342a55b46Smrg test "$#" -gt 1 && \ 4214e3d74329Smrg func_fatal_help "'$dest' is not a directory" 421542a55b46Smrg fi 421642a55b46Smrg case $destdir in 421742a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 421842a55b46Smrg *) 421942a55b46Smrg for file in $files; do 422042a55b46Smrg case $file in 422142a55b46Smrg *.lo) ;; 422242a55b46Smrg *) 4223e3d74329Smrg func_fatal_help "'$destdir' must be an absolute directory name" 422442a55b46Smrg ;; 422542a55b46Smrg esac 422642a55b46Smrg done 422742a55b46Smrg ;; 422842a55b46Smrg esac 4229c582b7e3Smrg 423042a55b46Smrg # This variable tells wrapper scripts just to set variables rather 423142a55b46Smrg # than running their programs. 4232e3d74329Smrg libtool_install_magic=$magic 4233c582b7e3Smrg 423442a55b46Smrg staticlibs= 423542a55b46Smrg future_libdirs= 423642a55b46Smrg current_libdirs= 423742a55b46Smrg for file in $files; do 4238c582b7e3Smrg 423942a55b46Smrg # Do each installation. 424042a55b46Smrg case $file in 424142a55b46Smrg *.$libext) 424242a55b46Smrg # Do the static libraries later. 424342a55b46Smrg func_append staticlibs " $file" 424442a55b46Smrg ;; 4245c582b7e3Smrg 424642a55b46Smrg *.la) 424742a55b46Smrg func_resolve_sysroot "$file" 424842a55b46Smrg file=$func_resolve_sysroot_result 4249c582b7e3Smrg 425042a55b46Smrg # Check to see that this really is a libtool archive. 425142a55b46Smrg func_lalib_unsafe_p "$file" \ 4252e3d74329Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4253c582b7e3Smrg 425442a55b46Smrg library_names= 425542a55b46Smrg old_library= 425642a55b46Smrg relink_command= 425742a55b46Smrg func_source "$file" 4258c582b7e3Smrg 425942a55b46Smrg # Add the libdir to current_libdirs if it is the destination. 426042a55b46Smrg if test "X$destdir" = "X$libdir"; then 426142a55b46Smrg case "$current_libdirs " in 426242a55b46Smrg *" $libdir "*) ;; 426342a55b46Smrg *) func_append current_libdirs " $libdir" ;; 426442a55b46Smrg esac 426542a55b46Smrg else 426642a55b46Smrg # Note the libdir as a future libdir. 426742a55b46Smrg case "$future_libdirs " in 426842a55b46Smrg *" $libdir "*) ;; 426942a55b46Smrg *) func_append future_libdirs " $libdir" ;; 427042a55b46Smrg esac 427142a55b46Smrg fi 4272c582b7e3Smrg 427342a55b46Smrg func_dirname "$file" "/" "" 4274e3d74329Smrg dir=$func_dirname_result 427542a55b46Smrg func_append dir "$objdir" 4276c582b7e3Smrg 427742a55b46Smrg if test -n "$relink_command"; then 427842a55b46Smrg # Determine the prefix the user has applied to our future dir. 427942a55b46Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280c582b7e3Smrg 428142a55b46Smrg # Don't allow the user to place us outside of our expected 428242a55b46Smrg # location b/c this prevents finding dependent libraries that 428342a55b46Smrg # are installed to the same prefix. 428442a55b46Smrg # At present, this check doesn't affect windows .dll's that 428542a55b46Smrg # are installed into $libdir/../bin (currently, that works fine) 428642a55b46Smrg # but it's something to keep an eye on. 428742a55b46Smrg test "$inst_prefix_dir" = "$destdir" && \ 4288e3d74329Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 428942a55b46Smrg 429042a55b46Smrg if test -n "$inst_prefix_dir"; then 429142a55b46Smrg # Stick the inst_prefix_dir data into the link command. 429242a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293c582b7e3Smrg else 429442a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295c582b7e3Smrg fi 4296c582b7e3Smrg 4297e3d74329Smrg func_warning "relinking '$file'" 429842a55b46Smrg func_show_eval "$relink_command" \ 4299e3d74329Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 430042a55b46Smrg fi 430142a55b46Smrg 430242a55b46Smrg # See the names of the shared library. 430342a55b46Smrg set dummy $library_names; shift 430442a55b46Smrg if test -n "$1"; then 4305e3d74329Smrg realname=$1 430642a55b46Smrg shift 430742a55b46Smrg 4308e3d74329Smrg srcname=$realname 4309e3d74329Smrg test -n "$relink_command" && srcname=${realname}T 431042a55b46Smrg 431142a55b46Smrg # Install the shared library and build the symlinks. 431242a55b46Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 431342a55b46Smrg 'exit $?' 4314e3d74329Smrg tstripme=$stripme 431542a55b46Smrg case $host_os in 431642a55b46Smrg cygwin* | mingw* | pw32* | cegcc*) 431742a55b46Smrg case $realname in 431842a55b46Smrg *.dll.a) 4319e3d74329Smrg tstripme= 4320e3d74329Smrg ;; 4321e3d74329Smrg esac 4322e3d74329Smrg ;; 4323e3d74329Smrg os2*) 4324e3d74329Smrg case $realname in 4325e3d74329Smrg *_dll.a) 4326e3d74329Smrg tstripme= 432742a55b46Smrg ;; 432842a55b46Smrg esac 432942a55b46Smrg ;; 433042a55b46Smrg esac 433142a55b46Smrg if test -n "$tstripme" && test -n "$striplib"; then 433242a55b46Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333c582b7e3Smrg fi 4334c582b7e3Smrg 433542a55b46Smrg if test "$#" -gt 0; then 433642a55b46Smrg # Delete the old symlinks, and create new ones. 4337e3d74329Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 433842a55b46Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 433942a55b46Smrg # so we also need to try rm && ln -s. 434042a55b46Smrg for linkname 434142a55b46Smrg do 434242a55b46Smrg test "$linkname" != "$realname" \ 434342a55b46Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344c582b7e3Smrg done 4345c582b7e3Smrg fi 4346c582b7e3Smrg 434742a55b46Smrg # Do each command in the postinstall commands. 4348e3d74329Smrg lib=$destdir/$realname 434942a55b46Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 435042a55b46Smrg fi 4351c582b7e3Smrg 435242a55b46Smrg # Install the pseudo-library for information purposes. 435342a55b46Smrg func_basename "$file" 4354e3d74329Smrg name=$func_basename_result 4355e3d74329Smrg instname=$dir/${name}i 435642a55b46Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357c582b7e3Smrg 435842a55b46Smrg # Maybe install the static library, too. 435942a55b46Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 436042a55b46Smrg ;; 436142a55b46Smrg 436242a55b46Smrg *.lo) 436342a55b46Smrg # Install (i.e. copy) a libtool object. 436442a55b46Smrg 436542a55b46Smrg # Figure out destination file name, if it wasn't already specified. 436642a55b46Smrg if test -n "$destname"; then 4367e3d74329Smrg destfile=$destdir/$destname 4368c582b7e3Smrg else 436942a55b46Smrg func_basename "$file" 4370e3d74329Smrg destfile=$func_basename_result 4371e3d74329Smrg destfile=$destdir/$destfile 4372c582b7e3Smrg fi 437342a55b46Smrg 437442a55b46Smrg # Deduce the name of the destination old-style object file. 437542a55b46Smrg case $destfile in 437642a55b46Smrg *.lo) 437742a55b46Smrg func_lo2o "$destfile" 437842a55b46Smrg staticdest=$func_lo2o_result 437942a55b46Smrg ;; 438042a55b46Smrg *.$objext) 4381e3d74329Smrg staticdest=$destfile 438242a55b46Smrg destfile= 438342a55b46Smrg ;; 438442a55b46Smrg *) 4385e3d74329Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386c582b7e3Smrg ;; 4387c582b7e3Smrg esac 4388c582b7e3Smrg 438942a55b46Smrg # Install the libtool object if requested. 439042a55b46Smrg test -n "$destfile" && \ 439142a55b46Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392c582b7e3Smrg 439342a55b46Smrg # Install the old object if enabled. 4394e3d74329Smrg if test yes = "$build_old_libs"; then 439542a55b46Smrg # Deduce the name of the old-style object file. 439642a55b46Smrg func_lo2o "$file" 439742a55b46Smrg staticobj=$func_lo2o_result 439842a55b46Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 439942a55b46Smrg fi 440042a55b46Smrg exit $EXIT_SUCCESS 440142a55b46Smrg ;; 4402c582b7e3Smrg 440342a55b46Smrg *) 440442a55b46Smrg # Figure out destination file name, if it wasn't already specified. 440542a55b46Smrg if test -n "$destname"; then 4406e3d74329Smrg destfile=$destdir/$destname 440742a55b46Smrg else 440842a55b46Smrg func_basename "$file" 4409e3d74329Smrg destfile=$func_basename_result 4410e3d74329Smrg destfile=$destdir/$destfile 441142a55b46Smrg fi 4412c582b7e3Smrg 441342a55b46Smrg # If the file is missing, and there is a .exe on the end, strip it 441442a55b46Smrg # because it is most likely a libtool script we actually want to 441542a55b46Smrg # install 4416e3d74329Smrg stripped_ext= 441742a55b46Smrg case $file in 441842a55b46Smrg *.exe) 441942a55b46Smrg if test ! -f "$file"; then 442042a55b46Smrg func_stripname '' '.exe' "$file" 442142a55b46Smrg file=$func_stripname_result 4422e3d74329Smrg stripped_ext=.exe 442342a55b46Smrg fi 442442a55b46Smrg ;; 442542a55b46Smrg esac 4426c582b7e3Smrg 442742a55b46Smrg # Do a test to see if this is really a libtool program. 442842a55b46Smrg case $host in 442942a55b46Smrg *cygwin* | *mingw*) 443042a55b46Smrg if func_ltwrapper_executable_p "$file"; then 443142a55b46Smrg func_ltwrapper_scriptname "$file" 443242a55b46Smrg wrapper=$func_ltwrapper_scriptname_result 443342a55b46Smrg else 443442a55b46Smrg func_stripname '' '.exe' "$file" 443542a55b46Smrg wrapper=$func_stripname_result 443642a55b46Smrg fi 443742a55b46Smrg ;; 443842a55b46Smrg *) 443942a55b46Smrg wrapper=$file 444042a55b46Smrg ;; 444142a55b46Smrg esac 444242a55b46Smrg if func_ltwrapper_script_p "$wrapper"; then 444342a55b46Smrg notinst_deplibs= 444442a55b46Smrg relink_command= 4445c582b7e3Smrg 444642a55b46Smrg func_source "$wrapper" 4447c582b7e3Smrg 444842a55b46Smrg # Check the variables that should have been set. 444942a55b46Smrg test -z "$generated_by_libtool_version" && \ 4450e3d74329Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451c582b7e3Smrg 4452e3d74329Smrg finalize=: 445342a55b46Smrg for lib in $notinst_deplibs; do 445442a55b46Smrg # Check to see that each library is installed. 445542a55b46Smrg libdir= 445642a55b46Smrg if test -f "$lib"; then 445742a55b46Smrg func_source "$lib" 445842a55b46Smrg fi 4459e3d74329Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 446042a55b46Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4461e3d74329Smrg func_warning "'$lib' has not been installed in '$libdir'" 4462e3d74329Smrg finalize=false 446342a55b46Smrg fi 446442a55b46Smrg done 4465c582b7e3Smrg 446642a55b46Smrg relink_command= 446742a55b46Smrg func_source "$wrapper" 446842a55b46Smrg 446942a55b46Smrg outputname= 4470e3d74329Smrg if test no = "$fast_install" && test -n "$relink_command"; then 447142a55b46Smrg $opt_dry_run || { 4472e3d74329Smrg if $finalize; then 447342a55b46Smrg tmpdir=`func_mktempdir` 447442a55b46Smrg func_basename "$file$stripped_ext" 4475e3d74329Smrg file=$func_basename_result 4476e3d74329Smrg outputname=$tmpdir/$file 447742a55b46Smrg # Replace the output file specification. 447842a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 447942a55b46Smrg 4480e3d74329Smrg $opt_quiet || { 448142a55b46Smrg func_quote_for_expand "$relink_command" 448242a55b46Smrg eval "func_echo $func_quote_for_expand_result" 448342a55b46Smrg } 448442a55b46Smrg if eval "$relink_command"; then : 448542a55b46Smrg else 4486e3d74329Smrg func_error "error: relink '$file' with the above command before installing it" 448742a55b46Smrg $opt_dry_run || ${RM}r "$tmpdir" 448842a55b46Smrg continue 448942a55b46Smrg fi 4490e3d74329Smrg file=$outputname 449142a55b46Smrg else 4492e3d74329Smrg func_warning "cannot relink '$file'" 449342a55b46Smrg fi 449442a55b46Smrg } 449542a55b46Smrg else 449642a55b46Smrg # Install the binary that we compiled earlier. 449742a55b46Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 449842a55b46Smrg fi 4499c582b7e3Smrg fi 450042a55b46Smrg 450142a55b46Smrg # remove .exe since cygwin /usr/bin/install will append another 450242a55b46Smrg # one anyway 450342a55b46Smrg case $install_prog,$host in 450442a55b46Smrg */usr/bin/install*,*cygwin*) 450542a55b46Smrg case $file:$destfile in 450642a55b46Smrg *.exe:*.exe) 450742a55b46Smrg # this is ok 450842a55b46Smrg ;; 450942a55b46Smrg *.exe:*) 451042a55b46Smrg destfile=$destfile.exe 451142a55b46Smrg ;; 451242a55b46Smrg *:*.exe) 451342a55b46Smrg func_stripname '' '.exe' "$destfile" 451442a55b46Smrg destfile=$func_stripname_result 451542a55b46Smrg ;; 451642a55b46Smrg esac 451742a55b46Smrg ;; 451842a55b46Smrg esac 451942a55b46Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 452042a55b46Smrg $opt_dry_run || if test -n "$outputname"; then 452142a55b46Smrg ${RM}r "$tmpdir" 4522c582b7e3Smrg fi 4523c582b7e3Smrg ;; 4524c582b7e3Smrg esac 452542a55b46Smrg done 4526c582b7e3Smrg 452742a55b46Smrg for file in $staticlibs; do 452842a55b46Smrg func_basename "$file" 4529e3d74329Smrg name=$func_basename_result 4530c582b7e3Smrg 453142a55b46Smrg # Set up the ranlib parameters. 4532e3d74329Smrg oldlib=$destdir/$name 453342a55b46Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 453442a55b46Smrg tool_oldlib=$func_to_tool_file_result 4535c582b7e3Smrg 453642a55b46Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 453742a55b46Smrg 453842a55b46Smrg if test -n "$stripme" && test -n "$old_striplib"; then 453942a55b46Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540c582b7e3Smrg fi 4541c582b7e3Smrg 454242a55b46Smrg # Do each command in the postinstall commands. 454342a55b46Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 454442a55b46Smrg done 4545c582b7e3Smrg 454642a55b46Smrg test -n "$future_libdirs" && \ 4547e3d74329Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548c582b7e3Smrg 454942a55b46Smrg if test -n "$current_libdirs"; then 455042a55b46Smrg # Maybe just do a dry run. 455142a55b46Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552e3d74329Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 455342a55b46Smrg else 455442a55b46Smrg exit $EXIT_SUCCESS 455542a55b46Smrg fi 455642a55b46Smrg} 4557c582b7e3Smrg 4558e3d74329Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559c582b7e3Smrg 4560c582b7e3Smrg 456142a55b46Smrg# func_generate_dlsyms outputname originator pic_p 456242a55b46Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 456342a55b46Smrg# a dlpreopen symbol table. 456442a55b46Smrgfunc_generate_dlsyms () 456542a55b46Smrg{ 4566e3d74329Smrg $debug_cmd 4567e3d74329Smrg 4568e3d74329Smrg my_outputname=$1 4569e3d74329Smrg my_originator=$2 4570e3d74329Smrg my_pic_p=${3-false} 4571e3d74329Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 457242a55b46Smrg my_dlsyms= 457342a55b46Smrg 4574e3d74329Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 457542a55b46Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576e3d74329Smrg my_dlsyms=${my_outputname}S.c 457742a55b46Smrg else 457842a55b46Smrg func_error "not configured to extract global symbols from dlpreopened files" 457942a55b46Smrg fi 458042a55b46Smrg fi 4581c582b7e3Smrg 458242a55b46Smrg if test -n "$my_dlsyms"; then 458342a55b46Smrg case $my_dlsyms in 458442a55b46Smrg "") ;; 458542a55b46Smrg *.c) 458642a55b46Smrg # Discover the nlist of each of the dlfiles. 4587e3d74329Smrg nlist=$output_objdir/$my_outputname.nm 4588c582b7e3Smrg 458942a55b46Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590c582b7e3Smrg 459142a55b46Smrg # Parse the name list into a source file. 459242a55b46Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4593c582b7e3Smrg 459442a55b46Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595e3d74329Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596e3d74329Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597c582b7e3Smrg 459842a55b46Smrg#ifdef __cplusplus 459942a55b46Smrgextern \"C\" { 460042a55b46Smrg#endif 4601c582b7e3Smrg 4602e3d74329Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460342a55b46Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460442a55b46Smrg#endif 4605c582b7e3Smrg 460642a55b46Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607e3d74329Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608e3d74329Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 460942a55b46Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 461042a55b46Smrg# define LT_DLSYM_CONST 4611e3d74329Smrg#elif defined __osf__ 461242a55b46Smrg/* This system does not cope well with relocations in const data. */ 461342a55b46Smrg# define LT_DLSYM_CONST 461442a55b46Smrg#else 461542a55b46Smrg# define LT_DLSYM_CONST const 461642a55b46Smrg#endif 4617c582b7e3Smrg 4618e3d74329Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619e3d74329Smrg 462042a55b46Smrg/* External symbol declarations for the compiler. */\ 462142a55b46Smrg" 4622c582b7e3Smrg 4623e3d74329Smrg if test yes = "$dlself"; then 4624e3d74329Smrg func_verbose "generating symbol list for '$output'" 4625c582b7e3Smrg 462642a55b46Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627c582b7e3Smrg 462842a55b46Smrg # Add our own program objects to the symbol list. 462942a55b46Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 463042a55b46Smrg for progfile in $progfiles; do 463142a55b46Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632e3d74329Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 463342a55b46Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634c582b7e3Smrg done 4635c582b7e3Smrg 463642a55b46Smrg if test -n "$exclude_expsyms"; then 463742a55b46Smrg $opt_dry_run || { 463842a55b46Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 463942a55b46Smrg eval '$MV "$nlist"T "$nlist"' 464042a55b46Smrg } 464142a55b46Smrg fi 4642c582b7e3Smrg 464342a55b46Smrg if test -n "$export_symbols_regex"; then 464442a55b46Smrg $opt_dry_run || { 464542a55b46Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 464642a55b46Smrg eval '$MV "$nlist"T "$nlist"' 464742a55b46Smrg } 464842a55b46Smrg fi 4649c582b7e3Smrg 465042a55b46Smrg # Prepare the list of exported symbols 465142a55b46Smrg if test -z "$export_symbols"; then 4652e3d74329Smrg export_symbols=$output_objdir/$outputname.exp 465342a55b46Smrg $opt_dry_run || { 465442a55b46Smrg $RM $export_symbols 4655e3d74329Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 465642a55b46Smrg case $host in 465742a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 465842a55b46Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 465942a55b46Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 466042a55b46Smrg ;; 466142a55b46Smrg esac 466242a55b46Smrg } 466342a55b46Smrg else 466442a55b46Smrg $opt_dry_run || { 4665e3d74329Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 466642a55b46Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 466742a55b46Smrg eval '$MV "$nlist"T "$nlist"' 466842a55b46Smrg case $host in 466942a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 467042a55b46Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 467142a55b46Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 467242a55b46Smrg ;; 467342a55b46Smrg esac 467442a55b46Smrg } 467542a55b46Smrg fi 467642a55b46Smrg fi 4677c582b7e3Smrg 467842a55b46Smrg for dlprefile in $dlprefiles; do 4679e3d74329Smrg func_verbose "extracting global C symbols from '$dlprefile'" 468042a55b46Smrg func_basename "$dlprefile" 4681e3d74329Smrg name=$func_basename_result 468242a55b46Smrg case $host in 468342a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 468442a55b46Smrg # if an import library, we need to obtain dlname 468542a55b46Smrg if func_win32_import_lib_p "$dlprefile"; then 468642a55b46Smrg func_tr_sh "$dlprefile" 468742a55b46Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688e3d74329Smrg dlprefile_dlbasename= 468942a55b46Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 469042a55b46Smrg # Use subshell, to avoid clobbering current variable values 469142a55b46Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692e3d74329Smrg if test -n "$dlprefile_dlname"; then 469342a55b46Smrg func_basename "$dlprefile_dlname" 4694e3d74329Smrg dlprefile_dlbasename=$func_basename_result 469542a55b46Smrg else 469642a55b46Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 469742a55b46Smrg $sharedlib_from_linklib_cmd "$dlprefile" 469842a55b46Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 469942a55b46Smrg fi 470042a55b46Smrg fi 470142a55b46Smrg $opt_dry_run || { 4702e3d74329Smrg if test -n "$dlprefile_dlbasename"; then 470342a55b46Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 470442a55b46Smrg else 470542a55b46Smrg func_warning "Could not compute DLL name from $name" 470642a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 470742a55b46Smrg fi 470842a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 470942a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 471042a55b46Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 471142a55b46Smrg } 471242a55b46Smrg else # not an import lib 471342a55b46Smrg $opt_dry_run || { 471442a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 471542a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 471642a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 471742a55b46Smrg } 471842a55b46Smrg fi 471942a55b46Smrg ;; 472042a55b46Smrg *) 472142a55b46Smrg $opt_dry_run || { 472242a55b46Smrg eval '$ECHO ": $name " >> "$nlist"' 472342a55b46Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 472442a55b46Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 472542a55b46Smrg } 472642a55b46Smrg ;; 472742a55b46Smrg esac 472842a55b46Smrg done 4729c582b7e3Smrg 473042a55b46Smrg $opt_dry_run || { 473142a55b46Smrg # Make sure we have at least an empty file. 473242a55b46Smrg test -f "$nlist" || : > "$nlist" 4733c582b7e3Smrg 473442a55b46Smrg if test -n "$exclude_expsyms"; then 473542a55b46Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 473642a55b46Smrg $MV "$nlist"T "$nlist" 473742a55b46Smrg fi 4738c582b7e3Smrg 473942a55b46Smrg # Try sorting and uniquifying the output. 474042a55b46Smrg if $GREP -v "^: " < "$nlist" | 474142a55b46Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 474242a55b46Smrg sort -k 3 474342a55b46Smrg else 474442a55b46Smrg sort +2 474542a55b46Smrg fi | 474642a55b46Smrg uniq > "$nlist"S; then 474742a55b46Smrg : 474842a55b46Smrg else 474942a55b46Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 475042a55b46Smrg fi 4751c582b7e3Smrg 475242a55b46Smrg if test -f "$nlist"S; then 475342a55b46Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 475442a55b46Smrg else 475542a55b46Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 475642a55b46Smrg fi 4757c582b7e3Smrg 4758e3d74329Smrg func_show_eval '$RM "${nlist}I"' 4759e3d74329Smrg if test -n "$global_symbol_to_import"; then 4760e3d74329Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761e3d74329Smrg fi 4762e3d74329Smrg 476342a55b46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 476442a55b46Smrg 476542a55b46Smrg/* The mapping between symbol names and symbols. */ 476642a55b46Smrgtypedef struct { 476742a55b46Smrg const char *name; 476842a55b46Smrg void *address; 476942a55b46Smrg} lt_dlsymlist; 477042a55b46Smrgextern LT_DLSYM_CONST lt_dlsymlist 4771e3d74329Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772e3d74329Smrg" 4773e3d74329Smrg 4774e3d74329Smrg if test -s "$nlist"I; then 4775e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4776e3d74329Smrgstatic void lt_syminit(void) 4777e3d74329Smrg{ 4778e3d74329Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779e3d74329Smrg for (; symbol->name; ++symbol) 4780e3d74329Smrg {" 4781e3d74329Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4783e3d74329Smrg } 4784e3d74329Smrg}" 4785e3d74329Smrg fi 4786e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478742a55b46SmrgLT_DLSYM_CONST lt_dlsymlist 478842a55b46Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789e3d74329Smrg{ {\"$my_originator\", (void *) 0}," 4790e3d74329Smrg 4791e3d74329Smrg if test -s "$nlist"I; then 4792e3d74329Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4793e3d74329Smrg {\"@INIT@\", (void *) <_syminit}," 4794e3d74329Smrg fi 479542a55b46Smrg 479642a55b46Smrg case $need_lib_prefix in 479742a55b46Smrg no) 479842a55b46Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799c582b7e3Smrg ;; 4800c582b7e3Smrg *) 480142a55b46Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802c582b7e3Smrg ;; 4803c582b7e3Smrg esac 480442a55b46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 480542a55b46Smrg {0, (void *) 0} 480642a55b46Smrg}; 4807c582b7e3Smrg 480842a55b46Smrg/* This works around a problem in FreeBSD linker */ 480942a55b46Smrg#ifdef FREEBSD_WORKAROUND 481042a55b46Smrgstatic const void *lt_preloaded_setup() { 481142a55b46Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 481242a55b46Smrg} 481342a55b46Smrg#endif 4814c582b7e3Smrg 481542a55b46Smrg#ifdef __cplusplus 481642a55b46Smrg} 481742a55b46Smrg#endif\ 481842a55b46Smrg" 481942a55b46Smrg } # !$opt_dry_run 4820c582b7e3Smrg 482142a55b46Smrg pic_flag_for_symtable= 482242a55b46Smrg case "$compile_command " in 482342a55b46Smrg *" -static "*) ;; 482442a55b46Smrg *) 482542a55b46Smrg case $host in 482642a55b46Smrg # compiling the symbol table file with pic_flag works around 482742a55b46Smrg # a FreeBSD bug that causes programs to crash when -lm is 482842a55b46Smrg # linked before any other PIC object. But we must not use 482942a55b46Smrg # pic_flag when linking with -static. The problem exists in 483042a55b46Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 483142a55b46Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 483242a55b46Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 483342a55b46Smrg *-*-hpux*) 483442a55b46Smrg pic_flag_for_symtable=" $pic_flag" ;; 483542a55b46Smrg *) 4836e3d74329Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 483742a55b46Smrg ;; 483842a55b46Smrg esac 483942a55b46Smrg ;; 484042a55b46Smrg esac 484142a55b46Smrg symtab_cflags= 484242a55b46Smrg for arg in $LTCFLAGS; do 484342a55b46Smrg case $arg in 484442a55b46Smrg -pie | -fpie | -fPIE) ;; 484542a55b46Smrg *) func_append symtab_cflags " $arg" ;; 4846c582b7e3Smrg esac 4847c582b7e3Smrg done 4848c582b7e3Smrg 484942a55b46Smrg # Now compile the dynamic symbol file. 485042a55b46Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851c582b7e3Smrg 485242a55b46Smrg # Clean up the generated files. 4853e3d74329Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854c582b7e3Smrg 485542a55b46Smrg # Transform the symbol file into the correct name. 4856e3d74329Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 485742a55b46Smrg case $host in 485842a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 485942a55b46Smrg if test -f "$output_objdir/$my_outputname.def"; then 486042a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486142a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486242a55b46Smrg else 486342a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486442a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486542a55b46Smrg fi 486642a55b46Smrg ;; 486742a55b46Smrg *) 486842a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486942a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 487042a55b46Smrg ;; 487142a55b46Smrg esac 487242a55b46Smrg ;; 487342a55b46Smrg *) 4874e3d74329Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 487542a55b46Smrg ;; 487642a55b46Smrg esac 487742a55b46Smrg else 487842a55b46Smrg # We keep going just in case the user didn't refer to 487942a55b46Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 488042a55b46Smrg # really was required. 4881c582b7e3Smrg 488242a55b46Smrg # Nullify the symbol file. 488342a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488442a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 488542a55b46Smrg fi 488642a55b46Smrg} 4887c582b7e3Smrg 4888e3d74329Smrg# func_cygming_gnu_implib_p ARG 4889e3d74329Smrg# This predicate returns with zero status (TRUE) if 4890e3d74329Smrg# ARG is a GNU/binutils-style import library. Returns 4891e3d74329Smrg# with nonzero status (FALSE) otherwise. 4892e3d74329Smrgfunc_cygming_gnu_implib_p () 4893e3d74329Smrg{ 4894e3d74329Smrg $debug_cmd 4895e3d74329Smrg 4896e3d74329Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897e3d74329Smrg 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)$'` 4898e3d74329Smrg test -n "$func_cygming_gnu_implib_tmp" 4899e3d74329Smrg} 4900e3d74329Smrg 4901e3d74329Smrg# func_cygming_ms_implib_p ARG 4902e3d74329Smrg# This predicate returns with zero status (TRUE) if 4903e3d74329Smrg# ARG is an MS-style import library. Returns 4904e3d74329Smrg# with nonzero status (FALSE) otherwise. 4905e3d74329Smrgfunc_cygming_ms_implib_p () 4906e3d74329Smrg{ 4907e3d74329Smrg $debug_cmd 4908e3d74329Smrg 4909e3d74329Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910e3d74329Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911e3d74329Smrg test -n "$func_cygming_ms_implib_tmp" 4912e3d74329Smrg} 4913e3d74329Smrg 491442a55b46Smrg# func_win32_libid arg 491542a55b46Smrg# return the library type of file 'arg' 491642a55b46Smrg# 491742a55b46Smrg# Need a lot of goo to handle *both* DLLs and import libs 491842a55b46Smrg# Has to be a shell function in order to 'eat' the argument 491942a55b46Smrg# that is supplied when $file_magic_command is called. 492042a55b46Smrg# Despite the name, also deal with 64 bit binaries. 492142a55b46Smrgfunc_win32_libid () 492242a55b46Smrg{ 4923e3d74329Smrg $debug_cmd 4924e3d74329Smrg 4925e3d74329Smrg win32_libid_type=unknown 492642a55b46Smrg win32_fileres=`file -L $1 2>/dev/null` 492742a55b46Smrg case $win32_fileres in 492842a55b46Smrg *ar\ archive\ import\ library*) # definitely import 492942a55b46Smrg win32_libid_type="x86 archive import" 493042a55b46Smrg ;; 493142a55b46Smrg *ar\ archive*) # could be an import, or static 493242a55b46Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 493342a55b46Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493442a55b46Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935e3d74329Smrg case $nm_interface in 4936e3d74329Smrg "MS dumpbin") 4937e3d74329Smrg if func_cygming_ms_implib_p "$1" || 4938e3d74329Smrg func_cygming_gnu_implib_p "$1" 4939e3d74329Smrg then 4940e3d74329Smrg win32_nmres=import 4941e3d74329Smrg else 4942e3d74329Smrg win32_nmres= 4943e3d74329Smrg fi 4944e3d74329Smrg ;; 4945e3d74329Smrg *) 4946e3d74329Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947e3d74329Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948e3d74329Smrg $SED -n -e ' 494942a55b46Smrg 1,100{ 495042a55b46Smrg / I /{ 4951e3d74329Smrg s|.*|import| 495242a55b46Smrg p 495342a55b46Smrg q 495442a55b46Smrg } 495542a55b46Smrg }'` 4956e3d74329Smrg ;; 4957e3d74329Smrg esac 495842a55b46Smrg case $win32_nmres in 495942a55b46Smrg import*) win32_libid_type="x86 archive import";; 496042a55b46Smrg *) win32_libid_type="x86 archive static";; 496142a55b46Smrg esac 496242a55b46Smrg fi 496342a55b46Smrg ;; 496442a55b46Smrg *DLL*) 496542a55b46Smrg win32_libid_type="x86 DLL" 496642a55b46Smrg ;; 496742a55b46Smrg *executable*) # but shell scripts are "executable" too... 496842a55b46Smrg case $win32_fileres in 496942a55b46Smrg *MS\ Windows\ PE\ Intel*) 497042a55b46Smrg win32_libid_type="x86 DLL" 497142a55b46Smrg ;; 497242a55b46Smrg esac 497342a55b46Smrg ;; 497442a55b46Smrg esac 497542a55b46Smrg $ECHO "$win32_libid_type" 497642a55b46Smrg} 497742a55b46Smrg 497842a55b46Smrg# func_cygming_dll_for_implib ARG 497942a55b46Smrg# 498042a55b46Smrg# Platform-specific function to extract the 498142a55b46Smrg# name of the DLL associated with the specified 498242a55b46Smrg# import library ARG. 498342a55b46Smrg# Invoked by eval'ing the libtool variable 498442a55b46Smrg# $sharedlib_from_linklib_cmd 498542a55b46Smrg# Result is available in the variable 498642a55b46Smrg# $sharedlib_from_linklib_result 498742a55b46Smrgfunc_cygming_dll_for_implib () 498842a55b46Smrg{ 4989e3d74329Smrg $debug_cmd 4990e3d74329Smrg 499142a55b46Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 499242a55b46Smrg} 499342a55b46Smrg 499442a55b46Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 499542a55b46Smrg# 499642a55b46Smrg# The is the core of a fallback implementation of a 499742a55b46Smrg# platform-specific function to extract the name of the 499842a55b46Smrg# DLL associated with the specified import library LIBNAME. 499942a55b46Smrg# 500042a55b46Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 500142a55b46Smrg# on the platform and compiler that created the implib. 500242a55b46Smrg# 500342a55b46Smrg# Echos the name of the DLL associated with the 500442a55b46Smrg# specified import library. 500542a55b46Smrgfunc_cygming_dll_for_implib_fallback_core () 500642a55b46Smrg{ 5007e3d74329Smrg $debug_cmd 5008e3d74329Smrg 500942a55b46Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 501042a55b46Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 501142a55b46Smrg $SED '/^Contents of section '"$match_literal"':/{ 501242a55b46Smrg # Place marker at beginning of archive member dllname section 501342a55b46Smrg s/.*/====MARK====/ 501442a55b46Smrg p 501542a55b46Smrg d 501642a55b46Smrg } 501742a55b46Smrg # These lines can sometimes be longer than 43 characters, but 501842a55b46Smrg # are always uninteresting 501942a55b46Smrg /:[ ]*file format pe[i]\{,1\}-/d 502042a55b46Smrg /^In archive [^:]*:/d 502142a55b46Smrg # Ensure marker is printed 502242a55b46Smrg /^====MARK====/p 502342a55b46Smrg # Remove all lines with less than 43 characters 502442a55b46Smrg /^.\{43\}/!d 502542a55b46Smrg # From remaining lines, remove first 43 characters 502642a55b46Smrg s/^.\{43\}//' | 502742a55b46Smrg $SED -n ' 502842a55b46Smrg # Join marker and all lines until next marker into a single line 502942a55b46Smrg /^====MARK====/ b para 503042a55b46Smrg H 503142a55b46Smrg $ b para 503242a55b46Smrg b 503342a55b46Smrg :para 503442a55b46Smrg x 503542a55b46Smrg s/\n//g 503642a55b46Smrg # Remove the marker 503742a55b46Smrg s/^====MARK====// 503842a55b46Smrg # Remove trailing dots and whitespace 503942a55b46Smrg s/[\. \t]*$// 504042a55b46Smrg # Print 504142a55b46Smrg /./p' | 504242a55b46Smrg # we now have a list, one entry per line, of the stringified 504342a55b46Smrg # contents of the appropriate section of all members of the 5044e3d74329Smrg # archive that possess that section. Heuristic: eliminate 5045e3d74329Smrg # all those that have a first or second character that is 504642a55b46Smrg # a '.' (that is, objdump's representation of an unprintable 504742a55b46Smrg # character.) This should work for all archives with less than 504842a55b46Smrg # 0x302f exports -- but will fail for DLLs whose name actually 504942a55b46Smrg # begins with a literal '.' or a single character followed by 505042a55b46Smrg # a '.'. 505142a55b46Smrg # 505242a55b46Smrg # Of those that remain, print the first one. 505342a55b46Smrg $SED -e '/^\./d;/^.\./d;q' 505442a55b46Smrg} 505542a55b46Smrg 505642a55b46Smrg# func_cygming_dll_for_implib_fallback ARG 505742a55b46Smrg# Platform-specific function to extract the 505842a55b46Smrg# name of the DLL associated with the specified 505942a55b46Smrg# import library ARG. 506042a55b46Smrg# 506142a55b46Smrg# This fallback implementation is for use when $DLLTOOL 506242a55b46Smrg# does not support the --identify-strict option. 506342a55b46Smrg# Invoked by eval'ing the libtool variable 506442a55b46Smrg# $sharedlib_from_linklib_cmd 506542a55b46Smrg# Result is available in the variable 506642a55b46Smrg# $sharedlib_from_linklib_result 506742a55b46Smrgfunc_cygming_dll_for_implib_fallback () 506842a55b46Smrg{ 5069e3d74329Smrg $debug_cmd 5070e3d74329Smrg 5071e3d74329Smrg if func_cygming_gnu_implib_p "$1"; then 507242a55b46Smrg # binutils import library 507342a55b46Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074e3d74329Smrg elif func_cygming_ms_implib_p "$1"; then 507542a55b46Smrg # ms-generated import library 507642a55b46Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 507742a55b46Smrg else 507842a55b46Smrg # unknown 5079e3d74329Smrg sharedlib_from_linklib_result= 508042a55b46Smrg fi 508142a55b46Smrg} 508242a55b46Smrg 508342a55b46Smrg 508442a55b46Smrg# func_extract_an_archive dir oldlib 508542a55b46Smrgfunc_extract_an_archive () 508642a55b46Smrg{ 5087e3d74329Smrg $debug_cmd 5088e3d74329Smrg 5089e3d74329Smrg f_ex_an_ar_dir=$1; shift 5090e3d74329Smrg f_ex_an_ar_oldlib=$1 5091e3d74329Smrg if test yes = "$lock_old_archive_extraction"; then 509242a55b46Smrg lockfile=$f_ex_an_ar_oldlib.lock 509342a55b46Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509442a55b46Smrg func_echo "Waiting for $lockfile to be removed" 509542a55b46Smrg sleep 2 5096c582b7e3Smrg done 509742a55b46Smrg fi 509842a55b46Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509942a55b46Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100e3d74329Smrg if test yes = "$lock_old_archive_extraction"; then 510142a55b46Smrg $opt_dry_run || rm -f "$lockfile" 510242a55b46Smrg fi 510342a55b46Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 510442a55b46Smrg : 510542a55b46Smrg else 510642a55b46Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 510742a55b46Smrg fi 510842a55b46Smrg} 5109c582b7e3Smrg 511042a55b46Smrg 511142a55b46Smrg# func_extract_archives gentop oldlib ... 511242a55b46Smrgfunc_extract_archives () 511342a55b46Smrg{ 5114e3d74329Smrg $debug_cmd 5115e3d74329Smrg 5116e3d74329Smrg my_gentop=$1; shift 511742a55b46Smrg my_oldlibs=${1+"$@"} 5118e3d74329Smrg my_oldobjs= 5119e3d74329Smrg my_xlib= 5120e3d74329Smrg my_xabs= 5121e3d74329Smrg my_xdir= 512242a55b46Smrg 512342a55b46Smrg for my_xlib in $my_oldlibs; do 512442a55b46Smrg # Extract the objects. 512542a55b46Smrg case $my_xlib in 5126e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 512742a55b46Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 512842a55b46Smrg esac 512942a55b46Smrg func_basename "$my_xlib" 5130e3d74329Smrg my_xlib=$func_basename_result 513142a55b46Smrg my_xlib_u=$my_xlib 513242a55b46Smrg while :; do 513342a55b46Smrg case " $extracted_archives " in 513442a55b46Smrg *" $my_xlib_u "*) 513542a55b46Smrg func_arith $extracted_serial + 1 513642a55b46Smrg extracted_serial=$func_arith_result 513742a55b46Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 513842a55b46Smrg *) break ;; 5139c582b7e3Smrg esac 5140c582b7e3Smrg done 514142a55b46Smrg extracted_archives="$extracted_archives $my_xlib_u" 5142e3d74329Smrg my_xdir=$my_gentop/$my_xlib_u 5143c582b7e3Smrg 514442a55b46Smrg func_mkdir_p "$my_xdir" 5145c582b7e3Smrg 514642a55b46Smrg case $host in 514742a55b46Smrg *-darwin*) 514842a55b46Smrg func_verbose "Extracting $my_xabs" 514942a55b46Smrg # Do not bother doing anything if just a dry run 515042a55b46Smrg $opt_dry_run || { 515142a55b46Smrg darwin_orig_dir=`pwd` 515242a55b46Smrg cd $my_xdir || exit $? 515342a55b46Smrg darwin_archive=$my_xabs 515442a55b46Smrg darwin_curdir=`pwd` 5155e3d74329Smrg func_basename "$darwin_archive" 5156e3d74329Smrg darwin_base_archive=$func_basename_result 515742a55b46Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 515842a55b46Smrg if test -n "$darwin_arches"; then 515942a55b46Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 516042a55b46Smrg darwin_arch= 516142a55b46Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162e3d74329Smrg for darwin_arch in $darwin_arches; do 5163e3d74329Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164e3d74329Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165e3d74329Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166e3d74329Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 516742a55b46Smrg cd "$darwin_curdir" 5168e3d74329Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 516942a55b46Smrg done # $darwin_arches 517042a55b46Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171e3d74329Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 517242a55b46Smrg darwin_file= 517342a55b46Smrg darwin_files= 517442a55b46Smrg for darwin_file in $darwin_filelist; do 517542a55b46Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 517642a55b46Smrg $LIPO -create -output "$darwin_file" $darwin_files 517742a55b46Smrg done # $darwin_filelist 517842a55b46Smrg $RM -rf unfat-$$ 517942a55b46Smrg cd "$darwin_orig_dir" 5180c582b7e3Smrg else 518142a55b46Smrg cd $darwin_orig_dir 518242a55b46Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 518342a55b46Smrg fi # $darwin_arches 518442a55b46Smrg } # !$opt_dry_run 518542a55b46Smrg ;; 518642a55b46Smrg *) 518742a55b46Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 518842a55b46Smrg ;; 518942a55b46Smrg esac 519042a55b46Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 519142a55b46Smrg done 5192c582b7e3Smrg 5193e3d74329Smrg func_extract_archives_result=$my_oldobjs 519442a55b46Smrg} 5195c582b7e3Smrg 5196c582b7e3Smrg 519742a55b46Smrg# func_emit_wrapper [arg=no] 519842a55b46Smrg# 519942a55b46Smrg# Emit a libtool wrapper script on stdout. 520042a55b46Smrg# Don't directly open a file because we may want to 520142a55b46Smrg# incorporate the script contents within a cygwin/mingw 520242a55b46Smrg# wrapper executable. Must ONLY be called from within 520342a55b46Smrg# func_mode_link because it depends on a number of variables 520442a55b46Smrg# set therein. 520542a55b46Smrg# 520642a55b46Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520742a55b46Smrg# variable will take. If 'yes', then the emitted script 5208e3d74329Smrg# will assume that the directory where it is stored is 520942a55b46Smrg# the $objdir directory. This is a cygwin/mingw-specific 521042a55b46Smrg# behavior. 521142a55b46Smrgfunc_emit_wrapper () 521242a55b46Smrg{ 521342a55b46Smrg func_emit_wrapper_arg1=${1-no} 5214c582b7e3Smrg 521542a55b46Smrg $ECHO "\ 521642a55b46Smrg#! $SHELL 5217c582b7e3Smrg 521842a55b46Smrg# $output - temporary wrapper script for $objdir/$outputname 5219e3d74329Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 522042a55b46Smrg# 522142a55b46Smrg# The $output program cannot be directly executed until all the libtool 522242a55b46Smrg# libraries that it depends on are installed. 522342a55b46Smrg# 522442a55b46Smrg# This wrapper script should never be moved out of the build directory. 522542a55b46Smrg# If it is, it will not operate correctly. 5226c582b7e3Smrg 522742a55b46Smrg# Sed substitution that helps us do robust quoting. It backslashifies 522842a55b46Smrg# metacharacters that are still active within double-quoted strings. 522942a55b46Smrgsed_quote_subst='$sed_quote_subst' 5230c582b7e3Smrg 523142a55b46Smrg# Be Bourne compatible 523242a55b46Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 523342a55b46Smrg emulate sh 523442a55b46Smrg NULLCMD=: 523542a55b46Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 523642a55b46Smrg # is contrary to our usage. Disable this feature. 523742a55b46Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 523842a55b46Smrg setopt NO_GLOB_SUBST 523942a55b46Smrgelse 524042a55b46Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 524142a55b46Smrgfi 524242a55b46SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 524342a55b46SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244c582b7e3Smrg 524542a55b46Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 524642a55b46Smrg# if CDPATH is set. 524742a55b46Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248c582b7e3Smrg 524942a55b46Smrgrelink_command=\"$relink_command\" 5250c582b7e3Smrg 525142a55b46Smrg# This environment variable determines our operation mode. 525242a55b46Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 525342a55b46Smrg # install mode needs the following variables: 525442a55b46Smrg generated_by_libtool_version='$macro_version' 525542a55b46Smrg notinst_deplibs='$notinst_deplibs' 525642a55b46Smrgelse 525742a55b46Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 525842a55b46Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525942a55b46Smrg file=\"\$0\"" 5260c582b7e3Smrg 526142a55b46Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526242a55b46Smrg $ECHO "\ 5263c582b7e3Smrg 526442a55b46Smrg# A function that is used when there is no print builtin or printf. 526542a55b46Smrgfunc_fallback_echo () 526642a55b46Smrg{ 526742a55b46Smrg eval 'cat <<_LTECHO_EOF 526842a55b46Smrg\$1 526942a55b46Smrg_LTECHO_EOF' 527042a55b46Smrg} 527142a55b46Smrg ECHO=\"$qECHO\" 527242a55b46Smrg fi 5273c582b7e3Smrg 527442a55b46Smrg# Very basic option parsing. These options are (a) specific to 527542a55b46Smrg# the libtool wrapper, (b) are identical between the wrapper 5276e3d74329Smrg# /script/ and the wrapper /executable/ that is used only on 527742a55b46Smrg# windows platforms, and (c) all begin with the string "--lt-" 5278e3d74329Smrg# (application programs are unlikely to have options that match 527942a55b46Smrg# this pattern). 528042a55b46Smrg# 528142a55b46Smrg# There are only two supported options: --lt-debug and 528242a55b46Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 528342a55b46Smrg# 528442a55b46Smrg# The first argument to this parsing function should be the 528542a55b46Smrg# script's $0 value, followed by "$@". 528642a55b46Smrglt_option_debug= 528742a55b46Smrgfunc_parse_lt_options () 528842a55b46Smrg{ 528942a55b46Smrg lt_script_arg0=\$0 529042a55b46Smrg shift 529142a55b46Smrg for lt_opt 529242a55b46Smrg do 529342a55b46Smrg case \"\$lt_opt\" in 529442a55b46Smrg --lt-debug) lt_option_debug=1 ;; 529542a55b46Smrg --lt-dump-script) 529642a55b46Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529742a55b46Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529842a55b46Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529942a55b46Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 530042a55b46Smrg exit 0 530142a55b46Smrg ;; 530242a55b46Smrg --lt-*) 530342a55b46Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530442a55b46Smrg exit 1 530542a55b46Smrg ;; 530642a55b46Smrg esac 530742a55b46Smrg done 5308c582b7e3Smrg 530942a55b46Smrg # Print the debug banner immediately: 531042a55b46Smrg if test -n \"\$lt_option_debug\"; then 5311e3d74329Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531242a55b46Smrg fi 531342a55b46Smrg} 5314c582b7e3Smrg 531542a55b46Smrg# Used when --lt-debug. Prints its arguments to stdout 531642a55b46Smrg# (redirection is the responsibility of the caller) 531742a55b46Smrgfunc_lt_dump_args () 531842a55b46Smrg{ 531942a55b46Smrg lt_dump_args_N=1; 532042a55b46Smrg for lt_arg 532142a55b46Smrg do 5322e3d74329Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532342a55b46Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532442a55b46Smrg done 532542a55b46Smrg} 5326c582b7e3Smrg 532742a55b46Smrg# Core function for launching the target application 532842a55b46Smrgfunc_exec_program_core () 532942a55b46Smrg{ 533042a55b46Smrg" 533142a55b46Smrg case $host in 533242a55b46Smrg # Backslashes separate directories on plain windows 533342a55b46Smrg *-*-mingw | *-*-os2* | *-cegcc*) 533442a55b46Smrg $ECHO "\ 533542a55b46Smrg if test -n \"\$lt_option_debug\"; then 5336e3d74329Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533742a55b46Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533842a55b46Smrg fi 533942a55b46Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534042a55b46Smrg" 534142a55b46Smrg ;; 5342c582b7e3Smrg 534342a55b46Smrg *) 534442a55b46Smrg $ECHO "\ 534542a55b46Smrg if test -n \"\$lt_option_debug\"; then 5346e3d74329Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534742a55b46Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534842a55b46Smrg fi 534942a55b46Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535042a55b46Smrg" 535142a55b46Smrg ;; 535242a55b46Smrg esac 535342a55b46Smrg $ECHO "\ 535442a55b46Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535542a55b46Smrg exit 1 535642a55b46Smrg} 5357c582b7e3Smrg 535842a55b46Smrg# A function to encapsulate launching the target application 535942a55b46Smrg# Strips options in the --lt-* namespace from \$@ and 536042a55b46Smrg# launches target application with the remaining arguments. 536142a55b46Smrgfunc_exec_program () 536242a55b46Smrg{ 536342a55b46Smrg case \" \$* \" in 536442a55b46Smrg *\\ --lt-*) 536542a55b46Smrg for lt_wr_arg 536642a55b46Smrg do 536742a55b46Smrg case \$lt_wr_arg in 536842a55b46Smrg --lt-*) ;; 536942a55b46Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 537042a55b46Smrg esac 537142a55b46Smrg shift 537242a55b46Smrg done ;; 537342a55b46Smrg esac 537442a55b46Smrg func_exec_program_core \${1+\"\$@\"} 537542a55b46Smrg} 5376c582b7e3Smrg 537742a55b46Smrg # Parse options 537842a55b46Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379c582b7e3Smrg 538042a55b46Smrg # Find the directory that this script lives in. 538142a55b46Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 538242a55b46Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383c582b7e3Smrg 538442a55b46Smrg # Follow symbolic links until we get to the real thisdir. 538542a55b46Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 538642a55b46Smrg while test -n \"\$file\"; do 538742a55b46Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388c582b7e3Smrg 538942a55b46Smrg # If there was a directory component, then change thisdir. 539042a55b46Smrg if test \"x\$destdir\" != \"x\$file\"; then 539142a55b46Smrg case \"\$destdir\" in 539242a55b46Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 539342a55b46Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 539442a55b46Smrg esac 539542a55b46Smrg fi 5396c582b7e3Smrg 539742a55b46Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539842a55b46Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 539942a55b46Smrg done 5400c582b7e3Smrg 540142a55b46Smrg # Usually 'no', except on cygwin/mingw when embedded into 540242a55b46Smrg # the cwrapper. 540342a55b46Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 540442a55b46Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 540542a55b46Smrg # special case for '.' 540642a55b46Smrg if test \"\$thisdir\" = \".\"; then 540742a55b46Smrg thisdir=\`pwd\` 540842a55b46Smrg fi 540942a55b46Smrg # remove .libs from thisdir 541042a55b46Smrg case \"\$thisdir\" in 541142a55b46Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 541242a55b46Smrg $objdir ) thisdir=. ;; 541342a55b46Smrg esac 541442a55b46Smrg fi 5415c582b7e3Smrg 541642a55b46Smrg # Try to get the absolute directory name. 541742a55b46Smrg absdir=\`cd \"\$thisdir\" && pwd\` 541842a55b46Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 541942a55b46Smrg" 5420c582b7e3Smrg 5421e3d74329Smrg if test yes = "$fast_install"; then 542242a55b46Smrg $ECHO "\ 542342a55b46Smrg program=lt-'$outputname'$exeext 542442a55b46Smrg progdir=\"\$thisdir/$objdir\" 5425c582b7e3Smrg 542642a55b46Smrg if test ! -f \"\$progdir/\$program\" || 5427e3d74329Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 542842a55b46Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429c582b7e3Smrg 543042a55b46Smrg file=\"\$\$-\$program\" 5431c582b7e3Smrg 543242a55b46Smrg if test ! -d \"\$progdir\"; then 543342a55b46Smrg $MKDIR \"\$progdir\" 543442a55b46Smrg else 543542a55b46Smrg $RM \"\$progdir/\$file\" 543642a55b46Smrg fi" 5437c582b7e3Smrg 543842a55b46Smrg $ECHO "\ 5439c582b7e3Smrg 544042a55b46Smrg # relink executable if necessary 544142a55b46Smrg if test -n \"\$relink_command\"; then 544242a55b46Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 544342a55b46Smrg else 5444e3d74329Smrg \$ECHO \"\$relink_command_output\" >&2 544542a55b46Smrg $RM \"\$progdir/\$file\" 544642a55b46Smrg exit 1 544742a55b46Smrg fi 544842a55b46Smrg fi 5449c582b7e3Smrg 545042a55b46Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 545142a55b46Smrg { $RM \"\$progdir/\$program\"; 545242a55b46Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 545342a55b46Smrg $RM \"\$progdir/\$file\" 545442a55b46Smrg fi" 545542a55b46Smrg else 545642a55b46Smrg $ECHO "\ 545742a55b46Smrg program='$outputname' 545842a55b46Smrg progdir=\"\$thisdir/$objdir\" 545942a55b46Smrg" 546042a55b46Smrg fi 5461c582b7e3Smrg 546242a55b46Smrg $ECHO "\ 5463c582b7e3Smrg 546442a55b46Smrg if test -f \"\$progdir/\$program\"; then" 546542a55b46Smrg 546642a55b46Smrg # fixup the dll searchpath if we need to. 546742a55b46Smrg # 546842a55b46Smrg # Fix the DLL searchpath if we need to. Do this before prepending 546942a55b46Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 547042a55b46Smrg # libraries must come first. 547142a55b46Smrg if test -n "$dllsearchpath"; then 547242a55b46Smrg $ECHO "\ 547342a55b46Smrg # Add the dll search path components to the executable PATH 547442a55b46Smrg PATH=$dllsearchpath:\$PATH 547542a55b46Smrg" 5476c582b7e3Smrg fi 5477c582b7e3Smrg 547842a55b46Smrg # Export our shlibpath_var if we have one. 5479e3d74329Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 548042a55b46Smrg $ECHO "\ 548142a55b46Smrg # Add our own library path to $shlibpath_var 548242a55b46Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483c582b7e3Smrg 548442a55b46Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 548542a55b46Smrg # The second colon is a workaround for a bug in BeOS R4 sed 548642a55b46Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 548742a55b46Smrg 548842a55b46Smrg export $shlibpath_var 548942a55b46Smrg" 5490c582b7e3Smrg fi 5491c582b7e3Smrg 549242a55b46Smrg $ECHO "\ 549342a55b46Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 549442a55b46Smrg # Run the actual program with our arguments. 549542a55b46Smrg func_exec_program \${1+\"\$@\"} 549642a55b46Smrg fi 549742a55b46Smrg else 549842a55b46Smrg # The program doesn't exist. 5499e3d74329Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 550042a55b46Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550142a55b46Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 550242a55b46Smrg exit 1 550342a55b46Smrg fi 550442a55b46Smrgfi\ 550542a55b46Smrg" 550642a55b46Smrg} 5507c582b7e3Smrg 5508c582b7e3Smrg 550942a55b46Smrg# func_emit_cwrapperexe_src 551042a55b46Smrg# emit the source code for a wrapper executable on stdout 551142a55b46Smrg# Must ONLY be called from within func_mode_link because 551242a55b46Smrg# it depends on a number of variable set therein. 551342a55b46Smrgfunc_emit_cwrapperexe_src () 551442a55b46Smrg{ 551542a55b46Smrg cat <<EOF 5516c582b7e3Smrg 551742a55b46Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518e3d74329Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519c582b7e3Smrg 552042a55b46Smrg The $output program cannot be directly executed until all the libtool 552142a55b46Smrg libraries that it depends on are installed. 5522c582b7e3Smrg 552342a55b46Smrg This wrapper executable should never be moved out of the build directory. 552442a55b46Smrg If it is, it will not operate correctly. 552542a55b46Smrg*/ 552642a55b46SmrgEOF 552742a55b46Smrg cat <<"EOF" 552842a55b46Smrg#ifdef _MSC_VER 552942a55b46Smrg# define _CRT_SECURE_NO_DEPRECATE 1 553042a55b46Smrg#endif 553142a55b46Smrg#include <stdio.h> 553242a55b46Smrg#include <stdlib.h> 553342a55b46Smrg#ifdef _MSC_VER 553442a55b46Smrg# include <direct.h> 553542a55b46Smrg# include <process.h> 553642a55b46Smrg# include <io.h> 553742a55b46Smrg#else 553842a55b46Smrg# include <unistd.h> 553942a55b46Smrg# include <stdint.h> 554042a55b46Smrg# ifdef __CYGWIN__ 554142a55b46Smrg# include <io.h> 554242a55b46Smrg# endif 554342a55b46Smrg#endif 554442a55b46Smrg#include <malloc.h> 554542a55b46Smrg#include <stdarg.h> 554642a55b46Smrg#include <assert.h> 554742a55b46Smrg#include <string.h> 554842a55b46Smrg#include <ctype.h> 554942a55b46Smrg#include <errno.h> 555042a55b46Smrg#include <fcntl.h> 555142a55b46Smrg#include <sys/stat.h> 5552c582b7e3Smrg 5553e3d74329Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554e3d74329Smrg 555542a55b46Smrg/* declarations of non-ANSI functions */ 5556e3d74329Smrg#if defined __MINGW32__ 555742a55b46Smrg# ifdef __STRICT_ANSI__ 555842a55b46Smrgint _putenv (const char *); 555942a55b46Smrg# endif 5560e3d74329Smrg#elif defined __CYGWIN__ 556142a55b46Smrg# ifdef __STRICT_ANSI__ 556242a55b46Smrgchar *realpath (const char *, char *); 556342a55b46Smrgint putenv (char *); 556442a55b46Smrgint setenv (const char *, const char *, int); 556542a55b46Smrg# endif 5566e3d74329Smrg/* #elif defined other_platform || defined ... */ 556742a55b46Smrg#endif 5568c582b7e3Smrg 556942a55b46Smrg/* portability defines, excluding path handling macros */ 5570e3d74329Smrg#if defined _MSC_VER 557142a55b46Smrg# define setmode _setmode 557242a55b46Smrg# define stat _stat 557342a55b46Smrg# define chmod _chmod 557442a55b46Smrg# define getcwd _getcwd 557542a55b46Smrg# define putenv _putenv 557642a55b46Smrg# define S_IXUSR _S_IEXEC 5577e3d74329Smrg#elif defined __MINGW32__ 557842a55b46Smrg# define setmode _setmode 557942a55b46Smrg# define stat _stat 558042a55b46Smrg# define chmod _chmod 558142a55b46Smrg# define getcwd _getcwd 558242a55b46Smrg# define putenv _putenv 5583e3d74329Smrg#elif defined __CYGWIN__ 558442a55b46Smrg# define HAVE_SETENV 558542a55b46Smrg# define FOPEN_WB "wb" 5586e3d74329Smrg/* #elif defined other platforms ... */ 558742a55b46Smrg#endif 5588c582b7e3Smrg 5589e3d74329Smrg#if defined PATH_MAX 559042a55b46Smrg# define LT_PATHMAX PATH_MAX 5591e3d74329Smrg#elif defined MAXPATHLEN 559242a55b46Smrg# define LT_PATHMAX MAXPATHLEN 559342a55b46Smrg#else 559442a55b46Smrg# define LT_PATHMAX 1024 559542a55b46Smrg#endif 5596c582b7e3Smrg 559742a55b46Smrg#ifndef S_IXOTH 559842a55b46Smrg# define S_IXOTH 0 559942a55b46Smrg#endif 560042a55b46Smrg#ifndef S_IXGRP 560142a55b46Smrg# define S_IXGRP 0 560242a55b46Smrg#endif 5603c582b7e3Smrg 560442a55b46Smrg/* path handling portability macros */ 560542a55b46Smrg#ifndef DIR_SEPARATOR 560642a55b46Smrg# define DIR_SEPARATOR '/' 560742a55b46Smrg# define PATH_SEPARATOR ':' 560842a55b46Smrg#endif 5609c582b7e3Smrg 5610e3d74329Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611e3d74329Smrg defined __OS2__ 561242a55b46Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 561342a55b46Smrg# define FOPEN_WB "wb" 561442a55b46Smrg# ifndef DIR_SEPARATOR_2 561542a55b46Smrg# define DIR_SEPARATOR_2 '\\' 561642a55b46Smrg# endif 561742a55b46Smrg# ifndef PATH_SEPARATOR_2 561842a55b46Smrg# define PATH_SEPARATOR_2 ';' 561942a55b46Smrg# endif 562042a55b46Smrg#endif 5621c582b7e3Smrg 562242a55b46Smrg#ifndef DIR_SEPARATOR_2 562342a55b46Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 562442a55b46Smrg#else /* DIR_SEPARATOR_2 */ 562542a55b46Smrg# define IS_DIR_SEPARATOR(ch) \ 562642a55b46Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 562742a55b46Smrg#endif /* DIR_SEPARATOR_2 */ 5628c582b7e3Smrg 562942a55b46Smrg#ifndef PATH_SEPARATOR_2 563042a55b46Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 563142a55b46Smrg#else /* PATH_SEPARATOR_2 */ 563242a55b46Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 563342a55b46Smrg#endif /* PATH_SEPARATOR_2 */ 5634c582b7e3Smrg 563542a55b46Smrg#ifndef FOPEN_WB 563642a55b46Smrg# define FOPEN_WB "w" 563742a55b46Smrg#endif 563842a55b46Smrg#ifndef _O_BINARY 563942a55b46Smrg# define _O_BINARY 0 564042a55b46Smrg#endif 5641c582b7e3Smrg 564242a55b46Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 564342a55b46Smrg#define XFREE(stale) do { \ 5644e3d74329Smrg if (stale) { free (stale); stale = 0; } \ 564542a55b46Smrg} while (0) 5646c582b7e3Smrg 5647e3d74329Smrg#if defined LT_DEBUGWRAPPER 564842a55b46Smrgstatic int lt_debug = 1; 564942a55b46Smrg#else 565042a55b46Smrgstatic int lt_debug = 0; 565142a55b46Smrg#endif 5652c582b7e3Smrg 565342a55b46Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565442a55b46Smrg 565542a55b46Smrgvoid *xmalloc (size_t num); 565642a55b46Smrgchar *xstrdup (const char *string); 565742a55b46Smrgconst char *base_name (const char *name); 565842a55b46Smrgchar *find_executable (const char *wrapper); 565942a55b46Smrgchar *chase_symlinks (const char *pathspec); 566042a55b46Smrgint make_executable (const char *path); 566142a55b46Smrgint check_executable (const char *path); 566242a55b46Smrgchar *strendzap (char *str, const char *pat); 566342a55b46Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566442a55b46Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566542a55b46Smrgstatic const char *nonnull (const char *s); 566642a55b46Smrgstatic const char *nonempty (const char *s); 566742a55b46Smrgvoid lt_setenv (const char *name, const char *value); 566842a55b46Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 566942a55b46Smrgvoid lt_update_exe_path (const char *name, const char *value); 567042a55b46Smrgvoid lt_update_lib_path (const char *name, const char *value); 567142a55b46Smrgchar **prepare_spawn (char **argv); 567242a55b46Smrgvoid lt_dump_script (FILE *f); 567342a55b46SmrgEOF 5674c582b7e3Smrg 567542a55b46Smrg cat <<EOF 5676e3d74329Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677e3d74329Smrg# define externally_visible volatile 5678e3d74329Smrg#else 5679e3d74329Smrg# define externally_visible __attribute__((externally_visible)) volatile 5680e3d74329Smrg#endif 5681e3d74329Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 568242a55b46Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 568342a55b46SmrgEOF 5684c582b7e3Smrg 5685e3d74329Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 568642a55b46Smrg func_to_host_path "$temp_rpath" 568742a55b46Smrg cat <<EOF 568842a55b46Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 568942a55b46SmrgEOF 569042a55b46Smrg else 569142a55b46Smrg cat <<"EOF" 569242a55b46Smrgconst char * LIB_PATH_VALUE = ""; 569342a55b46SmrgEOF 569442a55b46Smrg fi 5695c582b7e3Smrg 569642a55b46Smrg if test -n "$dllsearchpath"; then 569742a55b46Smrg func_to_host_path "$dllsearchpath:" 569842a55b46Smrg cat <<EOF 569942a55b46Smrgconst char * EXE_PATH_VARNAME = "PATH"; 570042a55b46Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 570142a55b46SmrgEOF 570242a55b46Smrg else 570342a55b46Smrg cat <<"EOF" 570442a55b46Smrgconst char * EXE_PATH_VARNAME = ""; 570542a55b46Smrgconst char * EXE_PATH_VALUE = ""; 570642a55b46SmrgEOF 570742a55b46Smrg fi 5708c582b7e3Smrg 5709e3d74329Smrg if test yes = "$fast_install"; then 571042a55b46Smrg cat <<EOF 571142a55b46Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 571242a55b46SmrgEOF 571342a55b46Smrg else 571442a55b46Smrg cat <<EOF 571542a55b46Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 571642a55b46SmrgEOF 571742a55b46Smrg fi 5718c582b7e3Smrg 5719c582b7e3Smrg 572042a55b46Smrg cat <<"EOF" 5721c582b7e3Smrg 572242a55b46Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723c582b7e3Smrg 572442a55b46Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 572542a55b46Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572642a55b46Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727c582b7e3Smrg 572842a55b46Smrgint 572942a55b46Smrgmain (int argc, char *argv[]) 573042a55b46Smrg{ 573142a55b46Smrg char **newargz; 573242a55b46Smrg int newargc; 573342a55b46Smrg char *tmp_pathspec; 573442a55b46Smrg char *actual_cwrapper_path; 573542a55b46Smrg char *actual_cwrapper_name; 573642a55b46Smrg char *target_name; 573742a55b46Smrg char *lt_argv_zero; 5738e3d74329Smrg int rval = 127; 573942a55b46Smrg 574042a55b46Smrg int i; 5741c582b7e3Smrg 574242a55b46Smrg program_name = (char *) xstrdup (base_name (argv[0])); 5743e3d74329Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744c582b7e3Smrg 574542a55b46Smrg /* very simple arg parsing; don't want to rely on getopt 574642a55b46Smrg * also, copy all non cwrapper options to newargz, except 574742a55b46Smrg * argz[0], which is handled differently 574842a55b46Smrg */ 574942a55b46Smrg newargc=0; 575042a55b46Smrg for (i = 1; i < argc; i++) 575142a55b46Smrg { 5752e3d74329Smrg if (STREQ (argv[i], dumpscript_opt)) 575342a55b46Smrg { 575442a55b46SmrgEOF 5755e3d74329Smrg case $host in 575642a55b46Smrg *mingw* | *cygwin* ) 575742a55b46Smrg # make stdout use "unix" line endings 575842a55b46Smrg echo " setmode(1,_O_BINARY);" 575942a55b46Smrg ;; 576042a55b46Smrg esac 5761c582b7e3Smrg 576242a55b46Smrg cat <<"EOF" 576342a55b46Smrg lt_dump_script (stdout); 576442a55b46Smrg return 0; 576542a55b46Smrg } 5766e3d74329Smrg if (STREQ (argv[i], debug_opt)) 576742a55b46Smrg { 576842a55b46Smrg lt_debug = 1; 576942a55b46Smrg continue; 577042a55b46Smrg } 5771e3d74329Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577242a55b46Smrg { 577342a55b46Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577442a55b46Smrg namespace, but it is not one of the ones we know about and 577542a55b46Smrg have already dealt with, above (inluding dump-script), then 577642a55b46Smrg report an error. Otherwise, targets might begin to believe 577742a55b46Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577842a55b46Smrg namespace. The first time any user complains about this, we'll 577942a55b46Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578042a55b46Smrg or a configure.ac-settable value. 578142a55b46Smrg */ 578242a55b46Smrg lt_fatal (__FILE__, __LINE__, 578342a55b46Smrg "unrecognized %s option: '%s'", 578442a55b46Smrg ltwrapper_option_prefix, argv[i]); 578542a55b46Smrg } 578642a55b46Smrg /* otherwise ... */ 578742a55b46Smrg newargz[++newargc] = xstrdup (argv[i]); 578842a55b46Smrg } 578942a55b46Smrg newargz[++newargc] = NULL; 5790c582b7e3Smrg 579142a55b46SmrgEOF 579242a55b46Smrg cat <<EOF 579342a55b46Smrg /* The GNU banner must be the first non-error debug message */ 5794e3d74329Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579542a55b46SmrgEOF 579642a55b46Smrg cat <<"EOF" 579742a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579842a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 579942a55b46Smrg 580042a55b46Smrg tmp_pathspec = find_executable (argv[0]); 580142a55b46Smrg if (tmp_pathspec == NULL) 580242a55b46Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580342a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 580442a55b46Smrg "(main) found exe (before symlink chase) at: %s\n", 580542a55b46Smrg tmp_pathspec); 580642a55b46Smrg 580742a55b46Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580842a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 580942a55b46Smrg "(main) found exe (after symlink chase) at: %s\n", 581042a55b46Smrg actual_cwrapper_path); 581142a55b46Smrg XFREE (tmp_pathspec); 581242a55b46Smrg 581342a55b46Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 581442a55b46Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 581542a55b46Smrg 581642a55b46Smrg /* wrapper name transforms */ 581742a55b46Smrg strendzap (actual_cwrapper_name, ".exe"); 581842a55b46Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 581942a55b46Smrg XFREE (actual_cwrapper_name); 582042a55b46Smrg actual_cwrapper_name = tmp_pathspec; 582142a55b46Smrg tmp_pathspec = 0; 582242a55b46Smrg 582342a55b46Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 582442a55b46Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 582542a55b46Smrg strendzap (target_name, ".exe"); 582642a55b46Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 582742a55b46Smrg XFREE (target_name); 582842a55b46Smrg target_name = tmp_pathspec; 582942a55b46Smrg tmp_pathspec = 0; 583042a55b46Smrg 583142a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 583242a55b46Smrg "(main) libtool target name: %s\n", 583342a55b46Smrg target_name); 583442a55b46SmrgEOF 583542a55b46Smrg 583642a55b46Smrg cat <<EOF 583742a55b46Smrg newargz[0] = 583842a55b46Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 583942a55b46Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 584042a55b46Smrg strcpy (newargz[0], actual_cwrapper_path); 584142a55b46Smrg strcat (newargz[0], "$objdir"); 584242a55b46Smrg strcat (newargz[0], "/"); 584342a55b46SmrgEOF 584442a55b46Smrg 584542a55b46Smrg cat <<"EOF" 584642a55b46Smrg /* stop here, and copy so we don't have to do this twice */ 584742a55b46Smrg tmp_pathspec = xstrdup (newargz[0]); 584842a55b46Smrg 584942a55b46Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 585042a55b46Smrg strcat (newargz[0], actual_cwrapper_name); 585142a55b46Smrg 585242a55b46Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 585342a55b46Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 585442a55b46Smrg XFREE (tmp_pathspec); 585542a55b46Smrg tmp_pathspec = NULL; 585642a55b46SmrgEOF 585742a55b46Smrg 585842a55b46Smrg case $host_os in 585942a55b46Smrg mingw*) 586042a55b46Smrg cat <<"EOF" 586142a55b46Smrg { 586242a55b46Smrg char* p; 586342a55b46Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 586442a55b46Smrg { 586542a55b46Smrg *p = '/'; 586642a55b46Smrg } 586742a55b46Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 586842a55b46Smrg { 586942a55b46Smrg *p = '/'; 587042a55b46Smrg } 587142a55b46Smrg } 587242a55b46SmrgEOF 587342a55b46Smrg ;; 587442a55b46Smrg esac 587542a55b46Smrg 587642a55b46Smrg cat <<"EOF" 587742a55b46Smrg XFREE (target_name); 587842a55b46Smrg XFREE (actual_cwrapper_path); 587942a55b46Smrg XFREE (actual_cwrapper_name); 588042a55b46Smrg 588142a55b46Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 588242a55b46Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 588342a55b46Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 588442a55b46Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 588542a55b46Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 588642a55b46Smrg libraries must come first. */ 588742a55b46Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 588842a55b46Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 588942a55b46Smrg 589042a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589142a55b46Smrg nonnull (lt_argv_zero)); 589242a55b46Smrg for (i = 0; i < newargc; i++) 589342a55b46Smrg { 589442a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589542a55b46Smrg i, nonnull (newargz[i])); 589642a55b46Smrg } 589742a55b46Smrg 589842a55b46SmrgEOF 589942a55b46Smrg 590042a55b46Smrg case $host_os in 590142a55b46Smrg mingw*) 590242a55b46Smrg cat <<"EOF" 590342a55b46Smrg /* execv doesn't actually work on mingw as expected on unix */ 590442a55b46Smrg newargz = prepare_spawn (newargz); 5905e3d74329Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 590642a55b46Smrg if (rval == -1) 590742a55b46Smrg { 590842a55b46Smrg /* failed to start process */ 590942a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 591042a55b46Smrg "(main) failed to launch target \"%s\": %s\n", 591142a55b46Smrg lt_argv_zero, nonnull (strerror (errno))); 591242a55b46Smrg return 127; 591342a55b46Smrg } 591442a55b46Smrg return rval; 591542a55b46SmrgEOF 5916c582b7e3Smrg ;; 5917c582b7e3Smrg *) 591842a55b46Smrg cat <<"EOF" 591942a55b46Smrg execv (lt_argv_zero, newargz); 592042a55b46Smrg return rval; /* =127, but avoids unused variable warning */ 592142a55b46SmrgEOF 5922c582b7e3Smrg ;; 592342a55b46Smrg esac 5924c582b7e3Smrg 592542a55b46Smrg cat <<"EOF" 592642a55b46Smrg} 5927c582b7e3Smrg 592842a55b46Smrgvoid * 592942a55b46Smrgxmalloc (size_t num) 593042a55b46Smrg{ 593142a55b46Smrg void *p = (void *) malloc (num); 593242a55b46Smrg if (!p) 593342a55b46Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934c582b7e3Smrg 593542a55b46Smrg return p; 593642a55b46Smrg} 5937c582b7e3Smrg 593842a55b46Smrgchar * 593942a55b46Smrgxstrdup (const char *string) 594042a55b46Smrg{ 594142a55b46Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 594242a55b46Smrg string) : NULL; 594342a55b46Smrg} 5944c582b7e3Smrg 594542a55b46Smrgconst char * 594642a55b46Smrgbase_name (const char *name) 594742a55b46Smrg{ 594842a55b46Smrg const char *base; 5949c582b7e3Smrg 5950e3d74329Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 595142a55b46Smrg /* Skip over the disk name in MSDOS pathnames. */ 595242a55b46Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 595342a55b46Smrg name += 2; 5954c582b7e3Smrg#endif 5955c582b7e3Smrg 595642a55b46Smrg for (base = name; *name; name++) 595742a55b46Smrg if (IS_DIR_SEPARATOR (*name)) 595842a55b46Smrg base = name + 1; 595942a55b46Smrg return base; 596042a55b46Smrg} 5961c582b7e3Smrg 596242a55b46Smrgint 596342a55b46Smrgcheck_executable (const char *path) 596442a55b46Smrg{ 596542a55b46Smrg struct stat st; 5966c582b7e3Smrg 596742a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596842a55b46Smrg nonempty (path)); 596942a55b46Smrg if ((!path) || (!*path)) 597042a55b46Smrg return 0; 5971c582b7e3Smrg 597242a55b46Smrg if ((stat (path, &st) >= 0) 597342a55b46Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 597442a55b46Smrg return 1; 597542a55b46Smrg else 597642a55b46Smrg return 0; 597742a55b46Smrg} 5978c582b7e3Smrg 597942a55b46Smrgint 598042a55b46Smrgmake_executable (const char *path) 598142a55b46Smrg{ 598242a55b46Smrg int rval = 0; 598342a55b46Smrg struct stat st; 5984c582b7e3Smrg 598542a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598642a55b46Smrg nonempty (path)); 598742a55b46Smrg if ((!path) || (!*path)) 598842a55b46Smrg return 0; 5989c582b7e3Smrg 599042a55b46Smrg if (stat (path, &st) >= 0) 599142a55b46Smrg { 599242a55b46Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 599342a55b46Smrg } 599442a55b46Smrg return rval; 599542a55b46Smrg} 5996c582b7e3Smrg 599742a55b46Smrg/* Searches for the full path of the wrapper. Returns 599842a55b46Smrg newly allocated full path name if found, NULL otherwise 599942a55b46Smrg Does not chase symlinks, even on platforms that support them. 600042a55b46Smrg*/ 600142a55b46Smrgchar * 600242a55b46Smrgfind_executable (const char *wrapper) 600342a55b46Smrg{ 600442a55b46Smrg int has_slash = 0; 600542a55b46Smrg const char *p; 600642a55b46Smrg const char *p_next; 600742a55b46Smrg /* static buffer for getcwd */ 600842a55b46Smrg char tmp[LT_PATHMAX + 1]; 6009e3d74329Smrg size_t tmp_len; 601042a55b46Smrg char *concat_name; 6011c582b7e3Smrg 601242a55b46Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601342a55b46Smrg nonempty (wrapper)); 6014c582b7e3Smrg 601542a55b46Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 601642a55b46Smrg return NULL; 6017c582b7e3Smrg 601842a55b46Smrg /* Absolute path? */ 6019e3d74329Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 602042a55b46Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 602142a55b46Smrg { 602242a55b46Smrg concat_name = xstrdup (wrapper); 602342a55b46Smrg if (check_executable (concat_name)) 602442a55b46Smrg return concat_name; 602542a55b46Smrg XFREE (concat_name); 602642a55b46Smrg } 602742a55b46Smrg else 602842a55b46Smrg { 602942a55b46Smrg#endif 603042a55b46Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 603142a55b46Smrg { 603242a55b46Smrg concat_name = xstrdup (wrapper); 603342a55b46Smrg if (check_executable (concat_name)) 603442a55b46Smrg return concat_name; 603542a55b46Smrg XFREE (concat_name); 603642a55b46Smrg } 6037e3d74329Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 603842a55b46Smrg } 603942a55b46Smrg#endif 6040c582b7e3Smrg 604142a55b46Smrg for (p = wrapper; *p; p++) 604242a55b46Smrg if (*p == '/') 604342a55b46Smrg { 604442a55b46Smrg has_slash = 1; 604542a55b46Smrg break; 604642a55b46Smrg } 604742a55b46Smrg if (!has_slash) 604842a55b46Smrg { 604942a55b46Smrg /* no slashes; search PATH */ 605042a55b46Smrg const char *path = getenv ("PATH"); 605142a55b46Smrg if (path != NULL) 605242a55b46Smrg { 605342a55b46Smrg for (p = path; *p; p = p_next) 605442a55b46Smrg { 605542a55b46Smrg const char *q; 605642a55b46Smrg size_t p_len; 605742a55b46Smrg for (q = p; *q; q++) 605842a55b46Smrg if (IS_PATH_SEPARATOR (*q)) 605942a55b46Smrg break; 6060e3d74329Smrg p_len = (size_t) (q - p); 606142a55b46Smrg p_next = (*q == '\0' ? q : q + 1); 606242a55b46Smrg if (p_len == 0) 606342a55b46Smrg { 606442a55b46Smrg /* empty path: current directory */ 606542a55b46Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606642a55b46Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606742a55b46Smrg nonnull (strerror (errno))); 606842a55b46Smrg tmp_len = strlen (tmp); 606942a55b46Smrg concat_name = 607042a55b46Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 607142a55b46Smrg memcpy (concat_name, tmp, tmp_len); 607242a55b46Smrg concat_name[tmp_len] = '/'; 607342a55b46Smrg strcpy (concat_name + tmp_len + 1, wrapper); 607442a55b46Smrg } 607542a55b46Smrg else 607642a55b46Smrg { 607742a55b46Smrg concat_name = 607842a55b46Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 607942a55b46Smrg memcpy (concat_name, p, p_len); 608042a55b46Smrg concat_name[p_len] = '/'; 608142a55b46Smrg strcpy (concat_name + p_len + 1, wrapper); 608242a55b46Smrg } 608342a55b46Smrg if (check_executable (concat_name)) 608442a55b46Smrg return concat_name; 608542a55b46Smrg XFREE (concat_name); 608642a55b46Smrg } 608742a55b46Smrg } 608842a55b46Smrg /* not found in PATH; assume curdir */ 608942a55b46Smrg } 609042a55b46Smrg /* Relative path | not found in path: prepend cwd */ 609142a55b46Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609242a55b46Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609342a55b46Smrg nonnull (strerror (errno))); 609442a55b46Smrg tmp_len = strlen (tmp); 609542a55b46Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 609642a55b46Smrg memcpy (concat_name, tmp, tmp_len); 609742a55b46Smrg concat_name[tmp_len] = '/'; 609842a55b46Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099c582b7e3Smrg 610042a55b46Smrg if (check_executable (concat_name)) 610142a55b46Smrg return concat_name; 610242a55b46Smrg XFREE (concat_name); 610342a55b46Smrg return NULL; 610442a55b46Smrg} 6105c582b7e3Smrg 610642a55b46Smrgchar * 610742a55b46Smrgchase_symlinks (const char *pathspec) 610842a55b46Smrg{ 610942a55b46Smrg#ifndef S_ISLNK 611042a55b46Smrg return xstrdup (pathspec); 611142a55b46Smrg#else 611242a55b46Smrg char buf[LT_PATHMAX]; 611342a55b46Smrg struct stat s; 611442a55b46Smrg char *tmp_pathspec = xstrdup (pathspec); 611542a55b46Smrg char *p; 611642a55b46Smrg int has_symlinks = 0; 611742a55b46Smrg while (strlen (tmp_pathspec) && !has_symlinks) 611842a55b46Smrg { 611942a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 612042a55b46Smrg "checking path component for symlinks: %s\n", 612142a55b46Smrg tmp_pathspec); 612242a55b46Smrg if (lstat (tmp_pathspec, &s) == 0) 612342a55b46Smrg { 612442a55b46Smrg if (S_ISLNK (s.st_mode) != 0) 612542a55b46Smrg { 612642a55b46Smrg has_symlinks = 1; 612742a55b46Smrg break; 612842a55b46Smrg } 612942a55b46Smrg 613042a55b46Smrg /* search backwards for last DIR_SEPARATOR */ 613142a55b46Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 613242a55b46Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613342a55b46Smrg p--; 613442a55b46Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613542a55b46Smrg { 613642a55b46Smrg /* no more DIR_SEPARATORS left */ 613742a55b46Smrg break; 613842a55b46Smrg } 613942a55b46Smrg *p = '\0'; 614042a55b46Smrg } 614142a55b46Smrg else 614242a55b46Smrg { 614342a55b46Smrg lt_fatal (__FILE__, __LINE__, 614442a55b46Smrg "error accessing file \"%s\": %s", 614542a55b46Smrg tmp_pathspec, nonnull (strerror (errno))); 614642a55b46Smrg } 614742a55b46Smrg } 614842a55b46Smrg XFREE (tmp_pathspec); 6149c582b7e3Smrg 615042a55b46Smrg if (!has_symlinks) 615142a55b46Smrg { 615242a55b46Smrg return xstrdup (pathspec); 615342a55b46Smrg } 6154c582b7e3Smrg 615542a55b46Smrg tmp_pathspec = realpath (pathspec, buf); 615642a55b46Smrg if (tmp_pathspec == 0) 615742a55b46Smrg { 615842a55b46Smrg lt_fatal (__FILE__, __LINE__, 615942a55b46Smrg "could not follow symlinks for %s", pathspec); 616042a55b46Smrg } 616142a55b46Smrg return xstrdup (tmp_pathspec); 6162c582b7e3Smrg#endif 616342a55b46Smrg} 6164c582b7e3Smrg 616542a55b46Smrgchar * 616642a55b46Smrgstrendzap (char *str, const char *pat) 616742a55b46Smrg{ 616842a55b46Smrg size_t len, patlen; 6169c582b7e3Smrg 617042a55b46Smrg assert (str != NULL); 617142a55b46Smrg assert (pat != NULL); 6172c582b7e3Smrg 617342a55b46Smrg len = strlen (str); 617442a55b46Smrg patlen = strlen (pat); 6175c582b7e3Smrg 617642a55b46Smrg if (patlen <= len) 617742a55b46Smrg { 617842a55b46Smrg str += len - patlen; 6179e3d74329Smrg if (STREQ (str, pat)) 618042a55b46Smrg *str = '\0'; 618142a55b46Smrg } 618242a55b46Smrg return str; 6183c582b7e3Smrg} 6184c582b7e3Smrg 618542a55b46Smrgvoid 618642a55b46Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618742a55b46Smrg{ 618842a55b46Smrg va_list args; 618942a55b46Smrg if (lt_debug) 619042a55b46Smrg { 619142a55b46Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619242a55b46Smrg va_start (args, fmt); 619342a55b46Smrg (void) vfprintf (stderr, fmt, args); 619442a55b46Smrg va_end (args); 619542a55b46Smrg } 619642a55b46Smrg} 6197c582b7e3Smrg 619842a55b46Smrgstatic void 619942a55b46Smrglt_error_core (int exit_status, const char *file, 620042a55b46Smrg int line, const char *mode, 620142a55b46Smrg const char *message, va_list ap) 620242a55b46Smrg{ 620342a55b46Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 620442a55b46Smrg vfprintf (stderr, message, ap); 620542a55b46Smrg fprintf (stderr, ".\n"); 6206c582b7e3Smrg 620742a55b46Smrg if (exit_status >= 0) 620842a55b46Smrg exit (exit_status); 6209c582b7e3Smrg} 6210c582b7e3Smrg 621142a55b46Smrgvoid 621242a55b46Smrglt_fatal (const char *file, int line, const char *message, ...) 621342a55b46Smrg{ 621442a55b46Smrg va_list ap; 621542a55b46Smrg va_start (ap, message); 621642a55b46Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 621742a55b46Smrg va_end (ap); 6218c582b7e3Smrg} 6219c582b7e3Smrg 622042a55b46Smrgstatic const char * 622142a55b46Smrgnonnull (const char *s) 622242a55b46Smrg{ 622342a55b46Smrg return s ? s : "(null)"; 622442a55b46Smrg} 6225c582b7e3Smrg 622642a55b46Smrgstatic const char * 622742a55b46Smrgnonempty (const char *s) 622842a55b46Smrg{ 622942a55b46Smrg return (s && !*s) ? "(empty)" : nonnull (s); 623042a55b46Smrg} 6231c582b7e3Smrg 623242a55b46Smrgvoid 623342a55b46Smrglt_setenv (const char *name, const char *value) 623442a55b46Smrg{ 623542a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 623642a55b46Smrg "(lt_setenv) setting '%s' to '%s'\n", 623742a55b46Smrg nonnull (name), nonnull (value)); 623842a55b46Smrg { 623942a55b46Smrg#ifdef HAVE_SETENV 624042a55b46Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 624142a55b46Smrg char *str = xstrdup (value); 624242a55b46Smrg setenv (name, str, 1); 624342a55b46Smrg#else 6244e3d74329Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 624542a55b46Smrg char *str = XMALLOC (char, len); 624642a55b46Smrg sprintf (str, "%s=%s", name, value); 624742a55b46Smrg if (putenv (str) != EXIT_SUCCESS) 624842a55b46Smrg { 624942a55b46Smrg XFREE (str); 625042a55b46Smrg } 625142a55b46Smrg#endif 625242a55b46Smrg } 625342a55b46Smrg} 6254c582b7e3Smrg 625542a55b46Smrgchar * 625642a55b46Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 625742a55b46Smrg{ 625842a55b46Smrg char *new_value; 625942a55b46Smrg if (orig_value && *orig_value) 626042a55b46Smrg { 6261e3d74329Smrg size_t orig_value_len = strlen (orig_value); 6262e3d74329Smrg size_t add_len = strlen (add); 626342a55b46Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 626442a55b46Smrg if (to_end) 626542a55b46Smrg { 626642a55b46Smrg strcpy (new_value, orig_value); 626742a55b46Smrg strcpy (new_value + orig_value_len, add); 626842a55b46Smrg } 6269c582b7e3Smrg else 627042a55b46Smrg { 627142a55b46Smrg strcpy (new_value, add); 627242a55b46Smrg strcpy (new_value + add_len, orig_value); 627342a55b46Smrg } 627442a55b46Smrg } 627542a55b46Smrg else 627642a55b46Smrg { 627742a55b46Smrg new_value = xstrdup (add); 627842a55b46Smrg } 627942a55b46Smrg return new_value; 628042a55b46Smrg} 6281c582b7e3Smrg 628242a55b46Smrgvoid 628342a55b46Smrglt_update_exe_path (const char *name, const char *value) 628442a55b46Smrg{ 628542a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 628642a55b46Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628742a55b46Smrg nonnull (name), nonnull (value)); 6288c582b7e3Smrg 628942a55b46Smrg if (name && *name && value && *value) 629042a55b46Smrg { 629142a55b46Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 629242a55b46Smrg /* some systems can't cope with a ':'-terminated path #' */ 6293e3d74329Smrg size_t len = strlen (new_value); 6294e3d74329Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 629542a55b46Smrg { 6296e3d74329Smrg new_value[--len] = '\0'; 629742a55b46Smrg } 629842a55b46Smrg lt_setenv (name, new_value); 629942a55b46Smrg XFREE (new_value); 630042a55b46Smrg } 630142a55b46Smrg} 6302c582b7e3Smrg 630342a55b46Smrgvoid 630442a55b46Smrglt_update_lib_path (const char *name, const char *value) 630542a55b46Smrg{ 630642a55b46Smrg lt_debugprintf (__FILE__, __LINE__, 630742a55b46Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630842a55b46Smrg nonnull (name), nonnull (value)); 6309c582b7e3Smrg 631042a55b46Smrg if (name && *name && value && *value) 631142a55b46Smrg { 631242a55b46Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 631342a55b46Smrg lt_setenv (name, new_value); 631442a55b46Smrg XFREE (new_value); 631542a55b46Smrg } 631642a55b46Smrg} 6317c582b7e3Smrg 6318c582b7e3SmrgEOF 631942a55b46Smrg case $host_os in 632042a55b46Smrg mingw*) 632142a55b46Smrg cat <<"EOF" 632242a55b46Smrg 632342a55b46Smrg/* Prepares an argument vector before calling spawn(). 632442a55b46Smrg Note that spawn() does not by itself call the command interpreter 632542a55b46Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632642a55b46Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632742a55b46Smrg GetVersionEx(&v); 632842a55b46Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632942a55b46Smrg }) ? "cmd.exe" : "command.com"). 633042a55b46Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 633142a55b46Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633242a55b46Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633342a55b46Smrg special way: 633442a55b46Smrg - Space and tab are interpreted as delimiters. They are not treated as 633542a55b46Smrg delimiters if they are surrounded by double quotes: "...". 633642a55b46Smrg - Unescaped double quotes are removed from the input. Their only effect is 633742a55b46Smrg that within double quotes, space and tab are treated like normal 633842a55b46Smrg characters. 633942a55b46Smrg - Backslashes not followed by double quotes are not special. 634042a55b46Smrg - But 2*n+1 backslashes followed by a double quote become 634142a55b46Smrg n backslashes followed by a double quote (n >= 0): 634242a55b46Smrg \" -> " 634342a55b46Smrg \\\" -> \" 634442a55b46Smrg \\\\\" -> \\" 634542a55b46Smrg */ 634642a55b46Smrg#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" 634742a55b46Smrg#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" 634842a55b46Smrgchar ** 634942a55b46Smrgprepare_spawn (char **argv) 6350c582b7e3Smrg{ 635142a55b46Smrg size_t argc; 635242a55b46Smrg char **new_argv; 635342a55b46Smrg size_t i; 6354c582b7e3Smrg 635542a55b46Smrg /* Count number of arguments. */ 635642a55b46Smrg for (argc = 0; argv[argc] != NULL; argc++) 635742a55b46Smrg ; 6358c582b7e3Smrg 635942a55b46Smrg /* Allocate new argument vector. */ 636042a55b46Smrg new_argv = XMALLOC (char *, argc + 1); 6361c582b7e3Smrg 636242a55b46Smrg /* Put quoted arguments into the new argument vector. */ 636342a55b46Smrg for (i = 0; i < argc; i++) 636442a55b46Smrg { 636542a55b46Smrg const char *string = argv[i]; 636642a55b46Smrg 636742a55b46Smrg if (string[0] == '\0') 636842a55b46Smrg new_argv[i] = xstrdup ("\"\""); 636942a55b46Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637042a55b46Smrg { 637142a55b46Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637242a55b46Smrg size_t length; 637342a55b46Smrg unsigned int backslashes; 637442a55b46Smrg const char *s; 637542a55b46Smrg char *quoted_string; 637642a55b46Smrg char *p; 637742a55b46Smrg 637842a55b46Smrg length = 0; 637942a55b46Smrg backslashes = 0; 638042a55b46Smrg if (quote_around) 638142a55b46Smrg length++; 638242a55b46Smrg for (s = string; *s != '\0'; s++) 638342a55b46Smrg { 638442a55b46Smrg char c = *s; 638542a55b46Smrg if (c == '"') 638642a55b46Smrg length += backslashes + 1; 638742a55b46Smrg length++; 638842a55b46Smrg if (c == '\\') 638942a55b46Smrg backslashes++; 639042a55b46Smrg else 639142a55b46Smrg backslashes = 0; 639242a55b46Smrg } 639342a55b46Smrg if (quote_around) 639442a55b46Smrg length += backslashes + 1; 639542a55b46Smrg 639642a55b46Smrg quoted_string = XMALLOC (char, length + 1); 639742a55b46Smrg 639842a55b46Smrg p = quoted_string; 639942a55b46Smrg backslashes = 0; 640042a55b46Smrg if (quote_around) 640142a55b46Smrg *p++ = '"'; 640242a55b46Smrg for (s = string; *s != '\0'; s++) 640342a55b46Smrg { 640442a55b46Smrg char c = *s; 640542a55b46Smrg if (c == '"') 640642a55b46Smrg { 640742a55b46Smrg unsigned int j; 640842a55b46Smrg for (j = backslashes + 1; j > 0; j--) 640942a55b46Smrg *p++ = '\\'; 641042a55b46Smrg } 641142a55b46Smrg *p++ = c; 641242a55b46Smrg if (c == '\\') 641342a55b46Smrg backslashes++; 641442a55b46Smrg else 641542a55b46Smrg backslashes = 0; 641642a55b46Smrg } 641742a55b46Smrg if (quote_around) 641842a55b46Smrg { 641942a55b46Smrg unsigned int j; 642042a55b46Smrg for (j = backslashes; j > 0; j--) 642142a55b46Smrg *p++ = '\\'; 642242a55b46Smrg *p++ = '"'; 642342a55b46Smrg } 642442a55b46Smrg *p = '\0'; 6425c582b7e3Smrg 642642a55b46Smrg new_argv[i] = quoted_string; 642742a55b46Smrg } 642842a55b46Smrg else 642942a55b46Smrg new_argv[i] = (char *) string; 643042a55b46Smrg } 643142a55b46Smrg new_argv[argc] = NULL; 6432c582b7e3Smrg 643342a55b46Smrg return new_argv; 643442a55b46Smrg} 6435c582b7e3SmrgEOF 643642a55b46Smrg ;; 643742a55b46Smrg esac 6438c582b7e3Smrg 643942a55b46Smrg cat <<"EOF" 644042a55b46Smrgvoid lt_dump_script (FILE* f) 644142a55b46Smrg{ 6442c582b7e3SmrgEOF 644342a55b46Smrg func_emit_wrapper yes | 644442a55b46Smrg $SED -n -e ' 644542a55b46Smrgs/^\(.\{79\}\)\(..*\)/\1\ 644642a55b46Smrg\2/ 644742a55b46Smrgh 644842a55b46Smrgs/\([\\"]\)/\\\1/g 644942a55b46Smrgs/$/\\n/ 645042a55b46Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 645142a55b46Smrgg 645242a55b46SmrgD' 645342a55b46Smrg cat <<"EOF" 6454c582b7e3Smrg} 645542a55b46SmrgEOF 6456c582b7e3Smrg} 645742a55b46Smrg# end: func_emit_cwrapperexe_src 6458c582b7e3Smrg 645942a55b46Smrg# func_win32_import_lib_p ARG 646042a55b46Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646142a55b46Smrgfunc_win32_import_lib_p () 6462c582b7e3Smrg{ 6463e3d74329Smrg $debug_cmd 6464e3d74329Smrg 646542a55b46Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646642a55b46Smrg *import*) : ;; 646742a55b46Smrg *) false ;; 646842a55b46Smrg esac 6469c582b7e3Smrg} 6470c582b7e3Smrg 6471e3d74329Smrg# func_suncc_cstd_abi 6472e3d74329Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473e3d74329Smrg# Several compiler flags select an ABI that is incompatible with the 6474e3d74329Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475e3d74329Smrgfunc_suncc_cstd_abi () 6476e3d74329Smrg{ 6477e3d74329Smrg $debug_cmd 6478e3d74329Smrg 6479e3d74329Smrg case " $compile_command " in 6480e3d74329Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481e3d74329Smrg suncc_use_cstd_abi=no 6482e3d74329Smrg ;; 6483e3d74329Smrg *) 6484e3d74329Smrg suncc_use_cstd_abi=yes 6485e3d74329Smrg ;; 6486e3d74329Smrg esac 6487e3d74329Smrg} 6488e3d74329Smrg 648942a55b46Smrg# func_mode_link arg... 649042a55b46Smrgfunc_mode_link () 6491c582b7e3Smrg{ 6492e3d74329Smrg $debug_cmd 6493e3d74329Smrg 649442a55b46Smrg case $host in 649542a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 649642a55b46Smrg # It is impossible to link a dll without this setting, and 649742a55b46Smrg # we shouldn't force the makefile maintainer to figure out 6498e3d74329Smrg # what system we are compiling for in order to pass an extra 649942a55b46Smrg # flag for every libtool invocation. 650042a55b46Smrg # allow_undefined=no 6501c582b7e3Smrg 650242a55b46Smrg # FIXME: Unfortunately, there are problems with the above when trying 6503e3d74329Smrg # to make a dll that has undefined symbols, in which case not 650442a55b46Smrg # even a static library is built. For now, we need to specify 650542a55b46Smrg # -no-undefined on the libtool link line when we can be certain 650642a55b46Smrg # that all symbols are satisfied, otherwise we get a static library. 650742a55b46Smrg allow_undefined=yes 650842a55b46Smrg ;; 650942a55b46Smrg *) 651042a55b46Smrg allow_undefined=yes 651142a55b46Smrg ;; 651242a55b46Smrg esac 651342a55b46Smrg libtool_args=$nonopt 651442a55b46Smrg base_compile="$nonopt $@" 651542a55b46Smrg compile_command=$nonopt 651642a55b46Smrg finalize_command=$nonopt 6517c582b7e3Smrg 651842a55b46Smrg compile_rpath= 651942a55b46Smrg finalize_rpath= 652042a55b46Smrg compile_shlibpath= 652142a55b46Smrg finalize_shlibpath= 652242a55b46Smrg convenience= 652342a55b46Smrg old_convenience= 652442a55b46Smrg deplibs= 652542a55b46Smrg old_deplibs= 652642a55b46Smrg compiler_flags= 652742a55b46Smrg linker_flags= 652842a55b46Smrg dllsearchpath= 652942a55b46Smrg lib_search_path=`pwd` 653042a55b46Smrg inst_prefix_dir= 653142a55b46Smrg new_inherited_linker_flags= 6532c582b7e3Smrg 653342a55b46Smrg avoid_version=no 653442a55b46Smrg bindir= 653542a55b46Smrg dlfiles= 653642a55b46Smrg dlprefiles= 653742a55b46Smrg dlself=no 653842a55b46Smrg export_dynamic=no 653942a55b46Smrg export_symbols= 654042a55b46Smrg export_symbols_regex= 654142a55b46Smrg generated= 654242a55b46Smrg libobjs= 654342a55b46Smrg ltlibs= 654442a55b46Smrg module=no 654542a55b46Smrg no_install=no 654642a55b46Smrg objs= 6547e3d74329Smrg os2dllname= 654842a55b46Smrg non_pic_objects= 654942a55b46Smrg precious_files_regex= 655042a55b46Smrg prefer_static_libs=no 6551e3d74329Smrg preload=false 655242a55b46Smrg prev= 655342a55b46Smrg prevarg= 655442a55b46Smrg release= 655542a55b46Smrg rpath= 655642a55b46Smrg xrpath= 655742a55b46Smrg perm_rpath= 655842a55b46Smrg temp_rpath= 655942a55b46Smrg thread_safe=no 656042a55b46Smrg vinfo= 656142a55b46Smrg vinfo_number=no 656242a55b46Smrg weak_libs= 6563e3d74329Smrg single_module=$wl-single_module 656442a55b46Smrg func_infer_tag $base_compile 6565c582b7e3Smrg 656642a55b46Smrg # We need to know -static, to get the right output filenames. 656742a55b46Smrg for arg 656842a55b46Smrg do 656942a55b46Smrg case $arg in 657042a55b46Smrg -shared) 6571e3d74329Smrg test yes != "$build_libtool_libs" \ 6572e3d74329Smrg && func_fatal_configuration "cannot build a shared library" 657342a55b46Smrg build_old_libs=no 657442a55b46Smrg break 657542a55b46Smrg ;; 657642a55b46Smrg -all-static | -static | -static-libtool-libs) 657742a55b46Smrg case $arg in 657842a55b46Smrg -all-static) 6579e3d74329Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 658042a55b46Smrg func_warning "complete static linking is impossible in this configuration" 658142a55b46Smrg fi 658242a55b46Smrg if test -n "$link_static_flag"; then 658342a55b46Smrg dlopen_self=$dlopen_self_static 658442a55b46Smrg fi 658542a55b46Smrg prefer_static_libs=yes 658642a55b46Smrg ;; 658742a55b46Smrg -static) 658842a55b46Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 658942a55b46Smrg dlopen_self=$dlopen_self_static 659042a55b46Smrg fi 659142a55b46Smrg prefer_static_libs=built 659242a55b46Smrg ;; 659342a55b46Smrg -static-libtool-libs) 659442a55b46Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 659542a55b46Smrg dlopen_self=$dlopen_self_static 659642a55b46Smrg fi 659742a55b46Smrg prefer_static_libs=yes 659842a55b46Smrg ;; 659942a55b46Smrg esac 660042a55b46Smrg build_libtool_libs=no 660142a55b46Smrg build_old_libs=yes 660242a55b46Smrg break 660342a55b46Smrg ;; 660442a55b46Smrg esac 660542a55b46Smrg done 6606c582b7e3Smrg 660742a55b46Smrg # See if our shared archives depend on static archives. 660842a55b46Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609c582b7e3Smrg 661042a55b46Smrg # Go through the arguments, transforming them on the way. 661142a55b46Smrg while test "$#" -gt 0; do 6612e3d74329Smrg arg=$1 661342a55b46Smrg shift 661442a55b46Smrg func_quote_for_eval "$arg" 661542a55b46Smrg qarg=$func_quote_for_eval_unquoted_result 661642a55b46Smrg func_append libtool_args " $func_quote_for_eval_result" 6617c582b7e3Smrg 661842a55b46Smrg # If the previous option needs an argument, assign it. 661942a55b46Smrg if test -n "$prev"; then 662042a55b46Smrg case $prev in 662142a55b46Smrg output) 662242a55b46Smrg func_append compile_command " @OUTPUT@" 662342a55b46Smrg func_append finalize_command " @OUTPUT@" 662442a55b46Smrg ;; 662542a55b46Smrg esac 6626c582b7e3Smrg 662742a55b46Smrg case $prev in 662842a55b46Smrg bindir) 6629e3d74329Smrg bindir=$arg 663042a55b46Smrg prev= 663142a55b46Smrg continue 663242a55b46Smrg ;; 663342a55b46Smrg dlfiles|dlprefiles) 6634e3d74329Smrg $preload || { 663542a55b46Smrg # Add the symbol object into the linking commands. 663642a55b46Smrg func_append compile_command " @SYMFILE@" 663742a55b46Smrg func_append finalize_command " @SYMFILE@" 6638e3d74329Smrg preload=: 6639e3d74329Smrg } 664042a55b46Smrg case $arg in 664142a55b46Smrg *.la | *.lo) ;; # We handle these cases below. 664242a55b46Smrg force) 6643e3d74329Smrg if test no = "$dlself"; then 664442a55b46Smrg dlself=needless 664542a55b46Smrg export_dynamic=yes 664642a55b46Smrg fi 664742a55b46Smrg prev= 664842a55b46Smrg continue 664942a55b46Smrg ;; 665042a55b46Smrg self) 6651e3d74329Smrg if test dlprefiles = "$prev"; then 665242a55b46Smrg dlself=yes 6653e3d74329Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 665442a55b46Smrg dlself=yes 665542a55b46Smrg else 665642a55b46Smrg dlself=needless 665742a55b46Smrg export_dynamic=yes 665842a55b46Smrg fi 665942a55b46Smrg prev= 666042a55b46Smrg continue 666142a55b46Smrg ;; 666242a55b46Smrg *) 6663e3d74329Smrg if test dlfiles = "$prev"; then 666442a55b46Smrg func_append dlfiles " $arg" 666542a55b46Smrg else 666642a55b46Smrg func_append dlprefiles " $arg" 666742a55b46Smrg fi 666842a55b46Smrg prev= 666942a55b46Smrg continue 667042a55b46Smrg ;; 667142a55b46Smrg esac 667242a55b46Smrg ;; 667342a55b46Smrg expsyms) 6674e3d74329Smrg export_symbols=$arg 667542a55b46Smrg test -f "$arg" \ 6676e3d74329Smrg || func_fatal_error "symbol file '$arg' does not exist" 667742a55b46Smrg prev= 667842a55b46Smrg continue 667942a55b46Smrg ;; 668042a55b46Smrg expsyms_regex) 6681e3d74329Smrg export_symbols_regex=$arg 668242a55b46Smrg prev= 668342a55b46Smrg continue 668442a55b46Smrg ;; 668542a55b46Smrg framework) 668642a55b46Smrg case $host in 668742a55b46Smrg *-*-darwin*) 668842a55b46Smrg case "$deplibs " in 668942a55b46Smrg *" $qarg.ltframework "*) ;; 669042a55b46Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 669142a55b46Smrg ;; 669242a55b46Smrg esac 669342a55b46Smrg ;; 669442a55b46Smrg esac 669542a55b46Smrg prev= 669642a55b46Smrg continue 669742a55b46Smrg ;; 669842a55b46Smrg inst_prefix) 6699e3d74329Smrg inst_prefix_dir=$arg 6700e3d74329Smrg prev= 6701e3d74329Smrg continue 6702e3d74329Smrg ;; 6703e3d74329Smrg mllvm) 6704e3d74329Smrg # Clang does not use LLVM to link, so we can simply discard any 6705e3d74329Smrg # '-mllvm $arg' options when doing the link step. 670642a55b46Smrg prev= 670742a55b46Smrg continue 670842a55b46Smrg ;; 670942a55b46Smrg objectlist) 671042a55b46Smrg if test -f "$arg"; then 671142a55b46Smrg save_arg=$arg 671242a55b46Smrg moreargs= 671342a55b46Smrg for fil in `cat "$save_arg"` 671442a55b46Smrg do 671542a55b46Smrg# func_append moreargs " $fil" 671642a55b46Smrg arg=$fil 671742a55b46Smrg # A libtool-controlled object. 6718c582b7e3Smrg 671942a55b46Smrg # Check to see that this really is a libtool object. 672042a55b46Smrg if func_lalib_unsafe_p "$arg"; then 672142a55b46Smrg pic_object= 672242a55b46Smrg non_pic_object= 6723c582b7e3Smrg 672442a55b46Smrg # Read the .lo file 672542a55b46Smrg func_source "$arg" 6726c582b7e3Smrg 672742a55b46Smrg if test -z "$pic_object" || 672842a55b46Smrg test -z "$non_pic_object" || 6729e3d74329Smrg test none = "$pic_object" && 6730e3d74329Smrg test none = "$non_pic_object"; then 6731e3d74329Smrg func_fatal_error "cannot find name of object for '$arg'" 673242a55b46Smrg fi 6733c582b7e3Smrg 673442a55b46Smrg # Extract subdirectory from the argument. 673542a55b46Smrg func_dirname "$arg" "/" "" 6736e3d74329Smrg xdir=$func_dirname_result 6737c582b7e3Smrg 6738e3d74329Smrg if test none != "$pic_object"; then 673942a55b46Smrg # Prepend the subdirectory the object is found in. 6740e3d74329Smrg pic_object=$xdir$pic_object 6741c582b7e3Smrg 6742e3d74329Smrg if test dlfiles = "$prev"; then 6743e3d74329Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 674442a55b46Smrg func_append dlfiles " $pic_object" 674542a55b46Smrg prev= 674642a55b46Smrg continue 674742a55b46Smrg else 674842a55b46Smrg # If libtool objects are unsupported, then we need to preload. 674942a55b46Smrg prev=dlprefiles 675042a55b46Smrg fi 675142a55b46Smrg fi 6752c582b7e3Smrg 675342a55b46Smrg # CHECK ME: I think I busted this. -Ossama 6754e3d74329Smrg if test dlprefiles = "$prev"; then 675542a55b46Smrg # Preload the old-style object. 675642a55b46Smrg func_append dlprefiles " $pic_object" 675742a55b46Smrg prev= 675842a55b46Smrg fi 6759c582b7e3Smrg 676042a55b46Smrg # A PIC object. 676142a55b46Smrg func_append libobjs " $pic_object" 6762e3d74329Smrg arg=$pic_object 676342a55b46Smrg fi 6764c582b7e3Smrg 676542a55b46Smrg # Non-PIC object. 6766e3d74329Smrg if test none != "$non_pic_object"; then 676742a55b46Smrg # Prepend the subdirectory the object is found in. 6768e3d74329Smrg non_pic_object=$xdir$non_pic_object 6769c582b7e3Smrg 677042a55b46Smrg # A standard non-PIC object 677142a55b46Smrg func_append non_pic_objects " $non_pic_object" 6772e3d74329Smrg if test -z "$pic_object" || test none = "$pic_object"; then 6773e3d74329Smrg arg=$non_pic_object 677442a55b46Smrg fi 677542a55b46Smrg else 677642a55b46Smrg # If the PIC object exists, use it instead. 677742a55b46Smrg # $xdir was prepended to $pic_object above. 6778e3d74329Smrg non_pic_object=$pic_object 677942a55b46Smrg func_append non_pic_objects " $non_pic_object" 678042a55b46Smrg fi 678142a55b46Smrg else 678242a55b46Smrg # Only an error if not doing a dry-run. 678342a55b46Smrg if $opt_dry_run; then 678442a55b46Smrg # Extract subdirectory from the argument. 678542a55b46Smrg func_dirname "$arg" "/" "" 6786e3d74329Smrg xdir=$func_dirname_result 678742a55b46Smrg 678842a55b46Smrg func_lo2o "$arg" 678942a55b46Smrg pic_object=$xdir$objdir/$func_lo2o_result 679042a55b46Smrg non_pic_object=$xdir$func_lo2o_result 679142a55b46Smrg func_append libobjs " $pic_object" 679242a55b46Smrg func_append non_pic_objects " $non_pic_object" 679342a55b46Smrg else 6794e3d74329Smrg func_fatal_error "'$arg' is not a valid libtool object" 679542a55b46Smrg fi 679642a55b46Smrg fi 679742a55b46Smrg done 679842a55b46Smrg else 6799e3d74329Smrg func_fatal_error "link input file '$arg' does not exist" 680042a55b46Smrg fi 680142a55b46Smrg arg=$save_arg 680242a55b46Smrg prev= 680342a55b46Smrg continue 680442a55b46Smrg ;; 6805e3d74329Smrg os2dllname) 6806e3d74329Smrg os2dllname=$arg 6807e3d74329Smrg prev= 6808e3d74329Smrg continue 6809e3d74329Smrg ;; 681042a55b46Smrg precious_regex) 6811e3d74329Smrg precious_files_regex=$arg 681242a55b46Smrg prev= 681342a55b46Smrg continue 681442a55b46Smrg ;; 681542a55b46Smrg release) 6816e3d74329Smrg release=-$arg 681742a55b46Smrg prev= 681842a55b46Smrg continue 681942a55b46Smrg ;; 682042a55b46Smrg rpath | xrpath) 682142a55b46Smrg # We need an absolute path. 682242a55b46Smrg case $arg in 682342a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 682442a55b46Smrg *) 682542a55b46Smrg func_fatal_error "only absolute run-paths are allowed" 682642a55b46Smrg ;; 682742a55b46Smrg esac 6828e3d74329Smrg if test rpath = "$prev"; then 682942a55b46Smrg case "$rpath " in 683042a55b46Smrg *" $arg "*) ;; 683142a55b46Smrg *) func_append rpath " $arg" ;; 683242a55b46Smrg esac 683342a55b46Smrg else 683442a55b46Smrg case "$xrpath " in 683542a55b46Smrg *" $arg "*) ;; 683642a55b46Smrg *) func_append xrpath " $arg" ;; 683742a55b46Smrg esac 683842a55b46Smrg fi 683942a55b46Smrg prev= 684042a55b46Smrg continue 684142a55b46Smrg ;; 684242a55b46Smrg shrext) 6843e3d74329Smrg shrext_cmds=$arg 684442a55b46Smrg prev= 684542a55b46Smrg continue 684642a55b46Smrg ;; 684742a55b46Smrg weak) 684842a55b46Smrg func_append weak_libs " $arg" 684942a55b46Smrg prev= 685042a55b46Smrg continue 685142a55b46Smrg ;; 685242a55b46Smrg xcclinker) 685342a55b46Smrg func_append linker_flags " $qarg" 685442a55b46Smrg func_append compiler_flags " $qarg" 685542a55b46Smrg prev= 685642a55b46Smrg func_append compile_command " $qarg" 685742a55b46Smrg func_append finalize_command " $qarg" 685842a55b46Smrg continue 685942a55b46Smrg ;; 686042a55b46Smrg xcompiler) 686142a55b46Smrg func_append compiler_flags " $qarg" 686242a55b46Smrg prev= 686342a55b46Smrg func_append compile_command " $qarg" 686442a55b46Smrg func_append finalize_command " $qarg" 686542a55b46Smrg continue 686642a55b46Smrg ;; 686742a55b46Smrg xlinker) 686842a55b46Smrg func_append linker_flags " $qarg" 686942a55b46Smrg func_append compiler_flags " $wl$qarg" 687042a55b46Smrg prev= 687142a55b46Smrg func_append compile_command " $wl$qarg" 687242a55b46Smrg func_append finalize_command " $wl$qarg" 687342a55b46Smrg continue 687442a55b46Smrg ;; 687542a55b46Smrg *) 687642a55b46Smrg eval "$prev=\"\$arg\"" 687742a55b46Smrg prev= 687842a55b46Smrg continue 687942a55b46Smrg ;; 688042a55b46Smrg esac 688142a55b46Smrg fi # test -n "$prev" 6882c582b7e3Smrg 6883e3d74329Smrg prevarg=$arg 6884c582b7e3Smrg 688542a55b46Smrg case $arg in 688642a55b46Smrg -all-static) 688742a55b46Smrg if test -n "$link_static_flag"; then 688842a55b46Smrg # See comment for -static flag below, for more details. 688942a55b46Smrg func_append compile_command " $link_static_flag" 689042a55b46Smrg func_append finalize_command " $link_static_flag" 689142a55b46Smrg fi 689242a55b46Smrg continue 689342a55b46Smrg ;; 6894c582b7e3Smrg 689542a55b46Smrg -allow-undefined) 689642a55b46Smrg # FIXME: remove this flag sometime in the future. 6897e3d74329Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 689842a55b46Smrg ;; 6899c582b7e3Smrg 690042a55b46Smrg -avoid-version) 690142a55b46Smrg avoid_version=yes 690242a55b46Smrg continue 690342a55b46Smrg ;; 6904c582b7e3Smrg 690542a55b46Smrg -bindir) 690642a55b46Smrg prev=bindir 690742a55b46Smrg continue 690842a55b46Smrg ;; 6909c582b7e3Smrg 691042a55b46Smrg -dlopen) 691142a55b46Smrg prev=dlfiles 691242a55b46Smrg continue 691342a55b46Smrg ;; 6914c582b7e3Smrg 691542a55b46Smrg -dlpreopen) 691642a55b46Smrg prev=dlprefiles 691742a55b46Smrg continue 691842a55b46Smrg ;; 6919c582b7e3Smrg 692042a55b46Smrg -export-dynamic) 692142a55b46Smrg export_dynamic=yes 692242a55b46Smrg continue 692342a55b46Smrg ;; 6924c582b7e3Smrg 692542a55b46Smrg -export-symbols | -export-symbols-regex) 692642a55b46Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 692742a55b46Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 692842a55b46Smrg fi 6929e3d74329Smrg if test X-export-symbols = "X$arg"; then 693042a55b46Smrg prev=expsyms 693142a55b46Smrg else 693242a55b46Smrg prev=expsyms_regex 693342a55b46Smrg fi 693442a55b46Smrg continue 693542a55b46Smrg ;; 6936c582b7e3Smrg 693742a55b46Smrg -framework) 693842a55b46Smrg prev=framework 693942a55b46Smrg continue 694042a55b46Smrg ;; 6941c582b7e3Smrg 694242a55b46Smrg -inst-prefix-dir) 694342a55b46Smrg prev=inst_prefix 694442a55b46Smrg continue 694542a55b46Smrg ;; 6946c582b7e3Smrg 694742a55b46Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 694842a55b46Smrg # so, if we see these flags be careful not to treat them like -L 694942a55b46Smrg -L[A-Z][A-Z]*:*) 695042a55b46Smrg case $with_gcc/$host in 695142a55b46Smrg no/*-*-irix* | /*-*-irix*) 695242a55b46Smrg func_append compile_command " $arg" 695342a55b46Smrg func_append finalize_command " $arg" 695442a55b46Smrg ;; 695542a55b46Smrg esac 695642a55b46Smrg continue 695742a55b46Smrg ;; 6958c582b7e3Smrg 695942a55b46Smrg -L*) 696042a55b46Smrg func_stripname "-L" '' "$arg" 696142a55b46Smrg if test -z "$func_stripname_result"; then 696242a55b46Smrg if test "$#" -gt 0; then 6963e3d74329Smrg func_fatal_error "require no space between '-L' and '$1'" 696442a55b46Smrg else 6965e3d74329Smrg func_fatal_error "need path for '-L' option" 696642a55b46Smrg fi 696742a55b46Smrg fi 696842a55b46Smrg func_resolve_sysroot "$func_stripname_result" 696942a55b46Smrg dir=$func_resolve_sysroot_result 697042a55b46Smrg # We need an absolute path. 697142a55b46Smrg case $dir in 697242a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 697342a55b46Smrg *) 697442a55b46Smrg absdir=`cd "$dir" && pwd` 697542a55b46Smrg test -z "$absdir" && \ 6976e3d74329Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977e3d74329Smrg dir=$absdir 697842a55b46Smrg ;; 697942a55b46Smrg esac 698042a55b46Smrg case "$deplibs " in 698142a55b46Smrg *" -L$dir "* | *" $arg "*) 698242a55b46Smrg # Will only happen for absolute or sysroot arguments 698342a55b46Smrg ;; 698442a55b46Smrg *) 698542a55b46Smrg # Preserve sysroot, but never include relative directories 698642a55b46Smrg case $dir in 698742a55b46Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 698842a55b46Smrg *) func_append deplibs " -L$dir" ;; 698942a55b46Smrg esac 699042a55b46Smrg func_append lib_search_path " $dir" 699142a55b46Smrg ;; 699242a55b46Smrg esac 699342a55b46Smrg case $host in 699442a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699542a55b46Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 699642a55b46Smrg case :$dllsearchpath: in 699742a55b46Smrg *":$dir:"*) ;; 699842a55b46Smrg ::) dllsearchpath=$dir;; 699942a55b46Smrg *) func_append dllsearchpath ":$dir";; 700042a55b46Smrg esac 700142a55b46Smrg case :$dllsearchpath: in 700242a55b46Smrg *":$testbindir:"*) ;; 700342a55b46Smrg ::) dllsearchpath=$testbindir;; 700442a55b46Smrg *) func_append dllsearchpath ":$testbindir";; 700542a55b46Smrg esac 700642a55b46Smrg ;; 700742a55b46Smrg esac 700842a55b46Smrg continue 700942a55b46Smrg ;; 7010c582b7e3Smrg 701142a55b46Smrg -l*) 7012e3d74329Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 701342a55b46Smrg case $host in 701442a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 701542a55b46Smrg # These systems don't actually have a C or math library (as such) 701642a55b46Smrg continue 701742a55b46Smrg ;; 701842a55b46Smrg *-*-os2*) 701942a55b46Smrg # These systems don't actually have a C library (as such) 7020e3d74329Smrg test X-lc = "X$arg" && continue 702142a55b46Smrg ;; 7022e3d74329Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 702342a55b46Smrg # Do not include libc due to us having libc/libc_r. 7024e3d74329Smrg test X-lc = "X$arg" && continue 702542a55b46Smrg ;; 702642a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 702742a55b46Smrg # Rhapsody C and math libraries are in the System framework 702842a55b46Smrg func_append deplibs " System.ltframework" 702942a55b46Smrg continue 703042a55b46Smrg ;; 703142a55b46Smrg *-*-sco3.2v5* | *-*-sco5v6*) 703242a55b46Smrg # Causes problems with __ctype 7033e3d74329Smrg test X-lc = "X$arg" && continue 703442a55b46Smrg ;; 703542a55b46Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 703642a55b46Smrg # Compiler inserts libc in the correct place for threads to work 7037e3d74329Smrg test X-lc = "X$arg" && continue 703842a55b46Smrg ;; 703942a55b46Smrg esac 7040e3d74329Smrg elif test X-lc_r = "X$arg"; then 704142a55b46Smrg case $host in 7042e3d74329Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 704342a55b46Smrg # Do not include libc_r directly, use -pthread flag. 704442a55b46Smrg continue 704542a55b46Smrg ;; 704642a55b46Smrg esac 704742a55b46Smrg fi 704842a55b46Smrg func_append deplibs " $arg" 704942a55b46Smrg continue 705042a55b46Smrg ;; 705142a55b46Smrg 7052e3d74329Smrg -mllvm) 7053e3d74329Smrg prev=mllvm 7054e3d74329Smrg continue 7055e3d74329Smrg ;; 7056e3d74329Smrg 705742a55b46Smrg -module) 705842a55b46Smrg module=yes 705942a55b46Smrg continue 706042a55b46Smrg ;; 706142a55b46Smrg 706242a55b46Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 706342a55b46Smrg # classes, name mangling, and exception handling. 706442a55b46Smrg # Darwin uses the -arch flag to determine output architecture. 706542a55b46Smrg -model|-arch|-isysroot|--sysroot) 706642a55b46Smrg func_append compiler_flags " $arg" 706742a55b46Smrg func_append compile_command " $arg" 706842a55b46Smrg func_append finalize_command " $arg" 706942a55b46Smrg prev=xcompiler 707042a55b46Smrg continue 707142a55b46Smrg ;; 707242a55b46Smrg 707342a55b46Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 707442a55b46Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 707542a55b46Smrg func_append compiler_flags " $arg" 707642a55b46Smrg func_append compile_command " $arg" 707742a55b46Smrg func_append finalize_command " $arg" 707842a55b46Smrg case "$new_inherited_linker_flags " in 707942a55b46Smrg *" $arg "*) ;; 708042a55b46Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 708142a55b46Smrg esac 708242a55b46Smrg continue 708342a55b46Smrg ;; 708442a55b46Smrg 708542a55b46Smrg -multi_module) 7086e3d74329Smrg single_module=$wl-multi_module 708742a55b46Smrg continue 708842a55b46Smrg ;; 708942a55b46Smrg 709042a55b46Smrg -no-fast-install) 709142a55b46Smrg fast_install=no 709242a55b46Smrg continue 709342a55b46Smrg ;; 709442a55b46Smrg 709542a55b46Smrg -no-install) 709642a55b46Smrg case $host in 709742a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 709842a55b46Smrg # The PATH hackery in wrapper scripts is required on Windows 709942a55b46Smrg # and Darwin in order for the loader to find any dlls it needs. 7100e3d74329Smrg func_warning "'-no-install' is ignored for $host" 7101e3d74329Smrg func_warning "assuming '-no-fast-install' instead" 710242a55b46Smrg fast_install=no 710342a55b46Smrg ;; 710442a55b46Smrg *) no_install=yes ;; 710542a55b46Smrg esac 710642a55b46Smrg continue 710742a55b46Smrg ;; 710842a55b46Smrg 710942a55b46Smrg -no-undefined) 711042a55b46Smrg allow_undefined=no 711142a55b46Smrg continue 711242a55b46Smrg ;; 711342a55b46Smrg 711442a55b46Smrg -objectlist) 711542a55b46Smrg prev=objectlist 711642a55b46Smrg continue 711742a55b46Smrg ;; 711842a55b46Smrg 7119e3d74329Smrg -os2dllname) 7120e3d74329Smrg prev=os2dllname 7121e3d74329Smrg continue 7122e3d74329Smrg ;; 7123e3d74329Smrg 712442a55b46Smrg -o) prev=output ;; 712542a55b46Smrg 712642a55b46Smrg -precious-files-regex) 712742a55b46Smrg prev=precious_regex 712842a55b46Smrg continue 712942a55b46Smrg ;; 713042a55b46Smrg 713142a55b46Smrg -release) 713242a55b46Smrg prev=release 713342a55b46Smrg continue 713442a55b46Smrg ;; 713542a55b46Smrg 713642a55b46Smrg -rpath) 713742a55b46Smrg prev=rpath 713842a55b46Smrg continue 713942a55b46Smrg ;; 714042a55b46Smrg 714142a55b46Smrg -R) 714242a55b46Smrg prev=xrpath 714342a55b46Smrg continue 714442a55b46Smrg ;; 714542a55b46Smrg 714642a55b46Smrg -R*) 714742a55b46Smrg func_stripname '-R' '' "$arg" 714842a55b46Smrg dir=$func_stripname_result 714942a55b46Smrg # We need an absolute path. 715042a55b46Smrg case $dir in 715142a55b46Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 715242a55b46Smrg =*) 715342a55b46Smrg func_stripname '=' '' "$dir" 715442a55b46Smrg dir=$lt_sysroot$func_stripname_result 715542a55b46Smrg ;; 715642a55b46Smrg *) 715742a55b46Smrg func_fatal_error "only absolute run-paths are allowed" 715842a55b46Smrg ;; 715942a55b46Smrg esac 716042a55b46Smrg case "$xrpath " in 716142a55b46Smrg *" $dir "*) ;; 716242a55b46Smrg *) func_append xrpath " $dir" ;; 716342a55b46Smrg esac 716442a55b46Smrg continue 716542a55b46Smrg ;; 716642a55b46Smrg 716742a55b46Smrg -shared) 716842a55b46Smrg # The effects of -shared are defined in a previous loop. 716942a55b46Smrg continue 717042a55b46Smrg ;; 717142a55b46Smrg 717242a55b46Smrg -shrext) 717342a55b46Smrg prev=shrext 717442a55b46Smrg continue 717542a55b46Smrg ;; 717642a55b46Smrg 717742a55b46Smrg -static | -static-libtool-libs) 717842a55b46Smrg # The effects of -static are defined in a previous loop. 717942a55b46Smrg # We used to do the same as -all-static on platforms that 718042a55b46Smrg # didn't have a PIC flag, but the assumption that the effects 718142a55b46Smrg # would be equivalent was wrong. It would break on at least 718242a55b46Smrg # Digital Unix and AIX. 718342a55b46Smrg continue 718442a55b46Smrg ;; 718542a55b46Smrg 718642a55b46Smrg -thread-safe) 718742a55b46Smrg thread_safe=yes 718842a55b46Smrg continue 718942a55b46Smrg ;; 719042a55b46Smrg 719142a55b46Smrg -version-info) 719242a55b46Smrg prev=vinfo 719342a55b46Smrg continue 719442a55b46Smrg ;; 719542a55b46Smrg 719642a55b46Smrg -version-number) 719742a55b46Smrg prev=vinfo 719842a55b46Smrg vinfo_number=yes 719942a55b46Smrg continue 720042a55b46Smrg ;; 720142a55b46Smrg 720242a55b46Smrg -weak) 720342a55b46Smrg prev=weak 720442a55b46Smrg continue 720542a55b46Smrg ;; 720642a55b46Smrg 720742a55b46Smrg -Wc,*) 720842a55b46Smrg func_stripname '-Wc,' '' "$arg" 720942a55b46Smrg args=$func_stripname_result 721042a55b46Smrg arg= 7211e3d74329Smrg save_ifs=$IFS; IFS=, 721242a55b46Smrg for flag in $args; do 7213e3d74329Smrg IFS=$save_ifs 721442a55b46Smrg func_quote_for_eval "$flag" 721542a55b46Smrg func_append arg " $func_quote_for_eval_result" 721642a55b46Smrg func_append compiler_flags " $func_quote_for_eval_result" 721742a55b46Smrg done 7218e3d74329Smrg IFS=$save_ifs 721942a55b46Smrg func_stripname ' ' '' "$arg" 722042a55b46Smrg arg=$func_stripname_result 722142a55b46Smrg ;; 722242a55b46Smrg 722342a55b46Smrg -Wl,*) 722442a55b46Smrg func_stripname '-Wl,' '' "$arg" 722542a55b46Smrg args=$func_stripname_result 722642a55b46Smrg arg= 7227e3d74329Smrg save_ifs=$IFS; IFS=, 722842a55b46Smrg for flag in $args; do 7229e3d74329Smrg IFS=$save_ifs 723042a55b46Smrg func_quote_for_eval "$flag" 723142a55b46Smrg func_append arg " $wl$func_quote_for_eval_result" 723242a55b46Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 723342a55b46Smrg func_append linker_flags " $func_quote_for_eval_result" 723442a55b46Smrg done 7235e3d74329Smrg IFS=$save_ifs 723642a55b46Smrg func_stripname ' ' '' "$arg" 723742a55b46Smrg arg=$func_stripname_result 723842a55b46Smrg ;; 723942a55b46Smrg 724042a55b46Smrg -Xcompiler) 724142a55b46Smrg prev=xcompiler 724242a55b46Smrg continue 724342a55b46Smrg ;; 724442a55b46Smrg 724542a55b46Smrg -Xlinker) 724642a55b46Smrg prev=xlinker 724742a55b46Smrg continue 724842a55b46Smrg ;; 724942a55b46Smrg 725042a55b46Smrg -XCClinker) 725142a55b46Smrg prev=xcclinker 725242a55b46Smrg continue 725342a55b46Smrg ;; 725442a55b46Smrg 725542a55b46Smrg # -msg_* for osf cc 725642a55b46Smrg -msg_*) 725742a55b46Smrg func_quote_for_eval "$arg" 7258e3d74329Smrg arg=$func_quote_for_eval_result 725942a55b46Smrg ;; 726042a55b46Smrg 726142a55b46Smrg # Flags to be passed through unchanged, with rationale: 726242a55b46Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726342a55b46Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 726442a55b46Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726542a55b46Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726642a55b46Smrg # -q* compiler args for the IBM compiler 726742a55b46Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726842a55b46Smrg # -F/path path to uninstalled frameworks, gcc on darwin 726942a55b46Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270e3d74329Smrg # -fstack-protector* stack protector flags for GCC 727142a55b46Smrg # @file GCC response files 727242a55b46Smrg # -tp=* Portland pgcc target processor selection 727342a55b46Smrg # --sysroot=* for sysroot support 7274e3d74329Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275e3d74329Smrg # -stdlib=* select c++ std lib with clang 727642a55b46Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 727742a55b46Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7278e3d74329Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 727942a55b46Smrg func_quote_for_eval "$arg" 7280e3d74329Smrg arg=$func_quote_for_eval_result 728142a55b46Smrg func_append compile_command " $arg" 728242a55b46Smrg func_append finalize_command " $arg" 728342a55b46Smrg func_append compiler_flags " $arg" 728442a55b46Smrg continue 728542a55b46Smrg ;; 728642a55b46Smrg 7287e3d74329Smrg -Z*) 7288e3d74329Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289e3d74329Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7290e3d74329Smrg compiler_flags="$compiler_flags $arg" 7291e3d74329Smrg func_append compile_command " $arg" 7292e3d74329Smrg func_append finalize_command " $arg" 7293e3d74329Smrg case $arg in 7294e3d74329Smrg -Zlinker | -Zstack) 7295e3d74329Smrg prev=xcompiler 7296e3d74329Smrg ;; 7297e3d74329Smrg esac 7298e3d74329Smrg continue 7299e3d74329Smrg else 7300e3d74329Smrg # Otherwise treat like 'Some other compiler flag' below 7301e3d74329Smrg func_quote_for_eval "$arg" 7302e3d74329Smrg arg=$func_quote_for_eval_result 7303e3d74329Smrg fi 7304e3d74329Smrg ;; 7305e3d74329Smrg 730642a55b46Smrg # Some other compiler flag. 730742a55b46Smrg -* | +*) 730842a55b46Smrg func_quote_for_eval "$arg" 7309e3d74329Smrg arg=$func_quote_for_eval_result 731042a55b46Smrg ;; 731142a55b46Smrg 731242a55b46Smrg *.$objext) 731342a55b46Smrg # A standard object. 731442a55b46Smrg func_append objs " $arg" 731542a55b46Smrg ;; 731642a55b46Smrg 731742a55b46Smrg *.lo) 731842a55b46Smrg # A libtool-controlled object. 731942a55b46Smrg 732042a55b46Smrg # Check to see that this really is a libtool object. 732142a55b46Smrg if func_lalib_unsafe_p "$arg"; then 732242a55b46Smrg pic_object= 732342a55b46Smrg non_pic_object= 732442a55b46Smrg 732542a55b46Smrg # Read the .lo file 732642a55b46Smrg func_source "$arg" 732742a55b46Smrg 732842a55b46Smrg if test -z "$pic_object" || 732942a55b46Smrg test -z "$non_pic_object" || 7330e3d74329Smrg test none = "$pic_object" && 7331e3d74329Smrg test none = "$non_pic_object"; then 7332e3d74329Smrg func_fatal_error "cannot find name of object for '$arg'" 733342a55b46Smrg fi 733442a55b46Smrg 733542a55b46Smrg # Extract subdirectory from the argument. 733642a55b46Smrg func_dirname "$arg" "/" "" 7337e3d74329Smrg xdir=$func_dirname_result 733842a55b46Smrg 7339e3d74329Smrg test none = "$pic_object" || { 734042a55b46Smrg # Prepend the subdirectory the object is found in. 7341e3d74329Smrg pic_object=$xdir$pic_object 734242a55b46Smrg 7343e3d74329Smrg if test dlfiles = "$prev"; then 7344e3d74329Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 734542a55b46Smrg func_append dlfiles " $pic_object" 734642a55b46Smrg prev= 734742a55b46Smrg continue 734842a55b46Smrg else 734942a55b46Smrg # If libtool objects are unsupported, then we need to preload. 735042a55b46Smrg prev=dlprefiles 735142a55b46Smrg fi 735242a55b46Smrg fi 735342a55b46Smrg 735442a55b46Smrg # CHECK ME: I think I busted this. -Ossama 7355e3d74329Smrg if test dlprefiles = "$prev"; then 735642a55b46Smrg # Preload the old-style object. 735742a55b46Smrg func_append dlprefiles " $pic_object" 735842a55b46Smrg prev= 735942a55b46Smrg fi 736042a55b46Smrg 736142a55b46Smrg # A PIC object. 736242a55b46Smrg func_append libobjs " $pic_object" 7363e3d74329Smrg arg=$pic_object 7364e3d74329Smrg } 736542a55b46Smrg 736642a55b46Smrg # Non-PIC object. 7367e3d74329Smrg if test none != "$non_pic_object"; then 736842a55b46Smrg # Prepend the subdirectory the object is found in. 7369e3d74329Smrg non_pic_object=$xdir$non_pic_object 737042a55b46Smrg 737142a55b46Smrg # A standard non-PIC object 737242a55b46Smrg func_append non_pic_objects " $non_pic_object" 7373e3d74329Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7374e3d74329Smrg arg=$non_pic_object 737542a55b46Smrg fi 737642a55b46Smrg else 737742a55b46Smrg # If the PIC object exists, use it instead. 737842a55b46Smrg # $xdir was prepended to $pic_object above. 7379e3d74329Smrg non_pic_object=$pic_object 738042a55b46Smrg func_append non_pic_objects " $non_pic_object" 738142a55b46Smrg fi 738242a55b46Smrg else 738342a55b46Smrg # Only an error if not doing a dry-run. 738442a55b46Smrg if $opt_dry_run; then 738542a55b46Smrg # Extract subdirectory from the argument. 738642a55b46Smrg func_dirname "$arg" "/" "" 7387e3d74329Smrg xdir=$func_dirname_result 738842a55b46Smrg 738942a55b46Smrg func_lo2o "$arg" 739042a55b46Smrg pic_object=$xdir$objdir/$func_lo2o_result 739142a55b46Smrg non_pic_object=$xdir$func_lo2o_result 739242a55b46Smrg func_append libobjs " $pic_object" 739342a55b46Smrg func_append non_pic_objects " $non_pic_object" 739442a55b46Smrg else 7395e3d74329Smrg func_fatal_error "'$arg' is not a valid libtool object" 739642a55b46Smrg fi 739742a55b46Smrg fi 739842a55b46Smrg ;; 739942a55b46Smrg 740042a55b46Smrg *.$libext) 740142a55b46Smrg # An archive. 740242a55b46Smrg func_append deplibs " $arg" 740342a55b46Smrg func_append old_deplibs " $arg" 740442a55b46Smrg continue 740542a55b46Smrg ;; 740642a55b46Smrg 740742a55b46Smrg *.la) 740842a55b46Smrg # A libtool-controlled library. 740942a55b46Smrg 741042a55b46Smrg func_resolve_sysroot "$arg" 7411e3d74329Smrg if test dlfiles = "$prev"; then 741242a55b46Smrg # This library was specified with -dlopen. 741342a55b46Smrg func_append dlfiles " $func_resolve_sysroot_result" 741442a55b46Smrg prev= 7415e3d74329Smrg elif test dlprefiles = "$prev"; then 741642a55b46Smrg # The library was specified with -dlpreopen. 741742a55b46Smrg func_append dlprefiles " $func_resolve_sysroot_result" 741842a55b46Smrg prev= 741942a55b46Smrg else 742042a55b46Smrg func_append deplibs " $func_resolve_sysroot_result" 742142a55b46Smrg fi 742242a55b46Smrg continue 742342a55b46Smrg ;; 742442a55b46Smrg 742542a55b46Smrg # Some other compiler argument. 742642a55b46Smrg *) 742742a55b46Smrg # Unknown arguments in both finalize_command and compile_command need 742842a55b46Smrg # to be aesthetically quoted because they are evaled later. 742942a55b46Smrg func_quote_for_eval "$arg" 7430e3d74329Smrg arg=$func_quote_for_eval_result 743142a55b46Smrg ;; 743242a55b46Smrg esac # arg 743342a55b46Smrg 743442a55b46Smrg # Now actually substitute the argument into the commands. 743542a55b46Smrg if test -n "$arg"; then 743642a55b46Smrg func_append compile_command " $arg" 743742a55b46Smrg func_append finalize_command " $arg" 743842a55b46Smrg fi 743942a55b46Smrg done # argument parsing loop 744042a55b46Smrg 744142a55b46Smrg test -n "$prev" && \ 7442e3d74329Smrg func_fatal_help "the '$prevarg' option requires an argument" 744342a55b46Smrg 7444e3d74329Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 744542a55b46Smrg eval arg=\"$export_dynamic_flag_spec\" 744642a55b46Smrg func_append compile_command " $arg" 744742a55b46Smrg func_append finalize_command " $arg" 744842a55b46Smrg fi 744942a55b46Smrg 745042a55b46Smrg oldlibs= 745142a55b46Smrg # calculate the name of the file, without its directory 745242a55b46Smrg func_basename "$output" 7453e3d74329Smrg outputname=$func_basename_result 7454e3d74329Smrg libobjs_save=$libobjs 745542a55b46Smrg 745642a55b46Smrg if test -n "$shlibpath_var"; then 745742a55b46Smrg # get the directories listed in $shlibpath_var 7458e3d74329Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 745942a55b46Smrg else 746042a55b46Smrg shlib_search_path= 746142a55b46Smrg fi 746242a55b46Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 746342a55b46Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 746442a55b46Smrg 7465e3d74329Smrg # Definition is injected by LT_CONFIG during libtool generation. 7466e3d74329Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467e3d74329Smrg 746842a55b46Smrg func_dirname "$output" "/" "" 7469e3d74329Smrg output_objdir=$func_dirname_result$objdir 747042a55b46Smrg func_to_tool_file "$output_objdir/" 747142a55b46Smrg tool_output_objdir=$func_to_tool_file_result 747242a55b46Smrg # Create the object directory. 747342a55b46Smrg func_mkdir_p "$output_objdir" 747442a55b46Smrg 747542a55b46Smrg # Determine the type of output 747642a55b46Smrg case $output in 747742a55b46Smrg "") 747842a55b46Smrg func_fatal_help "you must specify an output file" 747942a55b46Smrg ;; 748042a55b46Smrg *.$libext) linkmode=oldlib ;; 748142a55b46Smrg *.lo | *.$objext) linkmode=obj ;; 748242a55b46Smrg *.la) linkmode=lib ;; 748342a55b46Smrg *) linkmode=prog ;; # Anything else should be a program. 748442a55b46Smrg esac 748542a55b46Smrg 748642a55b46Smrg specialdeplibs= 748742a55b46Smrg 748842a55b46Smrg libs= 748942a55b46Smrg # Find all interdependent deplibs by searching for libraries 749042a55b46Smrg # that are linked more than once (e.g. -la -lb -la) 749142a55b46Smrg for deplib in $deplibs; do 7492e3d74329Smrg if $opt_preserve_dup_deps; then 749342a55b46Smrg case "$libs " in 749442a55b46Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 749542a55b46Smrg esac 749642a55b46Smrg fi 749742a55b46Smrg func_append libs " $deplib" 749842a55b46Smrg done 749942a55b46Smrg 7500e3d74329Smrg if test lib = "$linkmode"; then 750142a55b46Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 750242a55b46Smrg 750342a55b46Smrg # Compute libraries that are listed more than once in $predeps 750442a55b46Smrg # $postdeps and mark them as special (i.e., whose duplicates are 750542a55b46Smrg # not to be eliminated). 750642a55b46Smrg pre_post_deps= 750742a55b46Smrg if $opt_duplicate_compiler_generated_deps; then 750842a55b46Smrg for pre_post_dep in $predeps $postdeps; do 750942a55b46Smrg case "$pre_post_deps " in 751042a55b46Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 751142a55b46Smrg esac 751242a55b46Smrg func_append pre_post_deps " $pre_post_dep" 751342a55b46Smrg done 751442a55b46Smrg fi 751542a55b46Smrg pre_post_deps= 751642a55b46Smrg fi 751742a55b46Smrg 751842a55b46Smrg deplibs= 751942a55b46Smrg newdependency_libs= 752042a55b46Smrg newlib_search_path= 752142a55b46Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 752242a55b46Smrg notinst_deplibs= # not-installed libtool libraries 752342a55b46Smrg notinst_path= # paths that contain not-installed libtool libraries 752442a55b46Smrg 752542a55b46Smrg case $linkmode in 752642a55b46Smrg lib) 752742a55b46Smrg passes="conv dlpreopen link" 752842a55b46Smrg for file in $dlfiles $dlprefiles; do 752942a55b46Smrg case $file in 753042a55b46Smrg *.la) ;; 753142a55b46Smrg *) 7532e3d74329Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 753342a55b46Smrg ;; 753442a55b46Smrg esac 753542a55b46Smrg done 753642a55b46Smrg ;; 753742a55b46Smrg prog) 753842a55b46Smrg compile_deplibs= 753942a55b46Smrg finalize_deplibs= 7540e3d74329Smrg alldeplibs=false 754142a55b46Smrg newdlfiles= 754242a55b46Smrg newdlprefiles= 754342a55b46Smrg passes="conv scan dlopen dlpreopen link" 754442a55b46Smrg ;; 754542a55b46Smrg *) passes="conv" 754642a55b46Smrg ;; 754742a55b46Smrg esac 754842a55b46Smrg 754942a55b46Smrg for pass in $passes; do 755042a55b46Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 755142a55b46Smrg # so that -L comes before libs that need it for instance... 7552e3d74329Smrg if test lib,link = "$linkmode,$pass"; then 755342a55b46Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 755442a55b46Smrg ## order, and fix it there properly 755542a55b46Smrg tmp_deplibs= 755642a55b46Smrg for deplib in $deplibs; do 755742a55b46Smrg tmp_deplibs="$deplib $tmp_deplibs" 755842a55b46Smrg done 7559e3d74329Smrg deplibs=$tmp_deplibs 756042a55b46Smrg fi 756142a55b46Smrg 7562e3d74329Smrg if test lib,link = "$linkmode,$pass" || 7563e3d74329Smrg test prog,scan = "$linkmode,$pass"; then 7564e3d74329Smrg libs=$deplibs 756542a55b46Smrg deplibs= 756642a55b46Smrg fi 7567e3d74329Smrg if test prog = "$linkmode"; then 756842a55b46Smrg case $pass in 7569e3d74329Smrg dlopen) libs=$dlfiles ;; 7570e3d74329Smrg dlpreopen) libs=$dlprefiles ;; 7571e3d74329Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 757242a55b46Smrg esac 757342a55b46Smrg fi 7574e3d74329Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 757542a55b46Smrg # Collect and forward deplibs of preopened libtool libs 757642a55b46Smrg for lib in $dlprefiles; do 757742a55b46Smrg # Ignore non-libtool-libs 757842a55b46Smrg dependency_libs= 757942a55b46Smrg func_resolve_sysroot "$lib" 758042a55b46Smrg case $lib in 758142a55b46Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 758242a55b46Smrg esac 758342a55b46Smrg 758442a55b46Smrg # Collect preopened libtool deplibs, except any this library 758542a55b46Smrg # has declared as weak libs 758642a55b46Smrg for deplib in $dependency_libs; do 758742a55b46Smrg func_basename "$deplib" 758842a55b46Smrg deplib_base=$func_basename_result 758942a55b46Smrg case " $weak_libs " in 759042a55b46Smrg *" $deplib_base "*) ;; 759142a55b46Smrg *) func_append deplibs " $deplib" ;; 759242a55b46Smrg esac 759342a55b46Smrg done 759442a55b46Smrg done 7595e3d74329Smrg libs=$dlprefiles 759642a55b46Smrg fi 7597e3d74329Smrg if test dlopen = "$pass"; then 759842a55b46Smrg # Collect dlpreopened libraries 7599e3d74329Smrg save_deplibs=$deplibs 760042a55b46Smrg deplibs= 760142a55b46Smrg fi 760242a55b46Smrg 760342a55b46Smrg for deplib in $libs; do 760442a55b46Smrg lib= 7605e3d74329Smrg found=false 760642a55b46Smrg case $deplib in 760742a55b46Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 760842a55b46Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 761042a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 761142a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 761242a55b46Smrg else 761342a55b46Smrg func_append compiler_flags " $deplib" 7614e3d74329Smrg if test lib = "$linkmode"; then 761542a55b46Smrg case "$new_inherited_linker_flags " in 761642a55b46Smrg *" $deplib "*) ;; 761742a55b46Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 761842a55b46Smrg esac 761942a55b46Smrg fi 762042a55b46Smrg fi 762142a55b46Smrg continue 762242a55b46Smrg ;; 762342a55b46Smrg -l*) 7624e3d74329Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7625e3d74329Smrg func_warning "'-l' is ignored for archives/objects" 762642a55b46Smrg continue 762742a55b46Smrg fi 762842a55b46Smrg func_stripname '-l' '' "$deplib" 762942a55b46Smrg name=$func_stripname_result 7630e3d74329Smrg if test lib = "$linkmode"; then 763142a55b46Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 763242a55b46Smrg else 763342a55b46Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 763442a55b46Smrg fi 763542a55b46Smrg for searchdir in $searchdirs; do 763642a55b46Smrg for search_ext in .la $std_shrext .so .a; do 763742a55b46Smrg # Search the libtool library 7638e3d74329Smrg lib=$searchdir/lib$name$search_ext 763942a55b46Smrg if test -f "$lib"; then 7640e3d74329Smrg if test .la = "$search_ext"; then 7641e3d74329Smrg found=: 764242a55b46Smrg else 7643e3d74329Smrg found=false 764442a55b46Smrg fi 764542a55b46Smrg break 2 764642a55b46Smrg fi 764742a55b46Smrg done 764842a55b46Smrg done 7649e3d74329Smrg if $found; then 7650e3d74329Smrg # deplib is a libtool library 765142a55b46Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 765242a55b46Smrg # We need to do some special things here, and not later. 7653e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 765442a55b46Smrg case " $predeps $postdeps " in 765542a55b46Smrg *" $deplib "*) 765642a55b46Smrg if func_lalib_p "$lib"; then 765742a55b46Smrg library_names= 765842a55b46Smrg old_library= 765942a55b46Smrg func_source "$lib" 766042a55b46Smrg for l in $old_library $library_names; do 7661e3d74329Smrg ll=$l 766242a55b46Smrg done 7663e3d74329Smrg if test "X$ll" = "X$old_library"; then # only static version available 7664e3d74329Smrg found=false 766542a55b46Smrg func_dirname "$lib" "" "." 7666e3d74329Smrg ladir=$func_dirname_result 766742a55b46Smrg lib=$ladir/$old_library 7668e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 766942a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 767042a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 767142a55b46Smrg else 767242a55b46Smrg deplibs="$deplib $deplibs" 7673e3d74329Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 767442a55b46Smrg fi 767542a55b46Smrg continue 767642a55b46Smrg fi 767742a55b46Smrg fi 767842a55b46Smrg ;; 767942a55b46Smrg *) ;; 768042a55b46Smrg esac 768142a55b46Smrg fi 7682e3d74329Smrg else 7683e3d74329Smrg # deplib doesn't seem to be a libtool library 7684e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 7685e3d74329Smrg compile_deplibs="$deplib $compile_deplibs" 7686e3d74329Smrg finalize_deplibs="$deplib $finalize_deplibs" 7687e3d74329Smrg else 7688e3d74329Smrg deplibs="$deplib $deplibs" 7689e3d74329Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690e3d74329Smrg fi 7691e3d74329Smrg continue 769242a55b46Smrg fi 769342a55b46Smrg ;; # -l 769442a55b46Smrg *.ltframework) 7695e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 769642a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 769742a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 769842a55b46Smrg else 769942a55b46Smrg deplibs="$deplib $deplibs" 7700e3d74329Smrg if test lib = "$linkmode"; then 770142a55b46Smrg case "$new_inherited_linker_flags " in 770242a55b46Smrg *" $deplib "*) ;; 770342a55b46Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 770442a55b46Smrg esac 770542a55b46Smrg fi 770642a55b46Smrg fi 770742a55b46Smrg continue 770842a55b46Smrg ;; 770942a55b46Smrg -L*) 771042a55b46Smrg case $linkmode in 771142a55b46Smrg lib) 771242a55b46Smrg deplibs="$deplib $deplibs" 7713e3d74329Smrg test conv = "$pass" && continue 771442a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 771542a55b46Smrg func_stripname '-L' '' "$deplib" 771642a55b46Smrg func_resolve_sysroot "$func_stripname_result" 771742a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 771842a55b46Smrg ;; 771942a55b46Smrg prog) 7720e3d74329Smrg if test conv = "$pass"; then 772142a55b46Smrg deplibs="$deplib $deplibs" 772242a55b46Smrg continue 772342a55b46Smrg fi 7724e3d74329Smrg if test scan = "$pass"; then 772542a55b46Smrg deplibs="$deplib $deplibs" 772642a55b46Smrg else 772742a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 772842a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 772942a55b46Smrg fi 773042a55b46Smrg func_stripname '-L' '' "$deplib" 773142a55b46Smrg func_resolve_sysroot "$func_stripname_result" 773242a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 773342a55b46Smrg ;; 773442a55b46Smrg *) 7735e3d74329Smrg func_warning "'-L' is ignored for archives/objects" 773642a55b46Smrg ;; 773742a55b46Smrg esac # linkmode 773842a55b46Smrg continue 773942a55b46Smrg ;; # -L 774042a55b46Smrg -R*) 7741e3d74329Smrg if test link = "$pass"; then 774242a55b46Smrg func_stripname '-R' '' "$deplib" 774342a55b46Smrg func_resolve_sysroot "$func_stripname_result" 774442a55b46Smrg dir=$func_resolve_sysroot_result 774542a55b46Smrg # Make sure the xrpath contains only unique directories. 774642a55b46Smrg case "$xrpath " in 774742a55b46Smrg *" $dir "*) ;; 774842a55b46Smrg *) func_append xrpath " $dir" ;; 774942a55b46Smrg esac 775042a55b46Smrg fi 775142a55b46Smrg deplibs="$deplib $deplibs" 775242a55b46Smrg continue 775342a55b46Smrg ;; 775442a55b46Smrg *.la) 775542a55b46Smrg func_resolve_sysroot "$deplib" 775642a55b46Smrg lib=$func_resolve_sysroot_result 775742a55b46Smrg ;; 775842a55b46Smrg *.$libext) 7759e3d74329Smrg if test conv = "$pass"; then 776042a55b46Smrg deplibs="$deplib $deplibs" 776142a55b46Smrg continue 776242a55b46Smrg fi 776342a55b46Smrg case $linkmode in 776442a55b46Smrg lib) 776542a55b46Smrg # Linking convenience modules into shared libraries is allowed, 776642a55b46Smrg # but linking other static libraries is non-portable. 776742a55b46Smrg case " $dlpreconveniencelibs " in 776842a55b46Smrg *" $deplib "*) ;; 776942a55b46Smrg *) 7770e3d74329Smrg valid_a_lib=false 777142a55b46Smrg case $deplibs_check_method in 777242a55b46Smrg match_pattern*) 777342a55b46Smrg set dummy $deplibs_check_method; shift 777442a55b46Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777542a55b46Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 777642a55b46Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 7777e3d74329Smrg valid_a_lib=: 777842a55b46Smrg fi 777942a55b46Smrg ;; 778042a55b46Smrg pass_all) 7781e3d74329Smrg valid_a_lib=: 778242a55b46Smrg ;; 778342a55b46Smrg esac 7784e3d74329Smrg if $valid_a_lib; then 7785e3d74329Smrg echo 7786e3d74329Smrg $ECHO "*** Warning: Linking the shared library $output against the" 7787e3d74329Smrg $ECHO "*** static library $deplib is not portable!" 7788e3d74329Smrg deplibs="$deplib $deplibs" 7789e3d74329Smrg else 779042a55b46Smrg echo 779142a55b46Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779242a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 779342a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 779442a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 779542a55b46Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 779642a55b46Smrg echo "*** that it is just a static archive that I should not use here." 779742a55b46Smrg fi 779842a55b46Smrg ;; 779942a55b46Smrg esac 780042a55b46Smrg continue 780142a55b46Smrg ;; 780242a55b46Smrg prog) 7803e3d74329Smrg if test link != "$pass"; then 780442a55b46Smrg deplibs="$deplib $deplibs" 780542a55b46Smrg else 780642a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 780742a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 780842a55b46Smrg fi 780942a55b46Smrg continue 781042a55b46Smrg ;; 781142a55b46Smrg esac # linkmode 781242a55b46Smrg ;; # *.$libext 781342a55b46Smrg *.lo | *.$objext) 7814e3d74329Smrg if test conv = "$pass"; then 781542a55b46Smrg deplibs="$deplib $deplibs" 7816e3d74329Smrg elif test prog = "$linkmode"; then 7817e3d74329Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 781842a55b46Smrg # If there is no dlopen support or we're linking statically, 781942a55b46Smrg # we need to preload. 782042a55b46Smrg func_append newdlprefiles " $deplib" 782142a55b46Smrg compile_deplibs="$deplib $compile_deplibs" 782242a55b46Smrg finalize_deplibs="$deplib $finalize_deplibs" 782342a55b46Smrg else 782442a55b46Smrg func_append newdlfiles " $deplib" 782542a55b46Smrg fi 782642a55b46Smrg fi 782742a55b46Smrg continue 782842a55b46Smrg ;; 782942a55b46Smrg %DEPLIBS%) 7830e3d74329Smrg alldeplibs=: 783142a55b46Smrg continue 783242a55b46Smrg ;; 783342a55b46Smrg esac # case $deplib 783442a55b46Smrg 7835e3d74329Smrg $found || test -f "$lib" \ 7836e3d74329Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 783742a55b46Smrg 783842a55b46Smrg # Check to see that this really is a libtool archive. 783942a55b46Smrg func_lalib_unsafe_p "$lib" \ 7840e3d74329Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 784142a55b46Smrg 784242a55b46Smrg func_dirname "$lib" "" "." 7843e3d74329Smrg ladir=$func_dirname_result 784442a55b46Smrg 784542a55b46Smrg dlname= 784642a55b46Smrg dlopen= 784742a55b46Smrg dlpreopen= 784842a55b46Smrg libdir= 784942a55b46Smrg library_names= 785042a55b46Smrg old_library= 785142a55b46Smrg inherited_linker_flags= 785242a55b46Smrg # If the library was installed with an old release of libtool, 785342a55b46Smrg # it will not redefine variables installed, or shouldnotlink 785442a55b46Smrg installed=yes 785542a55b46Smrg shouldnotlink=no 785642a55b46Smrg avoidtemprpath= 785742a55b46Smrg 785842a55b46Smrg 785942a55b46Smrg # Read the .la file 786042a55b46Smrg func_source "$lib" 786142a55b46Smrg 786242a55b46Smrg # Convert "-framework foo" to "foo.ltframework" 786342a55b46Smrg if test -n "$inherited_linker_flags"; then 786442a55b46Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 786542a55b46Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 786642a55b46Smrg case " $new_inherited_linker_flags " in 786742a55b46Smrg *" $tmp_inherited_linker_flag "*) ;; 786842a55b46Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 786942a55b46Smrg esac 787042a55b46Smrg done 787142a55b46Smrg fi 787242a55b46Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873e3d74329Smrg if test lib,link = "$linkmode,$pass" || 7874e3d74329Smrg test prog,scan = "$linkmode,$pass" || 7875e3d74329Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 787642a55b46Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 787742a55b46Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 787842a55b46Smrg fi 787942a55b46Smrg 7880e3d74329Smrg if test conv = "$pass"; then 788142a55b46Smrg # Only check for convenience libraries 788242a55b46Smrg deplibs="$lib $deplibs" 788342a55b46Smrg if test -z "$libdir"; then 788442a55b46Smrg if test -z "$old_library"; then 7885e3d74329Smrg func_fatal_error "cannot find name of link library for '$lib'" 788642a55b46Smrg fi 788742a55b46Smrg # It is a libtool convenience library, so add in its objects. 788842a55b46Smrg func_append convenience " $ladir/$objdir/$old_library" 788942a55b46Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7890e3d74329Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891e3d74329Smrg func_fatal_error "'$lib' is not a convenience library" 789242a55b46Smrg fi 7893e3d74329Smrg tmp_libs= 7894e3d74329Smrg for deplib in $dependency_libs; do 7895e3d74329Smrg deplibs="$deplib $deplibs" 7896e3d74329Smrg if $opt_preserve_dup_deps; then 7897e3d74329Smrg case "$tmp_libs " in 7898e3d74329Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899e3d74329Smrg esac 7900e3d74329Smrg fi 7901e3d74329Smrg func_append tmp_libs " $deplib" 7902e3d74329Smrg done 790342a55b46Smrg continue 790442a55b46Smrg fi # $pass = conv 790542a55b46Smrg 790642a55b46Smrg 790742a55b46Smrg # Get the name of the library we link against. 790842a55b46Smrg linklib= 790942a55b46Smrg if test -n "$old_library" && 7910e3d74329Smrg { test yes = "$prefer_static_libs" || 7911e3d74329Smrg test built,no = "$prefer_static_libs,$installed"; }; then 791242a55b46Smrg linklib=$old_library 791342a55b46Smrg else 791442a55b46Smrg for l in $old_library $library_names; do 7915e3d74329Smrg linklib=$l 791642a55b46Smrg done 791742a55b46Smrg fi 791842a55b46Smrg if test -z "$linklib"; then 7919e3d74329Smrg func_fatal_error "cannot find name of link library for '$lib'" 792042a55b46Smrg fi 792142a55b46Smrg 792242a55b46Smrg # This library was specified with -dlopen. 7923e3d74329Smrg if test dlopen = "$pass"; then 7924e3d74329Smrg test -z "$libdir" \ 7925e3d74329Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 792642a55b46Smrg if test -z "$dlname" || 7927e3d74329Smrg test yes != "$dlopen_support" || 7928e3d74329Smrg test no = "$build_libtool_libs" 7929e3d74329Smrg then 793042a55b46Smrg # If there is no dlname, no dlopen support or we're linking 793142a55b46Smrg # statically, we need to preload. We also need to preload any 793242a55b46Smrg # dependent libraries so libltdl's deplib preloader doesn't 793342a55b46Smrg # bomb out in the load deplibs phase. 793442a55b46Smrg func_append dlprefiles " $lib $dependency_libs" 793542a55b46Smrg else 793642a55b46Smrg func_append newdlfiles " $lib" 793742a55b46Smrg fi 793842a55b46Smrg continue 793942a55b46Smrg fi # $pass = dlopen 794042a55b46Smrg 794142a55b46Smrg # We need an absolute path. 794242a55b46Smrg case $ladir in 7943e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 794442a55b46Smrg *) 794542a55b46Smrg abs_ladir=`cd "$ladir" && pwd` 794642a55b46Smrg if test -z "$abs_ladir"; then 7947e3d74329Smrg func_warning "cannot determine absolute directory name of '$ladir'" 794842a55b46Smrg func_warning "passing it literally to the linker, although it might fail" 7949e3d74329Smrg abs_ladir=$ladir 795042a55b46Smrg fi 795142a55b46Smrg ;; 795242a55b46Smrg esac 795342a55b46Smrg func_basename "$lib" 7954e3d74329Smrg laname=$func_basename_result 795542a55b46Smrg 795642a55b46Smrg # Find the relevant object directory and library name. 7957e3d74329Smrg if test yes = "$installed"; then 795842a55b46Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959e3d74329Smrg func_warning "library '$lib' was moved." 7960e3d74329Smrg dir=$ladir 7961e3d74329Smrg absdir=$abs_ladir 7962e3d74329Smrg libdir=$abs_ladir 796342a55b46Smrg else 7964e3d74329Smrg dir=$lt_sysroot$libdir 7965e3d74329Smrg absdir=$lt_sysroot$libdir 796642a55b46Smrg fi 7967e3d74329Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 796842a55b46Smrg else 796942a55b46Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970e3d74329Smrg dir=$ladir 7971e3d74329Smrg absdir=$abs_ladir 797242a55b46Smrg # Remove this search path later 797342a55b46Smrg func_append notinst_path " $abs_ladir" 797442a55b46Smrg else 7975e3d74329Smrg dir=$ladir/$objdir 7976e3d74329Smrg absdir=$abs_ladir/$objdir 797742a55b46Smrg # Remove this search path later 797842a55b46Smrg func_append notinst_path " $abs_ladir" 797942a55b46Smrg fi 798042a55b46Smrg fi # $installed = yes 798142a55b46Smrg func_stripname 'lib' '.la' "$laname" 798242a55b46Smrg name=$func_stripname_result 798342a55b46Smrg 798442a55b46Smrg # This library was specified with -dlpreopen. 7985e3d74329Smrg if test dlpreopen = "$pass"; then 7986e3d74329Smrg if test -z "$libdir" && test prog = "$linkmode"; then 7987e3d74329Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 798842a55b46Smrg fi 7989e3d74329Smrg case $host in 799042a55b46Smrg # special handling for platforms with PE-DLLs. 799142a55b46Smrg *cygwin* | *mingw* | *cegcc* ) 799242a55b46Smrg # Linker will automatically link against shared library if both 799342a55b46Smrg # static and shared are present. Therefore, ensure we extract 799442a55b46Smrg # symbols from the import library if a shared library is present 799542a55b46Smrg # (otherwise, the dlopen module name will be incorrect). We do 799642a55b46Smrg # this by putting the import library name into $newdlprefiles. 799742a55b46Smrg # We recover the dlopen module name by 'saving' the la file 799842a55b46Smrg # name in a special purpose variable, and (later) extracting the 799942a55b46Smrg # dlname from the la file. 800042a55b46Smrg if test -n "$dlname"; then 800142a55b46Smrg func_tr_sh "$dir/$linklib" 800242a55b46Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 800342a55b46Smrg func_append newdlprefiles " $dir/$linklib" 800442a55b46Smrg else 800542a55b46Smrg func_append newdlprefiles " $dir/$old_library" 800642a55b46Smrg # Keep a list of preopened convenience libraries to check 800742a55b46Smrg # that they are being used correctly in the link pass. 800842a55b46Smrg test -z "$libdir" && \ 800942a55b46Smrg func_append dlpreconveniencelibs " $dir/$old_library" 801042a55b46Smrg fi 801142a55b46Smrg ;; 801242a55b46Smrg * ) 801342a55b46Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 801442a55b46Smrg # are required to link). 801542a55b46Smrg if test -n "$old_library"; then 801642a55b46Smrg func_append newdlprefiles " $dir/$old_library" 801742a55b46Smrg # Keep a list of preopened convenience libraries to check 801842a55b46Smrg # that they are being used correctly in the link pass. 801942a55b46Smrg test -z "$libdir" && \ 802042a55b46Smrg func_append dlpreconveniencelibs " $dir/$old_library" 802142a55b46Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 802242a55b46Smrg elif test -n "$dlname"; then 802342a55b46Smrg func_append newdlprefiles " $dir/$dlname" 802442a55b46Smrg else 802542a55b46Smrg func_append newdlprefiles " $dir/$linklib" 802642a55b46Smrg fi 802742a55b46Smrg ;; 802842a55b46Smrg esac 802942a55b46Smrg fi # $pass = dlpreopen 803042a55b46Smrg 803142a55b46Smrg if test -z "$libdir"; then 803242a55b46Smrg # Link the convenience library 8033e3d74329Smrg if test lib = "$linkmode"; then 803442a55b46Smrg deplibs="$dir/$old_library $deplibs" 8035e3d74329Smrg elif test prog,link = "$linkmode,$pass"; then 803642a55b46Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 803742a55b46Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 803842a55b46Smrg else 803942a55b46Smrg deplibs="$lib $deplibs" # used for prog,scan pass 804042a55b46Smrg fi 804142a55b46Smrg continue 804242a55b46Smrg fi 804342a55b46Smrg 804442a55b46Smrg 8045e3d74329Smrg if test prog = "$linkmode" && test link != "$pass"; then 804642a55b46Smrg func_append newlib_search_path " $ladir" 804742a55b46Smrg deplibs="$lib $deplibs" 804842a55b46Smrg 8049e3d74329Smrg linkalldeplibs=false 8050e3d74329Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8051e3d74329Smrg test no = "$build_libtool_libs"; then 8052e3d74329Smrg linkalldeplibs=: 805342a55b46Smrg fi 805442a55b46Smrg 805542a55b46Smrg tmp_libs= 805642a55b46Smrg for deplib in $dependency_libs; do 805742a55b46Smrg case $deplib in 805842a55b46Smrg -L*) func_stripname '-L' '' "$deplib" 805942a55b46Smrg func_resolve_sysroot "$func_stripname_result" 806042a55b46Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 806142a55b46Smrg ;; 806242a55b46Smrg esac 806342a55b46Smrg # Need to link against all dependency_libs? 8064e3d74329Smrg if $linkalldeplibs; then 806542a55b46Smrg deplibs="$deplib $deplibs" 806642a55b46Smrg else 806742a55b46Smrg # Need to hardcode shared library paths 806842a55b46Smrg # or/and link against static libraries 806942a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 807042a55b46Smrg fi 8071e3d74329Smrg if $opt_preserve_dup_deps; then 807242a55b46Smrg case "$tmp_libs " in 807342a55b46Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 807442a55b46Smrg esac 807542a55b46Smrg fi 807642a55b46Smrg func_append tmp_libs " $deplib" 807742a55b46Smrg done # for deplib 807842a55b46Smrg continue 807942a55b46Smrg fi # $linkmode = prog... 808042a55b46Smrg 8081e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 808242a55b46Smrg if test -n "$library_names" && 8083e3d74329Smrg { { test no = "$prefer_static_libs" || 8084e3d74329Smrg test built,yes = "$prefer_static_libs,$installed"; } || 808542a55b46Smrg test -z "$old_library"; }; then 808642a55b46Smrg # We need to hardcode the library path 8087e3d74329Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 808842a55b46Smrg # Make sure the rpath contains only unique directories. 8089e3d74329Smrg case $temp_rpath: in 809042a55b46Smrg *"$absdir:"*) ;; 809142a55b46Smrg *) func_append temp_rpath "$absdir:" ;; 809242a55b46Smrg esac 809342a55b46Smrg fi 809442a55b46Smrg 809542a55b46Smrg # Hardcode the library path. 809642a55b46Smrg # Skip directories that are in the system default run-time 809742a55b46Smrg # search path. 809842a55b46Smrg case " $sys_lib_dlsearch_path " in 809942a55b46Smrg *" $absdir "*) ;; 810042a55b46Smrg *) 810142a55b46Smrg case "$compile_rpath " in 810242a55b46Smrg *" $absdir "*) ;; 810342a55b46Smrg *) func_append compile_rpath " $absdir" ;; 810442a55b46Smrg esac 810542a55b46Smrg ;; 810642a55b46Smrg esac 810742a55b46Smrg case " $sys_lib_dlsearch_path " in 810842a55b46Smrg *" $libdir "*) ;; 810942a55b46Smrg *) 811042a55b46Smrg case "$finalize_rpath " in 811142a55b46Smrg *" $libdir "*) ;; 811242a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 811342a55b46Smrg esac 811442a55b46Smrg ;; 811542a55b46Smrg esac 811642a55b46Smrg fi # $linkmode,$pass = prog,link... 811742a55b46Smrg 8118e3d74329Smrg if $alldeplibs && 8119e3d74329Smrg { test pass_all = "$deplibs_check_method" || 8120e3d74329Smrg { test yes = "$build_libtool_libs" && 812142a55b46Smrg test -n "$library_names"; }; }; then 812242a55b46Smrg # We only need to search for static libraries 812342a55b46Smrg continue 812442a55b46Smrg fi 812542a55b46Smrg fi 812642a55b46Smrg 812742a55b46Smrg link_static=no # Whether the deplib will be linked statically 812842a55b46Smrg use_static_libs=$prefer_static_libs 8129e3d74329Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 813042a55b46Smrg use_static_libs=no 813142a55b46Smrg fi 813242a55b46Smrg if test -n "$library_names" && 8133e3d74329Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 813442a55b46Smrg case $host in 8135e3d74329Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 813642a55b46Smrg # No point in relinking DLLs because paths are not encoded 813742a55b46Smrg func_append notinst_deplibs " $lib" 813842a55b46Smrg need_relink=no 813942a55b46Smrg ;; 814042a55b46Smrg *) 8141e3d74329Smrg if test no = "$installed"; then 814242a55b46Smrg func_append notinst_deplibs " $lib" 814342a55b46Smrg need_relink=yes 814442a55b46Smrg fi 814542a55b46Smrg ;; 814642a55b46Smrg esac 814742a55b46Smrg # This is a shared library 814842a55b46Smrg 814942a55b46Smrg # Warn about portability, can't link against -module's on some 815042a55b46Smrg # systems (darwin). Don't bleat about dlopened modules though! 8151e3d74329Smrg dlopenmodule= 815242a55b46Smrg for dlpremoduletest in $dlprefiles; do 815342a55b46Smrg if test "X$dlpremoduletest" = "X$lib"; then 8154e3d74329Smrg dlopenmodule=$dlpremoduletest 815542a55b46Smrg break 815642a55b46Smrg fi 815742a55b46Smrg done 8158e3d74329Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 815942a55b46Smrg echo 8160e3d74329Smrg if test prog = "$linkmode"; then 816142a55b46Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 816242a55b46Smrg else 816342a55b46Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 816442a55b46Smrg fi 816542a55b46Smrg $ECHO "*** $linklib is not portable!" 816642a55b46Smrg fi 8167e3d74329Smrg if test lib = "$linkmode" && 8168e3d74329Smrg test yes = "$hardcode_into_libs"; then 816942a55b46Smrg # Hardcode the library path. 817042a55b46Smrg # Skip directories that are in the system default run-time 817142a55b46Smrg # search path. 817242a55b46Smrg case " $sys_lib_dlsearch_path " in 817342a55b46Smrg *" $absdir "*) ;; 817442a55b46Smrg *) 817542a55b46Smrg case "$compile_rpath " in 817642a55b46Smrg *" $absdir "*) ;; 817742a55b46Smrg *) func_append compile_rpath " $absdir" ;; 817842a55b46Smrg esac 817942a55b46Smrg ;; 818042a55b46Smrg esac 818142a55b46Smrg case " $sys_lib_dlsearch_path " in 818242a55b46Smrg *" $libdir "*) ;; 818342a55b46Smrg *) 818442a55b46Smrg case "$finalize_rpath " in 818542a55b46Smrg *" $libdir "*) ;; 818642a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 818742a55b46Smrg esac 818842a55b46Smrg ;; 818942a55b46Smrg esac 819042a55b46Smrg fi 819142a55b46Smrg 819242a55b46Smrg if test -n "$old_archive_from_expsyms_cmds"; then 819342a55b46Smrg # figure out the soname 819442a55b46Smrg set dummy $library_names 819542a55b46Smrg shift 8196e3d74329Smrg realname=$1 819742a55b46Smrg shift 819842a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 819942a55b46Smrg # use dlname if we got it. it's perfectly good, no? 820042a55b46Smrg if test -n "$dlname"; then 8201e3d74329Smrg soname=$dlname 820242a55b46Smrg elif test -n "$soname_spec"; then 820342a55b46Smrg # bleh windows 820442a55b46Smrg case $host in 8205e3d74329Smrg *cygwin* | mingw* | *cegcc* | *os2*) 820642a55b46Smrg func_arith $current - $age 820742a55b46Smrg major=$func_arith_result 8208e3d74329Smrg versuffix=-$major 820942a55b46Smrg ;; 821042a55b46Smrg esac 821142a55b46Smrg eval soname=\"$soname_spec\" 821242a55b46Smrg else 8213e3d74329Smrg soname=$realname 821442a55b46Smrg fi 821542a55b46Smrg 821642a55b46Smrg # Make a new name for the extract_expsyms_cmds to use 8217e3d74329Smrg soroot=$soname 821842a55b46Smrg func_basename "$soroot" 8219e3d74329Smrg soname=$func_basename_result 822042a55b46Smrg func_stripname 'lib' '.dll' "$soname" 822142a55b46Smrg newlib=libimp-$func_stripname_result.a 822242a55b46Smrg 822342a55b46Smrg # If the library has no export list, then create one now 822442a55b46Smrg if test -f "$output_objdir/$soname-def"; then : 822542a55b46Smrg else 8226e3d74329Smrg func_verbose "extracting exported symbol list from '$soname'" 822742a55b46Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 822842a55b46Smrg fi 822942a55b46Smrg 823042a55b46Smrg # Create $newlib 823142a55b46Smrg if test -f "$output_objdir/$newlib"; then :; else 8232e3d74329Smrg func_verbose "generating import library for '$soname'" 823342a55b46Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 823442a55b46Smrg fi 823542a55b46Smrg # make sure the library variables are pointing to the new library 823642a55b46Smrg dir=$output_objdir 823742a55b46Smrg linklib=$newlib 823842a55b46Smrg fi # test -n "$old_archive_from_expsyms_cmds" 823942a55b46Smrg 8240e3d74329Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 824142a55b46Smrg add_shlibpath= 824242a55b46Smrg add_dir= 824342a55b46Smrg add= 824442a55b46Smrg lib_linked=yes 824542a55b46Smrg case $hardcode_action in 824642a55b46Smrg immediate | unsupported) 8247e3d74329Smrg if test no = "$hardcode_direct"; then 8248e3d74329Smrg add=$dir/$linklib 824942a55b46Smrg case $host in 8250e3d74329Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251e3d74329Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 825242a55b46Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253e3d74329Smrg *-*-unixware7*) add_dir=-L$dir ;; 825442a55b46Smrg *-*-darwin* ) 8255e3d74329Smrg # if the lib is a (non-dlopened) module then we cannot 825642a55b46Smrg # link against it, someone is ignoring the earlier warnings 825742a55b46Smrg if /usr/bin/file -L $add 2> /dev/null | 8258e3d74329Smrg $GREP ": [^:]* bundle" >/dev/null; then 825942a55b46Smrg if test "X$dlopenmodule" != "X$lib"; then 826042a55b46Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261e3d74329Smrg if test -z "$old_library"; then 826242a55b46Smrg echo 826342a55b46Smrg echo "*** And there doesn't seem to be a static archive available" 826442a55b46Smrg echo "*** The link will probably fail, sorry" 826542a55b46Smrg else 8266e3d74329Smrg add=$dir/$old_library 826742a55b46Smrg fi 826842a55b46Smrg elif test -n "$old_library"; then 8269e3d74329Smrg add=$dir/$old_library 827042a55b46Smrg fi 827142a55b46Smrg fi 827242a55b46Smrg esac 8273e3d74329Smrg elif test no = "$hardcode_minus_L"; then 827442a55b46Smrg case $host in 8275e3d74329Smrg *-*-sunos*) add_shlibpath=$dir ;; 827642a55b46Smrg esac 8277e3d74329Smrg add_dir=-L$dir 8278e3d74329Smrg add=-l$name 8279e3d74329Smrg elif test no = "$hardcode_shlibpath_var"; then 8280e3d74329Smrg add_shlibpath=$dir 8281e3d74329Smrg add=-l$name 828242a55b46Smrg else 828342a55b46Smrg lib_linked=no 828442a55b46Smrg fi 828542a55b46Smrg ;; 828642a55b46Smrg relink) 8287e3d74329Smrg if test yes = "$hardcode_direct" && 8288e3d74329Smrg test no = "$hardcode_direct_absolute"; then 8289e3d74329Smrg add=$dir/$linklib 8290e3d74329Smrg elif test yes = "$hardcode_minus_L"; then 8291e3d74329Smrg add_dir=-L$absdir 829242a55b46Smrg # Try looking first in the location we're being installed to. 829342a55b46Smrg if test -n "$inst_prefix_dir"; then 829442a55b46Smrg case $libdir in 829542a55b46Smrg [\\/]*) 829642a55b46Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 829742a55b46Smrg ;; 829842a55b46Smrg esac 829942a55b46Smrg fi 8300e3d74329Smrg add=-l$name 8301e3d74329Smrg elif test yes = "$hardcode_shlibpath_var"; then 8302e3d74329Smrg add_shlibpath=$dir 8303e3d74329Smrg add=-l$name 830442a55b46Smrg else 830542a55b46Smrg lib_linked=no 830642a55b46Smrg fi 830742a55b46Smrg ;; 830842a55b46Smrg *) lib_linked=no ;; 830942a55b46Smrg esac 831042a55b46Smrg 8311e3d74329Smrg if test yes != "$lib_linked"; then 831242a55b46Smrg func_fatal_configuration "unsupported hardcode properties" 831342a55b46Smrg fi 831442a55b46Smrg 831542a55b46Smrg if test -n "$add_shlibpath"; then 831642a55b46Smrg case :$compile_shlibpath: in 831742a55b46Smrg *":$add_shlibpath:"*) ;; 831842a55b46Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 831942a55b46Smrg esac 832042a55b46Smrg fi 8321e3d74329Smrg if test prog = "$linkmode"; then 832242a55b46Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 832342a55b46Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 832442a55b46Smrg else 832542a55b46Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 832642a55b46Smrg test -n "$add" && deplibs="$add $deplibs" 8327e3d74329Smrg if test yes != "$hardcode_direct" && 8328e3d74329Smrg test yes != "$hardcode_minus_L" && 8329e3d74329Smrg test yes = "$hardcode_shlibpath_var"; then 833042a55b46Smrg case :$finalize_shlibpath: in 833142a55b46Smrg *":$libdir:"*) ;; 833242a55b46Smrg *) func_append finalize_shlibpath "$libdir:" ;; 833342a55b46Smrg esac 833442a55b46Smrg fi 833542a55b46Smrg fi 833642a55b46Smrg fi 833742a55b46Smrg 8338e3d74329Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 833942a55b46Smrg add_shlibpath= 834042a55b46Smrg add_dir= 834142a55b46Smrg add= 834242a55b46Smrg # Finalize command for both is simple: just hardcode it. 8343e3d74329Smrg if test yes = "$hardcode_direct" && 8344e3d74329Smrg test no = "$hardcode_direct_absolute"; then 8345e3d74329Smrg add=$libdir/$linklib 8346e3d74329Smrg elif test yes = "$hardcode_minus_L"; then 8347e3d74329Smrg add_dir=-L$libdir 8348e3d74329Smrg add=-l$name 8349e3d74329Smrg elif test yes = "$hardcode_shlibpath_var"; then 835042a55b46Smrg case :$finalize_shlibpath: in 835142a55b46Smrg *":$libdir:"*) ;; 835242a55b46Smrg *) func_append finalize_shlibpath "$libdir:" ;; 835342a55b46Smrg esac 8354e3d74329Smrg add=-l$name 8355e3d74329Smrg elif test yes = "$hardcode_automatic"; then 835642a55b46Smrg if test -n "$inst_prefix_dir" && 8357e3d74329Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8358e3d74329Smrg add=$inst_prefix_dir$libdir/$linklib 835942a55b46Smrg else 8360e3d74329Smrg add=$libdir/$linklib 836142a55b46Smrg fi 836242a55b46Smrg else 836342a55b46Smrg # We cannot seem to hardcode it, guess we'll fake it. 8364e3d74329Smrg add_dir=-L$libdir 836542a55b46Smrg # Try looking first in the location we're being installed to. 836642a55b46Smrg if test -n "$inst_prefix_dir"; then 836742a55b46Smrg case $libdir in 836842a55b46Smrg [\\/]*) 836942a55b46Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 837042a55b46Smrg ;; 837142a55b46Smrg esac 837242a55b46Smrg fi 8373e3d74329Smrg add=-l$name 837442a55b46Smrg fi 837542a55b46Smrg 8376e3d74329Smrg if test prog = "$linkmode"; then 837742a55b46Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 837842a55b46Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 837942a55b46Smrg else 838042a55b46Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 838142a55b46Smrg test -n "$add" && deplibs="$add $deplibs" 838242a55b46Smrg fi 838342a55b46Smrg fi 8384e3d74329Smrg elif test prog = "$linkmode"; then 838542a55b46Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 838642a55b46Smrg # is not unsupported. This is valid on all known static and 838742a55b46Smrg # shared platforms. 8388e3d74329Smrg if test unsupported != "$hardcode_direct"; then 8389e3d74329Smrg test -n "$old_library" && linklib=$old_library 839042a55b46Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 839142a55b46Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 839242a55b46Smrg else 839342a55b46Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 839442a55b46Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 839542a55b46Smrg fi 8396e3d74329Smrg elif test yes = "$build_libtool_libs"; then 839742a55b46Smrg # Not a shared library 8398e3d74329Smrg if test pass_all != "$deplibs_check_method"; then 839942a55b46Smrg # We're trying link a shared library against a static one 840042a55b46Smrg # but the system doesn't support it. 840142a55b46Smrg 840242a55b46Smrg # Just print a warning and add the library to dependency_libs so 840342a55b46Smrg # that the program can be linked against the static library. 840442a55b46Smrg echo 8405e3d74329Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 840642a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 840742a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 840842a55b46Smrg echo "*** shared version of the library, which you do not appear to have." 8409e3d74329Smrg if test yes = "$module"; then 841042a55b46Smrg echo "*** But as you try to build a module library, libtool will still create " 841142a55b46Smrg echo "*** a static module, that should work as long as the dlopening application" 841242a55b46Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 841342a55b46Smrg if test -z "$global_symbol_pipe"; then 841442a55b46Smrg echo 841542a55b46Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8416e3d74329Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 841742a55b46Smrg echo "*** not find such a program. So, this module is probably useless." 8418e3d74329Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 841942a55b46Smrg fi 8420e3d74329Smrg if test no = "$build_old_libs"; then 842142a55b46Smrg build_libtool_libs=module 842242a55b46Smrg build_old_libs=yes 842342a55b46Smrg else 842442a55b46Smrg build_libtool_libs=no 842542a55b46Smrg fi 842642a55b46Smrg fi 842742a55b46Smrg else 842842a55b46Smrg deplibs="$dir/$old_library $deplibs" 842942a55b46Smrg link_static=yes 843042a55b46Smrg fi 843142a55b46Smrg fi # link shared/static library? 843242a55b46Smrg 8433e3d74329Smrg if test lib = "$linkmode"; then 843442a55b46Smrg if test -n "$dependency_libs" && 8435e3d74329Smrg { test yes != "$hardcode_into_libs" || 8436e3d74329Smrg test yes = "$build_old_libs" || 8437e3d74329Smrg test yes = "$link_static"; }; then 843842a55b46Smrg # Extract -R from dependency_libs 843942a55b46Smrg temp_deplibs= 844042a55b46Smrg for libdir in $dependency_libs; do 844142a55b46Smrg case $libdir in 844242a55b46Smrg -R*) func_stripname '-R' '' "$libdir" 844342a55b46Smrg temp_xrpath=$func_stripname_result 844442a55b46Smrg case " $xrpath " in 844542a55b46Smrg *" $temp_xrpath "*) ;; 844642a55b46Smrg *) func_append xrpath " $temp_xrpath";; 844742a55b46Smrg esac;; 844842a55b46Smrg *) func_append temp_deplibs " $libdir";; 844942a55b46Smrg esac 845042a55b46Smrg done 8451e3d74329Smrg dependency_libs=$temp_deplibs 845242a55b46Smrg fi 845342a55b46Smrg 845442a55b46Smrg func_append newlib_search_path " $absdir" 845542a55b46Smrg # Link against this library 8456e3d74329Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 845742a55b46Smrg # ... and its dependency_libs 845842a55b46Smrg tmp_libs= 845942a55b46Smrg for deplib in $dependency_libs; do 846042a55b46Smrg newdependency_libs="$deplib $newdependency_libs" 846142a55b46Smrg case $deplib in 846242a55b46Smrg -L*) func_stripname '-L' '' "$deplib" 846342a55b46Smrg func_resolve_sysroot "$func_stripname_result";; 846442a55b46Smrg *) func_resolve_sysroot "$deplib" ;; 846542a55b46Smrg esac 8466e3d74329Smrg if $opt_preserve_dup_deps; then 846742a55b46Smrg case "$tmp_libs " in 846842a55b46Smrg *" $func_resolve_sysroot_result "*) 846942a55b46Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 847042a55b46Smrg esac 847142a55b46Smrg fi 847242a55b46Smrg func_append tmp_libs " $func_resolve_sysroot_result" 847342a55b46Smrg done 847442a55b46Smrg 8475e3d74329Smrg if test no != "$link_all_deplibs"; then 847642a55b46Smrg # Add the search paths of all dependency libraries 847742a55b46Smrg for deplib in $dependency_libs; do 847842a55b46Smrg path= 847942a55b46Smrg case $deplib in 8480e3d74329Smrg -L*) path=$deplib ;; 848142a55b46Smrg *.la) 848242a55b46Smrg func_resolve_sysroot "$deplib" 848342a55b46Smrg deplib=$func_resolve_sysroot_result 848442a55b46Smrg func_dirname "$deplib" "" "." 848542a55b46Smrg dir=$func_dirname_result 848642a55b46Smrg # We need an absolute path. 848742a55b46Smrg case $dir in 8488e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 848942a55b46Smrg *) 849042a55b46Smrg absdir=`cd "$dir" && pwd` 849142a55b46Smrg if test -z "$absdir"; then 8492e3d74329Smrg func_warning "cannot determine absolute directory name of '$dir'" 8493e3d74329Smrg absdir=$dir 849442a55b46Smrg fi 849542a55b46Smrg ;; 849642a55b46Smrg esac 849742a55b46Smrg if $GREP "^installed=no" $deplib > /dev/null; then 849842a55b46Smrg case $host in 849942a55b46Smrg *-*-darwin*) 850042a55b46Smrg depdepl= 8501e3d74329Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502e3d74329Smrg if test -n "$deplibrary_names"; then 8503e3d74329Smrg for tmp in $deplibrary_names; do 850442a55b46Smrg depdepl=$tmp 850542a55b46Smrg done 8506e3d74329Smrg if test -f "$absdir/$objdir/$depdepl"; then 8507e3d74329Smrg depdepl=$absdir/$objdir/$depdepl 8508e3d74329Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 850942a55b46Smrg if test -z "$darwin_install_name"; then 8510e3d74329Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 851142a55b46Smrg fi 8512e3d74329Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513e3d74329Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 851442a55b46Smrg path= 851542a55b46Smrg fi 851642a55b46Smrg fi 851742a55b46Smrg ;; 851842a55b46Smrg *) 8519e3d74329Smrg path=-L$absdir/$objdir 852042a55b46Smrg ;; 852142a55b46Smrg esac 852242a55b46Smrg else 8523e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 852442a55b46Smrg test -z "$libdir" && \ 8525e3d74329Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 852642a55b46Smrg test "$absdir" != "$libdir" && \ 8527e3d74329Smrg func_warning "'$deplib' seems to be moved" 852842a55b46Smrg 8529e3d74329Smrg path=-L$absdir 853042a55b46Smrg fi 853142a55b46Smrg ;; 853242a55b46Smrg esac 853342a55b46Smrg case " $deplibs " in 853442a55b46Smrg *" $path "*) ;; 853542a55b46Smrg *) deplibs="$path $deplibs" ;; 853642a55b46Smrg esac 853742a55b46Smrg done 853842a55b46Smrg fi # link_all_deplibs != no 853942a55b46Smrg fi # linkmode = lib 854042a55b46Smrg done # for deplib in $libs 8541e3d74329Smrg if test link = "$pass"; then 8542e3d74329Smrg if test prog = "$linkmode"; then 854342a55b46Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 854442a55b46Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 854542a55b46Smrg else 854642a55b46Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 854742a55b46Smrg fi 854842a55b46Smrg fi 8549e3d74329Smrg dependency_libs=$newdependency_libs 8550e3d74329Smrg if test dlpreopen = "$pass"; then 855142a55b46Smrg # Link the dlpreopened libraries before other libraries 855242a55b46Smrg for deplib in $save_deplibs; do 855342a55b46Smrg deplibs="$deplib $deplibs" 855442a55b46Smrg done 855542a55b46Smrg fi 8556e3d74329Smrg if test dlopen != "$pass"; then 8557e3d74329Smrg test conv = "$pass" || { 855842a55b46Smrg # Make sure lib_search_path contains only unique directories. 855942a55b46Smrg lib_search_path= 856042a55b46Smrg for dir in $newlib_search_path; do 856142a55b46Smrg case "$lib_search_path " in 856242a55b46Smrg *" $dir "*) ;; 856342a55b46Smrg *) func_append lib_search_path " $dir" ;; 856442a55b46Smrg esac 856542a55b46Smrg done 856642a55b46Smrg newlib_search_path= 8567e3d74329Smrg } 856842a55b46Smrg 8569e3d74329Smrg if test prog,link = "$linkmode,$pass"; then 857042a55b46Smrg vars="compile_deplibs finalize_deplibs" 8571e3d74329Smrg else 8572e3d74329Smrg vars=deplibs 857342a55b46Smrg fi 857442a55b46Smrg for var in $vars dependency_libs; do 857542a55b46Smrg # Add libraries to $var in reverse order 857642a55b46Smrg eval tmp_libs=\"\$$var\" 857742a55b46Smrg new_libs= 857842a55b46Smrg for deplib in $tmp_libs; do 857942a55b46Smrg # FIXME: Pedantically, this is the right thing to do, so 858042a55b46Smrg # that some nasty dependency loop isn't accidentally 858142a55b46Smrg # broken: 858242a55b46Smrg #new_libs="$deplib $new_libs" 858342a55b46Smrg # Pragmatically, this seems to cause very few problems in 858442a55b46Smrg # practice: 858542a55b46Smrg case $deplib in 858642a55b46Smrg -L*) new_libs="$deplib $new_libs" ;; 858742a55b46Smrg -R*) ;; 858842a55b46Smrg *) 858942a55b46Smrg # And here is the reason: when a library appears more 859042a55b46Smrg # than once as an explicit dependence of a library, or 859142a55b46Smrg # is implicitly linked in more than once by the 859242a55b46Smrg # compiler, it is considered special, and multiple 859342a55b46Smrg # occurrences thereof are not removed. Compare this 859442a55b46Smrg # with having the same library being listed as a 859542a55b46Smrg # dependency of multiple other libraries: in this case, 859642a55b46Smrg # we know (pedantically, we assume) the library does not 859742a55b46Smrg # need to be listed more than once, so we keep only the 859842a55b46Smrg # last copy. This is not always right, but it is rare 859942a55b46Smrg # enough that we require users that really mean to play 860042a55b46Smrg # such unportable linking tricks to link the library 860142a55b46Smrg # using -Wl,-lname, so that libtool does not consider it 860242a55b46Smrg # for duplicate removal. 860342a55b46Smrg case " $specialdeplibs " in 860442a55b46Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 860542a55b46Smrg *) 860642a55b46Smrg case " $new_libs " in 860742a55b46Smrg *" $deplib "*) ;; 860842a55b46Smrg *) new_libs="$deplib $new_libs" ;; 860942a55b46Smrg esac 861042a55b46Smrg ;; 861142a55b46Smrg esac 861242a55b46Smrg ;; 861342a55b46Smrg esac 861442a55b46Smrg done 861542a55b46Smrg tmp_libs= 861642a55b46Smrg for deplib in $new_libs; do 861742a55b46Smrg case $deplib in 861842a55b46Smrg -L*) 861942a55b46Smrg case " $tmp_libs " in 862042a55b46Smrg *" $deplib "*) ;; 862142a55b46Smrg *) func_append tmp_libs " $deplib" ;; 862242a55b46Smrg esac 862342a55b46Smrg ;; 862442a55b46Smrg *) func_append tmp_libs " $deplib" ;; 862542a55b46Smrg esac 862642a55b46Smrg done 862742a55b46Smrg eval $var=\"$tmp_libs\" 862842a55b46Smrg done # for var 862942a55b46Smrg fi 8630e3d74329Smrg 8631e3d74329Smrg # Add Sun CC postdeps if required: 8632e3d74329Smrg test CXX = "$tagname" && { 8633e3d74329Smrg case $host_os in 8634e3d74329Smrg linux*) 8635e3d74329Smrg case `$CC -V 2>&1 | sed 5q` in 8636e3d74329Smrg *Sun\ C*) # Sun C++ 5.9 8637e3d74329Smrg func_suncc_cstd_abi 8638e3d74329Smrg 8639e3d74329Smrg if test no != "$suncc_use_cstd_abi"; then 8640e3d74329Smrg func_append postdeps ' -library=Cstd -library=Crun' 8641e3d74329Smrg fi 8642e3d74329Smrg ;; 8643e3d74329Smrg esac 8644e3d74329Smrg ;; 8645e3d74329Smrg 8646e3d74329Smrg solaris*) 8647e3d74329Smrg func_cc_basename "$CC" 8648e3d74329Smrg case $func_cc_basename_result in 8649e3d74329Smrg CC* | sunCC*) 8650e3d74329Smrg func_suncc_cstd_abi 8651e3d74329Smrg 8652e3d74329Smrg if test no != "$suncc_use_cstd_abi"; then 8653e3d74329Smrg func_append postdeps ' -library=Cstd -library=Crun' 8654e3d74329Smrg fi 8655e3d74329Smrg ;; 8656e3d74329Smrg esac 8657e3d74329Smrg ;; 8658e3d74329Smrg esac 8659e3d74329Smrg } 8660e3d74329Smrg 866142a55b46Smrg # Last step: remove runtime libs from dependency_libs 866242a55b46Smrg # (they stay in deplibs) 866342a55b46Smrg tmp_libs= 8664e3d74329Smrg for i in $dependency_libs; do 866542a55b46Smrg case " $predeps $postdeps $compiler_lib_search_path " in 866642a55b46Smrg *" $i "*) 8667e3d74329Smrg i= 866842a55b46Smrg ;; 866942a55b46Smrg esac 8670e3d74329Smrg if test -n "$i"; then 867142a55b46Smrg func_append tmp_libs " $i" 867242a55b46Smrg fi 867342a55b46Smrg done 867442a55b46Smrg dependency_libs=$tmp_libs 867542a55b46Smrg done # for pass 8676e3d74329Smrg if test prog = "$linkmode"; then 8677e3d74329Smrg dlfiles=$newdlfiles 867842a55b46Smrg fi 8679e3d74329Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8680e3d74329Smrg dlprefiles=$newdlprefiles 868142a55b46Smrg fi 868242a55b46Smrg 868342a55b46Smrg case $linkmode in 868442a55b46Smrg oldlib) 8685e3d74329Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686e3d74329Smrg func_warning "'-dlopen' is ignored for archives" 868742a55b46Smrg fi 868842a55b46Smrg 868942a55b46Smrg case " $deplibs" in 869042a55b46Smrg *\ -l* | *\ -L*) 8691e3d74329Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 869242a55b46Smrg esac 869342a55b46Smrg 869442a55b46Smrg test -n "$rpath" && \ 8695e3d74329Smrg func_warning "'-rpath' is ignored for archives" 869642a55b46Smrg 869742a55b46Smrg test -n "$xrpath" && \ 8698e3d74329Smrg func_warning "'-R' is ignored for archives" 869942a55b46Smrg 870042a55b46Smrg test -n "$vinfo" && \ 8701e3d74329Smrg func_warning "'-version-info/-version-number' is ignored for archives" 870242a55b46Smrg 870342a55b46Smrg test -n "$release" && \ 8704e3d74329Smrg func_warning "'-release' is ignored for archives" 870542a55b46Smrg 870642a55b46Smrg test -n "$export_symbols$export_symbols_regex" && \ 8707e3d74329Smrg func_warning "'-export-symbols' is ignored for archives" 870842a55b46Smrg 870942a55b46Smrg # Now set the variables for building old libraries. 871042a55b46Smrg build_libtool_libs=no 8711e3d74329Smrg oldlibs=$output 871242a55b46Smrg func_append objs "$old_deplibs" 871342a55b46Smrg ;; 871442a55b46Smrg 871542a55b46Smrg lib) 8716e3d74329Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 871742a55b46Smrg case $outputname in 871842a55b46Smrg lib*) 871942a55b46Smrg func_stripname 'lib' '.la' "$outputname" 872042a55b46Smrg name=$func_stripname_result 872142a55b46Smrg eval shared_ext=\"$shrext_cmds\" 872242a55b46Smrg eval libname=\"$libname_spec\" 872342a55b46Smrg ;; 872442a55b46Smrg *) 8725e3d74329Smrg test no = "$module" \ 8726e3d74329Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 872742a55b46Smrg 8728e3d74329Smrg if test no != "$need_lib_prefix"; then 872942a55b46Smrg # Add the "lib" prefix for modules if required 873042a55b46Smrg func_stripname '' '.la' "$outputname" 873142a55b46Smrg name=$func_stripname_result 873242a55b46Smrg eval shared_ext=\"$shrext_cmds\" 873342a55b46Smrg eval libname=\"$libname_spec\" 873442a55b46Smrg else 873542a55b46Smrg func_stripname '' '.la' "$outputname" 873642a55b46Smrg libname=$func_stripname_result 873742a55b46Smrg fi 873842a55b46Smrg ;; 873942a55b46Smrg esac 874042a55b46Smrg 874142a55b46Smrg if test -n "$objs"; then 8742e3d74329Smrg if test pass_all != "$deplibs_check_method"; then 8743e3d74329Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 874442a55b46Smrg else 874542a55b46Smrg echo 874642a55b46Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 874742a55b46Smrg $ECHO "*** objects $objs is not portable!" 874842a55b46Smrg func_append libobjs " $objs" 874942a55b46Smrg fi 875042a55b46Smrg fi 875142a55b46Smrg 8752e3d74329Smrg test no = "$dlself" \ 8753e3d74329Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 875442a55b46Smrg 875542a55b46Smrg set dummy $rpath 875642a55b46Smrg shift 8757e3d74329Smrg test 1 -lt "$#" \ 8758e3d74329Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 875942a55b46Smrg 8760e3d74329Smrg install_libdir=$1 876142a55b46Smrg 876242a55b46Smrg oldlibs= 876342a55b46Smrg if test -z "$rpath"; then 8764e3d74329Smrg if test yes = "$build_libtool_libs"; then 876542a55b46Smrg # Building a libtool convenience library. 8766e3d74329Smrg # Some compilers have problems with a '.al' extension so 876742a55b46Smrg # convenience libraries should have the same extension an 876842a55b46Smrg # archive normally would. 876942a55b46Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 877042a55b46Smrg build_libtool_libs=convenience 877142a55b46Smrg build_old_libs=yes 877242a55b46Smrg fi 877342a55b46Smrg 877442a55b46Smrg test -n "$vinfo" && \ 8775e3d74329Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 877642a55b46Smrg 877742a55b46Smrg test -n "$release" && \ 8778e3d74329Smrg func_warning "'-release' is ignored for convenience libraries" 877942a55b46Smrg else 878042a55b46Smrg 878142a55b46Smrg # Parse the version information argument. 8782e3d74329Smrg save_ifs=$IFS; IFS=: 878342a55b46Smrg set dummy $vinfo 0 0 0 878442a55b46Smrg shift 8785e3d74329Smrg IFS=$save_ifs 878642a55b46Smrg 878742a55b46Smrg test -n "$7" && \ 8788e3d74329Smrg func_fatal_help "too many parameters to '-version-info'" 878942a55b46Smrg 879042a55b46Smrg # convert absolute version numbers to libtool ages 879142a55b46Smrg # this retains compatibility with .la files and attempts 879242a55b46Smrg # to make the code below a bit more comprehensible 879342a55b46Smrg 879442a55b46Smrg case $vinfo_number in 879542a55b46Smrg yes) 8796e3d74329Smrg number_major=$1 8797e3d74329Smrg number_minor=$2 8798e3d74329Smrg number_revision=$3 879942a55b46Smrg # 880042a55b46Smrg # There are really only two kinds -- those that 880142a55b46Smrg # use the current revision as the major version 880242a55b46Smrg # and those that subtract age and use age as 880342a55b46Smrg # a minor version. But, then there is irix 8804e3d74329Smrg # that has an extra 1 added just for fun 880542a55b46Smrg # 880642a55b46Smrg case $version_type in 880742a55b46Smrg # correct linux to gnu/linux during the next big refactor 8808e3d74329Smrg darwin|freebsd-elf|linux|osf|windows|none) 880942a55b46Smrg func_arith $number_major + $number_minor 881042a55b46Smrg current=$func_arith_result 8811e3d74329Smrg age=$number_minor 8812e3d74329Smrg revision=$number_revision 881342a55b46Smrg ;; 8814e3d74329Smrg freebsd-aout|qnx|sunos) 8815e3d74329Smrg current=$number_major 8816e3d74329Smrg revision=$number_minor 8817e3d74329Smrg age=0 881842a55b46Smrg ;; 881942a55b46Smrg irix|nonstopux) 882042a55b46Smrg func_arith $number_major + $number_minor 882142a55b46Smrg current=$func_arith_result 8822e3d74329Smrg age=$number_minor 8823e3d74329Smrg revision=$number_minor 882442a55b46Smrg lt_irix_increment=no 882542a55b46Smrg ;; 882642a55b46Smrg esac 882742a55b46Smrg ;; 882842a55b46Smrg no) 8829e3d74329Smrg current=$1 8830e3d74329Smrg revision=$2 8831e3d74329Smrg age=$3 883242a55b46Smrg ;; 883342a55b46Smrg esac 883442a55b46Smrg 883542a55b46Smrg # Check that each of the things are valid numbers. 883642a55b46Smrg case $current in 883742a55b46Smrg 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]) ;; 883842a55b46Smrg *) 8839e3d74329Smrg func_error "CURRENT '$current' must be a nonnegative integer" 8840e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 884142a55b46Smrg ;; 884242a55b46Smrg esac 884342a55b46Smrg 884442a55b46Smrg case $revision in 884542a55b46Smrg 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]) ;; 884642a55b46Smrg *) 8847e3d74329Smrg func_error "REVISION '$revision' must be a nonnegative integer" 8848e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 884942a55b46Smrg ;; 885042a55b46Smrg esac 885142a55b46Smrg 885242a55b46Smrg case $age in 885342a55b46Smrg 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]) ;; 885442a55b46Smrg *) 8855e3d74329Smrg func_error "AGE '$age' must be a nonnegative integer" 8856e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 885742a55b46Smrg ;; 885842a55b46Smrg esac 885942a55b46Smrg 886042a55b46Smrg if test "$age" -gt "$current"; then 8861e3d74329Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 8862e3d74329Smrg func_fatal_error "'$vinfo' is not valid version information" 886342a55b46Smrg fi 886442a55b46Smrg 886542a55b46Smrg # Calculate the version variables. 886642a55b46Smrg major= 886742a55b46Smrg versuffix= 886842a55b46Smrg verstring= 886942a55b46Smrg case $version_type in 887042a55b46Smrg none) ;; 887142a55b46Smrg 887242a55b46Smrg darwin) 887342a55b46Smrg # Like Linux, but with the current version available in 887442a55b46Smrg # verstring for coding it into the library header 887542a55b46Smrg func_arith $current - $age 887642a55b46Smrg major=.$func_arith_result 8877e3d74329Smrg versuffix=$major.$age.$revision 887842a55b46Smrg # Darwin ld doesn't like 0 for these options... 887942a55b46Smrg func_arith $current + 1 888042a55b46Smrg minor_current=$func_arith_result 8881e3d74329Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888242a55b46Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883e3d74329Smrg # On Darwin other compilers 8884e3d74329Smrg case $CC in 8885e3d74329Smrg nagfor*) 8886e3d74329Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887e3d74329Smrg ;; 8888e3d74329Smrg *) 8889e3d74329Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890e3d74329Smrg ;; 8891e3d74329Smrg esac 889242a55b46Smrg ;; 889342a55b46Smrg 889442a55b46Smrg freebsd-aout) 8895e3d74329Smrg major=.$current 8896e3d74329Smrg versuffix=.$current.$revision 889742a55b46Smrg ;; 889842a55b46Smrg 889942a55b46Smrg freebsd-elf) 8900e3d74329Smrg func_arith $current - $age 8901e3d74329Smrg major=.$func_arith_result 8902e3d74329Smrg versuffix=$major.$age.$revision 890342a55b46Smrg ;; 890442a55b46Smrg 890542a55b46Smrg irix | nonstopux) 8906e3d74329Smrg if test no = "$lt_irix_increment"; then 890742a55b46Smrg func_arith $current - $age 890842a55b46Smrg else 890942a55b46Smrg func_arith $current - $age + 1 891042a55b46Smrg fi 891142a55b46Smrg major=$func_arith_result 891242a55b46Smrg 891342a55b46Smrg case $version_type in 891442a55b46Smrg nonstopux) verstring_prefix=nonstopux ;; 891542a55b46Smrg *) verstring_prefix=sgi ;; 891642a55b46Smrg esac 8917e3d74329Smrg verstring=$verstring_prefix$major.$revision 891842a55b46Smrg 891942a55b46Smrg # Add in all the interfaces that we are compatible with. 892042a55b46Smrg loop=$revision 8921e3d74329Smrg while test 0 -ne "$loop"; do 892242a55b46Smrg func_arith $revision - $loop 892342a55b46Smrg iface=$func_arith_result 892442a55b46Smrg func_arith $loop - 1 892542a55b46Smrg loop=$func_arith_result 8926e3d74329Smrg verstring=$verstring_prefix$major.$iface:$verstring 892742a55b46Smrg done 892842a55b46Smrg 8929e3d74329Smrg # Before this point, $major must not contain '.'. 893042a55b46Smrg major=.$major 8931e3d74329Smrg versuffix=$major.$revision 893242a55b46Smrg ;; 893342a55b46Smrg 893442a55b46Smrg linux) # correct to gnu/linux during the next big refactor 893542a55b46Smrg func_arith $current - $age 893642a55b46Smrg major=.$func_arith_result 8937e3d74329Smrg versuffix=$major.$age.$revision 893842a55b46Smrg ;; 893942a55b46Smrg 894042a55b46Smrg osf) 894142a55b46Smrg func_arith $current - $age 894242a55b46Smrg major=.$func_arith_result 8943e3d74329Smrg versuffix=.$current.$age.$revision 8944e3d74329Smrg verstring=$current.$age.$revision 894542a55b46Smrg 894642a55b46Smrg # Add in all the interfaces that we are compatible with. 894742a55b46Smrg loop=$age 8948e3d74329Smrg while test 0 -ne "$loop"; do 894942a55b46Smrg func_arith $current - $loop 895042a55b46Smrg iface=$func_arith_result 895142a55b46Smrg func_arith $loop - 1 895242a55b46Smrg loop=$func_arith_result 8953e3d74329Smrg verstring=$verstring:$iface.0 895442a55b46Smrg done 895542a55b46Smrg 895642a55b46Smrg # Make executables depend on our current version. 8957e3d74329Smrg func_append verstring ":$current.0" 895842a55b46Smrg ;; 895942a55b46Smrg 896042a55b46Smrg qnx) 8961e3d74329Smrg major=.$current 8962e3d74329Smrg versuffix=.$current 8963e3d74329Smrg ;; 8964e3d74329Smrg 8965e3d74329Smrg sco) 8966e3d74329Smrg major=.$current 8967e3d74329Smrg versuffix=.$current 896842a55b46Smrg ;; 896942a55b46Smrg 897042a55b46Smrg sunos) 8971e3d74329Smrg major=.$current 8972e3d74329Smrg versuffix=.$current.$revision 897342a55b46Smrg ;; 897442a55b46Smrg 897542a55b46Smrg windows) 897642a55b46Smrg # Use '-' rather than '.', since we only want one 8977e3d74329Smrg # extension on DOS 8.3 file systems. 897842a55b46Smrg func_arith $current - $age 897942a55b46Smrg major=$func_arith_result 8980e3d74329Smrg versuffix=-$major 898142a55b46Smrg ;; 898242a55b46Smrg 898342a55b46Smrg *) 8984e3d74329Smrg func_fatal_configuration "unknown library version type '$version_type'" 898542a55b46Smrg ;; 898642a55b46Smrg esac 898742a55b46Smrg 898842a55b46Smrg # Clear the version info if we defaulted, and they specified a release. 898942a55b46Smrg if test -z "$vinfo" && test -n "$release"; then 899042a55b46Smrg major= 899142a55b46Smrg case $version_type in 899242a55b46Smrg darwin) 899342a55b46Smrg # we can't check for "0.0" in archive_cmds due to quoting 899442a55b46Smrg # problems, so we reset it completely 899542a55b46Smrg verstring= 899642a55b46Smrg ;; 899742a55b46Smrg *) 8998e3d74329Smrg verstring=0.0 899942a55b46Smrg ;; 900042a55b46Smrg esac 9001e3d74329Smrg if test no = "$need_version"; then 900242a55b46Smrg versuffix= 900342a55b46Smrg else 9004e3d74329Smrg versuffix=.0.0 900542a55b46Smrg fi 900642a55b46Smrg fi 900742a55b46Smrg 900842a55b46Smrg # Remove version info from name if versioning should be avoided 9009e3d74329Smrg if test yes,no = "$avoid_version,$need_version"; then 901042a55b46Smrg major= 901142a55b46Smrg versuffix= 9012e3d74329Smrg verstring= 901342a55b46Smrg fi 901442a55b46Smrg 901542a55b46Smrg # Check to see if the archive will have undefined symbols. 9016e3d74329Smrg if test yes = "$allow_undefined"; then 9017e3d74329Smrg if test unsupported = "$allow_undefined_flag"; then 9018e3d74329Smrg if test yes = "$build_old_libs"; then 9019e3d74329Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020e3d74329Smrg build_libtool_libs=no 9021e3d74329Smrg else 9022e3d74329Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023e3d74329Smrg fi 902442a55b46Smrg fi 902542a55b46Smrg else 902642a55b46Smrg # Don't allow undefined symbols. 9027e3d74329Smrg allow_undefined_flag=$no_undefined_flag 902842a55b46Smrg fi 902942a55b46Smrg 903042a55b46Smrg fi 903142a55b46Smrg 9032e3d74329Smrg func_generate_dlsyms "$libname" "$libname" : 903342a55b46Smrg func_append libobjs " $symfileobj" 9034e3d74329Smrg test " " = "$libobjs" && libobjs= 903542a55b46Smrg 9036e3d74329Smrg if test relink != "$opt_mode"; then 903742a55b46Smrg # Remove our outputs, but don't remove object files since they 903842a55b46Smrg # may have been created when compiling PIC objects. 903942a55b46Smrg removelist= 904042a55b46Smrg tempremovelist=`$ECHO "$output_objdir/*"` 904142a55b46Smrg for p in $tempremovelist; do 904242a55b46Smrg case $p in 904342a55b46Smrg *.$objext | *.gcno) 904442a55b46Smrg ;; 9045e3d74329Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046e3d74329Smrg if test -n "$precious_files_regex"; then 904742a55b46Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 904842a55b46Smrg then 904942a55b46Smrg continue 905042a55b46Smrg fi 905142a55b46Smrg fi 905242a55b46Smrg func_append removelist " $p" 905342a55b46Smrg ;; 905442a55b46Smrg *) ;; 905542a55b46Smrg esac 905642a55b46Smrg done 905742a55b46Smrg test -n "$removelist" && \ 905842a55b46Smrg func_show_eval "${RM}r \$removelist" 905942a55b46Smrg fi 906042a55b46Smrg 906142a55b46Smrg # Now set the variables for building old libraries. 9062e3d74329Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 906342a55b46Smrg func_append oldlibs " $output_objdir/$libname.$libext" 906442a55b46Smrg 906542a55b46Smrg # Transform .lo files to .o files. 9066e3d74329Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 906742a55b46Smrg fi 906842a55b46Smrg 906942a55b46Smrg # Eliminate all temporary directories. 907042a55b46Smrg #for path in $notinst_path; do 907142a55b46Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 907242a55b46Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 907342a55b46Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 907442a55b46Smrg #done 907542a55b46Smrg 907642a55b46Smrg if test -n "$xrpath"; then 907742a55b46Smrg # If the user specified any rpath flags, then add them. 907842a55b46Smrg temp_xrpath= 907942a55b46Smrg for libdir in $xrpath; do 908042a55b46Smrg func_replace_sysroot "$libdir" 908142a55b46Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 908242a55b46Smrg case "$finalize_rpath " in 908342a55b46Smrg *" $libdir "*) ;; 908442a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 908542a55b46Smrg esac 908642a55b46Smrg done 9087e3d74329Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 908842a55b46Smrg dependency_libs="$temp_xrpath $dependency_libs" 908942a55b46Smrg fi 909042a55b46Smrg fi 909142a55b46Smrg 909242a55b46Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9093e3d74329Smrg old_dlfiles=$dlfiles 909442a55b46Smrg dlfiles= 909542a55b46Smrg for lib in $old_dlfiles; do 909642a55b46Smrg case " $dlprefiles $dlfiles " in 909742a55b46Smrg *" $lib "*) ;; 909842a55b46Smrg *) func_append dlfiles " $lib" ;; 909942a55b46Smrg esac 910042a55b46Smrg done 910142a55b46Smrg 910242a55b46Smrg # Make sure dlprefiles contains only unique files 9103e3d74329Smrg old_dlprefiles=$dlprefiles 910442a55b46Smrg dlprefiles= 910542a55b46Smrg for lib in $old_dlprefiles; do 910642a55b46Smrg case "$dlprefiles " in 910742a55b46Smrg *" $lib "*) ;; 910842a55b46Smrg *) func_append dlprefiles " $lib" ;; 910942a55b46Smrg esac 911042a55b46Smrg done 911142a55b46Smrg 9112e3d74329Smrg if test yes = "$build_libtool_libs"; then 911342a55b46Smrg if test -n "$rpath"; then 911442a55b46Smrg case $host in 911542a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 911642a55b46Smrg # these systems don't actually have a c library (as such)! 911742a55b46Smrg ;; 911842a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 911942a55b46Smrg # Rhapsody C library is in the System framework 912042a55b46Smrg func_append deplibs " System.ltframework" 912142a55b46Smrg ;; 912242a55b46Smrg *-*-netbsd*) 912342a55b46Smrg # Don't link with libc until the a.out ld.so is fixed. 912442a55b46Smrg ;; 912542a55b46Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 912642a55b46Smrg # Do not include libc due to us having libc/libc_r. 912742a55b46Smrg ;; 912842a55b46Smrg *-*-sco3.2v5* | *-*-sco5v6*) 912942a55b46Smrg # Causes problems with __ctype 913042a55b46Smrg ;; 913142a55b46Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 913242a55b46Smrg # Compiler inserts libc in the correct place for threads to work 913342a55b46Smrg ;; 913442a55b46Smrg *) 913542a55b46Smrg # Add libc to deplibs on all other systems if necessary. 9136e3d74329Smrg if test yes = "$build_libtool_need_lc"; then 913742a55b46Smrg func_append deplibs " -lc" 913842a55b46Smrg fi 913942a55b46Smrg ;; 914042a55b46Smrg esac 914142a55b46Smrg fi 914242a55b46Smrg 914342a55b46Smrg # Transform deplibs into only deplibs that can be linked in shared. 914442a55b46Smrg name_save=$name 914542a55b46Smrg libname_save=$libname 914642a55b46Smrg release_save=$release 914742a55b46Smrg versuffix_save=$versuffix 914842a55b46Smrg major_save=$major 914942a55b46Smrg # I'm not sure if I'm treating the release correctly. I think 915042a55b46Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 915142a55b46Smrg # add it in twice. Is that correct? 9152e3d74329Smrg release= 9153e3d74329Smrg versuffix= 9154e3d74329Smrg major= 915542a55b46Smrg newdeplibs= 915642a55b46Smrg droppeddeps=no 915742a55b46Smrg case $deplibs_check_method in 915842a55b46Smrg pass_all) 915942a55b46Smrg # Don't check for shared/static. Everything works. 916042a55b46Smrg # This might be a little naive. We might want to check 916142a55b46Smrg # whether the library exists or not. But this is on 916242a55b46Smrg # osf3 & osf4 and I'm not really sure... Just 916342a55b46Smrg # implementing what was already the behavior. 916442a55b46Smrg newdeplibs=$deplibs 916542a55b46Smrg ;; 916642a55b46Smrg test_compile) 916742a55b46Smrg # This code stresses the "libraries are programs" paradigm to its 916842a55b46Smrg # limits. Maybe even breaks it. We compile a program, linking it 916942a55b46Smrg # against the deplibs as a proxy for the library. Then we can check 917042a55b46Smrg # whether they linked in statically or dynamically with ldd. 917142a55b46Smrg $opt_dry_run || $RM conftest.c 917242a55b46Smrg cat > conftest.c <<EOF 917342a55b46Smrg int main() { return 0; } 917442a55b46SmrgEOF 917542a55b46Smrg $opt_dry_run || $RM conftest 917642a55b46Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 917742a55b46Smrg ldd_output=`ldd conftest` 917842a55b46Smrg for i in $deplibs; do 917942a55b46Smrg case $i in 918042a55b46Smrg -l*) 918142a55b46Smrg func_stripname -l '' "$i" 918242a55b46Smrg name=$func_stripname_result 9183e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 918442a55b46Smrg case " $predeps $postdeps " in 918542a55b46Smrg *" $i "*) 918642a55b46Smrg func_append newdeplibs " $i" 9187e3d74329Smrg i= 918842a55b46Smrg ;; 918942a55b46Smrg esac 919042a55b46Smrg fi 9191e3d74329Smrg if test -n "$i"; then 919242a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 919342a55b46Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 919442a55b46Smrg set dummy $deplib_matches; shift 919542a55b46Smrg deplib_match=$1 9196e3d74329Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 919742a55b46Smrg func_append newdeplibs " $i" 919842a55b46Smrg else 919942a55b46Smrg droppeddeps=yes 920042a55b46Smrg echo 920142a55b46Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 920242a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 920342a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 920442a55b46Smrg echo "*** shared version of the library, which I believe you do not have" 920542a55b46Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 920642a55b46Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 920742a55b46Smrg fi 920842a55b46Smrg fi 920942a55b46Smrg ;; 921042a55b46Smrg *) 921142a55b46Smrg func_append newdeplibs " $i" 921242a55b46Smrg ;; 921342a55b46Smrg esac 921442a55b46Smrg done 921542a55b46Smrg else 921642a55b46Smrg # Error occurred in the first compile. Let's try to salvage 921742a55b46Smrg # the situation: Compile a separate program for each library. 921842a55b46Smrg for i in $deplibs; do 921942a55b46Smrg case $i in 922042a55b46Smrg -l*) 922142a55b46Smrg func_stripname -l '' "$i" 922242a55b46Smrg name=$func_stripname_result 922342a55b46Smrg $opt_dry_run || $RM conftest 922442a55b46Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 922542a55b46Smrg ldd_output=`ldd conftest` 9226e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 922742a55b46Smrg case " $predeps $postdeps " in 922842a55b46Smrg *" $i "*) 922942a55b46Smrg func_append newdeplibs " $i" 9230e3d74329Smrg i= 923142a55b46Smrg ;; 923242a55b46Smrg esac 923342a55b46Smrg fi 9234e3d74329Smrg if test -n "$i"; then 923542a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 923642a55b46Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 923742a55b46Smrg set dummy $deplib_matches; shift 923842a55b46Smrg deplib_match=$1 9239e3d74329Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 924042a55b46Smrg func_append newdeplibs " $i" 924142a55b46Smrg else 924242a55b46Smrg droppeddeps=yes 924342a55b46Smrg echo 924442a55b46Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 924542a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 924642a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 924742a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 924842a55b46Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 924942a55b46Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 925042a55b46Smrg fi 925142a55b46Smrg fi 925242a55b46Smrg else 925342a55b46Smrg droppeddeps=yes 925442a55b46Smrg echo 925542a55b46Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 925642a55b46Smrg echo "*** make it link in! You will probably need to install it or some" 925742a55b46Smrg echo "*** library that it depends on before this library will be fully" 925842a55b46Smrg echo "*** functional. Installing it before continuing would be even better." 925942a55b46Smrg fi 926042a55b46Smrg ;; 926142a55b46Smrg *) 926242a55b46Smrg func_append newdeplibs " $i" 926342a55b46Smrg ;; 926442a55b46Smrg esac 926542a55b46Smrg done 926642a55b46Smrg fi 926742a55b46Smrg ;; 926842a55b46Smrg file_magic*) 926942a55b46Smrg set dummy $deplibs_check_method; shift 927042a55b46Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 927142a55b46Smrg for a_deplib in $deplibs; do 927242a55b46Smrg case $a_deplib in 927342a55b46Smrg -l*) 927442a55b46Smrg func_stripname -l '' "$a_deplib" 927542a55b46Smrg name=$func_stripname_result 9276e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 927742a55b46Smrg case " $predeps $postdeps " in 927842a55b46Smrg *" $a_deplib "*) 927942a55b46Smrg func_append newdeplibs " $a_deplib" 9280e3d74329Smrg a_deplib= 928142a55b46Smrg ;; 928242a55b46Smrg esac 928342a55b46Smrg fi 9284e3d74329Smrg if test -n "$a_deplib"; then 928542a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 928642a55b46Smrg if test -n "$file_magic_glob"; then 928742a55b46Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 928842a55b46Smrg else 928942a55b46Smrg libnameglob=$libname 929042a55b46Smrg fi 9291e3d74329Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 929242a55b46Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293e3d74329Smrg if test yes = "$want_nocaseglob"; then 929442a55b46Smrg shopt -s nocaseglob 929542a55b46Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929642a55b46Smrg $nocaseglob 929742a55b46Smrg else 929842a55b46Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929942a55b46Smrg fi 930042a55b46Smrg for potent_lib in $potential_libs; do 930142a55b46Smrg # Follow soft links. 930242a55b46Smrg if ls -lLd "$potent_lib" 2>/dev/null | 930342a55b46Smrg $GREP " -> " >/dev/null; then 930442a55b46Smrg continue 930542a55b46Smrg fi 930642a55b46Smrg # The statement above tries to avoid entering an 930742a55b46Smrg # endless loop below, in case of cyclic links. 930842a55b46Smrg # We might still enter an endless loop, since a link 930942a55b46Smrg # loop can be closed while we follow links, 931042a55b46Smrg # but so what? 9311e3d74329Smrg potlib=$potent_lib 931242a55b46Smrg while test -h "$potlib" 2>/dev/null; do 9313e3d74329Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 931442a55b46Smrg case $potliblink in 9315e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316e3d74329Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 931742a55b46Smrg esac 931842a55b46Smrg done 931942a55b46Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 932042a55b46Smrg $SED -e 10q | 932142a55b46Smrg $EGREP "$file_magic_regex" > /dev/null; then 932242a55b46Smrg func_append newdeplibs " $a_deplib" 9323e3d74329Smrg a_deplib= 932442a55b46Smrg break 2 932542a55b46Smrg fi 932642a55b46Smrg done 932742a55b46Smrg done 932842a55b46Smrg fi 9329e3d74329Smrg if test -n "$a_deplib"; then 933042a55b46Smrg droppeddeps=yes 933142a55b46Smrg echo 933242a55b46Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 933342a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 933442a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 933542a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 933642a55b46Smrg echo "*** because I did check the linker path looking for a file starting" 9337e3d74329Smrg if test -z "$potlib"; then 933842a55b46Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 933942a55b46Smrg else 934042a55b46Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 934142a55b46Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 934242a55b46Smrg fi 934342a55b46Smrg fi 934442a55b46Smrg ;; 934542a55b46Smrg *) 934642a55b46Smrg # Add a -L argument. 934742a55b46Smrg func_append newdeplibs " $a_deplib" 934842a55b46Smrg ;; 934942a55b46Smrg esac 935042a55b46Smrg done # Gone through all deplibs. 935142a55b46Smrg ;; 935242a55b46Smrg match_pattern*) 935342a55b46Smrg set dummy $deplibs_check_method; shift 935442a55b46Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 935542a55b46Smrg for a_deplib in $deplibs; do 935642a55b46Smrg case $a_deplib in 935742a55b46Smrg -l*) 935842a55b46Smrg func_stripname -l '' "$a_deplib" 935942a55b46Smrg name=$func_stripname_result 9360e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 936142a55b46Smrg case " $predeps $postdeps " in 936242a55b46Smrg *" $a_deplib "*) 936342a55b46Smrg func_append newdeplibs " $a_deplib" 9364e3d74329Smrg a_deplib= 936542a55b46Smrg ;; 936642a55b46Smrg esac 936742a55b46Smrg fi 9368e3d74329Smrg if test -n "$a_deplib"; then 936942a55b46Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 937042a55b46Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 937142a55b46Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 937242a55b46Smrg for potent_lib in $potential_libs; do 9373e3d74329Smrg potlib=$potent_lib # see symlink-check above in file_magic test 937442a55b46Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 937542a55b46Smrg $EGREP "$match_pattern_regex" > /dev/null; then 937642a55b46Smrg func_append newdeplibs " $a_deplib" 9377e3d74329Smrg a_deplib= 937842a55b46Smrg break 2 937942a55b46Smrg fi 938042a55b46Smrg done 938142a55b46Smrg done 938242a55b46Smrg fi 9383e3d74329Smrg if test -n "$a_deplib"; then 938442a55b46Smrg droppeddeps=yes 938542a55b46Smrg echo 938642a55b46Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 938742a55b46Smrg echo "*** I have the capability to make that library automatically link in when" 938842a55b46Smrg echo "*** you link to this library. But I can only do this if you have a" 938942a55b46Smrg echo "*** shared version of the library, which you do not appear to have" 939042a55b46Smrg echo "*** because I did check the linker path looking for a file starting" 9391e3d74329Smrg if test -z "$potlib"; then 939242a55b46Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 939342a55b46Smrg else 939442a55b46Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 939542a55b46Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 939642a55b46Smrg fi 939742a55b46Smrg fi 939842a55b46Smrg ;; 939942a55b46Smrg *) 940042a55b46Smrg # Add a -L argument. 940142a55b46Smrg func_append newdeplibs " $a_deplib" 940242a55b46Smrg ;; 940342a55b46Smrg esac 940442a55b46Smrg done # Gone through all deplibs. 940542a55b46Smrg ;; 940642a55b46Smrg none | unknown | *) 9407e3d74329Smrg newdeplibs= 940842a55b46Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409e3d74329Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410e3d74329Smrg for i in $predeps $postdeps; do 941142a55b46Smrg # can't use Xsed below, because $i might contain '/' 9412e3d74329Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 941342a55b46Smrg done 941442a55b46Smrg fi 941542a55b46Smrg case $tmp_deplibs in 941642a55b46Smrg *[!\ \ ]*) 941742a55b46Smrg echo 9418e3d74329Smrg if test none = "$deplibs_check_method"; then 941942a55b46Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 942042a55b46Smrg else 942142a55b46Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 942242a55b46Smrg fi 942342a55b46Smrg echo "*** All declared inter-library dependencies are being dropped." 942442a55b46Smrg droppeddeps=yes 942542a55b46Smrg ;; 942642a55b46Smrg esac 942742a55b46Smrg ;; 942842a55b46Smrg esac 942942a55b46Smrg versuffix=$versuffix_save 943042a55b46Smrg major=$major_save 943142a55b46Smrg release=$release_save 943242a55b46Smrg libname=$libname_save 943342a55b46Smrg name=$name_save 9434c582b7e3Smrg 943542a55b46Smrg case $host in 943642a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 943742a55b46Smrg # On Rhapsody replace the C library with the System framework 943842a55b46Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 943942a55b46Smrg ;; 944042a55b46Smrg esac 9441c582b7e3Smrg 9442e3d74329Smrg if test yes = "$droppeddeps"; then 9443e3d74329Smrg if test yes = "$module"; then 944442a55b46Smrg echo 944542a55b46Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 944642a55b46Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 944742a55b46Smrg echo "*** a static module, that should work as long as the dlopening" 944842a55b46Smrg echo "*** application is linked with the -dlopen flag." 944942a55b46Smrg if test -z "$global_symbol_pipe"; then 945042a55b46Smrg echo 945142a55b46Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9452e3d74329Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 945342a55b46Smrg echo "*** not find such a program. So, this module is probably useless." 9454e3d74329Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 945542a55b46Smrg fi 9456e3d74329Smrg if test no = "$build_old_libs"; then 9457e3d74329Smrg oldlibs=$output_objdir/$libname.$libext 945842a55b46Smrg build_libtool_libs=module 945942a55b46Smrg build_old_libs=yes 946042a55b46Smrg else 946142a55b46Smrg build_libtool_libs=no 946242a55b46Smrg fi 946342a55b46Smrg else 946442a55b46Smrg echo "*** The inter-library dependencies that have been dropped here will be" 946542a55b46Smrg echo "*** automatically added whenever a program is linked with this library" 946642a55b46Smrg echo "*** or is declared to -dlopen it." 9467c582b7e3Smrg 9468e3d74329Smrg if test no = "$allow_undefined"; then 946942a55b46Smrg echo 947042a55b46Smrg echo "*** Since this library must not contain undefined symbols," 947142a55b46Smrg echo "*** because either the platform does not support them or" 947242a55b46Smrg echo "*** it was explicitly requested with -no-undefined," 947342a55b46Smrg echo "*** libtool will only create a static version of it." 9474e3d74329Smrg if test no = "$build_old_libs"; then 9475e3d74329Smrg oldlibs=$output_objdir/$libname.$libext 947642a55b46Smrg build_libtool_libs=module 947742a55b46Smrg build_old_libs=yes 947842a55b46Smrg else 947942a55b46Smrg build_libtool_libs=no 948042a55b46Smrg fi 948142a55b46Smrg fi 948242a55b46Smrg fi 9483c582b7e3Smrg fi 948442a55b46Smrg # Done checking deplibs! 948542a55b46Smrg deplibs=$newdeplibs 948642a55b46Smrg fi 948742a55b46Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 948842a55b46Smrg case $host in 948942a55b46Smrg *-*-darwin*) 949042a55b46Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949142a55b46Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949242a55b46Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949342a55b46Smrg ;; 949442a55b46Smrg esac 9495c582b7e3Smrg 949642a55b46Smrg # move library search paths that coincide with paths to not yet 949742a55b46Smrg # installed libraries to the beginning of the library search list 949842a55b46Smrg new_libs= 949942a55b46Smrg for path in $notinst_path; do 950042a55b46Smrg case " $new_libs " in 950142a55b46Smrg *" -L$path/$objdir "*) ;; 950242a55b46Smrg *) 950342a55b46Smrg case " $deplibs " in 950442a55b46Smrg *" -L$path/$objdir "*) 950542a55b46Smrg func_append new_libs " -L$path/$objdir" ;; 950642a55b46Smrg esac 950742a55b46Smrg ;; 950842a55b46Smrg esac 950942a55b46Smrg done 951042a55b46Smrg for deplib in $deplibs; do 951142a55b46Smrg case $deplib in 951242a55b46Smrg -L*) 951342a55b46Smrg case " $new_libs " in 951442a55b46Smrg *" $deplib "*) ;; 951542a55b46Smrg *) func_append new_libs " $deplib" ;; 951642a55b46Smrg esac 951742a55b46Smrg ;; 951842a55b46Smrg *) func_append new_libs " $deplib" ;; 951942a55b46Smrg esac 952042a55b46Smrg done 9521e3d74329Smrg deplibs=$new_libs 9522c582b7e3Smrg 952342a55b46Smrg # All the library-specific variables (install_libdir is set above). 952442a55b46Smrg library_names= 952542a55b46Smrg old_library= 952642a55b46Smrg dlname= 9527c582b7e3Smrg 952842a55b46Smrg # Test again, we may have decided not to build it any more 9529e3d74329Smrg if test yes = "$build_libtool_libs"; then 9530e3d74329Smrg # Remove $wl instances when linking with ld. 953142a55b46Smrg # FIXME: should test the right _cmds variable. 953242a55b46Smrg case $archive_cmds in 953342a55b46Smrg *\$LD\ *) wl= ;; 953442a55b46Smrg esac 9535e3d74329Smrg if test yes = "$hardcode_into_libs"; then 953642a55b46Smrg # Hardcode the library paths 953742a55b46Smrg hardcode_libdirs= 953842a55b46Smrg dep_rpath= 9539e3d74329Smrg rpath=$finalize_rpath 9540e3d74329Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 954142a55b46Smrg for libdir in $rpath; do 954242a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 954342a55b46Smrg if test -n "$hardcode_libdir_separator"; then 954442a55b46Smrg func_replace_sysroot "$libdir" 954542a55b46Smrg libdir=$func_replace_sysroot_result 954642a55b46Smrg if test -z "$hardcode_libdirs"; then 9547e3d74329Smrg hardcode_libdirs=$libdir 954842a55b46Smrg else 954942a55b46Smrg # Just accumulate the unique libdirs. 955042a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 955142a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 955242a55b46Smrg ;; 955342a55b46Smrg *) 955442a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 955542a55b46Smrg ;; 955642a55b46Smrg esac 955742a55b46Smrg fi 955842a55b46Smrg else 955942a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 956042a55b46Smrg func_append dep_rpath " $flag" 956142a55b46Smrg fi 956242a55b46Smrg elif test -n "$runpath_var"; then 956342a55b46Smrg case "$perm_rpath " in 956442a55b46Smrg *" $libdir "*) ;; 956542a55b46Smrg *) func_append perm_rpath " $libdir" ;; 956642a55b46Smrg esac 956742a55b46Smrg fi 956842a55b46Smrg done 956942a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 957042a55b46Smrg if test -n "$hardcode_libdir_separator" && 957142a55b46Smrg test -n "$hardcode_libdirs"; then 9572e3d74329Smrg libdir=$hardcode_libdirs 957342a55b46Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 957442a55b46Smrg fi 957542a55b46Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 957642a55b46Smrg # We should set the runpath_var. 957742a55b46Smrg rpath= 957842a55b46Smrg for dir in $perm_rpath; do 957942a55b46Smrg func_append rpath "$dir:" 958042a55b46Smrg done 958142a55b46Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 958242a55b46Smrg fi 958342a55b46Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584c582b7e3Smrg fi 9585c582b7e3Smrg 9586e3d74329Smrg shlibpath=$finalize_shlibpath 9587e3d74329Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 958842a55b46Smrg if test -n "$shlibpath"; then 958942a55b46Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590c582b7e3Smrg fi 9591c582b7e3Smrg 959242a55b46Smrg # Get the real and link names of the library. 959342a55b46Smrg eval shared_ext=\"$shrext_cmds\" 959442a55b46Smrg eval library_names=\"$library_names_spec\" 959542a55b46Smrg set dummy $library_names 959642a55b46Smrg shift 9597e3d74329Smrg realname=$1 959842a55b46Smrg shift 9599c582b7e3Smrg 960042a55b46Smrg if test -n "$soname_spec"; then 960142a55b46Smrg eval soname=\"$soname_spec\" 9602c582b7e3Smrg else 9603e3d74329Smrg soname=$realname 960442a55b46Smrg fi 960542a55b46Smrg if test -z "$dlname"; then 960642a55b46Smrg dlname=$soname 9607c582b7e3Smrg fi 9608c582b7e3Smrg 9609e3d74329Smrg lib=$output_objdir/$realname 961042a55b46Smrg linknames= 961142a55b46Smrg for link 961242a55b46Smrg do 961342a55b46Smrg func_append linknames " $link" 961442a55b46Smrg done 9615c582b7e3Smrg 961642a55b46Smrg # Use standard objects if they are pic 961742a55b46Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 961842a55b46Smrg test "X$libobjs" = "X " && libobjs= 9619c582b7e3Smrg 962042a55b46Smrg delfiles= 962142a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 962242a55b46Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623e3d74329Smrg export_symbols=$output_objdir/$libname.uexp 962442a55b46Smrg func_append delfiles " $export_symbols" 962542a55b46Smrg fi 9626c582b7e3Smrg 962742a55b46Smrg orig_export_symbols= 962842a55b46Smrg case $host_os in 962942a55b46Smrg cygwin* | mingw* | cegcc*) 963042a55b46Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 963142a55b46Smrg # exporting using user supplied symfile 9632e3d74329Smrg func_dll_def_p "$export_symbols" || { 963342a55b46Smrg # and it's NOT already a .def file. Must figure out 963442a55b46Smrg # which of the given symbols are data symbols and tag 963542a55b46Smrg # them as such. So, trigger use of export_symbols_cmds. 963642a55b46Smrg # export_symbols gets reassigned inside the "prepare 963742a55b46Smrg # the list of exported symbols" if statement, so the 963842a55b46Smrg # include_expsyms logic still works. 9639e3d74329Smrg orig_export_symbols=$export_symbols 964042a55b46Smrg export_symbols= 964142a55b46Smrg always_export_symbols=yes 9642e3d74329Smrg } 9643c582b7e3Smrg fi 964442a55b46Smrg ;; 964542a55b46Smrg esac 9646c582b7e3Smrg 964742a55b46Smrg # Prepare the list of exported symbols 964842a55b46Smrg if test -z "$export_symbols"; then 9649e3d74329Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650e3d74329Smrg func_verbose "generating symbol list for '$libname.la'" 9651e3d74329Smrg export_symbols=$output_objdir/$libname.exp 965242a55b46Smrg $opt_dry_run || $RM $export_symbols 965342a55b46Smrg cmds=$export_symbols_cmds 9654e3d74329Smrg save_ifs=$IFS; IFS='~' 965542a55b46Smrg for cmd1 in $cmds; do 9656e3d74329Smrg IFS=$save_ifs 965742a55b46Smrg # Take the normal branch if the nm_file_list_spec branch 965842a55b46Smrg # doesn't work or if tool conversion is not needed. 965942a55b46Smrg case $nm_file_list_spec~$to_tool_file_cmd in 966042a55b46Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 966142a55b46Smrg try_normal_branch=yes 966242a55b46Smrg eval cmd=\"$cmd1\" 966342a55b46Smrg func_len " $cmd" 966442a55b46Smrg len=$func_len_result 966542a55b46Smrg ;; 966642a55b46Smrg *) 966742a55b46Smrg try_normal_branch=no 966842a55b46Smrg ;; 966942a55b46Smrg esac 9670e3d74329Smrg if test yes = "$try_normal_branch" \ 967142a55b46Smrg && { test "$len" -lt "$max_cmd_len" \ 967242a55b46Smrg || test "$max_cmd_len" -le -1; } 967342a55b46Smrg then 967442a55b46Smrg func_show_eval "$cmd" 'exit $?' 967542a55b46Smrg skipped_export=false 967642a55b46Smrg elif test -n "$nm_file_list_spec"; then 967742a55b46Smrg func_basename "$output" 967842a55b46Smrg output_la=$func_basename_result 967942a55b46Smrg save_libobjs=$libobjs 968042a55b46Smrg save_output=$output 9681e3d74329Smrg output=$output_objdir/$output_la.nm 968242a55b46Smrg func_to_tool_file "$output" 968342a55b46Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 968442a55b46Smrg func_append delfiles " $output" 968542a55b46Smrg func_verbose "creating $NM input file list: $output" 968642a55b46Smrg for obj in $save_libobjs; do 968742a55b46Smrg func_to_tool_file "$obj" 968842a55b46Smrg $ECHO "$func_to_tool_file_result" 968942a55b46Smrg done > "$output" 969042a55b46Smrg eval cmd=\"$cmd1\" 969142a55b46Smrg func_show_eval "$cmd" 'exit $?' 969242a55b46Smrg output=$save_output 969342a55b46Smrg libobjs=$save_libobjs 969442a55b46Smrg skipped_export=false 969542a55b46Smrg else 969642a55b46Smrg # The command line is too long to execute in one step. 969742a55b46Smrg func_verbose "using reloadable object file for export list..." 969842a55b46Smrg skipped_export=: 969942a55b46Smrg # Break out early, otherwise skipped_export may be 970042a55b46Smrg # set to false by a later but shorter cmd. 970142a55b46Smrg break 970242a55b46Smrg fi 970342a55b46Smrg done 9704e3d74329Smrg IFS=$save_ifs 9705e3d74329Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 970642a55b46Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 970742a55b46Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 970842a55b46Smrg fi 970942a55b46Smrg fi 971042a55b46Smrg fi 971142a55b46Smrg 971242a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713e3d74329Smrg tmp_export_symbols=$export_symbols 9714e3d74329Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 971542a55b46Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716c582b7e3Smrg fi 9717c582b7e3Smrg 9718e3d74329Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 971942a55b46Smrg # The given exports_symbols file has to be filtered, so filter it. 9720e3d74329Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 972142a55b46Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722e3d74329Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 972342a55b46Smrg # though. Also, the filter scales superlinearly with the number of 972442a55b46Smrg # global variables. join(1) would be nice here, but unfortunately 972542a55b46Smrg # isn't a blessed tool. 972642a55b46Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 972742a55b46Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 972842a55b46Smrg export_symbols=$output_objdir/$libname.def 972942a55b46Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 973042a55b46Smrg fi 9731c582b7e3Smrg 973242a55b46Smrg tmp_deplibs= 973342a55b46Smrg for test_deplib in $deplibs; do 973442a55b46Smrg case " $convenience " in 973542a55b46Smrg *" $test_deplib "*) ;; 973642a55b46Smrg *) 973742a55b46Smrg func_append tmp_deplibs " $test_deplib" 973842a55b46Smrg ;; 973942a55b46Smrg esac 974042a55b46Smrg done 9741e3d74329Smrg deplibs=$tmp_deplibs 9742c582b7e3Smrg 974342a55b46Smrg if test -n "$convenience"; then 974442a55b46Smrg if test -n "$whole_archive_flag_spec" && 9745e3d74329Smrg test yes = "$compiler_needs_object" && 974642a55b46Smrg test -z "$libobjs"; then 974742a55b46Smrg # extract the archives, so we have objects to list. 974842a55b46Smrg # TODO: could optimize this to just extract one archive. 974942a55b46Smrg whole_archive_flag_spec= 975042a55b46Smrg fi 975142a55b46Smrg if test -n "$whole_archive_flag_spec"; then 975242a55b46Smrg save_libobjs=$libobjs 975342a55b46Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 975442a55b46Smrg test "X$libobjs" = "X " && libobjs= 9755c582b7e3Smrg else 9756e3d74329Smrg gentop=$output_objdir/${outputname}x 975742a55b46Smrg func_append generated " $gentop" 975842a55b46Smrg 975942a55b46Smrg func_extract_archives $gentop $convenience 976042a55b46Smrg func_append libobjs " $func_extract_archives_result" 976142a55b46Smrg test "X$libobjs" = "X " && libobjs= 9762c582b7e3Smrg fi 9763c582b7e3Smrg fi 9764c582b7e3Smrg 9765e3d74329Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 976642a55b46Smrg eval flag=\"$thread_safe_flag_spec\" 976742a55b46Smrg func_append linker_flags " $flag" 976842a55b46Smrg fi 9769c582b7e3Smrg 977042a55b46Smrg # Make a backup of the uninstalled library when relinking 9771e3d74329Smrg if test relink = "$opt_mode"; then 977242a55b46Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 977342a55b46Smrg fi 9774c582b7e3Smrg 977542a55b46Smrg # Do each of the archive commands. 9776e3d74329Smrg if test yes = "$module" && test -n "$module_cmds"; then 977742a55b46Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 977842a55b46Smrg eval test_cmds=\"$module_expsym_cmds\" 977942a55b46Smrg cmds=$module_expsym_cmds 978042a55b46Smrg else 978142a55b46Smrg eval test_cmds=\"$module_cmds\" 978242a55b46Smrg cmds=$module_cmds 978342a55b46Smrg fi 9784c582b7e3Smrg else 978542a55b46Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 978642a55b46Smrg eval test_cmds=\"$archive_expsym_cmds\" 978742a55b46Smrg cmds=$archive_expsym_cmds 978842a55b46Smrg else 978942a55b46Smrg eval test_cmds=\"$archive_cmds\" 979042a55b46Smrg cmds=$archive_cmds 979142a55b46Smrg fi 9792c582b7e3Smrg fi 9793c582b7e3Smrg 9794e3d74329Smrg if test : != "$skipped_export" && 979542a55b46Smrg func_len " $test_cmds" && 979642a55b46Smrg len=$func_len_result && 979742a55b46Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 979842a55b46Smrg : 979942a55b46Smrg else 980042a55b46Smrg # The command line is too long to link in one step, link piecewise 980142a55b46Smrg # or, if using GNU ld and skipped_export is not :, use a linker 980242a55b46Smrg # script. 9803c582b7e3Smrg 980442a55b46Smrg # Save the value of $output and $libobjs because we want to 980542a55b46Smrg # use them later. If we have whole_archive_flag_spec, we 980642a55b46Smrg # want to use save_libobjs as it was before 980742a55b46Smrg # whole_archive_flag_spec was expanded, because we can't 980842a55b46Smrg # assume the linker understands whole_archive_flag_spec. 980942a55b46Smrg # This may have to be revisited, in case too many 981042a55b46Smrg # convenience libraries get linked in and end up exceeding 981142a55b46Smrg # the spec. 981242a55b46Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 981342a55b46Smrg save_libobjs=$libobjs 981442a55b46Smrg fi 981542a55b46Smrg save_output=$output 981642a55b46Smrg func_basename "$output" 981742a55b46Smrg output_la=$func_basename_result 981842a55b46Smrg 981942a55b46Smrg # Clear the reloadable object creation command queue and 982042a55b46Smrg # initialize k to one. 982142a55b46Smrg test_cmds= 982242a55b46Smrg concat_cmds= 982342a55b46Smrg objlist= 982442a55b46Smrg last_robj= 982542a55b46Smrg k=1 982642a55b46Smrg 9827e3d74329Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828e3d74329Smrg output=$output_objdir/$output_la.lnkscript 982942a55b46Smrg func_verbose "creating GNU ld script: $output" 983042a55b46Smrg echo 'INPUT (' > $output 983142a55b46Smrg for obj in $save_libobjs 983242a55b46Smrg do 983342a55b46Smrg func_to_tool_file "$obj" 983442a55b46Smrg $ECHO "$func_to_tool_file_result" >> $output 983542a55b46Smrg done 983642a55b46Smrg echo ')' >> $output 983742a55b46Smrg func_append delfiles " $output" 983842a55b46Smrg func_to_tool_file "$output" 983942a55b46Smrg output=$func_to_tool_file_result 9840e3d74329Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841e3d74329Smrg output=$output_objdir/$output_la.lnk 984242a55b46Smrg func_verbose "creating linker input file list: $output" 984342a55b46Smrg : > $output 984442a55b46Smrg set x $save_libobjs 984542a55b46Smrg shift 984642a55b46Smrg firstobj= 9847e3d74329Smrg if test yes = "$compiler_needs_object"; then 984842a55b46Smrg firstobj="$1 " 984942a55b46Smrg shift 9850c582b7e3Smrg fi 985142a55b46Smrg for obj 985242a55b46Smrg do 985342a55b46Smrg func_to_tool_file "$obj" 985442a55b46Smrg $ECHO "$func_to_tool_file_result" >> $output 9855c582b7e3Smrg done 985642a55b46Smrg func_append delfiles " $output" 985742a55b46Smrg func_to_tool_file "$output" 985842a55b46Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 985942a55b46Smrg else 986042a55b46Smrg if test -n "$save_libobjs"; then 986142a55b46Smrg func_verbose "creating reloadable object files..." 9862e3d74329Smrg output=$output_objdir/$output_la-$k.$objext 986342a55b46Smrg eval test_cmds=\"$reload_cmds\" 986442a55b46Smrg func_len " $test_cmds" 986542a55b46Smrg len0=$func_len_result 986642a55b46Smrg len=$len0 986742a55b46Smrg 986842a55b46Smrg # Loop over the list of objects to be linked. 986942a55b46Smrg for obj in $save_libobjs 987042a55b46Smrg do 987142a55b46Smrg func_len " $obj" 987242a55b46Smrg func_arith $len + $func_len_result 987342a55b46Smrg len=$func_arith_result 9874e3d74329Smrg if test -z "$objlist" || 987542a55b46Smrg test "$len" -lt "$max_cmd_len"; then 987642a55b46Smrg func_append objlist " $obj" 987742a55b46Smrg else 987842a55b46Smrg # The command $test_cmds is almost too long, add a 987942a55b46Smrg # command to the queue. 9880e3d74329Smrg if test 1 -eq "$k"; then 988142a55b46Smrg # The first file doesn't have a previous command to add. 988242a55b46Smrg reload_objs=$objlist 988342a55b46Smrg eval concat_cmds=\"$reload_cmds\" 988442a55b46Smrg else 988542a55b46Smrg # All subsequent reloadable object files will link in 988642a55b46Smrg # the last one created. 988742a55b46Smrg reload_objs="$objlist $last_robj" 988842a55b46Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 988942a55b46Smrg fi 9890e3d74329Smrg last_robj=$output_objdir/$output_la-$k.$objext 989142a55b46Smrg func_arith $k + 1 989242a55b46Smrg k=$func_arith_result 9893e3d74329Smrg output=$output_objdir/$output_la-$k.$objext 989442a55b46Smrg objlist=" $obj" 989542a55b46Smrg func_len " $last_robj" 989642a55b46Smrg func_arith $len0 + $func_len_result 989742a55b46Smrg len=$func_arith_result 989842a55b46Smrg fi 989942a55b46Smrg done 990042a55b46Smrg # Handle the remaining objects by creating one last 990142a55b46Smrg # reloadable object file. All subsequent reloadable object 990242a55b46Smrg # files will link in the last one created. 990342a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 990442a55b46Smrg reload_objs="$objlist $last_robj" 9905e3d74329Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 990642a55b46Smrg if test -n "$last_robj"; then 9907e3d74329Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908c582b7e3Smrg fi 990942a55b46Smrg func_append delfiles " $output" 991042a55b46Smrg 991142a55b46Smrg else 991242a55b46Smrg output= 991342a55b46Smrg fi 991442a55b46Smrg 9915e3d74329Smrg ${skipped_export-false} && { 9916e3d74329Smrg func_verbose "generating symbol list for '$libname.la'" 9917e3d74329Smrg export_symbols=$output_objdir/$libname.exp 991842a55b46Smrg $opt_dry_run || $RM $export_symbols 991942a55b46Smrg libobjs=$output 992042a55b46Smrg # Append the command to create the export file. 992142a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 992242a55b46Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 992342a55b46Smrg if test -n "$last_robj"; then 992442a55b46Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925c582b7e3Smrg fi 9926e3d74329Smrg } 992742a55b46Smrg 992842a55b46Smrg test -n "$save_libobjs" && 992942a55b46Smrg func_verbose "creating a temporary reloadable object file: $output" 993042a55b46Smrg 993142a55b46Smrg # Loop through the commands generated above and execute them. 9932e3d74329Smrg save_ifs=$IFS; IFS='~' 993342a55b46Smrg for cmd in $concat_cmds; do 9934e3d74329Smrg IFS=$save_ifs 9935e3d74329Smrg $opt_quiet || { 993642a55b46Smrg func_quote_for_expand "$cmd" 993742a55b46Smrg eval "func_echo $func_quote_for_expand_result" 993842a55b46Smrg } 993942a55b46Smrg $opt_dry_run || eval "$cmd" || { 994042a55b46Smrg lt_exit=$? 994142a55b46Smrg 994242a55b46Smrg # Restore the uninstalled library and exit 9943e3d74329Smrg if test relink = "$opt_mode"; then 994442a55b46Smrg ( cd "$output_objdir" && \ 994542a55b46Smrg $RM "${realname}T" && \ 994642a55b46Smrg $MV "${realname}U" "$realname" ) 994742a55b46Smrg fi 994842a55b46Smrg 994942a55b46Smrg exit $lt_exit 995042a55b46Smrg } 9951c582b7e3Smrg done 9952e3d74329Smrg IFS=$save_ifs 995342a55b46Smrg 995442a55b46Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 995542a55b46Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 995642a55b46Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 995742a55b46Smrg fi 995842a55b46Smrg fi 995942a55b46Smrg 9960e3d74329Smrg ${skipped_export-false} && { 996142a55b46Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962e3d74329Smrg tmp_export_symbols=$export_symbols 9963e3d74329Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 996442a55b46Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 996542a55b46Smrg fi 996642a55b46Smrg 996742a55b46Smrg if test -n "$orig_export_symbols"; then 996842a55b46Smrg # The given exports_symbols file has to be filtered, so filter it. 9969e3d74329Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 997042a55b46Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971e3d74329Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 997242a55b46Smrg # though. Also, the filter scales superlinearly with the number of 997342a55b46Smrg # global variables. join(1) would be nice here, but unfortunately 997442a55b46Smrg # isn't a blessed tool. 997542a55b46Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 997642a55b46Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 997742a55b46Smrg export_symbols=$output_objdir/$libname.def 997842a55b46Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 997942a55b46Smrg fi 9980e3d74329Smrg } 998142a55b46Smrg 998242a55b46Smrg libobjs=$output 998342a55b46Smrg # Restore the value of output. 998442a55b46Smrg output=$save_output 998542a55b46Smrg 998642a55b46Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 998742a55b46Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 998842a55b46Smrg test "X$libobjs" = "X " && libobjs= 998942a55b46Smrg fi 999042a55b46Smrg # Expand the library linking commands again to reset the 999142a55b46Smrg # value of $libobjs for piecewise linking. 999242a55b46Smrg 999342a55b46Smrg # Do each of the archive commands. 9994e3d74329Smrg if test yes = "$module" && test -n "$module_cmds"; then 999542a55b46Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 999642a55b46Smrg cmds=$module_expsym_cmds 999742a55b46Smrg else 999842a55b46Smrg cmds=$module_cmds 999942a55b46Smrg fi 10000c582b7e3Smrg else 1000142a55b46Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1000242a55b46Smrg cmds=$archive_expsym_cmds 1000342a55b46Smrg else 1000442a55b46Smrg cmds=$archive_cmds 1000542a55b46Smrg fi 10006c582b7e3Smrg fi 1000742a55b46Smrg fi 10008c582b7e3Smrg 1000942a55b46Smrg if test -n "$delfiles"; then 1001042a55b46Smrg # Append the command to remove temporary files to $cmds. 1001142a55b46Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 1001242a55b46Smrg fi 10013c582b7e3Smrg 1001442a55b46Smrg # Add any objects from preloaded convenience libraries 1001542a55b46Smrg if test -n "$dlprefiles"; then 10016e3d74329Smrg gentop=$output_objdir/${outputname}x 1001742a55b46Smrg func_append generated " $gentop" 10018c582b7e3Smrg 1001942a55b46Smrg func_extract_archives $gentop $dlprefiles 1002042a55b46Smrg func_append libobjs " $func_extract_archives_result" 1002142a55b46Smrg test "X$libobjs" = "X " && libobjs= 1002242a55b46Smrg fi 10023c582b7e3Smrg 10024e3d74329Smrg save_ifs=$IFS; IFS='~' 1002542a55b46Smrg for cmd in $cmds; do 10026e3d74329Smrg IFS=$sp$nl 1002742a55b46Smrg eval cmd=\"$cmd\" 10028e3d74329Smrg IFS=$save_ifs 10029e3d74329Smrg $opt_quiet || { 1003042a55b46Smrg func_quote_for_expand "$cmd" 1003142a55b46Smrg eval "func_echo $func_quote_for_expand_result" 1003242a55b46Smrg } 1003342a55b46Smrg $opt_dry_run || eval "$cmd" || { 1003442a55b46Smrg lt_exit=$? 10035c582b7e3Smrg 1003642a55b46Smrg # Restore the uninstalled library and exit 10037e3d74329Smrg if test relink = "$opt_mode"; then 1003842a55b46Smrg ( cd "$output_objdir" && \ 1003942a55b46Smrg $RM "${realname}T" && \ 1004042a55b46Smrg $MV "${realname}U" "$realname" ) 1004142a55b46Smrg fi 10042c582b7e3Smrg 1004342a55b46Smrg exit $lt_exit 1004442a55b46Smrg } 1004542a55b46Smrg done 10046e3d74329Smrg IFS=$save_ifs 10047c582b7e3Smrg 1004842a55b46Smrg # Restore the uninstalled library and exit 10049e3d74329Smrg if test relink = "$opt_mode"; then 1005042a55b46Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051c582b7e3Smrg 1005242a55b46Smrg if test -n "$convenience"; then 1005342a55b46Smrg if test -z "$whole_archive_flag_spec"; then 1005442a55b46Smrg func_show_eval '${RM}r "$gentop"' 1005542a55b46Smrg fi 1005642a55b46Smrg fi 10057c582b7e3Smrg 1005842a55b46Smrg exit $EXIT_SUCCESS 1005942a55b46Smrg fi 1006042a55b46Smrg 1006142a55b46Smrg # Create links to the real library. 1006242a55b46Smrg for linkname in $linknames; do 1006342a55b46Smrg if test "$realname" != "$linkname"; then 1006442a55b46Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065c582b7e3Smrg fi 10066c582b7e3Smrg done 10067c582b7e3Smrg 1006842a55b46Smrg # If -module or -export-dynamic was specified, set the dlname. 10069e3d74329Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 1007042a55b46Smrg # On all known operating systems, these are identical. 10071e3d74329Smrg dlname=$soname 1007242a55b46Smrg fi 1007342a55b46Smrg fi 10074c582b7e3Smrg ;; 10075c582b7e3Smrg 1007642a55b46Smrg obj) 10077e3d74329Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078e3d74329Smrg func_warning "'-dlopen' is ignored for objects" 1007942a55b46Smrg fi 10080c582b7e3Smrg 1008142a55b46Smrg case " $deplibs" in 1008242a55b46Smrg *\ -l* | *\ -L*) 10083e3d74329Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084c582b7e3Smrg esac 10085c582b7e3Smrg 1008642a55b46Smrg test -n "$rpath" && \ 10087e3d74329Smrg func_warning "'-rpath' is ignored for objects" 10088c582b7e3Smrg 1008942a55b46Smrg test -n "$xrpath" && \ 10090e3d74329Smrg func_warning "'-R' is ignored for objects" 10091c582b7e3Smrg 1009242a55b46Smrg test -n "$vinfo" && \ 10093e3d74329Smrg func_warning "'-version-info' is ignored for objects" 1009442a55b46Smrg 1009542a55b46Smrg test -n "$release" && \ 10096e3d74329Smrg func_warning "'-release' is ignored for objects" 1009742a55b46Smrg 1009842a55b46Smrg case $output in 1009942a55b46Smrg *.lo) 1010042a55b46Smrg test -n "$objs$old_deplibs" && \ 10101e3d74329Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1010242a55b46Smrg 1010342a55b46Smrg libobj=$output 1010442a55b46Smrg func_lo2o "$libobj" 1010542a55b46Smrg obj=$func_lo2o_result 10106c582b7e3Smrg ;; 10107c582b7e3Smrg *) 1010842a55b46Smrg libobj= 10109e3d74329Smrg obj=$output 10110c582b7e3Smrg ;; 10111c582b7e3Smrg esac 10112c582b7e3Smrg 1011342a55b46Smrg # Delete the old objects. 1011442a55b46Smrg $opt_dry_run || $RM $obj $libobj 10115c582b7e3Smrg 1011642a55b46Smrg # Objects from convenience libraries. This assumes 1011742a55b46Smrg # single-version convenience libraries. Whenever we create 1011842a55b46Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 1011942a55b46Smrg # the extraction. 1012042a55b46Smrg reload_conv_objs= 1012142a55b46Smrg gentop= 10122e3d74329Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10123e3d74329Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10124e3d74329Smrg # into space. 10125e3d74329Smrg case $reload_cmds in 10126e3d74329Smrg *\$LD[\ \$]*) wl= ;; 10127e3d74329Smrg esac 1012842a55b46Smrg if test -n "$convenience"; then 1012942a55b46Smrg if test -n "$whole_archive_flag_spec"; then 1013042a55b46Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131e3d74329Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132e3d74329Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1013342a55b46Smrg else 10134e3d74329Smrg gentop=$output_objdir/${obj}x 1013542a55b46Smrg func_append generated " $gentop" 10136c582b7e3Smrg 1013742a55b46Smrg func_extract_archives $gentop $convenience 1013842a55b46Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1013942a55b46Smrg fi 10140c582b7e3Smrg fi 10141c582b7e3Smrg 1014242a55b46Smrg # If we're not building shared, we need to use non_pic_objs 10143e3d74329Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144c582b7e3Smrg 1014542a55b46Smrg # Create the old-style object. 10146e3d74329Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147c582b7e3Smrg 10148e3d74329Smrg output=$obj 1014942a55b46Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1015042a55b46Smrg 1015142a55b46Smrg # Exit if we aren't doing a library object file. 1015242a55b46Smrg if test -z "$libobj"; then 1015342a55b46Smrg if test -n "$gentop"; then 1015442a55b46Smrg func_show_eval '${RM}r "$gentop"' 1015542a55b46Smrg fi 1015642a55b46Smrg 1015742a55b46Smrg exit $EXIT_SUCCESS 10158c582b7e3Smrg fi 1015942a55b46Smrg 10160e3d74329Smrg test yes = "$build_libtool_libs" || { 1016142a55b46Smrg if test -n "$gentop"; then 1016242a55b46Smrg func_show_eval '${RM}r "$gentop"' 1016342a55b46Smrg fi 1016442a55b46Smrg 1016542a55b46Smrg # Create an invalid libtool object if no PIC, so that we don't 1016642a55b46Smrg # accidentally link it into a program. 1016742a55b46Smrg # $show "echo timestamp > $libobj" 1016842a55b46Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1016942a55b46Smrg exit $EXIT_SUCCESS 10170e3d74329Smrg } 1017142a55b46Smrg 10172e3d74329Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1017342a55b46Smrg # Only do commands if we really have different PIC objects. 1017442a55b46Smrg reload_objs="$libobjs $reload_conv_objs" 10175e3d74329Smrg output=$libobj 1017642a55b46Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1017742a55b46Smrg fi 1017842a55b46Smrg 1017942a55b46Smrg if test -n "$gentop"; then 1018042a55b46Smrg func_show_eval '${RM}r "$gentop"' 1018142a55b46Smrg fi 1018242a55b46Smrg 1018342a55b46Smrg exit $EXIT_SUCCESS 10184c582b7e3Smrg ;; 10185c582b7e3Smrg 1018642a55b46Smrg prog) 1018742a55b46Smrg case $host in 1018842a55b46Smrg *cygwin*) func_stripname '' '.exe' "$output" 1018942a55b46Smrg output=$func_stripname_result.exe;; 1019042a55b46Smrg esac 1019142a55b46Smrg test -n "$vinfo" && \ 10192e3d74329Smrg func_warning "'-version-info' is ignored for programs" 10193c582b7e3Smrg 1019442a55b46Smrg test -n "$release" && \ 10195e3d74329Smrg func_warning "'-release' is ignored for programs" 10196c582b7e3Smrg 10197e3d74329Smrg $preload \ 10198e3d74329Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199e3d74329Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 1020042a55b46Smrg 1020142a55b46Smrg case $host in 1020242a55b46Smrg *-*-rhapsody* | *-*-darwin1.[012]) 1020342a55b46Smrg # On Rhapsody replace the C library is the System framework 1020442a55b46Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020542a55b46Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206c582b7e3Smrg ;; 1020742a55b46Smrg esac 10208c582b7e3Smrg 1020942a55b46Smrg case $host in 1021042a55b46Smrg *-*-darwin*) 1021142a55b46Smrg # Don't allow lazy linking, it breaks C++ global constructors 1021242a55b46Smrg # But is supposedly fixed on 10.4 or later (yay!). 10213e3d74329Smrg if test CXX = "$tagname"; then 1021442a55b46Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1021542a55b46Smrg 10.[0123]) 10216e3d74329Smrg func_append compile_command " $wl-bind_at_load" 10217e3d74329Smrg func_append finalize_command " $wl-bind_at_load" 1021842a55b46Smrg ;; 1021942a55b46Smrg esac 10220c582b7e3Smrg fi 1022142a55b46Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1022242a55b46Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022342a55b46Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022442a55b46Smrg ;; 1022542a55b46Smrg esac 10226c582b7e3Smrg 10227c582b7e3Smrg 1022842a55b46Smrg # move library search paths that coincide with paths to not yet 1022942a55b46Smrg # installed libraries to the beginning of the library search list 1023042a55b46Smrg new_libs= 1023142a55b46Smrg for path in $notinst_path; do 1023242a55b46Smrg case " $new_libs " in 1023342a55b46Smrg *" -L$path/$objdir "*) ;; 1023442a55b46Smrg *) 1023542a55b46Smrg case " $compile_deplibs " in 1023642a55b46Smrg *" -L$path/$objdir "*) 1023742a55b46Smrg func_append new_libs " -L$path/$objdir" ;; 10238c582b7e3Smrg esac 1023942a55b46Smrg ;; 1024042a55b46Smrg esac 1024142a55b46Smrg done 1024242a55b46Smrg for deplib in $compile_deplibs; do 1024342a55b46Smrg case $deplib in 1024442a55b46Smrg -L*) 1024542a55b46Smrg case " $new_libs " in 1024642a55b46Smrg *" $deplib "*) ;; 1024742a55b46Smrg *) func_append new_libs " $deplib" ;; 10248c582b7e3Smrg esac 1024942a55b46Smrg ;; 1025042a55b46Smrg *) func_append new_libs " $deplib" ;; 1025142a55b46Smrg esac 1025242a55b46Smrg done 10253e3d74329Smrg compile_deplibs=$new_libs 10254c582b7e3Smrg 10255c582b7e3Smrg 1025642a55b46Smrg func_append compile_command " $compile_deplibs" 1025742a55b46Smrg func_append finalize_command " $finalize_deplibs" 10258c582b7e3Smrg 1025942a55b46Smrg if test -n "$rpath$xrpath"; then 1026042a55b46Smrg # If the user specified any rpath flags, then add them. 1026142a55b46Smrg for libdir in $rpath $xrpath; do 1026242a55b46Smrg # This is the magic to use -rpath. 1026342a55b46Smrg case "$finalize_rpath " in 1026442a55b46Smrg *" $libdir "*) ;; 1026542a55b46Smrg *) func_append finalize_rpath " $libdir" ;; 1026642a55b46Smrg esac 1026742a55b46Smrg done 1026842a55b46Smrg fi 10269c582b7e3Smrg 1027042a55b46Smrg # Now hardcode the library paths 1027142a55b46Smrg rpath= 1027242a55b46Smrg hardcode_libdirs= 1027342a55b46Smrg for libdir in $compile_rpath $finalize_rpath; do 1027442a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 1027542a55b46Smrg if test -n "$hardcode_libdir_separator"; then 1027642a55b46Smrg if test -z "$hardcode_libdirs"; then 10277e3d74329Smrg hardcode_libdirs=$libdir 1027842a55b46Smrg else 1027942a55b46Smrg # Just accumulate the unique libdirs. 1028042a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1028142a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1028242a55b46Smrg ;; 1028342a55b46Smrg *) 1028442a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1028542a55b46Smrg ;; 1028642a55b46Smrg esac 1028742a55b46Smrg fi 10288c582b7e3Smrg else 1028942a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1029042a55b46Smrg func_append rpath " $flag" 10291c582b7e3Smrg fi 1029242a55b46Smrg elif test -n "$runpath_var"; then 1029342a55b46Smrg case "$perm_rpath " in 1029442a55b46Smrg *" $libdir "*) ;; 1029542a55b46Smrg *) func_append perm_rpath " $libdir" ;; 1029642a55b46Smrg esac 1029742a55b46Smrg fi 1029842a55b46Smrg case $host in 1029942a55b46Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300e3d74329Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1030142a55b46Smrg case :$dllsearchpath: in 1030242a55b46Smrg *":$libdir:"*) ;; 1030342a55b46Smrg ::) dllsearchpath=$libdir;; 1030442a55b46Smrg *) func_append dllsearchpath ":$libdir";; 1030542a55b46Smrg esac 1030642a55b46Smrg case :$dllsearchpath: in 1030742a55b46Smrg *":$testbindir:"*) ;; 1030842a55b46Smrg ::) dllsearchpath=$testbindir;; 1030942a55b46Smrg *) func_append dllsearchpath ":$testbindir";; 1031042a55b46Smrg esac 1031142a55b46Smrg ;; 1031242a55b46Smrg esac 1031342a55b46Smrg done 1031442a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 1031542a55b46Smrg if test -n "$hardcode_libdir_separator" && 1031642a55b46Smrg test -n "$hardcode_libdirs"; then 10317e3d74329Smrg libdir=$hardcode_libdirs 1031842a55b46Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1031942a55b46Smrg fi 10320e3d74329Smrg compile_rpath=$rpath 10321c582b7e3Smrg 1032242a55b46Smrg rpath= 1032342a55b46Smrg hardcode_libdirs= 1032442a55b46Smrg for libdir in $finalize_rpath; do 1032542a55b46Smrg if test -n "$hardcode_libdir_flag_spec"; then 1032642a55b46Smrg if test -n "$hardcode_libdir_separator"; then 1032742a55b46Smrg if test -z "$hardcode_libdirs"; then 10328e3d74329Smrg hardcode_libdirs=$libdir 1032942a55b46Smrg else 1033042a55b46Smrg # Just accumulate the unique libdirs. 1033142a55b46Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1033242a55b46Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1033342a55b46Smrg ;; 1033442a55b46Smrg *) 1033542a55b46Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1033642a55b46Smrg ;; 1033742a55b46Smrg esac 1033842a55b46Smrg fi 10339c582b7e3Smrg else 1034042a55b46Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1034142a55b46Smrg func_append rpath " $flag" 10342c582b7e3Smrg fi 1034342a55b46Smrg elif test -n "$runpath_var"; then 1034442a55b46Smrg case "$finalize_perm_rpath " in 1034542a55b46Smrg *" $libdir "*) ;; 1034642a55b46Smrg *) func_append finalize_perm_rpath " $libdir" ;; 1034742a55b46Smrg esac 10348c582b7e3Smrg fi 1034942a55b46Smrg done 1035042a55b46Smrg # Substitute the hardcoded libdirs into the rpath. 1035142a55b46Smrg if test -n "$hardcode_libdir_separator" && 1035242a55b46Smrg test -n "$hardcode_libdirs"; then 10353e3d74329Smrg libdir=$hardcode_libdirs 1035442a55b46Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1035542a55b46Smrg fi 10356e3d74329Smrg finalize_rpath=$rpath 10357c582b7e3Smrg 10358e3d74329Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1035942a55b46Smrg # Transform all the library objects into standard objects. 1036042a55b46Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036142a55b46Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036242a55b46Smrg fi 10363c582b7e3Smrg 10364e3d74329Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365c582b7e3Smrg 1036642a55b46Smrg # template prelinking step 1036742a55b46Smrg if test -n "$prelink_cmds"; then 1036842a55b46Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 1036942a55b46Smrg fi 10370c582b7e3Smrg 10371e3d74329Smrg wrappers_required=: 1037242a55b46Smrg case $host in 1037342a55b46Smrg *cegcc* | *mingw32ce*) 1037442a55b46Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375e3d74329Smrg wrappers_required=false 1037642a55b46Smrg ;; 1037742a55b46Smrg *cygwin* | *mingw* ) 10378e3d74329Smrg test yes = "$build_libtool_libs" || wrappers_required=false 1037942a55b46Smrg ;; 1038042a55b46Smrg *) 10381e3d74329Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382e3d74329Smrg wrappers_required=false 1038342a55b46Smrg fi 1038442a55b46Smrg ;; 1038542a55b46Smrg esac 10386e3d74329Smrg $wrappers_required || { 1038742a55b46Smrg # Replace the output file specification. 1038842a55b46Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389e3d74329Smrg link_command=$compile_command$compile_rpath 10390c582b7e3Smrg 1039142a55b46Smrg # We have no uninstalled library dependencies, so finalize right now. 1039242a55b46Smrg exit_status=0 1039342a55b46Smrg func_show_eval "$link_command" 'exit_status=$?' 10394c582b7e3Smrg 1039542a55b46Smrg if test -n "$postlink_cmds"; then 1039642a55b46Smrg func_to_tool_file "$output" 1039742a55b46Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1039842a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10399c582b7e3Smrg fi 10400c582b7e3Smrg 1040142a55b46Smrg # Delete the generated files. 10402e3d74329Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10403e3d74329Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1040442a55b46Smrg fi 10405c582b7e3Smrg 1040642a55b46Smrg exit $exit_status 10407e3d74329Smrg } 10408c582b7e3Smrg 1040942a55b46Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1041042a55b46Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1041142a55b46Smrg fi 1041242a55b46Smrg if test -n "$finalize_shlibpath"; then 1041342a55b46Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1041442a55b46Smrg fi 10415c582b7e3Smrg 1041642a55b46Smrg compile_var= 1041742a55b46Smrg finalize_var= 1041842a55b46Smrg if test -n "$runpath_var"; then 1041942a55b46Smrg if test -n "$perm_rpath"; then 1042042a55b46Smrg # We should set the runpath_var. 1042142a55b46Smrg rpath= 1042242a55b46Smrg for dir in $perm_rpath; do 1042342a55b46Smrg func_append rpath "$dir:" 1042442a55b46Smrg done 1042542a55b46Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426c582b7e3Smrg fi 1042742a55b46Smrg if test -n "$finalize_perm_rpath"; then 1042842a55b46Smrg # We should set the runpath_var. 1042942a55b46Smrg rpath= 1043042a55b46Smrg for dir in $finalize_perm_rpath; do 1043142a55b46Smrg func_append rpath "$dir:" 1043242a55b46Smrg done 1043342a55b46Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434c582b7e3Smrg fi 1043542a55b46Smrg fi 10436c582b7e3Smrg 10437e3d74329Smrg if test yes = "$no_install"; then 1043842a55b46Smrg # We don't need to create a wrapper script. 10439e3d74329Smrg link_command=$compile_var$compile_command$compile_rpath 1044042a55b46Smrg # Replace the output file specification. 1044142a55b46Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1044242a55b46Smrg # Delete the old output file. 1044342a55b46Smrg $opt_dry_run || $RM $output 1044442a55b46Smrg # Link the executable and exit 1044542a55b46Smrg func_show_eval "$link_command" 'exit $?' 10446c582b7e3Smrg 1044742a55b46Smrg if test -n "$postlink_cmds"; then 1044842a55b46Smrg func_to_tool_file "$output" 1044942a55b46Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1045042a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10451c582b7e3Smrg fi 1045242a55b46Smrg 10453c582b7e3Smrg exit $EXIT_SUCCESS 1045442a55b46Smrg fi 10455c582b7e3Smrg 10456e3d74329Smrg case $hardcode_action,$fast_install in 10457e3d74329Smrg relink,*) 10458e3d74329Smrg # Fast installation is not supported 10459e3d74329Smrg link_command=$compile_var$compile_command$compile_rpath 10460e3d74329Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1046142a55b46Smrg 10462e3d74329Smrg func_warning "this platform does not like uninstalled shared libraries" 10463e3d74329Smrg func_warning "'$output' will be relinked during installation" 10464e3d74329Smrg ;; 10465e3d74329Smrg *,yes) 10466e3d74329Smrg link_command=$finalize_var$compile_command$finalize_rpath 10467e3d74329Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468e3d74329Smrg ;; 10469e3d74329Smrg *,no) 10470e3d74329Smrg link_command=$compile_var$compile_command$compile_rpath 10471e3d74329Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10472e3d74329Smrg ;; 10473e3d74329Smrg *,needless) 10474e3d74329Smrg link_command=$finalize_var$compile_command$finalize_rpath 10475e3d74329Smrg relink_command= 10476e3d74329Smrg ;; 10477e3d74329Smrg esac 10478c582b7e3Smrg 1047942a55b46Smrg # Replace the output file specification. 1048042a55b46Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481c582b7e3Smrg 1048242a55b46Smrg # Delete the old output files. 1048342a55b46Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484c582b7e3Smrg 1048542a55b46Smrg func_show_eval "$link_command" 'exit $?' 10486c582b7e3Smrg 1048742a55b46Smrg if test -n "$postlink_cmds"; then 1048842a55b46Smrg func_to_tool_file "$output_objdir/$outputname" 1048942a55b46Smrg 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'` 1049042a55b46Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1049142a55b46Smrg fi 10492c582b7e3Smrg 1049342a55b46Smrg # Now create the wrapper script. 1049442a55b46Smrg func_verbose "creating $output" 10495c582b7e3Smrg 1049642a55b46Smrg # Quote the relink command for shipping. 1049742a55b46Smrg if test -n "$relink_command"; then 1049842a55b46Smrg # Preserve any variables that may affect compiler behavior 1049942a55b46Smrg for var in $variables_saved_for_relink; do 1050042a55b46Smrg if eval test -z \"\${$var+set}\"; then 1050142a55b46Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1050242a55b46Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1050342a55b46Smrg relink_command="$var=; export $var; $relink_command" 10504c582b7e3Smrg else 1050542a55b46Smrg func_quote_for_eval "$var_value" 1050642a55b46Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507c582b7e3Smrg fi 1050842a55b46Smrg done 1050942a55b46Smrg relink_command="(cd `pwd`; $relink_command)" 1051042a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1051142a55b46Smrg fi 1051242a55b46Smrg 1051342a55b46Smrg # Only actually do things if not in dry run mode. 1051442a55b46Smrg $opt_dry_run || { 1051542a55b46Smrg # win32 will think the script is a binary if it has 1051642a55b46Smrg # a .exe suffix, so we strip it off here. 1051742a55b46Smrg case $output in 1051842a55b46Smrg *.exe) func_stripname '' '.exe' "$output" 1051942a55b46Smrg output=$func_stripname_result ;; 10520c582b7e3Smrg esac 1052142a55b46Smrg # test for cygwin because mv fails w/o .exe extensions 1052242a55b46Smrg case $host in 1052342a55b46Smrg *cygwin*) 1052442a55b46Smrg exeext=.exe 1052542a55b46Smrg func_stripname '' '.exe' "$outputname" 1052642a55b46Smrg outputname=$func_stripname_result ;; 1052742a55b46Smrg *) exeext= ;; 1052842a55b46Smrg esac 1052942a55b46Smrg case $host in 1053042a55b46Smrg *cygwin* | *mingw* ) 1053142a55b46Smrg func_dirname_and_basename "$output" "" "." 1053242a55b46Smrg output_name=$func_basename_result 1053342a55b46Smrg output_path=$func_dirname_result 10534e3d74329Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10535e3d74329Smrg cwrapper=$output_path/$output_name.exe 1053642a55b46Smrg $RM $cwrappersource $cwrapper 1053742a55b46Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1053842a55b46Smrg 1053942a55b46Smrg func_emit_cwrapperexe_src > $cwrappersource 1054042a55b46Smrg 1054142a55b46Smrg # The wrapper executable is built using the $host compiler, 1054242a55b46Smrg # because it contains $host paths and files. If cross- 1054342a55b46Smrg # compiling, it, like the target executable, must be 1054442a55b46Smrg # executed on the $host or under an emulation environment. 1054542a55b46Smrg $opt_dry_run || { 1054642a55b46Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1054742a55b46Smrg $STRIP $cwrapper 1054842a55b46Smrg } 10549c582b7e3Smrg 1055042a55b46Smrg # Now, create the wrapper script for func_source use: 1055142a55b46Smrg func_ltwrapper_scriptname $cwrapper 1055242a55b46Smrg $RM $func_ltwrapper_scriptname_result 1055342a55b46Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1055442a55b46Smrg $opt_dry_run || { 1055542a55b46Smrg # note: this script will not be executed, so do not chmod. 10556e3d74329Smrg if test "x$build" = "x$host"; then 1055742a55b46Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 1055842a55b46Smrg else 1055942a55b46Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 1056042a55b46Smrg fi 1056142a55b46Smrg } 1056242a55b46Smrg ;; 1056342a55b46Smrg * ) 1056442a55b46Smrg $RM $output 1056542a55b46Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566c582b7e3Smrg 1056742a55b46Smrg func_emit_wrapper no > $output 1056842a55b46Smrg chmod +x $output 1056942a55b46Smrg ;; 1057042a55b46Smrg esac 1057142a55b46Smrg } 1057242a55b46Smrg exit $EXIT_SUCCESS 1057342a55b46Smrg ;; 1057442a55b46Smrg esac 10575c582b7e3Smrg 1057642a55b46Smrg # See if we need to build an old-fashioned archive. 1057742a55b46Smrg for oldlib in $oldlibs; do 10578c582b7e3Smrg 10579e3d74329Smrg case $build_libtool_libs in 10580e3d74329Smrg convenience) 10581e3d74329Smrg oldobjs="$libobjs_save $symfileobj" 10582e3d74329Smrg addlibs=$convenience 1058342a55b46Smrg build_libtool_libs=no 10584e3d74329Smrg ;; 10585e3d74329Smrg module) 10586e3d74329Smrg oldobjs=$libobjs_save 10587e3d74329Smrg addlibs=$old_convenience 10588e3d74329Smrg build_libtool_libs=no 10589e3d74329Smrg ;; 10590e3d74329Smrg *) 1059142a55b46Smrg oldobjs="$old_deplibs $non_pic_objects" 10592e3d74329Smrg $preload && test -f "$symfileobj" \ 10593e3d74329Smrg && func_append oldobjs " $symfileobj" 10594e3d74329Smrg addlibs=$old_convenience 10595e3d74329Smrg ;; 10596e3d74329Smrg esac 10597c582b7e3Smrg 1059842a55b46Smrg if test -n "$addlibs"; then 10599e3d74329Smrg gentop=$output_objdir/${outputname}x 1060042a55b46Smrg func_append generated " $gentop" 10601c582b7e3Smrg 1060242a55b46Smrg func_extract_archives $gentop $addlibs 1060342a55b46Smrg func_append oldobjs " $func_extract_archives_result" 1060442a55b46Smrg fi 10605c582b7e3Smrg 1060642a55b46Smrg # Do each command in the archive commands. 10607e3d74329Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1060842a55b46Smrg cmds=$old_archive_from_new_cmds 1060942a55b46Smrg else 10610c582b7e3Smrg 1061142a55b46Smrg # Add any objects from preloaded convenience libraries 1061242a55b46Smrg if test -n "$dlprefiles"; then 10613e3d74329Smrg gentop=$output_objdir/${outputname}x 1061442a55b46Smrg func_append generated " $gentop" 10615c582b7e3Smrg 1061642a55b46Smrg func_extract_archives $gentop $dlprefiles 1061742a55b46Smrg func_append oldobjs " $func_extract_archives_result" 1061842a55b46Smrg fi 10619c582b7e3Smrg 1062042a55b46Smrg # POSIX demands no paths to be encoded in archives. We have 1062142a55b46Smrg # to avoid creating archives with duplicate basenames if we 1062242a55b46Smrg # might have to extract them afterwards, e.g., when creating a 1062342a55b46Smrg # static archive out of a convenience library, or when linking 1062442a55b46Smrg # the entirety of a libtool archive into another (currently 1062542a55b46Smrg # not supported by libtool). 1062642a55b46Smrg if (for obj in $oldobjs 1062742a55b46Smrg do 1062842a55b46Smrg func_basename "$obj" 1062942a55b46Smrg $ECHO "$func_basename_result" 1063042a55b46Smrg done | sort | sort -uc >/dev/null 2>&1); then 1063142a55b46Smrg : 1063242a55b46Smrg else 1063342a55b46Smrg echo "copying selected object files to avoid basename conflicts..." 10634e3d74329Smrg gentop=$output_objdir/${outputname}x 1063542a55b46Smrg func_append generated " $gentop" 1063642a55b46Smrg func_mkdir_p "$gentop" 1063742a55b46Smrg save_oldobjs=$oldobjs 1063842a55b46Smrg oldobjs= 1063942a55b46Smrg counter=1 1064042a55b46Smrg for obj in $save_oldobjs 1064142a55b46Smrg do 1064242a55b46Smrg func_basename "$obj" 10643e3d74329Smrg objbase=$func_basename_result 1064442a55b46Smrg case " $oldobjs " in 1064542a55b46Smrg " ") oldobjs=$obj ;; 1064642a55b46Smrg *[\ /]"$objbase "*) 1064742a55b46Smrg while :; do 1064842a55b46Smrg # Make sure we don't pick an alternate name that also 1064942a55b46Smrg # overlaps. 1065042a55b46Smrg newobj=lt$counter-$objbase 1065142a55b46Smrg func_arith $counter + 1 1065242a55b46Smrg counter=$func_arith_result 1065342a55b46Smrg case " $oldobjs " in 1065442a55b46Smrg *[\ /]"$newobj "*) ;; 1065542a55b46Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1065642a55b46Smrg esac 1065742a55b46Smrg done 1065842a55b46Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1065942a55b46Smrg func_append oldobjs " $gentop/$newobj" 1066042a55b46Smrg ;; 1066142a55b46Smrg *) func_append oldobjs " $obj" ;; 1066242a55b46Smrg esac 10663c582b7e3Smrg done 10664c582b7e3Smrg fi 1066542a55b46Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1066642a55b46Smrg tool_oldlib=$func_to_tool_file_result 1066742a55b46Smrg eval cmds=\"$old_archive_cmds\" 10668c582b7e3Smrg 1066942a55b46Smrg func_len " $cmds" 1067042a55b46Smrg len=$func_len_result 1067142a55b46Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1067242a55b46Smrg cmds=$old_archive_cmds 1067342a55b46Smrg elif test -n "$archiver_list_spec"; then 1067442a55b46Smrg func_verbose "using command file archive linking..." 1067542a55b46Smrg for obj in $oldobjs 1067642a55b46Smrg do 1067742a55b46Smrg func_to_tool_file "$obj" 1067842a55b46Smrg $ECHO "$func_to_tool_file_result" 1067942a55b46Smrg done > $output_objdir/$libname.libcmd 1068042a55b46Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1068142a55b46Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1068242a55b46Smrg cmds=$old_archive_cmds 1068342a55b46Smrg else 1068442a55b46Smrg # the command line is too long to link in one step, link in parts 1068542a55b46Smrg func_verbose "using piecewise archive linking..." 1068642a55b46Smrg save_RANLIB=$RANLIB 1068742a55b46Smrg RANLIB=: 1068842a55b46Smrg objlist= 1068942a55b46Smrg concat_cmds= 1069042a55b46Smrg save_oldobjs=$oldobjs 1069142a55b46Smrg oldobjs= 1069242a55b46Smrg # Is there a better way of finding the last object in the list? 1069342a55b46Smrg for obj in $save_oldobjs 1069442a55b46Smrg do 1069542a55b46Smrg last_oldobj=$obj 1069642a55b46Smrg done 1069742a55b46Smrg eval test_cmds=\"$old_archive_cmds\" 1069842a55b46Smrg func_len " $test_cmds" 1069942a55b46Smrg len0=$func_len_result 1070042a55b46Smrg len=$len0 1070142a55b46Smrg for obj in $save_oldobjs 1070242a55b46Smrg do 1070342a55b46Smrg func_len " $obj" 1070442a55b46Smrg func_arith $len + $func_len_result 1070542a55b46Smrg len=$func_arith_result 1070642a55b46Smrg func_append objlist " $obj" 1070742a55b46Smrg if test "$len" -lt "$max_cmd_len"; then 1070842a55b46Smrg : 1070942a55b46Smrg else 1071042a55b46Smrg # the above command should be used before it gets too long 1071142a55b46Smrg oldobjs=$objlist 10712e3d74329Smrg if test "$obj" = "$last_oldobj"; then 1071342a55b46Smrg RANLIB=$save_RANLIB 1071442a55b46Smrg fi 1071542a55b46Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716e3d74329Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1071742a55b46Smrg objlist= 1071842a55b46Smrg len=$len0 1071942a55b46Smrg fi 1072042a55b46Smrg done 1072142a55b46Smrg RANLIB=$save_RANLIB 1072242a55b46Smrg oldobjs=$objlist 10723e3d74329Smrg if test -z "$oldobjs"; then 1072442a55b46Smrg eval cmds=\"\$concat_cmds\" 1072542a55b46Smrg else 1072642a55b46Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1072742a55b46Smrg fi 1072842a55b46Smrg fi 1072942a55b46Smrg fi 1073042a55b46Smrg func_execute_cmds "$cmds" 'exit $?' 10731c582b7e3Smrg done 10732c582b7e3Smrg 1073342a55b46Smrg test -n "$generated" && \ 1073442a55b46Smrg func_show_eval "${RM}r$generated" 10735c582b7e3Smrg 1073642a55b46Smrg # Now create the libtool archive. 1073742a55b46Smrg case $output in 1073842a55b46Smrg *.la) 1073942a55b46Smrg old_library= 10740e3d74329Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 1074142a55b46Smrg func_verbose "creating $output" 10742c582b7e3Smrg 1074342a55b46Smrg # Preserve any variables that may affect compiler behavior 1074442a55b46Smrg for var in $variables_saved_for_relink; do 1074542a55b46Smrg if eval test -z \"\${$var+set}\"; then 1074642a55b46Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1074742a55b46Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1074842a55b46Smrg relink_command="$var=; export $var; $relink_command" 10749c582b7e3Smrg else 1075042a55b46Smrg func_quote_for_eval "$var_value" 1075142a55b46Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752c582b7e3Smrg fi 1075342a55b46Smrg done 1075442a55b46Smrg # Quote the link command for shipping. 10755e3d74329Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1075642a55b46Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757e3d74329Smrg if test yes = "$hardcode_automatic"; then 1075842a55b46Smrg relink_command= 1075942a55b46Smrg fi 10760c582b7e3Smrg 1076142a55b46Smrg # Only create the output if not a dry run. 1076242a55b46Smrg $opt_dry_run || { 1076342a55b46Smrg for installed in no yes; do 10764e3d74329Smrg if test yes = "$installed"; then 1076542a55b46Smrg if test -z "$install_libdir"; then 1076642a55b46Smrg break 1076742a55b46Smrg fi 10768e3d74329Smrg output=$output_objdir/${outputname}i 1076942a55b46Smrg # Replace all uninstalled libtool libraries with the installed ones 1077042a55b46Smrg newdependency_libs= 1077142a55b46Smrg for deplib in $dependency_libs; do 1077242a55b46Smrg case $deplib in 1077342a55b46Smrg *.la) 1077442a55b46Smrg func_basename "$deplib" 10775e3d74329Smrg name=$func_basename_result 1077642a55b46Smrg func_resolve_sysroot "$deplib" 10777e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1077842a55b46Smrg test -z "$libdir" && \ 10779e3d74329Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 1078042a55b46Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1078142a55b46Smrg ;; 1078242a55b46Smrg -L*) 1078342a55b46Smrg func_stripname -L '' "$deplib" 1078442a55b46Smrg func_replace_sysroot "$func_stripname_result" 1078542a55b46Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1078642a55b46Smrg ;; 1078742a55b46Smrg -R*) 1078842a55b46Smrg func_stripname -R '' "$deplib" 1078942a55b46Smrg func_replace_sysroot "$func_stripname_result" 1079042a55b46Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1079142a55b46Smrg ;; 1079242a55b46Smrg *) func_append newdependency_libs " $deplib" ;; 1079342a55b46Smrg esac 1079442a55b46Smrg done 10795e3d74329Smrg dependency_libs=$newdependency_libs 1079642a55b46Smrg newdlfiles= 1079742a55b46Smrg 1079842a55b46Smrg for lib in $dlfiles; do 1079942a55b46Smrg case $lib in 1080042a55b46Smrg *.la) 1080142a55b46Smrg func_basename "$lib" 10802e3d74329Smrg name=$func_basename_result 10803e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1080442a55b46Smrg test -z "$libdir" && \ 10805e3d74329Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1080642a55b46Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1080742a55b46Smrg ;; 1080842a55b46Smrg *) func_append newdlfiles " $lib" ;; 1080942a55b46Smrg esac 1081042a55b46Smrg done 10811e3d74329Smrg dlfiles=$newdlfiles 1081242a55b46Smrg newdlprefiles= 1081342a55b46Smrg for lib in $dlprefiles; do 1081442a55b46Smrg case $lib in 1081542a55b46Smrg *.la) 1081642a55b46Smrg # Only pass preopened files to the pseudo-archive (for 1081742a55b46Smrg # eventual linking with the app. that links it) if we 1081842a55b46Smrg # didn't already link the preopened objects directly into 1081942a55b46Smrg # the library: 1082042a55b46Smrg func_basename "$lib" 10821e3d74329Smrg name=$func_basename_result 10822e3d74329Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1082342a55b46Smrg test -z "$libdir" && \ 10824e3d74329Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1082542a55b46Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1082642a55b46Smrg ;; 1082742a55b46Smrg esac 1082842a55b46Smrg done 10829e3d74329Smrg dlprefiles=$newdlprefiles 1083042a55b46Smrg else 1083142a55b46Smrg newdlfiles= 1083242a55b46Smrg for lib in $dlfiles; do 1083342a55b46Smrg case $lib in 10834e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1083542a55b46Smrg *) abs=`pwd`"/$lib" ;; 1083642a55b46Smrg esac 1083742a55b46Smrg func_append newdlfiles " $abs" 1083842a55b46Smrg done 10839e3d74329Smrg dlfiles=$newdlfiles 1084042a55b46Smrg newdlprefiles= 1084142a55b46Smrg for lib in $dlprefiles; do 1084242a55b46Smrg case $lib in 10843e3d74329Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1084442a55b46Smrg *) abs=`pwd`"/$lib" ;; 1084542a55b46Smrg esac 1084642a55b46Smrg func_append newdlprefiles " $abs" 1084742a55b46Smrg done 10848e3d74329Smrg dlprefiles=$newdlprefiles 1084942a55b46Smrg fi 1085042a55b46Smrg $RM $output 1085142a55b46Smrg # place dlname in correct position for cygwin 1085242a55b46Smrg # In fact, it would be nice if we could use this code for all target 1085342a55b46Smrg # systems that can't hard-code library paths into their executables 1085442a55b46Smrg # and that have no shared library path variable independent of PATH, 1085542a55b46Smrg # but it turns out we can't easily determine that from inspecting 1085642a55b46Smrg # libtool variables, so we have to hard-code the OSs to which it 1085742a55b46Smrg # applies here; at the moment, that means platforms that use the PE 1085842a55b46Smrg # object format with DLL files. See the long comment at the top of 1085942a55b46Smrg # tests/bindir.at for full details. 1086042a55b46Smrg tdlname=$dlname 1086142a55b46Smrg case $host,$output,$installed,$module,$dlname in 1086242a55b46Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1086342a55b46Smrg # If a -bindir argument was supplied, place the dll there. 10864e3d74329Smrg if test -n "$bindir"; then 1086542a55b46Smrg func_relative_path "$install_libdir" "$bindir" 10866e3d74329Smrg tdlname=$func_relative_path_result/$dlname 1086742a55b46Smrg else 1086842a55b46Smrg # Otherwise fall back on heuristic. 1086942a55b46Smrg tdlname=../bin/$dlname 1087042a55b46Smrg fi 1087142a55b46Smrg ;; 1087242a55b46Smrg esac 1087342a55b46Smrg $ECHO > $output "\ 1087442a55b46Smrg# $outputname - a libtool library file 10875e3d74329Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1087642a55b46Smrg# 1087742a55b46Smrg# Please DO NOT delete this file! 1087842a55b46Smrg# It is necessary for linking the library. 10879c582b7e3Smrg 1088042a55b46Smrg# The name that we can dlopen(3). 1088142a55b46Smrgdlname='$tdlname' 10882c582b7e3Smrg 1088342a55b46Smrg# Names of this library. 1088442a55b46Smrglibrary_names='$library_names' 10885c582b7e3Smrg 1088642a55b46Smrg# The name of the static archive. 1088742a55b46Smrgold_library='$old_library' 10888c582b7e3Smrg 10889e3d74329Smrg# Linker flags that cannot go in dependency_libs. 1089042a55b46Smrginherited_linker_flags='$new_inherited_linker_flags' 10891c582b7e3Smrg 1089242a55b46Smrg# Libraries that this one depends upon. 1089342a55b46Smrgdependency_libs='$dependency_libs' 10894c582b7e3Smrg 1089542a55b46Smrg# Names of additional weak libraries provided by this library 1089642a55b46Smrgweak_library_names='$weak_libs' 10897c582b7e3Smrg 1089842a55b46Smrg# Version information for $libname. 1089942a55b46Smrgcurrent=$current 1090042a55b46Smrgage=$age 1090142a55b46Smrgrevision=$revision 10902c582b7e3Smrg 1090342a55b46Smrg# Is this an already installed library? 1090442a55b46Smrginstalled=$installed 10905c582b7e3Smrg 1090642a55b46Smrg# Should we warn about portability when linking against -modules? 1090742a55b46Smrgshouldnotlink=$module 10908c582b7e3Smrg 1090942a55b46Smrg# Files to dlopen/dlpreopen 1091042a55b46Smrgdlopen='$dlfiles' 1091142a55b46Smrgdlpreopen='$dlprefiles' 10912c582b7e3Smrg 1091342a55b46Smrg# Directory that this library needs to be installed in: 1091442a55b46Smrglibdir='$install_libdir'" 10915e3d74329Smrg if test no,yes = "$installed,$need_relink"; then 1091642a55b46Smrg $ECHO >> $output "\ 1091742a55b46Smrgrelink_command=\"$relink_command\"" 1091842a55b46Smrg fi 1091942a55b46Smrg done 1092042a55b46Smrg } 10921c582b7e3Smrg 1092242a55b46Smrg # Do a symbolic link so that the libtool archive can be found in 1092342a55b46Smrg # LD_LIBRARY_PATH before the program is installed. 1092442a55b46Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1092542a55b46Smrg ;; 1092642a55b46Smrg esac 1092742a55b46Smrg exit $EXIT_SUCCESS 1092842a55b46Smrg} 10929c582b7e3Smrg 10930e3d74329Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931e3d74329Smrg func_mode_link ${1+"$@"} 10932e3d74329Smrgfi 10933c582b7e3Smrg 10934c582b7e3Smrg 1093542a55b46Smrg# func_mode_uninstall arg... 1093642a55b46Smrgfunc_mode_uninstall () 1093742a55b46Smrg{ 10938e3d74329Smrg $debug_cmd 10939e3d74329Smrg 10940e3d74329Smrg RM=$nonopt 10941c582b7e3Smrg files= 10942e3d74329Smrg rmforce=false 10943c582b7e3Smrg exit_status=0 10944c582b7e3Smrg 10945c582b7e3Smrg # This variable tells wrapper scripts just to set variables rather 10946c582b7e3Smrg # than running their programs. 10947e3d74329Smrg libtool_install_magic=$magic 10948c582b7e3Smrg 10949c582b7e3Smrg for arg 10950c582b7e3Smrg do 10951c582b7e3Smrg case $arg in 10952e3d74329Smrg -f) func_append RM " $arg"; rmforce=: ;; 1095342a55b46Smrg -*) func_append RM " $arg" ;; 1095442a55b46Smrg *) func_append files " $arg" ;; 10955c582b7e3Smrg esac 10956c582b7e3Smrg done 10957c582b7e3Smrg 1095842a55b46Smrg test -z "$RM" && \ 1095942a55b46Smrg func_fatal_help "you must specify an RM program" 10960c582b7e3Smrg 10961c582b7e3Smrg rmdirs= 10962c582b7e3Smrg 10963c582b7e3Smrg for file in $files; do 1096442a55b46Smrg func_dirname "$file" "" "." 10965e3d74329Smrg dir=$func_dirname_result 10966e3d74329Smrg if test . = "$dir"; then 10967e3d74329Smrg odir=$objdir 10968c582b7e3Smrg else 10969e3d74329Smrg odir=$dir/$objdir 10970c582b7e3Smrg fi 1097142a55b46Smrg func_basename "$file" 10972e3d74329Smrg name=$func_basename_result 10973e3d74329Smrg test uninstall = "$opt_mode" && odir=$dir 10974c582b7e3Smrg 1097542a55b46Smrg # Remember odir for removal later, being careful to avoid duplicates 10976e3d74329Smrg if test clean = "$opt_mode"; then 10977c582b7e3Smrg case " $rmdirs " in 1097842a55b46Smrg *" $odir "*) ;; 1097942a55b46Smrg *) func_append rmdirs " $odir" ;; 10980c582b7e3Smrg esac 10981c582b7e3Smrg fi 10982c582b7e3Smrg 10983c582b7e3Smrg # Don't error if the file doesn't exist and rm -f was used. 1098442a55b46Smrg if { test -L "$file"; } >/dev/null 2>&1 || 1098542a55b46Smrg { test -h "$file"; } >/dev/null 2>&1 || 1098642a55b46Smrg test -f "$file"; then 10987c582b7e3Smrg : 10988c582b7e3Smrg elif test -d "$file"; then 10989c582b7e3Smrg exit_status=1 10990c582b7e3Smrg continue 10991e3d74329Smrg elif $rmforce; then 10992c582b7e3Smrg continue 10993c582b7e3Smrg fi 10994c582b7e3Smrg 10995e3d74329Smrg rmfiles=$file 10996c582b7e3Smrg 10997c582b7e3Smrg case $name in 10998c582b7e3Smrg *.la) 10999c582b7e3Smrg # Possibly a libtool archive, so verify it. 1100042a55b46Smrg if func_lalib_p "$file"; then 1100142a55b46Smrg func_source $dir/$name 11002c582b7e3Smrg 11003c582b7e3Smrg # Delete the libtool libraries and symlinks. 11004c582b7e3Smrg for n in $library_names; do 1100542a55b46Smrg func_append rmfiles " $odir/$n" 11006c582b7e3Smrg done 1100742a55b46Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008c582b7e3Smrg 11009e3d74329Smrg case $opt_mode in 11010c582b7e3Smrg clean) 1101142a55b46Smrg case " $library_names " in 11012c582b7e3Smrg *" $dlname "*) ;; 1101342a55b46Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014c582b7e3Smrg esac 1101542a55b46Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016c582b7e3Smrg ;; 11017c582b7e3Smrg uninstall) 11018c582b7e3Smrg if test -n "$library_names"; then 11019c582b7e3Smrg # Do each command in the postuninstall commands. 11020e3d74329Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021c582b7e3Smrg fi 11022c582b7e3Smrg 11023c582b7e3Smrg if test -n "$old_library"; then 11024c582b7e3Smrg # Do each command in the old_postuninstall commands. 11025e3d74329Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026c582b7e3Smrg fi 11027c582b7e3Smrg # FIXME: should reinstall the best remaining shared library. 11028c582b7e3Smrg ;; 11029c582b7e3Smrg esac 11030c582b7e3Smrg fi 11031c582b7e3Smrg ;; 11032c582b7e3Smrg 11033c582b7e3Smrg *.lo) 11034c582b7e3Smrg # Possibly a libtool object, so verify it. 1103542a55b46Smrg if func_lalib_p "$file"; then 11036c582b7e3Smrg 11037c582b7e3Smrg # Read the .lo file 1103842a55b46Smrg func_source $dir/$name 11039c582b7e3Smrg 11040c582b7e3Smrg # Add PIC object to the list of files to remove. 11041e3d74329Smrg if test -n "$pic_object" && test none != "$pic_object"; then 1104242a55b46Smrg func_append rmfiles " $dir/$pic_object" 11043c582b7e3Smrg fi 11044c582b7e3Smrg 11045c582b7e3Smrg # Add non-PIC object to the list of files to remove. 11046e3d74329Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1104742a55b46Smrg func_append rmfiles " $dir/$non_pic_object" 11048c582b7e3Smrg fi 11049c582b7e3Smrg fi 11050c582b7e3Smrg ;; 11051c582b7e3Smrg 11052c582b7e3Smrg *) 11053e3d74329Smrg if test clean = "$opt_mode"; then 11054c582b7e3Smrg noexename=$name 11055c582b7e3Smrg case $file in 11056c582b7e3Smrg *.exe) 1105742a55b46Smrg func_stripname '' '.exe' "$file" 1105842a55b46Smrg file=$func_stripname_result 1105942a55b46Smrg func_stripname '' '.exe' "$name" 1106042a55b46Smrg noexename=$func_stripname_result 11061c582b7e3Smrg # $file with .exe has already been added to rmfiles, 11062c582b7e3Smrg # add $file without .exe 1106342a55b46Smrg func_append rmfiles " $file" 11064c582b7e3Smrg ;; 11065c582b7e3Smrg esac 11066c582b7e3Smrg # Do a test to see if this is a libtool program. 1106742a55b46Smrg if func_ltwrapper_p "$file"; then 1106842a55b46Smrg if func_ltwrapper_executable_p "$file"; then 1106942a55b46Smrg func_ltwrapper_scriptname "$file" 1107042a55b46Smrg relink_command= 1107142a55b46Smrg func_source $func_ltwrapper_scriptname_result 1107242a55b46Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1107342a55b46Smrg else 1107442a55b46Smrg relink_command= 1107542a55b46Smrg func_source $dir/$noexename 1107642a55b46Smrg fi 11077c582b7e3Smrg 11078c582b7e3Smrg # note $name still contains .exe if it was in $file originally 11079c582b7e3Smrg # as does the version of $file that was added into $rmfiles 11080e3d74329Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081e3d74329Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 1108242a55b46Smrg func_append rmfiles " $odir/lt-$name" 11083c582b7e3Smrg fi 11084e3d74329Smrg if test "X$noexename" != "X$name"; then 11085e3d74329Smrg func_append rmfiles " $odir/lt-$noexename.c" 11086c582b7e3Smrg fi 11087c582b7e3Smrg fi 11088c582b7e3Smrg fi 11089c582b7e3Smrg ;; 11090c582b7e3Smrg esac 1109142a55b46Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092c582b7e3Smrg done 11093c582b7e3Smrg 11094e3d74329Smrg # Try to remove the $objdir's in the directories where we deleted files 11095c582b7e3Smrg for dir in $rmdirs; do 11096c582b7e3Smrg if test -d "$dir"; then 1109742a55b46Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098c582b7e3Smrg fi 11099c582b7e3Smrg done 11100c582b7e3Smrg 11101c582b7e3Smrg exit $exit_status 1110242a55b46Smrg} 11103c582b7e3Smrg 11104e3d74329Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105e3d74329Smrg func_mode_uninstall ${1+"$@"} 11106e3d74329Smrgfi 11107c582b7e3Smrg 1110842a55b46Smrgtest -z "$opt_mode" && { 11109e3d74329Smrg help=$generic_help 1111042a55b46Smrg func_fatal_help "you must specify a MODE" 1111142a55b46Smrg} 1111242a55b46Smrg 1111342a55b46Smrgtest -z "$exec_cmd" && \ 11114e3d74329Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11115c582b7e3Smrg 11116c582b7e3Smrgif test -n "$exec_cmd"; then 1111742a55b46Smrg eval exec "$exec_cmd" 11118c582b7e3Smrg exit $EXIT_FAILURE 11119c582b7e3Smrgfi 11120c582b7e3Smrg 1112142a55b46Smrgexit $exit_status 11122c582b7e3Smrg 11123c582b7e3Smrg 11124c582b7e3Smrg# The TAGs below are defined such that we never get into a situation 11125e3d74329Smrg# where we disable both kinds of libraries. Given conflicting 11126c582b7e3Smrg# choices, we go for a static library, that is the most portable, 11127c582b7e3Smrg# since we can't tell whether shared libraries were disabled because 11128c582b7e3Smrg# the user asked for that or because the platform doesn't support 11129c582b7e3Smrg# them. This is particularly important on AIX, because we don't 11130c582b7e3Smrg# support having both static and shared libraries enabled at the same 11131c582b7e3Smrg# time on that platform, so we default to a shared-only configuration. 11132c582b7e3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11133c582b7e3Smrg# configuration. But we'll never go from static-only to shared-only. 11134c582b7e3Smrg 11135c582b7e3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1113642a55b46Smrgbuild_libtool_libs=no 1113742a55b46Smrgbuild_old_libs=yes 11138c582b7e3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139c582b7e3Smrg 11140c582b7e3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1114142a55b46Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142c582b7e3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11143c582b7e3Smrg 11144c582b7e3Smrg# Local Variables: 11145c582b7e3Smrg# mode:shell-script 11146c582b7e3Smrg# sh-indentation:2 11147c582b7e3Smrg# End: 11148