1949d0342Smrg#! /usr/bin/env sh 2949d0342Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3949d0342Smrg## by inline-source v2019-02-19.15 4d5c3dbf1Smrg 5dc088bc7Smrg# libtool (GNU libtool) 2.5.4 6949d0342Smrg# Provide generalized library-building support services. 7d5c3dbf1Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8d5c3dbf1Smrg 9dc088bc7Smrg# Copyright (C) 1996-2019, 2021-2024 Free Software Foundation, Inc. 10d5c3dbf1Smrg# This is free software; see the source for copying conditions. There is NO 11d5c3dbf1Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12d5c3dbf1Smrg 13d5c3dbf1Smrg# GNU Libtool is free software; you can redistribute it and/or modify 149f606849Smrg# it under the terms of the GNU General Public License as published by 159f606849Smrg# the Free Software Foundation; either version 2 of the License, or 169f606849Smrg# (at your option) any later version. 179f606849Smrg# 18d5c3dbf1Smrg# As a special exception to the GNU General Public License, 19d5c3dbf1Smrg# if you distribute this file as part of a program or library that 20d5c3dbf1Smrg# is built using GNU Libtool, you may include this file under the 21d5c3dbf1Smrg# same distribution terms that you use for the rest of that program. 22d5c3dbf1Smrg# 23d5c3dbf1Smrg# GNU Libtool is distributed in the hope that it will be useful, but 249f606849Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 259f606849Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 269f606849Smrg# General Public License for more details. 279f606849Smrg# 289f606849Smrg# You should have received a copy of the GNU General Public License 29949d0342Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 309f606849Smrg 31949d0342Smrg 32949d0342SmrgPROGRAM=libtool 33949d0342SmrgPACKAGE=libtool 34dc088bc7SmrgVERSION=2.5.4 35dc088bc7Smrgpackage_revision=2.5.4 36949d0342Smrg 37949d0342Smrg 38949d0342Smrg## ------ ## 39949d0342Smrg## Usage. ## 40949d0342Smrg## ------ ## 41949d0342Smrg 42949d0342Smrg# Run './libtool --help' for help with using this script from the 43949d0342Smrg# command line. 44949d0342Smrg 45949d0342Smrg 46949d0342Smrg## ------------------------------- ## 47949d0342Smrg## User overridable command paths. ## 48949d0342Smrg## ------------------------------- ## 49949d0342Smrg 50949d0342Smrg# After configure completes, it has a better idea of some of the 51949d0342Smrg# shell tools we need than the defaults used by the functions shared 52949d0342Smrg# with bootstrap, so set those here where they can still be over- 53949d0342Smrg# ridden by the user, but otherwise take precedence. 54949d0342Smrg 55949d0342Smrg: ${AUTOCONF="autoconf"} 56949d0342Smrg: ${AUTOMAKE="automake"} 57949d0342Smrg 58949d0342Smrg 59949d0342Smrg## -------------------------- ## 60949d0342Smrg## Source external libraries. ## 61949d0342Smrg## -------------------------- ## 62949d0342Smrg 63949d0342Smrg# Much of our low-level functionality needs to be sourced from external 64949d0342Smrg# libraries, which are installed to $pkgauxdir. 65949d0342Smrg 66949d0342Smrg# Set a version string for this script. 67949d0342Smrgscriptversion=2019-02-19.15; # UTC 68949d0342Smrg 69949d0342Smrg# General shell script boiler plate, and helper functions. 70949d0342Smrg# Written by Gary V. Vaughan, 2004 71949d0342Smrg 72949d0342Smrg# This is free software. There is NO warranty; not even for 73949d0342Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74d5c3dbf1Smrg# 75dc088bc7Smrg# Copyright (C) 2004-2019, 2021, 2023-2024 Bootstrap Authors 76d5c3dbf1Smrg# 77949d0342Smrg# This file is dual licensed under the terms of the MIT license 78dc088bc7Smrg# <https://opensource.org/licenses/MIT>, and GPL version 2 or later 79dc088bc7Smrg# <https://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80949d0342Smrg# these licenses when using or redistributing this software or any of 81949d0342Smrg# the files within it. See the URLs above, or the file `LICENSE` 82949d0342Smrg# included in the Bootstrap distribution for the full license texts. 83949d0342Smrg 84949d0342Smrg# Please report bugs or propose patches to: 85949d0342Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 86949d0342Smrg 87949d0342Smrg 88949d0342Smrg## ------ ## 89949d0342Smrg## Usage. ## 90949d0342Smrg## ------ ## 91949d0342Smrg 92949d0342Smrg# Evaluate this file near the top of your script to gain access to 93949d0342Smrg# the functions and variables defined here: 94d5c3dbf1Smrg# 95949d0342Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96d5c3dbf1Smrg# 97949d0342Smrg# If you need to override any of the default environment variable 98949d0342Smrg# settings, do that before evaluating this file. 999f606849Smrg 100fba89afeSmrg 101949d0342Smrg## -------------------- ## 102949d0342Smrg## Shell normalisation. ## 103949d0342Smrg## -------------------- ## 104949d0342Smrg 105949d0342Smrg# Some shells need a little help to be as Bourne compatible as possible. 106949d0342Smrg# Before doing anything else, make sure all that help has been provided! 107949d0342Smrg 108949d0342SmrgDUALCASE=1; export DUALCASE # for MKS sh 109949d0342Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110fba89afeSmrg emulate sh 111fba89afeSmrg NULLCMD=: 112949d0342Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113fba89afeSmrg # is contrary to our usage. Disable this feature. 114fba89afeSmrg alias -g '${1+"$@"}'='"$@"' 1159f606849Smrg setopt NO_GLOB_SUBST 116fba89afeSmrgelse 117949d0342Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1189f606849Smrgfi 1199f606849Smrg 120949d0342Smrg# NLS nuisances: We save the old values in case they are required later. 121949d0342Smrg_G_user_locale= 122949d0342Smrg_G_safe_locale= 123949d0342Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124fba89afeSmrgdo 125949d0342Smrg eval "if test set = \"\${$_G_var+set}\"; then 126949d0342Smrg save_$_G_var=\$$_G_var 127949d0342Smrg $_G_var=C 128949d0342Smrg export $_G_var 129949d0342Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130949d0342Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131fba89afeSmrg fi" 132fba89afeSmrgdone 133949d0342Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134949d0342Smrg# in case the environment reset is needed later and the $save_* variant is not 135949d0342Smrg# defined (see the code above). 136d5c3dbf1SmrgLC_ALL=C 137d5c3dbf1SmrgLANGUAGE=C 138d5c3dbf1Smrgexport LANGUAGE LC_ALL 139fba89afeSmrg 140949d0342Smrg# Make sure IFS has a sensible default 141949d0342Smrgsp=' ' 142949d0342Smrgnl=' 143949d0342Smrg' 144949d0342SmrgIFS="$sp $nl" 145949d0342Smrg 146dc088bc7Smrg# There are apparently some systems that use ';' as a PATH separator! 147949d0342Smrgif test "${PATH_SEPARATOR+set}" != set; then 148949d0342Smrg PATH_SEPARATOR=: 149949d0342Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 150949d0342Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 151949d0342Smrg PATH_SEPARATOR=';' 152949d0342Smrg } 153949d0342Smrgfi 154d5c3dbf1Smrg 155d5c3dbf1Smrg 156949d0342Smrg# func_unset VAR 157949d0342Smrg# -------------- 158949d0342Smrg# Portably unset VAR. 159949d0342Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160949d0342Smrg# status if VAR is already unset, which might be problematic if the 161949d0342Smrg# statement is used at the end of a function (thus poisoning its return 162949d0342Smrg# value) or when 'set -e' is active (causing even a spurious abort of 163949d0342Smrg# the script in this case). 164949d0342Smrgfunc_unset () 165949d0342Smrg{ 166949d0342Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167949d0342Smrg} 168d5c3dbf1Smrg 169d5c3dbf1Smrg 170949d0342Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171949d0342Smrgfunc_unset CDPATH 172d5c3dbf1Smrg 173949d0342Smrg# Make sure ${,E,F}GREP behave sanely. 174949d0342Smrgfunc_unset GREP_OPTIONS 175d5c3dbf1Smrg 1769f606849Smrg 177949d0342Smrg## ------------------------- ## 178949d0342Smrg## Locate command utilities. ## 179949d0342Smrg## ------------------------- ## 1809f606849Smrg 181d5c3dbf1Smrg 182949d0342Smrg# func_executable_p FILE 183949d0342Smrg# ---------------------- 184949d0342Smrg# Check that FILE is an executable regular file. 185949d0342Smrgfunc_executable_p () 186cdbfa18aSmrg{ 187949d0342Smrg test -f "$1" && test -x "$1" 188949d0342Smrg} 189cdbfa18aSmrg 190cdbfa18aSmrg 191949d0342Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 192949d0342Smrg# -------------------------------------------- 193949d0342Smrg# Search for either a program that responds to --version with output 194949d0342Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 195949d0342Smrg# trying all the directories in PATH with each of the elements of 196949d0342Smrg# PROGS_LIST. 197949d0342Smrg# 198949d0342Smrg# CHECK_FUNC should accept the path to a candidate program, and 199949d0342Smrg# set $func_check_prog_result if it truncates its output less than 200949d0342Smrg# $_G_path_prog_max characters. 201949d0342Smrgfunc_path_progs () 202cdbfa18aSmrg{ 203949d0342Smrg _G_progs_list=$1 204949d0342Smrg _G_check_func=$2 205949d0342Smrg _G_PATH=${3-"$PATH"} 206949d0342Smrg 207949d0342Smrg _G_path_prog_max=0 208949d0342Smrg _G_path_prog_found=false 209949d0342Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 210949d0342Smrg for _G_dir in $_G_PATH; do 211949d0342Smrg IFS=$_G_save_IFS 212949d0342Smrg test -z "$_G_dir" && _G_dir=. 213949d0342Smrg for _G_prog_name in $_G_progs_list; do 214949d0342Smrg for _exeext in '' .EXE; do 215949d0342Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 216949d0342Smrg func_executable_p "$_G_path_prog" || continue 217949d0342Smrg case `"$_G_path_prog" --version 2>&1` in 218949d0342Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 219949d0342Smrg *) $_G_check_func $_G_path_prog 220949d0342Smrg func_path_progs_result=$func_check_prog_result 221949d0342Smrg ;; 222949d0342Smrg esac 223949d0342Smrg $_G_path_prog_found && break 3 224949d0342Smrg done 225949d0342Smrg done 226949d0342Smrg done 227949d0342Smrg IFS=$_G_save_IFS 228949d0342Smrg test -z "$func_path_progs_result" && { 229949d0342Smrg echo "no acceptable sed could be found in \$PATH" >&2 230949d0342Smrg exit 1 231949d0342Smrg } 232949d0342Smrg} 233cdbfa18aSmrg 234cdbfa18aSmrg 235949d0342Smrg# We want to be able to use the functions in this file before configure 236949d0342Smrg# has figured out where the best binaries are kept, which means we have 237949d0342Smrg# to search for them ourselves - except when the results are already set 238949d0342Smrg# where we skip the searches. 239cdbfa18aSmrg 240949d0342Smrg# Unless the user overrides by setting SED, search the path for either GNU 241949d0342Smrg# sed, or the sed that truncates its output the least. 242949d0342Smrgtest -z "$SED" && { 243949d0342Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 244949d0342Smrg for _G_i in 1 2 3 4 5 6 7; do 245949d0342Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 246949d0342Smrg done 247949d0342Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 248949d0342Smrg _G_sed_script= 249cdbfa18aSmrg 250949d0342Smrg func_check_prog_sed () 251949d0342Smrg { 252949d0342Smrg _G_path_prog=$1 2539f606849Smrg 254949d0342Smrg _G_count=0 255949d0342Smrg printf 0123456789 >conftest.in 256949d0342Smrg while : 257949d0342Smrg do 258949d0342Smrg cat conftest.in conftest.in >conftest.tmp 259949d0342Smrg mv conftest.tmp conftest.in 260949d0342Smrg cp conftest.in conftest.nl 261949d0342Smrg echo '' >> conftest.nl 262949d0342Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 263949d0342Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 264949d0342Smrg _G_count=`expr $_G_count + 1` 265949d0342Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 266949d0342Smrg # Best one so far, save it but keep looking for a better one 267949d0342Smrg func_check_prog_result=$_G_path_prog 268949d0342Smrg _G_path_prog_max=$_G_count 269949d0342Smrg fi 270949d0342Smrg # 10*(2^10) chars as input seems more than enough 271949d0342Smrg test 10 -lt "$_G_count" && break 272949d0342Smrg done 273949d0342Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 274949d0342Smrg } 275d5c3dbf1Smrg 276949d0342Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 277949d0342Smrg rm -f conftest.sed 278949d0342Smrg SED=$func_path_progs_result 279949d0342Smrg} 280d5c3dbf1Smrg 281949d0342Smrg 282949d0342Smrg# Unless the user overrides by setting GREP, search the path for either GNU 283949d0342Smrg# grep, or the grep that truncates its output the least. 284949d0342Smrgtest -z "$GREP" && { 285949d0342Smrg func_check_prog_grep () 286949d0342Smrg { 287949d0342Smrg _G_path_prog=$1 288949d0342Smrg 289949d0342Smrg _G_count=0 290949d0342Smrg _G_path_prog_max=0 291949d0342Smrg printf 0123456789 >conftest.in 292949d0342Smrg while : 293949d0342Smrg do 294949d0342Smrg cat conftest.in conftest.in >conftest.tmp 295949d0342Smrg mv conftest.tmp conftest.in 296949d0342Smrg cp conftest.in conftest.nl 297949d0342Smrg echo 'GREP' >> conftest.nl 298949d0342Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 299949d0342Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 300949d0342Smrg _G_count=`expr $_G_count + 1` 301949d0342Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 302949d0342Smrg # Best one so far, save it but keep looking for a better one 303949d0342Smrg func_check_prog_result=$_G_path_prog 304949d0342Smrg _G_path_prog_max=$_G_count 305949d0342Smrg fi 306949d0342Smrg # 10*(2^10) chars as input seems more than enough 307949d0342Smrg test 10 -lt "$_G_count" && break 308949d0342Smrg done 309949d0342Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 310949d0342Smrg } 311949d0342Smrg 312949d0342Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 313949d0342Smrg GREP=$func_path_progs_result 314949d0342Smrg} 315949d0342Smrg 316949d0342Smrg 317949d0342Smrg## ------------------------------- ## 318949d0342Smrg## User overridable command paths. ## 319949d0342Smrg## ------------------------------- ## 320949d0342Smrg 321949d0342Smrg# All uppercase variable names are used for environment variables. These 322949d0342Smrg# variables can be overridden by the user before calling a script that 323949d0342Smrg# uses them if a suitable command of that name is not already available 324949d0342Smrg# in the command search PATH. 325949d0342Smrg 326949d0342Smrg: ${CP="cp -f"} 327949d0342Smrg: ${ECHO="printf %s\n"} 328949d0342Smrg: ${EGREP="$GREP -E"} 329949d0342Smrg: ${FGREP="$GREP -F"} 330949d0342Smrg: ${LN_S="ln -s"} 331949d0342Smrg: ${MAKE="make"} 332949d0342Smrg: ${MKDIR="mkdir"} 333949d0342Smrg: ${MV="mv -f"} 334949d0342Smrg: ${RM="rm -f"} 335949d0342Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336949d0342Smrg 337949d0342Smrg 338949d0342Smrg## -------------------- ## 339949d0342Smrg## Useful sed snippets. ## 340949d0342Smrg## -------------------- ## 341949d0342Smrg 342949d0342Smrgsed_dirname='s|/[^/]*$||' 343949d0342Smrgsed_basename='s|^.*/||' 344949d0342Smrg 345949d0342Smrg# Sed substitution that helps us do robust quoting. It backslashifies 346949d0342Smrg# metacharacters that are still active within double-quoted strings. 347949d0342Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348949d0342Smrg 349949d0342Smrg# Same as above, but do not quote variable references. 350949d0342Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351949d0342Smrg 352949d0342Smrg# Sed substitution that turns a string into a regex matching for the 353949d0342Smrg# string literally. 354949d0342Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355949d0342Smrg 356949d0342Smrg# Sed substitution that converts a w32 file name or path 357949d0342Smrg# that contains forward slashes, into one that contains 358949d0342Smrg# (escaped) backslashes. A very naive implementation. 359949d0342Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 360949d0342Smrg 361949d0342Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 362949d0342Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 363949d0342Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 364949d0342Smrg# expansion. Since each input '\' is now two '\'s, look for any number 365949d0342Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 366949d0342Smrg_G_bs='\\' 367949d0342Smrg_G_bs2='\\\\' 368949d0342Smrg_G_bs4='\\\\\\\\' 369949d0342Smrg_G_dollar='\$' 370949d0342Smrgsed_double_backslash="\ 371949d0342Smrg s/$_G_bs4/&\\ 372949d0342Smrg/g 373949d0342Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 374949d0342Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 375949d0342Smrg s/\n//g" 376949d0342Smrg 377949d0342Smrg# require_check_ifs_backslash 378949d0342Smrg# --------------------------- 379949d0342Smrg# Check if we can use backslash as IFS='\' separator, and set 380949d0342Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 381949d0342Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382949d0342Smrgfunc_require_check_ifs_backslash () 383d5c3dbf1Smrg{ 384949d0342Smrg _G_save_IFS=$IFS 385949d0342Smrg IFS='\' 386949d0342Smrg _G_check_ifs_backshlash='a\\b' 387949d0342Smrg for _G_i in $_G_check_ifs_backshlash 388949d0342Smrg do 389949d0342Smrg case $_G_i in 390949d0342Smrg a) 391949d0342Smrg check_ifs_backshlash_broken=false 392d5c3dbf1Smrg ;; 393949d0342Smrg '') 394949d0342Smrg break 395d5c3dbf1Smrg ;; 396949d0342Smrg *) 397949d0342Smrg check_ifs_backshlash_broken=: 398949d0342Smrg break 399d5c3dbf1Smrg ;; 400d5c3dbf1Smrg esac 401d5c3dbf1Smrg done 402949d0342Smrg IFS=$_G_save_IFS 403949d0342Smrg require_check_ifs_backslash=: 404d5c3dbf1Smrg} 405d5c3dbf1Smrg 406d5c3dbf1Smrg 407949d0342Smrg## ----------------- ## 408949d0342Smrg## Global variables. ## 409949d0342Smrg## ----------------- ## 410d5c3dbf1Smrg 411949d0342Smrg# Except for the global variables explicitly listed below, the following 412949d0342Smrg# functions in the '^func_' namespace, and the '^require_' namespace 413949d0342Smrg# variables initialised in the 'Resource management' section, sourcing 414949d0342Smrg# this file will not pollute your global namespace with anything 415949d0342Smrg# else. There's no portable way to scope variables in Bourne shell 416949d0342Smrg# though, so actually running these functions will sometimes place 417949d0342Smrg# results into a variable named after the function, and often use 418949d0342Smrg# temporary variables in the '^_G_' namespace. If you are careful to 419949d0342Smrg# avoid using those namespaces casually in your sourcing script, things 420949d0342Smrg# should continue to work as you expect. And, of course, you can freely 421949d0342Smrg# overwrite any of the functions or variables defined here before 422949d0342Smrg# calling anything to customize them. 423949d0342Smrg 424949d0342SmrgEXIT_SUCCESS=0 425949d0342SmrgEXIT_FAILURE=1 426949d0342SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 427949d0342SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428949d0342Smrg 429949d0342Smrg# Allow overriding, eg assuming that you follow the convention of 430949d0342Smrg# putting '$debug_cmd' at the start of all your functions, you can get 431949d0342Smrg# bash to show function call trace with: 432949d0342Smrg# 433949d0342Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 434949d0342Smrgdebug_cmd=${debug_cmd-":"} 435949d0342Smrgexit_cmd=: 436949d0342Smrg 437949d0342Smrg# By convention, finish your script with: 438949d0342Smrg# 439949d0342Smrg# exit $exit_status 440949d0342Smrg# 441949d0342Smrg# so that you can set exit_status to non-zero if you want to indicate 442949d0342Smrg# something went wrong during execution without actually bailing out at 443949d0342Smrg# the point of failure. 444949d0342Smrgexit_status=$EXIT_SUCCESS 445d5c3dbf1Smrg 446949d0342Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 447949d0342Smrg# is ksh but when the shell is invoked as "sh" and the current value of 448949d0342Smrg# the _XPG environment variable is not equal to 1 (one), the special 449949d0342Smrg# positional parameter $0, within a function call, is the name of the 450949d0342Smrg# function. 451949d0342Smrgprogpath=$0 452949d0342Smrg 453949d0342Smrg# The name of this program. 454949d0342Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455d5c3dbf1Smrg 456949d0342Smrg# Make sure we have an absolute progpath for reexecution: 457d5c3dbf1Smrgcase $progpath in 458d5c3dbf1Smrg [\\/]*|[A-Za-z]:\\*) ;; 459d5c3dbf1Smrg *[\\/]*) 460949d0342Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461d5c3dbf1Smrg progdir=`cd "$progdir" && pwd` 462949d0342Smrg progpath=$progdir/$progname 463d5c3dbf1Smrg ;; 464d5c3dbf1Smrg *) 465949d0342Smrg _G_IFS=$IFS 466cdbfa18aSmrg IFS=${PATH_SEPARATOR-:} 467d5c3dbf1Smrg for progdir in $PATH; do 468949d0342Smrg IFS=$_G_IFS 469d5c3dbf1Smrg test -x "$progdir/$progname" && break 470d5c3dbf1Smrg done 471949d0342Smrg IFS=$_G_IFS 472d5c3dbf1Smrg test -n "$progdir" || progdir=`pwd` 473949d0342Smrg progpath=$progdir/$progname 474d5c3dbf1Smrg ;; 475d5c3dbf1Smrgesac 476d5c3dbf1Smrg 477d5c3dbf1Smrg 478949d0342Smrg## ----------------- ## 479949d0342Smrg## Standard options. ## 480949d0342Smrg## ----------------- ## 481cdbfa18aSmrg 482949d0342Smrg# The following options affect the operation of the functions defined 483949d0342Smrg# below, and should be set appropriately depending on run-time para- 484949d0342Smrg# meters passed on the command line. 485d5c3dbf1Smrg 486d5c3dbf1Smrgopt_dry_run=false 487d5c3dbf1Smrgopt_quiet=false 488d5c3dbf1Smrgopt_verbose=false 489d5c3dbf1Smrg 490949d0342Smrg# Categories 'all' and 'none' are always available. Append any others 491949d0342Smrg# you will pass as the first argument to func_warning from your own 492949d0342Smrg# code. 493949d0342Smrgwarning_categories= 494d5c3dbf1Smrg 495949d0342Smrg# By default, display warnings according to 'opt_warning_types'. Set 496949d0342Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 497949d0342Smrg# treat the next displayed warning as a fatal error. 498949d0342Smrgwarning_func=func_warn_and_continue 499d5c3dbf1Smrg 500949d0342Smrg# Set to 'all' to display all warnings, 'none' to suppress all 501949d0342Smrg# warnings, or a space delimited list of some subset of 502949d0342Smrg# 'warning_categories' to display only the listed warnings. 503949d0342Smrgopt_warning_types=all 504d5c3dbf1Smrg 505d5c3dbf1Smrg 506949d0342Smrg## -------------------- ## 507949d0342Smrg## Resource management. ## 508949d0342Smrg## -------------------- ## 509d5c3dbf1Smrg 510949d0342Smrg# This section contains definitions for functions that each ensure a 511949d0342Smrg# particular resource (a file, or a non-empty configuration variable for 512949d0342Smrg# example) is available, and if appropriate to extract default values 513949d0342Smrg# from pertinent package files. Call them using their associated 514949d0342Smrg# 'require_*' variable to ensure that they are executed, at most, once. 515949d0342Smrg# 516949d0342Smrg# It's entirely deliberate that calling these functions can set 517949d0342Smrg# variables that don't obey the namespace limitations obeyed by the rest 518949d0342Smrg# of this file, in order that that they be as useful as possible to 519949d0342Smrg# callers. 520d5c3dbf1Smrg 521d5c3dbf1Smrg 522949d0342Smrg# require_term_colors 523949d0342Smrg# ------------------- 524949d0342Smrg# Allow display of bold text on terminals that support it. 525949d0342Smrgrequire_term_colors=func_require_term_colors 526949d0342Smrgfunc_require_term_colors () 527d5c3dbf1Smrg{ 528949d0342Smrg $debug_cmd 529949d0342Smrg 530949d0342Smrg test -t 1 && { 531949d0342Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 532949d0342Smrg # precedence, because most terminfo databases neglect to describe 533949d0342Smrg # whether color sequences are supported. 534949d0342Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 535949d0342Smrg 536949d0342Smrg if test 1 = "$USE_ANSI_COLORS"; then 537949d0342Smrg # Standard ANSI escape sequences 538949d0342Smrg tc_reset='[0m' 539949d0342Smrg tc_bold='[1m'; tc_standout='[7m' 540949d0342Smrg tc_red='[31m'; tc_green='[32m' 541949d0342Smrg tc_blue='[34m'; tc_cyan='[36m' 542949d0342Smrg else 543949d0342Smrg # Otherwise trust the terminfo database after all. 544949d0342Smrg test -n "`tput sgr0 2>/dev/null`" && { 545949d0342Smrg tc_reset=`tput sgr0` 546949d0342Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 547949d0342Smrg tc_standout=$tc_bold 548949d0342Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 549949d0342Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 550949d0342Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 551949d0342Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 552949d0342Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 553949d0342Smrg } 554949d0342Smrg fi 555949d0342Smrg } 556d5c3dbf1Smrg 557949d0342Smrg require_term_colors=: 558d5c3dbf1Smrg} 559d5c3dbf1Smrg 560d5c3dbf1Smrg 561949d0342Smrg## ----------------- ## 562949d0342Smrg## Function library. ## 563949d0342Smrg## ----------------- ## 564d5c3dbf1Smrg 565949d0342Smrg# This section contains a variety of useful functions to call in your 566949d0342Smrg# scripts. Take note of the portable wrappers for features provided by 567949d0342Smrg# some modern shells, which will fall back to slower equivalents on 568949d0342Smrg# less featureful shells. 569d5c3dbf1Smrg 570949d0342Smrg 571949d0342Smrg# func_append VAR VALUE 572949d0342Smrg# --------------------- 573949d0342Smrg# Append VALUE onto the existing contents of VAR. 574949d0342Smrg 575949d0342Smrg # We should try to minimise forks, especially on Windows where they are 576949d0342Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 577949d0342Smrg # being used: 578949d0342Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 579949d0342Smrg : ${_G_HAVE_ARITH_OP="yes"} 580949d0342Smrg : ${_G_HAVE_XSI_OPS="yes"} 581949d0342Smrg # The += operator was introduced in bash 3.1 582949d0342Smrg case $BASH_VERSION in 583949d0342Smrg [12].* | 3.0 | 3.0*) ;; 584949d0342Smrg *) 585949d0342Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 586949d0342Smrg ;; 587949d0342Smrg esac 588949d0342Smrg fi 589949d0342Smrg 590949d0342Smrg # _G_HAVE_PLUSEQ_OP 591949d0342Smrg # Can be empty, in which case the shell is probed, "yes" if += is 592dc088bc7Smrg # usable or anything else if it does not work. 593949d0342Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 594949d0342Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 595949d0342Smrg && _G_HAVE_PLUSEQ_OP=yes 596949d0342Smrg 597949d0342Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 598949d0342Smrgthen 599949d0342Smrg # This is an XSI compatible shell, allowing a faster implementation... 600949d0342Smrg eval 'func_append () 601949d0342Smrg { 602949d0342Smrg $debug_cmd 603949d0342Smrg 604949d0342Smrg eval "$1+=\$2" 605949d0342Smrg }' 606949d0342Smrgelse 607949d0342Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 608949d0342Smrg func_append () 609949d0342Smrg { 610949d0342Smrg $debug_cmd 611949d0342Smrg 612949d0342Smrg eval "$1=\$$1\$2" 613949d0342Smrg } 614949d0342Smrgfi 615949d0342Smrg 616949d0342Smrg 617949d0342Smrg# func_append_quoted VAR VALUE 618949d0342Smrg# ---------------------------- 619949d0342Smrg# Quote VALUE and append to the end of shell variable VAR, separated 620949d0342Smrg# by a space. 621949d0342Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 622949d0342Smrg eval 'func_append_quoted () 623949d0342Smrg { 624949d0342Smrg $debug_cmd 625949d0342Smrg 626949d0342Smrg func_quote_arg pretty "$2" 627949d0342Smrg eval "$1+=\\ \$func_quote_arg_result" 628949d0342Smrg }' 629949d0342Smrgelse 630949d0342Smrg func_append_quoted () 631949d0342Smrg { 632949d0342Smrg $debug_cmd 633949d0342Smrg 634949d0342Smrg func_quote_arg pretty "$2" 635949d0342Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 636949d0342Smrg } 637949d0342Smrgfi 638949d0342Smrg 639949d0342Smrg 640949d0342Smrg# func_append_uniq VAR VALUE 641949d0342Smrg# -------------------------- 642949d0342Smrg# Append unique VALUE onto the existing contents of VAR, assuming 643949d0342Smrg# entries are delimited by the first character of VALUE. For example: 644949d0342Smrg# 645949d0342Smrg# func_append_uniq options " --another-option option-argument" 646949d0342Smrg# 647949d0342Smrg# will only append to $options if " --another-option option-argument " 648949d0342Smrg# is not already present somewhere in $options already (note spaces at 649949d0342Smrg# each end implied by leading space in second argument). 650949d0342Smrgfunc_append_uniq () 651949d0342Smrg{ 652949d0342Smrg $debug_cmd 653949d0342Smrg 654949d0342Smrg eval _G_current_value='`$ECHO $'$1'`' 655949d0342Smrg _G_delim=`expr "$2" : '\(.\)'` 656949d0342Smrg 657949d0342Smrg case $_G_delim$_G_current_value$_G_delim in 658949d0342Smrg *"$2$_G_delim"*) ;; 659949d0342Smrg *) func_append "$@" ;; 660949d0342Smrg esac 661949d0342Smrg} 662949d0342Smrg 663949d0342Smrg 664949d0342Smrg# func_arith TERM... 665949d0342Smrg# ------------------ 666949d0342Smrg# Set func_arith_result to the result of evaluating TERMs. 667949d0342Smrg test -z "$_G_HAVE_ARITH_OP" \ 668949d0342Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 669949d0342Smrg && _G_HAVE_ARITH_OP=yes 670949d0342Smrg 671949d0342Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 672949d0342Smrg eval 'func_arith () 673949d0342Smrg { 674949d0342Smrg $debug_cmd 675949d0342Smrg 676949d0342Smrg func_arith_result=$(( $* )) 677949d0342Smrg }' 678949d0342Smrgelse 679949d0342Smrg func_arith () 680949d0342Smrg { 681949d0342Smrg $debug_cmd 682949d0342Smrg 683949d0342Smrg func_arith_result=`expr "$@"` 684949d0342Smrg } 685949d0342Smrgfi 686949d0342Smrg 687949d0342Smrg 688949d0342Smrg# func_basename FILE 689949d0342Smrg# ------------------ 690949d0342Smrg# Set func_basename_result to FILE with everything up to and including 691949d0342Smrg# the last / stripped. 692949d0342Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 693949d0342Smrg # If this shell supports suffix pattern removal, then use it to avoid 694949d0342Smrg # forking. Hide the definitions single quotes in case the shell chokes 695949d0342Smrg # on unsupported syntax... 696949d0342Smrg _b='func_basename_result=${1##*/}' 697949d0342Smrg _d='case $1 in 698949d0342Smrg */*) func_dirname_result=${1%/*}$2 ;; 699949d0342Smrg * ) func_dirname_result=$3 ;; 700949d0342Smrg esac' 701949d0342Smrg 702949d0342Smrgelse 703949d0342Smrg # ...otherwise fall back to using sed. 704949d0342Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 705949d0342Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 706949d0342Smrg if test "X$func_dirname_result" = "X$1"; then 707949d0342Smrg func_dirname_result=$3 708949d0342Smrg else 709949d0342Smrg func_append func_dirname_result "$2" 710949d0342Smrg fi' 711949d0342Smrgfi 712949d0342Smrg 713949d0342Smrgeval 'func_basename () 714949d0342Smrg{ 715949d0342Smrg $debug_cmd 716949d0342Smrg 717949d0342Smrg '"$_b"' 718949d0342Smrg}' 719949d0342Smrg 720949d0342Smrg 721949d0342Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 722949d0342Smrg# ------------------------------------------- 723949d0342Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 724949d0342Smrg# otherwise set result to NONDIR_REPLACEMENT. 725949d0342Smrgeval 'func_dirname () 726949d0342Smrg{ 727949d0342Smrg $debug_cmd 728949d0342Smrg 729949d0342Smrg '"$_d"' 730949d0342Smrg}' 731949d0342Smrg 732949d0342Smrg 733949d0342Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 734949d0342Smrg# -------------------------------------------------------- 735949d0342Smrg# Perform func_basename and func_dirname in a single function 736949d0342Smrg# call: 737949d0342Smrg# dirname: Compute the dirname of FILE. If nonempty, 738949d0342Smrg# add APPEND to the result, otherwise set result 739949d0342Smrg# to NONDIR_REPLACEMENT. 740949d0342Smrg# value returned in "$func_dirname_result" 741949d0342Smrg# basename: Compute filename of FILE. 742dc088bc7Smrg# value returned in "$func_basename_result" 743949d0342Smrg# For efficiency, we do not delegate to the functions above but instead 744949d0342Smrg# duplicate the functionality here. 745949d0342Smrgeval 'func_dirname_and_basename () 746949d0342Smrg{ 747949d0342Smrg $debug_cmd 748949d0342Smrg 749949d0342Smrg '"$_b"' 750949d0342Smrg '"$_d"' 751949d0342Smrg}' 752949d0342Smrg 753949d0342Smrg 754949d0342Smrg# func_echo ARG... 755949d0342Smrg# ---------------- 756949d0342Smrg# Echo program name prefixed message. 757949d0342Smrgfunc_echo () 758949d0342Smrg{ 759949d0342Smrg $debug_cmd 760949d0342Smrg 761949d0342Smrg _G_message=$* 762949d0342Smrg 763949d0342Smrg func_echo_IFS=$IFS 764949d0342Smrg IFS=$nl 765949d0342Smrg for _G_line in $_G_message; do 766949d0342Smrg IFS=$func_echo_IFS 767949d0342Smrg $ECHO "$progname: $_G_line" 768949d0342Smrg done 769949d0342Smrg IFS=$func_echo_IFS 770949d0342Smrg} 771949d0342Smrg 772949d0342Smrg 773949d0342Smrg# func_echo_all ARG... 774949d0342Smrg# -------------------- 775949d0342Smrg# Invoke $ECHO with all args, space-separated. 776949d0342Smrgfunc_echo_all () 777949d0342Smrg{ 778949d0342Smrg $ECHO "$*" 779949d0342Smrg} 780949d0342Smrg 781949d0342Smrg 782949d0342Smrg# func_echo_infix_1 INFIX ARG... 783949d0342Smrg# ------------------------------ 784949d0342Smrg# Echo program name, followed by INFIX on the first line, with any 785949d0342Smrg# additional lines not showing INFIX. 786949d0342Smrgfunc_echo_infix_1 () 787949d0342Smrg{ 788949d0342Smrg $debug_cmd 789949d0342Smrg 790949d0342Smrg $require_term_colors 791949d0342Smrg 792949d0342Smrg _G_infix=$1; shift 793949d0342Smrg _G_indent=$_G_infix 794949d0342Smrg _G_prefix="$progname: $_G_infix: " 795949d0342Smrg _G_message=$* 796949d0342Smrg 797949d0342Smrg # Strip color escape sequences before counting printable length 798949d0342Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 799949d0342Smrg do 800949d0342Smrg test -n "$_G_tc" && { 801949d0342Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 802949d0342Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 803949d0342Smrg } 804949d0342Smrg done 805949d0342Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 806949d0342Smrg 807949d0342Smrg func_echo_infix_1_IFS=$IFS 808949d0342Smrg IFS=$nl 809949d0342Smrg for _G_line in $_G_message; do 810949d0342Smrg IFS=$func_echo_infix_1_IFS 811949d0342Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 812949d0342Smrg _G_prefix=$_G_indent 813949d0342Smrg done 814949d0342Smrg IFS=$func_echo_infix_1_IFS 815949d0342Smrg} 816949d0342Smrg 817949d0342Smrg 818949d0342Smrg# func_error ARG... 819949d0342Smrg# ----------------- 820949d0342Smrg# Echo program name prefixed message to standard error. 821949d0342Smrgfunc_error () 822949d0342Smrg{ 823949d0342Smrg $debug_cmd 824949d0342Smrg 825949d0342Smrg $require_term_colors 826949d0342Smrg 827949d0342Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 828949d0342Smrg} 829949d0342Smrg 830949d0342Smrg 831949d0342Smrg# func_fatal_error ARG... 832949d0342Smrg# ----------------------- 833949d0342Smrg# Echo program name prefixed message to standard error, and exit. 834949d0342Smrgfunc_fatal_error () 835949d0342Smrg{ 836949d0342Smrg $debug_cmd 837949d0342Smrg 838949d0342Smrg func_error "$*" 839949d0342Smrg exit $EXIT_FAILURE 840949d0342Smrg} 841949d0342Smrg 842949d0342Smrg 843949d0342Smrg# func_grep EXPRESSION FILENAME 844949d0342Smrg# ----------------------------- 845949d0342Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 846949d0342Smrgfunc_grep () 847d5c3dbf1Smrg{ 848949d0342Smrg $debug_cmd 849949d0342Smrg 850949d0342Smrg $GREP "$1" "$2" >/dev/null 2>&1 851949d0342Smrg} 852949d0342Smrg 853d5c3dbf1Smrg 854949d0342Smrg# func_len STRING 855949d0342Smrg# --------------- 856949d0342Smrg# Set func_len_result to the length of STRING. STRING may not 857949d0342Smrg# start with a hyphen. 858949d0342Smrg test -z "$_G_HAVE_XSI_OPS" \ 859949d0342Smrg && (eval 'x=a/b/c; 860949d0342Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 861949d0342Smrg && _G_HAVE_XSI_OPS=yes 862949d0342Smrg 863949d0342Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 864949d0342Smrg eval 'func_len () 865949d0342Smrg { 866949d0342Smrg $debug_cmd 867949d0342Smrg 868949d0342Smrg func_len_result=${#1} 869949d0342Smrg }' 870949d0342Smrgelse 871949d0342Smrg func_len () 872949d0342Smrg { 873949d0342Smrg $debug_cmd 874949d0342Smrg 875949d0342Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 876949d0342Smrg } 877949d0342Smrgfi 878949d0342Smrg 879949d0342Smrg 880949d0342Smrg# func_mkdir_p DIRECTORY-PATH 881949d0342Smrg# --------------------------- 882949d0342Smrg# Make sure the entire path to DIRECTORY-PATH is available. 883949d0342Smrgfunc_mkdir_p () 884949d0342Smrg{ 885949d0342Smrg $debug_cmd 886d5c3dbf1Smrg 887949d0342Smrg _G_directory_path=$1 888949d0342Smrg _G_dir_list= 889949d0342Smrg 890949d0342Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 891949d0342Smrg 892949d0342Smrg # Protect directory names starting with '-' 893949d0342Smrg case $_G_directory_path in 894949d0342Smrg -*) _G_directory_path=./$_G_directory_path ;; 895d5c3dbf1Smrg esac 896d5c3dbf1Smrg 897d5c3dbf1Smrg # While some portion of DIR does not yet exist... 898949d0342Smrg while test ! -d "$_G_directory_path"; do 899d5c3dbf1Smrg # ...make a list in topmost first order. Use a colon delimited 900dc088bc7Smrg # list in case some portion of path contains whitespace. 901949d0342Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 902d5c3dbf1Smrg 903d5c3dbf1Smrg # If the last portion added has no slash in it, the list is done 904949d0342Smrg case $_G_directory_path in */*) ;; *) break ;; esac 905d5c3dbf1Smrg 906d5c3dbf1Smrg # ...otherwise throw away the child directory and loop 907949d0342Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908d5c3dbf1Smrg done 909949d0342Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910d5c3dbf1Smrg 911949d0342Smrg func_mkdir_p_IFS=$IFS; IFS=: 912949d0342Smrg for _G_dir in $_G_dir_list; do 913949d0342Smrg IFS=$func_mkdir_p_IFS 914949d0342Smrg # mkdir can fail with a 'File exist' error if two processes 915d5c3dbf1Smrg # try to create one of the directories concurrently. Don't 916d5c3dbf1Smrg # stop in that case! 917949d0342Smrg $MKDIR "$_G_dir" 2>/dev/null || : 918d5c3dbf1Smrg done 919949d0342Smrg IFS=$func_mkdir_p_IFS 920d5c3dbf1Smrg 921d5c3dbf1Smrg # Bail out if we (or some other process) failed to create a directory. 922949d0342Smrg test -d "$_G_directory_path" || \ 923949d0342Smrg func_fatal_error "Failed to create '$1'" 924d5c3dbf1Smrg fi 925d5c3dbf1Smrg} 9269f606849Smrg 9279f606849Smrg 928949d0342Smrg# func_mktempdir [BASENAME] 929949d0342Smrg# ------------------------- 9309f606849Smrg# Make a temporary directory that won't clash with other running 9319f606849Smrg# libtool processes, and avoids race conditions if possible. If 932949d0342Smrg# given, BASENAME is the basename for that directory. 9339f606849Smrgfunc_mktempdir () 9349f606849Smrg{ 935949d0342Smrg $debug_cmd 9369f606849Smrg 937949d0342Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938949d0342Smrg 939949d0342Smrg if test : = "$opt_dry_run"; then 9409f606849Smrg # Return a directory name, but don't create it in dry-run mode 941949d0342Smrg _G_tmpdir=$_G_template-$$ 9429f606849Smrg else 9439f606849Smrg 9449f606849Smrg # If mktemp works, use that first and foremost 945949d0342Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9469f606849Smrg 947949d0342Smrg if test ! -d "$_G_tmpdir"; then 948d5c3dbf1Smrg # Failing that, at least try and use $RANDOM to avoid a race 949949d0342Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9509f606849Smrg 951949d0342Smrg func_mktempdir_umask=`umask` 952d5c3dbf1Smrg umask 0077 953949d0342Smrg $MKDIR "$_G_tmpdir" 954949d0342Smrg umask $func_mktempdir_umask 9559f606849Smrg fi 9569f606849Smrg 9579f606849Smrg # If we're not in dry-run mode, bomb out on failure 958949d0342Smrg test -d "$_G_tmpdir" || \ 959949d0342Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9609f606849Smrg fi 9619f606849Smrg 962949d0342Smrg $ECHO "$_G_tmpdir" 9639f606849Smrg} 9649f606849Smrg 9659f606849Smrg 966949d0342Smrg# func_normal_abspath PATH 967949d0342Smrg# ------------------------ 968949d0342Smrg# Remove doubled-up and trailing slashes, "." path components, 969949d0342Smrg# and cancel out any ".." path components in PATH after making 970949d0342Smrg# it an absolute path. 971949d0342Smrgfunc_normal_abspath () 9729f606849Smrg{ 973949d0342Smrg $debug_cmd 974949d0342Smrg 975949d0342Smrg # These SED scripts presuppose an absolute path with a trailing slash. 976949d0342Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 977949d0342Smrg _G_pathcdr='s|^/[^/]*||' 978949d0342Smrg _G_removedotparts=':dotsl 979949d0342Smrg s|/\./|/|g 980949d0342Smrg t dotsl 981949d0342Smrg s|/\.$|/|' 982949d0342Smrg _G_collapseslashes='s|/\{1,\}|/|g' 983949d0342Smrg _G_finalslash='s|/*$|/|' 984949d0342Smrg 985949d0342Smrg # Start from root dir and reassemble the path. 986949d0342Smrg func_normal_abspath_result= 987949d0342Smrg func_normal_abspath_tpath=$1 988949d0342Smrg func_normal_abspath_altnamespace= 989949d0342Smrg case $func_normal_abspath_tpath in 990949d0342Smrg "") 991949d0342Smrg # Empty path, that just means $cwd. 992949d0342Smrg func_stripname '' '/' "`pwd`" 993949d0342Smrg func_normal_abspath_result=$func_stripname_result 994949d0342Smrg return 995949d0342Smrg ;; 996949d0342Smrg # The next three entries are used to spot a run of precisely 997949d0342Smrg # two leading slashes without using negated character classes; 998949d0342Smrg # we take advantage of case's first-match behaviour. 999949d0342Smrg ///*) 1000949d0342Smrg # Unusual form of absolute path, do nothing. 1001949d0342Smrg ;; 1002949d0342Smrg //*) 1003949d0342Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 1004949d0342Smrg # and for example Cygwin uses it to access remote file shares 1005949d0342Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 1006949d0342Smrg func_normal_abspath_altnamespace=/ 1007949d0342Smrg ;; 1008949d0342Smrg /*) 1009949d0342Smrg # Absolute path, do nothing. 1010949d0342Smrg ;; 1011d5c3dbf1Smrg *) 1012949d0342Smrg # Relative path, prepend $cwd. 1013949d0342Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1014949d0342Smrg ;; 1015d5c3dbf1Smrg esac 1016d5c3dbf1Smrg 1017949d0342Smrg # Cancel out all the simple stuff to save iterations. We also want 1018949d0342Smrg # the path to end with a slash for ease of parsing, so make sure 1019949d0342Smrg # there is one (and only one) here. 1020949d0342Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1021949d0342Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1022949d0342Smrg while :; do 1023949d0342Smrg # Processed it all yet? 1024949d0342Smrg if test / = "$func_normal_abspath_tpath"; then 1025949d0342Smrg # If we ascended to the root using ".." the result may be empty now. 1026949d0342Smrg if test -z "$func_normal_abspath_result"; then 1027949d0342Smrg func_normal_abspath_result=/ 1028949d0342Smrg fi 1029949d0342Smrg break 1030949d0342Smrg fi 1031949d0342Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1032949d0342Smrg -e "$_G_pathcar"` 1033949d0342Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1034949d0342Smrg -e "$_G_pathcdr"` 1035949d0342Smrg # Figure out what to do with it 1036949d0342Smrg case $func_normal_abspath_tcomponent in 1037949d0342Smrg "") 1038949d0342Smrg # Trailing empty path component, ignore it. 1039949d0342Smrg ;; 1040949d0342Smrg ..) 1041949d0342Smrg # Parent dir; strip last assembled component from result. 1042949d0342Smrg func_dirname "$func_normal_abspath_result" 1043949d0342Smrg func_normal_abspath_result=$func_dirname_result 1044949d0342Smrg ;; 1045949d0342Smrg *) 1046949d0342Smrg # Actual path component, append it. 1047949d0342Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1048949d0342Smrg ;; 1049949d0342Smrg esac 1050949d0342Smrg done 1051949d0342Smrg # Restore leading double-slash if one was found on entry. 1052949d0342Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1053949d0342Smrg} 1054949d0342Smrg 1055949d0342Smrg 1056949d0342Smrg# func_notquiet ARG... 1057949d0342Smrg# -------------------- 1058949d0342Smrg# Echo program name prefixed message only when not in quiet mode. 1059949d0342Smrgfunc_notquiet () 1060949d0342Smrg{ 1061949d0342Smrg $debug_cmd 1062949d0342Smrg 1063949d0342Smrg $opt_quiet || func_echo ${1+"$@"} 1064949d0342Smrg 1065949d0342Smrg # A bug in bash halts the script if the last line of a function 1066949d0342Smrg # fails when set -e is in force, so we need another command to 1067949d0342Smrg # work around that: 1068949d0342Smrg : 1069949d0342Smrg} 1070949d0342Smrg 1071949d0342Smrg 1072949d0342Smrg# func_relative_path SRCDIR DSTDIR 1073949d0342Smrg# -------------------------------- 1074949d0342Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1075949d0342Smrgfunc_relative_path () 1076949d0342Smrg{ 1077949d0342Smrg $debug_cmd 1078949d0342Smrg 1079949d0342Smrg func_relative_path_result= 1080949d0342Smrg func_normal_abspath "$1" 1081949d0342Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1082949d0342Smrg func_normal_abspath "$2" 1083949d0342Smrg func_relative_path_tbindir=$func_normal_abspath_result 1084949d0342Smrg 1085949d0342Smrg # Ascend the tree starting from libdir 1086949d0342Smrg while :; do 1087949d0342Smrg # check if we have found a prefix of bindir 1088949d0342Smrg case $func_relative_path_tbindir in 1089949d0342Smrg $func_relative_path_tlibdir) 1090949d0342Smrg # found an exact match 1091949d0342Smrg func_relative_path_tcancelled= 1092949d0342Smrg break 1093949d0342Smrg ;; 1094949d0342Smrg $func_relative_path_tlibdir*) 1095949d0342Smrg # found a matching prefix 1096949d0342Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1097949d0342Smrg func_relative_path_tcancelled=$func_stripname_result 1098949d0342Smrg if test -z "$func_relative_path_result"; then 1099949d0342Smrg func_relative_path_result=. 1100949d0342Smrg fi 1101949d0342Smrg break 1102949d0342Smrg ;; 1103949d0342Smrg *) 1104949d0342Smrg func_dirname $func_relative_path_tlibdir 1105949d0342Smrg func_relative_path_tlibdir=$func_dirname_result 1106949d0342Smrg if test -z "$func_relative_path_tlibdir"; then 1107949d0342Smrg # Have to descend all the way to the root! 1108949d0342Smrg func_relative_path_result=../$func_relative_path_result 1109949d0342Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1110949d0342Smrg break 1111949d0342Smrg fi 1112949d0342Smrg func_relative_path_result=../$func_relative_path_result 1113949d0342Smrg ;; 1114949d0342Smrg esac 1115949d0342Smrg done 1116949d0342Smrg 1117949d0342Smrg # Now calculate path; take care to avoid doubling-up slashes. 1118949d0342Smrg func_stripname '' '/' "$func_relative_path_result" 1119949d0342Smrg func_relative_path_result=$func_stripname_result 1120949d0342Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1121949d0342Smrg if test -n "$func_stripname_result"; then 1122949d0342Smrg func_append func_relative_path_result "/$func_stripname_result" 1123949d0342Smrg fi 1124949d0342Smrg 1125949d0342Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1126949d0342Smrg if test -n "$func_relative_path_result"; then 1127949d0342Smrg func_stripname './' '' "$func_relative_path_result" 1128949d0342Smrg func_relative_path_result=$func_stripname_result 1129949d0342Smrg fi 1130949d0342Smrg 1131949d0342Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1132949d0342Smrg 1133949d0342Smrg : 1134949d0342Smrg} 1135949d0342Smrg 1136949d0342Smrg 1137949d0342Smrg# func_quote_portable EVAL ARG 1138949d0342Smrg# ---------------------------- 1139949d0342Smrg# Internal function to portably implement func_quote_arg. Note that we still 1140949d0342Smrg# keep attention to performance here so we as much as possible try to avoid 1141949d0342Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142949d0342Smrgfunc_quote_portable () 1143949d0342Smrg{ 1144949d0342Smrg $debug_cmd 1145949d0342Smrg 1146949d0342Smrg $require_check_ifs_backslash 1147949d0342Smrg 1148949d0342Smrg func_quote_portable_result=$2 1149949d0342Smrg 1150949d0342Smrg # one-time-loop (easy break) 1151949d0342Smrg while true 1152949d0342Smrg do 1153949d0342Smrg if $1; then 1154949d0342Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155949d0342Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156949d0342Smrg break 1157949d0342Smrg fi 1158949d0342Smrg 1159949d0342Smrg # Quote for eval. 1160949d0342Smrg case $func_quote_portable_result in 1161949d0342Smrg *[\\\`\"\$]*) 1162949d0342Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163949d0342Smrg # contains the shell wildcard characters. 1164949d0342Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165949d0342Smrg :*|*[\[\*\?]*) 1166949d0342Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167949d0342Smrg | $SED "$sed_quote_subst"` 1168949d0342Smrg break 1169949d0342Smrg ;; 1170949d0342Smrg esac 1171949d0342Smrg 1172949d0342Smrg func_quote_portable_old_IFS=$IFS 1173949d0342Smrg for _G_char in '\' '`' '"' '$' 1174949d0342Smrg do 1175949d0342Smrg # STATE($1) PREV($2) SEPARATOR($3) 1176949d0342Smrg set start "" "" 1177949d0342Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178949d0342Smrg IFS=$_G_char 1179949d0342Smrg for _G_part in $func_quote_portable_result 1180949d0342Smrg do 1181949d0342Smrg case $1 in 1182949d0342Smrg quote) 1183949d0342Smrg func_append func_quote_portable_result "$3$2" 1184949d0342Smrg set quote "$_G_part" "\\$_G_char" 1185949d0342Smrg ;; 1186949d0342Smrg start) 1187949d0342Smrg set first "" "" 1188949d0342Smrg func_quote_portable_result= 1189949d0342Smrg ;; 1190949d0342Smrg first) 1191949d0342Smrg set quote "$_G_part" "" 1192949d0342Smrg ;; 1193949d0342Smrg esac 1194949d0342Smrg done 1195949d0342Smrg done 1196949d0342Smrg IFS=$func_quote_portable_old_IFS 1197949d0342Smrg ;; 1198949d0342Smrg *) ;; 1199949d0342Smrg esac 1200949d0342Smrg break 1201949d0342Smrg done 1202949d0342Smrg 1203949d0342Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204949d0342Smrg case $func_quote_portable_result in 1205949d0342Smrg # double-quote args containing shell metacharacters to delay 1206949d0342Smrg # word splitting, command substitution and variable expansion 1207949d0342Smrg # for a subsequent eval. 1208949d0342Smrg # many bourne shells cannot handle close brackets correctly 1209d5c3dbf1Smrg # in scan sets, so we specify it separately. 1210d5c3dbf1Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211949d0342Smrg func_quote_portable_result=\"$func_quote_portable_result\" 1212d5c3dbf1Smrg ;; 12139f606849Smrg esac 12149f606849Smrg} 12159f606849Smrg 12169f606849Smrg 1217949d0342Smrg# func_quotefast_eval ARG 1218949d0342Smrg# ----------------------- 1219949d0342Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220949d0342Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221949d0342Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222949d0342Smrg printf -v _GL_test_printf_tilde %q '~' 1223949d0342Smrg if test '\~' = "$_GL_test_printf_tilde"; then 1224949d0342Smrg func_quotefast_eval () 1225949d0342Smrg { 1226949d0342Smrg printf -v func_quotefast_eval_result %q "$1" 1227949d0342Smrg } 1228949d0342Smrg else 1229949d0342Smrg # Broken older Bash implementations. Make those faster too if possible. 1230949d0342Smrg func_quotefast_eval () 1231949d0342Smrg { 1232949d0342Smrg case $1 in 1233949d0342Smrg '~'*) 1234949d0342Smrg func_quote_portable false "$1" 1235949d0342Smrg func_quotefast_eval_result=$func_quote_portable_result 1236949d0342Smrg ;; 1237949d0342Smrg *) 1238949d0342Smrg printf -v func_quotefast_eval_result %q "$1" 1239949d0342Smrg ;; 1240949d0342Smrg esac 1241949d0342Smrg } 1242949d0342Smrg fi 1243949d0342Smrgelse 1244949d0342Smrg func_quotefast_eval () 1245949d0342Smrg { 1246949d0342Smrg func_quote_portable false "$1" 1247949d0342Smrg func_quotefast_eval_result=$func_quote_portable_result 1248949d0342Smrg } 1249949d0342Smrgfi 1250949d0342Smrg 1251949d0342Smrg 1252949d0342Smrg# func_quote_arg MODEs ARG 1253949d0342Smrg# ------------------------ 1254949d0342Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255949d0342Smrg# specifiers listed below separated by ',' character. This function returns two 1256949d0342Smrg# values: 1257949d0342Smrg# i) func_quote_arg_result 1258949d0342Smrg# double-quoted (when needed), suitable for a subsequent eval 1259949d0342Smrg# ii) func_quote_arg_unquoted_result 1260949d0342Smrg# has all characters that are still active within double 1261949d0342Smrg# quotes backslashified. Available only if 'unquoted' is specified. 1262949d0342Smrg# 1263949d0342Smrg# Available modes: 1264949d0342Smrg# ---------------- 1265949d0342Smrg# 'eval' (default) 1266949d0342Smrg# - escape shell special characters 1267949d0342Smrg# 'expand' 1268949d0342Smrg# - the same as 'eval'; but do not quote variable references 1269949d0342Smrg# 'pretty' 1270949d0342Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271949d0342Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272949d0342Smrg# of 'echo a\ b'. This is slower than default on some shells. 1273949d0342Smrg# 'unquoted' 1274949d0342Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275949d0342Smrg# wrapping double-quotes. 1276949d0342Smrg# 1277949d0342Smrg# Examples for 'func_quote_arg pretty,unquoted string': 1278949d0342Smrg# 1279949d0342Smrg# string | *_result | *_unquoted_result 1280949d0342Smrg# ------------+-----------------------+------------------- 1281949d0342Smrg# " | \" | \" 1282949d0342Smrg# a b | "a b" | a b 1283949d0342Smrg# "a b" | "\"a b\"" | \"a b\" 1284949d0342Smrg# * | "*" | * 1285949d0342Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286949d0342Smrg# 1287949d0342Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288949d0342Smrg# 1289949d0342Smrg# string | *_result | *_unquoted_result 1290949d0342Smrg# --------------+---------------------+-------------------- 1291949d0342Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292949d0342Smrgfunc_quote_arg () 12939f606849Smrg{ 1294949d0342Smrg _G_quote_expand=false 1295949d0342Smrg case ,$1, in 1296949d0342Smrg *,expand,*) 1297949d0342Smrg _G_quote_expand=: 1298949d0342Smrg ;; 1299d5c3dbf1Smrg esac 1300d5c3dbf1Smrg 1301949d0342Smrg case ,$1, in 1302949d0342Smrg *,pretty,*|*,expand,*|*,unquoted,*) 1303949d0342Smrg func_quote_portable $_G_quote_expand "$2" 1304949d0342Smrg func_quote_arg_result=$func_quote_portable_result 1305949d0342Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306949d0342Smrg ;; 1307949d0342Smrg *) 1308949d0342Smrg # Faster quote-for-eval for some shells. 1309949d0342Smrg func_quotefast_eval "$2" 1310949d0342Smrg func_quote_arg_result=$func_quotefast_eval_result 1311d5c3dbf1Smrg ;; 1312d5c3dbf1Smrg esac 1313949d0342Smrg} 1314949d0342Smrg 1315d5c3dbf1Smrg 1316949d0342Smrg# func_quote MODEs ARGs... 1317949d0342Smrg# ------------------------ 1318949d0342Smrg# Quote all ARGs to be evaled later and join them into single command. See 1319949d0342Smrg# func_quote_arg's description for more info. 1320949d0342Smrgfunc_quote () 1321949d0342Smrg{ 1322949d0342Smrg $debug_cmd 1323949d0342Smrg _G_func_quote_mode=$1 ; shift 1324949d0342Smrg func_quote_result= 1325949d0342Smrg while test 0 -lt $#; do 1326949d0342Smrg func_quote_arg "$_G_func_quote_mode" "$1" 1327949d0342Smrg if test -n "$func_quote_result"; then 1328949d0342Smrg func_append func_quote_result " $func_quote_arg_result" 1329949d0342Smrg else 1330949d0342Smrg func_append func_quote_result "$func_quote_arg_result" 1331949d0342Smrg fi 1332949d0342Smrg shift 1333949d0342Smrg done 13349f606849Smrg} 13359f606849Smrg 13369f606849Smrg 1337949d0342Smrg# func_stripname PREFIX SUFFIX NAME 1338949d0342Smrg# --------------------------------- 1339949d0342Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1340949d0342Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1341949d0342Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1342949d0342Smrg# dot (in which case that matches only a dot). 1343949d0342Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1344949d0342Smrg eval 'func_stripname () 1345949d0342Smrg { 1346949d0342Smrg $debug_cmd 1347949d0342Smrg 1348949d0342Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1349949d0342Smrg # positional parameters, so assign one to ordinary variable first. 1350949d0342Smrg func_stripname_result=$3 1351949d0342Smrg func_stripname_result=${func_stripname_result#"$1"} 1352949d0342Smrg func_stripname_result=${func_stripname_result%"$2"} 1353949d0342Smrg }' 1354949d0342Smrgelse 1355949d0342Smrg func_stripname () 1356949d0342Smrg { 1357949d0342Smrg $debug_cmd 1358949d0342Smrg 1359949d0342Smrg case $2 in 1360949d0342Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1361949d0342Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1362949d0342Smrg esac 1363949d0342Smrg } 1364949d0342Smrgfi 1365949d0342Smrg 1366949d0342Smrg 1367949d0342Smrg# func_show_eval CMD [FAIL_EXP] 1368949d0342Smrg# ----------------------------- 1369949d0342Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1370d5c3dbf1Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1371d5c3dbf1Smrg# is given, then evaluate it. 1372d5c3dbf1Smrgfunc_show_eval () 13739f606849Smrg{ 1374949d0342Smrg $debug_cmd 1375949d0342Smrg 1376949d0342Smrg _G_cmd=$1 1377949d0342Smrg _G_fail_exp=${2-':'} 1378949d0342Smrg 1379949d0342Smrg func_quote_arg pretty,expand "$_G_cmd" 1380949d0342Smrg eval "func_notquiet $func_quote_arg_result" 1381949d0342Smrg 1382949d0342Smrg $opt_dry_run || { 1383949d0342Smrg eval "$_G_cmd" 1384949d0342Smrg _G_status=$? 1385949d0342Smrg if test 0 -ne "$_G_status"; then 1386949d0342Smrg eval "(exit $_G_status); $_G_fail_exp" 1387949d0342Smrg fi 1388949d0342Smrg } 1389949d0342Smrg} 1390949d0342Smrg 1391949d0342Smrg 1392949d0342Smrg# func_show_eval_locale CMD [FAIL_EXP] 1393949d0342Smrg# ------------------------------------ 1394949d0342Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1395949d0342Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1396949d0342Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1397949d0342Smrgfunc_show_eval_locale () 1398949d0342Smrg{ 1399949d0342Smrg $debug_cmd 1400949d0342Smrg 1401949d0342Smrg _G_cmd=$1 1402949d0342Smrg _G_fail_exp=${2-':'} 1403949d0342Smrg 1404949d0342Smrg $opt_quiet || { 1405949d0342Smrg func_quote_arg expand,pretty "$_G_cmd" 1406949d0342Smrg eval "func_echo $func_quote_arg_result" 1407949d0342Smrg } 1408949d0342Smrg 1409949d0342Smrg $opt_dry_run || { 1410949d0342Smrg eval "$_G_user_locale 1411949d0342Smrg $_G_cmd" 1412949d0342Smrg _G_status=$? 1413949d0342Smrg eval "$_G_safe_locale" 1414949d0342Smrg if test 0 -ne "$_G_status"; then 1415949d0342Smrg eval "(exit $_G_status); $_G_fail_exp" 1416949d0342Smrg fi 1417949d0342Smrg } 1418949d0342Smrg} 1419949d0342Smrg 1420949d0342Smrg 1421949d0342Smrg# func_tr_sh 1422949d0342Smrg# ---------- 1423949d0342Smrg# Turn $1 into a string suitable for a shell variable name. 1424949d0342Smrg# Result is stored in $func_tr_sh_result. All characters 1425949d0342Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1426949d0342Smrg# if $1 begins with a digit, a '_' is prepended as well. 1427949d0342Smrgfunc_tr_sh () 1428949d0342Smrg{ 1429949d0342Smrg $debug_cmd 1430949d0342Smrg 1431949d0342Smrg case $1 in 1432949d0342Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1433949d0342Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1434949d0342Smrg ;; 1435949d0342Smrg * ) 1436949d0342Smrg func_tr_sh_result=$1 1437949d0342Smrg ;; 1438949d0342Smrg esac 1439949d0342Smrg} 1440949d0342Smrg 1441949d0342Smrg 1442949d0342Smrg# func_verbose ARG... 1443949d0342Smrg# ------------------- 1444949d0342Smrg# Echo program name prefixed message in verbose mode only. 1445949d0342Smrgfunc_verbose () 1446949d0342Smrg{ 1447949d0342Smrg $debug_cmd 1448949d0342Smrg 1449949d0342Smrg $opt_verbose && func_echo "$*" 1450949d0342Smrg 1451949d0342Smrg : 1452949d0342Smrg} 1453949d0342Smrg 1454949d0342Smrg 1455949d0342Smrg# func_warn_and_continue ARG... 1456949d0342Smrg# ----------------------------- 1457949d0342Smrg# Echo program name prefixed warning message to standard error. 1458949d0342Smrgfunc_warn_and_continue () 1459949d0342Smrg{ 1460949d0342Smrg $debug_cmd 1461949d0342Smrg 1462949d0342Smrg $require_term_colors 1463949d0342Smrg 1464949d0342Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1465949d0342Smrg} 1466949d0342Smrg 1467949d0342Smrg 1468949d0342Smrg# func_warning CATEGORY ARG... 1469949d0342Smrg# ---------------------------- 1470949d0342Smrg# Echo program name prefixed warning message to standard error. Warning 1471949d0342Smrg# messages can be filtered according to CATEGORY, where this function 1472949d0342Smrg# elides messages where CATEGORY is not listed in the global variable 1473949d0342Smrg# 'opt_warning_types'. 1474949d0342Smrgfunc_warning () 1475949d0342Smrg{ 1476949d0342Smrg $debug_cmd 1477949d0342Smrg 1478949d0342Smrg # CATEGORY must be in the warning_categories list! 1479949d0342Smrg case " $warning_categories " in 1480949d0342Smrg *" $1 "*) ;; 1481949d0342Smrg *) func_internal_error "invalid warning category '$1'" ;; 1482949d0342Smrg esac 1483949d0342Smrg 1484949d0342Smrg _G_category=$1 1485949d0342Smrg shift 1486949d0342Smrg 1487949d0342Smrg case " $opt_warning_types " in 1488949d0342Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1489949d0342Smrg esac 1490949d0342Smrg} 1491949d0342Smrg 1492949d0342Smrg 1493949d0342Smrg# func_sort_ver VER1 VER2 1494949d0342Smrg# ----------------------- 1495949d0342Smrg# 'sort -V' is not generally available. 1496949d0342Smrg# Note this deviates from the version comparison in automake 1497949d0342Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1498949d0342Smrg# but this should suffice as we won't be specifying old 1499949d0342Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1500949d0342Smrg# If we did want full compatibility then we should probably 1501949d0342Smrg# use m4_version_compare from autoconf. 1502949d0342Smrgfunc_sort_ver () 1503949d0342Smrg{ 1504949d0342Smrg $debug_cmd 1505949d0342Smrg 1506949d0342Smrg printf '%s\n%s\n' "$1" "$2" \ 1507949d0342Smrg | 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 1508949d0342Smrg} 1509949d0342Smrg 1510949d0342Smrg# func_lt_ver PREV CURR 1511949d0342Smrg# --------------------- 1512949d0342Smrg# Return true if PREV and CURR are in the correct order according to 1513949d0342Smrg# func_sort_ver, otherwise false. Use it like this: 1514949d0342Smrg# 1515949d0342Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1516949d0342Smrgfunc_lt_ver () 1517949d0342Smrg{ 1518949d0342Smrg $debug_cmd 1519949d0342Smrg 1520949d0342Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1521949d0342Smrg} 1522949d0342Smrg 1523949d0342Smrg 1524949d0342Smrg# Local variables: 1525949d0342Smrg# mode: shell-script 1526949d0342Smrg# sh-indentation: 2 1527949d0342Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1528949d0342Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1529949d0342Smrg# time-stamp-time-zone: "UTC" 1530949d0342Smrg# End: 1531949d0342Smrg#! /bin/sh 1532949d0342Smrg 1533949d0342Smrg# A portable, pluggable option parser for Bourne shell. 1534949d0342Smrg# Written by Gary V. Vaughan, 2010 1535949d0342Smrg 1536949d0342Smrg# This is free software. There is NO warranty; not even for 1537949d0342Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538949d0342Smrg# 1539dc088bc7Smrg# Copyright (C) 2010-2019, 2021, 2023-2024 Bootstrap Authors 1540949d0342Smrg# 1541949d0342Smrg# This file is dual licensed under the terms of the MIT license 1542dc088bc7Smrg# <https://opensource.org/licenses/MIT>, and GPL version 2 or later 1543dc088bc7Smrg# <https://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544949d0342Smrg# these licenses when using or redistributing this software or any of 1545949d0342Smrg# the files within it. See the URLs above, or the file `LICENSE` 1546949d0342Smrg# included in the Bootstrap distribution for the full license texts. 1547949d0342Smrg 1548949d0342Smrg# Please report bugs or propose patches to: 1549949d0342Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 1550949d0342Smrg 1551949d0342Smrg# Set a version string for this script. 1552949d0342Smrgscriptversion=2019-02-19.15; # UTC 1553949d0342Smrg 1554949d0342Smrg 1555949d0342Smrg## ------ ## 1556949d0342Smrg## Usage. ## 1557949d0342Smrg## ------ ## 1558949d0342Smrg 1559949d0342Smrg# This file is a library for parsing options in your shell scripts along 1560949d0342Smrg# with assorted other useful supporting features that you can make use 1561949d0342Smrg# of too. 1562949d0342Smrg# 1563949d0342Smrg# For the simplest scripts you might need only: 1564949d0342Smrg# 1565949d0342Smrg# #!/bin/sh 1566949d0342Smrg# . relative/path/to/funclib.sh 1567949d0342Smrg# . relative/path/to/options-parser 1568949d0342Smrg# scriptversion=1.0 1569949d0342Smrg# func_options ${1+"$@"} 1570949d0342Smrg# eval set dummy "$func_options_result"; shift 1571949d0342Smrg# ...rest of your script... 1572949d0342Smrg# 1573949d0342Smrg# In order for the '--version' option to work, you will need to have a 1574949d0342Smrg# suitably formatted comment like the one at the top of this file 1575949d0342Smrg# starting with '# Written by ' and ending with '# Copyright'. 1576949d0342Smrg# 1577949d0342Smrg# For '-h' and '--help' to work, you will also need a one line 1578949d0342Smrg# description of your script's purpose in a comment directly above the 1579949d0342Smrg# '# Written by ' line, like the one at the top of this file. 1580949d0342Smrg# 1581949d0342Smrg# The default options also support '--debug', which will turn on shell 1582949d0342Smrg# execution tracing (see the comment above debug_cmd below for another 1583949d0342Smrg# use), and '--verbose' and the func_verbose function to allow your script 1584949d0342Smrg# to display verbose messages only when your user has specified 1585949d0342Smrg# '--verbose'. 1586949d0342Smrg# 1587949d0342Smrg# After sourcing this file, you can plug in processing for additional 1588949d0342Smrg# options by amending the variables from the 'Configuration' section 1589949d0342Smrg# below, and following the instructions in the 'Option parsing' 1590949d0342Smrg# section further down. 1591949d0342Smrg 1592949d0342Smrg## -------------- ## 1593949d0342Smrg## Configuration. ## 1594949d0342Smrg## -------------- ## 1595949d0342Smrg 1596949d0342Smrg# You should override these variables in your script after sourcing this 1597949d0342Smrg# file so that they reflect the customisations you have added to the 1598949d0342Smrg# option parser. 1599949d0342Smrg 1600949d0342Smrg# The usage line for option parsing errors and the start of '-h' and 1601949d0342Smrg# '--help' output messages. You can embed shell variables for delayed 1602949d0342Smrg# expansion at the time the message is displayed, but you will need to 1603949d0342Smrg# quote other shell meta-characters carefully to prevent them being 1604949d0342Smrg# expanded when the contents are evaled. 1605949d0342Smrgusage='$progpath [OPTION]...' 1606949d0342Smrg 1607949d0342Smrg# Short help message in response to '-h' and '--help'. Add to this or 1608949d0342Smrg# override it after sourcing this library to reflect the full set of 1609949d0342Smrg# options your script accepts. 1610949d0342Smrgusage_message="\ 1611949d0342Smrg --debug enable verbose shell tracing 1612949d0342Smrg -W, --warnings=CATEGORY 1613949d0342Smrg report the warnings falling in CATEGORY [all] 1614949d0342Smrg -v, --verbose verbosely report processing 1615949d0342Smrg --version print version information and exit 1616949d0342Smrg -h, --help print short or long help message and exit 1617949d0342Smrg" 1618949d0342Smrg 1619949d0342Smrg# Additional text appended to 'usage_message' in response to '--help'. 1620949d0342Smrglong_help_message=" 1621949d0342SmrgWarning categories include: 1622949d0342Smrg 'all' show all warnings 1623949d0342Smrg 'none' turn off all the warnings 1624949d0342Smrg 'error' warnings are treated as fatal errors" 1625949d0342Smrg 1626949d0342Smrg# Help message printed before fatal option parsing errors. 1627949d0342Smrgfatal_help="Try '\$progname --help' for more information." 1628949d0342Smrg 1629949d0342Smrg 1630949d0342Smrg 1631949d0342Smrg## ------------------------- ## 1632949d0342Smrg## Hook function management. ## 1633949d0342Smrg## ------------------------- ## 1634949d0342Smrg 1635949d0342Smrg# This section contains functions for adding, removing, and running hooks 1636949d0342Smrg# in the main code. A hook is just a list of function names that can be 1637949d0342Smrg# run in order later on. 1638949d0342Smrg 1639949d0342Smrg# func_hookable FUNC_NAME 1640949d0342Smrg# ----------------------- 1641949d0342Smrg# Declare that FUNC_NAME will run hooks added with 1642949d0342Smrg# 'func_add_hook FUNC_NAME ...'. 1643949d0342Smrgfunc_hookable () 1644949d0342Smrg{ 1645949d0342Smrg $debug_cmd 1646949d0342Smrg 1647949d0342Smrg func_append hookable_fns " $1" 1648949d0342Smrg} 1649949d0342Smrg 1650949d0342Smrg 1651949d0342Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1652949d0342Smrg# --------------------------------- 1653949d0342Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1654949d0342Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1655949d0342Smrgfunc_add_hook () 1656949d0342Smrg{ 1657949d0342Smrg $debug_cmd 1658949d0342Smrg 1659949d0342Smrg case " $hookable_fns " in 1660949d0342Smrg *" $1 "*) ;; 1661949d0342Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1662949d0342Smrg esac 1663949d0342Smrg 1664949d0342Smrg eval func_append ${1}_hooks '" $2"' 1665949d0342Smrg} 1666949d0342Smrg 1667949d0342Smrg 1668949d0342Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1669949d0342Smrg# ------------------------------------ 1670949d0342Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671949d0342Smrg# FUNC_NAME. 1672949d0342Smrgfunc_remove_hook () 1673949d0342Smrg{ 1674949d0342Smrg $debug_cmd 1675949d0342Smrg 1676949d0342Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1677949d0342Smrg} 1678949d0342Smrg 1679949d0342Smrg 1680949d0342Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681949d0342Smrg# --------------------------------------------- 1682949d0342Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683949d0342Smrg# *_result variable of FUNC_NAME_B. 1684949d0342Smrgfunc_propagate_result () 1685949d0342Smrg{ 1686949d0342Smrg $debug_cmd 1687949d0342Smrg 1688949d0342Smrg func_propagate_result_result=: 1689949d0342Smrg if eval "test \"\${${1}_result+set}\" = set" 1690949d0342Smrg then 1691949d0342Smrg eval "${2}_result=\$${1}_result" 1692949d0342Smrg else 1693949d0342Smrg func_propagate_result_result=false 1694949d0342Smrg fi 1695949d0342Smrg} 1696949d0342Smrg 1697949d0342Smrg 1698949d0342Smrg# func_run_hooks FUNC_NAME [ARG]... 1699949d0342Smrg# --------------------------------- 1700949d0342Smrg# Run all hook functions registered to FUNC_NAME. 1701949d0342Smrg# It's assumed that the list of hook functions contains nothing more 1702949d0342Smrg# than a whitespace-delimited list of legal shell function names, and 1703949d0342Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1704949d0342Smrg# whitespace. 1705949d0342Smrgfunc_run_hooks () 1706949d0342Smrg{ 1707949d0342Smrg $debug_cmd 1708949d0342Smrg 1709949d0342Smrg case " $hookable_fns " in 1710949d0342Smrg *" $1 "*) ;; 1711949d0342Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712949d0342Smrg esac 1713949d0342Smrg 1714949d0342Smrg eval _G_hook_fns=\$$1_hooks; shift 1715949d0342Smrg 1716949d0342Smrg for _G_hook in $_G_hook_fns; do 1717949d0342Smrg func_unset "${_G_hook}_result" 1718949d0342Smrg eval $_G_hook '${1+"$@"}' 1719949d0342Smrg func_propagate_result $_G_hook func_run_hooks 1720949d0342Smrg if $func_propagate_result_result; then 1721949d0342Smrg eval set dummy "$func_run_hooks_result"; shift 1722949d0342Smrg fi 1723949d0342Smrg done 1724949d0342Smrg} 1725949d0342Smrg 1726949d0342Smrg 1727949d0342Smrg 1728949d0342Smrg## --------------- ## 1729949d0342Smrg## Option parsing. ## 1730949d0342Smrg## --------------- ## 1731949d0342Smrg 1732949d0342Smrg# In order to add your own option parsing hooks, you must accept the 1733949d0342Smrg# full positional parameter list from your hook function. You may remove 1734949d0342Smrg# or edit any options that you action, and then pass back the remaining 1735949d0342Smrg# unprocessed options in '<hooked_function_name>_result', escaped 1736949d0342Smrg# suitably for 'eval'. 1737949d0342Smrg# 1738949d0342Smrg# The '<hooked_function_name>_result' variable is automatically unset 1739949d0342Smrg# before your hook gets called; for best performance, only set the 1740949d0342Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741949d0342Smrg# function unnecessarily because it can be an expensive operation on some 1742949d0342Smrg# machines). 1743949d0342Smrg# 1744949d0342Smrg# Like this: 1745949d0342Smrg# 1746949d0342Smrg# my_options_prep () 1747949d0342Smrg# { 1748949d0342Smrg# $debug_cmd 1749949d0342Smrg# 1750949d0342Smrg# # Extend the existing usage message. 1751949d0342Smrg# usage_message=$usage_message' 1752949d0342Smrg# -s, --silent don'\''t print informational messages 1753949d0342Smrg# ' 1754949d0342Smrg# # No change in '$@' (ignored completely by this hook). Leave 1755949d0342Smrg# # my_options_prep_result variable intact. 1756949d0342Smrg# } 1757949d0342Smrg# func_add_hook func_options_prep my_options_prep 1758949d0342Smrg# 1759949d0342Smrg# 1760949d0342Smrg# my_silent_option () 1761949d0342Smrg# { 1762949d0342Smrg# $debug_cmd 1763949d0342Smrg# 1764949d0342Smrg# args_changed=false 1765949d0342Smrg# 1766949d0342Smrg# # Note that, for efficiency, we parse as many options as we can 1767949d0342Smrg# # recognise in a loop before passing the remainder back to the 1768949d0342Smrg# # caller on the first unrecognised argument we encounter. 1769949d0342Smrg# while test $# -gt 0; do 1770949d0342Smrg# opt=$1; shift 1771949d0342Smrg# case $opt in 1772949d0342Smrg# --silent|-s) opt_silent=: 1773949d0342Smrg# args_changed=: 1774949d0342Smrg# ;; 1775949d0342Smrg# # Separate non-argument short options: 1776949d0342Smrg# -s*) func_split_short_opt "$_G_opt" 1777949d0342Smrg# set dummy "$func_split_short_opt_name" \ 1778949d0342Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1779949d0342Smrg# shift 1780949d0342Smrg# args_changed=: 1781949d0342Smrg# ;; 1782949d0342Smrg# *) # Make sure the first unrecognised option "$_G_opt" 1783949d0342Smrg# # is added back to "$@" in case we need it later, 1784949d0342Smrg# # if $args_changed was set to 'true'. 1785949d0342Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1786949d0342Smrg# esac 1787949d0342Smrg# done 1788949d0342Smrg# 1789949d0342Smrg# # Only call 'func_quote' here if we processed at least one argument. 1790949d0342Smrg# if $args_changed; then 1791949d0342Smrg# func_quote eval ${1+"$@"} 1792949d0342Smrg# my_silent_option_result=$func_quote_result 1793949d0342Smrg# fi 1794949d0342Smrg# } 1795949d0342Smrg# func_add_hook func_parse_options my_silent_option 1796949d0342Smrg# 1797949d0342Smrg# 1798949d0342Smrg# my_option_validation () 1799949d0342Smrg# { 1800949d0342Smrg# $debug_cmd 1801949d0342Smrg# 1802949d0342Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1803949d0342Smrg# '--silent' and '--verbose' options are mutually exclusive." 1804949d0342Smrg# } 1805949d0342Smrg# func_add_hook func_validate_options my_option_validation 1806949d0342Smrg# 1807949d0342Smrg# You'll also need to manually amend $usage_message to reflect the extra 1808949d0342Smrg# options you parse. It's preferable to append if you can, so that 1809949d0342Smrg# multiple option parsing hooks can be added safely. 1810949d0342Smrg 1811949d0342Smrg 1812949d0342Smrg# func_options_finish [ARG]... 1813949d0342Smrg# ---------------------------- 1814949d0342Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815949d0342Smrgfunc_options_finish () 1816949d0342Smrg{ 1817949d0342Smrg $debug_cmd 1818949d0342Smrg 1819949d0342Smrg func_run_hooks func_options ${1+"$@"} 1820949d0342Smrg func_propagate_result func_run_hooks func_options_finish 1821949d0342Smrg} 1822949d0342Smrg 1823949d0342Smrg 1824949d0342Smrg# func_options [ARG]... 1825949d0342Smrg# --------------------- 1826949d0342Smrg# All the functions called inside func_options are hookable. See the 1827949d0342Smrg# individual implementations for details. 1828949d0342Smrgfunc_hookable func_options 1829949d0342Smrgfunc_options () 1830949d0342Smrg{ 1831949d0342Smrg $debug_cmd 1832949d0342Smrg 1833949d0342Smrg _G_options_quoted=false 1834949d0342Smrg 1835949d0342Smrg for my_func in options_prep parse_options validate_options options_finish 1836949d0342Smrg do 1837949d0342Smrg func_unset func_${my_func}_result 1838949d0342Smrg func_unset func_run_hooks_result 1839949d0342Smrg eval func_$my_func '${1+"$@"}' 1840949d0342Smrg func_propagate_result func_$my_func func_options 1841949d0342Smrg if $func_propagate_result_result; then 1842949d0342Smrg eval set dummy "$func_options_result"; shift 1843949d0342Smrg _G_options_quoted=: 1844949d0342Smrg fi 1845949d0342Smrg done 1846949d0342Smrg 1847949d0342Smrg $_G_options_quoted || { 1848949d0342Smrg # As we (func_options) are top-level options-parser function and 1849949d0342Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850949d0342Smrg # caller. 1851949d0342Smrg func_quote eval ${1+"$@"} 1852949d0342Smrg func_options_result=$func_quote_result 1853949d0342Smrg } 1854949d0342Smrg} 1855949d0342Smrg 1856949d0342Smrg 1857949d0342Smrg# func_options_prep [ARG]... 1858949d0342Smrg# -------------------------- 1859949d0342Smrg# All initialisations required before starting the option parse loop. 1860949d0342Smrg# Note that when calling hook functions, we pass through the list of 1861949d0342Smrg# positional parameters. If a hook function modifies that list, and 1862949d0342Smrg# needs to propagate that back to rest of this script, then the complete 1863949d0342Smrg# modified list must be put in 'func_run_hooks_result' before returning. 1864949d0342Smrgfunc_hookable func_options_prep 1865949d0342Smrgfunc_options_prep () 1866949d0342Smrg{ 1867949d0342Smrg $debug_cmd 1868949d0342Smrg 1869949d0342Smrg # Option defaults: 1870949d0342Smrg opt_verbose=false 1871949d0342Smrg opt_warning_types= 1872949d0342Smrg 1873949d0342Smrg func_run_hooks func_options_prep ${1+"$@"} 1874949d0342Smrg func_propagate_result func_run_hooks func_options_prep 1875949d0342Smrg} 1876949d0342Smrg 1877949d0342Smrg 1878949d0342Smrg# func_parse_options [ARG]... 1879949d0342Smrg# --------------------------- 1880949d0342Smrg# The main option parsing loop. 1881949d0342Smrgfunc_hookable func_parse_options 1882949d0342Smrgfunc_parse_options () 1883949d0342Smrg{ 1884949d0342Smrg $debug_cmd 1885949d0342Smrg 1886949d0342Smrg _G_parse_options_requote=false 1887949d0342Smrg # this just eases exit handling 1888949d0342Smrg while test $# -gt 0; do 1889949d0342Smrg # Defer to hook functions for initial option parsing, so they 1890949d0342Smrg # get priority in the event of reusing an option name. 1891949d0342Smrg func_run_hooks func_parse_options ${1+"$@"} 1892949d0342Smrg func_propagate_result func_run_hooks func_parse_options 1893949d0342Smrg if $func_propagate_result_result; then 1894949d0342Smrg eval set dummy "$func_parse_options_result"; shift 1895949d0342Smrg # Even though we may have changed "$@", we passed the "$@" array 1896949d0342Smrg # down into the hook and it quoted it for us (because we are in 1897949d0342Smrg # this if-branch). No need to quote it again. 1898949d0342Smrg _G_parse_options_requote=false 1899949d0342Smrg fi 1900949d0342Smrg 1901949d0342Smrg # Break out of the loop if we already parsed every option. 1902949d0342Smrg test $# -gt 0 || break 1903949d0342Smrg 1904949d0342Smrg # We expect that one of the options parsed in this function matches 1905949d0342Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906949d0342Smrg _G_match_parse_options=: 1907949d0342Smrg _G_opt=$1 1908949d0342Smrg shift 1909949d0342Smrg case $_G_opt in 1910949d0342Smrg --debug|-x) debug_cmd='set -x' 1911949d0342Smrg func_echo "enabling shell trace mode" >&2 1912949d0342Smrg $debug_cmd 1913949d0342Smrg ;; 1914949d0342Smrg 1915949d0342Smrg --no-warnings|--no-warning|--no-warn) 1916949d0342Smrg set dummy --warnings none ${1+"$@"} 1917949d0342Smrg shift 1918949d0342Smrg ;; 19199f606849Smrg 1920949d0342Smrg --warnings|--warning|-W) 1921949d0342Smrg if test $# = 0 && func_missing_arg $_G_opt; then 1922949d0342Smrg _G_parse_options_requote=: 1923949d0342Smrg break 1924949d0342Smrg fi 1925949d0342Smrg case " $warning_categories $1" in 1926949d0342Smrg *" $1 "*) 1927949d0342Smrg # trailing space prevents matching last $1 above 1928949d0342Smrg func_append_uniq opt_warning_types " $1" 1929949d0342Smrg ;; 1930949d0342Smrg *all) 1931949d0342Smrg opt_warning_types=$warning_categories 1932949d0342Smrg ;; 1933949d0342Smrg *none) 1934949d0342Smrg opt_warning_types=none 1935949d0342Smrg warning_func=: 1936949d0342Smrg ;; 1937949d0342Smrg *error) 1938949d0342Smrg opt_warning_types=$warning_categories 1939949d0342Smrg warning_func=func_fatal_error 1940949d0342Smrg ;; 1941949d0342Smrg *) 1942949d0342Smrg func_fatal_error \ 1943949d0342Smrg "unsupported warning category: '$1'" 1944949d0342Smrg ;; 1945949d0342Smrg esac 1946949d0342Smrg shift 1947949d0342Smrg ;; 1948949d0342Smrg 1949949d0342Smrg --verbose|-v) opt_verbose=: ;; 1950949d0342Smrg --version) func_version ;; 1951949d0342Smrg -\?|-h) func_usage ;; 1952949d0342Smrg --help) func_help ;; 1953949d0342Smrg 1954949d0342Smrg # Separate optargs to long options (plugins may need this): 1955949d0342Smrg --*=*) func_split_equals "$_G_opt" 1956949d0342Smrg set dummy "$func_split_equals_lhs" \ 1957949d0342Smrg "$func_split_equals_rhs" ${1+"$@"} 1958949d0342Smrg shift 1959949d0342Smrg ;; 1960949d0342Smrg 1961949d0342Smrg # Separate optargs to short options: 1962949d0342Smrg -W*) 1963949d0342Smrg func_split_short_opt "$_G_opt" 1964949d0342Smrg set dummy "$func_split_short_opt_name" \ 1965949d0342Smrg "$func_split_short_opt_arg" ${1+"$@"} 1966949d0342Smrg shift 1967949d0342Smrg ;; 1968949d0342Smrg 1969949d0342Smrg # Separate non-argument short options: 1970949d0342Smrg -\?*|-h*|-v*|-x*) 1971949d0342Smrg func_split_short_opt "$_G_opt" 1972949d0342Smrg set dummy "$func_split_short_opt_name" \ 1973949d0342Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1974949d0342Smrg shift 1975949d0342Smrg ;; 1976949d0342Smrg 1977949d0342Smrg --) _G_parse_options_requote=: ; break ;; 1978949d0342Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979949d0342Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980949d0342Smrg _G_match_parse_options=false 1981949d0342Smrg break 1982949d0342Smrg ;; 1983949d0342Smrg esac 1984d5c3dbf1Smrg 1985949d0342Smrg if $_G_match_parse_options; then 1986949d0342Smrg _G_parse_options_requote=: 1987d5c3dbf1Smrg fi 1988949d0342Smrg done 1989949d0342Smrg 1990949d0342Smrg if $_G_parse_options_requote; then 1991949d0342Smrg # save modified positional parameters for caller 1992949d0342Smrg func_quote eval ${1+"$@"} 1993949d0342Smrg func_parse_options_result=$func_quote_result 19949f606849Smrg fi 19959f606849Smrg} 19969f606849Smrg 1997d5c3dbf1Smrg 1998949d0342Smrg# func_validate_options [ARG]... 1999949d0342Smrg# ------------------------------ 2000949d0342Smrg# Perform any sanity checks on option settings and/or unconsumed 2001949d0342Smrg# arguments. 2002949d0342Smrgfunc_hookable func_validate_options 2003949d0342Smrgfunc_validate_options () 20049f606849Smrg{ 2005949d0342Smrg $debug_cmd 20069f606849Smrg 2007949d0342Smrg # Display all warnings if -W was not given. 2008949d0342Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20099f606849Smrg 2010949d0342Smrg func_run_hooks func_validate_options ${1+"$@"} 2011949d0342Smrg func_propagate_result func_run_hooks func_validate_options 20129f606849Smrg 2013949d0342Smrg # Bail if the options were screwed! 2014949d0342Smrg $exit_cmd $EXIT_FAILURE 2015cdbfa18aSmrg} 2016cdbfa18aSmrg 20179f606849Smrg 2018cdbfa18aSmrg 2019949d0342Smrg## ----------------- ## 2020949d0342Smrg## Helper functions. ## 2021949d0342Smrg## ----------------- ## 20229f606849Smrg 2023949d0342Smrg# This section contains the helper functions used by the rest of the 2024949d0342Smrg# hookable option parser framework in ascii-betical order. 2025949d0342Smrg 2026949d0342Smrg 2027949d0342Smrg# func_fatal_help ARG... 2028949d0342Smrg# ---------------------- 2029949d0342Smrg# Echo program name prefixed message to standard error, followed by 2030949d0342Smrg# a help hint, and exit. 2031949d0342Smrgfunc_fatal_help () 2032d5c3dbf1Smrg{ 2033949d0342Smrg $debug_cmd 2034cdbfa18aSmrg 2035949d0342Smrg eval \$ECHO \""Usage: $usage"\" 2036949d0342Smrg eval \$ECHO \""$fatal_help"\" 2037949d0342Smrg func_error ${1+"$@"} 2038949d0342Smrg exit $EXIT_FAILURE 2039d5c3dbf1Smrg} 20409f606849Smrg 2041949d0342Smrg 2042949d0342Smrg# func_help 2043949d0342Smrg# --------- 2044949d0342Smrg# Echo long help message to standard output and exit. 2045d5c3dbf1Smrgfunc_help () 2046d5c3dbf1Smrg{ 2047949d0342Smrg $debug_cmd 2048949d0342Smrg 2049949d0342Smrg func_usage_message 2050949d0342Smrg $ECHO "$long_help_message" 2051949d0342Smrg exit 0 2052d5c3dbf1Smrg} 20539f606849Smrg 2054949d0342Smrg 2055949d0342Smrg# func_missing_arg ARGNAME 2056949d0342Smrg# ------------------------ 2057d5c3dbf1Smrg# Echo program name prefixed message to standard error and set global 2058d5c3dbf1Smrg# exit_cmd. 2059d5c3dbf1Smrgfunc_missing_arg () 2060d5c3dbf1Smrg{ 2061949d0342Smrg $debug_cmd 2062cdbfa18aSmrg 2063949d0342Smrg func_error "Missing argument for '$1'." 2064d5c3dbf1Smrg exit_cmd=exit 2065d5c3dbf1Smrg} 20669f606849Smrg 20679f606849Smrg 2068949d0342Smrg# func_split_equals STRING 2069949d0342Smrg# ------------------------ 2070949d0342Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071949d0342Smrg# after splitting STRING at the '=' sign. 2072949d0342Smrgtest -z "$_G_HAVE_XSI_OPS" \ 2073949d0342Smrg && (eval 'x=a/b/c; 2074949d0342Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2075949d0342Smrg && _G_HAVE_XSI_OPS=yes 2076949d0342Smrg 2077949d0342Smrgif test yes = "$_G_HAVE_XSI_OPS" 2078949d0342Smrgthen 2079949d0342Smrg # This is an XSI compatible shell, allowing a faster implementation... 2080949d0342Smrg eval 'func_split_equals () 2081949d0342Smrg { 2082949d0342Smrg $debug_cmd 2083949d0342Smrg 2084949d0342Smrg func_split_equals_lhs=${1%%=*} 2085949d0342Smrg func_split_equals_rhs=${1#*=} 2086949d0342Smrg if test "x$func_split_equals_lhs" = "x$1"; then 2087949d0342Smrg func_split_equals_rhs= 2088949d0342Smrg fi 2089949d0342Smrg }' 2090949d0342Smrgelse 2091949d0342Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2092949d0342Smrg func_split_equals () 2093949d0342Smrg { 2094949d0342Smrg $debug_cmd 2095949d0342Smrg 2096949d0342Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2097949d0342Smrg func_split_equals_rhs= 2098949d0342Smrg test "x$func_split_equals_lhs=" = "x$1" \ 2099949d0342Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2100949d0342Smrg } 2101949d0342Smrgfi #func_split_equals 2102949d0342Smrg 2103949d0342Smrg 2104949d0342Smrg# func_split_short_opt SHORTOPT 2105949d0342Smrg# ----------------------------- 2106cdbfa18aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107cdbfa18aSmrg# variables after splitting SHORTOPT after the 2nd character. 2108949d0342Smrgif test yes = "$_G_HAVE_XSI_OPS" 2109949d0342Smrgthen 2110949d0342Smrg # This is an XSI compatible shell, allowing a faster implementation... 2111949d0342Smrg eval 'func_split_short_opt () 2112949d0342Smrg { 2113949d0342Smrg $debug_cmd 2114949d0342Smrg 2115949d0342Smrg func_split_short_opt_arg=${1#??} 2116949d0342Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2117949d0342Smrg }' 2118949d0342Smrgelse 2119949d0342Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2120949d0342Smrg func_split_short_opt () 2121949d0342Smrg { 2122949d0342Smrg $debug_cmd 2123949d0342Smrg 2124949d0342Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 2125949d0342Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2126949d0342Smrg } 2127949d0342Smrgfi #func_split_short_opt 2128949d0342Smrg 2129949d0342Smrg 2130949d0342Smrg# func_usage 2131949d0342Smrg# ---------- 2132949d0342Smrg# Echo short help message to standard output and exit. 2133949d0342Smrgfunc_usage () 2134cdbfa18aSmrg{ 2135949d0342Smrg $debug_cmd 2136cdbfa18aSmrg 2137949d0342Smrg func_usage_message 2138949d0342Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2139949d0342Smrg exit 0 2140949d0342Smrg} 2141cdbfa18aSmrg 2142cdbfa18aSmrg 2143949d0342Smrg# func_usage_message 2144949d0342Smrg# ------------------ 2145949d0342Smrg# Echo short help message to standard output. 2146949d0342Smrgfunc_usage_message () 2147cdbfa18aSmrg{ 2148949d0342Smrg $debug_cmd 2149949d0342Smrg 2150949d0342Smrg eval \$ECHO \""Usage: $usage"\" 2151949d0342Smrg echo 2152949d0342Smrg $SED -n 's|^# || 2153949d0342Smrg /^Written by/{ 2154949d0342Smrg x;p;x 2155949d0342Smrg } 2156949d0342Smrg h 2157949d0342Smrg /^Written by/q' < "$progpath" 2158949d0342Smrg echo 2159949d0342Smrg eval \$ECHO \""$usage_message"\" 2160949d0342Smrg} 2161cdbfa18aSmrg 2162cdbfa18aSmrg 2163949d0342Smrg# func_version 2164949d0342Smrg# ------------ 2165949d0342Smrg# Echo version message to standard output and exit. 2166949d0342Smrg# The version message is extracted from the calling file's header 2167949d0342Smrg# comments, with leading '# ' stripped: 2168949d0342Smrg# 1. First display the progname and version 2169949d0342Smrg# 2. Followed by the header comment line matching /^# Written by / 2170949d0342Smrg# 3. Then a blank line followed by the first following line matching 2171949d0342Smrg# /^# Copyright / 2172949d0342Smrg# 4. Immediately followed by any lines between the previous matches, 2173949d0342Smrg# except lines preceding the intervening completely blank line. 2174949d0342Smrg# For example, see the header comments of this file. 2175949d0342Smrgfunc_version () 2176949d0342Smrg{ 2177949d0342Smrg $debug_cmd 21789f606849Smrg 2179949d0342Smrg printf '%s\n' "$progname $scriptversion" 2180949d0342Smrg $SED -n ' 2181949d0342Smrg /^# Written by /!b 2182949d0342Smrg s|^# ||; p; n 21839f606849Smrg 2184949d0342Smrg :fwd2blnk 2185949d0342Smrg /./ { 2186949d0342Smrg n 2187949d0342Smrg b fwd2blnk 2188949d0342Smrg } 2189949d0342Smrg p; n 2190949d0342Smrg 2191949d0342Smrg :holdwrnt 2192949d0342Smrg s|^# || 2193949d0342Smrg s|^# *$|| 2194949d0342Smrg /^Copyright /!{ 2195949d0342Smrg /./H 2196949d0342Smrg n 2197949d0342Smrg b holdwrnt 2198949d0342Smrg } 2199fba89afeSmrg 2200949d0342Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201949d0342Smrg G 2202949d0342Smrg s|\(\n\)\n*|\1|g 2203949d0342Smrg p; q' < "$progpath" 22049f606849Smrg 2205949d0342Smrg exit $? 2206949d0342Smrg} 2207d5c3dbf1Smrg 2208d5c3dbf1Smrg 2209949d0342Smrg# Local variables: 2210949d0342Smrg# mode: shell-script 2211949d0342Smrg# sh-indentation: 2 2212949d0342Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213949d0342Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2214949d0342Smrg# time-stamp-time-zone: "UTC" 2215949d0342Smrg# End: 2216d5c3dbf1Smrg 2217949d0342Smrg# Set a version string. 2218dc088bc7Smrgscriptversion='(GNU libtool) 2.5.4' 2219dc088bc7Smrg 2220dc088bc7Smrg# func_version 2221dc088bc7Smrg# ------------ 2222dc088bc7Smrg# Echo version message to standard output and exit. 2223dc088bc7Smrgfunc_version () 2224dc088bc7Smrg{ 2225dc088bc7Smrg $debug_cmd 2226dc088bc7Smrg 2227dc088bc7Smrg year=`date +%Y` 2228dc088bc7Smrg 2229dc088bc7Smrg cat <<EOF 2230dc088bc7Smrg$progname $scriptversion 2231dc088bc7SmrgCopyright (C) $year Free Software Foundation, Inc. 2232dc088bc7SmrgLicense GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html> 2233dc088bc7SmrgThis is free software: you are free to change and redistribute it. 2234dc088bc7SmrgThere is NO WARRANTY, to the extent permitted by law. 2235dc088bc7Smrg 2236dc088bc7SmrgOriginally written by Gordon Matzigkeit, 1996 2237dc088bc7Smrg(See AUTHORS for complete contributor listing) 2238dc088bc7SmrgEOF 2239dc088bc7Smrg 2240dc088bc7Smrg exit $? 2241dc088bc7Smrg} 2242d5c3dbf1Smrg 2243cdbfa18aSmrg 2244949d0342Smrg# func_echo ARG... 2245949d0342Smrg# ---------------- 2246949d0342Smrg# Libtool also displays the current mode in messages, so override 2247949d0342Smrg# funclib.sh func_echo with this custom definition. 2248949d0342Smrgfunc_echo () 2249cdbfa18aSmrg{ 2250949d0342Smrg $debug_cmd 2251cdbfa18aSmrg 2252949d0342Smrg _G_message=$* 2253cdbfa18aSmrg 2254949d0342Smrg func_echo_IFS=$IFS 2255949d0342Smrg IFS=$nl 2256949d0342Smrg for _G_line in $_G_message; do 2257949d0342Smrg IFS=$func_echo_IFS 2258949d0342Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2259949d0342Smrg done 2260949d0342Smrg IFS=$func_echo_IFS 2261949d0342Smrg} 2262cdbfa18aSmrg 2263cdbfa18aSmrg 2264949d0342Smrg## ---------------- ## 2265949d0342Smrg## Options parsing. ## 2266949d0342Smrg## ---------------- ## 2267949d0342Smrg 2268949d0342Smrg# Hook in the functions to make sure our own options are parsed during 2269949d0342Smrg# the option parsing loop. 2270949d0342Smrg 2271949d0342Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2272949d0342Smrg 2273949d0342Smrg# Short help message in response to '-h'. 2274949d0342Smrgusage_message="Options: 2275dc088bc7Smrg --config show all configuration variables 2276dc088bc7Smrg --debug enable verbose shell tracing 2277dc088bc7Smrg -n, --dry-run display commands without modifying any files 2278dc088bc7Smrg --features display basic configuration information 2279dc088bc7Smrg --finish use operation '--mode=finish' 2280dc088bc7Smrg --mode=MODE use operation mode MODE 2281dc088bc7Smrg --no-finish don't update shared library cache 2282dc088bc7Smrg --no-quiet, --no-silent print default informational messages 2283dc088bc7Smrg --no-warnings equivalent to '-Wnone' 2284dc088bc7Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2285dc088bc7Smrg --quiet, --silent don't print informational messages 2286dc088bc7Smrg --reorder-cache=DIRS reorder shared library cache for preferred DIRS 2287dc088bc7Smrg --tag=TAG use configuration variables from tag TAG 2288dc088bc7Smrg -v, --verbose print more informational messages than default 2289dc088bc7Smrg --version print version information 2290dc088bc7Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2291dc088bc7Smrg -h, --help, --help-all print short, long, or detailed help message 2292949d0342Smrg" 2293cdbfa18aSmrg 2294949d0342Smrg# Additional text appended to 'usage_message' in response to '--help'. 2295949d0342Smrgfunc_help () 2296cdbfa18aSmrg{ 2297949d0342Smrg $debug_cmd 2298949d0342Smrg 2299949d0342Smrg func_usage_message 2300949d0342Smrg $ECHO "$long_help_message 2301949d0342Smrg 2302949d0342SmrgMODE must be one of the following: 2303949d0342Smrg 2304949d0342Smrg clean remove files from the build directory 2305949d0342Smrg compile compile a source file into a libtool object 2306949d0342Smrg execute automatically set library path, then run a program 2307949d0342Smrg finish complete the installation of libtool libraries 2308949d0342Smrg install install libraries or executables 2309949d0342Smrg link create a library or an executable 2310949d0342Smrg uninstall remove libraries from an installed directory 2311949d0342Smrg 2312949d0342SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2313949d0342Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2314949d0342SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2315949d0342Smrg 2316949d0342SmrgWhen reporting a bug, please describe a test case to reproduce it and 2317949d0342Smrginclude the following information: 2318949d0342Smrg 2319949d0342Smrg host-triplet: $host 2320949d0342Smrg shell: $SHELL 2321949d0342Smrg compiler: $LTCC 2322949d0342Smrg compiler flags: $LTCFLAGS 2323949d0342Smrg linker: $LD (gnu? $with_gnu_ld) 2324dc088bc7Smrg version: $progname $scriptversion 2325949d0342Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2326949d0342Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2327949d0342Smrg 2328949d0342SmrgReport bugs to <bug-libtool@gnu.org>. 2329dc088bc7SmrgGNU libtool home page: <https://www.gnu.org/software/libtool/>. 2330dc088bc7SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 2331949d0342Smrg exit 0 2332949d0342Smrg} 2333949d0342Smrg 2334949d0342Smrg 2335949d0342Smrg# func_lo2o OBJECT-NAME 2336949d0342Smrg# --------------------- 2337949d0342Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2338949d0342Smrg# object suffix. 2339949d0342Smrg 2340949d0342Smrglo2o=s/\\.lo\$/.$objext/ 2341949d0342Smrgo2lo=s/\\.$objext\$/.lo/ 2342949d0342Smrg 2343949d0342Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2344949d0342Smrg eval 'func_lo2o () 2345949d0342Smrg { 2346949d0342Smrg case $1 in 2347949d0342Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2348949d0342Smrg * ) func_lo2o_result=$1 ;; 2349949d0342Smrg esac 2350949d0342Smrg }' 2351949d0342Smrg 2352949d0342Smrg # func_xform LIBOBJ-OR-SOURCE 2353949d0342Smrg # --------------------------- 2354949d0342Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2355949d0342Smrg # suffix to a '.lo' libtool-object suffix. 2356949d0342Smrg eval 'func_xform () 2357949d0342Smrg { 2358949d0342Smrg func_xform_result=${1%.*}.lo 2359949d0342Smrg }' 2360949d0342Smrgelse 2361949d0342Smrg # ...otherwise fall back to using sed. 2362949d0342Smrg func_lo2o () 2363949d0342Smrg { 2364949d0342Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2365949d0342Smrg } 2366949d0342Smrg 2367949d0342Smrg func_xform () 2368949d0342Smrg { 2369949d0342Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2370949d0342Smrg } 2371949d0342Smrgfi 2372cdbfa18aSmrg 2373cdbfa18aSmrg 2374949d0342Smrg# func_fatal_configuration ARG... 2375949d0342Smrg# ------------------------------- 2376d5c3dbf1Smrg# Echo program name prefixed message to standard error, followed by 2377d5c3dbf1Smrg# a configuration failure hint, and exit. 2378d5c3dbf1Smrgfunc_fatal_configuration () 2379d5c3dbf1Smrg{ 2380949d0342Smrg func_fatal_error ${1+"$@"} \ 2381949d0342Smrg "See the $PACKAGE documentation for more information." \ 2382949d0342Smrg "Fatal configuration error." 2383d5c3dbf1Smrg} 2384d5c3dbf1Smrg 2385d5c3dbf1Smrg 2386d5c3dbf1Smrg# func_config 2387949d0342Smrg# ----------- 2388d5c3dbf1Smrg# Display the configuration for all the tags in this script. 2389d5c3dbf1Smrgfunc_config () 2390d5c3dbf1Smrg{ 2391d5c3dbf1Smrg re_begincf='^# ### BEGIN LIBTOOL' 2392d5c3dbf1Smrg re_endcf='^# ### END LIBTOOL' 2393d5c3dbf1Smrg 2394d5c3dbf1Smrg # Default configuration. 2395d5c3dbf1Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2396d5c3dbf1Smrg 23979f606849Smrg # Now print the configurations for the tags. 23989f606849Smrg for tagname in $taglist; do 2399d5c3dbf1Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 24009f606849Smrg done 24019f606849Smrg 2402d5c3dbf1Smrg exit $? 2403d5c3dbf1Smrg} 24049f606849Smrg 2405949d0342Smrg 2406d5c3dbf1Smrg# func_features 2407949d0342Smrg# ------------- 2408d5c3dbf1Smrg# Display the features supported by this script. 2409d5c3dbf1Smrgfunc_features () 2410d5c3dbf1Smrg{ 2411d5c3dbf1Smrg echo "host: $host" 2412949d0342Smrg if test yes = "$build_libtool_libs"; then 2413d5c3dbf1Smrg echo "enable shared libraries" 24149f606849Smrg else 2415d5c3dbf1Smrg echo "disable shared libraries" 24169f606849Smrg fi 2417949d0342Smrg if test yes = "$build_old_libs"; then 2418d5c3dbf1Smrg echo "enable static libraries" 24199f606849Smrg else 2420d5c3dbf1Smrg echo "disable static libraries" 24219f606849Smrg fi 2422d5c3dbf1Smrg 24239f606849Smrg exit $? 2424d5c3dbf1Smrg} 24259f606849Smrg 2426949d0342Smrg 2427949d0342Smrg# func_enable_tag TAGNAME 2428949d0342Smrg# ----------------------- 2429d5c3dbf1Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2430d5c3dbf1Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2431d5c3dbf1Smrg# variable here. 2432d5c3dbf1Smrgfunc_enable_tag () 2433d5c3dbf1Smrg{ 2434949d0342Smrg # Global variable: 2435949d0342Smrg tagname=$1 24369f606849Smrg 2437949d0342Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2438949d0342Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2439949d0342Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24409f606849Smrg 2441949d0342Smrg # Validate tagname. 2442949d0342Smrg case $tagname in 2443949d0342Smrg *[!-_A-Za-z0-9,/]*) 2444949d0342Smrg func_fatal_error "invalid tag name: $tagname" 2445949d0342Smrg ;; 2446949d0342Smrg esac 24479f606849Smrg 2448949d0342Smrg # Don't test for the "default" C tag, as we know it's 2449949d0342Smrg # there but not specially marked. 2450949d0342Smrg case $tagname in 2451949d0342Smrg CC) ;; 2452d5c3dbf1Smrg *) 2453949d0342Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2454949d0342Smrg taglist="$taglist $tagname" 2455949d0342Smrg 2456949d0342Smrg # Evaluate the configuration. Be careful to quote the path 2457949d0342Smrg # and the sed script, to avoid splitting on whitespace, but 2458949d0342Smrg # also don't use non-portable quotes within backquotes within 2459949d0342Smrg # quotes we have to do it in 2 steps: 2460949d0342Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2461949d0342Smrg eval "$extractedcf" 2462949d0342Smrg else 2463949d0342Smrg func_error "ignoring unknown tag $tagname" 2464949d0342Smrg fi 2465949d0342Smrg ;; 2466949d0342Smrg esac 2467d5c3dbf1Smrg} 2468d5c3dbf1Smrg 2469949d0342Smrg 2470cdbfa18aSmrg# func_check_version_match 2471949d0342Smrg# ------------------------ 2472cdbfa18aSmrg# Ensure that we are using m4 macros, and libtool script from the same 2473cdbfa18aSmrg# release of libtool. 2474cdbfa18aSmrgfunc_check_version_match () 2475d5c3dbf1Smrg{ 2476949d0342Smrg if test "$package_revision" != "$macro_revision"; then 2477949d0342Smrg if test "$VERSION" != "$macro_version"; then 2478949d0342Smrg if test -z "$macro_version"; then 2479949d0342Smrg cat >&2 <<_LT_EOF 2480cdbfa18aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2481cdbfa18aSmrg$progname: definition of this LT_INIT comes from an older release. 2482cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2483cdbfa18aSmrg$progname: and run autoconf again. 2484cdbfa18aSmrg_LT_EOF 2485949d0342Smrg else 2486949d0342Smrg cat >&2 <<_LT_EOF 2487cdbfa18aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2488cdbfa18aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2489cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2490cdbfa18aSmrg$progname: and run autoconf again. 2491cdbfa18aSmrg_LT_EOF 2492949d0342Smrg fi 2493949d0342Smrg else 2494949d0342Smrg cat >&2 <<_LT_EOF 2495cdbfa18aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2496cdbfa18aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2497cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2498cdbfa18aSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2499cdbfa18aSmrg_LT_EOF 2500949d0342Smrg fi 2501cdbfa18aSmrg 2502949d0342Smrg exit $EXIT_MISMATCH 2503949d0342Smrg fi 2504cdbfa18aSmrg} 2505cdbfa18aSmrg 2506cdbfa18aSmrg 2507949d0342Smrg# libtool_options_prep [ARG]... 2508949d0342Smrg# ----------------------------- 2509949d0342Smrg# Preparation for options parsed by libtool. 2510949d0342Smrglibtool_options_prep () 2511949d0342Smrg{ 2512949d0342Smrg $debug_mode 2513cdbfa18aSmrg 2514949d0342Smrg # Option defaults: 2515949d0342Smrg opt_config=false 2516949d0342Smrg opt_dlopen= 2517949d0342Smrg opt_dry_run=false 2518949d0342Smrg opt_help=false 2519949d0342Smrg opt_mode= 2520dc088bc7Smrg opt_reorder_cache=false 2521949d0342Smrg opt_preserve_dup_deps=false 2522949d0342Smrg opt_quiet=false 2523dc088bc7Smrg opt_finishing=true 2524dc088bc7Smrg opt_warning= 2525cdbfa18aSmrg 2526949d0342Smrg nonopt= 2527949d0342Smrg preserve_args= 25289f606849Smrg 2529949d0342Smrg _G_rc_lt_options_prep=: 25309f606849Smrg 2531949d0342Smrg # Shorthand for --mode=foo, only valid as the first argument 2532949d0342Smrg case $1 in 2533949d0342Smrg clean|clea|cle|cl) 2534949d0342Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2535949d0342Smrg ;; 2536949d0342Smrg compile|compil|compi|comp|com|co|c) 2537949d0342Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2538949d0342Smrg ;; 2539949d0342Smrg execute|execut|execu|exec|exe|ex|e) 2540949d0342Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2541949d0342Smrg ;; 2542949d0342Smrg finish|finis|fini|fin|fi|f) 2543949d0342Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2544949d0342Smrg ;; 2545949d0342Smrg install|instal|insta|inst|ins|in|i) 2546949d0342Smrg shift; set dummy --mode install ${1+"$@"}; shift 2547949d0342Smrg ;; 2548949d0342Smrg link|lin|li|l) 2549949d0342Smrg shift; set dummy --mode link ${1+"$@"}; shift 2550949d0342Smrg ;; 2551949d0342Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2552949d0342Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2553949d0342Smrg ;; 2554949d0342Smrg *) 2555949d0342Smrg _G_rc_lt_options_prep=false 2556949d0342Smrg ;; 2557d5c3dbf1Smrg esac 2558d5c3dbf1Smrg 2559949d0342Smrg if $_G_rc_lt_options_prep; then 2560949d0342Smrg # Pass back the list of options. 2561949d0342Smrg func_quote eval ${1+"$@"} 2562949d0342Smrg libtool_options_prep_result=$func_quote_result 2563949d0342Smrg fi 2564949d0342Smrg} 2565949d0342Smrgfunc_add_hook func_options_prep libtool_options_prep 2566cdbfa18aSmrg 2567cdbfa18aSmrg 2568949d0342Smrg# libtool_parse_options [ARG]... 2569949d0342Smrg# --------------------------------- 2570949d0342Smrg# Provide handling for libtool specific options. 2571949d0342Smrglibtool_parse_options () 2572949d0342Smrg{ 2573949d0342Smrg $debug_cmd 2574d5c3dbf1Smrg 2575949d0342Smrg _G_rc_lt_parse_options=false 25769f606849Smrg 2577949d0342Smrg # Perform our own loop to consume as many options as possible in 2578949d0342Smrg # each iteration. 2579949d0342Smrg while test $# -gt 0; do 2580949d0342Smrg _G_match_lt_parse_options=: 2581949d0342Smrg _G_opt=$1 2582949d0342Smrg shift 2583949d0342Smrg case $_G_opt in 2584949d0342Smrg --dry-run|--dryrun|-n) 2585949d0342Smrg opt_dry_run=: 2586949d0342Smrg ;; 2587949d0342Smrg 2588949d0342Smrg --config) func_config ;; 2589949d0342Smrg 2590949d0342Smrg --dlopen|-dlopen) 2591949d0342Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2592949d0342Smrg}$1" 2593949d0342Smrg shift 2594949d0342Smrg ;; 2595949d0342Smrg 2596949d0342Smrg --preserve-dup-deps) 2597949d0342Smrg opt_preserve_dup_deps=: ;; 2598949d0342Smrg 2599949d0342Smrg --features) func_features ;; 2600949d0342Smrg 2601949d0342Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2602949d0342Smrg 2603949d0342Smrg --help) opt_help=: ;; 2604949d0342Smrg 2605949d0342Smrg --help-all) opt_help=': help-all' ;; 2606949d0342Smrg 2607949d0342Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2608949d0342Smrg opt_mode=$1 2609949d0342Smrg case $1 in 2610949d0342Smrg # Valid mode arguments: 2611949d0342Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2612949d0342Smrg 2613949d0342Smrg # Catch anything else as an error 2614dc088bc7Smrg *) func_error "invalid argument '$1' for $_G_opt" 2615949d0342Smrg exit_cmd=exit 2616949d0342Smrg ;; 2617949d0342Smrg esac 2618949d0342Smrg shift 2619949d0342Smrg ;; 2620949d0342Smrg 2621dc088bc7Smrg --no-finish) 2622dc088bc7Smrg opt_finishing=false 2623dc088bc7Smrg func_append preserve_args " $_G_opt" 2624dc088bc7Smrg ;; 2625dc088bc7Smrg 2626949d0342Smrg --no-silent|--no-quiet) 2627949d0342Smrg opt_quiet=false 2628949d0342Smrg func_append preserve_args " $_G_opt" 2629949d0342Smrg ;; 2630949d0342Smrg 2631949d0342Smrg --no-warnings|--no-warning|--no-warn) 2632949d0342Smrg opt_warning=false 2633949d0342Smrg func_append preserve_args " $_G_opt" 2634949d0342Smrg ;; 2635949d0342Smrg 2636949d0342Smrg --no-verbose) 2637949d0342Smrg opt_verbose=false 2638949d0342Smrg func_append preserve_args " $_G_opt" 2639949d0342Smrg ;; 2640949d0342Smrg 2641dc088bc7Smrg --reorder-cache) 2642dc088bc7Smrg opt_reorder_cache=true 2643dc088bc7Smrg shared_lib_dirs=$1 2644dc088bc7Smrg if test -n "$shared_lib_dirs"; then 2645dc088bc7Smrg case $1 in 2646dc088bc7Smrg # Must begin with /: 2647dc088bc7Smrg /*) ;; 2648dc088bc7Smrg 2649dc088bc7Smrg # Catch anything else as an error (relative paths) 2650dc088bc7Smrg *) func_error "invalid argument '$1' for $_G_opt" 2651dc088bc7Smrg func_error "absolute paths are required for $_G_opt" 2652dc088bc7Smrg exit_cmd=exit 2653dc088bc7Smrg ;; 2654dc088bc7Smrg esac 2655dc088bc7Smrg fi 2656dc088bc7Smrg shift 2657dc088bc7Smrg ;; 2658dc088bc7Smrg 2659949d0342Smrg --silent|--quiet) 2660949d0342Smrg opt_quiet=: 2661949d0342Smrg opt_verbose=false 2662949d0342Smrg func_append preserve_args " $_G_opt" 2663949d0342Smrg ;; 2664949d0342Smrg 2665949d0342Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2666949d0342Smrg opt_tag=$1 2667949d0342Smrg func_append preserve_args " $_G_opt $1" 2668949d0342Smrg func_enable_tag "$1" 2669949d0342Smrg shift 2670949d0342Smrg ;; 2671949d0342Smrg 2672949d0342Smrg --verbose|-v) opt_quiet=false 2673949d0342Smrg opt_verbose=: 2674949d0342Smrg func_append preserve_args " $_G_opt" 2675949d0342Smrg ;; 2676949d0342Smrg 2677949d0342Smrg # An option not handled by this hook function: 2678949d0342Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2679949d0342Smrg _G_match_lt_parse_options=false 2680949d0342Smrg break 2681949d0342Smrg ;; 2682949d0342Smrg esac 2683949d0342Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2684949d0342Smrg done 2685d5c3dbf1Smrg 2686949d0342Smrg if $_G_rc_lt_parse_options; then 2687949d0342Smrg # save modified positional parameters for caller 2688949d0342Smrg func_quote eval ${1+"$@"} 2689949d0342Smrg libtool_parse_options_result=$func_quote_result 2690d5c3dbf1Smrg fi 2691949d0342Smrg} 2692949d0342Smrgfunc_add_hook func_parse_options libtool_parse_options 2693949d0342Smrg 2694d5c3dbf1Smrg 2695dc088bc7Smrg# func_warning ARG... 2696dc088bc7Smrg# ------------------- 2697dc088bc7Smrg# Libtool warnings are not categorized, so override funclib.sh 2698dc088bc7Smrg# func_warning with this simpler definition. 2699dc088bc7Smrgfunc_warning () 2700dc088bc7Smrg{ 2701dc088bc7Smrg if $opt_warning; then 2702dc088bc7Smrg $debug_cmd 2703dc088bc7Smrg $warning_func ${1+"$@"} 2704dc088bc7Smrg fi 2705dc088bc7Smrg} 2706dc088bc7Smrg 2707d5c3dbf1Smrg 2708949d0342Smrg# libtool_validate_options [ARG]... 2709949d0342Smrg# --------------------------------- 2710949d0342Smrg# Perform any sanity checks on option settings and/or unconsumed 2711949d0342Smrg# arguments. 2712949d0342Smrglibtool_validate_options () 2713949d0342Smrg{ 2714949d0342Smrg # save first non-option argument 2715949d0342Smrg if test 0 -lt $#; then 2716949d0342Smrg nonopt=$1 2717949d0342Smrg shift 2718cdbfa18aSmrg fi 2719d5c3dbf1Smrg 2720949d0342Smrg # preserve --debug 2721949d0342Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2722949d0342Smrg 2723dc088bc7Smrg case $host_os in 2724949d0342Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2725949d0342Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2726dc088bc7Smrg cygwin* | mingw* | windows* | pw32* | cegcc* | solaris2* | os2*) 2727949d0342Smrg # don't eliminate duplications in $postdeps and $predeps 2728949d0342Smrg opt_duplicate_compiler_generated_deps=: 2729949d0342Smrg ;; 2730949d0342Smrg *) 2731949d0342Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2732949d0342Smrg ;; 2733949d0342Smrg esac 2734949d0342Smrg 2735949d0342Smrg $opt_help || { 2736949d0342Smrg # Sanity checks first: 2737949d0342Smrg func_check_version_match 2738949d0342Smrg 2739949d0342Smrg test yes != "$build_libtool_libs" \ 2740949d0342Smrg && test yes != "$build_old_libs" \ 2741949d0342Smrg && func_fatal_configuration "not configured to build any kind of library" 2742949d0342Smrg 2743949d0342Smrg # Darwin sucks 2744949d0342Smrg eval std_shrext=\"$shrext_cmds\" 2745d5c3dbf1Smrg 2746949d0342Smrg # Only execute mode is allowed to have -dlopen flags. 2747949d0342Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2748949d0342Smrg func_error "unrecognized option '-dlopen'" 2749949d0342Smrg $ECHO "$help" 1>&2 2750949d0342Smrg exit $EXIT_FAILURE 2751949d0342Smrg fi 2752949d0342Smrg 2753949d0342Smrg # Change the help message to a mode-specific one. 2754949d0342Smrg generic_help=$help 2755949d0342Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2756949d0342Smrg } 2757d5c3dbf1Smrg 2758949d0342Smrg # Pass back the unparsed argument list 2759949d0342Smrg func_quote eval ${1+"$@"} 2760949d0342Smrg libtool_validate_options_result=$func_quote_result 2761cdbfa18aSmrg} 2762949d0342Smrgfunc_add_hook func_validate_options libtool_validate_options 2763949d0342Smrg 2764d5c3dbf1Smrg 2765949d0342Smrg# Process options as early as possible so that --help and --version 2766949d0342Smrg# can return quickly. 2767949d0342Smrgfunc_options ${1+"$@"} 2768949d0342Smrgeval set dummy "$func_options_result"; shift 2769d5c3dbf1Smrg 27709f606849Smrg 27719f606849Smrg 2772cdbfa18aSmrg## ----------- ## 2773cdbfa18aSmrg## Main. ## 2774cdbfa18aSmrg## ----------- ## 27759f606849Smrg 2776949d0342Smrgmagic='%%%MAGIC variable%%%' 2777949d0342Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2778949d0342Smrg 2779949d0342Smrg# Global variables. 2780949d0342Smrgextracted_archives= 2781949d0342Smrgextracted_serial=0 2782949d0342Smrg 2783949d0342Smrg# If this variable is set in any of the actions, the command in it 2784949d0342Smrg# will be execed at the end. This prevents here-documents from being 2785949d0342Smrg# left over by shells. 2786949d0342Smrgexec_cmd= 2787949d0342Smrg 2788949d0342Smrg 2789949d0342Smrg# A function that is used when there is no print builtin or printf. 2790949d0342Smrgfunc_fallback_echo () 2791949d0342Smrg{ 2792949d0342Smrg eval 'cat <<_LTECHO_EOF 2793949d0342Smrg$1 2794949d0342Smrg_LTECHO_EOF' 2795949d0342Smrg} 2796949d0342Smrg 2797949d0342Smrg# func_generated_by_libtool 2798949d0342Smrg# True iff stdin has been generated by Libtool. This function is only 2799949d0342Smrg# a basic sanity check; it will hardly flush out determined imposters. 2800949d0342Smrgfunc_generated_by_libtool_p () 2801949d0342Smrg{ 2802949d0342Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2803949d0342Smrg} 2804949d0342Smrg 2805d5c3dbf1Smrg# func_lalib_p file 2806949d0342Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2807d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2808d5c3dbf1Smrg# determined imposters. 2809d5c3dbf1Smrgfunc_lalib_p () 2810d5c3dbf1Smrg{ 2811d5c3dbf1Smrg test -f "$1" && 2812949d0342Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2813d5c3dbf1Smrg} 28149f606849Smrg 2815d5c3dbf1Smrg# func_lalib_unsafe_p file 2816949d0342Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2817d5c3dbf1Smrg# This function implements the same check as func_lalib_p without 2818d5c3dbf1Smrg# resorting to external programs. To this end, it redirects stdin and 2819d5c3dbf1Smrg# closes it afterwards, without saving the original file descriptor. 2820d5c3dbf1Smrg# As a safety measure, use it only where a negative result would be 2821949d0342Smrg# fatal anyway. Works if 'file' does not exist. 2822d5c3dbf1Smrgfunc_lalib_unsafe_p () 2823d5c3dbf1Smrg{ 2824d5c3dbf1Smrg lalib_p=no 2825d5c3dbf1Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2826d5c3dbf1Smrg for lalib_p_l in 1 2 3 4 2827d5c3dbf1Smrg do 2828d5c3dbf1Smrg read lalib_p_line 2829949d0342Smrg case $lalib_p_line in 2830d5c3dbf1Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2831d5c3dbf1Smrg esac 2832d5c3dbf1Smrg done 2833d5c3dbf1Smrg exec 0<&5 5<&- 2834d5c3dbf1Smrg fi 2835949d0342Smrg test yes = "$lalib_p" 2836d5c3dbf1Smrg} 28379f606849Smrg 2838d5c3dbf1Smrg# func_ltwrapper_script_p file 2839d5c3dbf1Smrg# True iff FILE is a libtool wrapper script 2840d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2841d5c3dbf1Smrg# determined imposters. 2842d5c3dbf1Smrgfunc_ltwrapper_script_p () 2843d5c3dbf1Smrg{ 2844949d0342Smrg test -f "$1" && 2845949d0342Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2846d5c3dbf1Smrg} 28479f606849Smrg 2848d5c3dbf1Smrg# func_ltwrapper_executable_p file 2849d5c3dbf1Smrg# True iff FILE is a libtool wrapper executable 2850d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2851d5c3dbf1Smrg# determined imposters. 2852d5c3dbf1Smrgfunc_ltwrapper_executable_p () 2853d5c3dbf1Smrg{ 2854d5c3dbf1Smrg func_ltwrapper_exec_suffix= 2855d5c3dbf1Smrg case $1 in 2856d5c3dbf1Smrg *.exe) ;; 2857d5c3dbf1Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2858d5c3dbf1Smrg esac 2859d5c3dbf1Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2860d5c3dbf1Smrg} 2861d5c3dbf1Smrg 2862d5c3dbf1Smrg# func_ltwrapper_scriptname file 2863d5c3dbf1Smrg# Assumes file is an ltwrapper_executable 2864d5c3dbf1Smrg# uses $file to determine the appropriate filename for a 2865d5c3dbf1Smrg# temporary ltwrapper_script. 2866d5c3dbf1Smrgfunc_ltwrapper_scriptname () 2867d5c3dbf1Smrg{ 2868cdbfa18aSmrg func_dirname_and_basename "$1" "" "." 2869cdbfa18aSmrg func_stripname '' '.exe' "$func_basename_result" 2870949d0342Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2871d5c3dbf1Smrg} 2872d5c3dbf1Smrg 2873d5c3dbf1Smrg# func_ltwrapper_p file 2874d5c3dbf1Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2875d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2876d5c3dbf1Smrg# determined imposters. 2877d5c3dbf1Smrgfunc_ltwrapper_p () 2878d5c3dbf1Smrg{ 2879d5c3dbf1Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2880d5c3dbf1Smrg} 2881d5c3dbf1Smrg 2882d5c3dbf1Smrg 2883d5c3dbf1Smrg# func_execute_cmds commands fail_cmd 2884d5c3dbf1Smrg# Execute tilde-delimited COMMANDS. 2885d5c3dbf1Smrg# If FAIL_CMD is given, eval that upon failure. 2886d5c3dbf1Smrg# FAIL_CMD may read-access the current command in variable CMD! 2887d5c3dbf1Smrgfunc_execute_cmds () 2888d5c3dbf1Smrg{ 2889949d0342Smrg $debug_cmd 2890949d0342Smrg 2891d5c3dbf1Smrg save_ifs=$IFS; IFS='~' 2892d5c3dbf1Smrg for cmd in $1; do 2893949d0342Smrg IFS=$sp$nl 2894d5c3dbf1Smrg eval cmd=\"$cmd\" 2895949d0342Smrg IFS=$save_ifs 2896d5c3dbf1Smrg func_show_eval "$cmd" "${2-:}" 2897d5c3dbf1Smrg done 2898d5c3dbf1Smrg IFS=$save_ifs 2899d5c3dbf1Smrg} 2900d5c3dbf1Smrg 2901d5c3dbf1Smrg 2902d5c3dbf1Smrg# func_source file 2903d5c3dbf1Smrg# Source FILE, adding directory component if necessary. 2904d5c3dbf1Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2905d5c3dbf1Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2906d5c3dbf1Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2907949d0342Smrg# 'FILE.' does not work on cygwin managed mounts. 2908d5c3dbf1Smrgfunc_source () 2909d5c3dbf1Smrg{ 2910949d0342Smrg $debug_cmd 2911949d0342Smrg 2912d5c3dbf1Smrg case $1 in 2913d5c3dbf1Smrg */* | *\\*) . "$1" ;; 2914d5c3dbf1Smrg *) . "./$1" ;; 2915d5c3dbf1Smrg esac 2916d5c3dbf1Smrg} 2917d5c3dbf1Smrg 2918d5c3dbf1Smrg 2919cdbfa18aSmrg# func_resolve_sysroot PATH 2920cdbfa18aSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2921cdbfa18aSmrg# func_resolve_sysroot_result 2922cdbfa18aSmrgfunc_resolve_sysroot () 2923cdbfa18aSmrg{ 2924cdbfa18aSmrg func_resolve_sysroot_result=$1 2925cdbfa18aSmrg case $func_resolve_sysroot_result in 2926cdbfa18aSmrg =*) 2927cdbfa18aSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2928cdbfa18aSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2929cdbfa18aSmrg ;; 2930cdbfa18aSmrg esac 2931cdbfa18aSmrg} 2932cdbfa18aSmrg 2933cdbfa18aSmrg# func_replace_sysroot PATH 2934cdbfa18aSmrg# If PATH begins with the sysroot, replace it with = and 2935cdbfa18aSmrg# store the result into func_replace_sysroot_result. 2936cdbfa18aSmrgfunc_replace_sysroot () 2937cdbfa18aSmrg{ 2938949d0342Smrg case $lt_sysroot:$1 in 2939cdbfa18aSmrg ?*:"$lt_sysroot"*) 2940cdbfa18aSmrg func_stripname "$lt_sysroot" '' "$1" 2941949d0342Smrg func_replace_sysroot_result='='$func_stripname_result 2942cdbfa18aSmrg ;; 2943cdbfa18aSmrg *) 2944cdbfa18aSmrg # Including no sysroot. 2945cdbfa18aSmrg func_replace_sysroot_result=$1 2946cdbfa18aSmrg ;; 2947cdbfa18aSmrg esac 2948cdbfa18aSmrg} 2949cdbfa18aSmrg 2950d5c3dbf1Smrg# func_infer_tag arg 2951d5c3dbf1Smrg# Infer tagged configuration to use if any are available and 2952d5c3dbf1Smrg# if one wasn't chosen via the "--tag" command line option. 2953d5c3dbf1Smrg# Only attempt this if the compiler in the base compile 2954d5c3dbf1Smrg# command doesn't match the default compiler. 2955d5c3dbf1Smrg# arg is usually of the form 'gcc ...' 2956d5c3dbf1Smrgfunc_infer_tag () 2957d5c3dbf1Smrg{ 2958949d0342Smrg $debug_cmd 2959949d0342Smrg 2960d5c3dbf1Smrg if test -n "$available_tags" && test -z "$tagname"; then 2961d5c3dbf1Smrg CC_quoted= 2962d5c3dbf1Smrg for arg in $CC; do 2963cdbfa18aSmrg func_append_quoted CC_quoted "$arg" 2964d5c3dbf1Smrg done 2965d5c3dbf1Smrg CC_expanded=`func_echo_all $CC` 2966d5c3dbf1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2967d5c3dbf1Smrg case $@ in 2968d5c3dbf1Smrg # Blanks in the command may have been stripped by the calling shell, 2969d5c3dbf1Smrg # but not from the CC environment variable when configure was run. 2970d5c3dbf1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2971d5c3dbf1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2972d5c3dbf1Smrg # Blanks at the start of $base_compile will cause this to fail 2973d5c3dbf1Smrg # if we don't check for them as well. 2974d5c3dbf1Smrg *) 2975d5c3dbf1Smrg for z in $available_tags; do 2976d5c3dbf1Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2977d5c3dbf1Smrg # Evaluate the configuration. 2978949d0342Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2979d5c3dbf1Smrg CC_quoted= 2980d5c3dbf1Smrg for arg in $CC; do 2981d5c3dbf1Smrg # Double-quote args containing other shell metacharacters. 2982cdbfa18aSmrg func_append_quoted CC_quoted "$arg" 2983d5c3dbf1Smrg done 2984d5c3dbf1Smrg CC_expanded=`func_echo_all $CC` 2985d5c3dbf1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2986d5c3dbf1Smrg case "$@ " in 2987d5c3dbf1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2988d5c3dbf1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2989d5c3dbf1Smrg # The compiler in the base compile command matches 2990d5c3dbf1Smrg # the one in the tagged configuration. 2991d5c3dbf1Smrg # Assume this is the tagged configuration we want. 2992d5c3dbf1Smrg tagname=$z 2993d5c3dbf1Smrg break 2994d5c3dbf1Smrg ;; 2995d5c3dbf1Smrg esac 2996d5c3dbf1Smrg fi 2997d5c3dbf1Smrg done 2998d5c3dbf1Smrg # If $tagname still isn't set, then no tagged configuration 2999d5c3dbf1Smrg # was found and let the user know that the "--tag" command 3000d5c3dbf1Smrg # line option must be used. 3001d5c3dbf1Smrg if test -z "$tagname"; then 3002d5c3dbf1Smrg func_echo "unable to infer tagged configuration" 3003949d0342Smrg func_fatal_error "specify a tag with '--tag'" 3004d5c3dbf1Smrg# else 3005d5c3dbf1Smrg# func_verbose "using $tagname tagged configuration" 3006d5c3dbf1Smrg fi 3007d5c3dbf1Smrg ;; 3008d5c3dbf1Smrg esac 3009d5c3dbf1Smrg fi 3010d5c3dbf1Smrg} 3011d5c3dbf1Smrg 3012d5c3dbf1Smrg 3013cdbfa18aSmrg 3014cdbfa18aSmrg# func_write_libtool_object output_name pic_name nonpic_name 3015cdbfa18aSmrg# Create a libtool object file (analogous to a ".la" file), 3016cdbfa18aSmrg# but don't create it if we're doing a dry run. 3017cdbfa18aSmrgfunc_write_libtool_object () 3018cdbfa18aSmrg{ 3019949d0342Smrg write_libobj=$1 3020949d0342Smrg if test yes = "$build_libtool_libs"; then 3021949d0342Smrg write_lobj=\'$2\' 3022cdbfa18aSmrg else 3023cdbfa18aSmrg write_lobj=none 3024cdbfa18aSmrg fi 3025cdbfa18aSmrg 3026949d0342Smrg if test yes = "$build_old_libs"; then 3027949d0342Smrg write_oldobj=\'$3\' 3028cdbfa18aSmrg else 3029cdbfa18aSmrg write_oldobj=none 3030cdbfa18aSmrg fi 3031cdbfa18aSmrg 3032cdbfa18aSmrg $opt_dry_run || { 3033cdbfa18aSmrg cat >${write_libobj}T <<EOF 3034cdbfa18aSmrg# $write_libobj - a libtool object file 3035949d0342Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 3036cdbfa18aSmrg# 3037cdbfa18aSmrg# Please DO NOT delete this file! 3038cdbfa18aSmrg# It is necessary for linking the library. 3039cdbfa18aSmrg 3040cdbfa18aSmrg# Name of the PIC object. 3041cdbfa18aSmrgpic_object=$write_lobj 3042cdbfa18aSmrg 3043cdbfa18aSmrg# Name of the non-PIC object 3044cdbfa18aSmrgnon_pic_object=$write_oldobj 3045cdbfa18aSmrg 3046cdbfa18aSmrgEOF 3047949d0342Smrg $MV "${write_libobj}T" "$write_libobj" 3048cdbfa18aSmrg } 3049cdbfa18aSmrg} 3050cdbfa18aSmrg 3051cdbfa18aSmrg 3052cdbfa18aSmrg################################################## 3053cdbfa18aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3054cdbfa18aSmrg################################################## 3055cdbfa18aSmrg 3056cdbfa18aSmrg# func_convert_core_file_wine_to_w32 ARG 3057cdbfa18aSmrg# Helper function used by file name conversion functions when $build is *nix, 3058dc088bc7Smrg# and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a 3059cdbfa18aSmrg# correctly configured wine environment available, with the winepath program 3060cdbfa18aSmrg# in $build's $PATH. 3061cdbfa18aSmrg# 3062cdbfa18aSmrg# ARG is the $build file name to be converted to w32 format. 3063cdbfa18aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3064cdbfa18aSmrg# be empty on error (or when ARG is empty) 3065cdbfa18aSmrgfunc_convert_core_file_wine_to_w32 () 3066cdbfa18aSmrg{ 3067949d0342Smrg $debug_cmd 3068949d0342Smrg 3069949d0342Smrg func_convert_core_file_wine_to_w32_result=$1 3070cdbfa18aSmrg if test -n "$1"; then 3071cdbfa18aSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3072cdbfa18aSmrg # are forced to check the contents of stdout. On the other hand, if the 3073cdbfa18aSmrg # command is not found, the shell will set an exit code of 127 and print 3074cdbfa18aSmrg # *an error message* to stdout. So we must check for both error code of 3075cdbfa18aSmrg # zero AND non-empty stdout, which explains the odd construction: 3076cdbfa18aSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3077949d0342Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3078cdbfa18aSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3079949d0342Smrg $SED -e "$sed_naive_backslashify"` 3080cdbfa18aSmrg else 3081cdbfa18aSmrg func_convert_core_file_wine_to_w32_result= 3082cdbfa18aSmrg fi 3083cdbfa18aSmrg fi 3084cdbfa18aSmrg} 3085cdbfa18aSmrg# end: func_convert_core_file_wine_to_w32 3086cdbfa18aSmrg 3087cdbfa18aSmrg 3088cdbfa18aSmrg# func_convert_core_path_wine_to_w32 ARG 3089cdbfa18aSmrg# Helper function used by path conversion functions when $build is *nix, and 3090dc088bc7Smrg# $host is mingw, windows, cygwin, or some other w32 environment. Relies on a 3091dc088bc7Smrg# correctly configured wine environment available, with the winepath program 3092dc088bc7Smrg# in $build's $PATH. Assumes ARG has no leading or trailing path separator 3093dc088bc7Smrg# characters. 3094cdbfa18aSmrg# 3095cdbfa18aSmrg# ARG is path to be converted from $build format to win32. 3096cdbfa18aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3097cdbfa18aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3098cdbfa18aSmrg# are convertible, then the result may be empty. 3099cdbfa18aSmrgfunc_convert_core_path_wine_to_w32 () 3100cdbfa18aSmrg{ 3101949d0342Smrg $debug_cmd 3102949d0342Smrg 3103cdbfa18aSmrg # unfortunately, winepath doesn't convert paths, only file names 3104949d0342Smrg func_convert_core_path_wine_to_w32_result= 3105cdbfa18aSmrg if test -n "$1"; then 3106cdbfa18aSmrg oldIFS=$IFS 3107cdbfa18aSmrg IFS=: 3108cdbfa18aSmrg for func_convert_core_path_wine_to_w32_f in $1; do 3109cdbfa18aSmrg IFS=$oldIFS 3110cdbfa18aSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3111949d0342Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3112cdbfa18aSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3113949d0342Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3114cdbfa18aSmrg else 3115cdbfa18aSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3116cdbfa18aSmrg fi 3117cdbfa18aSmrg fi 3118cdbfa18aSmrg done 3119cdbfa18aSmrg IFS=$oldIFS 3120cdbfa18aSmrg fi 3121cdbfa18aSmrg} 3122cdbfa18aSmrg# end: func_convert_core_path_wine_to_w32 3123cdbfa18aSmrg 3124cdbfa18aSmrg 3125cdbfa18aSmrg# func_cygpath ARGS... 3126cdbfa18aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3127cdbfa18aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3128cdbfa18aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3129cdbfa18aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3130cdbfa18aSmrg# file name or path is assumed to be in w32 format, as previously converted 3131cdbfa18aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3132cdbfa18aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 3133cdbfa18aSmrg# Cygwin format). Returns an empty string on error. 3134cdbfa18aSmrg# 3135cdbfa18aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 3136cdbfa18aSmrg# be converted. 3137cdbfa18aSmrg# 3138cdbfa18aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3139cdbfa18aSmrg# environment variable; do not put it in $PATH. 3140cdbfa18aSmrgfunc_cygpath () 3141cdbfa18aSmrg{ 3142949d0342Smrg $debug_cmd 3143949d0342Smrg 3144cdbfa18aSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3145cdbfa18aSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3146cdbfa18aSmrg if test "$?" -ne 0; then 3147cdbfa18aSmrg # on failure, ensure result is empty 3148cdbfa18aSmrg func_cygpath_result= 3149cdbfa18aSmrg fi 3150cdbfa18aSmrg else 3151cdbfa18aSmrg func_cygpath_result= 3152949d0342Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3153cdbfa18aSmrg fi 3154cdbfa18aSmrg} 3155cdbfa18aSmrg#end: func_cygpath 3156cdbfa18aSmrg 3157cdbfa18aSmrg 3158cdbfa18aSmrg# func_convert_core_msys_to_w32 ARG 3159cdbfa18aSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 3160cdbfa18aSmrg# result in func_convert_core_msys_to_w32_result. 3161cdbfa18aSmrgfunc_convert_core_msys_to_w32 () 3162cdbfa18aSmrg{ 3163949d0342Smrg $debug_cmd 3164949d0342Smrg 3165cdbfa18aSmrg # awkward: cmd appends spaces to result 3166cdbfa18aSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3167949d0342Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3168cdbfa18aSmrg} 3169cdbfa18aSmrg#end: func_convert_core_msys_to_w32 3170cdbfa18aSmrg 3171cdbfa18aSmrg 3172cdbfa18aSmrg# func_convert_file_check ARG1 ARG2 3173cdbfa18aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 3174cdbfa18aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3175cdbfa18aSmrg# func_to_host_file_result to ARG1). 3176cdbfa18aSmrgfunc_convert_file_check () 3177cdbfa18aSmrg{ 3178949d0342Smrg $debug_cmd 3179949d0342Smrg 3180949d0342Smrg if test -z "$2" && test -n "$1"; then 3181cdbfa18aSmrg func_error "Could not determine host file name corresponding to" 3182949d0342Smrg func_error " '$1'" 3183cdbfa18aSmrg func_error "Continuing, but uninstalled executables may not work." 3184cdbfa18aSmrg # Fallback: 3185949d0342Smrg func_to_host_file_result=$1 3186cdbfa18aSmrg fi 3187cdbfa18aSmrg} 3188cdbfa18aSmrg# end func_convert_file_check 3189cdbfa18aSmrg 3190cdbfa18aSmrg 3191cdbfa18aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3192cdbfa18aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3193cdbfa18aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3194cdbfa18aSmrg# func_to_host_file_result to a simplistic fallback value (see below). 3195cdbfa18aSmrgfunc_convert_path_check () 3196cdbfa18aSmrg{ 3197949d0342Smrg $debug_cmd 3198949d0342Smrg 3199cdbfa18aSmrg if test -z "$4" && test -n "$3"; then 3200cdbfa18aSmrg func_error "Could not determine the host path corresponding to" 3201949d0342Smrg func_error " '$3'" 3202cdbfa18aSmrg func_error "Continuing, but uninstalled executables may not work." 3203cdbfa18aSmrg # Fallback. This is a deliberately simplistic "conversion" and 3204cdbfa18aSmrg # should not be "improved". See libtool.info. 3205cdbfa18aSmrg if test "x$1" != "x$2"; then 3206cdbfa18aSmrg lt_replace_pathsep_chars="s|$1|$2|g" 3207cdbfa18aSmrg func_to_host_path_result=`echo "$3" | 3208cdbfa18aSmrg $SED -e "$lt_replace_pathsep_chars"` 3209cdbfa18aSmrg else 3210949d0342Smrg func_to_host_path_result=$3 3211cdbfa18aSmrg fi 3212cdbfa18aSmrg fi 3213cdbfa18aSmrg} 3214cdbfa18aSmrg# end func_convert_path_check 3215cdbfa18aSmrg 3216cdbfa18aSmrg 3217cdbfa18aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3218cdbfa18aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3219cdbfa18aSmrg# and appending REPL if ORIG matches BACKPAT. 3220cdbfa18aSmrgfunc_convert_path_front_back_pathsep () 3221cdbfa18aSmrg{ 3222949d0342Smrg $debug_cmd 3223949d0342Smrg 3224cdbfa18aSmrg case $4 in 3225949d0342Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3226cdbfa18aSmrg ;; 3227cdbfa18aSmrg esac 3228cdbfa18aSmrg case $4 in 3229cdbfa18aSmrg $2 ) func_append func_to_host_path_result "$3" 3230cdbfa18aSmrg ;; 3231cdbfa18aSmrg esac 3232cdbfa18aSmrg} 3233cdbfa18aSmrg# end func_convert_path_front_back_pathsep 3234cdbfa18aSmrg 3235cdbfa18aSmrg 3236dc088bc7Smrg# func_convert_delimited_path PATH ORIG_DELIMITER NEW_DELIMITER 3237dc088bc7Smrg# Replaces a delimiter for a given path. 3238dc088bc7Smrgfunc_convert_delimited_path () 3239dc088bc7Smrg{ 3240dc088bc7Smrg converted_path=`$ECHO "$1" | $SED "s#$2#$3#g"` 3241dc088bc7Smrg} 3242dc088bc7Smrg# end func_convert_delimited_path 3243dc088bc7Smrg 3244dc088bc7Smrg 3245cdbfa18aSmrg################################################## 3246cdbfa18aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3247cdbfa18aSmrg################################################## 3248949d0342Smrg# invoked via '$to_host_file_cmd ARG' 3249cdbfa18aSmrg# 3250cdbfa18aSmrg# In each case, ARG is the path to be converted from $build to $host format. 3251cdbfa18aSmrg# Result will be available in $func_to_host_file_result. 3252cdbfa18aSmrg 3253cdbfa18aSmrg 3254cdbfa18aSmrg# func_to_host_file ARG 3255cdbfa18aSmrg# Converts the file name ARG from $build format to $host format. Return result 3256cdbfa18aSmrg# in func_to_host_file_result. 3257cdbfa18aSmrgfunc_to_host_file () 3258cdbfa18aSmrg{ 3259949d0342Smrg $debug_cmd 3260949d0342Smrg 3261cdbfa18aSmrg $to_host_file_cmd "$1" 3262cdbfa18aSmrg} 3263cdbfa18aSmrg# end func_to_host_file 3264cdbfa18aSmrg 3265cdbfa18aSmrg 3266cdbfa18aSmrg# func_to_tool_file ARG LAZY 3267cdbfa18aSmrg# converts the file name ARG from $build format to toolchain format. Return 3268cdbfa18aSmrg# result in func_to_tool_file_result. If the conversion in use is listed 3269cdbfa18aSmrg# in (the comma separated) LAZY, no conversion takes place. 3270cdbfa18aSmrgfunc_to_tool_file () 3271cdbfa18aSmrg{ 3272949d0342Smrg $debug_cmd 3273949d0342Smrg 3274cdbfa18aSmrg case ,$2, in 3275cdbfa18aSmrg *,"$to_tool_file_cmd",*) 3276cdbfa18aSmrg func_to_tool_file_result=$1 3277cdbfa18aSmrg ;; 3278cdbfa18aSmrg *) 3279cdbfa18aSmrg $to_tool_file_cmd "$1" 3280cdbfa18aSmrg func_to_tool_file_result=$func_to_host_file_result 3281cdbfa18aSmrg ;; 3282cdbfa18aSmrg esac 3283cdbfa18aSmrg} 3284cdbfa18aSmrg# end func_to_tool_file 3285cdbfa18aSmrg 3286cdbfa18aSmrg 3287cdbfa18aSmrg# func_convert_file_noop ARG 3288cdbfa18aSmrg# Copy ARG to func_to_host_file_result. 3289cdbfa18aSmrgfunc_convert_file_noop () 3290cdbfa18aSmrg{ 3291949d0342Smrg func_to_host_file_result=$1 3292cdbfa18aSmrg} 3293cdbfa18aSmrg# end func_convert_file_noop 3294cdbfa18aSmrg 3295cdbfa18aSmrg 3296cdbfa18aSmrg# func_convert_file_msys_to_w32 ARG 3297cdbfa18aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3298cdbfa18aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3299cdbfa18aSmrg# func_to_host_file_result. 3300cdbfa18aSmrgfunc_convert_file_msys_to_w32 () 3301cdbfa18aSmrg{ 3302949d0342Smrg $debug_cmd 3303949d0342Smrg 3304949d0342Smrg func_to_host_file_result=$1 3305cdbfa18aSmrg if test -n "$1"; then 3306cdbfa18aSmrg func_convert_core_msys_to_w32 "$1" 3307949d0342Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3308cdbfa18aSmrg fi 3309cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3310cdbfa18aSmrg} 3311cdbfa18aSmrg# end func_convert_file_msys_to_w32 3312cdbfa18aSmrg 3313cdbfa18aSmrg 3314cdbfa18aSmrg# func_convert_file_cygwin_to_w32 ARG 3315cdbfa18aSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3316cdbfa18aSmrg# func_to_host_file_result. 3317cdbfa18aSmrgfunc_convert_file_cygwin_to_w32 () 3318cdbfa18aSmrg{ 3319949d0342Smrg $debug_cmd 3320949d0342Smrg 3321949d0342Smrg func_to_host_file_result=$1 3322cdbfa18aSmrg if test -n "$1"; then 3323cdbfa18aSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3324cdbfa18aSmrg # LT_CYGPATH in this case. 3325cdbfa18aSmrg func_to_host_file_result=`cygpath -m "$1"` 3326cdbfa18aSmrg fi 3327cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3328cdbfa18aSmrg} 3329cdbfa18aSmrg# end func_convert_file_cygwin_to_w32 3330cdbfa18aSmrg 3331cdbfa18aSmrg 3332cdbfa18aSmrg# func_convert_file_nix_to_w32 ARG 3333cdbfa18aSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3334cdbfa18aSmrg# and a working winepath. Returns result in func_to_host_file_result. 3335cdbfa18aSmrgfunc_convert_file_nix_to_w32 () 3336cdbfa18aSmrg{ 3337949d0342Smrg $debug_cmd 3338949d0342Smrg 3339949d0342Smrg func_to_host_file_result=$1 3340cdbfa18aSmrg if test -n "$1"; then 3341cdbfa18aSmrg func_convert_core_file_wine_to_w32 "$1" 3342949d0342Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3343cdbfa18aSmrg fi 3344cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3345cdbfa18aSmrg} 3346cdbfa18aSmrg# end func_convert_file_nix_to_w32 3347cdbfa18aSmrg 3348cdbfa18aSmrg 3349cdbfa18aSmrg# func_convert_file_msys_to_cygwin ARG 3350cdbfa18aSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3351cdbfa18aSmrg# Returns result in func_to_host_file_result. 3352cdbfa18aSmrgfunc_convert_file_msys_to_cygwin () 3353cdbfa18aSmrg{ 3354949d0342Smrg $debug_cmd 3355949d0342Smrg 3356949d0342Smrg func_to_host_file_result=$1 3357cdbfa18aSmrg if test -n "$1"; then 3358cdbfa18aSmrg func_convert_core_msys_to_w32 "$1" 3359cdbfa18aSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3360949d0342Smrg func_to_host_file_result=$func_cygpath_result 3361cdbfa18aSmrg fi 3362cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3363cdbfa18aSmrg} 3364cdbfa18aSmrg# end func_convert_file_msys_to_cygwin 3365cdbfa18aSmrg 3366cdbfa18aSmrg 3367cdbfa18aSmrg# func_convert_file_nix_to_cygwin ARG 3368cdbfa18aSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3369cdbfa18aSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3370cdbfa18aSmrg# in func_to_host_file_result. 3371cdbfa18aSmrgfunc_convert_file_nix_to_cygwin () 3372cdbfa18aSmrg{ 3373949d0342Smrg $debug_cmd 3374949d0342Smrg 3375949d0342Smrg func_to_host_file_result=$1 3376cdbfa18aSmrg if test -n "$1"; then 3377cdbfa18aSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3378cdbfa18aSmrg func_convert_core_file_wine_to_w32 "$1" 3379cdbfa18aSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3380949d0342Smrg func_to_host_file_result=$func_cygpath_result 3381cdbfa18aSmrg fi 3382cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3383cdbfa18aSmrg} 3384cdbfa18aSmrg# end func_convert_file_nix_to_cygwin 3385cdbfa18aSmrg 3386cdbfa18aSmrg 3387cdbfa18aSmrg############################################# 3388cdbfa18aSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3389cdbfa18aSmrg############################################# 3390949d0342Smrg# invoked via '$to_host_path_cmd ARG' 3391cdbfa18aSmrg# 3392cdbfa18aSmrg# In each case, ARG is the path to be converted from $build to $host format. 3393cdbfa18aSmrg# The result will be available in $func_to_host_path_result. 3394cdbfa18aSmrg# 3395cdbfa18aSmrg# Path separators are also converted from $build format to $host format. If 3396cdbfa18aSmrg# ARG begins or ends with a path separator character, it is preserved (but 3397cdbfa18aSmrg# converted to $host format) on output. 3398cdbfa18aSmrg# 3399cdbfa18aSmrg# All path conversion functions are named using the following convention: 3400cdbfa18aSmrg# file name conversion function : func_convert_file_X_to_Y () 3401cdbfa18aSmrg# path conversion function : func_convert_path_X_to_Y () 3402cdbfa18aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3403cdbfa18aSmrg# same. If conversion functions are added for new $build/$host combinations, 3404cdbfa18aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3405cdbfa18aSmrg# will break. 3406cdbfa18aSmrg 3407cdbfa18aSmrg 3408cdbfa18aSmrg# func_init_to_host_path_cmd 3409cdbfa18aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3410cdbfa18aSmrg# appropriate value, based on the value of $to_host_file_cmd. 3411cdbfa18aSmrgto_host_path_cmd= 3412cdbfa18aSmrgfunc_init_to_host_path_cmd () 3413cdbfa18aSmrg{ 3414949d0342Smrg $debug_cmd 3415949d0342Smrg 3416cdbfa18aSmrg if test -z "$to_host_path_cmd"; then 3417cdbfa18aSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3418949d0342Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 3419cdbfa18aSmrg fi 3420cdbfa18aSmrg} 3421cdbfa18aSmrg 3422cdbfa18aSmrg 3423cdbfa18aSmrg# func_to_host_path ARG 3424cdbfa18aSmrg# Converts the path ARG from $build format to $host format. Return result 3425cdbfa18aSmrg# in func_to_host_path_result. 3426cdbfa18aSmrgfunc_to_host_path () 3427cdbfa18aSmrg{ 3428949d0342Smrg $debug_cmd 3429949d0342Smrg 3430cdbfa18aSmrg func_init_to_host_path_cmd 3431cdbfa18aSmrg $to_host_path_cmd "$1" 3432cdbfa18aSmrg} 3433cdbfa18aSmrg# end func_to_host_path 3434cdbfa18aSmrg 3435cdbfa18aSmrg 3436cdbfa18aSmrg# func_convert_path_noop ARG 3437cdbfa18aSmrg# Copy ARG to func_to_host_path_result. 3438cdbfa18aSmrgfunc_convert_path_noop () 3439cdbfa18aSmrg{ 3440949d0342Smrg func_to_host_path_result=$1 3441cdbfa18aSmrg} 3442cdbfa18aSmrg# end func_convert_path_noop 3443cdbfa18aSmrg 3444cdbfa18aSmrg 3445cdbfa18aSmrg# func_convert_path_msys_to_w32 ARG 3446cdbfa18aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3447cdbfa18aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3448cdbfa18aSmrg# func_to_host_path_result. 3449cdbfa18aSmrgfunc_convert_path_msys_to_w32 () 3450cdbfa18aSmrg{ 3451949d0342Smrg $debug_cmd 3452949d0342Smrg 3453949d0342Smrg func_to_host_path_result=$1 3454cdbfa18aSmrg if test -n "$1"; then 3455cdbfa18aSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3456cdbfa18aSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3457cdbfa18aSmrg # and winepath ignores them completely. 3458cdbfa18aSmrg func_stripname : : "$1" 3459cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3460cdbfa18aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3461949d0342Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3462cdbfa18aSmrg func_convert_path_check : ";" \ 3463cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3464cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3465cdbfa18aSmrg fi 3466cdbfa18aSmrg} 3467cdbfa18aSmrg# end func_convert_path_msys_to_w32 3468cdbfa18aSmrg 3469cdbfa18aSmrg 3470cdbfa18aSmrg# func_convert_path_cygwin_to_w32 ARG 3471cdbfa18aSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3472cdbfa18aSmrg# func_to_host_file_result. 3473cdbfa18aSmrgfunc_convert_path_cygwin_to_w32 () 3474cdbfa18aSmrg{ 3475949d0342Smrg $debug_cmd 3476949d0342Smrg 3477949d0342Smrg func_to_host_path_result=$1 3478cdbfa18aSmrg if test -n "$1"; then 3479cdbfa18aSmrg # See func_convert_path_msys_to_w32: 3480cdbfa18aSmrg func_stripname : : "$1" 3481cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3482cdbfa18aSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3483cdbfa18aSmrg func_convert_path_check : ";" \ 3484cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3485cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3486cdbfa18aSmrg fi 3487cdbfa18aSmrg} 3488cdbfa18aSmrg# end func_convert_path_cygwin_to_w32 3489cdbfa18aSmrg 3490cdbfa18aSmrg 3491cdbfa18aSmrg# func_convert_path_nix_to_w32 ARG 3492cdbfa18aSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3493cdbfa18aSmrg# a working winepath. Returns result in func_to_host_file_result. 3494cdbfa18aSmrgfunc_convert_path_nix_to_w32 () 3495d5c3dbf1Smrg{ 3496949d0342Smrg $debug_cmd 3497949d0342Smrg 3498949d0342Smrg func_to_host_path_result=$1 3499cdbfa18aSmrg if test -n "$1"; then 3500cdbfa18aSmrg # See func_convert_path_msys_to_w32: 3501cdbfa18aSmrg func_stripname : : "$1" 3502cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3503cdbfa18aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3504949d0342Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3505cdbfa18aSmrg func_convert_path_check : ";" \ 3506cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3507cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3508cdbfa18aSmrg fi 3509cdbfa18aSmrg} 3510cdbfa18aSmrg# end func_convert_path_nix_to_w32 3511d5c3dbf1Smrg 3512d5c3dbf1Smrg 3513cdbfa18aSmrg# func_convert_path_msys_to_cygwin ARG 3514cdbfa18aSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3515cdbfa18aSmrg# Returns result in func_to_host_file_result. 3516cdbfa18aSmrgfunc_convert_path_msys_to_cygwin () 3517cdbfa18aSmrg{ 3518949d0342Smrg $debug_cmd 3519949d0342Smrg 3520949d0342Smrg func_to_host_path_result=$1 3521cdbfa18aSmrg if test -n "$1"; then 3522cdbfa18aSmrg # See func_convert_path_msys_to_w32: 3523cdbfa18aSmrg func_stripname : : "$1" 3524cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3525cdbfa18aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3526cdbfa18aSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3527949d0342Smrg func_to_host_path_result=$func_cygpath_result 3528cdbfa18aSmrg func_convert_path_check : : \ 3529cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3530cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3531cdbfa18aSmrg fi 3532cdbfa18aSmrg} 3533cdbfa18aSmrg# end func_convert_path_msys_to_cygwin 3534d5c3dbf1Smrg 3535d5c3dbf1Smrg 3536cdbfa18aSmrg# func_convert_path_nix_to_cygwin ARG 3537cdbfa18aSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3538cdbfa18aSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3539cdbfa18aSmrg# func_to_host_file_result. 3540cdbfa18aSmrgfunc_convert_path_nix_to_cygwin () 3541cdbfa18aSmrg{ 3542949d0342Smrg $debug_cmd 3543949d0342Smrg 3544949d0342Smrg func_to_host_path_result=$1 3545cdbfa18aSmrg if test -n "$1"; then 3546cdbfa18aSmrg # Remove leading and trailing path separator characters from 3547cdbfa18aSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3548cdbfa18aSmrg # into '.;' and ';.', and winepath ignores them completely. 3549cdbfa18aSmrg func_stripname : : "$1" 3550cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3551cdbfa18aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3552cdbfa18aSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3553949d0342Smrg func_to_host_path_result=$func_cygpath_result 3554cdbfa18aSmrg func_convert_path_check : : \ 3555cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3556cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3557cdbfa18aSmrg fi 3558d5c3dbf1Smrg} 3559cdbfa18aSmrg# end func_convert_path_nix_to_cygwin 3560cdbfa18aSmrg 3561d5c3dbf1Smrg 3562949d0342Smrg# func_dll_def_p FILE 3563949d0342Smrg# True iff FILE is a Windows DLL '.def' file. 3564949d0342Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3565949d0342Smrgfunc_dll_def_p () 3566949d0342Smrg{ 3567949d0342Smrg $debug_cmd 3568949d0342Smrg 3569949d0342Smrg func_dll_def_p_tmp=`$SED -n \ 3570949d0342Smrg -e 's/^[ ]*//' \ 3571949d0342Smrg -e '/^\(;.*\)*$/d' \ 3572949d0342Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3573949d0342Smrg -e q \ 3574949d0342Smrg "$1"` 3575949d0342Smrg test DEF = "$func_dll_def_p_tmp" 3576949d0342Smrg} 3577949d0342Smrg 3578949d0342Smrg 3579dc088bc7Smrg# func_reorder_shared_lib_cache DIRS 3580dc088bc7Smrg# Reorder the shared library cache by unconfiguring previous shared library cache 3581dc088bc7Smrg# and configuring preferred search directories before previous search directories. 3582dc088bc7Smrg# Previous shared library cache: /usr/lib /usr/local/lib 3583dc088bc7Smrg# Preferred search directories: /tmp/testing 3584dc088bc7Smrg# Reordered shared library cache: /tmp/testing /usr/lib /usr/local/lib 3585dc088bc7Smrgfunc_reorder_shared_lib_cache () 3586dc088bc7Smrg{ 3587dc088bc7Smrg $debug_cmd 3588dc088bc7Smrg 3589dc088bc7Smrg case $host_os in 3590dc088bc7Smrg openbsd*) 3591dc088bc7Smrg get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"` 3592dc088bc7Smrg func_convert_delimited_path "$get_search_directories" ':' '\ ' 3593dc088bc7Smrg save_search_directories=$converted_path 3594dc088bc7Smrg func_convert_delimited_path "$1" ':' '\ ' 3595dc088bc7Smrg 3596dc088bc7Smrg # Ensure directories exist 3597dc088bc7Smrg for dir in $converted_path; do 3598dc088bc7Smrg # Ensure each directory is an absolute path 3599dc088bc7Smrg case $dir in 3600dc088bc7Smrg /*) ;; 3601dc088bc7Smrg *) func_error "Directory '$dir' is not an absolute path" 3602dc088bc7Smrg exit $EXIT_FAILURE ;; 3603dc088bc7Smrg esac 3604dc088bc7Smrg # Ensure no trailing slashes 3605dc088bc7Smrg func_stripname '' '/' "$dir" 3606dc088bc7Smrg dir=$func_stripname_result 3607dc088bc7Smrg if test -d "$dir"; then 3608dc088bc7Smrg if test -n "$preferred_search_directories"; then 3609dc088bc7Smrg preferred_search_directories="$preferred_search_directories $dir" 3610dc088bc7Smrg else 3611dc088bc7Smrg preferred_search_directories=$dir 3612dc088bc7Smrg fi 3613dc088bc7Smrg else 3614dc088bc7Smrg func_error "Directory '$dir' does not exist" 3615dc088bc7Smrg exit $EXIT_FAILURE 3616dc088bc7Smrg fi 3617dc088bc7Smrg done 3618dc088bc7Smrg 3619dc088bc7Smrg PATH="$PATH:/sbin" ldconfig -U $save_search_directories 3620dc088bc7Smrg PATH="$PATH:/sbin" ldconfig -m $preferred_search_directories $save_search_directories 3621dc088bc7Smrg get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"` 3622dc088bc7Smrg func_convert_delimited_path "$get_search_directories" ':' '\ ' 3623dc088bc7Smrg reordered_search_directories=$converted_path 3624dc088bc7Smrg 3625dc088bc7Smrg $ECHO "Original: $save_search_directories" 3626dc088bc7Smrg $ECHO "Reordered: $reordered_search_directories" 3627dc088bc7Smrg exit $EXIT_SUCCESS 3628dc088bc7Smrg ;; 3629dc088bc7Smrg *) 3630dc088bc7Smrg func_error "--reorder-cache is not supported for host_os=$host_os." 3631dc088bc7Smrg exit $EXIT_FAILURE 3632dc088bc7Smrg ;; 3633dc088bc7Smrg esac 3634dc088bc7Smrg} 3635dc088bc7Smrg# end func_reorder_shared_lib_cache 3636dc088bc7Smrg 3637dc088bc7Smrg 3638d5c3dbf1Smrg# func_mode_compile arg... 3639d5c3dbf1Smrgfunc_mode_compile () 3640d5c3dbf1Smrg{ 3641949d0342Smrg $debug_cmd 3642949d0342Smrg 3643d5c3dbf1Smrg # Get the compilation command and the source file. 3644d5c3dbf1Smrg base_compile= 3645949d0342Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3646d5c3dbf1Smrg suppress_opt=yes 3647d5c3dbf1Smrg suppress_output= 3648d5c3dbf1Smrg arg_mode=normal 3649d5c3dbf1Smrg libobj= 3650d5c3dbf1Smrg later= 3651d5c3dbf1Smrg pie_flag= 3652d5c3dbf1Smrg 3653d5c3dbf1Smrg for arg 3654d5c3dbf1Smrg do 3655d5c3dbf1Smrg case $arg_mode in 3656d5c3dbf1Smrg arg ) 3657d5c3dbf1Smrg # do not "continue". Instead, add this to base_compile 3658949d0342Smrg lastarg=$arg 3659d5c3dbf1Smrg arg_mode=normal 3660d5c3dbf1Smrg ;; 3661d5c3dbf1Smrg 3662d5c3dbf1Smrg target ) 3663949d0342Smrg libobj=$arg 3664d5c3dbf1Smrg arg_mode=normal 3665d5c3dbf1Smrg continue 3666d5c3dbf1Smrg ;; 3667d5c3dbf1Smrg 3668d5c3dbf1Smrg normal ) 3669d5c3dbf1Smrg # Accept any command-line options. 3670d5c3dbf1Smrg case $arg in 3671d5c3dbf1Smrg -o) 3672d5c3dbf1Smrg test -n "$libobj" && \ 3673949d0342Smrg func_fatal_error "you cannot specify '-o' more than once" 3674d5c3dbf1Smrg arg_mode=target 3675d5c3dbf1Smrg continue 3676d5c3dbf1Smrg ;; 3677d5c3dbf1Smrg 3678d5c3dbf1Smrg -pie | -fpie | -fPIE) 3679cdbfa18aSmrg func_append pie_flag " $arg" 3680d5c3dbf1Smrg continue 3681d5c3dbf1Smrg ;; 3682d5c3dbf1Smrg 3683d5c3dbf1Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3684cdbfa18aSmrg func_append later " $arg" 3685d5c3dbf1Smrg continue 3686d5c3dbf1Smrg ;; 36879f606849Smrg 36889f606849Smrg -no-suppress) 36899f606849Smrg suppress_opt=no 36909f606849Smrg continue 36919f606849Smrg ;; 36929f606849Smrg 36939f606849Smrg -Xcompiler) 36949f606849Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 36959f606849Smrg continue # The current "srcfile" will either be retained or 36969f606849Smrg ;; # replaced later. I would guess that would be a bug. 36979f606849Smrg 36989f606849Smrg -Wc,*) 3699d5c3dbf1Smrg func_stripname '-Wc,' '' "$arg" 3700d5c3dbf1Smrg args=$func_stripname_result 37019f606849Smrg lastarg= 3702949d0342Smrg save_ifs=$IFS; IFS=, 3703d5c3dbf1Smrg for arg in $args; do 3704949d0342Smrg IFS=$save_ifs 3705cdbfa18aSmrg func_append_quoted lastarg "$arg" 37069f606849Smrg done 3707949d0342Smrg IFS=$save_ifs 3708d5c3dbf1Smrg func_stripname ' ' '' "$lastarg" 3709d5c3dbf1Smrg lastarg=$func_stripname_result 37109f606849Smrg 37119f606849Smrg # Add the arguments to base_compile. 3712cdbfa18aSmrg func_append base_compile " $lastarg" 37139f606849Smrg continue 37149f606849Smrg ;; 37159f606849Smrg 3716d5c3dbf1Smrg *) 37179f606849Smrg # Accept the current argument as the source file. 37189f606849Smrg # The previous "srcfile" becomes the current argument. 37199f606849Smrg # 3720949d0342Smrg lastarg=$srcfile 3721949d0342Smrg srcfile=$arg 37229f606849Smrg ;; 37239f606849Smrg esac # case $arg 37249f606849Smrg ;; 37259f606849Smrg esac # case $arg_mode 37269f606849Smrg 37279f606849Smrg # Aesthetically quote the previous argument. 3728cdbfa18aSmrg func_append_quoted base_compile "$lastarg" 37299f606849Smrg done # for arg 37309f606849Smrg 37319f606849Smrg case $arg_mode in 37329f606849Smrg arg) 3733d5c3dbf1Smrg func_fatal_error "you must specify an argument for -Xcompile" 37349f606849Smrg ;; 37359f606849Smrg target) 3736949d0342Smrg func_fatal_error "you must specify a target with '-o'" 37379f606849Smrg ;; 37389f606849Smrg *) 37399f606849Smrg # Get the name of the library object. 3740d5c3dbf1Smrg test -z "$libobj" && { 3741d5c3dbf1Smrg func_basename "$srcfile" 3742949d0342Smrg libobj=$func_basename_result 3743d5c3dbf1Smrg } 37449f606849Smrg ;; 37459f606849Smrg esac 37469f606849Smrg 37479f606849Smrg # Recognize several different file suffixes. 37489f606849Smrg # If the user specifies -o file.o, it is replaced with file.lo 37499f606849Smrg case $libobj in 3750d5c3dbf1Smrg *.[cCFSifmso] | \ 3751d5c3dbf1Smrg *.ada | *.adb | *.ads | *.asm | \ 3752d5c3dbf1Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3753cdbfa18aSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3754d5c3dbf1Smrg func_xform "$libobj" 3755d5c3dbf1Smrg libobj=$func_xform_result 3756d5c3dbf1Smrg ;; 37579f606849Smrg esac 37589f606849Smrg 37599f606849Smrg case $libobj in 3760d5c3dbf1Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 37619f606849Smrg *) 3762949d0342Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 37639f606849Smrg ;; 37649f606849Smrg esac 37659f606849Smrg 37669f606849Smrg func_infer_tag $base_compile 37679f606849Smrg 37689f606849Smrg for arg in $later; do 37699f606849Smrg case $arg in 3770d5c3dbf1Smrg -shared) 3771949d0342Smrg test yes = "$build_libtool_libs" \ 3772949d0342Smrg || func_fatal_configuration "cannot build a shared library" 3773d5c3dbf1Smrg build_old_libs=no 3774d5c3dbf1Smrg continue 3775d5c3dbf1Smrg ;; 3776d5c3dbf1Smrg 37779f606849Smrg -static) 3778d5c3dbf1Smrg build_libtool_libs=no 37799f606849Smrg build_old_libs=yes 37809f606849Smrg continue 37819f606849Smrg ;; 37829f606849Smrg 37839f606849Smrg -prefer-pic) 37849f606849Smrg pic_mode=yes 37859f606849Smrg continue 37869f606849Smrg ;; 37879f606849Smrg 37889f606849Smrg -prefer-non-pic) 37899f606849Smrg pic_mode=no 37909f606849Smrg continue 37919f606849Smrg ;; 37929f606849Smrg esac 37939f606849Smrg done 37949f606849Smrg 3795949d0342Smrg func_quote_arg pretty "$libobj" 3796949d0342Smrg test "X$libobj" != "X$func_quote_arg_result" \ 3797d5c3dbf1Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3798949d0342Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3799d5c3dbf1Smrg func_dirname_and_basename "$obj" "/" "" 3800949d0342Smrg objname=$func_basename_result 3801949d0342Smrg xdir=$func_dirname_result 3802949d0342Smrg lobj=$xdir$objdir/$objname 38039f606849Smrg 3804d5c3dbf1Smrg test -z "$base_compile" && \ 3805d5c3dbf1Smrg func_fatal_help "you must specify a compilation command" 38069f606849Smrg 38079f606849Smrg # Delete any leftover library objects. 3808949d0342Smrg if test yes = "$build_old_libs"; then 38099f606849Smrg removelist="$obj $lobj $libobj ${libobj}T" 38109f606849Smrg else 38119f606849Smrg removelist="$lobj $libobj ${libobj}T" 38129f606849Smrg fi 38139f606849Smrg 38149f606849Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 38159f606849Smrg case $host_os in 3816dc088bc7Smrg cygwin* | mingw* | windows* | pw32* | os2* | cegcc*) 38179f606849Smrg pic_mode=default 38189f606849Smrg ;; 38199f606849Smrg esac 3820949d0342Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 38219f606849Smrg # non-PIC code in shared libraries is not supported 38229f606849Smrg pic_mode=default 38239f606849Smrg fi 38249f606849Smrg 38259f606849Smrg # Calculate the filename of the output object if compiler does 38269f606849Smrg # not support -o with -c 3827949d0342Smrg if test no = "$compiler_c_o"; then 3828949d0342Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3829949d0342Smrg lockfile=$output_obj.lock 38309f606849Smrg else 38319f606849Smrg output_obj= 38329f606849Smrg need_locks=no 38339f606849Smrg lockfile= 38349f606849Smrg fi 38359f606849Smrg 38369f606849Smrg # Lock this critical section if it is needed 38379f606849Smrg # We use this script file to make the link, it avoids creating a new file 3838949d0342Smrg if test yes = "$need_locks"; then 3839d5c3dbf1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3840d5c3dbf1Smrg func_echo "Waiting for $lockfile to be removed" 38419f606849Smrg sleep 2 38429f606849Smrg done 3843949d0342Smrg elif test warn = "$need_locks"; then 38449f606849Smrg if test -f "$lockfile"; then 3845d5c3dbf1Smrg $ECHO "\ 38469f606849Smrg*** ERROR, $lockfile exists and contains: 38479f606849Smrg`cat $lockfile 2>/dev/null` 38489f606849Smrg 38499f606849SmrgThis indicates that another process is trying to use the same 38509f606849Smrgtemporary object file, and libtool could not work around it because 3851949d0342Smrgyour compiler does not support '-c' and '-o' together. If you 38529f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better 38539f606849Smrgavoid parallel builds (make -j) in this platform, or get a better 38549f606849Smrgcompiler." 38559f606849Smrg 3856d5c3dbf1Smrg $opt_dry_run || $RM $removelist 38579f606849Smrg exit $EXIT_FAILURE 38589f606849Smrg fi 3859cdbfa18aSmrg func_append removelist " $output_obj" 3860d5c3dbf1Smrg $ECHO "$srcfile" > "$lockfile" 38619f606849Smrg fi 38629f606849Smrg 3863d5c3dbf1Smrg $opt_dry_run || $RM $removelist 3864cdbfa18aSmrg func_append removelist " $lockfile" 3865d5c3dbf1Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3866d5c3dbf1Smrg 3867cdbfa18aSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3868cdbfa18aSmrg srcfile=$func_to_tool_file_result 3869949d0342Smrg func_quote_arg pretty "$srcfile" 3870949d0342Smrg qsrcfile=$func_quote_arg_result 38719f606849Smrg 38729f606849Smrg # Only build a PIC object if we are building libtool libraries. 3873949d0342Smrg if test yes = "$build_libtool_libs"; then 38749f606849Smrg # Without this assignment, base_compile gets emptied. 38759f606849Smrg fbsd_hideous_sh_bug=$base_compile 38769f606849Smrg 3877949d0342Smrg if test no != "$pic_mode"; then 38789f606849Smrg command="$base_compile $qsrcfile $pic_flag" 38799f606849Smrg else 38809f606849Smrg # Don't build PIC code 38819f606849Smrg command="$base_compile $qsrcfile" 38829f606849Smrg fi 38839f606849Smrg 3884d5c3dbf1Smrg func_mkdir_p "$xdir$objdir" 38859f606849Smrg 38869f606849Smrg if test -z "$output_obj"; then 38879f606849Smrg # Place PIC objects in $objdir 3888cdbfa18aSmrg func_append command " -o $lobj" 38899f606849Smrg fi 38909f606849Smrg 3891d5c3dbf1Smrg func_show_eval_locale "$command" \ 3892d5c3dbf1Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 38939f606849Smrg 3894949d0342Smrg if test warn = "$need_locks" && 38959f606849Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3896d5c3dbf1Smrg $ECHO "\ 38979f606849Smrg*** ERROR, $lockfile contains: 38989f606849Smrg`cat $lockfile 2>/dev/null` 38999f606849Smrg 39009f606849Smrgbut it should contain: 39019f606849Smrg$srcfile 39029f606849Smrg 39039f606849SmrgThis indicates that another process is trying to use the same 39049f606849Smrgtemporary object file, and libtool could not work around it because 3905949d0342Smrgyour compiler does not support '-c' and '-o' together. If you 39069f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better 39079f606849Smrgavoid parallel builds (make -j) in this platform, or get a better 39089f606849Smrgcompiler." 39099f606849Smrg 3910d5c3dbf1Smrg $opt_dry_run || $RM $removelist 39119f606849Smrg exit $EXIT_FAILURE 39129f606849Smrg fi 39139f606849Smrg 39149f606849Smrg # Just move the object if needed, then go on to compile the next one 39159f606849Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3916d5c3dbf1Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3917d5c3dbf1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 39189f606849Smrg fi 39199f606849Smrg 39209f606849Smrg # Allow error messages only from the first compilation. 3921949d0342Smrg if test yes = "$suppress_opt"; then 3922d5c3dbf1Smrg suppress_output=' >/dev/null 2>&1' 39239f606849Smrg fi 39249f606849Smrg fi 39259f606849Smrg 39269f606849Smrg # Only build a position-dependent object if we build old libraries. 3927949d0342Smrg if test yes = "$build_old_libs"; then 3928949d0342Smrg if test yes != "$pic_mode"; then 39299f606849Smrg # Don't build PIC code 3930d5c3dbf1Smrg command="$base_compile $qsrcfile$pie_flag" 39319f606849Smrg else 39329f606849Smrg command="$base_compile $qsrcfile $pic_flag" 39339f606849Smrg fi 3934949d0342Smrg if test yes = "$compiler_c_o"; then 3935cdbfa18aSmrg func_append command " -o $obj" 39369f606849Smrg fi 39379f606849Smrg 39389f606849Smrg # Suppress compiler output if we already did a PIC compilation. 3939cdbfa18aSmrg func_append command "$suppress_output" 3940d5c3dbf1Smrg func_show_eval_locale "$command" \ 3941d5c3dbf1Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 39429f606849Smrg 3943949d0342Smrg if test warn = "$need_locks" && 39449f606849Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3945d5c3dbf1Smrg $ECHO "\ 39469f606849Smrg*** ERROR, $lockfile contains: 39479f606849Smrg`cat $lockfile 2>/dev/null` 39489f606849Smrg 39499f606849Smrgbut it should contain: 39509f606849Smrg$srcfile 39519f606849Smrg 39529f606849SmrgThis indicates that another process is trying to use the same 39539f606849Smrgtemporary object file, and libtool could not work around it because 3954949d0342Smrgyour compiler does not support '-c' and '-o' together. If you 39559f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better 39569f606849Smrgavoid parallel builds (make -j) in this platform, or get a better 39579f606849Smrgcompiler." 39589f606849Smrg 3959d5c3dbf1Smrg $opt_dry_run || $RM $removelist 39609f606849Smrg exit $EXIT_FAILURE 39619f606849Smrg fi 39629f606849Smrg 39639f606849Smrg # Just move the object if needed 39649f606849Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3965d5c3dbf1Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3966d5c3dbf1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 39679f606849Smrg fi 39689f606849Smrg fi 39699f606849Smrg 3970d5c3dbf1Smrg $opt_dry_run || { 3971d5c3dbf1Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 39729f606849Smrg 3973d5c3dbf1Smrg # Unlock the critical section if it was locked 3974949d0342Smrg if test no != "$need_locks"; then 3975d5c3dbf1Smrg removelist=$lockfile 3976d5c3dbf1Smrg $RM "$lockfile" 3977d5c3dbf1Smrg fi 3978d5c3dbf1Smrg } 39799f606849Smrg 39809f606849Smrg exit $EXIT_SUCCESS 3981d5c3dbf1Smrg} 39829f606849Smrg 3983d5c3dbf1Smrg$opt_help || { 3984949d0342Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3985d5c3dbf1Smrg} 39869f606849Smrg 3987d5c3dbf1Smrgfunc_mode_help () 3988d5c3dbf1Smrg{ 3989d5c3dbf1Smrg # We need to display help for each of the modes. 3990cdbfa18aSmrg case $opt_mode in 3991d5c3dbf1Smrg "") 3992d5c3dbf1Smrg # Generic help is extracted from the usage comments 3993d5c3dbf1Smrg # at the start of this file. 3994d5c3dbf1Smrg func_help 3995d5c3dbf1Smrg ;; 39969f606849Smrg 3997d5c3dbf1Smrg clean) 3998d5c3dbf1Smrg $ECHO \ 3999d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 40009f606849Smrg 4001d5c3dbf1SmrgRemove files from the build directory. 40029f606849Smrg 4003d5c3dbf1SmrgRM is the name of the program to use to delete files associated with each FILE 4004949d0342Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4005d5c3dbf1Smrgto RM. 40069f606849Smrg 4007d5c3dbf1SmrgIf FILE is a libtool library, object or program, all the files associated 4008d5c3dbf1Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 4009d5c3dbf1Smrg ;; 40109f606849Smrg 4011d5c3dbf1Smrg compile) 4012d5c3dbf1Smrg $ECHO \ 4013d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 40149f606849Smrg 4015d5c3dbf1SmrgCompile a source file into a libtool library object. 40169f606849Smrg 4017d5c3dbf1SmrgThis mode accepts the following additional options: 40189f606849Smrg 4019d5c3dbf1Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 4020d5c3dbf1Smrg -no-suppress do not suppress compiler output for multiple passes 4021d5c3dbf1Smrg -prefer-pic try to build PIC objects only 4022d5c3dbf1Smrg -prefer-non-pic try to build non-PIC objects only 4023949d0342Smrg -shared do not build a '.o' file suitable for static linking 4024949d0342Smrg -static only build a '.o' file suitable for static linking 4025949d0342Smrg -Wc,FLAG 4026949d0342Smrg -Xcompiler FLAG pass FLAG directly to the compiler 40279f606849Smrg 4028949d0342SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 4029d5c3dbf1Smrgfrom the given SOURCEFILE. 40309f606849Smrg 4031d5c3dbf1SmrgThe output file name is determined by removing the directory component from 4032949d0342SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 4033949d0342Smrglibrary object suffix, '.lo'." 4034d5c3dbf1Smrg ;; 40359f606849Smrg 4036d5c3dbf1Smrg execute) 4037d5c3dbf1Smrg $ECHO \ 4038d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 40399f606849Smrg 4040d5c3dbf1SmrgAutomatically set library path, then run a program. 40419f606849Smrg 4042d5c3dbf1SmrgThis mode accepts the following additional options: 40439f606849Smrg 4044d5c3dbf1Smrg -dlopen FILE add the directory containing FILE to the library path 40459f606849Smrg 4046949d0342SmrgThis mode sets the library path environment variable according to '-dlopen' 4047d5c3dbf1Smrgflags. 40489f606849Smrg 4049d5c3dbf1SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 4050d5c3dbf1Smrginto their corresponding uninstalled binary, and any of their required library 4051d5c3dbf1Smrgdirectories are added to the library path. 40529f606849Smrg 4053d5c3dbf1SmrgThen, COMMAND is executed, with ARGS as arguments." 4054d5c3dbf1Smrg ;; 40559f606849Smrg 4056d5c3dbf1Smrg finish) 4057d5c3dbf1Smrg $ECHO \ 4058d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 40599f606849Smrg 4060d5c3dbf1SmrgComplete the installation of libtool libraries. 40619f606849Smrg 4062d5c3dbf1SmrgEach LIBDIR is a directory that contains libtool libraries. 40639f606849Smrg 4064d5c3dbf1SmrgThe commands that this mode executes may require superuser privileges. Use 4065949d0342Smrgthe '--dry-run' option if you just want to see what would be executed." 4066d5c3dbf1Smrg ;; 40679f606849Smrg 4068d5c3dbf1Smrg install) 4069d5c3dbf1Smrg $ECHO \ 4070d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 40719f606849Smrg 4072d5c3dbf1SmrgInstall executables or libraries. 40739f606849Smrg 4074d5c3dbf1SmrgINSTALL-COMMAND is the installation command. The first component should be 4075949d0342Smrgeither the 'install' or 'cp' program. 40769f606849Smrg 4077d5c3dbf1SmrgThe following components of INSTALL-COMMAND are treated specially: 40789f606849Smrg 4079d5c3dbf1Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 40809f606849Smrg 4081d5c3dbf1SmrgThe rest of the components are interpreted as arguments to that command (only 4082d5c3dbf1SmrgBSD-compatible install options are recognized)." 4083d5c3dbf1Smrg ;; 40849f606849Smrg 4085d5c3dbf1Smrg link) 4086d5c3dbf1Smrg $ECHO \ 4087d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 40889f606849Smrg 4089d5c3dbf1SmrgLink object files or libraries together to form another library, or to 4090d5c3dbf1Smrgcreate an executable program. 40919f606849Smrg 4092d5c3dbf1SmrgLINK-COMMAND is a command using the C compiler that you would use to create 4093d5c3dbf1Smrga program from several object files. 40949f606849Smrg 4095d5c3dbf1SmrgThe following components of LINK-COMMAND are treated specially: 40969f606849Smrg 4097d5c3dbf1Smrg -all-static do not do any dynamic linking at all 4098d5c3dbf1Smrg -avoid-version do not add a version suffix if possible 4099d5c3dbf1Smrg -bindir BINDIR specify path to binaries directory (for systems where 4100d5c3dbf1Smrg libraries must be found in the PATH setting at runtime) 4101949d0342Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 4102d5c3dbf1Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 4103d5c3dbf1Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 4104d5c3dbf1Smrg -export-symbols SYMFILE 4105d5c3dbf1Smrg try to export only the symbols listed in SYMFILE 4106d5c3dbf1Smrg -export-symbols-regex REGEX 4107d5c3dbf1Smrg try to export only the symbols matching REGEX 4108d5c3dbf1Smrg -LLIBDIR search LIBDIR for required installed libraries 4109d5c3dbf1Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 4110d5c3dbf1Smrg -module build a library that can dlopened 4111d5c3dbf1Smrg -no-fast-install disable the fast-install mode 4112d5c3dbf1Smrg -no-install link a not-installable executable 4113d5c3dbf1Smrg -no-undefined declare that a library does not refer to external symbols 4114d5c3dbf1Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 4115949d0342Smrg -objectlist FILE use a list of object files found in FILE to specify objects 4116949d0342Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 4117d5c3dbf1Smrg -precious-files-regex REGEX 4118d5c3dbf1Smrg don't remove output files matching REGEX 4119d5c3dbf1Smrg -release RELEASE specify package release information 4120d5c3dbf1Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4121d5c3dbf1Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4122d5c3dbf1Smrg -shared only do dynamic linking of libtool libraries 4123d5c3dbf1Smrg -shrext SUFFIX override the standard shared library file extension 4124d5c3dbf1Smrg -static do not do any dynamic linking of uninstalled libtool libraries 4125d5c3dbf1Smrg -static-libtool-libs 4126d5c3dbf1Smrg do not do any dynamic linking of libtool libraries 4127d5c3dbf1Smrg -version-info CURRENT[:REVISION[:AGE]] 4128d5c3dbf1Smrg specify library version info [each variable defaults to 0] 4129d5c3dbf1Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 4130d5c3dbf1Smrg -Wc,FLAG 4131d5c3dbf1Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4132949d0342Smrg -Wa,FLAG 4133949d0342Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4134d5c3dbf1Smrg -Wl,FLAG 4135d5c3dbf1Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4136d5c3dbf1Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 41379f606849Smrg 4138949d0342SmrgAll other options (arguments beginning with '-') are ignored. 41399f606849Smrg 4140949d0342SmrgEvery other argument is treated as a filename. Files ending in '.la' are 4141d5c3dbf1Smrgtreated as uninstalled libtool libraries, other files are standard or library 4142d5c3dbf1Smrgobject files. 41439f606849Smrg 4144949d0342SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 4145949d0342Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4146d5c3dbf1Smrgrequired, except when creating a convenience library. 41479f606849Smrg 4148949d0342SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4149949d0342Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4150fba89afeSmrg 4151949d0342SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4152d5c3dbf1Smrgis created, otherwise an executable program is created." 4153d5c3dbf1Smrg ;; 41549f606849Smrg 4155d5c3dbf1Smrg uninstall) 4156d5c3dbf1Smrg $ECHO \ 4157d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 41589f606849Smrg 4159d5c3dbf1SmrgRemove libraries from an installation directory. 41609f606849Smrg 4161d5c3dbf1SmrgRM is the name of the program to use to delete files associated with each FILE 4162949d0342Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4163d5c3dbf1Smrgto RM. 41649f606849Smrg 4165d5c3dbf1SmrgIf FILE is a libtool library, all the files associated with it are deleted. 4166d5c3dbf1SmrgOtherwise, only FILE itself is deleted using RM." 4167d5c3dbf1Smrg ;; 41689f606849Smrg 4169d5c3dbf1Smrg *) 4170949d0342Smrg func_fatal_help "invalid operation mode '$opt_mode'" 4171d5c3dbf1Smrg ;; 4172d5c3dbf1Smrg esac 41739f606849Smrg 4174d5c3dbf1Smrg echo 4175949d0342Smrg $ECHO "Try '$progname --help' for more information about other modes." 4176d5c3dbf1Smrg} 41779f606849Smrg 4178d5c3dbf1Smrg# Now that we've collected a possible --mode arg, show help if necessary 4179d5c3dbf1Smrgif $opt_help; then 4180949d0342Smrg if test : = "$opt_help"; then 4181d5c3dbf1Smrg func_mode_help 4182d5c3dbf1Smrg else 4183d5c3dbf1Smrg { 4184d5c3dbf1Smrg func_help noexit 4185cdbfa18aSmrg for opt_mode in compile link execute install finish uninstall clean; do 4186d5c3dbf1Smrg func_mode_help 4187d5c3dbf1Smrg done 4188949d0342Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4189d5c3dbf1Smrg { 4190d5c3dbf1Smrg func_help noexit 4191cdbfa18aSmrg for opt_mode in compile link execute install finish uninstall clean; do 4192d5c3dbf1Smrg echo 4193d5c3dbf1Smrg func_mode_help 4194d5c3dbf1Smrg done 4195d5c3dbf1Smrg } | 4196949d0342Smrg $SED '1d 4197d5c3dbf1Smrg /^When reporting/,/^Report/{ 4198d5c3dbf1Smrg H 4199d5c3dbf1Smrg d 4200d5c3dbf1Smrg } 4201d5c3dbf1Smrg $x 4202d5c3dbf1Smrg /information about other modes/d 4203d5c3dbf1Smrg /more detailed .*MODE/d 4204d5c3dbf1Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4205d5c3dbf1Smrg fi 4206d5c3dbf1Smrg exit $? 4207d5c3dbf1Smrgfi 42089f606849Smrg 42099f606849Smrg 4210dc088bc7Smrg# If option '--reorder-cache', reorder the shared library cache and exit. 4211dc088bc7Smrgif $opt_reorder_cache; then 4212dc088bc7Smrg func_reorder_shared_lib_cache $shared_lib_dirs 4213dc088bc7Smrgfi 4214dc088bc7Smrg 4215dc088bc7Smrg 4216d5c3dbf1Smrg# func_mode_execute arg... 4217d5c3dbf1Smrgfunc_mode_execute () 4218d5c3dbf1Smrg{ 4219949d0342Smrg $debug_cmd 4220949d0342Smrg 4221d5c3dbf1Smrg # The first argument is the command name. 4222949d0342Smrg cmd=$nonopt 4223d5c3dbf1Smrg test -z "$cmd" && \ 4224d5c3dbf1Smrg func_fatal_help "you must specify a COMMAND" 42259f606849Smrg 4226d5c3dbf1Smrg # Handle -dlopen flags immediately. 4227cdbfa18aSmrg for file in $opt_dlopen; do 4228d5c3dbf1Smrg test -f "$file" \ 4229949d0342Smrg || func_fatal_help "'$file' is not a file" 42309f606849Smrg 4231d5c3dbf1Smrg dir= 4232d5c3dbf1Smrg case $file in 4233d5c3dbf1Smrg *.la) 4234cdbfa18aSmrg func_resolve_sysroot "$file" 4235cdbfa18aSmrg file=$func_resolve_sysroot_result 4236cdbfa18aSmrg 4237d5c3dbf1Smrg # Check to see that this really is a libtool archive. 4238d5c3dbf1Smrg func_lalib_unsafe_p "$file" \ 4239949d0342Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 42409f606849Smrg 4241d5c3dbf1Smrg # Read the libtool library. 4242d5c3dbf1Smrg dlname= 4243d5c3dbf1Smrg library_names= 4244d5c3dbf1Smrg func_source "$file" 42459f606849Smrg 4246d5c3dbf1Smrg # Skip this library if it cannot be dlopened. 4247d5c3dbf1Smrg if test -z "$dlname"; then 4248d5c3dbf1Smrg # Warn if it was a shared library. 4249d5c3dbf1Smrg test -n "$library_names" && \ 4250949d0342Smrg func_warning "'$file' was not linked with '-export-dynamic'" 4251d5c3dbf1Smrg continue 4252d5c3dbf1Smrg fi 42539f606849Smrg 4254d5c3dbf1Smrg func_dirname "$file" "" "." 4255949d0342Smrg dir=$func_dirname_result 42569f606849Smrg 4257d5c3dbf1Smrg if test -f "$dir/$objdir/$dlname"; then 4258cdbfa18aSmrg func_append dir "/$objdir" 4259d5c3dbf1Smrg else 4260d5c3dbf1Smrg if test ! -f "$dir/$dlname"; then 4261949d0342Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4262d5c3dbf1Smrg fi 4263d5c3dbf1Smrg fi 42649f606849Smrg ;; 42659f606849Smrg 4266d5c3dbf1Smrg *.lo) 4267d5c3dbf1Smrg # Just add the directory containing the .lo file. 4268d5c3dbf1Smrg func_dirname "$file" "" "." 4269949d0342Smrg dir=$func_dirname_result 42709f606849Smrg ;; 4271d5c3dbf1Smrg 4272d5c3dbf1Smrg *) 4273949d0342Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 42749f606849Smrg continue 42759f606849Smrg ;; 4276d5c3dbf1Smrg esac 42779f606849Smrg 4278d5c3dbf1Smrg # Get the absolute pathname. 4279d5c3dbf1Smrg absdir=`cd "$dir" && pwd` 4280949d0342Smrg test -n "$absdir" && dir=$absdir 42819f606849Smrg 4282d5c3dbf1Smrg # Now add the directory to shlibpath_var. 4283d5c3dbf1Smrg if eval "test -z \"\$$shlibpath_var\""; then 4284d5c3dbf1Smrg eval "$shlibpath_var=\"\$dir\"" 4285d5c3dbf1Smrg else 4286d5c3dbf1Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4287d5c3dbf1Smrg fi 4288d5c3dbf1Smrg done 42899f606849Smrg 4290d5c3dbf1Smrg # This variable tells wrapper scripts just to set shlibpath_var 4291d5c3dbf1Smrg # rather than running their programs. 4292949d0342Smrg libtool_execute_magic=$magic 42939f606849Smrg 4294d5c3dbf1Smrg # Check if any of the arguments is a wrapper script. 4295d5c3dbf1Smrg args= 4296d5c3dbf1Smrg for file 4297d5c3dbf1Smrg do 4298d5c3dbf1Smrg case $file in 4299d5c3dbf1Smrg -* | *.la | *.lo ) ;; 4300d5c3dbf1Smrg *) 4301d5c3dbf1Smrg # Do a test to see if this is really a libtool program. 4302d5c3dbf1Smrg if func_ltwrapper_script_p "$file"; then 4303d5c3dbf1Smrg func_source "$file" 4304d5c3dbf1Smrg # Transform arg to wrapped name. 4305949d0342Smrg file=$progdir/$program 4306d5c3dbf1Smrg elif func_ltwrapper_executable_p "$file"; then 4307d5c3dbf1Smrg func_ltwrapper_scriptname "$file" 4308d5c3dbf1Smrg func_source "$func_ltwrapper_scriptname_result" 4309d5c3dbf1Smrg # Transform arg to wrapped name. 4310949d0342Smrg file=$progdir/$program 4311d5c3dbf1Smrg fi 43129f606849Smrg ;; 4313d5c3dbf1Smrg esac 4314d5c3dbf1Smrg # Quote arguments (to preserve shell metacharacters). 4315cdbfa18aSmrg func_append_quoted args "$file" 4316d5c3dbf1Smrg done 43179f606849Smrg 4318949d0342Smrg if $opt_dry_run; then 4319949d0342Smrg # Display what would be done. 4320949d0342Smrg if test -n "$shlibpath_var"; then 4321949d0342Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4322949d0342Smrg echo "export $shlibpath_var" 4323949d0342Smrg fi 4324949d0342Smrg $ECHO "$cmd$args" 4325949d0342Smrg exit $EXIT_SUCCESS 4326949d0342Smrg else 4327d5c3dbf1Smrg if test -n "$shlibpath_var"; then 4328d5c3dbf1Smrg # Export the shlibpath_var. 4329d5c3dbf1Smrg eval "export $shlibpath_var" 4330d5c3dbf1Smrg fi 43319f606849Smrg 4332d5c3dbf1Smrg # Restore saved environment variables 4333d5c3dbf1Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4334d5c3dbf1Smrg do 4335d5c3dbf1Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4336d5c3dbf1Smrg $lt_var=\$save_$lt_var; export $lt_var 4337d5c3dbf1Smrg else 4338d5c3dbf1Smrg $lt_unset $lt_var 4339d5c3dbf1Smrg fi" 4340d5c3dbf1Smrg done 43419f606849Smrg 4342d5c3dbf1Smrg # Now prepare to actually exec the command. 4343949d0342Smrg exec_cmd=\$cmd$args 4344d5c3dbf1Smrg fi 4345d5c3dbf1Smrg} 43469f606849Smrg 4347949d0342Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 43489f606849Smrg 43499f606849Smrg 4350d5c3dbf1Smrg# func_mode_finish arg... 4351d5c3dbf1Smrgfunc_mode_finish () 4352d5c3dbf1Smrg{ 4353949d0342Smrg $debug_cmd 4354949d0342Smrg 4355cdbfa18aSmrg libs= 4356cdbfa18aSmrg libdirs= 4357d5c3dbf1Smrg admincmds= 43589f606849Smrg 4359cdbfa18aSmrg for opt in "$nonopt" ${1+"$@"} 4360cdbfa18aSmrg do 4361cdbfa18aSmrg if test -d "$opt"; then 4362cdbfa18aSmrg func_append libdirs " $opt" 4363cdbfa18aSmrg 4364cdbfa18aSmrg elif test -f "$opt"; then 4365cdbfa18aSmrg if func_lalib_unsafe_p "$opt"; then 4366cdbfa18aSmrg func_append libs " $opt" 4367cdbfa18aSmrg else 4368949d0342Smrg func_warning "'$opt' is not a valid libtool archive" 4369cdbfa18aSmrg fi 4370cdbfa18aSmrg 4371cdbfa18aSmrg else 4372949d0342Smrg func_fatal_error "invalid argument '$opt'" 4373cdbfa18aSmrg fi 4374cdbfa18aSmrg done 4375cdbfa18aSmrg 4376cdbfa18aSmrg if test -n "$libs"; then 4377cdbfa18aSmrg if test -n "$lt_sysroot"; then 4378cdbfa18aSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4379cdbfa18aSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4380cdbfa18aSmrg else 4381cdbfa18aSmrg sysroot_cmd= 4382cdbfa18aSmrg fi 4383cdbfa18aSmrg 4384cdbfa18aSmrg # Remove sysroot references 4385cdbfa18aSmrg if $opt_dry_run; then 4386cdbfa18aSmrg for lib in $libs; do 4387949d0342Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4388cdbfa18aSmrg done 4389cdbfa18aSmrg else 4390cdbfa18aSmrg tmpdir=`func_mktempdir` 4391cdbfa18aSmrg for lib in $libs; do 4392949d0342Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4393cdbfa18aSmrg > $tmpdir/tmp-la 4394cdbfa18aSmrg mv -f $tmpdir/tmp-la $lib 4395cdbfa18aSmrg done 4396cdbfa18aSmrg ${RM}r "$tmpdir" 4397cdbfa18aSmrg fi 4398cdbfa18aSmrg fi 43999f606849Smrg 4400dc088bc7Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs" && $opt_finishing; then 4401d5c3dbf1Smrg for libdir in $libdirs; do 4402d5c3dbf1Smrg if test -n "$finish_cmds"; then 4403d5c3dbf1Smrg # Do each command in the finish commands. 4404d5c3dbf1Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4405d5c3dbf1Smrg'"$cmd"'"' 4406d5c3dbf1Smrg fi 4407d5c3dbf1Smrg if test -n "$finish_eval"; then 4408d5c3dbf1Smrg # Do the single finish_eval. 4409d5c3dbf1Smrg eval cmds=\"$finish_eval\" 4410cdbfa18aSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4411d5c3dbf1Smrg $cmds" 4412d5c3dbf1Smrg fi 4413d5c3dbf1Smrg done 4414d5c3dbf1Smrg fi 44159f606849Smrg 4416d5c3dbf1Smrg # Exit here if they wanted silent mode. 4417949d0342Smrg $opt_quiet && exit $EXIT_SUCCESS 44189f606849Smrg 4419cdbfa18aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4420cdbfa18aSmrg echo "----------------------------------------------------------------------" 4421cdbfa18aSmrg echo "Libraries have been installed in:" 4422cdbfa18aSmrg for libdir in $libdirs; do 4423cdbfa18aSmrg $ECHO " $libdir" 4424cdbfa18aSmrg done 4425dc088bc7Smrg if test "false" = "$opt_finishing"; then 4426dc088bc7Smrg echo 4427dc088bc7Smrg echo "NOTE: finish_cmds were not executed during testing, so you must" 4428dc088bc7Smrg echo "manually run ldconfig to add a given test directory, LIBDIR, to" 4429dc088bc7Smrg echo "the search path for generated executables." 4430dc088bc7Smrg fi 4431cdbfa18aSmrg echo 4432cdbfa18aSmrg echo "If you ever happen to want to link against installed libraries" 4433cdbfa18aSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4434949d0342Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4435cdbfa18aSmrg echo "flag during linking and do at least one of the following:" 4436cdbfa18aSmrg if test -n "$shlibpath_var"; then 4437949d0342Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4438cdbfa18aSmrg echo " during execution" 4439cdbfa18aSmrg fi 4440cdbfa18aSmrg if test -n "$runpath_var"; then 4441949d0342Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4442cdbfa18aSmrg echo " during linking" 4443cdbfa18aSmrg fi 4444cdbfa18aSmrg if test -n "$hardcode_libdir_flag_spec"; then 4445cdbfa18aSmrg libdir=LIBDIR 4446cdbfa18aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 44479f606849Smrg 4448949d0342Smrg $ECHO " - use the '$flag' linker flag" 4449cdbfa18aSmrg fi 4450cdbfa18aSmrg if test -n "$admincmds"; then 4451cdbfa18aSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4452cdbfa18aSmrg fi 4453cdbfa18aSmrg if test -f /etc/ld.so.conf; then 4454949d0342Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4455cdbfa18aSmrg fi 4456cdbfa18aSmrg echo 44579f606849Smrg 4458cdbfa18aSmrg echo "See any operating system documentation about shared libraries for" 4459cdbfa18aSmrg case $host in 4460cdbfa18aSmrg solaris2.[6789]|solaris2.1[0-9]) 4461cdbfa18aSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4462cdbfa18aSmrg echo "pages." 4463cdbfa18aSmrg ;; 4464cdbfa18aSmrg *) 4465cdbfa18aSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4466cdbfa18aSmrg ;; 4467cdbfa18aSmrg esac 4468cdbfa18aSmrg echo "----------------------------------------------------------------------" 4469cdbfa18aSmrg fi 4470d5c3dbf1Smrg exit $EXIT_SUCCESS 4471d5c3dbf1Smrg} 44729f606849Smrg 4473949d0342Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 44749f606849Smrg 44759f606849Smrg 4476d5c3dbf1Smrg# func_mode_install arg... 4477d5c3dbf1Smrgfunc_mode_install () 4478d5c3dbf1Smrg{ 4479949d0342Smrg $debug_cmd 4480949d0342Smrg 4481d5c3dbf1Smrg # There may be an optional sh(1) argument at the beginning of 4482d5c3dbf1Smrg # install_prog (especially on Windows NT). 4483949d0342Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4484d5c3dbf1Smrg # Allow the use of GNU shtool's install command. 4485949d0342Smrg case $nonopt in *shtool*) :;; *) false;; esac 4486949d0342Smrg then 4487d5c3dbf1Smrg # Aesthetically quote it. 4488949d0342Smrg func_quote_arg pretty "$nonopt" 4489949d0342Smrg install_prog="$func_quote_arg_result " 4490d5c3dbf1Smrg arg=$1 4491d5c3dbf1Smrg shift 4492d5c3dbf1Smrg else 4493d5c3dbf1Smrg install_prog= 4494d5c3dbf1Smrg arg=$nonopt 4495d5c3dbf1Smrg fi 44969f606849Smrg 4497d5c3dbf1Smrg # The real first argument should be the name of the installation program. 4498d5c3dbf1Smrg # Aesthetically quote it. 4499949d0342Smrg func_quote_arg pretty "$arg" 4500949d0342Smrg func_append install_prog "$func_quote_arg_result" 4501d5c3dbf1Smrg install_shared_prog=$install_prog 4502d5c3dbf1Smrg case " $install_prog " in 4503d5c3dbf1Smrg *[\\\ /]cp\ *) install_cp=: ;; 4504d5c3dbf1Smrg *) install_cp=false ;; 4505d5c3dbf1Smrg esac 45069f606849Smrg 4507d5c3dbf1Smrg # We need to accept at least all the BSD install flags. 4508d5c3dbf1Smrg dest= 4509d5c3dbf1Smrg files= 4510d5c3dbf1Smrg opts= 4511d5c3dbf1Smrg prev= 4512d5c3dbf1Smrg install_type= 4513949d0342Smrg isdir=false 4514d5c3dbf1Smrg stripme= 4515d5c3dbf1Smrg no_mode=: 4516d5c3dbf1Smrg for arg 4517d5c3dbf1Smrg do 4518d5c3dbf1Smrg arg2= 4519d5c3dbf1Smrg if test -n "$dest"; then 4520cdbfa18aSmrg func_append files " $dest" 4521d5c3dbf1Smrg dest=$arg 45229f606849Smrg continue 4523d5c3dbf1Smrg fi 45249f606849Smrg 4525d5c3dbf1Smrg case $arg in 4526949d0342Smrg -d) isdir=: ;; 4527d5c3dbf1Smrg -f) 4528d5c3dbf1Smrg if $install_cp; then :; else 4529d5c3dbf1Smrg prev=$arg 45309f606849Smrg fi 4531d5c3dbf1Smrg ;; 4532d5c3dbf1Smrg -g | -m | -o) 4533d5c3dbf1Smrg prev=$arg 4534d5c3dbf1Smrg ;; 4535d5c3dbf1Smrg -s) 4536d5c3dbf1Smrg stripme=" -s" 45379f606849Smrg continue 45389f606849Smrg ;; 4539d5c3dbf1Smrg -*) 4540d5c3dbf1Smrg ;; 45419f606849Smrg *) 4542d5c3dbf1Smrg # If the previous option needed an argument, then skip it. 4543d5c3dbf1Smrg if test -n "$prev"; then 4544949d0342Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4545d5c3dbf1Smrg arg2=$install_override_mode 4546d5c3dbf1Smrg no_mode=false 4547d5c3dbf1Smrg fi 4548d5c3dbf1Smrg prev= 4549d5c3dbf1Smrg else 4550d5c3dbf1Smrg dest=$arg 4551d5c3dbf1Smrg continue 4552d5c3dbf1Smrg fi 45539f606849Smrg ;; 4554d5c3dbf1Smrg esac 45559f606849Smrg 4556d5c3dbf1Smrg # Aesthetically quote the argument. 4557949d0342Smrg func_quote_arg pretty "$arg" 4558949d0342Smrg func_append install_prog " $func_quote_arg_result" 4559d5c3dbf1Smrg if test -n "$arg2"; then 4560949d0342Smrg func_quote_arg pretty "$arg2" 45619f606849Smrg fi 4562949d0342Smrg func_append install_shared_prog " $func_quote_arg_result" 4563d5c3dbf1Smrg done 45649f606849Smrg 4565d5c3dbf1Smrg test -z "$install_prog" && \ 4566d5c3dbf1Smrg func_fatal_help "you must specify an install program" 45679f606849Smrg 4568d5c3dbf1Smrg test -n "$prev" && \ 4569949d0342Smrg func_fatal_help "the '$prev' option requires an argument" 45709f606849Smrg 4571d5c3dbf1Smrg if test -n "$install_override_mode" && $no_mode; then 4572d5c3dbf1Smrg if $install_cp; then :; else 4573949d0342Smrg func_quote_arg pretty "$install_override_mode" 4574949d0342Smrg func_append install_shared_prog " -m $func_quote_arg_result" 4575d5c3dbf1Smrg fi 45769f606849Smrg fi 45779f606849Smrg 4578d5c3dbf1Smrg if test -z "$files"; then 4579d5c3dbf1Smrg if test -z "$dest"; then 4580d5c3dbf1Smrg func_fatal_help "no file or destination specified" 4581d5c3dbf1Smrg else 4582d5c3dbf1Smrg func_fatal_help "you must specify a destination" 45839f606849Smrg fi 45849f606849Smrg fi 45859f606849Smrg 4586d5c3dbf1Smrg # Strip any trailing slash from the destination. 4587d5c3dbf1Smrg func_stripname '' '/' "$dest" 4588d5c3dbf1Smrg dest=$func_stripname_result 45899f606849Smrg 4590d5c3dbf1Smrg # Check to see that the destination is a directory. 4591949d0342Smrg test -d "$dest" && isdir=: 4592949d0342Smrg if $isdir; then 4593949d0342Smrg destdir=$dest 4594d5c3dbf1Smrg destname= 4595d5c3dbf1Smrg else 4596d5c3dbf1Smrg func_dirname_and_basename "$dest" "" "." 4597949d0342Smrg destdir=$func_dirname_result 4598949d0342Smrg destname=$func_basename_result 4599d5c3dbf1Smrg 4600d5c3dbf1Smrg # Not a directory, so check to see that there is only one file specified. 4601d5c3dbf1Smrg set dummy $files; shift 4602d5c3dbf1Smrg test "$#" -gt 1 && \ 4603949d0342Smrg func_fatal_help "'$dest' is not a directory" 4604d5c3dbf1Smrg fi 4605d5c3dbf1Smrg case $destdir in 4606d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 46079f606849Smrg *) 4608d5c3dbf1Smrg for file in $files; do 4609d5c3dbf1Smrg case $file in 4610d5c3dbf1Smrg *.lo) ;; 4611d5c3dbf1Smrg *) 4612949d0342Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4613d5c3dbf1Smrg ;; 4614d5c3dbf1Smrg esac 4615d5c3dbf1Smrg done 46169f606849Smrg ;; 46179f606849Smrg esac 46189f606849Smrg 4619d5c3dbf1Smrg # This variable tells wrapper scripts just to set variables rather 4620d5c3dbf1Smrg # than running their programs. 4621949d0342Smrg libtool_install_magic=$magic 46229f606849Smrg 4623d5c3dbf1Smrg staticlibs= 4624d5c3dbf1Smrg future_libdirs= 4625d5c3dbf1Smrg current_libdirs= 4626d5c3dbf1Smrg for file in $files; do 46279f606849Smrg 4628d5c3dbf1Smrg # Do each installation. 4629d5c3dbf1Smrg case $file in 4630d5c3dbf1Smrg *.$libext) 4631d5c3dbf1Smrg # Do the static libraries later. 4632cdbfa18aSmrg func_append staticlibs " $file" 4633d5c3dbf1Smrg ;; 4634d5c3dbf1Smrg 4635d5c3dbf1Smrg *.la) 4636cdbfa18aSmrg func_resolve_sysroot "$file" 4637cdbfa18aSmrg file=$func_resolve_sysroot_result 4638cdbfa18aSmrg 4639d5c3dbf1Smrg # Check to see that this really is a libtool archive. 4640d5c3dbf1Smrg func_lalib_unsafe_p "$file" \ 4641949d0342Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4642d5c3dbf1Smrg 4643d5c3dbf1Smrg library_names= 4644d5c3dbf1Smrg old_library= 4645d5c3dbf1Smrg relink_command= 4646d5c3dbf1Smrg func_source "$file" 4647d5c3dbf1Smrg 4648d5c3dbf1Smrg # Add the libdir to current_libdirs if it is the destination. 4649d5c3dbf1Smrg if test "X$destdir" = "X$libdir"; then 4650d5c3dbf1Smrg case "$current_libdirs " in 4651d5c3dbf1Smrg *" $libdir "*) ;; 4652cdbfa18aSmrg *) func_append current_libdirs " $libdir" ;; 46539f606849Smrg esac 4654d5c3dbf1Smrg else 4655d5c3dbf1Smrg # Note the libdir as a future libdir. 4656d5c3dbf1Smrg case "$future_libdirs " in 4657d5c3dbf1Smrg *" $libdir "*) ;; 4658cdbfa18aSmrg *) func_append future_libdirs " $libdir" ;; 4659d5c3dbf1Smrg esac 4660d5c3dbf1Smrg fi 46619f606849Smrg 4662d5c3dbf1Smrg func_dirname "$file" "/" "" 4663949d0342Smrg dir=$func_dirname_result 4664cdbfa18aSmrg func_append dir "$objdir" 4665d5c3dbf1Smrg 4666d5c3dbf1Smrg if test -n "$relink_command"; then 4667dc088bc7Smrg # Strip any trailing slash from the destination. 4668dc088bc7Smrg func_stripname '' '/' "$libdir" 4669dc088bc7Smrg destlibdir=$func_stripname_result 4670dc088bc7Smrg 4671dc088bc7Smrg func_stripname '' '/' "$destdir" 4672dc088bc7Smrg s_destdir=$func_stripname_result 4673dc088bc7Smrg 4674d5c3dbf1Smrg # Determine the prefix the user has applied to our future dir. 4675dc088bc7Smrg inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$destlibdir\$%%"` 4676d5c3dbf1Smrg 4677d5c3dbf1Smrg # Don't allow the user to place us outside of our expected 4678d5c3dbf1Smrg # location b/c this prevents finding dependent libraries that 4679d5c3dbf1Smrg # are installed to the same prefix. 4680d5c3dbf1Smrg # At present, this check doesn't affect windows .dll's that 4681d5c3dbf1Smrg # are installed into $libdir/../bin (currently, that works fine) 4682d5c3dbf1Smrg # but it's something to keep an eye on. 4683d5c3dbf1Smrg test "$inst_prefix_dir" = "$destdir" && \ 4684949d0342Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4685d5c3dbf1Smrg 4686d5c3dbf1Smrg if test -n "$inst_prefix_dir"; then 4687d5c3dbf1Smrg # Stick the inst_prefix_dir data into the link command. 4688d5c3dbf1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4689d5c3dbf1Smrg else 4690d5c3dbf1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4691d5c3dbf1Smrg fi 4692d5c3dbf1Smrg 4693949d0342Smrg func_warning "relinking '$file'" 4694d5c3dbf1Smrg func_show_eval "$relink_command" \ 4695949d0342Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4696d5c3dbf1Smrg fi 4697d5c3dbf1Smrg 4698d5c3dbf1Smrg # See the names of the shared library. 4699d5c3dbf1Smrg set dummy $library_names; shift 4700d5c3dbf1Smrg if test -n "$1"; then 4701949d0342Smrg realname=$1 4702d5c3dbf1Smrg shift 4703d5c3dbf1Smrg 4704949d0342Smrg srcname=$realname 4705949d0342Smrg test -n "$relink_command" && srcname=${realname}T 4706d5c3dbf1Smrg 4707d5c3dbf1Smrg # Install the shared library and build the symlinks. 4708d5c3dbf1Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4709d5c3dbf1Smrg 'exit $?' 4710949d0342Smrg tstripme=$stripme 4711d5c3dbf1Smrg case $host_os in 4712dc088bc7Smrg cygwin* | mingw* | windows* | pw32* | cegcc*) 4713d5c3dbf1Smrg case $realname in 4714d5c3dbf1Smrg *.dll.a) 4715949d0342Smrg tstripme= 4716949d0342Smrg ;; 4717949d0342Smrg esac 4718949d0342Smrg ;; 4719949d0342Smrg os2*) 4720949d0342Smrg case $realname in 4721949d0342Smrg *_dll.a) 4722949d0342Smrg tstripme= 4723d5c3dbf1Smrg ;; 4724d5c3dbf1Smrg esac 47259f606849Smrg ;; 47269f606849Smrg esac 4727d5c3dbf1Smrg if test -n "$tstripme" && test -n "$striplib"; then 4728d5c3dbf1Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4729d5c3dbf1Smrg fi 4730d5c3dbf1Smrg 4731d5c3dbf1Smrg if test "$#" -gt 0; then 4732d5c3dbf1Smrg # Delete the old symlinks, and create new ones. 4733949d0342Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4734d5c3dbf1Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4735d5c3dbf1Smrg # so we also need to try rm && ln -s. 4736d5c3dbf1Smrg for linkname 4737d5c3dbf1Smrg do 4738d5c3dbf1Smrg test "$linkname" != "$realname" \ 4739d5c3dbf1Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4740d5c3dbf1Smrg done 4741d5c3dbf1Smrg fi 4742d5c3dbf1Smrg 4743d5c3dbf1Smrg # Do each command in the postinstall commands. 4744949d0342Smrg lib=$destdir/$realname 4745d5c3dbf1Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4746d5c3dbf1Smrg fi 4747d5c3dbf1Smrg 4748d5c3dbf1Smrg # Install the pseudo-library for information purposes. 4749d5c3dbf1Smrg func_basename "$file" 4750949d0342Smrg name=$func_basename_result 4751949d0342Smrg instname=$dir/${name}i 4752d5c3dbf1Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4753d5c3dbf1Smrg 4754d5c3dbf1Smrg # Maybe install the static library, too. 4755cdbfa18aSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 47569f606849Smrg ;; 4757d5c3dbf1Smrg 4758d5c3dbf1Smrg *.lo) 4759d5c3dbf1Smrg # Install (i.e. copy) a libtool object. 4760d5c3dbf1Smrg 4761d5c3dbf1Smrg # Figure out destination file name, if it wasn't already specified. 4762d5c3dbf1Smrg if test -n "$destname"; then 4763949d0342Smrg destfile=$destdir/$destname 4764d5c3dbf1Smrg else 4765d5c3dbf1Smrg func_basename "$file" 4766949d0342Smrg destfile=$func_basename_result 4767949d0342Smrg destfile=$destdir/$destfile 4768d5c3dbf1Smrg fi 4769d5c3dbf1Smrg 4770d5c3dbf1Smrg # Deduce the name of the destination old-style object file. 4771d5c3dbf1Smrg case $destfile in 4772d5c3dbf1Smrg *.lo) 4773d5c3dbf1Smrg func_lo2o "$destfile" 4774d5c3dbf1Smrg staticdest=$func_lo2o_result 47759f606849Smrg ;; 4776d5c3dbf1Smrg *.$objext) 4777949d0342Smrg staticdest=$destfile 4778d5c3dbf1Smrg destfile= 47799f606849Smrg ;; 4780d5c3dbf1Smrg *) 4781949d0342Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 47829f606849Smrg ;; 4783d5c3dbf1Smrg esac 4784d5c3dbf1Smrg 4785d5c3dbf1Smrg # Install the libtool object if requested. 4786d5c3dbf1Smrg test -n "$destfile" && \ 4787d5c3dbf1Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4788d5c3dbf1Smrg 4789d5c3dbf1Smrg # Install the old object if enabled. 4790949d0342Smrg if test yes = "$build_old_libs"; then 4791d5c3dbf1Smrg # Deduce the name of the old-style object file. 4792d5c3dbf1Smrg func_lo2o "$file" 4793d5c3dbf1Smrg staticobj=$func_lo2o_result 4794d5c3dbf1Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 47959f606849Smrg fi 4796d5c3dbf1Smrg exit $EXIT_SUCCESS 4797d5c3dbf1Smrg ;; 47989f606849Smrg 4799d5c3dbf1Smrg *) 4800d5c3dbf1Smrg # Figure out destination file name, if it wasn't already specified. 4801d5c3dbf1Smrg if test -n "$destname"; then 4802949d0342Smrg destfile=$destdir/$destname 48039f606849Smrg else 4804d5c3dbf1Smrg func_basename "$file" 4805949d0342Smrg destfile=$func_basename_result 4806949d0342Smrg destfile=$destdir/$destfile 48079f606849Smrg fi 48089f606849Smrg 4809d5c3dbf1Smrg # If the file is missing, and there is a .exe on the end, strip it 4810d5c3dbf1Smrg # because it is most likely a libtool script we actually want to 4811d5c3dbf1Smrg # install 4812949d0342Smrg stripped_ext= 4813d5c3dbf1Smrg case $file in 4814d5c3dbf1Smrg *.exe) 4815d5c3dbf1Smrg if test ! -f "$file"; then 4816d5c3dbf1Smrg func_stripname '' '.exe' "$file" 4817d5c3dbf1Smrg file=$func_stripname_result 4818949d0342Smrg stripped_ext=.exe 4819d5c3dbf1Smrg fi 4820d5c3dbf1Smrg ;; 4821d5c3dbf1Smrg esac 48229f606849Smrg 4823d5c3dbf1Smrg # Do a test to see if this is really a libtool program. 4824d5c3dbf1Smrg case $host in 4825dc088bc7Smrg *cygwin* | *mingw* | *windows*) 4826d5c3dbf1Smrg if func_ltwrapper_executable_p "$file"; then 4827d5c3dbf1Smrg func_ltwrapper_scriptname "$file" 4828d5c3dbf1Smrg wrapper=$func_ltwrapper_scriptname_result 4829d5c3dbf1Smrg else 4830d5c3dbf1Smrg func_stripname '' '.exe' "$file" 4831d5c3dbf1Smrg wrapper=$func_stripname_result 4832d5c3dbf1Smrg fi 4833d5c3dbf1Smrg ;; 4834d5c3dbf1Smrg *) 4835d5c3dbf1Smrg wrapper=$file 4836d5c3dbf1Smrg ;; 4837d5c3dbf1Smrg esac 4838d5c3dbf1Smrg if func_ltwrapper_script_p "$wrapper"; then 4839d5c3dbf1Smrg notinst_deplibs= 4840d5c3dbf1Smrg relink_command= 48419f606849Smrg 4842d5c3dbf1Smrg func_source "$wrapper" 48439f606849Smrg 4844d5c3dbf1Smrg # Check the variables that should have been set. 4845d5c3dbf1Smrg test -z "$generated_by_libtool_version" && \ 4846949d0342Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 48479f606849Smrg 4848949d0342Smrg finalize=: 4849d5c3dbf1Smrg for lib in $notinst_deplibs; do 4850d5c3dbf1Smrg # Check to see that each library is installed. 4851d5c3dbf1Smrg libdir= 4852d5c3dbf1Smrg if test -f "$lib"; then 4853d5c3dbf1Smrg func_source "$lib" 48549f606849Smrg fi 4855949d0342Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4856d5c3dbf1Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4857949d0342Smrg func_warning "'$lib' has not been installed in '$libdir'" 4858949d0342Smrg finalize=false 4859d5c3dbf1Smrg fi 4860d5c3dbf1Smrg done 48619f606849Smrg 4862d5c3dbf1Smrg relink_command= 4863d5c3dbf1Smrg func_source "$wrapper" 48649f606849Smrg 4865d5c3dbf1Smrg outputname= 4866949d0342Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4867d5c3dbf1Smrg $opt_dry_run || { 4868949d0342Smrg if $finalize; then 4869d5c3dbf1Smrg tmpdir=`func_mktempdir` 4870d5c3dbf1Smrg func_basename "$file$stripped_ext" 4871949d0342Smrg file=$func_basename_result 4872949d0342Smrg outputname=$tmpdir/$file 4873d5c3dbf1Smrg # Replace the output file specification. 4874d5c3dbf1Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4875d5c3dbf1Smrg 4876949d0342Smrg $opt_quiet || { 4877949d0342Smrg func_quote_arg expand,pretty "$relink_command" 4878949d0342Smrg eval "func_echo $func_quote_arg_result" 4879d5c3dbf1Smrg } 4880d5c3dbf1Smrg if eval "$relink_command"; then : 4881d5c3dbf1Smrg else 4882949d0342Smrg func_error "error: relink '$file' with the above command before installing it" 4883d5c3dbf1Smrg $opt_dry_run || ${RM}r "$tmpdir" 4884d5c3dbf1Smrg continue 4885d5c3dbf1Smrg fi 4886949d0342Smrg file=$outputname 4887d5c3dbf1Smrg else 4888949d0342Smrg func_warning "cannot relink '$file'" 4889d5c3dbf1Smrg fi 4890d5c3dbf1Smrg } 48919f606849Smrg else 4892d5c3dbf1Smrg # Install the binary that we compiled earlier. 4893d5c3dbf1Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 48949f606849Smrg fi 4895d5c3dbf1Smrg fi 48969f606849Smrg 4897d5c3dbf1Smrg # remove .exe since cygwin /usr/bin/install will append another 4898d5c3dbf1Smrg # one anyway 4899d5c3dbf1Smrg case $install_prog,$host in 4900d5c3dbf1Smrg */usr/bin/install*,*cygwin*) 4901d5c3dbf1Smrg case $file:$destfile in 4902d5c3dbf1Smrg *.exe:*.exe) 4903d5c3dbf1Smrg # this is ok 4904d5c3dbf1Smrg ;; 4905d5c3dbf1Smrg *.exe:*) 4906d5c3dbf1Smrg destfile=$destfile.exe 4907d5c3dbf1Smrg ;; 4908d5c3dbf1Smrg *:*.exe) 4909d5c3dbf1Smrg func_stripname '' '.exe' "$destfile" 4910d5c3dbf1Smrg destfile=$func_stripname_result 4911d5c3dbf1Smrg ;; 4912d5c3dbf1Smrg esac 49139f606849Smrg ;; 49149f606849Smrg esac 4915d5c3dbf1Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4916d5c3dbf1Smrg $opt_dry_run || if test -n "$outputname"; then 4917d5c3dbf1Smrg ${RM}r "$tmpdir" 4918d5c3dbf1Smrg fi 4919d5c3dbf1Smrg ;; 4920d5c3dbf1Smrg esac 4921d5c3dbf1Smrg done 49229f606849Smrg 4923d5c3dbf1Smrg for file in $staticlibs; do 4924d5c3dbf1Smrg func_basename "$file" 4925949d0342Smrg name=$func_basename_result 4926d5c3dbf1Smrg 4927d5c3dbf1Smrg # Set up the ranlib parameters. 4928949d0342Smrg oldlib=$destdir/$name 4929cdbfa18aSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4930cdbfa18aSmrg tool_oldlib=$func_to_tool_file_result 4931d5c3dbf1Smrg 4932d5c3dbf1Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4933d5c3dbf1Smrg 4934d5c3dbf1Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4935cdbfa18aSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4936d5c3dbf1Smrg fi 4937d5c3dbf1Smrg 4938d5c3dbf1Smrg # Do each command in the postinstall commands. 4939d5c3dbf1Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4940d5c3dbf1Smrg done 4941d5c3dbf1Smrg 4942d5c3dbf1Smrg test -n "$future_libdirs" && \ 4943949d0342Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4944d5c3dbf1Smrg 4945d5c3dbf1Smrg if test -n "$current_libdirs"; then 4946d5c3dbf1Smrg # Maybe just do a dry run. 4947d5c3dbf1Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4948949d0342Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4949d5c3dbf1Smrg else 4950d5c3dbf1Smrg exit $EXIT_SUCCESS 4951d5c3dbf1Smrg fi 4952d5c3dbf1Smrg} 4953d5c3dbf1Smrg 4954949d0342Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4955d5c3dbf1Smrg 4956d5c3dbf1Smrg 4957d5c3dbf1Smrg# func_generate_dlsyms outputname originator pic_p 4958d5c3dbf1Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4959d5c3dbf1Smrg# a dlpreopen symbol table. 4960d5c3dbf1Smrgfunc_generate_dlsyms () 4961d5c3dbf1Smrg{ 4962949d0342Smrg $debug_cmd 4963949d0342Smrg 4964949d0342Smrg my_outputname=$1 4965949d0342Smrg my_originator=$2 4966949d0342Smrg my_pic_p=${3-false} 4967949d0342Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4968d5c3dbf1Smrg my_dlsyms= 4969d5c3dbf1Smrg 4970949d0342Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4971d5c3dbf1Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4972949d0342Smrg my_dlsyms=${my_outputname}S.c 4973d5c3dbf1Smrg else 4974d5c3dbf1Smrg func_error "not configured to extract global symbols from dlpreopened files" 4975d5c3dbf1Smrg fi 4976d5c3dbf1Smrg fi 4977d5c3dbf1Smrg 4978d5c3dbf1Smrg if test -n "$my_dlsyms"; then 4979d5c3dbf1Smrg case $my_dlsyms in 4980d5c3dbf1Smrg "") ;; 4981d5c3dbf1Smrg *.c) 4982d5c3dbf1Smrg # Discover the nlist of each of the dlfiles. 4983949d0342Smrg nlist=$output_objdir/$my_outputname.nm 4984d5c3dbf1Smrg 4985d5c3dbf1Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4986d5c3dbf1Smrg 4987d5c3dbf1Smrg # Parse the name list into a source file. 4988d5c3dbf1Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4989d5c3dbf1Smrg 4990d5c3dbf1Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4991949d0342Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4992949d0342Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4993d5c3dbf1Smrg 4994d5c3dbf1Smrg#ifdef __cplusplus 4995d5c3dbf1Smrgextern \"C\" { 4996d5c3dbf1Smrg#endif 4997d5c3dbf1Smrg 4998949d0342Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4999d5c3dbf1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 5000d5c3dbf1Smrg#endif 5001d5c3dbf1Smrg 5002cdbfa18aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 5003949d0342Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 5004949d0342Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 5005cdbfa18aSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 5006cdbfa18aSmrg# define LT_DLSYM_CONST 5007949d0342Smrg#elif defined __osf__ 5008cdbfa18aSmrg/* This system does not cope well with relocations in const data. */ 5009cdbfa18aSmrg# define LT_DLSYM_CONST 5010cdbfa18aSmrg#else 5011cdbfa18aSmrg# define LT_DLSYM_CONST const 5012cdbfa18aSmrg#endif 5013cdbfa18aSmrg 5014949d0342Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5015949d0342Smrg 5016d5c3dbf1Smrg/* External symbol declarations for the compiler. */\ 5017d5c3dbf1Smrg" 5018d5c3dbf1Smrg 5019949d0342Smrg if test yes = "$dlself"; then 5020949d0342Smrg func_verbose "generating symbol list for '$output'" 5021d5c3dbf1Smrg 5022d5c3dbf1Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 5023d5c3dbf1Smrg 5024d5c3dbf1Smrg # Add our own program objects to the symbol list. 5025d5c3dbf1Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 5026d5c3dbf1Smrg for progfile in $progfiles; do 5027cdbfa18aSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 5028949d0342Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 5029cdbfa18aSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 5030d5c3dbf1Smrg done 5031d5c3dbf1Smrg 5032d5c3dbf1Smrg if test -n "$exclude_expsyms"; then 5033d5c3dbf1Smrg $opt_dry_run || { 5034d5c3dbf1Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 5035d5c3dbf1Smrg eval '$MV "$nlist"T "$nlist"' 5036d5c3dbf1Smrg } 50379f606849Smrg fi 5038d5c3dbf1Smrg 5039d5c3dbf1Smrg if test -n "$export_symbols_regex"; then 5040d5c3dbf1Smrg $opt_dry_run || { 5041d5c3dbf1Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 5042d5c3dbf1Smrg eval '$MV "$nlist"T "$nlist"' 5043d5c3dbf1Smrg } 5044d5c3dbf1Smrg fi 5045d5c3dbf1Smrg 5046d5c3dbf1Smrg # Prepare the list of exported symbols 5047d5c3dbf1Smrg if test -z "$export_symbols"; then 5048949d0342Smrg export_symbols=$output_objdir/$outputname.exp 5049d5c3dbf1Smrg $opt_dry_run || { 5050d5c3dbf1Smrg $RM $export_symbols 5051949d0342Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 5052d5c3dbf1Smrg case $host in 5053dc088bc7Smrg *cygwin* | *mingw* | *windows* | *cegcc* ) 5054d5c3dbf1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 5055d5c3dbf1Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 5056d5c3dbf1Smrg ;; 5057d5c3dbf1Smrg esac 5058d5c3dbf1Smrg } 50599f606849Smrg else 5060d5c3dbf1Smrg $opt_dry_run || { 5061949d0342Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 5062d5c3dbf1Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 5063d5c3dbf1Smrg eval '$MV "$nlist"T "$nlist"' 5064d5c3dbf1Smrg case $host in 5065dc088bc7Smrg *cygwin* | *mingw* | *windows* | *cegcc* ) 5066d5c3dbf1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 5067d5c3dbf1Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 5068d5c3dbf1Smrg ;; 5069d5c3dbf1Smrg esac 5070d5c3dbf1Smrg } 50719f606849Smrg fi 5072d5c3dbf1Smrg fi 50739f606849Smrg 5074d5c3dbf1Smrg for dlprefile in $dlprefiles; do 5075949d0342Smrg func_verbose "extracting global C symbols from '$dlprefile'" 5076d5c3dbf1Smrg func_basename "$dlprefile" 5077949d0342Smrg name=$func_basename_result 5078cdbfa18aSmrg case $host in 5079dc088bc7Smrg *cygwin* | *mingw* | *windows* | *cegcc* ) 5080cdbfa18aSmrg # if an import library, we need to obtain dlname 5081cdbfa18aSmrg if func_win32_import_lib_p "$dlprefile"; then 5082cdbfa18aSmrg func_tr_sh "$dlprefile" 5083cdbfa18aSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 5084949d0342Smrg dlprefile_dlbasename= 5085cdbfa18aSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 5086cdbfa18aSmrg # Use subshell, to avoid clobbering current variable values 5087cdbfa18aSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 5088949d0342Smrg if test -n "$dlprefile_dlname"; then 5089cdbfa18aSmrg func_basename "$dlprefile_dlname" 5090949d0342Smrg dlprefile_dlbasename=$func_basename_result 5091cdbfa18aSmrg else 5092cdbfa18aSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 5093cdbfa18aSmrg $sharedlib_from_linklib_cmd "$dlprefile" 5094cdbfa18aSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 5095cdbfa18aSmrg fi 5096cdbfa18aSmrg fi 5097cdbfa18aSmrg $opt_dry_run || { 5098949d0342Smrg if test -n "$dlprefile_dlbasename"; then 5099cdbfa18aSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 5100cdbfa18aSmrg else 5101cdbfa18aSmrg func_warning "Could not compute DLL name from $name" 5102cdbfa18aSmrg eval '$ECHO ": $name " >> "$nlist"' 5103cdbfa18aSmrg fi 5104cdbfa18aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 5105dc088bc7Smrg case $host in 5106dc088bc7Smrg i[3456]86-*-mingw32*) 5107dc088bc7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 5108dc088bc7Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 5109dc088bc7Smrg ;; 5110dc088bc7Smrg *) 5111dc088bc7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 5112dc088bc7Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/__nm_//' >> '$nlist'" 5113dc088bc7Smrg ;; 5114dc088bc7Smrg esac 5115cdbfa18aSmrg } 5116cdbfa18aSmrg else # not an import lib 5117cdbfa18aSmrg $opt_dry_run || { 5118cdbfa18aSmrg eval '$ECHO ": $name " >> "$nlist"' 5119cdbfa18aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 5120cdbfa18aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 5121cdbfa18aSmrg } 5122cdbfa18aSmrg fi 5123cdbfa18aSmrg ;; 5124cdbfa18aSmrg *) 5125cdbfa18aSmrg $opt_dry_run || { 5126cdbfa18aSmrg eval '$ECHO ": $name " >> "$nlist"' 5127cdbfa18aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 5128cdbfa18aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 5129cdbfa18aSmrg } 5130cdbfa18aSmrg ;; 5131cdbfa18aSmrg esac 5132d5c3dbf1Smrg done 5133d5c3dbf1Smrg 5134d5c3dbf1Smrg $opt_dry_run || { 5135d5c3dbf1Smrg # Make sure we have at least an empty file. 5136d5c3dbf1Smrg test -f "$nlist" || : > "$nlist" 5137d5c3dbf1Smrg 5138d5c3dbf1Smrg if test -n "$exclude_expsyms"; then 5139d5c3dbf1Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 5140d5c3dbf1Smrg $MV "$nlist"T "$nlist" 51419f606849Smrg fi 5142d5c3dbf1Smrg 5143d5c3dbf1Smrg # Try sorting and uniquifying the output. 5144d5c3dbf1Smrg if $GREP -v "^: " < "$nlist" | 5145d5c3dbf1Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 5146d5c3dbf1Smrg sort -k 3 5147d5c3dbf1Smrg else 5148d5c3dbf1Smrg sort +2 5149d5c3dbf1Smrg fi | 5150d5c3dbf1Smrg uniq > "$nlist"S; then 5151d5c3dbf1Smrg : 51529f606849Smrg else 5153d5c3dbf1Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 51549f606849Smrg fi 51559f606849Smrg 5156d5c3dbf1Smrg if test -f "$nlist"S; then 5157d5c3dbf1Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 51589f606849Smrg else 5159d5c3dbf1Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 51609f606849Smrg fi 51619f606849Smrg 5162949d0342Smrg func_show_eval '$RM "${nlist}I"' 5163949d0342Smrg if test -n "$global_symbol_to_import"; then 5164949d0342Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5165949d0342Smrg fi 5166949d0342Smrg 5167d5c3dbf1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 51689f606849Smrg 5169d5c3dbf1Smrg/* The mapping between symbol names and symbols. */ 5170d5c3dbf1Smrgtypedef struct { 5171d5c3dbf1Smrg const char *name; 5172d5c3dbf1Smrg void *address; 5173d5c3dbf1Smrg} lt_dlsymlist; 5174cdbfa18aSmrgextern LT_DLSYM_CONST lt_dlsymlist 5175949d0342Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5176949d0342Smrg" 5177949d0342Smrg 5178949d0342Smrg if test -s "$nlist"I; then 5179949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5180949d0342Smrgstatic void lt_syminit(void) 5181949d0342Smrg{ 5182949d0342Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5183949d0342Smrg for (; symbol->name; ++symbol) 5184949d0342Smrg {" 5185949d0342Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5186949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5187949d0342Smrg } 5188949d0342Smrg}" 5189949d0342Smrg fi 5190949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5191cdbfa18aSmrgLT_DLSYM_CONST lt_dlsymlist 5192d5c3dbf1Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 5193949d0342Smrg{ {\"$my_originator\", (void *) 0}," 5194949d0342Smrg 5195949d0342Smrg if test -s "$nlist"I; then 5196949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5197949d0342Smrg {\"@INIT@\", (void *) <_syminit}," 5198949d0342Smrg fi 51999f606849Smrg 5200d5c3dbf1Smrg case $need_lib_prefix in 5201d5c3dbf1Smrg no) 5202d5c3dbf1Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5203d5c3dbf1Smrg ;; 5204d5c3dbf1Smrg *) 5205d5c3dbf1Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5206d5c3dbf1Smrg ;; 5207d5c3dbf1Smrg esac 5208d5c3dbf1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5209d5c3dbf1Smrg {0, (void *) 0} 5210d5c3dbf1Smrg}; 52119f606849Smrg 5212d5c3dbf1Smrg/* This works around a problem in FreeBSD linker */ 5213d5c3dbf1Smrg#ifdef FREEBSD_WORKAROUND 5214d5c3dbf1Smrgstatic const void *lt_preloaded_setup() { 5215d5c3dbf1Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 5216d5c3dbf1Smrg} 5217d5c3dbf1Smrg#endif 52189f606849Smrg 5219d5c3dbf1Smrg#ifdef __cplusplus 5220d5c3dbf1Smrg} 5221d5c3dbf1Smrg#endif\ 5222d5c3dbf1Smrg" 5223d5c3dbf1Smrg } # !$opt_dry_run 52249f606849Smrg 5225d5c3dbf1Smrg pic_flag_for_symtable= 5226d5c3dbf1Smrg case "$compile_command " in 5227d5c3dbf1Smrg *" -static "*) ;; 5228d5c3dbf1Smrg *) 5229d5c3dbf1Smrg case $host in 5230d5c3dbf1Smrg # compiling the symbol table file with pic_flag works around 5231d5c3dbf1Smrg # a FreeBSD bug that causes programs to crash when -lm is 5232d5c3dbf1Smrg # linked before any other PIC object. But we must not use 5233d5c3dbf1Smrg # pic_flag when linking with -static. The problem exists in 5234d5c3dbf1Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5235cdbfa18aSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5236d5c3dbf1Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5237d5c3dbf1Smrg *-*-hpux*) 5238d5c3dbf1Smrg pic_flag_for_symtable=" $pic_flag" ;; 5239d5c3dbf1Smrg *) 5240949d0342Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5241d5c3dbf1Smrg ;; 5242d5c3dbf1Smrg esac 5243d5c3dbf1Smrg ;; 5244d5c3dbf1Smrg esac 5245d5c3dbf1Smrg symtab_cflags= 5246d5c3dbf1Smrg for arg in $LTCFLAGS; do 5247d5c3dbf1Smrg case $arg in 5248d5c3dbf1Smrg -pie | -fpie | -fPIE) ;; 5249cdbfa18aSmrg *) func_append symtab_cflags " $arg" ;; 5250d5c3dbf1Smrg esac 5251d5c3dbf1Smrg done 52529f606849Smrg 5253d5c3dbf1Smrg # Now compile the dynamic symbol file. 5254d5c3dbf1Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 52559f606849Smrg 5256d5c3dbf1Smrg # Clean up the generated files. 5257949d0342Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 52589f606849Smrg 5259d5c3dbf1Smrg # Transform the symbol file into the correct name. 5260949d0342Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 5261d5c3dbf1Smrg case $host in 5262dc088bc7Smrg *cygwin* | *mingw* | *windows* | *cegcc* ) 5263d5c3dbf1Smrg if test -f "$output_objdir/$my_outputname.def"; then 5264d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5265d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5266d5c3dbf1Smrg else 5267d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5268d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5269d5c3dbf1Smrg fi 5270d5c3dbf1Smrg ;; 5271d5c3dbf1Smrg *) 5272d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5273d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5274d5c3dbf1Smrg ;; 5275d5c3dbf1Smrg esac 5276d5c3dbf1Smrg ;; 5277d5c3dbf1Smrg *) 5278949d0342Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5279d5c3dbf1Smrg ;; 5280d5c3dbf1Smrg esac 5281d5c3dbf1Smrg else 5282d5c3dbf1Smrg # We keep going just in case the user didn't refer to 5283d5c3dbf1Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5284d5c3dbf1Smrg # really was required. 52859f606849Smrg 5286d5c3dbf1Smrg # Nullify the symbol file. 5287d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5288d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5289d5c3dbf1Smrg fi 5290d5c3dbf1Smrg} 52919f606849Smrg 5292949d0342Smrg# func_cygming_gnu_implib_p ARG 5293949d0342Smrg# This predicate returns with zero status (TRUE) if 5294949d0342Smrg# ARG is a GNU/binutils-style import library. Returns 5295949d0342Smrg# with nonzero status (FALSE) otherwise. 5296949d0342Smrgfunc_cygming_gnu_implib_p () 5297949d0342Smrg{ 5298949d0342Smrg $debug_cmd 5299949d0342Smrg 5300949d0342Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5301949d0342Smrg 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)$'` 5302949d0342Smrg test -n "$func_cygming_gnu_implib_tmp" 5303949d0342Smrg} 5304949d0342Smrg 5305949d0342Smrg# func_cygming_ms_implib_p ARG 5306949d0342Smrg# This predicate returns with zero status (TRUE) if 5307949d0342Smrg# ARG is an MS-style import library. Returns 5308949d0342Smrg# with nonzero status (FALSE) otherwise. 5309949d0342Smrgfunc_cygming_ms_implib_p () 5310949d0342Smrg{ 5311949d0342Smrg $debug_cmd 5312949d0342Smrg 5313949d0342Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5314949d0342Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5315949d0342Smrg test -n "$func_cygming_ms_implib_tmp" 5316949d0342Smrg} 5317949d0342Smrg 5318d5c3dbf1Smrg# func_win32_libid arg 5319d5c3dbf1Smrg# return the library type of file 'arg' 5320d5c3dbf1Smrg# 5321d5c3dbf1Smrg# Need a lot of goo to handle *both* DLLs and import libs 5322d5c3dbf1Smrg# Has to be a shell function in order to 'eat' the argument 5323d5c3dbf1Smrg# that is supplied when $file_magic_command is called. 5324d5c3dbf1Smrg# Despite the name, also deal with 64 bit binaries. 5325d5c3dbf1Smrgfunc_win32_libid () 5326d5c3dbf1Smrg{ 5327949d0342Smrg $debug_cmd 5328949d0342Smrg 5329949d0342Smrg win32_libid_type=unknown 5330d5c3dbf1Smrg win32_fileres=`file -L $1 2>/dev/null` 5331d5c3dbf1Smrg case $win32_fileres in 5332d5c3dbf1Smrg *ar\ archive\ import\ library*) # definitely import 5333d5c3dbf1Smrg win32_libid_type="x86 archive import" 5334d5c3dbf1Smrg ;; 5335d5c3dbf1Smrg *ar\ archive*) # could be an import, or static 5336d5c3dbf1Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5337d5c3dbf1Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5338dc088bc7Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' >/dev/null; then 5339949d0342Smrg case $nm_interface in 5340949d0342Smrg "MS dumpbin") 5341949d0342Smrg if func_cygming_ms_implib_p "$1" || 5342949d0342Smrg func_cygming_gnu_implib_p "$1" 5343949d0342Smrg then 5344949d0342Smrg win32_nmres=import 5345949d0342Smrg else 5346949d0342Smrg win32_nmres= 5347949d0342Smrg fi 5348949d0342Smrg ;; 5349949d0342Smrg *) 5350949d0342Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5351949d0342Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5352949d0342Smrg $SED -n -e ' 5353d5c3dbf1Smrg 1,100{ 5354d5c3dbf1Smrg / I /{ 5355949d0342Smrg s|.*|import| 5356d5c3dbf1Smrg p 5357d5c3dbf1Smrg q 5358d5c3dbf1Smrg } 5359d5c3dbf1Smrg }'` 5360949d0342Smrg ;; 5361949d0342Smrg esac 5362d5c3dbf1Smrg case $win32_nmres in 5363d5c3dbf1Smrg import*) win32_libid_type="x86 archive import";; 5364d5c3dbf1Smrg *) win32_libid_type="x86 archive static";; 5365d5c3dbf1Smrg esac 5366d5c3dbf1Smrg fi 5367d5c3dbf1Smrg ;; 5368d5c3dbf1Smrg *DLL*) 5369d5c3dbf1Smrg win32_libid_type="x86 DLL" 5370d5c3dbf1Smrg ;; 5371d5c3dbf1Smrg *executable*) # but shell scripts are "executable" too... 5372d5c3dbf1Smrg case $win32_fileres in 5373d5c3dbf1Smrg *MS\ Windows\ PE\ Intel*) 5374d5c3dbf1Smrg win32_libid_type="x86 DLL" 5375d5c3dbf1Smrg ;; 5376d5c3dbf1Smrg esac 5377d5c3dbf1Smrg ;; 5378d5c3dbf1Smrg esac 5379d5c3dbf1Smrg $ECHO "$win32_libid_type" 5380d5c3dbf1Smrg} 53819f606849Smrg 5382cdbfa18aSmrg# func_cygming_dll_for_implib ARG 5383cdbfa18aSmrg# 5384cdbfa18aSmrg# Platform-specific function to extract the 5385cdbfa18aSmrg# name of the DLL associated with the specified 5386cdbfa18aSmrg# import library ARG. 5387cdbfa18aSmrg# Invoked by eval'ing the libtool variable 5388cdbfa18aSmrg# $sharedlib_from_linklib_cmd 5389cdbfa18aSmrg# Result is available in the variable 5390cdbfa18aSmrg# $sharedlib_from_linklib_result 5391cdbfa18aSmrgfunc_cygming_dll_for_implib () 5392cdbfa18aSmrg{ 5393949d0342Smrg $debug_cmd 5394949d0342Smrg 5395cdbfa18aSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5396cdbfa18aSmrg} 5397cdbfa18aSmrg 5398cdbfa18aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5399cdbfa18aSmrg# 5400cdbfa18aSmrg# The is the core of a fallback implementation of a 5401cdbfa18aSmrg# platform-specific function to extract the name of the 5402cdbfa18aSmrg# DLL associated with the specified import library LIBNAME. 5403cdbfa18aSmrg# 5404cdbfa18aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5405cdbfa18aSmrg# on the platform and compiler that created the implib. 5406cdbfa18aSmrg# 5407cdbfa18aSmrg# Echos the name of the DLL associated with the 5408cdbfa18aSmrg# specified import library. 5409cdbfa18aSmrgfunc_cygming_dll_for_implib_fallback_core () 5410cdbfa18aSmrg{ 5411949d0342Smrg $debug_cmd 5412949d0342Smrg 5413cdbfa18aSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5414cdbfa18aSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5415cdbfa18aSmrg $SED '/^Contents of section '"$match_literal"':/{ 5416cdbfa18aSmrg # Place marker at beginning of archive member dllname section 5417cdbfa18aSmrg s/.*/====MARK====/ 5418cdbfa18aSmrg p 5419cdbfa18aSmrg d 5420cdbfa18aSmrg } 5421cdbfa18aSmrg # These lines can sometimes be longer than 43 characters, but 5422cdbfa18aSmrg # are always uninteresting 5423cdbfa18aSmrg /:[ ]*file format pe[i]\{,1\}-/d 5424cdbfa18aSmrg /^In archive [^:]*:/d 5425cdbfa18aSmrg # Ensure marker is printed 5426cdbfa18aSmrg /^====MARK====/p 5427cdbfa18aSmrg # Remove all lines with less than 43 characters 5428cdbfa18aSmrg /^.\{43\}/!d 5429cdbfa18aSmrg # From remaining lines, remove first 43 characters 5430cdbfa18aSmrg s/^.\{43\}//' | 5431cdbfa18aSmrg $SED -n ' 5432cdbfa18aSmrg # Join marker and all lines until next marker into a single line 5433cdbfa18aSmrg /^====MARK====/ b para 5434cdbfa18aSmrg H 5435cdbfa18aSmrg $ b para 5436cdbfa18aSmrg b 5437cdbfa18aSmrg :para 5438cdbfa18aSmrg x 5439cdbfa18aSmrg s/\n//g 5440cdbfa18aSmrg # Remove the marker 5441cdbfa18aSmrg s/^====MARK====// 5442cdbfa18aSmrg # Remove trailing dots and whitespace 5443cdbfa18aSmrg s/[\. \t]*$// 5444cdbfa18aSmrg # Print 5445cdbfa18aSmrg /./p' | 5446cdbfa18aSmrg # we now have a list, one entry per line, of the stringified 5447cdbfa18aSmrg # contents of the appropriate section of all members of the 5448949d0342Smrg # archive that possess that section. Heuristic: eliminate 5449949d0342Smrg # all those that have a first or second character that is 5450cdbfa18aSmrg # a '.' (that is, objdump's representation of an unprintable 5451cdbfa18aSmrg # character.) This should work for all archives with less than 5452cdbfa18aSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5453cdbfa18aSmrg # begins with a literal '.' or a single character followed by 5454cdbfa18aSmrg # a '.'. 5455cdbfa18aSmrg # 5456cdbfa18aSmrg # Of those that remain, print the first one. 5457cdbfa18aSmrg $SED -e '/^\./d;/^.\./d;q' 5458cdbfa18aSmrg} 5459cdbfa18aSmrg 5460cdbfa18aSmrg# func_cygming_dll_for_implib_fallback ARG 5461cdbfa18aSmrg# Platform-specific function to extract the 5462cdbfa18aSmrg# name of the DLL associated with the specified 5463cdbfa18aSmrg# import library ARG. 5464cdbfa18aSmrg# 5465cdbfa18aSmrg# This fallback implementation is for use when $DLLTOOL 5466cdbfa18aSmrg# does not support the --identify-strict option. 5467cdbfa18aSmrg# Invoked by eval'ing the libtool variable 5468cdbfa18aSmrg# $sharedlib_from_linklib_cmd 5469cdbfa18aSmrg# Result is available in the variable 5470cdbfa18aSmrg# $sharedlib_from_linklib_result 5471cdbfa18aSmrgfunc_cygming_dll_for_implib_fallback () 5472cdbfa18aSmrg{ 5473949d0342Smrg $debug_cmd 5474949d0342Smrg 5475949d0342Smrg if func_cygming_gnu_implib_p "$1"; then 5476cdbfa18aSmrg # binutils import library 5477cdbfa18aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5478949d0342Smrg elif func_cygming_ms_implib_p "$1"; then 5479cdbfa18aSmrg # ms-generated import library 5480cdbfa18aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5481cdbfa18aSmrg else 5482cdbfa18aSmrg # unknown 5483949d0342Smrg sharedlib_from_linklib_result= 5484cdbfa18aSmrg fi 5485cdbfa18aSmrg} 54869f606849Smrg 54879f606849Smrg 5488d5c3dbf1Smrg# func_extract_an_archive dir oldlib 5489d5c3dbf1Smrgfunc_extract_an_archive () 5490d5c3dbf1Smrg{ 5491949d0342Smrg $debug_cmd 5492949d0342Smrg 5493949d0342Smrg f_ex_an_ar_dir=$1; shift 5494949d0342Smrg f_ex_an_ar_oldlib=$1 5495949d0342Smrg if test yes = "$lock_old_archive_extraction"; then 5496d5c3dbf1Smrg lockfile=$f_ex_an_ar_oldlib.lock 5497d5c3dbf1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5498d5c3dbf1Smrg func_echo "Waiting for $lockfile to be removed" 5499d5c3dbf1Smrg sleep 2 5500d5c3dbf1Smrg done 5501d5c3dbf1Smrg fi 5502d5c3dbf1Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5503d5c3dbf1Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5504949d0342Smrg if test yes = "$lock_old_archive_extraction"; then 5505d5c3dbf1Smrg $opt_dry_run || rm -f "$lockfile" 5506d5c3dbf1Smrg fi 5507d5c3dbf1Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5508d5c3dbf1Smrg : 5509d5c3dbf1Smrg else 5510d5c3dbf1Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5511d5c3dbf1Smrg fi 5512d5c3dbf1Smrg} 55139f606849Smrg 55149f606849Smrg 5515d5c3dbf1Smrg# func_extract_archives gentop oldlib ... 5516d5c3dbf1Smrgfunc_extract_archives () 5517d5c3dbf1Smrg{ 5518949d0342Smrg $debug_cmd 5519949d0342Smrg 5520949d0342Smrg my_gentop=$1; shift 5521d5c3dbf1Smrg my_oldlibs=${1+"$@"} 5522949d0342Smrg my_oldobjs= 5523949d0342Smrg my_xlib= 5524949d0342Smrg my_xabs= 5525949d0342Smrg my_xdir= 55269f606849Smrg 5527d5c3dbf1Smrg for my_xlib in $my_oldlibs; do 5528d5c3dbf1Smrg # Extract the objects. 5529d5c3dbf1Smrg case $my_xlib in 5530949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5531d5c3dbf1Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5532d5c3dbf1Smrg esac 5533d5c3dbf1Smrg func_basename "$my_xlib" 5534949d0342Smrg my_xlib=$func_basename_result 5535d5c3dbf1Smrg my_xlib_u=$my_xlib 5536d5c3dbf1Smrg while :; do 5537d5c3dbf1Smrg case " $extracted_archives " in 5538d5c3dbf1Smrg *" $my_xlib_u "*) 5539d5c3dbf1Smrg func_arith $extracted_serial + 1 5540d5c3dbf1Smrg extracted_serial=$func_arith_result 5541d5c3dbf1Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5542d5c3dbf1Smrg *) break ;; 5543d5c3dbf1Smrg esac 5544d5c3dbf1Smrg done 5545d5c3dbf1Smrg extracted_archives="$extracted_archives $my_xlib_u" 5546949d0342Smrg my_xdir=$my_gentop/$my_xlib_u 55479f606849Smrg 5548d5c3dbf1Smrg func_mkdir_p "$my_xdir" 5549d5c3dbf1Smrg 5550d5c3dbf1Smrg case $host in 5551d5c3dbf1Smrg *-darwin*) 5552d5c3dbf1Smrg func_verbose "Extracting $my_xabs" 5553d5c3dbf1Smrg # Do not bother doing anything if just a dry run 5554d5c3dbf1Smrg $opt_dry_run || { 5555d5c3dbf1Smrg darwin_orig_dir=`pwd` 5556d5c3dbf1Smrg cd $my_xdir || exit $? 5557d5c3dbf1Smrg darwin_archive=$my_xabs 5558d5c3dbf1Smrg darwin_curdir=`pwd` 5559949d0342Smrg func_basename "$darwin_archive" 5560949d0342Smrg darwin_base_archive=$func_basename_result 5561d5c3dbf1Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5562d5c3dbf1Smrg if test -n "$darwin_arches"; then 5563d5c3dbf1Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5564d5c3dbf1Smrg darwin_arch= 5565d5c3dbf1Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5566949d0342Smrg for darwin_arch in $darwin_arches; do 5567949d0342Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5568949d0342Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5569949d0342Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5570949d0342Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5571d5c3dbf1Smrg cd "$darwin_curdir" 5572949d0342Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5573d5c3dbf1Smrg done # $darwin_arches 5574d5c3dbf1Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5575949d0342Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5576d5c3dbf1Smrg darwin_file= 5577d5c3dbf1Smrg darwin_files= 5578d5c3dbf1Smrg for darwin_file in $darwin_filelist; do 5579d5c3dbf1Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5580d5c3dbf1Smrg $LIPO -create -output "$darwin_file" $darwin_files 5581d5c3dbf1Smrg done # $darwin_filelist 5582d5c3dbf1Smrg $RM -rf unfat-$$ 5583d5c3dbf1Smrg cd "$darwin_orig_dir" 55849f606849Smrg else 5585d5c3dbf1Smrg cd $darwin_orig_dir 5586d5c3dbf1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5587d5c3dbf1Smrg fi # $darwin_arches 5588d5c3dbf1Smrg } # !$opt_dry_run 5589d5c3dbf1Smrg ;; 5590d5c3dbf1Smrg *) 5591d5c3dbf1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5592d5c3dbf1Smrg ;; 5593d5c3dbf1Smrg esac 5594d5c3dbf1Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5595d5c3dbf1Smrg done 55969f606849Smrg 5597949d0342Smrg func_extract_archives_result=$my_oldobjs 5598d5c3dbf1Smrg} 55999f606849Smrg 56009f606849Smrg 5601d5c3dbf1Smrg# func_emit_wrapper [arg=no] 5602d5c3dbf1Smrg# 5603d5c3dbf1Smrg# Emit a libtool wrapper script on stdout. 5604d5c3dbf1Smrg# Don't directly open a file because we may want to 5605dc088bc7Smrg# incorporate the script contents within a cygwin/mingw/windows 5606d5c3dbf1Smrg# wrapper executable. Must ONLY be called from within 5607d5c3dbf1Smrg# func_mode_link because it depends on a number of variables 5608d5c3dbf1Smrg# set therein. 5609d5c3dbf1Smrg# 5610d5c3dbf1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5611d5c3dbf1Smrg# variable will take. If 'yes', then the emitted script 5612949d0342Smrg# will assume that the directory where it is stored is 5613dc088bc7Smrg# the $objdir directory. This is a cygwin/mingw/windows-specific 5614d5c3dbf1Smrg# behavior. 5615d5c3dbf1Smrgfunc_emit_wrapper () 5616d5c3dbf1Smrg{ 5617d5c3dbf1Smrg func_emit_wrapper_arg1=${1-no} 56189f606849Smrg 5619d5c3dbf1Smrg $ECHO "\ 5620d5c3dbf1Smrg#! $SHELL 56219f606849Smrg 5622d5c3dbf1Smrg# $output - temporary wrapper script for $objdir/$outputname 5623949d0342Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5624d5c3dbf1Smrg# 5625d5c3dbf1Smrg# The $output program cannot be directly executed until all the libtool 5626d5c3dbf1Smrg# libraries that it depends on are installed. 5627d5c3dbf1Smrg# 5628d5c3dbf1Smrg# This wrapper script should never be moved out of the build directory. 5629d5c3dbf1Smrg# If it is, it will not operate correctly. 56309f606849Smrg 5631d5c3dbf1Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5632d5c3dbf1Smrg# metacharacters that are still active within double-quoted strings. 5633d5c3dbf1Smrgsed_quote_subst='$sed_quote_subst' 56349f606849Smrg 5635d5c3dbf1Smrg# Be Bourne compatible 5636d5c3dbf1Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5637d5c3dbf1Smrg emulate sh 5638d5c3dbf1Smrg NULLCMD=: 5639d5c3dbf1Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5640d5c3dbf1Smrg # is contrary to our usage. Disable this feature. 5641d5c3dbf1Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5642d5c3dbf1Smrg setopt NO_GLOB_SUBST 5643d5c3dbf1Smrgelse 5644d5c3dbf1Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5645d5c3dbf1Smrgfi 5646d5c3dbf1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5647d5c3dbf1SmrgDUALCASE=1; export DUALCASE # for MKS sh 56489f606849Smrg 5649d5c3dbf1Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5650d5c3dbf1Smrg# if CDPATH is set. 5651d5c3dbf1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 56529f606849Smrg 5653d5c3dbf1Smrgrelink_command=\"$relink_command\" 56549f606849Smrg 5655d5c3dbf1Smrg# This environment variable determines our operation mode. 5656d5c3dbf1Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5657d5c3dbf1Smrg # install mode needs the following variables: 5658d5c3dbf1Smrg generated_by_libtool_version='$macro_version' 5659d5c3dbf1Smrg notinst_deplibs='$notinst_deplibs' 5660d5c3dbf1Smrgelse 5661d5c3dbf1Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5662d5c3dbf1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5663d5c3dbf1Smrg file=\"\$0\"" 56649f606849Smrg 5665949d0342Smrg func_quote_arg pretty "$ECHO" 5666949d0342Smrg qECHO=$func_quote_arg_result 5667d5c3dbf1Smrg $ECHO "\ 56689f606849Smrg 5669d5c3dbf1Smrg# A function that is used when there is no print builtin or printf. 5670d5c3dbf1Smrgfunc_fallback_echo () 5671d5c3dbf1Smrg{ 5672d5c3dbf1Smrg eval 'cat <<_LTECHO_EOF 5673d5c3dbf1Smrg\$1 5674d5c3dbf1Smrg_LTECHO_EOF' 5675d5c3dbf1Smrg} 5676949d0342Smrg ECHO=$qECHO 5677d5c3dbf1Smrg fi 5678d5c3dbf1Smrg 5679d5c3dbf1Smrg# Very basic option parsing. These options are (a) specific to 5680d5c3dbf1Smrg# the libtool wrapper, (b) are identical between the wrapper 5681949d0342Smrg# /script/ and the wrapper /executable/ that is used only on 5682d5c3dbf1Smrg# windows platforms, and (c) all begin with the string "--lt-" 5683949d0342Smrg# (application programs are unlikely to have options that match 5684d5c3dbf1Smrg# this pattern). 5685d5c3dbf1Smrg# 5686d5c3dbf1Smrg# There are only two supported options: --lt-debug and 5687d5c3dbf1Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5688d5c3dbf1Smrg# 5689d5c3dbf1Smrg# The first argument to this parsing function should be the 5690d5c3dbf1Smrg# script's $0 value, followed by "$@". 5691d5c3dbf1Smrglt_option_debug= 5692d5c3dbf1Smrgfunc_parse_lt_options () 5693d5c3dbf1Smrg{ 5694d5c3dbf1Smrg lt_script_arg0=\$0 5695d5c3dbf1Smrg shift 5696d5c3dbf1Smrg for lt_opt 5697d5c3dbf1Smrg do 5698d5c3dbf1Smrg case \"\$lt_opt\" in 5699d5c3dbf1Smrg --lt-debug) lt_option_debug=1 ;; 5700d5c3dbf1Smrg --lt-dump-script) 5701d5c3dbf1Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5702d5c3dbf1Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5703d5c3dbf1Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5704d5c3dbf1Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5705d5c3dbf1Smrg exit 0 5706d5c3dbf1Smrg ;; 5707d5c3dbf1Smrg --lt-*) 5708d5c3dbf1Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5709d5c3dbf1Smrg exit 1 57109f606849Smrg ;; 5711d5c3dbf1Smrg esac 5712d5c3dbf1Smrg done 57139f606849Smrg 5714d5c3dbf1Smrg # Print the debug banner immediately: 5715d5c3dbf1Smrg if test -n \"\$lt_option_debug\"; then 5716949d0342Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5717d5c3dbf1Smrg fi 5718d5c3dbf1Smrg} 57199f606849Smrg 5720d5c3dbf1Smrg# Used when --lt-debug. Prints its arguments to stdout 5721d5c3dbf1Smrg# (redirection is the responsibility of the caller) 5722d5c3dbf1Smrgfunc_lt_dump_args () 5723d5c3dbf1Smrg{ 5724d5c3dbf1Smrg lt_dump_args_N=1; 5725d5c3dbf1Smrg for lt_arg 5726d5c3dbf1Smrg do 5727949d0342Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5728d5c3dbf1Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5729d5c3dbf1Smrg done 5730d5c3dbf1Smrg} 57319f606849Smrg 5732d5c3dbf1Smrg# Core function for launching the target application 5733d5c3dbf1Smrgfunc_exec_program_core () 5734d5c3dbf1Smrg{ 5735d5c3dbf1Smrg" 5736d5c3dbf1Smrg case $host in 5737d5c3dbf1Smrg # Backslashes separate directories on plain windows 5738dc088bc7Smrg *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*) 5739d5c3dbf1Smrg $ECHO "\ 5740d5c3dbf1Smrg if test -n \"\$lt_option_debug\"; then 5741949d0342Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5742d5c3dbf1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 57439f606849Smrg fi 5744d5c3dbf1Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5745d5c3dbf1Smrg" 5746d5c3dbf1Smrg ;; 57479f606849Smrg 5748d5c3dbf1Smrg *) 5749d5c3dbf1Smrg $ECHO "\ 5750d5c3dbf1Smrg if test -n \"\$lt_option_debug\"; then 5751949d0342Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5752d5c3dbf1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 57539f606849Smrg fi 5754d5c3dbf1Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5755d5c3dbf1Smrg" 5756d5c3dbf1Smrg ;; 5757d5c3dbf1Smrg esac 5758d5c3dbf1Smrg $ECHO "\ 5759d5c3dbf1Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5760d5c3dbf1Smrg exit 1 5761d5c3dbf1Smrg} 57629f606849Smrg 5763d5c3dbf1Smrg# A function to encapsulate launching the target application 5764d5c3dbf1Smrg# Strips options in the --lt-* namespace from \$@ and 5765d5c3dbf1Smrg# launches target application with the remaining arguments. 5766d5c3dbf1Smrgfunc_exec_program () 5767d5c3dbf1Smrg{ 5768cdbfa18aSmrg case \" \$* \" in 5769cdbfa18aSmrg *\\ --lt-*) 5770cdbfa18aSmrg for lt_wr_arg 5771cdbfa18aSmrg do 5772cdbfa18aSmrg case \$lt_wr_arg in 5773cdbfa18aSmrg --lt-*) ;; 5774cdbfa18aSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5775cdbfa18aSmrg esac 5776cdbfa18aSmrg shift 5777cdbfa18aSmrg done ;; 5778cdbfa18aSmrg esac 5779d5c3dbf1Smrg func_exec_program_core \${1+\"\$@\"} 5780d5c3dbf1Smrg} 57819f606849Smrg 5782d5c3dbf1Smrg # Parse options 5783d5c3dbf1Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 57849f606849Smrg 5785d5c3dbf1Smrg # Find the directory that this script lives in. 5786d5c3dbf1Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5787d5c3dbf1Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 57889f606849Smrg 5789d5c3dbf1Smrg # Follow symbolic links until we get to the real thisdir. 5790d5c3dbf1Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5791d5c3dbf1Smrg while test -n \"\$file\"; do 5792d5c3dbf1Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 57939f606849Smrg 5794d5c3dbf1Smrg # If there was a directory component, then change thisdir. 5795d5c3dbf1Smrg if test \"x\$destdir\" != \"x\$file\"; then 5796d5c3dbf1Smrg case \"\$destdir\" in 5797d5c3dbf1Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5798d5c3dbf1Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5799d5c3dbf1Smrg esac 5800d5c3dbf1Smrg fi 58019f606849Smrg 5802d5c3dbf1Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5803d5c3dbf1Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5804d5c3dbf1Smrg done 58059f606849Smrg 5806dc088bc7Smrg # Usually 'no', except on cygwin/mingw/windows when embedded into 5807d5c3dbf1Smrg # the cwrapper. 5808d5c3dbf1Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5809d5c3dbf1Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5810d5c3dbf1Smrg # special case for '.' 5811d5c3dbf1Smrg if test \"\$thisdir\" = \".\"; then 5812d5c3dbf1Smrg thisdir=\`pwd\` 5813d5c3dbf1Smrg fi 5814d5c3dbf1Smrg # remove .libs from thisdir 5815d5c3dbf1Smrg case \"\$thisdir\" in 5816d5c3dbf1Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5817d5c3dbf1Smrg $objdir ) thisdir=. ;; 5818d5c3dbf1Smrg esac 5819d5c3dbf1Smrg fi 58209f606849Smrg 5821d5c3dbf1Smrg # Try to get the absolute directory name. 5822d5c3dbf1Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5823d5c3dbf1Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5824d5c3dbf1Smrg" 58259f606849Smrg 5826949d0342Smrg if test yes = "$fast_install"; then 5827d5c3dbf1Smrg $ECHO "\ 5828d5c3dbf1Smrg program=lt-'$outputname'$exeext 5829d5c3dbf1Smrg progdir=\"\$thisdir/$objdir\" 58309f606849Smrg 5831d5c3dbf1Smrg if test ! -f \"\$progdir/\$program\" || 5832949d0342Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5833d5c3dbf1Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 58349f606849Smrg 5835d5c3dbf1Smrg file=\"\$\$-\$program\" 58369f606849Smrg 5837d5c3dbf1Smrg if test ! -d \"\$progdir\"; then 5838d5c3dbf1Smrg $MKDIR \"\$progdir\" 5839d5c3dbf1Smrg else 5840d5c3dbf1Smrg $RM \"\$progdir/\$file\" 5841d5c3dbf1Smrg fi" 58429f606849Smrg 5843d5c3dbf1Smrg $ECHO "\ 58449f606849Smrg 5845d5c3dbf1Smrg # relink executable if necessary 5846d5c3dbf1Smrg if test -n \"\$relink_command\"; then 5847d5c3dbf1Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5848d5c3dbf1Smrg else 5849949d0342Smrg \$ECHO \"\$relink_command_output\" >&2 5850d5c3dbf1Smrg $RM \"\$progdir/\$file\" 5851d5c3dbf1Smrg exit 1 5852d5c3dbf1Smrg fi 5853d5c3dbf1Smrg fi 58549f606849Smrg 5855d5c3dbf1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5856d5c3dbf1Smrg { $RM \"\$progdir/\$program\"; 5857d5c3dbf1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5858d5c3dbf1Smrg $RM \"\$progdir/\$file\" 5859d5c3dbf1Smrg fi" 5860d5c3dbf1Smrg else 5861d5c3dbf1Smrg $ECHO "\ 5862d5c3dbf1Smrg program='$outputname' 5863d5c3dbf1Smrg progdir=\"\$thisdir/$objdir\" 5864d5c3dbf1Smrg" 5865d5c3dbf1Smrg fi 58669f606849Smrg 5867d5c3dbf1Smrg $ECHO "\ 58689f606849Smrg 5869d5c3dbf1Smrg if test -f \"\$progdir/\$program\"; then" 58709f606849Smrg 5871cdbfa18aSmrg # fixup the dll searchpath if we need to. 5872cdbfa18aSmrg # 5873cdbfa18aSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5874cdbfa18aSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5875cdbfa18aSmrg # libraries must come first. 5876cdbfa18aSmrg if test -n "$dllsearchpath"; then 5877cdbfa18aSmrg $ECHO "\ 5878cdbfa18aSmrg # Add the dll search path components to the executable PATH 5879cdbfa18aSmrg PATH=$dllsearchpath:\$PATH 5880cdbfa18aSmrg" 5881cdbfa18aSmrg fi 5882cdbfa18aSmrg 5883d5c3dbf1Smrg # Export our shlibpath_var if we have one. 5884949d0342Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5885d5c3dbf1Smrg $ECHO "\ 5886d5c3dbf1Smrg # Add our own library path to $shlibpath_var 5887d5c3dbf1Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 58889f606849Smrg 5889d5c3dbf1Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5890d5c3dbf1Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5891d5c3dbf1Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 58929f606849Smrg 5893d5c3dbf1Smrg export $shlibpath_var 5894d5c3dbf1Smrg" 5895d5c3dbf1Smrg fi 58969f606849Smrg 5897d5c3dbf1Smrg $ECHO "\ 5898d5c3dbf1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5899d5c3dbf1Smrg # Run the actual program with our arguments. 5900d5c3dbf1Smrg func_exec_program \${1+\"\$@\"} 5901d5c3dbf1Smrg fi 5902d5c3dbf1Smrg else 5903d5c3dbf1Smrg # The program doesn't exist. 5904949d0342Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5905d5c3dbf1Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5906d5c3dbf1Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5907d5c3dbf1Smrg exit 1 5908d5c3dbf1Smrg fi 5909d5c3dbf1Smrgfi\ 5910d5c3dbf1Smrg" 5911d5c3dbf1Smrg} 59129f606849Smrg 59139f606849Smrg 5914d5c3dbf1Smrg# func_emit_cwrapperexe_src 5915d5c3dbf1Smrg# emit the source code for a wrapper executable on stdout 5916d5c3dbf1Smrg# Must ONLY be called from within func_mode_link because 5917d5c3dbf1Smrg# it depends on a number of variable set therein. 5918d5c3dbf1Smrgfunc_emit_cwrapperexe_src () 5919d5c3dbf1Smrg{ 5920d5c3dbf1Smrg cat <<EOF 59219f606849Smrg 5922d5c3dbf1Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5923949d0342Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 59249f606849Smrg 5925d5c3dbf1Smrg The $output program cannot be directly executed until all the libtool 5926d5c3dbf1Smrg libraries that it depends on are installed. 59279f606849Smrg 5928d5c3dbf1Smrg This wrapper executable should never be moved out of the build directory. 5929d5c3dbf1Smrg If it is, it will not operate correctly. 5930d5c3dbf1Smrg*/ 5931d5c3dbf1SmrgEOF 5932d5c3dbf1Smrg cat <<"EOF" 5933d5c3dbf1Smrg#ifdef _MSC_VER 5934d5c3dbf1Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5935d5c3dbf1Smrg#endif 5936d5c3dbf1Smrg#include <stdio.h> 5937d5c3dbf1Smrg#include <stdlib.h> 5938dc088bc7Smrg#if defined _WIN32 && !defined __GNUC__ 5939d5c3dbf1Smrg# include <direct.h> 5940d5c3dbf1Smrg# include <process.h> 5941d5c3dbf1Smrg# include <io.h> 5942d5c3dbf1Smrg#else 5943d5c3dbf1Smrg# include <unistd.h> 5944d5c3dbf1Smrg# include <stdint.h> 5945d5c3dbf1Smrg# ifdef __CYGWIN__ 5946d5c3dbf1Smrg# include <io.h> 5947d5c3dbf1Smrg# endif 5948d5c3dbf1Smrg#endif 5949d5c3dbf1Smrg#include <malloc.h> 5950d5c3dbf1Smrg#include <stdarg.h> 5951d5c3dbf1Smrg#include <assert.h> 5952d5c3dbf1Smrg#include <string.h> 5953d5c3dbf1Smrg#include <ctype.h> 5954d5c3dbf1Smrg#include <errno.h> 5955d5c3dbf1Smrg#include <fcntl.h> 5956d5c3dbf1Smrg#include <sys/stat.h> 59579f606849Smrg 5958949d0342Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5959949d0342Smrg 5960d5c3dbf1Smrg/* declarations of non-ANSI functions */ 5961949d0342Smrg#if defined __MINGW32__ 5962d5c3dbf1Smrg# ifdef __STRICT_ANSI__ 5963dc088bc7Smrg_CRTIMP int __cdecl _putenv (const char *); 5964d5c3dbf1Smrg# endif 5965949d0342Smrg#elif defined __CYGWIN__ 5966d5c3dbf1Smrg# ifdef __STRICT_ANSI__ 5967d5c3dbf1Smrgchar *realpath (const char *, char *); 5968d5c3dbf1Smrgint putenv (char *); 5969d5c3dbf1Smrgint setenv (const char *, const char *, int); 5970d5c3dbf1Smrg# endif 5971949d0342Smrg/* #elif defined other_platform || defined ... */ 5972d5c3dbf1Smrg#endif 59739f606849Smrg 5974d5c3dbf1Smrg/* portability defines, excluding path handling macros */ 5975949d0342Smrg#if defined _MSC_VER 5976d5c3dbf1Smrg# define setmode _setmode 5977d5c3dbf1Smrg# define stat _stat 5978d5c3dbf1Smrg# define chmod _chmod 5979d5c3dbf1Smrg# define getcwd _getcwd 5980d5c3dbf1Smrg# define putenv _putenv 5981d5c3dbf1Smrg# define S_IXUSR _S_IEXEC 5982949d0342Smrg#elif defined __MINGW32__ 5983d5c3dbf1Smrg# define setmode _setmode 5984d5c3dbf1Smrg# define stat _stat 5985d5c3dbf1Smrg# define chmod _chmod 5986d5c3dbf1Smrg# define getcwd _getcwd 5987d5c3dbf1Smrg# define putenv _putenv 5988949d0342Smrg#elif defined __CYGWIN__ 5989d5c3dbf1Smrg# define HAVE_SETENV 5990d5c3dbf1Smrg# define FOPEN_WB "wb" 5991949d0342Smrg/* #elif defined other platforms ... */ 5992d5c3dbf1Smrg#endif 59939f606849Smrg 5994949d0342Smrg#if defined PATH_MAX 5995d5c3dbf1Smrg# define LT_PATHMAX PATH_MAX 5996949d0342Smrg#elif defined MAXPATHLEN 5997d5c3dbf1Smrg# define LT_PATHMAX MAXPATHLEN 5998d5c3dbf1Smrg#else 5999d5c3dbf1Smrg# define LT_PATHMAX 1024 6000d5c3dbf1Smrg#endif 60019f606849Smrg 6002d5c3dbf1Smrg#ifndef S_IXOTH 6003d5c3dbf1Smrg# define S_IXOTH 0 6004d5c3dbf1Smrg#endif 6005d5c3dbf1Smrg#ifndef S_IXGRP 6006d5c3dbf1Smrg# define S_IXGRP 0 6007d5c3dbf1Smrg#endif 60089f606849Smrg 6009d5c3dbf1Smrg/* path handling portability macros */ 6010d5c3dbf1Smrg#ifndef DIR_SEPARATOR 6011d5c3dbf1Smrg# define DIR_SEPARATOR '/' 6012d5c3dbf1Smrg# define PATH_SEPARATOR ':' 6013d5c3dbf1Smrg#endif 60149f606849Smrg 6015949d0342Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 6016949d0342Smrg defined __OS2__ 6017d5c3dbf1Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 6018d5c3dbf1Smrg# define FOPEN_WB "wb" 6019d5c3dbf1Smrg# ifndef DIR_SEPARATOR_2 6020d5c3dbf1Smrg# define DIR_SEPARATOR_2 '\\' 6021d5c3dbf1Smrg# endif 6022d5c3dbf1Smrg# ifndef PATH_SEPARATOR_2 6023d5c3dbf1Smrg# define PATH_SEPARATOR_2 ';' 6024d5c3dbf1Smrg# endif 6025d5c3dbf1Smrg#endif 60269f606849Smrg 6027d5c3dbf1Smrg#ifndef DIR_SEPARATOR_2 6028d5c3dbf1Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 6029d5c3dbf1Smrg#else /* DIR_SEPARATOR_2 */ 6030d5c3dbf1Smrg# define IS_DIR_SEPARATOR(ch) \ 6031d5c3dbf1Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 6032d5c3dbf1Smrg#endif /* DIR_SEPARATOR_2 */ 60339f606849Smrg 6034d5c3dbf1Smrg#ifndef PATH_SEPARATOR_2 6035d5c3dbf1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 6036d5c3dbf1Smrg#else /* PATH_SEPARATOR_2 */ 6037d5c3dbf1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 6038d5c3dbf1Smrg#endif /* PATH_SEPARATOR_2 */ 6039d5c3dbf1Smrg 6040d5c3dbf1Smrg#ifndef FOPEN_WB 6041d5c3dbf1Smrg# define FOPEN_WB "w" 6042d5c3dbf1Smrg#endif 6043d5c3dbf1Smrg#ifndef _O_BINARY 6044d5c3dbf1Smrg# define _O_BINARY 0 6045d5c3dbf1Smrg#endif 6046d5c3dbf1Smrg 6047d5c3dbf1Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 6048d5c3dbf1Smrg#define XFREE(stale) do { \ 6049949d0342Smrg if (stale) { free (stale); stale = 0; } \ 6050d5c3dbf1Smrg} while (0) 6051d5c3dbf1Smrg 6052949d0342Smrg#if defined LT_DEBUGWRAPPER 6053d5c3dbf1Smrgstatic int lt_debug = 1; 6054d5c3dbf1Smrg#else 6055d5c3dbf1Smrgstatic int lt_debug = 0; 6056d5c3dbf1Smrg#endif 6057d5c3dbf1Smrg 6058d5c3dbf1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 6059d5c3dbf1Smrg 6060d5c3dbf1Smrgvoid *xmalloc (size_t num); 6061d5c3dbf1Smrgchar *xstrdup (const char *string); 6062d5c3dbf1Smrgconst char *base_name (const char *name); 6063d5c3dbf1Smrgchar *find_executable (const char *wrapper); 6064d5c3dbf1Smrgchar *chase_symlinks (const char *pathspec); 6065d5c3dbf1Smrgint make_executable (const char *path); 6066d5c3dbf1Smrgint check_executable (const char *path); 6067d5c3dbf1Smrgchar *strendzap (char *str, const char *pat); 6068d5c3dbf1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 6069d5c3dbf1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 6070d5c3dbf1Smrgstatic const char *nonnull (const char *s); 6071d5c3dbf1Smrgstatic const char *nonempty (const char *s); 6072d5c3dbf1Smrgvoid lt_setenv (const char *name, const char *value); 6073d5c3dbf1Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 6074d5c3dbf1Smrgvoid lt_update_exe_path (const char *name, const char *value); 6075d5c3dbf1Smrgvoid lt_update_lib_path (const char *name, const char *value); 6076d5c3dbf1Smrgchar **prepare_spawn (char **argv); 6077d5c3dbf1Smrgvoid lt_dump_script (FILE *f); 6078d5c3dbf1SmrgEOF 6079d5c3dbf1Smrg 6080d5c3dbf1Smrg cat <<EOF 6081949d0342Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 6082949d0342Smrg# define externally_visible volatile 6083949d0342Smrg#else 6084949d0342Smrg# define externally_visible __attribute__((externally_visible)) volatile 6085949d0342Smrg#endif 6086949d0342Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 6087d5c3dbf1Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 6088d5c3dbf1SmrgEOF 6089d5c3dbf1Smrg 6090949d0342Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 6091cdbfa18aSmrg func_to_host_path "$temp_rpath" 6092d5c3dbf1Smrg cat <<EOF 6093cdbfa18aSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 60949f606849SmrgEOF 60959f606849Smrg else 6096d5c3dbf1Smrg cat <<"EOF" 6097d5c3dbf1Smrgconst char * LIB_PATH_VALUE = ""; 6098d5c3dbf1SmrgEOF 60999f606849Smrg fi 6100d5c3dbf1Smrg 6101d5c3dbf1Smrg if test -n "$dllsearchpath"; then 6102cdbfa18aSmrg func_to_host_path "$dllsearchpath:" 6103d5c3dbf1Smrg cat <<EOF 6104d5c3dbf1Smrgconst char * EXE_PATH_VARNAME = "PATH"; 6105cdbfa18aSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 6106d5c3dbf1SmrgEOF 61079f606849Smrg else 6108d5c3dbf1Smrg cat <<"EOF" 6109d5c3dbf1Smrgconst char * EXE_PATH_VARNAME = ""; 6110d5c3dbf1Smrgconst char * EXE_PATH_VALUE = ""; 6111d5c3dbf1SmrgEOF 61129f606849Smrg fi 6113d5c3dbf1Smrg 6114949d0342Smrg if test yes = "$fast_install"; then 6115d5c3dbf1Smrg cat <<EOF 6116d5c3dbf1Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 6117d5c3dbf1SmrgEOF 61189f606849Smrg else 6119d5c3dbf1Smrg cat <<EOF 6120d5c3dbf1Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 6121d5c3dbf1SmrgEOF 61229f606849Smrg fi 61239f606849Smrg 61249f606849Smrg 6125d5c3dbf1Smrg cat <<"EOF" 61269f606849Smrg 6127d5c3dbf1Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 61289f606849Smrg 6129d5c3dbf1Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 6130d5c3dbf1Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 6131d5c3dbf1Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 61329f606849Smrg 6133d5c3dbf1Smrgint 6134d5c3dbf1Smrgmain (int argc, char *argv[]) 6135d5c3dbf1Smrg{ 6136d5c3dbf1Smrg char **newargz; 6137d5c3dbf1Smrg int newargc; 6138d5c3dbf1Smrg char *tmp_pathspec; 6139d5c3dbf1Smrg char *actual_cwrapper_path; 6140d5c3dbf1Smrg char *actual_cwrapper_name; 6141d5c3dbf1Smrg char *target_name; 6142d5c3dbf1Smrg char *lt_argv_zero; 6143949d0342Smrg int rval = 127; 61449f606849Smrg 6145d5c3dbf1Smrg int i; 61469f606849Smrg 6147d5c3dbf1Smrg program_name = (char *) xstrdup (base_name (argv[0])); 6148949d0342Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 61499f606849Smrg 6150d5c3dbf1Smrg /* very simple arg parsing; don't want to rely on getopt 6151d5c3dbf1Smrg * also, copy all non cwrapper options to newargz, except 6152d5c3dbf1Smrg * argz[0], which is handled differently 6153d5c3dbf1Smrg */ 6154d5c3dbf1Smrg newargc=0; 6155d5c3dbf1Smrg for (i = 1; i < argc; i++) 6156d5c3dbf1Smrg { 6157949d0342Smrg if (STREQ (argv[i], dumpscript_opt)) 6158d5c3dbf1Smrg { 6159d5c3dbf1SmrgEOF 6160949d0342Smrg case $host in 6161dc088bc7Smrg *mingw* | *windows* | *cygwin* ) 6162d5c3dbf1Smrg # make stdout use "unix" line endings 6163d5c3dbf1Smrg echo " setmode(1,_O_BINARY);" 6164d5c3dbf1Smrg ;; 6165fba89afeSmrg esac 61669f606849Smrg 6167d5c3dbf1Smrg cat <<"EOF" 6168d5c3dbf1Smrg lt_dump_script (stdout); 6169d5c3dbf1Smrg return 0; 6170d5c3dbf1Smrg } 6171949d0342Smrg if (STREQ (argv[i], debug_opt)) 6172d5c3dbf1Smrg { 6173d5c3dbf1Smrg lt_debug = 1; 6174d5c3dbf1Smrg continue; 6175d5c3dbf1Smrg } 6176949d0342Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6177d5c3dbf1Smrg { 6178d5c3dbf1Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6179d5c3dbf1Smrg namespace, but it is not one of the ones we know about and 6180dc088bc7Smrg have already dealt with, above (including dump-script), then 6181d5c3dbf1Smrg report an error. Otherwise, targets might begin to believe 6182d5c3dbf1Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6183d5c3dbf1Smrg namespace. The first time any user complains about this, we'll 6184d5c3dbf1Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6185d5c3dbf1Smrg or a configure.ac-settable value. 6186d5c3dbf1Smrg */ 6187d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, 6188d5c3dbf1Smrg "unrecognized %s option: '%s'", 6189d5c3dbf1Smrg ltwrapper_option_prefix, argv[i]); 6190d5c3dbf1Smrg } 6191d5c3dbf1Smrg /* otherwise ... */ 6192d5c3dbf1Smrg newargz[++newargc] = xstrdup (argv[i]); 6193d5c3dbf1Smrg } 6194d5c3dbf1Smrg newargz[++newargc] = NULL; 61959f606849Smrg 6196d5c3dbf1SmrgEOF 6197d5c3dbf1Smrg cat <<EOF 6198d5c3dbf1Smrg /* The GNU banner must be the first non-error debug message */ 6199949d0342Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6200d5c3dbf1SmrgEOF 6201d5c3dbf1Smrg cat <<"EOF" 6202d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6203d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6204d5c3dbf1Smrg 6205d5c3dbf1Smrg tmp_pathspec = find_executable (argv[0]); 6206d5c3dbf1Smrg if (tmp_pathspec == NULL) 6207d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6208d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6209d5c3dbf1Smrg "(main) found exe (before symlink chase) at: %s\n", 6210d5c3dbf1Smrg tmp_pathspec); 6211d5c3dbf1Smrg 6212d5c3dbf1Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6213d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6214d5c3dbf1Smrg "(main) found exe (after symlink chase) at: %s\n", 6215d5c3dbf1Smrg actual_cwrapper_path); 6216d5c3dbf1Smrg XFREE (tmp_pathspec); 6217d5c3dbf1Smrg 6218d5c3dbf1Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6219d5c3dbf1Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6220d5c3dbf1Smrg 6221d5c3dbf1Smrg /* wrapper name transforms */ 6222d5c3dbf1Smrg strendzap (actual_cwrapper_name, ".exe"); 6223d5c3dbf1Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6224d5c3dbf1Smrg XFREE (actual_cwrapper_name); 6225d5c3dbf1Smrg actual_cwrapper_name = tmp_pathspec; 6226d5c3dbf1Smrg tmp_pathspec = 0; 6227d5c3dbf1Smrg 6228d5c3dbf1Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6229d5c3dbf1Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6230d5c3dbf1Smrg strendzap (target_name, ".exe"); 6231d5c3dbf1Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6232d5c3dbf1Smrg XFREE (target_name); 6233d5c3dbf1Smrg target_name = tmp_pathspec; 6234d5c3dbf1Smrg tmp_pathspec = 0; 6235d5c3dbf1Smrg 6236d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6237d5c3dbf1Smrg "(main) libtool target name: %s\n", 6238d5c3dbf1Smrg target_name); 6239d5c3dbf1SmrgEOF 62409f606849Smrg 6241d5c3dbf1Smrg cat <<EOF 6242d5c3dbf1Smrg newargz[0] = 6243d5c3dbf1Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6244d5c3dbf1Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6245d5c3dbf1Smrg strcpy (newargz[0], actual_cwrapper_path); 6246d5c3dbf1Smrg strcat (newargz[0], "$objdir"); 6247d5c3dbf1Smrg strcat (newargz[0], "/"); 6248d5c3dbf1SmrgEOF 62499f606849Smrg 6250d5c3dbf1Smrg cat <<"EOF" 6251d5c3dbf1Smrg /* stop here, and copy so we don't have to do this twice */ 6252d5c3dbf1Smrg tmp_pathspec = xstrdup (newargz[0]); 62539f606849Smrg 6254d5c3dbf1Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6255d5c3dbf1Smrg strcat (newargz[0], actual_cwrapper_name); 62569f606849Smrg 6257d5c3dbf1Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 6258d5c3dbf1Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6259d5c3dbf1Smrg XFREE (tmp_pathspec); 6260d5c3dbf1Smrg tmp_pathspec = NULL; 6261d5c3dbf1SmrgEOF 62629f606849Smrg 6263d5c3dbf1Smrg case $host_os in 6264dc088bc7Smrg mingw* | windows*) 6265d5c3dbf1Smrg cat <<"EOF" 6266d5c3dbf1Smrg { 6267d5c3dbf1Smrg char* p; 6268d5c3dbf1Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 6269d5c3dbf1Smrg { 6270d5c3dbf1Smrg *p = '/'; 6271d5c3dbf1Smrg } 6272d5c3dbf1Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6273d5c3dbf1Smrg { 6274d5c3dbf1Smrg *p = '/'; 6275d5c3dbf1Smrg } 6276d5c3dbf1Smrg } 6277d5c3dbf1SmrgEOF 6278d5c3dbf1Smrg ;; 6279d5c3dbf1Smrg esac 62809f606849Smrg 6281d5c3dbf1Smrg cat <<"EOF" 6282d5c3dbf1Smrg XFREE (target_name); 6283d5c3dbf1Smrg XFREE (actual_cwrapper_path); 6284d5c3dbf1Smrg XFREE (actual_cwrapper_name); 62859f606849Smrg 6286d5c3dbf1Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6287d5c3dbf1Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6288cdbfa18aSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6289cdbfa18aSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6290cdbfa18aSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6291cdbfa18aSmrg libraries must come first. */ 6292d5c3dbf1Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6293cdbfa18aSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 62949f606849Smrg 6295d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6296d5c3dbf1Smrg nonnull (lt_argv_zero)); 6297d5c3dbf1Smrg for (i = 0; i < newargc; i++) 6298d5c3dbf1Smrg { 6299d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6300d5c3dbf1Smrg i, nonnull (newargz[i])); 6301d5c3dbf1Smrg } 63029f606849Smrg 6303d5c3dbf1SmrgEOF 63049f606849Smrg 6305d5c3dbf1Smrg case $host_os in 6306dc088bc7Smrg mingw* | windows*) 6307d5c3dbf1Smrg cat <<"EOF" 6308d5c3dbf1Smrg /* execv doesn't actually work on mingw as expected on unix */ 6309d5c3dbf1Smrg newargz = prepare_spawn (newargz); 6310949d0342Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6311d5c3dbf1Smrg if (rval == -1) 6312d5c3dbf1Smrg { 6313d5c3dbf1Smrg /* failed to start process */ 6314d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6315d5c3dbf1Smrg "(main) failed to launch target \"%s\": %s\n", 6316d5c3dbf1Smrg lt_argv_zero, nonnull (strerror (errno))); 6317d5c3dbf1Smrg return 127; 6318d5c3dbf1Smrg } 6319d5c3dbf1Smrg return rval; 6320d5c3dbf1SmrgEOF 6321d5c3dbf1Smrg ;; 6322d5c3dbf1Smrg *) 6323d5c3dbf1Smrg cat <<"EOF" 6324d5c3dbf1Smrg execv (lt_argv_zero, newargz); 6325d5c3dbf1Smrg return rval; /* =127, but avoids unused variable warning */ 6326d5c3dbf1SmrgEOF 6327d5c3dbf1Smrg ;; 6328d5c3dbf1Smrg esac 63299f606849Smrg 6330d5c3dbf1Smrg cat <<"EOF" 6331d5c3dbf1Smrg} 63329f606849Smrg 6333d5c3dbf1Smrgvoid * 6334d5c3dbf1Smrgxmalloc (size_t num) 6335d5c3dbf1Smrg{ 6336d5c3dbf1Smrg void *p = (void *) malloc (num); 6337d5c3dbf1Smrg if (!p) 6338d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 63399f606849Smrg 6340d5c3dbf1Smrg return p; 6341d5c3dbf1Smrg} 63429f606849Smrg 6343d5c3dbf1Smrgchar * 6344d5c3dbf1Smrgxstrdup (const char *string) 6345d5c3dbf1Smrg{ 6346d5c3dbf1Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6347d5c3dbf1Smrg string) : NULL; 6348d5c3dbf1Smrg} 63499f606849Smrg 6350d5c3dbf1Smrgconst char * 6351d5c3dbf1Smrgbase_name (const char *name) 6352d5c3dbf1Smrg{ 6353d5c3dbf1Smrg const char *base; 63549f606849Smrg 6355949d0342Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6356d5c3dbf1Smrg /* Skip over the disk name in MSDOS pathnames. */ 6357d5c3dbf1Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6358d5c3dbf1Smrg name += 2; 6359d5c3dbf1Smrg#endif 63609f606849Smrg 6361d5c3dbf1Smrg for (base = name; *name; name++) 6362d5c3dbf1Smrg if (IS_DIR_SEPARATOR (*name)) 6363d5c3dbf1Smrg base = name + 1; 6364d5c3dbf1Smrg return base; 6365d5c3dbf1Smrg} 63669f606849Smrg 6367d5c3dbf1Smrgint 6368d5c3dbf1Smrgcheck_executable (const char *path) 6369d5c3dbf1Smrg{ 6370d5c3dbf1Smrg struct stat st; 63719f606849Smrg 6372d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6373d5c3dbf1Smrg nonempty (path)); 6374d5c3dbf1Smrg if ((!path) || (!*path)) 6375d5c3dbf1Smrg return 0; 63769f606849Smrg 6377d5c3dbf1Smrg if ((stat (path, &st) >= 0) 6378d5c3dbf1Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6379d5c3dbf1Smrg return 1; 6380d5c3dbf1Smrg else 6381d5c3dbf1Smrg return 0; 6382d5c3dbf1Smrg} 63839f606849Smrg 6384d5c3dbf1Smrgint 6385d5c3dbf1Smrgmake_executable (const char *path) 6386d5c3dbf1Smrg{ 6387d5c3dbf1Smrg int rval = 0; 6388d5c3dbf1Smrg struct stat st; 63899f606849Smrg 6390d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6391d5c3dbf1Smrg nonempty (path)); 6392d5c3dbf1Smrg if ((!path) || (!*path)) 6393d5c3dbf1Smrg return 0; 63949f606849Smrg 6395d5c3dbf1Smrg if (stat (path, &st) >= 0) 6396d5c3dbf1Smrg { 6397d5c3dbf1Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6398d5c3dbf1Smrg } 6399d5c3dbf1Smrg return rval; 6400d5c3dbf1Smrg} 64019f606849Smrg 6402d5c3dbf1Smrg/* Searches for the full path of the wrapper. Returns 6403d5c3dbf1Smrg newly allocated full path name if found, NULL otherwise 6404d5c3dbf1Smrg Does not chase symlinks, even on platforms that support them. 6405d5c3dbf1Smrg*/ 6406d5c3dbf1Smrgchar * 6407d5c3dbf1Smrgfind_executable (const char *wrapper) 6408d5c3dbf1Smrg{ 6409d5c3dbf1Smrg int has_slash = 0; 6410d5c3dbf1Smrg const char *p; 6411d5c3dbf1Smrg const char *p_next; 6412d5c3dbf1Smrg /* static buffer for getcwd */ 6413d5c3dbf1Smrg char tmp[LT_PATHMAX + 1]; 6414949d0342Smrg size_t tmp_len; 6415d5c3dbf1Smrg char *concat_name; 64169f606849Smrg 6417d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6418d5c3dbf1Smrg nonempty (wrapper)); 64199f606849Smrg 6420d5c3dbf1Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6421d5c3dbf1Smrg return NULL; 64229f606849Smrg 6423d5c3dbf1Smrg /* Absolute path? */ 6424949d0342Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6425d5c3dbf1Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6426d5c3dbf1Smrg { 6427d5c3dbf1Smrg concat_name = xstrdup (wrapper); 6428d5c3dbf1Smrg if (check_executable (concat_name)) 6429d5c3dbf1Smrg return concat_name; 6430d5c3dbf1Smrg XFREE (concat_name); 6431d5c3dbf1Smrg } 6432d5c3dbf1Smrg else 6433d5c3dbf1Smrg { 6434d5c3dbf1Smrg#endif 6435d5c3dbf1Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6436d5c3dbf1Smrg { 6437d5c3dbf1Smrg concat_name = xstrdup (wrapper); 6438d5c3dbf1Smrg if (check_executable (concat_name)) 6439d5c3dbf1Smrg return concat_name; 6440d5c3dbf1Smrg XFREE (concat_name); 6441d5c3dbf1Smrg } 6442949d0342Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6443d5c3dbf1Smrg } 6444d5c3dbf1Smrg#endif 64459f606849Smrg 6446d5c3dbf1Smrg for (p = wrapper; *p; p++) 6447d5c3dbf1Smrg if (*p == '/') 6448d5c3dbf1Smrg { 6449d5c3dbf1Smrg has_slash = 1; 6450d5c3dbf1Smrg break; 6451d5c3dbf1Smrg } 6452d5c3dbf1Smrg if (!has_slash) 6453d5c3dbf1Smrg { 6454d5c3dbf1Smrg /* no slashes; search PATH */ 6455d5c3dbf1Smrg const char *path = getenv ("PATH"); 6456d5c3dbf1Smrg if (path != NULL) 6457d5c3dbf1Smrg { 6458d5c3dbf1Smrg for (p = path; *p; p = p_next) 6459d5c3dbf1Smrg { 6460d5c3dbf1Smrg const char *q; 6461d5c3dbf1Smrg size_t p_len; 6462d5c3dbf1Smrg for (q = p; *q; q++) 6463d5c3dbf1Smrg if (IS_PATH_SEPARATOR (*q)) 6464d5c3dbf1Smrg break; 6465949d0342Smrg p_len = (size_t) (q - p); 6466d5c3dbf1Smrg p_next = (*q == '\0' ? q : q + 1); 6467d5c3dbf1Smrg if (p_len == 0) 6468d5c3dbf1Smrg { 6469d5c3dbf1Smrg /* empty path: current directory */ 6470d5c3dbf1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6471d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6472d5c3dbf1Smrg nonnull (strerror (errno))); 6473d5c3dbf1Smrg tmp_len = strlen (tmp); 6474d5c3dbf1Smrg concat_name = 6475d5c3dbf1Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6476d5c3dbf1Smrg memcpy (concat_name, tmp, tmp_len); 6477d5c3dbf1Smrg concat_name[tmp_len] = '/'; 6478d5c3dbf1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6479d5c3dbf1Smrg } 6480d5c3dbf1Smrg else 6481d5c3dbf1Smrg { 6482d5c3dbf1Smrg concat_name = 6483d5c3dbf1Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6484d5c3dbf1Smrg memcpy (concat_name, p, p_len); 6485d5c3dbf1Smrg concat_name[p_len] = '/'; 6486d5c3dbf1Smrg strcpy (concat_name + p_len + 1, wrapper); 6487d5c3dbf1Smrg } 6488d5c3dbf1Smrg if (check_executable (concat_name)) 6489d5c3dbf1Smrg return concat_name; 6490d5c3dbf1Smrg XFREE (concat_name); 6491d5c3dbf1Smrg } 6492d5c3dbf1Smrg } 6493d5c3dbf1Smrg /* not found in PATH; assume curdir */ 6494d5c3dbf1Smrg } 6495d5c3dbf1Smrg /* Relative path | not found in path: prepend cwd */ 6496d5c3dbf1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6497d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6498d5c3dbf1Smrg nonnull (strerror (errno))); 6499d5c3dbf1Smrg tmp_len = strlen (tmp); 6500d5c3dbf1Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6501d5c3dbf1Smrg memcpy (concat_name, tmp, tmp_len); 6502d5c3dbf1Smrg concat_name[tmp_len] = '/'; 6503d5c3dbf1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 65049f606849Smrg 6505d5c3dbf1Smrg if (check_executable (concat_name)) 6506d5c3dbf1Smrg return concat_name; 6507d5c3dbf1Smrg XFREE (concat_name); 6508d5c3dbf1Smrg return NULL; 6509d5c3dbf1Smrg} 65109f606849Smrg 6511d5c3dbf1Smrgchar * 6512d5c3dbf1Smrgchase_symlinks (const char *pathspec) 6513d5c3dbf1Smrg{ 6514d5c3dbf1Smrg#ifndef S_ISLNK 6515d5c3dbf1Smrg return xstrdup (pathspec); 6516d5c3dbf1Smrg#else 6517d5c3dbf1Smrg char buf[LT_PATHMAX]; 6518d5c3dbf1Smrg struct stat s; 6519d5c3dbf1Smrg char *tmp_pathspec = xstrdup (pathspec); 6520d5c3dbf1Smrg char *p; 6521d5c3dbf1Smrg int has_symlinks = 0; 6522d5c3dbf1Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6523d5c3dbf1Smrg { 6524d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6525d5c3dbf1Smrg "checking path component for symlinks: %s\n", 6526d5c3dbf1Smrg tmp_pathspec); 6527d5c3dbf1Smrg if (lstat (tmp_pathspec, &s) == 0) 6528d5c3dbf1Smrg { 6529d5c3dbf1Smrg if (S_ISLNK (s.st_mode) != 0) 6530d5c3dbf1Smrg { 6531d5c3dbf1Smrg has_symlinks = 1; 6532d5c3dbf1Smrg break; 6533d5c3dbf1Smrg } 65349f606849Smrg 6535d5c3dbf1Smrg /* search backwards for last DIR_SEPARATOR */ 6536d5c3dbf1Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6537d5c3dbf1Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6538d5c3dbf1Smrg p--; 6539d5c3dbf1Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6540d5c3dbf1Smrg { 6541d5c3dbf1Smrg /* no more DIR_SEPARATORS left */ 6542d5c3dbf1Smrg break; 6543d5c3dbf1Smrg } 6544d5c3dbf1Smrg *p = '\0'; 6545d5c3dbf1Smrg } 6546d5c3dbf1Smrg else 6547d5c3dbf1Smrg { 6548d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, 6549d5c3dbf1Smrg "error accessing file \"%s\": %s", 6550d5c3dbf1Smrg tmp_pathspec, nonnull (strerror (errno))); 6551d5c3dbf1Smrg } 6552d5c3dbf1Smrg } 6553d5c3dbf1Smrg XFREE (tmp_pathspec); 65549f606849Smrg 6555d5c3dbf1Smrg if (!has_symlinks) 6556d5c3dbf1Smrg { 6557d5c3dbf1Smrg return xstrdup (pathspec); 6558d5c3dbf1Smrg } 65599f606849Smrg 6560d5c3dbf1Smrg tmp_pathspec = realpath (pathspec, buf); 6561d5c3dbf1Smrg if (tmp_pathspec == 0) 6562d5c3dbf1Smrg { 6563d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, 6564d5c3dbf1Smrg "could not follow symlinks for %s", pathspec); 6565d5c3dbf1Smrg } 6566d5c3dbf1Smrg return xstrdup (tmp_pathspec); 6567d5c3dbf1Smrg#endif 6568d5c3dbf1Smrg} 65699f606849Smrg 6570d5c3dbf1Smrgchar * 6571d5c3dbf1Smrgstrendzap (char *str, const char *pat) 6572d5c3dbf1Smrg{ 6573d5c3dbf1Smrg size_t len, patlen; 65749f606849Smrg 6575d5c3dbf1Smrg assert (str != NULL); 6576d5c3dbf1Smrg assert (pat != NULL); 65779f606849Smrg 6578d5c3dbf1Smrg len = strlen (str); 6579d5c3dbf1Smrg patlen = strlen (pat); 65809f606849Smrg 6581d5c3dbf1Smrg if (patlen <= len) 6582d5c3dbf1Smrg { 6583d5c3dbf1Smrg str += len - patlen; 6584949d0342Smrg if (STREQ (str, pat)) 6585d5c3dbf1Smrg *str = '\0'; 6586d5c3dbf1Smrg } 6587d5c3dbf1Smrg return str; 6588d5c3dbf1Smrg} 65899f606849Smrg 6590d5c3dbf1Smrgvoid 6591d5c3dbf1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6592d5c3dbf1Smrg{ 6593d5c3dbf1Smrg va_list args; 6594d5c3dbf1Smrg if (lt_debug) 6595d5c3dbf1Smrg { 6596d5c3dbf1Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6597d5c3dbf1Smrg va_start (args, fmt); 6598d5c3dbf1Smrg (void) vfprintf (stderr, fmt, args); 6599d5c3dbf1Smrg va_end (args); 6600d5c3dbf1Smrg } 6601d5c3dbf1Smrg} 66029f606849Smrg 6603d5c3dbf1Smrgstatic void 6604d5c3dbf1Smrglt_error_core (int exit_status, const char *file, 6605d5c3dbf1Smrg int line, const char *mode, 6606d5c3dbf1Smrg const char *message, va_list ap) 6607d5c3dbf1Smrg{ 6608d5c3dbf1Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6609d5c3dbf1Smrg vfprintf (stderr, message, ap); 6610d5c3dbf1Smrg fprintf (stderr, ".\n"); 66119f606849Smrg 6612d5c3dbf1Smrg if (exit_status >= 0) 6613d5c3dbf1Smrg exit (exit_status); 6614d5c3dbf1Smrg} 66159f606849Smrg 6616d5c3dbf1Smrgvoid 6617d5c3dbf1Smrglt_fatal (const char *file, int line, const char *message, ...) 6618d5c3dbf1Smrg{ 6619d5c3dbf1Smrg va_list ap; 6620d5c3dbf1Smrg va_start (ap, message); 6621d5c3dbf1Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6622d5c3dbf1Smrg va_end (ap); 6623d5c3dbf1Smrg} 66249f606849Smrg 6625d5c3dbf1Smrgstatic const char * 6626d5c3dbf1Smrgnonnull (const char *s) 6627d5c3dbf1Smrg{ 6628d5c3dbf1Smrg return s ? s : "(null)"; 6629d5c3dbf1Smrg} 66309f606849Smrg 6631d5c3dbf1Smrgstatic const char * 6632d5c3dbf1Smrgnonempty (const char *s) 6633d5c3dbf1Smrg{ 6634d5c3dbf1Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6635d5c3dbf1Smrg} 66369f606849Smrg 6637d5c3dbf1Smrgvoid 6638d5c3dbf1Smrglt_setenv (const char *name, const char *value) 6639d5c3dbf1Smrg{ 6640d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6641d5c3dbf1Smrg "(lt_setenv) setting '%s' to '%s'\n", 6642d5c3dbf1Smrg nonnull (name), nonnull (value)); 6643d5c3dbf1Smrg { 6644d5c3dbf1Smrg#ifdef HAVE_SETENV 6645d5c3dbf1Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6646d5c3dbf1Smrg char *str = xstrdup (value); 6647d5c3dbf1Smrg setenv (name, str, 1); 6648d5c3dbf1Smrg#else 6649949d0342Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6650d5c3dbf1Smrg char *str = XMALLOC (char, len); 6651d5c3dbf1Smrg sprintf (str, "%s=%s", name, value); 6652d5c3dbf1Smrg if (putenv (str) != EXIT_SUCCESS) 6653d5c3dbf1Smrg { 6654d5c3dbf1Smrg XFREE (str); 6655d5c3dbf1Smrg } 6656d5c3dbf1Smrg#endif 6657d5c3dbf1Smrg } 6658d5c3dbf1Smrg} 66599f606849Smrg 6660d5c3dbf1Smrgchar * 6661d5c3dbf1Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6662d5c3dbf1Smrg{ 6663d5c3dbf1Smrg char *new_value; 6664d5c3dbf1Smrg if (orig_value && *orig_value) 6665d5c3dbf1Smrg { 6666949d0342Smrg size_t orig_value_len = strlen (orig_value); 6667949d0342Smrg size_t add_len = strlen (add); 6668d5c3dbf1Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6669d5c3dbf1Smrg if (to_end) 6670d5c3dbf1Smrg { 6671d5c3dbf1Smrg strcpy (new_value, orig_value); 6672d5c3dbf1Smrg strcpy (new_value + orig_value_len, add); 6673d5c3dbf1Smrg } 6674d5c3dbf1Smrg else 6675d5c3dbf1Smrg { 6676d5c3dbf1Smrg strcpy (new_value, add); 6677d5c3dbf1Smrg strcpy (new_value + add_len, orig_value); 6678d5c3dbf1Smrg } 6679d5c3dbf1Smrg } 6680d5c3dbf1Smrg else 6681d5c3dbf1Smrg { 6682d5c3dbf1Smrg new_value = xstrdup (add); 6683d5c3dbf1Smrg } 6684d5c3dbf1Smrg return new_value; 6685d5c3dbf1Smrg} 66869f606849Smrg 6687d5c3dbf1Smrgvoid 6688d5c3dbf1Smrglt_update_exe_path (const char *name, const char *value) 6689d5c3dbf1Smrg{ 6690d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6691d5c3dbf1Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6692d5c3dbf1Smrg nonnull (name), nonnull (value)); 66939f606849Smrg 6694d5c3dbf1Smrg if (name && *name && value && *value) 6695d5c3dbf1Smrg { 6696d5c3dbf1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6697d5c3dbf1Smrg /* some systems can't cope with a ':'-terminated path #' */ 6698949d0342Smrg size_t len = strlen (new_value); 6699949d0342Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6700d5c3dbf1Smrg { 6701949d0342Smrg new_value[--len] = '\0'; 6702d5c3dbf1Smrg } 6703d5c3dbf1Smrg lt_setenv (name, new_value); 6704d5c3dbf1Smrg XFREE (new_value); 6705d5c3dbf1Smrg } 6706d5c3dbf1Smrg} 67079f606849Smrg 6708d5c3dbf1Smrgvoid 6709d5c3dbf1Smrglt_update_lib_path (const char *name, const char *value) 6710d5c3dbf1Smrg{ 6711d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6712d5c3dbf1Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6713d5c3dbf1Smrg nonnull (name), nonnull (value)); 67149f606849Smrg 6715d5c3dbf1Smrg if (name && *name && value && *value) 6716d5c3dbf1Smrg { 6717d5c3dbf1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6718d5c3dbf1Smrg lt_setenv (name, new_value); 6719d5c3dbf1Smrg XFREE (new_value); 6720d5c3dbf1Smrg } 6721d5c3dbf1Smrg} 67229f606849Smrg 6723d5c3dbf1SmrgEOF 6724d5c3dbf1Smrg case $host_os in 6725dc088bc7Smrg mingw* | windows*) 6726d5c3dbf1Smrg cat <<"EOF" 6727d5c3dbf1Smrg 6728d5c3dbf1Smrg/* Prepares an argument vector before calling spawn(). 6729d5c3dbf1Smrg Note that spawn() does not by itself call the command interpreter 6730d5c3dbf1Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6731d5c3dbf1Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6732d5c3dbf1Smrg GetVersionEx(&v); 6733d5c3dbf1Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6734d5c3dbf1Smrg }) ? "cmd.exe" : "command.com"). 6735d5c3dbf1Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6736d5c3dbf1Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6737d5c3dbf1Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6738d5c3dbf1Smrg special way: 6739d5c3dbf1Smrg - Space and tab are interpreted as delimiters. They are not treated as 6740d5c3dbf1Smrg delimiters if they are surrounded by double quotes: "...". 6741d5c3dbf1Smrg - Unescaped double quotes are removed from the input. Their only effect is 6742d5c3dbf1Smrg that within double quotes, space and tab are treated like normal 6743d5c3dbf1Smrg characters. 6744d5c3dbf1Smrg - Backslashes not followed by double quotes are not special. 6745d5c3dbf1Smrg - But 2*n+1 backslashes followed by a double quote become 6746d5c3dbf1Smrg n backslashes followed by a double quote (n >= 0): 6747d5c3dbf1Smrg \" -> " 6748d5c3dbf1Smrg \\\" -> \" 6749d5c3dbf1Smrg \\\\\" -> \\" 6750d5c3dbf1Smrg */ 6751d5c3dbf1Smrg#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" 6752d5c3dbf1Smrg#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" 6753d5c3dbf1Smrgchar ** 6754d5c3dbf1Smrgprepare_spawn (char **argv) 6755d5c3dbf1Smrg{ 6756d5c3dbf1Smrg size_t argc; 6757d5c3dbf1Smrg char **new_argv; 6758d5c3dbf1Smrg size_t i; 67599f606849Smrg 6760d5c3dbf1Smrg /* Count number of arguments. */ 6761d5c3dbf1Smrg for (argc = 0; argv[argc] != NULL; argc++) 6762d5c3dbf1Smrg ; 67639f606849Smrg 6764d5c3dbf1Smrg /* Allocate new argument vector. */ 6765d5c3dbf1Smrg new_argv = XMALLOC (char *, argc + 1); 67669f606849Smrg 6767d5c3dbf1Smrg /* Put quoted arguments into the new argument vector. */ 6768d5c3dbf1Smrg for (i = 0; i < argc; i++) 6769d5c3dbf1Smrg { 6770d5c3dbf1Smrg const char *string = argv[i]; 6771d5c3dbf1Smrg 6772d5c3dbf1Smrg if (string[0] == '\0') 6773d5c3dbf1Smrg new_argv[i] = xstrdup ("\"\""); 6774d5c3dbf1Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6775d5c3dbf1Smrg { 6776d5c3dbf1Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6777d5c3dbf1Smrg size_t length; 6778d5c3dbf1Smrg unsigned int backslashes; 6779d5c3dbf1Smrg const char *s; 6780d5c3dbf1Smrg char *quoted_string; 6781d5c3dbf1Smrg char *p; 6782d5c3dbf1Smrg 6783d5c3dbf1Smrg length = 0; 6784d5c3dbf1Smrg backslashes = 0; 6785d5c3dbf1Smrg if (quote_around) 6786d5c3dbf1Smrg length++; 6787d5c3dbf1Smrg for (s = string; *s != '\0'; s++) 6788d5c3dbf1Smrg { 6789d5c3dbf1Smrg char c = *s; 6790d5c3dbf1Smrg if (c == '"') 6791d5c3dbf1Smrg length += backslashes + 1; 6792d5c3dbf1Smrg length++; 6793d5c3dbf1Smrg if (c == '\\') 6794d5c3dbf1Smrg backslashes++; 6795d5c3dbf1Smrg else 6796d5c3dbf1Smrg backslashes = 0; 6797d5c3dbf1Smrg } 6798d5c3dbf1Smrg if (quote_around) 6799d5c3dbf1Smrg length += backslashes + 1; 6800d5c3dbf1Smrg 6801d5c3dbf1Smrg quoted_string = XMALLOC (char, length + 1); 6802d5c3dbf1Smrg 6803d5c3dbf1Smrg p = quoted_string; 6804d5c3dbf1Smrg backslashes = 0; 6805d5c3dbf1Smrg if (quote_around) 6806d5c3dbf1Smrg *p++ = '"'; 6807d5c3dbf1Smrg for (s = string; *s != '\0'; s++) 6808d5c3dbf1Smrg { 6809d5c3dbf1Smrg char c = *s; 6810d5c3dbf1Smrg if (c == '"') 6811d5c3dbf1Smrg { 6812d5c3dbf1Smrg unsigned int j; 6813d5c3dbf1Smrg for (j = backslashes + 1; j > 0; j--) 6814d5c3dbf1Smrg *p++ = '\\'; 6815d5c3dbf1Smrg } 6816d5c3dbf1Smrg *p++ = c; 6817d5c3dbf1Smrg if (c == '\\') 6818d5c3dbf1Smrg backslashes++; 6819d5c3dbf1Smrg else 6820d5c3dbf1Smrg backslashes = 0; 6821d5c3dbf1Smrg } 6822d5c3dbf1Smrg if (quote_around) 6823d5c3dbf1Smrg { 6824d5c3dbf1Smrg unsigned int j; 6825d5c3dbf1Smrg for (j = backslashes; j > 0; j--) 6826d5c3dbf1Smrg *p++ = '\\'; 6827d5c3dbf1Smrg *p++ = '"'; 6828d5c3dbf1Smrg } 6829d5c3dbf1Smrg *p = '\0'; 68309f606849Smrg 6831d5c3dbf1Smrg new_argv[i] = quoted_string; 6832d5c3dbf1Smrg } 6833d5c3dbf1Smrg else 6834d5c3dbf1Smrg new_argv[i] = (char *) string; 6835d5c3dbf1Smrg } 6836d5c3dbf1Smrg new_argv[argc] = NULL; 68379f606849Smrg 6838d5c3dbf1Smrg return new_argv; 6839d5c3dbf1Smrg} 6840d5c3dbf1SmrgEOF 68419f606849Smrg ;; 6842d5c3dbf1Smrg esac 68439f606849Smrg 6844d5c3dbf1Smrg cat <<"EOF" 6845d5c3dbf1Smrgvoid lt_dump_script (FILE* f) 6846d5c3dbf1Smrg{ 6847d5c3dbf1SmrgEOF 6848d5c3dbf1Smrg func_emit_wrapper yes | 6849cdbfa18aSmrg $SED -n -e ' 6850cdbfa18aSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6851cdbfa18aSmrg\2/ 6852cdbfa18aSmrgh 6853cdbfa18aSmrgs/\([\\"]\)/\\\1/g 6854cdbfa18aSmrgs/$/\\n/ 6855cdbfa18aSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6856cdbfa18aSmrgg 6857cdbfa18aSmrgD' 6858d5c3dbf1Smrg cat <<"EOF" 6859d5c3dbf1Smrg} 6860d5c3dbf1SmrgEOF 6861d5c3dbf1Smrg} 6862d5c3dbf1Smrg# end: func_emit_cwrapperexe_src 68639f606849Smrg 6864d5c3dbf1Smrg# func_win32_import_lib_p ARG 6865d5c3dbf1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6866d5c3dbf1Smrgfunc_win32_import_lib_p () 6867d5c3dbf1Smrg{ 6868949d0342Smrg $debug_cmd 6869949d0342Smrg 6870d5c3dbf1Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6871d5c3dbf1Smrg *import*) : ;; 6872d5c3dbf1Smrg *) false ;; 6873d5c3dbf1Smrg esac 6874d5c3dbf1Smrg} 68759f606849Smrg 6876949d0342Smrg# func_suncc_cstd_abi 6877949d0342Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6878949d0342Smrg# Several compiler flags select an ABI that is incompatible with the 6879949d0342Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6880949d0342Smrgfunc_suncc_cstd_abi () 6881949d0342Smrg{ 6882949d0342Smrg $debug_cmd 6883949d0342Smrg 6884949d0342Smrg case " $compile_command " in 6885949d0342Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6886949d0342Smrg suncc_use_cstd_abi=no 6887949d0342Smrg ;; 6888949d0342Smrg *) 6889949d0342Smrg suncc_use_cstd_abi=yes 6890949d0342Smrg ;; 6891949d0342Smrg esac 6892949d0342Smrg} 6893949d0342Smrg 6894d5c3dbf1Smrg# func_mode_link arg... 6895d5c3dbf1Smrgfunc_mode_link () 6896d5c3dbf1Smrg{ 6897949d0342Smrg $debug_cmd 6898949d0342Smrg 6899d5c3dbf1Smrg case $host in 6900dc088bc7Smrg *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) 6901d5c3dbf1Smrg # It is impossible to link a dll without this setting, and 6902d5c3dbf1Smrg # we shouldn't force the makefile maintainer to figure out 6903949d0342Smrg # what system we are compiling for in order to pass an extra 6904d5c3dbf1Smrg # flag for every libtool invocation. 6905d5c3dbf1Smrg # allow_undefined=no 69069f606849Smrg 6907d5c3dbf1Smrg # FIXME: Unfortunately, there are problems with the above when trying 6908949d0342Smrg # to make a dll that has undefined symbols, in which case not 6909d5c3dbf1Smrg # even a static library is built. For now, we need to specify 6910d5c3dbf1Smrg # -no-undefined on the libtool link line when we can be certain 6911d5c3dbf1Smrg # that all symbols are satisfied, otherwise we get a static library. 6912d5c3dbf1Smrg allow_undefined=yes 6913d5c3dbf1Smrg ;; 6914d5c3dbf1Smrg *) 6915d5c3dbf1Smrg allow_undefined=yes 6916d5c3dbf1Smrg ;; 6917d5c3dbf1Smrg esac 6918d5c3dbf1Smrg libtool_args=$nonopt 6919d5c3dbf1Smrg base_compile="$nonopt $@" 6920d5c3dbf1Smrg compile_command=$nonopt 6921d5c3dbf1Smrg finalize_command=$nonopt 69229f606849Smrg 6923d5c3dbf1Smrg compile_rpath= 6924dc088bc7Smrg compile_rpath_tail= 6925d5c3dbf1Smrg finalize_rpath= 6926d5c3dbf1Smrg compile_shlibpath= 6927d5c3dbf1Smrg finalize_shlibpath= 6928d5c3dbf1Smrg convenience= 6929d5c3dbf1Smrg old_convenience= 6930d5c3dbf1Smrg deplibs= 6931d5c3dbf1Smrg old_deplibs= 6932d5c3dbf1Smrg compiler_flags= 6933d5c3dbf1Smrg linker_flags= 6934d5c3dbf1Smrg dllsearchpath= 6935d5c3dbf1Smrg lib_search_path=`pwd` 6936d5c3dbf1Smrg inst_prefix_dir= 6937d5c3dbf1Smrg new_inherited_linker_flags= 69389f606849Smrg 6939d5c3dbf1Smrg avoid_version=no 6940d5c3dbf1Smrg bindir= 6941d5c3dbf1Smrg dlfiles= 6942d5c3dbf1Smrg dlprefiles= 6943d5c3dbf1Smrg dlself=no 6944d5c3dbf1Smrg export_dynamic=no 6945d5c3dbf1Smrg export_symbols= 6946d5c3dbf1Smrg export_symbols_regex= 6947d5c3dbf1Smrg generated= 6948d5c3dbf1Smrg libobjs= 6949d5c3dbf1Smrg ltlibs= 6950d5c3dbf1Smrg module=no 6951d5c3dbf1Smrg no_install=no 6952d5c3dbf1Smrg objs= 6953949d0342Smrg os2dllname= 6954d5c3dbf1Smrg non_pic_objects= 6955d5c3dbf1Smrg precious_files_regex= 6956d5c3dbf1Smrg prefer_static_libs=no 6957949d0342Smrg preload=false 6958d5c3dbf1Smrg prev= 6959d5c3dbf1Smrg prevarg= 6960d5c3dbf1Smrg release= 6961d5c3dbf1Smrg rpath= 6962d5c3dbf1Smrg xrpath= 6963d5c3dbf1Smrg perm_rpath= 6964d5c3dbf1Smrg temp_rpath= 6965dc088bc7Smrg temp_rpath_tail= 6966d5c3dbf1Smrg thread_safe=no 6967d5c3dbf1Smrg vinfo= 6968d5c3dbf1Smrg vinfo_number=no 6969d5c3dbf1Smrg weak_libs= 6970dc088bc7Smrg rpath_arg= 6971949d0342Smrg single_module=$wl-single_module 6972d5c3dbf1Smrg func_infer_tag $base_compile 69739f606849Smrg 6974d5c3dbf1Smrg # We need to know -static, to get the right output filenames. 6975d5c3dbf1Smrg for arg 6976d5c3dbf1Smrg do 6977d5c3dbf1Smrg case $arg in 6978d5c3dbf1Smrg -shared) 6979949d0342Smrg test yes != "$build_libtool_libs" \ 6980949d0342Smrg && func_fatal_configuration "cannot build a shared library" 6981d5c3dbf1Smrg build_old_libs=no 6982d5c3dbf1Smrg break 6983d5c3dbf1Smrg ;; 6984d5c3dbf1Smrg -all-static | -static | -static-libtool-libs) 6985d5c3dbf1Smrg case $arg in 6986d5c3dbf1Smrg -all-static) 6987949d0342Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6988d5c3dbf1Smrg func_warning "complete static linking is impossible in this configuration" 6989d5c3dbf1Smrg fi 6990d5c3dbf1Smrg if test -n "$link_static_flag"; then 6991d5c3dbf1Smrg dlopen_self=$dlopen_self_static 6992d5c3dbf1Smrg fi 6993d5c3dbf1Smrg prefer_static_libs=yes 6994d5c3dbf1Smrg ;; 6995d5c3dbf1Smrg -static) 6996d5c3dbf1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6997d5c3dbf1Smrg dlopen_self=$dlopen_self_static 6998d5c3dbf1Smrg fi 6999d5c3dbf1Smrg prefer_static_libs=built 7000d5c3dbf1Smrg ;; 7001d5c3dbf1Smrg -static-libtool-libs) 7002d5c3dbf1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 7003d5c3dbf1Smrg dlopen_self=$dlopen_self_static 7004d5c3dbf1Smrg fi 7005d5c3dbf1Smrg prefer_static_libs=yes 7006d5c3dbf1Smrg ;; 7007d5c3dbf1Smrg esac 7008d5c3dbf1Smrg build_libtool_libs=no 7009d5c3dbf1Smrg build_old_libs=yes 7010d5c3dbf1Smrg break 7011d5c3dbf1Smrg ;; 7012d5c3dbf1Smrg esac 7013d5c3dbf1Smrg done 70149f606849Smrg 7015d5c3dbf1Smrg # See if our shared archives depend on static archives. 7016d5c3dbf1Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 70179f606849Smrg 7018d5c3dbf1Smrg # Go through the arguments, transforming them on the way. 7019d5c3dbf1Smrg while test "$#" -gt 0; do 7020949d0342Smrg arg=$1 7021d5c3dbf1Smrg shift 7022949d0342Smrg func_quote_arg pretty,unquoted "$arg" 7023949d0342Smrg qarg=$func_quote_arg_unquoted_result 7024949d0342Smrg func_append libtool_args " $func_quote_arg_result" 70259f606849Smrg 7026d5c3dbf1Smrg # If the previous option needs an argument, assign it. 7027d5c3dbf1Smrg if test -n "$prev"; then 7028d5c3dbf1Smrg case $prev in 7029d5c3dbf1Smrg output) 7030d5c3dbf1Smrg func_append compile_command " @OUTPUT@" 7031d5c3dbf1Smrg func_append finalize_command " @OUTPUT@" 7032d5c3dbf1Smrg ;; 7033d5c3dbf1Smrg esac 70349f606849Smrg 7035d5c3dbf1Smrg case $prev in 7036d5c3dbf1Smrg bindir) 7037949d0342Smrg bindir=$arg 7038d5c3dbf1Smrg prev= 7039d5c3dbf1Smrg continue 7040d5c3dbf1Smrg ;; 7041d5c3dbf1Smrg dlfiles|dlprefiles) 7042949d0342Smrg $preload || { 7043d5c3dbf1Smrg # Add the symbol object into the linking commands. 7044d5c3dbf1Smrg func_append compile_command " @SYMFILE@" 7045d5c3dbf1Smrg func_append finalize_command " @SYMFILE@" 7046949d0342Smrg preload=: 7047949d0342Smrg } 7048d5c3dbf1Smrg case $arg in 7049d5c3dbf1Smrg *.la | *.lo) ;; # We handle these cases below. 7050d5c3dbf1Smrg force) 7051949d0342Smrg if test no = "$dlself"; then 7052d5c3dbf1Smrg dlself=needless 7053d5c3dbf1Smrg export_dynamic=yes 70549f606849Smrg fi 7055d5c3dbf1Smrg prev= 7056d5c3dbf1Smrg continue 7057d5c3dbf1Smrg ;; 7058d5c3dbf1Smrg self) 7059949d0342Smrg if test dlprefiles = "$prev"; then 7060d5c3dbf1Smrg dlself=yes 7061949d0342Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 7062d5c3dbf1Smrg dlself=yes 70639f606849Smrg else 7064d5c3dbf1Smrg dlself=needless 7065d5c3dbf1Smrg export_dynamic=yes 70669f606849Smrg fi 7067d5c3dbf1Smrg prev= 7068d5c3dbf1Smrg continue 7069d5c3dbf1Smrg ;; 7070d5c3dbf1Smrg *) 7071949d0342Smrg if test dlfiles = "$prev"; then 7072cdbfa18aSmrg func_append dlfiles " $arg" 70739f606849Smrg else 7074cdbfa18aSmrg func_append dlprefiles " $arg" 70759f606849Smrg fi 7076d5c3dbf1Smrg prev= 7077d5c3dbf1Smrg continue 7078d5c3dbf1Smrg ;; 7079d5c3dbf1Smrg esac 7080d5c3dbf1Smrg ;; 7081d5c3dbf1Smrg expsyms) 7082949d0342Smrg export_symbols=$arg 7083d5c3dbf1Smrg test -f "$arg" \ 7084949d0342Smrg || func_fatal_error "symbol file '$arg' does not exist" 7085d5c3dbf1Smrg prev= 7086d5c3dbf1Smrg continue 7087d5c3dbf1Smrg ;; 7088d5c3dbf1Smrg expsyms_regex) 7089949d0342Smrg export_symbols_regex=$arg 7090d5c3dbf1Smrg prev= 7091d5c3dbf1Smrg continue 7092d5c3dbf1Smrg ;; 7093d5c3dbf1Smrg framework) 70949f606849Smrg case $host in 7095d5c3dbf1Smrg *-*-darwin*) 7096d5c3dbf1Smrg case "$deplibs " in 7097d5c3dbf1Smrg *" $qarg.ltframework "*) ;; 7098cdbfa18aSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 7099d5c3dbf1Smrg ;; 7100d5c3dbf1Smrg esac 7101d5c3dbf1Smrg ;; 71029f606849Smrg esac 7103d5c3dbf1Smrg prev= 7104d5c3dbf1Smrg continue 71059f606849Smrg ;; 7106d5c3dbf1Smrg inst_prefix) 7107949d0342Smrg inst_prefix_dir=$arg 7108949d0342Smrg prev= 7109949d0342Smrg continue 7110949d0342Smrg ;; 7111949d0342Smrg mllvm) 7112949d0342Smrg # Clang does not use LLVM to link, so we can simply discard any 7113949d0342Smrg # '-mllvm $arg' options when doing the link step. 7114d5c3dbf1Smrg prev= 7115d5c3dbf1Smrg continue 71169f606849Smrg ;; 7117d5c3dbf1Smrg objectlist) 7118d5c3dbf1Smrg if test -f "$arg"; then 7119d5c3dbf1Smrg save_arg=$arg 7120d5c3dbf1Smrg moreargs= 7121d5c3dbf1Smrg for fil in `cat "$save_arg"` 7122d5c3dbf1Smrg do 7123cdbfa18aSmrg# func_append moreargs " $fil" 7124d5c3dbf1Smrg arg=$fil 7125d5c3dbf1Smrg # A libtool-controlled object. 71269f606849Smrg 7127d5c3dbf1Smrg # Check to see that this really is a libtool object. 7128d5c3dbf1Smrg if func_lalib_unsafe_p "$arg"; then 7129d5c3dbf1Smrg pic_object= 7130d5c3dbf1Smrg non_pic_object= 71319f606849Smrg 7132d5c3dbf1Smrg # Read the .lo file 7133d5c3dbf1Smrg func_source "$arg" 71349f606849Smrg 7135d5c3dbf1Smrg if test -z "$pic_object" || 7136d5c3dbf1Smrg test -z "$non_pic_object" || 7137949d0342Smrg test none = "$pic_object" && 7138949d0342Smrg test none = "$non_pic_object"; then 7139949d0342Smrg func_fatal_error "cannot find name of object for '$arg'" 7140d5c3dbf1Smrg fi 71419f606849Smrg 7142d5c3dbf1Smrg # Extract subdirectory from the argument. 7143d5c3dbf1Smrg func_dirname "$arg" "/" "" 7144949d0342Smrg xdir=$func_dirname_result 71459f606849Smrg 7146949d0342Smrg if test none != "$pic_object"; then 7147d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 7148949d0342Smrg pic_object=$xdir$pic_object 71499f606849Smrg 7150949d0342Smrg if test dlfiles = "$prev"; then 7151949d0342Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7152cdbfa18aSmrg func_append dlfiles " $pic_object" 7153d5c3dbf1Smrg prev= 7154d5c3dbf1Smrg continue 7155d5c3dbf1Smrg else 7156d5c3dbf1Smrg # If libtool objects are unsupported, then we need to preload. 7157d5c3dbf1Smrg prev=dlprefiles 7158d5c3dbf1Smrg fi 7159d5c3dbf1Smrg fi 71609f606849Smrg 7161d5c3dbf1Smrg # CHECK ME: I think I busted this. -Ossama 7162949d0342Smrg if test dlprefiles = "$prev"; then 7163d5c3dbf1Smrg # Preload the old-style object. 7164cdbfa18aSmrg func_append dlprefiles " $pic_object" 7165d5c3dbf1Smrg prev= 7166d5c3dbf1Smrg fi 71679f606849Smrg 7168d5c3dbf1Smrg # A PIC object. 7169d5c3dbf1Smrg func_append libobjs " $pic_object" 7170949d0342Smrg arg=$pic_object 7171d5c3dbf1Smrg fi 71729f606849Smrg 7173d5c3dbf1Smrg # Non-PIC object. 7174949d0342Smrg if test none != "$non_pic_object"; then 7175d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 7176949d0342Smrg non_pic_object=$xdir$non_pic_object 71779f606849Smrg 7178d5c3dbf1Smrg # A standard non-PIC object 7179d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7180949d0342Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7181949d0342Smrg arg=$non_pic_object 7182d5c3dbf1Smrg fi 7183d5c3dbf1Smrg else 7184d5c3dbf1Smrg # If the PIC object exists, use it instead. 7185d5c3dbf1Smrg # $xdir was prepended to $pic_object above. 7186949d0342Smrg non_pic_object=$pic_object 7187d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7188d5c3dbf1Smrg fi 7189d5c3dbf1Smrg else 7190d5c3dbf1Smrg # Only an error if not doing a dry-run. 7191d5c3dbf1Smrg if $opt_dry_run; then 7192d5c3dbf1Smrg # Extract subdirectory from the argument. 7193d5c3dbf1Smrg func_dirname "$arg" "/" "" 7194949d0342Smrg xdir=$func_dirname_result 7195d5c3dbf1Smrg 7196d5c3dbf1Smrg func_lo2o "$arg" 7197d5c3dbf1Smrg pic_object=$xdir$objdir/$func_lo2o_result 7198d5c3dbf1Smrg non_pic_object=$xdir$func_lo2o_result 7199d5c3dbf1Smrg func_append libobjs " $pic_object" 7200d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7201d5c3dbf1Smrg else 7202949d0342Smrg func_fatal_error "'$arg' is not a valid libtool object" 7203d5c3dbf1Smrg fi 7204d5c3dbf1Smrg fi 7205d5c3dbf1Smrg done 72069f606849Smrg else 7207949d0342Smrg func_fatal_error "link input file '$arg' does not exist" 72089f606849Smrg fi 7209d5c3dbf1Smrg arg=$save_arg 7210d5c3dbf1Smrg prev= 7211d5c3dbf1Smrg continue 7212d5c3dbf1Smrg ;; 7213949d0342Smrg os2dllname) 7214949d0342Smrg os2dllname=$arg 7215949d0342Smrg prev= 7216949d0342Smrg continue 7217949d0342Smrg ;; 7218d5c3dbf1Smrg precious_regex) 7219949d0342Smrg precious_files_regex=$arg 7220d5c3dbf1Smrg prev= 7221d5c3dbf1Smrg continue 7222d5c3dbf1Smrg ;; 7223d5c3dbf1Smrg release) 7224949d0342Smrg release=-$arg 7225d5c3dbf1Smrg prev= 7226d5c3dbf1Smrg continue 7227d5c3dbf1Smrg ;; 7228d5c3dbf1Smrg rpath | xrpath) 7229d5c3dbf1Smrg # We need an absolute path. 7230d5c3dbf1Smrg case $arg in 7231d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7232d5c3dbf1Smrg *) 7233dc088bc7Smrg func_fatal_error "argument to -rpath is not absolute: $arg" 7234d5c3dbf1Smrg ;; 7235d5c3dbf1Smrg esac 7236949d0342Smrg if test rpath = "$prev"; then 7237d5c3dbf1Smrg case "$rpath " in 7238d5c3dbf1Smrg *" $arg "*) ;; 7239cdbfa18aSmrg *) func_append rpath " $arg" ;; 7240d5c3dbf1Smrg esac 72419f606849Smrg else 7242d5c3dbf1Smrg case "$xrpath " in 7243d5c3dbf1Smrg *" $arg "*) ;; 7244cdbfa18aSmrg *) func_append xrpath " $arg" ;; 7245d5c3dbf1Smrg esac 72469f606849Smrg fi 7247d5c3dbf1Smrg prev= 7248d5c3dbf1Smrg continue 7249d5c3dbf1Smrg ;; 7250d5c3dbf1Smrg shrext) 7251949d0342Smrg shrext_cmds=$arg 7252d5c3dbf1Smrg prev= 7253d5c3dbf1Smrg continue 7254d5c3dbf1Smrg ;; 7255d5c3dbf1Smrg weak) 7256cdbfa18aSmrg func_append weak_libs " $arg" 7257d5c3dbf1Smrg prev= 7258d5c3dbf1Smrg continue 7259d5c3dbf1Smrg ;; 7260949d0342Smrg xassembler) 7261949d0342Smrg func_append compiler_flags " -Xassembler $qarg" 7262949d0342Smrg prev= 7263949d0342Smrg func_append compile_command " -Xassembler $qarg" 7264949d0342Smrg func_append finalize_command " -Xassembler $qarg" 7265949d0342Smrg continue 7266949d0342Smrg ;; 7267d5c3dbf1Smrg xcclinker) 7268cdbfa18aSmrg func_append linker_flags " $qarg" 7269cdbfa18aSmrg func_append compiler_flags " $qarg" 7270d5c3dbf1Smrg prev= 7271d5c3dbf1Smrg func_append compile_command " $qarg" 7272d5c3dbf1Smrg func_append finalize_command " $qarg" 7273d5c3dbf1Smrg continue 7274d5c3dbf1Smrg ;; 7275d5c3dbf1Smrg xcompiler) 7276cdbfa18aSmrg func_append compiler_flags " $qarg" 7277d5c3dbf1Smrg prev= 7278d5c3dbf1Smrg func_append compile_command " $qarg" 7279d5c3dbf1Smrg func_append finalize_command " $qarg" 7280d5c3dbf1Smrg continue 7281d5c3dbf1Smrg ;; 7282d5c3dbf1Smrg xlinker) 7283cdbfa18aSmrg func_append linker_flags " $qarg" 7284cdbfa18aSmrg func_append compiler_flags " $wl$qarg" 7285d5c3dbf1Smrg prev= 7286d5c3dbf1Smrg func_append compile_command " $wl$qarg" 7287d5c3dbf1Smrg func_append finalize_command " $wl$qarg" 7288d5c3dbf1Smrg continue 7289d5c3dbf1Smrg ;; 7290d5c3dbf1Smrg *) 7291d5c3dbf1Smrg eval "$prev=\"\$arg\"" 7292d5c3dbf1Smrg prev= 7293d5c3dbf1Smrg continue 7294d5c3dbf1Smrg ;; 72959f606849Smrg esac 7296d5c3dbf1Smrg fi # test -n "$prev" 72979f606849Smrg 7298949d0342Smrg prevarg=$arg 72999f606849Smrg 7300d5c3dbf1Smrg case $arg in 7301d5c3dbf1Smrg -all-static) 7302d5c3dbf1Smrg if test -n "$link_static_flag"; then 7303d5c3dbf1Smrg # See comment for -static flag below, for more details. 7304d5c3dbf1Smrg func_append compile_command " $link_static_flag" 7305d5c3dbf1Smrg func_append finalize_command " $link_static_flag" 7306d5c3dbf1Smrg fi 7307d5c3dbf1Smrg continue 7308d5c3dbf1Smrg ;; 73099f606849Smrg 7310d5c3dbf1Smrg -allow-undefined) 7311d5c3dbf1Smrg # FIXME: remove this flag sometime in the future. 7312949d0342Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7313d5c3dbf1Smrg ;; 73149f606849Smrg 7315d5c3dbf1Smrg -avoid-version) 7316d5c3dbf1Smrg avoid_version=yes 7317d5c3dbf1Smrg continue 7318d5c3dbf1Smrg ;; 73199f606849Smrg 7320d5c3dbf1Smrg -bindir) 7321d5c3dbf1Smrg prev=bindir 7322d5c3dbf1Smrg continue 7323d5c3dbf1Smrg ;; 73249f606849Smrg 7325d5c3dbf1Smrg -dlopen) 7326d5c3dbf1Smrg prev=dlfiles 7327d5c3dbf1Smrg continue 7328d5c3dbf1Smrg ;; 73299f606849Smrg 7330d5c3dbf1Smrg -dlpreopen) 7331d5c3dbf1Smrg prev=dlprefiles 7332d5c3dbf1Smrg continue 7333d5c3dbf1Smrg ;; 73349f606849Smrg 7335d5c3dbf1Smrg -export-dynamic) 7336d5c3dbf1Smrg export_dynamic=yes 7337d5c3dbf1Smrg continue 7338d5c3dbf1Smrg ;; 73399f606849Smrg 7340d5c3dbf1Smrg -export-symbols | -export-symbols-regex) 7341d5c3dbf1Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7342d5c3dbf1Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7343d5c3dbf1Smrg fi 7344949d0342Smrg if test X-export-symbols = "X$arg"; then 7345d5c3dbf1Smrg prev=expsyms 7346d5c3dbf1Smrg else 7347d5c3dbf1Smrg prev=expsyms_regex 7348d5c3dbf1Smrg fi 7349d5c3dbf1Smrg continue 7350d5c3dbf1Smrg ;; 73519f606849Smrg 7352d5c3dbf1Smrg -framework) 7353d5c3dbf1Smrg prev=framework 7354d5c3dbf1Smrg continue 7355d5c3dbf1Smrg ;; 73569f606849Smrg 7357d5c3dbf1Smrg -inst-prefix-dir) 7358d5c3dbf1Smrg prev=inst_prefix 7359d5c3dbf1Smrg continue 7360d5c3dbf1Smrg ;; 73619f606849Smrg 7362d5c3dbf1Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7363d5c3dbf1Smrg # so, if we see these flags be careful not to treat them like -L 7364d5c3dbf1Smrg -L[A-Z][A-Z]*:*) 7365d5c3dbf1Smrg case $with_gcc/$host in 7366d5c3dbf1Smrg no/*-*-irix* | /*-*-irix*) 7367d5c3dbf1Smrg func_append compile_command " $arg" 7368d5c3dbf1Smrg func_append finalize_command " $arg" 7369d5c3dbf1Smrg ;; 7370d5c3dbf1Smrg esac 7371d5c3dbf1Smrg continue 7372d5c3dbf1Smrg ;; 73739f606849Smrg 7374d5c3dbf1Smrg -L*) 7375cdbfa18aSmrg func_stripname "-L" '' "$arg" 7376cdbfa18aSmrg if test -z "$func_stripname_result"; then 7377d5c3dbf1Smrg if test "$#" -gt 0; then 7378949d0342Smrg func_fatal_error "require no space between '-L' and '$1'" 7379d5c3dbf1Smrg else 7380949d0342Smrg func_fatal_error "need path for '-L' option" 7381d5c3dbf1Smrg fi 7382d5c3dbf1Smrg fi 7383cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 7384cdbfa18aSmrg dir=$func_resolve_sysroot_result 7385d5c3dbf1Smrg # We need an absolute path. 7386d5c3dbf1Smrg case $dir in 7387d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7388d5c3dbf1Smrg *) 7389d5c3dbf1Smrg absdir=`cd "$dir" && pwd` 7390d5c3dbf1Smrg test -z "$absdir" && \ 7391949d0342Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7392949d0342Smrg dir=$absdir 7393d5c3dbf1Smrg ;; 7394d5c3dbf1Smrg esac 7395d5c3dbf1Smrg case "$deplibs " in 7396cdbfa18aSmrg *" -L$dir "* | *" $arg "*) 7397cdbfa18aSmrg # Will only happen for absolute or sysroot arguments 7398cdbfa18aSmrg ;; 7399d5c3dbf1Smrg *) 7400cdbfa18aSmrg # Preserve sysroot, but never include relative directories 7401cdbfa18aSmrg case $dir in 7402cdbfa18aSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7403cdbfa18aSmrg *) func_append deplibs " -L$dir" ;; 7404cdbfa18aSmrg esac 7405cdbfa18aSmrg func_append lib_search_path " $dir" 7406d5c3dbf1Smrg ;; 7407d5c3dbf1Smrg esac 7408d5c3dbf1Smrg case $host in 7409dc088bc7Smrg *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) 7410d5c3dbf1Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7411d5c3dbf1Smrg case :$dllsearchpath: in 7412d5c3dbf1Smrg *":$dir:"*) ;; 7413d5c3dbf1Smrg ::) dllsearchpath=$dir;; 7414cdbfa18aSmrg *) func_append dllsearchpath ":$dir";; 7415d5c3dbf1Smrg esac 7416d5c3dbf1Smrg case :$dllsearchpath: in 7417d5c3dbf1Smrg *":$testbindir:"*) ;; 7418d5c3dbf1Smrg ::) dllsearchpath=$testbindir;; 7419cdbfa18aSmrg *) func_append dllsearchpath ":$testbindir";; 7420d5c3dbf1Smrg esac 7421d5c3dbf1Smrg ;; 7422d5c3dbf1Smrg esac 7423d5c3dbf1Smrg continue 7424d5c3dbf1Smrg ;; 74259f606849Smrg 7426d5c3dbf1Smrg -l*) 7427949d0342Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7428d5c3dbf1Smrg case $host in 7429dc088bc7Smrg *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7430d5c3dbf1Smrg # These systems don't actually have a C or math library (as such) 7431d5c3dbf1Smrg continue 7432d5c3dbf1Smrg ;; 7433d5c3dbf1Smrg *-*-os2*) 7434d5c3dbf1Smrg # These systems don't actually have a C library (as such) 7435949d0342Smrg test X-lc = "X$arg" && continue 7436d5c3dbf1Smrg ;; 7437dc088bc7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 7438d5c3dbf1Smrg # Do not include libc due to us having libc/libc_r. 7439949d0342Smrg test X-lc = "X$arg" && continue 7440d5c3dbf1Smrg ;; 7441d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7442d5c3dbf1Smrg # Rhapsody C and math libraries are in the System framework 7443cdbfa18aSmrg func_append deplibs " System.ltframework" 7444d5c3dbf1Smrg continue 7445d5c3dbf1Smrg ;; 7446d5c3dbf1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7447d5c3dbf1Smrg # Causes problems with __ctype 7448949d0342Smrg test X-lc = "X$arg" && continue 7449d5c3dbf1Smrg ;; 7450d5c3dbf1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7451d5c3dbf1Smrg # Compiler inserts libc in the correct place for threads to work 7452949d0342Smrg test X-lc = "X$arg" && continue 7453d5c3dbf1Smrg ;; 7454d5c3dbf1Smrg esac 7455949d0342Smrg elif test X-lc_r = "X$arg"; then 7456d5c3dbf1Smrg case $host in 7457dc088bc7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 7458d5c3dbf1Smrg # Do not include libc_r directly, use -pthread flag. 7459d5c3dbf1Smrg continue 7460d5c3dbf1Smrg ;; 7461d5c3dbf1Smrg esac 7462d5c3dbf1Smrg fi 7463cdbfa18aSmrg func_append deplibs " $arg" 7464d5c3dbf1Smrg continue 7465d5c3dbf1Smrg ;; 74669f606849Smrg 7467949d0342Smrg -mllvm) 7468949d0342Smrg prev=mllvm 7469949d0342Smrg continue 7470949d0342Smrg ;; 7471949d0342Smrg 7472d5c3dbf1Smrg -module) 7473d5c3dbf1Smrg module=yes 7474d5c3dbf1Smrg continue 7475d5c3dbf1Smrg ;; 74769f606849Smrg 7477d5c3dbf1Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7478d5c3dbf1Smrg # classes, name mangling, and exception handling. 7479d5c3dbf1Smrg # Darwin uses the -arch flag to determine output architecture. 7480dc088bc7Smrg # -q <option> for IBM XL C/C++ compiler. 7481dc088bc7Smrg -model|-arch|-isysroot|--sysroot|-q) 7482cdbfa18aSmrg func_append compiler_flags " $arg" 7483d5c3dbf1Smrg func_append compile_command " $arg" 7484d5c3dbf1Smrg func_append finalize_command " $arg" 7485d5c3dbf1Smrg prev=xcompiler 7486d5c3dbf1Smrg continue 7487d5c3dbf1Smrg ;; 7488949d0342Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7489949d0342Smrg -pthread) 7490949d0342Smrg case $host in 7491949d0342Smrg *solaris2*) ;; 7492949d0342Smrg *) 7493949d0342Smrg case "$new_inherited_linker_flags " in 7494949d0342Smrg *" $arg "*) ;; 7495949d0342Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7496949d0342Smrg esac 7497949d0342Smrg ;; 7498949d0342Smrg esac 7499949d0342Smrg continue 7500949d0342Smrg ;; 7501949d0342Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7502dc088bc7Smrg |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7503cdbfa18aSmrg func_append compiler_flags " $arg" 7504d5c3dbf1Smrg func_append compile_command " $arg" 7505d5c3dbf1Smrg func_append finalize_command " $arg" 7506d5c3dbf1Smrg case "$new_inherited_linker_flags " in 7507d5c3dbf1Smrg *" $arg "*) ;; 7508cdbfa18aSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7509d5c3dbf1Smrg esac 7510d5c3dbf1Smrg continue 7511d5c3dbf1Smrg ;; 75129f606849Smrg 7513d5c3dbf1Smrg -multi_module) 7514949d0342Smrg single_module=$wl-multi_module 7515d5c3dbf1Smrg continue 7516d5c3dbf1Smrg ;; 75179f606849Smrg 7518d5c3dbf1Smrg -no-fast-install) 7519d5c3dbf1Smrg fast_install=no 7520d5c3dbf1Smrg continue 7521d5c3dbf1Smrg ;; 75229f606849Smrg 7523d5c3dbf1Smrg -no-install) 7524d5c3dbf1Smrg case $host in 7525dc088bc7Smrg *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7526d5c3dbf1Smrg # The PATH hackery in wrapper scripts is required on Windows 7527d5c3dbf1Smrg # and Darwin in order for the loader to find any dlls it needs. 7528949d0342Smrg func_warning "'-no-install' is ignored for $host" 7529949d0342Smrg func_warning "assuming '-no-fast-install' instead" 7530d5c3dbf1Smrg fast_install=no 7531d5c3dbf1Smrg ;; 7532d5c3dbf1Smrg *) no_install=yes ;; 7533d5c3dbf1Smrg esac 7534d5c3dbf1Smrg continue 7535d5c3dbf1Smrg ;; 75369f606849Smrg 7537d5c3dbf1Smrg -no-undefined) 7538d5c3dbf1Smrg allow_undefined=no 7539d5c3dbf1Smrg continue 7540d5c3dbf1Smrg ;; 75419f606849Smrg 7542d5c3dbf1Smrg -objectlist) 7543d5c3dbf1Smrg prev=objectlist 7544d5c3dbf1Smrg continue 7545d5c3dbf1Smrg ;; 75469f606849Smrg 7547949d0342Smrg -os2dllname) 7548949d0342Smrg prev=os2dllname 7549949d0342Smrg continue 7550949d0342Smrg ;; 7551949d0342Smrg 7552d5c3dbf1Smrg -o) prev=output ;; 75539f606849Smrg 7554d5c3dbf1Smrg -precious-files-regex) 7555d5c3dbf1Smrg prev=precious_regex 7556d5c3dbf1Smrg continue 7557d5c3dbf1Smrg ;; 75589f606849Smrg 7559d5c3dbf1Smrg -release) 7560d5c3dbf1Smrg prev=release 7561d5c3dbf1Smrg continue 7562d5c3dbf1Smrg ;; 75639f606849Smrg 7564d5c3dbf1Smrg -rpath) 7565d5c3dbf1Smrg prev=rpath 7566d5c3dbf1Smrg continue 7567d5c3dbf1Smrg ;; 75689f606849Smrg 7569d5c3dbf1Smrg -R) 7570d5c3dbf1Smrg prev=xrpath 7571d5c3dbf1Smrg continue 7572d5c3dbf1Smrg ;; 75739f606849Smrg 7574d5c3dbf1Smrg -R*) 7575d5c3dbf1Smrg func_stripname '-R' '' "$arg" 7576d5c3dbf1Smrg dir=$func_stripname_result 7577d5c3dbf1Smrg # We need an absolute path. 7578d5c3dbf1Smrg case $dir in 7579d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7580cdbfa18aSmrg =*) 7581cdbfa18aSmrg func_stripname '=' '' "$dir" 7582cdbfa18aSmrg dir=$lt_sysroot$func_stripname_result 7583cdbfa18aSmrg ;; 7584d5c3dbf1Smrg *) 7585dc088bc7Smrg func_fatal_error "argument ($arg) to '-R' is not an absolute path: $dir" 7586d5c3dbf1Smrg ;; 7587d5c3dbf1Smrg esac 7588d5c3dbf1Smrg case "$xrpath " in 7589d5c3dbf1Smrg *" $dir "*) ;; 7590cdbfa18aSmrg *) func_append xrpath " $dir" ;; 7591d5c3dbf1Smrg esac 7592d5c3dbf1Smrg continue 7593d5c3dbf1Smrg ;; 75949f606849Smrg 7595d5c3dbf1Smrg -shared) 7596d5c3dbf1Smrg # The effects of -shared are defined in a previous loop. 7597d5c3dbf1Smrg continue 7598d5c3dbf1Smrg ;; 75999f606849Smrg 7600d5c3dbf1Smrg -shrext) 7601d5c3dbf1Smrg prev=shrext 7602d5c3dbf1Smrg continue 7603d5c3dbf1Smrg ;; 76049f606849Smrg 7605d5c3dbf1Smrg -static | -static-libtool-libs) 7606d5c3dbf1Smrg # The effects of -static are defined in a previous loop. 7607d5c3dbf1Smrg # We used to do the same as -all-static on platforms that 7608d5c3dbf1Smrg # didn't have a PIC flag, but the assumption that the effects 7609d5c3dbf1Smrg # would be equivalent was wrong. It would break on at least 7610d5c3dbf1Smrg # Digital Unix and AIX. 7611d5c3dbf1Smrg continue 7612d5c3dbf1Smrg ;; 76139f606849Smrg 7614d5c3dbf1Smrg -thread-safe) 7615d5c3dbf1Smrg thread_safe=yes 7616d5c3dbf1Smrg continue 7617d5c3dbf1Smrg ;; 76189f606849Smrg 7619d5c3dbf1Smrg -version-info) 7620d5c3dbf1Smrg prev=vinfo 7621d5c3dbf1Smrg continue 7622d5c3dbf1Smrg ;; 76239f606849Smrg 7624d5c3dbf1Smrg -version-number) 7625d5c3dbf1Smrg prev=vinfo 7626d5c3dbf1Smrg vinfo_number=yes 7627d5c3dbf1Smrg continue 7628d5c3dbf1Smrg ;; 76299f606849Smrg 7630d5c3dbf1Smrg -weak) 7631d5c3dbf1Smrg prev=weak 7632d5c3dbf1Smrg continue 7633d5c3dbf1Smrg ;; 76349f606849Smrg 7635d5c3dbf1Smrg -Wc,*) 7636d5c3dbf1Smrg func_stripname '-Wc,' '' "$arg" 7637d5c3dbf1Smrg args=$func_stripname_result 7638d5c3dbf1Smrg arg= 7639949d0342Smrg save_ifs=$IFS; IFS=, 7640d5c3dbf1Smrg for flag in $args; do 7641949d0342Smrg IFS=$save_ifs 7642949d0342Smrg func_quote_arg pretty "$flag" 7643949d0342Smrg func_append arg " $func_quote_arg_result" 7644949d0342Smrg func_append compiler_flags " $func_quote_arg_result" 7645d5c3dbf1Smrg done 7646949d0342Smrg IFS=$save_ifs 7647d5c3dbf1Smrg func_stripname ' ' '' "$arg" 7648d5c3dbf1Smrg arg=$func_stripname_result 7649d5c3dbf1Smrg ;; 76509f606849Smrg 7651d5c3dbf1Smrg -Wl,*) 7652d5c3dbf1Smrg func_stripname '-Wl,' '' "$arg" 7653d5c3dbf1Smrg args=$func_stripname_result 7654d5c3dbf1Smrg arg= 7655949d0342Smrg save_ifs=$IFS; IFS=, 7656d5c3dbf1Smrg for flag in $args; do 7657949d0342Smrg IFS=$save_ifs 7658949d0342Smrg func_quote_arg pretty "$flag" 7659949d0342Smrg func_append arg " $wl$func_quote_arg_result" 7660949d0342Smrg func_append compiler_flags " $wl$func_quote_arg_result" 7661949d0342Smrg func_append linker_flags " $func_quote_arg_result" 7662d5c3dbf1Smrg done 7663949d0342Smrg IFS=$save_ifs 7664d5c3dbf1Smrg func_stripname ' ' '' "$arg" 7665d5c3dbf1Smrg arg=$func_stripname_result 7666d5c3dbf1Smrg ;; 76679f606849Smrg 7668949d0342Smrg -Xassembler) 7669949d0342Smrg prev=xassembler 7670949d0342Smrg continue 7671949d0342Smrg ;; 7672949d0342Smrg 7673d5c3dbf1Smrg -Xcompiler) 7674d5c3dbf1Smrg prev=xcompiler 7675d5c3dbf1Smrg continue 7676d5c3dbf1Smrg ;; 76779f606849Smrg 7678d5c3dbf1Smrg -Xlinker) 7679d5c3dbf1Smrg prev=xlinker 7680d5c3dbf1Smrg continue 7681d5c3dbf1Smrg ;; 76829f606849Smrg 7683d5c3dbf1Smrg -XCClinker) 7684d5c3dbf1Smrg prev=xcclinker 7685d5c3dbf1Smrg continue 7686d5c3dbf1Smrg ;; 76879f606849Smrg 7688d5c3dbf1Smrg # -msg_* for osf cc 7689d5c3dbf1Smrg -msg_*) 7690949d0342Smrg func_quote_arg pretty "$arg" 7691949d0342Smrg arg=$func_quote_arg_result 7692d5c3dbf1Smrg ;; 76939f606849Smrg 7694d5c3dbf1Smrg # Flags to be passed through unchanged, with rationale: 7695d5c3dbf1Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7696d5c3dbf1Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7697d5c3dbf1Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7698d5c3dbf1Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7699d5c3dbf1Smrg # -q* compiler args for the IBM compiler 7700d5c3dbf1Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7701d5c3dbf1Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7702d5c3dbf1Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7703949d0342Smrg # -fstack-protector* stack protector flags for GCC 7704d5c3dbf1Smrg # @file GCC response files 7705d5c3dbf1Smrg # -tp=* Portland pgcc target processor selection 7706cdbfa18aSmrg # --sysroot=* for sysroot support 7707949d0342Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7708949d0342Smrg # -specs=* GCC specs files 7709949d0342Smrg # -stdlib=* select c++ std lib with clang 7710dc088bc7Smrg # -fdiagnostics-color* simply affects output 7711dc088bc7Smrg # -frecord-gcc-switches used to verify flags were respected 7712949d0342Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7713dc088bc7Smrg # -fno-sanitize* Clang/GCC memory and address sanitizer 7714dc088bc7Smrg # -shared-libsan Link with shared sanitizer runtimes (Clang) 7715dc088bc7Smrg # -static-libsan Link with static sanitizer runtimes (Clang) 7716dc088bc7Smrg # -no-canonical-prefixes Do not expand any symbolic links 7717949d0342Smrg # -fuse-ld=* Linker select flags for GCC 7718dc088bc7Smrg # -static-* direct GCC to link specific libraries statically 7719dc088bc7Smrg # -fcilkplus Cilk Plus language extension features for C/C++ 7720dc088bc7Smrg # -rtlib=* select c runtime lib with clang 7721dc088bc7Smrg # --unwindlib=* select unwinder library with clang 7722dc088bc7Smrg # -f{file|debug|macro|profile}-prefix-map=* needed for lto linking 7723949d0342Smrg # -Wa,* Pass flags directly to the assembler 7724dc088bc7Smrg # -Werror, -Werror=* Report (specified) warnings as errors 7725d5c3dbf1Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7726cdbfa18aSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7727dc088bc7Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-no-canonical-prefixes| \ 7728dc088bc7Smrg -stdlib=*|-rtlib=*|--unwindlib=*| \ 7729dc088bc7Smrg -specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \ 7730dc088bc7Smrg -ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \ 7731dc088bc7Smrg -fdiagnostics-color*|-frecord-gcc-switches| \ 7732dc088bc7Smrg -fuse-ld=*|-static-*|-fcilkplus|-Wa,*|-Werror|-Werror=*) 7733949d0342Smrg func_quote_arg pretty "$arg" 7734949d0342Smrg arg=$func_quote_arg_result 7735d5c3dbf1Smrg func_append compile_command " $arg" 7736d5c3dbf1Smrg func_append finalize_command " $arg" 7737cdbfa18aSmrg func_append compiler_flags " $arg" 7738d5c3dbf1Smrg continue 7739d5c3dbf1Smrg ;; 77409f606849Smrg 7741949d0342Smrg -Z*) 7742949d0342Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7743949d0342Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7744949d0342Smrg compiler_flags="$compiler_flags $arg" 7745949d0342Smrg func_append compile_command " $arg" 7746949d0342Smrg func_append finalize_command " $arg" 7747949d0342Smrg case $arg in 7748949d0342Smrg -Zlinker | -Zstack) 7749949d0342Smrg prev=xcompiler 7750949d0342Smrg ;; 7751949d0342Smrg esac 7752949d0342Smrg continue 7753949d0342Smrg else 7754949d0342Smrg # Otherwise treat like 'Some other compiler flag' below 7755949d0342Smrg func_quote_arg pretty "$arg" 7756949d0342Smrg arg=$func_quote_arg_result 7757949d0342Smrg fi 7758949d0342Smrg ;; 7759949d0342Smrg 7760d5c3dbf1Smrg # Some other compiler flag. 7761d5c3dbf1Smrg -* | +*) 7762949d0342Smrg func_quote_arg pretty "$arg" 7763949d0342Smrg arg=$func_quote_arg_result 7764d5c3dbf1Smrg ;; 77659f606849Smrg 7766d5c3dbf1Smrg *.$objext) 7767d5c3dbf1Smrg # A standard object. 7768cdbfa18aSmrg func_append objs " $arg" 7769d5c3dbf1Smrg ;; 77709f606849Smrg 7771d5c3dbf1Smrg *.lo) 7772d5c3dbf1Smrg # A libtool-controlled object. 77739f606849Smrg 7774d5c3dbf1Smrg # Check to see that this really is a libtool object. 7775d5c3dbf1Smrg if func_lalib_unsafe_p "$arg"; then 7776d5c3dbf1Smrg pic_object= 7777d5c3dbf1Smrg non_pic_object= 77789f606849Smrg 7779d5c3dbf1Smrg # Read the .lo file 7780d5c3dbf1Smrg func_source "$arg" 77819f606849Smrg 7782d5c3dbf1Smrg if test -z "$pic_object" || 7783d5c3dbf1Smrg test -z "$non_pic_object" || 7784949d0342Smrg test none = "$pic_object" && 7785949d0342Smrg test none = "$non_pic_object"; then 7786949d0342Smrg func_fatal_error "cannot find name of object for '$arg'" 7787d5c3dbf1Smrg fi 7788fba89afeSmrg 7789d5c3dbf1Smrg # Extract subdirectory from the argument. 7790d5c3dbf1Smrg func_dirname "$arg" "/" "" 7791949d0342Smrg xdir=$func_dirname_result 77929f606849Smrg 7793949d0342Smrg test none = "$pic_object" || { 7794d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 7795949d0342Smrg pic_object=$xdir$pic_object 77969f606849Smrg 7797949d0342Smrg if test dlfiles = "$prev"; then 7798949d0342Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7799cdbfa18aSmrg func_append dlfiles " $pic_object" 7800d5c3dbf1Smrg prev= 7801d5c3dbf1Smrg continue 7802d5c3dbf1Smrg else 7803d5c3dbf1Smrg # If libtool objects are unsupported, then we need to preload. 7804d5c3dbf1Smrg prev=dlprefiles 7805d5c3dbf1Smrg fi 7806d5c3dbf1Smrg fi 7807d5c3dbf1Smrg 7808d5c3dbf1Smrg # CHECK ME: I think I busted this. -Ossama 7809949d0342Smrg if test dlprefiles = "$prev"; then 7810d5c3dbf1Smrg # Preload the old-style object. 7811cdbfa18aSmrg func_append dlprefiles " $pic_object" 7812d5c3dbf1Smrg prev= 7813d5c3dbf1Smrg fi 7814d5c3dbf1Smrg 7815d5c3dbf1Smrg # A PIC object. 7816d5c3dbf1Smrg func_append libobjs " $pic_object" 7817949d0342Smrg arg=$pic_object 7818949d0342Smrg } 7819d5c3dbf1Smrg 7820d5c3dbf1Smrg # Non-PIC object. 7821949d0342Smrg if test none != "$non_pic_object"; then 7822d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 7823949d0342Smrg non_pic_object=$xdir$non_pic_object 7824d5c3dbf1Smrg 7825d5c3dbf1Smrg # A standard non-PIC object 7826d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7827949d0342Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7828949d0342Smrg arg=$non_pic_object 7829d5c3dbf1Smrg fi 7830d5c3dbf1Smrg else 7831d5c3dbf1Smrg # If the PIC object exists, use it instead. 7832d5c3dbf1Smrg # $xdir was prepended to $pic_object above. 7833949d0342Smrg non_pic_object=$pic_object 7834d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7835d5c3dbf1Smrg fi 7836d5c3dbf1Smrg else 7837d5c3dbf1Smrg # Only an error if not doing a dry-run. 7838d5c3dbf1Smrg if $opt_dry_run; then 7839d5c3dbf1Smrg # Extract subdirectory from the argument. 7840d5c3dbf1Smrg func_dirname "$arg" "/" "" 7841949d0342Smrg xdir=$func_dirname_result 7842d5c3dbf1Smrg 7843d5c3dbf1Smrg func_lo2o "$arg" 7844d5c3dbf1Smrg pic_object=$xdir$objdir/$func_lo2o_result 7845d5c3dbf1Smrg non_pic_object=$xdir$func_lo2o_result 7846d5c3dbf1Smrg func_append libobjs " $pic_object" 7847d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7848d5c3dbf1Smrg else 7849949d0342Smrg func_fatal_error "'$arg' is not a valid libtool object" 7850d5c3dbf1Smrg fi 7851d5c3dbf1Smrg fi 7852d5c3dbf1Smrg ;; 7853d5c3dbf1Smrg 7854d5c3dbf1Smrg *.$libext) 7855d5c3dbf1Smrg # An archive. 7856cdbfa18aSmrg func_append deplibs " $arg" 7857cdbfa18aSmrg func_append old_deplibs " $arg" 7858d5c3dbf1Smrg continue 7859d5c3dbf1Smrg ;; 7860d5c3dbf1Smrg 7861d5c3dbf1Smrg *.la) 7862d5c3dbf1Smrg # A libtool-controlled library. 7863d5c3dbf1Smrg 7864cdbfa18aSmrg func_resolve_sysroot "$arg" 7865949d0342Smrg if test dlfiles = "$prev"; then 7866d5c3dbf1Smrg # This library was specified with -dlopen. 7867cdbfa18aSmrg func_append dlfiles " $func_resolve_sysroot_result" 7868d5c3dbf1Smrg prev= 7869949d0342Smrg elif test dlprefiles = "$prev"; then 7870d5c3dbf1Smrg # The library was specified with -dlpreopen. 7871cdbfa18aSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7872d5c3dbf1Smrg prev= 7873d5c3dbf1Smrg else 7874cdbfa18aSmrg func_append deplibs " $func_resolve_sysroot_result" 7875d5c3dbf1Smrg fi 7876d5c3dbf1Smrg continue 7877d5c3dbf1Smrg ;; 7878d5c3dbf1Smrg 7879d5c3dbf1Smrg # Some other compiler argument. 7880d5c3dbf1Smrg *) 7881d5c3dbf1Smrg # Unknown arguments in both finalize_command and compile_command need 7882d5c3dbf1Smrg # to be aesthetically quoted because they are evaled later. 7883949d0342Smrg func_quote_arg pretty "$arg" 7884949d0342Smrg arg=$func_quote_arg_result 7885d5c3dbf1Smrg ;; 7886d5c3dbf1Smrg esac # arg 7887d5c3dbf1Smrg 7888d5c3dbf1Smrg # Now actually substitute the argument into the commands. 7889d5c3dbf1Smrg if test -n "$arg"; then 7890dc088bc7Smrg if test -n "$rpath_arg"; then 7891dc088bc7Smrg func_append finalize_rpath " ${arg##*,}" 7892dc088bc7Smrg unset rpath_arg 7893dc088bc7Smrg else 7894dc088bc7Smrg case $arg in 7895dc088bc7Smrg -Wl,-rpath,*) 7896dc088bc7Smrg func_append finalize_rpath " ${arg##*,}";; 7897dc088bc7Smrg -Wl,-rpath) 7898dc088bc7Smrg rpath_arg=1;; 7899dc088bc7Smrg *) 7900dc088bc7Smrg func_append compile_command " $arg" 7901dc088bc7Smrg func_append finalize_command " $arg" 7902dc088bc7Smrg esac 7903dc088bc7Smrg fi 7904d5c3dbf1Smrg fi 7905d5c3dbf1Smrg done # argument parsing loop 7906d5c3dbf1Smrg 7907d5c3dbf1Smrg test -n "$prev" && \ 7908949d0342Smrg func_fatal_help "the '$prevarg' option requires an argument" 7909d5c3dbf1Smrg 7910949d0342Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7911d5c3dbf1Smrg eval arg=\"$export_dynamic_flag_spec\" 7912d5c3dbf1Smrg func_append compile_command " $arg" 7913d5c3dbf1Smrg func_append finalize_command " $arg" 7914d5c3dbf1Smrg fi 7915d5c3dbf1Smrg 7916d5c3dbf1Smrg oldlibs= 7917d5c3dbf1Smrg # calculate the name of the file, without its directory 7918d5c3dbf1Smrg func_basename "$output" 7919949d0342Smrg outputname=$func_basename_result 7920949d0342Smrg libobjs_save=$libobjs 7921d5c3dbf1Smrg 7922d5c3dbf1Smrg if test -n "$shlibpath_var"; then 7923d5c3dbf1Smrg # get the directories listed in $shlibpath_var 7924949d0342Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 79259f606849Smrg else 7926d5c3dbf1Smrg shlib_search_path= 79279f606849Smrg fi 7928d5c3dbf1Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7929d5c3dbf1Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 79309f606849Smrg 7931949d0342Smrg # Definition is injected by LT_CONFIG during libtool generation. 7932949d0342Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7933949d0342Smrg 7934d5c3dbf1Smrg func_dirname "$output" "/" "" 7935949d0342Smrg output_objdir=$func_dirname_result$objdir 7936cdbfa18aSmrg func_to_tool_file "$output_objdir/" 7937cdbfa18aSmrg tool_output_objdir=$func_to_tool_file_result 7938d5c3dbf1Smrg # Create the object directory. 7939d5c3dbf1Smrg func_mkdir_p "$output_objdir" 79409f606849Smrg 7941d5c3dbf1Smrg # Determine the type of output 7942d5c3dbf1Smrg case $output in 7943d5c3dbf1Smrg "") 7944d5c3dbf1Smrg func_fatal_help "you must specify an output file" 7945d5c3dbf1Smrg ;; 7946d5c3dbf1Smrg *.$libext) linkmode=oldlib ;; 7947d5c3dbf1Smrg *.lo | *.$objext) linkmode=obj ;; 7948d5c3dbf1Smrg *.la) linkmode=lib ;; 7949d5c3dbf1Smrg *) linkmode=prog ;; # Anything else should be a program. 7950d5c3dbf1Smrg esac 7951d5c3dbf1Smrg 7952d5c3dbf1Smrg specialdeplibs= 7953d5c3dbf1Smrg 7954d5c3dbf1Smrg libs= 7955d5c3dbf1Smrg # Find all interdependent deplibs by searching for libraries 7956d5c3dbf1Smrg # that are linked more than once (e.g. -la -lb -la) 7957d5c3dbf1Smrg for deplib in $deplibs; do 7958949d0342Smrg if $opt_preserve_dup_deps; then 7959d5c3dbf1Smrg case "$libs " in 7960cdbfa18aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7961d5c3dbf1Smrg esac 7962d5c3dbf1Smrg fi 7963cdbfa18aSmrg func_append libs " $deplib" 7964d5c3dbf1Smrg done 7965d5c3dbf1Smrg 7966949d0342Smrg if test lib = "$linkmode"; then 7967d5c3dbf1Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7968d5c3dbf1Smrg 7969d5c3dbf1Smrg # Compute libraries that are listed more than once in $predeps 7970d5c3dbf1Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7971d5c3dbf1Smrg # not to be eliminated). 7972d5c3dbf1Smrg pre_post_deps= 7973d5c3dbf1Smrg if $opt_duplicate_compiler_generated_deps; then 7974d5c3dbf1Smrg for pre_post_dep in $predeps $postdeps; do 7975d5c3dbf1Smrg case "$pre_post_deps " in 7976cdbfa18aSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7977d5c3dbf1Smrg esac 7978cdbfa18aSmrg func_append pre_post_deps " $pre_post_dep" 7979d5c3dbf1Smrg done 7980d5c3dbf1Smrg fi 7981d5c3dbf1Smrg pre_post_deps= 7982d5c3dbf1Smrg fi 7983d5c3dbf1Smrg 7984d5c3dbf1Smrg deplibs= 7985d5c3dbf1Smrg newdependency_libs= 7986d5c3dbf1Smrg newlib_search_path= 7987d5c3dbf1Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7988d5c3dbf1Smrg notinst_deplibs= # not-installed libtool libraries 7989d5c3dbf1Smrg notinst_path= # paths that contain not-installed libtool libraries 7990d5c3dbf1Smrg 7991d5c3dbf1Smrg case $linkmode in 7992d5c3dbf1Smrg lib) 7993d5c3dbf1Smrg passes="conv dlpreopen link" 7994d5c3dbf1Smrg for file in $dlfiles $dlprefiles; do 7995d5c3dbf1Smrg case $file in 7996d5c3dbf1Smrg *.la) ;; 7997d5c3dbf1Smrg *) 7998949d0342Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7999d5c3dbf1Smrg ;; 8000d5c3dbf1Smrg esac 8001d5c3dbf1Smrg done 8002d5c3dbf1Smrg ;; 8003d5c3dbf1Smrg prog) 8004d5c3dbf1Smrg compile_deplibs= 8005d5c3dbf1Smrg finalize_deplibs= 8006949d0342Smrg alldeplibs=false 8007d5c3dbf1Smrg newdlfiles= 8008d5c3dbf1Smrg newdlprefiles= 8009d5c3dbf1Smrg passes="conv scan dlopen dlpreopen link" 8010d5c3dbf1Smrg ;; 8011d5c3dbf1Smrg *) passes="conv" 8012d5c3dbf1Smrg ;; 8013d5c3dbf1Smrg esac 8014d5c3dbf1Smrg 8015d5c3dbf1Smrg for pass in $passes; do 8016d5c3dbf1Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 8017d5c3dbf1Smrg # so that -L comes before libs that need it for instance... 8018949d0342Smrg if test lib,link = "$linkmode,$pass"; then 8019d5c3dbf1Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 8020d5c3dbf1Smrg ## order, and fix it there properly 8021d5c3dbf1Smrg tmp_deplibs= 8022d5c3dbf1Smrg for deplib in $deplibs; do 8023d5c3dbf1Smrg tmp_deplibs="$deplib $tmp_deplibs" 8024d5c3dbf1Smrg done 8025949d0342Smrg deplibs=$tmp_deplibs 8026d5c3dbf1Smrg fi 8027d5c3dbf1Smrg 8028949d0342Smrg if test lib,link = "$linkmode,$pass" || 8029949d0342Smrg test prog,scan = "$linkmode,$pass"; then 8030949d0342Smrg libs=$deplibs 8031d5c3dbf1Smrg deplibs= 8032d5c3dbf1Smrg fi 8033949d0342Smrg if test prog = "$linkmode"; then 8034d5c3dbf1Smrg case $pass in 8035949d0342Smrg dlopen) libs=$dlfiles ;; 8036949d0342Smrg dlpreopen) libs=$dlprefiles ;; 8037949d0342Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 8038d5c3dbf1Smrg esac 8039d5c3dbf1Smrg fi 8040949d0342Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 8041d5c3dbf1Smrg # Collect and forward deplibs of preopened libtool libs 8042d5c3dbf1Smrg for lib in $dlprefiles; do 8043d5c3dbf1Smrg # Ignore non-libtool-libs 8044d5c3dbf1Smrg dependency_libs= 8045cdbfa18aSmrg func_resolve_sysroot "$lib" 8046d5c3dbf1Smrg case $lib in 8047cdbfa18aSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 8048d5c3dbf1Smrg esac 8049d5c3dbf1Smrg 8050d5c3dbf1Smrg # Collect preopened libtool deplibs, except any this library 8051d5c3dbf1Smrg # has declared as weak libs 8052d5c3dbf1Smrg for deplib in $dependency_libs; do 8053d5c3dbf1Smrg func_basename "$deplib" 8054d5c3dbf1Smrg deplib_base=$func_basename_result 8055d5c3dbf1Smrg case " $weak_libs " in 8056d5c3dbf1Smrg *" $deplib_base "*) ;; 8057cdbfa18aSmrg *) func_append deplibs " $deplib" ;; 8058d5c3dbf1Smrg esac 8059d5c3dbf1Smrg done 8060d5c3dbf1Smrg done 8061949d0342Smrg libs=$dlprefiles 8062d5c3dbf1Smrg fi 8063949d0342Smrg if test dlopen = "$pass"; then 8064d5c3dbf1Smrg # Collect dlpreopened libraries 8065949d0342Smrg save_deplibs=$deplibs 8066d5c3dbf1Smrg deplibs= 8067d5c3dbf1Smrg fi 8068d5c3dbf1Smrg 8069d5c3dbf1Smrg for deplib in $libs; do 8070d5c3dbf1Smrg lib= 8071949d0342Smrg found=false 8072d5c3dbf1Smrg case $deplib in 8073cdbfa18aSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 8074dc088bc7Smrg |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 8075949d0342Smrg if test prog,link = "$linkmode,$pass"; then 8076d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8077d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8078d5c3dbf1Smrg else 8079cdbfa18aSmrg func_append compiler_flags " $deplib" 8080949d0342Smrg if test lib = "$linkmode"; then 8081d5c3dbf1Smrg case "$new_inherited_linker_flags " in 8082d5c3dbf1Smrg *" $deplib "*) ;; 8083cdbfa18aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 8084d5c3dbf1Smrg esac 8085d5c3dbf1Smrg fi 8086d5c3dbf1Smrg fi 8087d5c3dbf1Smrg continue 8088d5c3dbf1Smrg ;; 8089d5c3dbf1Smrg -l*) 8090949d0342Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 8091949d0342Smrg func_warning "'-l' is ignored for archives/objects" 8092d5c3dbf1Smrg continue 8093d5c3dbf1Smrg fi 8094d5c3dbf1Smrg func_stripname '-l' '' "$deplib" 8095d5c3dbf1Smrg name=$func_stripname_result 8096949d0342Smrg if test lib = "$linkmode"; then 8097d5c3dbf1Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 8098d5c3dbf1Smrg else 8099d5c3dbf1Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 8100d5c3dbf1Smrg fi 8101d5c3dbf1Smrg for searchdir in $searchdirs; do 8102d5c3dbf1Smrg for search_ext in .la $std_shrext .so .a; do 8103d5c3dbf1Smrg # Search the libtool library 8104949d0342Smrg lib=$searchdir/lib$name$search_ext 8105d5c3dbf1Smrg if test -f "$lib"; then 8106949d0342Smrg if test .la = "$search_ext"; then 8107949d0342Smrg found=: 8108d5c3dbf1Smrg else 8109949d0342Smrg found=false 8110d5c3dbf1Smrg fi 8111d5c3dbf1Smrg break 2 8112d5c3dbf1Smrg fi 8113d5c3dbf1Smrg done 8114d5c3dbf1Smrg done 8115949d0342Smrg if $found; then 8116949d0342Smrg # deplib is a libtool library 8117d5c3dbf1Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 8118d5c3dbf1Smrg # We need to do some special things here, and not later. 8119949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 8120d5c3dbf1Smrg case " $predeps $postdeps " in 8121d5c3dbf1Smrg *" $deplib "*) 8122d5c3dbf1Smrg if func_lalib_p "$lib"; then 8123d5c3dbf1Smrg library_names= 8124d5c3dbf1Smrg old_library= 8125d5c3dbf1Smrg func_source "$lib" 8126d5c3dbf1Smrg for l in $old_library $library_names; do 8127949d0342Smrg ll=$l 8128d5c3dbf1Smrg done 8129949d0342Smrg if test "X$ll" = "X$old_library"; then # only static version available 8130949d0342Smrg found=false 8131d5c3dbf1Smrg func_dirname "$lib" "" "." 8132949d0342Smrg ladir=$func_dirname_result 8133d5c3dbf1Smrg lib=$ladir/$old_library 8134949d0342Smrg if test prog,link = "$linkmode,$pass"; then 8135d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8136d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8137d5c3dbf1Smrg else 8138d5c3dbf1Smrg deplibs="$deplib $deplibs" 8139949d0342Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 8140d5c3dbf1Smrg fi 8141d5c3dbf1Smrg continue 8142d5c3dbf1Smrg fi 8143d5c3dbf1Smrg fi 8144d5c3dbf1Smrg ;; 8145d5c3dbf1Smrg *) ;; 8146d5c3dbf1Smrg esac 8147d5c3dbf1Smrg fi 8148949d0342Smrg else 8149949d0342Smrg # deplib doesn't seem to be a libtool library 8150949d0342Smrg if test prog,link = "$linkmode,$pass"; then 8151949d0342Smrg compile_deplibs="$deplib $compile_deplibs" 8152949d0342Smrg finalize_deplibs="$deplib $finalize_deplibs" 8153949d0342Smrg else 8154949d0342Smrg deplibs="$deplib $deplibs" 8155949d0342Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 8156949d0342Smrg fi 8157949d0342Smrg continue 8158d5c3dbf1Smrg fi 8159d5c3dbf1Smrg ;; # -l 8160d5c3dbf1Smrg *.ltframework) 8161949d0342Smrg if test prog,link = "$linkmode,$pass"; then 8162d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8163d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8164d5c3dbf1Smrg else 8165d5c3dbf1Smrg deplibs="$deplib $deplibs" 8166949d0342Smrg if test lib = "$linkmode"; then 8167d5c3dbf1Smrg case "$new_inherited_linker_flags " in 8168d5c3dbf1Smrg *" $deplib "*) ;; 8169cdbfa18aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 8170d5c3dbf1Smrg esac 8171d5c3dbf1Smrg fi 8172d5c3dbf1Smrg fi 8173d5c3dbf1Smrg continue 8174d5c3dbf1Smrg ;; 8175d5c3dbf1Smrg -L*) 8176d5c3dbf1Smrg case $linkmode in 8177d5c3dbf1Smrg lib) 8178d5c3dbf1Smrg deplibs="$deplib $deplibs" 8179949d0342Smrg test conv = "$pass" && continue 8180d5c3dbf1Smrg newdependency_libs="$deplib $newdependency_libs" 8181d5c3dbf1Smrg func_stripname '-L' '' "$deplib" 8182cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8183cdbfa18aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8184d5c3dbf1Smrg ;; 8185d5c3dbf1Smrg prog) 8186949d0342Smrg if test conv = "$pass"; then 8187d5c3dbf1Smrg deplibs="$deplib $deplibs" 8188d5c3dbf1Smrg continue 8189d5c3dbf1Smrg fi 8190949d0342Smrg if test scan = "$pass"; then 8191d5c3dbf1Smrg deplibs="$deplib $deplibs" 8192d5c3dbf1Smrg else 8193d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8194d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8195d5c3dbf1Smrg fi 8196d5c3dbf1Smrg func_stripname '-L' '' "$deplib" 8197cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8198cdbfa18aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8199d5c3dbf1Smrg ;; 8200d5c3dbf1Smrg *) 8201949d0342Smrg func_warning "'-L' is ignored for archives/objects" 8202d5c3dbf1Smrg ;; 8203d5c3dbf1Smrg esac # linkmode 8204d5c3dbf1Smrg continue 8205d5c3dbf1Smrg ;; # -L 8206d5c3dbf1Smrg -R*) 8207949d0342Smrg if test link = "$pass"; then 8208d5c3dbf1Smrg func_stripname '-R' '' "$deplib" 8209cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8210cdbfa18aSmrg dir=$func_resolve_sysroot_result 8211d5c3dbf1Smrg # Make sure the xrpath contains only unique directories. 8212d5c3dbf1Smrg case "$xrpath " in 8213d5c3dbf1Smrg *" $dir "*) ;; 8214cdbfa18aSmrg *) func_append xrpath " $dir" ;; 8215d5c3dbf1Smrg esac 8216d5c3dbf1Smrg fi 8217d5c3dbf1Smrg deplibs="$deplib $deplibs" 8218d5c3dbf1Smrg continue 8219d5c3dbf1Smrg ;; 8220cdbfa18aSmrg *.la) 8221cdbfa18aSmrg func_resolve_sysroot "$deplib" 8222cdbfa18aSmrg lib=$func_resolve_sysroot_result 8223cdbfa18aSmrg ;; 8224d5c3dbf1Smrg *.$libext) 8225949d0342Smrg if test conv = "$pass"; then 8226d5c3dbf1Smrg deplibs="$deplib $deplibs" 8227d5c3dbf1Smrg continue 8228d5c3dbf1Smrg fi 8229d5c3dbf1Smrg case $linkmode in 8230d5c3dbf1Smrg lib) 8231d5c3dbf1Smrg # Linking convenience modules into shared libraries is allowed, 8232d5c3dbf1Smrg # but linking other static libraries is non-portable. 8233d5c3dbf1Smrg case " $dlpreconveniencelibs " in 8234d5c3dbf1Smrg *" $deplib "*) ;; 8235d5c3dbf1Smrg *) 8236949d0342Smrg valid_a_lib=false 8237d5c3dbf1Smrg case $deplibs_check_method in 8238d5c3dbf1Smrg match_pattern*) 8239d5c3dbf1Smrg set dummy $deplibs_check_method; shift 8240d5c3dbf1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8241d5c3dbf1Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8242d5c3dbf1Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 8243949d0342Smrg valid_a_lib=: 8244d5c3dbf1Smrg fi 8245d5c3dbf1Smrg ;; 8246d5c3dbf1Smrg pass_all) 8247949d0342Smrg valid_a_lib=: 8248d5c3dbf1Smrg ;; 8249d5c3dbf1Smrg esac 8250949d0342Smrg if $valid_a_lib; then 8251dc088bc7Smrg func_warning "Linking the shared library $output against the static library $deplib is not portable!" 8252949d0342Smrg deplibs="$deplib $deplibs" 8253949d0342Smrg else 8254dc088bc7Smrg func_warning "Trying to link with static lib archive $deplib." 8255dc088bc7Smrg func_warning "I have the capability to make that library automatically link in when" 8256dc088bc7Smrg func_warning "you link to this library. But I can only do this if you have a" 8257dc088bc7Smrg func_warning "shared version of the library, which you do not appear to have" 8258dc088bc7Smrg func_warning "because the file extensions .$libext of this argument makes me believe" 8259dc088bc7Smrg func_warning "that it is just a static archive that I should not use here." 8260d5c3dbf1Smrg fi 8261d5c3dbf1Smrg ;; 8262d5c3dbf1Smrg esac 8263d5c3dbf1Smrg continue 8264d5c3dbf1Smrg ;; 8265d5c3dbf1Smrg prog) 8266949d0342Smrg if test link != "$pass"; then 8267d5c3dbf1Smrg deplibs="$deplib $deplibs" 8268d5c3dbf1Smrg else 8269d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8270d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8271d5c3dbf1Smrg fi 8272d5c3dbf1Smrg continue 8273d5c3dbf1Smrg ;; 8274d5c3dbf1Smrg esac # linkmode 8275d5c3dbf1Smrg ;; # *.$libext 8276d5c3dbf1Smrg *.lo | *.$objext) 8277949d0342Smrg if test conv = "$pass"; then 8278d5c3dbf1Smrg deplibs="$deplib $deplibs" 8279949d0342Smrg elif test prog = "$linkmode"; then 8280949d0342Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8281d5c3dbf1Smrg # If there is no dlopen support or we're linking statically, 8282d5c3dbf1Smrg # we need to preload. 8283cdbfa18aSmrg func_append newdlprefiles " $deplib" 8284d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8285d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8286d5c3dbf1Smrg else 8287cdbfa18aSmrg func_append newdlfiles " $deplib" 8288d5c3dbf1Smrg fi 8289d5c3dbf1Smrg fi 8290d5c3dbf1Smrg continue 8291d5c3dbf1Smrg ;; 8292d5c3dbf1Smrg %DEPLIBS%) 8293949d0342Smrg alldeplibs=: 8294d5c3dbf1Smrg continue 8295d5c3dbf1Smrg ;; 8296d5c3dbf1Smrg esac # case $deplib 8297d5c3dbf1Smrg 8298949d0342Smrg $found || test -f "$lib" \ 8299949d0342Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8300d5c3dbf1Smrg 8301d5c3dbf1Smrg # Check to see that this really is a libtool archive. 8302d5c3dbf1Smrg func_lalib_unsafe_p "$lib" \ 8303949d0342Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 8304d5c3dbf1Smrg 8305d5c3dbf1Smrg func_dirname "$lib" "" "." 8306949d0342Smrg ladir=$func_dirname_result 8307d5c3dbf1Smrg 8308d5c3dbf1Smrg dlname= 8309d5c3dbf1Smrg dlopen= 8310d5c3dbf1Smrg dlpreopen= 8311d5c3dbf1Smrg libdir= 8312d5c3dbf1Smrg library_names= 8313d5c3dbf1Smrg old_library= 8314d5c3dbf1Smrg inherited_linker_flags= 8315d5c3dbf1Smrg # If the library was installed with an old release of libtool, 8316d5c3dbf1Smrg # it will not redefine variables installed, or shouldnotlink 8317d5c3dbf1Smrg installed=yes 8318d5c3dbf1Smrg shouldnotlink=no 8319d5c3dbf1Smrg avoidtemprpath= 8320d5c3dbf1Smrg 8321d5c3dbf1Smrg 8322d5c3dbf1Smrg # Read the .la file 8323d5c3dbf1Smrg func_source "$lib" 8324d5c3dbf1Smrg 8325d5c3dbf1Smrg # Convert "-framework foo" to "foo.ltframework" 8326d5c3dbf1Smrg if test -n "$inherited_linker_flags"; then 8327d5c3dbf1Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8328d5c3dbf1Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8329d5c3dbf1Smrg case " $new_inherited_linker_flags " in 8330d5c3dbf1Smrg *" $tmp_inherited_linker_flag "*) ;; 8331cdbfa18aSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8332d5c3dbf1Smrg esac 8333d5c3dbf1Smrg done 8334d5c3dbf1Smrg fi 8335d5c3dbf1Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8336949d0342Smrg if test lib,link = "$linkmode,$pass" || 8337949d0342Smrg test prog,scan = "$linkmode,$pass" || 8338949d0342Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8339cdbfa18aSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8340cdbfa18aSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8341d5c3dbf1Smrg fi 8342d5c3dbf1Smrg 8343949d0342Smrg if test conv = "$pass"; then 8344d5c3dbf1Smrg # Only check for convenience libraries 8345d5c3dbf1Smrg deplibs="$lib $deplibs" 8346d5c3dbf1Smrg if test -z "$libdir"; then 8347d5c3dbf1Smrg if test -z "$old_library"; then 8348949d0342Smrg func_fatal_error "cannot find name of link library for '$lib'" 8349d5c3dbf1Smrg fi 8350d5c3dbf1Smrg # It is a libtool convenience library, so add in its objects. 8351cdbfa18aSmrg func_append convenience " $ladir/$objdir/$old_library" 8352cdbfa18aSmrg func_append old_convenience " $ladir/$objdir/$old_library" 8353949d0342Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8354949d0342Smrg func_fatal_error "'$lib' is not a convenience library" 8355d5c3dbf1Smrg fi 8356949d0342Smrg tmp_libs= 8357949d0342Smrg for deplib in $dependency_libs; do 8358949d0342Smrg deplibs="$deplib $deplibs" 8359949d0342Smrg if $opt_preserve_dup_deps; then 8360949d0342Smrg case "$tmp_libs " in 8361949d0342Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8362949d0342Smrg esac 8363949d0342Smrg fi 8364949d0342Smrg func_append tmp_libs " $deplib" 8365949d0342Smrg done 8366d5c3dbf1Smrg continue 8367d5c3dbf1Smrg fi # $pass = conv 8368d5c3dbf1Smrg 8369d5c3dbf1Smrg 8370d5c3dbf1Smrg # Get the name of the library we link against. 8371d5c3dbf1Smrg linklib= 8372cdbfa18aSmrg if test -n "$old_library" && 8373949d0342Smrg { test yes = "$prefer_static_libs" || 8374949d0342Smrg test built,no = "$prefer_static_libs,$installed"; }; then 8375cdbfa18aSmrg linklib=$old_library 8376cdbfa18aSmrg else 8377cdbfa18aSmrg for l in $old_library $library_names; do 8378949d0342Smrg linklib=$l 8379cdbfa18aSmrg done 8380cdbfa18aSmrg fi 8381d5c3dbf1Smrg if test -z "$linklib"; then 8382949d0342Smrg func_fatal_error "cannot find name of link library for '$lib'" 8383d5c3dbf1Smrg fi 8384d5c3dbf1Smrg 8385d5c3dbf1Smrg # This library was specified with -dlopen. 8386949d0342Smrg if test dlopen = "$pass"; then 8387949d0342Smrg test -z "$libdir" \ 8388949d0342Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8389d5c3dbf1Smrg if test -z "$dlname" || 8390949d0342Smrg test yes != "$dlopen_support" || 8391949d0342Smrg test no = "$build_libtool_libs" 8392949d0342Smrg then 8393d5c3dbf1Smrg # If there is no dlname, no dlopen support or we're linking 8394d5c3dbf1Smrg # statically, we need to preload. We also need to preload any 8395d5c3dbf1Smrg # dependent libraries so libltdl's deplib preloader doesn't 8396d5c3dbf1Smrg # bomb out in the load deplibs phase. 8397cdbfa18aSmrg func_append dlprefiles " $lib $dependency_libs" 8398d5c3dbf1Smrg else 8399cdbfa18aSmrg func_append newdlfiles " $lib" 8400d5c3dbf1Smrg fi 8401d5c3dbf1Smrg continue 8402d5c3dbf1Smrg fi # $pass = dlopen 8403d5c3dbf1Smrg 8404d5c3dbf1Smrg # We need an absolute path. 8405d5c3dbf1Smrg case $ladir in 8406949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8407d5c3dbf1Smrg *) 8408d5c3dbf1Smrg abs_ladir=`cd "$ladir" && pwd` 8409d5c3dbf1Smrg if test -z "$abs_ladir"; then 8410949d0342Smrg func_warning "cannot determine absolute directory name of '$ladir'" 8411d5c3dbf1Smrg func_warning "passing it literally to the linker, although it might fail" 8412949d0342Smrg abs_ladir=$ladir 8413d5c3dbf1Smrg fi 8414d5c3dbf1Smrg ;; 8415d5c3dbf1Smrg esac 8416d5c3dbf1Smrg func_basename "$lib" 8417949d0342Smrg laname=$func_basename_result 8418d5c3dbf1Smrg 8419d5c3dbf1Smrg # Find the relevant object directory and library name. 8420949d0342Smrg if test yes = "$installed"; then 8421cdbfa18aSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8422949d0342Smrg func_warning "library '$lib' was moved." 8423949d0342Smrg dir=$ladir 8424949d0342Smrg absdir=$abs_ladir 8425949d0342Smrg libdir=$abs_ladir 8426d5c3dbf1Smrg else 8427949d0342Smrg dir=$lt_sysroot$libdir 8428949d0342Smrg absdir=$lt_sysroot$libdir 8429d5c3dbf1Smrg fi 8430949d0342Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8431d5c3dbf1Smrg else 8432d5c3dbf1Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8433949d0342Smrg dir=$ladir 8434949d0342Smrg absdir=$abs_ladir 8435d5c3dbf1Smrg # Remove this search path later 8436cdbfa18aSmrg func_append notinst_path " $abs_ladir" 8437d5c3dbf1Smrg else 8438949d0342Smrg dir=$ladir/$objdir 8439949d0342Smrg absdir=$abs_ladir/$objdir 8440d5c3dbf1Smrg # Remove this search path later 8441cdbfa18aSmrg func_append notinst_path " $abs_ladir" 8442d5c3dbf1Smrg fi 8443d5c3dbf1Smrg fi # $installed = yes 8444d5c3dbf1Smrg func_stripname 'lib' '.la' "$laname" 8445d5c3dbf1Smrg name=$func_stripname_result 8446d5c3dbf1Smrg 8447d5c3dbf1Smrg # This library was specified with -dlpreopen. 8448949d0342Smrg if test dlpreopen = "$pass"; then 8449949d0342Smrg if test -z "$libdir" && test prog = "$linkmode"; then 8450949d0342Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8451d5c3dbf1Smrg fi 8452949d0342Smrg case $host in 8453cdbfa18aSmrg # special handling for platforms with PE-DLLs. 8454dc088bc7Smrg *cygwin* | *mingw* | *windows* | *cegcc* ) 8455cdbfa18aSmrg # Linker will automatically link against shared library if both 8456cdbfa18aSmrg # static and shared are present. Therefore, ensure we extract 8457cdbfa18aSmrg # symbols from the import library if a shared library is present 8458cdbfa18aSmrg # (otherwise, the dlopen module name will be incorrect). We do 8459cdbfa18aSmrg # this by putting the import library name into $newdlprefiles. 8460cdbfa18aSmrg # We recover the dlopen module name by 'saving' the la file 8461cdbfa18aSmrg # name in a special purpose variable, and (later) extracting the 8462cdbfa18aSmrg # dlname from the la file. 8463cdbfa18aSmrg if test -n "$dlname"; then 8464cdbfa18aSmrg func_tr_sh "$dir/$linklib" 8465cdbfa18aSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8466cdbfa18aSmrg func_append newdlprefiles " $dir/$linklib" 8467cdbfa18aSmrg else 8468cdbfa18aSmrg func_append newdlprefiles " $dir/$old_library" 8469cdbfa18aSmrg # Keep a list of preopened convenience libraries to check 8470cdbfa18aSmrg # that they are being used correctly in the link pass. 8471cdbfa18aSmrg test -z "$libdir" && \ 8472cdbfa18aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8473cdbfa18aSmrg fi 8474cdbfa18aSmrg ;; 8475cdbfa18aSmrg * ) 8476cdbfa18aSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8477cdbfa18aSmrg # are required to link). 8478cdbfa18aSmrg if test -n "$old_library"; then 8479cdbfa18aSmrg func_append newdlprefiles " $dir/$old_library" 8480cdbfa18aSmrg # Keep a list of preopened convenience libraries to check 8481cdbfa18aSmrg # that they are being used correctly in the link pass. 8482cdbfa18aSmrg test -z "$libdir" && \ 8483cdbfa18aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8484cdbfa18aSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8485cdbfa18aSmrg elif test -n "$dlname"; then 8486cdbfa18aSmrg func_append newdlprefiles " $dir/$dlname" 8487cdbfa18aSmrg else 8488cdbfa18aSmrg func_append newdlprefiles " $dir/$linklib" 8489cdbfa18aSmrg fi 8490cdbfa18aSmrg ;; 8491cdbfa18aSmrg esac 8492d5c3dbf1Smrg fi # $pass = dlpreopen 8493d5c3dbf1Smrg 8494d5c3dbf1Smrg if test -z "$libdir"; then 8495d5c3dbf1Smrg # Link the convenience library 8496949d0342Smrg if test lib = "$linkmode"; then 8497d5c3dbf1Smrg deplibs="$dir/$old_library $deplibs" 8498949d0342Smrg elif test prog,link = "$linkmode,$pass"; then 8499d5c3dbf1Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8500d5c3dbf1Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8501d5c3dbf1Smrg else 8502d5c3dbf1Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8503d5c3dbf1Smrg fi 8504d5c3dbf1Smrg continue 8505d5c3dbf1Smrg fi 8506d5c3dbf1Smrg 8507d5c3dbf1Smrg 8508949d0342Smrg if test prog = "$linkmode" && test link != "$pass"; then 8509cdbfa18aSmrg func_append newlib_search_path " $ladir" 8510d5c3dbf1Smrg deplibs="$lib $deplibs" 8511d5c3dbf1Smrg 8512949d0342Smrg linkalldeplibs=false 8513949d0342Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8514949d0342Smrg test no = "$build_libtool_libs"; then 8515949d0342Smrg linkalldeplibs=: 8516d5c3dbf1Smrg fi 8517d5c3dbf1Smrg 8518d5c3dbf1Smrg tmp_libs= 8519d5c3dbf1Smrg for deplib in $dependency_libs; do 8520d5c3dbf1Smrg case $deplib in 8521d5c3dbf1Smrg -L*) func_stripname '-L' '' "$deplib" 8522cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8523cdbfa18aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8524d5c3dbf1Smrg ;; 8525d5c3dbf1Smrg esac 8526d5c3dbf1Smrg # Need to link against all dependency_libs? 8527949d0342Smrg if $linkalldeplibs; then 8528d5c3dbf1Smrg deplibs="$deplib $deplibs" 8529d5c3dbf1Smrg else 8530d5c3dbf1Smrg # Need to hardcode shared library paths 8531d5c3dbf1Smrg # or/and link against static libraries 8532d5c3dbf1Smrg newdependency_libs="$deplib $newdependency_libs" 8533d5c3dbf1Smrg fi 8534949d0342Smrg if $opt_preserve_dup_deps; then 8535d5c3dbf1Smrg case "$tmp_libs " in 8536cdbfa18aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8537d5c3dbf1Smrg esac 8538d5c3dbf1Smrg fi 8539cdbfa18aSmrg func_append tmp_libs " $deplib" 8540d5c3dbf1Smrg done # for deplib 8541d5c3dbf1Smrg continue 8542d5c3dbf1Smrg fi # $linkmode = prog... 8543d5c3dbf1Smrg 8544949d0342Smrg if test prog,link = "$linkmode,$pass"; then 8545d5c3dbf1Smrg if test -n "$library_names" && 8546949d0342Smrg { { test no = "$prefer_static_libs" || 8547949d0342Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8548d5c3dbf1Smrg test -z "$old_library"; }; then 8549d5c3dbf1Smrg # We need to hardcode the library path 8550949d0342Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8551d5c3dbf1Smrg # Make sure the rpath contains only unique directories. 8552949d0342Smrg case $temp_rpath: in 8553d5c3dbf1Smrg *"$absdir:"*) ;; 8554dc088bc7Smrg *) case $absdir in 8555dc088bc7Smrg "$progdir/"*) func_append temp_rpath "$absdir:" ;; 8556dc088bc7Smrg *) func_append temp_rpath_tail "$absdir:" ;; 8557dc088bc7Smrg esac 8558d5c3dbf1Smrg esac 8559d5c3dbf1Smrg fi 8560d5c3dbf1Smrg 8561d5c3dbf1Smrg # Hardcode the library path. 8562d5c3dbf1Smrg # Skip directories that are in the system default run-time 8563d5c3dbf1Smrg # search path. 8564d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8565d5c3dbf1Smrg *" $absdir "*) ;; 8566d5c3dbf1Smrg *) 8567dc088bc7Smrg case "$compile_rpath$compile_rpath_tail " in 8568d5c3dbf1Smrg *" $absdir "*) ;; 8569dc088bc7Smrg *) case $absdir in 8570dc088bc7Smrg "$progdir/"*) func_append compile_rpath " $absdir" ;; 8571dc088bc7Smrg *) func_append compile_rpath_tail " $absdir" ;; 8572dc088bc7Smrg esac 8573d5c3dbf1Smrg esac 8574d5c3dbf1Smrg ;; 8575d5c3dbf1Smrg esac 8576d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8577d5c3dbf1Smrg *" $libdir "*) ;; 8578d5c3dbf1Smrg *) 8579d5c3dbf1Smrg case "$finalize_rpath " in 8580d5c3dbf1Smrg *" $libdir "*) ;; 8581cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 8582d5c3dbf1Smrg esac 8583d5c3dbf1Smrg ;; 8584d5c3dbf1Smrg esac 8585d5c3dbf1Smrg fi # $linkmode,$pass = prog,link... 8586d5c3dbf1Smrg 8587949d0342Smrg if $alldeplibs && 8588949d0342Smrg { test pass_all = "$deplibs_check_method" || 8589949d0342Smrg { test yes = "$build_libtool_libs" && 8590d5c3dbf1Smrg test -n "$library_names"; }; }; then 8591d5c3dbf1Smrg # We only need to search for static libraries 8592d5c3dbf1Smrg continue 8593d5c3dbf1Smrg fi 8594d5c3dbf1Smrg fi 8595d5c3dbf1Smrg 8596d5c3dbf1Smrg link_static=no # Whether the deplib will be linked statically 8597d5c3dbf1Smrg use_static_libs=$prefer_static_libs 8598949d0342Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8599d5c3dbf1Smrg use_static_libs=no 8600d5c3dbf1Smrg fi 8601d5c3dbf1Smrg if test -n "$library_names" && 8602949d0342Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8603dc088bc7Smrg case $host_os in 8604dc088bc7Smrg cygwin* | mingw* | windows* | cegcc* | os2*) 8605d5c3dbf1Smrg # No point in relinking DLLs because paths are not encoded 8606cdbfa18aSmrg func_append notinst_deplibs " $lib" 8607d5c3dbf1Smrg need_relink=no 8608d5c3dbf1Smrg ;; 8609d5c3dbf1Smrg *) 8610949d0342Smrg if test no = "$installed"; then 8611cdbfa18aSmrg func_append notinst_deplibs " $lib" 8612d5c3dbf1Smrg need_relink=yes 8613d5c3dbf1Smrg fi 8614d5c3dbf1Smrg ;; 8615d5c3dbf1Smrg esac 8616d5c3dbf1Smrg # This is a shared library 8617d5c3dbf1Smrg 8618d5c3dbf1Smrg # Warn about portability, can't link against -module's on some 8619d5c3dbf1Smrg # systems (darwin). Don't bleat about dlopened modules though! 8620949d0342Smrg dlopenmodule= 8621d5c3dbf1Smrg for dlpremoduletest in $dlprefiles; do 8622d5c3dbf1Smrg if test "X$dlpremoduletest" = "X$lib"; then 8623949d0342Smrg dlopenmodule=$dlpremoduletest 8624d5c3dbf1Smrg break 8625d5c3dbf1Smrg fi 8626d5c3dbf1Smrg done 8627949d0342Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8628d5c3dbf1Smrg echo 8629949d0342Smrg if test prog = "$linkmode"; then 8630dc088bc7Smrg func_warning "Linking the executable $output against the loadable module" 8631d5c3dbf1Smrg else 8632dc088bc7Smrg func_warning "Linking the shared library $output against the loadable module" 8633d5c3dbf1Smrg fi 8634dc088bc7Smrg func_warning "$linklib is not portable!" 8635d5c3dbf1Smrg fi 8636949d0342Smrg if test lib = "$linkmode" && 8637949d0342Smrg test yes = "$hardcode_into_libs"; then 8638d5c3dbf1Smrg # Hardcode the library path. 8639d5c3dbf1Smrg # Skip directories that are in the system default run-time 8640d5c3dbf1Smrg # search path. 8641d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8642d5c3dbf1Smrg *" $absdir "*) ;; 8643d5c3dbf1Smrg *) 8644dc088bc7Smrg case "$compile_rpath$compile_rpath_tail " in 8645d5c3dbf1Smrg *" $absdir "*) ;; 8646dc088bc7Smrg *) case $absdir in 8647dc088bc7Smrg "$progdir/"*) func_append compile_rpath " $absdir" ;; 8648dc088bc7Smrg *) func_append compile_rpath_tail " $absdir" ;; 8649dc088bc7Smrg esac 8650d5c3dbf1Smrg esac 8651d5c3dbf1Smrg ;; 8652d5c3dbf1Smrg esac 8653d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8654d5c3dbf1Smrg *" $libdir "*) ;; 8655d5c3dbf1Smrg *) 8656d5c3dbf1Smrg case "$finalize_rpath " in 8657d5c3dbf1Smrg *" $libdir "*) ;; 8658cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 8659d5c3dbf1Smrg esac 8660d5c3dbf1Smrg ;; 8661d5c3dbf1Smrg esac 8662d5c3dbf1Smrg fi 8663d5c3dbf1Smrg 8664d5c3dbf1Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8665d5c3dbf1Smrg # figure out the soname 8666d5c3dbf1Smrg set dummy $library_names 8667d5c3dbf1Smrg shift 8668949d0342Smrg realname=$1 8669d5c3dbf1Smrg shift 8670d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8671d5c3dbf1Smrg # use dlname if we got it. it's perfectly good, no? 8672d5c3dbf1Smrg if test -n "$dlname"; then 8673949d0342Smrg soname=$dlname 8674d5c3dbf1Smrg elif test -n "$soname_spec"; then 8675d5c3dbf1Smrg # bleh windows 8676dc088bc7Smrg case $host_os in 8677dc088bc7Smrg cygwin* | mingw* | windows* | cegcc* | os2*) 8678d5c3dbf1Smrg func_arith $current - $age 8679d5c3dbf1Smrg major=$func_arith_result 8680949d0342Smrg versuffix=-$major 8681d5c3dbf1Smrg ;; 8682d5c3dbf1Smrg esac 8683d5c3dbf1Smrg eval soname=\"$soname_spec\" 8684d5c3dbf1Smrg else 8685949d0342Smrg soname=$realname 8686d5c3dbf1Smrg fi 8687d5c3dbf1Smrg 8688d5c3dbf1Smrg # Make a new name for the extract_expsyms_cmds to use 8689949d0342Smrg soroot=$soname 8690d5c3dbf1Smrg func_basename "$soroot" 8691949d0342Smrg soname=$func_basename_result 8692d5c3dbf1Smrg func_stripname 'lib' '.dll' "$soname" 8693d5c3dbf1Smrg newlib=libimp-$func_stripname_result.a 8694d5c3dbf1Smrg 8695d5c3dbf1Smrg # If the library has no export list, then create one now 8696d5c3dbf1Smrg if test -f "$output_objdir/$soname-def"; then : 8697d5c3dbf1Smrg else 8698949d0342Smrg func_verbose "extracting exported symbol list from '$soname'" 8699d5c3dbf1Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8700d5c3dbf1Smrg fi 8701d5c3dbf1Smrg 8702d5c3dbf1Smrg # Create $newlib 8703d5c3dbf1Smrg if test -f "$output_objdir/$newlib"; then :; else 8704949d0342Smrg func_verbose "generating import library for '$soname'" 8705d5c3dbf1Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8706d5c3dbf1Smrg fi 8707d5c3dbf1Smrg # make sure the library variables are pointing to the new library 8708d5c3dbf1Smrg dir=$output_objdir 8709d5c3dbf1Smrg linklib=$newlib 8710d5c3dbf1Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8711d5c3dbf1Smrg 8712949d0342Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8713d5c3dbf1Smrg add_shlibpath= 8714d5c3dbf1Smrg add_dir= 8715d5c3dbf1Smrg add= 8716d5c3dbf1Smrg lib_linked=yes 8717d5c3dbf1Smrg case $hardcode_action in 8718d5c3dbf1Smrg immediate | unsupported) 8719949d0342Smrg if test no = "$hardcode_direct"; then 8720949d0342Smrg add=$dir/$linklib 8721d5c3dbf1Smrg case $host in 8722949d0342Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8723949d0342Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8724dc088bc7Smrg *-*-emscripten*) add_dir=-L$dir ;; 8725d5c3dbf1Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8726949d0342Smrg *-*-unixware7*) add_dir=-L$dir ;; 8727d5c3dbf1Smrg *-*-darwin* ) 8728949d0342Smrg # if the lib is a (non-dlopened) module then we cannot 8729d5c3dbf1Smrg # link against it, someone is ignoring the earlier warnings 8730d5c3dbf1Smrg if /usr/bin/file -L $add 2> /dev/null | 8731949d0342Smrg $GREP ": [^:]* bundle" >/dev/null; then 8732d5c3dbf1Smrg if test "X$dlopenmodule" != "X$lib"; then 8733dc088bc7Smrg func_warning "lib $linklib is a module, not a shared library" 8734949d0342Smrg if test -z "$old_library"; then 8735dc088bc7Smrg func_warning "And there doesn't seem to be a static archive available" 8736dc088bc7Smrg func_warning "The link will probably fail, sorry" 8737d5c3dbf1Smrg else 8738949d0342Smrg add=$dir/$old_library 8739d5c3dbf1Smrg fi 8740d5c3dbf1Smrg elif test -n "$old_library"; then 8741949d0342Smrg add=$dir/$old_library 8742d5c3dbf1Smrg fi 8743d5c3dbf1Smrg fi 8744d5c3dbf1Smrg esac 8745949d0342Smrg elif test no = "$hardcode_minus_L"; then 8746d5c3dbf1Smrg case $host in 8747949d0342Smrg *-*-sunos*) add_shlibpath=$dir ;; 8748d5c3dbf1Smrg esac 8749949d0342Smrg add_dir=-L$dir 8750949d0342Smrg add=-l$name 8751949d0342Smrg elif test no = "$hardcode_shlibpath_var"; then 8752949d0342Smrg add_shlibpath=$dir 8753949d0342Smrg add=-l$name 8754d5c3dbf1Smrg else 8755d5c3dbf1Smrg lib_linked=no 8756d5c3dbf1Smrg fi 8757d5c3dbf1Smrg ;; 8758d5c3dbf1Smrg relink) 8759949d0342Smrg if test yes = "$hardcode_direct" && 8760949d0342Smrg test no = "$hardcode_direct_absolute"; then 8761949d0342Smrg add=$dir/$linklib 8762949d0342Smrg elif test yes = "$hardcode_minus_L"; then 8763949d0342Smrg add_dir=-L$absdir 8764d5c3dbf1Smrg # Try looking first in the location we're being installed to. 8765d5c3dbf1Smrg if test -n "$inst_prefix_dir"; then 8766d5c3dbf1Smrg case $libdir in 8767d5c3dbf1Smrg [\\/]*) 8768cdbfa18aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8769d5c3dbf1Smrg ;; 8770d5c3dbf1Smrg esac 8771d5c3dbf1Smrg fi 8772949d0342Smrg add=-l$name 8773949d0342Smrg elif test yes = "$hardcode_shlibpath_var"; then 8774949d0342Smrg add_shlibpath=$dir 8775949d0342Smrg add=-l$name 8776d5c3dbf1Smrg else 8777d5c3dbf1Smrg lib_linked=no 8778d5c3dbf1Smrg fi 8779d5c3dbf1Smrg ;; 8780d5c3dbf1Smrg *) lib_linked=no ;; 8781d5c3dbf1Smrg esac 8782d5c3dbf1Smrg 8783949d0342Smrg if test yes != "$lib_linked"; then 8784d5c3dbf1Smrg func_fatal_configuration "unsupported hardcode properties" 8785d5c3dbf1Smrg fi 8786d5c3dbf1Smrg 8787d5c3dbf1Smrg if test -n "$add_shlibpath"; then 8788d5c3dbf1Smrg case :$compile_shlibpath: in 8789d5c3dbf1Smrg *":$add_shlibpath:"*) ;; 8790cdbfa18aSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8791d5c3dbf1Smrg esac 8792d5c3dbf1Smrg fi 8793949d0342Smrg if test prog = "$linkmode"; then 8794d5c3dbf1Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8795d5c3dbf1Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8796d5c3dbf1Smrg else 8797d5c3dbf1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8798d5c3dbf1Smrg test -n "$add" && deplibs="$add $deplibs" 8799949d0342Smrg if test yes != "$hardcode_direct" && 8800949d0342Smrg test yes != "$hardcode_minus_L" && 8801949d0342Smrg test yes = "$hardcode_shlibpath_var"; then 8802d5c3dbf1Smrg case :$finalize_shlibpath: in 8803d5c3dbf1Smrg *":$libdir:"*) ;; 8804cdbfa18aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8805d5c3dbf1Smrg esac 8806d5c3dbf1Smrg fi 8807d5c3dbf1Smrg fi 8808d5c3dbf1Smrg fi 8809d5c3dbf1Smrg 8810949d0342Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8811d5c3dbf1Smrg add_shlibpath= 8812d5c3dbf1Smrg add_dir= 8813d5c3dbf1Smrg add= 8814d5c3dbf1Smrg # Finalize command for both is simple: just hardcode it. 8815949d0342Smrg if test yes = "$hardcode_direct" && 8816949d0342Smrg test no = "$hardcode_direct_absolute"; then 8817949d0342Smrg add=$libdir/$linklib 8818949d0342Smrg elif test yes = "$hardcode_minus_L"; then 8819dc088bc7Smrg add_dir=-L$lt_sysroot$libdir 8820949d0342Smrg add=-l$name 8821949d0342Smrg elif test yes = "$hardcode_shlibpath_var"; then 8822d5c3dbf1Smrg case :$finalize_shlibpath: in 8823d5c3dbf1Smrg *":$libdir:"*) ;; 8824cdbfa18aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8825d5c3dbf1Smrg esac 8826949d0342Smrg add=-l$name 8827949d0342Smrg elif test yes = "$hardcode_automatic"; then 8828d5c3dbf1Smrg if test -n "$inst_prefix_dir" && 8829949d0342Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8830949d0342Smrg add=$inst_prefix_dir$libdir/$linklib 8831d5c3dbf1Smrg else 8832949d0342Smrg add=$libdir/$linklib 8833d5c3dbf1Smrg fi 8834d5c3dbf1Smrg else 8835d5c3dbf1Smrg # We cannot seem to hardcode it, guess we'll fake it. 8836dc088bc7Smrg add_dir=-L$lt_sysroot$libdir 8837d5c3dbf1Smrg # Try looking first in the location we're being installed to. 8838d5c3dbf1Smrg if test -n "$inst_prefix_dir"; then 8839d5c3dbf1Smrg case $libdir in 8840d5c3dbf1Smrg [\\/]*) 8841cdbfa18aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8842d5c3dbf1Smrg ;; 8843d5c3dbf1Smrg esac 8844d5c3dbf1Smrg fi 8845949d0342Smrg add=-l$name 8846d5c3dbf1Smrg fi 8847d5c3dbf1Smrg 8848949d0342Smrg if test prog = "$linkmode"; then 8849d5c3dbf1Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8850d5c3dbf1Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8851d5c3dbf1Smrg else 8852d5c3dbf1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8853d5c3dbf1Smrg test -n "$add" && deplibs="$add $deplibs" 8854d5c3dbf1Smrg fi 8855d5c3dbf1Smrg fi 8856949d0342Smrg elif test prog = "$linkmode"; then 8857d5c3dbf1Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8858d5c3dbf1Smrg # is not unsupported. This is valid on all known static and 8859d5c3dbf1Smrg # shared platforms. 8860949d0342Smrg if test unsupported != "$hardcode_direct"; then 8861949d0342Smrg test -n "$old_library" && linklib=$old_library 8862d5c3dbf1Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8863d5c3dbf1Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8864d5c3dbf1Smrg else 8865d5c3dbf1Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8866d5c3dbf1Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8867d5c3dbf1Smrg fi 8868949d0342Smrg elif test yes = "$build_libtool_libs"; then 8869d5c3dbf1Smrg # Not a shared library 8870949d0342Smrg if test pass_all != "$deplibs_check_method"; then 8871d5c3dbf1Smrg # We're trying link a shared library against a static one 8872d5c3dbf1Smrg # but the system doesn't support it. 8873d5c3dbf1Smrg 8874d5c3dbf1Smrg # Just print a warning and add the library to dependency_libs so 8875d5c3dbf1Smrg # that the program can be linked against the static library. 8876dc088bc7Smrg func_warning "This system cannot link to static lib archive $lib." 8877dc088bc7Smrg func_warning "I have the capability to make that library automatically link in when" 8878dc088bc7Smrg func_warning "you link to this library. But I can only do this if you have a" 8879dc088bc7Smrg func_warning "shared version of the library, which you do not appear to have." 8880949d0342Smrg if test yes = "$module"; then 8881dc088bc7Smrg func_warning "But as you try to build a module library, libtool will still create " 8882dc088bc7Smrg func_warning "a static module, that should work as long as the dlopening application" 8883dc088bc7Smrg func_warning "is linked with the -dlopen flag to resolve symbols at runtime." 8884d5c3dbf1Smrg if test -z "$global_symbol_pipe"; then 8885dc088bc7Smrg func_warning "However, this would only work if libtool was able to extract symbol" 8886dc088bc7Smrg func_warning "lists from a program, using 'nm' or equivalent, but libtool could" 8887dc088bc7Smrg func_warning "not find such a program. So, this module is probably useless." 8888dc088bc7Smrg func_warning "'nm' from GNU binutils and a full rebuild may help." 8889d5c3dbf1Smrg fi 8890949d0342Smrg if test no = "$build_old_libs"; then 8891d5c3dbf1Smrg build_libtool_libs=module 8892d5c3dbf1Smrg build_old_libs=yes 8893d5c3dbf1Smrg else 8894d5c3dbf1Smrg build_libtool_libs=no 8895d5c3dbf1Smrg fi 8896d5c3dbf1Smrg fi 8897d5c3dbf1Smrg else 8898d5c3dbf1Smrg deplibs="$dir/$old_library $deplibs" 8899d5c3dbf1Smrg link_static=yes 8900d5c3dbf1Smrg fi 8901d5c3dbf1Smrg fi # link shared/static library? 8902d5c3dbf1Smrg 8903949d0342Smrg if test lib = "$linkmode"; then 8904d5c3dbf1Smrg if test -n "$dependency_libs" && 8905949d0342Smrg { test yes != "$hardcode_into_libs" || 8906949d0342Smrg test yes = "$build_old_libs" || 8907949d0342Smrg test yes = "$link_static"; }; then 8908d5c3dbf1Smrg # Extract -R from dependency_libs 8909d5c3dbf1Smrg temp_deplibs= 8910d5c3dbf1Smrg for libdir in $dependency_libs; do 8911d5c3dbf1Smrg case $libdir in 8912d5c3dbf1Smrg -R*) func_stripname '-R' '' "$libdir" 8913d5c3dbf1Smrg temp_xrpath=$func_stripname_result 8914d5c3dbf1Smrg case " $xrpath " in 8915d5c3dbf1Smrg *" $temp_xrpath "*) ;; 8916cdbfa18aSmrg *) func_append xrpath " $temp_xrpath";; 8917d5c3dbf1Smrg esac;; 8918cdbfa18aSmrg *) func_append temp_deplibs " $libdir";; 8919d5c3dbf1Smrg esac 8920d5c3dbf1Smrg done 8921949d0342Smrg dependency_libs=$temp_deplibs 8922d5c3dbf1Smrg fi 8923d5c3dbf1Smrg 8924cdbfa18aSmrg func_append newlib_search_path " $absdir" 8925d5c3dbf1Smrg # Link against this library 8926949d0342Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8927d5c3dbf1Smrg # ... and its dependency_libs 8928d5c3dbf1Smrg tmp_libs= 8929d5c3dbf1Smrg for deplib in $dependency_libs; do 8930d5c3dbf1Smrg newdependency_libs="$deplib $newdependency_libs" 8931cdbfa18aSmrg case $deplib in 8932cdbfa18aSmrg -L*) func_stripname '-L' '' "$deplib" 8933cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result";; 8934cdbfa18aSmrg *) func_resolve_sysroot "$deplib" ;; 8935cdbfa18aSmrg esac 8936949d0342Smrg if $opt_preserve_dup_deps; then 8937d5c3dbf1Smrg case "$tmp_libs " in 8938cdbfa18aSmrg *" $func_resolve_sysroot_result "*) 8939cdbfa18aSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8940d5c3dbf1Smrg esac 8941d5c3dbf1Smrg fi 8942cdbfa18aSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8943d5c3dbf1Smrg done 8944d5c3dbf1Smrg 8945949d0342Smrg if test no != "$link_all_deplibs"; then 8946d5c3dbf1Smrg # Add the search paths of all dependency libraries 8947d5c3dbf1Smrg for deplib in $dependency_libs; do 8948d5c3dbf1Smrg path= 8949d5c3dbf1Smrg case $deplib in 8950949d0342Smrg -L*) path=$deplib ;; 8951d5c3dbf1Smrg *.la) 8952cdbfa18aSmrg func_resolve_sysroot "$deplib" 8953cdbfa18aSmrg deplib=$func_resolve_sysroot_result 8954d5c3dbf1Smrg func_dirname "$deplib" "" "." 8955cdbfa18aSmrg dir=$func_dirname_result 8956d5c3dbf1Smrg # We need an absolute path. 8957d5c3dbf1Smrg case $dir in 8958949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8959d5c3dbf1Smrg *) 8960d5c3dbf1Smrg absdir=`cd "$dir" && pwd` 8961d5c3dbf1Smrg if test -z "$absdir"; then 8962949d0342Smrg func_warning "cannot determine absolute directory name of '$dir'" 8963949d0342Smrg absdir=$dir 8964d5c3dbf1Smrg fi 8965d5c3dbf1Smrg ;; 8966d5c3dbf1Smrg esac 8967d5c3dbf1Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8968d5c3dbf1Smrg case $host in 8969d5c3dbf1Smrg *-*-darwin*) 8970d5c3dbf1Smrg depdepl= 8971949d0342Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8972949d0342Smrg if test -n "$deplibrary_names"; then 8973949d0342Smrg for tmp in $deplibrary_names; do 8974d5c3dbf1Smrg depdepl=$tmp 8975d5c3dbf1Smrg done 8976949d0342Smrg if test -f "$absdir/$objdir/$depdepl"; then 8977949d0342Smrg depdepl=$absdir/$objdir/$depdepl 8978949d0342Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8979d5c3dbf1Smrg if test -z "$darwin_install_name"; then 8980949d0342Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8981d5c3dbf1Smrg fi 8982949d0342Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8983949d0342Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8984d5c3dbf1Smrg path= 8985d5c3dbf1Smrg fi 8986d5c3dbf1Smrg fi 8987d5c3dbf1Smrg ;; 8988d5c3dbf1Smrg *) 8989949d0342Smrg path=-L$absdir/$objdir 8990d5c3dbf1Smrg ;; 8991d5c3dbf1Smrg esac 8992d5c3dbf1Smrg else 8993949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8994d5c3dbf1Smrg test -z "$libdir" && \ 8995949d0342Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8996d5c3dbf1Smrg test "$absdir" != "$libdir" && \ 8997949d0342Smrg func_warning "'$deplib' seems to be moved" 8998d5c3dbf1Smrg 8999949d0342Smrg path=-L$absdir 9000d5c3dbf1Smrg fi 9001d5c3dbf1Smrg ;; 9002d5c3dbf1Smrg esac 9003d5c3dbf1Smrg case " $deplibs " in 9004d5c3dbf1Smrg *" $path "*) ;; 9005d5c3dbf1Smrg *) deplibs="$path $deplibs" ;; 9006d5c3dbf1Smrg esac 9007d5c3dbf1Smrg done 9008d5c3dbf1Smrg fi # link_all_deplibs != no 9009d5c3dbf1Smrg fi # linkmode = lib 9010d5c3dbf1Smrg done # for deplib in $libs 9011dc088bc7Smrg 9012dc088bc7Smrg func_append temp_rpath "$temp_rpath_tail" 9013dc088bc7Smrg func_append compile_rpath "$compile_rpath_tail" 9014dc088bc7Smrg 9015949d0342Smrg if test link = "$pass"; then 9016949d0342Smrg if test prog = "$linkmode"; then 9017d5c3dbf1Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 9018d5c3dbf1Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 9019d5c3dbf1Smrg else 9020d5c3dbf1Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9021d5c3dbf1Smrg fi 9022d5c3dbf1Smrg fi 9023949d0342Smrg dependency_libs=$newdependency_libs 9024949d0342Smrg if test dlpreopen = "$pass"; then 9025d5c3dbf1Smrg # Link the dlpreopened libraries before other libraries 9026d5c3dbf1Smrg for deplib in $save_deplibs; do 9027d5c3dbf1Smrg deplibs="$deplib $deplibs" 9028d5c3dbf1Smrg done 9029d5c3dbf1Smrg fi 9030949d0342Smrg if test dlopen != "$pass"; then 9031949d0342Smrg test conv = "$pass" || { 9032d5c3dbf1Smrg # Make sure lib_search_path contains only unique directories. 9033d5c3dbf1Smrg lib_search_path= 9034d5c3dbf1Smrg for dir in $newlib_search_path; do 9035d5c3dbf1Smrg case "$lib_search_path " in 9036d5c3dbf1Smrg *" $dir "*) ;; 9037cdbfa18aSmrg *) func_append lib_search_path " $dir" ;; 9038d5c3dbf1Smrg esac 9039d5c3dbf1Smrg done 9040d5c3dbf1Smrg newlib_search_path= 9041949d0342Smrg } 9042d5c3dbf1Smrg 9043949d0342Smrg if test prog,link = "$linkmode,$pass"; then 9044d5c3dbf1Smrg vars="compile_deplibs finalize_deplibs" 9045949d0342Smrg else 9046949d0342Smrg vars=deplibs 9047d5c3dbf1Smrg fi 9048d5c3dbf1Smrg for var in $vars dependency_libs; do 9049d5c3dbf1Smrg # Add libraries to $var in reverse order 9050d5c3dbf1Smrg eval tmp_libs=\"\$$var\" 9051d5c3dbf1Smrg new_libs= 9052dc088bc7Smrg # FIXME: Pedantically, this is the right thing to do, so 9053dc088bc7Smrg # that some nasty dependency loop isn't accidentally 9054dc088bc7Smrg # broken: new_libs="$deplib $new_libs" 9055d5c3dbf1Smrg for deplib in $tmp_libs; do 9056dc088bc7Smrg if $opt_preserve_dup_deps; then 9057dc088bc7Smrg new_libs="$deplib $new_libs" 9058dc088bc7Smrg else 9059dc088bc7Smrg # Pragmatically, this seems to cause very few problems in 9060dc088bc7Smrg # practice: 9061dc088bc7Smrg case $deplib in 9062dc088bc7Smrg -L*) new_libs="$deplib $new_libs" ;; 9063dc088bc7Smrg -R*) ;; 9064d5c3dbf1Smrg *) 9065dc088bc7Smrg # And here is the reason: when a library appears more 9066dc088bc7Smrg # than once as an explicit dependence of a library, or 9067dc088bc7Smrg # is implicitly linked in more than once by the 9068dc088bc7Smrg # compiler, it is considered special, and multiple 9069dc088bc7Smrg # occurrences thereof are not removed. Compare this 9070dc088bc7Smrg # with having the same library being listed as a 9071dc088bc7Smrg # dependency of multiple other libraries: in this case, 9072dc088bc7Smrg # we know (pedantically, we assume) the library does not 9073dc088bc7Smrg # need to be listed more than once, so we keep only the 9074dc088bc7Smrg # last copy. This is not always right, but it is rare 9075dc088bc7Smrg # enough that we require users that really mean to play 9076dc088bc7Smrg # such unportable linking tricks to link the library 9077dc088bc7Smrg # using -Wl,-lname, so that libtool does not consider it 9078dc088bc7Smrg # for duplicate removal. And if not possible for portability 9079dc088bc7Smrg # reasons, then --preserve-dup-deps should be used. 9080dc088bc7Smrg case " $specialdeplibs " in 9081dc088bc7Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 9082dc088bc7Smrg *) 9083dc088bc7Smrg case " $new_libs " in 9084dc088bc7Smrg *" $deplib "*) ;; 9085dc088bc7Smrg *) new_libs="$deplib $new_libs" ;; 9086dc088bc7Smrg esac 9087dc088bc7Smrg ;; 9088dc088bc7Smrg esac 9089dc088bc7Smrg ;; 9090d5c3dbf1Smrg esac 9091dc088bc7Smrg fi 9092d5c3dbf1Smrg done 9093d5c3dbf1Smrg tmp_libs= 9094d5c3dbf1Smrg for deplib in $new_libs; do 9095d5c3dbf1Smrg case $deplib in 9096d5c3dbf1Smrg -L*) 9097d5c3dbf1Smrg case " $tmp_libs " in 9098d5c3dbf1Smrg *" $deplib "*) ;; 9099cdbfa18aSmrg *) func_append tmp_libs " $deplib" ;; 9100d5c3dbf1Smrg esac 9101d5c3dbf1Smrg ;; 9102cdbfa18aSmrg *) func_append tmp_libs " $deplib" ;; 9103d5c3dbf1Smrg esac 9104d5c3dbf1Smrg done 9105d5c3dbf1Smrg eval $var=\"$tmp_libs\" 9106d5c3dbf1Smrg done # for var 9107d5c3dbf1Smrg fi 9108949d0342Smrg 9109949d0342Smrg # Add Sun CC postdeps if required: 9110949d0342Smrg test CXX = "$tagname" && { 9111949d0342Smrg case $host_os in 9112949d0342Smrg linux*) 9113949d0342Smrg case `$CC -V 2>&1 | $SED 5q` in 9114949d0342Smrg *Sun\ C*) # Sun C++ 5.9 9115949d0342Smrg func_suncc_cstd_abi 9116949d0342Smrg 9117949d0342Smrg if test no != "$suncc_use_cstd_abi"; then 9118949d0342Smrg func_append postdeps ' -library=Cstd -library=Crun' 9119949d0342Smrg fi 9120949d0342Smrg ;; 9121949d0342Smrg esac 9122949d0342Smrg ;; 9123949d0342Smrg 9124949d0342Smrg solaris*) 9125949d0342Smrg func_cc_basename "$CC" 9126949d0342Smrg case $func_cc_basename_result in 9127949d0342Smrg CC* | sunCC*) 9128949d0342Smrg func_suncc_cstd_abi 9129949d0342Smrg 9130949d0342Smrg if test no != "$suncc_use_cstd_abi"; then 9131949d0342Smrg func_append postdeps ' -library=Cstd -library=Crun' 9132949d0342Smrg fi 9133949d0342Smrg ;; 9134949d0342Smrg esac 9135949d0342Smrg ;; 9136949d0342Smrg esac 9137949d0342Smrg } 9138949d0342Smrg 9139d5c3dbf1Smrg # Last step: remove runtime libs from dependency_libs 9140d5c3dbf1Smrg # (they stay in deplibs) 9141d5c3dbf1Smrg tmp_libs= 9142949d0342Smrg for i in $dependency_libs; do 9143d5c3dbf1Smrg case " $predeps $postdeps $compiler_lib_search_path " in 9144d5c3dbf1Smrg *" $i "*) 9145949d0342Smrg i= 9146d5c3dbf1Smrg ;; 9147d5c3dbf1Smrg esac 9148949d0342Smrg if test -n "$i"; then 9149cdbfa18aSmrg func_append tmp_libs " $i" 9150d5c3dbf1Smrg fi 9151d5c3dbf1Smrg done 9152d5c3dbf1Smrg dependency_libs=$tmp_libs 9153d5c3dbf1Smrg done # for pass 9154949d0342Smrg if test prog = "$linkmode"; then 9155949d0342Smrg dlfiles=$newdlfiles 9156d5c3dbf1Smrg fi 9157949d0342Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 9158949d0342Smrg dlprefiles=$newdlprefiles 9159d5c3dbf1Smrg fi 9160d5c3dbf1Smrg 9161d5c3dbf1Smrg case $linkmode in 9162d5c3dbf1Smrg oldlib) 9163949d0342Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 9164949d0342Smrg func_warning "'-dlopen' is ignored for archives" 9165d5c3dbf1Smrg fi 9166d5c3dbf1Smrg 9167d5c3dbf1Smrg case " $deplibs" in 9168d5c3dbf1Smrg *\ -l* | *\ -L*) 9169949d0342Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 9170d5c3dbf1Smrg esac 9171d5c3dbf1Smrg 9172d5c3dbf1Smrg test -n "$rpath" && \ 9173949d0342Smrg func_warning "'-rpath' is ignored for archives" 9174d5c3dbf1Smrg 9175d5c3dbf1Smrg test -n "$xrpath" && \ 9176949d0342Smrg func_warning "'-R' is ignored for archives" 9177d5c3dbf1Smrg 9178d5c3dbf1Smrg test -n "$vinfo" && \ 9179949d0342Smrg func_warning "'-version-info/-version-number' is ignored for archives" 9180d5c3dbf1Smrg 9181d5c3dbf1Smrg test -n "$release" && \ 9182949d0342Smrg func_warning "'-release' is ignored for archives" 9183d5c3dbf1Smrg 9184d5c3dbf1Smrg test -n "$export_symbols$export_symbols_regex" && \ 9185949d0342Smrg func_warning "'-export-symbols' is ignored for archives" 9186d5c3dbf1Smrg 9187d5c3dbf1Smrg # Now set the variables for building old libraries. 9188d5c3dbf1Smrg build_libtool_libs=no 9189949d0342Smrg oldlibs=$output 9190cdbfa18aSmrg func_append objs "$old_deplibs" 9191d5c3dbf1Smrg ;; 9192d5c3dbf1Smrg 9193d5c3dbf1Smrg lib) 9194949d0342Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 9195d5c3dbf1Smrg case $outputname in 9196d5c3dbf1Smrg lib*) 9197d5c3dbf1Smrg func_stripname 'lib' '.la' "$outputname" 9198d5c3dbf1Smrg name=$func_stripname_result 9199d5c3dbf1Smrg eval shared_ext=\"$shrext_cmds\" 9200d5c3dbf1Smrg eval libname=\"$libname_spec\" 9201d5c3dbf1Smrg ;; 9202d5c3dbf1Smrg *) 9203949d0342Smrg test no = "$module" \ 9204949d0342Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9205d5c3dbf1Smrg 9206949d0342Smrg if test no != "$need_lib_prefix"; then 9207d5c3dbf1Smrg # Add the "lib" prefix for modules if required 9208d5c3dbf1Smrg func_stripname '' '.la' "$outputname" 9209d5c3dbf1Smrg name=$func_stripname_result 9210d5c3dbf1Smrg eval shared_ext=\"$shrext_cmds\" 9211d5c3dbf1Smrg eval libname=\"$libname_spec\" 9212d5c3dbf1Smrg else 9213d5c3dbf1Smrg func_stripname '' '.la' "$outputname" 9214d5c3dbf1Smrg libname=$func_stripname_result 9215d5c3dbf1Smrg fi 9216d5c3dbf1Smrg ;; 9217d5c3dbf1Smrg esac 9218d5c3dbf1Smrg 9219d5c3dbf1Smrg if test -n "$objs"; then 9220949d0342Smrg if test pass_all != "$deplibs_check_method"; then 9221949d0342Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9222d5c3dbf1Smrg else 9223dc088bc7Smrg func_warning "Linking the shared library $output against the non-libtool objects $objs is not portable!" 9224cdbfa18aSmrg func_append libobjs " $objs" 9225d5c3dbf1Smrg fi 9226d5c3dbf1Smrg fi 9227d5c3dbf1Smrg 9228949d0342Smrg test no = "$dlself" \ 9229949d0342Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9230d5c3dbf1Smrg 9231d5c3dbf1Smrg set dummy $rpath 9232d5c3dbf1Smrg shift 9233949d0342Smrg test 1 -lt "$#" \ 9234949d0342Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9235d5c3dbf1Smrg 9236949d0342Smrg install_libdir=$1 9237d5c3dbf1Smrg 9238d5c3dbf1Smrg oldlibs= 9239d5c3dbf1Smrg if test -z "$rpath"; then 9240949d0342Smrg if test yes = "$build_libtool_libs"; then 9241d5c3dbf1Smrg # Building a libtool convenience library. 9242949d0342Smrg # Some compilers have problems with a '.al' extension so 9243d5c3dbf1Smrg # convenience libraries should have the same extension an 9244d5c3dbf1Smrg # archive normally would. 9245d5c3dbf1Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9246d5c3dbf1Smrg build_libtool_libs=convenience 9247d5c3dbf1Smrg build_old_libs=yes 9248d5c3dbf1Smrg fi 9249d5c3dbf1Smrg 9250d5c3dbf1Smrg test -n "$vinfo" && \ 9251949d0342Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9252d5c3dbf1Smrg 9253d5c3dbf1Smrg test -n "$release" && \ 9254949d0342Smrg func_warning "'-release' is ignored for convenience libraries" 9255d5c3dbf1Smrg else 9256d5c3dbf1Smrg 9257d5c3dbf1Smrg # Parse the version information argument. 9258949d0342Smrg save_ifs=$IFS; IFS=: 9259d5c3dbf1Smrg set dummy $vinfo 0 0 0 9260d5c3dbf1Smrg shift 9261949d0342Smrg IFS=$save_ifs 9262d5c3dbf1Smrg 9263d5c3dbf1Smrg test -n "$7" && \ 9264949d0342Smrg func_fatal_help "too many parameters to '-version-info'" 9265d5c3dbf1Smrg 9266d5c3dbf1Smrg # convert absolute version numbers to libtool ages 9267d5c3dbf1Smrg # this retains compatibility with .la files and attempts 9268d5c3dbf1Smrg # to make the code below a bit more comprehensible 9269d5c3dbf1Smrg 9270d5c3dbf1Smrg case $vinfo_number in 9271d5c3dbf1Smrg yes) 9272949d0342Smrg number_major=$1 9273949d0342Smrg number_minor=$2 9274949d0342Smrg number_revision=$3 9275d5c3dbf1Smrg # 9276d5c3dbf1Smrg # There are really only two kinds -- those that 9277d5c3dbf1Smrg # use the current revision as the major version 9278d5c3dbf1Smrg # and those that subtract age and use age as 9279d5c3dbf1Smrg # a minor version. But, then there is irix 9280949d0342Smrg # that has an extra 1 added just for fun 9281d5c3dbf1Smrg # 9282d5c3dbf1Smrg case $version_type in 9283cdbfa18aSmrg # correct linux to gnu/linux during the next big refactor 9284dc088bc7Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|qnx|windows|none) 9285d5c3dbf1Smrg func_arith $number_major + $number_minor 9286d5c3dbf1Smrg current=$func_arith_result 9287949d0342Smrg age=$number_minor 9288949d0342Smrg revision=$number_revision 9289d5c3dbf1Smrg ;; 9290dc088bc7Smrg freebsd-aout|sco|sunos) 9291949d0342Smrg current=$number_major 9292949d0342Smrg revision=$number_minor 9293949d0342Smrg age=0 9294d5c3dbf1Smrg ;; 9295d5c3dbf1Smrg irix|nonstopux) 9296d5c3dbf1Smrg func_arith $number_major + $number_minor 9297d5c3dbf1Smrg current=$func_arith_result 9298949d0342Smrg age=$number_minor 9299949d0342Smrg revision=$number_minor 9300d5c3dbf1Smrg lt_irix_increment=no 9301d5c3dbf1Smrg ;; 9302dc088bc7Smrg *) 9303dc088bc7Smrg func_fatal_configuration "$modename: unknown library version type '$version_type'" 9304dc088bc7Smrg ;; 9305d5c3dbf1Smrg esac 9306d5c3dbf1Smrg ;; 9307d5c3dbf1Smrg no) 9308949d0342Smrg current=$1 9309949d0342Smrg revision=$2 9310949d0342Smrg age=$3 9311d5c3dbf1Smrg ;; 9312d5c3dbf1Smrg esac 9313d5c3dbf1Smrg 9314d5c3dbf1Smrg # Check that each of the things are valid numbers. 9315d5c3dbf1Smrg case $current in 9316d5c3dbf1Smrg 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]) ;; 9317d5c3dbf1Smrg *) 9318949d0342Smrg func_error "CURRENT '$current' must be a nonnegative integer" 9319949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9320d5c3dbf1Smrg ;; 9321d5c3dbf1Smrg esac 9322d5c3dbf1Smrg 9323d5c3dbf1Smrg case $revision in 9324d5c3dbf1Smrg 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]) ;; 9325d5c3dbf1Smrg *) 9326949d0342Smrg func_error "REVISION '$revision' must be a nonnegative integer" 9327949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9328d5c3dbf1Smrg ;; 9329d5c3dbf1Smrg esac 9330d5c3dbf1Smrg 9331d5c3dbf1Smrg case $age in 9332d5c3dbf1Smrg 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]) ;; 9333d5c3dbf1Smrg *) 9334949d0342Smrg func_error "AGE '$age' must be a nonnegative integer" 9335949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9336d5c3dbf1Smrg ;; 9337d5c3dbf1Smrg esac 9338d5c3dbf1Smrg 9339d5c3dbf1Smrg if test "$age" -gt "$current"; then 9340949d0342Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 9341949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9342d5c3dbf1Smrg fi 9343d5c3dbf1Smrg 9344d5c3dbf1Smrg # Calculate the version variables. 9345d5c3dbf1Smrg major= 9346d5c3dbf1Smrg versuffix= 9347d5c3dbf1Smrg verstring= 9348d5c3dbf1Smrg case $version_type in 9349d5c3dbf1Smrg none) ;; 9350d5c3dbf1Smrg 9351d5c3dbf1Smrg darwin) 9352d5c3dbf1Smrg # Like Linux, but with the current version available in 9353d5c3dbf1Smrg # verstring for coding it into the library header 9354d5c3dbf1Smrg func_arith $current - $age 9355d5c3dbf1Smrg major=.$func_arith_result 9356949d0342Smrg versuffix=$major.$age.$revision 9357d5c3dbf1Smrg # Darwin ld doesn't like 0 for these options... 9358d5c3dbf1Smrg func_arith $current + 1 9359d5c3dbf1Smrg minor_current=$func_arith_result 9360949d0342Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9361d5c3dbf1Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9362949d0342Smrg # On Darwin other compilers 9363949d0342Smrg case $CC in 9364949d0342Smrg nagfor*) 9365949d0342Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9366949d0342Smrg ;; 9367949d0342Smrg *) 9368949d0342Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9369949d0342Smrg ;; 9370949d0342Smrg esac 9371d5c3dbf1Smrg ;; 9372d5c3dbf1Smrg 9373d5c3dbf1Smrg freebsd-aout) 9374949d0342Smrg major=.$current 9375949d0342Smrg versuffix=.$current.$revision 9376d5c3dbf1Smrg ;; 9377d5c3dbf1Smrg 9378949d0342Smrg freebsd-elf | midnightbsd-elf) 9379949d0342Smrg func_arith $current - $age 9380949d0342Smrg major=.$func_arith_result 9381949d0342Smrg versuffix=$major.$age.$revision 9382d5c3dbf1Smrg ;; 9383d5c3dbf1Smrg 9384d5c3dbf1Smrg irix | nonstopux) 9385949d0342Smrg if test no = "$lt_irix_increment"; then 9386d5c3dbf1Smrg func_arith $current - $age 9387d5c3dbf1Smrg else 9388d5c3dbf1Smrg func_arith $current - $age + 1 9389d5c3dbf1Smrg fi 9390d5c3dbf1Smrg major=$func_arith_result 9391d5c3dbf1Smrg 9392d5c3dbf1Smrg case $version_type in 9393d5c3dbf1Smrg nonstopux) verstring_prefix=nonstopux ;; 9394d5c3dbf1Smrg *) verstring_prefix=sgi ;; 9395d5c3dbf1Smrg esac 9396949d0342Smrg verstring=$verstring_prefix$major.$revision 9397d5c3dbf1Smrg 9398d5c3dbf1Smrg # Add in all the interfaces that we are compatible with. 9399d5c3dbf1Smrg loop=$revision 9400949d0342Smrg while test 0 -ne "$loop"; do 9401d5c3dbf1Smrg func_arith $revision - $loop 9402d5c3dbf1Smrg iface=$func_arith_result 9403d5c3dbf1Smrg func_arith $loop - 1 9404d5c3dbf1Smrg loop=$func_arith_result 9405949d0342Smrg verstring=$verstring_prefix$major.$iface:$verstring 9406d5c3dbf1Smrg done 9407d5c3dbf1Smrg 9408949d0342Smrg # Before this point, $major must not contain '.'. 9409d5c3dbf1Smrg major=.$major 9410949d0342Smrg versuffix=$major.$revision 9411d5c3dbf1Smrg ;; 9412d5c3dbf1Smrg 9413cdbfa18aSmrg linux) # correct to gnu/linux during the next big refactor 9414d5c3dbf1Smrg func_arith $current - $age 9415d5c3dbf1Smrg major=.$func_arith_result 9416949d0342Smrg versuffix=$major.$age.$revision 9417d5c3dbf1Smrg ;; 9418d5c3dbf1Smrg 9419d5c3dbf1Smrg osf) 9420d5c3dbf1Smrg func_arith $current - $age 9421d5c3dbf1Smrg major=.$func_arith_result 9422949d0342Smrg versuffix=.$current.$age.$revision 9423949d0342Smrg verstring=$current.$age.$revision 9424d5c3dbf1Smrg 9425d5c3dbf1Smrg # Add in all the interfaces that we are compatible with. 9426d5c3dbf1Smrg loop=$age 9427949d0342Smrg while test 0 -ne "$loop"; do 9428d5c3dbf1Smrg func_arith $current - $loop 9429d5c3dbf1Smrg iface=$func_arith_result 9430d5c3dbf1Smrg func_arith $loop - 1 9431d5c3dbf1Smrg loop=$func_arith_result 9432949d0342Smrg verstring=$verstring:$iface.0 9433d5c3dbf1Smrg done 9434d5c3dbf1Smrg 9435d5c3dbf1Smrg # Make executables depend on our current version. 9436949d0342Smrg func_append verstring ":$current.0" 9437d5c3dbf1Smrg ;; 9438d5c3dbf1Smrg 9439d5c3dbf1Smrg qnx) 9440dc088bc7Smrg func_arith $current - $age 9441dc088bc7Smrg major=.$func_arith_result 9442dc088bc7Smrg versuffix=$major.$age.$revision 9443949d0342Smrg ;; 9444949d0342Smrg 9445949d0342Smrg sco) 9446949d0342Smrg major=.$current 9447949d0342Smrg versuffix=.$current 9448d5c3dbf1Smrg ;; 9449d5c3dbf1Smrg 9450d5c3dbf1Smrg sunos) 9451949d0342Smrg major=.$current 9452949d0342Smrg versuffix=.$current.$revision 9453d5c3dbf1Smrg ;; 9454d5c3dbf1Smrg 9455d5c3dbf1Smrg windows) 9456d5c3dbf1Smrg # Use '-' rather than '.', since we only want one 9457949d0342Smrg # extension on DOS 8.3 file systems. 9458d5c3dbf1Smrg func_arith $current - $age 9459d5c3dbf1Smrg major=$func_arith_result 9460949d0342Smrg versuffix=-$major 9461d5c3dbf1Smrg ;; 9462d5c3dbf1Smrg 9463d5c3dbf1Smrg *) 9464949d0342Smrg func_fatal_configuration "unknown library version type '$version_type'" 9465d5c3dbf1Smrg ;; 9466d5c3dbf1Smrg esac 9467d5c3dbf1Smrg 9468d5c3dbf1Smrg # Clear the version info if we defaulted, and they specified a release. 9469d5c3dbf1Smrg if test -z "$vinfo" && test -n "$release"; then 9470d5c3dbf1Smrg major= 9471d5c3dbf1Smrg case $version_type in 9472d5c3dbf1Smrg darwin) 9473d5c3dbf1Smrg # we can't check for "0.0" in archive_cmds due to quoting 9474d5c3dbf1Smrg # problems, so we reset it completely 9475d5c3dbf1Smrg verstring= 9476d5c3dbf1Smrg ;; 9477d5c3dbf1Smrg *) 9478949d0342Smrg verstring=0.0 9479d5c3dbf1Smrg ;; 9480d5c3dbf1Smrg esac 9481949d0342Smrg if test no = "$need_version"; then 9482d5c3dbf1Smrg versuffix= 9483d5c3dbf1Smrg else 9484949d0342Smrg versuffix=.0.0 9485d5c3dbf1Smrg fi 9486d5c3dbf1Smrg fi 9487d5c3dbf1Smrg 9488d5c3dbf1Smrg # Remove version info from name if versioning should be avoided 9489949d0342Smrg if test yes,no = "$avoid_version,$need_version"; then 9490d5c3dbf1Smrg major= 9491d5c3dbf1Smrg versuffix= 9492949d0342Smrg verstring= 9493d5c3dbf1Smrg fi 9494d5c3dbf1Smrg 9495d5c3dbf1Smrg # Check to see if the archive will have undefined symbols. 9496949d0342Smrg if test yes = "$allow_undefined"; then 9497949d0342Smrg if test unsupported = "$allow_undefined_flag"; then 9498949d0342Smrg if test yes = "$build_old_libs"; then 9499949d0342Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9500949d0342Smrg build_libtool_libs=no 9501949d0342Smrg else 9502949d0342Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9503949d0342Smrg fi 9504d5c3dbf1Smrg fi 9505d5c3dbf1Smrg else 9506d5c3dbf1Smrg # Don't allow undefined symbols. 9507949d0342Smrg allow_undefined_flag=$no_undefined_flag 9508d5c3dbf1Smrg fi 9509d5c3dbf1Smrg 9510d5c3dbf1Smrg fi 9511d5c3dbf1Smrg 9512949d0342Smrg func_generate_dlsyms "$libname" "$libname" : 9513cdbfa18aSmrg func_append libobjs " $symfileobj" 9514949d0342Smrg test " " = "$libobjs" && libobjs= 9515d5c3dbf1Smrg 9516949d0342Smrg if test relink != "$opt_mode"; then 9517d5c3dbf1Smrg # Remove our outputs, but don't remove object files since they 9518d5c3dbf1Smrg # may have been created when compiling PIC objects. 9519d5c3dbf1Smrg removelist= 9520d5c3dbf1Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9521d5c3dbf1Smrg for p in $tempremovelist; do 9522d5c3dbf1Smrg case $p in 9523d5c3dbf1Smrg *.$objext | *.gcno) 9524d5c3dbf1Smrg ;; 9525949d0342Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9526949d0342Smrg if test -n "$precious_files_regex"; then 9527d5c3dbf1Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9528d5c3dbf1Smrg then 9529d5c3dbf1Smrg continue 9530d5c3dbf1Smrg fi 9531d5c3dbf1Smrg fi 9532cdbfa18aSmrg func_append removelist " $p" 9533d5c3dbf1Smrg ;; 9534d5c3dbf1Smrg *) ;; 9535d5c3dbf1Smrg esac 9536d5c3dbf1Smrg done 9537d5c3dbf1Smrg test -n "$removelist" && \ 9538d5c3dbf1Smrg func_show_eval "${RM}r \$removelist" 9539d5c3dbf1Smrg fi 9540d5c3dbf1Smrg 9541d5c3dbf1Smrg # Now set the variables for building old libraries. 9542949d0342Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9543cdbfa18aSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9544d5c3dbf1Smrg 9545d5c3dbf1Smrg # Transform .lo files to .o files. 9546949d0342Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9547d5c3dbf1Smrg fi 9548d5c3dbf1Smrg 9549d5c3dbf1Smrg # Eliminate all temporary directories. 9550d5c3dbf1Smrg #for path in $notinst_path; do 9551d5c3dbf1Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9552d5c3dbf1Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9553d5c3dbf1Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9554d5c3dbf1Smrg #done 9555d5c3dbf1Smrg 9556d5c3dbf1Smrg if test -n "$xrpath"; then 9557d5c3dbf1Smrg # If the user specified any rpath flags, then add them. 9558d5c3dbf1Smrg temp_xrpath= 9559d5c3dbf1Smrg for libdir in $xrpath; do 9560cdbfa18aSmrg func_replace_sysroot "$libdir" 9561cdbfa18aSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9562d5c3dbf1Smrg case "$finalize_rpath " in 9563d5c3dbf1Smrg *" $libdir "*) ;; 9564cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 9565d5c3dbf1Smrg esac 9566d5c3dbf1Smrg done 9567949d0342Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9568d5c3dbf1Smrg dependency_libs="$temp_xrpath $dependency_libs" 9569d5c3dbf1Smrg fi 9570d5c3dbf1Smrg fi 9571d5c3dbf1Smrg 9572d5c3dbf1Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9573949d0342Smrg old_dlfiles=$dlfiles 9574d5c3dbf1Smrg dlfiles= 9575d5c3dbf1Smrg for lib in $old_dlfiles; do 9576d5c3dbf1Smrg case " $dlprefiles $dlfiles " in 9577d5c3dbf1Smrg *" $lib "*) ;; 9578cdbfa18aSmrg *) func_append dlfiles " $lib" ;; 9579d5c3dbf1Smrg esac 9580d5c3dbf1Smrg done 9581d5c3dbf1Smrg 9582d5c3dbf1Smrg # Make sure dlprefiles contains only unique files 9583949d0342Smrg old_dlprefiles=$dlprefiles 9584d5c3dbf1Smrg dlprefiles= 9585d5c3dbf1Smrg for lib in $old_dlprefiles; do 9586d5c3dbf1Smrg case "$dlprefiles " in 9587d5c3dbf1Smrg *" $lib "*) ;; 9588cdbfa18aSmrg *) func_append dlprefiles " $lib" ;; 9589d5c3dbf1Smrg esac 9590d5c3dbf1Smrg done 9591d5c3dbf1Smrg 9592949d0342Smrg if test yes = "$build_libtool_libs"; then 9593d5c3dbf1Smrg if test -n "$rpath"; then 9594d5c3dbf1Smrg case $host in 9595dc088bc7Smrg *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9596d5c3dbf1Smrg # these systems don't actually have a c library (as such)! 9597d5c3dbf1Smrg ;; 9598d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9599d5c3dbf1Smrg # Rhapsody C library is in the System framework 9600cdbfa18aSmrg func_append deplibs " System.ltframework" 9601d5c3dbf1Smrg ;; 9602d5c3dbf1Smrg *-*-netbsd*) 9603d5c3dbf1Smrg # Don't link with libc until the a.out ld.so is fixed. 9604d5c3dbf1Smrg ;; 9605949d0342Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9606d5c3dbf1Smrg # Do not include libc due to us having libc/libc_r. 9607d5c3dbf1Smrg ;; 9608d5c3dbf1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9609d5c3dbf1Smrg # Causes problems with __ctype 9610d5c3dbf1Smrg ;; 9611d5c3dbf1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9612d5c3dbf1Smrg # Compiler inserts libc in the correct place for threads to work 9613d5c3dbf1Smrg ;; 9614d5c3dbf1Smrg *) 9615d5c3dbf1Smrg # Add libc to deplibs on all other systems if necessary. 9616949d0342Smrg if test yes = "$build_libtool_need_lc"; then 9617cdbfa18aSmrg func_append deplibs " -lc" 9618d5c3dbf1Smrg fi 9619d5c3dbf1Smrg ;; 9620d5c3dbf1Smrg esac 9621d5c3dbf1Smrg fi 9622d5c3dbf1Smrg 9623d5c3dbf1Smrg # Transform deplibs into only deplibs that can be linked in shared. 9624d5c3dbf1Smrg name_save=$name 9625d5c3dbf1Smrg libname_save=$libname 9626d5c3dbf1Smrg release_save=$release 9627d5c3dbf1Smrg versuffix_save=$versuffix 9628d5c3dbf1Smrg major_save=$major 9629d5c3dbf1Smrg # I'm not sure if I'm treating the release correctly. I think 9630d5c3dbf1Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9631d5c3dbf1Smrg # add it in twice. Is that correct? 9632949d0342Smrg release= 9633949d0342Smrg versuffix= 9634949d0342Smrg major= 9635d5c3dbf1Smrg newdeplibs= 9636d5c3dbf1Smrg droppeddeps=no 9637d5c3dbf1Smrg case $deplibs_check_method in 9638d5c3dbf1Smrg pass_all) 9639d5c3dbf1Smrg # Don't check for shared/static. Everything works. 9640d5c3dbf1Smrg # This might be a little naive. We might want to check 9641d5c3dbf1Smrg # whether the library exists or not. But this is on 9642d5c3dbf1Smrg # osf3 & osf4 and I'm not really sure... Just 9643d5c3dbf1Smrg # implementing what was already the behavior. 9644d5c3dbf1Smrg newdeplibs=$deplibs 9645d5c3dbf1Smrg ;; 9646d5c3dbf1Smrg file_magic*) 9647d5c3dbf1Smrg set dummy $deplibs_check_method; shift 9648d5c3dbf1Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9649d5c3dbf1Smrg for a_deplib in $deplibs; do 9650d5c3dbf1Smrg case $a_deplib in 9651d5c3dbf1Smrg -l*) 9652d5c3dbf1Smrg func_stripname -l '' "$a_deplib" 9653d5c3dbf1Smrg name=$func_stripname_result 9654949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9655d5c3dbf1Smrg case " $predeps $postdeps " in 9656d5c3dbf1Smrg *" $a_deplib "*) 9657cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9658949d0342Smrg a_deplib= 9659d5c3dbf1Smrg ;; 9660d5c3dbf1Smrg esac 9661d5c3dbf1Smrg fi 9662949d0342Smrg if test -n "$a_deplib"; then 9663d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9664cdbfa18aSmrg if test -n "$file_magic_glob"; then 9665cdbfa18aSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9666cdbfa18aSmrg else 9667cdbfa18aSmrg libnameglob=$libname 9668cdbfa18aSmrg fi 9669949d0342Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9670d5c3dbf1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9671949d0342Smrg if test yes = "$want_nocaseglob"; then 9672cdbfa18aSmrg shopt -s nocaseglob 9673cdbfa18aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9674cdbfa18aSmrg $nocaseglob 9675cdbfa18aSmrg else 9676cdbfa18aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9677cdbfa18aSmrg fi 9678d5c3dbf1Smrg for potent_lib in $potential_libs; do 9679d5c3dbf1Smrg # Follow soft links. 9680d5c3dbf1Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9681d5c3dbf1Smrg $GREP " -> " >/dev/null; then 9682d5c3dbf1Smrg continue 9683d5c3dbf1Smrg fi 9684d5c3dbf1Smrg # The statement above tries to avoid entering an 9685d5c3dbf1Smrg # endless loop below, in case of cyclic links. 9686d5c3dbf1Smrg # We might still enter an endless loop, since a link 9687d5c3dbf1Smrg # loop can be closed while we follow links, 9688d5c3dbf1Smrg # but so what? 9689949d0342Smrg potlib=$potent_lib 9690d5c3dbf1Smrg while test -h "$potlib" 2>/dev/null; do 9691949d0342Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9692d5c3dbf1Smrg case $potliblink in 9693949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9694949d0342Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9695d5c3dbf1Smrg esac 9696d5c3dbf1Smrg done 9697d5c3dbf1Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9698d5c3dbf1Smrg $SED -e 10q | 9699d5c3dbf1Smrg $EGREP "$file_magic_regex" > /dev/null; then 9700cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9701949d0342Smrg a_deplib= 9702d5c3dbf1Smrg break 2 9703d5c3dbf1Smrg fi 9704d5c3dbf1Smrg done 9705d5c3dbf1Smrg done 9706d5c3dbf1Smrg fi 9707949d0342Smrg if test -n "$a_deplib"; then 9708d5c3dbf1Smrg droppeddeps=yes 9709dc088bc7Smrg func_warning "Linker path does not have real file for library $a_deplib." 9710dc088bc7Smrg func_warning "I have the capability to make that library automatically link in when" 9711dc088bc7Smrg func_warning "you link to this library. But I can only do this if you have a" 9712dc088bc7Smrg func_warning "shared version of the library, which you do not appear to have" 9713dc088bc7Smrg func_warning "because I did check the linker path looking for a file starting" 9714949d0342Smrg if test -z "$potlib"; then 9715dc088bc7Smrg func_warning "with $libname but no candidates were found. (...for file magic test)" 9716d5c3dbf1Smrg else 9717dc088bc7Smrg func_warning "with $libname and none of the candidates passed a file format test" 9718dc088bc7Smrg func_warning "using a file magic. Last file checked: $potlib" 9719d5c3dbf1Smrg fi 9720d5c3dbf1Smrg fi 9721d5c3dbf1Smrg ;; 9722d5c3dbf1Smrg *) 9723d5c3dbf1Smrg # Add a -L argument. 9724cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9725d5c3dbf1Smrg ;; 9726d5c3dbf1Smrg esac 9727d5c3dbf1Smrg done # Gone through all deplibs. 9728d5c3dbf1Smrg ;; 9729d5c3dbf1Smrg match_pattern*) 9730d5c3dbf1Smrg set dummy $deplibs_check_method; shift 9731d5c3dbf1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9732d5c3dbf1Smrg for a_deplib in $deplibs; do 9733d5c3dbf1Smrg case $a_deplib in 9734d5c3dbf1Smrg -l*) 9735d5c3dbf1Smrg func_stripname -l '' "$a_deplib" 9736d5c3dbf1Smrg name=$func_stripname_result 9737949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9738d5c3dbf1Smrg case " $predeps $postdeps " in 9739d5c3dbf1Smrg *" $a_deplib "*) 9740cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9741949d0342Smrg a_deplib= 9742d5c3dbf1Smrg ;; 9743d5c3dbf1Smrg esac 9744d5c3dbf1Smrg fi 9745949d0342Smrg if test -n "$a_deplib"; then 9746d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9747d5c3dbf1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9748d5c3dbf1Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9749d5c3dbf1Smrg for potent_lib in $potential_libs; do 9750949d0342Smrg potlib=$potent_lib # see symlink-check above in file_magic test 9751d5c3dbf1Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9752d5c3dbf1Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9753cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9754949d0342Smrg a_deplib= 9755d5c3dbf1Smrg break 2 9756d5c3dbf1Smrg fi 9757d5c3dbf1Smrg done 9758d5c3dbf1Smrg done 9759d5c3dbf1Smrg fi 9760949d0342Smrg if test -n "$a_deplib"; then 9761d5c3dbf1Smrg droppeddeps=yes 9762dc088bc7Smrg func_warning "Linker path does not have real file for library $a_deplib." 9763dc088bc7Smrg func_warning "I have the capability to make that library automatically link in when" 9764dc088bc7Smrg func_warning "you link to this library. But I can only do this if you have a" 9765dc088bc7Smrg func_warning "shared version of the library, which you do not appear to have" 9766dc088bc7Smrg func_warning "because I did check the linker path looking for a file starting" 9767949d0342Smrg if test -z "$potlib"; then 9768dc088bc7Smrg func_warning "with $libname but no candidates were found. (...for regex pattern test)" 9769d5c3dbf1Smrg else 9770dc088bc7Smrg func_warning "with $libname and none of the candidates passed a file format test" 9771dc088bc7Smrg func_warning "using a regex pattern. Last file checked: $potlib" 9772d5c3dbf1Smrg fi 9773d5c3dbf1Smrg fi 9774d5c3dbf1Smrg ;; 9775d5c3dbf1Smrg *) 9776d5c3dbf1Smrg # Add a -L argument. 9777cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9778d5c3dbf1Smrg ;; 9779d5c3dbf1Smrg esac 9780d5c3dbf1Smrg done # Gone through all deplibs. 9781d5c3dbf1Smrg ;; 9782d5c3dbf1Smrg none | unknown | *) 9783949d0342Smrg newdeplibs= 9784d5c3dbf1Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9785949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9786949d0342Smrg for i in $predeps $postdeps; do 9787d5c3dbf1Smrg # can't use Xsed below, because $i might contain '/' 9788949d0342Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9789d5c3dbf1Smrg done 9790d5c3dbf1Smrg fi 9791d5c3dbf1Smrg case $tmp_deplibs in 9792d5c3dbf1Smrg *[!\ \ ]*) 9793d5c3dbf1Smrg echo 9794949d0342Smrg if test none = "$deplibs_check_method"; then 9795dc088bc7Smrg func_warning "Inter-library dependencies are not supported in this platform." 9796d5c3dbf1Smrg else 9797dc088bc7Smrg func_warning "Inter-library dependencies are not known to be supported." 9798d5c3dbf1Smrg fi 9799dc088bc7Smrg func_warning "All declared inter-library dependencies are being dropped." 9800d5c3dbf1Smrg droppeddeps=yes 9801d5c3dbf1Smrg ;; 9802d5c3dbf1Smrg esac 9803d5c3dbf1Smrg ;; 9804d5c3dbf1Smrg esac 9805d5c3dbf1Smrg versuffix=$versuffix_save 9806d5c3dbf1Smrg major=$major_save 9807d5c3dbf1Smrg release=$release_save 9808d5c3dbf1Smrg libname=$libname_save 9809d5c3dbf1Smrg name=$name_save 9810d5c3dbf1Smrg 9811d5c3dbf1Smrg case $host in 9812d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9813d5c3dbf1Smrg # On Rhapsody replace the C library with the System framework 9814d5c3dbf1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9815d5c3dbf1Smrg ;; 9816d5c3dbf1Smrg esac 9817d5c3dbf1Smrg 9818949d0342Smrg if test yes = "$droppeddeps"; then 9819949d0342Smrg if test yes = "$module"; then 9820dc088bc7Smrg func_warning "libtool could not satisfy all declared inter-library" 9821dc088bc7Smrg func_warning "dependencies of module $libname. Therefore, libtool will create" 9822dc088bc7Smrg func_warning "a static module, that should work as long as the dlopening" 9823dc088bc7Smrg func_warning "application is linked with the -dlopen flag." 9824d5c3dbf1Smrg if test -z "$global_symbol_pipe"; then 9825dc088bc7Smrg func_warning "However, this would only work if libtool was able to extract symbol" 9826dc088bc7Smrg func_warning "lists from a program, using 'nm' or equivalent, but libtool could" 9827dc088bc7Smrg func_warning "not find such a program. So, this module is probably useless." 9828dc088bc7Smrg func_warning "'nm' from GNU binutils and a full rebuild may help." 9829d5c3dbf1Smrg fi 9830949d0342Smrg if test no = "$build_old_libs"; then 9831949d0342Smrg oldlibs=$output_objdir/$libname.$libext 9832d5c3dbf1Smrg build_libtool_libs=module 9833d5c3dbf1Smrg build_old_libs=yes 9834d5c3dbf1Smrg else 9835d5c3dbf1Smrg build_libtool_libs=no 9836d5c3dbf1Smrg fi 9837d5c3dbf1Smrg else 9838d5c3dbf1Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9839d5c3dbf1Smrg echo "*** automatically added whenever a program is linked with this library" 9840d5c3dbf1Smrg echo "*** or is declared to -dlopen it." 9841d5c3dbf1Smrg 9842949d0342Smrg if test no = "$allow_undefined"; then 9843d5c3dbf1Smrg echo 9844d5c3dbf1Smrg echo "*** Since this library must not contain undefined symbols," 9845d5c3dbf1Smrg echo "*** because either the platform does not support them or" 9846d5c3dbf1Smrg echo "*** it was explicitly requested with -no-undefined," 9847d5c3dbf1Smrg echo "*** libtool will only create a static version of it." 9848949d0342Smrg if test no = "$build_old_libs"; then 9849949d0342Smrg oldlibs=$output_objdir/$libname.$libext 9850d5c3dbf1Smrg build_libtool_libs=module 9851d5c3dbf1Smrg build_old_libs=yes 9852d5c3dbf1Smrg else 9853d5c3dbf1Smrg build_libtool_libs=no 9854d5c3dbf1Smrg fi 9855d5c3dbf1Smrg fi 9856d5c3dbf1Smrg fi 9857d5c3dbf1Smrg fi 9858d5c3dbf1Smrg # Done checking deplibs! 9859d5c3dbf1Smrg deplibs=$newdeplibs 9860d5c3dbf1Smrg fi 9861d5c3dbf1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9862d5c3dbf1Smrg case $host in 9863d5c3dbf1Smrg *-*-darwin*) 9864d5c3dbf1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9865d5c3dbf1Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9866d5c3dbf1Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9867d5c3dbf1Smrg ;; 9868d5c3dbf1Smrg esac 9869d5c3dbf1Smrg 9870d5c3dbf1Smrg # move library search paths that coincide with paths to not yet 9871d5c3dbf1Smrg # installed libraries to the beginning of the library search list 9872d5c3dbf1Smrg new_libs= 9873d5c3dbf1Smrg for path in $notinst_path; do 9874d5c3dbf1Smrg case " $new_libs " in 9875d5c3dbf1Smrg *" -L$path/$objdir "*) ;; 9876d5c3dbf1Smrg *) 9877d5c3dbf1Smrg case " $deplibs " in 9878d5c3dbf1Smrg *" -L$path/$objdir "*) 9879cdbfa18aSmrg func_append new_libs " -L$path/$objdir" ;; 9880d5c3dbf1Smrg esac 9881d5c3dbf1Smrg ;; 9882d5c3dbf1Smrg esac 9883d5c3dbf1Smrg done 9884d5c3dbf1Smrg for deplib in $deplibs; do 9885d5c3dbf1Smrg case $deplib in 9886d5c3dbf1Smrg -L*) 9887d5c3dbf1Smrg case " $new_libs " in 9888d5c3dbf1Smrg *" $deplib "*) ;; 9889cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 9890d5c3dbf1Smrg esac 9891d5c3dbf1Smrg ;; 9892cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 9893d5c3dbf1Smrg esac 9894d5c3dbf1Smrg done 9895949d0342Smrg deplibs=$new_libs 9896d5c3dbf1Smrg 9897d5c3dbf1Smrg # All the library-specific variables (install_libdir is set above). 9898d5c3dbf1Smrg library_names= 9899d5c3dbf1Smrg old_library= 9900d5c3dbf1Smrg dlname= 9901d5c3dbf1Smrg 9902d5c3dbf1Smrg # Test again, we may have decided not to build it any more 9903949d0342Smrg if test yes = "$build_libtool_libs"; then 9904949d0342Smrg # Remove $wl instances when linking with ld. 9905cdbfa18aSmrg # FIXME: should test the right _cmds variable. 9906cdbfa18aSmrg case $archive_cmds in 9907cdbfa18aSmrg *\$LD\ *) wl= ;; 9908cdbfa18aSmrg esac 9909949d0342Smrg if test yes = "$hardcode_into_libs"; then 9910d5c3dbf1Smrg # Hardcode the library paths 9911d5c3dbf1Smrg hardcode_libdirs= 9912d5c3dbf1Smrg dep_rpath= 9913949d0342Smrg rpath=$finalize_rpath 9914949d0342Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9915d5c3dbf1Smrg for libdir in $rpath; do 9916d5c3dbf1Smrg if test -n "$hardcode_libdir_flag_spec"; then 9917d5c3dbf1Smrg if test -n "$hardcode_libdir_separator"; then 9918cdbfa18aSmrg func_replace_sysroot "$libdir" 9919cdbfa18aSmrg libdir=$func_replace_sysroot_result 9920d5c3dbf1Smrg if test -z "$hardcode_libdirs"; then 9921949d0342Smrg hardcode_libdirs=$libdir 9922d5c3dbf1Smrg else 9923d5c3dbf1Smrg # Just accumulate the unique libdirs. 9924d5c3dbf1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9925d5c3dbf1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9926d5c3dbf1Smrg ;; 9927d5c3dbf1Smrg *) 9928cdbfa18aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9929d5c3dbf1Smrg ;; 9930d5c3dbf1Smrg esac 9931d5c3dbf1Smrg fi 9932d5c3dbf1Smrg else 9933d5c3dbf1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9934cdbfa18aSmrg func_append dep_rpath " $flag" 9935d5c3dbf1Smrg fi 9936d5c3dbf1Smrg elif test -n "$runpath_var"; then 9937d5c3dbf1Smrg case "$perm_rpath " in 9938d5c3dbf1Smrg *" $libdir "*) ;; 9939cdbfa18aSmrg *) func_append perm_rpath " $libdir" ;; 9940d5c3dbf1Smrg esac 9941d5c3dbf1Smrg fi 9942d5c3dbf1Smrg done 9943d5c3dbf1Smrg # Substitute the hardcoded libdirs into the rpath. 9944d5c3dbf1Smrg if test -n "$hardcode_libdir_separator" && 9945d5c3dbf1Smrg test -n "$hardcode_libdirs"; then 9946949d0342Smrg libdir=$hardcode_libdirs 9947cdbfa18aSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9948d5c3dbf1Smrg fi 9949d5c3dbf1Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9950d5c3dbf1Smrg # We should set the runpath_var. 9951d5c3dbf1Smrg rpath= 9952d5c3dbf1Smrg for dir in $perm_rpath; do 9953cdbfa18aSmrg func_append rpath "$dir:" 9954d5c3dbf1Smrg done 9955d5c3dbf1Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9956d5c3dbf1Smrg fi 9957d5c3dbf1Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9958d5c3dbf1Smrg fi 99599f606849Smrg 9960949d0342Smrg shlibpath=$finalize_shlibpath 9961949d0342Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9962d5c3dbf1Smrg if test -n "$shlibpath"; then 9963d5c3dbf1Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9964d5c3dbf1Smrg fi 99659f606849Smrg 9966d5c3dbf1Smrg # Get the real and link names of the library. 9967d5c3dbf1Smrg eval shared_ext=\"$shrext_cmds\" 9968d5c3dbf1Smrg eval library_names=\"$library_names_spec\" 9969d5c3dbf1Smrg set dummy $library_names 9970d5c3dbf1Smrg shift 9971949d0342Smrg realname=$1 9972d5c3dbf1Smrg shift 99739f606849Smrg 9974d5c3dbf1Smrg if test -n "$soname_spec"; then 9975d5c3dbf1Smrg eval soname=\"$soname_spec\" 9976d5c3dbf1Smrg else 9977949d0342Smrg soname=$realname 9978d5c3dbf1Smrg fi 9979d5c3dbf1Smrg if test -z "$dlname"; then 9980d5c3dbf1Smrg dlname=$soname 9981d5c3dbf1Smrg fi 99829f606849Smrg 9983949d0342Smrg lib=$output_objdir/$realname 9984d5c3dbf1Smrg linknames= 9985d5c3dbf1Smrg for link 9986d5c3dbf1Smrg do 9987cdbfa18aSmrg func_append linknames " $link" 9988d5c3dbf1Smrg done 99899f606849Smrg 9990d5c3dbf1Smrg # Use standard objects if they are pic 9991d5c3dbf1Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9992d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 99939f606849Smrg 9994d5c3dbf1Smrg delfiles= 9995d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9996d5c3dbf1Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9997949d0342Smrg export_symbols=$output_objdir/$libname.uexp 9998cdbfa18aSmrg func_append delfiles " $export_symbols" 9999d5c3dbf1Smrg fi 100009f606849Smrg 10001d5c3dbf1Smrg orig_export_symbols= 10002d5c3dbf1Smrg case $host_os in 10003dc088bc7Smrg cygwin* | mingw* | windows* | cegcc*) 10004d5c3dbf1Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 10005d5c3dbf1Smrg # exporting using user supplied symfile 10006949d0342Smrg func_dll_def_p "$export_symbols" || { 10007d5c3dbf1Smrg # and it's NOT already a .def file. Must figure out 10008d5c3dbf1Smrg # which of the given symbols are data symbols and tag 10009d5c3dbf1Smrg # them as such. So, trigger use of export_symbols_cmds. 10010d5c3dbf1Smrg # export_symbols gets reassigned inside the "prepare 10011d5c3dbf1Smrg # the list of exported symbols" if statement, so the 10012d5c3dbf1Smrg # include_expsyms logic still works. 10013949d0342Smrg orig_export_symbols=$export_symbols 10014d5c3dbf1Smrg export_symbols= 10015d5c3dbf1Smrg always_export_symbols=yes 10016949d0342Smrg } 10017d5c3dbf1Smrg fi 10018d5c3dbf1Smrg ;; 10019d5c3dbf1Smrg esac 100209f606849Smrg 10021d5c3dbf1Smrg # Prepare the list of exported symbols 10022d5c3dbf1Smrg if test -z "$export_symbols"; then 10023949d0342Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 10024949d0342Smrg func_verbose "generating symbol list for '$libname.la'" 10025949d0342Smrg export_symbols=$output_objdir/$libname.exp 10026d5c3dbf1Smrg $opt_dry_run || $RM $export_symbols 10027d5c3dbf1Smrg cmds=$export_symbols_cmds 10028949d0342Smrg save_ifs=$IFS; IFS='~' 10029cdbfa18aSmrg for cmd1 in $cmds; do 10030949d0342Smrg IFS=$save_ifs 10031cdbfa18aSmrg # Take the normal branch if the nm_file_list_spec branch 10032cdbfa18aSmrg # doesn't work or if tool conversion is not needed. 10033cdbfa18aSmrg case $nm_file_list_spec~$to_tool_file_cmd in 10034cdbfa18aSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 10035cdbfa18aSmrg try_normal_branch=yes 10036cdbfa18aSmrg eval cmd=\"$cmd1\" 10037cdbfa18aSmrg func_len " $cmd" 10038cdbfa18aSmrg len=$func_len_result 10039cdbfa18aSmrg ;; 10040cdbfa18aSmrg *) 10041cdbfa18aSmrg try_normal_branch=no 10042cdbfa18aSmrg ;; 10043cdbfa18aSmrg esac 10044949d0342Smrg if test yes = "$try_normal_branch" \ 10045cdbfa18aSmrg && { test "$len" -lt "$max_cmd_len" \ 10046cdbfa18aSmrg || test "$max_cmd_len" -le -1; } 10047cdbfa18aSmrg then 10048cdbfa18aSmrg func_show_eval "$cmd" 'exit $?' 10049cdbfa18aSmrg skipped_export=false 10050cdbfa18aSmrg elif test -n "$nm_file_list_spec"; then 10051cdbfa18aSmrg func_basename "$output" 10052cdbfa18aSmrg output_la=$func_basename_result 10053cdbfa18aSmrg save_libobjs=$libobjs 10054cdbfa18aSmrg save_output=$output 10055949d0342Smrg output=$output_objdir/$output_la.nm 10056cdbfa18aSmrg func_to_tool_file "$output" 10057cdbfa18aSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 10058cdbfa18aSmrg func_append delfiles " $output" 10059cdbfa18aSmrg func_verbose "creating $NM input file list: $output" 10060cdbfa18aSmrg for obj in $save_libobjs; do 10061cdbfa18aSmrg func_to_tool_file "$obj" 10062cdbfa18aSmrg $ECHO "$func_to_tool_file_result" 10063cdbfa18aSmrg done > "$output" 10064cdbfa18aSmrg eval cmd=\"$cmd1\" 10065d5c3dbf1Smrg func_show_eval "$cmd" 'exit $?' 10066cdbfa18aSmrg output=$save_output 10067cdbfa18aSmrg libobjs=$save_libobjs 10068d5c3dbf1Smrg skipped_export=false 10069d5c3dbf1Smrg else 10070d5c3dbf1Smrg # The command line is too long to execute in one step. 10071d5c3dbf1Smrg func_verbose "using reloadable object file for export list..." 10072d5c3dbf1Smrg skipped_export=: 10073d5c3dbf1Smrg # Break out early, otherwise skipped_export may be 10074d5c3dbf1Smrg # set to false by a later but shorter cmd. 10075d5c3dbf1Smrg break 10076d5c3dbf1Smrg fi 10077d5c3dbf1Smrg done 10078949d0342Smrg IFS=$save_ifs 10079949d0342Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 10080d5c3dbf1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10081d5c3dbf1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10082d5c3dbf1Smrg fi 10083d5c3dbf1Smrg fi 10084d5c3dbf1Smrg fi 100859f606849Smrg 10086d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10087949d0342Smrg tmp_export_symbols=$export_symbols 10088949d0342Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10089d5c3dbf1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10090d5c3dbf1Smrg fi 100919f606849Smrg 10092949d0342Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10093d5c3dbf1Smrg # The given exports_symbols file has to be filtered, so filter it. 10094949d0342Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10095d5c3dbf1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10096949d0342Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10097d5c3dbf1Smrg # though. Also, the filter scales superlinearly with the number of 10098d5c3dbf1Smrg # global variables. join(1) would be nice here, but unfortunately 10099d5c3dbf1Smrg # isn't a blessed tool. 10100d5c3dbf1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10101cdbfa18aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10102d5c3dbf1Smrg export_symbols=$output_objdir/$libname.def 10103d5c3dbf1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 101049f606849Smrg fi 101059f606849Smrg 10106d5c3dbf1Smrg tmp_deplibs= 10107d5c3dbf1Smrg for test_deplib in $deplibs; do 10108d5c3dbf1Smrg case " $convenience " in 10109d5c3dbf1Smrg *" $test_deplib "*) ;; 10110d5c3dbf1Smrg *) 10111cdbfa18aSmrg func_append tmp_deplibs " $test_deplib" 10112d5c3dbf1Smrg ;; 10113d5c3dbf1Smrg esac 10114d5c3dbf1Smrg done 10115949d0342Smrg deplibs=$tmp_deplibs 101169f606849Smrg 10117d5c3dbf1Smrg if test -n "$convenience"; then 10118d5c3dbf1Smrg if test -n "$whole_archive_flag_spec" && 10119949d0342Smrg test yes = "$compiler_needs_object" && 10120d5c3dbf1Smrg test -z "$libobjs"; then 10121d5c3dbf1Smrg # extract the archives, so we have objects to list. 10122d5c3dbf1Smrg # TODO: could optimize this to just extract one archive. 10123d5c3dbf1Smrg whole_archive_flag_spec= 10124d5c3dbf1Smrg fi 10125d5c3dbf1Smrg if test -n "$whole_archive_flag_spec"; then 10126d5c3dbf1Smrg save_libobjs=$libobjs 10127d5c3dbf1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10128d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 10129d5c3dbf1Smrg else 10130949d0342Smrg gentop=$output_objdir/${outputname}x 10131cdbfa18aSmrg func_append generated " $gentop" 101329f606849Smrg 10133d5c3dbf1Smrg func_extract_archives $gentop $convenience 10134cdbfa18aSmrg func_append libobjs " $func_extract_archives_result" 10135d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 10136d5c3dbf1Smrg fi 10137d5c3dbf1Smrg fi 101389f606849Smrg 10139949d0342Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10140d5c3dbf1Smrg eval flag=\"$thread_safe_flag_spec\" 10141cdbfa18aSmrg func_append linker_flags " $flag" 10142d5c3dbf1Smrg fi 101439f606849Smrg 10144d5c3dbf1Smrg # Make a backup of the uninstalled library when relinking 10145949d0342Smrg if test relink = "$opt_mode"; then 10146d5c3dbf1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 101479f606849Smrg fi 101489f606849Smrg 10149d5c3dbf1Smrg # Do each of the archive commands. 10150949d0342Smrg if test yes = "$module" && test -n "$module_cmds"; then 10151d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10152d5c3dbf1Smrg eval test_cmds=\"$module_expsym_cmds\" 10153d5c3dbf1Smrg cmds=$module_expsym_cmds 10154d5c3dbf1Smrg else 10155d5c3dbf1Smrg eval test_cmds=\"$module_cmds\" 10156d5c3dbf1Smrg cmds=$module_cmds 10157d5c3dbf1Smrg fi 10158d5c3dbf1Smrg else 10159d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10160d5c3dbf1Smrg eval test_cmds=\"$archive_expsym_cmds\" 10161d5c3dbf1Smrg cmds=$archive_expsym_cmds 10162d5c3dbf1Smrg else 10163d5c3dbf1Smrg eval test_cmds=\"$archive_cmds\" 10164d5c3dbf1Smrg cmds=$archive_cmds 10165d5c3dbf1Smrg fi 101669f606849Smrg fi 101679f606849Smrg 10168949d0342Smrg if test : != "$skipped_export" && 10169d5c3dbf1Smrg func_len " $test_cmds" && 10170d5c3dbf1Smrg len=$func_len_result && 10171d5c3dbf1Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10172d5c3dbf1Smrg : 10173d5c3dbf1Smrg else 10174d5c3dbf1Smrg # The command line is too long to link in one step, link piecewise 10175d5c3dbf1Smrg # or, if using GNU ld and skipped_export is not :, use a linker 10176d5c3dbf1Smrg # script. 101779f606849Smrg 10178d5c3dbf1Smrg # Save the value of $output and $libobjs because we want to 10179d5c3dbf1Smrg # use them later. If we have whole_archive_flag_spec, we 10180d5c3dbf1Smrg # want to use save_libobjs as it was before 10181d5c3dbf1Smrg # whole_archive_flag_spec was expanded, because we can't 10182d5c3dbf1Smrg # assume the linker understands whole_archive_flag_spec. 10183d5c3dbf1Smrg # This may have to be revisited, in case too many 10184d5c3dbf1Smrg # convenience libraries get linked in and end up exceeding 10185d5c3dbf1Smrg # the spec. 10186d5c3dbf1Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10187d5c3dbf1Smrg save_libobjs=$libobjs 10188d5c3dbf1Smrg fi 10189d5c3dbf1Smrg save_output=$output 10190d5c3dbf1Smrg func_basename "$output" 10191d5c3dbf1Smrg output_la=$func_basename_result 101929f606849Smrg 10193d5c3dbf1Smrg # Clear the reloadable object creation command queue and 10194d5c3dbf1Smrg # initialize k to one. 10195d5c3dbf1Smrg test_cmds= 10196d5c3dbf1Smrg concat_cmds= 10197d5c3dbf1Smrg objlist= 10198d5c3dbf1Smrg last_robj= 10199d5c3dbf1Smrg k=1 102009f606849Smrg 10201dc088bc7Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10202949d0342Smrg output=$output_objdir/$output_la.lnk 10203d5c3dbf1Smrg func_verbose "creating linker input file list: $output" 10204d5c3dbf1Smrg : > $output 10205d5c3dbf1Smrg set x $save_libobjs 10206d5c3dbf1Smrg shift 10207d5c3dbf1Smrg firstobj= 10208949d0342Smrg if test yes = "$compiler_needs_object"; then 10209d5c3dbf1Smrg firstobj="$1 " 10210d5c3dbf1Smrg shift 10211d5c3dbf1Smrg fi 10212d5c3dbf1Smrg for obj 10213d5c3dbf1Smrg do 10214cdbfa18aSmrg func_to_tool_file "$obj" 10215cdbfa18aSmrg $ECHO "$func_to_tool_file_result" >> $output 10216d5c3dbf1Smrg done 10217cdbfa18aSmrg func_append delfiles " $output" 10218cdbfa18aSmrg func_to_tool_file "$output" 10219cdbfa18aSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10220dc088bc7Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10221dc088bc7Smrg output=$output_objdir/$output_la.lnkscript 10222dc088bc7Smrg func_verbose "creating GNU ld script: $output" 10223dc088bc7Smrg echo 'INPUT (' > $output 10224dc088bc7Smrg for obj in $save_libobjs 10225dc088bc7Smrg do 10226dc088bc7Smrg func_to_tool_file "$obj" 10227dc088bc7Smrg $ECHO "$func_to_tool_file_result" >> $output 10228dc088bc7Smrg done 10229dc088bc7Smrg echo ')' >> $output 10230dc088bc7Smrg func_append delfiles " $output" 10231dc088bc7Smrg func_to_tool_file "$output" 10232dc088bc7Smrg output=$func_to_tool_file_result 10233d5c3dbf1Smrg else 10234d5c3dbf1Smrg if test -n "$save_libobjs"; then 10235d5c3dbf1Smrg func_verbose "creating reloadable object files..." 10236949d0342Smrg output=$output_objdir/$output_la-$k.$objext 10237d5c3dbf1Smrg eval test_cmds=\"$reload_cmds\" 10238d5c3dbf1Smrg func_len " $test_cmds" 10239d5c3dbf1Smrg len0=$func_len_result 10240d5c3dbf1Smrg len=$len0 10241d5c3dbf1Smrg 10242d5c3dbf1Smrg # Loop over the list of objects to be linked. 10243d5c3dbf1Smrg for obj in $save_libobjs 10244d5c3dbf1Smrg do 10245d5c3dbf1Smrg func_len " $obj" 10246d5c3dbf1Smrg func_arith $len + $func_len_result 10247d5c3dbf1Smrg len=$func_arith_result 10248949d0342Smrg if test -z "$objlist" || 10249d5c3dbf1Smrg test "$len" -lt "$max_cmd_len"; then 10250d5c3dbf1Smrg func_append objlist " $obj" 10251d5c3dbf1Smrg else 10252d5c3dbf1Smrg # The command $test_cmds is almost too long, add a 10253d5c3dbf1Smrg # command to the queue. 10254949d0342Smrg if test 1 -eq "$k"; then 10255d5c3dbf1Smrg # The first file doesn't have a previous command to add. 10256d5c3dbf1Smrg reload_objs=$objlist 10257d5c3dbf1Smrg eval concat_cmds=\"$reload_cmds\" 10258d5c3dbf1Smrg else 10259d5c3dbf1Smrg # All subsequent reloadable object files will link in 10260d5c3dbf1Smrg # the last one created. 10261d5c3dbf1Smrg reload_objs="$objlist $last_robj" 10262d5c3dbf1Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10263d5c3dbf1Smrg fi 10264949d0342Smrg last_robj=$output_objdir/$output_la-$k.$objext 10265d5c3dbf1Smrg func_arith $k + 1 10266d5c3dbf1Smrg k=$func_arith_result 10267949d0342Smrg output=$output_objdir/$output_la-$k.$objext 10268d5c3dbf1Smrg objlist=" $obj" 10269d5c3dbf1Smrg func_len " $last_robj" 10270d5c3dbf1Smrg func_arith $len0 + $func_len_result 10271d5c3dbf1Smrg len=$func_arith_result 10272d5c3dbf1Smrg fi 10273d5c3dbf1Smrg done 10274d5c3dbf1Smrg # Handle the remaining objects by creating one last 10275d5c3dbf1Smrg # reloadable object file. All subsequent reloadable object 10276d5c3dbf1Smrg # files will link in the last one created. 10277d5c3dbf1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10278d5c3dbf1Smrg reload_objs="$objlist $last_robj" 10279949d0342Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10280d5c3dbf1Smrg if test -n "$last_robj"; then 10281949d0342Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10282d5c3dbf1Smrg fi 10283cdbfa18aSmrg func_append delfiles " $output" 10284d5c3dbf1Smrg 10285d5c3dbf1Smrg else 10286d5c3dbf1Smrg output= 10287d5c3dbf1Smrg fi 102889f606849Smrg 10289949d0342Smrg ${skipped_export-false} && { 10290949d0342Smrg func_verbose "generating symbol list for '$libname.la'" 10291949d0342Smrg export_symbols=$output_objdir/$libname.exp 10292d5c3dbf1Smrg $opt_dry_run || $RM $export_symbols 10293d5c3dbf1Smrg libobjs=$output 10294d5c3dbf1Smrg # Append the command to create the export file. 10295d5c3dbf1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10296d5c3dbf1Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10297d5c3dbf1Smrg if test -n "$last_robj"; then 10298d5c3dbf1Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10299d5c3dbf1Smrg fi 10300949d0342Smrg } 103019f606849Smrg 10302d5c3dbf1Smrg test -n "$save_libobjs" && 10303d5c3dbf1Smrg func_verbose "creating a temporary reloadable object file: $output" 103049f606849Smrg 10305d5c3dbf1Smrg # Loop through the commands generated above and execute them. 10306949d0342Smrg save_ifs=$IFS; IFS='~' 10307d5c3dbf1Smrg for cmd in $concat_cmds; do 10308949d0342Smrg IFS=$save_ifs 10309949d0342Smrg $opt_quiet || { 10310949d0342Smrg func_quote_arg expand,pretty "$cmd" 10311949d0342Smrg eval "func_echo $func_quote_arg_result" 10312d5c3dbf1Smrg } 10313d5c3dbf1Smrg $opt_dry_run || eval "$cmd" || { 10314d5c3dbf1Smrg lt_exit=$? 10315d5c3dbf1Smrg 10316d5c3dbf1Smrg # Restore the uninstalled library and exit 10317949d0342Smrg if test relink = "$opt_mode"; then 10318d5c3dbf1Smrg ( cd "$output_objdir" && \ 10319d5c3dbf1Smrg $RM "${realname}T" && \ 10320d5c3dbf1Smrg $MV "${realname}U" "$realname" ) 10321d5c3dbf1Smrg fi 103229f606849Smrg 10323d5c3dbf1Smrg exit $lt_exit 10324d5c3dbf1Smrg } 10325d5c3dbf1Smrg done 10326949d0342Smrg IFS=$save_ifs 103279f606849Smrg 10328d5c3dbf1Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10329d5c3dbf1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10330d5c3dbf1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 103319f606849Smrg fi 103329f606849Smrg fi 103339f606849Smrg 10334949d0342Smrg ${skipped_export-false} && { 10335d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10336949d0342Smrg tmp_export_symbols=$export_symbols 10337949d0342Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10338d5c3dbf1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10339d5c3dbf1Smrg fi 103409f606849Smrg 10341d5c3dbf1Smrg if test -n "$orig_export_symbols"; then 10342d5c3dbf1Smrg # The given exports_symbols file has to be filtered, so filter it. 10343949d0342Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10344d5c3dbf1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10345949d0342Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10346d5c3dbf1Smrg # though. Also, the filter scales superlinearly with the number of 10347d5c3dbf1Smrg # global variables. join(1) would be nice here, but unfortunately 10348d5c3dbf1Smrg # isn't a blessed tool. 10349d5c3dbf1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10350cdbfa18aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10351d5c3dbf1Smrg export_symbols=$output_objdir/$libname.def 10352d5c3dbf1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10353d5c3dbf1Smrg fi 10354949d0342Smrg } 103559f606849Smrg 10356d5c3dbf1Smrg libobjs=$output 10357d5c3dbf1Smrg # Restore the value of output. 10358d5c3dbf1Smrg output=$save_output 103599f606849Smrg 10360d5c3dbf1Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10361d5c3dbf1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10362d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 10363d5c3dbf1Smrg fi 10364d5c3dbf1Smrg # Expand the library linking commands again to reset the 10365d5c3dbf1Smrg # value of $libobjs for piecewise linking. 10366d5c3dbf1Smrg 10367d5c3dbf1Smrg # Do each of the archive commands. 10368949d0342Smrg if test yes = "$module" && test -n "$module_cmds"; then 10369d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10370d5c3dbf1Smrg cmds=$module_expsym_cmds 103719f606849Smrg else 10372d5c3dbf1Smrg cmds=$module_cmds 103739f606849Smrg fi 103749f606849Smrg else 10375d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10376d5c3dbf1Smrg cmds=$archive_expsym_cmds 10377d5c3dbf1Smrg else 10378d5c3dbf1Smrg cmds=$archive_cmds 10379d5c3dbf1Smrg fi 103809f606849Smrg fi 103819f606849Smrg fi 103829f606849Smrg 10383d5c3dbf1Smrg if test -n "$delfiles"; then 10384d5c3dbf1Smrg # Append the command to remove temporary files to $cmds. 10385d5c3dbf1Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10386d5c3dbf1Smrg fi 103879f606849Smrg 10388d5c3dbf1Smrg # Add any objects from preloaded convenience libraries 10389d5c3dbf1Smrg if test -n "$dlprefiles"; then 10390949d0342Smrg gentop=$output_objdir/${outputname}x 10391cdbfa18aSmrg func_append generated " $gentop" 103929f606849Smrg 10393d5c3dbf1Smrg func_extract_archives $gentop $dlprefiles 10394cdbfa18aSmrg func_append libobjs " $func_extract_archives_result" 10395d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 103969f606849Smrg fi 103979f606849Smrg 10398949d0342Smrg save_ifs=$IFS; IFS='~' 10399d5c3dbf1Smrg for cmd in $cmds; do 10400949d0342Smrg IFS=$sp$nl 10401d5c3dbf1Smrg eval cmd=\"$cmd\" 10402949d0342Smrg IFS=$save_ifs 10403949d0342Smrg $opt_quiet || { 10404949d0342Smrg func_quote_arg expand,pretty "$cmd" 10405949d0342Smrg eval "func_echo $func_quote_arg_result" 10406d5c3dbf1Smrg } 10407d5c3dbf1Smrg $opt_dry_run || eval "$cmd" || { 10408d5c3dbf1Smrg lt_exit=$? 104099f606849Smrg 10410d5c3dbf1Smrg # Restore the uninstalled library and exit 10411949d0342Smrg if test relink = "$opt_mode"; then 10412d5c3dbf1Smrg ( cd "$output_objdir" && \ 10413d5c3dbf1Smrg $RM "${realname}T" && \ 10414d5c3dbf1Smrg $MV "${realname}U" "$realname" ) 104159f606849Smrg fi 104169f606849Smrg 10417d5c3dbf1Smrg exit $lt_exit 10418d5c3dbf1Smrg } 10419d5c3dbf1Smrg done 10420949d0342Smrg IFS=$save_ifs 104219f606849Smrg 10422d5c3dbf1Smrg # Restore the uninstalled library and exit 10423949d0342Smrg if test relink = "$opt_mode"; then 10424d5c3dbf1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 104259f606849Smrg 10426d5c3dbf1Smrg if test -n "$convenience"; then 10427d5c3dbf1Smrg if test -z "$whole_archive_flag_spec"; then 10428d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10429d5c3dbf1Smrg fi 10430d5c3dbf1Smrg fi 104319f606849Smrg 10432d5c3dbf1Smrg exit $EXIT_SUCCESS 10433d5c3dbf1Smrg fi 104349f606849Smrg 10435d5c3dbf1Smrg # Create links to the real library. 10436d5c3dbf1Smrg for linkname in $linknames; do 10437d5c3dbf1Smrg if test "$realname" != "$linkname"; then 10438d5c3dbf1Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10439d5c3dbf1Smrg fi 10440d5c3dbf1Smrg done 104419f606849Smrg 10442d5c3dbf1Smrg # If -module or -export-dynamic was specified, set the dlname. 10443949d0342Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10444d5c3dbf1Smrg # On all known operating systems, these are identical. 10445949d0342Smrg dlname=$soname 10446d5c3dbf1Smrg fi 10447d5c3dbf1Smrg fi 10448d5c3dbf1Smrg ;; 104499f606849Smrg 10450d5c3dbf1Smrg obj) 10451949d0342Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10452949d0342Smrg func_warning "'-dlopen' is ignored for objects" 10453d5c3dbf1Smrg fi 104549f606849Smrg 10455d5c3dbf1Smrg case " $deplibs" in 10456d5c3dbf1Smrg *\ -l* | *\ -L*) 10457949d0342Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10458d5c3dbf1Smrg esac 104599f606849Smrg 10460d5c3dbf1Smrg test -n "$rpath" && \ 10461949d0342Smrg func_warning "'-rpath' is ignored for objects" 104629f606849Smrg 10463d5c3dbf1Smrg test -n "$xrpath" && \ 10464949d0342Smrg func_warning "'-R' is ignored for objects" 10465d5c3dbf1Smrg 10466d5c3dbf1Smrg test -n "$vinfo" && \ 10467949d0342Smrg func_warning "'-version-info' is ignored for objects" 104689f606849Smrg 10469d5c3dbf1Smrg test -n "$release" && \ 10470949d0342Smrg func_warning "'-release' is ignored for objects" 104719f606849Smrg 10472d5c3dbf1Smrg case $output in 10473d5c3dbf1Smrg *.lo) 10474d5c3dbf1Smrg test -n "$objs$old_deplibs" && \ 10475949d0342Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10476d5c3dbf1Smrg 10477d5c3dbf1Smrg libobj=$output 10478d5c3dbf1Smrg func_lo2o "$libobj" 10479d5c3dbf1Smrg obj=$func_lo2o_result 10480d5c3dbf1Smrg ;; 10481d5c3dbf1Smrg *) 10482d5c3dbf1Smrg libobj= 10483949d0342Smrg obj=$output 104849f606849Smrg ;; 104859f606849Smrg esac 104869f606849Smrg 10487d5c3dbf1Smrg # Delete the old objects. 10488d5c3dbf1Smrg $opt_dry_run || $RM $obj $libobj 104899f606849Smrg 10490d5c3dbf1Smrg # Objects from convenience libraries. This assumes 10491d5c3dbf1Smrg # single-version convenience libraries. Whenever we create 10492d5c3dbf1Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10493d5c3dbf1Smrg # the extraction. 10494d5c3dbf1Smrg reload_conv_objs= 10495d5c3dbf1Smrg gentop= 10496949d0342Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10497949d0342Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10498949d0342Smrg # into space. 10499949d0342Smrg case $reload_cmds in 10500949d0342Smrg *\$LD[\ \$]*) wl= ;; 10501949d0342Smrg esac 10502d5c3dbf1Smrg if test -n "$convenience"; then 10503d5c3dbf1Smrg if test -n "$whole_archive_flag_spec"; then 10504d5c3dbf1Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10505949d0342Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10506949d0342Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 105079f606849Smrg else 10508949d0342Smrg gentop=$output_objdir/${obj}x 10509cdbfa18aSmrg func_append generated " $gentop" 10510d5c3dbf1Smrg 10511d5c3dbf1Smrg func_extract_archives $gentop $convenience 10512d5c3dbf1Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 105139f606849Smrg fi 10514d5c3dbf1Smrg fi 105159f606849Smrg 10516cdbfa18aSmrg # If we're not building shared, we need to use non_pic_objs 10517949d0342Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10518cdbfa18aSmrg 10519d5c3dbf1Smrg # Create the old-style object. 10520949d0342Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 105219f606849Smrg 10522949d0342Smrg output=$obj 10523d5c3dbf1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 105249f606849Smrg 10525d5c3dbf1Smrg # Exit if we aren't doing a library object file. 10526d5c3dbf1Smrg if test -z "$libobj"; then 10527d5c3dbf1Smrg if test -n "$gentop"; then 10528d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10529d5c3dbf1Smrg fi 105309f606849Smrg 10531d5c3dbf1Smrg exit $EXIT_SUCCESS 105329f606849Smrg fi 105339f606849Smrg 10534949d0342Smrg test yes = "$build_libtool_libs" || { 10535d5c3dbf1Smrg if test -n "$gentop"; then 10536d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10537d5c3dbf1Smrg fi 105389f606849Smrg 10539d5c3dbf1Smrg # Create an invalid libtool object if no PIC, so that we don't 10540d5c3dbf1Smrg # accidentally link it into a program. 10541d5c3dbf1Smrg # $show "echo timestamp > $libobj" 10542d5c3dbf1Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10543d5c3dbf1Smrg exit $EXIT_SUCCESS 10544949d0342Smrg } 105459f606849Smrg 10546949d0342Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10547d5c3dbf1Smrg # Only do commands if we really have different PIC objects. 10548d5c3dbf1Smrg reload_objs="$libobjs $reload_conv_objs" 10549949d0342Smrg output=$libobj 10550d5c3dbf1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 105519f606849Smrg fi 10552d5c3dbf1Smrg 10553d5c3dbf1Smrg if test -n "$gentop"; then 10554d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10555d5c3dbf1Smrg fi 10556d5c3dbf1Smrg 10557d5c3dbf1Smrg exit $EXIT_SUCCESS 105589f606849Smrg ;; 105599f606849Smrg 10560d5c3dbf1Smrg prog) 10561d5c3dbf1Smrg case $host in 10562d5c3dbf1Smrg *cygwin*) func_stripname '' '.exe' "$output" 10563d5c3dbf1Smrg output=$func_stripname_result.exe;; 10564d5c3dbf1Smrg esac 10565d5c3dbf1Smrg test -n "$vinfo" && \ 10566949d0342Smrg func_warning "'-version-info' is ignored for programs" 105679f606849Smrg 10568d5c3dbf1Smrg test -n "$release" && \ 10569949d0342Smrg func_warning "'-release' is ignored for programs" 105709f606849Smrg 10571949d0342Smrg $preload \ 10572949d0342Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10573949d0342Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10574d5c3dbf1Smrg 10575d5c3dbf1Smrg case $host in 10576d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10577d5c3dbf1Smrg # On Rhapsody replace the C library is the System framework 10578d5c3dbf1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10579d5c3dbf1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 105809f606849Smrg ;; 10581d5c3dbf1Smrg esac 105829f606849Smrg 10583d5c3dbf1Smrg case $host in 10584d5c3dbf1Smrg *-*-darwin*) 10585d5c3dbf1Smrg # Don't allow lazy linking, it breaks C++ global constructors 10586d5c3dbf1Smrg # But is supposedly fixed on 10.4 or later (yay!). 10587949d0342Smrg if test CXX = "$tagname"; then 10588d5c3dbf1Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10589d5c3dbf1Smrg 10.[0123]) 10590949d0342Smrg func_append compile_command " $wl-bind_at_load" 10591949d0342Smrg func_append finalize_command " $wl-bind_at_load" 10592d5c3dbf1Smrg ;; 10593d5c3dbf1Smrg esac 105949f606849Smrg fi 10595d5c3dbf1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10596d5c3dbf1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10597d5c3dbf1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10598d5c3dbf1Smrg ;; 10599d5c3dbf1Smrg esac 106009f606849Smrg 106019f606849Smrg 10602d5c3dbf1Smrg # move library search paths that coincide with paths to not yet 10603d5c3dbf1Smrg # installed libraries to the beginning of the library search list 10604d5c3dbf1Smrg new_libs= 10605d5c3dbf1Smrg for path in $notinst_path; do 10606d5c3dbf1Smrg case " $new_libs " in 10607d5c3dbf1Smrg *" -L$path/$objdir "*) ;; 10608d5c3dbf1Smrg *) 10609d5c3dbf1Smrg case " $compile_deplibs " in 10610d5c3dbf1Smrg *" -L$path/$objdir "*) 10611cdbfa18aSmrg func_append new_libs " -L$path/$objdir" ;; 106129f606849Smrg esac 10613d5c3dbf1Smrg ;; 10614d5c3dbf1Smrg esac 10615d5c3dbf1Smrg done 10616d5c3dbf1Smrg for deplib in $compile_deplibs; do 10617d5c3dbf1Smrg case $deplib in 10618d5c3dbf1Smrg -L*) 10619d5c3dbf1Smrg case " $new_libs " in 10620d5c3dbf1Smrg *" $deplib "*) ;; 10621cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 106229f606849Smrg esac 10623d5c3dbf1Smrg ;; 10624cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 10625d5c3dbf1Smrg esac 10626d5c3dbf1Smrg done 10627949d0342Smrg compile_deplibs=$new_libs 106289f606849Smrg 106299f606849Smrg 10630cdbfa18aSmrg func_append compile_command " $compile_deplibs" 10631cdbfa18aSmrg func_append finalize_command " $finalize_deplibs" 106329f606849Smrg 10633d5c3dbf1Smrg if test -n "$rpath$xrpath"; then 10634d5c3dbf1Smrg # If the user specified any rpath flags, then add them. 10635d5c3dbf1Smrg for libdir in $rpath $xrpath; do 10636d5c3dbf1Smrg # This is the magic to use -rpath. 10637d5c3dbf1Smrg case "$finalize_rpath " in 10638d5c3dbf1Smrg *" $libdir "*) ;; 10639cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 10640d5c3dbf1Smrg esac 10641d5c3dbf1Smrg done 10642d5c3dbf1Smrg fi 106439f606849Smrg 10644d5c3dbf1Smrg # Now hardcode the library paths 10645d5c3dbf1Smrg rpath= 10646d5c3dbf1Smrg hardcode_libdirs= 10647d5c3dbf1Smrg for libdir in $compile_rpath $finalize_rpath; do 10648d5c3dbf1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10649d5c3dbf1Smrg if test -n "$hardcode_libdir_separator"; then 10650d5c3dbf1Smrg if test -z "$hardcode_libdirs"; then 10651949d0342Smrg hardcode_libdirs=$libdir 10652d5c3dbf1Smrg else 10653d5c3dbf1Smrg # Just accumulate the unique libdirs. 10654d5c3dbf1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10655d5c3dbf1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10656d5c3dbf1Smrg ;; 10657d5c3dbf1Smrg *) 10658cdbfa18aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10659d5c3dbf1Smrg ;; 10660d5c3dbf1Smrg esac 10661d5c3dbf1Smrg fi 106629f606849Smrg else 10663d5c3dbf1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10664cdbfa18aSmrg func_append rpath " $flag" 106659f606849Smrg fi 10666d5c3dbf1Smrg elif test -n "$runpath_var"; then 10667d5c3dbf1Smrg case "$perm_rpath " in 10668d5c3dbf1Smrg *" $libdir "*) ;; 10669cdbfa18aSmrg *) func_append perm_rpath " $libdir" ;; 10670d5c3dbf1Smrg esac 10671d5c3dbf1Smrg fi 10672d5c3dbf1Smrg case $host in 10673dc088bc7Smrg *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) 10674949d0342Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10675d5c3dbf1Smrg case :$dllsearchpath: in 10676d5c3dbf1Smrg *":$libdir:"*) ;; 10677d5c3dbf1Smrg ::) dllsearchpath=$libdir;; 10678cdbfa18aSmrg *) func_append dllsearchpath ":$libdir";; 10679d5c3dbf1Smrg esac 10680d5c3dbf1Smrg case :$dllsearchpath: in 10681d5c3dbf1Smrg *":$testbindir:"*) ;; 10682d5c3dbf1Smrg ::) dllsearchpath=$testbindir;; 10683cdbfa18aSmrg *) func_append dllsearchpath ":$testbindir";; 10684d5c3dbf1Smrg esac 10685d5c3dbf1Smrg ;; 10686d5c3dbf1Smrg esac 10687d5c3dbf1Smrg done 10688d5c3dbf1Smrg # Substitute the hardcoded libdirs into the rpath. 10689d5c3dbf1Smrg if test -n "$hardcode_libdir_separator" && 10690d5c3dbf1Smrg test -n "$hardcode_libdirs"; then 10691949d0342Smrg libdir=$hardcode_libdirs 10692d5c3dbf1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10693d5c3dbf1Smrg fi 10694949d0342Smrg compile_rpath=$rpath 106959f606849Smrg 10696d5c3dbf1Smrg rpath= 10697d5c3dbf1Smrg hardcode_libdirs= 10698d5c3dbf1Smrg for libdir in $finalize_rpath; do 10699d5c3dbf1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10700d5c3dbf1Smrg if test -n "$hardcode_libdir_separator"; then 10701d5c3dbf1Smrg if test -z "$hardcode_libdirs"; then 10702949d0342Smrg hardcode_libdirs=$libdir 10703d5c3dbf1Smrg else 10704d5c3dbf1Smrg # Just accumulate the unique libdirs. 10705d5c3dbf1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10706d5c3dbf1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10707d5c3dbf1Smrg ;; 10708d5c3dbf1Smrg *) 10709cdbfa18aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10710d5c3dbf1Smrg ;; 10711d5c3dbf1Smrg esac 10712d5c3dbf1Smrg fi 107139f606849Smrg else 10714d5c3dbf1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10715cdbfa18aSmrg func_append rpath " $flag" 107169f606849Smrg fi 10717d5c3dbf1Smrg elif test -n "$runpath_var"; then 10718d5c3dbf1Smrg case "$finalize_perm_rpath " in 10719d5c3dbf1Smrg *" $libdir "*) ;; 10720cdbfa18aSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10721d5c3dbf1Smrg esac 107229f606849Smrg fi 10723d5c3dbf1Smrg done 10724d5c3dbf1Smrg # Substitute the hardcoded libdirs into the rpath. 10725d5c3dbf1Smrg if test -n "$hardcode_libdir_separator" && 10726d5c3dbf1Smrg test -n "$hardcode_libdirs"; then 10727949d0342Smrg libdir=$hardcode_libdirs 10728d5c3dbf1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10729d5c3dbf1Smrg fi 10730949d0342Smrg finalize_rpath=$rpath 107319f606849Smrg 10732949d0342Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10733d5c3dbf1Smrg # Transform all the library objects into standard objects. 10734d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10735d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10736d5c3dbf1Smrg fi 107379f606849Smrg 10738949d0342Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 107399f606849Smrg 10740d5c3dbf1Smrg # template prelinking step 10741d5c3dbf1Smrg if test -n "$prelink_cmds"; then 10742d5c3dbf1Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10743d5c3dbf1Smrg fi 107449f606849Smrg 10745949d0342Smrg wrappers_required=: 10746d5c3dbf1Smrg case $host in 10747d5c3dbf1Smrg *cegcc* | *mingw32ce*) 10748d5c3dbf1Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10749949d0342Smrg wrappers_required=false 10750d5c3dbf1Smrg ;; 10751dc088bc7Smrg *cygwin* | *mingw* | *windows* ) 10752949d0342Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10753d5c3dbf1Smrg ;; 10754d5c3dbf1Smrg *) 10755949d0342Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10756949d0342Smrg wrappers_required=false 10757d5c3dbf1Smrg fi 10758d5c3dbf1Smrg ;; 10759d5c3dbf1Smrg esac 10760949d0342Smrg $wrappers_required || { 10761d5c3dbf1Smrg # Replace the output file specification. 10762d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10763949d0342Smrg link_command=$compile_command$compile_rpath 107649f606849Smrg 10765d5c3dbf1Smrg # We have no uninstalled library dependencies, so finalize right now. 10766d5c3dbf1Smrg exit_status=0 10767d5c3dbf1Smrg func_show_eval "$link_command" 'exit_status=$?' 107689f606849Smrg 10769cdbfa18aSmrg if test -n "$postlink_cmds"; then 10770cdbfa18aSmrg func_to_tool_file "$output" 10771cdbfa18aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10772cdbfa18aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10773cdbfa18aSmrg fi 10774cdbfa18aSmrg 10775d5c3dbf1Smrg # Delete the generated files. 10776949d0342Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10777949d0342Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 107789f606849Smrg fi 107799f606849Smrg 10780d5c3dbf1Smrg exit $exit_status 10781949d0342Smrg } 107829f606849Smrg 10783d5c3dbf1Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10784d5c3dbf1Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10785d5c3dbf1Smrg fi 10786d5c3dbf1Smrg if test -n "$finalize_shlibpath"; then 10787d5c3dbf1Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10788d5c3dbf1Smrg fi 107899f606849Smrg 10790d5c3dbf1Smrg compile_var= 10791d5c3dbf1Smrg finalize_var= 10792d5c3dbf1Smrg if test -n "$runpath_var"; then 10793d5c3dbf1Smrg if test -n "$perm_rpath"; then 10794d5c3dbf1Smrg # We should set the runpath_var. 10795d5c3dbf1Smrg rpath= 10796d5c3dbf1Smrg for dir in $perm_rpath; do 10797cdbfa18aSmrg func_append rpath "$dir:" 10798d5c3dbf1Smrg done 10799d5c3dbf1Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 108009f606849Smrg fi 10801d5c3dbf1Smrg if test -n "$finalize_perm_rpath"; then 10802d5c3dbf1Smrg # We should set the runpath_var. 10803d5c3dbf1Smrg rpath= 10804d5c3dbf1Smrg for dir in $finalize_perm_rpath; do 10805cdbfa18aSmrg func_append rpath "$dir:" 10806d5c3dbf1Smrg done 10807d5c3dbf1Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 108089f606849Smrg fi 10809d5c3dbf1Smrg fi 108109f606849Smrg 10811949d0342Smrg if test yes = "$no_install"; then 10812d5c3dbf1Smrg # We don't need to create a wrapper script. 10813949d0342Smrg link_command=$compile_var$compile_command$compile_rpath 10814d5c3dbf1Smrg # Replace the output file specification. 10815d5c3dbf1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10816d5c3dbf1Smrg # Delete the old output file. 10817d5c3dbf1Smrg $opt_dry_run || $RM $output 10818d5c3dbf1Smrg # Link the executable and exit 10819d5c3dbf1Smrg func_show_eval "$link_command" 'exit $?' 10820cdbfa18aSmrg 10821cdbfa18aSmrg if test -n "$postlink_cmds"; then 10822cdbfa18aSmrg func_to_tool_file "$output" 10823cdbfa18aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10824cdbfa18aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10825cdbfa18aSmrg fi 10826cdbfa18aSmrg 108279f606849Smrg exit $EXIT_SUCCESS 10828d5c3dbf1Smrg fi 108299f606849Smrg 10830949d0342Smrg case $hardcode_action,$fast_install in 10831949d0342Smrg relink,*) 10832949d0342Smrg # Fast installation is not supported 10833949d0342Smrg link_command=$compile_var$compile_command$compile_rpath 10834949d0342Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10835d5c3dbf1Smrg 10836949d0342Smrg func_warning "this platform does not like uninstalled shared libraries" 10837949d0342Smrg func_warning "'$output' will be relinked during installation" 10838949d0342Smrg ;; 10839949d0342Smrg *,yes) 10840949d0342Smrg link_command=$finalize_var$compile_command$finalize_rpath 10841949d0342Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10842949d0342Smrg ;; 10843949d0342Smrg *,no) 10844949d0342Smrg link_command=$compile_var$compile_command$compile_rpath 10845949d0342Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10846949d0342Smrg ;; 10847949d0342Smrg *,needless) 10848949d0342Smrg link_command=$finalize_var$compile_command$finalize_rpath 10849949d0342Smrg relink_command= 10850949d0342Smrg ;; 10851949d0342Smrg esac 108529f606849Smrg 10853d5c3dbf1Smrg # Replace the output file specification. 10854d5c3dbf1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 108559f606849Smrg 10856d5c3dbf1Smrg # Delete the old output files. 10857d5c3dbf1Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 108589f606849Smrg 10859d5c3dbf1Smrg func_show_eval "$link_command" 'exit $?' 108609f606849Smrg 10861cdbfa18aSmrg if test -n "$postlink_cmds"; then 10862cdbfa18aSmrg func_to_tool_file "$output_objdir/$outputname" 10863cdbfa18aSmrg 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'` 10864cdbfa18aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10865cdbfa18aSmrg fi 10866cdbfa18aSmrg 10867d5c3dbf1Smrg # Now create the wrapper script. 10868d5c3dbf1Smrg func_verbose "creating $output" 108699f606849Smrg 10870d5c3dbf1Smrg # Quote the relink command for shipping. 10871d5c3dbf1Smrg if test -n "$relink_command"; then 10872d5c3dbf1Smrg # Preserve any variables that may affect compiler behavior 10873d5c3dbf1Smrg for var in $variables_saved_for_relink; do 10874d5c3dbf1Smrg if eval test -z \"\${$var+set}\"; then 10875d5c3dbf1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10876d5c3dbf1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10877d5c3dbf1Smrg relink_command="$var=; export $var; $relink_command" 108789f606849Smrg else 10879949d0342Smrg func_quote_arg pretty "$var_value" 10880949d0342Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 108819f606849Smrg fi 10882d5c3dbf1Smrg done 10883949d0342Smrg func_quote eval cd "`pwd`" 10884949d0342Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10885949d0342Smrg relink_command=$func_quote_arg_unquoted_result 10886d5c3dbf1Smrg fi 108879f606849Smrg 10888d5c3dbf1Smrg # Only actually do things if not in dry run mode. 10889d5c3dbf1Smrg $opt_dry_run || { 10890d5c3dbf1Smrg # win32 will think the script is a binary if it has 10891d5c3dbf1Smrg # a .exe suffix, so we strip it off here. 10892d5c3dbf1Smrg case $output in 10893d5c3dbf1Smrg *.exe) func_stripname '' '.exe' "$output" 10894d5c3dbf1Smrg output=$func_stripname_result ;; 10895d5c3dbf1Smrg esac 10896d5c3dbf1Smrg # test for cygwin because mv fails w/o .exe extensions 10897d5c3dbf1Smrg case $host in 10898d5c3dbf1Smrg *cygwin*) 10899d5c3dbf1Smrg exeext=.exe 10900d5c3dbf1Smrg func_stripname '' '.exe' "$outputname" 10901d5c3dbf1Smrg outputname=$func_stripname_result ;; 10902d5c3dbf1Smrg *) exeext= ;; 109039f606849Smrg esac 10904d5c3dbf1Smrg case $host in 10905dc088bc7Smrg *cygwin* | *mingw* | windows* ) 10906d5c3dbf1Smrg func_dirname_and_basename "$output" "" "." 10907d5c3dbf1Smrg output_name=$func_basename_result 10908d5c3dbf1Smrg output_path=$func_dirname_result 10909949d0342Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10910949d0342Smrg cwrapper=$output_path/$output_name.exe 10911d5c3dbf1Smrg $RM $cwrappersource $cwrapper 10912d5c3dbf1Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10913d5c3dbf1Smrg 10914d5c3dbf1Smrg func_emit_cwrapperexe_src > $cwrappersource 10915d5c3dbf1Smrg 10916d5c3dbf1Smrg # The wrapper executable is built using the $host compiler, 10917d5c3dbf1Smrg # because it contains $host paths and files. If cross- 10918d5c3dbf1Smrg # compiling, it, like the target executable, must be 10919d5c3dbf1Smrg # executed on the $host or under an emulation environment. 10920d5c3dbf1Smrg $opt_dry_run || { 10921d5c3dbf1Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10922d5c3dbf1Smrg $STRIP $cwrapper 10923d5c3dbf1Smrg } 109249f606849Smrg 10925d5c3dbf1Smrg # Now, create the wrapper script for func_source use: 10926d5c3dbf1Smrg func_ltwrapper_scriptname $cwrapper 10927d5c3dbf1Smrg $RM $func_ltwrapper_scriptname_result 10928d5c3dbf1Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10929d5c3dbf1Smrg $opt_dry_run || { 10930d5c3dbf1Smrg # note: this script will not be executed, so do not chmod. 10931949d0342Smrg if test "x$build" = "x$host"; then 10932d5c3dbf1Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10933d5c3dbf1Smrg else 10934d5c3dbf1Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10935d5c3dbf1Smrg fi 10936d5c3dbf1Smrg } 10937d5c3dbf1Smrg ;; 10938d5c3dbf1Smrg * ) 10939d5c3dbf1Smrg $RM $output 10940d5c3dbf1Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 109419f606849Smrg 10942d5c3dbf1Smrg func_emit_wrapper no > $output 10943d5c3dbf1Smrg chmod +x $output 10944d5c3dbf1Smrg ;; 10945d5c3dbf1Smrg esac 10946d5c3dbf1Smrg } 10947d5c3dbf1Smrg exit $EXIT_SUCCESS 10948d5c3dbf1Smrg ;; 10949d5c3dbf1Smrg esac 109509f606849Smrg 10951d5c3dbf1Smrg # See if we need to build an old-fashioned archive. 10952d5c3dbf1Smrg for oldlib in $oldlibs; do 109539f606849Smrg 10954949d0342Smrg case $build_libtool_libs in 10955949d0342Smrg convenience) 10956949d0342Smrg oldobjs="$libobjs_save $symfileobj" 10957949d0342Smrg addlibs=$convenience 10958d5c3dbf1Smrg build_libtool_libs=no 10959949d0342Smrg ;; 10960949d0342Smrg module) 10961949d0342Smrg oldobjs=$libobjs_save 10962949d0342Smrg addlibs=$old_convenience 10963949d0342Smrg build_libtool_libs=no 10964949d0342Smrg ;; 10965949d0342Smrg *) 10966d5c3dbf1Smrg oldobjs="$old_deplibs $non_pic_objects" 10967949d0342Smrg $preload && test -f "$symfileobj" \ 10968949d0342Smrg && func_append oldobjs " $symfileobj" 10969949d0342Smrg addlibs=$old_convenience 10970949d0342Smrg ;; 10971949d0342Smrg esac 109729f606849Smrg 10973d5c3dbf1Smrg if test -n "$addlibs"; then 10974949d0342Smrg gentop=$output_objdir/${outputname}x 10975cdbfa18aSmrg func_append generated " $gentop" 109769f606849Smrg 10977d5c3dbf1Smrg func_extract_archives $gentop $addlibs 10978cdbfa18aSmrg func_append oldobjs " $func_extract_archives_result" 10979d5c3dbf1Smrg fi 109809f606849Smrg 10981d5c3dbf1Smrg # Do each command in the archive commands. 10982949d0342Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10983d5c3dbf1Smrg cmds=$old_archive_from_new_cmds 10984d5c3dbf1Smrg else 109859f606849Smrg 10986d5c3dbf1Smrg # Add any objects from preloaded convenience libraries 10987d5c3dbf1Smrg if test -n "$dlprefiles"; then 10988949d0342Smrg gentop=$output_objdir/${outputname}x 10989cdbfa18aSmrg func_append generated " $gentop" 109909f606849Smrg 10991d5c3dbf1Smrg func_extract_archives $gentop $dlprefiles 10992cdbfa18aSmrg func_append oldobjs " $func_extract_archives_result" 10993d5c3dbf1Smrg fi 109949f606849Smrg 10995d5c3dbf1Smrg # POSIX demands no paths to be encoded in archives. We have 10996d5c3dbf1Smrg # to avoid creating archives with duplicate basenames if we 10997d5c3dbf1Smrg # might have to extract them afterwards, e.g., when creating a 10998d5c3dbf1Smrg # static archive out of a convenience library, or when linking 10999d5c3dbf1Smrg # the entirety of a libtool archive into another (currently 11000d5c3dbf1Smrg # not supported by libtool). 11001d5c3dbf1Smrg if (for obj in $oldobjs 11002d5c3dbf1Smrg do 11003d5c3dbf1Smrg func_basename "$obj" 11004d5c3dbf1Smrg $ECHO "$func_basename_result" 11005d5c3dbf1Smrg done | sort | sort -uc >/dev/null 2>&1); then 11006d5c3dbf1Smrg : 11007d5c3dbf1Smrg else 11008d5c3dbf1Smrg echo "copying selected object files to avoid basename conflicts..." 11009949d0342Smrg gentop=$output_objdir/${outputname}x 11010cdbfa18aSmrg func_append generated " $gentop" 11011d5c3dbf1Smrg func_mkdir_p "$gentop" 11012d5c3dbf1Smrg save_oldobjs=$oldobjs 11013d5c3dbf1Smrg oldobjs= 11014d5c3dbf1Smrg counter=1 11015d5c3dbf1Smrg for obj in $save_oldobjs 11016d5c3dbf1Smrg do 11017d5c3dbf1Smrg func_basename "$obj" 11018949d0342Smrg objbase=$func_basename_result 11019d5c3dbf1Smrg case " $oldobjs " in 11020d5c3dbf1Smrg " ") oldobjs=$obj ;; 11021d5c3dbf1Smrg *[\ /]"$objbase "*) 11022d5c3dbf1Smrg while :; do 11023d5c3dbf1Smrg # Make sure we don't pick an alternate name that also 11024d5c3dbf1Smrg # overlaps. 11025d5c3dbf1Smrg newobj=lt$counter-$objbase 11026d5c3dbf1Smrg func_arith $counter + 1 11027d5c3dbf1Smrg counter=$func_arith_result 11028d5c3dbf1Smrg case " $oldobjs " in 11029d5c3dbf1Smrg *[\ /]"$newobj "*) ;; 11030d5c3dbf1Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 11031d5c3dbf1Smrg esac 11032d5c3dbf1Smrg done 11033d5c3dbf1Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 11034cdbfa18aSmrg func_append oldobjs " $gentop/$newobj" 11035d5c3dbf1Smrg ;; 11036cdbfa18aSmrg *) func_append oldobjs " $obj" ;; 11037d5c3dbf1Smrg esac 110389f606849Smrg done 110399f606849Smrg fi 11040cdbfa18aSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 11041cdbfa18aSmrg tool_oldlib=$func_to_tool_file_result 11042d5c3dbf1Smrg eval cmds=\"$old_archive_cmds\" 110439f606849Smrg 11044d5c3dbf1Smrg func_len " $cmds" 11045d5c3dbf1Smrg len=$func_len_result 11046d5c3dbf1Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 11047d5c3dbf1Smrg cmds=$old_archive_cmds 11048cdbfa18aSmrg elif test -n "$archiver_list_spec"; then 11049cdbfa18aSmrg func_verbose "using command file archive linking..." 11050cdbfa18aSmrg for obj in $oldobjs 11051cdbfa18aSmrg do 11052cdbfa18aSmrg func_to_tool_file "$obj" 11053cdbfa18aSmrg $ECHO "$func_to_tool_file_result" 11054cdbfa18aSmrg done > $output_objdir/$libname.libcmd 11055cdbfa18aSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 11056cdbfa18aSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 11057cdbfa18aSmrg cmds=$old_archive_cmds 11058d5c3dbf1Smrg else 11059d5c3dbf1Smrg # the command line is too long to link in one step, link in parts 11060d5c3dbf1Smrg func_verbose "using piecewise archive linking..." 11061d5c3dbf1Smrg save_RANLIB=$RANLIB 11062d5c3dbf1Smrg RANLIB=: 11063d5c3dbf1Smrg objlist= 11064d5c3dbf1Smrg concat_cmds= 11065d5c3dbf1Smrg save_oldobjs=$oldobjs 11066d5c3dbf1Smrg oldobjs= 11067d5c3dbf1Smrg # Is there a better way of finding the last object in the list? 11068d5c3dbf1Smrg for obj in $save_oldobjs 11069d5c3dbf1Smrg do 11070d5c3dbf1Smrg last_oldobj=$obj 11071d5c3dbf1Smrg done 11072d5c3dbf1Smrg eval test_cmds=\"$old_archive_cmds\" 11073d5c3dbf1Smrg func_len " $test_cmds" 11074d5c3dbf1Smrg len0=$func_len_result 11075d5c3dbf1Smrg len=$len0 11076d5c3dbf1Smrg for obj in $save_oldobjs 11077d5c3dbf1Smrg do 11078d5c3dbf1Smrg func_len " $obj" 11079d5c3dbf1Smrg func_arith $len + $func_len_result 11080d5c3dbf1Smrg len=$func_arith_result 11081d5c3dbf1Smrg func_append objlist " $obj" 11082d5c3dbf1Smrg if test "$len" -lt "$max_cmd_len"; then 11083d5c3dbf1Smrg : 11084d5c3dbf1Smrg else 11085d5c3dbf1Smrg # the above command should be used before it gets too long 11086d5c3dbf1Smrg oldobjs=$objlist 11087949d0342Smrg if test "$obj" = "$last_oldobj"; then 11088d5c3dbf1Smrg RANLIB=$save_RANLIB 11089d5c3dbf1Smrg fi 11090d5c3dbf1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11091949d0342Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11092d5c3dbf1Smrg objlist= 11093d5c3dbf1Smrg len=$len0 11094d5c3dbf1Smrg fi 11095d5c3dbf1Smrg done 11096d5c3dbf1Smrg RANLIB=$save_RANLIB 11097d5c3dbf1Smrg oldobjs=$objlist 11098949d0342Smrg if test -z "$oldobjs"; then 11099d5c3dbf1Smrg eval cmds=\"\$concat_cmds\" 11100d5c3dbf1Smrg else 11101d5c3dbf1Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11102d5c3dbf1Smrg fi 11103d5c3dbf1Smrg fi 11104d5c3dbf1Smrg fi 11105d5c3dbf1Smrg func_execute_cmds "$cmds" 'exit $?' 111069f606849Smrg done 111079f606849Smrg 11108d5c3dbf1Smrg test -n "$generated" && \ 11109d5c3dbf1Smrg func_show_eval "${RM}r$generated" 111109f606849Smrg 11111d5c3dbf1Smrg # Now create the libtool archive. 11112d5c3dbf1Smrg case $output in 11113d5c3dbf1Smrg *.la) 11114d5c3dbf1Smrg old_library= 11115949d0342Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 11116d5c3dbf1Smrg func_verbose "creating $output" 111179f606849Smrg 11118d5c3dbf1Smrg # Preserve any variables that may affect compiler behavior 11119d5c3dbf1Smrg for var in $variables_saved_for_relink; do 11120d5c3dbf1Smrg if eval test -z \"\${$var+set}\"; then 11121d5c3dbf1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11122d5c3dbf1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 11123d5c3dbf1Smrg relink_command="$var=; export $var; $relink_command" 111249f606849Smrg else 11125949d0342Smrg func_quote_arg pretty,unquoted "$var_value" 11126949d0342Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 111279f606849Smrg fi 11128d5c3dbf1Smrg done 11129d5c3dbf1Smrg # Quote the link command for shipping. 11130949d0342Smrg func_quote eval cd "`pwd`" 11131949d0342Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11132949d0342Smrg func_quote_arg pretty,unquoted "$relink_command" 11133949d0342Smrg relink_command=$func_quote_arg_unquoted_result 11134949d0342Smrg if test yes = "$hardcode_automatic"; then 11135d5c3dbf1Smrg relink_command= 11136d5c3dbf1Smrg fi 111379f606849Smrg 11138d5c3dbf1Smrg # Only create the output if not a dry run. 11139d5c3dbf1Smrg $opt_dry_run || { 11140d5c3dbf1Smrg for installed in no yes; do 11141949d0342Smrg if test yes = "$installed"; then 11142d5c3dbf1Smrg if test -z "$install_libdir"; then 11143d5c3dbf1Smrg break 11144d5c3dbf1Smrg fi 11145949d0342Smrg output=$output_objdir/${outputname}i 11146d5c3dbf1Smrg # Replace all uninstalled libtool libraries with the installed ones 11147d5c3dbf1Smrg newdependency_libs= 11148d5c3dbf1Smrg for deplib in $dependency_libs; do 11149d5c3dbf1Smrg case $deplib in 11150d5c3dbf1Smrg *.la) 11151d5c3dbf1Smrg func_basename "$deplib" 11152949d0342Smrg name=$func_basename_result 11153cdbfa18aSmrg func_resolve_sysroot "$deplib" 11154949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11155d5c3dbf1Smrg test -z "$libdir" && \ 11156949d0342Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 11157cdbfa18aSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11158cdbfa18aSmrg ;; 11159cdbfa18aSmrg -L*) 11160cdbfa18aSmrg func_stripname -L '' "$deplib" 11161cdbfa18aSmrg func_replace_sysroot "$func_stripname_result" 11162cdbfa18aSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11163cdbfa18aSmrg ;; 11164cdbfa18aSmrg -R*) 11165cdbfa18aSmrg func_stripname -R '' "$deplib" 11166cdbfa18aSmrg func_replace_sysroot "$func_stripname_result" 11167cdbfa18aSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11168d5c3dbf1Smrg ;; 11169cdbfa18aSmrg *) func_append newdependency_libs " $deplib" ;; 11170d5c3dbf1Smrg esac 11171d5c3dbf1Smrg done 11172949d0342Smrg dependency_libs=$newdependency_libs 11173d5c3dbf1Smrg newdlfiles= 11174d5c3dbf1Smrg 11175d5c3dbf1Smrg for lib in $dlfiles; do 11176d5c3dbf1Smrg case $lib in 11177d5c3dbf1Smrg *.la) 11178d5c3dbf1Smrg func_basename "$lib" 11179949d0342Smrg name=$func_basename_result 11180949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11181d5c3dbf1Smrg test -z "$libdir" && \ 11182949d0342Smrg func_fatal_error "'$lib' is not a valid libtool archive" 11183cdbfa18aSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11184d5c3dbf1Smrg ;; 11185cdbfa18aSmrg *) func_append newdlfiles " $lib" ;; 11186d5c3dbf1Smrg esac 11187d5c3dbf1Smrg done 11188949d0342Smrg dlfiles=$newdlfiles 11189d5c3dbf1Smrg newdlprefiles= 11190d5c3dbf1Smrg for lib in $dlprefiles; do 11191d5c3dbf1Smrg case $lib in 11192d5c3dbf1Smrg *.la) 11193d5c3dbf1Smrg # Only pass preopened files to the pseudo-archive (for 11194d5c3dbf1Smrg # eventual linking with the app. that links it) if we 11195d5c3dbf1Smrg # didn't already link the preopened objects directly into 11196d5c3dbf1Smrg # the library: 11197d5c3dbf1Smrg func_basename "$lib" 11198949d0342Smrg name=$func_basename_result 11199949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11200d5c3dbf1Smrg test -z "$libdir" && \ 11201949d0342Smrg func_fatal_error "'$lib' is not a valid libtool archive" 11202cdbfa18aSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11203d5c3dbf1Smrg ;; 11204d5c3dbf1Smrg esac 11205d5c3dbf1Smrg done 11206949d0342Smrg dlprefiles=$newdlprefiles 11207d5c3dbf1Smrg else 11208d5c3dbf1Smrg newdlfiles= 11209d5c3dbf1Smrg for lib in $dlfiles; do 11210d5c3dbf1Smrg case $lib in 11211949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11212d5c3dbf1Smrg *) abs=`pwd`"/$lib" ;; 11213d5c3dbf1Smrg esac 11214cdbfa18aSmrg func_append newdlfiles " $abs" 11215d5c3dbf1Smrg done 11216949d0342Smrg dlfiles=$newdlfiles 11217d5c3dbf1Smrg newdlprefiles= 11218d5c3dbf1Smrg for lib in $dlprefiles; do 11219d5c3dbf1Smrg case $lib in 11220949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11221d5c3dbf1Smrg *) abs=`pwd`"/$lib" ;; 11222d5c3dbf1Smrg esac 11223cdbfa18aSmrg func_append newdlprefiles " $abs" 11224d5c3dbf1Smrg done 11225949d0342Smrg dlprefiles=$newdlprefiles 11226d5c3dbf1Smrg fi 11227d5c3dbf1Smrg $RM $output 11228d5c3dbf1Smrg # place dlname in correct position for cygwin 11229d5c3dbf1Smrg # In fact, it would be nice if we could use this code for all target 11230d5c3dbf1Smrg # systems that can't hard-code library paths into their executables 11231d5c3dbf1Smrg # and that have no shared library path variable independent of PATH, 11232d5c3dbf1Smrg # but it turns out we can't easily determine that from inspecting 11233d5c3dbf1Smrg # libtool variables, so we have to hard-code the OSs to which it 11234d5c3dbf1Smrg # applies here; at the moment, that means platforms that use the PE 11235d5c3dbf1Smrg # object format with DLL files. See the long comment at the top of 11236d5c3dbf1Smrg # tests/bindir.at for full details. 11237d5c3dbf1Smrg tdlname=$dlname 11238d5c3dbf1Smrg case $host,$output,$installed,$module,$dlname in 11239dc088bc7Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *windows*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11240d5c3dbf1Smrg # If a -bindir argument was supplied, place the dll there. 11241949d0342Smrg if test -n "$bindir"; then 11242d5c3dbf1Smrg func_relative_path "$install_libdir" "$bindir" 11243949d0342Smrg tdlname=$func_relative_path_result/$dlname 11244d5c3dbf1Smrg else 11245d5c3dbf1Smrg # Otherwise fall back on heuristic. 11246d5c3dbf1Smrg tdlname=../bin/$dlname 11247d5c3dbf1Smrg fi 11248d5c3dbf1Smrg ;; 11249d5c3dbf1Smrg esac 11250d5c3dbf1Smrg $ECHO > $output "\ 11251d5c3dbf1Smrg# $outputname - a libtool library file 11252949d0342Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11253d5c3dbf1Smrg# 11254d5c3dbf1Smrg# Please DO NOT delete this file! 11255d5c3dbf1Smrg# It is necessary for linking the library. 112569f606849Smrg 11257d5c3dbf1Smrg# The name that we can dlopen(3). 11258d5c3dbf1Smrgdlname='$tdlname' 112599f606849Smrg 11260d5c3dbf1Smrg# Names of this library. 11261d5c3dbf1Smrglibrary_names='$library_names' 112629f606849Smrg 11263d5c3dbf1Smrg# The name of the static archive. 11264d5c3dbf1Smrgold_library='$old_library' 112659f606849Smrg 11266949d0342Smrg# Linker flags that cannot go in dependency_libs. 11267d5c3dbf1Smrginherited_linker_flags='$new_inherited_linker_flags' 112689f606849Smrg 11269d5c3dbf1Smrg# Libraries that this one depends upon. 11270d5c3dbf1Smrgdependency_libs='$dependency_libs' 112719f606849Smrg 11272d5c3dbf1Smrg# Names of additional weak libraries provided by this library 11273d5c3dbf1Smrgweak_library_names='$weak_libs' 112749f606849Smrg 11275d5c3dbf1Smrg# Version information for $libname. 11276d5c3dbf1Smrgcurrent=$current 11277d5c3dbf1Smrgage=$age 11278d5c3dbf1Smrgrevision=$revision 112799f606849Smrg 11280d5c3dbf1Smrg# Is this an already installed library? 11281d5c3dbf1Smrginstalled=$installed 112829f606849Smrg 11283d5c3dbf1Smrg# Should we warn about portability when linking against -modules? 11284d5c3dbf1Smrgshouldnotlink=$module 112859f606849Smrg 11286d5c3dbf1Smrg# Files to dlopen/dlpreopen 11287d5c3dbf1Smrgdlopen='$dlfiles' 11288d5c3dbf1Smrgdlpreopen='$dlprefiles' 112899f606849Smrg 11290d5c3dbf1Smrg# Directory that this library needs to be installed in: 11291d5c3dbf1Smrglibdir='$install_libdir'" 11292949d0342Smrg if test no,yes = "$installed,$need_relink"; then 11293d5c3dbf1Smrg $ECHO >> $output "\ 11294d5c3dbf1Smrgrelink_command=\"$relink_command\"" 11295d5c3dbf1Smrg fi 11296d5c3dbf1Smrg done 11297d5c3dbf1Smrg } 112989f606849Smrg 11299d5c3dbf1Smrg # Do a symbolic link so that the libtool archive can be found in 11300d5c3dbf1Smrg # LD_LIBRARY_PATH before the program is installed. 11301d5c3dbf1Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11302d5c3dbf1Smrg ;; 11303d5c3dbf1Smrg esac 11304d5c3dbf1Smrg exit $EXIT_SUCCESS 11305d5c3dbf1Smrg} 113069f606849Smrg 11307949d0342Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 11308949d0342Smrg func_mode_link ${1+"$@"} 11309949d0342Smrgfi 113109f606849Smrg 113119f606849Smrg 11312d5c3dbf1Smrg# func_mode_uninstall arg... 11313d5c3dbf1Smrgfunc_mode_uninstall () 11314d5c3dbf1Smrg{ 11315949d0342Smrg $debug_cmd 11316949d0342Smrg 11317949d0342Smrg RM=$nonopt 113189f606849Smrg files= 11319949d0342Smrg rmforce=false 113209f606849Smrg exit_status=0 113219f606849Smrg 113229f606849Smrg # This variable tells wrapper scripts just to set variables rather 113239f606849Smrg # than running their programs. 11324949d0342Smrg libtool_install_magic=$magic 113259f606849Smrg 113269f606849Smrg for arg 113279f606849Smrg do 113289f606849Smrg case $arg in 11329949d0342Smrg -f) func_append RM " $arg"; rmforce=: ;; 11330cdbfa18aSmrg -*) func_append RM " $arg" ;; 11331cdbfa18aSmrg *) func_append files " $arg" ;; 113329f606849Smrg esac 113339f606849Smrg done 113349f606849Smrg 11335d5c3dbf1Smrg test -z "$RM" && \ 11336d5c3dbf1Smrg func_fatal_help "you must specify an RM program" 113379f606849Smrg 113389f606849Smrg rmdirs= 113399f606849Smrg 113409f606849Smrg for file in $files; do 11341d5c3dbf1Smrg func_dirname "$file" "" "." 11342949d0342Smrg dir=$func_dirname_result 11343949d0342Smrg if test . = "$dir"; then 11344949d0342Smrg odir=$objdir 113459f606849Smrg else 11346949d0342Smrg odir=$dir/$objdir 113479f606849Smrg fi 11348d5c3dbf1Smrg func_basename "$file" 11349949d0342Smrg name=$func_basename_result 11350949d0342Smrg test uninstall = "$opt_mode" && odir=$dir 113519f606849Smrg 11352cdbfa18aSmrg # Remember odir for removal later, being careful to avoid duplicates 11353949d0342Smrg if test clean = "$opt_mode"; then 113549f606849Smrg case " $rmdirs " in 11355cdbfa18aSmrg *" $odir "*) ;; 11356cdbfa18aSmrg *) func_append rmdirs " $odir" ;; 113579f606849Smrg esac 113589f606849Smrg fi 113599f606849Smrg 113609f606849Smrg # Don't error if the file doesn't exist and rm -f was used. 11361d5c3dbf1Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11362d5c3dbf1Smrg { test -h "$file"; } >/dev/null 2>&1 || 11363d5c3dbf1Smrg test -f "$file"; then 113649f606849Smrg : 113659f606849Smrg elif test -d "$file"; then 113669f606849Smrg exit_status=1 113679f606849Smrg continue 11368949d0342Smrg elif $rmforce; then 113699f606849Smrg continue 113709f606849Smrg fi 113719f606849Smrg 11372949d0342Smrg rmfiles=$file 113739f606849Smrg 113749f606849Smrg case $name in 113759f606849Smrg *.la) 113769f606849Smrg # Possibly a libtool archive, so verify it. 11377d5c3dbf1Smrg if func_lalib_p "$file"; then 11378d5c3dbf1Smrg func_source $dir/$name 113799f606849Smrg 113809f606849Smrg # Delete the libtool libraries and symlinks. 113819f606849Smrg for n in $library_names; do 11382cdbfa18aSmrg func_append rmfiles " $odir/$n" 113839f606849Smrg done 11384cdbfa18aSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 113859f606849Smrg 11386949d0342Smrg case $opt_mode in 113879f606849Smrg clean) 11388cdbfa18aSmrg case " $library_names " in 113899f606849Smrg *" $dlname "*) ;; 11390cdbfa18aSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113919f606849Smrg esac 11392cdbfa18aSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113939f606849Smrg ;; 113949f606849Smrg uninstall) 113959f606849Smrg if test -n "$library_names"; then 113969f606849Smrg # Do each command in the postuninstall commands. 11397949d0342Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113989f606849Smrg fi 113999f606849Smrg 114009f606849Smrg if test -n "$old_library"; then 114019f606849Smrg # Do each command in the old_postuninstall commands. 11402949d0342Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 114039f606849Smrg fi 114049f606849Smrg # FIXME: should reinstall the best remaining shared library. 114059f606849Smrg ;; 114069f606849Smrg esac 114079f606849Smrg fi 114089f606849Smrg ;; 114099f606849Smrg 114109f606849Smrg *.lo) 114119f606849Smrg # Possibly a libtool object, so verify it. 11412d5c3dbf1Smrg if func_lalib_p "$file"; then 114139f606849Smrg 114149f606849Smrg # Read the .lo file 11415d5c3dbf1Smrg func_source $dir/$name 114169f606849Smrg 114179f606849Smrg # Add PIC object to the list of files to remove. 11418949d0342Smrg if test -n "$pic_object" && test none != "$pic_object"; then 11419cdbfa18aSmrg func_append rmfiles " $dir/$pic_object" 114209f606849Smrg fi 114219f606849Smrg 114229f606849Smrg # Add non-PIC object to the list of files to remove. 11423949d0342Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11424cdbfa18aSmrg func_append rmfiles " $dir/$non_pic_object" 114259f606849Smrg fi 114269f606849Smrg fi 114279f606849Smrg ;; 114289f606849Smrg 114299f606849Smrg *) 11430949d0342Smrg if test clean = "$opt_mode"; then 114319f606849Smrg noexename=$name 114329f606849Smrg case $file in 114339f606849Smrg *.exe) 11434d5c3dbf1Smrg func_stripname '' '.exe' "$file" 11435d5c3dbf1Smrg file=$func_stripname_result 11436d5c3dbf1Smrg func_stripname '' '.exe' "$name" 11437d5c3dbf1Smrg noexename=$func_stripname_result 114389f606849Smrg # $file with .exe has already been added to rmfiles, 114399f606849Smrg # add $file without .exe 11440cdbfa18aSmrg func_append rmfiles " $file" 114419f606849Smrg ;; 114429f606849Smrg esac 114439f606849Smrg # Do a test to see if this is a libtool program. 11444d5c3dbf1Smrg if func_ltwrapper_p "$file"; then 11445d5c3dbf1Smrg if func_ltwrapper_executable_p "$file"; then 11446d5c3dbf1Smrg func_ltwrapper_scriptname "$file" 11447d5c3dbf1Smrg relink_command= 11448d5c3dbf1Smrg func_source $func_ltwrapper_scriptname_result 11449cdbfa18aSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11450d5c3dbf1Smrg else 11451d5c3dbf1Smrg relink_command= 11452d5c3dbf1Smrg func_source $dir/$noexename 11453d5c3dbf1Smrg fi 114549f606849Smrg 114559f606849Smrg # note $name still contains .exe if it was in $file originally 114569f606849Smrg # as does the version of $file that was added into $rmfiles 11457949d0342Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11458949d0342Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 11459cdbfa18aSmrg func_append rmfiles " $odir/lt-$name" 114609f606849Smrg fi 11461949d0342Smrg if test "X$noexename" != "X$name"; then 11462949d0342Smrg func_append rmfiles " $odir/lt-$noexename.c" 114639f606849Smrg fi 114649f606849Smrg fi 114659f606849Smrg fi 114669f606849Smrg ;; 114679f606849Smrg esac 11468d5c3dbf1Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 114699f606849Smrg done 114709f606849Smrg 11471949d0342Smrg # Try to remove the $objdir's in the directories where we deleted files 114729f606849Smrg for dir in $rmdirs; do 114739f606849Smrg if test -d "$dir"; then 11474d5c3dbf1Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 114759f606849Smrg fi 114769f606849Smrg done 114779f606849Smrg 114789f606849Smrg exit $exit_status 11479d5c3dbf1Smrg} 114809f606849Smrg 11481949d0342Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11482949d0342Smrg func_mode_uninstall ${1+"$@"} 11483949d0342Smrgfi 114849f606849Smrg 11485cdbfa18aSmrgtest -z "$opt_mode" && { 11486949d0342Smrg help=$generic_help 11487d5c3dbf1Smrg func_fatal_help "you must specify a MODE" 11488d5c3dbf1Smrg} 11489d5c3dbf1Smrg 11490d5c3dbf1Smrgtest -z "$exec_cmd" && \ 11491949d0342Smrg func_fatal_help "invalid operation mode '$opt_mode'" 114929f606849Smrg 114939f606849Smrgif test -n "$exec_cmd"; then 11494d5c3dbf1Smrg eval exec "$exec_cmd" 114959f606849Smrg exit $EXIT_FAILURE 114969f606849Smrgfi 114979f606849Smrg 11498d5c3dbf1Smrgexit $exit_status 114999f606849Smrg 115009f606849Smrg 115019f606849Smrg# The TAGs below are defined such that we never get into a situation 11502949d0342Smrg# where we disable both kinds of libraries. Given conflicting 115039f606849Smrg# choices, we go for a static library, that is the most portable, 115049f606849Smrg# since we can't tell whether shared libraries were disabled because 115059f606849Smrg# the user asked for that or because the platform doesn't support 115069f606849Smrg# them. This is particularly important on AIX, because we don't 115079f606849Smrg# support having both static and shared libraries enabled at the same 115089f606849Smrg# time on that platform, so we default to a shared-only configuration. 115099f606849Smrg# If a disable-shared tag is given, we'll fallback to a static-only 115109f606849Smrg# configuration. But we'll never go from static-only to shared-only. 115119f606849Smrg 115129f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11513d5c3dbf1Smrgbuild_libtool_libs=no 11514d5c3dbf1Smrgbuild_old_libs=yes 115159f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 115169f606849Smrg 115179f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11518d5c3dbf1Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 115199f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-static 115209f606849Smrg 115219f606849Smrg# Local Variables: 115229f606849Smrg# mode:shell-script 115239f606849Smrg# sh-indentation:2 115249f606849Smrg# End: 11525