ltmain.sh revision 949d0342
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 5949d0342Smrg# libtool (GNU libtool) 2.4.7 6949d0342Smrg# Provide generalized library-building support services. 7d5c3dbf1Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8d5c3dbf1Smrg 9949d0342Smrg# Copyright (C) 1996-2019, 2021-2022 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 34949d0342SmrgVERSION=2.4.7 35949d0342Smrgpackage_revision=2.4.7 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# 75949d0342Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76d5c3dbf1Smrg# 77949d0342Smrg# This file is dual licensed under the terms of the MIT license 78949d0342Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79949d0342Smrg# <http://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 146949d0342Smrg# There are apparently some retarded 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 592949d0342Smrg # useable 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. 742949d0342Smrg# value retuned 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 900d5c3dbf1Smrg # list incase 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# 1539949d0342Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540949d0342Smrg# 1541949d0342Smrg# This file is dual licensed under the terms of the MIT license 1542949d0342Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543949d0342Smrg# <http://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. 2218949d0342Smrgscriptversion='(GNU libtool) 2.4.7' 2219d5c3dbf1Smrg 2220cdbfa18aSmrg 2221949d0342Smrg# func_echo ARG... 2222949d0342Smrg# ---------------- 2223949d0342Smrg# Libtool also displays the current mode in messages, so override 2224949d0342Smrg# funclib.sh func_echo with this custom definition. 2225949d0342Smrgfunc_echo () 2226cdbfa18aSmrg{ 2227949d0342Smrg $debug_cmd 2228cdbfa18aSmrg 2229949d0342Smrg _G_message=$* 2230cdbfa18aSmrg 2231949d0342Smrg func_echo_IFS=$IFS 2232949d0342Smrg IFS=$nl 2233949d0342Smrg for _G_line in $_G_message; do 2234949d0342Smrg IFS=$func_echo_IFS 2235949d0342Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2236949d0342Smrg done 2237949d0342Smrg IFS=$func_echo_IFS 2238949d0342Smrg} 2239cdbfa18aSmrg 2240cdbfa18aSmrg 2241949d0342Smrg# func_warning ARG... 2242949d0342Smrg# ------------------- 2243949d0342Smrg# Libtool warnings are not categorized, so override funclib.sh 2244949d0342Smrg# func_warning with this simpler definition. 2245949d0342Smrgfunc_warning () 2246cdbfa18aSmrg{ 2247949d0342Smrg $debug_cmd 2248cdbfa18aSmrg 2249949d0342Smrg $warning_func ${1+"$@"} 2250949d0342Smrg} 2251cdbfa18aSmrg 2252cdbfa18aSmrg 2253949d0342Smrg## ---------------- ## 2254949d0342Smrg## Options parsing. ## 2255949d0342Smrg## ---------------- ## 2256949d0342Smrg 2257949d0342Smrg# Hook in the functions to make sure our own options are parsed during 2258949d0342Smrg# the option parsing loop. 2259949d0342Smrg 2260949d0342Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2261949d0342Smrg 2262949d0342Smrg# Short help message in response to '-h'. 2263949d0342Smrgusage_message="Options: 2264949d0342Smrg --config show all configuration variables 2265949d0342Smrg --debug enable verbose shell tracing 2266949d0342Smrg -n, --dry-run display commands without modifying any files 2267949d0342Smrg --features display basic configuration information and exit 2268949d0342Smrg --mode=MODE use operation mode MODE 2269949d0342Smrg --no-warnings equivalent to '-Wnone' 2270949d0342Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2271949d0342Smrg --quiet, --silent don't print informational messages 2272949d0342Smrg --tag=TAG use configuration variables from tag TAG 2273949d0342Smrg -v, --verbose print more informational messages than default 2274949d0342Smrg --version print version information 2275949d0342Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2276949d0342Smrg -h, --help, --help-all print short, long, or detailed help message 2277949d0342Smrg" 2278cdbfa18aSmrg 2279949d0342Smrg# Additional text appended to 'usage_message' in response to '--help'. 2280949d0342Smrgfunc_help () 2281cdbfa18aSmrg{ 2282949d0342Smrg $debug_cmd 2283949d0342Smrg 2284949d0342Smrg func_usage_message 2285949d0342Smrg $ECHO "$long_help_message 2286949d0342Smrg 2287949d0342SmrgMODE must be one of the following: 2288949d0342Smrg 2289949d0342Smrg clean remove files from the build directory 2290949d0342Smrg compile compile a source file into a libtool object 2291949d0342Smrg execute automatically set library path, then run a program 2292949d0342Smrg finish complete the installation of libtool libraries 2293949d0342Smrg install install libraries or executables 2294949d0342Smrg link create a library or an executable 2295949d0342Smrg uninstall remove libraries from an installed directory 2296949d0342Smrg 2297949d0342SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2298949d0342Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2299949d0342SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2300949d0342Smrg 2301949d0342SmrgWhen reporting a bug, please describe a test case to reproduce it and 2302949d0342Smrginclude the following information: 2303949d0342Smrg 2304949d0342Smrg host-triplet: $host 2305949d0342Smrg shell: $SHELL 2306949d0342Smrg compiler: $LTCC 2307949d0342Smrg compiler flags: $LTCFLAGS 2308949d0342Smrg linker: $LD (gnu? $with_gnu_ld) 2309949d0342Smrg version: $progname (GNU libtool) 2.4.7 2310949d0342Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2311949d0342Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2312949d0342Smrg 2313949d0342SmrgReport bugs to <bug-libtool@gnu.org>. 2314949d0342SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2315949d0342SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2316949d0342Smrg exit 0 2317949d0342Smrg} 2318949d0342Smrg 2319949d0342Smrg 2320949d0342Smrg# func_lo2o OBJECT-NAME 2321949d0342Smrg# --------------------- 2322949d0342Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2323949d0342Smrg# object suffix. 2324949d0342Smrg 2325949d0342Smrglo2o=s/\\.lo\$/.$objext/ 2326949d0342Smrgo2lo=s/\\.$objext\$/.lo/ 2327949d0342Smrg 2328949d0342Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2329949d0342Smrg eval 'func_lo2o () 2330949d0342Smrg { 2331949d0342Smrg case $1 in 2332949d0342Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2333949d0342Smrg * ) func_lo2o_result=$1 ;; 2334949d0342Smrg esac 2335949d0342Smrg }' 2336949d0342Smrg 2337949d0342Smrg # func_xform LIBOBJ-OR-SOURCE 2338949d0342Smrg # --------------------------- 2339949d0342Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2340949d0342Smrg # suffix to a '.lo' libtool-object suffix. 2341949d0342Smrg eval 'func_xform () 2342949d0342Smrg { 2343949d0342Smrg func_xform_result=${1%.*}.lo 2344949d0342Smrg }' 2345949d0342Smrgelse 2346949d0342Smrg # ...otherwise fall back to using sed. 2347949d0342Smrg func_lo2o () 2348949d0342Smrg { 2349949d0342Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2350949d0342Smrg } 2351949d0342Smrg 2352949d0342Smrg func_xform () 2353949d0342Smrg { 2354949d0342Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2355949d0342Smrg } 2356949d0342Smrgfi 2357cdbfa18aSmrg 2358cdbfa18aSmrg 2359949d0342Smrg# func_fatal_configuration ARG... 2360949d0342Smrg# ------------------------------- 2361d5c3dbf1Smrg# Echo program name prefixed message to standard error, followed by 2362d5c3dbf1Smrg# a configuration failure hint, and exit. 2363d5c3dbf1Smrgfunc_fatal_configuration () 2364d5c3dbf1Smrg{ 2365949d0342Smrg func_fatal_error ${1+"$@"} \ 2366949d0342Smrg "See the $PACKAGE documentation for more information." \ 2367949d0342Smrg "Fatal configuration error." 2368d5c3dbf1Smrg} 2369d5c3dbf1Smrg 2370d5c3dbf1Smrg 2371d5c3dbf1Smrg# func_config 2372949d0342Smrg# ----------- 2373d5c3dbf1Smrg# Display the configuration for all the tags in this script. 2374d5c3dbf1Smrgfunc_config () 2375d5c3dbf1Smrg{ 2376d5c3dbf1Smrg re_begincf='^# ### BEGIN LIBTOOL' 2377d5c3dbf1Smrg re_endcf='^# ### END LIBTOOL' 2378d5c3dbf1Smrg 2379d5c3dbf1Smrg # Default configuration. 2380d5c3dbf1Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381d5c3dbf1Smrg 23829f606849Smrg # Now print the configurations for the tags. 23839f606849Smrg for tagname in $taglist; do 2384d5c3dbf1Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23859f606849Smrg done 23869f606849Smrg 2387d5c3dbf1Smrg exit $? 2388d5c3dbf1Smrg} 23899f606849Smrg 2390949d0342Smrg 2391d5c3dbf1Smrg# func_features 2392949d0342Smrg# ------------- 2393d5c3dbf1Smrg# Display the features supported by this script. 2394d5c3dbf1Smrgfunc_features () 2395d5c3dbf1Smrg{ 2396d5c3dbf1Smrg echo "host: $host" 2397949d0342Smrg if test yes = "$build_libtool_libs"; then 2398d5c3dbf1Smrg echo "enable shared libraries" 23999f606849Smrg else 2400d5c3dbf1Smrg echo "disable shared libraries" 24019f606849Smrg fi 2402949d0342Smrg if test yes = "$build_old_libs"; then 2403d5c3dbf1Smrg echo "enable static libraries" 24049f606849Smrg else 2405d5c3dbf1Smrg echo "disable static libraries" 24069f606849Smrg fi 2407d5c3dbf1Smrg 24089f606849Smrg exit $? 2409d5c3dbf1Smrg} 24109f606849Smrg 2411949d0342Smrg 2412949d0342Smrg# func_enable_tag TAGNAME 2413949d0342Smrg# ----------------------- 2414d5c3dbf1Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415d5c3dbf1Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416d5c3dbf1Smrg# variable here. 2417d5c3dbf1Smrgfunc_enable_tag () 2418d5c3dbf1Smrg{ 2419949d0342Smrg # Global variable: 2420949d0342Smrg tagname=$1 24219f606849Smrg 2422949d0342Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2423949d0342Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2424949d0342Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24259f606849Smrg 2426949d0342Smrg # Validate tagname. 2427949d0342Smrg case $tagname in 2428949d0342Smrg *[!-_A-Za-z0-9,/]*) 2429949d0342Smrg func_fatal_error "invalid tag name: $tagname" 2430949d0342Smrg ;; 2431949d0342Smrg esac 24329f606849Smrg 2433949d0342Smrg # Don't test for the "default" C tag, as we know it's 2434949d0342Smrg # there but not specially marked. 2435949d0342Smrg case $tagname in 2436949d0342Smrg CC) ;; 2437d5c3dbf1Smrg *) 2438949d0342Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2439949d0342Smrg taglist="$taglist $tagname" 2440949d0342Smrg 2441949d0342Smrg # Evaluate the configuration. Be careful to quote the path 2442949d0342Smrg # and the sed script, to avoid splitting on whitespace, but 2443949d0342Smrg # also don't use non-portable quotes within backquotes within 2444949d0342Smrg # quotes we have to do it in 2 steps: 2445949d0342Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2446949d0342Smrg eval "$extractedcf" 2447949d0342Smrg else 2448949d0342Smrg func_error "ignoring unknown tag $tagname" 2449949d0342Smrg fi 2450949d0342Smrg ;; 2451949d0342Smrg esac 2452d5c3dbf1Smrg} 2453d5c3dbf1Smrg 2454949d0342Smrg 2455cdbfa18aSmrg# func_check_version_match 2456949d0342Smrg# ------------------------ 2457cdbfa18aSmrg# Ensure that we are using m4 macros, and libtool script from the same 2458cdbfa18aSmrg# release of libtool. 2459cdbfa18aSmrgfunc_check_version_match () 2460d5c3dbf1Smrg{ 2461949d0342Smrg if test "$package_revision" != "$macro_revision"; then 2462949d0342Smrg if test "$VERSION" != "$macro_version"; then 2463949d0342Smrg if test -z "$macro_version"; then 2464949d0342Smrg cat >&2 <<_LT_EOF 2465cdbfa18aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466cdbfa18aSmrg$progname: definition of this LT_INIT comes from an older release. 2467cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468cdbfa18aSmrg$progname: and run autoconf again. 2469cdbfa18aSmrg_LT_EOF 2470949d0342Smrg else 2471949d0342Smrg cat >&2 <<_LT_EOF 2472cdbfa18aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473cdbfa18aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475cdbfa18aSmrg$progname: and run autoconf again. 2476cdbfa18aSmrg_LT_EOF 2477949d0342Smrg fi 2478949d0342Smrg else 2479949d0342Smrg cat >&2 <<_LT_EOF 2480cdbfa18aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481cdbfa18aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483cdbfa18aSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484cdbfa18aSmrg_LT_EOF 2485949d0342Smrg fi 2486cdbfa18aSmrg 2487949d0342Smrg exit $EXIT_MISMATCH 2488949d0342Smrg fi 2489cdbfa18aSmrg} 2490cdbfa18aSmrg 2491cdbfa18aSmrg 2492949d0342Smrg# libtool_options_prep [ARG]... 2493949d0342Smrg# ----------------------------- 2494949d0342Smrg# Preparation for options parsed by libtool. 2495949d0342Smrglibtool_options_prep () 2496949d0342Smrg{ 2497949d0342Smrg $debug_mode 2498cdbfa18aSmrg 2499949d0342Smrg # Option defaults: 2500949d0342Smrg opt_config=false 2501949d0342Smrg opt_dlopen= 2502949d0342Smrg opt_dry_run=false 2503949d0342Smrg opt_help=false 2504949d0342Smrg opt_mode= 2505949d0342Smrg opt_preserve_dup_deps=false 2506949d0342Smrg opt_quiet=false 2507cdbfa18aSmrg 2508949d0342Smrg nonopt= 2509949d0342Smrg preserve_args= 25109f606849Smrg 2511949d0342Smrg _G_rc_lt_options_prep=: 25129f606849Smrg 2513949d0342Smrg # Shorthand for --mode=foo, only valid as the first argument 2514949d0342Smrg case $1 in 2515949d0342Smrg clean|clea|cle|cl) 2516949d0342Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2517949d0342Smrg ;; 2518949d0342Smrg compile|compil|compi|comp|com|co|c) 2519949d0342Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2520949d0342Smrg ;; 2521949d0342Smrg execute|execut|execu|exec|exe|ex|e) 2522949d0342Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2523949d0342Smrg ;; 2524949d0342Smrg finish|finis|fini|fin|fi|f) 2525949d0342Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2526949d0342Smrg ;; 2527949d0342Smrg install|instal|insta|inst|ins|in|i) 2528949d0342Smrg shift; set dummy --mode install ${1+"$@"}; shift 2529949d0342Smrg ;; 2530949d0342Smrg link|lin|li|l) 2531949d0342Smrg shift; set dummy --mode link ${1+"$@"}; shift 2532949d0342Smrg ;; 2533949d0342Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2534949d0342Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2535949d0342Smrg ;; 2536949d0342Smrg *) 2537949d0342Smrg _G_rc_lt_options_prep=false 2538949d0342Smrg ;; 2539d5c3dbf1Smrg esac 2540d5c3dbf1Smrg 2541949d0342Smrg if $_G_rc_lt_options_prep; then 2542949d0342Smrg # Pass back the list of options. 2543949d0342Smrg func_quote eval ${1+"$@"} 2544949d0342Smrg libtool_options_prep_result=$func_quote_result 2545949d0342Smrg fi 2546949d0342Smrg} 2547949d0342Smrgfunc_add_hook func_options_prep libtool_options_prep 2548cdbfa18aSmrg 2549cdbfa18aSmrg 2550949d0342Smrg# libtool_parse_options [ARG]... 2551949d0342Smrg# --------------------------------- 2552949d0342Smrg# Provide handling for libtool specific options. 2553949d0342Smrglibtool_parse_options () 2554949d0342Smrg{ 2555949d0342Smrg $debug_cmd 2556d5c3dbf1Smrg 2557949d0342Smrg _G_rc_lt_parse_options=false 25589f606849Smrg 2559949d0342Smrg # Perform our own loop to consume as many options as possible in 2560949d0342Smrg # each iteration. 2561949d0342Smrg while test $# -gt 0; do 2562949d0342Smrg _G_match_lt_parse_options=: 2563949d0342Smrg _G_opt=$1 2564949d0342Smrg shift 2565949d0342Smrg case $_G_opt in 2566949d0342Smrg --dry-run|--dryrun|-n) 2567949d0342Smrg opt_dry_run=: 2568949d0342Smrg ;; 2569949d0342Smrg 2570949d0342Smrg --config) func_config ;; 2571949d0342Smrg 2572949d0342Smrg --dlopen|-dlopen) 2573949d0342Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2574949d0342Smrg}$1" 2575949d0342Smrg shift 2576949d0342Smrg ;; 2577949d0342Smrg 2578949d0342Smrg --preserve-dup-deps) 2579949d0342Smrg opt_preserve_dup_deps=: ;; 2580949d0342Smrg 2581949d0342Smrg --features) func_features ;; 2582949d0342Smrg 2583949d0342Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2584949d0342Smrg 2585949d0342Smrg --help) opt_help=: ;; 2586949d0342Smrg 2587949d0342Smrg --help-all) opt_help=': help-all' ;; 2588949d0342Smrg 2589949d0342Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2590949d0342Smrg opt_mode=$1 2591949d0342Smrg case $1 in 2592949d0342Smrg # Valid mode arguments: 2593949d0342Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2594949d0342Smrg 2595949d0342Smrg # Catch anything else as an error 2596949d0342Smrg *) func_error "invalid argument for $_G_opt" 2597949d0342Smrg exit_cmd=exit 2598949d0342Smrg break 2599949d0342Smrg ;; 2600949d0342Smrg esac 2601949d0342Smrg shift 2602949d0342Smrg ;; 2603949d0342Smrg 2604949d0342Smrg --no-silent|--no-quiet) 2605949d0342Smrg opt_quiet=false 2606949d0342Smrg func_append preserve_args " $_G_opt" 2607949d0342Smrg ;; 2608949d0342Smrg 2609949d0342Smrg --no-warnings|--no-warning|--no-warn) 2610949d0342Smrg opt_warning=false 2611949d0342Smrg func_append preserve_args " $_G_opt" 2612949d0342Smrg ;; 2613949d0342Smrg 2614949d0342Smrg --no-verbose) 2615949d0342Smrg opt_verbose=false 2616949d0342Smrg func_append preserve_args " $_G_opt" 2617949d0342Smrg ;; 2618949d0342Smrg 2619949d0342Smrg --silent|--quiet) 2620949d0342Smrg opt_quiet=: 2621949d0342Smrg opt_verbose=false 2622949d0342Smrg func_append preserve_args " $_G_opt" 2623949d0342Smrg ;; 2624949d0342Smrg 2625949d0342Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2626949d0342Smrg opt_tag=$1 2627949d0342Smrg func_append preserve_args " $_G_opt $1" 2628949d0342Smrg func_enable_tag "$1" 2629949d0342Smrg shift 2630949d0342Smrg ;; 2631949d0342Smrg 2632949d0342Smrg --verbose|-v) opt_quiet=false 2633949d0342Smrg opt_verbose=: 2634949d0342Smrg func_append preserve_args " $_G_opt" 2635949d0342Smrg ;; 2636949d0342Smrg 2637949d0342Smrg # An option not handled by this hook function: 2638949d0342Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639949d0342Smrg _G_match_lt_parse_options=false 2640949d0342Smrg break 2641949d0342Smrg ;; 2642949d0342Smrg esac 2643949d0342Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2644949d0342Smrg done 2645d5c3dbf1Smrg 2646949d0342Smrg if $_G_rc_lt_parse_options; then 2647949d0342Smrg # save modified positional parameters for caller 2648949d0342Smrg func_quote eval ${1+"$@"} 2649949d0342Smrg libtool_parse_options_result=$func_quote_result 2650d5c3dbf1Smrg fi 2651949d0342Smrg} 2652949d0342Smrgfunc_add_hook func_parse_options libtool_parse_options 2653949d0342Smrg 2654d5c3dbf1Smrg 2655d5c3dbf1Smrg 2656949d0342Smrg# libtool_validate_options [ARG]... 2657949d0342Smrg# --------------------------------- 2658949d0342Smrg# Perform any sanity checks on option settings and/or unconsumed 2659949d0342Smrg# arguments. 2660949d0342Smrglibtool_validate_options () 2661949d0342Smrg{ 2662949d0342Smrg # save first non-option argument 2663949d0342Smrg if test 0 -lt $#; then 2664949d0342Smrg nonopt=$1 2665949d0342Smrg shift 2666cdbfa18aSmrg fi 2667d5c3dbf1Smrg 2668949d0342Smrg # preserve --debug 2669949d0342Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670949d0342Smrg 2671949d0342Smrg case $host in 2672949d0342Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2673949d0342Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2674949d0342Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2675949d0342Smrg # don't eliminate duplications in $postdeps and $predeps 2676949d0342Smrg opt_duplicate_compiler_generated_deps=: 2677949d0342Smrg ;; 2678949d0342Smrg *) 2679949d0342Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2680949d0342Smrg ;; 2681949d0342Smrg esac 2682949d0342Smrg 2683949d0342Smrg $opt_help || { 2684949d0342Smrg # Sanity checks first: 2685949d0342Smrg func_check_version_match 2686949d0342Smrg 2687949d0342Smrg test yes != "$build_libtool_libs" \ 2688949d0342Smrg && test yes != "$build_old_libs" \ 2689949d0342Smrg && func_fatal_configuration "not configured to build any kind of library" 2690949d0342Smrg 2691949d0342Smrg # Darwin sucks 2692949d0342Smrg eval std_shrext=\"$shrext_cmds\" 2693d5c3dbf1Smrg 2694949d0342Smrg # Only execute mode is allowed to have -dlopen flags. 2695949d0342Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2696949d0342Smrg func_error "unrecognized option '-dlopen'" 2697949d0342Smrg $ECHO "$help" 1>&2 2698949d0342Smrg exit $EXIT_FAILURE 2699949d0342Smrg fi 2700949d0342Smrg 2701949d0342Smrg # Change the help message to a mode-specific one. 2702949d0342Smrg generic_help=$help 2703949d0342Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2704949d0342Smrg } 2705d5c3dbf1Smrg 2706949d0342Smrg # Pass back the unparsed argument list 2707949d0342Smrg func_quote eval ${1+"$@"} 2708949d0342Smrg libtool_validate_options_result=$func_quote_result 2709cdbfa18aSmrg} 2710949d0342Smrgfunc_add_hook func_validate_options libtool_validate_options 2711949d0342Smrg 2712d5c3dbf1Smrg 2713949d0342Smrg# Process options as early as possible so that --help and --version 2714949d0342Smrg# can return quickly. 2715949d0342Smrgfunc_options ${1+"$@"} 2716949d0342Smrgeval set dummy "$func_options_result"; shift 2717d5c3dbf1Smrg 27189f606849Smrg 27199f606849Smrg 2720cdbfa18aSmrg## ----------- ## 2721cdbfa18aSmrg## Main. ## 2722cdbfa18aSmrg## ----------- ## 27239f606849Smrg 2724949d0342Smrgmagic='%%%MAGIC variable%%%' 2725949d0342Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2726949d0342Smrg 2727949d0342Smrg# Global variables. 2728949d0342Smrgextracted_archives= 2729949d0342Smrgextracted_serial=0 2730949d0342Smrg 2731949d0342Smrg# If this variable is set in any of the actions, the command in it 2732949d0342Smrg# will be execed at the end. This prevents here-documents from being 2733949d0342Smrg# left over by shells. 2734949d0342Smrgexec_cmd= 2735949d0342Smrg 2736949d0342Smrg 2737949d0342Smrg# A function that is used when there is no print builtin or printf. 2738949d0342Smrgfunc_fallback_echo () 2739949d0342Smrg{ 2740949d0342Smrg eval 'cat <<_LTECHO_EOF 2741949d0342Smrg$1 2742949d0342Smrg_LTECHO_EOF' 2743949d0342Smrg} 2744949d0342Smrg 2745949d0342Smrg# func_generated_by_libtool 2746949d0342Smrg# True iff stdin has been generated by Libtool. This function is only 2747949d0342Smrg# a basic sanity check; it will hardly flush out determined imposters. 2748949d0342Smrgfunc_generated_by_libtool_p () 2749949d0342Smrg{ 2750949d0342Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2751949d0342Smrg} 2752949d0342Smrg 2753d5c3dbf1Smrg# func_lalib_p file 2754949d0342Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2756d5c3dbf1Smrg# determined imposters. 2757d5c3dbf1Smrgfunc_lalib_p () 2758d5c3dbf1Smrg{ 2759d5c3dbf1Smrg test -f "$1" && 2760949d0342Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761d5c3dbf1Smrg} 27629f606849Smrg 2763d5c3dbf1Smrg# func_lalib_unsafe_p file 2764949d0342Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765d5c3dbf1Smrg# This function implements the same check as func_lalib_p without 2766d5c3dbf1Smrg# resorting to external programs. To this end, it redirects stdin and 2767d5c3dbf1Smrg# closes it afterwards, without saving the original file descriptor. 2768d5c3dbf1Smrg# As a safety measure, use it only where a negative result would be 2769949d0342Smrg# fatal anyway. Works if 'file' does not exist. 2770d5c3dbf1Smrgfunc_lalib_unsafe_p () 2771d5c3dbf1Smrg{ 2772d5c3dbf1Smrg lalib_p=no 2773d5c3dbf1Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774d5c3dbf1Smrg for lalib_p_l in 1 2 3 4 2775d5c3dbf1Smrg do 2776d5c3dbf1Smrg read lalib_p_line 2777949d0342Smrg case $lalib_p_line in 2778d5c3dbf1Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779d5c3dbf1Smrg esac 2780d5c3dbf1Smrg done 2781d5c3dbf1Smrg exec 0<&5 5<&- 2782d5c3dbf1Smrg fi 2783949d0342Smrg test yes = "$lalib_p" 2784d5c3dbf1Smrg} 27859f606849Smrg 2786d5c3dbf1Smrg# func_ltwrapper_script_p file 2787d5c3dbf1Smrg# True iff FILE is a libtool wrapper script 2788d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2789d5c3dbf1Smrg# determined imposters. 2790d5c3dbf1Smrgfunc_ltwrapper_script_p () 2791d5c3dbf1Smrg{ 2792949d0342Smrg test -f "$1" && 2793949d0342Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794d5c3dbf1Smrg} 27959f606849Smrg 2796d5c3dbf1Smrg# func_ltwrapper_executable_p file 2797d5c3dbf1Smrg# True iff FILE is a libtool wrapper executable 2798d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2799d5c3dbf1Smrg# determined imposters. 2800d5c3dbf1Smrgfunc_ltwrapper_executable_p () 2801d5c3dbf1Smrg{ 2802d5c3dbf1Smrg func_ltwrapper_exec_suffix= 2803d5c3dbf1Smrg case $1 in 2804d5c3dbf1Smrg *.exe) ;; 2805d5c3dbf1Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2806d5c3dbf1Smrg esac 2807d5c3dbf1Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808d5c3dbf1Smrg} 2809d5c3dbf1Smrg 2810d5c3dbf1Smrg# func_ltwrapper_scriptname file 2811d5c3dbf1Smrg# Assumes file is an ltwrapper_executable 2812d5c3dbf1Smrg# uses $file to determine the appropriate filename for a 2813d5c3dbf1Smrg# temporary ltwrapper_script. 2814d5c3dbf1Smrgfunc_ltwrapper_scriptname () 2815d5c3dbf1Smrg{ 2816cdbfa18aSmrg func_dirname_and_basename "$1" "" "." 2817cdbfa18aSmrg func_stripname '' '.exe' "$func_basename_result" 2818949d0342Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819d5c3dbf1Smrg} 2820d5c3dbf1Smrg 2821d5c3dbf1Smrg# func_ltwrapper_p file 2822d5c3dbf1Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2823d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out 2824d5c3dbf1Smrg# determined imposters. 2825d5c3dbf1Smrgfunc_ltwrapper_p () 2826d5c3dbf1Smrg{ 2827d5c3dbf1Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828d5c3dbf1Smrg} 2829d5c3dbf1Smrg 2830d5c3dbf1Smrg 2831d5c3dbf1Smrg# func_execute_cmds commands fail_cmd 2832d5c3dbf1Smrg# Execute tilde-delimited COMMANDS. 2833d5c3dbf1Smrg# If FAIL_CMD is given, eval that upon failure. 2834d5c3dbf1Smrg# FAIL_CMD may read-access the current command in variable CMD! 2835d5c3dbf1Smrgfunc_execute_cmds () 2836d5c3dbf1Smrg{ 2837949d0342Smrg $debug_cmd 2838949d0342Smrg 2839d5c3dbf1Smrg save_ifs=$IFS; IFS='~' 2840d5c3dbf1Smrg for cmd in $1; do 2841949d0342Smrg IFS=$sp$nl 2842d5c3dbf1Smrg eval cmd=\"$cmd\" 2843949d0342Smrg IFS=$save_ifs 2844d5c3dbf1Smrg func_show_eval "$cmd" "${2-:}" 2845d5c3dbf1Smrg done 2846d5c3dbf1Smrg IFS=$save_ifs 2847d5c3dbf1Smrg} 2848d5c3dbf1Smrg 2849d5c3dbf1Smrg 2850d5c3dbf1Smrg# func_source file 2851d5c3dbf1Smrg# Source FILE, adding directory component if necessary. 2852d5c3dbf1Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853d5c3dbf1Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854d5c3dbf1Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2855949d0342Smrg# 'FILE.' does not work on cygwin managed mounts. 2856d5c3dbf1Smrgfunc_source () 2857d5c3dbf1Smrg{ 2858949d0342Smrg $debug_cmd 2859949d0342Smrg 2860d5c3dbf1Smrg case $1 in 2861d5c3dbf1Smrg */* | *\\*) . "$1" ;; 2862d5c3dbf1Smrg *) . "./$1" ;; 2863d5c3dbf1Smrg esac 2864d5c3dbf1Smrg} 2865d5c3dbf1Smrg 2866d5c3dbf1Smrg 2867cdbfa18aSmrg# func_resolve_sysroot PATH 2868cdbfa18aSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2869cdbfa18aSmrg# func_resolve_sysroot_result 2870cdbfa18aSmrgfunc_resolve_sysroot () 2871cdbfa18aSmrg{ 2872cdbfa18aSmrg func_resolve_sysroot_result=$1 2873cdbfa18aSmrg case $func_resolve_sysroot_result in 2874cdbfa18aSmrg =*) 2875cdbfa18aSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876cdbfa18aSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877cdbfa18aSmrg ;; 2878cdbfa18aSmrg esac 2879cdbfa18aSmrg} 2880cdbfa18aSmrg 2881cdbfa18aSmrg# func_replace_sysroot PATH 2882cdbfa18aSmrg# If PATH begins with the sysroot, replace it with = and 2883cdbfa18aSmrg# store the result into func_replace_sysroot_result. 2884cdbfa18aSmrgfunc_replace_sysroot () 2885cdbfa18aSmrg{ 2886949d0342Smrg case $lt_sysroot:$1 in 2887cdbfa18aSmrg ?*:"$lt_sysroot"*) 2888cdbfa18aSmrg func_stripname "$lt_sysroot" '' "$1" 2889949d0342Smrg func_replace_sysroot_result='='$func_stripname_result 2890cdbfa18aSmrg ;; 2891cdbfa18aSmrg *) 2892cdbfa18aSmrg # Including no sysroot. 2893cdbfa18aSmrg func_replace_sysroot_result=$1 2894cdbfa18aSmrg ;; 2895cdbfa18aSmrg esac 2896cdbfa18aSmrg} 2897cdbfa18aSmrg 2898d5c3dbf1Smrg# func_infer_tag arg 2899d5c3dbf1Smrg# Infer tagged configuration to use if any are available and 2900d5c3dbf1Smrg# if one wasn't chosen via the "--tag" command line option. 2901d5c3dbf1Smrg# Only attempt this if the compiler in the base compile 2902d5c3dbf1Smrg# command doesn't match the default compiler. 2903d5c3dbf1Smrg# arg is usually of the form 'gcc ...' 2904d5c3dbf1Smrgfunc_infer_tag () 2905d5c3dbf1Smrg{ 2906949d0342Smrg $debug_cmd 2907949d0342Smrg 2908d5c3dbf1Smrg if test -n "$available_tags" && test -z "$tagname"; then 2909d5c3dbf1Smrg CC_quoted= 2910d5c3dbf1Smrg for arg in $CC; do 2911cdbfa18aSmrg func_append_quoted CC_quoted "$arg" 2912d5c3dbf1Smrg done 2913d5c3dbf1Smrg CC_expanded=`func_echo_all $CC` 2914d5c3dbf1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915d5c3dbf1Smrg case $@ in 2916d5c3dbf1Smrg # Blanks in the command may have been stripped by the calling shell, 2917d5c3dbf1Smrg # but not from the CC environment variable when configure was run. 2918d5c3dbf1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919d5c3dbf1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920d5c3dbf1Smrg # Blanks at the start of $base_compile will cause this to fail 2921d5c3dbf1Smrg # if we don't check for them as well. 2922d5c3dbf1Smrg *) 2923d5c3dbf1Smrg for z in $available_tags; do 2924d5c3dbf1Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925d5c3dbf1Smrg # Evaluate the configuration. 2926949d0342Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927d5c3dbf1Smrg CC_quoted= 2928d5c3dbf1Smrg for arg in $CC; do 2929d5c3dbf1Smrg # Double-quote args containing other shell metacharacters. 2930cdbfa18aSmrg func_append_quoted CC_quoted "$arg" 2931d5c3dbf1Smrg done 2932d5c3dbf1Smrg CC_expanded=`func_echo_all $CC` 2933d5c3dbf1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934d5c3dbf1Smrg case "$@ " in 2935d5c3dbf1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936d5c3dbf1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937d5c3dbf1Smrg # The compiler in the base compile command matches 2938d5c3dbf1Smrg # the one in the tagged configuration. 2939d5c3dbf1Smrg # Assume this is the tagged configuration we want. 2940d5c3dbf1Smrg tagname=$z 2941d5c3dbf1Smrg break 2942d5c3dbf1Smrg ;; 2943d5c3dbf1Smrg esac 2944d5c3dbf1Smrg fi 2945d5c3dbf1Smrg done 2946d5c3dbf1Smrg # If $tagname still isn't set, then no tagged configuration 2947d5c3dbf1Smrg # was found and let the user know that the "--tag" command 2948d5c3dbf1Smrg # line option must be used. 2949d5c3dbf1Smrg if test -z "$tagname"; then 2950d5c3dbf1Smrg func_echo "unable to infer tagged configuration" 2951949d0342Smrg func_fatal_error "specify a tag with '--tag'" 2952d5c3dbf1Smrg# else 2953d5c3dbf1Smrg# func_verbose "using $tagname tagged configuration" 2954d5c3dbf1Smrg fi 2955d5c3dbf1Smrg ;; 2956d5c3dbf1Smrg esac 2957d5c3dbf1Smrg fi 2958d5c3dbf1Smrg} 2959d5c3dbf1Smrg 2960d5c3dbf1Smrg 2961cdbfa18aSmrg 2962cdbfa18aSmrg# func_write_libtool_object output_name pic_name nonpic_name 2963cdbfa18aSmrg# Create a libtool object file (analogous to a ".la" file), 2964cdbfa18aSmrg# but don't create it if we're doing a dry run. 2965cdbfa18aSmrgfunc_write_libtool_object () 2966cdbfa18aSmrg{ 2967949d0342Smrg write_libobj=$1 2968949d0342Smrg if test yes = "$build_libtool_libs"; then 2969949d0342Smrg write_lobj=\'$2\' 2970cdbfa18aSmrg else 2971cdbfa18aSmrg write_lobj=none 2972cdbfa18aSmrg fi 2973cdbfa18aSmrg 2974949d0342Smrg if test yes = "$build_old_libs"; then 2975949d0342Smrg write_oldobj=\'$3\' 2976cdbfa18aSmrg else 2977cdbfa18aSmrg write_oldobj=none 2978cdbfa18aSmrg fi 2979cdbfa18aSmrg 2980cdbfa18aSmrg $opt_dry_run || { 2981cdbfa18aSmrg cat >${write_libobj}T <<EOF 2982cdbfa18aSmrg# $write_libobj - a libtool object file 2983949d0342Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984cdbfa18aSmrg# 2985cdbfa18aSmrg# Please DO NOT delete this file! 2986cdbfa18aSmrg# It is necessary for linking the library. 2987cdbfa18aSmrg 2988cdbfa18aSmrg# Name of the PIC object. 2989cdbfa18aSmrgpic_object=$write_lobj 2990cdbfa18aSmrg 2991cdbfa18aSmrg# Name of the non-PIC object 2992cdbfa18aSmrgnon_pic_object=$write_oldobj 2993cdbfa18aSmrg 2994cdbfa18aSmrgEOF 2995949d0342Smrg $MV "${write_libobj}T" "$write_libobj" 2996cdbfa18aSmrg } 2997cdbfa18aSmrg} 2998cdbfa18aSmrg 2999cdbfa18aSmrg 3000cdbfa18aSmrg################################################## 3001cdbfa18aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002cdbfa18aSmrg################################################## 3003cdbfa18aSmrg 3004cdbfa18aSmrg# func_convert_core_file_wine_to_w32 ARG 3005cdbfa18aSmrg# Helper function used by file name conversion functions when $build is *nix, 3006cdbfa18aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007cdbfa18aSmrg# correctly configured wine environment available, with the winepath program 3008cdbfa18aSmrg# in $build's $PATH. 3009cdbfa18aSmrg# 3010cdbfa18aSmrg# ARG is the $build file name to be converted to w32 format. 3011cdbfa18aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012cdbfa18aSmrg# be empty on error (or when ARG is empty) 3013cdbfa18aSmrgfunc_convert_core_file_wine_to_w32 () 3014cdbfa18aSmrg{ 3015949d0342Smrg $debug_cmd 3016949d0342Smrg 3017949d0342Smrg func_convert_core_file_wine_to_w32_result=$1 3018cdbfa18aSmrg if test -n "$1"; then 3019cdbfa18aSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020cdbfa18aSmrg # are forced to check the contents of stdout. On the other hand, if the 3021cdbfa18aSmrg # command is not found, the shell will set an exit code of 127 and print 3022cdbfa18aSmrg # *an error message* to stdout. So we must check for both error code of 3023cdbfa18aSmrg # zero AND non-empty stdout, which explains the odd construction: 3024cdbfa18aSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3025949d0342Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026cdbfa18aSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3027949d0342Smrg $SED -e "$sed_naive_backslashify"` 3028cdbfa18aSmrg else 3029cdbfa18aSmrg func_convert_core_file_wine_to_w32_result= 3030cdbfa18aSmrg fi 3031cdbfa18aSmrg fi 3032cdbfa18aSmrg} 3033cdbfa18aSmrg# end: func_convert_core_file_wine_to_w32 3034cdbfa18aSmrg 3035cdbfa18aSmrg 3036cdbfa18aSmrg# func_convert_core_path_wine_to_w32 ARG 3037cdbfa18aSmrg# Helper function used by path conversion functions when $build is *nix, and 3038cdbfa18aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039cdbfa18aSmrg# configured wine environment available, with the winepath program in $build's 3040cdbfa18aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041cdbfa18aSmrg# 3042cdbfa18aSmrg# ARG is path to be converted from $build format to win32. 3043cdbfa18aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044cdbfa18aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045cdbfa18aSmrg# are convertible, then the result may be empty. 3046cdbfa18aSmrgfunc_convert_core_path_wine_to_w32 () 3047cdbfa18aSmrg{ 3048949d0342Smrg $debug_cmd 3049949d0342Smrg 3050cdbfa18aSmrg # unfortunately, winepath doesn't convert paths, only file names 3051949d0342Smrg func_convert_core_path_wine_to_w32_result= 3052cdbfa18aSmrg if test -n "$1"; then 3053cdbfa18aSmrg oldIFS=$IFS 3054cdbfa18aSmrg IFS=: 3055cdbfa18aSmrg for func_convert_core_path_wine_to_w32_f in $1; do 3056cdbfa18aSmrg IFS=$oldIFS 3057cdbfa18aSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3058949d0342Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059cdbfa18aSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3060949d0342Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061cdbfa18aSmrg else 3062cdbfa18aSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063cdbfa18aSmrg fi 3064cdbfa18aSmrg fi 3065cdbfa18aSmrg done 3066cdbfa18aSmrg IFS=$oldIFS 3067cdbfa18aSmrg fi 3068cdbfa18aSmrg} 3069cdbfa18aSmrg# end: func_convert_core_path_wine_to_w32 3070cdbfa18aSmrg 3071cdbfa18aSmrg 3072cdbfa18aSmrg# func_cygpath ARGS... 3073cdbfa18aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074cdbfa18aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075cdbfa18aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076cdbfa18aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077cdbfa18aSmrg# file name or path is assumed to be in w32 format, as previously converted 3078cdbfa18aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079cdbfa18aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080cdbfa18aSmrg# Cygwin format). Returns an empty string on error. 3081cdbfa18aSmrg# 3082cdbfa18aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083cdbfa18aSmrg# be converted. 3084cdbfa18aSmrg# 3085cdbfa18aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086cdbfa18aSmrg# environment variable; do not put it in $PATH. 3087cdbfa18aSmrgfunc_cygpath () 3088cdbfa18aSmrg{ 3089949d0342Smrg $debug_cmd 3090949d0342Smrg 3091cdbfa18aSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092cdbfa18aSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093cdbfa18aSmrg if test "$?" -ne 0; then 3094cdbfa18aSmrg # on failure, ensure result is empty 3095cdbfa18aSmrg func_cygpath_result= 3096cdbfa18aSmrg fi 3097cdbfa18aSmrg else 3098cdbfa18aSmrg func_cygpath_result= 3099949d0342Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100cdbfa18aSmrg fi 3101cdbfa18aSmrg} 3102cdbfa18aSmrg#end: func_cygpath 3103cdbfa18aSmrg 3104cdbfa18aSmrg 3105cdbfa18aSmrg# func_convert_core_msys_to_w32 ARG 3106cdbfa18aSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107cdbfa18aSmrg# result in func_convert_core_msys_to_w32_result. 3108cdbfa18aSmrgfunc_convert_core_msys_to_w32 () 3109cdbfa18aSmrg{ 3110949d0342Smrg $debug_cmd 3111949d0342Smrg 3112cdbfa18aSmrg # awkward: cmd appends spaces to result 3113cdbfa18aSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3114949d0342Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115cdbfa18aSmrg} 3116cdbfa18aSmrg#end: func_convert_core_msys_to_w32 3117cdbfa18aSmrg 3118cdbfa18aSmrg 3119cdbfa18aSmrg# func_convert_file_check ARG1 ARG2 3120cdbfa18aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121cdbfa18aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122cdbfa18aSmrg# func_to_host_file_result to ARG1). 3123cdbfa18aSmrgfunc_convert_file_check () 3124cdbfa18aSmrg{ 3125949d0342Smrg $debug_cmd 3126949d0342Smrg 3127949d0342Smrg if test -z "$2" && test -n "$1"; then 3128cdbfa18aSmrg func_error "Could not determine host file name corresponding to" 3129949d0342Smrg func_error " '$1'" 3130cdbfa18aSmrg func_error "Continuing, but uninstalled executables may not work." 3131cdbfa18aSmrg # Fallback: 3132949d0342Smrg func_to_host_file_result=$1 3133cdbfa18aSmrg fi 3134cdbfa18aSmrg} 3135cdbfa18aSmrg# end func_convert_file_check 3136cdbfa18aSmrg 3137cdbfa18aSmrg 3138cdbfa18aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139cdbfa18aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140cdbfa18aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141cdbfa18aSmrg# func_to_host_file_result to a simplistic fallback value (see below). 3142cdbfa18aSmrgfunc_convert_path_check () 3143cdbfa18aSmrg{ 3144949d0342Smrg $debug_cmd 3145949d0342Smrg 3146cdbfa18aSmrg if test -z "$4" && test -n "$3"; then 3147cdbfa18aSmrg func_error "Could not determine the host path corresponding to" 3148949d0342Smrg func_error " '$3'" 3149cdbfa18aSmrg func_error "Continuing, but uninstalled executables may not work." 3150cdbfa18aSmrg # Fallback. This is a deliberately simplistic "conversion" and 3151cdbfa18aSmrg # should not be "improved". See libtool.info. 3152cdbfa18aSmrg if test "x$1" != "x$2"; then 3153cdbfa18aSmrg lt_replace_pathsep_chars="s|$1|$2|g" 3154cdbfa18aSmrg func_to_host_path_result=`echo "$3" | 3155cdbfa18aSmrg $SED -e "$lt_replace_pathsep_chars"` 3156cdbfa18aSmrg else 3157949d0342Smrg func_to_host_path_result=$3 3158cdbfa18aSmrg fi 3159cdbfa18aSmrg fi 3160cdbfa18aSmrg} 3161cdbfa18aSmrg# end func_convert_path_check 3162cdbfa18aSmrg 3163cdbfa18aSmrg 3164cdbfa18aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165cdbfa18aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166cdbfa18aSmrg# and appending REPL if ORIG matches BACKPAT. 3167cdbfa18aSmrgfunc_convert_path_front_back_pathsep () 3168cdbfa18aSmrg{ 3169949d0342Smrg $debug_cmd 3170949d0342Smrg 3171cdbfa18aSmrg case $4 in 3172949d0342Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173cdbfa18aSmrg ;; 3174cdbfa18aSmrg esac 3175cdbfa18aSmrg case $4 in 3176cdbfa18aSmrg $2 ) func_append func_to_host_path_result "$3" 3177cdbfa18aSmrg ;; 3178cdbfa18aSmrg esac 3179cdbfa18aSmrg} 3180cdbfa18aSmrg# end func_convert_path_front_back_pathsep 3181cdbfa18aSmrg 3182cdbfa18aSmrg 3183cdbfa18aSmrg################################################## 3184cdbfa18aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185cdbfa18aSmrg################################################## 3186949d0342Smrg# invoked via '$to_host_file_cmd ARG' 3187cdbfa18aSmrg# 3188cdbfa18aSmrg# In each case, ARG is the path to be converted from $build to $host format. 3189cdbfa18aSmrg# Result will be available in $func_to_host_file_result. 3190cdbfa18aSmrg 3191cdbfa18aSmrg 3192cdbfa18aSmrg# func_to_host_file ARG 3193cdbfa18aSmrg# Converts the file name ARG from $build format to $host format. Return result 3194cdbfa18aSmrg# in func_to_host_file_result. 3195cdbfa18aSmrgfunc_to_host_file () 3196cdbfa18aSmrg{ 3197949d0342Smrg $debug_cmd 3198949d0342Smrg 3199cdbfa18aSmrg $to_host_file_cmd "$1" 3200cdbfa18aSmrg} 3201cdbfa18aSmrg# end func_to_host_file 3202cdbfa18aSmrg 3203cdbfa18aSmrg 3204cdbfa18aSmrg# func_to_tool_file ARG LAZY 3205cdbfa18aSmrg# converts the file name ARG from $build format to toolchain format. Return 3206cdbfa18aSmrg# result in func_to_tool_file_result. If the conversion in use is listed 3207cdbfa18aSmrg# in (the comma separated) LAZY, no conversion takes place. 3208cdbfa18aSmrgfunc_to_tool_file () 3209cdbfa18aSmrg{ 3210949d0342Smrg $debug_cmd 3211949d0342Smrg 3212cdbfa18aSmrg case ,$2, in 3213cdbfa18aSmrg *,"$to_tool_file_cmd",*) 3214cdbfa18aSmrg func_to_tool_file_result=$1 3215cdbfa18aSmrg ;; 3216cdbfa18aSmrg *) 3217cdbfa18aSmrg $to_tool_file_cmd "$1" 3218cdbfa18aSmrg func_to_tool_file_result=$func_to_host_file_result 3219cdbfa18aSmrg ;; 3220cdbfa18aSmrg esac 3221cdbfa18aSmrg} 3222cdbfa18aSmrg# end func_to_tool_file 3223cdbfa18aSmrg 3224cdbfa18aSmrg 3225cdbfa18aSmrg# func_convert_file_noop ARG 3226cdbfa18aSmrg# Copy ARG to func_to_host_file_result. 3227cdbfa18aSmrgfunc_convert_file_noop () 3228cdbfa18aSmrg{ 3229949d0342Smrg func_to_host_file_result=$1 3230cdbfa18aSmrg} 3231cdbfa18aSmrg# end func_convert_file_noop 3232cdbfa18aSmrg 3233cdbfa18aSmrg 3234cdbfa18aSmrg# func_convert_file_msys_to_w32 ARG 3235cdbfa18aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236cdbfa18aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237cdbfa18aSmrg# func_to_host_file_result. 3238cdbfa18aSmrgfunc_convert_file_msys_to_w32 () 3239cdbfa18aSmrg{ 3240949d0342Smrg $debug_cmd 3241949d0342Smrg 3242949d0342Smrg func_to_host_file_result=$1 3243cdbfa18aSmrg if test -n "$1"; then 3244cdbfa18aSmrg func_convert_core_msys_to_w32 "$1" 3245949d0342Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246cdbfa18aSmrg fi 3247cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3248cdbfa18aSmrg} 3249cdbfa18aSmrg# end func_convert_file_msys_to_w32 3250cdbfa18aSmrg 3251cdbfa18aSmrg 3252cdbfa18aSmrg# func_convert_file_cygwin_to_w32 ARG 3253cdbfa18aSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254cdbfa18aSmrg# func_to_host_file_result. 3255cdbfa18aSmrgfunc_convert_file_cygwin_to_w32 () 3256cdbfa18aSmrg{ 3257949d0342Smrg $debug_cmd 3258949d0342Smrg 3259949d0342Smrg func_to_host_file_result=$1 3260cdbfa18aSmrg if test -n "$1"; then 3261cdbfa18aSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262cdbfa18aSmrg # LT_CYGPATH in this case. 3263cdbfa18aSmrg func_to_host_file_result=`cygpath -m "$1"` 3264cdbfa18aSmrg fi 3265cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3266cdbfa18aSmrg} 3267cdbfa18aSmrg# end func_convert_file_cygwin_to_w32 3268cdbfa18aSmrg 3269cdbfa18aSmrg 3270cdbfa18aSmrg# func_convert_file_nix_to_w32 ARG 3271cdbfa18aSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272cdbfa18aSmrg# and a working winepath. Returns result in func_to_host_file_result. 3273cdbfa18aSmrgfunc_convert_file_nix_to_w32 () 3274cdbfa18aSmrg{ 3275949d0342Smrg $debug_cmd 3276949d0342Smrg 3277949d0342Smrg func_to_host_file_result=$1 3278cdbfa18aSmrg if test -n "$1"; then 3279cdbfa18aSmrg func_convert_core_file_wine_to_w32 "$1" 3280949d0342Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281cdbfa18aSmrg fi 3282cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3283cdbfa18aSmrg} 3284cdbfa18aSmrg# end func_convert_file_nix_to_w32 3285cdbfa18aSmrg 3286cdbfa18aSmrg 3287cdbfa18aSmrg# func_convert_file_msys_to_cygwin ARG 3288cdbfa18aSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289cdbfa18aSmrg# Returns result in func_to_host_file_result. 3290cdbfa18aSmrgfunc_convert_file_msys_to_cygwin () 3291cdbfa18aSmrg{ 3292949d0342Smrg $debug_cmd 3293949d0342Smrg 3294949d0342Smrg func_to_host_file_result=$1 3295cdbfa18aSmrg if test -n "$1"; then 3296cdbfa18aSmrg func_convert_core_msys_to_w32 "$1" 3297cdbfa18aSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3298949d0342Smrg func_to_host_file_result=$func_cygpath_result 3299cdbfa18aSmrg fi 3300cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3301cdbfa18aSmrg} 3302cdbfa18aSmrg# end func_convert_file_msys_to_cygwin 3303cdbfa18aSmrg 3304cdbfa18aSmrg 3305cdbfa18aSmrg# func_convert_file_nix_to_cygwin ARG 3306cdbfa18aSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307cdbfa18aSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308cdbfa18aSmrg# in func_to_host_file_result. 3309cdbfa18aSmrgfunc_convert_file_nix_to_cygwin () 3310cdbfa18aSmrg{ 3311949d0342Smrg $debug_cmd 3312949d0342Smrg 3313949d0342Smrg func_to_host_file_result=$1 3314cdbfa18aSmrg if test -n "$1"; then 3315cdbfa18aSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316cdbfa18aSmrg func_convert_core_file_wine_to_w32 "$1" 3317cdbfa18aSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3318949d0342Smrg func_to_host_file_result=$func_cygpath_result 3319cdbfa18aSmrg fi 3320cdbfa18aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3321cdbfa18aSmrg} 3322cdbfa18aSmrg# end func_convert_file_nix_to_cygwin 3323cdbfa18aSmrg 3324cdbfa18aSmrg 3325cdbfa18aSmrg############################################# 3326cdbfa18aSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3327cdbfa18aSmrg############################################# 3328949d0342Smrg# invoked via '$to_host_path_cmd ARG' 3329cdbfa18aSmrg# 3330cdbfa18aSmrg# In each case, ARG is the path to be converted from $build to $host format. 3331cdbfa18aSmrg# The result will be available in $func_to_host_path_result. 3332cdbfa18aSmrg# 3333cdbfa18aSmrg# Path separators are also converted from $build format to $host format. If 3334cdbfa18aSmrg# ARG begins or ends with a path separator character, it is preserved (but 3335cdbfa18aSmrg# converted to $host format) on output. 3336cdbfa18aSmrg# 3337cdbfa18aSmrg# All path conversion functions are named using the following convention: 3338cdbfa18aSmrg# file name conversion function : func_convert_file_X_to_Y () 3339cdbfa18aSmrg# path conversion function : func_convert_path_X_to_Y () 3340cdbfa18aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341cdbfa18aSmrg# same. If conversion functions are added for new $build/$host combinations, 3342cdbfa18aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343cdbfa18aSmrg# will break. 3344cdbfa18aSmrg 3345cdbfa18aSmrg 3346cdbfa18aSmrg# func_init_to_host_path_cmd 3347cdbfa18aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348cdbfa18aSmrg# appropriate value, based on the value of $to_host_file_cmd. 3349cdbfa18aSmrgto_host_path_cmd= 3350cdbfa18aSmrgfunc_init_to_host_path_cmd () 3351cdbfa18aSmrg{ 3352949d0342Smrg $debug_cmd 3353949d0342Smrg 3354cdbfa18aSmrg if test -z "$to_host_path_cmd"; then 3355cdbfa18aSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3356949d0342Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357cdbfa18aSmrg fi 3358cdbfa18aSmrg} 3359cdbfa18aSmrg 3360cdbfa18aSmrg 3361cdbfa18aSmrg# func_to_host_path ARG 3362cdbfa18aSmrg# Converts the path ARG from $build format to $host format. Return result 3363cdbfa18aSmrg# in func_to_host_path_result. 3364cdbfa18aSmrgfunc_to_host_path () 3365cdbfa18aSmrg{ 3366949d0342Smrg $debug_cmd 3367949d0342Smrg 3368cdbfa18aSmrg func_init_to_host_path_cmd 3369cdbfa18aSmrg $to_host_path_cmd "$1" 3370cdbfa18aSmrg} 3371cdbfa18aSmrg# end func_to_host_path 3372cdbfa18aSmrg 3373cdbfa18aSmrg 3374cdbfa18aSmrg# func_convert_path_noop ARG 3375cdbfa18aSmrg# Copy ARG to func_to_host_path_result. 3376cdbfa18aSmrgfunc_convert_path_noop () 3377cdbfa18aSmrg{ 3378949d0342Smrg func_to_host_path_result=$1 3379cdbfa18aSmrg} 3380cdbfa18aSmrg# end func_convert_path_noop 3381cdbfa18aSmrg 3382cdbfa18aSmrg 3383cdbfa18aSmrg# func_convert_path_msys_to_w32 ARG 3384cdbfa18aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385cdbfa18aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386cdbfa18aSmrg# func_to_host_path_result. 3387cdbfa18aSmrgfunc_convert_path_msys_to_w32 () 3388cdbfa18aSmrg{ 3389949d0342Smrg $debug_cmd 3390949d0342Smrg 3391949d0342Smrg func_to_host_path_result=$1 3392cdbfa18aSmrg if test -n "$1"; then 3393cdbfa18aSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3394cdbfa18aSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395cdbfa18aSmrg # and winepath ignores them completely. 3396cdbfa18aSmrg func_stripname : : "$1" 3397cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3398cdbfa18aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3399949d0342Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400cdbfa18aSmrg func_convert_path_check : ";" \ 3401cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403cdbfa18aSmrg fi 3404cdbfa18aSmrg} 3405cdbfa18aSmrg# end func_convert_path_msys_to_w32 3406cdbfa18aSmrg 3407cdbfa18aSmrg 3408cdbfa18aSmrg# func_convert_path_cygwin_to_w32 ARG 3409cdbfa18aSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410cdbfa18aSmrg# func_to_host_file_result. 3411cdbfa18aSmrgfunc_convert_path_cygwin_to_w32 () 3412cdbfa18aSmrg{ 3413949d0342Smrg $debug_cmd 3414949d0342Smrg 3415949d0342Smrg func_to_host_path_result=$1 3416cdbfa18aSmrg if test -n "$1"; then 3417cdbfa18aSmrg # See func_convert_path_msys_to_w32: 3418cdbfa18aSmrg func_stripname : : "$1" 3419cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3420cdbfa18aSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421cdbfa18aSmrg func_convert_path_check : ";" \ 3422cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424cdbfa18aSmrg fi 3425cdbfa18aSmrg} 3426cdbfa18aSmrg# end func_convert_path_cygwin_to_w32 3427cdbfa18aSmrg 3428cdbfa18aSmrg 3429cdbfa18aSmrg# func_convert_path_nix_to_w32 ARG 3430cdbfa18aSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431cdbfa18aSmrg# a working winepath. Returns result in func_to_host_file_result. 3432cdbfa18aSmrgfunc_convert_path_nix_to_w32 () 3433d5c3dbf1Smrg{ 3434949d0342Smrg $debug_cmd 3435949d0342Smrg 3436949d0342Smrg func_to_host_path_result=$1 3437cdbfa18aSmrg if test -n "$1"; then 3438cdbfa18aSmrg # See func_convert_path_msys_to_w32: 3439cdbfa18aSmrg func_stripname : : "$1" 3440cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3441cdbfa18aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3442949d0342Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443cdbfa18aSmrg func_convert_path_check : ";" \ 3444cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446cdbfa18aSmrg fi 3447cdbfa18aSmrg} 3448cdbfa18aSmrg# end func_convert_path_nix_to_w32 3449d5c3dbf1Smrg 3450d5c3dbf1Smrg 3451cdbfa18aSmrg# func_convert_path_msys_to_cygwin ARG 3452cdbfa18aSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453cdbfa18aSmrg# Returns result in func_to_host_file_result. 3454cdbfa18aSmrgfunc_convert_path_msys_to_cygwin () 3455cdbfa18aSmrg{ 3456949d0342Smrg $debug_cmd 3457949d0342Smrg 3458949d0342Smrg func_to_host_path_result=$1 3459cdbfa18aSmrg if test -n "$1"; then 3460cdbfa18aSmrg # See func_convert_path_msys_to_w32: 3461cdbfa18aSmrg func_stripname : : "$1" 3462cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3463cdbfa18aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464cdbfa18aSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3465949d0342Smrg func_to_host_path_result=$func_cygpath_result 3466cdbfa18aSmrg func_convert_path_check : : \ 3467cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469cdbfa18aSmrg fi 3470cdbfa18aSmrg} 3471cdbfa18aSmrg# end func_convert_path_msys_to_cygwin 3472d5c3dbf1Smrg 3473d5c3dbf1Smrg 3474cdbfa18aSmrg# func_convert_path_nix_to_cygwin ARG 3475cdbfa18aSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476cdbfa18aSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477cdbfa18aSmrg# func_to_host_file_result. 3478cdbfa18aSmrgfunc_convert_path_nix_to_cygwin () 3479cdbfa18aSmrg{ 3480949d0342Smrg $debug_cmd 3481949d0342Smrg 3482949d0342Smrg func_to_host_path_result=$1 3483cdbfa18aSmrg if test -n "$1"; then 3484cdbfa18aSmrg # Remove leading and trailing path separator characters from 3485cdbfa18aSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486cdbfa18aSmrg # into '.;' and ';.', and winepath ignores them completely. 3487cdbfa18aSmrg func_stripname : : "$1" 3488cdbfa18aSmrg func_to_host_path_tmp1=$func_stripname_result 3489cdbfa18aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490cdbfa18aSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3491949d0342Smrg func_to_host_path_result=$func_cygpath_result 3492cdbfa18aSmrg func_convert_path_check : : \ 3493cdbfa18aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494cdbfa18aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495cdbfa18aSmrg fi 3496d5c3dbf1Smrg} 3497cdbfa18aSmrg# end func_convert_path_nix_to_cygwin 3498cdbfa18aSmrg 3499d5c3dbf1Smrg 3500949d0342Smrg# func_dll_def_p FILE 3501949d0342Smrg# True iff FILE is a Windows DLL '.def' file. 3502949d0342Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3503949d0342Smrgfunc_dll_def_p () 3504949d0342Smrg{ 3505949d0342Smrg $debug_cmd 3506949d0342Smrg 3507949d0342Smrg func_dll_def_p_tmp=`$SED -n \ 3508949d0342Smrg -e 's/^[ ]*//' \ 3509949d0342Smrg -e '/^\(;.*\)*$/d' \ 3510949d0342Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3511949d0342Smrg -e q \ 3512949d0342Smrg "$1"` 3513949d0342Smrg test DEF = "$func_dll_def_p_tmp" 3514949d0342Smrg} 3515949d0342Smrg 3516949d0342Smrg 3517d5c3dbf1Smrg# func_mode_compile arg... 3518d5c3dbf1Smrgfunc_mode_compile () 3519d5c3dbf1Smrg{ 3520949d0342Smrg $debug_cmd 3521949d0342Smrg 3522d5c3dbf1Smrg # Get the compilation command and the source file. 3523d5c3dbf1Smrg base_compile= 3524949d0342Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525d5c3dbf1Smrg suppress_opt=yes 3526d5c3dbf1Smrg suppress_output= 3527d5c3dbf1Smrg arg_mode=normal 3528d5c3dbf1Smrg libobj= 3529d5c3dbf1Smrg later= 3530d5c3dbf1Smrg pie_flag= 3531d5c3dbf1Smrg 3532d5c3dbf1Smrg for arg 3533d5c3dbf1Smrg do 3534d5c3dbf1Smrg case $arg_mode in 3535d5c3dbf1Smrg arg ) 3536d5c3dbf1Smrg # do not "continue". Instead, add this to base_compile 3537949d0342Smrg lastarg=$arg 3538d5c3dbf1Smrg arg_mode=normal 3539d5c3dbf1Smrg ;; 3540d5c3dbf1Smrg 3541d5c3dbf1Smrg target ) 3542949d0342Smrg libobj=$arg 3543d5c3dbf1Smrg arg_mode=normal 3544d5c3dbf1Smrg continue 3545d5c3dbf1Smrg ;; 3546d5c3dbf1Smrg 3547d5c3dbf1Smrg normal ) 3548d5c3dbf1Smrg # Accept any command-line options. 3549d5c3dbf1Smrg case $arg in 3550d5c3dbf1Smrg -o) 3551d5c3dbf1Smrg test -n "$libobj" && \ 3552949d0342Smrg func_fatal_error "you cannot specify '-o' more than once" 3553d5c3dbf1Smrg arg_mode=target 3554d5c3dbf1Smrg continue 3555d5c3dbf1Smrg ;; 3556d5c3dbf1Smrg 3557d5c3dbf1Smrg -pie | -fpie | -fPIE) 3558cdbfa18aSmrg func_append pie_flag " $arg" 3559d5c3dbf1Smrg continue 3560d5c3dbf1Smrg ;; 3561d5c3dbf1Smrg 3562d5c3dbf1Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563cdbfa18aSmrg func_append later " $arg" 3564d5c3dbf1Smrg continue 3565d5c3dbf1Smrg ;; 35669f606849Smrg 35679f606849Smrg -no-suppress) 35689f606849Smrg suppress_opt=no 35699f606849Smrg continue 35709f606849Smrg ;; 35719f606849Smrg 35729f606849Smrg -Xcompiler) 35739f606849Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 35749f606849Smrg continue # The current "srcfile" will either be retained or 35759f606849Smrg ;; # replaced later. I would guess that would be a bug. 35769f606849Smrg 35779f606849Smrg -Wc,*) 3578d5c3dbf1Smrg func_stripname '-Wc,' '' "$arg" 3579d5c3dbf1Smrg args=$func_stripname_result 35809f606849Smrg lastarg= 3581949d0342Smrg save_ifs=$IFS; IFS=, 3582d5c3dbf1Smrg for arg in $args; do 3583949d0342Smrg IFS=$save_ifs 3584cdbfa18aSmrg func_append_quoted lastarg "$arg" 35859f606849Smrg done 3586949d0342Smrg IFS=$save_ifs 3587d5c3dbf1Smrg func_stripname ' ' '' "$lastarg" 3588d5c3dbf1Smrg lastarg=$func_stripname_result 35899f606849Smrg 35909f606849Smrg # Add the arguments to base_compile. 3591cdbfa18aSmrg func_append base_compile " $lastarg" 35929f606849Smrg continue 35939f606849Smrg ;; 35949f606849Smrg 3595d5c3dbf1Smrg *) 35969f606849Smrg # Accept the current argument as the source file. 35979f606849Smrg # The previous "srcfile" becomes the current argument. 35989f606849Smrg # 3599949d0342Smrg lastarg=$srcfile 3600949d0342Smrg srcfile=$arg 36019f606849Smrg ;; 36029f606849Smrg esac # case $arg 36039f606849Smrg ;; 36049f606849Smrg esac # case $arg_mode 36059f606849Smrg 36069f606849Smrg # Aesthetically quote the previous argument. 3607cdbfa18aSmrg func_append_quoted base_compile "$lastarg" 36089f606849Smrg done # for arg 36099f606849Smrg 36109f606849Smrg case $arg_mode in 36119f606849Smrg arg) 3612d5c3dbf1Smrg func_fatal_error "you must specify an argument for -Xcompile" 36139f606849Smrg ;; 36149f606849Smrg target) 3615949d0342Smrg func_fatal_error "you must specify a target with '-o'" 36169f606849Smrg ;; 36179f606849Smrg *) 36189f606849Smrg # Get the name of the library object. 3619d5c3dbf1Smrg test -z "$libobj" && { 3620d5c3dbf1Smrg func_basename "$srcfile" 3621949d0342Smrg libobj=$func_basename_result 3622d5c3dbf1Smrg } 36239f606849Smrg ;; 36249f606849Smrg esac 36259f606849Smrg 36269f606849Smrg # Recognize several different file suffixes. 36279f606849Smrg # If the user specifies -o file.o, it is replaced with file.lo 36289f606849Smrg case $libobj in 3629d5c3dbf1Smrg *.[cCFSifmso] | \ 3630d5c3dbf1Smrg *.ada | *.adb | *.ads | *.asm | \ 3631d5c3dbf1Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632cdbfa18aSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633d5c3dbf1Smrg func_xform "$libobj" 3634d5c3dbf1Smrg libobj=$func_xform_result 3635d5c3dbf1Smrg ;; 36369f606849Smrg esac 36379f606849Smrg 36389f606849Smrg case $libobj in 3639d5c3dbf1Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36409f606849Smrg *) 3641949d0342Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 36429f606849Smrg ;; 36439f606849Smrg esac 36449f606849Smrg 36459f606849Smrg func_infer_tag $base_compile 36469f606849Smrg 36479f606849Smrg for arg in $later; do 36489f606849Smrg case $arg in 3649d5c3dbf1Smrg -shared) 3650949d0342Smrg test yes = "$build_libtool_libs" \ 3651949d0342Smrg || func_fatal_configuration "cannot build a shared library" 3652d5c3dbf1Smrg build_old_libs=no 3653d5c3dbf1Smrg continue 3654d5c3dbf1Smrg ;; 3655d5c3dbf1Smrg 36569f606849Smrg -static) 3657d5c3dbf1Smrg build_libtool_libs=no 36589f606849Smrg build_old_libs=yes 36599f606849Smrg continue 36609f606849Smrg ;; 36619f606849Smrg 36629f606849Smrg -prefer-pic) 36639f606849Smrg pic_mode=yes 36649f606849Smrg continue 36659f606849Smrg ;; 36669f606849Smrg 36679f606849Smrg -prefer-non-pic) 36689f606849Smrg pic_mode=no 36699f606849Smrg continue 36709f606849Smrg ;; 36719f606849Smrg esac 36729f606849Smrg done 36739f606849Smrg 3674949d0342Smrg func_quote_arg pretty "$libobj" 3675949d0342Smrg test "X$libobj" != "X$func_quote_arg_result" \ 3676d5c3dbf1Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3677949d0342Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678d5c3dbf1Smrg func_dirname_and_basename "$obj" "/" "" 3679949d0342Smrg objname=$func_basename_result 3680949d0342Smrg xdir=$func_dirname_result 3681949d0342Smrg lobj=$xdir$objdir/$objname 36829f606849Smrg 3683d5c3dbf1Smrg test -z "$base_compile" && \ 3684d5c3dbf1Smrg func_fatal_help "you must specify a compilation command" 36859f606849Smrg 36869f606849Smrg # Delete any leftover library objects. 3687949d0342Smrg if test yes = "$build_old_libs"; then 36889f606849Smrg removelist="$obj $lobj $libobj ${libobj}T" 36899f606849Smrg else 36909f606849Smrg removelist="$lobj $libobj ${libobj}T" 36919f606849Smrg fi 36929f606849Smrg 36939f606849Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 36949f606849Smrg case $host_os in 3695d5c3dbf1Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36969f606849Smrg pic_mode=default 36979f606849Smrg ;; 36989f606849Smrg esac 3699949d0342Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 37009f606849Smrg # non-PIC code in shared libraries is not supported 37019f606849Smrg pic_mode=default 37029f606849Smrg fi 37039f606849Smrg 37049f606849Smrg # Calculate the filename of the output object if compiler does 37059f606849Smrg # not support -o with -c 3706949d0342Smrg if test no = "$compiler_c_o"; then 3707949d0342Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3708949d0342Smrg lockfile=$output_obj.lock 37099f606849Smrg else 37109f606849Smrg output_obj= 37119f606849Smrg need_locks=no 37129f606849Smrg lockfile= 37139f606849Smrg fi 37149f606849Smrg 37159f606849Smrg # Lock this critical section if it is needed 37169f606849Smrg # We use this script file to make the link, it avoids creating a new file 3717949d0342Smrg if test yes = "$need_locks"; then 3718d5c3dbf1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719d5c3dbf1Smrg func_echo "Waiting for $lockfile to be removed" 37209f606849Smrg sleep 2 37219f606849Smrg done 3722949d0342Smrg elif test warn = "$need_locks"; then 37239f606849Smrg if test -f "$lockfile"; then 3724d5c3dbf1Smrg $ECHO "\ 37259f606849Smrg*** ERROR, $lockfile exists and contains: 37269f606849Smrg`cat $lockfile 2>/dev/null` 37279f606849Smrg 37289f606849SmrgThis indicates that another process is trying to use the same 37299f606849Smrgtemporary object file, and libtool could not work around it because 3730949d0342Smrgyour compiler does not support '-c' and '-o' together. If you 37319f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better 37329f606849Smrgavoid parallel builds (make -j) in this platform, or get a better 37339f606849Smrgcompiler." 37349f606849Smrg 3735d5c3dbf1Smrg $opt_dry_run || $RM $removelist 37369f606849Smrg exit $EXIT_FAILURE 37379f606849Smrg fi 3738cdbfa18aSmrg func_append removelist " $output_obj" 3739d5c3dbf1Smrg $ECHO "$srcfile" > "$lockfile" 37409f606849Smrg fi 37419f606849Smrg 3742d5c3dbf1Smrg $opt_dry_run || $RM $removelist 3743cdbfa18aSmrg func_append removelist " $lockfile" 3744d5c3dbf1Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745d5c3dbf1Smrg 3746cdbfa18aSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747cdbfa18aSmrg srcfile=$func_to_tool_file_result 3748949d0342Smrg func_quote_arg pretty "$srcfile" 3749949d0342Smrg qsrcfile=$func_quote_arg_result 37509f606849Smrg 37519f606849Smrg # Only build a PIC object if we are building libtool libraries. 3752949d0342Smrg if test yes = "$build_libtool_libs"; then 37539f606849Smrg # Without this assignment, base_compile gets emptied. 37549f606849Smrg fbsd_hideous_sh_bug=$base_compile 37559f606849Smrg 3756949d0342Smrg if test no != "$pic_mode"; then 37579f606849Smrg command="$base_compile $qsrcfile $pic_flag" 37589f606849Smrg else 37599f606849Smrg # Don't build PIC code 37609f606849Smrg command="$base_compile $qsrcfile" 37619f606849Smrg fi 37629f606849Smrg 3763d5c3dbf1Smrg func_mkdir_p "$xdir$objdir" 37649f606849Smrg 37659f606849Smrg if test -z "$output_obj"; then 37669f606849Smrg # Place PIC objects in $objdir 3767cdbfa18aSmrg func_append command " -o $lobj" 37689f606849Smrg fi 37699f606849Smrg 3770d5c3dbf1Smrg func_show_eval_locale "$command" \ 3771d5c3dbf1Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37729f606849Smrg 3773949d0342Smrg if test warn = "$need_locks" && 37749f606849Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775d5c3dbf1Smrg $ECHO "\ 37769f606849Smrg*** ERROR, $lockfile contains: 37779f606849Smrg`cat $lockfile 2>/dev/null` 37789f606849Smrg 37799f606849Smrgbut it should contain: 37809f606849Smrg$srcfile 37819f606849Smrg 37829f606849SmrgThis indicates that another process is trying to use the same 37839f606849Smrgtemporary object file, and libtool could not work around it because 3784949d0342Smrgyour compiler does not support '-c' and '-o' together. If you 37859f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better 37869f606849Smrgavoid parallel builds (make -j) in this platform, or get a better 37879f606849Smrgcompiler." 37889f606849Smrg 3789d5c3dbf1Smrg $opt_dry_run || $RM $removelist 37909f606849Smrg exit $EXIT_FAILURE 37919f606849Smrg fi 37929f606849Smrg 37939f606849Smrg # Just move the object if needed, then go on to compile the next one 37949f606849Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795d5c3dbf1Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796d5c3dbf1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37979f606849Smrg fi 37989f606849Smrg 37999f606849Smrg # Allow error messages only from the first compilation. 3800949d0342Smrg if test yes = "$suppress_opt"; then 3801d5c3dbf1Smrg suppress_output=' >/dev/null 2>&1' 38029f606849Smrg fi 38039f606849Smrg fi 38049f606849Smrg 38059f606849Smrg # Only build a position-dependent object if we build old libraries. 3806949d0342Smrg if test yes = "$build_old_libs"; then 3807949d0342Smrg if test yes != "$pic_mode"; then 38089f606849Smrg # Don't build PIC code 3809d5c3dbf1Smrg command="$base_compile $qsrcfile$pie_flag" 38109f606849Smrg else 38119f606849Smrg command="$base_compile $qsrcfile $pic_flag" 38129f606849Smrg fi 3813949d0342Smrg if test yes = "$compiler_c_o"; then 3814cdbfa18aSmrg func_append command " -o $obj" 38159f606849Smrg fi 38169f606849Smrg 38179f606849Smrg # Suppress compiler output if we already did a PIC compilation. 3818cdbfa18aSmrg func_append command "$suppress_output" 3819d5c3dbf1Smrg func_show_eval_locale "$command" \ 3820d5c3dbf1Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38219f606849Smrg 3822949d0342Smrg if test warn = "$need_locks" && 38239f606849Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824d5c3dbf1Smrg $ECHO "\ 38259f606849Smrg*** ERROR, $lockfile contains: 38269f606849Smrg`cat $lockfile 2>/dev/null` 38279f606849Smrg 38289f606849Smrgbut it should contain: 38299f606849Smrg$srcfile 38309f606849Smrg 38319f606849SmrgThis indicates that another process is trying to use the same 38329f606849Smrgtemporary object file, and libtool could not work around it because 3833949d0342Smrgyour compiler does not support '-c' and '-o' together. If you 38349f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better 38359f606849Smrgavoid parallel builds (make -j) in this platform, or get a better 38369f606849Smrgcompiler." 38379f606849Smrg 3838d5c3dbf1Smrg $opt_dry_run || $RM $removelist 38399f606849Smrg exit $EXIT_FAILURE 38409f606849Smrg fi 38419f606849Smrg 38429f606849Smrg # Just move the object if needed 38439f606849Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844d5c3dbf1Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845d5c3dbf1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38469f606849Smrg fi 38479f606849Smrg fi 38489f606849Smrg 3849d5c3dbf1Smrg $opt_dry_run || { 3850d5c3dbf1Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38519f606849Smrg 3852d5c3dbf1Smrg # Unlock the critical section if it was locked 3853949d0342Smrg if test no != "$need_locks"; then 3854d5c3dbf1Smrg removelist=$lockfile 3855d5c3dbf1Smrg $RM "$lockfile" 3856d5c3dbf1Smrg fi 3857d5c3dbf1Smrg } 38589f606849Smrg 38599f606849Smrg exit $EXIT_SUCCESS 3860d5c3dbf1Smrg} 38619f606849Smrg 3862d5c3dbf1Smrg$opt_help || { 3863949d0342Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864d5c3dbf1Smrg} 38659f606849Smrg 3866d5c3dbf1Smrgfunc_mode_help () 3867d5c3dbf1Smrg{ 3868d5c3dbf1Smrg # We need to display help for each of the modes. 3869cdbfa18aSmrg case $opt_mode in 3870d5c3dbf1Smrg "") 3871d5c3dbf1Smrg # Generic help is extracted from the usage comments 3872d5c3dbf1Smrg # at the start of this file. 3873d5c3dbf1Smrg func_help 3874d5c3dbf1Smrg ;; 38759f606849Smrg 3876d5c3dbf1Smrg clean) 3877d5c3dbf1Smrg $ECHO \ 3878d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38799f606849Smrg 3880d5c3dbf1SmrgRemove files from the build directory. 38819f606849Smrg 3882d5c3dbf1SmrgRM is the name of the program to use to delete files associated with each FILE 3883949d0342Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884d5c3dbf1Smrgto RM. 38859f606849Smrg 3886d5c3dbf1SmrgIf FILE is a libtool library, object or program, all the files associated 3887d5c3dbf1Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888d5c3dbf1Smrg ;; 38899f606849Smrg 3890d5c3dbf1Smrg compile) 3891d5c3dbf1Smrg $ECHO \ 3892d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38939f606849Smrg 3894d5c3dbf1SmrgCompile a source file into a libtool library object. 38959f606849Smrg 3896d5c3dbf1SmrgThis mode accepts the following additional options: 38979f606849Smrg 3898d5c3dbf1Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899d5c3dbf1Smrg -no-suppress do not suppress compiler output for multiple passes 3900d5c3dbf1Smrg -prefer-pic try to build PIC objects only 3901d5c3dbf1Smrg -prefer-non-pic try to build non-PIC objects only 3902949d0342Smrg -shared do not build a '.o' file suitable for static linking 3903949d0342Smrg -static only build a '.o' file suitable for static linking 3904949d0342Smrg -Wc,FLAG 3905949d0342Smrg -Xcompiler FLAG pass FLAG directly to the compiler 39069f606849Smrg 3907949d0342SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908d5c3dbf1Smrgfrom the given SOURCEFILE. 39099f606849Smrg 3910d5c3dbf1SmrgThe output file name is determined by removing the directory component from 3911949d0342SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3912949d0342Smrglibrary object suffix, '.lo'." 3913d5c3dbf1Smrg ;; 39149f606849Smrg 3915d5c3dbf1Smrg execute) 3916d5c3dbf1Smrg $ECHO \ 3917d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39189f606849Smrg 3919d5c3dbf1SmrgAutomatically set library path, then run a program. 39209f606849Smrg 3921d5c3dbf1SmrgThis mode accepts the following additional options: 39229f606849Smrg 3923d5c3dbf1Smrg -dlopen FILE add the directory containing FILE to the library path 39249f606849Smrg 3925949d0342SmrgThis mode sets the library path environment variable according to '-dlopen' 3926d5c3dbf1Smrgflags. 39279f606849Smrg 3928d5c3dbf1SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929d5c3dbf1Smrginto their corresponding uninstalled binary, and any of their required library 3930d5c3dbf1Smrgdirectories are added to the library path. 39319f606849Smrg 3932d5c3dbf1SmrgThen, COMMAND is executed, with ARGS as arguments." 3933d5c3dbf1Smrg ;; 39349f606849Smrg 3935d5c3dbf1Smrg finish) 3936d5c3dbf1Smrg $ECHO \ 3937d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39389f606849Smrg 3939d5c3dbf1SmrgComplete the installation of libtool libraries. 39409f606849Smrg 3941d5c3dbf1SmrgEach LIBDIR is a directory that contains libtool libraries. 39429f606849Smrg 3943d5c3dbf1SmrgThe commands that this mode executes may require superuser privileges. Use 3944949d0342Smrgthe '--dry-run' option if you just want to see what would be executed." 3945d5c3dbf1Smrg ;; 39469f606849Smrg 3947d5c3dbf1Smrg install) 3948d5c3dbf1Smrg $ECHO \ 3949d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39509f606849Smrg 3951d5c3dbf1SmrgInstall executables or libraries. 39529f606849Smrg 3953d5c3dbf1SmrgINSTALL-COMMAND is the installation command. The first component should be 3954949d0342Smrgeither the 'install' or 'cp' program. 39559f606849Smrg 3956d5c3dbf1SmrgThe following components of INSTALL-COMMAND are treated specially: 39579f606849Smrg 3958d5c3dbf1Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39599f606849Smrg 3960d5c3dbf1SmrgThe rest of the components are interpreted as arguments to that command (only 3961d5c3dbf1SmrgBSD-compatible install options are recognized)." 3962d5c3dbf1Smrg ;; 39639f606849Smrg 3964d5c3dbf1Smrg link) 3965d5c3dbf1Smrg $ECHO \ 3966d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39679f606849Smrg 3968d5c3dbf1SmrgLink object files or libraries together to form another library, or to 3969d5c3dbf1Smrgcreate an executable program. 39709f606849Smrg 3971d5c3dbf1SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972d5c3dbf1Smrga program from several object files. 39739f606849Smrg 3974d5c3dbf1SmrgThe following components of LINK-COMMAND are treated specially: 39759f606849Smrg 3976d5c3dbf1Smrg -all-static do not do any dynamic linking at all 3977d5c3dbf1Smrg -avoid-version do not add a version suffix if possible 3978d5c3dbf1Smrg -bindir BINDIR specify path to binaries directory (for systems where 3979d5c3dbf1Smrg libraries must be found in the PATH setting at runtime) 3980949d0342Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981d5c3dbf1Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982d5c3dbf1Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983d5c3dbf1Smrg -export-symbols SYMFILE 3984d5c3dbf1Smrg try to export only the symbols listed in SYMFILE 3985d5c3dbf1Smrg -export-symbols-regex REGEX 3986d5c3dbf1Smrg try to export only the symbols matching REGEX 3987d5c3dbf1Smrg -LLIBDIR search LIBDIR for required installed libraries 3988d5c3dbf1Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989d5c3dbf1Smrg -module build a library that can dlopened 3990d5c3dbf1Smrg -no-fast-install disable the fast-install mode 3991d5c3dbf1Smrg -no-install link a not-installable executable 3992d5c3dbf1Smrg -no-undefined declare that a library does not refer to external symbols 3993d5c3dbf1Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3994949d0342Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3995949d0342Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996d5c3dbf1Smrg -precious-files-regex REGEX 3997d5c3dbf1Smrg don't remove output files matching REGEX 3998d5c3dbf1Smrg -release RELEASE specify package release information 3999d5c3dbf1Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000d5c3dbf1Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001d5c3dbf1Smrg -shared only do dynamic linking of libtool libraries 4002d5c3dbf1Smrg -shrext SUFFIX override the standard shared library file extension 4003d5c3dbf1Smrg -static do not do any dynamic linking of uninstalled libtool libraries 4004d5c3dbf1Smrg -static-libtool-libs 4005d5c3dbf1Smrg do not do any dynamic linking of libtool libraries 4006d5c3dbf1Smrg -version-info CURRENT[:REVISION[:AGE]] 4007d5c3dbf1Smrg specify library version info [each variable defaults to 0] 4008d5c3dbf1Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009d5c3dbf1Smrg -Wc,FLAG 4010d5c3dbf1Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011949d0342Smrg -Wa,FLAG 4012949d0342Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013d5c3dbf1Smrg -Wl,FLAG 4014d5c3dbf1Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015d5c3dbf1Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40169f606849Smrg 4017949d0342SmrgAll other options (arguments beginning with '-') are ignored. 40189f606849Smrg 4019949d0342SmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020d5c3dbf1Smrgtreated as uninstalled libtool libraries, other files are standard or library 4021d5c3dbf1Smrgobject files. 40229f606849Smrg 4023949d0342SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 4024949d0342Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025d5c3dbf1Smrgrequired, except when creating a convenience library. 40269f606849Smrg 4027949d0342SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4028949d0342Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029fba89afeSmrg 4030949d0342SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031d5c3dbf1Smrgis created, otherwise an executable program is created." 4032d5c3dbf1Smrg ;; 40339f606849Smrg 4034d5c3dbf1Smrg uninstall) 4035d5c3dbf1Smrg $ECHO \ 4036d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40379f606849Smrg 4038d5c3dbf1SmrgRemove libraries from an installation directory. 40399f606849Smrg 4040d5c3dbf1SmrgRM is the name of the program to use to delete files associated with each FILE 4041949d0342Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042d5c3dbf1Smrgto RM. 40439f606849Smrg 4044d5c3dbf1SmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045d5c3dbf1SmrgOtherwise, only FILE itself is deleted using RM." 4046d5c3dbf1Smrg ;; 40479f606849Smrg 4048d5c3dbf1Smrg *) 4049949d0342Smrg func_fatal_help "invalid operation mode '$opt_mode'" 4050d5c3dbf1Smrg ;; 4051d5c3dbf1Smrg esac 40529f606849Smrg 4053d5c3dbf1Smrg echo 4054949d0342Smrg $ECHO "Try '$progname --help' for more information about other modes." 4055d5c3dbf1Smrg} 40569f606849Smrg 4057d5c3dbf1Smrg# Now that we've collected a possible --mode arg, show help if necessary 4058d5c3dbf1Smrgif $opt_help; then 4059949d0342Smrg if test : = "$opt_help"; then 4060d5c3dbf1Smrg func_mode_help 4061d5c3dbf1Smrg else 4062d5c3dbf1Smrg { 4063d5c3dbf1Smrg func_help noexit 4064cdbfa18aSmrg for opt_mode in compile link execute install finish uninstall clean; do 4065d5c3dbf1Smrg func_mode_help 4066d5c3dbf1Smrg done 4067949d0342Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068d5c3dbf1Smrg { 4069d5c3dbf1Smrg func_help noexit 4070cdbfa18aSmrg for opt_mode in compile link execute install finish uninstall clean; do 4071d5c3dbf1Smrg echo 4072d5c3dbf1Smrg func_mode_help 4073d5c3dbf1Smrg done 4074d5c3dbf1Smrg } | 4075949d0342Smrg $SED '1d 4076d5c3dbf1Smrg /^When reporting/,/^Report/{ 4077d5c3dbf1Smrg H 4078d5c3dbf1Smrg d 4079d5c3dbf1Smrg } 4080d5c3dbf1Smrg $x 4081d5c3dbf1Smrg /information about other modes/d 4082d5c3dbf1Smrg /more detailed .*MODE/d 4083d5c3dbf1Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084d5c3dbf1Smrg fi 4085d5c3dbf1Smrg exit $? 4086d5c3dbf1Smrgfi 40879f606849Smrg 40889f606849Smrg 4089d5c3dbf1Smrg# func_mode_execute arg... 4090d5c3dbf1Smrgfunc_mode_execute () 4091d5c3dbf1Smrg{ 4092949d0342Smrg $debug_cmd 4093949d0342Smrg 4094d5c3dbf1Smrg # The first argument is the command name. 4095949d0342Smrg cmd=$nonopt 4096d5c3dbf1Smrg test -z "$cmd" && \ 4097d5c3dbf1Smrg func_fatal_help "you must specify a COMMAND" 40989f606849Smrg 4099d5c3dbf1Smrg # Handle -dlopen flags immediately. 4100cdbfa18aSmrg for file in $opt_dlopen; do 4101d5c3dbf1Smrg test -f "$file" \ 4102949d0342Smrg || func_fatal_help "'$file' is not a file" 41039f606849Smrg 4104d5c3dbf1Smrg dir= 4105d5c3dbf1Smrg case $file in 4106d5c3dbf1Smrg *.la) 4107cdbfa18aSmrg func_resolve_sysroot "$file" 4108cdbfa18aSmrg file=$func_resolve_sysroot_result 4109cdbfa18aSmrg 4110d5c3dbf1Smrg # Check to see that this really is a libtool archive. 4111d5c3dbf1Smrg func_lalib_unsafe_p "$file" \ 4112949d0342Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 41139f606849Smrg 4114d5c3dbf1Smrg # Read the libtool library. 4115d5c3dbf1Smrg dlname= 4116d5c3dbf1Smrg library_names= 4117d5c3dbf1Smrg func_source "$file" 41189f606849Smrg 4119d5c3dbf1Smrg # Skip this library if it cannot be dlopened. 4120d5c3dbf1Smrg if test -z "$dlname"; then 4121d5c3dbf1Smrg # Warn if it was a shared library. 4122d5c3dbf1Smrg test -n "$library_names" && \ 4123949d0342Smrg func_warning "'$file' was not linked with '-export-dynamic'" 4124d5c3dbf1Smrg continue 4125d5c3dbf1Smrg fi 41269f606849Smrg 4127d5c3dbf1Smrg func_dirname "$file" "" "." 4128949d0342Smrg dir=$func_dirname_result 41299f606849Smrg 4130d5c3dbf1Smrg if test -f "$dir/$objdir/$dlname"; then 4131cdbfa18aSmrg func_append dir "/$objdir" 4132d5c3dbf1Smrg else 4133d5c3dbf1Smrg if test ! -f "$dir/$dlname"; then 4134949d0342Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135d5c3dbf1Smrg fi 4136d5c3dbf1Smrg fi 41379f606849Smrg ;; 41389f606849Smrg 4139d5c3dbf1Smrg *.lo) 4140d5c3dbf1Smrg # Just add the directory containing the .lo file. 4141d5c3dbf1Smrg func_dirname "$file" "" "." 4142949d0342Smrg dir=$func_dirname_result 41439f606849Smrg ;; 4144d5c3dbf1Smrg 4145d5c3dbf1Smrg *) 4146949d0342Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41479f606849Smrg continue 41489f606849Smrg ;; 4149d5c3dbf1Smrg esac 41509f606849Smrg 4151d5c3dbf1Smrg # Get the absolute pathname. 4152d5c3dbf1Smrg absdir=`cd "$dir" && pwd` 4153949d0342Smrg test -n "$absdir" && dir=$absdir 41549f606849Smrg 4155d5c3dbf1Smrg # Now add the directory to shlibpath_var. 4156d5c3dbf1Smrg if eval "test -z \"\$$shlibpath_var\""; then 4157d5c3dbf1Smrg eval "$shlibpath_var=\"\$dir\"" 4158d5c3dbf1Smrg else 4159d5c3dbf1Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160d5c3dbf1Smrg fi 4161d5c3dbf1Smrg done 41629f606849Smrg 4163d5c3dbf1Smrg # This variable tells wrapper scripts just to set shlibpath_var 4164d5c3dbf1Smrg # rather than running their programs. 4165949d0342Smrg libtool_execute_magic=$magic 41669f606849Smrg 4167d5c3dbf1Smrg # Check if any of the arguments is a wrapper script. 4168d5c3dbf1Smrg args= 4169d5c3dbf1Smrg for file 4170d5c3dbf1Smrg do 4171d5c3dbf1Smrg case $file in 4172d5c3dbf1Smrg -* | *.la | *.lo ) ;; 4173d5c3dbf1Smrg *) 4174d5c3dbf1Smrg # Do a test to see if this is really a libtool program. 4175d5c3dbf1Smrg if func_ltwrapper_script_p "$file"; then 4176d5c3dbf1Smrg func_source "$file" 4177d5c3dbf1Smrg # Transform arg to wrapped name. 4178949d0342Smrg file=$progdir/$program 4179d5c3dbf1Smrg elif func_ltwrapper_executable_p "$file"; then 4180d5c3dbf1Smrg func_ltwrapper_scriptname "$file" 4181d5c3dbf1Smrg func_source "$func_ltwrapper_scriptname_result" 4182d5c3dbf1Smrg # Transform arg to wrapped name. 4183949d0342Smrg file=$progdir/$program 4184d5c3dbf1Smrg fi 41859f606849Smrg ;; 4186d5c3dbf1Smrg esac 4187d5c3dbf1Smrg # Quote arguments (to preserve shell metacharacters). 4188cdbfa18aSmrg func_append_quoted args "$file" 4189d5c3dbf1Smrg done 41909f606849Smrg 4191949d0342Smrg if $opt_dry_run; then 4192949d0342Smrg # Display what would be done. 4193949d0342Smrg if test -n "$shlibpath_var"; then 4194949d0342Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4195949d0342Smrg echo "export $shlibpath_var" 4196949d0342Smrg fi 4197949d0342Smrg $ECHO "$cmd$args" 4198949d0342Smrg exit $EXIT_SUCCESS 4199949d0342Smrg else 4200d5c3dbf1Smrg if test -n "$shlibpath_var"; then 4201d5c3dbf1Smrg # Export the shlibpath_var. 4202d5c3dbf1Smrg eval "export $shlibpath_var" 4203d5c3dbf1Smrg fi 42049f606849Smrg 4205d5c3dbf1Smrg # Restore saved environment variables 4206d5c3dbf1Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207d5c3dbf1Smrg do 4208d5c3dbf1Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209d5c3dbf1Smrg $lt_var=\$save_$lt_var; export $lt_var 4210d5c3dbf1Smrg else 4211d5c3dbf1Smrg $lt_unset $lt_var 4212d5c3dbf1Smrg fi" 4213d5c3dbf1Smrg done 42149f606849Smrg 4215d5c3dbf1Smrg # Now prepare to actually exec the command. 4216949d0342Smrg exec_cmd=\$cmd$args 4217d5c3dbf1Smrg fi 4218d5c3dbf1Smrg} 42199f606849Smrg 4220949d0342Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42219f606849Smrg 42229f606849Smrg 4223d5c3dbf1Smrg# func_mode_finish arg... 4224d5c3dbf1Smrgfunc_mode_finish () 4225d5c3dbf1Smrg{ 4226949d0342Smrg $debug_cmd 4227949d0342Smrg 4228cdbfa18aSmrg libs= 4229cdbfa18aSmrg libdirs= 4230d5c3dbf1Smrg admincmds= 42319f606849Smrg 4232cdbfa18aSmrg for opt in "$nonopt" ${1+"$@"} 4233cdbfa18aSmrg do 4234cdbfa18aSmrg if test -d "$opt"; then 4235cdbfa18aSmrg func_append libdirs " $opt" 4236cdbfa18aSmrg 4237cdbfa18aSmrg elif test -f "$opt"; then 4238cdbfa18aSmrg if func_lalib_unsafe_p "$opt"; then 4239cdbfa18aSmrg func_append libs " $opt" 4240cdbfa18aSmrg else 4241949d0342Smrg func_warning "'$opt' is not a valid libtool archive" 4242cdbfa18aSmrg fi 4243cdbfa18aSmrg 4244cdbfa18aSmrg else 4245949d0342Smrg func_fatal_error "invalid argument '$opt'" 4246cdbfa18aSmrg fi 4247cdbfa18aSmrg done 4248cdbfa18aSmrg 4249cdbfa18aSmrg if test -n "$libs"; then 4250cdbfa18aSmrg if test -n "$lt_sysroot"; then 4251cdbfa18aSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252cdbfa18aSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253cdbfa18aSmrg else 4254cdbfa18aSmrg sysroot_cmd= 4255cdbfa18aSmrg fi 4256cdbfa18aSmrg 4257cdbfa18aSmrg # Remove sysroot references 4258cdbfa18aSmrg if $opt_dry_run; then 4259cdbfa18aSmrg for lib in $libs; do 4260949d0342Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261cdbfa18aSmrg done 4262cdbfa18aSmrg else 4263cdbfa18aSmrg tmpdir=`func_mktempdir` 4264cdbfa18aSmrg for lib in $libs; do 4265949d0342Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266cdbfa18aSmrg > $tmpdir/tmp-la 4267cdbfa18aSmrg mv -f $tmpdir/tmp-la $lib 4268cdbfa18aSmrg done 4269cdbfa18aSmrg ${RM}r "$tmpdir" 4270cdbfa18aSmrg fi 4271cdbfa18aSmrg fi 42729f606849Smrg 4273cdbfa18aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274d5c3dbf1Smrg for libdir in $libdirs; do 4275d5c3dbf1Smrg if test -n "$finish_cmds"; then 4276d5c3dbf1Smrg # Do each command in the finish commands. 4277d5c3dbf1Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278d5c3dbf1Smrg'"$cmd"'"' 4279d5c3dbf1Smrg fi 4280d5c3dbf1Smrg if test -n "$finish_eval"; then 4281d5c3dbf1Smrg # Do the single finish_eval. 4282d5c3dbf1Smrg eval cmds=\"$finish_eval\" 4283cdbfa18aSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284d5c3dbf1Smrg $cmds" 4285d5c3dbf1Smrg fi 4286d5c3dbf1Smrg done 4287d5c3dbf1Smrg fi 42889f606849Smrg 4289d5c3dbf1Smrg # Exit here if they wanted silent mode. 4290949d0342Smrg $opt_quiet && exit $EXIT_SUCCESS 42919f606849Smrg 4292cdbfa18aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293cdbfa18aSmrg echo "----------------------------------------------------------------------" 4294cdbfa18aSmrg echo "Libraries have been installed in:" 4295cdbfa18aSmrg for libdir in $libdirs; do 4296cdbfa18aSmrg $ECHO " $libdir" 4297cdbfa18aSmrg done 4298cdbfa18aSmrg echo 4299cdbfa18aSmrg echo "If you ever happen to want to link against installed libraries" 4300cdbfa18aSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4301949d0342Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302cdbfa18aSmrg echo "flag during linking and do at least one of the following:" 4303cdbfa18aSmrg if test -n "$shlibpath_var"; then 4304949d0342Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305cdbfa18aSmrg echo " during execution" 4306cdbfa18aSmrg fi 4307cdbfa18aSmrg if test -n "$runpath_var"; then 4308949d0342Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309cdbfa18aSmrg echo " during linking" 4310cdbfa18aSmrg fi 4311cdbfa18aSmrg if test -n "$hardcode_libdir_flag_spec"; then 4312cdbfa18aSmrg libdir=LIBDIR 4313cdbfa18aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 43149f606849Smrg 4315949d0342Smrg $ECHO " - use the '$flag' linker flag" 4316cdbfa18aSmrg fi 4317cdbfa18aSmrg if test -n "$admincmds"; then 4318cdbfa18aSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4319cdbfa18aSmrg fi 4320cdbfa18aSmrg if test -f /etc/ld.so.conf; then 4321949d0342Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322cdbfa18aSmrg fi 4323cdbfa18aSmrg echo 43249f606849Smrg 4325cdbfa18aSmrg echo "See any operating system documentation about shared libraries for" 4326cdbfa18aSmrg case $host in 4327cdbfa18aSmrg solaris2.[6789]|solaris2.1[0-9]) 4328cdbfa18aSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329cdbfa18aSmrg echo "pages." 4330cdbfa18aSmrg ;; 4331cdbfa18aSmrg *) 4332cdbfa18aSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333cdbfa18aSmrg ;; 4334cdbfa18aSmrg esac 4335cdbfa18aSmrg echo "----------------------------------------------------------------------" 4336cdbfa18aSmrg fi 4337d5c3dbf1Smrg exit $EXIT_SUCCESS 4338d5c3dbf1Smrg} 43399f606849Smrg 4340949d0342Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43419f606849Smrg 43429f606849Smrg 4343d5c3dbf1Smrg# func_mode_install arg... 4344d5c3dbf1Smrgfunc_mode_install () 4345d5c3dbf1Smrg{ 4346949d0342Smrg $debug_cmd 4347949d0342Smrg 4348d5c3dbf1Smrg # There may be an optional sh(1) argument at the beginning of 4349d5c3dbf1Smrg # install_prog (especially on Windows NT). 4350949d0342Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351d5c3dbf1Smrg # Allow the use of GNU shtool's install command. 4352949d0342Smrg case $nonopt in *shtool*) :;; *) false;; esac 4353949d0342Smrg then 4354d5c3dbf1Smrg # Aesthetically quote it. 4355949d0342Smrg func_quote_arg pretty "$nonopt" 4356949d0342Smrg install_prog="$func_quote_arg_result " 4357d5c3dbf1Smrg arg=$1 4358d5c3dbf1Smrg shift 4359d5c3dbf1Smrg else 4360d5c3dbf1Smrg install_prog= 4361d5c3dbf1Smrg arg=$nonopt 4362d5c3dbf1Smrg fi 43639f606849Smrg 4364d5c3dbf1Smrg # The real first argument should be the name of the installation program. 4365d5c3dbf1Smrg # Aesthetically quote it. 4366949d0342Smrg func_quote_arg pretty "$arg" 4367949d0342Smrg func_append install_prog "$func_quote_arg_result" 4368d5c3dbf1Smrg install_shared_prog=$install_prog 4369d5c3dbf1Smrg case " $install_prog " in 4370d5c3dbf1Smrg *[\\\ /]cp\ *) install_cp=: ;; 4371d5c3dbf1Smrg *) install_cp=false ;; 4372d5c3dbf1Smrg esac 43739f606849Smrg 4374d5c3dbf1Smrg # We need to accept at least all the BSD install flags. 4375d5c3dbf1Smrg dest= 4376d5c3dbf1Smrg files= 4377d5c3dbf1Smrg opts= 4378d5c3dbf1Smrg prev= 4379d5c3dbf1Smrg install_type= 4380949d0342Smrg isdir=false 4381d5c3dbf1Smrg stripme= 4382d5c3dbf1Smrg no_mode=: 4383d5c3dbf1Smrg for arg 4384d5c3dbf1Smrg do 4385d5c3dbf1Smrg arg2= 4386d5c3dbf1Smrg if test -n "$dest"; then 4387cdbfa18aSmrg func_append files " $dest" 4388d5c3dbf1Smrg dest=$arg 43899f606849Smrg continue 4390d5c3dbf1Smrg fi 43919f606849Smrg 4392d5c3dbf1Smrg case $arg in 4393949d0342Smrg -d) isdir=: ;; 4394d5c3dbf1Smrg -f) 4395d5c3dbf1Smrg if $install_cp; then :; else 4396d5c3dbf1Smrg prev=$arg 43979f606849Smrg fi 4398d5c3dbf1Smrg ;; 4399d5c3dbf1Smrg -g | -m | -o) 4400d5c3dbf1Smrg prev=$arg 4401d5c3dbf1Smrg ;; 4402d5c3dbf1Smrg -s) 4403d5c3dbf1Smrg stripme=" -s" 44049f606849Smrg continue 44059f606849Smrg ;; 4406d5c3dbf1Smrg -*) 4407d5c3dbf1Smrg ;; 44089f606849Smrg *) 4409d5c3dbf1Smrg # If the previous option needed an argument, then skip it. 4410d5c3dbf1Smrg if test -n "$prev"; then 4411949d0342Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412d5c3dbf1Smrg arg2=$install_override_mode 4413d5c3dbf1Smrg no_mode=false 4414d5c3dbf1Smrg fi 4415d5c3dbf1Smrg prev= 4416d5c3dbf1Smrg else 4417d5c3dbf1Smrg dest=$arg 4418d5c3dbf1Smrg continue 4419d5c3dbf1Smrg fi 44209f606849Smrg ;; 4421d5c3dbf1Smrg esac 44229f606849Smrg 4423d5c3dbf1Smrg # Aesthetically quote the argument. 4424949d0342Smrg func_quote_arg pretty "$arg" 4425949d0342Smrg func_append install_prog " $func_quote_arg_result" 4426d5c3dbf1Smrg if test -n "$arg2"; then 4427949d0342Smrg func_quote_arg pretty "$arg2" 44289f606849Smrg fi 4429949d0342Smrg func_append install_shared_prog " $func_quote_arg_result" 4430d5c3dbf1Smrg done 44319f606849Smrg 4432d5c3dbf1Smrg test -z "$install_prog" && \ 4433d5c3dbf1Smrg func_fatal_help "you must specify an install program" 44349f606849Smrg 4435d5c3dbf1Smrg test -n "$prev" && \ 4436949d0342Smrg func_fatal_help "the '$prev' option requires an argument" 44379f606849Smrg 4438d5c3dbf1Smrg if test -n "$install_override_mode" && $no_mode; then 4439d5c3dbf1Smrg if $install_cp; then :; else 4440949d0342Smrg func_quote_arg pretty "$install_override_mode" 4441949d0342Smrg func_append install_shared_prog " -m $func_quote_arg_result" 4442d5c3dbf1Smrg fi 44439f606849Smrg fi 44449f606849Smrg 4445d5c3dbf1Smrg if test -z "$files"; then 4446d5c3dbf1Smrg if test -z "$dest"; then 4447d5c3dbf1Smrg func_fatal_help "no file or destination specified" 4448d5c3dbf1Smrg else 4449d5c3dbf1Smrg func_fatal_help "you must specify a destination" 44509f606849Smrg fi 44519f606849Smrg fi 44529f606849Smrg 4453d5c3dbf1Smrg # Strip any trailing slash from the destination. 4454d5c3dbf1Smrg func_stripname '' '/' "$dest" 4455d5c3dbf1Smrg dest=$func_stripname_result 44569f606849Smrg 4457d5c3dbf1Smrg # Check to see that the destination is a directory. 4458949d0342Smrg test -d "$dest" && isdir=: 4459949d0342Smrg if $isdir; then 4460949d0342Smrg destdir=$dest 4461d5c3dbf1Smrg destname= 4462d5c3dbf1Smrg else 4463d5c3dbf1Smrg func_dirname_and_basename "$dest" "" "." 4464949d0342Smrg destdir=$func_dirname_result 4465949d0342Smrg destname=$func_basename_result 4466d5c3dbf1Smrg 4467d5c3dbf1Smrg # Not a directory, so check to see that there is only one file specified. 4468d5c3dbf1Smrg set dummy $files; shift 4469d5c3dbf1Smrg test "$#" -gt 1 && \ 4470949d0342Smrg func_fatal_help "'$dest' is not a directory" 4471d5c3dbf1Smrg fi 4472d5c3dbf1Smrg case $destdir in 4473d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44749f606849Smrg *) 4475d5c3dbf1Smrg for file in $files; do 4476d5c3dbf1Smrg case $file in 4477d5c3dbf1Smrg *.lo) ;; 4478d5c3dbf1Smrg *) 4479949d0342Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4480d5c3dbf1Smrg ;; 4481d5c3dbf1Smrg esac 4482d5c3dbf1Smrg done 44839f606849Smrg ;; 44849f606849Smrg esac 44859f606849Smrg 4486d5c3dbf1Smrg # This variable tells wrapper scripts just to set variables rather 4487d5c3dbf1Smrg # than running their programs. 4488949d0342Smrg libtool_install_magic=$magic 44899f606849Smrg 4490d5c3dbf1Smrg staticlibs= 4491d5c3dbf1Smrg future_libdirs= 4492d5c3dbf1Smrg current_libdirs= 4493d5c3dbf1Smrg for file in $files; do 44949f606849Smrg 4495d5c3dbf1Smrg # Do each installation. 4496d5c3dbf1Smrg case $file in 4497d5c3dbf1Smrg *.$libext) 4498d5c3dbf1Smrg # Do the static libraries later. 4499cdbfa18aSmrg func_append staticlibs " $file" 4500d5c3dbf1Smrg ;; 4501d5c3dbf1Smrg 4502d5c3dbf1Smrg *.la) 4503cdbfa18aSmrg func_resolve_sysroot "$file" 4504cdbfa18aSmrg file=$func_resolve_sysroot_result 4505cdbfa18aSmrg 4506d5c3dbf1Smrg # Check to see that this really is a libtool archive. 4507d5c3dbf1Smrg func_lalib_unsafe_p "$file" \ 4508949d0342Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4509d5c3dbf1Smrg 4510d5c3dbf1Smrg library_names= 4511d5c3dbf1Smrg old_library= 4512d5c3dbf1Smrg relink_command= 4513d5c3dbf1Smrg func_source "$file" 4514d5c3dbf1Smrg 4515d5c3dbf1Smrg # Add the libdir to current_libdirs if it is the destination. 4516d5c3dbf1Smrg if test "X$destdir" = "X$libdir"; then 4517d5c3dbf1Smrg case "$current_libdirs " in 4518d5c3dbf1Smrg *" $libdir "*) ;; 4519cdbfa18aSmrg *) func_append current_libdirs " $libdir" ;; 45209f606849Smrg esac 4521d5c3dbf1Smrg else 4522d5c3dbf1Smrg # Note the libdir as a future libdir. 4523d5c3dbf1Smrg case "$future_libdirs " in 4524d5c3dbf1Smrg *" $libdir "*) ;; 4525cdbfa18aSmrg *) func_append future_libdirs " $libdir" ;; 4526d5c3dbf1Smrg esac 4527d5c3dbf1Smrg fi 45289f606849Smrg 4529d5c3dbf1Smrg func_dirname "$file" "/" "" 4530949d0342Smrg dir=$func_dirname_result 4531cdbfa18aSmrg func_append dir "$objdir" 4532d5c3dbf1Smrg 4533d5c3dbf1Smrg if test -n "$relink_command"; then 4534d5c3dbf1Smrg # Determine the prefix the user has applied to our future dir. 4535d5c3dbf1Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536d5c3dbf1Smrg 4537d5c3dbf1Smrg # Don't allow the user to place us outside of our expected 4538d5c3dbf1Smrg # location b/c this prevents finding dependent libraries that 4539d5c3dbf1Smrg # are installed to the same prefix. 4540d5c3dbf1Smrg # At present, this check doesn't affect windows .dll's that 4541d5c3dbf1Smrg # are installed into $libdir/../bin (currently, that works fine) 4542d5c3dbf1Smrg # but it's something to keep an eye on. 4543d5c3dbf1Smrg test "$inst_prefix_dir" = "$destdir" && \ 4544949d0342Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545d5c3dbf1Smrg 4546d5c3dbf1Smrg if test -n "$inst_prefix_dir"; then 4547d5c3dbf1Smrg # Stick the inst_prefix_dir data into the link command. 4548d5c3dbf1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549d5c3dbf1Smrg else 4550d5c3dbf1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551d5c3dbf1Smrg fi 4552d5c3dbf1Smrg 4553949d0342Smrg func_warning "relinking '$file'" 4554d5c3dbf1Smrg func_show_eval "$relink_command" \ 4555949d0342Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556d5c3dbf1Smrg fi 4557d5c3dbf1Smrg 4558d5c3dbf1Smrg # See the names of the shared library. 4559d5c3dbf1Smrg set dummy $library_names; shift 4560d5c3dbf1Smrg if test -n "$1"; then 4561949d0342Smrg realname=$1 4562d5c3dbf1Smrg shift 4563d5c3dbf1Smrg 4564949d0342Smrg srcname=$realname 4565949d0342Smrg test -n "$relink_command" && srcname=${realname}T 4566d5c3dbf1Smrg 4567d5c3dbf1Smrg # Install the shared library and build the symlinks. 4568d5c3dbf1Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569d5c3dbf1Smrg 'exit $?' 4570949d0342Smrg tstripme=$stripme 4571d5c3dbf1Smrg case $host_os in 4572d5c3dbf1Smrg cygwin* | mingw* | pw32* | cegcc*) 4573d5c3dbf1Smrg case $realname in 4574d5c3dbf1Smrg *.dll.a) 4575949d0342Smrg tstripme= 4576949d0342Smrg ;; 4577949d0342Smrg esac 4578949d0342Smrg ;; 4579949d0342Smrg os2*) 4580949d0342Smrg case $realname in 4581949d0342Smrg *_dll.a) 4582949d0342Smrg tstripme= 4583d5c3dbf1Smrg ;; 4584d5c3dbf1Smrg esac 45859f606849Smrg ;; 45869f606849Smrg esac 4587d5c3dbf1Smrg if test -n "$tstripme" && test -n "$striplib"; then 4588d5c3dbf1Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589d5c3dbf1Smrg fi 4590d5c3dbf1Smrg 4591d5c3dbf1Smrg if test "$#" -gt 0; then 4592d5c3dbf1Smrg # Delete the old symlinks, and create new ones. 4593949d0342Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594d5c3dbf1Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595d5c3dbf1Smrg # so we also need to try rm && ln -s. 4596d5c3dbf1Smrg for linkname 4597d5c3dbf1Smrg do 4598d5c3dbf1Smrg test "$linkname" != "$realname" \ 4599d5c3dbf1Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600d5c3dbf1Smrg done 4601d5c3dbf1Smrg fi 4602d5c3dbf1Smrg 4603d5c3dbf1Smrg # Do each command in the postinstall commands. 4604949d0342Smrg lib=$destdir/$realname 4605d5c3dbf1Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606d5c3dbf1Smrg fi 4607d5c3dbf1Smrg 4608d5c3dbf1Smrg # Install the pseudo-library for information purposes. 4609d5c3dbf1Smrg func_basename "$file" 4610949d0342Smrg name=$func_basename_result 4611949d0342Smrg instname=$dir/${name}i 4612d5c3dbf1Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613d5c3dbf1Smrg 4614d5c3dbf1Smrg # Maybe install the static library, too. 4615cdbfa18aSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 46169f606849Smrg ;; 4617d5c3dbf1Smrg 4618d5c3dbf1Smrg *.lo) 4619d5c3dbf1Smrg # Install (i.e. copy) a libtool object. 4620d5c3dbf1Smrg 4621d5c3dbf1Smrg # Figure out destination file name, if it wasn't already specified. 4622d5c3dbf1Smrg if test -n "$destname"; then 4623949d0342Smrg destfile=$destdir/$destname 4624d5c3dbf1Smrg else 4625d5c3dbf1Smrg func_basename "$file" 4626949d0342Smrg destfile=$func_basename_result 4627949d0342Smrg destfile=$destdir/$destfile 4628d5c3dbf1Smrg fi 4629d5c3dbf1Smrg 4630d5c3dbf1Smrg # Deduce the name of the destination old-style object file. 4631d5c3dbf1Smrg case $destfile in 4632d5c3dbf1Smrg *.lo) 4633d5c3dbf1Smrg func_lo2o "$destfile" 4634d5c3dbf1Smrg staticdest=$func_lo2o_result 46359f606849Smrg ;; 4636d5c3dbf1Smrg *.$objext) 4637949d0342Smrg staticdest=$destfile 4638d5c3dbf1Smrg destfile= 46399f606849Smrg ;; 4640d5c3dbf1Smrg *) 4641949d0342Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46429f606849Smrg ;; 4643d5c3dbf1Smrg esac 4644d5c3dbf1Smrg 4645d5c3dbf1Smrg # Install the libtool object if requested. 4646d5c3dbf1Smrg test -n "$destfile" && \ 4647d5c3dbf1Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648d5c3dbf1Smrg 4649d5c3dbf1Smrg # Install the old object if enabled. 4650949d0342Smrg if test yes = "$build_old_libs"; then 4651d5c3dbf1Smrg # Deduce the name of the old-style object file. 4652d5c3dbf1Smrg func_lo2o "$file" 4653d5c3dbf1Smrg staticobj=$func_lo2o_result 4654d5c3dbf1Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 46559f606849Smrg fi 4656d5c3dbf1Smrg exit $EXIT_SUCCESS 4657d5c3dbf1Smrg ;; 46589f606849Smrg 4659d5c3dbf1Smrg *) 4660d5c3dbf1Smrg # Figure out destination file name, if it wasn't already specified. 4661d5c3dbf1Smrg if test -n "$destname"; then 4662949d0342Smrg destfile=$destdir/$destname 46639f606849Smrg else 4664d5c3dbf1Smrg func_basename "$file" 4665949d0342Smrg destfile=$func_basename_result 4666949d0342Smrg destfile=$destdir/$destfile 46679f606849Smrg fi 46689f606849Smrg 4669d5c3dbf1Smrg # If the file is missing, and there is a .exe on the end, strip it 4670d5c3dbf1Smrg # because it is most likely a libtool script we actually want to 4671d5c3dbf1Smrg # install 4672949d0342Smrg stripped_ext= 4673d5c3dbf1Smrg case $file in 4674d5c3dbf1Smrg *.exe) 4675d5c3dbf1Smrg if test ! -f "$file"; then 4676d5c3dbf1Smrg func_stripname '' '.exe' "$file" 4677d5c3dbf1Smrg file=$func_stripname_result 4678949d0342Smrg stripped_ext=.exe 4679d5c3dbf1Smrg fi 4680d5c3dbf1Smrg ;; 4681d5c3dbf1Smrg esac 46829f606849Smrg 4683d5c3dbf1Smrg # Do a test to see if this is really a libtool program. 4684d5c3dbf1Smrg case $host in 4685d5c3dbf1Smrg *cygwin* | *mingw*) 4686d5c3dbf1Smrg if func_ltwrapper_executable_p "$file"; then 4687d5c3dbf1Smrg func_ltwrapper_scriptname "$file" 4688d5c3dbf1Smrg wrapper=$func_ltwrapper_scriptname_result 4689d5c3dbf1Smrg else 4690d5c3dbf1Smrg func_stripname '' '.exe' "$file" 4691d5c3dbf1Smrg wrapper=$func_stripname_result 4692d5c3dbf1Smrg fi 4693d5c3dbf1Smrg ;; 4694d5c3dbf1Smrg *) 4695d5c3dbf1Smrg wrapper=$file 4696d5c3dbf1Smrg ;; 4697d5c3dbf1Smrg esac 4698d5c3dbf1Smrg if func_ltwrapper_script_p "$wrapper"; then 4699d5c3dbf1Smrg notinst_deplibs= 4700d5c3dbf1Smrg relink_command= 47019f606849Smrg 4702d5c3dbf1Smrg func_source "$wrapper" 47039f606849Smrg 4704d5c3dbf1Smrg # Check the variables that should have been set. 4705d5c3dbf1Smrg test -z "$generated_by_libtool_version" && \ 4706949d0342Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47079f606849Smrg 4708949d0342Smrg finalize=: 4709d5c3dbf1Smrg for lib in $notinst_deplibs; do 4710d5c3dbf1Smrg # Check to see that each library is installed. 4711d5c3dbf1Smrg libdir= 4712d5c3dbf1Smrg if test -f "$lib"; then 4713d5c3dbf1Smrg func_source "$lib" 47149f606849Smrg fi 4715949d0342Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716d5c3dbf1Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4717949d0342Smrg func_warning "'$lib' has not been installed in '$libdir'" 4718949d0342Smrg finalize=false 4719d5c3dbf1Smrg fi 4720d5c3dbf1Smrg done 47219f606849Smrg 4722d5c3dbf1Smrg relink_command= 4723d5c3dbf1Smrg func_source "$wrapper" 47249f606849Smrg 4725d5c3dbf1Smrg outputname= 4726949d0342Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4727d5c3dbf1Smrg $opt_dry_run || { 4728949d0342Smrg if $finalize; then 4729d5c3dbf1Smrg tmpdir=`func_mktempdir` 4730d5c3dbf1Smrg func_basename "$file$stripped_ext" 4731949d0342Smrg file=$func_basename_result 4732949d0342Smrg outputname=$tmpdir/$file 4733d5c3dbf1Smrg # Replace the output file specification. 4734d5c3dbf1Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735d5c3dbf1Smrg 4736949d0342Smrg $opt_quiet || { 4737949d0342Smrg func_quote_arg expand,pretty "$relink_command" 4738949d0342Smrg eval "func_echo $func_quote_arg_result" 4739d5c3dbf1Smrg } 4740d5c3dbf1Smrg if eval "$relink_command"; then : 4741d5c3dbf1Smrg else 4742949d0342Smrg func_error "error: relink '$file' with the above command before installing it" 4743d5c3dbf1Smrg $opt_dry_run || ${RM}r "$tmpdir" 4744d5c3dbf1Smrg continue 4745d5c3dbf1Smrg fi 4746949d0342Smrg file=$outputname 4747d5c3dbf1Smrg else 4748949d0342Smrg func_warning "cannot relink '$file'" 4749d5c3dbf1Smrg fi 4750d5c3dbf1Smrg } 47519f606849Smrg else 4752d5c3dbf1Smrg # Install the binary that we compiled earlier. 4753d5c3dbf1Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47549f606849Smrg fi 4755d5c3dbf1Smrg fi 47569f606849Smrg 4757d5c3dbf1Smrg # remove .exe since cygwin /usr/bin/install will append another 4758d5c3dbf1Smrg # one anyway 4759d5c3dbf1Smrg case $install_prog,$host in 4760d5c3dbf1Smrg */usr/bin/install*,*cygwin*) 4761d5c3dbf1Smrg case $file:$destfile in 4762d5c3dbf1Smrg *.exe:*.exe) 4763d5c3dbf1Smrg # this is ok 4764d5c3dbf1Smrg ;; 4765d5c3dbf1Smrg *.exe:*) 4766d5c3dbf1Smrg destfile=$destfile.exe 4767d5c3dbf1Smrg ;; 4768d5c3dbf1Smrg *:*.exe) 4769d5c3dbf1Smrg func_stripname '' '.exe' "$destfile" 4770d5c3dbf1Smrg destfile=$func_stripname_result 4771d5c3dbf1Smrg ;; 4772d5c3dbf1Smrg esac 47739f606849Smrg ;; 47749f606849Smrg esac 4775d5c3dbf1Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776d5c3dbf1Smrg $opt_dry_run || if test -n "$outputname"; then 4777d5c3dbf1Smrg ${RM}r "$tmpdir" 4778d5c3dbf1Smrg fi 4779d5c3dbf1Smrg ;; 4780d5c3dbf1Smrg esac 4781d5c3dbf1Smrg done 47829f606849Smrg 4783d5c3dbf1Smrg for file in $staticlibs; do 4784d5c3dbf1Smrg func_basename "$file" 4785949d0342Smrg name=$func_basename_result 4786d5c3dbf1Smrg 4787d5c3dbf1Smrg # Set up the ranlib parameters. 4788949d0342Smrg oldlib=$destdir/$name 4789cdbfa18aSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790cdbfa18aSmrg tool_oldlib=$func_to_tool_file_result 4791d5c3dbf1Smrg 4792d5c3dbf1Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793d5c3dbf1Smrg 4794d5c3dbf1Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4795cdbfa18aSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796d5c3dbf1Smrg fi 4797d5c3dbf1Smrg 4798d5c3dbf1Smrg # Do each command in the postinstall commands. 4799d5c3dbf1Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800d5c3dbf1Smrg done 4801d5c3dbf1Smrg 4802d5c3dbf1Smrg test -n "$future_libdirs" && \ 4803949d0342Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804d5c3dbf1Smrg 4805d5c3dbf1Smrg if test -n "$current_libdirs"; then 4806d5c3dbf1Smrg # Maybe just do a dry run. 4807d5c3dbf1Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4808949d0342Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809d5c3dbf1Smrg else 4810d5c3dbf1Smrg exit $EXIT_SUCCESS 4811d5c3dbf1Smrg fi 4812d5c3dbf1Smrg} 4813d5c3dbf1Smrg 4814949d0342Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815d5c3dbf1Smrg 4816d5c3dbf1Smrg 4817d5c3dbf1Smrg# func_generate_dlsyms outputname originator pic_p 4818d5c3dbf1Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819d5c3dbf1Smrg# a dlpreopen symbol table. 4820d5c3dbf1Smrgfunc_generate_dlsyms () 4821d5c3dbf1Smrg{ 4822949d0342Smrg $debug_cmd 4823949d0342Smrg 4824949d0342Smrg my_outputname=$1 4825949d0342Smrg my_originator=$2 4826949d0342Smrg my_pic_p=${3-false} 4827949d0342Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828d5c3dbf1Smrg my_dlsyms= 4829d5c3dbf1Smrg 4830949d0342Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831d5c3dbf1Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4832949d0342Smrg my_dlsyms=${my_outputname}S.c 4833d5c3dbf1Smrg else 4834d5c3dbf1Smrg func_error "not configured to extract global symbols from dlpreopened files" 4835d5c3dbf1Smrg fi 4836d5c3dbf1Smrg fi 4837d5c3dbf1Smrg 4838d5c3dbf1Smrg if test -n "$my_dlsyms"; then 4839d5c3dbf1Smrg case $my_dlsyms in 4840d5c3dbf1Smrg "") ;; 4841d5c3dbf1Smrg *.c) 4842d5c3dbf1Smrg # Discover the nlist of each of the dlfiles. 4843949d0342Smrg nlist=$output_objdir/$my_outputname.nm 4844d5c3dbf1Smrg 4845d5c3dbf1Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846d5c3dbf1Smrg 4847d5c3dbf1Smrg # Parse the name list into a source file. 4848d5c3dbf1Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4849d5c3dbf1Smrg 4850d5c3dbf1Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4851949d0342Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4852949d0342Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853d5c3dbf1Smrg 4854d5c3dbf1Smrg#ifdef __cplusplus 4855d5c3dbf1Smrgextern \"C\" { 4856d5c3dbf1Smrg#endif 4857d5c3dbf1Smrg 4858949d0342Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859d5c3dbf1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860d5c3dbf1Smrg#endif 4861d5c3dbf1Smrg 4862cdbfa18aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4863949d0342Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4864949d0342Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865cdbfa18aSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866cdbfa18aSmrg# define LT_DLSYM_CONST 4867949d0342Smrg#elif defined __osf__ 4868cdbfa18aSmrg/* This system does not cope well with relocations in const data. */ 4869cdbfa18aSmrg# define LT_DLSYM_CONST 4870cdbfa18aSmrg#else 4871cdbfa18aSmrg# define LT_DLSYM_CONST const 4872cdbfa18aSmrg#endif 4873cdbfa18aSmrg 4874949d0342Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4875949d0342Smrg 4876d5c3dbf1Smrg/* External symbol declarations for the compiler. */\ 4877d5c3dbf1Smrg" 4878d5c3dbf1Smrg 4879949d0342Smrg if test yes = "$dlself"; then 4880949d0342Smrg func_verbose "generating symbol list for '$output'" 4881d5c3dbf1Smrg 4882d5c3dbf1Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883d5c3dbf1Smrg 4884d5c3dbf1Smrg # Add our own program objects to the symbol list. 4885d5c3dbf1Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886d5c3dbf1Smrg for progfile in $progfiles; do 4887cdbfa18aSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4888949d0342Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889cdbfa18aSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890d5c3dbf1Smrg done 4891d5c3dbf1Smrg 4892d5c3dbf1Smrg if test -n "$exclude_expsyms"; then 4893d5c3dbf1Smrg $opt_dry_run || { 4894d5c3dbf1Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895d5c3dbf1Smrg eval '$MV "$nlist"T "$nlist"' 4896d5c3dbf1Smrg } 48979f606849Smrg fi 4898d5c3dbf1Smrg 4899d5c3dbf1Smrg if test -n "$export_symbols_regex"; then 4900d5c3dbf1Smrg $opt_dry_run || { 4901d5c3dbf1Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902d5c3dbf1Smrg eval '$MV "$nlist"T "$nlist"' 4903d5c3dbf1Smrg } 4904d5c3dbf1Smrg fi 4905d5c3dbf1Smrg 4906d5c3dbf1Smrg # Prepare the list of exported symbols 4907d5c3dbf1Smrg if test -z "$export_symbols"; then 4908949d0342Smrg export_symbols=$output_objdir/$outputname.exp 4909d5c3dbf1Smrg $opt_dry_run || { 4910d5c3dbf1Smrg $RM $export_symbols 4911949d0342Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912d5c3dbf1Smrg case $host in 4913d5c3dbf1Smrg *cygwin* | *mingw* | *cegcc* ) 4914d5c3dbf1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915d5c3dbf1Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916d5c3dbf1Smrg ;; 4917d5c3dbf1Smrg esac 4918d5c3dbf1Smrg } 49199f606849Smrg else 4920d5c3dbf1Smrg $opt_dry_run || { 4921949d0342Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922d5c3dbf1Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923d5c3dbf1Smrg eval '$MV "$nlist"T "$nlist"' 4924d5c3dbf1Smrg case $host in 4925d5c3dbf1Smrg *cygwin* | *mingw* | *cegcc* ) 4926d5c3dbf1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927d5c3dbf1Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928d5c3dbf1Smrg ;; 4929d5c3dbf1Smrg esac 4930d5c3dbf1Smrg } 49319f606849Smrg fi 4932d5c3dbf1Smrg fi 49339f606849Smrg 4934d5c3dbf1Smrg for dlprefile in $dlprefiles; do 4935949d0342Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4936d5c3dbf1Smrg func_basename "$dlprefile" 4937949d0342Smrg name=$func_basename_result 4938cdbfa18aSmrg case $host in 4939cdbfa18aSmrg *cygwin* | *mingw* | *cegcc* ) 4940cdbfa18aSmrg # if an import library, we need to obtain dlname 4941cdbfa18aSmrg if func_win32_import_lib_p "$dlprefile"; then 4942cdbfa18aSmrg func_tr_sh "$dlprefile" 4943cdbfa18aSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4944949d0342Smrg dlprefile_dlbasename= 4945cdbfa18aSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946cdbfa18aSmrg # Use subshell, to avoid clobbering current variable values 4947cdbfa18aSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4948949d0342Smrg if test -n "$dlprefile_dlname"; then 4949cdbfa18aSmrg func_basename "$dlprefile_dlname" 4950949d0342Smrg dlprefile_dlbasename=$func_basename_result 4951cdbfa18aSmrg else 4952cdbfa18aSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953cdbfa18aSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4954cdbfa18aSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955cdbfa18aSmrg fi 4956cdbfa18aSmrg fi 4957cdbfa18aSmrg $opt_dry_run || { 4958949d0342Smrg if test -n "$dlprefile_dlbasename"; then 4959cdbfa18aSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960cdbfa18aSmrg else 4961cdbfa18aSmrg func_warning "Could not compute DLL name from $name" 4962cdbfa18aSmrg eval '$ECHO ": $name " >> "$nlist"' 4963cdbfa18aSmrg fi 4964cdbfa18aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965cdbfa18aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966cdbfa18aSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967cdbfa18aSmrg } 4968cdbfa18aSmrg else # not an import lib 4969cdbfa18aSmrg $opt_dry_run || { 4970cdbfa18aSmrg eval '$ECHO ": $name " >> "$nlist"' 4971cdbfa18aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972cdbfa18aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973cdbfa18aSmrg } 4974cdbfa18aSmrg fi 4975cdbfa18aSmrg ;; 4976cdbfa18aSmrg *) 4977cdbfa18aSmrg $opt_dry_run || { 4978cdbfa18aSmrg eval '$ECHO ": $name " >> "$nlist"' 4979cdbfa18aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980cdbfa18aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981cdbfa18aSmrg } 4982cdbfa18aSmrg ;; 4983cdbfa18aSmrg esac 4984d5c3dbf1Smrg done 4985d5c3dbf1Smrg 4986d5c3dbf1Smrg $opt_dry_run || { 4987d5c3dbf1Smrg # Make sure we have at least an empty file. 4988d5c3dbf1Smrg test -f "$nlist" || : > "$nlist" 4989d5c3dbf1Smrg 4990d5c3dbf1Smrg if test -n "$exclude_expsyms"; then 4991d5c3dbf1Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992d5c3dbf1Smrg $MV "$nlist"T "$nlist" 49939f606849Smrg fi 4994d5c3dbf1Smrg 4995d5c3dbf1Smrg # Try sorting and uniquifying the output. 4996d5c3dbf1Smrg if $GREP -v "^: " < "$nlist" | 4997d5c3dbf1Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998d5c3dbf1Smrg sort -k 3 4999d5c3dbf1Smrg else 5000d5c3dbf1Smrg sort +2 5001d5c3dbf1Smrg fi | 5002d5c3dbf1Smrg uniq > "$nlist"S; then 5003d5c3dbf1Smrg : 50049f606849Smrg else 5005d5c3dbf1Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 50069f606849Smrg fi 50079f606849Smrg 5008d5c3dbf1Smrg if test -f "$nlist"S; then 5009d5c3dbf1Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50109f606849Smrg else 5011d5c3dbf1Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50129f606849Smrg fi 50139f606849Smrg 5014949d0342Smrg func_show_eval '$RM "${nlist}I"' 5015949d0342Smrg if test -n "$global_symbol_to_import"; then 5016949d0342Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5017949d0342Smrg fi 5018949d0342Smrg 5019d5c3dbf1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50209f606849Smrg 5021d5c3dbf1Smrg/* The mapping between symbol names and symbols. */ 5022d5c3dbf1Smrgtypedef struct { 5023d5c3dbf1Smrg const char *name; 5024d5c3dbf1Smrg void *address; 5025d5c3dbf1Smrg} lt_dlsymlist; 5026cdbfa18aSmrgextern LT_DLSYM_CONST lt_dlsymlist 5027949d0342Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5028949d0342Smrg" 5029949d0342Smrg 5030949d0342Smrg if test -s "$nlist"I; then 5031949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5032949d0342Smrgstatic void lt_syminit(void) 5033949d0342Smrg{ 5034949d0342Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5035949d0342Smrg for (; symbol->name; ++symbol) 5036949d0342Smrg {" 5037949d0342Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5038949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5039949d0342Smrg } 5040949d0342Smrg}" 5041949d0342Smrg fi 5042949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5043cdbfa18aSmrgLT_DLSYM_CONST lt_dlsymlist 5044d5c3dbf1Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 5045949d0342Smrg{ {\"$my_originator\", (void *) 0}," 5046949d0342Smrg 5047949d0342Smrg if test -s "$nlist"I; then 5048949d0342Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5049949d0342Smrg {\"@INIT@\", (void *) <_syminit}," 5050949d0342Smrg fi 50519f606849Smrg 5052d5c3dbf1Smrg case $need_lib_prefix in 5053d5c3dbf1Smrg no) 5054d5c3dbf1Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055d5c3dbf1Smrg ;; 5056d5c3dbf1Smrg *) 5057d5c3dbf1Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058d5c3dbf1Smrg ;; 5059d5c3dbf1Smrg esac 5060d5c3dbf1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5061d5c3dbf1Smrg {0, (void *) 0} 5062d5c3dbf1Smrg}; 50639f606849Smrg 5064d5c3dbf1Smrg/* This works around a problem in FreeBSD linker */ 5065d5c3dbf1Smrg#ifdef FREEBSD_WORKAROUND 5066d5c3dbf1Smrgstatic const void *lt_preloaded_setup() { 5067d5c3dbf1Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068d5c3dbf1Smrg} 5069d5c3dbf1Smrg#endif 50709f606849Smrg 5071d5c3dbf1Smrg#ifdef __cplusplus 5072d5c3dbf1Smrg} 5073d5c3dbf1Smrg#endif\ 5074d5c3dbf1Smrg" 5075d5c3dbf1Smrg } # !$opt_dry_run 50769f606849Smrg 5077d5c3dbf1Smrg pic_flag_for_symtable= 5078d5c3dbf1Smrg case "$compile_command " in 5079d5c3dbf1Smrg *" -static "*) ;; 5080d5c3dbf1Smrg *) 5081d5c3dbf1Smrg case $host in 5082d5c3dbf1Smrg # compiling the symbol table file with pic_flag works around 5083d5c3dbf1Smrg # a FreeBSD bug that causes programs to crash when -lm is 5084d5c3dbf1Smrg # linked before any other PIC object. But we must not use 5085d5c3dbf1Smrg # pic_flag when linking with -static. The problem exists in 5086d5c3dbf1Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087cdbfa18aSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088d5c3dbf1Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089d5c3dbf1Smrg *-*-hpux*) 5090d5c3dbf1Smrg pic_flag_for_symtable=" $pic_flag" ;; 5091d5c3dbf1Smrg *) 5092949d0342Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093d5c3dbf1Smrg ;; 5094d5c3dbf1Smrg esac 5095d5c3dbf1Smrg ;; 5096d5c3dbf1Smrg esac 5097d5c3dbf1Smrg symtab_cflags= 5098d5c3dbf1Smrg for arg in $LTCFLAGS; do 5099d5c3dbf1Smrg case $arg in 5100d5c3dbf1Smrg -pie | -fpie | -fPIE) ;; 5101cdbfa18aSmrg *) func_append symtab_cflags " $arg" ;; 5102d5c3dbf1Smrg esac 5103d5c3dbf1Smrg done 51049f606849Smrg 5105d5c3dbf1Smrg # Now compile the dynamic symbol file. 5106d5c3dbf1Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51079f606849Smrg 5108d5c3dbf1Smrg # Clean up the generated files. 5109949d0342Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51109f606849Smrg 5111d5c3dbf1Smrg # Transform the symbol file into the correct name. 5112949d0342Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113d5c3dbf1Smrg case $host in 5114d5c3dbf1Smrg *cygwin* | *mingw* | *cegcc* ) 5115d5c3dbf1Smrg if test -f "$output_objdir/$my_outputname.def"; then 5116d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118d5c3dbf1Smrg else 5119d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121d5c3dbf1Smrg fi 5122d5c3dbf1Smrg ;; 5123d5c3dbf1Smrg *) 5124d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126d5c3dbf1Smrg ;; 5127d5c3dbf1Smrg esac 5128d5c3dbf1Smrg ;; 5129d5c3dbf1Smrg *) 5130949d0342Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131d5c3dbf1Smrg ;; 5132d5c3dbf1Smrg esac 5133d5c3dbf1Smrg else 5134d5c3dbf1Smrg # We keep going just in case the user didn't refer to 5135d5c3dbf1Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136d5c3dbf1Smrg # really was required. 51379f606849Smrg 5138d5c3dbf1Smrg # Nullify the symbol file. 5139d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141d5c3dbf1Smrg fi 5142d5c3dbf1Smrg} 51439f606849Smrg 5144949d0342Smrg# func_cygming_gnu_implib_p ARG 5145949d0342Smrg# This predicate returns with zero status (TRUE) if 5146949d0342Smrg# ARG is a GNU/binutils-style import library. Returns 5147949d0342Smrg# with nonzero status (FALSE) otherwise. 5148949d0342Smrgfunc_cygming_gnu_implib_p () 5149949d0342Smrg{ 5150949d0342Smrg $debug_cmd 5151949d0342Smrg 5152949d0342Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5153949d0342Smrg 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)$'` 5154949d0342Smrg test -n "$func_cygming_gnu_implib_tmp" 5155949d0342Smrg} 5156949d0342Smrg 5157949d0342Smrg# func_cygming_ms_implib_p ARG 5158949d0342Smrg# This predicate returns with zero status (TRUE) if 5159949d0342Smrg# ARG is an MS-style import library. Returns 5160949d0342Smrg# with nonzero status (FALSE) otherwise. 5161949d0342Smrgfunc_cygming_ms_implib_p () 5162949d0342Smrg{ 5163949d0342Smrg $debug_cmd 5164949d0342Smrg 5165949d0342Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5166949d0342Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5167949d0342Smrg test -n "$func_cygming_ms_implib_tmp" 5168949d0342Smrg} 5169949d0342Smrg 5170d5c3dbf1Smrg# func_win32_libid arg 5171d5c3dbf1Smrg# return the library type of file 'arg' 5172d5c3dbf1Smrg# 5173d5c3dbf1Smrg# Need a lot of goo to handle *both* DLLs and import libs 5174d5c3dbf1Smrg# Has to be a shell function in order to 'eat' the argument 5175d5c3dbf1Smrg# that is supplied when $file_magic_command is called. 5176d5c3dbf1Smrg# Despite the name, also deal with 64 bit binaries. 5177d5c3dbf1Smrgfunc_win32_libid () 5178d5c3dbf1Smrg{ 5179949d0342Smrg $debug_cmd 5180949d0342Smrg 5181949d0342Smrg win32_libid_type=unknown 5182d5c3dbf1Smrg win32_fileres=`file -L $1 2>/dev/null` 5183d5c3dbf1Smrg case $win32_fileres in 5184d5c3dbf1Smrg *ar\ archive\ import\ library*) # definitely import 5185d5c3dbf1Smrg win32_libid_type="x86 archive import" 5186d5c3dbf1Smrg ;; 5187d5c3dbf1Smrg *ar\ archive*) # could be an import, or static 5188d5c3dbf1Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189d5c3dbf1Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190d5c3dbf1Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5191949d0342Smrg case $nm_interface in 5192949d0342Smrg "MS dumpbin") 5193949d0342Smrg if func_cygming_ms_implib_p "$1" || 5194949d0342Smrg func_cygming_gnu_implib_p "$1" 5195949d0342Smrg then 5196949d0342Smrg win32_nmres=import 5197949d0342Smrg else 5198949d0342Smrg win32_nmres= 5199949d0342Smrg fi 5200949d0342Smrg ;; 5201949d0342Smrg *) 5202949d0342Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5203949d0342Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5204949d0342Smrg $SED -n -e ' 5205d5c3dbf1Smrg 1,100{ 5206d5c3dbf1Smrg / I /{ 5207949d0342Smrg s|.*|import| 5208d5c3dbf1Smrg p 5209d5c3dbf1Smrg q 5210d5c3dbf1Smrg } 5211d5c3dbf1Smrg }'` 5212949d0342Smrg ;; 5213949d0342Smrg esac 5214d5c3dbf1Smrg case $win32_nmres in 5215d5c3dbf1Smrg import*) win32_libid_type="x86 archive import";; 5216d5c3dbf1Smrg *) win32_libid_type="x86 archive static";; 5217d5c3dbf1Smrg esac 5218d5c3dbf1Smrg fi 5219d5c3dbf1Smrg ;; 5220d5c3dbf1Smrg *DLL*) 5221d5c3dbf1Smrg win32_libid_type="x86 DLL" 5222d5c3dbf1Smrg ;; 5223d5c3dbf1Smrg *executable*) # but shell scripts are "executable" too... 5224d5c3dbf1Smrg case $win32_fileres in 5225d5c3dbf1Smrg *MS\ Windows\ PE\ Intel*) 5226d5c3dbf1Smrg win32_libid_type="x86 DLL" 5227d5c3dbf1Smrg ;; 5228d5c3dbf1Smrg esac 5229d5c3dbf1Smrg ;; 5230d5c3dbf1Smrg esac 5231d5c3dbf1Smrg $ECHO "$win32_libid_type" 5232d5c3dbf1Smrg} 52339f606849Smrg 5234cdbfa18aSmrg# func_cygming_dll_for_implib ARG 5235cdbfa18aSmrg# 5236cdbfa18aSmrg# Platform-specific function to extract the 5237cdbfa18aSmrg# name of the DLL associated with the specified 5238cdbfa18aSmrg# import library ARG. 5239cdbfa18aSmrg# Invoked by eval'ing the libtool variable 5240cdbfa18aSmrg# $sharedlib_from_linklib_cmd 5241cdbfa18aSmrg# Result is available in the variable 5242cdbfa18aSmrg# $sharedlib_from_linklib_result 5243cdbfa18aSmrgfunc_cygming_dll_for_implib () 5244cdbfa18aSmrg{ 5245949d0342Smrg $debug_cmd 5246949d0342Smrg 5247cdbfa18aSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248cdbfa18aSmrg} 5249cdbfa18aSmrg 5250cdbfa18aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251cdbfa18aSmrg# 5252cdbfa18aSmrg# The is the core of a fallback implementation of a 5253cdbfa18aSmrg# platform-specific function to extract the name of the 5254cdbfa18aSmrg# DLL associated with the specified import library LIBNAME. 5255cdbfa18aSmrg# 5256cdbfa18aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257cdbfa18aSmrg# on the platform and compiler that created the implib. 5258cdbfa18aSmrg# 5259cdbfa18aSmrg# Echos the name of the DLL associated with the 5260cdbfa18aSmrg# specified import library. 5261cdbfa18aSmrgfunc_cygming_dll_for_implib_fallback_core () 5262cdbfa18aSmrg{ 5263949d0342Smrg $debug_cmd 5264949d0342Smrg 5265cdbfa18aSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266cdbfa18aSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267cdbfa18aSmrg $SED '/^Contents of section '"$match_literal"':/{ 5268cdbfa18aSmrg # Place marker at beginning of archive member dllname section 5269cdbfa18aSmrg s/.*/====MARK====/ 5270cdbfa18aSmrg p 5271cdbfa18aSmrg d 5272cdbfa18aSmrg } 5273cdbfa18aSmrg # These lines can sometimes be longer than 43 characters, but 5274cdbfa18aSmrg # are always uninteresting 5275cdbfa18aSmrg /:[ ]*file format pe[i]\{,1\}-/d 5276cdbfa18aSmrg /^In archive [^:]*:/d 5277cdbfa18aSmrg # Ensure marker is printed 5278cdbfa18aSmrg /^====MARK====/p 5279cdbfa18aSmrg # Remove all lines with less than 43 characters 5280cdbfa18aSmrg /^.\{43\}/!d 5281cdbfa18aSmrg # From remaining lines, remove first 43 characters 5282cdbfa18aSmrg s/^.\{43\}//' | 5283cdbfa18aSmrg $SED -n ' 5284cdbfa18aSmrg # Join marker and all lines until next marker into a single line 5285cdbfa18aSmrg /^====MARK====/ b para 5286cdbfa18aSmrg H 5287cdbfa18aSmrg $ b para 5288cdbfa18aSmrg b 5289cdbfa18aSmrg :para 5290cdbfa18aSmrg x 5291cdbfa18aSmrg s/\n//g 5292cdbfa18aSmrg # Remove the marker 5293cdbfa18aSmrg s/^====MARK====// 5294cdbfa18aSmrg # Remove trailing dots and whitespace 5295cdbfa18aSmrg s/[\. \t]*$// 5296cdbfa18aSmrg # Print 5297cdbfa18aSmrg /./p' | 5298cdbfa18aSmrg # we now have a list, one entry per line, of the stringified 5299cdbfa18aSmrg # contents of the appropriate section of all members of the 5300949d0342Smrg # archive that possess that section. Heuristic: eliminate 5301949d0342Smrg # all those that have a first or second character that is 5302cdbfa18aSmrg # a '.' (that is, objdump's representation of an unprintable 5303cdbfa18aSmrg # character.) This should work for all archives with less than 5304cdbfa18aSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5305cdbfa18aSmrg # begins with a literal '.' or a single character followed by 5306cdbfa18aSmrg # a '.'. 5307cdbfa18aSmrg # 5308cdbfa18aSmrg # Of those that remain, print the first one. 5309cdbfa18aSmrg $SED -e '/^\./d;/^.\./d;q' 5310cdbfa18aSmrg} 5311cdbfa18aSmrg 5312cdbfa18aSmrg# func_cygming_dll_for_implib_fallback ARG 5313cdbfa18aSmrg# Platform-specific function to extract the 5314cdbfa18aSmrg# name of the DLL associated with the specified 5315cdbfa18aSmrg# import library ARG. 5316cdbfa18aSmrg# 5317cdbfa18aSmrg# This fallback implementation is for use when $DLLTOOL 5318cdbfa18aSmrg# does not support the --identify-strict option. 5319cdbfa18aSmrg# Invoked by eval'ing the libtool variable 5320cdbfa18aSmrg# $sharedlib_from_linklib_cmd 5321cdbfa18aSmrg# Result is available in the variable 5322cdbfa18aSmrg# $sharedlib_from_linklib_result 5323cdbfa18aSmrgfunc_cygming_dll_for_implib_fallback () 5324cdbfa18aSmrg{ 5325949d0342Smrg $debug_cmd 5326949d0342Smrg 5327949d0342Smrg if func_cygming_gnu_implib_p "$1"; then 5328cdbfa18aSmrg # binutils import library 5329cdbfa18aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5330949d0342Smrg elif func_cygming_ms_implib_p "$1"; then 5331cdbfa18aSmrg # ms-generated import library 5332cdbfa18aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333cdbfa18aSmrg else 5334cdbfa18aSmrg # unknown 5335949d0342Smrg sharedlib_from_linklib_result= 5336cdbfa18aSmrg fi 5337cdbfa18aSmrg} 53389f606849Smrg 53399f606849Smrg 5340d5c3dbf1Smrg# func_extract_an_archive dir oldlib 5341d5c3dbf1Smrgfunc_extract_an_archive () 5342d5c3dbf1Smrg{ 5343949d0342Smrg $debug_cmd 5344949d0342Smrg 5345949d0342Smrg f_ex_an_ar_dir=$1; shift 5346949d0342Smrg f_ex_an_ar_oldlib=$1 5347949d0342Smrg if test yes = "$lock_old_archive_extraction"; then 5348d5c3dbf1Smrg lockfile=$f_ex_an_ar_oldlib.lock 5349d5c3dbf1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350d5c3dbf1Smrg func_echo "Waiting for $lockfile to be removed" 5351d5c3dbf1Smrg sleep 2 5352d5c3dbf1Smrg done 5353d5c3dbf1Smrg fi 5354d5c3dbf1Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355d5c3dbf1Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5356949d0342Smrg if test yes = "$lock_old_archive_extraction"; then 5357d5c3dbf1Smrg $opt_dry_run || rm -f "$lockfile" 5358d5c3dbf1Smrg fi 5359d5c3dbf1Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360d5c3dbf1Smrg : 5361d5c3dbf1Smrg else 5362d5c3dbf1Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363d5c3dbf1Smrg fi 5364d5c3dbf1Smrg} 53659f606849Smrg 53669f606849Smrg 5367d5c3dbf1Smrg# func_extract_archives gentop oldlib ... 5368d5c3dbf1Smrgfunc_extract_archives () 5369d5c3dbf1Smrg{ 5370949d0342Smrg $debug_cmd 5371949d0342Smrg 5372949d0342Smrg my_gentop=$1; shift 5373d5c3dbf1Smrg my_oldlibs=${1+"$@"} 5374949d0342Smrg my_oldobjs= 5375949d0342Smrg my_xlib= 5376949d0342Smrg my_xabs= 5377949d0342Smrg my_xdir= 53789f606849Smrg 5379d5c3dbf1Smrg for my_xlib in $my_oldlibs; do 5380d5c3dbf1Smrg # Extract the objects. 5381d5c3dbf1Smrg case $my_xlib in 5382949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383d5c3dbf1Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384d5c3dbf1Smrg esac 5385d5c3dbf1Smrg func_basename "$my_xlib" 5386949d0342Smrg my_xlib=$func_basename_result 5387d5c3dbf1Smrg my_xlib_u=$my_xlib 5388d5c3dbf1Smrg while :; do 5389d5c3dbf1Smrg case " $extracted_archives " in 5390d5c3dbf1Smrg *" $my_xlib_u "*) 5391d5c3dbf1Smrg func_arith $extracted_serial + 1 5392d5c3dbf1Smrg extracted_serial=$func_arith_result 5393d5c3dbf1Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394d5c3dbf1Smrg *) break ;; 5395d5c3dbf1Smrg esac 5396d5c3dbf1Smrg done 5397d5c3dbf1Smrg extracted_archives="$extracted_archives $my_xlib_u" 5398949d0342Smrg my_xdir=$my_gentop/$my_xlib_u 53999f606849Smrg 5400d5c3dbf1Smrg func_mkdir_p "$my_xdir" 5401d5c3dbf1Smrg 5402d5c3dbf1Smrg case $host in 5403d5c3dbf1Smrg *-darwin*) 5404d5c3dbf1Smrg func_verbose "Extracting $my_xabs" 5405d5c3dbf1Smrg # Do not bother doing anything if just a dry run 5406d5c3dbf1Smrg $opt_dry_run || { 5407d5c3dbf1Smrg darwin_orig_dir=`pwd` 5408d5c3dbf1Smrg cd $my_xdir || exit $? 5409d5c3dbf1Smrg darwin_archive=$my_xabs 5410d5c3dbf1Smrg darwin_curdir=`pwd` 5411949d0342Smrg func_basename "$darwin_archive" 5412949d0342Smrg darwin_base_archive=$func_basename_result 5413d5c3dbf1Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414d5c3dbf1Smrg if test -n "$darwin_arches"; then 5415d5c3dbf1Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416d5c3dbf1Smrg darwin_arch= 5417d5c3dbf1Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5418949d0342Smrg for darwin_arch in $darwin_arches; do 5419949d0342Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5420949d0342Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5421949d0342Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5422949d0342Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423d5c3dbf1Smrg cd "$darwin_curdir" 5424949d0342Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425d5c3dbf1Smrg done # $darwin_arches 5426d5c3dbf1Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5427949d0342Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428d5c3dbf1Smrg darwin_file= 5429d5c3dbf1Smrg darwin_files= 5430d5c3dbf1Smrg for darwin_file in $darwin_filelist; do 5431d5c3dbf1Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432d5c3dbf1Smrg $LIPO -create -output "$darwin_file" $darwin_files 5433d5c3dbf1Smrg done # $darwin_filelist 5434d5c3dbf1Smrg $RM -rf unfat-$$ 5435d5c3dbf1Smrg cd "$darwin_orig_dir" 54369f606849Smrg else 5437d5c3dbf1Smrg cd $darwin_orig_dir 5438d5c3dbf1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439d5c3dbf1Smrg fi # $darwin_arches 5440d5c3dbf1Smrg } # !$opt_dry_run 5441d5c3dbf1Smrg ;; 5442d5c3dbf1Smrg *) 5443d5c3dbf1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444d5c3dbf1Smrg ;; 5445d5c3dbf1Smrg esac 5446d5c3dbf1Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447d5c3dbf1Smrg done 54489f606849Smrg 5449949d0342Smrg func_extract_archives_result=$my_oldobjs 5450d5c3dbf1Smrg} 54519f606849Smrg 54529f606849Smrg 5453d5c3dbf1Smrg# func_emit_wrapper [arg=no] 5454d5c3dbf1Smrg# 5455d5c3dbf1Smrg# Emit a libtool wrapper script on stdout. 5456d5c3dbf1Smrg# Don't directly open a file because we may want to 5457d5c3dbf1Smrg# incorporate the script contents within a cygwin/mingw 5458d5c3dbf1Smrg# wrapper executable. Must ONLY be called from within 5459d5c3dbf1Smrg# func_mode_link because it depends on a number of variables 5460d5c3dbf1Smrg# set therein. 5461d5c3dbf1Smrg# 5462d5c3dbf1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463d5c3dbf1Smrg# variable will take. If 'yes', then the emitted script 5464949d0342Smrg# will assume that the directory where it is stored is 5465d5c3dbf1Smrg# the $objdir directory. This is a cygwin/mingw-specific 5466d5c3dbf1Smrg# behavior. 5467d5c3dbf1Smrgfunc_emit_wrapper () 5468d5c3dbf1Smrg{ 5469d5c3dbf1Smrg func_emit_wrapper_arg1=${1-no} 54709f606849Smrg 5471d5c3dbf1Smrg $ECHO "\ 5472d5c3dbf1Smrg#! $SHELL 54739f606849Smrg 5474d5c3dbf1Smrg# $output - temporary wrapper script for $objdir/$outputname 5475949d0342Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476d5c3dbf1Smrg# 5477d5c3dbf1Smrg# The $output program cannot be directly executed until all the libtool 5478d5c3dbf1Smrg# libraries that it depends on are installed. 5479d5c3dbf1Smrg# 5480d5c3dbf1Smrg# This wrapper script should never be moved out of the build directory. 5481d5c3dbf1Smrg# If it is, it will not operate correctly. 54829f606849Smrg 5483d5c3dbf1Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5484d5c3dbf1Smrg# metacharacters that are still active within double-quoted strings. 5485d5c3dbf1Smrgsed_quote_subst='$sed_quote_subst' 54869f606849Smrg 5487d5c3dbf1Smrg# Be Bourne compatible 5488d5c3dbf1Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489d5c3dbf1Smrg emulate sh 5490d5c3dbf1Smrg NULLCMD=: 5491d5c3dbf1Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492d5c3dbf1Smrg # is contrary to our usage. Disable this feature. 5493d5c3dbf1Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494d5c3dbf1Smrg setopt NO_GLOB_SUBST 5495d5c3dbf1Smrgelse 5496d5c3dbf1Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497d5c3dbf1Smrgfi 5498d5c3dbf1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499d5c3dbf1SmrgDUALCASE=1; export DUALCASE # for MKS sh 55009f606849Smrg 5501d5c3dbf1Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502d5c3dbf1Smrg# if CDPATH is set. 5503d5c3dbf1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55049f606849Smrg 5505d5c3dbf1Smrgrelink_command=\"$relink_command\" 55069f606849Smrg 5507d5c3dbf1Smrg# This environment variable determines our operation mode. 5508d5c3dbf1Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509d5c3dbf1Smrg # install mode needs the following variables: 5510d5c3dbf1Smrg generated_by_libtool_version='$macro_version' 5511d5c3dbf1Smrg notinst_deplibs='$notinst_deplibs' 5512d5c3dbf1Smrgelse 5513d5c3dbf1Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514d5c3dbf1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515d5c3dbf1Smrg file=\"\$0\"" 55169f606849Smrg 5517949d0342Smrg func_quote_arg pretty "$ECHO" 5518949d0342Smrg qECHO=$func_quote_arg_result 5519d5c3dbf1Smrg $ECHO "\ 55209f606849Smrg 5521d5c3dbf1Smrg# A function that is used when there is no print builtin or printf. 5522d5c3dbf1Smrgfunc_fallback_echo () 5523d5c3dbf1Smrg{ 5524d5c3dbf1Smrg eval 'cat <<_LTECHO_EOF 5525d5c3dbf1Smrg\$1 5526d5c3dbf1Smrg_LTECHO_EOF' 5527d5c3dbf1Smrg} 5528949d0342Smrg ECHO=$qECHO 5529d5c3dbf1Smrg fi 5530d5c3dbf1Smrg 5531d5c3dbf1Smrg# Very basic option parsing. These options are (a) specific to 5532d5c3dbf1Smrg# the libtool wrapper, (b) are identical between the wrapper 5533949d0342Smrg# /script/ and the wrapper /executable/ that is used only on 5534d5c3dbf1Smrg# windows platforms, and (c) all begin with the string "--lt-" 5535949d0342Smrg# (application programs are unlikely to have options that match 5536d5c3dbf1Smrg# this pattern). 5537d5c3dbf1Smrg# 5538d5c3dbf1Smrg# There are only two supported options: --lt-debug and 5539d5c3dbf1Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540d5c3dbf1Smrg# 5541d5c3dbf1Smrg# The first argument to this parsing function should be the 5542d5c3dbf1Smrg# script's $0 value, followed by "$@". 5543d5c3dbf1Smrglt_option_debug= 5544d5c3dbf1Smrgfunc_parse_lt_options () 5545d5c3dbf1Smrg{ 5546d5c3dbf1Smrg lt_script_arg0=\$0 5547d5c3dbf1Smrg shift 5548d5c3dbf1Smrg for lt_opt 5549d5c3dbf1Smrg do 5550d5c3dbf1Smrg case \"\$lt_opt\" in 5551d5c3dbf1Smrg --lt-debug) lt_option_debug=1 ;; 5552d5c3dbf1Smrg --lt-dump-script) 5553d5c3dbf1Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554d5c3dbf1Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555d5c3dbf1Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556d5c3dbf1Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557d5c3dbf1Smrg exit 0 5558d5c3dbf1Smrg ;; 5559d5c3dbf1Smrg --lt-*) 5560d5c3dbf1Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561d5c3dbf1Smrg exit 1 55629f606849Smrg ;; 5563d5c3dbf1Smrg esac 5564d5c3dbf1Smrg done 55659f606849Smrg 5566d5c3dbf1Smrg # Print the debug banner immediately: 5567d5c3dbf1Smrg if test -n \"\$lt_option_debug\"; then 5568949d0342Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569d5c3dbf1Smrg fi 5570d5c3dbf1Smrg} 55719f606849Smrg 5572d5c3dbf1Smrg# Used when --lt-debug. Prints its arguments to stdout 5573d5c3dbf1Smrg# (redirection is the responsibility of the caller) 5574d5c3dbf1Smrgfunc_lt_dump_args () 5575d5c3dbf1Smrg{ 5576d5c3dbf1Smrg lt_dump_args_N=1; 5577d5c3dbf1Smrg for lt_arg 5578d5c3dbf1Smrg do 5579949d0342Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580d5c3dbf1Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581d5c3dbf1Smrg done 5582d5c3dbf1Smrg} 55839f606849Smrg 5584d5c3dbf1Smrg# Core function for launching the target application 5585d5c3dbf1Smrgfunc_exec_program_core () 5586d5c3dbf1Smrg{ 5587d5c3dbf1Smrg" 5588d5c3dbf1Smrg case $host in 5589d5c3dbf1Smrg # Backslashes separate directories on plain windows 5590d5c3dbf1Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5591d5c3dbf1Smrg $ECHO "\ 5592d5c3dbf1Smrg if test -n \"\$lt_option_debug\"; then 5593949d0342Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594d5c3dbf1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55959f606849Smrg fi 5596d5c3dbf1Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597d5c3dbf1Smrg" 5598d5c3dbf1Smrg ;; 55999f606849Smrg 5600d5c3dbf1Smrg *) 5601d5c3dbf1Smrg $ECHO "\ 5602d5c3dbf1Smrg if test -n \"\$lt_option_debug\"; then 5603949d0342Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604d5c3dbf1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 56059f606849Smrg fi 5606d5c3dbf1Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607d5c3dbf1Smrg" 5608d5c3dbf1Smrg ;; 5609d5c3dbf1Smrg esac 5610d5c3dbf1Smrg $ECHO "\ 5611d5c3dbf1Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612d5c3dbf1Smrg exit 1 5613d5c3dbf1Smrg} 56149f606849Smrg 5615d5c3dbf1Smrg# A function to encapsulate launching the target application 5616d5c3dbf1Smrg# Strips options in the --lt-* namespace from \$@ and 5617d5c3dbf1Smrg# launches target application with the remaining arguments. 5618d5c3dbf1Smrgfunc_exec_program () 5619d5c3dbf1Smrg{ 5620cdbfa18aSmrg case \" \$* \" in 5621cdbfa18aSmrg *\\ --lt-*) 5622cdbfa18aSmrg for lt_wr_arg 5623cdbfa18aSmrg do 5624cdbfa18aSmrg case \$lt_wr_arg in 5625cdbfa18aSmrg --lt-*) ;; 5626cdbfa18aSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627cdbfa18aSmrg esac 5628cdbfa18aSmrg shift 5629cdbfa18aSmrg done ;; 5630cdbfa18aSmrg esac 5631d5c3dbf1Smrg func_exec_program_core \${1+\"\$@\"} 5632d5c3dbf1Smrg} 56339f606849Smrg 5634d5c3dbf1Smrg # Parse options 5635d5c3dbf1Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56369f606849Smrg 5637d5c3dbf1Smrg # Find the directory that this script lives in. 5638d5c3dbf1Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639d5c3dbf1Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56409f606849Smrg 5641d5c3dbf1Smrg # Follow symbolic links until we get to the real thisdir. 5642d5c3dbf1Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643d5c3dbf1Smrg while test -n \"\$file\"; do 5644d5c3dbf1Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56459f606849Smrg 5646d5c3dbf1Smrg # If there was a directory component, then change thisdir. 5647d5c3dbf1Smrg if test \"x\$destdir\" != \"x\$file\"; then 5648d5c3dbf1Smrg case \"\$destdir\" in 5649d5c3dbf1Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650d5c3dbf1Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651d5c3dbf1Smrg esac 5652d5c3dbf1Smrg fi 56539f606849Smrg 5654d5c3dbf1Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655d5c3dbf1Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656d5c3dbf1Smrg done 56579f606849Smrg 5658d5c3dbf1Smrg # Usually 'no', except on cygwin/mingw when embedded into 5659d5c3dbf1Smrg # the cwrapper. 5660d5c3dbf1Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661d5c3dbf1Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662d5c3dbf1Smrg # special case for '.' 5663d5c3dbf1Smrg if test \"\$thisdir\" = \".\"; then 5664d5c3dbf1Smrg thisdir=\`pwd\` 5665d5c3dbf1Smrg fi 5666d5c3dbf1Smrg # remove .libs from thisdir 5667d5c3dbf1Smrg case \"\$thisdir\" in 5668d5c3dbf1Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669d5c3dbf1Smrg $objdir ) thisdir=. ;; 5670d5c3dbf1Smrg esac 5671d5c3dbf1Smrg fi 56729f606849Smrg 5673d5c3dbf1Smrg # Try to get the absolute directory name. 5674d5c3dbf1Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5675d5c3dbf1Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676d5c3dbf1Smrg" 56779f606849Smrg 5678949d0342Smrg if test yes = "$fast_install"; then 5679d5c3dbf1Smrg $ECHO "\ 5680d5c3dbf1Smrg program=lt-'$outputname'$exeext 5681d5c3dbf1Smrg progdir=\"\$thisdir/$objdir\" 56829f606849Smrg 5683d5c3dbf1Smrg if test ! -f \"\$progdir/\$program\" || 5684949d0342Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685d5c3dbf1Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56869f606849Smrg 5687d5c3dbf1Smrg file=\"\$\$-\$program\" 56889f606849Smrg 5689d5c3dbf1Smrg if test ! -d \"\$progdir\"; then 5690d5c3dbf1Smrg $MKDIR \"\$progdir\" 5691d5c3dbf1Smrg else 5692d5c3dbf1Smrg $RM \"\$progdir/\$file\" 5693d5c3dbf1Smrg fi" 56949f606849Smrg 5695d5c3dbf1Smrg $ECHO "\ 56969f606849Smrg 5697d5c3dbf1Smrg # relink executable if necessary 5698d5c3dbf1Smrg if test -n \"\$relink_command\"; then 5699d5c3dbf1Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700d5c3dbf1Smrg else 5701949d0342Smrg \$ECHO \"\$relink_command_output\" >&2 5702d5c3dbf1Smrg $RM \"\$progdir/\$file\" 5703d5c3dbf1Smrg exit 1 5704d5c3dbf1Smrg fi 5705d5c3dbf1Smrg fi 57069f606849Smrg 5707d5c3dbf1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708d5c3dbf1Smrg { $RM \"\$progdir/\$program\"; 5709d5c3dbf1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710d5c3dbf1Smrg $RM \"\$progdir/\$file\" 5711d5c3dbf1Smrg fi" 5712d5c3dbf1Smrg else 5713d5c3dbf1Smrg $ECHO "\ 5714d5c3dbf1Smrg program='$outputname' 5715d5c3dbf1Smrg progdir=\"\$thisdir/$objdir\" 5716d5c3dbf1Smrg" 5717d5c3dbf1Smrg fi 57189f606849Smrg 5719d5c3dbf1Smrg $ECHO "\ 57209f606849Smrg 5721d5c3dbf1Smrg if test -f \"\$progdir/\$program\"; then" 57229f606849Smrg 5723cdbfa18aSmrg # fixup the dll searchpath if we need to. 5724cdbfa18aSmrg # 5725cdbfa18aSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5726cdbfa18aSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727cdbfa18aSmrg # libraries must come first. 5728cdbfa18aSmrg if test -n "$dllsearchpath"; then 5729cdbfa18aSmrg $ECHO "\ 5730cdbfa18aSmrg # Add the dll search path components to the executable PATH 5731cdbfa18aSmrg PATH=$dllsearchpath:\$PATH 5732cdbfa18aSmrg" 5733cdbfa18aSmrg fi 5734cdbfa18aSmrg 5735d5c3dbf1Smrg # Export our shlibpath_var if we have one. 5736949d0342Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737d5c3dbf1Smrg $ECHO "\ 5738d5c3dbf1Smrg # Add our own library path to $shlibpath_var 5739d5c3dbf1Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57409f606849Smrg 5741d5c3dbf1Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742d5c3dbf1Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5743d5c3dbf1Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57449f606849Smrg 5745d5c3dbf1Smrg export $shlibpath_var 5746d5c3dbf1Smrg" 5747d5c3dbf1Smrg fi 57489f606849Smrg 5749d5c3dbf1Smrg $ECHO "\ 5750d5c3dbf1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751d5c3dbf1Smrg # Run the actual program with our arguments. 5752d5c3dbf1Smrg func_exec_program \${1+\"\$@\"} 5753d5c3dbf1Smrg fi 5754d5c3dbf1Smrg else 5755d5c3dbf1Smrg # The program doesn't exist. 5756949d0342Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757d5c3dbf1Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758d5c3dbf1Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759d5c3dbf1Smrg exit 1 5760d5c3dbf1Smrg fi 5761d5c3dbf1Smrgfi\ 5762d5c3dbf1Smrg" 5763d5c3dbf1Smrg} 57649f606849Smrg 57659f606849Smrg 5766d5c3dbf1Smrg# func_emit_cwrapperexe_src 5767d5c3dbf1Smrg# emit the source code for a wrapper executable on stdout 5768d5c3dbf1Smrg# Must ONLY be called from within func_mode_link because 5769d5c3dbf1Smrg# it depends on a number of variable set therein. 5770d5c3dbf1Smrgfunc_emit_cwrapperexe_src () 5771d5c3dbf1Smrg{ 5772d5c3dbf1Smrg cat <<EOF 57739f606849Smrg 5774d5c3dbf1Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5775949d0342Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57769f606849Smrg 5777d5c3dbf1Smrg The $output program cannot be directly executed until all the libtool 5778d5c3dbf1Smrg libraries that it depends on are installed. 57799f606849Smrg 5780d5c3dbf1Smrg This wrapper executable should never be moved out of the build directory. 5781d5c3dbf1Smrg If it is, it will not operate correctly. 5782d5c3dbf1Smrg*/ 5783d5c3dbf1SmrgEOF 5784d5c3dbf1Smrg cat <<"EOF" 5785d5c3dbf1Smrg#ifdef _MSC_VER 5786d5c3dbf1Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5787d5c3dbf1Smrg#endif 5788d5c3dbf1Smrg#include <stdio.h> 5789d5c3dbf1Smrg#include <stdlib.h> 5790d5c3dbf1Smrg#ifdef _MSC_VER 5791d5c3dbf1Smrg# include <direct.h> 5792d5c3dbf1Smrg# include <process.h> 5793d5c3dbf1Smrg# include <io.h> 5794d5c3dbf1Smrg#else 5795d5c3dbf1Smrg# include <unistd.h> 5796d5c3dbf1Smrg# include <stdint.h> 5797d5c3dbf1Smrg# ifdef __CYGWIN__ 5798d5c3dbf1Smrg# include <io.h> 5799d5c3dbf1Smrg# endif 5800d5c3dbf1Smrg#endif 5801d5c3dbf1Smrg#include <malloc.h> 5802d5c3dbf1Smrg#include <stdarg.h> 5803d5c3dbf1Smrg#include <assert.h> 5804d5c3dbf1Smrg#include <string.h> 5805d5c3dbf1Smrg#include <ctype.h> 5806d5c3dbf1Smrg#include <errno.h> 5807d5c3dbf1Smrg#include <fcntl.h> 5808d5c3dbf1Smrg#include <sys/stat.h> 58099f606849Smrg 5810949d0342Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5811949d0342Smrg 5812d5c3dbf1Smrg/* declarations of non-ANSI functions */ 5813949d0342Smrg#if defined __MINGW32__ 5814d5c3dbf1Smrg# ifdef __STRICT_ANSI__ 5815d5c3dbf1Smrgint _putenv (const char *); 5816d5c3dbf1Smrg# endif 5817949d0342Smrg#elif defined __CYGWIN__ 5818d5c3dbf1Smrg# ifdef __STRICT_ANSI__ 5819d5c3dbf1Smrgchar *realpath (const char *, char *); 5820d5c3dbf1Smrgint putenv (char *); 5821d5c3dbf1Smrgint setenv (const char *, const char *, int); 5822d5c3dbf1Smrg# endif 5823949d0342Smrg/* #elif defined other_platform || defined ... */ 5824d5c3dbf1Smrg#endif 58259f606849Smrg 5826d5c3dbf1Smrg/* portability defines, excluding path handling macros */ 5827949d0342Smrg#if defined _MSC_VER 5828d5c3dbf1Smrg# define setmode _setmode 5829d5c3dbf1Smrg# define stat _stat 5830d5c3dbf1Smrg# define chmod _chmod 5831d5c3dbf1Smrg# define getcwd _getcwd 5832d5c3dbf1Smrg# define putenv _putenv 5833d5c3dbf1Smrg# define S_IXUSR _S_IEXEC 5834949d0342Smrg#elif defined __MINGW32__ 5835d5c3dbf1Smrg# define setmode _setmode 5836d5c3dbf1Smrg# define stat _stat 5837d5c3dbf1Smrg# define chmod _chmod 5838d5c3dbf1Smrg# define getcwd _getcwd 5839d5c3dbf1Smrg# define putenv _putenv 5840949d0342Smrg#elif defined __CYGWIN__ 5841d5c3dbf1Smrg# define HAVE_SETENV 5842d5c3dbf1Smrg# define FOPEN_WB "wb" 5843949d0342Smrg/* #elif defined other platforms ... */ 5844d5c3dbf1Smrg#endif 58459f606849Smrg 5846949d0342Smrg#if defined PATH_MAX 5847d5c3dbf1Smrg# define LT_PATHMAX PATH_MAX 5848949d0342Smrg#elif defined MAXPATHLEN 5849d5c3dbf1Smrg# define LT_PATHMAX MAXPATHLEN 5850d5c3dbf1Smrg#else 5851d5c3dbf1Smrg# define LT_PATHMAX 1024 5852d5c3dbf1Smrg#endif 58539f606849Smrg 5854d5c3dbf1Smrg#ifndef S_IXOTH 5855d5c3dbf1Smrg# define S_IXOTH 0 5856d5c3dbf1Smrg#endif 5857d5c3dbf1Smrg#ifndef S_IXGRP 5858d5c3dbf1Smrg# define S_IXGRP 0 5859d5c3dbf1Smrg#endif 58609f606849Smrg 5861d5c3dbf1Smrg/* path handling portability macros */ 5862d5c3dbf1Smrg#ifndef DIR_SEPARATOR 5863d5c3dbf1Smrg# define DIR_SEPARATOR '/' 5864d5c3dbf1Smrg# define PATH_SEPARATOR ':' 5865d5c3dbf1Smrg#endif 58669f606849Smrg 5867949d0342Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5868949d0342Smrg defined __OS2__ 5869d5c3dbf1Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870d5c3dbf1Smrg# define FOPEN_WB "wb" 5871d5c3dbf1Smrg# ifndef DIR_SEPARATOR_2 5872d5c3dbf1Smrg# define DIR_SEPARATOR_2 '\\' 5873d5c3dbf1Smrg# endif 5874d5c3dbf1Smrg# ifndef PATH_SEPARATOR_2 5875d5c3dbf1Smrg# define PATH_SEPARATOR_2 ';' 5876d5c3dbf1Smrg# endif 5877d5c3dbf1Smrg#endif 58789f606849Smrg 5879d5c3dbf1Smrg#ifndef DIR_SEPARATOR_2 5880d5c3dbf1Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881d5c3dbf1Smrg#else /* DIR_SEPARATOR_2 */ 5882d5c3dbf1Smrg# define IS_DIR_SEPARATOR(ch) \ 5883d5c3dbf1Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884d5c3dbf1Smrg#endif /* DIR_SEPARATOR_2 */ 58859f606849Smrg 5886d5c3dbf1Smrg#ifndef PATH_SEPARATOR_2 5887d5c3dbf1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888d5c3dbf1Smrg#else /* PATH_SEPARATOR_2 */ 5889d5c3dbf1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890d5c3dbf1Smrg#endif /* PATH_SEPARATOR_2 */ 5891d5c3dbf1Smrg 5892d5c3dbf1Smrg#ifndef FOPEN_WB 5893d5c3dbf1Smrg# define FOPEN_WB "w" 5894d5c3dbf1Smrg#endif 5895d5c3dbf1Smrg#ifndef _O_BINARY 5896d5c3dbf1Smrg# define _O_BINARY 0 5897d5c3dbf1Smrg#endif 5898d5c3dbf1Smrg 5899d5c3dbf1Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900d5c3dbf1Smrg#define XFREE(stale) do { \ 5901949d0342Smrg if (stale) { free (stale); stale = 0; } \ 5902d5c3dbf1Smrg} while (0) 5903d5c3dbf1Smrg 5904949d0342Smrg#if defined LT_DEBUGWRAPPER 5905d5c3dbf1Smrgstatic int lt_debug = 1; 5906d5c3dbf1Smrg#else 5907d5c3dbf1Smrgstatic int lt_debug = 0; 5908d5c3dbf1Smrg#endif 5909d5c3dbf1Smrg 5910d5c3dbf1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911d5c3dbf1Smrg 5912d5c3dbf1Smrgvoid *xmalloc (size_t num); 5913d5c3dbf1Smrgchar *xstrdup (const char *string); 5914d5c3dbf1Smrgconst char *base_name (const char *name); 5915d5c3dbf1Smrgchar *find_executable (const char *wrapper); 5916d5c3dbf1Smrgchar *chase_symlinks (const char *pathspec); 5917d5c3dbf1Smrgint make_executable (const char *path); 5918d5c3dbf1Smrgint check_executable (const char *path); 5919d5c3dbf1Smrgchar *strendzap (char *str, const char *pat); 5920d5c3dbf1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921d5c3dbf1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922d5c3dbf1Smrgstatic const char *nonnull (const char *s); 5923d5c3dbf1Smrgstatic const char *nonempty (const char *s); 5924d5c3dbf1Smrgvoid lt_setenv (const char *name, const char *value); 5925d5c3dbf1Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926d5c3dbf1Smrgvoid lt_update_exe_path (const char *name, const char *value); 5927d5c3dbf1Smrgvoid lt_update_lib_path (const char *name, const char *value); 5928d5c3dbf1Smrgchar **prepare_spawn (char **argv); 5929d5c3dbf1Smrgvoid lt_dump_script (FILE *f); 5930d5c3dbf1SmrgEOF 5931d5c3dbf1Smrg 5932d5c3dbf1Smrg cat <<EOF 5933949d0342Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5934949d0342Smrg# define externally_visible volatile 5935949d0342Smrg#else 5936949d0342Smrg# define externally_visible __attribute__((externally_visible)) volatile 5937949d0342Smrg#endif 5938949d0342Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939d5c3dbf1Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940d5c3dbf1SmrgEOF 5941d5c3dbf1Smrg 5942949d0342Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943cdbfa18aSmrg func_to_host_path "$temp_rpath" 5944d5c3dbf1Smrg cat <<EOF 5945cdbfa18aSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59469f606849SmrgEOF 59479f606849Smrg else 5948d5c3dbf1Smrg cat <<"EOF" 5949d5c3dbf1Smrgconst char * LIB_PATH_VALUE = ""; 5950d5c3dbf1SmrgEOF 59519f606849Smrg fi 5952d5c3dbf1Smrg 5953d5c3dbf1Smrg if test -n "$dllsearchpath"; then 5954cdbfa18aSmrg func_to_host_path "$dllsearchpath:" 5955d5c3dbf1Smrg cat <<EOF 5956d5c3dbf1Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5957cdbfa18aSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958d5c3dbf1SmrgEOF 59599f606849Smrg else 5960d5c3dbf1Smrg cat <<"EOF" 5961d5c3dbf1Smrgconst char * EXE_PATH_VARNAME = ""; 5962d5c3dbf1Smrgconst char * EXE_PATH_VALUE = ""; 5963d5c3dbf1SmrgEOF 59649f606849Smrg fi 5965d5c3dbf1Smrg 5966949d0342Smrg if test yes = "$fast_install"; then 5967d5c3dbf1Smrg cat <<EOF 5968d5c3dbf1Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969d5c3dbf1SmrgEOF 59709f606849Smrg else 5971d5c3dbf1Smrg cat <<EOF 5972d5c3dbf1Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973d5c3dbf1SmrgEOF 59749f606849Smrg fi 59759f606849Smrg 59769f606849Smrg 5977d5c3dbf1Smrg cat <<"EOF" 59789f606849Smrg 5979d5c3dbf1Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59809f606849Smrg 5981d5c3dbf1Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982d5c3dbf1Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983d5c3dbf1Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59849f606849Smrg 5985d5c3dbf1Smrgint 5986d5c3dbf1Smrgmain (int argc, char *argv[]) 5987d5c3dbf1Smrg{ 5988d5c3dbf1Smrg char **newargz; 5989d5c3dbf1Smrg int newargc; 5990d5c3dbf1Smrg char *tmp_pathspec; 5991d5c3dbf1Smrg char *actual_cwrapper_path; 5992d5c3dbf1Smrg char *actual_cwrapper_name; 5993d5c3dbf1Smrg char *target_name; 5994d5c3dbf1Smrg char *lt_argv_zero; 5995949d0342Smrg int rval = 127; 59969f606849Smrg 5997d5c3dbf1Smrg int i; 59989f606849Smrg 5999d5c3dbf1Smrg program_name = (char *) xstrdup (base_name (argv[0])); 6000949d0342Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 60019f606849Smrg 6002d5c3dbf1Smrg /* very simple arg parsing; don't want to rely on getopt 6003d5c3dbf1Smrg * also, copy all non cwrapper options to newargz, except 6004d5c3dbf1Smrg * argz[0], which is handled differently 6005d5c3dbf1Smrg */ 6006d5c3dbf1Smrg newargc=0; 6007d5c3dbf1Smrg for (i = 1; i < argc; i++) 6008d5c3dbf1Smrg { 6009949d0342Smrg if (STREQ (argv[i], dumpscript_opt)) 6010d5c3dbf1Smrg { 6011d5c3dbf1SmrgEOF 6012949d0342Smrg case $host in 6013d5c3dbf1Smrg *mingw* | *cygwin* ) 6014d5c3dbf1Smrg # make stdout use "unix" line endings 6015d5c3dbf1Smrg echo " setmode(1,_O_BINARY);" 6016d5c3dbf1Smrg ;; 6017fba89afeSmrg esac 60189f606849Smrg 6019d5c3dbf1Smrg cat <<"EOF" 6020d5c3dbf1Smrg lt_dump_script (stdout); 6021d5c3dbf1Smrg return 0; 6022d5c3dbf1Smrg } 6023949d0342Smrg if (STREQ (argv[i], debug_opt)) 6024d5c3dbf1Smrg { 6025d5c3dbf1Smrg lt_debug = 1; 6026d5c3dbf1Smrg continue; 6027d5c3dbf1Smrg } 6028949d0342Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029d5c3dbf1Smrg { 6030d5c3dbf1Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031d5c3dbf1Smrg namespace, but it is not one of the ones we know about and 6032d5c3dbf1Smrg have already dealt with, above (inluding dump-script), then 6033d5c3dbf1Smrg report an error. Otherwise, targets might begin to believe 6034d5c3dbf1Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035d5c3dbf1Smrg namespace. The first time any user complains about this, we'll 6036d5c3dbf1Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037d5c3dbf1Smrg or a configure.ac-settable value. 6038d5c3dbf1Smrg */ 6039d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, 6040d5c3dbf1Smrg "unrecognized %s option: '%s'", 6041d5c3dbf1Smrg ltwrapper_option_prefix, argv[i]); 6042d5c3dbf1Smrg } 6043d5c3dbf1Smrg /* otherwise ... */ 6044d5c3dbf1Smrg newargz[++newargc] = xstrdup (argv[i]); 6045d5c3dbf1Smrg } 6046d5c3dbf1Smrg newargz[++newargc] = NULL; 60479f606849Smrg 6048d5c3dbf1SmrgEOF 6049d5c3dbf1Smrg cat <<EOF 6050d5c3dbf1Smrg /* The GNU banner must be the first non-error debug message */ 6051949d0342Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052d5c3dbf1SmrgEOF 6053d5c3dbf1Smrg cat <<"EOF" 6054d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056d5c3dbf1Smrg 6057d5c3dbf1Smrg tmp_pathspec = find_executable (argv[0]); 6058d5c3dbf1Smrg if (tmp_pathspec == NULL) 6059d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6061d5c3dbf1Smrg "(main) found exe (before symlink chase) at: %s\n", 6062d5c3dbf1Smrg tmp_pathspec); 6063d5c3dbf1Smrg 6064d5c3dbf1Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6066d5c3dbf1Smrg "(main) found exe (after symlink chase) at: %s\n", 6067d5c3dbf1Smrg actual_cwrapper_path); 6068d5c3dbf1Smrg XFREE (tmp_pathspec); 6069d5c3dbf1Smrg 6070d5c3dbf1Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071d5c3dbf1Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072d5c3dbf1Smrg 6073d5c3dbf1Smrg /* wrapper name transforms */ 6074d5c3dbf1Smrg strendzap (actual_cwrapper_name, ".exe"); 6075d5c3dbf1Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076d5c3dbf1Smrg XFREE (actual_cwrapper_name); 6077d5c3dbf1Smrg actual_cwrapper_name = tmp_pathspec; 6078d5c3dbf1Smrg tmp_pathspec = 0; 6079d5c3dbf1Smrg 6080d5c3dbf1Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081d5c3dbf1Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082d5c3dbf1Smrg strendzap (target_name, ".exe"); 6083d5c3dbf1Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084d5c3dbf1Smrg XFREE (target_name); 6085d5c3dbf1Smrg target_name = tmp_pathspec; 6086d5c3dbf1Smrg tmp_pathspec = 0; 6087d5c3dbf1Smrg 6088d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6089d5c3dbf1Smrg "(main) libtool target name: %s\n", 6090d5c3dbf1Smrg target_name); 6091d5c3dbf1SmrgEOF 60929f606849Smrg 6093d5c3dbf1Smrg cat <<EOF 6094d5c3dbf1Smrg newargz[0] = 6095d5c3dbf1Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096d5c3dbf1Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097d5c3dbf1Smrg strcpy (newargz[0], actual_cwrapper_path); 6098d5c3dbf1Smrg strcat (newargz[0], "$objdir"); 6099d5c3dbf1Smrg strcat (newargz[0], "/"); 6100d5c3dbf1SmrgEOF 61019f606849Smrg 6102d5c3dbf1Smrg cat <<"EOF" 6103d5c3dbf1Smrg /* stop here, and copy so we don't have to do this twice */ 6104d5c3dbf1Smrg tmp_pathspec = xstrdup (newargz[0]); 61059f606849Smrg 6106d5c3dbf1Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107d5c3dbf1Smrg strcat (newargz[0], actual_cwrapper_name); 61089f606849Smrg 6109d5c3dbf1Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110d5c3dbf1Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111d5c3dbf1Smrg XFREE (tmp_pathspec); 6112d5c3dbf1Smrg tmp_pathspec = NULL; 6113d5c3dbf1SmrgEOF 61149f606849Smrg 6115d5c3dbf1Smrg case $host_os in 6116d5c3dbf1Smrg mingw*) 6117d5c3dbf1Smrg cat <<"EOF" 6118d5c3dbf1Smrg { 6119d5c3dbf1Smrg char* p; 6120d5c3dbf1Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121d5c3dbf1Smrg { 6122d5c3dbf1Smrg *p = '/'; 6123d5c3dbf1Smrg } 6124d5c3dbf1Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125d5c3dbf1Smrg { 6126d5c3dbf1Smrg *p = '/'; 6127d5c3dbf1Smrg } 6128d5c3dbf1Smrg } 6129d5c3dbf1SmrgEOF 6130d5c3dbf1Smrg ;; 6131d5c3dbf1Smrg esac 61329f606849Smrg 6133d5c3dbf1Smrg cat <<"EOF" 6134d5c3dbf1Smrg XFREE (target_name); 6135d5c3dbf1Smrg XFREE (actual_cwrapper_path); 6136d5c3dbf1Smrg XFREE (actual_cwrapper_name); 61379f606849Smrg 6138d5c3dbf1Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139d5c3dbf1Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140cdbfa18aSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141cdbfa18aSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142cdbfa18aSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143cdbfa18aSmrg libraries must come first. */ 6144d5c3dbf1Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145cdbfa18aSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61469f606849Smrg 6147d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148d5c3dbf1Smrg nonnull (lt_argv_zero)); 6149d5c3dbf1Smrg for (i = 0; i < newargc; i++) 6150d5c3dbf1Smrg { 6151d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152d5c3dbf1Smrg i, nonnull (newargz[i])); 6153d5c3dbf1Smrg } 61549f606849Smrg 6155d5c3dbf1SmrgEOF 61569f606849Smrg 6157d5c3dbf1Smrg case $host_os in 6158d5c3dbf1Smrg mingw*) 6159d5c3dbf1Smrg cat <<"EOF" 6160d5c3dbf1Smrg /* execv doesn't actually work on mingw as expected on unix */ 6161d5c3dbf1Smrg newargz = prepare_spawn (newargz); 6162949d0342Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163d5c3dbf1Smrg if (rval == -1) 6164d5c3dbf1Smrg { 6165d5c3dbf1Smrg /* failed to start process */ 6166d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6167d5c3dbf1Smrg "(main) failed to launch target \"%s\": %s\n", 6168d5c3dbf1Smrg lt_argv_zero, nonnull (strerror (errno))); 6169d5c3dbf1Smrg return 127; 6170d5c3dbf1Smrg } 6171d5c3dbf1Smrg return rval; 6172d5c3dbf1SmrgEOF 6173d5c3dbf1Smrg ;; 6174d5c3dbf1Smrg *) 6175d5c3dbf1Smrg cat <<"EOF" 6176d5c3dbf1Smrg execv (lt_argv_zero, newargz); 6177d5c3dbf1Smrg return rval; /* =127, but avoids unused variable warning */ 6178d5c3dbf1SmrgEOF 6179d5c3dbf1Smrg ;; 6180d5c3dbf1Smrg esac 61819f606849Smrg 6182d5c3dbf1Smrg cat <<"EOF" 6183d5c3dbf1Smrg} 61849f606849Smrg 6185d5c3dbf1Smrgvoid * 6186d5c3dbf1Smrgxmalloc (size_t num) 6187d5c3dbf1Smrg{ 6188d5c3dbf1Smrg void *p = (void *) malloc (num); 6189d5c3dbf1Smrg if (!p) 6190d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61919f606849Smrg 6192d5c3dbf1Smrg return p; 6193d5c3dbf1Smrg} 61949f606849Smrg 6195d5c3dbf1Smrgchar * 6196d5c3dbf1Smrgxstrdup (const char *string) 6197d5c3dbf1Smrg{ 6198d5c3dbf1Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199d5c3dbf1Smrg string) : NULL; 6200d5c3dbf1Smrg} 62019f606849Smrg 6202d5c3dbf1Smrgconst char * 6203d5c3dbf1Smrgbase_name (const char *name) 6204d5c3dbf1Smrg{ 6205d5c3dbf1Smrg const char *base; 62069f606849Smrg 6207949d0342Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208d5c3dbf1Smrg /* Skip over the disk name in MSDOS pathnames. */ 6209d5c3dbf1Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210d5c3dbf1Smrg name += 2; 6211d5c3dbf1Smrg#endif 62129f606849Smrg 6213d5c3dbf1Smrg for (base = name; *name; name++) 6214d5c3dbf1Smrg if (IS_DIR_SEPARATOR (*name)) 6215d5c3dbf1Smrg base = name + 1; 6216d5c3dbf1Smrg return base; 6217d5c3dbf1Smrg} 62189f606849Smrg 6219d5c3dbf1Smrgint 6220d5c3dbf1Smrgcheck_executable (const char *path) 6221d5c3dbf1Smrg{ 6222d5c3dbf1Smrg struct stat st; 62239f606849Smrg 6224d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225d5c3dbf1Smrg nonempty (path)); 6226d5c3dbf1Smrg if ((!path) || (!*path)) 6227d5c3dbf1Smrg return 0; 62289f606849Smrg 6229d5c3dbf1Smrg if ((stat (path, &st) >= 0) 6230d5c3dbf1Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231d5c3dbf1Smrg return 1; 6232d5c3dbf1Smrg else 6233d5c3dbf1Smrg return 0; 6234d5c3dbf1Smrg} 62359f606849Smrg 6236d5c3dbf1Smrgint 6237d5c3dbf1Smrgmake_executable (const char *path) 6238d5c3dbf1Smrg{ 6239d5c3dbf1Smrg int rval = 0; 6240d5c3dbf1Smrg struct stat st; 62419f606849Smrg 6242d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243d5c3dbf1Smrg nonempty (path)); 6244d5c3dbf1Smrg if ((!path) || (!*path)) 6245d5c3dbf1Smrg return 0; 62469f606849Smrg 6247d5c3dbf1Smrg if (stat (path, &st) >= 0) 6248d5c3dbf1Smrg { 6249d5c3dbf1Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250d5c3dbf1Smrg } 6251d5c3dbf1Smrg return rval; 6252d5c3dbf1Smrg} 62539f606849Smrg 6254d5c3dbf1Smrg/* Searches for the full path of the wrapper. Returns 6255d5c3dbf1Smrg newly allocated full path name if found, NULL otherwise 6256d5c3dbf1Smrg Does not chase symlinks, even on platforms that support them. 6257d5c3dbf1Smrg*/ 6258d5c3dbf1Smrgchar * 6259d5c3dbf1Smrgfind_executable (const char *wrapper) 6260d5c3dbf1Smrg{ 6261d5c3dbf1Smrg int has_slash = 0; 6262d5c3dbf1Smrg const char *p; 6263d5c3dbf1Smrg const char *p_next; 6264d5c3dbf1Smrg /* static buffer for getcwd */ 6265d5c3dbf1Smrg char tmp[LT_PATHMAX + 1]; 6266949d0342Smrg size_t tmp_len; 6267d5c3dbf1Smrg char *concat_name; 62689f606849Smrg 6269d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270d5c3dbf1Smrg nonempty (wrapper)); 62719f606849Smrg 6272d5c3dbf1Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273d5c3dbf1Smrg return NULL; 62749f606849Smrg 6275d5c3dbf1Smrg /* Absolute path? */ 6276949d0342Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277d5c3dbf1Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278d5c3dbf1Smrg { 6279d5c3dbf1Smrg concat_name = xstrdup (wrapper); 6280d5c3dbf1Smrg if (check_executable (concat_name)) 6281d5c3dbf1Smrg return concat_name; 6282d5c3dbf1Smrg XFREE (concat_name); 6283d5c3dbf1Smrg } 6284d5c3dbf1Smrg else 6285d5c3dbf1Smrg { 6286d5c3dbf1Smrg#endif 6287d5c3dbf1Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288d5c3dbf1Smrg { 6289d5c3dbf1Smrg concat_name = xstrdup (wrapper); 6290d5c3dbf1Smrg if (check_executable (concat_name)) 6291d5c3dbf1Smrg return concat_name; 6292d5c3dbf1Smrg XFREE (concat_name); 6293d5c3dbf1Smrg } 6294949d0342Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295d5c3dbf1Smrg } 6296d5c3dbf1Smrg#endif 62979f606849Smrg 6298d5c3dbf1Smrg for (p = wrapper; *p; p++) 6299d5c3dbf1Smrg if (*p == '/') 6300d5c3dbf1Smrg { 6301d5c3dbf1Smrg has_slash = 1; 6302d5c3dbf1Smrg break; 6303d5c3dbf1Smrg } 6304d5c3dbf1Smrg if (!has_slash) 6305d5c3dbf1Smrg { 6306d5c3dbf1Smrg /* no slashes; search PATH */ 6307d5c3dbf1Smrg const char *path = getenv ("PATH"); 6308d5c3dbf1Smrg if (path != NULL) 6309d5c3dbf1Smrg { 6310d5c3dbf1Smrg for (p = path; *p; p = p_next) 6311d5c3dbf1Smrg { 6312d5c3dbf1Smrg const char *q; 6313d5c3dbf1Smrg size_t p_len; 6314d5c3dbf1Smrg for (q = p; *q; q++) 6315d5c3dbf1Smrg if (IS_PATH_SEPARATOR (*q)) 6316d5c3dbf1Smrg break; 6317949d0342Smrg p_len = (size_t) (q - p); 6318d5c3dbf1Smrg p_next = (*q == '\0' ? q : q + 1); 6319d5c3dbf1Smrg if (p_len == 0) 6320d5c3dbf1Smrg { 6321d5c3dbf1Smrg /* empty path: current directory */ 6322d5c3dbf1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324d5c3dbf1Smrg nonnull (strerror (errno))); 6325d5c3dbf1Smrg tmp_len = strlen (tmp); 6326d5c3dbf1Smrg concat_name = 6327d5c3dbf1Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328d5c3dbf1Smrg memcpy (concat_name, tmp, tmp_len); 6329d5c3dbf1Smrg concat_name[tmp_len] = '/'; 6330d5c3dbf1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6331d5c3dbf1Smrg } 6332d5c3dbf1Smrg else 6333d5c3dbf1Smrg { 6334d5c3dbf1Smrg concat_name = 6335d5c3dbf1Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336d5c3dbf1Smrg memcpy (concat_name, p, p_len); 6337d5c3dbf1Smrg concat_name[p_len] = '/'; 6338d5c3dbf1Smrg strcpy (concat_name + p_len + 1, wrapper); 6339d5c3dbf1Smrg } 6340d5c3dbf1Smrg if (check_executable (concat_name)) 6341d5c3dbf1Smrg return concat_name; 6342d5c3dbf1Smrg XFREE (concat_name); 6343d5c3dbf1Smrg } 6344d5c3dbf1Smrg } 6345d5c3dbf1Smrg /* not found in PATH; assume curdir */ 6346d5c3dbf1Smrg } 6347d5c3dbf1Smrg /* Relative path | not found in path: prepend cwd */ 6348d5c3dbf1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350d5c3dbf1Smrg nonnull (strerror (errno))); 6351d5c3dbf1Smrg tmp_len = strlen (tmp); 6352d5c3dbf1Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353d5c3dbf1Smrg memcpy (concat_name, tmp, tmp_len); 6354d5c3dbf1Smrg concat_name[tmp_len] = '/'; 6355d5c3dbf1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63569f606849Smrg 6357d5c3dbf1Smrg if (check_executable (concat_name)) 6358d5c3dbf1Smrg return concat_name; 6359d5c3dbf1Smrg XFREE (concat_name); 6360d5c3dbf1Smrg return NULL; 6361d5c3dbf1Smrg} 63629f606849Smrg 6363d5c3dbf1Smrgchar * 6364d5c3dbf1Smrgchase_symlinks (const char *pathspec) 6365d5c3dbf1Smrg{ 6366d5c3dbf1Smrg#ifndef S_ISLNK 6367d5c3dbf1Smrg return xstrdup (pathspec); 6368d5c3dbf1Smrg#else 6369d5c3dbf1Smrg char buf[LT_PATHMAX]; 6370d5c3dbf1Smrg struct stat s; 6371d5c3dbf1Smrg char *tmp_pathspec = xstrdup (pathspec); 6372d5c3dbf1Smrg char *p; 6373d5c3dbf1Smrg int has_symlinks = 0; 6374d5c3dbf1Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6375d5c3dbf1Smrg { 6376d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6377d5c3dbf1Smrg "checking path component for symlinks: %s\n", 6378d5c3dbf1Smrg tmp_pathspec); 6379d5c3dbf1Smrg if (lstat (tmp_pathspec, &s) == 0) 6380d5c3dbf1Smrg { 6381d5c3dbf1Smrg if (S_ISLNK (s.st_mode) != 0) 6382d5c3dbf1Smrg { 6383d5c3dbf1Smrg has_symlinks = 1; 6384d5c3dbf1Smrg break; 6385d5c3dbf1Smrg } 63869f606849Smrg 6387d5c3dbf1Smrg /* search backwards for last DIR_SEPARATOR */ 6388d5c3dbf1Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389d5c3dbf1Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390d5c3dbf1Smrg p--; 6391d5c3dbf1Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392d5c3dbf1Smrg { 6393d5c3dbf1Smrg /* no more DIR_SEPARATORS left */ 6394d5c3dbf1Smrg break; 6395d5c3dbf1Smrg } 6396d5c3dbf1Smrg *p = '\0'; 6397d5c3dbf1Smrg } 6398d5c3dbf1Smrg else 6399d5c3dbf1Smrg { 6400d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, 6401d5c3dbf1Smrg "error accessing file \"%s\": %s", 6402d5c3dbf1Smrg tmp_pathspec, nonnull (strerror (errno))); 6403d5c3dbf1Smrg } 6404d5c3dbf1Smrg } 6405d5c3dbf1Smrg XFREE (tmp_pathspec); 64069f606849Smrg 6407d5c3dbf1Smrg if (!has_symlinks) 6408d5c3dbf1Smrg { 6409d5c3dbf1Smrg return xstrdup (pathspec); 6410d5c3dbf1Smrg } 64119f606849Smrg 6412d5c3dbf1Smrg tmp_pathspec = realpath (pathspec, buf); 6413d5c3dbf1Smrg if (tmp_pathspec == 0) 6414d5c3dbf1Smrg { 6415d5c3dbf1Smrg lt_fatal (__FILE__, __LINE__, 6416d5c3dbf1Smrg "could not follow symlinks for %s", pathspec); 6417d5c3dbf1Smrg } 6418d5c3dbf1Smrg return xstrdup (tmp_pathspec); 6419d5c3dbf1Smrg#endif 6420d5c3dbf1Smrg} 64219f606849Smrg 6422d5c3dbf1Smrgchar * 6423d5c3dbf1Smrgstrendzap (char *str, const char *pat) 6424d5c3dbf1Smrg{ 6425d5c3dbf1Smrg size_t len, patlen; 64269f606849Smrg 6427d5c3dbf1Smrg assert (str != NULL); 6428d5c3dbf1Smrg assert (pat != NULL); 64299f606849Smrg 6430d5c3dbf1Smrg len = strlen (str); 6431d5c3dbf1Smrg patlen = strlen (pat); 64329f606849Smrg 6433d5c3dbf1Smrg if (patlen <= len) 6434d5c3dbf1Smrg { 6435d5c3dbf1Smrg str += len - patlen; 6436949d0342Smrg if (STREQ (str, pat)) 6437d5c3dbf1Smrg *str = '\0'; 6438d5c3dbf1Smrg } 6439d5c3dbf1Smrg return str; 6440d5c3dbf1Smrg} 64419f606849Smrg 6442d5c3dbf1Smrgvoid 6443d5c3dbf1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444d5c3dbf1Smrg{ 6445d5c3dbf1Smrg va_list args; 6446d5c3dbf1Smrg if (lt_debug) 6447d5c3dbf1Smrg { 6448d5c3dbf1Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449d5c3dbf1Smrg va_start (args, fmt); 6450d5c3dbf1Smrg (void) vfprintf (stderr, fmt, args); 6451d5c3dbf1Smrg va_end (args); 6452d5c3dbf1Smrg } 6453d5c3dbf1Smrg} 64549f606849Smrg 6455d5c3dbf1Smrgstatic void 6456d5c3dbf1Smrglt_error_core (int exit_status, const char *file, 6457d5c3dbf1Smrg int line, const char *mode, 6458d5c3dbf1Smrg const char *message, va_list ap) 6459d5c3dbf1Smrg{ 6460d5c3dbf1Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461d5c3dbf1Smrg vfprintf (stderr, message, ap); 6462d5c3dbf1Smrg fprintf (stderr, ".\n"); 64639f606849Smrg 6464d5c3dbf1Smrg if (exit_status >= 0) 6465d5c3dbf1Smrg exit (exit_status); 6466d5c3dbf1Smrg} 64679f606849Smrg 6468d5c3dbf1Smrgvoid 6469d5c3dbf1Smrglt_fatal (const char *file, int line, const char *message, ...) 6470d5c3dbf1Smrg{ 6471d5c3dbf1Smrg va_list ap; 6472d5c3dbf1Smrg va_start (ap, message); 6473d5c3dbf1Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474d5c3dbf1Smrg va_end (ap); 6475d5c3dbf1Smrg} 64769f606849Smrg 6477d5c3dbf1Smrgstatic const char * 6478d5c3dbf1Smrgnonnull (const char *s) 6479d5c3dbf1Smrg{ 6480d5c3dbf1Smrg return s ? s : "(null)"; 6481d5c3dbf1Smrg} 64829f606849Smrg 6483d5c3dbf1Smrgstatic const char * 6484d5c3dbf1Smrgnonempty (const char *s) 6485d5c3dbf1Smrg{ 6486d5c3dbf1Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6487d5c3dbf1Smrg} 64889f606849Smrg 6489d5c3dbf1Smrgvoid 6490d5c3dbf1Smrglt_setenv (const char *name, const char *value) 6491d5c3dbf1Smrg{ 6492d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6493d5c3dbf1Smrg "(lt_setenv) setting '%s' to '%s'\n", 6494d5c3dbf1Smrg nonnull (name), nonnull (value)); 6495d5c3dbf1Smrg { 6496d5c3dbf1Smrg#ifdef HAVE_SETENV 6497d5c3dbf1Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498d5c3dbf1Smrg char *str = xstrdup (value); 6499d5c3dbf1Smrg setenv (name, str, 1); 6500d5c3dbf1Smrg#else 6501949d0342Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502d5c3dbf1Smrg char *str = XMALLOC (char, len); 6503d5c3dbf1Smrg sprintf (str, "%s=%s", name, value); 6504d5c3dbf1Smrg if (putenv (str) != EXIT_SUCCESS) 6505d5c3dbf1Smrg { 6506d5c3dbf1Smrg XFREE (str); 6507d5c3dbf1Smrg } 6508d5c3dbf1Smrg#endif 6509d5c3dbf1Smrg } 6510d5c3dbf1Smrg} 65119f606849Smrg 6512d5c3dbf1Smrgchar * 6513d5c3dbf1Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514d5c3dbf1Smrg{ 6515d5c3dbf1Smrg char *new_value; 6516d5c3dbf1Smrg if (orig_value && *orig_value) 6517d5c3dbf1Smrg { 6518949d0342Smrg size_t orig_value_len = strlen (orig_value); 6519949d0342Smrg size_t add_len = strlen (add); 6520d5c3dbf1Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521d5c3dbf1Smrg if (to_end) 6522d5c3dbf1Smrg { 6523d5c3dbf1Smrg strcpy (new_value, orig_value); 6524d5c3dbf1Smrg strcpy (new_value + orig_value_len, add); 6525d5c3dbf1Smrg } 6526d5c3dbf1Smrg else 6527d5c3dbf1Smrg { 6528d5c3dbf1Smrg strcpy (new_value, add); 6529d5c3dbf1Smrg strcpy (new_value + add_len, orig_value); 6530d5c3dbf1Smrg } 6531d5c3dbf1Smrg } 6532d5c3dbf1Smrg else 6533d5c3dbf1Smrg { 6534d5c3dbf1Smrg new_value = xstrdup (add); 6535d5c3dbf1Smrg } 6536d5c3dbf1Smrg return new_value; 6537d5c3dbf1Smrg} 65389f606849Smrg 6539d5c3dbf1Smrgvoid 6540d5c3dbf1Smrglt_update_exe_path (const char *name, const char *value) 6541d5c3dbf1Smrg{ 6542d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6543d5c3dbf1Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544d5c3dbf1Smrg nonnull (name), nonnull (value)); 65459f606849Smrg 6546d5c3dbf1Smrg if (name && *name && value && *value) 6547d5c3dbf1Smrg { 6548d5c3dbf1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549d5c3dbf1Smrg /* some systems can't cope with a ':'-terminated path #' */ 6550949d0342Smrg size_t len = strlen (new_value); 6551949d0342Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552d5c3dbf1Smrg { 6553949d0342Smrg new_value[--len] = '\0'; 6554d5c3dbf1Smrg } 6555d5c3dbf1Smrg lt_setenv (name, new_value); 6556d5c3dbf1Smrg XFREE (new_value); 6557d5c3dbf1Smrg } 6558d5c3dbf1Smrg} 65599f606849Smrg 6560d5c3dbf1Smrgvoid 6561d5c3dbf1Smrglt_update_lib_path (const char *name, const char *value) 6562d5c3dbf1Smrg{ 6563d5c3dbf1Smrg lt_debugprintf (__FILE__, __LINE__, 6564d5c3dbf1Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565d5c3dbf1Smrg nonnull (name), nonnull (value)); 65669f606849Smrg 6567d5c3dbf1Smrg if (name && *name && value && *value) 6568d5c3dbf1Smrg { 6569d5c3dbf1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570d5c3dbf1Smrg lt_setenv (name, new_value); 6571d5c3dbf1Smrg XFREE (new_value); 6572d5c3dbf1Smrg } 6573d5c3dbf1Smrg} 65749f606849Smrg 6575d5c3dbf1SmrgEOF 6576d5c3dbf1Smrg case $host_os in 6577d5c3dbf1Smrg mingw*) 6578d5c3dbf1Smrg cat <<"EOF" 6579d5c3dbf1Smrg 6580d5c3dbf1Smrg/* Prepares an argument vector before calling spawn(). 6581d5c3dbf1Smrg Note that spawn() does not by itself call the command interpreter 6582d5c3dbf1Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583d5c3dbf1Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584d5c3dbf1Smrg GetVersionEx(&v); 6585d5c3dbf1Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586d5c3dbf1Smrg }) ? "cmd.exe" : "command.com"). 6587d5c3dbf1Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588d5c3dbf1Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589d5c3dbf1Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590d5c3dbf1Smrg special way: 6591d5c3dbf1Smrg - Space and tab are interpreted as delimiters. They are not treated as 6592d5c3dbf1Smrg delimiters if they are surrounded by double quotes: "...". 6593d5c3dbf1Smrg - Unescaped double quotes are removed from the input. Their only effect is 6594d5c3dbf1Smrg that within double quotes, space and tab are treated like normal 6595d5c3dbf1Smrg characters. 6596d5c3dbf1Smrg - Backslashes not followed by double quotes are not special. 6597d5c3dbf1Smrg - But 2*n+1 backslashes followed by a double quote become 6598d5c3dbf1Smrg n backslashes followed by a double quote (n >= 0): 6599d5c3dbf1Smrg \" -> " 6600d5c3dbf1Smrg \\\" -> \" 6601d5c3dbf1Smrg \\\\\" -> \\" 6602d5c3dbf1Smrg */ 6603d5c3dbf1Smrg#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" 6604d5c3dbf1Smrg#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" 6605d5c3dbf1Smrgchar ** 6606d5c3dbf1Smrgprepare_spawn (char **argv) 6607d5c3dbf1Smrg{ 6608d5c3dbf1Smrg size_t argc; 6609d5c3dbf1Smrg char **new_argv; 6610d5c3dbf1Smrg size_t i; 66119f606849Smrg 6612d5c3dbf1Smrg /* Count number of arguments. */ 6613d5c3dbf1Smrg for (argc = 0; argv[argc] != NULL; argc++) 6614d5c3dbf1Smrg ; 66159f606849Smrg 6616d5c3dbf1Smrg /* Allocate new argument vector. */ 6617d5c3dbf1Smrg new_argv = XMALLOC (char *, argc + 1); 66189f606849Smrg 6619d5c3dbf1Smrg /* Put quoted arguments into the new argument vector. */ 6620d5c3dbf1Smrg for (i = 0; i < argc; i++) 6621d5c3dbf1Smrg { 6622d5c3dbf1Smrg const char *string = argv[i]; 6623d5c3dbf1Smrg 6624d5c3dbf1Smrg if (string[0] == '\0') 6625d5c3dbf1Smrg new_argv[i] = xstrdup ("\"\""); 6626d5c3dbf1Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627d5c3dbf1Smrg { 6628d5c3dbf1Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629d5c3dbf1Smrg size_t length; 6630d5c3dbf1Smrg unsigned int backslashes; 6631d5c3dbf1Smrg const char *s; 6632d5c3dbf1Smrg char *quoted_string; 6633d5c3dbf1Smrg char *p; 6634d5c3dbf1Smrg 6635d5c3dbf1Smrg length = 0; 6636d5c3dbf1Smrg backslashes = 0; 6637d5c3dbf1Smrg if (quote_around) 6638d5c3dbf1Smrg length++; 6639d5c3dbf1Smrg for (s = string; *s != '\0'; s++) 6640d5c3dbf1Smrg { 6641d5c3dbf1Smrg char c = *s; 6642d5c3dbf1Smrg if (c == '"') 6643d5c3dbf1Smrg length += backslashes + 1; 6644d5c3dbf1Smrg length++; 6645d5c3dbf1Smrg if (c == '\\') 6646d5c3dbf1Smrg backslashes++; 6647d5c3dbf1Smrg else 6648d5c3dbf1Smrg backslashes = 0; 6649d5c3dbf1Smrg } 6650d5c3dbf1Smrg if (quote_around) 6651d5c3dbf1Smrg length += backslashes + 1; 6652d5c3dbf1Smrg 6653d5c3dbf1Smrg quoted_string = XMALLOC (char, length + 1); 6654d5c3dbf1Smrg 6655d5c3dbf1Smrg p = quoted_string; 6656d5c3dbf1Smrg backslashes = 0; 6657d5c3dbf1Smrg if (quote_around) 6658d5c3dbf1Smrg *p++ = '"'; 6659d5c3dbf1Smrg for (s = string; *s != '\0'; s++) 6660d5c3dbf1Smrg { 6661d5c3dbf1Smrg char c = *s; 6662d5c3dbf1Smrg if (c == '"') 6663d5c3dbf1Smrg { 6664d5c3dbf1Smrg unsigned int j; 6665d5c3dbf1Smrg for (j = backslashes + 1; j > 0; j--) 6666d5c3dbf1Smrg *p++ = '\\'; 6667d5c3dbf1Smrg } 6668d5c3dbf1Smrg *p++ = c; 6669d5c3dbf1Smrg if (c == '\\') 6670d5c3dbf1Smrg backslashes++; 6671d5c3dbf1Smrg else 6672d5c3dbf1Smrg backslashes = 0; 6673d5c3dbf1Smrg } 6674d5c3dbf1Smrg if (quote_around) 6675d5c3dbf1Smrg { 6676d5c3dbf1Smrg unsigned int j; 6677d5c3dbf1Smrg for (j = backslashes; j > 0; j--) 6678d5c3dbf1Smrg *p++ = '\\'; 6679d5c3dbf1Smrg *p++ = '"'; 6680d5c3dbf1Smrg } 6681d5c3dbf1Smrg *p = '\0'; 66829f606849Smrg 6683d5c3dbf1Smrg new_argv[i] = quoted_string; 6684d5c3dbf1Smrg } 6685d5c3dbf1Smrg else 6686d5c3dbf1Smrg new_argv[i] = (char *) string; 6687d5c3dbf1Smrg } 6688d5c3dbf1Smrg new_argv[argc] = NULL; 66899f606849Smrg 6690d5c3dbf1Smrg return new_argv; 6691d5c3dbf1Smrg} 6692d5c3dbf1SmrgEOF 66939f606849Smrg ;; 6694d5c3dbf1Smrg esac 66959f606849Smrg 6696d5c3dbf1Smrg cat <<"EOF" 6697d5c3dbf1Smrgvoid lt_dump_script (FILE* f) 6698d5c3dbf1Smrg{ 6699d5c3dbf1SmrgEOF 6700d5c3dbf1Smrg func_emit_wrapper yes | 6701cdbfa18aSmrg $SED -n -e ' 6702cdbfa18aSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6703cdbfa18aSmrg\2/ 6704cdbfa18aSmrgh 6705cdbfa18aSmrgs/\([\\"]\)/\\\1/g 6706cdbfa18aSmrgs/$/\\n/ 6707cdbfa18aSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6708cdbfa18aSmrgg 6709cdbfa18aSmrgD' 6710d5c3dbf1Smrg cat <<"EOF" 6711d5c3dbf1Smrg} 6712d5c3dbf1SmrgEOF 6713d5c3dbf1Smrg} 6714d5c3dbf1Smrg# end: func_emit_cwrapperexe_src 67159f606849Smrg 6716d5c3dbf1Smrg# func_win32_import_lib_p ARG 6717d5c3dbf1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718d5c3dbf1Smrgfunc_win32_import_lib_p () 6719d5c3dbf1Smrg{ 6720949d0342Smrg $debug_cmd 6721949d0342Smrg 6722d5c3dbf1Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723d5c3dbf1Smrg *import*) : ;; 6724d5c3dbf1Smrg *) false ;; 6725d5c3dbf1Smrg esac 6726d5c3dbf1Smrg} 67279f606849Smrg 6728949d0342Smrg# func_suncc_cstd_abi 6729949d0342Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6730949d0342Smrg# Several compiler flags select an ABI that is incompatible with the 6731949d0342Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6732949d0342Smrgfunc_suncc_cstd_abi () 6733949d0342Smrg{ 6734949d0342Smrg $debug_cmd 6735949d0342Smrg 6736949d0342Smrg case " $compile_command " in 6737949d0342Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6738949d0342Smrg suncc_use_cstd_abi=no 6739949d0342Smrg ;; 6740949d0342Smrg *) 6741949d0342Smrg suncc_use_cstd_abi=yes 6742949d0342Smrg ;; 6743949d0342Smrg esac 6744949d0342Smrg} 6745949d0342Smrg 6746d5c3dbf1Smrg# func_mode_link arg... 6747d5c3dbf1Smrgfunc_mode_link () 6748d5c3dbf1Smrg{ 6749949d0342Smrg $debug_cmd 6750949d0342Smrg 6751d5c3dbf1Smrg case $host in 6752d5c3dbf1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753d5c3dbf1Smrg # It is impossible to link a dll without this setting, and 6754d5c3dbf1Smrg # we shouldn't force the makefile maintainer to figure out 6755949d0342Smrg # what system we are compiling for in order to pass an extra 6756d5c3dbf1Smrg # flag for every libtool invocation. 6757d5c3dbf1Smrg # allow_undefined=no 67589f606849Smrg 6759d5c3dbf1Smrg # FIXME: Unfortunately, there are problems with the above when trying 6760949d0342Smrg # to make a dll that has undefined symbols, in which case not 6761d5c3dbf1Smrg # even a static library is built. For now, we need to specify 6762d5c3dbf1Smrg # -no-undefined on the libtool link line when we can be certain 6763d5c3dbf1Smrg # that all symbols are satisfied, otherwise we get a static library. 6764d5c3dbf1Smrg allow_undefined=yes 6765d5c3dbf1Smrg ;; 6766d5c3dbf1Smrg *) 6767d5c3dbf1Smrg allow_undefined=yes 6768d5c3dbf1Smrg ;; 6769d5c3dbf1Smrg esac 6770d5c3dbf1Smrg libtool_args=$nonopt 6771d5c3dbf1Smrg base_compile="$nonopt $@" 6772d5c3dbf1Smrg compile_command=$nonopt 6773d5c3dbf1Smrg finalize_command=$nonopt 67749f606849Smrg 6775d5c3dbf1Smrg compile_rpath= 6776d5c3dbf1Smrg finalize_rpath= 6777d5c3dbf1Smrg compile_shlibpath= 6778d5c3dbf1Smrg finalize_shlibpath= 6779d5c3dbf1Smrg convenience= 6780d5c3dbf1Smrg old_convenience= 6781d5c3dbf1Smrg deplibs= 6782d5c3dbf1Smrg old_deplibs= 6783d5c3dbf1Smrg compiler_flags= 6784d5c3dbf1Smrg linker_flags= 6785d5c3dbf1Smrg dllsearchpath= 6786d5c3dbf1Smrg lib_search_path=`pwd` 6787d5c3dbf1Smrg inst_prefix_dir= 6788d5c3dbf1Smrg new_inherited_linker_flags= 67899f606849Smrg 6790d5c3dbf1Smrg avoid_version=no 6791d5c3dbf1Smrg bindir= 6792d5c3dbf1Smrg dlfiles= 6793d5c3dbf1Smrg dlprefiles= 6794d5c3dbf1Smrg dlself=no 6795d5c3dbf1Smrg export_dynamic=no 6796d5c3dbf1Smrg export_symbols= 6797d5c3dbf1Smrg export_symbols_regex= 6798d5c3dbf1Smrg generated= 6799d5c3dbf1Smrg libobjs= 6800d5c3dbf1Smrg ltlibs= 6801d5c3dbf1Smrg module=no 6802d5c3dbf1Smrg no_install=no 6803d5c3dbf1Smrg objs= 6804949d0342Smrg os2dllname= 6805d5c3dbf1Smrg non_pic_objects= 6806d5c3dbf1Smrg precious_files_regex= 6807d5c3dbf1Smrg prefer_static_libs=no 6808949d0342Smrg preload=false 6809d5c3dbf1Smrg prev= 6810d5c3dbf1Smrg prevarg= 6811d5c3dbf1Smrg release= 6812d5c3dbf1Smrg rpath= 6813d5c3dbf1Smrg xrpath= 6814d5c3dbf1Smrg perm_rpath= 6815d5c3dbf1Smrg temp_rpath= 6816d5c3dbf1Smrg thread_safe=no 6817d5c3dbf1Smrg vinfo= 6818d5c3dbf1Smrg vinfo_number=no 6819d5c3dbf1Smrg weak_libs= 6820949d0342Smrg single_module=$wl-single_module 6821d5c3dbf1Smrg func_infer_tag $base_compile 68229f606849Smrg 6823d5c3dbf1Smrg # We need to know -static, to get the right output filenames. 6824d5c3dbf1Smrg for arg 6825d5c3dbf1Smrg do 6826d5c3dbf1Smrg case $arg in 6827d5c3dbf1Smrg -shared) 6828949d0342Smrg test yes != "$build_libtool_libs" \ 6829949d0342Smrg && func_fatal_configuration "cannot build a shared library" 6830d5c3dbf1Smrg build_old_libs=no 6831d5c3dbf1Smrg break 6832d5c3dbf1Smrg ;; 6833d5c3dbf1Smrg -all-static | -static | -static-libtool-libs) 6834d5c3dbf1Smrg case $arg in 6835d5c3dbf1Smrg -all-static) 6836949d0342Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837d5c3dbf1Smrg func_warning "complete static linking is impossible in this configuration" 6838d5c3dbf1Smrg fi 6839d5c3dbf1Smrg if test -n "$link_static_flag"; then 6840d5c3dbf1Smrg dlopen_self=$dlopen_self_static 6841d5c3dbf1Smrg fi 6842d5c3dbf1Smrg prefer_static_libs=yes 6843d5c3dbf1Smrg ;; 6844d5c3dbf1Smrg -static) 6845d5c3dbf1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846d5c3dbf1Smrg dlopen_self=$dlopen_self_static 6847d5c3dbf1Smrg fi 6848d5c3dbf1Smrg prefer_static_libs=built 6849d5c3dbf1Smrg ;; 6850d5c3dbf1Smrg -static-libtool-libs) 6851d5c3dbf1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852d5c3dbf1Smrg dlopen_self=$dlopen_self_static 6853d5c3dbf1Smrg fi 6854d5c3dbf1Smrg prefer_static_libs=yes 6855d5c3dbf1Smrg ;; 6856d5c3dbf1Smrg esac 6857d5c3dbf1Smrg build_libtool_libs=no 6858d5c3dbf1Smrg build_old_libs=yes 6859d5c3dbf1Smrg break 6860d5c3dbf1Smrg ;; 6861d5c3dbf1Smrg esac 6862d5c3dbf1Smrg done 68639f606849Smrg 6864d5c3dbf1Smrg # See if our shared archives depend on static archives. 6865d5c3dbf1Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68669f606849Smrg 6867d5c3dbf1Smrg # Go through the arguments, transforming them on the way. 6868d5c3dbf1Smrg while test "$#" -gt 0; do 6869949d0342Smrg arg=$1 6870d5c3dbf1Smrg shift 6871949d0342Smrg func_quote_arg pretty,unquoted "$arg" 6872949d0342Smrg qarg=$func_quote_arg_unquoted_result 6873949d0342Smrg func_append libtool_args " $func_quote_arg_result" 68749f606849Smrg 6875d5c3dbf1Smrg # If the previous option needs an argument, assign it. 6876d5c3dbf1Smrg if test -n "$prev"; then 6877d5c3dbf1Smrg case $prev in 6878d5c3dbf1Smrg output) 6879d5c3dbf1Smrg func_append compile_command " @OUTPUT@" 6880d5c3dbf1Smrg func_append finalize_command " @OUTPUT@" 6881d5c3dbf1Smrg ;; 6882d5c3dbf1Smrg esac 68839f606849Smrg 6884d5c3dbf1Smrg case $prev in 6885d5c3dbf1Smrg bindir) 6886949d0342Smrg bindir=$arg 6887d5c3dbf1Smrg prev= 6888d5c3dbf1Smrg continue 6889d5c3dbf1Smrg ;; 6890d5c3dbf1Smrg dlfiles|dlprefiles) 6891949d0342Smrg $preload || { 6892d5c3dbf1Smrg # Add the symbol object into the linking commands. 6893d5c3dbf1Smrg func_append compile_command " @SYMFILE@" 6894d5c3dbf1Smrg func_append finalize_command " @SYMFILE@" 6895949d0342Smrg preload=: 6896949d0342Smrg } 6897d5c3dbf1Smrg case $arg in 6898d5c3dbf1Smrg *.la | *.lo) ;; # We handle these cases below. 6899d5c3dbf1Smrg force) 6900949d0342Smrg if test no = "$dlself"; then 6901d5c3dbf1Smrg dlself=needless 6902d5c3dbf1Smrg export_dynamic=yes 69039f606849Smrg fi 6904d5c3dbf1Smrg prev= 6905d5c3dbf1Smrg continue 6906d5c3dbf1Smrg ;; 6907d5c3dbf1Smrg self) 6908949d0342Smrg if test dlprefiles = "$prev"; then 6909d5c3dbf1Smrg dlself=yes 6910949d0342Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911d5c3dbf1Smrg dlself=yes 69129f606849Smrg else 6913d5c3dbf1Smrg dlself=needless 6914d5c3dbf1Smrg export_dynamic=yes 69159f606849Smrg fi 6916d5c3dbf1Smrg prev= 6917d5c3dbf1Smrg continue 6918d5c3dbf1Smrg ;; 6919d5c3dbf1Smrg *) 6920949d0342Smrg if test dlfiles = "$prev"; then 6921cdbfa18aSmrg func_append dlfiles " $arg" 69229f606849Smrg else 6923cdbfa18aSmrg func_append dlprefiles " $arg" 69249f606849Smrg fi 6925d5c3dbf1Smrg prev= 6926d5c3dbf1Smrg continue 6927d5c3dbf1Smrg ;; 6928d5c3dbf1Smrg esac 6929d5c3dbf1Smrg ;; 6930d5c3dbf1Smrg expsyms) 6931949d0342Smrg export_symbols=$arg 6932d5c3dbf1Smrg test -f "$arg" \ 6933949d0342Smrg || func_fatal_error "symbol file '$arg' does not exist" 6934d5c3dbf1Smrg prev= 6935d5c3dbf1Smrg continue 6936d5c3dbf1Smrg ;; 6937d5c3dbf1Smrg expsyms_regex) 6938949d0342Smrg export_symbols_regex=$arg 6939d5c3dbf1Smrg prev= 6940d5c3dbf1Smrg continue 6941d5c3dbf1Smrg ;; 6942d5c3dbf1Smrg framework) 69439f606849Smrg case $host in 6944d5c3dbf1Smrg *-*-darwin*) 6945d5c3dbf1Smrg case "$deplibs " in 6946d5c3dbf1Smrg *" $qarg.ltframework "*) ;; 6947cdbfa18aSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948d5c3dbf1Smrg ;; 6949d5c3dbf1Smrg esac 6950d5c3dbf1Smrg ;; 69519f606849Smrg esac 6952d5c3dbf1Smrg prev= 6953d5c3dbf1Smrg continue 69549f606849Smrg ;; 6955d5c3dbf1Smrg inst_prefix) 6956949d0342Smrg inst_prefix_dir=$arg 6957949d0342Smrg prev= 6958949d0342Smrg continue 6959949d0342Smrg ;; 6960949d0342Smrg mllvm) 6961949d0342Smrg # Clang does not use LLVM to link, so we can simply discard any 6962949d0342Smrg # '-mllvm $arg' options when doing the link step. 6963d5c3dbf1Smrg prev= 6964d5c3dbf1Smrg continue 69659f606849Smrg ;; 6966d5c3dbf1Smrg objectlist) 6967d5c3dbf1Smrg if test -f "$arg"; then 6968d5c3dbf1Smrg save_arg=$arg 6969d5c3dbf1Smrg moreargs= 6970d5c3dbf1Smrg for fil in `cat "$save_arg"` 6971d5c3dbf1Smrg do 6972cdbfa18aSmrg# func_append moreargs " $fil" 6973d5c3dbf1Smrg arg=$fil 6974d5c3dbf1Smrg # A libtool-controlled object. 69759f606849Smrg 6976d5c3dbf1Smrg # Check to see that this really is a libtool object. 6977d5c3dbf1Smrg if func_lalib_unsafe_p "$arg"; then 6978d5c3dbf1Smrg pic_object= 6979d5c3dbf1Smrg non_pic_object= 69809f606849Smrg 6981d5c3dbf1Smrg # Read the .lo file 6982d5c3dbf1Smrg func_source "$arg" 69839f606849Smrg 6984d5c3dbf1Smrg if test -z "$pic_object" || 6985d5c3dbf1Smrg test -z "$non_pic_object" || 6986949d0342Smrg test none = "$pic_object" && 6987949d0342Smrg test none = "$non_pic_object"; then 6988949d0342Smrg func_fatal_error "cannot find name of object for '$arg'" 6989d5c3dbf1Smrg fi 69909f606849Smrg 6991d5c3dbf1Smrg # Extract subdirectory from the argument. 6992d5c3dbf1Smrg func_dirname "$arg" "/" "" 6993949d0342Smrg xdir=$func_dirname_result 69949f606849Smrg 6995949d0342Smrg if test none != "$pic_object"; then 6996d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 6997949d0342Smrg pic_object=$xdir$pic_object 69989f606849Smrg 6999949d0342Smrg if test dlfiles = "$prev"; then 7000949d0342Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001cdbfa18aSmrg func_append dlfiles " $pic_object" 7002d5c3dbf1Smrg prev= 7003d5c3dbf1Smrg continue 7004d5c3dbf1Smrg else 7005d5c3dbf1Smrg # If libtool objects are unsupported, then we need to preload. 7006d5c3dbf1Smrg prev=dlprefiles 7007d5c3dbf1Smrg fi 7008d5c3dbf1Smrg fi 70099f606849Smrg 7010d5c3dbf1Smrg # CHECK ME: I think I busted this. -Ossama 7011949d0342Smrg if test dlprefiles = "$prev"; then 7012d5c3dbf1Smrg # Preload the old-style object. 7013cdbfa18aSmrg func_append dlprefiles " $pic_object" 7014d5c3dbf1Smrg prev= 7015d5c3dbf1Smrg fi 70169f606849Smrg 7017d5c3dbf1Smrg # A PIC object. 7018d5c3dbf1Smrg func_append libobjs " $pic_object" 7019949d0342Smrg arg=$pic_object 7020d5c3dbf1Smrg fi 70219f606849Smrg 7022d5c3dbf1Smrg # Non-PIC object. 7023949d0342Smrg if test none != "$non_pic_object"; then 7024d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 7025949d0342Smrg non_pic_object=$xdir$non_pic_object 70269f606849Smrg 7027d5c3dbf1Smrg # A standard non-PIC object 7028d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7029949d0342Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7030949d0342Smrg arg=$non_pic_object 7031d5c3dbf1Smrg fi 7032d5c3dbf1Smrg else 7033d5c3dbf1Smrg # If the PIC object exists, use it instead. 7034d5c3dbf1Smrg # $xdir was prepended to $pic_object above. 7035949d0342Smrg non_pic_object=$pic_object 7036d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7037d5c3dbf1Smrg fi 7038d5c3dbf1Smrg else 7039d5c3dbf1Smrg # Only an error if not doing a dry-run. 7040d5c3dbf1Smrg if $opt_dry_run; then 7041d5c3dbf1Smrg # Extract subdirectory from the argument. 7042d5c3dbf1Smrg func_dirname "$arg" "/" "" 7043949d0342Smrg xdir=$func_dirname_result 7044d5c3dbf1Smrg 7045d5c3dbf1Smrg func_lo2o "$arg" 7046d5c3dbf1Smrg pic_object=$xdir$objdir/$func_lo2o_result 7047d5c3dbf1Smrg non_pic_object=$xdir$func_lo2o_result 7048d5c3dbf1Smrg func_append libobjs " $pic_object" 7049d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7050d5c3dbf1Smrg else 7051949d0342Smrg func_fatal_error "'$arg' is not a valid libtool object" 7052d5c3dbf1Smrg fi 7053d5c3dbf1Smrg fi 7054d5c3dbf1Smrg done 70559f606849Smrg else 7056949d0342Smrg func_fatal_error "link input file '$arg' does not exist" 70579f606849Smrg fi 7058d5c3dbf1Smrg arg=$save_arg 7059d5c3dbf1Smrg prev= 7060d5c3dbf1Smrg continue 7061d5c3dbf1Smrg ;; 7062949d0342Smrg os2dllname) 7063949d0342Smrg os2dllname=$arg 7064949d0342Smrg prev= 7065949d0342Smrg continue 7066949d0342Smrg ;; 7067d5c3dbf1Smrg precious_regex) 7068949d0342Smrg precious_files_regex=$arg 7069d5c3dbf1Smrg prev= 7070d5c3dbf1Smrg continue 7071d5c3dbf1Smrg ;; 7072d5c3dbf1Smrg release) 7073949d0342Smrg release=-$arg 7074d5c3dbf1Smrg prev= 7075d5c3dbf1Smrg continue 7076d5c3dbf1Smrg ;; 7077d5c3dbf1Smrg rpath | xrpath) 7078d5c3dbf1Smrg # We need an absolute path. 7079d5c3dbf1Smrg case $arg in 7080d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081d5c3dbf1Smrg *) 7082d5c3dbf1Smrg func_fatal_error "only absolute run-paths are allowed" 7083d5c3dbf1Smrg ;; 7084d5c3dbf1Smrg esac 7085949d0342Smrg if test rpath = "$prev"; then 7086d5c3dbf1Smrg case "$rpath " in 7087d5c3dbf1Smrg *" $arg "*) ;; 7088cdbfa18aSmrg *) func_append rpath " $arg" ;; 7089d5c3dbf1Smrg esac 70909f606849Smrg else 7091d5c3dbf1Smrg case "$xrpath " in 7092d5c3dbf1Smrg *" $arg "*) ;; 7093cdbfa18aSmrg *) func_append xrpath " $arg" ;; 7094d5c3dbf1Smrg esac 70959f606849Smrg fi 7096d5c3dbf1Smrg prev= 7097d5c3dbf1Smrg continue 7098d5c3dbf1Smrg ;; 7099d5c3dbf1Smrg shrext) 7100949d0342Smrg shrext_cmds=$arg 7101d5c3dbf1Smrg prev= 7102d5c3dbf1Smrg continue 7103d5c3dbf1Smrg ;; 7104d5c3dbf1Smrg weak) 7105cdbfa18aSmrg func_append weak_libs " $arg" 7106d5c3dbf1Smrg prev= 7107d5c3dbf1Smrg continue 7108d5c3dbf1Smrg ;; 7109949d0342Smrg xassembler) 7110949d0342Smrg func_append compiler_flags " -Xassembler $qarg" 7111949d0342Smrg prev= 7112949d0342Smrg func_append compile_command " -Xassembler $qarg" 7113949d0342Smrg func_append finalize_command " -Xassembler $qarg" 7114949d0342Smrg continue 7115949d0342Smrg ;; 7116d5c3dbf1Smrg xcclinker) 7117cdbfa18aSmrg func_append linker_flags " $qarg" 7118cdbfa18aSmrg func_append compiler_flags " $qarg" 7119d5c3dbf1Smrg prev= 7120d5c3dbf1Smrg func_append compile_command " $qarg" 7121d5c3dbf1Smrg func_append finalize_command " $qarg" 7122d5c3dbf1Smrg continue 7123d5c3dbf1Smrg ;; 7124d5c3dbf1Smrg xcompiler) 7125cdbfa18aSmrg func_append compiler_flags " $qarg" 7126d5c3dbf1Smrg prev= 7127d5c3dbf1Smrg func_append compile_command " $qarg" 7128d5c3dbf1Smrg func_append finalize_command " $qarg" 7129d5c3dbf1Smrg continue 7130d5c3dbf1Smrg ;; 7131d5c3dbf1Smrg xlinker) 7132cdbfa18aSmrg func_append linker_flags " $qarg" 7133cdbfa18aSmrg func_append compiler_flags " $wl$qarg" 7134d5c3dbf1Smrg prev= 7135d5c3dbf1Smrg func_append compile_command " $wl$qarg" 7136d5c3dbf1Smrg func_append finalize_command " $wl$qarg" 7137d5c3dbf1Smrg continue 7138d5c3dbf1Smrg ;; 7139d5c3dbf1Smrg *) 7140d5c3dbf1Smrg eval "$prev=\"\$arg\"" 7141d5c3dbf1Smrg prev= 7142d5c3dbf1Smrg continue 7143d5c3dbf1Smrg ;; 71449f606849Smrg esac 7145d5c3dbf1Smrg fi # test -n "$prev" 71469f606849Smrg 7147949d0342Smrg prevarg=$arg 71489f606849Smrg 7149d5c3dbf1Smrg case $arg in 7150d5c3dbf1Smrg -all-static) 7151d5c3dbf1Smrg if test -n "$link_static_flag"; then 7152d5c3dbf1Smrg # See comment for -static flag below, for more details. 7153d5c3dbf1Smrg func_append compile_command " $link_static_flag" 7154d5c3dbf1Smrg func_append finalize_command " $link_static_flag" 7155d5c3dbf1Smrg fi 7156d5c3dbf1Smrg continue 7157d5c3dbf1Smrg ;; 71589f606849Smrg 7159d5c3dbf1Smrg -allow-undefined) 7160d5c3dbf1Smrg # FIXME: remove this flag sometime in the future. 7161949d0342Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162d5c3dbf1Smrg ;; 71639f606849Smrg 7164d5c3dbf1Smrg -avoid-version) 7165d5c3dbf1Smrg avoid_version=yes 7166d5c3dbf1Smrg continue 7167d5c3dbf1Smrg ;; 71689f606849Smrg 7169d5c3dbf1Smrg -bindir) 7170d5c3dbf1Smrg prev=bindir 7171d5c3dbf1Smrg continue 7172d5c3dbf1Smrg ;; 71739f606849Smrg 7174d5c3dbf1Smrg -dlopen) 7175d5c3dbf1Smrg prev=dlfiles 7176d5c3dbf1Smrg continue 7177d5c3dbf1Smrg ;; 71789f606849Smrg 7179d5c3dbf1Smrg -dlpreopen) 7180d5c3dbf1Smrg prev=dlprefiles 7181d5c3dbf1Smrg continue 7182d5c3dbf1Smrg ;; 71839f606849Smrg 7184d5c3dbf1Smrg -export-dynamic) 7185d5c3dbf1Smrg export_dynamic=yes 7186d5c3dbf1Smrg continue 7187d5c3dbf1Smrg ;; 71889f606849Smrg 7189d5c3dbf1Smrg -export-symbols | -export-symbols-regex) 7190d5c3dbf1Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191d5c3dbf1Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192d5c3dbf1Smrg fi 7193949d0342Smrg if test X-export-symbols = "X$arg"; then 7194d5c3dbf1Smrg prev=expsyms 7195d5c3dbf1Smrg else 7196d5c3dbf1Smrg prev=expsyms_regex 7197d5c3dbf1Smrg fi 7198d5c3dbf1Smrg continue 7199d5c3dbf1Smrg ;; 72009f606849Smrg 7201d5c3dbf1Smrg -framework) 7202d5c3dbf1Smrg prev=framework 7203d5c3dbf1Smrg continue 7204d5c3dbf1Smrg ;; 72059f606849Smrg 7206d5c3dbf1Smrg -inst-prefix-dir) 7207d5c3dbf1Smrg prev=inst_prefix 7208d5c3dbf1Smrg continue 7209d5c3dbf1Smrg ;; 72109f606849Smrg 7211d5c3dbf1Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212d5c3dbf1Smrg # so, if we see these flags be careful not to treat them like -L 7213d5c3dbf1Smrg -L[A-Z][A-Z]*:*) 7214d5c3dbf1Smrg case $with_gcc/$host in 7215d5c3dbf1Smrg no/*-*-irix* | /*-*-irix*) 7216d5c3dbf1Smrg func_append compile_command " $arg" 7217d5c3dbf1Smrg func_append finalize_command " $arg" 7218d5c3dbf1Smrg ;; 7219d5c3dbf1Smrg esac 7220d5c3dbf1Smrg continue 7221d5c3dbf1Smrg ;; 72229f606849Smrg 7223d5c3dbf1Smrg -L*) 7224cdbfa18aSmrg func_stripname "-L" '' "$arg" 7225cdbfa18aSmrg if test -z "$func_stripname_result"; then 7226d5c3dbf1Smrg if test "$#" -gt 0; then 7227949d0342Smrg func_fatal_error "require no space between '-L' and '$1'" 7228d5c3dbf1Smrg else 7229949d0342Smrg func_fatal_error "need path for '-L' option" 7230d5c3dbf1Smrg fi 7231d5c3dbf1Smrg fi 7232cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 7233cdbfa18aSmrg dir=$func_resolve_sysroot_result 7234d5c3dbf1Smrg # We need an absolute path. 7235d5c3dbf1Smrg case $dir in 7236d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237d5c3dbf1Smrg *) 7238d5c3dbf1Smrg absdir=`cd "$dir" && pwd` 7239d5c3dbf1Smrg test -z "$absdir" && \ 7240949d0342Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7241949d0342Smrg dir=$absdir 7242d5c3dbf1Smrg ;; 7243d5c3dbf1Smrg esac 7244d5c3dbf1Smrg case "$deplibs " in 7245cdbfa18aSmrg *" -L$dir "* | *" $arg "*) 7246cdbfa18aSmrg # Will only happen for absolute or sysroot arguments 7247cdbfa18aSmrg ;; 7248d5c3dbf1Smrg *) 7249cdbfa18aSmrg # Preserve sysroot, but never include relative directories 7250cdbfa18aSmrg case $dir in 7251cdbfa18aSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252cdbfa18aSmrg *) func_append deplibs " -L$dir" ;; 7253cdbfa18aSmrg esac 7254cdbfa18aSmrg func_append lib_search_path " $dir" 7255d5c3dbf1Smrg ;; 7256d5c3dbf1Smrg esac 7257d5c3dbf1Smrg case $host in 7258d5c3dbf1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259d5c3dbf1Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260d5c3dbf1Smrg case :$dllsearchpath: in 7261d5c3dbf1Smrg *":$dir:"*) ;; 7262d5c3dbf1Smrg ::) dllsearchpath=$dir;; 7263cdbfa18aSmrg *) func_append dllsearchpath ":$dir";; 7264d5c3dbf1Smrg esac 7265d5c3dbf1Smrg case :$dllsearchpath: in 7266d5c3dbf1Smrg *":$testbindir:"*) ;; 7267d5c3dbf1Smrg ::) dllsearchpath=$testbindir;; 7268cdbfa18aSmrg *) func_append dllsearchpath ":$testbindir";; 7269d5c3dbf1Smrg esac 7270d5c3dbf1Smrg ;; 7271d5c3dbf1Smrg esac 7272d5c3dbf1Smrg continue 7273d5c3dbf1Smrg ;; 72749f606849Smrg 7275d5c3dbf1Smrg -l*) 7276949d0342Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277d5c3dbf1Smrg case $host in 7278d5c3dbf1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279d5c3dbf1Smrg # These systems don't actually have a C or math library (as such) 7280d5c3dbf1Smrg continue 7281d5c3dbf1Smrg ;; 7282d5c3dbf1Smrg *-*-os2*) 7283d5c3dbf1Smrg # These systems don't actually have a C library (as such) 7284949d0342Smrg test X-lc = "X$arg" && continue 7285d5c3dbf1Smrg ;; 7286949d0342Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287d5c3dbf1Smrg # Do not include libc due to us having libc/libc_r. 7288949d0342Smrg test X-lc = "X$arg" && continue 7289d5c3dbf1Smrg ;; 7290d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7291d5c3dbf1Smrg # Rhapsody C and math libraries are in the System framework 7292cdbfa18aSmrg func_append deplibs " System.ltframework" 7293d5c3dbf1Smrg continue 7294d5c3dbf1Smrg ;; 7295d5c3dbf1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7296d5c3dbf1Smrg # Causes problems with __ctype 7297949d0342Smrg test X-lc = "X$arg" && continue 7298d5c3dbf1Smrg ;; 7299d5c3dbf1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300d5c3dbf1Smrg # Compiler inserts libc in the correct place for threads to work 7301949d0342Smrg test X-lc = "X$arg" && continue 7302d5c3dbf1Smrg ;; 7303d5c3dbf1Smrg esac 7304949d0342Smrg elif test X-lc_r = "X$arg"; then 7305d5c3dbf1Smrg case $host in 7306949d0342Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307d5c3dbf1Smrg # Do not include libc_r directly, use -pthread flag. 7308d5c3dbf1Smrg continue 7309d5c3dbf1Smrg ;; 7310d5c3dbf1Smrg esac 7311d5c3dbf1Smrg fi 7312cdbfa18aSmrg func_append deplibs " $arg" 7313d5c3dbf1Smrg continue 7314d5c3dbf1Smrg ;; 73159f606849Smrg 7316949d0342Smrg -mllvm) 7317949d0342Smrg prev=mllvm 7318949d0342Smrg continue 7319949d0342Smrg ;; 7320949d0342Smrg 7321d5c3dbf1Smrg -module) 7322d5c3dbf1Smrg module=yes 7323d5c3dbf1Smrg continue 7324d5c3dbf1Smrg ;; 73259f606849Smrg 7326d5c3dbf1Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327d5c3dbf1Smrg # classes, name mangling, and exception handling. 7328d5c3dbf1Smrg # Darwin uses the -arch flag to determine output architecture. 7329cdbfa18aSmrg -model|-arch|-isysroot|--sysroot) 7330cdbfa18aSmrg func_append compiler_flags " $arg" 7331d5c3dbf1Smrg func_append compile_command " $arg" 7332d5c3dbf1Smrg func_append finalize_command " $arg" 7333d5c3dbf1Smrg prev=xcompiler 7334d5c3dbf1Smrg continue 7335d5c3dbf1Smrg ;; 7336949d0342Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337949d0342Smrg -pthread) 7338949d0342Smrg case $host in 7339949d0342Smrg *solaris2*) ;; 7340949d0342Smrg *) 7341949d0342Smrg case "$new_inherited_linker_flags " in 7342949d0342Smrg *" $arg "*) ;; 7343949d0342Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344949d0342Smrg esac 7345949d0342Smrg ;; 7346949d0342Smrg esac 7347949d0342Smrg continue 7348949d0342Smrg ;; 7349949d0342Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350cdbfa18aSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351cdbfa18aSmrg func_append compiler_flags " $arg" 7352d5c3dbf1Smrg func_append compile_command " $arg" 7353d5c3dbf1Smrg func_append finalize_command " $arg" 7354d5c3dbf1Smrg case "$new_inherited_linker_flags " in 7355d5c3dbf1Smrg *" $arg "*) ;; 7356cdbfa18aSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357d5c3dbf1Smrg esac 7358d5c3dbf1Smrg continue 7359d5c3dbf1Smrg ;; 73609f606849Smrg 7361d5c3dbf1Smrg -multi_module) 7362949d0342Smrg single_module=$wl-multi_module 7363d5c3dbf1Smrg continue 7364d5c3dbf1Smrg ;; 73659f606849Smrg 7366d5c3dbf1Smrg -no-fast-install) 7367d5c3dbf1Smrg fast_install=no 7368d5c3dbf1Smrg continue 7369d5c3dbf1Smrg ;; 73709f606849Smrg 7371d5c3dbf1Smrg -no-install) 7372d5c3dbf1Smrg case $host in 7373d5c3dbf1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374d5c3dbf1Smrg # The PATH hackery in wrapper scripts is required on Windows 7375d5c3dbf1Smrg # and Darwin in order for the loader to find any dlls it needs. 7376949d0342Smrg func_warning "'-no-install' is ignored for $host" 7377949d0342Smrg func_warning "assuming '-no-fast-install' instead" 7378d5c3dbf1Smrg fast_install=no 7379d5c3dbf1Smrg ;; 7380d5c3dbf1Smrg *) no_install=yes ;; 7381d5c3dbf1Smrg esac 7382d5c3dbf1Smrg continue 7383d5c3dbf1Smrg ;; 73849f606849Smrg 7385d5c3dbf1Smrg -no-undefined) 7386d5c3dbf1Smrg allow_undefined=no 7387d5c3dbf1Smrg continue 7388d5c3dbf1Smrg ;; 73899f606849Smrg 7390d5c3dbf1Smrg -objectlist) 7391d5c3dbf1Smrg prev=objectlist 7392d5c3dbf1Smrg continue 7393d5c3dbf1Smrg ;; 73949f606849Smrg 7395949d0342Smrg -os2dllname) 7396949d0342Smrg prev=os2dllname 7397949d0342Smrg continue 7398949d0342Smrg ;; 7399949d0342Smrg 7400d5c3dbf1Smrg -o) prev=output ;; 74019f606849Smrg 7402d5c3dbf1Smrg -precious-files-regex) 7403d5c3dbf1Smrg prev=precious_regex 7404d5c3dbf1Smrg continue 7405d5c3dbf1Smrg ;; 74069f606849Smrg 7407d5c3dbf1Smrg -release) 7408d5c3dbf1Smrg prev=release 7409d5c3dbf1Smrg continue 7410d5c3dbf1Smrg ;; 74119f606849Smrg 7412d5c3dbf1Smrg -rpath) 7413d5c3dbf1Smrg prev=rpath 7414d5c3dbf1Smrg continue 7415d5c3dbf1Smrg ;; 74169f606849Smrg 7417d5c3dbf1Smrg -R) 7418d5c3dbf1Smrg prev=xrpath 7419d5c3dbf1Smrg continue 7420d5c3dbf1Smrg ;; 74219f606849Smrg 7422d5c3dbf1Smrg -R*) 7423d5c3dbf1Smrg func_stripname '-R' '' "$arg" 7424d5c3dbf1Smrg dir=$func_stripname_result 7425d5c3dbf1Smrg # We need an absolute path. 7426d5c3dbf1Smrg case $dir in 7427d5c3dbf1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428cdbfa18aSmrg =*) 7429cdbfa18aSmrg func_stripname '=' '' "$dir" 7430cdbfa18aSmrg dir=$lt_sysroot$func_stripname_result 7431cdbfa18aSmrg ;; 7432d5c3dbf1Smrg *) 7433d5c3dbf1Smrg func_fatal_error "only absolute run-paths are allowed" 7434d5c3dbf1Smrg ;; 7435d5c3dbf1Smrg esac 7436d5c3dbf1Smrg case "$xrpath " in 7437d5c3dbf1Smrg *" $dir "*) ;; 7438cdbfa18aSmrg *) func_append xrpath " $dir" ;; 7439d5c3dbf1Smrg esac 7440d5c3dbf1Smrg continue 7441d5c3dbf1Smrg ;; 74429f606849Smrg 7443d5c3dbf1Smrg -shared) 7444d5c3dbf1Smrg # The effects of -shared are defined in a previous loop. 7445d5c3dbf1Smrg continue 7446d5c3dbf1Smrg ;; 74479f606849Smrg 7448d5c3dbf1Smrg -shrext) 7449d5c3dbf1Smrg prev=shrext 7450d5c3dbf1Smrg continue 7451d5c3dbf1Smrg ;; 74529f606849Smrg 7453d5c3dbf1Smrg -static | -static-libtool-libs) 7454d5c3dbf1Smrg # The effects of -static are defined in a previous loop. 7455d5c3dbf1Smrg # We used to do the same as -all-static on platforms that 7456d5c3dbf1Smrg # didn't have a PIC flag, but the assumption that the effects 7457d5c3dbf1Smrg # would be equivalent was wrong. It would break on at least 7458d5c3dbf1Smrg # Digital Unix and AIX. 7459d5c3dbf1Smrg continue 7460d5c3dbf1Smrg ;; 74619f606849Smrg 7462d5c3dbf1Smrg -thread-safe) 7463d5c3dbf1Smrg thread_safe=yes 7464d5c3dbf1Smrg continue 7465d5c3dbf1Smrg ;; 74669f606849Smrg 7467d5c3dbf1Smrg -version-info) 7468d5c3dbf1Smrg prev=vinfo 7469d5c3dbf1Smrg continue 7470d5c3dbf1Smrg ;; 74719f606849Smrg 7472d5c3dbf1Smrg -version-number) 7473d5c3dbf1Smrg prev=vinfo 7474d5c3dbf1Smrg vinfo_number=yes 7475d5c3dbf1Smrg continue 7476d5c3dbf1Smrg ;; 74779f606849Smrg 7478d5c3dbf1Smrg -weak) 7479d5c3dbf1Smrg prev=weak 7480d5c3dbf1Smrg continue 7481d5c3dbf1Smrg ;; 74829f606849Smrg 7483d5c3dbf1Smrg -Wc,*) 7484d5c3dbf1Smrg func_stripname '-Wc,' '' "$arg" 7485d5c3dbf1Smrg args=$func_stripname_result 7486d5c3dbf1Smrg arg= 7487949d0342Smrg save_ifs=$IFS; IFS=, 7488d5c3dbf1Smrg for flag in $args; do 7489949d0342Smrg IFS=$save_ifs 7490949d0342Smrg func_quote_arg pretty "$flag" 7491949d0342Smrg func_append arg " $func_quote_arg_result" 7492949d0342Smrg func_append compiler_flags " $func_quote_arg_result" 7493d5c3dbf1Smrg done 7494949d0342Smrg IFS=$save_ifs 7495d5c3dbf1Smrg func_stripname ' ' '' "$arg" 7496d5c3dbf1Smrg arg=$func_stripname_result 7497d5c3dbf1Smrg ;; 74989f606849Smrg 7499d5c3dbf1Smrg -Wl,*) 7500d5c3dbf1Smrg func_stripname '-Wl,' '' "$arg" 7501d5c3dbf1Smrg args=$func_stripname_result 7502d5c3dbf1Smrg arg= 7503949d0342Smrg save_ifs=$IFS; IFS=, 7504d5c3dbf1Smrg for flag in $args; do 7505949d0342Smrg IFS=$save_ifs 7506949d0342Smrg func_quote_arg pretty "$flag" 7507949d0342Smrg func_append arg " $wl$func_quote_arg_result" 7508949d0342Smrg func_append compiler_flags " $wl$func_quote_arg_result" 7509949d0342Smrg func_append linker_flags " $func_quote_arg_result" 7510d5c3dbf1Smrg done 7511949d0342Smrg IFS=$save_ifs 7512d5c3dbf1Smrg func_stripname ' ' '' "$arg" 7513d5c3dbf1Smrg arg=$func_stripname_result 7514d5c3dbf1Smrg ;; 75159f606849Smrg 7516949d0342Smrg -Xassembler) 7517949d0342Smrg prev=xassembler 7518949d0342Smrg continue 7519949d0342Smrg ;; 7520949d0342Smrg 7521d5c3dbf1Smrg -Xcompiler) 7522d5c3dbf1Smrg prev=xcompiler 7523d5c3dbf1Smrg continue 7524d5c3dbf1Smrg ;; 75259f606849Smrg 7526d5c3dbf1Smrg -Xlinker) 7527d5c3dbf1Smrg prev=xlinker 7528d5c3dbf1Smrg continue 7529d5c3dbf1Smrg ;; 75309f606849Smrg 7531d5c3dbf1Smrg -XCClinker) 7532d5c3dbf1Smrg prev=xcclinker 7533d5c3dbf1Smrg continue 7534d5c3dbf1Smrg ;; 75359f606849Smrg 7536d5c3dbf1Smrg # -msg_* for osf cc 7537d5c3dbf1Smrg -msg_*) 7538949d0342Smrg func_quote_arg pretty "$arg" 7539949d0342Smrg arg=$func_quote_arg_result 7540d5c3dbf1Smrg ;; 75419f606849Smrg 7542d5c3dbf1Smrg # Flags to be passed through unchanged, with rationale: 7543d5c3dbf1Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544d5c3dbf1Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545d5c3dbf1Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546d5c3dbf1Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547d5c3dbf1Smrg # -q* compiler args for the IBM compiler 7548d5c3dbf1Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549d5c3dbf1Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7550d5c3dbf1Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7551949d0342Smrg # -fstack-protector* stack protector flags for GCC 7552d5c3dbf1Smrg # @file GCC response files 7553d5c3dbf1Smrg # -tp=* Portland pgcc target processor selection 7554cdbfa18aSmrg # --sysroot=* for sysroot support 7555949d0342Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556949d0342Smrg # -specs=* GCC specs files 7557949d0342Smrg # -stdlib=* select c++ std lib with clang 7558949d0342Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7559949d0342Smrg # -fuse-ld=* Linker select flags for GCC 7560949d0342Smrg # -Wa,* Pass flags directly to the assembler 7561d5c3dbf1Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562cdbfa18aSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563949d0342Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7564949d0342Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7565949d0342Smrg func_quote_arg pretty "$arg" 7566949d0342Smrg arg=$func_quote_arg_result 7567d5c3dbf1Smrg func_append compile_command " $arg" 7568d5c3dbf1Smrg func_append finalize_command " $arg" 7569cdbfa18aSmrg func_append compiler_flags " $arg" 7570d5c3dbf1Smrg continue 7571d5c3dbf1Smrg ;; 75729f606849Smrg 7573949d0342Smrg -Z*) 7574949d0342Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7575949d0342Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7576949d0342Smrg compiler_flags="$compiler_flags $arg" 7577949d0342Smrg func_append compile_command " $arg" 7578949d0342Smrg func_append finalize_command " $arg" 7579949d0342Smrg case $arg in 7580949d0342Smrg -Zlinker | -Zstack) 7581949d0342Smrg prev=xcompiler 7582949d0342Smrg ;; 7583949d0342Smrg esac 7584949d0342Smrg continue 7585949d0342Smrg else 7586949d0342Smrg # Otherwise treat like 'Some other compiler flag' below 7587949d0342Smrg func_quote_arg pretty "$arg" 7588949d0342Smrg arg=$func_quote_arg_result 7589949d0342Smrg fi 7590949d0342Smrg ;; 7591949d0342Smrg 7592d5c3dbf1Smrg # Some other compiler flag. 7593d5c3dbf1Smrg -* | +*) 7594949d0342Smrg func_quote_arg pretty "$arg" 7595949d0342Smrg arg=$func_quote_arg_result 7596d5c3dbf1Smrg ;; 75979f606849Smrg 7598d5c3dbf1Smrg *.$objext) 7599d5c3dbf1Smrg # A standard object. 7600cdbfa18aSmrg func_append objs " $arg" 7601d5c3dbf1Smrg ;; 76029f606849Smrg 7603d5c3dbf1Smrg *.lo) 7604d5c3dbf1Smrg # A libtool-controlled object. 76059f606849Smrg 7606d5c3dbf1Smrg # Check to see that this really is a libtool object. 7607d5c3dbf1Smrg if func_lalib_unsafe_p "$arg"; then 7608d5c3dbf1Smrg pic_object= 7609d5c3dbf1Smrg non_pic_object= 76109f606849Smrg 7611d5c3dbf1Smrg # Read the .lo file 7612d5c3dbf1Smrg func_source "$arg" 76139f606849Smrg 7614d5c3dbf1Smrg if test -z "$pic_object" || 7615d5c3dbf1Smrg test -z "$non_pic_object" || 7616949d0342Smrg test none = "$pic_object" && 7617949d0342Smrg test none = "$non_pic_object"; then 7618949d0342Smrg func_fatal_error "cannot find name of object for '$arg'" 7619d5c3dbf1Smrg fi 7620fba89afeSmrg 7621d5c3dbf1Smrg # Extract subdirectory from the argument. 7622d5c3dbf1Smrg func_dirname "$arg" "/" "" 7623949d0342Smrg xdir=$func_dirname_result 76249f606849Smrg 7625949d0342Smrg test none = "$pic_object" || { 7626d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 7627949d0342Smrg pic_object=$xdir$pic_object 76289f606849Smrg 7629949d0342Smrg if test dlfiles = "$prev"; then 7630949d0342Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631cdbfa18aSmrg func_append dlfiles " $pic_object" 7632d5c3dbf1Smrg prev= 7633d5c3dbf1Smrg continue 7634d5c3dbf1Smrg else 7635d5c3dbf1Smrg # If libtool objects are unsupported, then we need to preload. 7636d5c3dbf1Smrg prev=dlprefiles 7637d5c3dbf1Smrg fi 7638d5c3dbf1Smrg fi 7639d5c3dbf1Smrg 7640d5c3dbf1Smrg # CHECK ME: I think I busted this. -Ossama 7641949d0342Smrg if test dlprefiles = "$prev"; then 7642d5c3dbf1Smrg # Preload the old-style object. 7643cdbfa18aSmrg func_append dlprefiles " $pic_object" 7644d5c3dbf1Smrg prev= 7645d5c3dbf1Smrg fi 7646d5c3dbf1Smrg 7647d5c3dbf1Smrg # A PIC object. 7648d5c3dbf1Smrg func_append libobjs " $pic_object" 7649949d0342Smrg arg=$pic_object 7650949d0342Smrg } 7651d5c3dbf1Smrg 7652d5c3dbf1Smrg # Non-PIC object. 7653949d0342Smrg if test none != "$non_pic_object"; then 7654d5c3dbf1Smrg # Prepend the subdirectory the object is found in. 7655949d0342Smrg non_pic_object=$xdir$non_pic_object 7656d5c3dbf1Smrg 7657d5c3dbf1Smrg # A standard non-PIC object 7658d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7659949d0342Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7660949d0342Smrg arg=$non_pic_object 7661d5c3dbf1Smrg fi 7662d5c3dbf1Smrg else 7663d5c3dbf1Smrg # If the PIC object exists, use it instead. 7664d5c3dbf1Smrg # $xdir was prepended to $pic_object above. 7665949d0342Smrg non_pic_object=$pic_object 7666d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7667d5c3dbf1Smrg fi 7668d5c3dbf1Smrg else 7669d5c3dbf1Smrg # Only an error if not doing a dry-run. 7670d5c3dbf1Smrg if $opt_dry_run; then 7671d5c3dbf1Smrg # Extract subdirectory from the argument. 7672d5c3dbf1Smrg func_dirname "$arg" "/" "" 7673949d0342Smrg xdir=$func_dirname_result 7674d5c3dbf1Smrg 7675d5c3dbf1Smrg func_lo2o "$arg" 7676d5c3dbf1Smrg pic_object=$xdir$objdir/$func_lo2o_result 7677d5c3dbf1Smrg non_pic_object=$xdir$func_lo2o_result 7678d5c3dbf1Smrg func_append libobjs " $pic_object" 7679d5c3dbf1Smrg func_append non_pic_objects " $non_pic_object" 7680d5c3dbf1Smrg else 7681949d0342Smrg func_fatal_error "'$arg' is not a valid libtool object" 7682d5c3dbf1Smrg fi 7683d5c3dbf1Smrg fi 7684d5c3dbf1Smrg ;; 7685d5c3dbf1Smrg 7686d5c3dbf1Smrg *.$libext) 7687d5c3dbf1Smrg # An archive. 7688cdbfa18aSmrg func_append deplibs " $arg" 7689cdbfa18aSmrg func_append old_deplibs " $arg" 7690d5c3dbf1Smrg continue 7691d5c3dbf1Smrg ;; 7692d5c3dbf1Smrg 7693d5c3dbf1Smrg *.la) 7694d5c3dbf1Smrg # A libtool-controlled library. 7695d5c3dbf1Smrg 7696cdbfa18aSmrg func_resolve_sysroot "$arg" 7697949d0342Smrg if test dlfiles = "$prev"; then 7698d5c3dbf1Smrg # This library was specified with -dlopen. 7699cdbfa18aSmrg func_append dlfiles " $func_resolve_sysroot_result" 7700d5c3dbf1Smrg prev= 7701949d0342Smrg elif test dlprefiles = "$prev"; then 7702d5c3dbf1Smrg # The library was specified with -dlpreopen. 7703cdbfa18aSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7704d5c3dbf1Smrg prev= 7705d5c3dbf1Smrg else 7706cdbfa18aSmrg func_append deplibs " $func_resolve_sysroot_result" 7707d5c3dbf1Smrg fi 7708d5c3dbf1Smrg continue 7709d5c3dbf1Smrg ;; 7710d5c3dbf1Smrg 7711d5c3dbf1Smrg # Some other compiler argument. 7712d5c3dbf1Smrg *) 7713d5c3dbf1Smrg # Unknown arguments in both finalize_command and compile_command need 7714d5c3dbf1Smrg # to be aesthetically quoted because they are evaled later. 7715949d0342Smrg func_quote_arg pretty "$arg" 7716949d0342Smrg arg=$func_quote_arg_result 7717d5c3dbf1Smrg ;; 7718d5c3dbf1Smrg esac # arg 7719d5c3dbf1Smrg 7720d5c3dbf1Smrg # Now actually substitute the argument into the commands. 7721d5c3dbf1Smrg if test -n "$arg"; then 7722d5c3dbf1Smrg func_append compile_command " $arg" 7723d5c3dbf1Smrg func_append finalize_command " $arg" 7724d5c3dbf1Smrg fi 7725d5c3dbf1Smrg done # argument parsing loop 7726d5c3dbf1Smrg 7727d5c3dbf1Smrg test -n "$prev" && \ 7728949d0342Smrg func_fatal_help "the '$prevarg' option requires an argument" 7729d5c3dbf1Smrg 7730949d0342Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731d5c3dbf1Smrg eval arg=\"$export_dynamic_flag_spec\" 7732d5c3dbf1Smrg func_append compile_command " $arg" 7733d5c3dbf1Smrg func_append finalize_command " $arg" 7734d5c3dbf1Smrg fi 7735d5c3dbf1Smrg 7736d5c3dbf1Smrg oldlibs= 7737d5c3dbf1Smrg # calculate the name of the file, without its directory 7738d5c3dbf1Smrg func_basename "$output" 7739949d0342Smrg outputname=$func_basename_result 7740949d0342Smrg libobjs_save=$libobjs 7741d5c3dbf1Smrg 7742d5c3dbf1Smrg if test -n "$shlibpath_var"; then 7743d5c3dbf1Smrg # get the directories listed in $shlibpath_var 7744949d0342Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77459f606849Smrg else 7746d5c3dbf1Smrg shlib_search_path= 77479f606849Smrg fi 7748d5c3dbf1Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749d5c3dbf1Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77509f606849Smrg 7751949d0342Smrg # Definition is injected by LT_CONFIG during libtool generation. 7752949d0342Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7753949d0342Smrg 7754d5c3dbf1Smrg func_dirname "$output" "/" "" 7755949d0342Smrg output_objdir=$func_dirname_result$objdir 7756cdbfa18aSmrg func_to_tool_file "$output_objdir/" 7757cdbfa18aSmrg tool_output_objdir=$func_to_tool_file_result 7758d5c3dbf1Smrg # Create the object directory. 7759d5c3dbf1Smrg func_mkdir_p "$output_objdir" 77609f606849Smrg 7761d5c3dbf1Smrg # Determine the type of output 7762d5c3dbf1Smrg case $output in 7763d5c3dbf1Smrg "") 7764d5c3dbf1Smrg func_fatal_help "you must specify an output file" 7765d5c3dbf1Smrg ;; 7766d5c3dbf1Smrg *.$libext) linkmode=oldlib ;; 7767d5c3dbf1Smrg *.lo | *.$objext) linkmode=obj ;; 7768d5c3dbf1Smrg *.la) linkmode=lib ;; 7769d5c3dbf1Smrg *) linkmode=prog ;; # Anything else should be a program. 7770d5c3dbf1Smrg esac 7771d5c3dbf1Smrg 7772d5c3dbf1Smrg specialdeplibs= 7773d5c3dbf1Smrg 7774d5c3dbf1Smrg libs= 7775d5c3dbf1Smrg # Find all interdependent deplibs by searching for libraries 7776d5c3dbf1Smrg # that are linked more than once (e.g. -la -lb -la) 7777d5c3dbf1Smrg for deplib in $deplibs; do 7778949d0342Smrg if $opt_preserve_dup_deps; then 7779d5c3dbf1Smrg case "$libs " in 7780cdbfa18aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781d5c3dbf1Smrg esac 7782d5c3dbf1Smrg fi 7783cdbfa18aSmrg func_append libs " $deplib" 7784d5c3dbf1Smrg done 7785d5c3dbf1Smrg 7786949d0342Smrg if test lib = "$linkmode"; then 7787d5c3dbf1Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788d5c3dbf1Smrg 7789d5c3dbf1Smrg # Compute libraries that are listed more than once in $predeps 7790d5c3dbf1Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7791d5c3dbf1Smrg # not to be eliminated). 7792d5c3dbf1Smrg pre_post_deps= 7793d5c3dbf1Smrg if $opt_duplicate_compiler_generated_deps; then 7794d5c3dbf1Smrg for pre_post_dep in $predeps $postdeps; do 7795d5c3dbf1Smrg case "$pre_post_deps " in 7796cdbfa18aSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797d5c3dbf1Smrg esac 7798cdbfa18aSmrg func_append pre_post_deps " $pre_post_dep" 7799d5c3dbf1Smrg done 7800d5c3dbf1Smrg fi 7801d5c3dbf1Smrg pre_post_deps= 7802d5c3dbf1Smrg fi 7803d5c3dbf1Smrg 7804d5c3dbf1Smrg deplibs= 7805d5c3dbf1Smrg newdependency_libs= 7806d5c3dbf1Smrg newlib_search_path= 7807d5c3dbf1Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808d5c3dbf1Smrg notinst_deplibs= # not-installed libtool libraries 7809d5c3dbf1Smrg notinst_path= # paths that contain not-installed libtool libraries 7810d5c3dbf1Smrg 7811d5c3dbf1Smrg case $linkmode in 7812d5c3dbf1Smrg lib) 7813d5c3dbf1Smrg passes="conv dlpreopen link" 7814d5c3dbf1Smrg for file in $dlfiles $dlprefiles; do 7815d5c3dbf1Smrg case $file in 7816d5c3dbf1Smrg *.la) ;; 7817d5c3dbf1Smrg *) 7818949d0342Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819d5c3dbf1Smrg ;; 7820d5c3dbf1Smrg esac 7821d5c3dbf1Smrg done 7822d5c3dbf1Smrg ;; 7823d5c3dbf1Smrg prog) 7824d5c3dbf1Smrg compile_deplibs= 7825d5c3dbf1Smrg finalize_deplibs= 7826949d0342Smrg alldeplibs=false 7827d5c3dbf1Smrg newdlfiles= 7828d5c3dbf1Smrg newdlprefiles= 7829d5c3dbf1Smrg passes="conv scan dlopen dlpreopen link" 7830d5c3dbf1Smrg ;; 7831d5c3dbf1Smrg *) passes="conv" 7832d5c3dbf1Smrg ;; 7833d5c3dbf1Smrg esac 7834d5c3dbf1Smrg 7835d5c3dbf1Smrg for pass in $passes; do 7836d5c3dbf1Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837d5c3dbf1Smrg # so that -L comes before libs that need it for instance... 7838949d0342Smrg if test lib,link = "$linkmode,$pass"; then 7839d5c3dbf1Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840d5c3dbf1Smrg ## order, and fix it there properly 7841d5c3dbf1Smrg tmp_deplibs= 7842d5c3dbf1Smrg for deplib in $deplibs; do 7843d5c3dbf1Smrg tmp_deplibs="$deplib $tmp_deplibs" 7844d5c3dbf1Smrg done 7845949d0342Smrg deplibs=$tmp_deplibs 7846d5c3dbf1Smrg fi 7847d5c3dbf1Smrg 7848949d0342Smrg if test lib,link = "$linkmode,$pass" || 7849949d0342Smrg test prog,scan = "$linkmode,$pass"; then 7850949d0342Smrg libs=$deplibs 7851d5c3dbf1Smrg deplibs= 7852d5c3dbf1Smrg fi 7853949d0342Smrg if test prog = "$linkmode"; then 7854d5c3dbf1Smrg case $pass in 7855949d0342Smrg dlopen) libs=$dlfiles ;; 7856949d0342Smrg dlpreopen) libs=$dlprefiles ;; 7857949d0342Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858d5c3dbf1Smrg esac 7859d5c3dbf1Smrg fi 7860949d0342Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861d5c3dbf1Smrg # Collect and forward deplibs of preopened libtool libs 7862d5c3dbf1Smrg for lib in $dlprefiles; do 7863d5c3dbf1Smrg # Ignore non-libtool-libs 7864d5c3dbf1Smrg dependency_libs= 7865cdbfa18aSmrg func_resolve_sysroot "$lib" 7866d5c3dbf1Smrg case $lib in 7867cdbfa18aSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868d5c3dbf1Smrg esac 7869d5c3dbf1Smrg 7870d5c3dbf1Smrg # Collect preopened libtool deplibs, except any this library 7871d5c3dbf1Smrg # has declared as weak libs 7872d5c3dbf1Smrg for deplib in $dependency_libs; do 7873d5c3dbf1Smrg func_basename "$deplib" 7874d5c3dbf1Smrg deplib_base=$func_basename_result 7875d5c3dbf1Smrg case " $weak_libs " in 7876d5c3dbf1Smrg *" $deplib_base "*) ;; 7877cdbfa18aSmrg *) func_append deplibs " $deplib" ;; 7878d5c3dbf1Smrg esac 7879d5c3dbf1Smrg done 7880d5c3dbf1Smrg done 7881949d0342Smrg libs=$dlprefiles 7882d5c3dbf1Smrg fi 7883949d0342Smrg if test dlopen = "$pass"; then 7884d5c3dbf1Smrg # Collect dlpreopened libraries 7885949d0342Smrg save_deplibs=$deplibs 7886d5c3dbf1Smrg deplibs= 7887d5c3dbf1Smrg fi 7888d5c3dbf1Smrg 7889d5c3dbf1Smrg for deplib in $libs; do 7890d5c3dbf1Smrg lib= 7891949d0342Smrg found=false 7892d5c3dbf1Smrg case $deplib in 7893cdbfa18aSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894cdbfa18aSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7895949d0342Smrg if test prog,link = "$linkmode,$pass"; then 7896d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 7897d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7898d5c3dbf1Smrg else 7899cdbfa18aSmrg func_append compiler_flags " $deplib" 7900949d0342Smrg if test lib = "$linkmode"; then 7901d5c3dbf1Smrg case "$new_inherited_linker_flags " in 7902d5c3dbf1Smrg *" $deplib "*) ;; 7903cdbfa18aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904d5c3dbf1Smrg esac 7905d5c3dbf1Smrg fi 7906d5c3dbf1Smrg fi 7907d5c3dbf1Smrg continue 7908d5c3dbf1Smrg ;; 7909d5c3dbf1Smrg -l*) 7910949d0342Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7911949d0342Smrg func_warning "'-l' is ignored for archives/objects" 7912d5c3dbf1Smrg continue 7913d5c3dbf1Smrg fi 7914d5c3dbf1Smrg func_stripname '-l' '' "$deplib" 7915d5c3dbf1Smrg name=$func_stripname_result 7916949d0342Smrg if test lib = "$linkmode"; then 7917d5c3dbf1Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918d5c3dbf1Smrg else 7919d5c3dbf1Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920d5c3dbf1Smrg fi 7921d5c3dbf1Smrg for searchdir in $searchdirs; do 7922d5c3dbf1Smrg for search_ext in .la $std_shrext .so .a; do 7923d5c3dbf1Smrg # Search the libtool library 7924949d0342Smrg lib=$searchdir/lib$name$search_ext 7925d5c3dbf1Smrg if test -f "$lib"; then 7926949d0342Smrg if test .la = "$search_ext"; then 7927949d0342Smrg found=: 7928d5c3dbf1Smrg else 7929949d0342Smrg found=false 7930d5c3dbf1Smrg fi 7931d5c3dbf1Smrg break 2 7932d5c3dbf1Smrg fi 7933d5c3dbf1Smrg done 7934d5c3dbf1Smrg done 7935949d0342Smrg if $found; then 7936949d0342Smrg # deplib is a libtool library 7937d5c3dbf1Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938d5c3dbf1Smrg # We need to do some special things here, and not later. 7939949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940d5c3dbf1Smrg case " $predeps $postdeps " in 7941d5c3dbf1Smrg *" $deplib "*) 7942d5c3dbf1Smrg if func_lalib_p "$lib"; then 7943d5c3dbf1Smrg library_names= 7944d5c3dbf1Smrg old_library= 7945d5c3dbf1Smrg func_source "$lib" 7946d5c3dbf1Smrg for l in $old_library $library_names; do 7947949d0342Smrg ll=$l 7948d5c3dbf1Smrg done 7949949d0342Smrg if test "X$ll" = "X$old_library"; then # only static version available 7950949d0342Smrg found=false 7951d5c3dbf1Smrg func_dirname "$lib" "" "." 7952949d0342Smrg ladir=$func_dirname_result 7953d5c3dbf1Smrg lib=$ladir/$old_library 7954949d0342Smrg if test prog,link = "$linkmode,$pass"; then 7955d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 7956d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7957d5c3dbf1Smrg else 7958d5c3dbf1Smrg deplibs="$deplib $deplibs" 7959949d0342Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960d5c3dbf1Smrg fi 7961d5c3dbf1Smrg continue 7962d5c3dbf1Smrg fi 7963d5c3dbf1Smrg fi 7964d5c3dbf1Smrg ;; 7965d5c3dbf1Smrg *) ;; 7966d5c3dbf1Smrg esac 7967d5c3dbf1Smrg fi 7968949d0342Smrg else 7969949d0342Smrg # deplib doesn't seem to be a libtool library 7970949d0342Smrg if test prog,link = "$linkmode,$pass"; then 7971949d0342Smrg compile_deplibs="$deplib $compile_deplibs" 7972949d0342Smrg finalize_deplibs="$deplib $finalize_deplibs" 7973949d0342Smrg else 7974949d0342Smrg deplibs="$deplib $deplibs" 7975949d0342Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7976949d0342Smrg fi 7977949d0342Smrg continue 7978d5c3dbf1Smrg fi 7979d5c3dbf1Smrg ;; # -l 7980d5c3dbf1Smrg *.ltframework) 7981949d0342Smrg if test prog,link = "$linkmode,$pass"; then 7982d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 7983d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7984d5c3dbf1Smrg else 7985d5c3dbf1Smrg deplibs="$deplib $deplibs" 7986949d0342Smrg if test lib = "$linkmode"; then 7987d5c3dbf1Smrg case "$new_inherited_linker_flags " in 7988d5c3dbf1Smrg *" $deplib "*) ;; 7989cdbfa18aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990d5c3dbf1Smrg esac 7991d5c3dbf1Smrg fi 7992d5c3dbf1Smrg fi 7993d5c3dbf1Smrg continue 7994d5c3dbf1Smrg ;; 7995d5c3dbf1Smrg -L*) 7996d5c3dbf1Smrg case $linkmode in 7997d5c3dbf1Smrg lib) 7998d5c3dbf1Smrg deplibs="$deplib $deplibs" 7999949d0342Smrg test conv = "$pass" && continue 8000d5c3dbf1Smrg newdependency_libs="$deplib $newdependency_libs" 8001d5c3dbf1Smrg func_stripname '-L' '' "$deplib" 8002cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8003cdbfa18aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004d5c3dbf1Smrg ;; 8005d5c3dbf1Smrg prog) 8006949d0342Smrg if test conv = "$pass"; then 8007d5c3dbf1Smrg deplibs="$deplib $deplibs" 8008d5c3dbf1Smrg continue 8009d5c3dbf1Smrg fi 8010949d0342Smrg if test scan = "$pass"; then 8011d5c3dbf1Smrg deplibs="$deplib $deplibs" 8012d5c3dbf1Smrg else 8013d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8014d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8015d5c3dbf1Smrg fi 8016d5c3dbf1Smrg func_stripname '-L' '' "$deplib" 8017cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8018cdbfa18aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019d5c3dbf1Smrg ;; 8020d5c3dbf1Smrg *) 8021949d0342Smrg func_warning "'-L' is ignored for archives/objects" 8022d5c3dbf1Smrg ;; 8023d5c3dbf1Smrg esac # linkmode 8024d5c3dbf1Smrg continue 8025d5c3dbf1Smrg ;; # -L 8026d5c3dbf1Smrg -R*) 8027949d0342Smrg if test link = "$pass"; then 8028d5c3dbf1Smrg func_stripname '-R' '' "$deplib" 8029cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8030cdbfa18aSmrg dir=$func_resolve_sysroot_result 8031d5c3dbf1Smrg # Make sure the xrpath contains only unique directories. 8032d5c3dbf1Smrg case "$xrpath " in 8033d5c3dbf1Smrg *" $dir "*) ;; 8034cdbfa18aSmrg *) func_append xrpath " $dir" ;; 8035d5c3dbf1Smrg esac 8036d5c3dbf1Smrg fi 8037d5c3dbf1Smrg deplibs="$deplib $deplibs" 8038d5c3dbf1Smrg continue 8039d5c3dbf1Smrg ;; 8040cdbfa18aSmrg *.la) 8041cdbfa18aSmrg func_resolve_sysroot "$deplib" 8042cdbfa18aSmrg lib=$func_resolve_sysroot_result 8043cdbfa18aSmrg ;; 8044d5c3dbf1Smrg *.$libext) 8045949d0342Smrg if test conv = "$pass"; then 8046d5c3dbf1Smrg deplibs="$deplib $deplibs" 8047d5c3dbf1Smrg continue 8048d5c3dbf1Smrg fi 8049d5c3dbf1Smrg case $linkmode in 8050d5c3dbf1Smrg lib) 8051d5c3dbf1Smrg # Linking convenience modules into shared libraries is allowed, 8052d5c3dbf1Smrg # but linking other static libraries is non-portable. 8053d5c3dbf1Smrg case " $dlpreconveniencelibs " in 8054d5c3dbf1Smrg *" $deplib "*) ;; 8055d5c3dbf1Smrg *) 8056949d0342Smrg valid_a_lib=false 8057d5c3dbf1Smrg case $deplibs_check_method in 8058d5c3dbf1Smrg match_pattern*) 8059d5c3dbf1Smrg set dummy $deplibs_check_method; shift 8060d5c3dbf1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061d5c3dbf1Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062d5c3dbf1Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 8063949d0342Smrg valid_a_lib=: 8064d5c3dbf1Smrg fi 8065d5c3dbf1Smrg ;; 8066d5c3dbf1Smrg pass_all) 8067949d0342Smrg valid_a_lib=: 8068d5c3dbf1Smrg ;; 8069d5c3dbf1Smrg esac 8070949d0342Smrg if $valid_a_lib; then 8071949d0342Smrg echo 8072949d0342Smrg $ECHO "*** Warning: Linking the shared library $output against the" 8073949d0342Smrg $ECHO "*** static library $deplib is not portable!" 8074949d0342Smrg deplibs="$deplib $deplibs" 8075949d0342Smrg else 8076d5c3dbf1Smrg echo 8077d5c3dbf1Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078d5c3dbf1Smrg echo "*** I have the capability to make that library automatically link in when" 8079d5c3dbf1Smrg echo "*** you link to this library. But I can only do this if you have a" 8080d5c3dbf1Smrg echo "*** shared version of the library, which you do not appear to have" 8081d5c3dbf1Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082d5c3dbf1Smrg echo "*** that it is just a static archive that I should not use here." 8083d5c3dbf1Smrg fi 8084d5c3dbf1Smrg ;; 8085d5c3dbf1Smrg esac 8086d5c3dbf1Smrg continue 8087d5c3dbf1Smrg ;; 8088d5c3dbf1Smrg prog) 8089949d0342Smrg if test link != "$pass"; then 8090d5c3dbf1Smrg deplibs="$deplib $deplibs" 8091d5c3dbf1Smrg else 8092d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8093d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8094d5c3dbf1Smrg fi 8095d5c3dbf1Smrg continue 8096d5c3dbf1Smrg ;; 8097d5c3dbf1Smrg esac # linkmode 8098d5c3dbf1Smrg ;; # *.$libext 8099d5c3dbf1Smrg *.lo | *.$objext) 8100949d0342Smrg if test conv = "$pass"; then 8101d5c3dbf1Smrg deplibs="$deplib $deplibs" 8102949d0342Smrg elif test prog = "$linkmode"; then 8103949d0342Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104d5c3dbf1Smrg # If there is no dlopen support or we're linking statically, 8105d5c3dbf1Smrg # we need to preload. 8106cdbfa18aSmrg func_append newdlprefiles " $deplib" 8107d5c3dbf1Smrg compile_deplibs="$deplib $compile_deplibs" 8108d5c3dbf1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8109d5c3dbf1Smrg else 8110cdbfa18aSmrg func_append newdlfiles " $deplib" 8111d5c3dbf1Smrg fi 8112d5c3dbf1Smrg fi 8113d5c3dbf1Smrg continue 8114d5c3dbf1Smrg ;; 8115d5c3dbf1Smrg %DEPLIBS%) 8116949d0342Smrg alldeplibs=: 8117d5c3dbf1Smrg continue 8118d5c3dbf1Smrg ;; 8119d5c3dbf1Smrg esac # case $deplib 8120d5c3dbf1Smrg 8121949d0342Smrg $found || test -f "$lib" \ 8122949d0342Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123d5c3dbf1Smrg 8124d5c3dbf1Smrg # Check to see that this really is a libtool archive. 8125d5c3dbf1Smrg func_lalib_unsafe_p "$lib" \ 8126949d0342Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127d5c3dbf1Smrg 8128d5c3dbf1Smrg func_dirname "$lib" "" "." 8129949d0342Smrg ladir=$func_dirname_result 8130d5c3dbf1Smrg 8131d5c3dbf1Smrg dlname= 8132d5c3dbf1Smrg dlopen= 8133d5c3dbf1Smrg dlpreopen= 8134d5c3dbf1Smrg libdir= 8135d5c3dbf1Smrg library_names= 8136d5c3dbf1Smrg old_library= 8137d5c3dbf1Smrg inherited_linker_flags= 8138d5c3dbf1Smrg # If the library was installed with an old release of libtool, 8139d5c3dbf1Smrg # it will not redefine variables installed, or shouldnotlink 8140d5c3dbf1Smrg installed=yes 8141d5c3dbf1Smrg shouldnotlink=no 8142d5c3dbf1Smrg avoidtemprpath= 8143d5c3dbf1Smrg 8144d5c3dbf1Smrg 8145d5c3dbf1Smrg # Read the .la file 8146d5c3dbf1Smrg func_source "$lib" 8147d5c3dbf1Smrg 8148d5c3dbf1Smrg # Convert "-framework foo" to "foo.ltframework" 8149d5c3dbf1Smrg if test -n "$inherited_linker_flags"; then 8150d5c3dbf1Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151d5c3dbf1Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152d5c3dbf1Smrg case " $new_inherited_linker_flags " in 8153d5c3dbf1Smrg *" $tmp_inherited_linker_flag "*) ;; 8154cdbfa18aSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155d5c3dbf1Smrg esac 8156d5c3dbf1Smrg done 8157d5c3dbf1Smrg fi 8158d5c3dbf1Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8159949d0342Smrg if test lib,link = "$linkmode,$pass" || 8160949d0342Smrg test prog,scan = "$linkmode,$pass" || 8161949d0342Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162cdbfa18aSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163cdbfa18aSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164d5c3dbf1Smrg fi 8165d5c3dbf1Smrg 8166949d0342Smrg if test conv = "$pass"; then 8167d5c3dbf1Smrg # Only check for convenience libraries 8168d5c3dbf1Smrg deplibs="$lib $deplibs" 8169d5c3dbf1Smrg if test -z "$libdir"; then 8170d5c3dbf1Smrg if test -z "$old_library"; then 8171949d0342Smrg func_fatal_error "cannot find name of link library for '$lib'" 8172d5c3dbf1Smrg fi 8173d5c3dbf1Smrg # It is a libtool convenience library, so add in its objects. 8174cdbfa18aSmrg func_append convenience " $ladir/$objdir/$old_library" 8175cdbfa18aSmrg func_append old_convenience " $ladir/$objdir/$old_library" 8176949d0342Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8177949d0342Smrg func_fatal_error "'$lib' is not a convenience library" 8178d5c3dbf1Smrg fi 8179949d0342Smrg tmp_libs= 8180949d0342Smrg for deplib in $dependency_libs; do 8181949d0342Smrg deplibs="$deplib $deplibs" 8182949d0342Smrg if $opt_preserve_dup_deps; then 8183949d0342Smrg case "$tmp_libs " in 8184949d0342Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185949d0342Smrg esac 8186949d0342Smrg fi 8187949d0342Smrg func_append tmp_libs " $deplib" 8188949d0342Smrg done 8189d5c3dbf1Smrg continue 8190d5c3dbf1Smrg fi # $pass = conv 8191d5c3dbf1Smrg 8192d5c3dbf1Smrg 8193d5c3dbf1Smrg # Get the name of the library we link against. 8194d5c3dbf1Smrg linklib= 8195cdbfa18aSmrg if test -n "$old_library" && 8196949d0342Smrg { test yes = "$prefer_static_libs" || 8197949d0342Smrg test built,no = "$prefer_static_libs,$installed"; }; then 8198cdbfa18aSmrg linklib=$old_library 8199cdbfa18aSmrg else 8200cdbfa18aSmrg for l in $old_library $library_names; do 8201949d0342Smrg linklib=$l 8202cdbfa18aSmrg done 8203cdbfa18aSmrg fi 8204d5c3dbf1Smrg if test -z "$linklib"; then 8205949d0342Smrg func_fatal_error "cannot find name of link library for '$lib'" 8206d5c3dbf1Smrg fi 8207d5c3dbf1Smrg 8208d5c3dbf1Smrg # This library was specified with -dlopen. 8209949d0342Smrg if test dlopen = "$pass"; then 8210949d0342Smrg test -z "$libdir" \ 8211949d0342Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212d5c3dbf1Smrg if test -z "$dlname" || 8213949d0342Smrg test yes != "$dlopen_support" || 8214949d0342Smrg test no = "$build_libtool_libs" 8215949d0342Smrg then 8216d5c3dbf1Smrg # If there is no dlname, no dlopen support or we're linking 8217d5c3dbf1Smrg # statically, we need to preload. We also need to preload any 8218d5c3dbf1Smrg # dependent libraries so libltdl's deplib preloader doesn't 8219d5c3dbf1Smrg # bomb out in the load deplibs phase. 8220cdbfa18aSmrg func_append dlprefiles " $lib $dependency_libs" 8221d5c3dbf1Smrg else 8222cdbfa18aSmrg func_append newdlfiles " $lib" 8223d5c3dbf1Smrg fi 8224d5c3dbf1Smrg continue 8225d5c3dbf1Smrg fi # $pass = dlopen 8226d5c3dbf1Smrg 8227d5c3dbf1Smrg # We need an absolute path. 8228d5c3dbf1Smrg case $ladir in 8229949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230d5c3dbf1Smrg *) 8231d5c3dbf1Smrg abs_ladir=`cd "$ladir" && pwd` 8232d5c3dbf1Smrg if test -z "$abs_ladir"; then 8233949d0342Smrg func_warning "cannot determine absolute directory name of '$ladir'" 8234d5c3dbf1Smrg func_warning "passing it literally to the linker, although it might fail" 8235949d0342Smrg abs_ladir=$ladir 8236d5c3dbf1Smrg fi 8237d5c3dbf1Smrg ;; 8238d5c3dbf1Smrg esac 8239d5c3dbf1Smrg func_basename "$lib" 8240949d0342Smrg laname=$func_basename_result 8241d5c3dbf1Smrg 8242d5c3dbf1Smrg # Find the relevant object directory and library name. 8243949d0342Smrg if test yes = "$installed"; then 8244cdbfa18aSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8245949d0342Smrg func_warning "library '$lib' was moved." 8246949d0342Smrg dir=$ladir 8247949d0342Smrg absdir=$abs_ladir 8248949d0342Smrg libdir=$abs_ladir 8249d5c3dbf1Smrg else 8250949d0342Smrg dir=$lt_sysroot$libdir 8251949d0342Smrg absdir=$lt_sysroot$libdir 8252d5c3dbf1Smrg fi 8253949d0342Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254d5c3dbf1Smrg else 8255d5c3dbf1Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8256949d0342Smrg dir=$ladir 8257949d0342Smrg absdir=$abs_ladir 8258d5c3dbf1Smrg # Remove this search path later 8259cdbfa18aSmrg func_append notinst_path " $abs_ladir" 8260d5c3dbf1Smrg else 8261949d0342Smrg dir=$ladir/$objdir 8262949d0342Smrg absdir=$abs_ladir/$objdir 8263d5c3dbf1Smrg # Remove this search path later 8264cdbfa18aSmrg func_append notinst_path " $abs_ladir" 8265d5c3dbf1Smrg fi 8266d5c3dbf1Smrg fi # $installed = yes 8267d5c3dbf1Smrg func_stripname 'lib' '.la' "$laname" 8268d5c3dbf1Smrg name=$func_stripname_result 8269d5c3dbf1Smrg 8270d5c3dbf1Smrg # This library was specified with -dlpreopen. 8271949d0342Smrg if test dlpreopen = "$pass"; then 8272949d0342Smrg if test -z "$libdir" && test prog = "$linkmode"; then 8273949d0342Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274d5c3dbf1Smrg fi 8275949d0342Smrg case $host in 8276cdbfa18aSmrg # special handling for platforms with PE-DLLs. 8277cdbfa18aSmrg *cygwin* | *mingw* | *cegcc* ) 8278cdbfa18aSmrg # Linker will automatically link against shared library if both 8279cdbfa18aSmrg # static and shared are present. Therefore, ensure we extract 8280cdbfa18aSmrg # symbols from the import library if a shared library is present 8281cdbfa18aSmrg # (otherwise, the dlopen module name will be incorrect). We do 8282cdbfa18aSmrg # this by putting the import library name into $newdlprefiles. 8283cdbfa18aSmrg # We recover the dlopen module name by 'saving' the la file 8284cdbfa18aSmrg # name in a special purpose variable, and (later) extracting the 8285cdbfa18aSmrg # dlname from the la file. 8286cdbfa18aSmrg if test -n "$dlname"; then 8287cdbfa18aSmrg func_tr_sh "$dir/$linklib" 8288cdbfa18aSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289cdbfa18aSmrg func_append newdlprefiles " $dir/$linklib" 8290cdbfa18aSmrg else 8291cdbfa18aSmrg func_append newdlprefiles " $dir/$old_library" 8292cdbfa18aSmrg # Keep a list of preopened convenience libraries to check 8293cdbfa18aSmrg # that they are being used correctly in the link pass. 8294cdbfa18aSmrg test -z "$libdir" && \ 8295cdbfa18aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8296cdbfa18aSmrg fi 8297cdbfa18aSmrg ;; 8298cdbfa18aSmrg * ) 8299cdbfa18aSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300cdbfa18aSmrg # are required to link). 8301cdbfa18aSmrg if test -n "$old_library"; then 8302cdbfa18aSmrg func_append newdlprefiles " $dir/$old_library" 8303cdbfa18aSmrg # Keep a list of preopened convenience libraries to check 8304cdbfa18aSmrg # that they are being used correctly in the link pass. 8305cdbfa18aSmrg test -z "$libdir" && \ 8306cdbfa18aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8307cdbfa18aSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308cdbfa18aSmrg elif test -n "$dlname"; then 8309cdbfa18aSmrg func_append newdlprefiles " $dir/$dlname" 8310cdbfa18aSmrg else 8311cdbfa18aSmrg func_append newdlprefiles " $dir/$linklib" 8312cdbfa18aSmrg fi 8313cdbfa18aSmrg ;; 8314cdbfa18aSmrg esac 8315d5c3dbf1Smrg fi # $pass = dlpreopen 8316d5c3dbf1Smrg 8317d5c3dbf1Smrg if test -z "$libdir"; then 8318d5c3dbf1Smrg # Link the convenience library 8319949d0342Smrg if test lib = "$linkmode"; then 8320d5c3dbf1Smrg deplibs="$dir/$old_library $deplibs" 8321949d0342Smrg elif test prog,link = "$linkmode,$pass"; then 8322d5c3dbf1Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323d5c3dbf1Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324d5c3dbf1Smrg else 8325d5c3dbf1Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8326d5c3dbf1Smrg fi 8327d5c3dbf1Smrg continue 8328d5c3dbf1Smrg fi 8329d5c3dbf1Smrg 8330d5c3dbf1Smrg 8331949d0342Smrg if test prog = "$linkmode" && test link != "$pass"; then 8332cdbfa18aSmrg func_append newlib_search_path " $ladir" 8333d5c3dbf1Smrg deplibs="$lib $deplibs" 8334d5c3dbf1Smrg 8335949d0342Smrg linkalldeplibs=false 8336949d0342Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8337949d0342Smrg test no = "$build_libtool_libs"; then 8338949d0342Smrg linkalldeplibs=: 8339d5c3dbf1Smrg fi 8340d5c3dbf1Smrg 8341d5c3dbf1Smrg tmp_libs= 8342d5c3dbf1Smrg for deplib in $dependency_libs; do 8343d5c3dbf1Smrg case $deplib in 8344d5c3dbf1Smrg -L*) func_stripname '-L' '' "$deplib" 8345cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result" 8346cdbfa18aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347d5c3dbf1Smrg ;; 8348d5c3dbf1Smrg esac 8349d5c3dbf1Smrg # Need to link against all dependency_libs? 8350949d0342Smrg if $linkalldeplibs; then 8351d5c3dbf1Smrg deplibs="$deplib $deplibs" 8352d5c3dbf1Smrg else 8353d5c3dbf1Smrg # Need to hardcode shared library paths 8354d5c3dbf1Smrg # or/and link against static libraries 8355d5c3dbf1Smrg newdependency_libs="$deplib $newdependency_libs" 8356d5c3dbf1Smrg fi 8357949d0342Smrg if $opt_preserve_dup_deps; then 8358d5c3dbf1Smrg case "$tmp_libs " in 8359cdbfa18aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360d5c3dbf1Smrg esac 8361d5c3dbf1Smrg fi 8362cdbfa18aSmrg func_append tmp_libs " $deplib" 8363d5c3dbf1Smrg done # for deplib 8364d5c3dbf1Smrg continue 8365d5c3dbf1Smrg fi # $linkmode = prog... 8366d5c3dbf1Smrg 8367949d0342Smrg if test prog,link = "$linkmode,$pass"; then 8368d5c3dbf1Smrg if test -n "$library_names" && 8369949d0342Smrg { { test no = "$prefer_static_libs" || 8370949d0342Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8371d5c3dbf1Smrg test -z "$old_library"; }; then 8372d5c3dbf1Smrg # We need to hardcode the library path 8373949d0342Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374d5c3dbf1Smrg # Make sure the rpath contains only unique directories. 8375949d0342Smrg case $temp_rpath: in 8376d5c3dbf1Smrg *"$absdir:"*) ;; 8377cdbfa18aSmrg *) func_append temp_rpath "$absdir:" ;; 8378d5c3dbf1Smrg esac 8379d5c3dbf1Smrg fi 8380d5c3dbf1Smrg 8381d5c3dbf1Smrg # Hardcode the library path. 8382d5c3dbf1Smrg # Skip directories that are in the system default run-time 8383d5c3dbf1Smrg # search path. 8384d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8385d5c3dbf1Smrg *" $absdir "*) ;; 8386d5c3dbf1Smrg *) 8387d5c3dbf1Smrg case "$compile_rpath " in 8388d5c3dbf1Smrg *" $absdir "*) ;; 8389cdbfa18aSmrg *) func_append compile_rpath " $absdir" ;; 8390d5c3dbf1Smrg esac 8391d5c3dbf1Smrg ;; 8392d5c3dbf1Smrg esac 8393d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8394d5c3dbf1Smrg *" $libdir "*) ;; 8395d5c3dbf1Smrg *) 8396d5c3dbf1Smrg case "$finalize_rpath " in 8397d5c3dbf1Smrg *" $libdir "*) ;; 8398cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 8399d5c3dbf1Smrg esac 8400d5c3dbf1Smrg ;; 8401d5c3dbf1Smrg esac 8402d5c3dbf1Smrg fi # $linkmode,$pass = prog,link... 8403d5c3dbf1Smrg 8404949d0342Smrg if $alldeplibs && 8405949d0342Smrg { test pass_all = "$deplibs_check_method" || 8406949d0342Smrg { test yes = "$build_libtool_libs" && 8407d5c3dbf1Smrg test -n "$library_names"; }; }; then 8408d5c3dbf1Smrg # We only need to search for static libraries 8409d5c3dbf1Smrg continue 8410d5c3dbf1Smrg fi 8411d5c3dbf1Smrg fi 8412d5c3dbf1Smrg 8413d5c3dbf1Smrg link_static=no # Whether the deplib will be linked statically 8414d5c3dbf1Smrg use_static_libs=$prefer_static_libs 8415949d0342Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416d5c3dbf1Smrg use_static_libs=no 8417d5c3dbf1Smrg fi 8418d5c3dbf1Smrg if test -n "$library_names" && 8419949d0342Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420d5c3dbf1Smrg case $host in 8421949d0342Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422d5c3dbf1Smrg # No point in relinking DLLs because paths are not encoded 8423cdbfa18aSmrg func_append notinst_deplibs " $lib" 8424d5c3dbf1Smrg need_relink=no 8425d5c3dbf1Smrg ;; 8426d5c3dbf1Smrg *) 8427949d0342Smrg if test no = "$installed"; then 8428cdbfa18aSmrg func_append notinst_deplibs " $lib" 8429d5c3dbf1Smrg need_relink=yes 8430d5c3dbf1Smrg fi 8431d5c3dbf1Smrg ;; 8432d5c3dbf1Smrg esac 8433d5c3dbf1Smrg # This is a shared library 8434d5c3dbf1Smrg 8435d5c3dbf1Smrg # Warn about portability, can't link against -module's on some 8436d5c3dbf1Smrg # systems (darwin). Don't bleat about dlopened modules though! 8437949d0342Smrg dlopenmodule= 8438d5c3dbf1Smrg for dlpremoduletest in $dlprefiles; do 8439d5c3dbf1Smrg if test "X$dlpremoduletest" = "X$lib"; then 8440949d0342Smrg dlopenmodule=$dlpremoduletest 8441d5c3dbf1Smrg break 8442d5c3dbf1Smrg fi 8443d5c3dbf1Smrg done 8444949d0342Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445d5c3dbf1Smrg echo 8446949d0342Smrg if test prog = "$linkmode"; then 8447d5c3dbf1Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448d5c3dbf1Smrg else 8449d5c3dbf1Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450d5c3dbf1Smrg fi 8451d5c3dbf1Smrg $ECHO "*** $linklib is not portable!" 8452d5c3dbf1Smrg fi 8453949d0342Smrg if test lib = "$linkmode" && 8454949d0342Smrg test yes = "$hardcode_into_libs"; then 8455d5c3dbf1Smrg # Hardcode the library path. 8456d5c3dbf1Smrg # Skip directories that are in the system default run-time 8457d5c3dbf1Smrg # search path. 8458d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8459d5c3dbf1Smrg *" $absdir "*) ;; 8460d5c3dbf1Smrg *) 8461d5c3dbf1Smrg case "$compile_rpath " in 8462d5c3dbf1Smrg *" $absdir "*) ;; 8463cdbfa18aSmrg *) func_append compile_rpath " $absdir" ;; 8464d5c3dbf1Smrg esac 8465d5c3dbf1Smrg ;; 8466d5c3dbf1Smrg esac 8467d5c3dbf1Smrg case " $sys_lib_dlsearch_path " in 8468d5c3dbf1Smrg *" $libdir "*) ;; 8469d5c3dbf1Smrg *) 8470d5c3dbf1Smrg case "$finalize_rpath " in 8471d5c3dbf1Smrg *" $libdir "*) ;; 8472cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 8473d5c3dbf1Smrg esac 8474d5c3dbf1Smrg ;; 8475d5c3dbf1Smrg esac 8476d5c3dbf1Smrg fi 8477d5c3dbf1Smrg 8478d5c3dbf1Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8479d5c3dbf1Smrg # figure out the soname 8480d5c3dbf1Smrg set dummy $library_names 8481d5c3dbf1Smrg shift 8482949d0342Smrg realname=$1 8483d5c3dbf1Smrg shift 8484d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485d5c3dbf1Smrg # use dlname if we got it. it's perfectly good, no? 8486d5c3dbf1Smrg if test -n "$dlname"; then 8487949d0342Smrg soname=$dlname 8488d5c3dbf1Smrg elif test -n "$soname_spec"; then 8489d5c3dbf1Smrg # bleh windows 8490d5c3dbf1Smrg case $host in 8491949d0342Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8492d5c3dbf1Smrg func_arith $current - $age 8493d5c3dbf1Smrg major=$func_arith_result 8494949d0342Smrg versuffix=-$major 8495d5c3dbf1Smrg ;; 8496d5c3dbf1Smrg esac 8497d5c3dbf1Smrg eval soname=\"$soname_spec\" 8498d5c3dbf1Smrg else 8499949d0342Smrg soname=$realname 8500d5c3dbf1Smrg fi 8501d5c3dbf1Smrg 8502d5c3dbf1Smrg # Make a new name for the extract_expsyms_cmds to use 8503949d0342Smrg soroot=$soname 8504d5c3dbf1Smrg func_basename "$soroot" 8505949d0342Smrg soname=$func_basename_result 8506d5c3dbf1Smrg func_stripname 'lib' '.dll' "$soname" 8507d5c3dbf1Smrg newlib=libimp-$func_stripname_result.a 8508d5c3dbf1Smrg 8509d5c3dbf1Smrg # If the library has no export list, then create one now 8510d5c3dbf1Smrg if test -f "$output_objdir/$soname-def"; then : 8511d5c3dbf1Smrg else 8512949d0342Smrg func_verbose "extracting exported symbol list from '$soname'" 8513d5c3dbf1Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514d5c3dbf1Smrg fi 8515d5c3dbf1Smrg 8516d5c3dbf1Smrg # Create $newlib 8517d5c3dbf1Smrg if test -f "$output_objdir/$newlib"; then :; else 8518949d0342Smrg func_verbose "generating import library for '$soname'" 8519d5c3dbf1Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520d5c3dbf1Smrg fi 8521d5c3dbf1Smrg # make sure the library variables are pointing to the new library 8522d5c3dbf1Smrg dir=$output_objdir 8523d5c3dbf1Smrg linklib=$newlib 8524d5c3dbf1Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8525d5c3dbf1Smrg 8526949d0342Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527d5c3dbf1Smrg add_shlibpath= 8528d5c3dbf1Smrg add_dir= 8529d5c3dbf1Smrg add= 8530d5c3dbf1Smrg lib_linked=yes 8531d5c3dbf1Smrg case $hardcode_action in 8532d5c3dbf1Smrg immediate | unsupported) 8533949d0342Smrg if test no = "$hardcode_direct"; then 8534949d0342Smrg add=$dir/$linklib 8535d5c3dbf1Smrg case $host in 8536949d0342Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8537949d0342Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538d5c3dbf1Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8539949d0342Smrg *-*-unixware7*) add_dir=-L$dir ;; 8540d5c3dbf1Smrg *-*-darwin* ) 8541949d0342Smrg # if the lib is a (non-dlopened) module then we cannot 8542d5c3dbf1Smrg # link against it, someone is ignoring the earlier warnings 8543d5c3dbf1Smrg if /usr/bin/file -L $add 2> /dev/null | 8544949d0342Smrg $GREP ": [^:]* bundle" >/dev/null; then 8545d5c3dbf1Smrg if test "X$dlopenmodule" != "X$lib"; then 8546d5c3dbf1Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8547949d0342Smrg if test -z "$old_library"; then 8548d5c3dbf1Smrg echo 8549d5c3dbf1Smrg echo "*** And there doesn't seem to be a static archive available" 8550d5c3dbf1Smrg echo "*** The link will probably fail, sorry" 8551d5c3dbf1Smrg else 8552949d0342Smrg add=$dir/$old_library 8553d5c3dbf1Smrg fi 8554d5c3dbf1Smrg elif test -n "$old_library"; then 8555949d0342Smrg add=$dir/$old_library 8556d5c3dbf1Smrg fi 8557d5c3dbf1Smrg fi 8558d5c3dbf1Smrg esac 8559949d0342Smrg elif test no = "$hardcode_minus_L"; then 8560d5c3dbf1Smrg case $host in 8561949d0342Smrg *-*-sunos*) add_shlibpath=$dir ;; 8562d5c3dbf1Smrg esac 8563949d0342Smrg add_dir=-L$dir 8564949d0342Smrg add=-l$name 8565949d0342Smrg elif test no = "$hardcode_shlibpath_var"; then 8566949d0342Smrg add_shlibpath=$dir 8567949d0342Smrg add=-l$name 8568d5c3dbf1Smrg else 8569d5c3dbf1Smrg lib_linked=no 8570d5c3dbf1Smrg fi 8571d5c3dbf1Smrg ;; 8572d5c3dbf1Smrg relink) 8573949d0342Smrg if test yes = "$hardcode_direct" && 8574949d0342Smrg test no = "$hardcode_direct_absolute"; then 8575949d0342Smrg add=$dir/$linklib 8576949d0342Smrg elif test yes = "$hardcode_minus_L"; then 8577949d0342Smrg add_dir=-L$absdir 8578d5c3dbf1Smrg # Try looking first in the location we're being installed to. 8579d5c3dbf1Smrg if test -n "$inst_prefix_dir"; then 8580d5c3dbf1Smrg case $libdir in 8581d5c3dbf1Smrg [\\/]*) 8582cdbfa18aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583d5c3dbf1Smrg ;; 8584d5c3dbf1Smrg esac 8585d5c3dbf1Smrg fi 8586949d0342Smrg add=-l$name 8587949d0342Smrg elif test yes = "$hardcode_shlibpath_var"; then 8588949d0342Smrg add_shlibpath=$dir 8589949d0342Smrg add=-l$name 8590d5c3dbf1Smrg else 8591d5c3dbf1Smrg lib_linked=no 8592d5c3dbf1Smrg fi 8593d5c3dbf1Smrg ;; 8594d5c3dbf1Smrg *) lib_linked=no ;; 8595d5c3dbf1Smrg esac 8596d5c3dbf1Smrg 8597949d0342Smrg if test yes != "$lib_linked"; then 8598d5c3dbf1Smrg func_fatal_configuration "unsupported hardcode properties" 8599d5c3dbf1Smrg fi 8600d5c3dbf1Smrg 8601d5c3dbf1Smrg if test -n "$add_shlibpath"; then 8602d5c3dbf1Smrg case :$compile_shlibpath: in 8603d5c3dbf1Smrg *":$add_shlibpath:"*) ;; 8604cdbfa18aSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605d5c3dbf1Smrg esac 8606d5c3dbf1Smrg fi 8607949d0342Smrg if test prog = "$linkmode"; then 8608d5c3dbf1Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609d5c3dbf1Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610d5c3dbf1Smrg else 8611d5c3dbf1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612d5c3dbf1Smrg test -n "$add" && deplibs="$add $deplibs" 8613949d0342Smrg if test yes != "$hardcode_direct" && 8614949d0342Smrg test yes != "$hardcode_minus_L" && 8615949d0342Smrg test yes = "$hardcode_shlibpath_var"; then 8616d5c3dbf1Smrg case :$finalize_shlibpath: in 8617d5c3dbf1Smrg *":$libdir:"*) ;; 8618cdbfa18aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8619d5c3dbf1Smrg esac 8620d5c3dbf1Smrg fi 8621d5c3dbf1Smrg fi 8622d5c3dbf1Smrg fi 8623d5c3dbf1Smrg 8624949d0342Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625d5c3dbf1Smrg add_shlibpath= 8626d5c3dbf1Smrg add_dir= 8627d5c3dbf1Smrg add= 8628d5c3dbf1Smrg # Finalize command for both is simple: just hardcode it. 8629949d0342Smrg if test yes = "$hardcode_direct" && 8630949d0342Smrg test no = "$hardcode_direct_absolute"; then 8631949d0342Smrg add=$libdir/$linklib 8632949d0342Smrg elif test yes = "$hardcode_minus_L"; then 8633949d0342Smrg add_dir=-L$libdir 8634949d0342Smrg add=-l$name 8635949d0342Smrg elif test yes = "$hardcode_shlibpath_var"; then 8636d5c3dbf1Smrg case :$finalize_shlibpath: in 8637d5c3dbf1Smrg *":$libdir:"*) ;; 8638cdbfa18aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8639d5c3dbf1Smrg esac 8640949d0342Smrg add=-l$name 8641949d0342Smrg elif test yes = "$hardcode_automatic"; then 8642d5c3dbf1Smrg if test -n "$inst_prefix_dir" && 8643949d0342Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8644949d0342Smrg add=$inst_prefix_dir$libdir/$linklib 8645d5c3dbf1Smrg else 8646949d0342Smrg add=$libdir/$linklib 8647d5c3dbf1Smrg fi 8648d5c3dbf1Smrg else 8649d5c3dbf1Smrg # We cannot seem to hardcode it, guess we'll fake it. 8650949d0342Smrg add_dir=-L$libdir 8651d5c3dbf1Smrg # Try looking first in the location we're being installed to. 8652d5c3dbf1Smrg if test -n "$inst_prefix_dir"; then 8653d5c3dbf1Smrg case $libdir in 8654d5c3dbf1Smrg [\\/]*) 8655cdbfa18aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656d5c3dbf1Smrg ;; 8657d5c3dbf1Smrg esac 8658d5c3dbf1Smrg fi 8659949d0342Smrg add=-l$name 8660d5c3dbf1Smrg fi 8661d5c3dbf1Smrg 8662949d0342Smrg if test prog = "$linkmode"; then 8663d5c3dbf1Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664d5c3dbf1Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665d5c3dbf1Smrg else 8666d5c3dbf1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667d5c3dbf1Smrg test -n "$add" && deplibs="$add $deplibs" 8668d5c3dbf1Smrg fi 8669d5c3dbf1Smrg fi 8670949d0342Smrg elif test prog = "$linkmode"; then 8671d5c3dbf1Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672d5c3dbf1Smrg # is not unsupported. This is valid on all known static and 8673d5c3dbf1Smrg # shared platforms. 8674949d0342Smrg if test unsupported != "$hardcode_direct"; then 8675949d0342Smrg test -n "$old_library" && linklib=$old_library 8676d5c3dbf1Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677d5c3dbf1Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678d5c3dbf1Smrg else 8679d5c3dbf1Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680d5c3dbf1Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681d5c3dbf1Smrg fi 8682949d0342Smrg elif test yes = "$build_libtool_libs"; then 8683d5c3dbf1Smrg # Not a shared library 8684949d0342Smrg if test pass_all != "$deplibs_check_method"; then 8685d5c3dbf1Smrg # We're trying link a shared library against a static one 8686d5c3dbf1Smrg # but the system doesn't support it. 8687d5c3dbf1Smrg 8688d5c3dbf1Smrg # Just print a warning and add the library to dependency_libs so 8689d5c3dbf1Smrg # that the program can be linked against the static library. 8690d5c3dbf1Smrg echo 8691949d0342Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692d5c3dbf1Smrg echo "*** I have the capability to make that library automatically link in when" 8693d5c3dbf1Smrg echo "*** you link to this library. But I can only do this if you have a" 8694d5c3dbf1Smrg echo "*** shared version of the library, which you do not appear to have." 8695949d0342Smrg if test yes = "$module"; then 8696d5c3dbf1Smrg echo "*** But as you try to build a module library, libtool will still create " 8697d5c3dbf1Smrg echo "*** a static module, that should work as long as the dlopening application" 8698d5c3dbf1Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699d5c3dbf1Smrg if test -z "$global_symbol_pipe"; then 8700d5c3dbf1Smrg echo 8701d5c3dbf1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8702949d0342Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703d5c3dbf1Smrg echo "*** not find such a program. So, this module is probably useless." 8704949d0342Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705d5c3dbf1Smrg fi 8706949d0342Smrg if test no = "$build_old_libs"; then 8707d5c3dbf1Smrg build_libtool_libs=module 8708d5c3dbf1Smrg build_old_libs=yes 8709d5c3dbf1Smrg else 8710d5c3dbf1Smrg build_libtool_libs=no 8711d5c3dbf1Smrg fi 8712d5c3dbf1Smrg fi 8713d5c3dbf1Smrg else 8714d5c3dbf1Smrg deplibs="$dir/$old_library $deplibs" 8715d5c3dbf1Smrg link_static=yes 8716d5c3dbf1Smrg fi 8717d5c3dbf1Smrg fi # link shared/static library? 8718d5c3dbf1Smrg 8719949d0342Smrg if test lib = "$linkmode"; then 8720d5c3dbf1Smrg if test -n "$dependency_libs" && 8721949d0342Smrg { test yes != "$hardcode_into_libs" || 8722949d0342Smrg test yes = "$build_old_libs" || 8723949d0342Smrg test yes = "$link_static"; }; then 8724d5c3dbf1Smrg # Extract -R from dependency_libs 8725d5c3dbf1Smrg temp_deplibs= 8726d5c3dbf1Smrg for libdir in $dependency_libs; do 8727d5c3dbf1Smrg case $libdir in 8728d5c3dbf1Smrg -R*) func_stripname '-R' '' "$libdir" 8729d5c3dbf1Smrg temp_xrpath=$func_stripname_result 8730d5c3dbf1Smrg case " $xrpath " in 8731d5c3dbf1Smrg *" $temp_xrpath "*) ;; 8732cdbfa18aSmrg *) func_append xrpath " $temp_xrpath";; 8733d5c3dbf1Smrg esac;; 8734cdbfa18aSmrg *) func_append temp_deplibs " $libdir";; 8735d5c3dbf1Smrg esac 8736d5c3dbf1Smrg done 8737949d0342Smrg dependency_libs=$temp_deplibs 8738d5c3dbf1Smrg fi 8739d5c3dbf1Smrg 8740cdbfa18aSmrg func_append newlib_search_path " $absdir" 8741d5c3dbf1Smrg # Link against this library 8742949d0342Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743d5c3dbf1Smrg # ... and its dependency_libs 8744d5c3dbf1Smrg tmp_libs= 8745d5c3dbf1Smrg for deplib in $dependency_libs; do 8746d5c3dbf1Smrg newdependency_libs="$deplib $newdependency_libs" 8747cdbfa18aSmrg case $deplib in 8748cdbfa18aSmrg -L*) func_stripname '-L' '' "$deplib" 8749cdbfa18aSmrg func_resolve_sysroot "$func_stripname_result";; 8750cdbfa18aSmrg *) func_resolve_sysroot "$deplib" ;; 8751cdbfa18aSmrg esac 8752949d0342Smrg if $opt_preserve_dup_deps; then 8753d5c3dbf1Smrg case "$tmp_libs " in 8754cdbfa18aSmrg *" $func_resolve_sysroot_result "*) 8755cdbfa18aSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756d5c3dbf1Smrg esac 8757d5c3dbf1Smrg fi 8758cdbfa18aSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8759d5c3dbf1Smrg done 8760d5c3dbf1Smrg 8761949d0342Smrg if test no != "$link_all_deplibs"; then 8762d5c3dbf1Smrg # Add the search paths of all dependency libraries 8763d5c3dbf1Smrg for deplib in $dependency_libs; do 8764d5c3dbf1Smrg path= 8765d5c3dbf1Smrg case $deplib in 8766949d0342Smrg -L*) path=$deplib ;; 8767d5c3dbf1Smrg *.la) 8768cdbfa18aSmrg func_resolve_sysroot "$deplib" 8769cdbfa18aSmrg deplib=$func_resolve_sysroot_result 8770d5c3dbf1Smrg func_dirname "$deplib" "" "." 8771cdbfa18aSmrg dir=$func_dirname_result 8772d5c3dbf1Smrg # We need an absolute path. 8773d5c3dbf1Smrg case $dir in 8774949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775d5c3dbf1Smrg *) 8776d5c3dbf1Smrg absdir=`cd "$dir" && pwd` 8777d5c3dbf1Smrg if test -z "$absdir"; then 8778949d0342Smrg func_warning "cannot determine absolute directory name of '$dir'" 8779949d0342Smrg absdir=$dir 8780d5c3dbf1Smrg fi 8781d5c3dbf1Smrg ;; 8782d5c3dbf1Smrg esac 8783d5c3dbf1Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8784d5c3dbf1Smrg case $host in 8785d5c3dbf1Smrg *-*-darwin*) 8786d5c3dbf1Smrg depdepl= 8787949d0342Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8788949d0342Smrg if test -n "$deplibrary_names"; then 8789949d0342Smrg for tmp in $deplibrary_names; do 8790d5c3dbf1Smrg depdepl=$tmp 8791d5c3dbf1Smrg done 8792949d0342Smrg if test -f "$absdir/$objdir/$depdepl"; then 8793949d0342Smrg depdepl=$absdir/$objdir/$depdepl 8794949d0342Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795d5c3dbf1Smrg if test -z "$darwin_install_name"; then 8796949d0342Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797d5c3dbf1Smrg fi 8798949d0342Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8799949d0342Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800d5c3dbf1Smrg path= 8801d5c3dbf1Smrg fi 8802d5c3dbf1Smrg fi 8803d5c3dbf1Smrg ;; 8804d5c3dbf1Smrg *) 8805949d0342Smrg path=-L$absdir/$objdir 8806d5c3dbf1Smrg ;; 8807d5c3dbf1Smrg esac 8808d5c3dbf1Smrg else 8809949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810d5c3dbf1Smrg test -z "$libdir" && \ 8811949d0342Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812d5c3dbf1Smrg test "$absdir" != "$libdir" && \ 8813949d0342Smrg func_warning "'$deplib' seems to be moved" 8814d5c3dbf1Smrg 8815949d0342Smrg path=-L$absdir 8816d5c3dbf1Smrg fi 8817d5c3dbf1Smrg ;; 8818d5c3dbf1Smrg esac 8819d5c3dbf1Smrg case " $deplibs " in 8820d5c3dbf1Smrg *" $path "*) ;; 8821d5c3dbf1Smrg *) deplibs="$path $deplibs" ;; 8822d5c3dbf1Smrg esac 8823d5c3dbf1Smrg done 8824d5c3dbf1Smrg fi # link_all_deplibs != no 8825d5c3dbf1Smrg fi # linkmode = lib 8826d5c3dbf1Smrg done # for deplib in $libs 8827949d0342Smrg if test link = "$pass"; then 8828949d0342Smrg if test prog = "$linkmode"; then 8829d5c3dbf1Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830d5c3dbf1Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831d5c3dbf1Smrg else 8832d5c3dbf1Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833d5c3dbf1Smrg fi 8834d5c3dbf1Smrg fi 8835949d0342Smrg dependency_libs=$newdependency_libs 8836949d0342Smrg if test dlpreopen = "$pass"; then 8837d5c3dbf1Smrg # Link the dlpreopened libraries before other libraries 8838d5c3dbf1Smrg for deplib in $save_deplibs; do 8839d5c3dbf1Smrg deplibs="$deplib $deplibs" 8840d5c3dbf1Smrg done 8841d5c3dbf1Smrg fi 8842949d0342Smrg if test dlopen != "$pass"; then 8843949d0342Smrg test conv = "$pass" || { 8844d5c3dbf1Smrg # Make sure lib_search_path contains only unique directories. 8845d5c3dbf1Smrg lib_search_path= 8846d5c3dbf1Smrg for dir in $newlib_search_path; do 8847d5c3dbf1Smrg case "$lib_search_path " in 8848d5c3dbf1Smrg *" $dir "*) ;; 8849cdbfa18aSmrg *) func_append lib_search_path " $dir" ;; 8850d5c3dbf1Smrg esac 8851d5c3dbf1Smrg done 8852d5c3dbf1Smrg newlib_search_path= 8853949d0342Smrg } 8854d5c3dbf1Smrg 8855949d0342Smrg if test prog,link = "$linkmode,$pass"; then 8856d5c3dbf1Smrg vars="compile_deplibs finalize_deplibs" 8857949d0342Smrg else 8858949d0342Smrg vars=deplibs 8859d5c3dbf1Smrg fi 8860d5c3dbf1Smrg for var in $vars dependency_libs; do 8861d5c3dbf1Smrg # Add libraries to $var in reverse order 8862d5c3dbf1Smrg eval tmp_libs=\"\$$var\" 8863d5c3dbf1Smrg new_libs= 8864d5c3dbf1Smrg for deplib in $tmp_libs; do 8865d5c3dbf1Smrg # FIXME: Pedantically, this is the right thing to do, so 8866d5c3dbf1Smrg # that some nasty dependency loop isn't accidentally 8867d5c3dbf1Smrg # broken: 8868d5c3dbf1Smrg #new_libs="$deplib $new_libs" 8869d5c3dbf1Smrg # Pragmatically, this seems to cause very few problems in 8870d5c3dbf1Smrg # practice: 8871d5c3dbf1Smrg case $deplib in 8872d5c3dbf1Smrg -L*) new_libs="$deplib $new_libs" ;; 8873d5c3dbf1Smrg -R*) ;; 8874d5c3dbf1Smrg *) 8875d5c3dbf1Smrg # And here is the reason: when a library appears more 8876d5c3dbf1Smrg # than once as an explicit dependence of a library, or 8877d5c3dbf1Smrg # is implicitly linked in more than once by the 8878d5c3dbf1Smrg # compiler, it is considered special, and multiple 8879d5c3dbf1Smrg # occurrences thereof are not removed. Compare this 8880d5c3dbf1Smrg # with having the same library being listed as a 8881d5c3dbf1Smrg # dependency of multiple other libraries: in this case, 8882d5c3dbf1Smrg # we know (pedantically, we assume) the library does not 8883d5c3dbf1Smrg # need to be listed more than once, so we keep only the 8884d5c3dbf1Smrg # last copy. This is not always right, but it is rare 8885d5c3dbf1Smrg # enough that we require users that really mean to play 8886d5c3dbf1Smrg # such unportable linking tricks to link the library 8887d5c3dbf1Smrg # using -Wl,-lname, so that libtool does not consider it 8888d5c3dbf1Smrg # for duplicate removal. 8889d5c3dbf1Smrg case " $specialdeplibs " in 8890d5c3dbf1Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891d5c3dbf1Smrg *) 8892d5c3dbf1Smrg case " $new_libs " in 8893d5c3dbf1Smrg *" $deplib "*) ;; 8894d5c3dbf1Smrg *) new_libs="$deplib $new_libs" ;; 8895d5c3dbf1Smrg esac 8896d5c3dbf1Smrg ;; 8897d5c3dbf1Smrg esac 8898d5c3dbf1Smrg ;; 8899d5c3dbf1Smrg esac 8900d5c3dbf1Smrg done 8901d5c3dbf1Smrg tmp_libs= 8902d5c3dbf1Smrg for deplib in $new_libs; do 8903d5c3dbf1Smrg case $deplib in 8904d5c3dbf1Smrg -L*) 8905d5c3dbf1Smrg case " $tmp_libs " in 8906d5c3dbf1Smrg *" $deplib "*) ;; 8907cdbfa18aSmrg *) func_append tmp_libs " $deplib" ;; 8908d5c3dbf1Smrg esac 8909d5c3dbf1Smrg ;; 8910cdbfa18aSmrg *) func_append tmp_libs " $deplib" ;; 8911d5c3dbf1Smrg esac 8912d5c3dbf1Smrg done 8913d5c3dbf1Smrg eval $var=\"$tmp_libs\" 8914d5c3dbf1Smrg done # for var 8915d5c3dbf1Smrg fi 8916949d0342Smrg 8917949d0342Smrg # Add Sun CC postdeps if required: 8918949d0342Smrg test CXX = "$tagname" && { 8919949d0342Smrg case $host_os in 8920949d0342Smrg linux*) 8921949d0342Smrg case `$CC -V 2>&1 | $SED 5q` in 8922949d0342Smrg *Sun\ C*) # Sun C++ 5.9 8923949d0342Smrg func_suncc_cstd_abi 8924949d0342Smrg 8925949d0342Smrg if test no != "$suncc_use_cstd_abi"; then 8926949d0342Smrg func_append postdeps ' -library=Cstd -library=Crun' 8927949d0342Smrg fi 8928949d0342Smrg ;; 8929949d0342Smrg esac 8930949d0342Smrg ;; 8931949d0342Smrg 8932949d0342Smrg solaris*) 8933949d0342Smrg func_cc_basename "$CC" 8934949d0342Smrg case $func_cc_basename_result in 8935949d0342Smrg CC* | sunCC*) 8936949d0342Smrg func_suncc_cstd_abi 8937949d0342Smrg 8938949d0342Smrg if test no != "$suncc_use_cstd_abi"; then 8939949d0342Smrg func_append postdeps ' -library=Cstd -library=Crun' 8940949d0342Smrg fi 8941949d0342Smrg ;; 8942949d0342Smrg esac 8943949d0342Smrg ;; 8944949d0342Smrg esac 8945949d0342Smrg } 8946949d0342Smrg 8947d5c3dbf1Smrg # Last step: remove runtime libs from dependency_libs 8948d5c3dbf1Smrg # (they stay in deplibs) 8949d5c3dbf1Smrg tmp_libs= 8950949d0342Smrg for i in $dependency_libs; do 8951d5c3dbf1Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8952d5c3dbf1Smrg *" $i "*) 8953949d0342Smrg i= 8954d5c3dbf1Smrg ;; 8955d5c3dbf1Smrg esac 8956949d0342Smrg if test -n "$i"; then 8957cdbfa18aSmrg func_append tmp_libs " $i" 8958d5c3dbf1Smrg fi 8959d5c3dbf1Smrg done 8960d5c3dbf1Smrg dependency_libs=$tmp_libs 8961d5c3dbf1Smrg done # for pass 8962949d0342Smrg if test prog = "$linkmode"; then 8963949d0342Smrg dlfiles=$newdlfiles 8964d5c3dbf1Smrg fi 8965949d0342Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8966949d0342Smrg dlprefiles=$newdlprefiles 8967d5c3dbf1Smrg fi 8968d5c3dbf1Smrg 8969d5c3dbf1Smrg case $linkmode in 8970d5c3dbf1Smrg oldlib) 8971949d0342Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8972949d0342Smrg func_warning "'-dlopen' is ignored for archives" 8973d5c3dbf1Smrg fi 8974d5c3dbf1Smrg 8975d5c3dbf1Smrg case " $deplibs" in 8976d5c3dbf1Smrg *\ -l* | *\ -L*) 8977949d0342Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978d5c3dbf1Smrg esac 8979d5c3dbf1Smrg 8980d5c3dbf1Smrg test -n "$rpath" && \ 8981949d0342Smrg func_warning "'-rpath' is ignored for archives" 8982d5c3dbf1Smrg 8983d5c3dbf1Smrg test -n "$xrpath" && \ 8984949d0342Smrg func_warning "'-R' is ignored for archives" 8985d5c3dbf1Smrg 8986d5c3dbf1Smrg test -n "$vinfo" && \ 8987949d0342Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8988d5c3dbf1Smrg 8989d5c3dbf1Smrg test -n "$release" && \ 8990949d0342Smrg func_warning "'-release' is ignored for archives" 8991d5c3dbf1Smrg 8992d5c3dbf1Smrg test -n "$export_symbols$export_symbols_regex" && \ 8993949d0342Smrg func_warning "'-export-symbols' is ignored for archives" 8994d5c3dbf1Smrg 8995d5c3dbf1Smrg # Now set the variables for building old libraries. 8996d5c3dbf1Smrg build_libtool_libs=no 8997949d0342Smrg oldlibs=$output 8998cdbfa18aSmrg func_append objs "$old_deplibs" 8999d5c3dbf1Smrg ;; 9000d5c3dbf1Smrg 9001d5c3dbf1Smrg lib) 9002949d0342Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003d5c3dbf1Smrg case $outputname in 9004d5c3dbf1Smrg lib*) 9005d5c3dbf1Smrg func_stripname 'lib' '.la' "$outputname" 9006d5c3dbf1Smrg name=$func_stripname_result 9007d5c3dbf1Smrg eval shared_ext=\"$shrext_cmds\" 9008d5c3dbf1Smrg eval libname=\"$libname_spec\" 9009d5c3dbf1Smrg ;; 9010d5c3dbf1Smrg *) 9011949d0342Smrg test no = "$module" \ 9012949d0342Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013d5c3dbf1Smrg 9014949d0342Smrg if test no != "$need_lib_prefix"; then 9015d5c3dbf1Smrg # Add the "lib" prefix for modules if required 9016d5c3dbf1Smrg func_stripname '' '.la' "$outputname" 9017d5c3dbf1Smrg name=$func_stripname_result 9018d5c3dbf1Smrg eval shared_ext=\"$shrext_cmds\" 9019d5c3dbf1Smrg eval libname=\"$libname_spec\" 9020d5c3dbf1Smrg else 9021d5c3dbf1Smrg func_stripname '' '.la' "$outputname" 9022d5c3dbf1Smrg libname=$func_stripname_result 9023d5c3dbf1Smrg fi 9024d5c3dbf1Smrg ;; 9025d5c3dbf1Smrg esac 9026d5c3dbf1Smrg 9027d5c3dbf1Smrg if test -n "$objs"; then 9028949d0342Smrg if test pass_all != "$deplibs_check_method"; then 9029949d0342Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030d5c3dbf1Smrg else 9031d5c3dbf1Smrg echo 9032d5c3dbf1Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033d5c3dbf1Smrg $ECHO "*** objects $objs is not portable!" 9034cdbfa18aSmrg func_append libobjs " $objs" 9035d5c3dbf1Smrg fi 9036d5c3dbf1Smrg fi 9037d5c3dbf1Smrg 9038949d0342Smrg test no = "$dlself" \ 9039949d0342Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040d5c3dbf1Smrg 9041d5c3dbf1Smrg set dummy $rpath 9042d5c3dbf1Smrg shift 9043949d0342Smrg test 1 -lt "$#" \ 9044949d0342Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045d5c3dbf1Smrg 9046949d0342Smrg install_libdir=$1 9047d5c3dbf1Smrg 9048d5c3dbf1Smrg oldlibs= 9049d5c3dbf1Smrg if test -z "$rpath"; then 9050949d0342Smrg if test yes = "$build_libtool_libs"; then 9051d5c3dbf1Smrg # Building a libtool convenience library. 9052949d0342Smrg # Some compilers have problems with a '.al' extension so 9053d5c3dbf1Smrg # convenience libraries should have the same extension an 9054d5c3dbf1Smrg # archive normally would. 9055d5c3dbf1Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056d5c3dbf1Smrg build_libtool_libs=convenience 9057d5c3dbf1Smrg build_old_libs=yes 9058d5c3dbf1Smrg fi 9059d5c3dbf1Smrg 9060d5c3dbf1Smrg test -n "$vinfo" && \ 9061949d0342Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062d5c3dbf1Smrg 9063d5c3dbf1Smrg test -n "$release" && \ 9064949d0342Smrg func_warning "'-release' is ignored for convenience libraries" 9065d5c3dbf1Smrg else 9066d5c3dbf1Smrg 9067d5c3dbf1Smrg # Parse the version information argument. 9068949d0342Smrg save_ifs=$IFS; IFS=: 9069d5c3dbf1Smrg set dummy $vinfo 0 0 0 9070d5c3dbf1Smrg shift 9071949d0342Smrg IFS=$save_ifs 9072d5c3dbf1Smrg 9073d5c3dbf1Smrg test -n "$7" && \ 9074949d0342Smrg func_fatal_help "too many parameters to '-version-info'" 9075d5c3dbf1Smrg 9076d5c3dbf1Smrg # convert absolute version numbers to libtool ages 9077d5c3dbf1Smrg # this retains compatibility with .la files and attempts 9078d5c3dbf1Smrg # to make the code below a bit more comprehensible 9079d5c3dbf1Smrg 9080d5c3dbf1Smrg case $vinfo_number in 9081d5c3dbf1Smrg yes) 9082949d0342Smrg number_major=$1 9083949d0342Smrg number_minor=$2 9084949d0342Smrg number_revision=$3 9085d5c3dbf1Smrg # 9086d5c3dbf1Smrg # There are really only two kinds -- those that 9087d5c3dbf1Smrg # use the current revision as the major version 9088d5c3dbf1Smrg # and those that subtract age and use age as 9089d5c3dbf1Smrg # a minor version. But, then there is irix 9090949d0342Smrg # that has an extra 1 added just for fun 9091d5c3dbf1Smrg # 9092d5c3dbf1Smrg case $version_type in 9093cdbfa18aSmrg # correct linux to gnu/linux during the next big refactor 9094949d0342Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095d5c3dbf1Smrg func_arith $number_major + $number_minor 9096d5c3dbf1Smrg current=$func_arith_result 9097949d0342Smrg age=$number_minor 9098949d0342Smrg revision=$number_revision 9099d5c3dbf1Smrg ;; 9100949d0342Smrg freebsd-aout|qnx|sunos) 9101949d0342Smrg current=$number_major 9102949d0342Smrg revision=$number_minor 9103949d0342Smrg age=0 9104d5c3dbf1Smrg ;; 9105d5c3dbf1Smrg irix|nonstopux) 9106d5c3dbf1Smrg func_arith $number_major + $number_minor 9107d5c3dbf1Smrg current=$func_arith_result 9108949d0342Smrg age=$number_minor 9109949d0342Smrg revision=$number_minor 9110d5c3dbf1Smrg lt_irix_increment=no 9111d5c3dbf1Smrg ;; 9112d5c3dbf1Smrg esac 9113d5c3dbf1Smrg ;; 9114d5c3dbf1Smrg no) 9115949d0342Smrg current=$1 9116949d0342Smrg revision=$2 9117949d0342Smrg age=$3 9118d5c3dbf1Smrg ;; 9119d5c3dbf1Smrg esac 9120d5c3dbf1Smrg 9121d5c3dbf1Smrg # Check that each of the things are valid numbers. 9122d5c3dbf1Smrg case $current in 9123d5c3dbf1Smrg 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]) ;; 9124d5c3dbf1Smrg *) 9125949d0342Smrg func_error "CURRENT '$current' must be a nonnegative integer" 9126949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9127d5c3dbf1Smrg ;; 9128d5c3dbf1Smrg esac 9129d5c3dbf1Smrg 9130d5c3dbf1Smrg case $revision in 9131d5c3dbf1Smrg 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]) ;; 9132d5c3dbf1Smrg *) 9133949d0342Smrg func_error "REVISION '$revision' must be a nonnegative integer" 9134949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9135d5c3dbf1Smrg ;; 9136d5c3dbf1Smrg esac 9137d5c3dbf1Smrg 9138d5c3dbf1Smrg case $age in 9139d5c3dbf1Smrg 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]) ;; 9140d5c3dbf1Smrg *) 9141949d0342Smrg func_error "AGE '$age' must be a nonnegative integer" 9142949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9143d5c3dbf1Smrg ;; 9144d5c3dbf1Smrg esac 9145d5c3dbf1Smrg 9146d5c3dbf1Smrg if test "$age" -gt "$current"; then 9147949d0342Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 9148949d0342Smrg func_fatal_error "'$vinfo' is not valid version information" 9149d5c3dbf1Smrg fi 9150d5c3dbf1Smrg 9151d5c3dbf1Smrg # Calculate the version variables. 9152d5c3dbf1Smrg major= 9153d5c3dbf1Smrg versuffix= 9154d5c3dbf1Smrg verstring= 9155d5c3dbf1Smrg case $version_type in 9156d5c3dbf1Smrg none) ;; 9157d5c3dbf1Smrg 9158d5c3dbf1Smrg darwin) 9159d5c3dbf1Smrg # Like Linux, but with the current version available in 9160d5c3dbf1Smrg # verstring for coding it into the library header 9161d5c3dbf1Smrg func_arith $current - $age 9162d5c3dbf1Smrg major=.$func_arith_result 9163949d0342Smrg versuffix=$major.$age.$revision 9164d5c3dbf1Smrg # Darwin ld doesn't like 0 for these options... 9165d5c3dbf1Smrg func_arith $current + 1 9166d5c3dbf1Smrg minor_current=$func_arith_result 9167949d0342Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168d5c3dbf1Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9169949d0342Smrg # On Darwin other compilers 9170949d0342Smrg case $CC in 9171949d0342Smrg nagfor*) 9172949d0342Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9173949d0342Smrg ;; 9174949d0342Smrg *) 9175949d0342Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9176949d0342Smrg ;; 9177949d0342Smrg esac 9178d5c3dbf1Smrg ;; 9179d5c3dbf1Smrg 9180d5c3dbf1Smrg freebsd-aout) 9181949d0342Smrg major=.$current 9182949d0342Smrg versuffix=.$current.$revision 9183d5c3dbf1Smrg ;; 9184d5c3dbf1Smrg 9185949d0342Smrg freebsd-elf | midnightbsd-elf) 9186949d0342Smrg func_arith $current - $age 9187949d0342Smrg major=.$func_arith_result 9188949d0342Smrg versuffix=$major.$age.$revision 9189d5c3dbf1Smrg ;; 9190d5c3dbf1Smrg 9191d5c3dbf1Smrg irix | nonstopux) 9192949d0342Smrg if test no = "$lt_irix_increment"; then 9193d5c3dbf1Smrg func_arith $current - $age 9194d5c3dbf1Smrg else 9195d5c3dbf1Smrg func_arith $current - $age + 1 9196d5c3dbf1Smrg fi 9197d5c3dbf1Smrg major=$func_arith_result 9198d5c3dbf1Smrg 9199d5c3dbf1Smrg case $version_type in 9200d5c3dbf1Smrg nonstopux) verstring_prefix=nonstopux ;; 9201d5c3dbf1Smrg *) verstring_prefix=sgi ;; 9202d5c3dbf1Smrg esac 9203949d0342Smrg verstring=$verstring_prefix$major.$revision 9204d5c3dbf1Smrg 9205d5c3dbf1Smrg # Add in all the interfaces that we are compatible with. 9206d5c3dbf1Smrg loop=$revision 9207949d0342Smrg while test 0 -ne "$loop"; do 9208d5c3dbf1Smrg func_arith $revision - $loop 9209d5c3dbf1Smrg iface=$func_arith_result 9210d5c3dbf1Smrg func_arith $loop - 1 9211d5c3dbf1Smrg loop=$func_arith_result 9212949d0342Smrg verstring=$verstring_prefix$major.$iface:$verstring 9213d5c3dbf1Smrg done 9214d5c3dbf1Smrg 9215949d0342Smrg # Before this point, $major must not contain '.'. 9216d5c3dbf1Smrg major=.$major 9217949d0342Smrg versuffix=$major.$revision 9218d5c3dbf1Smrg ;; 9219d5c3dbf1Smrg 9220cdbfa18aSmrg linux) # correct to gnu/linux during the next big refactor 9221d5c3dbf1Smrg func_arith $current - $age 9222d5c3dbf1Smrg major=.$func_arith_result 9223949d0342Smrg versuffix=$major.$age.$revision 9224d5c3dbf1Smrg ;; 9225d5c3dbf1Smrg 9226d5c3dbf1Smrg osf) 9227d5c3dbf1Smrg func_arith $current - $age 9228d5c3dbf1Smrg major=.$func_arith_result 9229949d0342Smrg versuffix=.$current.$age.$revision 9230949d0342Smrg verstring=$current.$age.$revision 9231d5c3dbf1Smrg 9232d5c3dbf1Smrg # Add in all the interfaces that we are compatible with. 9233d5c3dbf1Smrg loop=$age 9234949d0342Smrg while test 0 -ne "$loop"; do 9235d5c3dbf1Smrg func_arith $current - $loop 9236d5c3dbf1Smrg iface=$func_arith_result 9237d5c3dbf1Smrg func_arith $loop - 1 9238d5c3dbf1Smrg loop=$func_arith_result 9239949d0342Smrg verstring=$verstring:$iface.0 9240d5c3dbf1Smrg done 9241d5c3dbf1Smrg 9242d5c3dbf1Smrg # Make executables depend on our current version. 9243949d0342Smrg func_append verstring ":$current.0" 9244d5c3dbf1Smrg ;; 9245d5c3dbf1Smrg 9246d5c3dbf1Smrg qnx) 9247949d0342Smrg major=.$current 9248949d0342Smrg versuffix=.$current 9249949d0342Smrg ;; 9250949d0342Smrg 9251949d0342Smrg sco) 9252949d0342Smrg major=.$current 9253949d0342Smrg versuffix=.$current 9254d5c3dbf1Smrg ;; 9255d5c3dbf1Smrg 9256d5c3dbf1Smrg sunos) 9257949d0342Smrg major=.$current 9258949d0342Smrg versuffix=.$current.$revision 9259d5c3dbf1Smrg ;; 9260d5c3dbf1Smrg 9261d5c3dbf1Smrg windows) 9262d5c3dbf1Smrg # Use '-' rather than '.', since we only want one 9263949d0342Smrg # extension on DOS 8.3 file systems. 9264d5c3dbf1Smrg func_arith $current - $age 9265d5c3dbf1Smrg major=$func_arith_result 9266949d0342Smrg versuffix=-$major 9267d5c3dbf1Smrg ;; 9268d5c3dbf1Smrg 9269d5c3dbf1Smrg *) 9270949d0342Smrg func_fatal_configuration "unknown library version type '$version_type'" 9271d5c3dbf1Smrg ;; 9272d5c3dbf1Smrg esac 9273d5c3dbf1Smrg 9274d5c3dbf1Smrg # Clear the version info if we defaulted, and they specified a release. 9275d5c3dbf1Smrg if test -z "$vinfo" && test -n "$release"; then 9276d5c3dbf1Smrg major= 9277d5c3dbf1Smrg case $version_type in 9278d5c3dbf1Smrg darwin) 9279d5c3dbf1Smrg # we can't check for "0.0" in archive_cmds due to quoting 9280d5c3dbf1Smrg # problems, so we reset it completely 9281d5c3dbf1Smrg verstring= 9282d5c3dbf1Smrg ;; 9283d5c3dbf1Smrg *) 9284949d0342Smrg verstring=0.0 9285d5c3dbf1Smrg ;; 9286d5c3dbf1Smrg esac 9287949d0342Smrg if test no = "$need_version"; then 9288d5c3dbf1Smrg versuffix= 9289d5c3dbf1Smrg else 9290949d0342Smrg versuffix=.0.0 9291d5c3dbf1Smrg fi 9292d5c3dbf1Smrg fi 9293d5c3dbf1Smrg 9294d5c3dbf1Smrg # Remove version info from name if versioning should be avoided 9295949d0342Smrg if test yes,no = "$avoid_version,$need_version"; then 9296d5c3dbf1Smrg major= 9297d5c3dbf1Smrg versuffix= 9298949d0342Smrg verstring= 9299d5c3dbf1Smrg fi 9300d5c3dbf1Smrg 9301d5c3dbf1Smrg # Check to see if the archive will have undefined symbols. 9302949d0342Smrg if test yes = "$allow_undefined"; then 9303949d0342Smrg if test unsupported = "$allow_undefined_flag"; then 9304949d0342Smrg if test yes = "$build_old_libs"; then 9305949d0342Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9306949d0342Smrg build_libtool_libs=no 9307949d0342Smrg else 9308949d0342Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9309949d0342Smrg fi 9310d5c3dbf1Smrg fi 9311d5c3dbf1Smrg else 9312d5c3dbf1Smrg # Don't allow undefined symbols. 9313949d0342Smrg allow_undefined_flag=$no_undefined_flag 9314d5c3dbf1Smrg fi 9315d5c3dbf1Smrg 9316d5c3dbf1Smrg fi 9317d5c3dbf1Smrg 9318949d0342Smrg func_generate_dlsyms "$libname" "$libname" : 9319cdbfa18aSmrg func_append libobjs " $symfileobj" 9320949d0342Smrg test " " = "$libobjs" && libobjs= 9321d5c3dbf1Smrg 9322949d0342Smrg if test relink != "$opt_mode"; then 9323d5c3dbf1Smrg # Remove our outputs, but don't remove object files since they 9324d5c3dbf1Smrg # may have been created when compiling PIC objects. 9325d5c3dbf1Smrg removelist= 9326d5c3dbf1Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9327d5c3dbf1Smrg for p in $tempremovelist; do 9328d5c3dbf1Smrg case $p in 9329d5c3dbf1Smrg *.$objext | *.gcno) 9330d5c3dbf1Smrg ;; 9331949d0342Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9332949d0342Smrg if test -n "$precious_files_regex"; then 9333d5c3dbf1Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334d5c3dbf1Smrg then 9335d5c3dbf1Smrg continue 9336d5c3dbf1Smrg fi 9337d5c3dbf1Smrg fi 9338cdbfa18aSmrg func_append removelist " $p" 9339d5c3dbf1Smrg ;; 9340d5c3dbf1Smrg *) ;; 9341d5c3dbf1Smrg esac 9342d5c3dbf1Smrg done 9343d5c3dbf1Smrg test -n "$removelist" && \ 9344d5c3dbf1Smrg func_show_eval "${RM}r \$removelist" 9345d5c3dbf1Smrg fi 9346d5c3dbf1Smrg 9347d5c3dbf1Smrg # Now set the variables for building old libraries. 9348949d0342Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349cdbfa18aSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9350d5c3dbf1Smrg 9351d5c3dbf1Smrg # Transform .lo files to .o files. 9352949d0342Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353d5c3dbf1Smrg fi 9354d5c3dbf1Smrg 9355d5c3dbf1Smrg # Eliminate all temporary directories. 9356d5c3dbf1Smrg #for path in $notinst_path; do 9357d5c3dbf1Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358d5c3dbf1Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359d5c3dbf1Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360d5c3dbf1Smrg #done 9361d5c3dbf1Smrg 9362d5c3dbf1Smrg if test -n "$xrpath"; then 9363d5c3dbf1Smrg # If the user specified any rpath flags, then add them. 9364d5c3dbf1Smrg temp_xrpath= 9365d5c3dbf1Smrg for libdir in $xrpath; do 9366cdbfa18aSmrg func_replace_sysroot "$libdir" 9367cdbfa18aSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368d5c3dbf1Smrg case "$finalize_rpath " in 9369d5c3dbf1Smrg *" $libdir "*) ;; 9370cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 9371d5c3dbf1Smrg esac 9372d5c3dbf1Smrg done 9373949d0342Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374d5c3dbf1Smrg dependency_libs="$temp_xrpath $dependency_libs" 9375d5c3dbf1Smrg fi 9376d5c3dbf1Smrg fi 9377d5c3dbf1Smrg 9378d5c3dbf1Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9379949d0342Smrg old_dlfiles=$dlfiles 9380d5c3dbf1Smrg dlfiles= 9381d5c3dbf1Smrg for lib in $old_dlfiles; do 9382d5c3dbf1Smrg case " $dlprefiles $dlfiles " in 9383d5c3dbf1Smrg *" $lib "*) ;; 9384cdbfa18aSmrg *) func_append dlfiles " $lib" ;; 9385d5c3dbf1Smrg esac 9386d5c3dbf1Smrg done 9387d5c3dbf1Smrg 9388d5c3dbf1Smrg # Make sure dlprefiles contains only unique files 9389949d0342Smrg old_dlprefiles=$dlprefiles 9390d5c3dbf1Smrg dlprefiles= 9391d5c3dbf1Smrg for lib in $old_dlprefiles; do 9392d5c3dbf1Smrg case "$dlprefiles " in 9393d5c3dbf1Smrg *" $lib "*) ;; 9394cdbfa18aSmrg *) func_append dlprefiles " $lib" ;; 9395d5c3dbf1Smrg esac 9396d5c3dbf1Smrg done 9397d5c3dbf1Smrg 9398949d0342Smrg if test yes = "$build_libtool_libs"; then 9399d5c3dbf1Smrg if test -n "$rpath"; then 9400d5c3dbf1Smrg case $host in 9401d5c3dbf1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402d5c3dbf1Smrg # these systems don't actually have a c library (as such)! 9403d5c3dbf1Smrg ;; 9404d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9405d5c3dbf1Smrg # Rhapsody C library is in the System framework 9406cdbfa18aSmrg func_append deplibs " System.ltframework" 9407d5c3dbf1Smrg ;; 9408d5c3dbf1Smrg *-*-netbsd*) 9409d5c3dbf1Smrg # Don't link with libc until the a.out ld.so is fixed. 9410d5c3dbf1Smrg ;; 9411949d0342Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412d5c3dbf1Smrg # Do not include libc due to us having libc/libc_r. 9413d5c3dbf1Smrg ;; 9414d5c3dbf1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9415d5c3dbf1Smrg # Causes problems with __ctype 9416d5c3dbf1Smrg ;; 9417d5c3dbf1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418d5c3dbf1Smrg # Compiler inserts libc in the correct place for threads to work 9419d5c3dbf1Smrg ;; 9420d5c3dbf1Smrg *) 9421d5c3dbf1Smrg # Add libc to deplibs on all other systems if necessary. 9422949d0342Smrg if test yes = "$build_libtool_need_lc"; then 9423cdbfa18aSmrg func_append deplibs " -lc" 9424d5c3dbf1Smrg fi 9425d5c3dbf1Smrg ;; 9426d5c3dbf1Smrg esac 9427d5c3dbf1Smrg fi 9428d5c3dbf1Smrg 9429d5c3dbf1Smrg # Transform deplibs into only deplibs that can be linked in shared. 9430d5c3dbf1Smrg name_save=$name 9431d5c3dbf1Smrg libname_save=$libname 9432d5c3dbf1Smrg release_save=$release 9433d5c3dbf1Smrg versuffix_save=$versuffix 9434d5c3dbf1Smrg major_save=$major 9435d5c3dbf1Smrg # I'm not sure if I'm treating the release correctly. I think 9436d5c3dbf1Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437d5c3dbf1Smrg # add it in twice. Is that correct? 9438949d0342Smrg release= 9439949d0342Smrg versuffix= 9440949d0342Smrg major= 9441d5c3dbf1Smrg newdeplibs= 9442d5c3dbf1Smrg droppeddeps=no 9443d5c3dbf1Smrg case $deplibs_check_method in 9444d5c3dbf1Smrg pass_all) 9445d5c3dbf1Smrg # Don't check for shared/static. Everything works. 9446d5c3dbf1Smrg # This might be a little naive. We might want to check 9447d5c3dbf1Smrg # whether the library exists or not. But this is on 9448d5c3dbf1Smrg # osf3 & osf4 and I'm not really sure... Just 9449d5c3dbf1Smrg # implementing what was already the behavior. 9450d5c3dbf1Smrg newdeplibs=$deplibs 9451d5c3dbf1Smrg ;; 9452d5c3dbf1Smrg test_compile) 9453d5c3dbf1Smrg # This code stresses the "libraries are programs" paradigm to its 9454d5c3dbf1Smrg # limits. Maybe even breaks it. We compile a program, linking it 9455d5c3dbf1Smrg # against the deplibs as a proxy for the library. Then we can check 9456d5c3dbf1Smrg # whether they linked in statically or dynamically with ldd. 9457d5c3dbf1Smrg $opt_dry_run || $RM conftest.c 9458d5c3dbf1Smrg cat > conftest.c <<EOF 9459d5c3dbf1Smrg int main() { return 0; } 9460d5c3dbf1SmrgEOF 9461d5c3dbf1Smrg $opt_dry_run || $RM conftest 9462d5c3dbf1Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463d5c3dbf1Smrg ldd_output=`ldd conftest` 9464d5c3dbf1Smrg for i in $deplibs; do 9465d5c3dbf1Smrg case $i in 9466d5c3dbf1Smrg -l*) 9467d5c3dbf1Smrg func_stripname -l '' "$i" 9468d5c3dbf1Smrg name=$func_stripname_result 9469949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470d5c3dbf1Smrg case " $predeps $postdeps " in 9471d5c3dbf1Smrg *" $i "*) 9472cdbfa18aSmrg func_append newdeplibs " $i" 9473949d0342Smrg i= 9474d5c3dbf1Smrg ;; 9475d5c3dbf1Smrg esac 9476d5c3dbf1Smrg fi 9477949d0342Smrg if test -n "$i"; then 9478d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479d5c3dbf1Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480d5c3dbf1Smrg set dummy $deplib_matches; shift 9481d5c3dbf1Smrg deplib_match=$1 9482949d0342Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483cdbfa18aSmrg func_append newdeplibs " $i" 9484d5c3dbf1Smrg else 9485d5c3dbf1Smrg droppeddeps=yes 9486d5c3dbf1Smrg echo 9487d5c3dbf1Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488d5c3dbf1Smrg echo "*** I have the capability to make that library automatically link in when" 9489d5c3dbf1Smrg echo "*** you link to this library. But I can only do this if you have a" 9490d5c3dbf1Smrg echo "*** shared version of the library, which I believe you do not have" 9491d5c3dbf1Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492d5c3dbf1Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493d5c3dbf1Smrg fi 9494d5c3dbf1Smrg fi 9495d5c3dbf1Smrg ;; 9496d5c3dbf1Smrg *) 9497cdbfa18aSmrg func_append newdeplibs " $i" 9498d5c3dbf1Smrg ;; 9499d5c3dbf1Smrg esac 9500d5c3dbf1Smrg done 9501d5c3dbf1Smrg else 9502d5c3dbf1Smrg # Error occurred in the first compile. Let's try to salvage 9503d5c3dbf1Smrg # the situation: Compile a separate program for each library. 9504d5c3dbf1Smrg for i in $deplibs; do 9505d5c3dbf1Smrg case $i in 9506d5c3dbf1Smrg -l*) 9507d5c3dbf1Smrg func_stripname -l '' "$i" 9508d5c3dbf1Smrg name=$func_stripname_result 9509d5c3dbf1Smrg $opt_dry_run || $RM conftest 9510d5c3dbf1Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511d5c3dbf1Smrg ldd_output=`ldd conftest` 9512949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513d5c3dbf1Smrg case " $predeps $postdeps " in 9514d5c3dbf1Smrg *" $i "*) 9515cdbfa18aSmrg func_append newdeplibs " $i" 9516949d0342Smrg i= 9517d5c3dbf1Smrg ;; 9518d5c3dbf1Smrg esac 9519d5c3dbf1Smrg fi 9520949d0342Smrg if test -n "$i"; then 9521d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522d5c3dbf1Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523d5c3dbf1Smrg set dummy $deplib_matches; shift 9524d5c3dbf1Smrg deplib_match=$1 9525949d0342Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526cdbfa18aSmrg func_append newdeplibs " $i" 9527d5c3dbf1Smrg else 9528d5c3dbf1Smrg droppeddeps=yes 9529d5c3dbf1Smrg echo 9530d5c3dbf1Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531d5c3dbf1Smrg echo "*** I have the capability to make that library automatically link in when" 9532d5c3dbf1Smrg echo "*** you link to this library. But I can only do this if you have a" 9533d5c3dbf1Smrg echo "*** shared version of the library, which you do not appear to have" 9534d5c3dbf1Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535d5c3dbf1Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536d5c3dbf1Smrg fi 9537d5c3dbf1Smrg fi 9538d5c3dbf1Smrg else 9539d5c3dbf1Smrg droppeddeps=yes 9540d5c3dbf1Smrg echo 9541d5c3dbf1Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542d5c3dbf1Smrg echo "*** make it link in! You will probably need to install it or some" 9543d5c3dbf1Smrg echo "*** library that it depends on before this library will be fully" 9544d5c3dbf1Smrg echo "*** functional. Installing it before continuing would be even better." 9545d5c3dbf1Smrg fi 9546d5c3dbf1Smrg ;; 9547d5c3dbf1Smrg *) 9548cdbfa18aSmrg func_append newdeplibs " $i" 9549d5c3dbf1Smrg ;; 9550d5c3dbf1Smrg esac 9551d5c3dbf1Smrg done 9552d5c3dbf1Smrg fi 9553d5c3dbf1Smrg ;; 9554d5c3dbf1Smrg file_magic*) 9555d5c3dbf1Smrg set dummy $deplibs_check_method; shift 9556d5c3dbf1Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557d5c3dbf1Smrg for a_deplib in $deplibs; do 9558d5c3dbf1Smrg case $a_deplib in 9559d5c3dbf1Smrg -l*) 9560d5c3dbf1Smrg func_stripname -l '' "$a_deplib" 9561d5c3dbf1Smrg name=$func_stripname_result 9562949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563d5c3dbf1Smrg case " $predeps $postdeps " in 9564d5c3dbf1Smrg *" $a_deplib "*) 9565cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9566949d0342Smrg a_deplib= 9567d5c3dbf1Smrg ;; 9568d5c3dbf1Smrg esac 9569d5c3dbf1Smrg fi 9570949d0342Smrg if test -n "$a_deplib"; then 9571d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572cdbfa18aSmrg if test -n "$file_magic_glob"; then 9573cdbfa18aSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574cdbfa18aSmrg else 9575cdbfa18aSmrg libnameglob=$libname 9576cdbfa18aSmrg fi 9577949d0342Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578d5c3dbf1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9579949d0342Smrg if test yes = "$want_nocaseglob"; then 9580cdbfa18aSmrg shopt -s nocaseglob 9581cdbfa18aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582cdbfa18aSmrg $nocaseglob 9583cdbfa18aSmrg else 9584cdbfa18aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585cdbfa18aSmrg fi 9586d5c3dbf1Smrg for potent_lib in $potential_libs; do 9587d5c3dbf1Smrg # Follow soft links. 9588d5c3dbf1Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9589d5c3dbf1Smrg $GREP " -> " >/dev/null; then 9590d5c3dbf1Smrg continue 9591d5c3dbf1Smrg fi 9592d5c3dbf1Smrg # The statement above tries to avoid entering an 9593d5c3dbf1Smrg # endless loop below, in case of cyclic links. 9594d5c3dbf1Smrg # We might still enter an endless loop, since a link 9595d5c3dbf1Smrg # loop can be closed while we follow links, 9596d5c3dbf1Smrg # but so what? 9597949d0342Smrg potlib=$potent_lib 9598d5c3dbf1Smrg while test -h "$potlib" 2>/dev/null; do 9599949d0342Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600d5c3dbf1Smrg case $potliblink in 9601949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9602949d0342Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603d5c3dbf1Smrg esac 9604d5c3dbf1Smrg done 9605d5c3dbf1Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606d5c3dbf1Smrg $SED -e 10q | 9607d5c3dbf1Smrg $EGREP "$file_magic_regex" > /dev/null; then 9608cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9609949d0342Smrg a_deplib= 9610d5c3dbf1Smrg break 2 9611d5c3dbf1Smrg fi 9612d5c3dbf1Smrg done 9613d5c3dbf1Smrg done 9614d5c3dbf1Smrg fi 9615949d0342Smrg if test -n "$a_deplib"; then 9616d5c3dbf1Smrg droppeddeps=yes 9617d5c3dbf1Smrg echo 9618d5c3dbf1Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619d5c3dbf1Smrg echo "*** I have the capability to make that library automatically link in when" 9620d5c3dbf1Smrg echo "*** you link to this library. But I can only do this if you have a" 9621d5c3dbf1Smrg echo "*** shared version of the library, which you do not appear to have" 9622d5c3dbf1Smrg echo "*** because I did check the linker path looking for a file starting" 9623949d0342Smrg if test -z "$potlib"; then 9624d5c3dbf1Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625d5c3dbf1Smrg else 9626d5c3dbf1Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627d5c3dbf1Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628d5c3dbf1Smrg fi 9629d5c3dbf1Smrg fi 9630d5c3dbf1Smrg ;; 9631d5c3dbf1Smrg *) 9632d5c3dbf1Smrg # Add a -L argument. 9633cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9634d5c3dbf1Smrg ;; 9635d5c3dbf1Smrg esac 9636d5c3dbf1Smrg done # Gone through all deplibs. 9637d5c3dbf1Smrg ;; 9638d5c3dbf1Smrg match_pattern*) 9639d5c3dbf1Smrg set dummy $deplibs_check_method; shift 9640d5c3dbf1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641d5c3dbf1Smrg for a_deplib in $deplibs; do 9642d5c3dbf1Smrg case $a_deplib in 9643d5c3dbf1Smrg -l*) 9644d5c3dbf1Smrg func_stripname -l '' "$a_deplib" 9645d5c3dbf1Smrg name=$func_stripname_result 9646949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647d5c3dbf1Smrg case " $predeps $postdeps " in 9648d5c3dbf1Smrg *" $a_deplib "*) 9649cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9650949d0342Smrg a_deplib= 9651d5c3dbf1Smrg ;; 9652d5c3dbf1Smrg esac 9653d5c3dbf1Smrg fi 9654949d0342Smrg if test -n "$a_deplib"; then 9655d5c3dbf1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656d5c3dbf1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657d5c3dbf1Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658d5c3dbf1Smrg for potent_lib in $potential_libs; do 9659949d0342Smrg potlib=$potent_lib # see symlink-check above in file_magic test 9660d5c3dbf1Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661d5c3dbf1Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9662cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9663949d0342Smrg a_deplib= 9664d5c3dbf1Smrg break 2 9665d5c3dbf1Smrg fi 9666d5c3dbf1Smrg done 9667d5c3dbf1Smrg done 9668d5c3dbf1Smrg fi 9669949d0342Smrg if test -n "$a_deplib"; then 9670d5c3dbf1Smrg droppeddeps=yes 9671d5c3dbf1Smrg echo 9672d5c3dbf1Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673d5c3dbf1Smrg echo "*** I have the capability to make that library automatically link in when" 9674d5c3dbf1Smrg echo "*** you link to this library. But I can only do this if you have a" 9675d5c3dbf1Smrg echo "*** shared version of the library, which you do not appear to have" 9676d5c3dbf1Smrg echo "*** because I did check the linker path looking for a file starting" 9677949d0342Smrg if test -z "$potlib"; then 9678d5c3dbf1Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679d5c3dbf1Smrg else 9680d5c3dbf1Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681d5c3dbf1Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682d5c3dbf1Smrg fi 9683d5c3dbf1Smrg fi 9684d5c3dbf1Smrg ;; 9685d5c3dbf1Smrg *) 9686d5c3dbf1Smrg # Add a -L argument. 9687cdbfa18aSmrg func_append newdeplibs " $a_deplib" 9688d5c3dbf1Smrg ;; 9689d5c3dbf1Smrg esac 9690d5c3dbf1Smrg done # Gone through all deplibs. 9691d5c3dbf1Smrg ;; 9692d5c3dbf1Smrg none | unknown | *) 9693949d0342Smrg newdeplibs= 9694d5c3dbf1Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9695949d0342Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9696949d0342Smrg for i in $predeps $postdeps; do 9697d5c3dbf1Smrg # can't use Xsed below, because $i might contain '/' 9698949d0342Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699d5c3dbf1Smrg done 9700d5c3dbf1Smrg fi 9701d5c3dbf1Smrg case $tmp_deplibs in 9702d5c3dbf1Smrg *[!\ \ ]*) 9703d5c3dbf1Smrg echo 9704949d0342Smrg if test none = "$deplibs_check_method"; then 9705d5c3dbf1Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706d5c3dbf1Smrg else 9707d5c3dbf1Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708d5c3dbf1Smrg fi 9709d5c3dbf1Smrg echo "*** All declared inter-library dependencies are being dropped." 9710d5c3dbf1Smrg droppeddeps=yes 9711d5c3dbf1Smrg ;; 9712d5c3dbf1Smrg esac 9713d5c3dbf1Smrg ;; 9714d5c3dbf1Smrg esac 9715d5c3dbf1Smrg versuffix=$versuffix_save 9716d5c3dbf1Smrg major=$major_save 9717d5c3dbf1Smrg release=$release_save 9718d5c3dbf1Smrg libname=$libname_save 9719d5c3dbf1Smrg name=$name_save 9720d5c3dbf1Smrg 9721d5c3dbf1Smrg case $host in 9722d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9723d5c3dbf1Smrg # On Rhapsody replace the C library with the System framework 9724d5c3dbf1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725d5c3dbf1Smrg ;; 9726d5c3dbf1Smrg esac 9727d5c3dbf1Smrg 9728949d0342Smrg if test yes = "$droppeddeps"; then 9729949d0342Smrg if test yes = "$module"; then 9730d5c3dbf1Smrg echo 9731d5c3dbf1Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732d5c3dbf1Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733d5c3dbf1Smrg echo "*** a static module, that should work as long as the dlopening" 9734d5c3dbf1Smrg echo "*** application is linked with the -dlopen flag." 9735d5c3dbf1Smrg if test -z "$global_symbol_pipe"; then 9736d5c3dbf1Smrg echo 9737d5c3dbf1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9738949d0342Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739d5c3dbf1Smrg echo "*** not find such a program. So, this module is probably useless." 9740949d0342Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741d5c3dbf1Smrg fi 9742949d0342Smrg if test no = "$build_old_libs"; then 9743949d0342Smrg oldlibs=$output_objdir/$libname.$libext 9744d5c3dbf1Smrg build_libtool_libs=module 9745d5c3dbf1Smrg build_old_libs=yes 9746d5c3dbf1Smrg else 9747d5c3dbf1Smrg build_libtool_libs=no 9748d5c3dbf1Smrg fi 9749d5c3dbf1Smrg else 9750d5c3dbf1Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9751d5c3dbf1Smrg echo "*** automatically added whenever a program is linked with this library" 9752d5c3dbf1Smrg echo "*** or is declared to -dlopen it." 9753d5c3dbf1Smrg 9754949d0342Smrg if test no = "$allow_undefined"; then 9755d5c3dbf1Smrg echo 9756d5c3dbf1Smrg echo "*** Since this library must not contain undefined symbols," 9757d5c3dbf1Smrg echo "*** because either the platform does not support them or" 9758d5c3dbf1Smrg echo "*** it was explicitly requested with -no-undefined," 9759d5c3dbf1Smrg echo "*** libtool will only create a static version of it." 9760949d0342Smrg if test no = "$build_old_libs"; then 9761949d0342Smrg oldlibs=$output_objdir/$libname.$libext 9762d5c3dbf1Smrg build_libtool_libs=module 9763d5c3dbf1Smrg build_old_libs=yes 9764d5c3dbf1Smrg else 9765d5c3dbf1Smrg build_libtool_libs=no 9766d5c3dbf1Smrg fi 9767d5c3dbf1Smrg fi 9768d5c3dbf1Smrg fi 9769d5c3dbf1Smrg fi 9770d5c3dbf1Smrg # Done checking deplibs! 9771d5c3dbf1Smrg deplibs=$newdeplibs 9772d5c3dbf1Smrg fi 9773d5c3dbf1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774d5c3dbf1Smrg case $host in 9775d5c3dbf1Smrg *-*-darwin*) 9776d5c3dbf1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777d5c3dbf1Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778d5c3dbf1Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779d5c3dbf1Smrg ;; 9780d5c3dbf1Smrg esac 9781d5c3dbf1Smrg 9782d5c3dbf1Smrg # move library search paths that coincide with paths to not yet 9783d5c3dbf1Smrg # installed libraries to the beginning of the library search list 9784d5c3dbf1Smrg new_libs= 9785d5c3dbf1Smrg for path in $notinst_path; do 9786d5c3dbf1Smrg case " $new_libs " in 9787d5c3dbf1Smrg *" -L$path/$objdir "*) ;; 9788d5c3dbf1Smrg *) 9789d5c3dbf1Smrg case " $deplibs " in 9790d5c3dbf1Smrg *" -L$path/$objdir "*) 9791cdbfa18aSmrg func_append new_libs " -L$path/$objdir" ;; 9792d5c3dbf1Smrg esac 9793d5c3dbf1Smrg ;; 9794d5c3dbf1Smrg esac 9795d5c3dbf1Smrg done 9796d5c3dbf1Smrg for deplib in $deplibs; do 9797d5c3dbf1Smrg case $deplib in 9798d5c3dbf1Smrg -L*) 9799d5c3dbf1Smrg case " $new_libs " in 9800d5c3dbf1Smrg *" $deplib "*) ;; 9801cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 9802d5c3dbf1Smrg esac 9803d5c3dbf1Smrg ;; 9804cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 9805d5c3dbf1Smrg esac 9806d5c3dbf1Smrg done 9807949d0342Smrg deplibs=$new_libs 9808d5c3dbf1Smrg 9809d5c3dbf1Smrg # All the library-specific variables (install_libdir is set above). 9810d5c3dbf1Smrg library_names= 9811d5c3dbf1Smrg old_library= 9812d5c3dbf1Smrg dlname= 9813d5c3dbf1Smrg 9814d5c3dbf1Smrg # Test again, we may have decided not to build it any more 9815949d0342Smrg if test yes = "$build_libtool_libs"; then 9816949d0342Smrg # Remove $wl instances when linking with ld. 9817cdbfa18aSmrg # FIXME: should test the right _cmds variable. 9818cdbfa18aSmrg case $archive_cmds in 9819cdbfa18aSmrg *\$LD\ *) wl= ;; 9820cdbfa18aSmrg esac 9821949d0342Smrg if test yes = "$hardcode_into_libs"; then 9822d5c3dbf1Smrg # Hardcode the library paths 9823d5c3dbf1Smrg hardcode_libdirs= 9824d5c3dbf1Smrg dep_rpath= 9825949d0342Smrg rpath=$finalize_rpath 9826949d0342Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827d5c3dbf1Smrg for libdir in $rpath; do 9828d5c3dbf1Smrg if test -n "$hardcode_libdir_flag_spec"; then 9829d5c3dbf1Smrg if test -n "$hardcode_libdir_separator"; then 9830cdbfa18aSmrg func_replace_sysroot "$libdir" 9831cdbfa18aSmrg libdir=$func_replace_sysroot_result 9832d5c3dbf1Smrg if test -z "$hardcode_libdirs"; then 9833949d0342Smrg hardcode_libdirs=$libdir 9834d5c3dbf1Smrg else 9835d5c3dbf1Smrg # Just accumulate the unique libdirs. 9836d5c3dbf1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837d5c3dbf1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838d5c3dbf1Smrg ;; 9839d5c3dbf1Smrg *) 9840cdbfa18aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841d5c3dbf1Smrg ;; 9842d5c3dbf1Smrg esac 9843d5c3dbf1Smrg fi 9844d5c3dbf1Smrg else 9845d5c3dbf1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9846cdbfa18aSmrg func_append dep_rpath " $flag" 9847d5c3dbf1Smrg fi 9848d5c3dbf1Smrg elif test -n "$runpath_var"; then 9849d5c3dbf1Smrg case "$perm_rpath " in 9850d5c3dbf1Smrg *" $libdir "*) ;; 9851cdbfa18aSmrg *) func_append perm_rpath " $libdir" ;; 9852d5c3dbf1Smrg esac 9853d5c3dbf1Smrg fi 9854d5c3dbf1Smrg done 9855d5c3dbf1Smrg # Substitute the hardcoded libdirs into the rpath. 9856d5c3dbf1Smrg if test -n "$hardcode_libdir_separator" && 9857d5c3dbf1Smrg test -n "$hardcode_libdirs"; then 9858949d0342Smrg libdir=$hardcode_libdirs 9859cdbfa18aSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860d5c3dbf1Smrg fi 9861d5c3dbf1Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862d5c3dbf1Smrg # We should set the runpath_var. 9863d5c3dbf1Smrg rpath= 9864d5c3dbf1Smrg for dir in $perm_rpath; do 9865cdbfa18aSmrg func_append rpath "$dir:" 9866d5c3dbf1Smrg done 9867d5c3dbf1Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868d5c3dbf1Smrg fi 9869d5c3dbf1Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870d5c3dbf1Smrg fi 98719f606849Smrg 9872949d0342Smrg shlibpath=$finalize_shlibpath 9873949d0342Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874d5c3dbf1Smrg if test -n "$shlibpath"; then 9875d5c3dbf1Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876d5c3dbf1Smrg fi 98779f606849Smrg 9878d5c3dbf1Smrg # Get the real and link names of the library. 9879d5c3dbf1Smrg eval shared_ext=\"$shrext_cmds\" 9880d5c3dbf1Smrg eval library_names=\"$library_names_spec\" 9881d5c3dbf1Smrg set dummy $library_names 9882d5c3dbf1Smrg shift 9883949d0342Smrg realname=$1 9884d5c3dbf1Smrg shift 98859f606849Smrg 9886d5c3dbf1Smrg if test -n "$soname_spec"; then 9887d5c3dbf1Smrg eval soname=\"$soname_spec\" 9888d5c3dbf1Smrg else 9889949d0342Smrg soname=$realname 9890d5c3dbf1Smrg fi 9891d5c3dbf1Smrg if test -z "$dlname"; then 9892d5c3dbf1Smrg dlname=$soname 9893d5c3dbf1Smrg fi 98949f606849Smrg 9895949d0342Smrg lib=$output_objdir/$realname 9896d5c3dbf1Smrg linknames= 9897d5c3dbf1Smrg for link 9898d5c3dbf1Smrg do 9899cdbfa18aSmrg func_append linknames " $link" 9900d5c3dbf1Smrg done 99019f606849Smrg 9902d5c3dbf1Smrg # Use standard objects if they are pic 9903d5c3dbf1Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 99059f606849Smrg 9906d5c3dbf1Smrg delfiles= 9907d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908d5c3dbf1Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9909949d0342Smrg export_symbols=$output_objdir/$libname.uexp 9910cdbfa18aSmrg func_append delfiles " $export_symbols" 9911d5c3dbf1Smrg fi 99129f606849Smrg 9913d5c3dbf1Smrg orig_export_symbols= 9914d5c3dbf1Smrg case $host_os in 9915d5c3dbf1Smrg cygwin* | mingw* | cegcc*) 9916d5c3dbf1Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917d5c3dbf1Smrg # exporting using user supplied symfile 9918949d0342Smrg func_dll_def_p "$export_symbols" || { 9919d5c3dbf1Smrg # and it's NOT already a .def file. Must figure out 9920d5c3dbf1Smrg # which of the given symbols are data symbols and tag 9921d5c3dbf1Smrg # them as such. So, trigger use of export_symbols_cmds. 9922d5c3dbf1Smrg # export_symbols gets reassigned inside the "prepare 9923d5c3dbf1Smrg # the list of exported symbols" if statement, so the 9924d5c3dbf1Smrg # include_expsyms logic still works. 9925949d0342Smrg orig_export_symbols=$export_symbols 9926d5c3dbf1Smrg export_symbols= 9927d5c3dbf1Smrg always_export_symbols=yes 9928949d0342Smrg } 9929d5c3dbf1Smrg fi 9930d5c3dbf1Smrg ;; 9931d5c3dbf1Smrg esac 99329f606849Smrg 9933d5c3dbf1Smrg # Prepare the list of exported symbols 9934d5c3dbf1Smrg if test -z "$export_symbols"; then 9935949d0342Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9936949d0342Smrg func_verbose "generating symbol list for '$libname.la'" 9937949d0342Smrg export_symbols=$output_objdir/$libname.exp 9938d5c3dbf1Smrg $opt_dry_run || $RM $export_symbols 9939d5c3dbf1Smrg cmds=$export_symbols_cmds 9940949d0342Smrg save_ifs=$IFS; IFS='~' 9941cdbfa18aSmrg for cmd1 in $cmds; do 9942949d0342Smrg IFS=$save_ifs 9943cdbfa18aSmrg # Take the normal branch if the nm_file_list_spec branch 9944cdbfa18aSmrg # doesn't work or if tool conversion is not needed. 9945cdbfa18aSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9946cdbfa18aSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947cdbfa18aSmrg try_normal_branch=yes 9948cdbfa18aSmrg eval cmd=\"$cmd1\" 9949cdbfa18aSmrg func_len " $cmd" 9950cdbfa18aSmrg len=$func_len_result 9951cdbfa18aSmrg ;; 9952cdbfa18aSmrg *) 9953cdbfa18aSmrg try_normal_branch=no 9954cdbfa18aSmrg ;; 9955cdbfa18aSmrg esac 9956949d0342Smrg if test yes = "$try_normal_branch" \ 9957cdbfa18aSmrg && { test "$len" -lt "$max_cmd_len" \ 9958cdbfa18aSmrg || test "$max_cmd_len" -le -1; } 9959cdbfa18aSmrg then 9960cdbfa18aSmrg func_show_eval "$cmd" 'exit $?' 9961cdbfa18aSmrg skipped_export=false 9962cdbfa18aSmrg elif test -n "$nm_file_list_spec"; then 9963cdbfa18aSmrg func_basename "$output" 9964cdbfa18aSmrg output_la=$func_basename_result 9965cdbfa18aSmrg save_libobjs=$libobjs 9966cdbfa18aSmrg save_output=$output 9967949d0342Smrg output=$output_objdir/$output_la.nm 9968cdbfa18aSmrg func_to_tool_file "$output" 9969cdbfa18aSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970cdbfa18aSmrg func_append delfiles " $output" 9971cdbfa18aSmrg func_verbose "creating $NM input file list: $output" 9972cdbfa18aSmrg for obj in $save_libobjs; do 9973cdbfa18aSmrg func_to_tool_file "$obj" 9974cdbfa18aSmrg $ECHO "$func_to_tool_file_result" 9975cdbfa18aSmrg done > "$output" 9976cdbfa18aSmrg eval cmd=\"$cmd1\" 9977d5c3dbf1Smrg func_show_eval "$cmd" 'exit $?' 9978cdbfa18aSmrg output=$save_output 9979cdbfa18aSmrg libobjs=$save_libobjs 9980d5c3dbf1Smrg skipped_export=false 9981d5c3dbf1Smrg else 9982d5c3dbf1Smrg # The command line is too long to execute in one step. 9983d5c3dbf1Smrg func_verbose "using reloadable object file for export list..." 9984d5c3dbf1Smrg skipped_export=: 9985d5c3dbf1Smrg # Break out early, otherwise skipped_export may be 9986d5c3dbf1Smrg # set to false by a later but shorter cmd. 9987d5c3dbf1Smrg break 9988d5c3dbf1Smrg fi 9989d5c3dbf1Smrg done 9990949d0342Smrg IFS=$save_ifs 9991949d0342Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992d5c3dbf1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993d5c3dbf1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994d5c3dbf1Smrg fi 9995d5c3dbf1Smrg fi 9996d5c3dbf1Smrg fi 99979f606849Smrg 9998d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9999949d0342Smrg tmp_export_symbols=$export_symbols 10000949d0342Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001d5c3dbf1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002d5c3dbf1Smrg fi 100039f606849Smrg 10004949d0342Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005d5c3dbf1Smrg # The given exports_symbols file has to be filtered, so filter it. 10006949d0342Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007d5c3dbf1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10008949d0342Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009d5c3dbf1Smrg # though. Also, the filter scales superlinearly with the number of 10010d5c3dbf1Smrg # global variables. join(1) would be nice here, but unfortunately 10011d5c3dbf1Smrg # isn't a blessed tool. 10012d5c3dbf1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013cdbfa18aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014d5c3dbf1Smrg export_symbols=$output_objdir/$libname.def 10015d5c3dbf1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100169f606849Smrg fi 100179f606849Smrg 10018d5c3dbf1Smrg tmp_deplibs= 10019d5c3dbf1Smrg for test_deplib in $deplibs; do 10020d5c3dbf1Smrg case " $convenience " in 10021d5c3dbf1Smrg *" $test_deplib "*) ;; 10022d5c3dbf1Smrg *) 10023cdbfa18aSmrg func_append tmp_deplibs " $test_deplib" 10024d5c3dbf1Smrg ;; 10025d5c3dbf1Smrg esac 10026d5c3dbf1Smrg done 10027949d0342Smrg deplibs=$tmp_deplibs 100289f606849Smrg 10029d5c3dbf1Smrg if test -n "$convenience"; then 10030d5c3dbf1Smrg if test -n "$whole_archive_flag_spec" && 10031949d0342Smrg test yes = "$compiler_needs_object" && 10032d5c3dbf1Smrg test -z "$libobjs"; then 10033d5c3dbf1Smrg # extract the archives, so we have objects to list. 10034d5c3dbf1Smrg # TODO: could optimize this to just extract one archive. 10035d5c3dbf1Smrg whole_archive_flag_spec= 10036d5c3dbf1Smrg fi 10037d5c3dbf1Smrg if test -n "$whole_archive_flag_spec"; then 10038d5c3dbf1Smrg save_libobjs=$libobjs 10039d5c3dbf1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 10041d5c3dbf1Smrg else 10042949d0342Smrg gentop=$output_objdir/${outputname}x 10043cdbfa18aSmrg func_append generated " $gentop" 100449f606849Smrg 10045d5c3dbf1Smrg func_extract_archives $gentop $convenience 10046cdbfa18aSmrg func_append libobjs " $func_extract_archives_result" 10047d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 10048d5c3dbf1Smrg fi 10049d5c3dbf1Smrg fi 100509f606849Smrg 10051949d0342Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052d5c3dbf1Smrg eval flag=\"$thread_safe_flag_spec\" 10053cdbfa18aSmrg func_append linker_flags " $flag" 10054d5c3dbf1Smrg fi 100559f606849Smrg 10056d5c3dbf1Smrg # Make a backup of the uninstalled library when relinking 10057949d0342Smrg if test relink = "$opt_mode"; then 10058d5c3dbf1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 100599f606849Smrg fi 100609f606849Smrg 10061d5c3dbf1Smrg # Do each of the archive commands. 10062949d0342Smrg if test yes = "$module" && test -n "$module_cmds"; then 10063d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064d5c3dbf1Smrg eval test_cmds=\"$module_expsym_cmds\" 10065d5c3dbf1Smrg cmds=$module_expsym_cmds 10066d5c3dbf1Smrg else 10067d5c3dbf1Smrg eval test_cmds=\"$module_cmds\" 10068d5c3dbf1Smrg cmds=$module_cmds 10069d5c3dbf1Smrg fi 10070d5c3dbf1Smrg else 10071d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072d5c3dbf1Smrg eval test_cmds=\"$archive_expsym_cmds\" 10073d5c3dbf1Smrg cmds=$archive_expsym_cmds 10074d5c3dbf1Smrg else 10075d5c3dbf1Smrg eval test_cmds=\"$archive_cmds\" 10076d5c3dbf1Smrg cmds=$archive_cmds 10077d5c3dbf1Smrg fi 100789f606849Smrg fi 100799f606849Smrg 10080949d0342Smrg if test : != "$skipped_export" && 10081d5c3dbf1Smrg func_len " $test_cmds" && 10082d5c3dbf1Smrg len=$func_len_result && 10083d5c3dbf1Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084d5c3dbf1Smrg : 10085d5c3dbf1Smrg else 10086d5c3dbf1Smrg # The command line is too long to link in one step, link piecewise 10087d5c3dbf1Smrg # or, if using GNU ld and skipped_export is not :, use a linker 10088d5c3dbf1Smrg # script. 100899f606849Smrg 10090d5c3dbf1Smrg # Save the value of $output and $libobjs because we want to 10091d5c3dbf1Smrg # use them later. If we have whole_archive_flag_spec, we 10092d5c3dbf1Smrg # want to use save_libobjs as it was before 10093d5c3dbf1Smrg # whole_archive_flag_spec was expanded, because we can't 10094d5c3dbf1Smrg # assume the linker understands whole_archive_flag_spec. 10095d5c3dbf1Smrg # This may have to be revisited, in case too many 10096d5c3dbf1Smrg # convenience libraries get linked in and end up exceeding 10097d5c3dbf1Smrg # the spec. 10098d5c3dbf1Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099d5c3dbf1Smrg save_libobjs=$libobjs 10100d5c3dbf1Smrg fi 10101d5c3dbf1Smrg save_output=$output 10102d5c3dbf1Smrg func_basename "$output" 10103d5c3dbf1Smrg output_la=$func_basename_result 101049f606849Smrg 10105d5c3dbf1Smrg # Clear the reloadable object creation command queue and 10106d5c3dbf1Smrg # initialize k to one. 10107d5c3dbf1Smrg test_cmds= 10108d5c3dbf1Smrg concat_cmds= 10109d5c3dbf1Smrg objlist= 10110d5c3dbf1Smrg last_robj= 10111d5c3dbf1Smrg k=1 101129f606849Smrg 10113949d0342Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10114949d0342Smrg output=$output_objdir/$output_la.lnkscript 10115d5c3dbf1Smrg func_verbose "creating GNU ld script: $output" 10116d5c3dbf1Smrg echo 'INPUT (' > $output 10117d5c3dbf1Smrg for obj in $save_libobjs 10118d5c3dbf1Smrg do 10119cdbfa18aSmrg func_to_tool_file "$obj" 10120cdbfa18aSmrg $ECHO "$func_to_tool_file_result" >> $output 10121d5c3dbf1Smrg done 10122d5c3dbf1Smrg echo ')' >> $output 10123cdbfa18aSmrg func_append delfiles " $output" 10124cdbfa18aSmrg func_to_tool_file "$output" 10125cdbfa18aSmrg output=$func_to_tool_file_result 10126949d0342Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10127949d0342Smrg output=$output_objdir/$output_la.lnk 10128d5c3dbf1Smrg func_verbose "creating linker input file list: $output" 10129d5c3dbf1Smrg : > $output 10130d5c3dbf1Smrg set x $save_libobjs 10131d5c3dbf1Smrg shift 10132d5c3dbf1Smrg firstobj= 10133949d0342Smrg if test yes = "$compiler_needs_object"; then 10134d5c3dbf1Smrg firstobj="$1 " 10135d5c3dbf1Smrg shift 10136d5c3dbf1Smrg fi 10137d5c3dbf1Smrg for obj 10138d5c3dbf1Smrg do 10139cdbfa18aSmrg func_to_tool_file "$obj" 10140cdbfa18aSmrg $ECHO "$func_to_tool_file_result" >> $output 10141d5c3dbf1Smrg done 10142cdbfa18aSmrg func_append delfiles " $output" 10143cdbfa18aSmrg func_to_tool_file "$output" 10144cdbfa18aSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145d5c3dbf1Smrg else 10146d5c3dbf1Smrg if test -n "$save_libobjs"; then 10147d5c3dbf1Smrg func_verbose "creating reloadable object files..." 10148949d0342Smrg output=$output_objdir/$output_la-$k.$objext 10149d5c3dbf1Smrg eval test_cmds=\"$reload_cmds\" 10150d5c3dbf1Smrg func_len " $test_cmds" 10151d5c3dbf1Smrg len0=$func_len_result 10152d5c3dbf1Smrg len=$len0 10153d5c3dbf1Smrg 10154d5c3dbf1Smrg # Loop over the list of objects to be linked. 10155d5c3dbf1Smrg for obj in $save_libobjs 10156d5c3dbf1Smrg do 10157d5c3dbf1Smrg func_len " $obj" 10158d5c3dbf1Smrg func_arith $len + $func_len_result 10159d5c3dbf1Smrg len=$func_arith_result 10160949d0342Smrg if test -z "$objlist" || 10161d5c3dbf1Smrg test "$len" -lt "$max_cmd_len"; then 10162d5c3dbf1Smrg func_append objlist " $obj" 10163d5c3dbf1Smrg else 10164d5c3dbf1Smrg # The command $test_cmds is almost too long, add a 10165d5c3dbf1Smrg # command to the queue. 10166949d0342Smrg if test 1 -eq "$k"; then 10167d5c3dbf1Smrg # The first file doesn't have a previous command to add. 10168d5c3dbf1Smrg reload_objs=$objlist 10169d5c3dbf1Smrg eval concat_cmds=\"$reload_cmds\" 10170d5c3dbf1Smrg else 10171d5c3dbf1Smrg # All subsequent reloadable object files will link in 10172d5c3dbf1Smrg # the last one created. 10173d5c3dbf1Smrg reload_objs="$objlist $last_robj" 10174d5c3dbf1Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175d5c3dbf1Smrg fi 10176949d0342Smrg last_robj=$output_objdir/$output_la-$k.$objext 10177d5c3dbf1Smrg func_arith $k + 1 10178d5c3dbf1Smrg k=$func_arith_result 10179949d0342Smrg output=$output_objdir/$output_la-$k.$objext 10180d5c3dbf1Smrg objlist=" $obj" 10181d5c3dbf1Smrg func_len " $last_robj" 10182d5c3dbf1Smrg func_arith $len0 + $func_len_result 10183d5c3dbf1Smrg len=$func_arith_result 10184d5c3dbf1Smrg fi 10185d5c3dbf1Smrg done 10186d5c3dbf1Smrg # Handle the remaining objects by creating one last 10187d5c3dbf1Smrg # reloadable object file. All subsequent reloadable object 10188d5c3dbf1Smrg # files will link in the last one created. 10189d5c3dbf1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190d5c3dbf1Smrg reload_objs="$objlist $last_robj" 10191949d0342Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192d5c3dbf1Smrg if test -n "$last_robj"; then 10193949d0342Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194d5c3dbf1Smrg fi 10195cdbfa18aSmrg func_append delfiles " $output" 10196d5c3dbf1Smrg 10197d5c3dbf1Smrg else 10198d5c3dbf1Smrg output= 10199d5c3dbf1Smrg fi 102009f606849Smrg 10201949d0342Smrg ${skipped_export-false} && { 10202949d0342Smrg func_verbose "generating symbol list for '$libname.la'" 10203949d0342Smrg export_symbols=$output_objdir/$libname.exp 10204d5c3dbf1Smrg $opt_dry_run || $RM $export_symbols 10205d5c3dbf1Smrg libobjs=$output 10206d5c3dbf1Smrg # Append the command to create the export file. 10207d5c3dbf1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208d5c3dbf1Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209d5c3dbf1Smrg if test -n "$last_robj"; then 10210d5c3dbf1Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211d5c3dbf1Smrg fi 10212949d0342Smrg } 102139f606849Smrg 10214d5c3dbf1Smrg test -n "$save_libobjs" && 10215d5c3dbf1Smrg func_verbose "creating a temporary reloadable object file: $output" 102169f606849Smrg 10217d5c3dbf1Smrg # Loop through the commands generated above and execute them. 10218949d0342Smrg save_ifs=$IFS; IFS='~' 10219d5c3dbf1Smrg for cmd in $concat_cmds; do 10220949d0342Smrg IFS=$save_ifs 10221949d0342Smrg $opt_quiet || { 10222949d0342Smrg func_quote_arg expand,pretty "$cmd" 10223949d0342Smrg eval "func_echo $func_quote_arg_result" 10224d5c3dbf1Smrg } 10225d5c3dbf1Smrg $opt_dry_run || eval "$cmd" || { 10226d5c3dbf1Smrg lt_exit=$? 10227d5c3dbf1Smrg 10228d5c3dbf1Smrg # Restore the uninstalled library and exit 10229949d0342Smrg if test relink = "$opt_mode"; then 10230d5c3dbf1Smrg ( cd "$output_objdir" && \ 10231d5c3dbf1Smrg $RM "${realname}T" && \ 10232d5c3dbf1Smrg $MV "${realname}U" "$realname" ) 10233d5c3dbf1Smrg fi 102349f606849Smrg 10235d5c3dbf1Smrg exit $lt_exit 10236d5c3dbf1Smrg } 10237d5c3dbf1Smrg done 10238949d0342Smrg IFS=$save_ifs 102399f606849Smrg 10240d5c3dbf1Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241d5c3dbf1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242d5c3dbf1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102439f606849Smrg fi 102449f606849Smrg fi 102459f606849Smrg 10246949d0342Smrg ${skipped_export-false} && { 10247d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10248949d0342Smrg tmp_export_symbols=$export_symbols 10249949d0342Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250d5c3dbf1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251d5c3dbf1Smrg fi 102529f606849Smrg 10253d5c3dbf1Smrg if test -n "$orig_export_symbols"; then 10254d5c3dbf1Smrg # The given exports_symbols file has to be filtered, so filter it. 10255949d0342Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256d5c3dbf1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10257949d0342Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258d5c3dbf1Smrg # though. Also, the filter scales superlinearly with the number of 10259d5c3dbf1Smrg # global variables. join(1) would be nice here, but unfortunately 10260d5c3dbf1Smrg # isn't a blessed tool. 10261d5c3dbf1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262cdbfa18aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263d5c3dbf1Smrg export_symbols=$output_objdir/$libname.def 10264d5c3dbf1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265d5c3dbf1Smrg fi 10266949d0342Smrg } 102679f606849Smrg 10268d5c3dbf1Smrg libobjs=$output 10269d5c3dbf1Smrg # Restore the value of output. 10270d5c3dbf1Smrg output=$save_output 102719f606849Smrg 10272d5c3dbf1Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273d5c3dbf1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 10275d5c3dbf1Smrg fi 10276d5c3dbf1Smrg # Expand the library linking commands again to reset the 10277d5c3dbf1Smrg # value of $libobjs for piecewise linking. 10278d5c3dbf1Smrg 10279d5c3dbf1Smrg # Do each of the archive commands. 10280949d0342Smrg if test yes = "$module" && test -n "$module_cmds"; then 10281d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282d5c3dbf1Smrg cmds=$module_expsym_cmds 102839f606849Smrg else 10284d5c3dbf1Smrg cmds=$module_cmds 102859f606849Smrg fi 102869f606849Smrg else 10287d5c3dbf1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288d5c3dbf1Smrg cmds=$archive_expsym_cmds 10289d5c3dbf1Smrg else 10290d5c3dbf1Smrg cmds=$archive_cmds 10291d5c3dbf1Smrg fi 102929f606849Smrg fi 102939f606849Smrg fi 102949f606849Smrg 10295d5c3dbf1Smrg if test -n "$delfiles"; then 10296d5c3dbf1Smrg # Append the command to remove temporary files to $cmds. 10297d5c3dbf1Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298d5c3dbf1Smrg fi 102999f606849Smrg 10300d5c3dbf1Smrg # Add any objects from preloaded convenience libraries 10301d5c3dbf1Smrg if test -n "$dlprefiles"; then 10302949d0342Smrg gentop=$output_objdir/${outputname}x 10303cdbfa18aSmrg func_append generated " $gentop" 103049f606849Smrg 10305d5c3dbf1Smrg func_extract_archives $gentop $dlprefiles 10306cdbfa18aSmrg func_append libobjs " $func_extract_archives_result" 10307d5c3dbf1Smrg test "X$libobjs" = "X " && libobjs= 103089f606849Smrg fi 103099f606849Smrg 10310949d0342Smrg save_ifs=$IFS; IFS='~' 10311d5c3dbf1Smrg for cmd in $cmds; do 10312949d0342Smrg IFS=$sp$nl 10313d5c3dbf1Smrg eval cmd=\"$cmd\" 10314949d0342Smrg IFS=$save_ifs 10315949d0342Smrg $opt_quiet || { 10316949d0342Smrg func_quote_arg expand,pretty "$cmd" 10317949d0342Smrg eval "func_echo $func_quote_arg_result" 10318d5c3dbf1Smrg } 10319d5c3dbf1Smrg $opt_dry_run || eval "$cmd" || { 10320d5c3dbf1Smrg lt_exit=$? 103219f606849Smrg 10322d5c3dbf1Smrg # Restore the uninstalled library and exit 10323949d0342Smrg if test relink = "$opt_mode"; then 10324d5c3dbf1Smrg ( cd "$output_objdir" && \ 10325d5c3dbf1Smrg $RM "${realname}T" && \ 10326d5c3dbf1Smrg $MV "${realname}U" "$realname" ) 103279f606849Smrg fi 103289f606849Smrg 10329d5c3dbf1Smrg exit $lt_exit 10330d5c3dbf1Smrg } 10331d5c3dbf1Smrg done 10332949d0342Smrg IFS=$save_ifs 103339f606849Smrg 10334d5c3dbf1Smrg # Restore the uninstalled library and exit 10335949d0342Smrg if test relink = "$opt_mode"; then 10336d5c3dbf1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103379f606849Smrg 10338d5c3dbf1Smrg if test -n "$convenience"; then 10339d5c3dbf1Smrg if test -z "$whole_archive_flag_spec"; then 10340d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10341d5c3dbf1Smrg fi 10342d5c3dbf1Smrg fi 103439f606849Smrg 10344d5c3dbf1Smrg exit $EXIT_SUCCESS 10345d5c3dbf1Smrg fi 103469f606849Smrg 10347d5c3dbf1Smrg # Create links to the real library. 10348d5c3dbf1Smrg for linkname in $linknames; do 10349d5c3dbf1Smrg if test "$realname" != "$linkname"; then 10350d5c3dbf1Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351d5c3dbf1Smrg fi 10352d5c3dbf1Smrg done 103539f606849Smrg 10354d5c3dbf1Smrg # If -module or -export-dynamic was specified, set the dlname. 10355949d0342Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356d5c3dbf1Smrg # On all known operating systems, these are identical. 10357949d0342Smrg dlname=$soname 10358d5c3dbf1Smrg fi 10359d5c3dbf1Smrg fi 10360d5c3dbf1Smrg ;; 103619f606849Smrg 10362d5c3dbf1Smrg obj) 10363949d0342Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10364949d0342Smrg func_warning "'-dlopen' is ignored for objects" 10365d5c3dbf1Smrg fi 103669f606849Smrg 10367d5c3dbf1Smrg case " $deplibs" in 10368d5c3dbf1Smrg *\ -l* | *\ -L*) 10369949d0342Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370d5c3dbf1Smrg esac 103719f606849Smrg 10372d5c3dbf1Smrg test -n "$rpath" && \ 10373949d0342Smrg func_warning "'-rpath' is ignored for objects" 103749f606849Smrg 10375d5c3dbf1Smrg test -n "$xrpath" && \ 10376949d0342Smrg func_warning "'-R' is ignored for objects" 10377d5c3dbf1Smrg 10378d5c3dbf1Smrg test -n "$vinfo" && \ 10379949d0342Smrg func_warning "'-version-info' is ignored for objects" 103809f606849Smrg 10381d5c3dbf1Smrg test -n "$release" && \ 10382949d0342Smrg func_warning "'-release' is ignored for objects" 103839f606849Smrg 10384d5c3dbf1Smrg case $output in 10385d5c3dbf1Smrg *.lo) 10386d5c3dbf1Smrg test -n "$objs$old_deplibs" && \ 10387949d0342Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388d5c3dbf1Smrg 10389d5c3dbf1Smrg libobj=$output 10390d5c3dbf1Smrg func_lo2o "$libobj" 10391d5c3dbf1Smrg obj=$func_lo2o_result 10392d5c3dbf1Smrg ;; 10393d5c3dbf1Smrg *) 10394d5c3dbf1Smrg libobj= 10395949d0342Smrg obj=$output 103969f606849Smrg ;; 103979f606849Smrg esac 103989f606849Smrg 10399d5c3dbf1Smrg # Delete the old objects. 10400d5c3dbf1Smrg $opt_dry_run || $RM $obj $libobj 104019f606849Smrg 10402d5c3dbf1Smrg # Objects from convenience libraries. This assumes 10403d5c3dbf1Smrg # single-version convenience libraries. Whenever we create 10404d5c3dbf1Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405d5c3dbf1Smrg # the extraction. 10406d5c3dbf1Smrg reload_conv_objs= 10407d5c3dbf1Smrg gentop= 10408949d0342Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10409949d0342Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10410949d0342Smrg # into space. 10411949d0342Smrg case $reload_cmds in 10412949d0342Smrg *\$LD[\ \$]*) wl= ;; 10413949d0342Smrg esac 10414d5c3dbf1Smrg if test -n "$convenience"; then 10415d5c3dbf1Smrg if test -n "$whole_archive_flag_spec"; then 10416d5c3dbf1Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10417949d0342Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10418949d0342Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 104199f606849Smrg else 10420949d0342Smrg gentop=$output_objdir/${obj}x 10421cdbfa18aSmrg func_append generated " $gentop" 10422d5c3dbf1Smrg 10423d5c3dbf1Smrg func_extract_archives $gentop $convenience 10424d5c3dbf1Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 104259f606849Smrg fi 10426d5c3dbf1Smrg fi 104279f606849Smrg 10428cdbfa18aSmrg # If we're not building shared, we need to use non_pic_objs 10429949d0342Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430cdbfa18aSmrg 10431d5c3dbf1Smrg # Create the old-style object. 10432949d0342Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104339f606849Smrg 10434949d0342Smrg output=$obj 10435d5c3dbf1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104369f606849Smrg 10437d5c3dbf1Smrg # Exit if we aren't doing a library object file. 10438d5c3dbf1Smrg if test -z "$libobj"; then 10439d5c3dbf1Smrg if test -n "$gentop"; then 10440d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10441d5c3dbf1Smrg fi 104429f606849Smrg 10443d5c3dbf1Smrg exit $EXIT_SUCCESS 104449f606849Smrg fi 104459f606849Smrg 10446949d0342Smrg test yes = "$build_libtool_libs" || { 10447d5c3dbf1Smrg if test -n "$gentop"; then 10448d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10449d5c3dbf1Smrg fi 104509f606849Smrg 10451d5c3dbf1Smrg # Create an invalid libtool object if no PIC, so that we don't 10452d5c3dbf1Smrg # accidentally link it into a program. 10453d5c3dbf1Smrg # $show "echo timestamp > $libobj" 10454d5c3dbf1Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455d5c3dbf1Smrg exit $EXIT_SUCCESS 10456949d0342Smrg } 104579f606849Smrg 10458949d0342Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459d5c3dbf1Smrg # Only do commands if we really have different PIC objects. 10460d5c3dbf1Smrg reload_objs="$libobjs $reload_conv_objs" 10461949d0342Smrg output=$libobj 10462d5c3dbf1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104639f606849Smrg fi 10464d5c3dbf1Smrg 10465d5c3dbf1Smrg if test -n "$gentop"; then 10466d5c3dbf1Smrg func_show_eval '${RM}r "$gentop"' 10467d5c3dbf1Smrg fi 10468d5c3dbf1Smrg 10469d5c3dbf1Smrg exit $EXIT_SUCCESS 104709f606849Smrg ;; 104719f606849Smrg 10472d5c3dbf1Smrg prog) 10473d5c3dbf1Smrg case $host in 10474d5c3dbf1Smrg *cygwin*) func_stripname '' '.exe' "$output" 10475d5c3dbf1Smrg output=$func_stripname_result.exe;; 10476d5c3dbf1Smrg esac 10477d5c3dbf1Smrg test -n "$vinfo" && \ 10478949d0342Smrg func_warning "'-version-info' is ignored for programs" 104799f606849Smrg 10480d5c3dbf1Smrg test -n "$release" && \ 10481949d0342Smrg func_warning "'-release' is ignored for programs" 104829f606849Smrg 10483949d0342Smrg $preload \ 10484949d0342Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10485949d0342Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486d5c3dbf1Smrg 10487d5c3dbf1Smrg case $host in 10488d5c3dbf1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10489d5c3dbf1Smrg # On Rhapsody replace the C library is the System framework 10490d5c3dbf1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491d5c3dbf1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 104929f606849Smrg ;; 10493d5c3dbf1Smrg esac 104949f606849Smrg 10495d5c3dbf1Smrg case $host in 10496d5c3dbf1Smrg *-*-darwin*) 10497d5c3dbf1Smrg # Don't allow lazy linking, it breaks C++ global constructors 10498d5c3dbf1Smrg # But is supposedly fixed on 10.4 or later (yay!). 10499949d0342Smrg if test CXX = "$tagname"; then 10500d5c3dbf1Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501d5c3dbf1Smrg 10.[0123]) 10502949d0342Smrg func_append compile_command " $wl-bind_at_load" 10503949d0342Smrg func_append finalize_command " $wl-bind_at_load" 10504d5c3dbf1Smrg ;; 10505d5c3dbf1Smrg esac 105069f606849Smrg fi 10507d5c3dbf1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508d5c3dbf1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509d5c3dbf1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510d5c3dbf1Smrg ;; 10511d5c3dbf1Smrg esac 105129f606849Smrg 105139f606849Smrg 10514d5c3dbf1Smrg # move library search paths that coincide with paths to not yet 10515d5c3dbf1Smrg # installed libraries to the beginning of the library search list 10516d5c3dbf1Smrg new_libs= 10517d5c3dbf1Smrg for path in $notinst_path; do 10518d5c3dbf1Smrg case " $new_libs " in 10519d5c3dbf1Smrg *" -L$path/$objdir "*) ;; 10520d5c3dbf1Smrg *) 10521d5c3dbf1Smrg case " $compile_deplibs " in 10522d5c3dbf1Smrg *" -L$path/$objdir "*) 10523cdbfa18aSmrg func_append new_libs " -L$path/$objdir" ;; 105249f606849Smrg esac 10525d5c3dbf1Smrg ;; 10526d5c3dbf1Smrg esac 10527d5c3dbf1Smrg done 10528d5c3dbf1Smrg for deplib in $compile_deplibs; do 10529d5c3dbf1Smrg case $deplib in 10530d5c3dbf1Smrg -L*) 10531d5c3dbf1Smrg case " $new_libs " in 10532d5c3dbf1Smrg *" $deplib "*) ;; 10533cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 105349f606849Smrg esac 10535d5c3dbf1Smrg ;; 10536cdbfa18aSmrg *) func_append new_libs " $deplib" ;; 10537d5c3dbf1Smrg esac 10538d5c3dbf1Smrg done 10539949d0342Smrg compile_deplibs=$new_libs 105409f606849Smrg 105419f606849Smrg 10542cdbfa18aSmrg func_append compile_command " $compile_deplibs" 10543cdbfa18aSmrg func_append finalize_command " $finalize_deplibs" 105449f606849Smrg 10545d5c3dbf1Smrg if test -n "$rpath$xrpath"; then 10546d5c3dbf1Smrg # If the user specified any rpath flags, then add them. 10547d5c3dbf1Smrg for libdir in $rpath $xrpath; do 10548d5c3dbf1Smrg # This is the magic to use -rpath. 10549d5c3dbf1Smrg case "$finalize_rpath " in 10550d5c3dbf1Smrg *" $libdir "*) ;; 10551cdbfa18aSmrg *) func_append finalize_rpath " $libdir" ;; 10552d5c3dbf1Smrg esac 10553d5c3dbf1Smrg done 10554d5c3dbf1Smrg fi 105559f606849Smrg 10556d5c3dbf1Smrg # Now hardcode the library paths 10557d5c3dbf1Smrg rpath= 10558d5c3dbf1Smrg hardcode_libdirs= 10559d5c3dbf1Smrg for libdir in $compile_rpath $finalize_rpath; do 10560d5c3dbf1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10561d5c3dbf1Smrg if test -n "$hardcode_libdir_separator"; then 10562d5c3dbf1Smrg if test -z "$hardcode_libdirs"; then 10563949d0342Smrg hardcode_libdirs=$libdir 10564d5c3dbf1Smrg else 10565d5c3dbf1Smrg # Just accumulate the unique libdirs. 10566d5c3dbf1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567d5c3dbf1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568d5c3dbf1Smrg ;; 10569d5c3dbf1Smrg *) 10570cdbfa18aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571d5c3dbf1Smrg ;; 10572d5c3dbf1Smrg esac 10573d5c3dbf1Smrg fi 105749f606849Smrg else 10575d5c3dbf1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10576cdbfa18aSmrg func_append rpath " $flag" 105779f606849Smrg fi 10578d5c3dbf1Smrg elif test -n "$runpath_var"; then 10579d5c3dbf1Smrg case "$perm_rpath " in 10580d5c3dbf1Smrg *" $libdir "*) ;; 10581cdbfa18aSmrg *) func_append perm_rpath " $libdir" ;; 10582d5c3dbf1Smrg esac 10583d5c3dbf1Smrg fi 10584d5c3dbf1Smrg case $host in 10585d5c3dbf1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10586949d0342Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587d5c3dbf1Smrg case :$dllsearchpath: in 10588d5c3dbf1Smrg *":$libdir:"*) ;; 10589d5c3dbf1Smrg ::) dllsearchpath=$libdir;; 10590cdbfa18aSmrg *) func_append dllsearchpath ":$libdir";; 10591d5c3dbf1Smrg esac 10592d5c3dbf1Smrg case :$dllsearchpath: in 10593d5c3dbf1Smrg *":$testbindir:"*) ;; 10594d5c3dbf1Smrg ::) dllsearchpath=$testbindir;; 10595cdbfa18aSmrg *) func_append dllsearchpath ":$testbindir";; 10596d5c3dbf1Smrg esac 10597d5c3dbf1Smrg ;; 10598d5c3dbf1Smrg esac 10599d5c3dbf1Smrg done 10600d5c3dbf1Smrg # Substitute the hardcoded libdirs into the rpath. 10601d5c3dbf1Smrg if test -n "$hardcode_libdir_separator" && 10602d5c3dbf1Smrg test -n "$hardcode_libdirs"; then 10603949d0342Smrg libdir=$hardcode_libdirs 10604d5c3dbf1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605d5c3dbf1Smrg fi 10606949d0342Smrg compile_rpath=$rpath 106079f606849Smrg 10608d5c3dbf1Smrg rpath= 10609d5c3dbf1Smrg hardcode_libdirs= 10610d5c3dbf1Smrg for libdir in $finalize_rpath; do 10611d5c3dbf1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10612d5c3dbf1Smrg if test -n "$hardcode_libdir_separator"; then 10613d5c3dbf1Smrg if test -z "$hardcode_libdirs"; then 10614949d0342Smrg hardcode_libdirs=$libdir 10615d5c3dbf1Smrg else 10616d5c3dbf1Smrg # Just accumulate the unique libdirs. 10617d5c3dbf1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618d5c3dbf1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619d5c3dbf1Smrg ;; 10620d5c3dbf1Smrg *) 10621cdbfa18aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622d5c3dbf1Smrg ;; 10623d5c3dbf1Smrg esac 10624d5c3dbf1Smrg fi 106259f606849Smrg else 10626d5c3dbf1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10627cdbfa18aSmrg func_append rpath " $flag" 106289f606849Smrg fi 10629d5c3dbf1Smrg elif test -n "$runpath_var"; then 10630d5c3dbf1Smrg case "$finalize_perm_rpath " in 10631d5c3dbf1Smrg *" $libdir "*) ;; 10632cdbfa18aSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10633d5c3dbf1Smrg esac 106349f606849Smrg fi 10635d5c3dbf1Smrg done 10636d5c3dbf1Smrg # Substitute the hardcoded libdirs into the rpath. 10637d5c3dbf1Smrg if test -n "$hardcode_libdir_separator" && 10638d5c3dbf1Smrg test -n "$hardcode_libdirs"; then 10639949d0342Smrg libdir=$hardcode_libdirs 10640d5c3dbf1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641d5c3dbf1Smrg fi 10642949d0342Smrg finalize_rpath=$rpath 106439f606849Smrg 10644949d0342Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645d5c3dbf1Smrg # Transform all the library objects into standard objects. 10646d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647d5c3dbf1Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648d5c3dbf1Smrg fi 106499f606849Smrg 10650949d0342Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106519f606849Smrg 10652d5c3dbf1Smrg # template prelinking step 10653d5c3dbf1Smrg if test -n "$prelink_cmds"; then 10654d5c3dbf1Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655d5c3dbf1Smrg fi 106569f606849Smrg 10657949d0342Smrg wrappers_required=: 10658d5c3dbf1Smrg case $host in 10659d5c3dbf1Smrg *cegcc* | *mingw32ce*) 10660d5c3dbf1Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10661949d0342Smrg wrappers_required=false 10662d5c3dbf1Smrg ;; 10663d5c3dbf1Smrg *cygwin* | *mingw* ) 10664949d0342Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10665d5c3dbf1Smrg ;; 10666d5c3dbf1Smrg *) 10667949d0342Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10668949d0342Smrg wrappers_required=false 10669d5c3dbf1Smrg fi 10670d5c3dbf1Smrg ;; 10671d5c3dbf1Smrg esac 10672949d0342Smrg $wrappers_required || { 10673d5c3dbf1Smrg # Replace the output file specification. 10674d5c3dbf1Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10675949d0342Smrg link_command=$compile_command$compile_rpath 106769f606849Smrg 10677d5c3dbf1Smrg # We have no uninstalled library dependencies, so finalize right now. 10678d5c3dbf1Smrg exit_status=0 10679d5c3dbf1Smrg func_show_eval "$link_command" 'exit_status=$?' 106809f606849Smrg 10681cdbfa18aSmrg if test -n "$postlink_cmds"; then 10682cdbfa18aSmrg func_to_tool_file "$output" 10683cdbfa18aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684cdbfa18aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685cdbfa18aSmrg fi 10686cdbfa18aSmrg 10687d5c3dbf1Smrg # Delete the generated files. 10688949d0342Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10689949d0342Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 106909f606849Smrg fi 106919f606849Smrg 10692d5c3dbf1Smrg exit $exit_status 10693949d0342Smrg } 106949f606849Smrg 10695d5c3dbf1Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696d5c3dbf1Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697d5c3dbf1Smrg fi 10698d5c3dbf1Smrg if test -n "$finalize_shlibpath"; then 10699d5c3dbf1Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700d5c3dbf1Smrg fi 107019f606849Smrg 10702d5c3dbf1Smrg compile_var= 10703d5c3dbf1Smrg finalize_var= 10704d5c3dbf1Smrg if test -n "$runpath_var"; then 10705d5c3dbf1Smrg if test -n "$perm_rpath"; then 10706d5c3dbf1Smrg # We should set the runpath_var. 10707d5c3dbf1Smrg rpath= 10708d5c3dbf1Smrg for dir in $perm_rpath; do 10709cdbfa18aSmrg func_append rpath "$dir:" 10710d5c3dbf1Smrg done 10711d5c3dbf1Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107129f606849Smrg fi 10713d5c3dbf1Smrg if test -n "$finalize_perm_rpath"; then 10714d5c3dbf1Smrg # We should set the runpath_var. 10715d5c3dbf1Smrg rpath= 10716d5c3dbf1Smrg for dir in $finalize_perm_rpath; do 10717cdbfa18aSmrg func_append rpath "$dir:" 10718d5c3dbf1Smrg done 10719d5c3dbf1Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107209f606849Smrg fi 10721d5c3dbf1Smrg fi 107229f606849Smrg 10723949d0342Smrg if test yes = "$no_install"; then 10724d5c3dbf1Smrg # We don't need to create a wrapper script. 10725949d0342Smrg link_command=$compile_var$compile_command$compile_rpath 10726d5c3dbf1Smrg # Replace the output file specification. 10727d5c3dbf1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728d5c3dbf1Smrg # Delete the old output file. 10729d5c3dbf1Smrg $opt_dry_run || $RM $output 10730d5c3dbf1Smrg # Link the executable and exit 10731d5c3dbf1Smrg func_show_eval "$link_command" 'exit $?' 10732cdbfa18aSmrg 10733cdbfa18aSmrg if test -n "$postlink_cmds"; then 10734cdbfa18aSmrg func_to_tool_file "$output" 10735cdbfa18aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736cdbfa18aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737cdbfa18aSmrg fi 10738cdbfa18aSmrg 107399f606849Smrg exit $EXIT_SUCCESS 10740d5c3dbf1Smrg fi 107419f606849Smrg 10742949d0342Smrg case $hardcode_action,$fast_install in 10743949d0342Smrg relink,*) 10744949d0342Smrg # Fast installation is not supported 10745949d0342Smrg link_command=$compile_var$compile_command$compile_rpath 10746949d0342Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747d5c3dbf1Smrg 10748949d0342Smrg func_warning "this platform does not like uninstalled shared libraries" 10749949d0342Smrg func_warning "'$output' will be relinked during installation" 10750949d0342Smrg ;; 10751949d0342Smrg *,yes) 10752949d0342Smrg link_command=$finalize_var$compile_command$finalize_rpath 10753949d0342Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10754949d0342Smrg ;; 10755949d0342Smrg *,no) 10756949d0342Smrg link_command=$compile_var$compile_command$compile_rpath 10757949d0342Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10758949d0342Smrg ;; 10759949d0342Smrg *,needless) 10760949d0342Smrg link_command=$finalize_var$compile_command$finalize_rpath 10761949d0342Smrg relink_command= 10762949d0342Smrg ;; 10763949d0342Smrg esac 107649f606849Smrg 10765d5c3dbf1Smrg # Replace the output file specification. 10766d5c3dbf1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107679f606849Smrg 10768d5c3dbf1Smrg # Delete the old output files. 10769d5c3dbf1Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107709f606849Smrg 10771d5c3dbf1Smrg func_show_eval "$link_command" 'exit $?' 107729f606849Smrg 10773cdbfa18aSmrg if test -n "$postlink_cmds"; then 10774cdbfa18aSmrg func_to_tool_file "$output_objdir/$outputname" 10775cdbfa18aSmrg 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'` 10776cdbfa18aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777cdbfa18aSmrg fi 10778cdbfa18aSmrg 10779d5c3dbf1Smrg # Now create the wrapper script. 10780d5c3dbf1Smrg func_verbose "creating $output" 107819f606849Smrg 10782d5c3dbf1Smrg # Quote the relink command for shipping. 10783d5c3dbf1Smrg if test -n "$relink_command"; then 10784d5c3dbf1Smrg # Preserve any variables that may affect compiler behavior 10785d5c3dbf1Smrg for var in $variables_saved_for_relink; do 10786d5c3dbf1Smrg if eval test -z \"\${$var+set}\"; then 10787d5c3dbf1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788d5c3dbf1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10789d5c3dbf1Smrg relink_command="$var=; export $var; $relink_command" 107909f606849Smrg else 10791949d0342Smrg func_quote_arg pretty "$var_value" 10792949d0342Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 107939f606849Smrg fi 10794d5c3dbf1Smrg done 10795949d0342Smrg func_quote eval cd "`pwd`" 10796949d0342Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10797949d0342Smrg relink_command=$func_quote_arg_unquoted_result 10798d5c3dbf1Smrg fi 107999f606849Smrg 10800d5c3dbf1Smrg # Only actually do things if not in dry run mode. 10801d5c3dbf1Smrg $opt_dry_run || { 10802d5c3dbf1Smrg # win32 will think the script is a binary if it has 10803d5c3dbf1Smrg # a .exe suffix, so we strip it off here. 10804d5c3dbf1Smrg case $output in 10805d5c3dbf1Smrg *.exe) func_stripname '' '.exe' "$output" 10806d5c3dbf1Smrg output=$func_stripname_result ;; 10807d5c3dbf1Smrg esac 10808d5c3dbf1Smrg # test for cygwin because mv fails w/o .exe extensions 10809d5c3dbf1Smrg case $host in 10810d5c3dbf1Smrg *cygwin*) 10811d5c3dbf1Smrg exeext=.exe 10812d5c3dbf1Smrg func_stripname '' '.exe' "$outputname" 10813d5c3dbf1Smrg outputname=$func_stripname_result ;; 10814d5c3dbf1Smrg *) exeext= ;; 108159f606849Smrg esac 10816d5c3dbf1Smrg case $host in 10817d5c3dbf1Smrg *cygwin* | *mingw* ) 10818d5c3dbf1Smrg func_dirname_and_basename "$output" "" "." 10819d5c3dbf1Smrg output_name=$func_basename_result 10820d5c3dbf1Smrg output_path=$func_dirname_result 10821949d0342Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10822949d0342Smrg cwrapper=$output_path/$output_name.exe 10823d5c3dbf1Smrg $RM $cwrappersource $cwrapper 10824d5c3dbf1Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825d5c3dbf1Smrg 10826d5c3dbf1Smrg func_emit_cwrapperexe_src > $cwrappersource 10827d5c3dbf1Smrg 10828d5c3dbf1Smrg # The wrapper executable is built using the $host compiler, 10829d5c3dbf1Smrg # because it contains $host paths and files. If cross- 10830d5c3dbf1Smrg # compiling, it, like the target executable, must be 10831d5c3dbf1Smrg # executed on the $host or under an emulation environment. 10832d5c3dbf1Smrg $opt_dry_run || { 10833d5c3dbf1Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834d5c3dbf1Smrg $STRIP $cwrapper 10835d5c3dbf1Smrg } 108369f606849Smrg 10837d5c3dbf1Smrg # Now, create the wrapper script for func_source use: 10838d5c3dbf1Smrg func_ltwrapper_scriptname $cwrapper 10839d5c3dbf1Smrg $RM $func_ltwrapper_scriptname_result 10840d5c3dbf1Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841d5c3dbf1Smrg $opt_dry_run || { 10842d5c3dbf1Smrg # note: this script will not be executed, so do not chmod. 10843949d0342Smrg if test "x$build" = "x$host"; then 10844d5c3dbf1Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845d5c3dbf1Smrg else 10846d5c3dbf1Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847d5c3dbf1Smrg fi 10848d5c3dbf1Smrg } 10849d5c3dbf1Smrg ;; 10850d5c3dbf1Smrg * ) 10851d5c3dbf1Smrg $RM $output 10852d5c3dbf1Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108539f606849Smrg 10854d5c3dbf1Smrg func_emit_wrapper no > $output 10855d5c3dbf1Smrg chmod +x $output 10856d5c3dbf1Smrg ;; 10857d5c3dbf1Smrg esac 10858d5c3dbf1Smrg } 10859d5c3dbf1Smrg exit $EXIT_SUCCESS 10860d5c3dbf1Smrg ;; 10861d5c3dbf1Smrg esac 108629f606849Smrg 10863d5c3dbf1Smrg # See if we need to build an old-fashioned archive. 10864d5c3dbf1Smrg for oldlib in $oldlibs; do 108659f606849Smrg 10866949d0342Smrg case $build_libtool_libs in 10867949d0342Smrg convenience) 10868949d0342Smrg oldobjs="$libobjs_save $symfileobj" 10869949d0342Smrg addlibs=$convenience 10870d5c3dbf1Smrg build_libtool_libs=no 10871949d0342Smrg ;; 10872949d0342Smrg module) 10873949d0342Smrg oldobjs=$libobjs_save 10874949d0342Smrg addlibs=$old_convenience 10875949d0342Smrg build_libtool_libs=no 10876949d0342Smrg ;; 10877949d0342Smrg *) 10878d5c3dbf1Smrg oldobjs="$old_deplibs $non_pic_objects" 10879949d0342Smrg $preload && test -f "$symfileobj" \ 10880949d0342Smrg && func_append oldobjs " $symfileobj" 10881949d0342Smrg addlibs=$old_convenience 10882949d0342Smrg ;; 10883949d0342Smrg esac 108849f606849Smrg 10885d5c3dbf1Smrg if test -n "$addlibs"; then 10886949d0342Smrg gentop=$output_objdir/${outputname}x 10887cdbfa18aSmrg func_append generated " $gentop" 108889f606849Smrg 10889d5c3dbf1Smrg func_extract_archives $gentop $addlibs 10890cdbfa18aSmrg func_append oldobjs " $func_extract_archives_result" 10891d5c3dbf1Smrg fi 108929f606849Smrg 10893d5c3dbf1Smrg # Do each command in the archive commands. 10894949d0342Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895d5c3dbf1Smrg cmds=$old_archive_from_new_cmds 10896d5c3dbf1Smrg else 108979f606849Smrg 10898d5c3dbf1Smrg # Add any objects from preloaded convenience libraries 10899d5c3dbf1Smrg if test -n "$dlprefiles"; then 10900949d0342Smrg gentop=$output_objdir/${outputname}x 10901cdbfa18aSmrg func_append generated " $gentop" 109029f606849Smrg 10903d5c3dbf1Smrg func_extract_archives $gentop $dlprefiles 10904cdbfa18aSmrg func_append oldobjs " $func_extract_archives_result" 10905d5c3dbf1Smrg fi 109069f606849Smrg 10907d5c3dbf1Smrg # POSIX demands no paths to be encoded in archives. We have 10908d5c3dbf1Smrg # to avoid creating archives with duplicate basenames if we 10909d5c3dbf1Smrg # might have to extract them afterwards, e.g., when creating a 10910d5c3dbf1Smrg # static archive out of a convenience library, or when linking 10911d5c3dbf1Smrg # the entirety of a libtool archive into another (currently 10912d5c3dbf1Smrg # not supported by libtool). 10913d5c3dbf1Smrg if (for obj in $oldobjs 10914d5c3dbf1Smrg do 10915d5c3dbf1Smrg func_basename "$obj" 10916d5c3dbf1Smrg $ECHO "$func_basename_result" 10917d5c3dbf1Smrg done | sort | sort -uc >/dev/null 2>&1); then 10918d5c3dbf1Smrg : 10919d5c3dbf1Smrg else 10920d5c3dbf1Smrg echo "copying selected object files to avoid basename conflicts..." 10921949d0342Smrg gentop=$output_objdir/${outputname}x 10922cdbfa18aSmrg func_append generated " $gentop" 10923d5c3dbf1Smrg func_mkdir_p "$gentop" 10924d5c3dbf1Smrg save_oldobjs=$oldobjs 10925d5c3dbf1Smrg oldobjs= 10926d5c3dbf1Smrg counter=1 10927d5c3dbf1Smrg for obj in $save_oldobjs 10928d5c3dbf1Smrg do 10929d5c3dbf1Smrg func_basename "$obj" 10930949d0342Smrg objbase=$func_basename_result 10931d5c3dbf1Smrg case " $oldobjs " in 10932d5c3dbf1Smrg " ") oldobjs=$obj ;; 10933d5c3dbf1Smrg *[\ /]"$objbase "*) 10934d5c3dbf1Smrg while :; do 10935d5c3dbf1Smrg # Make sure we don't pick an alternate name that also 10936d5c3dbf1Smrg # overlaps. 10937d5c3dbf1Smrg newobj=lt$counter-$objbase 10938d5c3dbf1Smrg func_arith $counter + 1 10939d5c3dbf1Smrg counter=$func_arith_result 10940d5c3dbf1Smrg case " $oldobjs " in 10941d5c3dbf1Smrg *[\ /]"$newobj "*) ;; 10942d5c3dbf1Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943d5c3dbf1Smrg esac 10944d5c3dbf1Smrg done 10945d5c3dbf1Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946cdbfa18aSmrg func_append oldobjs " $gentop/$newobj" 10947d5c3dbf1Smrg ;; 10948cdbfa18aSmrg *) func_append oldobjs " $obj" ;; 10949d5c3dbf1Smrg esac 109509f606849Smrg done 109519f606849Smrg fi 10952cdbfa18aSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953cdbfa18aSmrg tool_oldlib=$func_to_tool_file_result 10954d5c3dbf1Smrg eval cmds=\"$old_archive_cmds\" 109559f606849Smrg 10956d5c3dbf1Smrg func_len " $cmds" 10957d5c3dbf1Smrg len=$func_len_result 10958d5c3dbf1Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959d5c3dbf1Smrg cmds=$old_archive_cmds 10960cdbfa18aSmrg elif test -n "$archiver_list_spec"; then 10961cdbfa18aSmrg func_verbose "using command file archive linking..." 10962cdbfa18aSmrg for obj in $oldobjs 10963cdbfa18aSmrg do 10964cdbfa18aSmrg func_to_tool_file "$obj" 10965cdbfa18aSmrg $ECHO "$func_to_tool_file_result" 10966cdbfa18aSmrg done > $output_objdir/$libname.libcmd 10967cdbfa18aSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968cdbfa18aSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969cdbfa18aSmrg cmds=$old_archive_cmds 10970d5c3dbf1Smrg else 10971d5c3dbf1Smrg # the command line is too long to link in one step, link in parts 10972d5c3dbf1Smrg func_verbose "using piecewise archive linking..." 10973d5c3dbf1Smrg save_RANLIB=$RANLIB 10974d5c3dbf1Smrg RANLIB=: 10975d5c3dbf1Smrg objlist= 10976d5c3dbf1Smrg concat_cmds= 10977d5c3dbf1Smrg save_oldobjs=$oldobjs 10978d5c3dbf1Smrg oldobjs= 10979d5c3dbf1Smrg # Is there a better way of finding the last object in the list? 10980d5c3dbf1Smrg for obj in $save_oldobjs 10981d5c3dbf1Smrg do 10982d5c3dbf1Smrg last_oldobj=$obj 10983d5c3dbf1Smrg done 10984d5c3dbf1Smrg eval test_cmds=\"$old_archive_cmds\" 10985d5c3dbf1Smrg func_len " $test_cmds" 10986d5c3dbf1Smrg len0=$func_len_result 10987d5c3dbf1Smrg len=$len0 10988d5c3dbf1Smrg for obj in $save_oldobjs 10989d5c3dbf1Smrg do 10990d5c3dbf1Smrg func_len " $obj" 10991d5c3dbf1Smrg func_arith $len + $func_len_result 10992d5c3dbf1Smrg len=$func_arith_result 10993d5c3dbf1Smrg func_append objlist " $obj" 10994d5c3dbf1Smrg if test "$len" -lt "$max_cmd_len"; then 10995d5c3dbf1Smrg : 10996d5c3dbf1Smrg else 10997d5c3dbf1Smrg # the above command should be used before it gets too long 10998d5c3dbf1Smrg oldobjs=$objlist 10999949d0342Smrg if test "$obj" = "$last_oldobj"; then 11000d5c3dbf1Smrg RANLIB=$save_RANLIB 11001d5c3dbf1Smrg fi 11002d5c3dbf1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11003949d0342Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004d5c3dbf1Smrg objlist= 11005d5c3dbf1Smrg len=$len0 11006d5c3dbf1Smrg fi 11007d5c3dbf1Smrg done 11008d5c3dbf1Smrg RANLIB=$save_RANLIB 11009d5c3dbf1Smrg oldobjs=$objlist 11010949d0342Smrg if test -z "$oldobjs"; then 11011d5c3dbf1Smrg eval cmds=\"\$concat_cmds\" 11012d5c3dbf1Smrg else 11013d5c3dbf1Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014d5c3dbf1Smrg fi 11015d5c3dbf1Smrg fi 11016d5c3dbf1Smrg fi 11017d5c3dbf1Smrg func_execute_cmds "$cmds" 'exit $?' 110189f606849Smrg done 110199f606849Smrg 11020d5c3dbf1Smrg test -n "$generated" && \ 11021d5c3dbf1Smrg func_show_eval "${RM}r$generated" 110229f606849Smrg 11023d5c3dbf1Smrg # Now create the libtool archive. 11024d5c3dbf1Smrg case $output in 11025d5c3dbf1Smrg *.la) 11026d5c3dbf1Smrg old_library= 11027949d0342Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028d5c3dbf1Smrg func_verbose "creating $output" 110299f606849Smrg 11030d5c3dbf1Smrg # Preserve any variables that may affect compiler behavior 11031d5c3dbf1Smrg for var in $variables_saved_for_relink; do 11032d5c3dbf1Smrg if eval test -z \"\${$var+set}\"; then 11033d5c3dbf1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034d5c3dbf1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 11035d5c3dbf1Smrg relink_command="$var=; export $var; $relink_command" 110369f606849Smrg else 11037949d0342Smrg func_quote_arg pretty,unquoted "$var_value" 11038949d0342Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110399f606849Smrg fi 11040d5c3dbf1Smrg done 11041d5c3dbf1Smrg # Quote the link command for shipping. 11042949d0342Smrg func_quote eval cd "`pwd`" 11043949d0342Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11044949d0342Smrg func_quote_arg pretty,unquoted "$relink_command" 11045949d0342Smrg relink_command=$func_quote_arg_unquoted_result 11046949d0342Smrg if test yes = "$hardcode_automatic"; then 11047d5c3dbf1Smrg relink_command= 11048d5c3dbf1Smrg fi 110499f606849Smrg 11050d5c3dbf1Smrg # Only create the output if not a dry run. 11051d5c3dbf1Smrg $opt_dry_run || { 11052d5c3dbf1Smrg for installed in no yes; do 11053949d0342Smrg if test yes = "$installed"; then 11054d5c3dbf1Smrg if test -z "$install_libdir"; then 11055d5c3dbf1Smrg break 11056d5c3dbf1Smrg fi 11057949d0342Smrg output=$output_objdir/${outputname}i 11058d5c3dbf1Smrg # Replace all uninstalled libtool libraries with the installed ones 11059d5c3dbf1Smrg newdependency_libs= 11060d5c3dbf1Smrg for deplib in $dependency_libs; do 11061d5c3dbf1Smrg case $deplib in 11062d5c3dbf1Smrg *.la) 11063d5c3dbf1Smrg func_basename "$deplib" 11064949d0342Smrg name=$func_basename_result 11065cdbfa18aSmrg func_resolve_sysroot "$deplib" 11066949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067d5c3dbf1Smrg test -z "$libdir" && \ 11068949d0342Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069cdbfa18aSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070cdbfa18aSmrg ;; 11071cdbfa18aSmrg -L*) 11072cdbfa18aSmrg func_stripname -L '' "$deplib" 11073cdbfa18aSmrg func_replace_sysroot "$func_stripname_result" 11074cdbfa18aSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075cdbfa18aSmrg ;; 11076cdbfa18aSmrg -R*) 11077cdbfa18aSmrg func_stripname -R '' "$deplib" 11078cdbfa18aSmrg func_replace_sysroot "$func_stripname_result" 11079cdbfa18aSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080d5c3dbf1Smrg ;; 11081cdbfa18aSmrg *) func_append newdependency_libs " $deplib" ;; 11082d5c3dbf1Smrg esac 11083d5c3dbf1Smrg done 11084949d0342Smrg dependency_libs=$newdependency_libs 11085d5c3dbf1Smrg newdlfiles= 11086d5c3dbf1Smrg 11087d5c3dbf1Smrg for lib in $dlfiles; do 11088d5c3dbf1Smrg case $lib in 11089d5c3dbf1Smrg *.la) 11090d5c3dbf1Smrg func_basename "$lib" 11091949d0342Smrg name=$func_basename_result 11092949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093d5c3dbf1Smrg test -z "$libdir" && \ 11094949d0342Smrg func_fatal_error "'$lib' is not a valid libtool archive" 11095cdbfa18aSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096d5c3dbf1Smrg ;; 11097cdbfa18aSmrg *) func_append newdlfiles " $lib" ;; 11098d5c3dbf1Smrg esac 11099d5c3dbf1Smrg done 11100949d0342Smrg dlfiles=$newdlfiles 11101d5c3dbf1Smrg newdlprefiles= 11102d5c3dbf1Smrg for lib in $dlprefiles; do 11103d5c3dbf1Smrg case $lib in 11104d5c3dbf1Smrg *.la) 11105d5c3dbf1Smrg # Only pass preopened files to the pseudo-archive (for 11106d5c3dbf1Smrg # eventual linking with the app. that links it) if we 11107d5c3dbf1Smrg # didn't already link the preopened objects directly into 11108d5c3dbf1Smrg # the library: 11109d5c3dbf1Smrg func_basename "$lib" 11110949d0342Smrg name=$func_basename_result 11111949d0342Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112d5c3dbf1Smrg test -z "$libdir" && \ 11113949d0342Smrg func_fatal_error "'$lib' is not a valid libtool archive" 11114cdbfa18aSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115d5c3dbf1Smrg ;; 11116d5c3dbf1Smrg esac 11117d5c3dbf1Smrg done 11118949d0342Smrg dlprefiles=$newdlprefiles 11119d5c3dbf1Smrg else 11120d5c3dbf1Smrg newdlfiles= 11121d5c3dbf1Smrg for lib in $dlfiles; do 11122d5c3dbf1Smrg case $lib in 11123949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124d5c3dbf1Smrg *) abs=`pwd`"/$lib" ;; 11125d5c3dbf1Smrg esac 11126cdbfa18aSmrg func_append newdlfiles " $abs" 11127d5c3dbf1Smrg done 11128949d0342Smrg dlfiles=$newdlfiles 11129d5c3dbf1Smrg newdlprefiles= 11130d5c3dbf1Smrg for lib in $dlprefiles; do 11131d5c3dbf1Smrg case $lib in 11132949d0342Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133d5c3dbf1Smrg *) abs=`pwd`"/$lib" ;; 11134d5c3dbf1Smrg esac 11135cdbfa18aSmrg func_append newdlprefiles " $abs" 11136d5c3dbf1Smrg done 11137949d0342Smrg dlprefiles=$newdlprefiles 11138d5c3dbf1Smrg fi 11139d5c3dbf1Smrg $RM $output 11140d5c3dbf1Smrg # place dlname in correct position for cygwin 11141d5c3dbf1Smrg # In fact, it would be nice if we could use this code for all target 11142d5c3dbf1Smrg # systems that can't hard-code library paths into their executables 11143d5c3dbf1Smrg # and that have no shared library path variable independent of PATH, 11144d5c3dbf1Smrg # but it turns out we can't easily determine that from inspecting 11145d5c3dbf1Smrg # libtool variables, so we have to hard-code the OSs to which it 11146d5c3dbf1Smrg # applies here; at the moment, that means platforms that use the PE 11147d5c3dbf1Smrg # object format with DLL files. See the long comment at the top of 11148d5c3dbf1Smrg # tests/bindir.at for full details. 11149d5c3dbf1Smrg tdlname=$dlname 11150d5c3dbf1Smrg case $host,$output,$installed,$module,$dlname in 11151d5c3dbf1Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152d5c3dbf1Smrg # If a -bindir argument was supplied, place the dll there. 11153949d0342Smrg if test -n "$bindir"; then 11154d5c3dbf1Smrg func_relative_path "$install_libdir" "$bindir" 11155949d0342Smrg tdlname=$func_relative_path_result/$dlname 11156d5c3dbf1Smrg else 11157d5c3dbf1Smrg # Otherwise fall back on heuristic. 11158d5c3dbf1Smrg tdlname=../bin/$dlname 11159d5c3dbf1Smrg fi 11160d5c3dbf1Smrg ;; 11161d5c3dbf1Smrg esac 11162d5c3dbf1Smrg $ECHO > $output "\ 11163d5c3dbf1Smrg# $outputname - a libtool library file 11164949d0342Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165d5c3dbf1Smrg# 11166d5c3dbf1Smrg# Please DO NOT delete this file! 11167d5c3dbf1Smrg# It is necessary for linking the library. 111689f606849Smrg 11169d5c3dbf1Smrg# The name that we can dlopen(3). 11170d5c3dbf1Smrgdlname='$tdlname' 111719f606849Smrg 11172d5c3dbf1Smrg# Names of this library. 11173d5c3dbf1Smrglibrary_names='$library_names' 111749f606849Smrg 11175d5c3dbf1Smrg# The name of the static archive. 11176d5c3dbf1Smrgold_library='$old_library' 111779f606849Smrg 11178949d0342Smrg# Linker flags that cannot go in dependency_libs. 11179d5c3dbf1Smrginherited_linker_flags='$new_inherited_linker_flags' 111809f606849Smrg 11181d5c3dbf1Smrg# Libraries that this one depends upon. 11182d5c3dbf1Smrgdependency_libs='$dependency_libs' 111839f606849Smrg 11184d5c3dbf1Smrg# Names of additional weak libraries provided by this library 11185d5c3dbf1Smrgweak_library_names='$weak_libs' 111869f606849Smrg 11187d5c3dbf1Smrg# Version information for $libname. 11188d5c3dbf1Smrgcurrent=$current 11189d5c3dbf1Smrgage=$age 11190d5c3dbf1Smrgrevision=$revision 111919f606849Smrg 11192d5c3dbf1Smrg# Is this an already installed library? 11193d5c3dbf1Smrginstalled=$installed 111949f606849Smrg 11195d5c3dbf1Smrg# Should we warn about portability when linking against -modules? 11196d5c3dbf1Smrgshouldnotlink=$module 111979f606849Smrg 11198d5c3dbf1Smrg# Files to dlopen/dlpreopen 11199d5c3dbf1Smrgdlopen='$dlfiles' 11200d5c3dbf1Smrgdlpreopen='$dlprefiles' 112019f606849Smrg 11202d5c3dbf1Smrg# Directory that this library needs to be installed in: 11203d5c3dbf1Smrglibdir='$install_libdir'" 11204949d0342Smrg if test no,yes = "$installed,$need_relink"; then 11205d5c3dbf1Smrg $ECHO >> $output "\ 11206d5c3dbf1Smrgrelink_command=\"$relink_command\"" 11207d5c3dbf1Smrg fi 11208d5c3dbf1Smrg done 11209d5c3dbf1Smrg } 112109f606849Smrg 11211d5c3dbf1Smrg # Do a symbolic link so that the libtool archive can be found in 11212d5c3dbf1Smrg # LD_LIBRARY_PATH before the program is installed. 11213d5c3dbf1Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214d5c3dbf1Smrg ;; 11215d5c3dbf1Smrg esac 11216d5c3dbf1Smrg exit $EXIT_SUCCESS 11217d5c3dbf1Smrg} 112189f606849Smrg 11219949d0342Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 11220949d0342Smrg func_mode_link ${1+"$@"} 11221949d0342Smrgfi 112229f606849Smrg 112239f606849Smrg 11224d5c3dbf1Smrg# func_mode_uninstall arg... 11225d5c3dbf1Smrgfunc_mode_uninstall () 11226d5c3dbf1Smrg{ 11227949d0342Smrg $debug_cmd 11228949d0342Smrg 11229949d0342Smrg RM=$nonopt 112309f606849Smrg files= 11231949d0342Smrg rmforce=false 112329f606849Smrg exit_status=0 112339f606849Smrg 112349f606849Smrg # This variable tells wrapper scripts just to set variables rather 112359f606849Smrg # than running their programs. 11236949d0342Smrg libtool_install_magic=$magic 112379f606849Smrg 112389f606849Smrg for arg 112399f606849Smrg do 112409f606849Smrg case $arg in 11241949d0342Smrg -f) func_append RM " $arg"; rmforce=: ;; 11242cdbfa18aSmrg -*) func_append RM " $arg" ;; 11243cdbfa18aSmrg *) func_append files " $arg" ;; 112449f606849Smrg esac 112459f606849Smrg done 112469f606849Smrg 11247d5c3dbf1Smrg test -z "$RM" && \ 11248d5c3dbf1Smrg func_fatal_help "you must specify an RM program" 112499f606849Smrg 112509f606849Smrg rmdirs= 112519f606849Smrg 112529f606849Smrg for file in $files; do 11253d5c3dbf1Smrg func_dirname "$file" "" "." 11254949d0342Smrg dir=$func_dirname_result 11255949d0342Smrg if test . = "$dir"; then 11256949d0342Smrg odir=$objdir 112579f606849Smrg else 11258949d0342Smrg odir=$dir/$objdir 112599f606849Smrg fi 11260d5c3dbf1Smrg func_basename "$file" 11261949d0342Smrg name=$func_basename_result 11262949d0342Smrg test uninstall = "$opt_mode" && odir=$dir 112639f606849Smrg 11264cdbfa18aSmrg # Remember odir for removal later, being careful to avoid duplicates 11265949d0342Smrg if test clean = "$opt_mode"; then 112669f606849Smrg case " $rmdirs " in 11267cdbfa18aSmrg *" $odir "*) ;; 11268cdbfa18aSmrg *) func_append rmdirs " $odir" ;; 112699f606849Smrg esac 112709f606849Smrg fi 112719f606849Smrg 112729f606849Smrg # Don't error if the file doesn't exist and rm -f was used. 11273d5c3dbf1Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11274d5c3dbf1Smrg { test -h "$file"; } >/dev/null 2>&1 || 11275d5c3dbf1Smrg test -f "$file"; then 112769f606849Smrg : 112779f606849Smrg elif test -d "$file"; then 112789f606849Smrg exit_status=1 112799f606849Smrg continue 11280949d0342Smrg elif $rmforce; then 112819f606849Smrg continue 112829f606849Smrg fi 112839f606849Smrg 11284949d0342Smrg rmfiles=$file 112859f606849Smrg 112869f606849Smrg case $name in 112879f606849Smrg *.la) 112889f606849Smrg # Possibly a libtool archive, so verify it. 11289d5c3dbf1Smrg if func_lalib_p "$file"; then 11290d5c3dbf1Smrg func_source $dir/$name 112919f606849Smrg 112929f606849Smrg # Delete the libtool libraries and symlinks. 112939f606849Smrg for n in $library_names; do 11294cdbfa18aSmrg func_append rmfiles " $odir/$n" 112959f606849Smrg done 11296cdbfa18aSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 112979f606849Smrg 11298949d0342Smrg case $opt_mode in 112999f606849Smrg clean) 11300cdbfa18aSmrg case " $library_names " in 113019f606849Smrg *" $dlname "*) ;; 11302cdbfa18aSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113039f606849Smrg esac 11304cdbfa18aSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113059f606849Smrg ;; 113069f606849Smrg uninstall) 113079f606849Smrg if test -n "$library_names"; then 113089f606849Smrg # Do each command in the postuninstall commands. 11309949d0342Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113109f606849Smrg fi 113119f606849Smrg 113129f606849Smrg if test -n "$old_library"; then 113139f606849Smrg # Do each command in the old_postuninstall commands. 11314949d0342Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113159f606849Smrg fi 113169f606849Smrg # FIXME: should reinstall the best remaining shared library. 113179f606849Smrg ;; 113189f606849Smrg esac 113199f606849Smrg fi 113209f606849Smrg ;; 113219f606849Smrg 113229f606849Smrg *.lo) 113239f606849Smrg # Possibly a libtool object, so verify it. 11324d5c3dbf1Smrg if func_lalib_p "$file"; then 113259f606849Smrg 113269f606849Smrg # Read the .lo file 11327d5c3dbf1Smrg func_source $dir/$name 113289f606849Smrg 113299f606849Smrg # Add PIC object to the list of files to remove. 11330949d0342Smrg if test -n "$pic_object" && test none != "$pic_object"; then 11331cdbfa18aSmrg func_append rmfiles " $dir/$pic_object" 113329f606849Smrg fi 113339f606849Smrg 113349f606849Smrg # Add non-PIC object to the list of files to remove. 11335949d0342Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336cdbfa18aSmrg func_append rmfiles " $dir/$non_pic_object" 113379f606849Smrg fi 113389f606849Smrg fi 113399f606849Smrg ;; 113409f606849Smrg 113419f606849Smrg *) 11342949d0342Smrg if test clean = "$opt_mode"; then 113439f606849Smrg noexename=$name 113449f606849Smrg case $file in 113459f606849Smrg *.exe) 11346d5c3dbf1Smrg func_stripname '' '.exe' "$file" 11347d5c3dbf1Smrg file=$func_stripname_result 11348d5c3dbf1Smrg func_stripname '' '.exe' "$name" 11349d5c3dbf1Smrg noexename=$func_stripname_result 113509f606849Smrg # $file with .exe has already been added to rmfiles, 113519f606849Smrg # add $file without .exe 11352cdbfa18aSmrg func_append rmfiles " $file" 113539f606849Smrg ;; 113549f606849Smrg esac 113559f606849Smrg # Do a test to see if this is a libtool program. 11356d5c3dbf1Smrg if func_ltwrapper_p "$file"; then 11357d5c3dbf1Smrg if func_ltwrapper_executable_p "$file"; then 11358d5c3dbf1Smrg func_ltwrapper_scriptname "$file" 11359d5c3dbf1Smrg relink_command= 11360d5c3dbf1Smrg func_source $func_ltwrapper_scriptname_result 11361cdbfa18aSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362d5c3dbf1Smrg else 11363d5c3dbf1Smrg relink_command= 11364d5c3dbf1Smrg func_source $dir/$noexename 11365d5c3dbf1Smrg fi 113669f606849Smrg 113679f606849Smrg # note $name still contains .exe if it was in $file originally 113689f606849Smrg # as does the version of $file that was added into $rmfiles 11369949d0342Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11370949d0342Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371cdbfa18aSmrg func_append rmfiles " $odir/lt-$name" 113729f606849Smrg fi 11373949d0342Smrg if test "X$noexename" != "X$name"; then 11374949d0342Smrg func_append rmfiles " $odir/lt-$noexename.c" 113759f606849Smrg fi 113769f606849Smrg fi 113779f606849Smrg fi 113789f606849Smrg ;; 113799f606849Smrg esac 11380d5c3dbf1Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113819f606849Smrg done 113829f606849Smrg 11383949d0342Smrg # Try to remove the $objdir's in the directories where we deleted files 113849f606849Smrg for dir in $rmdirs; do 113859f606849Smrg if test -d "$dir"; then 11386d5c3dbf1Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113879f606849Smrg fi 113889f606849Smrg done 113899f606849Smrg 113909f606849Smrg exit $exit_status 11391d5c3dbf1Smrg} 113929f606849Smrg 11393949d0342Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11394949d0342Smrg func_mode_uninstall ${1+"$@"} 11395949d0342Smrgfi 113969f606849Smrg 11397cdbfa18aSmrgtest -z "$opt_mode" && { 11398949d0342Smrg help=$generic_help 11399d5c3dbf1Smrg func_fatal_help "you must specify a MODE" 11400d5c3dbf1Smrg} 11401d5c3dbf1Smrg 11402d5c3dbf1Smrgtest -z "$exec_cmd" && \ 11403949d0342Smrg func_fatal_help "invalid operation mode '$opt_mode'" 114049f606849Smrg 114059f606849Smrgif test -n "$exec_cmd"; then 11406d5c3dbf1Smrg eval exec "$exec_cmd" 114079f606849Smrg exit $EXIT_FAILURE 114089f606849Smrgfi 114099f606849Smrg 11410d5c3dbf1Smrgexit $exit_status 114119f606849Smrg 114129f606849Smrg 114139f606849Smrg# The TAGs below are defined such that we never get into a situation 11414949d0342Smrg# where we disable both kinds of libraries. Given conflicting 114159f606849Smrg# choices, we go for a static library, that is the most portable, 114169f606849Smrg# since we can't tell whether shared libraries were disabled because 114179f606849Smrg# the user asked for that or because the platform doesn't support 114189f606849Smrg# them. This is particularly important on AIX, because we don't 114199f606849Smrg# support having both static and shared libraries enabled at the same 114209f606849Smrg# time on that platform, so we default to a shared-only configuration. 114219f606849Smrg# If a disable-shared tag is given, we'll fallback to a static-only 114229f606849Smrg# configuration. But we'll never go from static-only to shared-only. 114239f606849Smrg 114249f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425d5c3dbf1Smrgbuild_libtool_libs=no 11426d5c3dbf1Smrgbuild_old_libs=yes 114279f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 114289f606849Smrg 114299f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430d5c3dbf1Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114319f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-static 114329f606849Smrg 114339f606849Smrg# Local Variables: 114349f606849Smrg# mode:shell-script 114359f606849Smrg# sh-indentation:2 114369f606849Smrg# End: 11437