1b43acbb4Smrg#! /bin/sh 2b43acbb4Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3b43acbb4Smrg## by inline-source v2014-01-03.01 45a3d36dfSmrg 5b43acbb4Smrg# libtool (GNU libtool) 2.4.6 6b43acbb4Smrg# Provide generalized library-building support services. 75a3d36dfSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 85a3d36dfSmrg 9b43acbb4Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 105a3d36dfSmrg# This is free software; see the source for copying conditions. There is NO 115a3d36dfSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 125a3d36dfSmrg 135a3d36dfSmrg# GNU Libtool is free software; you can redistribute it and/or modify 1423a0898aSmrg# it under the terms of the GNU General Public License as published by 1523a0898aSmrg# the Free Software Foundation; either version 2 of the License, or 1623a0898aSmrg# (at your option) any later version. 1723a0898aSmrg# 185a3d36dfSmrg# As a special exception to the GNU General Public License, 195a3d36dfSmrg# if you distribute this file as part of a program or library that 205a3d36dfSmrg# is built using GNU Libtool, you may include this file under the 215a3d36dfSmrg# same distribution terms that you use for the rest of that program. 225a3d36dfSmrg# 235a3d36dfSmrg# GNU Libtool is distributed in the hope that it will be useful, but 2423a0898aSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2523a0898aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2623a0898aSmrg# General Public License for more details. 2723a0898aSmrg# 2823a0898aSmrg# You should have received a copy of the GNU General Public License 29b43acbb4Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30b3062210Smrg 3123a0898aSmrg 3241c30155SmrgPROGRAM=libtool 3323a0898aSmrgPACKAGE=libtool 34a97c3f35SmrgVERSION="2.4.6 Debian-2.4.6-0.1" 35b43acbb4Smrgpackage_revision=2.4.6 3623a0898aSmrg 37b43acbb4Smrg 38b43acbb4Smrg## ------ ## 39b43acbb4Smrg## Usage. ## 40b43acbb4Smrg## ------ ## 41b43acbb4Smrg 42b43acbb4Smrg# Run './libtool --help' for help with using this script from the 43b43acbb4Smrg# command line. 44b43acbb4Smrg 45b43acbb4Smrg 46b43acbb4Smrg## ------------------------------- ## 47b43acbb4Smrg## User overridable command paths. ## 48b43acbb4Smrg## ------------------------------- ## 49b43acbb4Smrg 50b43acbb4Smrg# After configure completes, it has a better idea of some of the 51b43acbb4Smrg# shell tools we need than the defaults used by the functions shared 52b43acbb4Smrg# with bootstrap, so set those here where they can still be over- 53b43acbb4Smrg# ridden by the user, but otherwise take precedence. 54b43acbb4Smrg 55b43acbb4Smrg: ${AUTOCONF="autoconf"} 56b43acbb4Smrg: ${AUTOMAKE="automake"} 57b43acbb4Smrg 58b43acbb4Smrg 59b43acbb4Smrg## -------------------------- ## 60b43acbb4Smrg## Source external libraries. ## 61b43acbb4Smrg## -------------------------- ## 62b43acbb4Smrg 63b43acbb4Smrg# Much of our low-level functionality needs to be sourced from external 64b43acbb4Smrg# libraries, which are installed to $pkgauxdir. 65b43acbb4Smrg 66b43acbb4Smrg# Set a version string for this script. 67b43acbb4Smrgscriptversion=2015-01-20.17; # UTC 68b43acbb4Smrg 69b43acbb4Smrg# General shell script boiler plate, and helper functions. 70b43acbb4Smrg# Written by Gary V. Vaughan, 2004 71b43acbb4Smrg 72b43acbb4Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73b43acbb4Smrg# This is free software; see the source for copying conditions. There is NO 74b43acbb4Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75b43acbb4Smrg 76b43acbb4Smrg# This program is free software; you can redistribute it and/or modify 77b43acbb4Smrg# it under the terms of the GNU General Public License as published by 78b43acbb4Smrg# the Free Software Foundation; either version 3 of the License, or 79b43acbb4Smrg# (at your option) any later version. 80b43acbb4Smrg 81b43acbb4Smrg# As a special exception to the GNU General Public License, if you distribute 82b43acbb4Smrg# this file as part of a program or library that is built using GNU Libtool, 83b43acbb4Smrg# you may include this file under the same distribution terms that you use 84b43acbb4Smrg# for the rest of that program. 85b43acbb4Smrg 86b43acbb4Smrg# This program is distributed in the hope that it will be useful, 87b43acbb4Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88b43acbb4Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89b43acbb4Smrg# General Public License for more details. 90b43acbb4Smrg 91b43acbb4Smrg# You should have received a copy of the GNU General Public License 92b43acbb4Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93b43acbb4Smrg 94b43acbb4Smrg# Please report bugs or propose patches to gary@gnu.org. 95b43acbb4Smrg 96b43acbb4Smrg 97b43acbb4Smrg## ------ ## 98b43acbb4Smrg## Usage. ## 99b43acbb4Smrg## ------ ## 100b43acbb4Smrg 101b43acbb4Smrg# Evaluate this file near the top of your script to gain access to 102b43acbb4Smrg# the functions and variables defined here: 103b43acbb4Smrg# 104b43acbb4Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105b43acbb4Smrg# 106b43acbb4Smrg# If you need to override any of the default environment variable 107b43acbb4Smrg# settings, do that before evaluating this file. 108b43acbb4Smrg 109b43acbb4Smrg 110b43acbb4Smrg## -------------------- ## 111b43acbb4Smrg## Shell normalisation. ## 112b43acbb4Smrg## -------------------- ## 113b43acbb4Smrg 114b43acbb4Smrg# Some shells need a little help to be as Bourne compatible as possible. 115b43acbb4Smrg# Before doing anything else, make sure all that help has been provided! 116b43acbb4Smrg 117b43acbb4SmrgDUALCASE=1; export DUALCASE # for MKS sh 118b43acbb4Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11923a0898aSmrg emulate sh 12023a0898aSmrg NULLCMD=: 121b43acbb4Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 12223a0898aSmrg # is contrary to our usage. Disable this feature. 12323a0898aSmrg alias -g '${1+"$@"}'='"$@"' 12423a0898aSmrg setopt NO_GLOB_SUBST 12523a0898aSmrgelse 126b43acbb4Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 12723a0898aSmrgfi 12841c30155Smrg 129b43acbb4Smrg# NLS nuisances: We save the old values in case they are required later. 130b43acbb4Smrg_G_user_locale= 131b43acbb4Smrg_G_safe_locale= 132b43acbb4Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 13323a0898aSmrgdo 134b43acbb4Smrg eval "if test set = \"\${$_G_var+set}\"; then 135b43acbb4Smrg save_$_G_var=\$$_G_var 136b43acbb4Smrg $_G_var=C 137b43acbb4Smrg export $_G_var 138b43acbb4Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139b43acbb4Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 14023a0898aSmrg fi" 14123a0898aSmrgdone 14223a0898aSmrg 143b43acbb4Smrg# CDPATH. 144b43acbb4Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 1455a3d36dfSmrg 146b43acbb4Smrg# Make sure IFS has a sensible default 147b43acbb4Smrgsp=' ' 148b43acbb4Smrgnl=' 149b43acbb4Smrg' 150b43acbb4SmrgIFS="$sp $nl" 151b43acbb4Smrg 152b43acbb4Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 153b43acbb4Smrgif test "${PATH_SEPARATOR+set}" != set; then 154b43acbb4Smrg PATH_SEPARATOR=: 155b43acbb4Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156b43acbb4Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157b43acbb4Smrg PATH_SEPARATOR=';' 158b43acbb4Smrg } 159b43acbb4Smrgfi 1605a3d36dfSmrg 1615a3d36dfSmrg 1625a3d36dfSmrg 163b43acbb4Smrg## ------------------------- ## 164b43acbb4Smrg## Locate command utilities. ## 165b43acbb4Smrg## ------------------------- ## 166b43acbb4Smrg 167b43acbb4Smrg 168b43acbb4Smrg# func_executable_p FILE 169b43acbb4Smrg# ---------------------- 170b43acbb4Smrg# Check that FILE is an executable regular file. 171b43acbb4Smrgfunc_executable_p () 172b43acbb4Smrg{ 173b43acbb4Smrg test -f "$1" && test -x "$1" 174b43acbb4Smrg} 175b43acbb4Smrg 176b43acbb4Smrg 177b43acbb4Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178b43acbb4Smrg# -------------------------------------------- 179b43acbb4Smrg# Search for either a program that responds to --version with output 180b43acbb4Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181b43acbb4Smrg# trying all the directories in PATH with each of the elements of 182b43acbb4Smrg# PROGS_LIST. 183b43acbb4Smrg# 184b43acbb4Smrg# CHECK_FUNC should accept the path to a candidate program, and 185b43acbb4Smrg# set $func_check_prog_result if it truncates its output less than 186b43acbb4Smrg# $_G_path_prog_max characters. 187b43acbb4Smrgfunc_path_progs () 188b43acbb4Smrg{ 189b43acbb4Smrg _G_progs_list=$1 190b43acbb4Smrg _G_check_func=$2 191b43acbb4Smrg _G_PATH=${3-"$PATH"} 192b43acbb4Smrg 193b43acbb4Smrg _G_path_prog_max=0 194b43acbb4Smrg _G_path_prog_found=false 195b43acbb4Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196b43acbb4Smrg for _G_dir in $_G_PATH; do 197b43acbb4Smrg IFS=$_G_save_IFS 198b43acbb4Smrg test -z "$_G_dir" && _G_dir=. 199b43acbb4Smrg for _G_prog_name in $_G_progs_list; do 200b43acbb4Smrg for _exeext in '' .EXE; do 201b43acbb4Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202b43acbb4Smrg func_executable_p "$_G_path_prog" || continue 203b43acbb4Smrg case `"$_G_path_prog" --version 2>&1` in 204b43acbb4Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205b43acbb4Smrg *) $_G_check_func $_G_path_prog 206b43acbb4Smrg func_path_progs_result=$func_check_prog_result 207b43acbb4Smrg ;; 208b43acbb4Smrg esac 209b43acbb4Smrg $_G_path_prog_found && break 3 210b43acbb4Smrg done 211b43acbb4Smrg done 212b43acbb4Smrg done 213b43acbb4Smrg IFS=$_G_save_IFS 214b43acbb4Smrg test -z "$func_path_progs_result" && { 215b43acbb4Smrg echo "no acceptable sed could be found in \$PATH" >&2 216b43acbb4Smrg exit 1 217b43acbb4Smrg } 218b43acbb4Smrg} 219b43acbb4Smrg 220b43acbb4Smrg 221b43acbb4Smrg# We want to be able to use the functions in this file before configure 222b43acbb4Smrg# has figured out where the best binaries are kept, which means we have 223b43acbb4Smrg# to search for them ourselves - except when the results are already set 224b43acbb4Smrg# where we skip the searches. 225b43acbb4Smrg 226b43acbb4Smrg# Unless the user overrides by setting SED, search the path for either GNU 227b43acbb4Smrg# sed, or the sed that truncates its output the least. 228b43acbb4Smrgtest -z "$SED" && { 229b43acbb4Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230b43acbb4Smrg for _G_i in 1 2 3 4 5 6 7; do 231b43acbb4Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232b43acbb4Smrg done 233b43acbb4Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234b43acbb4Smrg _G_sed_script= 235b43acbb4Smrg 236b43acbb4Smrg func_check_prog_sed () 237b43acbb4Smrg { 238b43acbb4Smrg _G_path_prog=$1 239b43acbb4Smrg 240b43acbb4Smrg _G_count=0 241b43acbb4Smrg printf 0123456789 >conftest.in 242b43acbb4Smrg while : 243b43acbb4Smrg do 244b43acbb4Smrg cat conftest.in conftest.in >conftest.tmp 245b43acbb4Smrg mv conftest.tmp conftest.in 246b43acbb4Smrg cp conftest.in conftest.nl 247b43acbb4Smrg echo '' >> conftest.nl 248b43acbb4Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249b43acbb4Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250b43acbb4Smrg _G_count=`expr $_G_count + 1` 251b43acbb4Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252b43acbb4Smrg # Best one so far, save it but keep looking for a better one 253b43acbb4Smrg func_check_prog_result=$_G_path_prog 254b43acbb4Smrg _G_path_prog_max=$_G_count 255b43acbb4Smrg fi 256b43acbb4Smrg # 10*(2^10) chars as input seems more than enough 257b43acbb4Smrg test 10 -lt "$_G_count" && break 258b43acbb4Smrg done 259b43acbb4Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260b43acbb4Smrg } 261b43acbb4Smrg 262b43acbb4Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263b43acbb4Smrg rm -f conftest.sed 264b43acbb4Smrg SED=$func_path_progs_result 265b43acbb4Smrg} 266b43acbb4Smrg 267b43acbb4Smrg 268b43acbb4Smrg# Unless the user overrides by setting GREP, search the path for either GNU 269b43acbb4Smrg# grep, or the grep that truncates its output the least. 270b43acbb4Smrgtest -z "$GREP" && { 271b43acbb4Smrg func_check_prog_grep () 272b43acbb4Smrg { 273b43acbb4Smrg _G_path_prog=$1 274b43acbb4Smrg 275b43acbb4Smrg _G_count=0 276b43acbb4Smrg _G_path_prog_max=0 277b43acbb4Smrg printf 0123456789 >conftest.in 278b43acbb4Smrg while : 279b43acbb4Smrg do 280b43acbb4Smrg cat conftest.in conftest.in >conftest.tmp 281b43acbb4Smrg mv conftest.tmp conftest.in 282b43acbb4Smrg cp conftest.in conftest.nl 283b43acbb4Smrg echo 'GREP' >> conftest.nl 284b43acbb4Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285b43acbb4Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286b43acbb4Smrg _G_count=`expr $_G_count + 1` 287b43acbb4Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288b43acbb4Smrg # Best one so far, save it but keep looking for a better one 289b43acbb4Smrg func_check_prog_result=$_G_path_prog 290b43acbb4Smrg _G_path_prog_max=$_G_count 291b43acbb4Smrg fi 292b43acbb4Smrg # 10*(2^10) chars as input seems more than enough 293b43acbb4Smrg test 10 -lt "$_G_count" && break 294b43acbb4Smrg done 295b43acbb4Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296b43acbb4Smrg } 297b43acbb4Smrg 298b43acbb4Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299b43acbb4Smrg GREP=$func_path_progs_result 300b43acbb4Smrg} 301b43acbb4Smrg 302b43acbb4Smrg 303b43acbb4Smrg## ------------------------------- ## 304b43acbb4Smrg## User overridable command paths. ## 305b43acbb4Smrg## ------------------------------- ## 306b43acbb4Smrg 307b43acbb4Smrg# All uppercase variable names are used for environment variables. These 308b43acbb4Smrg# variables can be overridden by the user before calling a script that 309b43acbb4Smrg# uses them if a suitable command of that name is not already available 310b43acbb4Smrg# in the command search PATH. 3115a3d36dfSmrg 3125a3d36dfSmrg: ${CP="cp -f"} 313b43acbb4Smrg: ${ECHO="printf %s\n"} 314b43acbb4Smrg: ${EGREP="$GREP -E"} 315b43acbb4Smrg: ${FGREP="$GREP -F"} 316b43acbb4Smrg: ${LN_S="ln -s"} 3175a3d36dfSmrg: ${MAKE="make"} 3185a3d36dfSmrg: ${MKDIR="mkdir"} 3195a3d36dfSmrg: ${MV="mv -f"} 3205a3d36dfSmrg: ${RM="rm -f"} 3215a3d36dfSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 32223a0898aSmrg 3235a3d36dfSmrg 324b43acbb4Smrg## -------------------- ## 325b43acbb4Smrg## Useful sed snippets. ## 326b43acbb4Smrg## -------------------- ## 32741c30155Smrg 328b43acbb4Smrgsed_dirname='s|/[^/]*$||' 329b43acbb4Smrgsed_basename='s|^.*/||' 33041c30155Smrg 331b43acbb4Smrg# Sed substitution that helps us do robust quoting. It backslashifies 332b43acbb4Smrg# metacharacters that are still active within double-quoted strings. 333b43acbb4Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 33441c30155Smrg 335b43acbb4Smrg# Same as above, but do not quote variable references. 336b43acbb4Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 33741c30155Smrg 338b43acbb4Smrg# Sed substitution that turns a string into a regex matching for the 339b43acbb4Smrg# string literally. 340b43acbb4Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 34141c30155Smrg 342b43acbb4Smrg# Sed substitution that converts a w32 file name or path 343b43acbb4Smrg# that contains forward slashes, into one that contains 344b43acbb4Smrg# (escaped) backslashes. A very naive implementation. 345b43acbb4Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346b43acbb4Smrg 347b43acbb4Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348b43acbb4Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349b43acbb4Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350b43acbb4Smrg# expansion. Since each input '\' is now two '\'s, look for any number 351b43acbb4Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352b43acbb4Smrg_G_bs='\\' 353b43acbb4Smrg_G_bs2='\\\\' 354b43acbb4Smrg_G_bs4='\\\\\\\\' 355b43acbb4Smrg_G_dollar='\$' 356b43acbb4Smrgsed_double_backslash="\ 357b43acbb4Smrg s/$_G_bs4/&\\ 358b43acbb4Smrg/g 359b43acbb4Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360b43acbb4Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361b43acbb4Smrg s/\n//g" 36241c30155Smrg 36341c30155Smrg 364b43acbb4Smrg## ----------------- ## 365b43acbb4Smrg## Global variables. ## 366b43acbb4Smrg## ----------------- ## 36741c30155Smrg 368b43acbb4Smrg# Except for the global variables explicitly listed below, the following 369b43acbb4Smrg# functions in the '^func_' namespace, and the '^require_' namespace 370b43acbb4Smrg# variables initialised in the 'Resource management' section, sourcing 371b43acbb4Smrg# this file will not pollute your global namespace with anything 372b43acbb4Smrg# else. There's no portable way to scope variables in Bourne shell 373b43acbb4Smrg# though, so actually running these functions will sometimes place 374b43acbb4Smrg# results into a variable named after the function, and often use 375b43acbb4Smrg# temporary variables in the '^_G_' namespace. If you are careful to 376b43acbb4Smrg# avoid using those namespaces casually in your sourcing script, things 377b43acbb4Smrg# should continue to work as you expect. And, of course, you can freely 378b43acbb4Smrg# overwrite any of the functions or variables defined here before 379b43acbb4Smrg# calling anything to customize them. 38041c30155Smrg 381b43acbb4SmrgEXIT_SUCCESS=0 382b43acbb4SmrgEXIT_FAILURE=1 383b43acbb4SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384b43acbb4SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 3857f7f5e4eSmrg 386b43acbb4Smrg# Allow overriding, eg assuming that you follow the convention of 387b43acbb4Smrg# putting '$debug_cmd' at the start of all your functions, you can get 388b43acbb4Smrg# bash to show function call trace with: 389b43acbb4Smrg# 390b43acbb4Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391b43acbb4Smrgdebug_cmd=${debug_cmd-":"} 392b43acbb4Smrgexit_cmd=: 3935a3d36dfSmrg 394b43acbb4Smrg# By convention, finish your script with: 395b43acbb4Smrg# 396b43acbb4Smrg# exit $exit_status 397b43acbb4Smrg# 398b43acbb4Smrg# so that you can set exit_status to non-zero if you want to indicate 399b43acbb4Smrg# something went wrong during execution without actually bailing out at 400b43acbb4Smrg# the point of failure. 401b43acbb4Smrgexit_status=$EXIT_SUCCESS 40241c30155Smrg 403b43acbb4Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404b43acbb4Smrg# is ksh but when the shell is invoked as "sh" and the current value of 405b43acbb4Smrg# the _XPG environment variable is not equal to 1 (one), the special 406b43acbb4Smrg# positional parameter $0, within a function call, is the name of the 407b43acbb4Smrg# function. 408b43acbb4Smrgprogpath=$0 4095a3d36dfSmrg 410b43acbb4Smrg# The name of this program. 411b43acbb4Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4125a3d36dfSmrg 413b43acbb4Smrg# Make sure we have an absolute progpath for reexecution: 4145a3d36dfSmrgcase $progpath in 4155a3d36dfSmrg [\\/]*|[A-Za-z]:\\*) ;; 4165a3d36dfSmrg *[\\/]*) 417b43acbb4Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4185a3d36dfSmrg progdir=`cd "$progdir" && pwd` 419b43acbb4Smrg progpath=$progdir/$progname 4205a3d36dfSmrg ;; 4215a3d36dfSmrg *) 422b43acbb4Smrg _G_IFS=$IFS 423b020570bSmrg IFS=${PATH_SEPARATOR-:} 4245a3d36dfSmrg for progdir in $PATH; do 425b43acbb4Smrg IFS=$_G_IFS 4265a3d36dfSmrg test -x "$progdir/$progname" && break 4275a3d36dfSmrg done 428b43acbb4Smrg IFS=$_G_IFS 4295a3d36dfSmrg test -n "$progdir" || progdir=`pwd` 430b43acbb4Smrg progpath=$progdir/$progname 4315a3d36dfSmrg ;; 4325a3d36dfSmrgesac 4335a3d36dfSmrg 4345a3d36dfSmrg 435b43acbb4Smrg## ----------------- ## 436b43acbb4Smrg## Standard options. ## 437b43acbb4Smrg## ----------------- ## 43841c30155Smrg 439b43acbb4Smrg# The following options affect the operation of the functions defined 440b43acbb4Smrg# below, and should be set appropriately depending on run-time para- 441b43acbb4Smrg# meters passed on the command line. 4425a3d36dfSmrg 4435a3d36dfSmrgopt_dry_run=false 4445a3d36dfSmrgopt_quiet=false 4455a3d36dfSmrgopt_verbose=false 4465a3d36dfSmrg 447b43acbb4Smrg# Categories 'all' and 'none' are always available. Append any others 448b43acbb4Smrg# you will pass as the first argument to func_warning from your own 449b43acbb4Smrg# code. 450b43acbb4Smrgwarning_categories= 4515a3d36dfSmrg 452b43acbb4Smrg# By default, display warnings according to 'opt_warning_types'. Set 453b43acbb4Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454b43acbb4Smrg# treat the next displayed warning as a fatal error. 455b43acbb4Smrgwarning_func=func_warn_and_continue 4565a3d36dfSmrg 457b43acbb4Smrg# Set to 'all' to display all warnings, 'none' to suppress all 458b43acbb4Smrg# warnings, or a space delimited list of some subset of 459b43acbb4Smrg# 'warning_categories' to display only the listed warnings. 460b43acbb4Smrgopt_warning_types=all 4615a3d36dfSmrg 46241c30155Smrg 463b43acbb4Smrg## -------------------- ## 464b43acbb4Smrg## Resource management. ## 465b43acbb4Smrg## -------------------- ## 4665a3d36dfSmrg 467b43acbb4Smrg# This section contains definitions for functions that each ensure a 468b43acbb4Smrg# particular resource (a file, or a non-empty configuration variable for 469b43acbb4Smrg# example) is available, and if appropriate to extract default values 470b43acbb4Smrg# from pertinent package files. Call them using their associated 471b43acbb4Smrg# 'require_*' variable to ensure that they are executed, at most, once. 472b43acbb4Smrg# 473b43acbb4Smrg# It's entirely deliberate that calling these functions can set 474b43acbb4Smrg# variables that don't obey the namespace limitations obeyed by the rest 475b43acbb4Smrg# of this file, in order that that they be as useful as possible to 476b43acbb4Smrg# callers. 4775a3d36dfSmrg 4785a3d36dfSmrg 479b43acbb4Smrg# require_term_colors 480b43acbb4Smrg# ------------------- 481b43acbb4Smrg# Allow display of bold text on terminals that support it. 482b43acbb4Smrgrequire_term_colors=func_require_term_colors 483b43acbb4Smrgfunc_require_term_colors () 4845a3d36dfSmrg{ 485b43acbb4Smrg $debug_cmd 486b43acbb4Smrg 487b43acbb4Smrg test -t 1 && { 488b43acbb4Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 489b43acbb4Smrg # precedence, because most terminfo databases neglect to describe 490b43acbb4Smrg # whether color sequences are supported. 491b43acbb4Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492b43acbb4Smrg 493b43acbb4Smrg if test 1 = "$USE_ANSI_COLORS"; then 494b43acbb4Smrg # Standard ANSI escape sequences 495b43acbb4Smrg tc_reset='[0m' 496b43acbb4Smrg tc_bold='[1m'; tc_standout='[7m' 497b43acbb4Smrg tc_red='[31m'; tc_green='[32m' 498b43acbb4Smrg tc_blue='[34m'; tc_cyan='[36m' 499b43acbb4Smrg else 500b43acbb4Smrg # Otherwise trust the terminfo database after all. 501b43acbb4Smrg test -n "`tput sgr0 2>/dev/null`" && { 502b43acbb4Smrg tc_reset=`tput sgr0` 503b43acbb4Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504b43acbb4Smrg tc_standout=$tc_bold 505b43acbb4Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506b43acbb4Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507b43acbb4Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508b43acbb4Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509b43acbb4Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510b43acbb4Smrg } 511b43acbb4Smrg fi 512b43acbb4Smrg } 5135a3d36dfSmrg 514b43acbb4Smrg require_term_colors=: 5155a3d36dfSmrg} 5165a3d36dfSmrg 5175a3d36dfSmrg 518b43acbb4Smrg## ----------------- ## 519b43acbb4Smrg## Function library. ## 520b43acbb4Smrg## ----------------- ## 521b43acbb4Smrg 522b43acbb4Smrg# This section contains a variety of useful functions to call in your 523b43acbb4Smrg# scripts. Take note of the portable wrappers for features provided by 524b43acbb4Smrg# some modern shells, which will fall back to slower equivalents on 525b43acbb4Smrg# less featureful shells. 526b43acbb4Smrg 527b43acbb4Smrg 528b43acbb4Smrg# func_append VAR VALUE 529b43acbb4Smrg# --------------------- 530b43acbb4Smrg# Append VALUE onto the existing contents of VAR. 531b43acbb4Smrg 532b43acbb4Smrg # We should try to minimise forks, especially on Windows where they are 533b43acbb4Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 534b43acbb4Smrg # being used: 535b43acbb4Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536b43acbb4Smrg : ${_G_HAVE_ARITH_OP="yes"} 537b43acbb4Smrg : ${_G_HAVE_XSI_OPS="yes"} 538b43acbb4Smrg # The += operator was introduced in bash 3.1 539b43acbb4Smrg case $BASH_VERSION in 540b43acbb4Smrg [12].* | 3.0 | 3.0*) ;; 541b43acbb4Smrg *) 542b43acbb4Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543b43acbb4Smrg ;; 544b43acbb4Smrg esac 545b43acbb4Smrg fi 546b43acbb4Smrg 547b43acbb4Smrg # _G_HAVE_PLUSEQ_OP 548b43acbb4Smrg # Can be empty, in which case the shell is probed, "yes" if += is 549b43acbb4Smrg # useable or anything else if it does not work. 550b43acbb4Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551b43acbb4Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552b43acbb4Smrg && _G_HAVE_PLUSEQ_OP=yes 553b43acbb4Smrg 554b43acbb4Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555b43acbb4Smrgthen 556b43acbb4Smrg # This is an XSI compatible shell, allowing a faster implementation... 557b43acbb4Smrg eval 'func_append () 558b43acbb4Smrg { 559b43acbb4Smrg $debug_cmd 560b43acbb4Smrg 561b43acbb4Smrg eval "$1+=\$2" 562b43acbb4Smrg }' 563b43acbb4Smrgelse 564b43acbb4Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 565b43acbb4Smrg func_append () 566b43acbb4Smrg { 567b43acbb4Smrg $debug_cmd 568b43acbb4Smrg 569b43acbb4Smrg eval "$1=\$$1\$2" 570b43acbb4Smrg } 571b43acbb4Smrgfi 572b43acbb4Smrg 573b43acbb4Smrg 574b43acbb4Smrg# func_append_quoted VAR VALUE 575b43acbb4Smrg# ---------------------------- 576b43acbb4Smrg# Quote VALUE and append to the end of shell variable VAR, separated 577b43acbb4Smrg# by a space. 578b43acbb4Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579b43acbb4Smrg eval 'func_append_quoted () 580b43acbb4Smrg { 581b43acbb4Smrg $debug_cmd 582b43acbb4Smrg 583b43acbb4Smrg func_quote_for_eval "$2" 584b43acbb4Smrg eval "$1+=\\ \$func_quote_for_eval_result" 585b43acbb4Smrg }' 586b43acbb4Smrgelse 587b43acbb4Smrg func_append_quoted () 588b43acbb4Smrg { 589b43acbb4Smrg $debug_cmd 590b43acbb4Smrg 591b43acbb4Smrg func_quote_for_eval "$2" 592b43acbb4Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593b43acbb4Smrg } 594b43acbb4Smrgfi 595b43acbb4Smrg 596b43acbb4Smrg 597b43acbb4Smrg# func_append_uniq VAR VALUE 598b43acbb4Smrg# -------------------------- 599b43acbb4Smrg# Append unique VALUE onto the existing contents of VAR, assuming 600b43acbb4Smrg# entries are delimited by the first character of VALUE. For example: 601b43acbb4Smrg# 602b43acbb4Smrg# func_append_uniq options " --another-option option-argument" 603b43acbb4Smrg# 604b43acbb4Smrg# will only append to $options if " --another-option option-argument " 605b43acbb4Smrg# is not already present somewhere in $options already (note spaces at 606b43acbb4Smrg# each end implied by leading space in second argument). 607b43acbb4Smrgfunc_append_uniq () 608b43acbb4Smrg{ 609b43acbb4Smrg $debug_cmd 610b43acbb4Smrg 611b43acbb4Smrg eval _G_current_value='`$ECHO $'$1'`' 612b43acbb4Smrg _G_delim=`expr "$2" : '\(.\)'` 613b43acbb4Smrg 614b43acbb4Smrg case $_G_delim$_G_current_value$_G_delim in 615b43acbb4Smrg *"$2$_G_delim"*) ;; 616b43acbb4Smrg *) func_append "$@" ;; 617b43acbb4Smrg esac 618b43acbb4Smrg} 619b43acbb4Smrg 620b43acbb4Smrg 621b43acbb4Smrg# func_arith TERM... 622b43acbb4Smrg# ------------------ 623b43acbb4Smrg# Set func_arith_result to the result of evaluating TERMs. 624b43acbb4Smrg test -z "$_G_HAVE_ARITH_OP" \ 625b43acbb4Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626b43acbb4Smrg && _G_HAVE_ARITH_OP=yes 627b43acbb4Smrg 628b43acbb4Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 629b43acbb4Smrg eval 'func_arith () 630b43acbb4Smrg { 631b43acbb4Smrg $debug_cmd 632b43acbb4Smrg 633b43acbb4Smrg func_arith_result=$(( $* )) 634b43acbb4Smrg }' 635b43acbb4Smrgelse 636b43acbb4Smrg func_arith () 637b43acbb4Smrg { 638b43acbb4Smrg $debug_cmd 639b43acbb4Smrg 640b43acbb4Smrg func_arith_result=`expr "$@"` 641b43acbb4Smrg } 642b43acbb4Smrgfi 643b43acbb4Smrg 644b43acbb4Smrg 645b43acbb4Smrg# func_basename FILE 646b43acbb4Smrg# ------------------ 647b43acbb4Smrg# Set func_basename_result to FILE with everything up to and including 648b43acbb4Smrg# the last / stripped. 649b43acbb4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 650b43acbb4Smrg # If this shell supports suffix pattern removal, then use it to avoid 651b43acbb4Smrg # forking. Hide the definitions single quotes in case the shell chokes 652b43acbb4Smrg # on unsupported syntax... 653b43acbb4Smrg _b='func_basename_result=${1##*/}' 654b43acbb4Smrg _d='case $1 in 655b43acbb4Smrg */*) func_dirname_result=${1%/*}$2 ;; 656b43acbb4Smrg * ) func_dirname_result=$3 ;; 657b43acbb4Smrg esac' 658b43acbb4Smrg 659b43acbb4Smrgelse 660b43acbb4Smrg # ...otherwise fall back to using sed. 661b43acbb4Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662b43acbb4Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663b43acbb4Smrg if test "X$func_dirname_result" = "X$1"; then 664b43acbb4Smrg func_dirname_result=$3 665b43acbb4Smrg else 666b43acbb4Smrg func_append func_dirname_result "$2" 667b43acbb4Smrg fi' 668b43acbb4Smrgfi 669b43acbb4Smrg 670b43acbb4Smrgeval 'func_basename () 671b43acbb4Smrg{ 672b43acbb4Smrg $debug_cmd 673b43acbb4Smrg 674b43acbb4Smrg '"$_b"' 675b43acbb4Smrg}' 676b43acbb4Smrg 677b43acbb4Smrg 678b43acbb4Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679b43acbb4Smrg# ------------------------------------------- 680b43acbb4Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681b43acbb4Smrg# otherwise set result to NONDIR_REPLACEMENT. 682b43acbb4Smrgeval 'func_dirname () 683b43acbb4Smrg{ 684b43acbb4Smrg $debug_cmd 685b43acbb4Smrg 686b43acbb4Smrg '"$_d"' 687b43acbb4Smrg}' 688b43acbb4Smrg 689b43acbb4Smrg 690b43acbb4Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691b43acbb4Smrg# -------------------------------------------------------- 692b43acbb4Smrg# Perform func_basename and func_dirname in a single function 693b43acbb4Smrg# call: 694b43acbb4Smrg# dirname: Compute the dirname of FILE. If nonempty, 695b43acbb4Smrg# add APPEND to the result, otherwise set result 696b43acbb4Smrg# to NONDIR_REPLACEMENT. 697b43acbb4Smrg# value returned in "$func_dirname_result" 698b43acbb4Smrg# basename: Compute filename of FILE. 699b43acbb4Smrg# value retuned in "$func_basename_result" 700b43acbb4Smrg# For efficiency, we do not delegate to the functions above but instead 701b43acbb4Smrg# duplicate the functionality here. 702b43acbb4Smrgeval 'func_dirname_and_basename () 703b43acbb4Smrg{ 704b43acbb4Smrg $debug_cmd 705b43acbb4Smrg 706b43acbb4Smrg '"$_b"' 707b43acbb4Smrg '"$_d"' 708b43acbb4Smrg}' 709b43acbb4Smrg 710b43acbb4Smrg 711b43acbb4Smrg# func_echo ARG... 712b43acbb4Smrg# ---------------- 713b43acbb4Smrg# Echo program name prefixed message. 714b43acbb4Smrgfunc_echo () 715b43acbb4Smrg{ 716b43acbb4Smrg $debug_cmd 717b43acbb4Smrg 718b43acbb4Smrg _G_message=$* 719b43acbb4Smrg 720b43acbb4Smrg func_echo_IFS=$IFS 721b43acbb4Smrg IFS=$nl 722b43acbb4Smrg for _G_line in $_G_message; do 723b43acbb4Smrg IFS=$func_echo_IFS 724b43acbb4Smrg $ECHO "$progname: $_G_line" 725b43acbb4Smrg done 726b43acbb4Smrg IFS=$func_echo_IFS 727b43acbb4Smrg} 728b43acbb4Smrg 729b43acbb4Smrg 730b43acbb4Smrg# func_echo_all ARG... 731b43acbb4Smrg# -------------------- 732b43acbb4Smrg# Invoke $ECHO with all args, space-separated. 733b43acbb4Smrgfunc_echo_all () 734b43acbb4Smrg{ 735b43acbb4Smrg $ECHO "$*" 736b43acbb4Smrg} 737b43acbb4Smrg 738b43acbb4Smrg 739b43acbb4Smrg# func_echo_infix_1 INFIX ARG... 740b43acbb4Smrg# ------------------------------ 741b43acbb4Smrg# Echo program name, followed by INFIX on the first line, with any 742b43acbb4Smrg# additional lines not showing INFIX. 743b43acbb4Smrgfunc_echo_infix_1 () 744b43acbb4Smrg{ 745b43acbb4Smrg $debug_cmd 746b43acbb4Smrg 747b43acbb4Smrg $require_term_colors 748b43acbb4Smrg 749b43acbb4Smrg _G_infix=$1; shift 750b43acbb4Smrg _G_indent=$_G_infix 751b43acbb4Smrg _G_prefix="$progname: $_G_infix: " 752b43acbb4Smrg _G_message=$* 753b43acbb4Smrg 754b43acbb4Smrg # Strip color escape sequences before counting printable length 755b43acbb4Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756b43acbb4Smrg do 757b43acbb4Smrg test -n "$_G_tc" && { 758b43acbb4Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759b43acbb4Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760b43acbb4Smrg } 761b43acbb4Smrg done 762b43acbb4Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763b43acbb4Smrg 764b43acbb4Smrg func_echo_infix_1_IFS=$IFS 765b43acbb4Smrg IFS=$nl 766b43acbb4Smrg for _G_line in $_G_message; do 767b43acbb4Smrg IFS=$func_echo_infix_1_IFS 768b43acbb4Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769b43acbb4Smrg _G_prefix=$_G_indent 770b43acbb4Smrg done 771b43acbb4Smrg IFS=$func_echo_infix_1_IFS 772b43acbb4Smrg} 773b43acbb4Smrg 774b43acbb4Smrg 775b43acbb4Smrg# func_error ARG... 776b43acbb4Smrg# ----------------- 777b43acbb4Smrg# Echo program name prefixed message to standard error. 778b43acbb4Smrgfunc_error () 779b43acbb4Smrg{ 780b43acbb4Smrg $debug_cmd 781b43acbb4Smrg 782b43acbb4Smrg $require_term_colors 783b43acbb4Smrg 784b43acbb4Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785b43acbb4Smrg} 786b43acbb4Smrg 787b43acbb4Smrg 788b43acbb4Smrg# func_fatal_error ARG... 789b43acbb4Smrg# ----------------------- 790b43acbb4Smrg# Echo program name prefixed message to standard error, and exit. 791b43acbb4Smrgfunc_fatal_error () 792b43acbb4Smrg{ 793b43acbb4Smrg $debug_cmd 794b43acbb4Smrg 795b43acbb4Smrg func_error "$*" 796b43acbb4Smrg exit $EXIT_FAILURE 797b43acbb4Smrg} 798b43acbb4Smrg 799b43acbb4Smrg 800b43acbb4Smrg# func_grep EXPRESSION FILENAME 801b43acbb4Smrg# ----------------------------- 8025a3d36dfSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8035a3d36dfSmrgfunc_grep () 8045a3d36dfSmrg{ 805b43acbb4Smrg $debug_cmd 806b43acbb4Smrg 8075a3d36dfSmrg $GREP "$1" "$2" >/dev/null 2>&1 8085a3d36dfSmrg} 8095a3d36dfSmrg 8105a3d36dfSmrg 811b43acbb4Smrg# func_len STRING 812b43acbb4Smrg# --------------- 813b43acbb4Smrg# Set func_len_result to the length of STRING. STRING may not 814b43acbb4Smrg# start with a hyphen. 815b43acbb4Smrg test -z "$_G_HAVE_XSI_OPS" \ 816b43acbb4Smrg && (eval 'x=a/b/c; 817b43acbb4Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818b43acbb4Smrg && _G_HAVE_XSI_OPS=yes 819b43acbb4Smrg 820b43acbb4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 821b43acbb4Smrg eval 'func_len () 822b43acbb4Smrg { 823b43acbb4Smrg $debug_cmd 824b43acbb4Smrg 825b43acbb4Smrg func_len_result=${#1} 826b43acbb4Smrg }' 827b43acbb4Smrgelse 828b43acbb4Smrg func_len () 829b43acbb4Smrg { 830b43acbb4Smrg $debug_cmd 831b43acbb4Smrg 832b43acbb4Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833b43acbb4Smrg } 834b43acbb4Smrgfi 835b43acbb4Smrg 836b43acbb4Smrg 837b43acbb4Smrg# func_mkdir_p DIRECTORY-PATH 838b43acbb4Smrg# --------------------------- 8395a3d36dfSmrg# Make sure the entire path to DIRECTORY-PATH is available. 8405a3d36dfSmrgfunc_mkdir_p () 8415a3d36dfSmrg{ 842b43acbb4Smrg $debug_cmd 8435a3d36dfSmrg 844b43acbb4Smrg _G_directory_path=$1 845b43acbb4Smrg _G_dir_list= 8465a3d36dfSmrg 847b43acbb4Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848b43acbb4Smrg 849b43acbb4Smrg # Protect directory names starting with '-' 850b43acbb4Smrg case $_G_directory_path in 851b43acbb4Smrg -*) _G_directory_path=./$_G_directory_path ;; 8525a3d36dfSmrg esac 8535a3d36dfSmrg 8545a3d36dfSmrg # While some portion of DIR does not yet exist... 855b43acbb4Smrg while test ! -d "$_G_directory_path"; do 8565a3d36dfSmrg # ...make a list in topmost first order. Use a colon delimited 8575a3d36dfSmrg # list incase some portion of path contains whitespace. 858b43acbb4Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 8595a3d36dfSmrg 8605a3d36dfSmrg # If the last portion added has no slash in it, the list is done 861b43acbb4Smrg case $_G_directory_path in */*) ;; *) break ;; esac 8625a3d36dfSmrg 8635a3d36dfSmrg # ...otherwise throw away the child directory and loop 864b43acbb4Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 8655a3d36dfSmrg done 866b43acbb4Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 8675a3d36dfSmrg 868b43acbb4Smrg func_mkdir_p_IFS=$IFS; IFS=: 869b43acbb4Smrg for _G_dir in $_G_dir_list; do 870b43acbb4Smrg IFS=$func_mkdir_p_IFS 871b43acbb4Smrg # mkdir can fail with a 'File exist' error if two processes 8725a3d36dfSmrg # try to create one of the directories concurrently. Don't 8735a3d36dfSmrg # stop in that case! 874b43acbb4Smrg $MKDIR "$_G_dir" 2>/dev/null || : 8755a3d36dfSmrg done 876b43acbb4Smrg IFS=$func_mkdir_p_IFS 8775a3d36dfSmrg 8785a3d36dfSmrg # Bail out if we (or some other process) failed to create a directory. 879b43acbb4Smrg test -d "$_G_directory_path" || \ 880b43acbb4Smrg func_fatal_error "Failed to create '$1'" 8815a3d36dfSmrg fi 8825a3d36dfSmrg} 88323a0898aSmrg 88423a0898aSmrg 885b43acbb4Smrg# func_mktempdir [BASENAME] 886b43acbb4Smrg# ------------------------- 88723a0898aSmrg# Make a temporary directory that won't clash with other running 88823a0898aSmrg# libtool processes, and avoids race conditions if possible. If 889b43acbb4Smrg# given, BASENAME is the basename for that directory. 89023a0898aSmrgfunc_mktempdir () 89123a0898aSmrg{ 892b43acbb4Smrg $debug_cmd 893b43acbb4Smrg 894b43acbb4Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 89523a0898aSmrg 896b43acbb4Smrg if test : = "$opt_dry_run"; then 89723a0898aSmrg # Return a directory name, but don't create it in dry-run mode 898b43acbb4Smrg _G_tmpdir=$_G_template-$$ 89923a0898aSmrg else 90023a0898aSmrg 90123a0898aSmrg # If mktemp works, use that first and foremost 902b43acbb4Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 90323a0898aSmrg 904b43acbb4Smrg if test ! -d "$_G_tmpdir"; then 9055a3d36dfSmrg # Failing that, at least try and use $RANDOM to avoid a race 906b43acbb4Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 90723a0898aSmrg 908b43acbb4Smrg func_mktempdir_umask=`umask` 9095a3d36dfSmrg umask 0077 910b43acbb4Smrg $MKDIR "$_G_tmpdir" 911b43acbb4Smrg umask $func_mktempdir_umask 91223a0898aSmrg fi 91323a0898aSmrg 91423a0898aSmrg # If we're not in dry-run mode, bomb out on failure 915b43acbb4Smrg test -d "$_G_tmpdir" || \ 916b43acbb4Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917b43acbb4Smrg fi 918b43acbb4Smrg 919b43acbb4Smrg $ECHO "$_G_tmpdir" 920b43acbb4Smrg} 921b43acbb4Smrg 922b43acbb4Smrg 923b43acbb4Smrg# func_normal_abspath PATH 924b43acbb4Smrg# ------------------------ 925b43acbb4Smrg# Remove doubled-up and trailing slashes, "." path components, 926b43acbb4Smrg# and cancel out any ".." path components in PATH after making 927b43acbb4Smrg# it an absolute path. 928b43acbb4Smrgfunc_normal_abspath () 929b43acbb4Smrg{ 930b43acbb4Smrg $debug_cmd 931b43acbb4Smrg 932b43acbb4Smrg # These SED scripts presuppose an absolute path with a trailing slash. 933b43acbb4Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934b43acbb4Smrg _G_pathcdr='s|^/[^/]*||' 935b43acbb4Smrg _G_removedotparts=':dotsl 936b43acbb4Smrg s|/\./|/|g 937b43acbb4Smrg t dotsl 938b43acbb4Smrg s|/\.$|/|' 939b43acbb4Smrg _G_collapseslashes='s|/\{1,\}|/|g' 940b43acbb4Smrg _G_finalslash='s|/*$|/|' 941b43acbb4Smrg 942b43acbb4Smrg # Start from root dir and reassemble the path. 943b43acbb4Smrg func_normal_abspath_result= 944b43acbb4Smrg func_normal_abspath_tpath=$1 945b43acbb4Smrg func_normal_abspath_altnamespace= 946b43acbb4Smrg case $func_normal_abspath_tpath in 947b43acbb4Smrg "") 948b43acbb4Smrg # Empty path, that just means $cwd. 949b43acbb4Smrg func_stripname '' '/' "`pwd`" 950b43acbb4Smrg func_normal_abspath_result=$func_stripname_result 951b43acbb4Smrg return 952b43acbb4Smrg ;; 953b43acbb4Smrg # The next three entries are used to spot a run of precisely 954b43acbb4Smrg # two leading slashes without using negated character classes; 955b43acbb4Smrg # we take advantage of case's first-match behaviour. 956b43acbb4Smrg ///*) 957b43acbb4Smrg # Unusual form of absolute path, do nothing. 958b43acbb4Smrg ;; 959b43acbb4Smrg //*) 960b43acbb4Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961b43acbb4Smrg # and for example Cygwin uses it to access remote file shares 962b43acbb4Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 963b43acbb4Smrg func_normal_abspath_altnamespace=/ 964b43acbb4Smrg ;; 965b43acbb4Smrg /*) 966b43acbb4Smrg # Absolute path, do nothing. 967b43acbb4Smrg ;; 968b43acbb4Smrg *) 969b43acbb4Smrg # Relative path, prepend $cwd. 970b43acbb4Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971b43acbb4Smrg ;; 972b43acbb4Smrg esac 973b43acbb4Smrg 974b43acbb4Smrg # Cancel out all the simple stuff to save iterations. We also want 975b43acbb4Smrg # the path to end with a slash for ease of parsing, so make sure 976b43acbb4Smrg # there is one (and only one) here. 977b43acbb4Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978b43acbb4Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979b43acbb4Smrg while :; do 980b43acbb4Smrg # Processed it all yet? 981b43acbb4Smrg if test / = "$func_normal_abspath_tpath"; then 982b43acbb4Smrg # If we ascended to the root using ".." the result may be empty now. 983b43acbb4Smrg if test -z "$func_normal_abspath_result"; then 984b43acbb4Smrg func_normal_abspath_result=/ 985b43acbb4Smrg fi 986b43acbb4Smrg break 987b43acbb4Smrg fi 988b43acbb4Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989b43acbb4Smrg -e "$_G_pathcar"` 990b43acbb4Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991b43acbb4Smrg -e "$_G_pathcdr"` 992b43acbb4Smrg # Figure out what to do with it 993b43acbb4Smrg case $func_normal_abspath_tcomponent in 994b43acbb4Smrg "") 995b43acbb4Smrg # Trailing empty path component, ignore it. 996b43acbb4Smrg ;; 997b43acbb4Smrg ..) 998b43acbb4Smrg # Parent dir; strip last assembled component from result. 999b43acbb4Smrg func_dirname "$func_normal_abspath_result" 1000b43acbb4Smrg func_normal_abspath_result=$func_dirname_result 1001b43acbb4Smrg ;; 1002b43acbb4Smrg *) 1003b43acbb4Smrg # Actual path component, append it. 1004b43acbb4Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005b43acbb4Smrg ;; 1006b43acbb4Smrg esac 1007b43acbb4Smrg done 1008b43acbb4Smrg # Restore leading double-slash if one was found on entry. 1009b43acbb4Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010b43acbb4Smrg} 1011b43acbb4Smrg 1012b43acbb4Smrg 1013b43acbb4Smrg# func_notquiet ARG... 1014b43acbb4Smrg# -------------------- 1015b43acbb4Smrg# Echo program name prefixed message only when not in quiet mode. 1016b43acbb4Smrgfunc_notquiet () 1017b43acbb4Smrg{ 1018b43acbb4Smrg $debug_cmd 1019b43acbb4Smrg 1020b43acbb4Smrg $opt_quiet || func_echo ${1+"$@"} 1021b43acbb4Smrg 1022b43acbb4Smrg # A bug in bash halts the script if the last line of a function 1023b43acbb4Smrg # fails when set -e is in force, so we need another command to 1024b43acbb4Smrg # work around that: 1025b43acbb4Smrg : 1026b43acbb4Smrg} 1027b43acbb4Smrg 1028b43acbb4Smrg 1029b43acbb4Smrg# func_relative_path SRCDIR DSTDIR 1030b43acbb4Smrg# -------------------------------- 1031b43acbb4Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032b43acbb4Smrgfunc_relative_path () 1033b43acbb4Smrg{ 1034b43acbb4Smrg $debug_cmd 1035b43acbb4Smrg 1036b43acbb4Smrg func_relative_path_result= 1037b43acbb4Smrg func_normal_abspath "$1" 1038b43acbb4Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1039b43acbb4Smrg func_normal_abspath "$2" 1040b43acbb4Smrg func_relative_path_tbindir=$func_normal_abspath_result 1041b43acbb4Smrg 1042b43acbb4Smrg # Ascend the tree starting from libdir 1043b43acbb4Smrg while :; do 1044b43acbb4Smrg # check if we have found a prefix of bindir 1045b43acbb4Smrg case $func_relative_path_tbindir in 1046b43acbb4Smrg $func_relative_path_tlibdir) 1047b43acbb4Smrg # found an exact match 1048b43acbb4Smrg func_relative_path_tcancelled= 1049b43acbb4Smrg break 1050b43acbb4Smrg ;; 1051b43acbb4Smrg $func_relative_path_tlibdir*) 1052b43acbb4Smrg # found a matching prefix 1053b43acbb4Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054b43acbb4Smrg func_relative_path_tcancelled=$func_stripname_result 1055b43acbb4Smrg if test -z "$func_relative_path_result"; then 1056b43acbb4Smrg func_relative_path_result=. 1057b43acbb4Smrg fi 1058b43acbb4Smrg break 1059b43acbb4Smrg ;; 1060b43acbb4Smrg *) 1061b43acbb4Smrg func_dirname $func_relative_path_tlibdir 1062b43acbb4Smrg func_relative_path_tlibdir=$func_dirname_result 1063b43acbb4Smrg if test -z "$func_relative_path_tlibdir"; then 1064b43acbb4Smrg # Have to descend all the way to the root! 1065b43acbb4Smrg func_relative_path_result=../$func_relative_path_result 1066b43acbb4Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067b43acbb4Smrg break 1068b43acbb4Smrg fi 1069b43acbb4Smrg func_relative_path_result=../$func_relative_path_result 1070b43acbb4Smrg ;; 1071b43acbb4Smrg esac 1072b43acbb4Smrg done 1073b43acbb4Smrg 1074b43acbb4Smrg # Now calculate path; take care to avoid doubling-up slashes. 1075b43acbb4Smrg func_stripname '' '/' "$func_relative_path_result" 1076b43acbb4Smrg func_relative_path_result=$func_stripname_result 1077b43acbb4Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078b43acbb4Smrg if test -n "$func_stripname_result"; then 1079b43acbb4Smrg func_append func_relative_path_result "/$func_stripname_result" 1080b43acbb4Smrg fi 1081b43acbb4Smrg 1082b43acbb4Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083b43acbb4Smrg if test -n "$func_relative_path_result"; then 1084b43acbb4Smrg func_stripname './' '' "$func_relative_path_result" 1085b43acbb4Smrg func_relative_path_result=$func_stripname_result 108623a0898aSmrg fi 108723a0898aSmrg 1088b43acbb4Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089b43acbb4Smrg 1090b43acbb4Smrg : 1091b43acbb4Smrg} 1092b43acbb4Smrg 1093b43acbb4Smrg 1094b43acbb4Smrg# func_quote_for_eval ARG... 1095b43acbb4Smrg# -------------------------- 1096b43acbb4Smrg# Aesthetically quote ARGs to be evaled later. 1097b43acbb4Smrg# This function returns two values: 1098b43acbb4Smrg# i) func_quote_for_eval_result 1099b43acbb4Smrg# double-quoted, suitable for a subsequent eval 1100b43acbb4Smrg# ii) func_quote_for_eval_unquoted_result 1101b43acbb4Smrg# has all characters that are still active within double 1102b43acbb4Smrg# quotes backslashified. 1103b43acbb4Smrgfunc_quote_for_eval () 1104b43acbb4Smrg{ 1105b43acbb4Smrg $debug_cmd 1106b43acbb4Smrg 1107b43acbb4Smrg func_quote_for_eval_unquoted_result= 1108b43acbb4Smrg func_quote_for_eval_result= 1109b43acbb4Smrg while test 0 -lt $#; do 1110b43acbb4Smrg case $1 in 1111b43acbb4Smrg *[\\\`\"\$]*) 1112b43acbb4Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113b43acbb4Smrg *) 1114b43acbb4Smrg _G_unquoted_arg=$1 ;; 1115b43acbb4Smrg esac 1116b43acbb4Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 1117b43acbb4Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118b43acbb4Smrg else 1119b43acbb4Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120b43acbb4Smrg fi 1121b43acbb4Smrg 1122b43acbb4Smrg case $_G_unquoted_arg in 1123b43acbb4Smrg # Double-quote args containing shell metacharacters to delay 1124b43acbb4Smrg # word splitting, command substitution and variable expansion 1125b43acbb4Smrg # for a subsequent eval. 1126b43acbb4Smrg # Many Bourne shells cannot handle close brackets correctly 1127b43acbb4Smrg # in scan sets, so we specify it separately. 1128b43acbb4Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129b43acbb4Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130b43acbb4Smrg ;; 1131b43acbb4Smrg *) 1132b43acbb4Smrg _G_quoted_arg=$_G_unquoted_arg 1133b43acbb4Smrg ;; 1134b43acbb4Smrg esac 1135b43acbb4Smrg 1136b43acbb4Smrg if test -n "$func_quote_for_eval_result"; then 1137b43acbb4Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1138b43acbb4Smrg else 1139b43acbb4Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1140b43acbb4Smrg fi 1141b43acbb4Smrg shift 1142b43acbb4Smrg done 1143b43acbb4Smrg} 1144b43acbb4Smrg 1145b43acbb4Smrg 1146b43acbb4Smrg# func_quote_for_expand ARG 1147b43acbb4Smrg# ------------------------- 1148b43acbb4Smrg# Aesthetically quote ARG to be evaled later; same as above, 1149b43acbb4Smrg# but do not quote variable references. 1150b43acbb4Smrgfunc_quote_for_expand () 1151b43acbb4Smrg{ 1152b43acbb4Smrg $debug_cmd 1153b43acbb4Smrg 1154b43acbb4Smrg case $1 in 1155b43acbb4Smrg *[\\\`\"]*) 1156b43acbb4Smrg _G_arg=`$ECHO "$1" | $SED \ 1157b43acbb4Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158b43acbb4Smrg *) 1159b43acbb4Smrg _G_arg=$1 ;; 1160b43acbb4Smrg esac 1161b43acbb4Smrg 1162b43acbb4Smrg case $_G_arg in 1163b43acbb4Smrg # Double-quote args containing shell metacharacters to delay 1164b43acbb4Smrg # word splitting and command substitution for a subsequent eval. 1165b43acbb4Smrg # Many Bourne shells cannot handle close brackets correctly 1166b43acbb4Smrg # in scan sets, so we specify it separately. 1167b43acbb4Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168b43acbb4Smrg _G_arg=\"$_G_arg\" 1169b43acbb4Smrg ;; 1170b43acbb4Smrg esac 1171b43acbb4Smrg 1172b43acbb4Smrg func_quote_for_expand_result=$_G_arg 1173b43acbb4Smrg} 1174b43acbb4Smrg 1175b43acbb4Smrg 1176b43acbb4Smrg# func_stripname PREFIX SUFFIX NAME 1177b43acbb4Smrg# --------------------------------- 1178b43acbb4Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179b43acbb4Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1180b43acbb4Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181b43acbb4Smrg# dot (in which case that matches only a dot). 1182b43acbb4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183b43acbb4Smrg eval 'func_stripname () 1184b43acbb4Smrg { 1185b43acbb4Smrg $debug_cmd 1186b43acbb4Smrg 1187b43acbb4Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188b43acbb4Smrg # positional parameters, so assign one to ordinary variable first. 1189b43acbb4Smrg func_stripname_result=$3 1190b43acbb4Smrg func_stripname_result=${func_stripname_result#"$1"} 1191b43acbb4Smrg func_stripname_result=${func_stripname_result%"$2"} 1192b43acbb4Smrg }' 1193b43acbb4Smrgelse 1194b43acbb4Smrg func_stripname () 1195b43acbb4Smrg { 1196b43acbb4Smrg $debug_cmd 1197b43acbb4Smrg 1198b43acbb4Smrg case $2 in 1199b43acbb4Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200b43acbb4Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201b43acbb4Smrg esac 1202b43acbb4Smrg } 1203b43acbb4Smrgfi 1204b43acbb4Smrg 1205b43acbb4Smrg 1206b43acbb4Smrg# func_show_eval CMD [FAIL_EXP] 1207b43acbb4Smrg# ----------------------------- 1208b43acbb4Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209b43acbb4Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210b43acbb4Smrg# is given, then evaluate it. 1211b43acbb4Smrgfunc_show_eval () 1212b43acbb4Smrg{ 1213b43acbb4Smrg $debug_cmd 1214b43acbb4Smrg 1215b43acbb4Smrg _G_cmd=$1 1216b43acbb4Smrg _G_fail_exp=${2-':'} 1217b43acbb4Smrg 1218b43acbb4Smrg func_quote_for_expand "$_G_cmd" 1219b43acbb4Smrg eval "func_notquiet $func_quote_for_expand_result" 1220b43acbb4Smrg 1221b43acbb4Smrg $opt_dry_run || { 1222b43acbb4Smrg eval "$_G_cmd" 1223b43acbb4Smrg _G_status=$? 1224b43acbb4Smrg if test 0 -ne "$_G_status"; then 1225b43acbb4Smrg eval "(exit $_G_status); $_G_fail_exp" 1226b43acbb4Smrg fi 1227b43acbb4Smrg } 1228b43acbb4Smrg} 1229b43acbb4Smrg 1230b43acbb4Smrg 1231b43acbb4Smrg# func_show_eval_locale CMD [FAIL_EXP] 1232b43acbb4Smrg# ------------------------------------ 1233b43acbb4Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234b43acbb4Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235b43acbb4Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1236b43acbb4Smrgfunc_show_eval_locale () 1237b43acbb4Smrg{ 1238b43acbb4Smrg $debug_cmd 1239b43acbb4Smrg 1240b43acbb4Smrg _G_cmd=$1 1241b43acbb4Smrg _G_fail_exp=${2-':'} 1242b43acbb4Smrg 1243b43acbb4Smrg $opt_quiet || { 1244b43acbb4Smrg func_quote_for_expand "$_G_cmd" 1245b43acbb4Smrg eval "func_echo $func_quote_for_expand_result" 1246b43acbb4Smrg } 1247b43acbb4Smrg 1248b43acbb4Smrg $opt_dry_run || { 1249b43acbb4Smrg eval "$_G_user_locale 1250b43acbb4Smrg $_G_cmd" 1251b43acbb4Smrg _G_status=$? 1252b43acbb4Smrg eval "$_G_safe_locale" 1253b43acbb4Smrg if test 0 -ne "$_G_status"; then 1254b43acbb4Smrg eval "(exit $_G_status); $_G_fail_exp" 1255b43acbb4Smrg fi 1256b43acbb4Smrg } 1257b43acbb4Smrg} 1258b43acbb4Smrg 1259b43acbb4Smrg 1260b43acbb4Smrg# func_tr_sh 1261b43acbb4Smrg# ---------- 1262b43acbb4Smrg# Turn $1 into a string suitable for a shell variable name. 1263b43acbb4Smrg# Result is stored in $func_tr_sh_result. All characters 1264b43acbb4Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265b43acbb4Smrg# if $1 begins with a digit, a '_' is prepended as well. 1266b43acbb4Smrgfunc_tr_sh () 1267b43acbb4Smrg{ 1268b43acbb4Smrg $debug_cmd 1269b43acbb4Smrg 1270b43acbb4Smrg case $1 in 1271b43acbb4Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1272b43acbb4Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273b43acbb4Smrg ;; 1274b43acbb4Smrg * ) 1275b43acbb4Smrg func_tr_sh_result=$1 1276b43acbb4Smrg ;; 1277b43acbb4Smrg esac 1278b43acbb4Smrg} 1279b43acbb4Smrg 1280b43acbb4Smrg 1281b43acbb4Smrg# func_verbose ARG... 1282b43acbb4Smrg# ------------------- 1283b43acbb4Smrg# Echo program name prefixed message in verbose mode only. 1284b43acbb4Smrgfunc_verbose () 1285b43acbb4Smrg{ 1286b43acbb4Smrg $debug_cmd 1287b43acbb4Smrg 1288b43acbb4Smrg $opt_verbose && func_echo "$*" 1289b43acbb4Smrg 1290b43acbb4Smrg : 1291b43acbb4Smrg} 1292b43acbb4Smrg 1293b43acbb4Smrg 1294b43acbb4Smrg# func_warn_and_continue ARG... 1295b43acbb4Smrg# ----------------------------- 1296b43acbb4Smrg# Echo program name prefixed warning message to standard error. 1297b43acbb4Smrgfunc_warn_and_continue () 1298b43acbb4Smrg{ 1299b43acbb4Smrg $debug_cmd 1300b43acbb4Smrg 1301b43acbb4Smrg $require_term_colors 1302b43acbb4Smrg 1303b43acbb4Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304b43acbb4Smrg} 1305b43acbb4Smrg 1306b43acbb4Smrg 1307b43acbb4Smrg# func_warning CATEGORY ARG... 1308b43acbb4Smrg# ---------------------------- 1309b43acbb4Smrg# Echo program name prefixed warning message to standard error. Warning 1310b43acbb4Smrg# messages can be filtered according to CATEGORY, where this function 1311b43acbb4Smrg# elides messages where CATEGORY is not listed in the global variable 1312b43acbb4Smrg# 'opt_warning_types'. 1313b43acbb4Smrgfunc_warning () 1314b43acbb4Smrg{ 1315b43acbb4Smrg $debug_cmd 1316b43acbb4Smrg 1317b43acbb4Smrg # CATEGORY must be in the warning_categories list! 1318b43acbb4Smrg case " $warning_categories " in 1319b43acbb4Smrg *" $1 "*) ;; 1320b43acbb4Smrg *) func_internal_error "invalid warning category '$1'" ;; 1321b43acbb4Smrg esac 1322b43acbb4Smrg 1323b43acbb4Smrg _G_category=$1 1324b43acbb4Smrg shift 1325b43acbb4Smrg 1326b43acbb4Smrg case " $opt_warning_types " in 1327b43acbb4Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328b43acbb4Smrg esac 1329b43acbb4Smrg} 1330b43acbb4Smrg 1331b43acbb4Smrg 1332b43acbb4Smrg# func_sort_ver VER1 VER2 1333b43acbb4Smrg# ----------------------- 1334b43acbb4Smrg# 'sort -V' is not generally available. 1335b43acbb4Smrg# Note this deviates from the version comparison in automake 1336b43acbb4Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337b43acbb4Smrg# but this should suffice as we won't be specifying old 1338b43acbb4Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1339b43acbb4Smrg# If we did want full compatibility then we should probably 1340b43acbb4Smrg# use m4_version_compare from autoconf. 1341b43acbb4Smrgfunc_sort_ver () 1342b43acbb4Smrg{ 1343b43acbb4Smrg $debug_cmd 1344b43acbb4Smrg 1345b43acbb4Smrg printf '%s\n%s\n' "$1" "$2" \ 1346b43acbb4Smrg | 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 1347b43acbb4Smrg} 1348b43acbb4Smrg 1349b43acbb4Smrg# func_lt_ver PREV CURR 1350b43acbb4Smrg# --------------------- 1351b43acbb4Smrg# Return true if PREV and CURR are in the correct order according to 1352b43acbb4Smrg# func_sort_ver, otherwise false. Use it like this: 1353b43acbb4Smrg# 1354b43acbb4Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355b43acbb4Smrgfunc_lt_ver () 1356b43acbb4Smrg{ 1357b43acbb4Smrg $debug_cmd 1358b43acbb4Smrg 1359b43acbb4Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360b43acbb4Smrg} 1361b43acbb4Smrg 1362b43acbb4Smrg 1363b43acbb4Smrg# Local variables: 1364b43acbb4Smrg# mode: shell-script 1365b43acbb4Smrg# sh-indentation: 2 1366b43acbb4Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367b43acbb4Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368b43acbb4Smrg# time-stamp-time-zone: "UTC" 1369b43acbb4Smrg# End: 1370b43acbb4Smrg#! /bin/sh 1371b43acbb4Smrg 1372b43acbb4Smrg# Set a version string for this script. 1373b43acbb4Smrgscriptversion=2014-01-07.03; # UTC 1374b43acbb4Smrg 1375b43acbb4Smrg# A portable, pluggable option parser for Bourne shell. 1376b43acbb4Smrg# Written by Gary V. Vaughan, 2010 1377b43acbb4Smrg 1378b43acbb4Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379b43acbb4Smrg# This is free software; see the source for copying conditions. There is NO 1380b43acbb4Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381b43acbb4Smrg 1382b43acbb4Smrg# This program is free software: you can redistribute it and/or modify 1383b43acbb4Smrg# it under the terms of the GNU General Public License as published by 1384b43acbb4Smrg# the Free Software Foundation, either version 3 of the License, or 1385b43acbb4Smrg# (at your option) any later version. 1386b43acbb4Smrg 1387b43acbb4Smrg# This program is distributed in the hope that it will be useful, 1388b43acbb4Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389b43acbb4Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390b43acbb4Smrg# GNU General Public License for more details. 1391b43acbb4Smrg 1392b43acbb4Smrg# You should have received a copy of the GNU General Public License 1393b43acbb4Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394b43acbb4Smrg 1395b43acbb4Smrg# Please report bugs or propose patches to gary@gnu.org. 1396b43acbb4Smrg 1397b43acbb4Smrg 1398b43acbb4Smrg## ------ ## 1399b43acbb4Smrg## Usage. ## 1400b43acbb4Smrg## ------ ## 1401b43acbb4Smrg 1402b43acbb4Smrg# This file is a library for parsing options in your shell scripts along 1403b43acbb4Smrg# with assorted other useful supporting features that you can make use 1404b43acbb4Smrg# of too. 1405b43acbb4Smrg# 1406b43acbb4Smrg# For the simplest scripts you might need only: 1407b43acbb4Smrg# 1408b43acbb4Smrg# #!/bin/sh 1409b43acbb4Smrg# . relative/path/to/funclib.sh 1410b43acbb4Smrg# . relative/path/to/options-parser 1411b43acbb4Smrg# scriptversion=1.0 1412b43acbb4Smrg# func_options ${1+"$@"} 1413b43acbb4Smrg# eval set dummy "$func_options_result"; shift 1414b43acbb4Smrg# ...rest of your script... 1415b43acbb4Smrg# 1416b43acbb4Smrg# In order for the '--version' option to work, you will need to have a 1417b43acbb4Smrg# suitably formatted comment like the one at the top of this file 1418b43acbb4Smrg# starting with '# Written by ' and ending with '# warranty; '. 1419b43acbb4Smrg# 1420b43acbb4Smrg# For '-h' and '--help' to work, you will also need a one line 1421b43acbb4Smrg# description of your script's purpose in a comment directly above the 1422b43acbb4Smrg# '# Written by ' line, like the one at the top of this file. 1423b43acbb4Smrg# 1424b43acbb4Smrg# The default options also support '--debug', which will turn on shell 1425b43acbb4Smrg# execution tracing (see the comment above debug_cmd below for another 1426b43acbb4Smrg# use), and '--verbose' and the func_verbose function to allow your script 1427b43acbb4Smrg# to display verbose messages only when your user has specified 1428b43acbb4Smrg# '--verbose'. 1429b43acbb4Smrg# 1430b43acbb4Smrg# After sourcing this file, you can plug processing for additional 1431b43acbb4Smrg# options by amending the variables from the 'Configuration' section 1432b43acbb4Smrg# below, and following the instructions in the 'Option parsing' 1433b43acbb4Smrg# section further down. 1434b43acbb4Smrg 1435b43acbb4Smrg## -------------- ## 1436b43acbb4Smrg## Configuration. ## 1437b43acbb4Smrg## -------------- ## 1438b43acbb4Smrg 1439b43acbb4Smrg# You should override these variables in your script after sourcing this 1440b43acbb4Smrg# file so that they reflect the customisations you have added to the 1441b43acbb4Smrg# option parser. 1442b43acbb4Smrg 1443b43acbb4Smrg# The usage line for option parsing errors and the start of '-h' and 1444b43acbb4Smrg# '--help' output messages. You can embed shell variables for delayed 1445b43acbb4Smrg# expansion at the time the message is displayed, but you will need to 1446b43acbb4Smrg# quote other shell meta-characters carefully to prevent them being 1447b43acbb4Smrg# expanded when the contents are evaled. 1448b43acbb4Smrgusage='$progpath [OPTION]...' 1449b43acbb4Smrg 1450b43acbb4Smrg# Short help message in response to '-h' and '--help'. Add to this or 1451b43acbb4Smrg# override it after sourcing this library to reflect the full set of 1452b43acbb4Smrg# options your script accepts. 1453b43acbb4Smrgusage_message="\ 1454b43acbb4Smrg --debug enable verbose shell tracing 1455b43acbb4Smrg -W, --warnings=CATEGORY 1456b43acbb4Smrg report the warnings falling in CATEGORY [all] 1457b43acbb4Smrg -v, --verbose verbosely report processing 1458b43acbb4Smrg --version print version information and exit 1459b43acbb4Smrg -h, --help print short or long help message and exit 1460b43acbb4Smrg" 1461b43acbb4Smrg 1462b43acbb4Smrg# Additional text appended to 'usage_message' in response to '--help'. 1463b43acbb4Smrglong_help_message=" 1464b43acbb4SmrgWarning categories include: 1465b43acbb4Smrg 'all' show all warnings 1466b43acbb4Smrg 'none' turn off all the warnings 1467b43acbb4Smrg 'error' warnings are treated as fatal errors" 1468b43acbb4Smrg 1469b43acbb4Smrg# Help message printed before fatal option parsing errors. 1470b43acbb4Smrgfatal_help="Try '\$progname --help' for more information." 1471b43acbb4Smrg 1472b43acbb4Smrg 1473b43acbb4Smrg 1474b43acbb4Smrg## ------------------------- ## 1475b43acbb4Smrg## Hook function management. ## 1476b43acbb4Smrg## ------------------------- ## 1477b43acbb4Smrg 1478b43acbb4Smrg# This section contains functions for adding, removing, and running hooks 1479b43acbb4Smrg# to the main code. A hook is just a named list of of function, that can 1480b43acbb4Smrg# be run in order later on. 1481b43acbb4Smrg 1482b43acbb4Smrg# func_hookable FUNC_NAME 1483b43acbb4Smrg# ----------------------- 1484b43acbb4Smrg# Declare that FUNC_NAME will run hooks added with 1485b43acbb4Smrg# 'func_add_hook FUNC_NAME ...'. 1486b43acbb4Smrgfunc_hookable () 1487b43acbb4Smrg{ 1488b43acbb4Smrg $debug_cmd 1489b43acbb4Smrg 1490b43acbb4Smrg func_append hookable_fns " $1" 1491b43acbb4Smrg} 1492b43acbb4Smrg 1493b43acbb4Smrg 1494b43acbb4Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1495b43acbb4Smrg# --------------------------------- 1496b43acbb4Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497b43acbb4Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1498b43acbb4Smrgfunc_add_hook () 1499b43acbb4Smrg{ 1500b43acbb4Smrg $debug_cmd 1501b43acbb4Smrg 1502b43acbb4Smrg case " $hookable_fns " in 1503b43acbb4Smrg *" $1 "*) ;; 1504b43acbb4Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505b43acbb4Smrg esac 1506b43acbb4Smrg 1507b43acbb4Smrg eval func_append ${1}_hooks '" $2"' 1508b43acbb4Smrg} 1509b43acbb4Smrg 1510b43acbb4Smrg 1511b43acbb4Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512b43acbb4Smrg# ------------------------------------ 1513b43acbb4Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514b43acbb4Smrgfunc_remove_hook () 1515b43acbb4Smrg{ 1516b43acbb4Smrg $debug_cmd 1517b43acbb4Smrg 1518b43acbb4Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519b43acbb4Smrg} 1520b43acbb4Smrg 1521b43acbb4Smrg 1522b43acbb4Smrg# func_run_hooks FUNC_NAME [ARG]... 1523b43acbb4Smrg# --------------------------------- 1524b43acbb4Smrg# Run all hook functions registered to FUNC_NAME. 1525b43acbb4Smrg# It is assumed that the list of hook functions contains nothing more 1526b43acbb4Smrg# than a whitespace-delimited list of legal shell function names, and 1527b43acbb4Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1528b43acbb4Smrg# whitespace. 1529b43acbb4Smrgfunc_run_hooks () 1530b43acbb4Smrg{ 1531b43acbb4Smrg $debug_cmd 1532b43acbb4Smrg 1533b43acbb4Smrg case " $hookable_fns " in 1534b43acbb4Smrg *" $1 "*) ;; 1535b43acbb4Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536b43acbb4Smrg esac 1537b43acbb4Smrg 1538b43acbb4Smrg eval _G_hook_fns=\$$1_hooks; shift 1539b43acbb4Smrg 1540b43acbb4Smrg for _G_hook in $_G_hook_fns; do 1541b43acbb4Smrg eval $_G_hook '"$@"' 1542b43acbb4Smrg 1543b43acbb4Smrg # store returned options list back into positional 1544b43acbb4Smrg # parameters for next 'cmd' execution. 1545b43acbb4Smrg eval _G_hook_result=\$${_G_hook}_result 1546b43acbb4Smrg eval set dummy "$_G_hook_result"; shift 1547b43acbb4Smrg done 1548b43acbb4Smrg 1549b43acbb4Smrg func_quote_for_eval ${1+"$@"} 1550b43acbb4Smrg func_run_hooks_result=$func_quote_for_eval_result 1551b43acbb4Smrg} 1552b43acbb4Smrg 1553b43acbb4Smrg 1554b43acbb4Smrg 1555b43acbb4Smrg## --------------- ## 1556b43acbb4Smrg## Option parsing. ## 1557b43acbb4Smrg## --------------- ## 1558b43acbb4Smrg 1559b43acbb4Smrg# In order to add your own option parsing hooks, you must accept the 1560b43acbb4Smrg# full positional parameter list in your hook function, remove any 1561b43acbb4Smrg# options that you action, and then pass back the remaining unprocessed 1562b43acbb4Smrg# options in '<hooked_function_name>_result', escaped suitably for 1563b43acbb4Smrg# 'eval'. Like this: 1564b43acbb4Smrg# 1565b43acbb4Smrg# my_options_prep () 1566b43acbb4Smrg# { 1567b43acbb4Smrg# $debug_cmd 1568b43acbb4Smrg# 1569b43acbb4Smrg# # Extend the existing usage message. 1570b43acbb4Smrg# usage_message=$usage_message' 1571b43acbb4Smrg# -s, --silent don'\''t print informational messages 1572b43acbb4Smrg# ' 1573b43acbb4Smrg# 1574b43acbb4Smrg# func_quote_for_eval ${1+"$@"} 1575b43acbb4Smrg# my_options_prep_result=$func_quote_for_eval_result 1576b43acbb4Smrg# } 1577b43acbb4Smrg# func_add_hook func_options_prep my_options_prep 1578b43acbb4Smrg# 1579b43acbb4Smrg# 1580b43acbb4Smrg# my_silent_option () 1581b43acbb4Smrg# { 1582b43acbb4Smrg# $debug_cmd 1583b43acbb4Smrg# 1584b43acbb4Smrg# # Note that for efficiency, we parse as many options as we can 1585b43acbb4Smrg# # recognise in a loop before passing the remainder back to the 1586b43acbb4Smrg# # caller on the first unrecognised argument we encounter. 1587b43acbb4Smrg# while test $# -gt 0; do 1588b43acbb4Smrg# opt=$1; shift 1589b43acbb4Smrg# case $opt in 1590b43acbb4Smrg# --silent|-s) opt_silent=: ;; 1591b43acbb4Smrg# # Separate non-argument short options: 1592b43acbb4Smrg# -s*) func_split_short_opt "$_G_opt" 1593b43acbb4Smrg# set dummy "$func_split_short_opt_name" \ 1594b43acbb4Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595b43acbb4Smrg# shift 1596b43acbb4Smrg# ;; 1597b43acbb4Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598b43acbb4Smrg# esac 1599b43acbb4Smrg# done 1600b43acbb4Smrg# 1601b43acbb4Smrg# func_quote_for_eval ${1+"$@"} 1602b43acbb4Smrg# my_silent_option_result=$func_quote_for_eval_result 1603b43acbb4Smrg# } 1604b43acbb4Smrg# func_add_hook func_parse_options my_silent_option 1605b43acbb4Smrg# 1606b43acbb4Smrg# 1607b43acbb4Smrg# my_option_validation () 1608b43acbb4Smrg# { 1609b43acbb4Smrg# $debug_cmd 1610b43acbb4Smrg# 1611b43acbb4Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612b43acbb4Smrg# '--silent' and '--verbose' options are mutually exclusive." 1613b43acbb4Smrg# 1614b43acbb4Smrg# func_quote_for_eval ${1+"$@"} 1615b43acbb4Smrg# my_option_validation_result=$func_quote_for_eval_result 1616b43acbb4Smrg# } 1617b43acbb4Smrg# func_add_hook func_validate_options my_option_validation 1618b43acbb4Smrg# 1619b43acbb4Smrg# You'll alse need to manually amend $usage_message to reflect the extra 1620b43acbb4Smrg# options you parse. It's preferable to append if you can, so that 1621b43acbb4Smrg# multiple option parsing hooks can be added safely. 1622b43acbb4Smrg 1623b43acbb4Smrg 1624b43acbb4Smrg# func_options [ARG]... 1625b43acbb4Smrg# --------------------- 1626b43acbb4Smrg# All the functions called inside func_options are hookable. See the 1627b43acbb4Smrg# individual implementations for details. 1628b43acbb4Smrgfunc_hookable func_options 1629b43acbb4Smrgfunc_options () 1630b43acbb4Smrg{ 1631b43acbb4Smrg $debug_cmd 1632b43acbb4Smrg 1633b43acbb4Smrg func_options_prep ${1+"$@"} 1634b43acbb4Smrg eval func_parse_options \ 1635b43acbb4Smrg ${func_options_prep_result+"$func_options_prep_result"} 1636b43acbb4Smrg eval func_validate_options \ 1637b43acbb4Smrg ${func_parse_options_result+"$func_parse_options_result"} 1638b43acbb4Smrg 1639b43acbb4Smrg eval func_run_hooks func_options \ 1640b43acbb4Smrg ${func_validate_options_result+"$func_validate_options_result"} 1641b43acbb4Smrg 1642b43acbb4Smrg # save modified positional parameters for caller 1643b43acbb4Smrg func_options_result=$func_run_hooks_result 164423a0898aSmrg} 164523a0898aSmrg 164623a0898aSmrg 1647b43acbb4Smrg# func_options_prep [ARG]... 1648b43acbb4Smrg# -------------------------- 1649b43acbb4Smrg# All initialisations required before starting the option parse loop. 1650b43acbb4Smrg# Note that when calling hook functions, we pass through the list of 1651b43acbb4Smrg# positional parameters. If a hook function modifies that list, and 1652b43acbb4Smrg# needs to propogate that back to rest of this script, then the complete 1653b43acbb4Smrg# modified list must be put in 'func_run_hooks_result' before 1654b43acbb4Smrg# returning. 1655b43acbb4Smrgfunc_hookable func_options_prep 1656b43acbb4Smrgfunc_options_prep () 165723a0898aSmrg{ 1658b43acbb4Smrg $debug_cmd 16595a3d36dfSmrg 1660b43acbb4Smrg # Option defaults: 1661b43acbb4Smrg opt_verbose=false 1662b43acbb4Smrg opt_warning_types= 1663b43acbb4Smrg 1664b43acbb4Smrg func_run_hooks func_options_prep ${1+"$@"} 1665b43acbb4Smrg 1666b43acbb4Smrg # save modified positional parameters for caller 1667b43acbb4Smrg func_options_prep_result=$func_run_hooks_result 166823a0898aSmrg} 166923a0898aSmrg 167023a0898aSmrg 1671b43acbb4Smrg# func_parse_options [ARG]... 1672b43acbb4Smrg# --------------------------- 1673b43acbb4Smrg# The main option parsing loop. 1674b43acbb4Smrgfunc_hookable func_parse_options 1675b43acbb4Smrgfunc_parse_options () 167623a0898aSmrg{ 1677b43acbb4Smrg $debug_cmd 16785a3d36dfSmrg 1679b43acbb4Smrg func_parse_options_result= 16805a3d36dfSmrg 1681b43acbb4Smrg # this just eases exit handling 1682b43acbb4Smrg while test $# -gt 0; do 1683b43acbb4Smrg # Defer to hook functions for initial option parsing, so they 1684b43acbb4Smrg # get priority in the event of reusing an option name. 1685b43acbb4Smrg func_run_hooks func_parse_options ${1+"$@"} 168623a0898aSmrg 1687b43acbb4Smrg # Adjust func_parse_options positional parameters to match 1688b43acbb4Smrg eval set dummy "$func_run_hooks_result"; shift 168923a0898aSmrg 1690b43acbb4Smrg # Break out of the loop if we already parsed every option. 1691b43acbb4Smrg test $# -gt 0 || break 16927f7f5e4eSmrg 1693b43acbb4Smrg _G_opt=$1 1694b43acbb4Smrg shift 1695b43acbb4Smrg case $_G_opt in 1696b43acbb4Smrg --debug|-x) debug_cmd='set -x' 1697b43acbb4Smrg func_echo "enabling shell trace mode" 1698b43acbb4Smrg $debug_cmd 1699b43acbb4Smrg ;; 1700b43acbb4Smrg 1701b43acbb4Smrg --no-warnings|--no-warning|--no-warn) 1702b43acbb4Smrg set dummy --warnings none ${1+"$@"} 1703b43acbb4Smrg shift 1704b43acbb4Smrg ;; 17055a3d36dfSmrg 1706b43acbb4Smrg --warnings|--warning|-W) 1707b43acbb4Smrg test $# = 0 && func_missing_arg $_G_opt && break 1708b43acbb4Smrg case " $warning_categories $1" in 1709b43acbb4Smrg *" $1 "*) 1710b43acbb4Smrg # trailing space prevents matching last $1 above 1711b43acbb4Smrg func_append_uniq opt_warning_types " $1" 1712b43acbb4Smrg ;; 1713b43acbb4Smrg *all) 1714b43acbb4Smrg opt_warning_types=$warning_categories 1715b43acbb4Smrg ;; 1716b43acbb4Smrg *none) 1717b43acbb4Smrg opt_warning_types=none 1718b43acbb4Smrg warning_func=: 1719b43acbb4Smrg ;; 1720b43acbb4Smrg *error) 1721b43acbb4Smrg opt_warning_types=$warning_categories 1722b43acbb4Smrg warning_func=func_fatal_error 1723b43acbb4Smrg ;; 1724b43acbb4Smrg *) 1725b43acbb4Smrg func_fatal_error \ 1726b43acbb4Smrg "unsupported warning category: '$1'" 1727b43acbb4Smrg ;; 1728b43acbb4Smrg esac 1729b43acbb4Smrg shift 1730b43acbb4Smrg ;; 1731b43acbb4Smrg 1732b43acbb4Smrg --verbose|-v) opt_verbose=: ;; 1733b43acbb4Smrg --version) func_version ;; 1734b43acbb4Smrg -\?|-h) func_usage ;; 1735b43acbb4Smrg --help) func_help ;; 1736b43acbb4Smrg 1737b43acbb4Smrg # Separate optargs to long options (plugins may need this): 1738b43acbb4Smrg --*=*) func_split_equals "$_G_opt" 1739b43acbb4Smrg set dummy "$func_split_equals_lhs" \ 1740b43acbb4Smrg "$func_split_equals_rhs" ${1+"$@"} 1741b43acbb4Smrg shift 1742b43acbb4Smrg ;; 1743b43acbb4Smrg 1744b43acbb4Smrg # Separate optargs to short options: 1745b43acbb4Smrg -W*) 1746b43acbb4Smrg func_split_short_opt "$_G_opt" 1747b43acbb4Smrg set dummy "$func_split_short_opt_name" \ 1748b43acbb4Smrg "$func_split_short_opt_arg" ${1+"$@"} 1749b43acbb4Smrg shift 1750b43acbb4Smrg ;; 1751b43acbb4Smrg 1752b43acbb4Smrg # Separate non-argument short options: 1753b43acbb4Smrg -\?*|-h*|-v*|-x*) 1754b43acbb4Smrg func_split_short_opt "$_G_opt" 1755b43acbb4Smrg set dummy "$func_split_short_opt_name" \ 1756b43acbb4Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1757b43acbb4Smrg shift 1758b43acbb4Smrg ;; 1759b43acbb4Smrg 1760b43acbb4Smrg --) break ;; 1761b43acbb4Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762b43acbb4Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763b43acbb4Smrg esac 1764b43acbb4Smrg done 1765b43acbb4Smrg 1766b43acbb4Smrg # save modified positional parameters for caller 1767b43acbb4Smrg func_quote_for_eval ${1+"$@"} 1768b43acbb4Smrg func_parse_options_result=$func_quote_for_eval_result 176923a0898aSmrg} 177023a0898aSmrg 17715a3d36dfSmrg 1772b43acbb4Smrg# func_validate_options [ARG]... 1773b43acbb4Smrg# ------------------------------ 1774b43acbb4Smrg# Perform any sanity checks on option settings and/or unconsumed 1775b43acbb4Smrg# arguments. 1776b43acbb4Smrgfunc_hookable func_validate_options 1777b43acbb4Smrgfunc_validate_options () 177823a0898aSmrg{ 1779b43acbb4Smrg $debug_cmd 17805a3d36dfSmrg 1781b43acbb4Smrg # Display all warnings if -W was not given. 1782b43acbb4Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 17835a3d36dfSmrg 1784b43acbb4Smrg func_run_hooks func_validate_options ${1+"$@"} 178523a0898aSmrg 1786b43acbb4Smrg # Bail if the options were screwed! 1787b43acbb4Smrg $exit_cmd $EXIT_FAILURE 1788b43acbb4Smrg 1789b43acbb4Smrg # save modified positional parameters for caller 1790b43acbb4Smrg func_validate_options_result=$func_run_hooks_result 179141c30155Smrg} 17925a3d36dfSmrg 17935a3d36dfSmrg 179441c30155Smrg 1795b43acbb4Smrg## ----------------- ## 1796b43acbb4Smrg## Helper functions. ## 1797b43acbb4Smrg## ----------------- ## 17985a3d36dfSmrg 1799b43acbb4Smrg# This section contains the helper functions used by the rest of the 1800b43acbb4Smrg# hookable option parser framework in ascii-betical order. 1801b43acbb4Smrg 1802b43acbb4Smrg 1803b43acbb4Smrg# func_fatal_help ARG... 1804b43acbb4Smrg# ---------------------- 1805b43acbb4Smrg# Echo program name prefixed message to standard error, followed by 1806b43acbb4Smrg# a help hint, and exit. 1807b43acbb4Smrgfunc_fatal_help () 18085a3d36dfSmrg{ 1809b43acbb4Smrg $debug_cmd 181041c30155Smrg 1811b43acbb4Smrg eval \$ECHO \""Usage: $usage"\" 1812b43acbb4Smrg eval \$ECHO \""$fatal_help"\" 1813b43acbb4Smrg func_error ${1+"$@"} 1814b43acbb4Smrg exit $EXIT_FAILURE 18155a3d36dfSmrg} 18165a3d36dfSmrg 1817b43acbb4Smrg 1818b43acbb4Smrg# func_help 1819b43acbb4Smrg# --------- 1820b43acbb4Smrg# Echo long help message to standard output and exit. 18215a3d36dfSmrgfunc_help () 18225a3d36dfSmrg{ 1823b43acbb4Smrg $debug_cmd 1824b43acbb4Smrg 1825b43acbb4Smrg func_usage_message 1826b43acbb4Smrg $ECHO "$long_help_message" 1827b43acbb4Smrg exit 0 18285a3d36dfSmrg} 18295a3d36dfSmrg 1830b43acbb4Smrg 1831b43acbb4Smrg# func_missing_arg ARGNAME 1832b43acbb4Smrg# ------------------------ 18335a3d36dfSmrg# Echo program name prefixed message to standard error and set global 18345a3d36dfSmrg# exit_cmd. 18355a3d36dfSmrgfunc_missing_arg () 18365a3d36dfSmrg{ 1837b43acbb4Smrg $debug_cmd 183841c30155Smrg 1839b43acbb4Smrg func_error "Missing argument for '$1'." 18405a3d36dfSmrg exit_cmd=exit 184123a0898aSmrg} 184223a0898aSmrg 18437f7f5e4eSmrg 1844b43acbb4Smrg# func_split_equals STRING 1845b43acbb4Smrg# ------------------------ 1846b43acbb4Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847b43acbb4Smrg# splitting STRING at the '=' sign. 1848b43acbb4Smrgtest -z "$_G_HAVE_XSI_OPS" \ 1849b43acbb4Smrg && (eval 'x=a/b/c; 1850b43acbb4Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851b43acbb4Smrg && _G_HAVE_XSI_OPS=yes 1852b43acbb4Smrg 1853b43acbb4Smrgif test yes = "$_G_HAVE_XSI_OPS" 1854b43acbb4Smrgthen 1855b43acbb4Smrg # This is an XSI compatible shell, allowing a faster implementation... 1856b43acbb4Smrg eval 'func_split_equals () 1857b43acbb4Smrg { 1858b43acbb4Smrg $debug_cmd 1859b43acbb4Smrg 1860b43acbb4Smrg func_split_equals_lhs=${1%%=*} 1861b43acbb4Smrg func_split_equals_rhs=${1#*=} 1862b43acbb4Smrg test "x$func_split_equals_lhs" = "x$1" \ 1863b43acbb4Smrg && func_split_equals_rhs= 1864b43acbb4Smrg }' 1865b43acbb4Smrgelse 1866b43acbb4Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867b43acbb4Smrg func_split_equals () 1868b43acbb4Smrg { 1869b43acbb4Smrg $debug_cmd 1870b43acbb4Smrg 1871b43acbb4Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872b43acbb4Smrg func_split_equals_rhs= 1873b43acbb4Smrg test "x$func_split_equals_lhs" = "x$1" \ 1874b43acbb4Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875b43acbb4Smrg } 1876b43acbb4Smrgfi #func_split_equals 1877b43acbb4Smrg 1878b43acbb4Smrg 1879b43acbb4Smrg# func_split_short_opt SHORTOPT 1880b43acbb4Smrg# ----------------------------- 188141c30155Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 188241c30155Smrg# variables after splitting SHORTOPT after the 2nd character. 1883b43acbb4Smrgif test yes = "$_G_HAVE_XSI_OPS" 1884b43acbb4Smrgthen 1885b43acbb4Smrg # This is an XSI compatible shell, allowing a faster implementation... 1886b43acbb4Smrg eval 'func_split_short_opt () 1887b43acbb4Smrg { 1888b43acbb4Smrg $debug_cmd 1889b43acbb4Smrg 1890b43acbb4Smrg func_split_short_opt_arg=${1#??} 1891b43acbb4Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892b43acbb4Smrg }' 1893b43acbb4Smrgelse 1894b43acbb4Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895b43acbb4Smrg func_split_short_opt () 1896b43acbb4Smrg { 1897b43acbb4Smrg $debug_cmd 1898b43acbb4Smrg 1899b43acbb4Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900b43acbb4Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901b43acbb4Smrg } 1902b43acbb4Smrgfi #func_split_short_opt 1903b43acbb4Smrg 1904b43acbb4Smrg 1905b43acbb4Smrg# func_usage 1906b43acbb4Smrg# ---------- 1907b43acbb4Smrg# Echo short help message to standard output and exit. 1908b43acbb4Smrgfunc_usage () 190941c30155Smrg{ 1910b43acbb4Smrg $debug_cmd 19117f7f5e4eSmrg 1912b43acbb4Smrg func_usage_message 1913b43acbb4Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914b43acbb4Smrg exit 0 1915b43acbb4Smrg} 191641c30155Smrg 191741c30155Smrg 1918b43acbb4Smrg# func_usage_message 1919b43acbb4Smrg# ------------------ 1920b43acbb4Smrg# Echo short help message to standard output. 1921b43acbb4Smrgfunc_usage_message () 192241c30155Smrg{ 1923b43acbb4Smrg $debug_cmd 192441c30155Smrg 1925b43acbb4Smrg eval \$ECHO \""Usage: $usage"\" 1926b43acbb4Smrg echo 1927b43acbb4Smrg $SED -n 's|^# || 1928b43acbb4Smrg /^Written by/{ 1929b43acbb4Smrg x;p;x 1930b43acbb4Smrg } 1931b43acbb4Smrg h 1932b43acbb4Smrg /^Written by/q' < "$progpath" 1933b43acbb4Smrg echo 1934b43acbb4Smrg eval \$ECHO \""$usage_message"\" 1935b43acbb4Smrg} 193641c30155Smrg 19375a3d36dfSmrg 1938b43acbb4Smrg# func_version 1939b43acbb4Smrg# ------------ 1940b43acbb4Smrg# Echo version message to standard output and exit. 1941b43acbb4Smrgfunc_version () 1942b43acbb4Smrg{ 1943b43acbb4Smrg $debug_cmd 19445a3d36dfSmrg 1945b43acbb4Smrg printf '%s\n' "$progname $scriptversion" 1946b43acbb4Smrg $SED -n ' 1947b43acbb4Smrg /(C)/!b go 1948b43acbb4Smrg :more 1949b43acbb4Smrg /\./!{ 1950b43acbb4Smrg N 1951b43acbb4Smrg s|\n# | | 1952b43acbb4Smrg b more 1953b43acbb4Smrg } 1954b43acbb4Smrg :go 1955b43acbb4Smrg /^# Written by /,/# warranty; / { 1956b43acbb4Smrg s|^# || 1957b43acbb4Smrg s|^# *$|| 1958b43acbb4Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959b43acbb4Smrg p 1960b43acbb4Smrg } 1961b43acbb4Smrg /^# Written by / { 1962b43acbb4Smrg s|^# || 1963b43acbb4Smrg p 1964b43acbb4Smrg } 1965b43acbb4Smrg /^warranty; /q' < "$progpath" 19665a3d36dfSmrg 1967b43acbb4Smrg exit $? 1968b43acbb4Smrg} 196923a0898aSmrg 197023a0898aSmrg 1971b43acbb4Smrg# Local variables: 1972b43acbb4Smrg# mode: shell-script 1973b43acbb4Smrg# sh-indentation: 2 1974b43acbb4Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1975b43acbb4Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976b43acbb4Smrg# time-stamp-time-zone: "UTC" 1977b43acbb4Smrg# End: 197823a0898aSmrg 1979b43acbb4Smrg# Set a version string. 1980b43acbb4Smrgscriptversion='(GNU libtool) 2.4.6' 19817f7f5e4eSmrg 19825a3d36dfSmrg 1983b43acbb4Smrg# func_echo ARG... 1984b43acbb4Smrg# ---------------- 1985b43acbb4Smrg# Libtool also displays the current mode in messages, so override 1986b43acbb4Smrg# funclib.sh func_echo with this custom definition. 1987b43acbb4Smrgfunc_echo () 198841c30155Smrg{ 1989b43acbb4Smrg $debug_cmd 199041c30155Smrg 1991b43acbb4Smrg _G_message=$* 199241c30155Smrg 1993b43acbb4Smrg func_echo_IFS=$IFS 1994b43acbb4Smrg IFS=$nl 1995b43acbb4Smrg for _G_line in $_G_message; do 1996b43acbb4Smrg IFS=$func_echo_IFS 1997b43acbb4Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998b43acbb4Smrg done 1999b43acbb4Smrg IFS=$func_echo_IFS 2000b43acbb4Smrg} 200141c30155Smrg 2002b43acbb4Smrg 2003b43acbb4Smrg# func_warning ARG... 2004b43acbb4Smrg# ------------------- 2005b43acbb4Smrg# Libtool warnings are not categorized, so override funclib.sh 2006b43acbb4Smrg# func_warning with this simpler definition. 2007b43acbb4Smrgfunc_warning () 200841c30155Smrg{ 2009b43acbb4Smrg $debug_cmd 201041c30155Smrg 2011b43acbb4Smrg $warning_func ${1+"$@"} 2012b43acbb4Smrg} 201341c30155Smrg 201441c30155Smrg 2015b43acbb4Smrg## ---------------- ## 2016b43acbb4Smrg## Options parsing. ## 2017b43acbb4Smrg## ---------------- ## 2018b43acbb4Smrg 2019b43acbb4Smrg# Hook in the functions to make sure our own options are parsed during 2020b43acbb4Smrg# the option parsing loop. 2021b43acbb4Smrg 2022b43acbb4Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023b43acbb4Smrg 2024b43acbb4Smrg# Short help message in response to '-h'. 2025b43acbb4Smrgusage_message="Options: 2026b43acbb4Smrg --config show all configuration variables 2027b43acbb4Smrg --debug enable verbose shell tracing 2028b43acbb4Smrg -n, --dry-run display commands without modifying any files 2029b43acbb4Smrg --features display basic configuration information and exit 2030b43acbb4Smrg --mode=MODE use operation mode MODE 2031b43acbb4Smrg --no-warnings equivalent to '-Wnone' 2032b43acbb4Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2033b43acbb4Smrg --quiet, --silent don't print informational messages 2034b43acbb4Smrg --tag=TAG use configuration variables from tag TAG 2035b43acbb4Smrg -v, --verbose print more informational messages than default 2036b43acbb4Smrg --version print version information 2037b43acbb4Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038b43acbb4Smrg -h, --help, --help-all print short, long, or detailed help message 2039b43acbb4Smrg" 204041c30155Smrg 2041b43acbb4Smrg# Additional text appended to 'usage_message' in response to '--help'. 2042b43acbb4Smrgfunc_help () 204341c30155Smrg{ 2044b43acbb4Smrg $debug_cmd 2045b43acbb4Smrg 2046b43acbb4Smrg func_usage_message 2047b43acbb4Smrg $ECHO "$long_help_message 2048b43acbb4Smrg 2049b43acbb4SmrgMODE must be one of the following: 2050b43acbb4Smrg 2051b43acbb4Smrg clean remove files from the build directory 2052b43acbb4Smrg compile compile a source file into a libtool object 2053b43acbb4Smrg execute automatically set library path, then run a program 2054b43acbb4Smrg finish complete the installation of libtool libraries 2055b43acbb4Smrg install install libraries or executables 2056b43acbb4Smrg link create a library or an executable 2057b43acbb4Smrg uninstall remove libraries from an installed directory 2058b43acbb4Smrg 2059b43acbb4SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060b43acbb4Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061b43acbb4SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062b43acbb4Smrg 2063b43acbb4SmrgWhen reporting a bug, please describe a test case to reproduce it and 2064b43acbb4Smrginclude the following information: 2065b43acbb4Smrg 2066b43acbb4Smrg host-triplet: $host 2067b43acbb4Smrg shell: $SHELL 2068b43acbb4Smrg compiler: $LTCC 2069b43acbb4Smrg compiler flags: $LTCFLAGS 2070b43acbb4Smrg linker: $LD (gnu? $with_gnu_ld) 2071b43acbb4Smrg version: $progname (GNU libtool) 2.4.6 2072b43acbb4Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073b43acbb4Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074b43acbb4Smrg 2075b43acbb4SmrgReport bugs to <bug-libtool@gnu.org>. 2076a97c3f35SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 2077b43acbb4SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078b43acbb4Smrg exit 0 2079b43acbb4Smrg} 208041c30155Smrg 208141c30155Smrg 2082b43acbb4Smrg# func_lo2o OBJECT-NAME 2083b43acbb4Smrg# --------------------- 2084b43acbb4Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085b43acbb4Smrg# object suffix. 2086b43acbb4Smrg 2087b43acbb4Smrglo2o=s/\\.lo\$/.$objext/ 2088b43acbb4Smrgo2lo=s/\\.$objext\$/.lo/ 2089b43acbb4Smrg 2090b43acbb4Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091b43acbb4Smrg eval 'func_lo2o () 2092b43acbb4Smrg { 2093b43acbb4Smrg case $1 in 2094b43acbb4Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095b43acbb4Smrg * ) func_lo2o_result=$1 ;; 2096b43acbb4Smrg esac 2097b43acbb4Smrg }' 2098b43acbb4Smrg 2099b43acbb4Smrg # func_xform LIBOBJ-OR-SOURCE 2100b43acbb4Smrg # --------------------------- 2101b43acbb4Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102b43acbb4Smrg # suffix to a '.lo' libtool-object suffix. 2103b43acbb4Smrg eval 'func_xform () 2104b43acbb4Smrg { 2105b43acbb4Smrg func_xform_result=${1%.*}.lo 2106b43acbb4Smrg }' 2107b43acbb4Smrgelse 2108b43acbb4Smrg # ...otherwise fall back to using sed. 2109b43acbb4Smrg func_lo2o () 2110b43acbb4Smrg { 2111b43acbb4Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112b43acbb4Smrg } 2113b43acbb4Smrg 2114b43acbb4Smrg func_xform () 2115b43acbb4Smrg { 2116b43acbb4Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117b43acbb4Smrg } 2118b43acbb4Smrgfi 211941c30155Smrg 212041c30155Smrg 2121b43acbb4Smrg# func_fatal_configuration ARG... 2122b43acbb4Smrg# ------------------------------- 21235a3d36dfSmrg# Echo program name prefixed message to standard error, followed by 21245a3d36dfSmrg# a configuration failure hint, and exit. 21255a3d36dfSmrgfunc_fatal_configuration () 21265a3d36dfSmrg{ 2127b43acbb4Smrg func__fatal_error ${1+"$@"} \ 2128b43acbb4Smrg "See the $PACKAGE documentation for more information." \ 2129b43acbb4Smrg "Fatal configuration error." 21305a3d36dfSmrg} 213123a0898aSmrg 21327f7f5e4eSmrg 21335a3d36dfSmrg# func_config 2134b43acbb4Smrg# ----------- 21355a3d36dfSmrg# Display the configuration for all the tags in this script. 21365a3d36dfSmrgfunc_config () 21375a3d36dfSmrg{ 21385a3d36dfSmrg re_begincf='^# ### BEGIN LIBTOOL' 21395a3d36dfSmrg re_endcf='^# ### END LIBTOOL' 21405a3d36dfSmrg 21415a3d36dfSmrg # Default configuration. 21425a3d36dfSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 214323a0898aSmrg 214423a0898aSmrg # Now print the configurations for the tags. 214523a0898aSmrg for tagname in $taglist; do 21465a3d36dfSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 214723a0898aSmrg done 2148b3062210Smrg 21495a3d36dfSmrg exit $? 21505a3d36dfSmrg} 2151b3062210Smrg 2152b43acbb4Smrg 21535a3d36dfSmrg# func_features 2154b43acbb4Smrg# ------------- 21555a3d36dfSmrg# Display the features supported by this script. 21565a3d36dfSmrgfunc_features () 21575a3d36dfSmrg{ 215841c30155Smrg echo "host: $host" 2159b43acbb4Smrg if test yes = "$build_libtool_libs"; then 216041c30155Smrg echo "enable shared libraries" 216123a0898aSmrg else 216241c30155Smrg echo "disable shared libraries" 216323a0898aSmrg fi 2164b43acbb4Smrg if test yes = "$build_old_libs"; then 216541c30155Smrg echo "enable static libraries" 216623a0898aSmrg else 216741c30155Smrg echo "disable static libraries" 216823a0898aSmrg fi 21695a3d36dfSmrg 217023a0898aSmrg exit $? 21715a3d36dfSmrg} 217223a0898aSmrg 2173b43acbb4Smrg 2174b43acbb4Smrg# func_enable_tag TAGNAME 2175b43acbb4Smrg# ----------------------- 21765a3d36dfSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 21775a3d36dfSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 21785a3d36dfSmrg# variable here. 21795a3d36dfSmrgfunc_enable_tag () 21805a3d36dfSmrg{ 2181b43acbb4Smrg # Global variable: 2182b43acbb4Smrg tagname=$1 218323a0898aSmrg 2184b43acbb4Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185b43acbb4Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186b43acbb4Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 21877f7f5e4eSmrg 2188b43acbb4Smrg # Validate tagname. 2189b43acbb4Smrg case $tagname in 2190b43acbb4Smrg *[!-_A-Za-z0-9,/]*) 2191b43acbb4Smrg func_fatal_error "invalid tag name: $tagname" 2192b43acbb4Smrg ;; 2193b43acbb4Smrg esac 219423a0898aSmrg 2195b43acbb4Smrg # Don't test for the "default" C tag, as we know it's 2196b43acbb4Smrg # there but not specially marked. 2197b43acbb4Smrg case $tagname in 2198b43acbb4Smrg CC) ;; 21995a3d36dfSmrg *) 2200b43acbb4Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201b43acbb4Smrg taglist="$taglist $tagname" 2202b43acbb4Smrg 2203b43acbb4Smrg # Evaluate the configuration. Be careful to quote the path 2204b43acbb4Smrg # and the sed script, to avoid splitting on whitespace, but 2205b43acbb4Smrg # also don't use non-portable quotes within backquotes within 2206b43acbb4Smrg # quotes we have to do it in 2 steps: 2207b43acbb4Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208b43acbb4Smrg eval "$extractedcf" 2209b43acbb4Smrg else 2210b43acbb4Smrg func_error "ignoring unknown tag $tagname" 2211b43acbb4Smrg fi 2212b43acbb4Smrg ;; 2213b43acbb4Smrg esac 22145a3d36dfSmrg} 22155a3d36dfSmrg 2216b43acbb4Smrg 221741c30155Smrg# func_check_version_match 2218b43acbb4Smrg# ------------------------ 221941c30155Smrg# Ensure that we are using m4 macros, and libtool script from the same 222041c30155Smrg# release of libtool. 222141c30155Smrgfunc_check_version_match () 22225a3d36dfSmrg{ 2223b43acbb4Smrg if test "$package_revision" != "$macro_revision"; then 2224b43acbb4Smrg if test "$VERSION" != "$macro_version"; then 2225b43acbb4Smrg if test -z "$macro_version"; then 2226b43acbb4Smrg cat >&2 <<_LT_EOF 222741c30155Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 222841c30155Smrg$progname: definition of this LT_INIT comes from an older release. 222941c30155Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223041c30155Smrg$progname: and run autoconf again. 223141c30155Smrg_LT_EOF 2232b43acbb4Smrg else 2233b43acbb4Smrg cat >&2 <<_LT_EOF 223441c30155Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 223541c30155Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 223641c30155Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223741c30155Smrg$progname: and run autoconf again. 223841c30155Smrg_LT_EOF 2239b43acbb4Smrg fi 2240b43acbb4Smrg else 2241b43acbb4Smrg cat >&2 <<_LT_EOF 224241c30155Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 224341c30155Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 224441c30155Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 224541c30155Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 224641c30155Smrg_LT_EOF 2247b43acbb4Smrg fi 224841c30155Smrg 2249b43acbb4Smrg exit $EXIT_MISMATCH 2250b43acbb4Smrg fi 225141c30155Smrg} 225241c30155Smrg 225341c30155Smrg 2254b43acbb4Smrg# libtool_options_prep [ARG]... 2255b43acbb4Smrg# ----------------------------- 2256b43acbb4Smrg# Preparation for options parsed by libtool. 2257b43acbb4Smrglibtool_options_prep () 2258b43acbb4Smrg{ 2259b43acbb4Smrg $debug_mode 226041c30155Smrg 2261b43acbb4Smrg # Option defaults: 2262b43acbb4Smrg opt_config=false 2263b43acbb4Smrg opt_dlopen= 2264b43acbb4Smrg opt_dry_run=false 2265b43acbb4Smrg opt_help=false 2266b43acbb4Smrg opt_mode= 2267b43acbb4Smrg opt_preserve_dup_deps=false 2268b43acbb4Smrg opt_quiet=false 226941c30155Smrg 2270b43acbb4Smrg nonopt= 2271b43acbb4Smrg preserve_args= 227241c30155Smrg 2273b43acbb4Smrg # Shorthand for --mode=foo, only valid as the first argument 2274b43acbb4Smrg case $1 in 2275b43acbb4Smrg clean|clea|cle|cl) 2276b43acbb4Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2277b43acbb4Smrg ;; 2278b43acbb4Smrg compile|compil|compi|comp|com|co|c) 2279b43acbb4Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2280b43acbb4Smrg ;; 2281b43acbb4Smrg execute|execut|execu|exec|exe|ex|e) 2282b43acbb4Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2283b43acbb4Smrg ;; 2284b43acbb4Smrg finish|finis|fini|fin|fi|f) 2285b43acbb4Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2286b43acbb4Smrg ;; 2287b43acbb4Smrg install|instal|insta|inst|ins|in|i) 2288b43acbb4Smrg shift; set dummy --mode install ${1+"$@"}; shift 2289b43acbb4Smrg ;; 2290b43acbb4Smrg link|lin|li|l) 2291b43acbb4Smrg shift; set dummy --mode link ${1+"$@"}; shift 2292b43acbb4Smrg ;; 2293b43acbb4Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294b43acbb4Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295b43acbb4Smrg ;; 2296b43acbb4Smrg esac 2297b43acbb4Smrg 2298b43acbb4Smrg # Pass back the list of options. 2299b43acbb4Smrg func_quote_for_eval ${1+"$@"} 2300b43acbb4Smrg libtool_options_prep_result=$func_quote_for_eval_result 2301b43acbb4Smrg} 2302b43acbb4Smrgfunc_add_hook func_options_prep libtool_options_prep 2303b3062210Smrg 230423a0898aSmrg 2305b43acbb4Smrg# libtool_parse_options [ARG]... 2306b43acbb4Smrg# --------------------------------- 2307b43acbb4Smrg# Provide handling for libtool specific options. 2308b43acbb4Smrglibtool_parse_options () 230941c30155Smrg{ 2310b43acbb4Smrg $debug_cmd 23115a3d36dfSmrg 2312b43acbb4Smrg # Perform our own loop to consume as many options as possible in 2313b43acbb4Smrg # each iteration. 2314b43acbb4Smrg while test $# -gt 0; do 2315b43acbb4Smrg _G_opt=$1 2316b43acbb4Smrg shift 2317b43acbb4Smrg case $_G_opt in 2318b43acbb4Smrg --dry-run|--dryrun|-n) 2319b43acbb4Smrg opt_dry_run=: 2320b43acbb4Smrg ;; 2321b43acbb4Smrg 2322b43acbb4Smrg --config) func_config ;; 2323b43acbb4Smrg 2324b43acbb4Smrg --dlopen|-dlopen) 2325b43acbb4Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326b43acbb4Smrg}$1" 2327b43acbb4Smrg shift 2328b43acbb4Smrg ;; 2329b43acbb4Smrg 2330b43acbb4Smrg --preserve-dup-deps) 2331b43acbb4Smrg opt_preserve_dup_deps=: ;; 2332b43acbb4Smrg 2333b43acbb4Smrg --features) func_features ;; 2334b43acbb4Smrg 2335b43acbb4Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336b43acbb4Smrg 2337b43acbb4Smrg --help) opt_help=: ;; 2338b43acbb4Smrg 2339b43acbb4Smrg --help-all) opt_help=': help-all' ;; 2340b43acbb4Smrg 2341b43acbb4Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342b43acbb4Smrg opt_mode=$1 2343b43acbb4Smrg case $1 in 2344b43acbb4Smrg # Valid mode arguments: 2345b43acbb4Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346b43acbb4Smrg 2347b43acbb4Smrg # Catch anything else as an error 2348b43acbb4Smrg *) func_error "invalid argument for $_G_opt" 2349b43acbb4Smrg exit_cmd=exit 2350b43acbb4Smrg break 2351b43acbb4Smrg ;; 2352b43acbb4Smrg esac 2353b43acbb4Smrg shift 2354b43acbb4Smrg ;; 2355b43acbb4Smrg 2356b43acbb4Smrg --no-silent|--no-quiet) 2357b43acbb4Smrg opt_quiet=false 2358b43acbb4Smrg func_append preserve_args " $_G_opt" 2359b43acbb4Smrg ;; 2360b43acbb4Smrg 2361b43acbb4Smrg --no-warnings|--no-warning|--no-warn) 2362b43acbb4Smrg opt_warning=false 2363b43acbb4Smrg func_append preserve_args " $_G_opt" 2364b43acbb4Smrg ;; 2365b43acbb4Smrg 2366b43acbb4Smrg --no-verbose) 2367b43acbb4Smrg opt_verbose=false 2368b43acbb4Smrg func_append preserve_args " $_G_opt" 2369b43acbb4Smrg ;; 2370b43acbb4Smrg 2371b43acbb4Smrg --silent|--quiet) 2372b43acbb4Smrg opt_quiet=: 2373b43acbb4Smrg opt_verbose=false 2374b43acbb4Smrg func_append preserve_args " $_G_opt" 2375b43acbb4Smrg ;; 2376b43acbb4Smrg 2377b43acbb4Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378b43acbb4Smrg opt_tag=$1 2379b43acbb4Smrg func_append preserve_args " $_G_opt $1" 2380b43acbb4Smrg func_enable_tag "$1" 2381b43acbb4Smrg shift 2382b43acbb4Smrg ;; 2383b43acbb4Smrg 2384b43acbb4Smrg --verbose|-v) opt_quiet=false 2385b43acbb4Smrg opt_verbose=: 2386b43acbb4Smrg func_append preserve_args " $_G_opt" 2387b43acbb4Smrg ;; 2388b43acbb4Smrg 2389b43acbb4Smrg # An option not handled by this hook function: 2390b43acbb4Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391b43acbb4Smrg esac 2392b43acbb4Smrg done 239341c30155Smrg 239441c30155Smrg 2395b43acbb4Smrg # save modified positional parameters for caller 2396b43acbb4Smrg func_quote_for_eval ${1+"$@"} 2397b43acbb4Smrg libtool_parse_options_result=$func_quote_for_eval_result 2398b43acbb4Smrg} 2399b43acbb4Smrgfunc_add_hook func_parse_options libtool_parse_options 24005a3d36dfSmrg 24017f7f5e4eSmrg 24025a3d36dfSmrg 2403b43acbb4Smrg# libtool_validate_options [ARG]... 2404b43acbb4Smrg# --------------------------------- 2405b43acbb4Smrg# Perform any sanity checks on option settings and/or unconsumed 2406b43acbb4Smrg# arguments. 2407b43acbb4Smrglibtool_validate_options () 2408b43acbb4Smrg{ 2409b43acbb4Smrg # save first non-option argument 2410b43acbb4Smrg if test 0 -lt $#; then 2411b43acbb4Smrg nonopt=$1 2412b43acbb4Smrg shift 24135a3d36dfSmrg fi 24145a3d36dfSmrg 2415b43acbb4Smrg # preserve --debug 2416b43acbb4Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 24175a3d36dfSmrg 2418b43acbb4Smrg case $host in 2419b43acbb4Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420b43acbb4Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421b43acbb4Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422b43acbb4Smrg # don't eliminate duplications in $postdeps and $predeps 2423b43acbb4Smrg opt_duplicate_compiler_generated_deps=: 2424b43acbb4Smrg ;; 2425b43acbb4Smrg *) 2426b43acbb4Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427b43acbb4Smrg ;; 2428b43acbb4Smrg esac 242923a0898aSmrg 2430b43acbb4Smrg $opt_help || { 2431b43acbb4Smrg # Sanity checks first: 2432b43acbb4Smrg func_check_version_match 2433b43acbb4Smrg 2434b43acbb4Smrg test yes != "$build_libtool_libs" \ 2435b43acbb4Smrg && test yes != "$build_old_libs" \ 2436b43acbb4Smrg && func_fatal_configuration "not configured to build any kind of library" 2437b43acbb4Smrg 2438b43acbb4Smrg # Darwin sucks 2439b43acbb4Smrg eval std_shrext=\"$shrext_cmds\" 2440b43acbb4Smrg 2441b43acbb4Smrg # Only execute mode is allowed to have -dlopen flags. 2442b43acbb4Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443b43acbb4Smrg func_error "unrecognized option '-dlopen'" 2444b43acbb4Smrg $ECHO "$help" 1>&2 2445b43acbb4Smrg exit $EXIT_FAILURE 2446b43acbb4Smrg fi 24475a3d36dfSmrg 2448b43acbb4Smrg # Change the help message to a mode-specific one. 2449b43acbb4Smrg generic_help=$help 2450b43acbb4Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451b43acbb4Smrg } 24525a3d36dfSmrg 2453b43acbb4Smrg # Pass back the unparsed argument list 2454b43acbb4Smrg func_quote_for_eval ${1+"$@"} 2455b43acbb4Smrg libtool_validate_options_result=$func_quote_for_eval_result 245641c30155Smrg} 2457b43acbb4Smrgfunc_add_hook func_validate_options libtool_validate_options 24585a3d36dfSmrg 24595a3d36dfSmrg 2460b43acbb4Smrg# Process options as early as possible so that --help and --version 2461b43acbb4Smrg# can return quickly. 2462b43acbb4Smrgfunc_options ${1+"$@"} 2463b43acbb4Smrgeval set dummy "$func_options_result"; shift 2464b43acbb4Smrg 246523a0898aSmrg 246623a0898aSmrg 246741c30155Smrg## ----------- ## 246841c30155Smrg## Main. ## 246941c30155Smrg## ----------- ## 247023a0898aSmrg 2471b43acbb4Smrgmagic='%%%MAGIC variable%%%' 2472b43acbb4Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2473b43acbb4Smrg 2474b43acbb4Smrg# Global variables. 2475b43acbb4Smrgextracted_archives= 2476b43acbb4Smrgextracted_serial=0 2477b43acbb4Smrg 2478b43acbb4Smrg# If this variable is set in any of the actions, the command in it 2479b43acbb4Smrg# will be execed at the end. This prevents here-documents from being 2480b43acbb4Smrg# left over by shells. 2481b43acbb4Smrgexec_cmd= 2482b43acbb4Smrg 2483b43acbb4Smrg 2484b43acbb4Smrg# A function that is used when there is no print builtin or printf. 2485b43acbb4Smrgfunc_fallback_echo () 2486b43acbb4Smrg{ 2487b43acbb4Smrg eval 'cat <<_LTECHO_EOF 2488b43acbb4Smrg$1 2489b43acbb4Smrg_LTECHO_EOF' 2490b43acbb4Smrg} 2491b43acbb4Smrg 2492b43acbb4Smrg# func_generated_by_libtool 2493b43acbb4Smrg# True iff stdin has been generated by Libtool. This function is only 2494b43acbb4Smrg# a basic sanity check; it will hardly flush out determined imposters. 2495b43acbb4Smrgfunc_generated_by_libtool_p () 2496b43acbb4Smrg{ 2497b43acbb4Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498b43acbb4Smrg} 2499b43acbb4Smrg 25005a3d36dfSmrg# func_lalib_p file 2501b43acbb4Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25025a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out 25035a3d36dfSmrg# determined imposters. 25045a3d36dfSmrgfunc_lalib_p () 25055a3d36dfSmrg{ 25065a3d36dfSmrg test -f "$1" && 2507b43acbb4Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 25085a3d36dfSmrg} 250923a0898aSmrg 25105a3d36dfSmrg# func_lalib_unsafe_p file 2511b43acbb4Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25125a3d36dfSmrg# This function implements the same check as func_lalib_p without 25135a3d36dfSmrg# resorting to external programs. To this end, it redirects stdin and 25145a3d36dfSmrg# closes it afterwards, without saving the original file descriptor. 25155a3d36dfSmrg# As a safety measure, use it only where a negative result would be 2516b43acbb4Smrg# fatal anyway. Works if 'file' does not exist. 25175a3d36dfSmrgfunc_lalib_unsafe_p () 25185a3d36dfSmrg{ 25195a3d36dfSmrg lalib_p=no 25205a3d36dfSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 25215a3d36dfSmrg for lalib_p_l in 1 2 3 4 25225a3d36dfSmrg do 25235a3d36dfSmrg read lalib_p_line 2524b43acbb4Smrg case $lalib_p_line in 25255a3d36dfSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 25265a3d36dfSmrg esac 25275a3d36dfSmrg done 25285a3d36dfSmrg exec 0<&5 5<&- 25295a3d36dfSmrg fi 2530b43acbb4Smrg test yes = "$lalib_p" 25315a3d36dfSmrg} 253223a0898aSmrg 25335a3d36dfSmrg# func_ltwrapper_script_p file 25345a3d36dfSmrg# True iff FILE is a libtool wrapper script 25355a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out 25365a3d36dfSmrg# determined imposters. 25375a3d36dfSmrgfunc_ltwrapper_script_p () 25385a3d36dfSmrg{ 2539b43acbb4Smrg test -f "$1" && 2540b43acbb4Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 25415a3d36dfSmrg} 254223a0898aSmrg 25435a3d36dfSmrg# func_ltwrapper_executable_p file 25445a3d36dfSmrg# True iff FILE is a libtool wrapper executable 25455a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out 25465a3d36dfSmrg# determined imposters. 25475a3d36dfSmrgfunc_ltwrapper_executable_p () 25485a3d36dfSmrg{ 25495a3d36dfSmrg func_ltwrapper_exec_suffix= 25505a3d36dfSmrg case $1 in 25515a3d36dfSmrg *.exe) ;; 25525a3d36dfSmrg *) func_ltwrapper_exec_suffix=.exe ;; 25535a3d36dfSmrg esac 25545a3d36dfSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 25555a3d36dfSmrg} 25567f7f5e4eSmrg 25575a3d36dfSmrg# func_ltwrapper_scriptname file 25585a3d36dfSmrg# Assumes file is an ltwrapper_executable 25595a3d36dfSmrg# uses $file to determine the appropriate filename for a 25605a3d36dfSmrg# temporary ltwrapper_script. 25615a3d36dfSmrgfunc_ltwrapper_scriptname () 25625a3d36dfSmrg{ 256341c30155Smrg func_dirname_and_basename "$1" "" "." 256441c30155Smrg func_stripname '' '.exe' "$func_basename_result" 2565b43acbb4Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 25665a3d36dfSmrg} 25675a3d36dfSmrg 25685a3d36dfSmrg# func_ltwrapper_p file 25695a3d36dfSmrg# True iff FILE is a libtool wrapper script or wrapper executable 25705a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out 25715a3d36dfSmrg# determined imposters. 25725a3d36dfSmrgfunc_ltwrapper_p () 25735a3d36dfSmrg{ 25745a3d36dfSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 25755a3d36dfSmrg} 25765a3d36dfSmrg 25775a3d36dfSmrg 25785a3d36dfSmrg# func_execute_cmds commands fail_cmd 25795a3d36dfSmrg# Execute tilde-delimited COMMANDS. 25805a3d36dfSmrg# If FAIL_CMD is given, eval that upon failure. 25815a3d36dfSmrg# FAIL_CMD may read-access the current command in variable CMD! 25825a3d36dfSmrgfunc_execute_cmds () 25835a3d36dfSmrg{ 2584b43acbb4Smrg $debug_cmd 2585b43acbb4Smrg 25865a3d36dfSmrg save_ifs=$IFS; IFS='~' 25875a3d36dfSmrg for cmd in $1; do 2588b43acbb4Smrg IFS=$sp$nl 25895a3d36dfSmrg eval cmd=\"$cmd\" 2590b43acbb4Smrg IFS=$save_ifs 25915a3d36dfSmrg func_show_eval "$cmd" "${2-:}" 25925a3d36dfSmrg done 25935a3d36dfSmrg IFS=$save_ifs 25945a3d36dfSmrg} 25955a3d36dfSmrg 25965a3d36dfSmrg 25975a3d36dfSmrg# func_source file 25985a3d36dfSmrg# Source FILE, adding directory component if necessary. 25995a3d36dfSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 26005a3d36dfSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 26015a3d36dfSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602b43acbb4Smrg# 'FILE.' does not work on cygwin managed mounts. 26035a3d36dfSmrgfunc_source () 26045a3d36dfSmrg{ 2605b43acbb4Smrg $debug_cmd 2606b43acbb4Smrg 26075a3d36dfSmrg case $1 in 26085a3d36dfSmrg */* | *\\*) . "$1" ;; 26095a3d36dfSmrg *) . "./$1" ;; 26105a3d36dfSmrg esac 26115a3d36dfSmrg} 26125a3d36dfSmrg 26135a3d36dfSmrg 261441c30155Smrg# func_resolve_sysroot PATH 261541c30155Smrg# Replace a leading = in PATH with a sysroot. Store the result into 261641c30155Smrg# func_resolve_sysroot_result 261741c30155Smrgfunc_resolve_sysroot () 261841c30155Smrg{ 261941c30155Smrg func_resolve_sysroot_result=$1 262041c30155Smrg case $func_resolve_sysroot_result in 262141c30155Smrg =*) 262241c30155Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 262341c30155Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 262441c30155Smrg ;; 262541c30155Smrg esac 262641c30155Smrg} 262741c30155Smrg 262841c30155Smrg# func_replace_sysroot PATH 262941c30155Smrg# If PATH begins with the sysroot, replace it with = and 263041c30155Smrg# store the result into func_replace_sysroot_result. 263141c30155Smrgfunc_replace_sysroot () 263241c30155Smrg{ 2633b43acbb4Smrg case $lt_sysroot:$1 in 263441c30155Smrg ?*:"$lt_sysroot"*) 263541c30155Smrg func_stripname "$lt_sysroot" '' "$1" 2636b43acbb4Smrg func_replace_sysroot_result='='$func_stripname_result 263741c30155Smrg ;; 263841c30155Smrg *) 263941c30155Smrg # Including no sysroot. 264041c30155Smrg func_replace_sysroot_result=$1 264141c30155Smrg ;; 264241c30155Smrg esac 264341c30155Smrg} 264441c30155Smrg 26455a3d36dfSmrg# func_infer_tag arg 26465a3d36dfSmrg# Infer tagged configuration to use if any are available and 26475a3d36dfSmrg# if one wasn't chosen via the "--tag" command line option. 26485a3d36dfSmrg# Only attempt this if the compiler in the base compile 26495a3d36dfSmrg# command doesn't match the default compiler. 26505a3d36dfSmrg# arg is usually of the form 'gcc ...' 26515a3d36dfSmrgfunc_infer_tag () 26525a3d36dfSmrg{ 2653b43acbb4Smrg $debug_cmd 2654b43acbb4Smrg 26555a3d36dfSmrg if test -n "$available_tags" && test -z "$tagname"; then 26565a3d36dfSmrg CC_quoted= 26575a3d36dfSmrg for arg in $CC; do 265841c30155Smrg func_append_quoted CC_quoted "$arg" 26595a3d36dfSmrg done 266041c30155Smrg CC_expanded=`func_echo_all $CC` 266141c30155Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26625a3d36dfSmrg case $@ in 26635a3d36dfSmrg # Blanks in the command may have been stripped by the calling shell, 26645a3d36dfSmrg # but not from the CC environment variable when configure was run. 266541c30155Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266641c30155Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 26675a3d36dfSmrg # Blanks at the start of $base_compile will cause this to fail 26685a3d36dfSmrg # if we don't check for them as well. 26695a3d36dfSmrg *) 26705a3d36dfSmrg for z in $available_tags; do 26715a3d36dfSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 26725a3d36dfSmrg # Evaluate the configuration. 2673b43acbb4Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 26745a3d36dfSmrg CC_quoted= 26755a3d36dfSmrg for arg in $CC; do 26765a3d36dfSmrg # Double-quote args containing other shell metacharacters. 267741c30155Smrg func_append_quoted CC_quoted "$arg" 26785a3d36dfSmrg done 267941c30155Smrg CC_expanded=`func_echo_all $CC` 268041c30155Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26815a3d36dfSmrg case "$@ " in 268241c30155Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268341c30155Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 26845a3d36dfSmrg # The compiler in the base compile command matches 26855a3d36dfSmrg # the one in the tagged configuration. 26865a3d36dfSmrg # Assume this is the tagged configuration we want. 26875a3d36dfSmrg tagname=$z 26885a3d36dfSmrg break 26895a3d36dfSmrg ;; 26905a3d36dfSmrg esac 26915a3d36dfSmrg fi 26925a3d36dfSmrg done 26935a3d36dfSmrg # If $tagname still isn't set, then no tagged configuration 26945a3d36dfSmrg # was found and let the user know that the "--tag" command 26955a3d36dfSmrg # line option must be used. 26965a3d36dfSmrg if test -z "$tagname"; then 26975a3d36dfSmrg func_echo "unable to infer tagged configuration" 2698b43acbb4Smrg func_fatal_error "specify a tag with '--tag'" 26995a3d36dfSmrg# else 27005a3d36dfSmrg# func_verbose "using $tagname tagged configuration" 27015a3d36dfSmrg fi 27025a3d36dfSmrg ;; 27035a3d36dfSmrg esac 27045a3d36dfSmrg fi 27055a3d36dfSmrg} 27065a3d36dfSmrg 27075a3d36dfSmrg 27085a3d36dfSmrg 27095a3d36dfSmrg# func_write_libtool_object output_name pic_name nonpic_name 27105a3d36dfSmrg# Create a libtool object file (analogous to a ".la" file), 27115a3d36dfSmrg# but don't create it if we're doing a dry run. 27125a3d36dfSmrgfunc_write_libtool_object () 27135a3d36dfSmrg{ 2714b43acbb4Smrg write_libobj=$1 2715b43acbb4Smrg if test yes = "$build_libtool_libs"; then 2716b43acbb4Smrg write_lobj=\'$2\' 27175a3d36dfSmrg else 27185a3d36dfSmrg write_lobj=none 27195a3d36dfSmrg fi 27205a3d36dfSmrg 2721b43acbb4Smrg if test yes = "$build_old_libs"; then 2722b43acbb4Smrg write_oldobj=\'$3\' 27235a3d36dfSmrg else 27245a3d36dfSmrg write_oldobj=none 27255a3d36dfSmrg fi 27265a3d36dfSmrg 27275a3d36dfSmrg $opt_dry_run || { 27285a3d36dfSmrg cat >${write_libobj}T <<EOF 27295a3d36dfSmrg# $write_libobj - a libtool object file 2730b43acbb4Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 27315a3d36dfSmrg# 27325a3d36dfSmrg# Please DO NOT delete this file! 27335a3d36dfSmrg# It is necessary for linking the library. 27345a3d36dfSmrg 27355a3d36dfSmrg# Name of the PIC object. 27365a3d36dfSmrgpic_object=$write_lobj 27375a3d36dfSmrg 27385a3d36dfSmrg# Name of the non-PIC object 27395a3d36dfSmrgnon_pic_object=$write_oldobj 27405a3d36dfSmrg 27415a3d36dfSmrgEOF 2742b43acbb4Smrg $MV "${write_libobj}T" "$write_libobj" 27435a3d36dfSmrg } 27445a3d36dfSmrg} 27455a3d36dfSmrg 274641c30155Smrg 274741c30155Smrg################################################## 274841c30155Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 274941c30155Smrg################################################## 275041c30155Smrg 275141c30155Smrg# func_convert_core_file_wine_to_w32 ARG 275241c30155Smrg# Helper function used by file name conversion functions when $build is *nix, 275341c30155Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 275441c30155Smrg# correctly configured wine environment available, with the winepath program 275541c30155Smrg# in $build's $PATH. 275641c30155Smrg# 275741c30155Smrg# ARG is the $build file name to be converted to w32 format. 275841c30155Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 275941c30155Smrg# be empty on error (or when ARG is empty) 276041c30155Smrgfunc_convert_core_file_wine_to_w32 () 276141c30155Smrg{ 2762b43acbb4Smrg $debug_cmd 2763b43acbb4Smrg 2764b43acbb4Smrg func_convert_core_file_wine_to_w32_result=$1 276541c30155Smrg if test -n "$1"; then 276641c30155Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 276741c30155Smrg # are forced to check the contents of stdout. On the other hand, if the 276841c30155Smrg # command is not found, the shell will set an exit code of 127 and print 276941c30155Smrg # *an error message* to stdout. So we must check for both error code of 277041c30155Smrg # zero AND non-empty stdout, which explains the odd construction: 277141c30155Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772b43acbb4Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 277341c30155Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774b43acbb4Smrg $SED -e "$sed_naive_backslashify"` 277541c30155Smrg else 277641c30155Smrg func_convert_core_file_wine_to_w32_result= 277741c30155Smrg fi 277841c30155Smrg fi 277941c30155Smrg} 278041c30155Smrg# end: func_convert_core_file_wine_to_w32 278141c30155Smrg 278241c30155Smrg 278341c30155Smrg# func_convert_core_path_wine_to_w32 ARG 278441c30155Smrg# Helper function used by path conversion functions when $build is *nix, and 278541c30155Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 278641c30155Smrg# configured wine environment available, with the winepath program in $build's 278741c30155Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 278841c30155Smrg# 278941c30155Smrg# ARG is path to be converted from $build format to win32. 279041c30155Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 279141c30155Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 279241c30155Smrg# are convertible, then the result may be empty. 279341c30155Smrgfunc_convert_core_path_wine_to_w32 () 279441c30155Smrg{ 2795b43acbb4Smrg $debug_cmd 2796b43acbb4Smrg 279741c30155Smrg # unfortunately, winepath doesn't convert paths, only file names 2798b43acbb4Smrg func_convert_core_path_wine_to_w32_result= 279941c30155Smrg if test -n "$1"; then 280041c30155Smrg oldIFS=$IFS 280141c30155Smrg IFS=: 280241c30155Smrg for func_convert_core_path_wine_to_w32_f in $1; do 280341c30155Smrg IFS=$oldIFS 280441c30155Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805b43acbb4Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 280641c30155Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807b43acbb4Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 280841c30155Smrg else 280941c30155Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 281041c30155Smrg fi 281141c30155Smrg fi 281241c30155Smrg done 281341c30155Smrg IFS=$oldIFS 281441c30155Smrg fi 281541c30155Smrg} 281641c30155Smrg# end: func_convert_core_path_wine_to_w32 281741c30155Smrg 281841c30155Smrg 281941c30155Smrg# func_cygpath ARGS... 282041c30155Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 282141c30155Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 282241c30155Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 282341c30155Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 282441c30155Smrg# file name or path is assumed to be in w32 format, as previously converted 282541c30155Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 282641c30155Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 282741c30155Smrg# Cygwin format). Returns an empty string on error. 282841c30155Smrg# 282941c30155Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 283041c30155Smrg# be converted. 283141c30155Smrg# 283241c30155Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 283341c30155Smrg# environment variable; do not put it in $PATH. 283441c30155Smrgfunc_cygpath () 283541c30155Smrg{ 2836b43acbb4Smrg $debug_cmd 2837b43acbb4Smrg 283841c30155Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 283941c30155Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 284041c30155Smrg if test "$?" -ne 0; then 284141c30155Smrg # on failure, ensure result is empty 284241c30155Smrg func_cygpath_result= 284341c30155Smrg fi 284441c30155Smrg else 284541c30155Smrg func_cygpath_result= 2846b43acbb4Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 284741c30155Smrg fi 284841c30155Smrg} 284941c30155Smrg#end: func_cygpath 285041c30155Smrg 285141c30155Smrg 285241c30155Smrg# func_convert_core_msys_to_w32 ARG 285341c30155Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 285441c30155Smrg# result in func_convert_core_msys_to_w32_result. 285541c30155Smrgfunc_convert_core_msys_to_w32 () 285641c30155Smrg{ 2857b43acbb4Smrg $debug_cmd 2858b43acbb4Smrg 285941c30155Smrg # awkward: cmd appends spaces to result 286041c30155Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861b43acbb4Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 286241c30155Smrg} 286341c30155Smrg#end: func_convert_core_msys_to_w32 286441c30155Smrg 286541c30155Smrg 286641c30155Smrg# func_convert_file_check ARG1 ARG2 286741c30155Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 286841c30155Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 286941c30155Smrg# func_to_host_file_result to ARG1). 287041c30155Smrgfunc_convert_file_check () 287141c30155Smrg{ 2872b43acbb4Smrg $debug_cmd 2873b43acbb4Smrg 2874b43acbb4Smrg if test -z "$2" && test -n "$1"; then 287541c30155Smrg func_error "Could not determine host file name corresponding to" 2876b43acbb4Smrg func_error " '$1'" 287741c30155Smrg func_error "Continuing, but uninstalled executables may not work." 287841c30155Smrg # Fallback: 2879b43acbb4Smrg func_to_host_file_result=$1 288041c30155Smrg fi 288141c30155Smrg} 288241c30155Smrg# end func_convert_file_check 288341c30155Smrg 288441c30155Smrg 288541c30155Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 288641c30155Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 288741c30155Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 288841c30155Smrg# func_to_host_file_result to a simplistic fallback value (see below). 288941c30155Smrgfunc_convert_path_check () 289041c30155Smrg{ 2891b43acbb4Smrg $debug_cmd 2892b43acbb4Smrg 289341c30155Smrg if test -z "$4" && test -n "$3"; then 289441c30155Smrg func_error "Could not determine the host path corresponding to" 2895b43acbb4Smrg func_error " '$3'" 289641c30155Smrg func_error "Continuing, but uninstalled executables may not work." 289741c30155Smrg # Fallback. This is a deliberately simplistic "conversion" and 289841c30155Smrg # should not be "improved". See libtool.info. 289941c30155Smrg if test "x$1" != "x$2"; then 290041c30155Smrg lt_replace_pathsep_chars="s|$1|$2|g" 290141c30155Smrg func_to_host_path_result=`echo "$3" | 290241c30155Smrg $SED -e "$lt_replace_pathsep_chars"` 290341c30155Smrg else 2904b43acbb4Smrg func_to_host_path_result=$3 290541c30155Smrg fi 290641c30155Smrg fi 290741c30155Smrg} 290841c30155Smrg# end func_convert_path_check 290941c30155Smrg 291041c30155Smrg 291141c30155Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 291241c30155Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 291341c30155Smrg# and appending REPL if ORIG matches BACKPAT. 291441c30155Smrgfunc_convert_path_front_back_pathsep () 291541c30155Smrg{ 2916b43acbb4Smrg $debug_cmd 2917b43acbb4Smrg 291841c30155Smrg case $4 in 2919b43acbb4Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 292041c30155Smrg ;; 292141c30155Smrg esac 292241c30155Smrg case $4 in 292341c30155Smrg $2 ) func_append func_to_host_path_result "$3" 292441c30155Smrg ;; 292541c30155Smrg esac 292641c30155Smrg} 292741c30155Smrg# end func_convert_path_front_back_pathsep 292841c30155Smrg 292941c30155Smrg 293041c30155Smrg################################################## 293141c30155Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 293241c30155Smrg################################################## 2933b43acbb4Smrg# invoked via '$to_host_file_cmd ARG' 293441c30155Smrg# 293541c30155Smrg# In each case, ARG is the path to be converted from $build to $host format. 293641c30155Smrg# Result will be available in $func_to_host_file_result. 293741c30155Smrg 293841c30155Smrg 293941c30155Smrg# func_to_host_file ARG 294041c30155Smrg# Converts the file name ARG from $build format to $host format. Return result 294141c30155Smrg# in func_to_host_file_result. 294241c30155Smrgfunc_to_host_file () 294341c30155Smrg{ 2944b43acbb4Smrg $debug_cmd 2945b43acbb4Smrg 294641c30155Smrg $to_host_file_cmd "$1" 294741c30155Smrg} 294841c30155Smrg# end func_to_host_file 294941c30155Smrg 295041c30155Smrg 295141c30155Smrg# func_to_tool_file ARG LAZY 295241c30155Smrg# converts the file name ARG from $build format to toolchain format. Return 295341c30155Smrg# result in func_to_tool_file_result. If the conversion in use is listed 295441c30155Smrg# in (the comma separated) LAZY, no conversion takes place. 295541c30155Smrgfunc_to_tool_file () 295641c30155Smrg{ 2957b43acbb4Smrg $debug_cmd 2958b43acbb4Smrg 295941c30155Smrg case ,$2, in 296041c30155Smrg *,"$to_tool_file_cmd",*) 296141c30155Smrg func_to_tool_file_result=$1 296241c30155Smrg ;; 296341c30155Smrg *) 296441c30155Smrg $to_tool_file_cmd "$1" 296541c30155Smrg func_to_tool_file_result=$func_to_host_file_result 296641c30155Smrg ;; 296741c30155Smrg esac 296841c30155Smrg} 296941c30155Smrg# end func_to_tool_file 297041c30155Smrg 297141c30155Smrg 297241c30155Smrg# func_convert_file_noop ARG 297341c30155Smrg# Copy ARG to func_to_host_file_result. 297441c30155Smrgfunc_convert_file_noop () 297541c30155Smrg{ 2976b43acbb4Smrg func_to_host_file_result=$1 297741c30155Smrg} 297841c30155Smrg# end func_convert_file_noop 297941c30155Smrg 298041c30155Smrg 298141c30155Smrg# func_convert_file_msys_to_w32 ARG 298241c30155Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 298341c30155Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 298441c30155Smrg# func_to_host_file_result. 298541c30155Smrgfunc_convert_file_msys_to_w32 () 298641c30155Smrg{ 2987b43acbb4Smrg $debug_cmd 2988b43acbb4Smrg 2989b43acbb4Smrg func_to_host_file_result=$1 299041c30155Smrg if test -n "$1"; then 299141c30155Smrg func_convert_core_msys_to_w32 "$1" 2992b43acbb4Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 299341c30155Smrg fi 299441c30155Smrg func_convert_file_check "$1" "$func_to_host_file_result" 299541c30155Smrg} 299641c30155Smrg# end func_convert_file_msys_to_w32 299741c30155Smrg 299841c30155Smrg 299941c30155Smrg# func_convert_file_cygwin_to_w32 ARG 300041c30155Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 300141c30155Smrg# func_to_host_file_result. 300241c30155Smrgfunc_convert_file_cygwin_to_w32 () 300341c30155Smrg{ 3004b43acbb4Smrg $debug_cmd 3005b43acbb4Smrg 3006b43acbb4Smrg func_to_host_file_result=$1 300741c30155Smrg if test -n "$1"; then 300841c30155Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 300941c30155Smrg # LT_CYGPATH in this case. 301041c30155Smrg func_to_host_file_result=`cygpath -m "$1"` 301141c30155Smrg fi 301241c30155Smrg func_convert_file_check "$1" "$func_to_host_file_result" 301341c30155Smrg} 301441c30155Smrg# end func_convert_file_cygwin_to_w32 301541c30155Smrg 301641c30155Smrg 301741c30155Smrg# func_convert_file_nix_to_w32 ARG 301841c30155Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 301941c30155Smrg# and a working winepath. Returns result in func_to_host_file_result. 302041c30155Smrgfunc_convert_file_nix_to_w32 () 302141c30155Smrg{ 3022b43acbb4Smrg $debug_cmd 3023b43acbb4Smrg 3024b43acbb4Smrg func_to_host_file_result=$1 302541c30155Smrg if test -n "$1"; then 302641c30155Smrg func_convert_core_file_wine_to_w32 "$1" 3027b43acbb4Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 302841c30155Smrg fi 302941c30155Smrg func_convert_file_check "$1" "$func_to_host_file_result" 303041c30155Smrg} 303141c30155Smrg# end func_convert_file_nix_to_w32 303241c30155Smrg 303341c30155Smrg 303441c30155Smrg# func_convert_file_msys_to_cygwin ARG 303541c30155Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 303641c30155Smrg# Returns result in func_to_host_file_result. 303741c30155Smrgfunc_convert_file_msys_to_cygwin () 303841c30155Smrg{ 3039b43acbb4Smrg $debug_cmd 3040b43acbb4Smrg 3041b43acbb4Smrg func_to_host_file_result=$1 304241c30155Smrg if test -n "$1"; then 304341c30155Smrg func_convert_core_msys_to_w32 "$1" 304441c30155Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045b43acbb4Smrg func_to_host_file_result=$func_cygpath_result 304641c30155Smrg fi 304741c30155Smrg func_convert_file_check "$1" "$func_to_host_file_result" 304841c30155Smrg} 304941c30155Smrg# end func_convert_file_msys_to_cygwin 305041c30155Smrg 305141c30155Smrg 305241c30155Smrg# func_convert_file_nix_to_cygwin ARG 305341c30155Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 305441c30155Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 305541c30155Smrg# in func_to_host_file_result. 305641c30155Smrgfunc_convert_file_nix_to_cygwin () 305741c30155Smrg{ 3058b43acbb4Smrg $debug_cmd 3059b43acbb4Smrg 3060b43acbb4Smrg func_to_host_file_result=$1 306141c30155Smrg if test -n "$1"; then 306241c30155Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 306341c30155Smrg func_convert_core_file_wine_to_w32 "$1" 306441c30155Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065b43acbb4Smrg func_to_host_file_result=$func_cygpath_result 306641c30155Smrg fi 306741c30155Smrg func_convert_file_check "$1" "$func_to_host_file_result" 306841c30155Smrg} 306941c30155Smrg# end func_convert_file_nix_to_cygwin 307041c30155Smrg 307141c30155Smrg 307241c30155Smrg############################################# 307341c30155Smrg# $build to $host PATH CONVERSION FUNCTIONS # 307441c30155Smrg############################################# 3075b43acbb4Smrg# invoked via '$to_host_path_cmd ARG' 307641c30155Smrg# 307741c30155Smrg# In each case, ARG is the path to be converted from $build to $host format. 307841c30155Smrg# The result will be available in $func_to_host_path_result. 307941c30155Smrg# 308041c30155Smrg# Path separators are also converted from $build format to $host format. If 308141c30155Smrg# ARG begins or ends with a path separator character, it is preserved (but 308241c30155Smrg# converted to $host format) on output. 308341c30155Smrg# 308441c30155Smrg# All path conversion functions are named using the following convention: 308541c30155Smrg# file name conversion function : func_convert_file_X_to_Y () 308641c30155Smrg# path conversion function : func_convert_path_X_to_Y () 308741c30155Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 308841c30155Smrg# same. If conversion functions are added for new $build/$host combinations, 308941c30155Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 309041c30155Smrg# will break. 309141c30155Smrg 309241c30155Smrg 309341c30155Smrg# func_init_to_host_path_cmd 309441c30155Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 309541c30155Smrg# appropriate value, based on the value of $to_host_file_cmd. 309641c30155Smrgto_host_path_cmd= 309741c30155Smrgfunc_init_to_host_path_cmd () 309841c30155Smrg{ 3099b43acbb4Smrg $debug_cmd 3100b43acbb4Smrg 310141c30155Smrg if test -z "$to_host_path_cmd"; then 310241c30155Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103b43acbb4Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 310441c30155Smrg fi 310541c30155Smrg} 310641c30155Smrg 310741c30155Smrg 310841c30155Smrg# func_to_host_path ARG 310941c30155Smrg# Converts the path ARG from $build format to $host format. Return result 311041c30155Smrg# in func_to_host_path_result. 311141c30155Smrgfunc_to_host_path () 311241c30155Smrg{ 3113b43acbb4Smrg $debug_cmd 3114b43acbb4Smrg 311541c30155Smrg func_init_to_host_path_cmd 311641c30155Smrg $to_host_path_cmd "$1" 311741c30155Smrg} 311841c30155Smrg# end func_to_host_path 311941c30155Smrg 312041c30155Smrg 312141c30155Smrg# func_convert_path_noop ARG 312241c30155Smrg# Copy ARG to func_to_host_path_result. 312341c30155Smrgfunc_convert_path_noop () 312441c30155Smrg{ 3125b43acbb4Smrg func_to_host_path_result=$1 312641c30155Smrg} 312741c30155Smrg# end func_convert_path_noop 312841c30155Smrg 312941c30155Smrg 313041c30155Smrg# func_convert_path_msys_to_w32 ARG 313141c30155Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 313241c30155Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 313341c30155Smrg# func_to_host_path_result. 313441c30155Smrgfunc_convert_path_msys_to_w32 () 313541c30155Smrg{ 3136b43acbb4Smrg $debug_cmd 3137b43acbb4Smrg 3138b43acbb4Smrg func_to_host_path_result=$1 313941c30155Smrg if test -n "$1"; then 314041c30155Smrg # Remove leading and trailing path separator characters from ARG. MSYS 314141c30155Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 314241c30155Smrg # and winepath ignores them completely. 314341c30155Smrg func_stripname : : "$1" 314441c30155Smrg func_to_host_path_tmp1=$func_stripname_result 314541c30155Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146b43acbb4Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 314741c30155Smrg func_convert_path_check : ";" \ 314841c30155Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 314941c30155Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 315041c30155Smrg fi 315141c30155Smrg} 315241c30155Smrg# end func_convert_path_msys_to_w32 315341c30155Smrg 315441c30155Smrg 315541c30155Smrg# func_convert_path_cygwin_to_w32 ARG 315641c30155Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 315741c30155Smrg# func_to_host_file_result. 315841c30155Smrgfunc_convert_path_cygwin_to_w32 () 315941c30155Smrg{ 3160b43acbb4Smrg $debug_cmd 3161b43acbb4Smrg 3162b43acbb4Smrg func_to_host_path_result=$1 316341c30155Smrg if test -n "$1"; then 316441c30155Smrg # See func_convert_path_msys_to_w32: 316541c30155Smrg func_stripname : : "$1" 316641c30155Smrg func_to_host_path_tmp1=$func_stripname_result 316741c30155Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 316841c30155Smrg func_convert_path_check : ";" \ 316941c30155Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 317041c30155Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 317141c30155Smrg fi 317241c30155Smrg} 317341c30155Smrg# end func_convert_path_cygwin_to_w32 317441c30155Smrg 317541c30155Smrg 317641c30155Smrg# func_convert_path_nix_to_w32 ARG 317741c30155Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 317841c30155Smrg# a working winepath. Returns result in func_to_host_file_result. 317941c30155Smrgfunc_convert_path_nix_to_w32 () 318041c30155Smrg{ 3181b43acbb4Smrg $debug_cmd 3182b43acbb4Smrg 3183b43acbb4Smrg func_to_host_path_result=$1 318441c30155Smrg if test -n "$1"; then 318541c30155Smrg # See func_convert_path_msys_to_w32: 318641c30155Smrg func_stripname : : "$1" 318741c30155Smrg func_to_host_path_tmp1=$func_stripname_result 318841c30155Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189b43acbb4Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 319041c30155Smrg func_convert_path_check : ";" \ 319141c30155Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 319241c30155Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 319341c30155Smrg fi 319441c30155Smrg} 319541c30155Smrg# end func_convert_path_nix_to_w32 319641c30155Smrg 319741c30155Smrg 319841c30155Smrg# func_convert_path_msys_to_cygwin ARG 319941c30155Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 320041c30155Smrg# Returns result in func_to_host_file_result. 320141c30155Smrgfunc_convert_path_msys_to_cygwin () 320241c30155Smrg{ 3203b43acbb4Smrg $debug_cmd 3204b43acbb4Smrg 3205b43acbb4Smrg func_to_host_path_result=$1 320641c30155Smrg if test -n "$1"; then 320741c30155Smrg # See func_convert_path_msys_to_w32: 320841c30155Smrg func_stripname : : "$1" 320941c30155Smrg func_to_host_path_tmp1=$func_stripname_result 321041c30155Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 321141c30155Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212b43acbb4Smrg func_to_host_path_result=$func_cygpath_result 321341c30155Smrg func_convert_path_check : : \ 321441c30155Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 321541c30155Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 321641c30155Smrg fi 321741c30155Smrg} 321841c30155Smrg# end func_convert_path_msys_to_cygwin 321941c30155Smrg 322041c30155Smrg 322141c30155Smrg# func_convert_path_nix_to_cygwin ARG 322241c30155Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 322341c30155Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 322441c30155Smrg# func_to_host_file_result. 322541c30155Smrgfunc_convert_path_nix_to_cygwin () 322641c30155Smrg{ 3227b43acbb4Smrg $debug_cmd 3228b43acbb4Smrg 3229b43acbb4Smrg func_to_host_path_result=$1 323041c30155Smrg if test -n "$1"; then 323141c30155Smrg # Remove leading and trailing path separator characters from 323241c30155Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 323341c30155Smrg # into '.;' and ';.', and winepath ignores them completely. 323441c30155Smrg func_stripname : : "$1" 323541c30155Smrg func_to_host_path_tmp1=$func_stripname_result 323641c30155Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323741c30155Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238b43acbb4Smrg func_to_host_path_result=$func_cygpath_result 323941c30155Smrg func_convert_path_check : : \ 324041c30155Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 324141c30155Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 324241c30155Smrg fi 324341c30155Smrg} 324441c30155Smrg# end func_convert_path_nix_to_cygwin 324541c30155Smrg 324641c30155Smrg 3247b43acbb4Smrg# func_dll_def_p FILE 3248b43acbb4Smrg# True iff FILE is a Windows DLL '.def' file. 3249b43acbb4Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250b43acbb4Smrgfunc_dll_def_p () 3251b43acbb4Smrg{ 3252b43acbb4Smrg $debug_cmd 3253b43acbb4Smrg 3254b43acbb4Smrg func_dll_def_p_tmp=`$SED -n \ 3255b43acbb4Smrg -e 's/^[ ]*//' \ 3256b43acbb4Smrg -e '/^\(;.*\)*$/d' \ 3257b43acbb4Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258b43acbb4Smrg -e q \ 3259b43acbb4Smrg "$1"` 3260b43acbb4Smrg test DEF = "$func_dll_def_p_tmp" 3261b43acbb4Smrg} 3262b43acbb4Smrg 3263b43acbb4Smrg 32645a3d36dfSmrg# func_mode_compile arg... 32655a3d36dfSmrgfunc_mode_compile () 32665a3d36dfSmrg{ 3267b43acbb4Smrg $debug_cmd 3268b43acbb4Smrg 32695a3d36dfSmrg # Get the compilation command and the source file. 32705a3d36dfSmrg base_compile= 3271b43acbb4Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 32725a3d36dfSmrg suppress_opt=yes 32735a3d36dfSmrg suppress_output= 32745a3d36dfSmrg arg_mode=normal 32755a3d36dfSmrg libobj= 32765a3d36dfSmrg later= 32775a3d36dfSmrg pie_flag= 32785a3d36dfSmrg 32795a3d36dfSmrg for arg 32805a3d36dfSmrg do 32815a3d36dfSmrg case $arg_mode in 32825a3d36dfSmrg arg ) 32835a3d36dfSmrg # do not "continue". Instead, add this to base_compile 3284b43acbb4Smrg lastarg=$arg 32855a3d36dfSmrg arg_mode=normal 32865a3d36dfSmrg ;; 32875a3d36dfSmrg 32885a3d36dfSmrg target ) 3289b43acbb4Smrg libobj=$arg 32905a3d36dfSmrg arg_mode=normal 32915a3d36dfSmrg continue 32925a3d36dfSmrg ;; 32935a3d36dfSmrg 32945a3d36dfSmrg normal ) 32955a3d36dfSmrg # Accept any command-line options. 32965a3d36dfSmrg case $arg in 32975a3d36dfSmrg -o) 32985a3d36dfSmrg test -n "$libobj" && \ 3299b43acbb4Smrg func_fatal_error "you cannot specify '-o' more than once" 33005a3d36dfSmrg arg_mode=target 33015a3d36dfSmrg continue 33025a3d36dfSmrg ;; 33035a3d36dfSmrg 33045a3d36dfSmrg -pie | -fpie | -fPIE) 330541c30155Smrg func_append pie_flag " $arg" 33065a3d36dfSmrg continue 33075a3d36dfSmrg ;; 33085a3d36dfSmrg 33095a3d36dfSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 331041c30155Smrg func_append later " $arg" 33115a3d36dfSmrg continue 33125a3d36dfSmrg ;; 33135a3d36dfSmrg 33145a3d36dfSmrg -no-suppress) 331523a0898aSmrg suppress_opt=no 331623a0898aSmrg continue 331723a0898aSmrg ;; 331823a0898aSmrg 331923a0898aSmrg -Xcompiler) 332023a0898aSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 332123a0898aSmrg continue # The current "srcfile" will either be retained or 332223a0898aSmrg ;; # replaced later. I would guess that would be a bug. 332323a0898aSmrg 332423a0898aSmrg -Wc,*) 33255a3d36dfSmrg func_stripname '-Wc,' '' "$arg" 33265a3d36dfSmrg args=$func_stripname_result 332723a0898aSmrg lastarg= 3328b43acbb4Smrg save_ifs=$IFS; IFS=, 33295a3d36dfSmrg for arg in $args; do 3330b43acbb4Smrg IFS=$save_ifs 333141c30155Smrg func_append_quoted lastarg "$arg" 333223a0898aSmrg done 3333b43acbb4Smrg IFS=$save_ifs 33345a3d36dfSmrg func_stripname ' ' '' "$lastarg" 33355a3d36dfSmrg lastarg=$func_stripname_result 333623a0898aSmrg 333723a0898aSmrg # Add the arguments to base_compile. 333841c30155Smrg func_append base_compile " $lastarg" 333923a0898aSmrg continue 334023a0898aSmrg ;; 334123a0898aSmrg 33425a3d36dfSmrg *) 334323a0898aSmrg # Accept the current argument as the source file. 334423a0898aSmrg # The previous "srcfile" becomes the current argument. 334523a0898aSmrg # 3346b43acbb4Smrg lastarg=$srcfile 3347b43acbb4Smrg srcfile=$arg 334823a0898aSmrg ;; 334923a0898aSmrg esac # case $arg 335023a0898aSmrg ;; 335123a0898aSmrg esac # case $arg_mode 335223a0898aSmrg 335323a0898aSmrg # Aesthetically quote the previous argument. 335441c30155Smrg func_append_quoted base_compile "$lastarg" 335523a0898aSmrg done # for arg 335623a0898aSmrg 335723a0898aSmrg case $arg_mode in 335823a0898aSmrg arg) 33595a3d36dfSmrg func_fatal_error "you must specify an argument for -Xcompile" 336023a0898aSmrg ;; 336123a0898aSmrg target) 3362b43acbb4Smrg func_fatal_error "you must specify a target with '-o'" 336323a0898aSmrg ;; 336423a0898aSmrg *) 336523a0898aSmrg # Get the name of the library object. 33665a3d36dfSmrg test -z "$libobj" && { 33675a3d36dfSmrg func_basename "$srcfile" 3368b43acbb4Smrg libobj=$func_basename_result 33695a3d36dfSmrg } 337023a0898aSmrg ;; 337123a0898aSmrg esac 337223a0898aSmrg 337323a0898aSmrg # Recognize several different file suffixes. 337423a0898aSmrg # If the user specifies -o file.o, it is replaced with file.lo 337523a0898aSmrg case $libobj in 33765a3d36dfSmrg *.[cCFSifmso] | \ 33775a3d36dfSmrg *.ada | *.adb | *.ads | *.asm | \ 33785a3d36dfSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379b020570bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 33805a3d36dfSmrg func_xform "$libobj" 33815a3d36dfSmrg libobj=$func_xform_result 33825a3d36dfSmrg ;; 338323a0898aSmrg esac 338423a0898aSmrg 338523a0898aSmrg case $libobj in 33865a3d36dfSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 338723a0898aSmrg *) 3388b43acbb4Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 338923a0898aSmrg ;; 339023a0898aSmrg esac 339123a0898aSmrg 339223a0898aSmrg func_infer_tag $base_compile 339323a0898aSmrg 339423a0898aSmrg for arg in $later; do 339523a0898aSmrg case $arg in 33965a3d36dfSmrg -shared) 3397b43acbb4Smrg test yes = "$build_libtool_libs" \ 3398b43acbb4Smrg || func_fatal_configuration "cannot build a shared library" 33995a3d36dfSmrg build_old_libs=no 34005a3d36dfSmrg continue 34015a3d36dfSmrg ;; 34025a3d36dfSmrg 340323a0898aSmrg -static) 34045a3d36dfSmrg build_libtool_libs=no 340523a0898aSmrg build_old_libs=yes 340623a0898aSmrg continue 340723a0898aSmrg ;; 340823a0898aSmrg 340923a0898aSmrg -prefer-pic) 341023a0898aSmrg pic_mode=yes 341123a0898aSmrg continue 341223a0898aSmrg ;; 341323a0898aSmrg 341423a0898aSmrg -prefer-non-pic) 341523a0898aSmrg pic_mode=no 341623a0898aSmrg continue 341723a0898aSmrg ;; 341823a0898aSmrg esac 341923a0898aSmrg done 342023a0898aSmrg 34215a3d36dfSmrg func_quote_for_eval "$libobj" 34225a3d36dfSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 34235a3d36dfSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424b43acbb4Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 34255a3d36dfSmrg func_dirname_and_basename "$obj" "/" "" 3426b43acbb4Smrg objname=$func_basename_result 3427b43acbb4Smrg xdir=$func_dirname_result 3428b43acbb4Smrg lobj=$xdir$objdir/$objname 342923a0898aSmrg 34305a3d36dfSmrg test -z "$base_compile" && \ 34315a3d36dfSmrg func_fatal_help "you must specify a compilation command" 343223a0898aSmrg 343323a0898aSmrg # Delete any leftover library objects. 3434b43acbb4Smrg if test yes = "$build_old_libs"; then 343523a0898aSmrg removelist="$obj $lobj $libobj ${libobj}T" 343623a0898aSmrg else 343723a0898aSmrg removelist="$lobj $libobj ${libobj}T" 343823a0898aSmrg fi 343923a0898aSmrg 344023a0898aSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 344123a0898aSmrg case $host_os in 34425a3d36dfSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 344323a0898aSmrg pic_mode=default 344423a0898aSmrg ;; 344523a0898aSmrg esac 3446b43acbb4Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 344723a0898aSmrg # non-PIC code in shared libraries is not supported 344823a0898aSmrg pic_mode=default 344923a0898aSmrg fi 345023a0898aSmrg 345123a0898aSmrg # Calculate the filename of the output object if compiler does 345223a0898aSmrg # not support -o with -c 3453b43acbb4Smrg if test no = "$compiler_c_o"; then 3454b43acbb4Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455b43acbb4Smrg lockfile=$output_obj.lock 345623a0898aSmrg else 345723a0898aSmrg output_obj= 345823a0898aSmrg need_locks=no 345923a0898aSmrg lockfile= 346023a0898aSmrg fi 346123a0898aSmrg 346223a0898aSmrg # Lock this critical section if it is needed 346323a0898aSmrg # We use this script file to make the link, it avoids creating a new file 3464b43acbb4Smrg if test yes = "$need_locks"; then 34655a3d36dfSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 34665a3d36dfSmrg func_echo "Waiting for $lockfile to be removed" 346723a0898aSmrg sleep 2 346823a0898aSmrg done 3469b43acbb4Smrg elif test warn = "$need_locks"; then 347023a0898aSmrg if test -f "$lockfile"; then 34715a3d36dfSmrg $ECHO "\ 347223a0898aSmrg*** ERROR, $lockfile exists and contains: 347323a0898aSmrg`cat $lockfile 2>/dev/null` 347423a0898aSmrg 347523a0898aSmrgThis indicates that another process is trying to use the same 347623a0898aSmrgtemporary object file, and libtool could not work around it because 3477b43acbb4Smrgyour compiler does not support '-c' and '-o' together. If you 347823a0898aSmrgrepeat this compilation, it may succeed, by chance, but you had better 347923a0898aSmrgavoid parallel builds (make -j) in this platform, or get a better 348023a0898aSmrgcompiler." 348123a0898aSmrg 34825a3d36dfSmrg $opt_dry_run || $RM $removelist 348323a0898aSmrg exit $EXIT_FAILURE 348423a0898aSmrg fi 348541c30155Smrg func_append removelist " $output_obj" 34865a3d36dfSmrg $ECHO "$srcfile" > "$lockfile" 348723a0898aSmrg fi 348823a0898aSmrg 34895a3d36dfSmrg $opt_dry_run || $RM $removelist 349041c30155Smrg func_append removelist " $lockfile" 34915a3d36dfSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 34925a3d36dfSmrg 349341c30155Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 349441c30155Smrg srcfile=$func_to_tool_file_result 34955a3d36dfSmrg func_quote_for_eval "$srcfile" 34965a3d36dfSmrg qsrcfile=$func_quote_for_eval_result 349723a0898aSmrg 349823a0898aSmrg # Only build a PIC object if we are building libtool libraries. 3499b43acbb4Smrg if test yes = "$build_libtool_libs"; then 350023a0898aSmrg # Without this assignment, base_compile gets emptied. 350123a0898aSmrg fbsd_hideous_sh_bug=$base_compile 350223a0898aSmrg 3503b43acbb4Smrg if test no != "$pic_mode"; then 350423a0898aSmrg command="$base_compile $qsrcfile $pic_flag" 350523a0898aSmrg else 350623a0898aSmrg # Don't build PIC code 350723a0898aSmrg command="$base_compile $qsrcfile" 350823a0898aSmrg fi 350923a0898aSmrg 35105a3d36dfSmrg func_mkdir_p "$xdir$objdir" 351123a0898aSmrg 351223a0898aSmrg if test -z "$output_obj"; then 351323a0898aSmrg # Place PIC objects in $objdir 351441c30155Smrg func_append command " -o $lobj" 351523a0898aSmrg fi 351623a0898aSmrg 35175a3d36dfSmrg func_show_eval_locale "$command" \ 35185a3d36dfSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 351923a0898aSmrg 3520b43acbb4Smrg if test warn = "$need_locks" && 352123a0898aSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35225a3d36dfSmrg $ECHO "\ 352323a0898aSmrg*** ERROR, $lockfile contains: 352423a0898aSmrg`cat $lockfile 2>/dev/null` 352523a0898aSmrg 352623a0898aSmrgbut it should contain: 352723a0898aSmrg$srcfile 352823a0898aSmrg 352923a0898aSmrgThis indicates that another process is trying to use the same 353023a0898aSmrgtemporary object file, and libtool could not work around it because 3531b43acbb4Smrgyour compiler does not support '-c' and '-o' together. If you 353223a0898aSmrgrepeat this compilation, it may succeed, by chance, but you had better 353323a0898aSmrgavoid parallel builds (make -j) in this platform, or get a better 353423a0898aSmrgcompiler." 353523a0898aSmrg 35365a3d36dfSmrg $opt_dry_run || $RM $removelist 353723a0898aSmrg exit $EXIT_FAILURE 353823a0898aSmrg fi 353923a0898aSmrg 354023a0898aSmrg # Just move the object if needed, then go on to compile the next one 354123a0898aSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 35425a3d36dfSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 35435a3d36dfSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 354423a0898aSmrg fi 354523a0898aSmrg 354623a0898aSmrg # Allow error messages only from the first compilation. 3547b43acbb4Smrg if test yes = "$suppress_opt"; then 35485a3d36dfSmrg suppress_output=' >/dev/null 2>&1' 354923a0898aSmrg fi 355023a0898aSmrg fi 355123a0898aSmrg 355223a0898aSmrg # Only build a position-dependent object if we build old libraries. 3553b43acbb4Smrg if test yes = "$build_old_libs"; then 3554b43acbb4Smrg if test yes != "$pic_mode"; then 355523a0898aSmrg # Don't build PIC code 35565a3d36dfSmrg command="$base_compile $qsrcfile$pie_flag" 355723a0898aSmrg else 355823a0898aSmrg command="$base_compile $qsrcfile $pic_flag" 355923a0898aSmrg fi 3560b43acbb4Smrg if test yes = "$compiler_c_o"; then 356141c30155Smrg func_append command " -o $obj" 356223a0898aSmrg fi 356323a0898aSmrg 356423a0898aSmrg # Suppress compiler output if we already did a PIC compilation. 356541c30155Smrg func_append command "$suppress_output" 35665a3d36dfSmrg func_show_eval_locale "$command" \ 35675a3d36dfSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 356823a0898aSmrg 3569b43acbb4Smrg if test warn = "$need_locks" && 357023a0898aSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35715a3d36dfSmrg $ECHO "\ 357223a0898aSmrg*** ERROR, $lockfile contains: 357323a0898aSmrg`cat $lockfile 2>/dev/null` 357423a0898aSmrg 357523a0898aSmrgbut it should contain: 357623a0898aSmrg$srcfile 357723a0898aSmrg 357823a0898aSmrgThis indicates that another process is trying to use the same 357923a0898aSmrgtemporary object file, and libtool could not work around it because 3580b43acbb4Smrgyour compiler does not support '-c' and '-o' together. If you 358123a0898aSmrgrepeat this compilation, it may succeed, by chance, but you had better 358223a0898aSmrgavoid parallel builds (make -j) in this platform, or get a better 358323a0898aSmrgcompiler." 358423a0898aSmrg 35855a3d36dfSmrg $opt_dry_run || $RM $removelist 358623a0898aSmrg exit $EXIT_FAILURE 358723a0898aSmrg fi 358823a0898aSmrg 358923a0898aSmrg # Just move the object if needed 359023a0898aSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 35915a3d36dfSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 35925a3d36dfSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 359323a0898aSmrg fi 359423a0898aSmrg fi 359523a0898aSmrg 35965a3d36dfSmrg $opt_dry_run || { 35975a3d36dfSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 359823a0898aSmrg 35995a3d36dfSmrg # Unlock the critical section if it was locked 3600b43acbb4Smrg if test no != "$need_locks"; then 36015a3d36dfSmrg removelist=$lockfile 36025a3d36dfSmrg $RM "$lockfile" 36035a3d36dfSmrg fi 36045a3d36dfSmrg } 360523a0898aSmrg 360623a0898aSmrg exit $EXIT_SUCCESS 36075a3d36dfSmrg} 360823a0898aSmrg 36095a3d36dfSmrg$opt_help || { 3610b43acbb4Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 36115a3d36dfSmrg} 361223a0898aSmrg 36135a3d36dfSmrgfunc_mode_help () 36145a3d36dfSmrg{ 36155a3d36dfSmrg # We need to display help for each of the modes. 361641c30155Smrg case $opt_mode in 36175a3d36dfSmrg "") 36185a3d36dfSmrg # Generic help is extracted from the usage comments 36195a3d36dfSmrg # at the start of this file. 36205a3d36dfSmrg func_help 36215a3d36dfSmrg ;; 362223a0898aSmrg 36235a3d36dfSmrg clean) 36245a3d36dfSmrg $ECHO \ 36255a3d36dfSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 362623a0898aSmrg 36275a3d36dfSmrgRemove files from the build directory. 362823a0898aSmrg 36295a3d36dfSmrgRM is the name of the program to use to delete files associated with each FILE 3630b43acbb4Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 36315a3d36dfSmrgto RM. 363223a0898aSmrg 36335a3d36dfSmrgIf FILE is a libtool library, object or program, all the files associated 36345a3d36dfSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 36355a3d36dfSmrg ;; 363623a0898aSmrg 36375a3d36dfSmrg compile) 36385a3d36dfSmrg $ECHO \ 36395a3d36dfSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 364023a0898aSmrg 36415a3d36dfSmrgCompile a source file into a libtool library object. 364223a0898aSmrg 36435a3d36dfSmrgThis mode accepts the following additional options: 364423a0898aSmrg 36455a3d36dfSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 36465a3d36dfSmrg -no-suppress do not suppress compiler output for multiple passes 364741c30155Smrg -prefer-pic try to build PIC objects only 364841c30155Smrg -prefer-non-pic try to build non-PIC objects only 3649b43acbb4Smrg -shared do not build a '.o' file suitable for static linking 3650b43acbb4Smrg -static only build a '.o' file suitable for static linking 365141c30155Smrg -Wc,FLAG pass FLAG directly to the compiler 365223a0898aSmrg 3653b43acbb4SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 36545a3d36dfSmrgfrom the given SOURCEFILE. 365523a0898aSmrg 36565a3d36dfSmrgThe output file name is determined by removing the directory component from 3657b43acbb4SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658b43acbb4Smrglibrary object suffix, '.lo'." 36595a3d36dfSmrg ;; 366023a0898aSmrg 36615a3d36dfSmrg execute) 36625a3d36dfSmrg $ECHO \ 36635a3d36dfSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 366423a0898aSmrg 36655a3d36dfSmrgAutomatically set library path, then run a program. 366623a0898aSmrg 36675a3d36dfSmrgThis mode accepts the following additional options: 366823a0898aSmrg 36695a3d36dfSmrg -dlopen FILE add the directory containing FILE to the library path 367023a0898aSmrg 3671b43acbb4SmrgThis mode sets the library path environment variable according to '-dlopen' 36725a3d36dfSmrgflags. 367323a0898aSmrg 36745a3d36dfSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 36755a3d36dfSmrginto their corresponding uninstalled binary, and any of their required library 36765a3d36dfSmrgdirectories are added to the library path. 367723a0898aSmrg 36785a3d36dfSmrgThen, COMMAND is executed, with ARGS as arguments." 36795a3d36dfSmrg ;; 368023a0898aSmrg 36815a3d36dfSmrg finish) 36825a3d36dfSmrg $ECHO \ 36835a3d36dfSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 368423a0898aSmrg 36855a3d36dfSmrgComplete the installation of libtool libraries. 368623a0898aSmrg 36875a3d36dfSmrgEach LIBDIR is a directory that contains libtool libraries. 368823a0898aSmrg 36895a3d36dfSmrgThe commands that this mode executes may require superuser privileges. Use 3690b43acbb4Smrgthe '--dry-run' option if you just want to see what would be executed." 36915a3d36dfSmrg ;; 369223a0898aSmrg 36935a3d36dfSmrg install) 36945a3d36dfSmrg $ECHO \ 36955a3d36dfSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 369623a0898aSmrg 36975a3d36dfSmrgInstall executables or libraries. 369823a0898aSmrg 36995a3d36dfSmrgINSTALL-COMMAND is the installation command. The first component should be 3700b43acbb4Smrgeither the 'install' or 'cp' program. 370123a0898aSmrg 37025a3d36dfSmrgThe following components of INSTALL-COMMAND are treated specially: 370323a0898aSmrg 370441c30155Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 370523a0898aSmrg 37065a3d36dfSmrgThe rest of the components are interpreted as arguments to that command (only 37075a3d36dfSmrgBSD-compatible install options are recognized)." 37085a3d36dfSmrg ;; 370923a0898aSmrg 37105a3d36dfSmrg link) 37115a3d36dfSmrg $ECHO \ 37125a3d36dfSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 371323a0898aSmrg 37145a3d36dfSmrgLink object files or libraries together to form another library, or to 37155a3d36dfSmrgcreate an executable program. 371623a0898aSmrg 37175a3d36dfSmrgLINK-COMMAND is a command using the C compiler that you would use to create 37185a3d36dfSmrga program from several object files. 371923a0898aSmrg 37205a3d36dfSmrgThe following components of LINK-COMMAND are treated specially: 372123a0898aSmrg 37225a3d36dfSmrg -all-static do not do any dynamic linking at all 37235a3d36dfSmrg -avoid-version do not add a version suffix if possible 372441c30155Smrg -bindir BINDIR specify path to binaries directory (for systems where 372541c30155Smrg libraries must be found in the PATH setting at runtime) 3726b43acbb4Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 37275a3d36dfSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 37285a3d36dfSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 37295a3d36dfSmrg -export-symbols SYMFILE 37305a3d36dfSmrg try to export only the symbols listed in SYMFILE 37315a3d36dfSmrg -export-symbols-regex REGEX 37325a3d36dfSmrg try to export only the symbols matching REGEX 37335a3d36dfSmrg -LLIBDIR search LIBDIR for required installed libraries 37345a3d36dfSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 37355a3d36dfSmrg -module build a library that can dlopened 37365a3d36dfSmrg -no-fast-install disable the fast-install mode 37375a3d36dfSmrg -no-install link a not-installable executable 37385a3d36dfSmrg -no-undefined declare that a library does not refer to external symbols 37395a3d36dfSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740b43acbb4Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3741b43acbb4Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 37425a3d36dfSmrg -precious-files-regex REGEX 37435a3d36dfSmrg don't remove output files matching REGEX 37445a3d36dfSmrg -release RELEASE specify package release information 37455a3d36dfSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 37465a3d36dfSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 37475a3d36dfSmrg -shared only do dynamic linking of libtool libraries 37485a3d36dfSmrg -shrext SUFFIX override the standard shared library file extension 37495a3d36dfSmrg -static do not do any dynamic linking of uninstalled libtool libraries 37505a3d36dfSmrg -static-libtool-libs 37515a3d36dfSmrg do not do any dynamic linking of libtool libraries 37525a3d36dfSmrg -version-info CURRENT[:REVISION[:AGE]] 37535a3d36dfSmrg specify library version info [each variable defaults to 0] 37545a3d36dfSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 375541c30155Smrg -Wc,FLAG 375641c30155Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375741c30155Smrg -Wl,FLAG 375841c30155Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375941c30155Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 376023a0898aSmrg 3761b43acbb4SmrgAll other options (arguments beginning with '-') are ignored. 376223a0898aSmrg 3763b43acbb4SmrgEvery other argument is treated as a filename. Files ending in '.la' are 37645a3d36dfSmrgtreated as uninstalled libtool libraries, other files are standard or library 37655a3d36dfSmrgobject files. 376623a0898aSmrg 3767b43acbb4SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768b43acbb4Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 37695a3d36dfSmrgrequired, except when creating a convenience library. 377023a0898aSmrg 3771b43acbb4SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772b43acbb4Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 377323a0898aSmrg 3774b43acbb4SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 37755a3d36dfSmrgis created, otherwise an executable program is created." 3776b3062210Smrg ;; 377723a0898aSmrg 37785a3d36dfSmrg uninstall) 37795a3d36dfSmrg $ECHO \ 37805a3d36dfSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 378123a0898aSmrg 37825a3d36dfSmrgRemove libraries from an installation directory. 378323a0898aSmrg 37845a3d36dfSmrgRM is the name of the program to use to delete files associated with each FILE 3785b43acbb4Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 37865a3d36dfSmrgto RM. 378723a0898aSmrg 37885a3d36dfSmrgIf FILE is a libtool library, all the files associated with it are deleted. 37895a3d36dfSmrgOtherwise, only FILE itself is deleted using RM." 37905a3d36dfSmrg ;; 37917f7f5e4eSmrg 37925a3d36dfSmrg *) 3793b43acbb4Smrg func_fatal_help "invalid operation mode '$opt_mode'" 37945a3d36dfSmrg ;; 37955a3d36dfSmrg esac 37967f7f5e4eSmrg 379741c30155Smrg echo 3798b43acbb4Smrg $ECHO "Try '$progname --help' for more information about other modes." 37995a3d36dfSmrg} 38007f7f5e4eSmrg 380141c30155Smrg# Now that we've collected a possible --mode arg, show help if necessary 380241c30155Smrgif $opt_help; then 3803b43acbb4Smrg if test : = "$opt_help"; then 380441c30155Smrg func_mode_help 380541c30155Smrg else 380641c30155Smrg { 380741c30155Smrg func_help noexit 380841c30155Smrg for opt_mode in compile link execute install finish uninstall clean; do 380941c30155Smrg func_mode_help 381041c30155Smrg done 3811b43acbb4Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381241c30155Smrg { 381341c30155Smrg func_help noexit 381441c30155Smrg for opt_mode in compile link execute install finish uninstall clean; do 381541c30155Smrg echo 381641c30155Smrg func_mode_help 381741c30155Smrg done 381841c30155Smrg } | 3819b43acbb4Smrg $SED '1d 382041c30155Smrg /^When reporting/,/^Report/{ 382141c30155Smrg H 382241c30155Smrg d 382341c30155Smrg } 382441c30155Smrg $x 382541c30155Smrg /information about other modes/d 382641c30155Smrg /more detailed .*MODE/d 382741c30155Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382841c30155Smrg fi 382941c30155Smrg exit $? 383041c30155Smrgfi 38317f7f5e4eSmrg 38327f7f5e4eSmrg 38335a3d36dfSmrg# func_mode_execute arg... 38345a3d36dfSmrgfunc_mode_execute () 38355a3d36dfSmrg{ 3836b43acbb4Smrg $debug_cmd 3837b43acbb4Smrg 38385a3d36dfSmrg # The first argument is the command name. 3839b43acbb4Smrg cmd=$nonopt 38405a3d36dfSmrg test -z "$cmd" && \ 38415a3d36dfSmrg func_fatal_help "you must specify a COMMAND" 3842b3062210Smrg 38435a3d36dfSmrg # Handle -dlopen flags immediately. 384441c30155Smrg for file in $opt_dlopen; do 38455a3d36dfSmrg test -f "$file" \ 3846b43acbb4Smrg || func_fatal_help "'$file' is not a file" 3847b3062210Smrg 38485a3d36dfSmrg dir= 38495a3d36dfSmrg case $file in 38505a3d36dfSmrg *.la) 385141c30155Smrg func_resolve_sysroot "$file" 385241c30155Smrg file=$func_resolve_sysroot_result 385341c30155Smrg 38545a3d36dfSmrg # Check to see that this really is a libtool archive. 38555a3d36dfSmrg func_lalib_unsafe_p "$file" \ 3856b43acbb4Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857b3062210Smrg 38585a3d36dfSmrg # Read the libtool library. 38595a3d36dfSmrg dlname= 38605a3d36dfSmrg library_names= 38615a3d36dfSmrg func_source "$file" 386223a0898aSmrg 38635a3d36dfSmrg # Skip this library if it cannot be dlopened. 38645a3d36dfSmrg if test -z "$dlname"; then 38655a3d36dfSmrg # Warn if it was a shared library. 38665a3d36dfSmrg test -n "$library_names" && \ 3867b43acbb4Smrg func_warning "'$file' was not linked with '-export-dynamic'" 38685a3d36dfSmrg continue 38695a3d36dfSmrg fi 387023a0898aSmrg 38715a3d36dfSmrg func_dirname "$file" "" "." 3872b43acbb4Smrg dir=$func_dirname_result 387323a0898aSmrg 38745a3d36dfSmrg if test -f "$dir/$objdir/$dlname"; then 387541c30155Smrg func_append dir "/$objdir" 38765a3d36dfSmrg else 38775a3d36dfSmrg if test ! -f "$dir/$dlname"; then 3878b43acbb4Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 38795a3d36dfSmrg fi 38805a3d36dfSmrg fi 3881b3062210Smrg ;; 388223a0898aSmrg 38835a3d36dfSmrg *.lo) 38845a3d36dfSmrg # Just add the directory containing the .lo file. 38855a3d36dfSmrg func_dirname "$file" "" "." 3886b43acbb4Smrg dir=$func_dirname_result 3887b3062210Smrg ;; 388823a0898aSmrg 38895a3d36dfSmrg *) 3890b43acbb4Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891b3062210Smrg continue 3892b3062210Smrg ;; 38935a3d36dfSmrg esac 389423a0898aSmrg 38955a3d36dfSmrg # Get the absolute pathname. 38965a3d36dfSmrg absdir=`cd "$dir" && pwd` 3897b43acbb4Smrg test -n "$absdir" && dir=$absdir 38987f7f5e4eSmrg 38995a3d36dfSmrg # Now add the directory to shlibpath_var. 39005a3d36dfSmrg if eval "test -z \"\$$shlibpath_var\""; then 39015a3d36dfSmrg eval "$shlibpath_var=\"\$dir\"" 39025a3d36dfSmrg else 39035a3d36dfSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 39045a3d36dfSmrg fi 39055a3d36dfSmrg done 39067f7f5e4eSmrg 39075a3d36dfSmrg # This variable tells wrapper scripts just to set shlibpath_var 39085a3d36dfSmrg # rather than running their programs. 3909b43acbb4Smrg libtool_execute_magic=$magic 39107f7f5e4eSmrg 39115a3d36dfSmrg # Check if any of the arguments is a wrapper script. 39125a3d36dfSmrg args= 39135a3d36dfSmrg for file 39145a3d36dfSmrg do 39155a3d36dfSmrg case $file in 391641c30155Smrg -* | *.la | *.lo ) ;; 39175a3d36dfSmrg *) 39185a3d36dfSmrg # Do a test to see if this is really a libtool program. 39195a3d36dfSmrg if func_ltwrapper_script_p "$file"; then 39205a3d36dfSmrg func_source "$file" 39215a3d36dfSmrg # Transform arg to wrapped name. 3922b43acbb4Smrg file=$progdir/$program 39235a3d36dfSmrg elif func_ltwrapper_executable_p "$file"; then 39245a3d36dfSmrg func_ltwrapper_scriptname "$file" 39255a3d36dfSmrg func_source "$func_ltwrapper_scriptname_result" 39265a3d36dfSmrg # Transform arg to wrapped name. 3927b43acbb4Smrg file=$progdir/$program 39285a3d36dfSmrg fi 39295a3d36dfSmrg ;; 39305a3d36dfSmrg esac 39315a3d36dfSmrg # Quote arguments (to preserve shell metacharacters). 393241c30155Smrg func_append_quoted args "$file" 39335a3d36dfSmrg done 39347f7f5e4eSmrg 3935b43acbb4Smrg if $opt_dry_run; then 3936b43acbb4Smrg # Display what would be done. 3937b43acbb4Smrg if test -n "$shlibpath_var"; then 3938b43acbb4Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939b43acbb4Smrg echo "export $shlibpath_var" 3940b43acbb4Smrg fi 3941b43acbb4Smrg $ECHO "$cmd$args" 3942b43acbb4Smrg exit $EXIT_SUCCESS 3943b43acbb4Smrg else 39445a3d36dfSmrg if test -n "$shlibpath_var"; then 39455a3d36dfSmrg # Export the shlibpath_var. 39465a3d36dfSmrg eval "export $shlibpath_var" 39475a3d36dfSmrg fi 39487f7f5e4eSmrg 39495a3d36dfSmrg # Restore saved environment variables 39505a3d36dfSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 39515a3d36dfSmrg do 39525a3d36dfSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 39535a3d36dfSmrg $lt_var=\$save_$lt_var; export $lt_var 3954b3062210Smrg else 39555a3d36dfSmrg $lt_unset $lt_var 39565a3d36dfSmrg fi" 39575a3d36dfSmrg done 39587f7f5e4eSmrg 39595a3d36dfSmrg # Now prepare to actually exec the command. 3960b43acbb4Smrg exec_cmd=\$cmd$args 39615a3d36dfSmrg fi 39625a3d36dfSmrg} 39637f7f5e4eSmrg 3964b43acbb4Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 396541c30155Smrg 39667f7f5e4eSmrg 396741c30155Smrg# func_mode_finish arg... 396841c30155Smrgfunc_mode_finish () 396941c30155Smrg{ 3970b43acbb4Smrg $debug_cmd 3971b43acbb4Smrg 397241c30155Smrg libs= 397341c30155Smrg libdirs= 397441c30155Smrg admincmds= 397541c30155Smrg 397641c30155Smrg for opt in "$nonopt" ${1+"$@"} 397741c30155Smrg do 397841c30155Smrg if test -d "$opt"; then 397941c30155Smrg func_append libdirs " $opt" 398041c30155Smrg 398141c30155Smrg elif test -f "$opt"; then 398241c30155Smrg if func_lalib_unsafe_p "$opt"; then 398341c30155Smrg func_append libs " $opt" 398441c30155Smrg else 3985b43acbb4Smrg func_warning "'$opt' is not a valid libtool archive" 398641c30155Smrg fi 398741c30155Smrg 398841c30155Smrg else 3989b43acbb4Smrg func_fatal_error "invalid argument '$opt'" 399041c30155Smrg fi 399141c30155Smrg done 399241c30155Smrg 399341c30155Smrg if test -n "$libs"; then 399441c30155Smrg if test -n "$lt_sysroot"; then 399541c30155Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 399641c30155Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 399741c30155Smrg else 399841c30155Smrg sysroot_cmd= 399941c30155Smrg fi 4000b3062210Smrg 400141c30155Smrg # Remove sysroot references 400241c30155Smrg if $opt_dry_run; then 400341c30155Smrg for lib in $libs; do 4004b43acbb4Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 400541c30155Smrg done 400641c30155Smrg else 400741c30155Smrg tmpdir=`func_mktempdir` 400841c30155Smrg for lib in $libs; do 4009b43acbb4Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 401041c30155Smrg > $tmpdir/tmp-la 401141c30155Smrg mv -f $tmpdir/tmp-la $lib 401241c30155Smrg done 401341c30155Smrg ${RM}r "$tmpdir" 401441c30155Smrg fi 401541c30155Smrg fi 401623a0898aSmrg 40175a3d36dfSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40185a3d36dfSmrg for libdir in $libdirs; do 40195a3d36dfSmrg if test -n "$finish_cmds"; then 40205a3d36dfSmrg # Do each command in the finish commands. 40215a3d36dfSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 40225a3d36dfSmrg'"$cmd"'"' 4023b3062210Smrg fi 40245a3d36dfSmrg if test -n "$finish_eval"; then 40255a3d36dfSmrg # Do the single finish_eval. 40265a3d36dfSmrg eval cmds=\"$finish_eval\" 402741c30155Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 40285a3d36dfSmrg $cmds" 40295a3d36dfSmrg fi 40305a3d36dfSmrg done 40315a3d36dfSmrg fi 403223a0898aSmrg 40335a3d36dfSmrg # Exit here if they wanted silent mode. 4034b43acbb4Smrg $opt_quiet && exit $EXIT_SUCCESS 403523a0898aSmrg 403641c30155Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 403741c30155Smrg echo "----------------------------------------------------------------------" 403841c30155Smrg echo "Libraries have been installed in:" 403941c30155Smrg for libdir in $libdirs; do 404041c30155Smrg $ECHO " $libdir" 404141c30155Smrg done 404241c30155Smrg echo 404341c30155Smrg echo "If you ever happen to want to link against installed libraries" 404441c30155Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045b43acbb4Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 404641c30155Smrg echo "flag during linking and do at least one of the following:" 404741c30155Smrg if test -n "$shlibpath_var"; then 4048b43acbb4Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 404941c30155Smrg echo " during execution" 405041c30155Smrg fi 405141c30155Smrg if test -n "$runpath_var"; then 4052b43acbb4Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 405341c30155Smrg echo " during linking" 405441c30155Smrg fi 405541c30155Smrg if test -n "$hardcode_libdir_flag_spec"; then 405641c30155Smrg libdir=LIBDIR 405741c30155Smrg eval flag=\"$hardcode_libdir_flag_spec\" 40585a3d36dfSmrg 4059b43acbb4Smrg $ECHO " - use the '$flag' linker flag" 406041c30155Smrg fi 406141c30155Smrg if test -n "$admincmds"; then 406241c30155Smrg $ECHO " - have your system administrator run these commands:$admincmds" 406341c30155Smrg fi 406441c30155Smrg if test -f /etc/ld.so.conf; then 4065b43acbb4Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 406641c30155Smrg fi 406741c30155Smrg echo 40685a3d36dfSmrg 406941c30155Smrg echo "See any operating system documentation about shared libraries for" 407041c30155Smrg case $host in 407141c30155Smrg solaris2.[6789]|solaris2.1[0-9]) 407241c30155Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 407341c30155Smrg echo "pages." 407441c30155Smrg ;; 407541c30155Smrg *) 407641c30155Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 407741c30155Smrg ;; 407841c30155Smrg esac 407941c30155Smrg echo "----------------------------------------------------------------------" 408041c30155Smrg fi 40815a3d36dfSmrg exit $EXIT_SUCCESS 40825a3d36dfSmrg} 40835a3d36dfSmrg 4084b43acbb4Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 40855a3d36dfSmrg 40865a3d36dfSmrg 40875a3d36dfSmrg# func_mode_install arg... 40885a3d36dfSmrgfunc_mode_install () 40895a3d36dfSmrg{ 4090b43acbb4Smrg $debug_cmd 4091b43acbb4Smrg 40925a3d36dfSmrg # There may be an optional sh(1) argument at the beginning of 40935a3d36dfSmrg # install_prog (especially on Windows NT). 4094b43acbb4Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 40955a3d36dfSmrg # Allow the use of GNU shtool's install command. 4096b43acbb4Smrg case $nonopt in *shtool*) :;; *) false;; esac 4097b43acbb4Smrg then 40985a3d36dfSmrg # Aesthetically quote it. 40995a3d36dfSmrg func_quote_for_eval "$nonopt" 41005a3d36dfSmrg install_prog="$func_quote_for_eval_result " 41015a3d36dfSmrg arg=$1 41025a3d36dfSmrg shift 41035a3d36dfSmrg else 41045a3d36dfSmrg install_prog= 41055a3d36dfSmrg arg=$nonopt 41065a3d36dfSmrg fi 41075a3d36dfSmrg 41085a3d36dfSmrg # The real first argument should be the name of the installation program. 41095a3d36dfSmrg # Aesthetically quote it. 41105a3d36dfSmrg func_quote_for_eval "$arg" 411141c30155Smrg func_append install_prog "$func_quote_for_eval_result" 411241c30155Smrg install_shared_prog=$install_prog 411341c30155Smrg case " $install_prog " in 411441c30155Smrg *[\\\ /]cp\ *) install_cp=: ;; 411541c30155Smrg *) install_cp=false ;; 411641c30155Smrg esac 41175a3d36dfSmrg 41185a3d36dfSmrg # We need to accept at least all the BSD install flags. 41195a3d36dfSmrg dest= 41205a3d36dfSmrg files= 41215a3d36dfSmrg opts= 41225a3d36dfSmrg prev= 41235a3d36dfSmrg install_type= 4124b43acbb4Smrg isdir=false 41255a3d36dfSmrg stripme= 412641c30155Smrg no_mode=: 41275a3d36dfSmrg for arg 41285a3d36dfSmrg do 412941c30155Smrg arg2= 41305a3d36dfSmrg if test -n "$dest"; then 413141c30155Smrg func_append files " $dest" 41325a3d36dfSmrg dest=$arg 41335a3d36dfSmrg continue 41345a3d36dfSmrg fi 41355a3d36dfSmrg 41365a3d36dfSmrg case $arg in 4137b43acbb4Smrg -d) isdir=: ;; 41385a3d36dfSmrg -f) 413941c30155Smrg if $install_cp; then :; else 414041c30155Smrg prev=$arg 414141c30155Smrg fi 41425a3d36dfSmrg ;; 41435a3d36dfSmrg -g | -m | -o) 41445a3d36dfSmrg prev=$arg 41455a3d36dfSmrg ;; 41465a3d36dfSmrg -s) 41475a3d36dfSmrg stripme=" -s" 41485a3d36dfSmrg continue 41495a3d36dfSmrg ;; 41505a3d36dfSmrg -*) 41515a3d36dfSmrg ;; 41525a3d36dfSmrg *) 41535a3d36dfSmrg # If the previous option needed an argument, then skip it. 41545a3d36dfSmrg if test -n "$prev"; then 4155b43acbb4Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415641c30155Smrg arg2=$install_override_mode 415741c30155Smrg no_mode=false 415841c30155Smrg fi 4159b3062210Smrg prev= 41607f7f5e4eSmrg else 41615a3d36dfSmrg dest=$arg 41625a3d36dfSmrg continue 416323a0898aSmrg fi 4164b3062210Smrg ;; 41655a3d36dfSmrg esac 416623a0898aSmrg 41675a3d36dfSmrg # Aesthetically quote the argument. 41685a3d36dfSmrg func_quote_for_eval "$arg" 416941c30155Smrg func_append install_prog " $func_quote_for_eval_result" 417041c30155Smrg if test -n "$arg2"; then 417141c30155Smrg func_quote_for_eval "$arg2" 417241c30155Smrg fi 417341c30155Smrg func_append install_shared_prog " $func_quote_for_eval_result" 41745a3d36dfSmrg done 417523a0898aSmrg 41765a3d36dfSmrg test -z "$install_prog" && \ 41775a3d36dfSmrg func_fatal_help "you must specify an install program" 417823a0898aSmrg 41795a3d36dfSmrg test -n "$prev" && \ 4180b43acbb4Smrg func_fatal_help "the '$prev' option requires an argument" 41817f7f5e4eSmrg 418241c30155Smrg if test -n "$install_override_mode" && $no_mode; then 418341c30155Smrg if $install_cp; then :; else 418441c30155Smrg func_quote_for_eval "$install_override_mode" 418541c30155Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418641c30155Smrg fi 418741c30155Smrg fi 418841c30155Smrg 41895a3d36dfSmrg if test -z "$files"; then 41905a3d36dfSmrg if test -z "$dest"; then 41915a3d36dfSmrg func_fatal_help "no file or destination specified" 41925a3d36dfSmrg else 41935a3d36dfSmrg func_fatal_help "you must specify a destination" 41945a3d36dfSmrg fi 4195b3062210Smrg fi 41967f7f5e4eSmrg 41975a3d36dfSmrg # Strip any trailing slash from the destination. 41985a3d36dfSmrg func_stripname '' '/' "$dest" 41995a3d36dfSmrg dest=$func_stripname_result 42007f7f5e4eSmrg 42015a3d36dfSmrg # Check to see that the destination is a directory. 4202b43acbb4Smrg test -d "$dest" && isdir=: 4203b43acbb4Smrg if $isdir; then 4204b43acbb4Smrg destdir=$dest 42055a3d36dfSmrg destname= 4206b3062210Smrg else 42075a3d36dfSmrg func_dirname_and_basename "$dest" "" "." 4208b43acbb4Smrg destdir=$func_dirname_result 4209b43acbb4Smrg destname=$func_basename_result 42107f7f5e4eSmrg 42115a3d36dfSmrg # Not a directory, so check to see that there is only one file specified. 42125a3d36dfSmrg set dummy $files; shift 42135a3d36dfSmrg test "$#" -gt 1 && \ 4214b43acbb4Smrg func_fatal_help "'$dest' is not a directory" 42157f7f5e4eSmrg fi 42165a3d36dfSmrg case $destdir in 42175a3d36dfSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218b3062210Smrg *) 42195a3d36dfSmrg for file in $files; do 42205a3d36dfSmrg case $file in 42215a3d36dfSmrg *.lo) ;; 42225a3d36dfSmrg *) 4223b43acbb4Smrg func_fatal_help "'$destdir' must be an absolute directory name" 42245a3d36dfSmrg ;; 42255a3d36dfSmrg esac 42265a3d36dfSmrg done 4227b3062210Smrg ;; 4228b3062210Smrg esac 422923a0898aSmrg 42305a3d36dfSmrg # This variable tells wrapper scripts just to set variables rather 42315a3d36dfSmrg # than running their programs. 4232b43acbb4Smrg libtool_install_magic=$magic 423323a0898aSmrg 42345a3d36dfSmrg staticlibs= 42355a3d36dfSmrg future_libdirs= 42365a3d36dfSmrg current_libdirs= 42375a3d36dfSmrg for file in $files; do 423823a0898aSmrg 42395a3d36dfSmrg # Do each installation. 42405a3d36dfSmrg case $file in 42415a3d36dfSmrg *.$libext) 42425a3d36dfSmrg # Do the static libraries later. 424341c30155Smrg func_append staticlibs " $file" 42445a3d36dfSmrg ;; 42455a3d36dfSmrg 42465a3d36dfSmrg *.la) 424741c30155Smrg func_resolve_sysroot "$file" 424841c30155Smrg file=$func_resolve_sysroot_result 424941c30155Smrg 42505a3d36dfSmrg # Check to see that this really is a libtool archive. 42515a3d36dfSmrg func_lalib_unsafe_p "$file" \ 4252b43acbb4Smrg || func_fatal_help "'$file' is not a valid libtool archive" 42535a3d36dfSmrg 42545a3d36dfSmrg library_names= 42555a3d36dfSmrg old_library= 42565a3d36dfSmrg relink_command= 42575a3d36dfSmrg func_source "$file" 42585a3d36dfSmrg 42595a3d36dfSmrg # Add the libdir to current_libdirs if it is the destination. 42605a3d36dfSmrg if test "X$destdir" = "X$libdir"; then 42615a3d36dfSmrg case "$current_libdirs " in 42625a3d36dfSmrg *" $libdir "*) ;; 426341c30155Smrg *) func_append current_libdirs " $libdir" ;; 42647f7f5e4eSmrg esac 42655a3d36dfSmrg else 42665a3d36dfSmrg # Note the libdir as a future libdir. 42675a3d36dfSmrg case "$future_libdirs " in 42685a3d36dfSmrg *" $libdir "*) ;; 426941c30155Smrg *) func_append future_libdirs " $libdir" ;; 42705a3d36dfSmrg esac 42715a3d36dfSmrg fi 427223a0898aSmrg 42735a3d36dfSmrg func_dirname "$file" "/" "" 4274b43acbb4Smrg dir=$func_dirname_result 427541c30155Smrg func_append dir "$objdir" 42765a3d36dfSmrg 42775a3d36dfSmrg if test -n "$relink_command"; then 42785a3d36dfSmrg # Determine the prefix the user has applied to our future dir. 427941c30155Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 42805a3d36dfSmrg 42815a3d36dfSmrg # Don't allow the user to place us outside of our expected 42825a3d36dfSmrg # location b/c this prevents finding dependent libraries that 42835a3d36dfSmrg # are installed to the same prefix. 42845a3d36dfSmrg # At present, this check doesn't affect windows .dll's that 42855a3d36dfSmrg # are installed into $libdir/../bin (currently, that works fine) 42865a3d36dfSmrg # but it's something to keep an eye on. 42875a3d36dfSmrg test "$inst_prefix_dir" = "$destdir" && \ 4288b43acbb4Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 42895a3d36dfSmrg 42905a3d36dfSmrg if test -n "$inst_prefix_dir"; then 42915a3d36dfSmrg # Stick the inst_prefix_dir data into the link command. 429241c30155Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 42935a3d36dfSmrg else 429441c30155Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 42955a3d36dfSmrg fi 42965a3d36dfSmrg 4297b43acbb4Smrg func_warning "relinking '$file'" 42985a3d36dfSmrg func_show_eval "$relink_command" \ 4299b43acbb4Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 43005a3d36dfSmrg fi 43015a3d36dfSmrg 43025a3d36dfSmrg # See the names of the shared library. 43035a3d36dfSmrg set dummy $library_names; shift 43045a3d36dfSmrg if test -n "$1"; then 4305b43acbb4Smrg realname=$1 43065a3d36dfSmrg shift 43075a3d36dfSmrg 4308b43acbb4Smrg srcname=$realname 4309b43acbb4Smrg test -n "$relink_command" && srcname=${realname}T 43105a3d36dfSmrg 43115a3d36dfSmrg # Install the shared library and build the symlinks. 431241c30155Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 43135a3d36dfSmrg 'exit $?' 4314b43acbb4Smrg tstripme=$stripme 43155a3d36dfSmrg case $host_os in 43165a3d36dfSmrg cygwin* | mingw* | pw32* | cegcc*) 43175a3d36dfSmrg case $realname in 43185a3d36dfSmrg *.dll.a) 4319b43acbb4Smrg tstripme= 4320b43acbb4Smrg ;; 4321b43acbb4Smrg esac 4322b43acbb4Smrg ;; 4323b43acbb4Smrg os2*) 4324b43acbb4Smrg case $realname in 4325b43acbb4Smrg *_dll.a) 4326b43acbb4Smrg tstripme= 43275a3d36dfSmrg ;; 43285a3d36dfSmrg esac 43297f7f5e4eSmrg ;; 43307f7f5e4eSmrg esac 43315a3d36dfSmrg if test -n "$tstripme" && test -n "$striplib"; then 43325a3d36dfSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333b3062210Smrg fi 43345a3d36dfSmrg 43355a3d36dfSmrg if test "$#" -gt 0; then 43365a3d36dfSmrg # Delete the old symlinks, and create new ones. 4337b43acbb4Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 43385a3d36dfSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 43395a3d36dfSmrg # so we also need to try rm && ln -s. 43405a3d36dfSmrg for linkname 43415a3d36dfSmrg do 43425a3d36dfSmrg test "$linkname" != "$realname" \ 43435a3d36dfSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344b3062210Smrg done 4345b3062210Smrg fi 434623a0898aSmrg 43475a3d36dfSmrg # Do each command in the postinstall commands. 4348b43acbb4Smrg lib=$destdir/$realname 43495a3d36dfSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350b3062210Smrg fi 435123a0898aSmrg 43525a3d36dfSmrg # Install the pseudo-library for information purposes. 43535a3d36dfSmrg func_basename "$file" 4354b43acbb4Smrg name=$func_basename_result 4355b43acbb4Smrg instname=$dir/${name}i 43565a3d36dfSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 435723a0898aSmrg 43585a3d36dfSmrg # Maybe install the static library, too. 435941c30155Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 43605a3d36dfSmrg ;; 436123a0898aSmrg 43625a3d36dfSmrg *.lo) 43635a3d36dfSmrg # Install (i.e. copy) a libtool object. 436423a0898aSmrg 43655a3d36dfSmrg # Figure out destination file name, if it wasn't already specified. 43665a3d36dfSmrg if test -n "$destname"; then 4367b43acbb4Smrg destfile=$destdir/$destname 43685a3d36dfSmrg else 43695a3d36dfSmrg func_basename "$file" 4370b43acbb4Smrg destfile=$func_basename_result 4371b43acbb4Smrg destfile=$destdir/$destfile 4372b3062210Smrg fi 437323a0898aSmrg 43745a3d36dfSmrg # Deduce the name of the destination old-style object file. 43755a3d36dfSmrg case $destfile in 43765a3d36dfSmrg *.lo) 43775a3d36dfSmrg func_lo2o "$destfile" 43785a3d36dfSmrg staticdest=$func_lo2o_result 43795a3d36dfSmrg ;; 43805a3d36dfSmrg *.$objext) 4381b43acbb4Smrg staticdest=$destfile 43825a3d36dfSmrg destfile= 43835a3d36dfSmrg ;; 43845a3d36dfSmrg *) 4385b43acbb4Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 43865a3d36dfSmrg ;; 43875a3d36dfSmrg esac 438823a0898aSmrg 43895a3d36dfSmrg # Install the libtool object if requested. 43905a3d36dfSmrg test -n "$destfile" && \ 43915a3d36dfSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 439223a0898aSmrg 43935a3d36dfSmrg # Install the old object if enabled. 4394b43acbb4Smrg if test yes = "$build_old_libs"; then 43955a3d36dfSmrg # Deduce the name of the old-style object file. 43965a3d36dfSmrg func_lo2o "$file" 43975a3d36dfSmrg staticobj=$func_lo2o_result 43985a3d36dfSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 439923a0898aSmrg fi 44005a3d36dfSmrg exit $EXIT_SUCCESS 44015a3d36dfSmrg ;; 440223a0898aSmrg 44035a3d36dfSmrg *) 44045a3d36dfSmrg # Figure out destination file name, if it wasn't already specified. 44055a3d36dfSmrg if test -n "$destname"; then 4406b43acbb4Smrg destfile=$destdir/$destname 44075a3d36dfSmrg else 44085a3d36dfSmrg func_basename "$file" 4409b43acbb4Smrg destfile=$func_basename_result 4410b43acbb4Smrg destfile=$destdir/$destfile 44115a3d36dfSmrg fi 441223a0898aSmrg 44135a3d36dfSmrg # If the file is missing, and there is a .exe on the end, strip it 44145a3d36dfSmrg # because it is most likely a libtool script we actually want to 44155a3d36dfSmrg # install 4416b43acbb4Smrg stripped_ext= 44175a3d36dfSmrg case $file in 44185a3d36dfSmrg *.exe) 44195a3d36dfSmrg if test ! -f "$file"; then 44205a3d36dfSmrg func_stripname '' '.exe' "$file" 44215a3d36dfSmrg file=$func_stripname_result 4422b43acbb4Smrg stripped_ext=.exe 44235a3d36dfSmrg fi 44245a3d36dfSmrg ;; 44255a3d36dfSmrg esac 44265a3d36dfSmrg 44275a3d36dfSmrg # Do a test to see if this is really a libtool program. 44285a3d36dfSmrg case $host in 44295a3d36dfSmrg *cygwin* | *mingw*) 44305a3d36dfSmrg if func_ltwrapper_executable_p "$file"; then 44315a3d36dfSmrg func_ltwrapper_scriptname "$file" 44325a3d36dfSmrg wrapper=$func_ltwrapper_scriptname_result 44335a3d36dfSmrg else 44345a3d36dfSmrg func_stripname '' '.exe' "$file" 44355a3d36dfSmrg wrapper=$func_stripname_result 44365a3d36dfSmrg fi 44375a3d36dfSmrg ;; 4438b3062210Smrg *) 44395a3d36dfSmrg wrapper=$file 44405a3d36dfSmrg ;; 44415a3d36dfSmrg esac 44425a3d36dfSmrg if func_ltwrapper_script_p "$wrapper"; then 44435a3d36dfSmrg notinst_deplibs= 44445a3d36dfSmrg relink_command= 44455a3d36dfSmrg 44465a3d36dfSmrg func_source "$wrapper" 44475a3d36dfSmrg 44485a3d36dfSmrg # Check the variables that should have been set. 44495a3d36dfSmrg test -z "$generated_by_libtool_version" && \ 4450b43acbb4Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 44515a3d36dfSmrg 4452b43acbb4Smrg finalize=: 44535a3d36dfSmrg for lib in $notinst_deplibs; do 44545a3d36dfSmrg # Check to see that each library is installed. 44555a3d36dfSmrg libdir= 44565a3d36dfSmrg if test -f "$lib"; then 44575a3d36dfSmrg func_source "$lib" 44585a3d36dfSmrg fi 4459b43acbb4Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 44605a3d36dfSmrg if test -n "$libdir" && test ! -f "$libfile"; then 4461b43acbb4Smrg func_warning "'$lib' has not been installed in '$libdir'" 4462b43acbb4Smrg finalize=false 44635a3d36dfSmrg fi 44645a3d36dfSmrg done 44655a3d36dfSmrg 44665a3d36dfSmrg relink_command= 44675a3d36dfSmrg func_source "$wrapper" 44685a3d36dfSmrg 44695a3d36dfSmrg outputname= 4470b43acbb4Smrg if test no = "$fast_install" && test -n "$relink_command"; then 44715a3d36dfSmrg $opt_dry_run || { 4472b43acbb4Smrg if $finalize; then 44735a3d36dfSmrg tmpdir=`func_mktempdir` 44745a3d36dfSmrg func_basename "$file$stripped_ext" 4475b43acbb4Smrg file=$func_basename_result 4476b43acbb4Smrg outputname=$tmpdir/$file 44775a3d36dfSmrg # Replace the output file specification. 447841c30155Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 44795a3d36dfSmrg 4480b43acbb4Smrg $opt_quiet || { 44815a3d36dfSmrg func_quote_for_expand "$relink_command" 44825a3d36dfSmrg eval "func_echo $func_quote_for_expand_result" 44835a3d36dfSmrg } 44845a3d36dfSmrg if eval "$relink_command"; then : 44855a3d36dfSmrg else 4486b43acbb4Smrg func_error "error: relink '$file' with the above command before installing it" 44875a3d36dfSmrg $opt_dry_run || ${RM}r "$tmpdir" 44885a3d36dfSmrg continue 44895a3d36dfSmrg fi 4490b43acbb4Smrg file=$outputname 44915a3d36dfSmrg else 4492b43acbb4Smrg func_warning "cannot relink '$file'" 44935a3d36dfSmrg fi 44945a3d36dfSmrg } 44955a3d36dfSmrg else 44965a3d36dfSmrg # Install the binary that we compiled earlier. 449741c30155Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498b3062210Smrg fi 44995a3d36dfSmrg fi 45005a3d36dfSmrg 45015a3d36dfSmrg # remove .exe since cygwin /usr/bin/install will append another 45025a3d36dfSmrg # one anyway 45035a3d36dfSmrg case $install_prog,$host in 45045a3d36dfSmrg */usr/bin/install*,*cygwin*) 45055a3d36dfSmrg case $file:$destfile in 45065a3d36dfSmrg *.exe:*.exe) 45075a3d36dfSmrg # this is ok 45085a3d36dfSmrg ;; 45095a3d36dfSmrg *.exe:*) 45105a3d36dfSmrg destfile=$destfile.exe 45115a3d36dfSmrg ;; 45125a3d36dfSmrg *:*.exe) 45135a3d36dfSmrg func_stripname '' '.exe' "$destfile" 45145a3d36dfSmrg destfile=$func_stripname_result 45155a3d36dfSmrg ;; 45165a3d36dfSmrg esac 4517b3062210Smrg ;; 4518b3062210Smrg esac 45195a3d36dfSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 45205a3d36dfSmrg $opt_dry_run || if test -n "$outputname"; then 45215a3d36dfSmrg ${RM}r "$tmpdir" 45225a3d36dfSmrg fi 45235a3d36dfSmrg ;; 45245a3d36dfSmrg esac 45255a3d36dfSmrg done 452623a0898aSmrg 45275a3d36dfSmrg for file in $staticlibs; do 45285a3d36dfSmrg func_basename "$file" 4529b43acbb4Smrg name=$func_basename_result 45305a3d36dfSmrg 45315a3d36dfSmrg # Set up the ranlib parameters. 4532b43acbb4Smrg oldlib=$destdir/$name 4533b020570bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534b020570bSmrg tool_oldlib=$func_to_tool_file_result 45355a3d36dfSmrg 45365a3d36dfSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 45375a3d36dfSmrg 45385a3d36dfSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4539b020570bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 45405a3d36dfSmrg fi 45415a3d36dfSmrg 45425a3d36dfSmrg # Do each command in the postinstall commands. 45435a3d36dfSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 45445a3d36dfSmrg done 45455a3d36dfSmrg 45465a3d36dfSmrg test -n "$future_libdirs" && \ 4547b43acbb4Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 45485a3d36dfSmrg 45495a3d36dfSmrg if test -n "$current_libdirs"; then 45505a3d36dfSmrg # Maybe just do a dry run. 45515a3d36dfSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552b43acbb4Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 45535a3d36dfSmrg else 45545a3d36dfSmrg exit $EXIT_SUCCESS 45555a3d36dfSmrg fi 45565a3d36dfSmrg} 45575a3d36dfSmrg 4558b43acbb4Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 45595a3d36dfSmrg 45605a3d36dfSmrg 45615a3d36dfSmrg# func_generate_dlsyms outputname originator pic_p 45625a3d36dfSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 45635a3d36dfSmrg# a dlpreopen symbol table. 45645a3d36dfSmrgfunc_generate_dlsyms () 45655a3d36dfSmrg{ 4566b43acbb4Smrg $debug_cmd 4567b43acbb4Smrg 4568b43acbb4Smrg my_outputname=$1 4569b43acbb4Smrg my_originator=$2 4570b43acbb4Smrg my_pic_p=${3-false} 4571b43acbb4Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 45725a3d36dfSmrg my_dlsyms= 45735a3d36dfSmrg 4574b43acbb4Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 45755a3d36dfSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576b43acbb4Smrg my_dlsyms=${my_outputname}S.c 45775a3d36dfSmrg else 45785a3d36dfSmrg func_error "not configured to extract global symbols from dlpreopened files" 45795a3d36dfSmrg fi 45805a3d36dfSmrg fi 45815a3d36dfSmrg 45825a3d36dfSmrg if test -n "$my_dlsyms"; then 45835a3d36dfSmrg case $my_dlsyms in 45845a3d36dfSmrg "") ;; 45855a3d36dfSmrg *.c) 45865a3d36dfSmrg # Discover the nlist of each of the dlfiles. 4587b43acbb4Smrg nlist=$output_objdir/$my_outputname.nm 45885a3d36dfSmrg 45895a3d36dfSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 45905a3d36dfSmrg 45915a3d36dfSmrg # Parse the name list into a source file. 45925a3d36dfSmrg func_verbose "creating $output_objdir/$my_dlsyms" 45935a3d36dfSmrg 45945a3d36dfSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595b43acbb4Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596b43acbb4Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 45975a3d36dfSmrg 45985a3d36dfSmrg#ifdef __cplusplus 45995a3d36dfSmrgextern \"C\" { 46005a3d36dfSmrg#endif 46015a3d36dfSmrg 4602b43acbb4Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460341c30155Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460441c30155Smrg#endif 460541c30155Smrg 460641c30155Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607b43acbb4Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608b43acbb4Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 460941c30155Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 461041c30155Smrg# define LT_DLSYM_CONST 4611b43acbb4Smrg#elif defined __osf__ 461241c30155Smrg/* This system does not cope well with relocations in const data. */ 461341c30155Smrg# define LT_DLSYM_CONST 461441c30155Smrg#else 461541c30155Smrg# define LT_DLSYM_CONST const 461641c30155Smrg#endif 461741c30155Smrg 4618b43acbb4Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619b43acbb4Smrg 46205a3d36dfSmrg/* External symbol declarations for the compiler. */\ 46215a3d36dfSmrg" 46225a3d36dfSmrg 4623b43acbb4Smrg if test yes = "$dlself"; then 4624b43acbb4Smrg func_verbose "generating symbol list for '$output'" 46255a3d36dfSmrg 46265a3d36dfSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 46275a3d36dfSmrg 46285a3d36dfSmrg # Add our own program objects to the symbol list. 462941c30155Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 46305a3d36dfSmrg for progfile in $progfiles; do 463141c30155Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632b43acbb4Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 463341c30155Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 46345a3d36dfSmrg done 46355a3d36dfSmrg 46365a3d36dfSmrg if test -n "$exclude_expsyms"; then 46375a3d36dfSmrg $opt_dry_run || { 46385a3d36dfSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 46395a3d36dfSmrg eval '$MV "$nlist"T "$nlist"' 46405a3d36dfSmrg } 4641b3062210Smrg fi 46425a3d36dfSmrg 46435a3d36dfSmrg if test -n "$export_symbols_regex"; then 46445a3d36dfSmrg $opt_dry_run || { 46455a3d36dfSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 46465a3d36dfSmrg eval '$MV "$nlist"T "$nlist"' 46475a3d36dfSmrg } 46485a3d36dfSmrg fi 46495a3d36dfSmrg 46505a3d36dfSmrg # Prepare the list of exported symbols 46515a3d36dfSmrg if test -z "$export_symbols"; then 4652b43acbb4Smrg export_symbols=$output_objdir/$outputname.exp 46535a3d36dfSmrg $opt_dry_run || { 46545a3d36dfSmrg $RM $export_symbols 4655b43acbb4Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 46565a3d36dfSmrg case $host in 46575a3d36dfSmrg *cygwin* | *mingw* | *cegcc* ) 46585a3d36dfSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46595a3d36dfSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 46605a3d36dfSmrg ;; 46615a3d36dfSmrg esac 46625a3d36dfSmrg } 4663b3062210Smrg else 46645a3d36dfSmrg $opt_dry_run || { 4665b43acbb4Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 46665a3d36dfSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 46675a3d36dfSmrg eval '$MV "$nlist"T "$nlist"' 46685a3d36dfSmrg case $host in 466941c30155Smrg *cygwin* | *mingw* | *cegcc* ) 46705a3d36dfSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46715a3d36dfSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 46725a3d36dfSmrg ;; 46735a3d36dfSmrg esac 46745a3d36dfSmrg } 4675b3062210Smrg fi 46765a3d36dfSmrg fi 467723a0898aSmrg 46785a3d36dfSmrg for dlprefile in $dlprefiles; do 4679b43acbb4Smrg func_verbose "extracting global C symbols from '$dlprefile'" 46805a3d36dfSmrg func_basename "$dlprefile" 4681b43acbb4Smrg name=$func_basename_result 468241c30155Smrg case $host in 468341c30155Smrg *cygwin* | *mingw* | *cegcc* ) 468441c30155Smrg # if an import library, we need to obtain dlname 468541c30155Smrg if func_win32_import_lib_p "$dlprefile"; then 468641c30155Smrg func_tr_sh "$dlprefile" 468741c30155Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688b43acbb4Smrg dlprefile_dlbasename= 468941c30155Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 469041c30155Smrg # Use subshell, to avoid clobbering current variable values 469141c30155Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692b43acbb4Smrg if test -n "$dlprefile_dlname"; then 469341c30155Smrg func_basename "$dlprefile_dlname" 4694b43acbb4Smrg dlprefile_dlbasename=$func_basename_result 469541c30155Smrg else 469641c30155Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 469741c30155Smrg $sharedlib_from_linklib_cmd "$dlprefile" 469841c30155Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 469941c30155Smrg fi 470041c30155Smrg fi 470141c30155Smrg $opt_dry_run || { 4702b43acbb4Smrg if test -n "$dlprefile_dlbasename"; then 470341c30155Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 470441c30155Smrg else 470541c30155Smrg func_warning "Could not compute DLL name from $name" 470641c30155Smrg eval '$ECHO ": $name " >> "$nlist"' 470741c30155Smrg fi 470841c30155Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 470941c30155Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 471041c30155Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 471141c30155Smrg } 471241c30155Smrg else # not an import lib 471341c30155Smrg $opt_dry_run || { 471441c30155Smrg eval '$ECHO ": $name " >> "$nlist"' 471541c30155Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 471641c30155Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 471741c30155Smrg } 471841c30155Smrg fi 471941c30155Smrg ;; 472041c30155Smrg *) 472141c30155Smrg $opt_dry_run || { 472241c30155Smrg eval '$ECHO ": $name " >> "$nlist"' 472341c30155Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 472441c30155Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 472541c30155Smrg } 472641c30155Smrg ;; 472741c30155Smrg esac 47285a3d36dfSmrg done 47295a3d36dfSmrg 47305a3d36dfSmrg $opt_dry_run || { 47315a3d36dfSmrg # Make sure we have at least an empty file. 47325a3d36dfSmrg test -f "$nlist" || : > "$nlist" 47335a3d36dfSmrg 47345a3d36dfSmrg if test -n "$exclude_expsyms"; then 47355a3d36dfSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 47365a3d36dfSmrg $MV "$nlist"T "$nlist" 4737b3062210Smrg fi 47385a3d36dfSmrg 47395a3d36dfSmrg # Try sorting and uniquifying the output. 47405a3d36dfSmrg if $GREP -v "^: " < "$nlist" | 47415a3d36dfSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 47425a3d36dfSmrg sort -k 3 47435a3d36dfSmrg else 47445a3d36dfSmrg sort +2 47455a3d36dfSmrg fi | 47465a3d36dfSmrg uniq > "$nlist"S; then 47475a3d36dfSmrg : 4748b3062210Smrg else 47495a3d36dfSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750b3062210Smrg fi 475123a0898aSmrg 47525a3d36dfSmrg if test -f "$nlist"S; then 47535a3d36dfSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754b3062210Smrg else 475541c30155Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756b3062210Smrg fi 475723a0898aSmrg 4758b43acbb4Smrg func_show_eval '$RM "${nlist}I"' 4759b43acbb4Smrg if test -n "$global_symbol_to_import"; then 4760b43acbb4Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761b43acbb4Smrg fi 4762b43acbb4Smrg 476341c30155Smrg echo >> "$output_objdir/$my_dlsyms" "\ 476423a0898aSmrg 47655a3d36dfSmrg/* The mapping between symbol names and symbols. */ 47665a3d36dfSmrgtypedef struct { 47675a3d36dfSmrg const char *name; 47685a3d36dfSmrg void *address; 47695a3d36dfSmrg} lt_dlsymlist; 477041c30155Smrgextern LT_DLSYM_CONST lt_dlsymlist 4771b43acbb4Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772b43acbb4Smrg" 4773b43acbb4Smrg 4774b43acbb4Smrg if test -s "$nlist"I; then 4775b43acbb4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4776b43acbb4Smrgstatic void lt_syminit(void) 4777b43acbb4Smrg{ 4778b43acbb4Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779b43acbb4Smrg for (; symbol->name; ++symbol) 4780b43acbb4Smrg {" 4781b43acbb4Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782b43acbb4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4783b43acbb4Smrg } 4784b43acbb4Smrg}" 4785b43acbb4Smrg fi 4786b43acbb4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478741c30155SmrgLT_DLSYM_CONST lt_dlsymlist 47885a3d36dfSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789b43acbb4Smrg{ {\"$my_originator\", (void *) 0}," 4790b43acbb4Smrg 4791b43acbb4Smrg if test -s "$nlist"I; then 4792b43acbb4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4793b43acbb4Smrg {\"@INIT@\", (void *) <_syminit}," 4794b43acbb4Smrg fi 479523a0898aSmrg 47965a3d36dfSmrg case $need_lib_prefix in 47975a3d36dfSmrg no) 47985a3d36dfSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 47995a3d36dfSmrg ;; 48005a3d36dfSmrg *) 48015a3d36dfSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 48025a3d36dfSmrg ;; 48035a3d36dfSmrg esac 480441c30155Smrg echo >> "$output_objdir/$my_dlsyms" "\ 48055a3d36dfSmrg {0, (void *) 0} 48065a3d36dfSmrg}; 48077f7f5e4eSmrg 48085a3d36dfSmrg/* This works around a problem in FreeBSD linker */ 48095a3d36dfSmrg#ifdef FREEBSD_WORKAROUND 48105a3d36dfSmrgstatic const void *lt_preloaded_setup() { 48115a3d36dfSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 48125a3d36dfSmrg} 48135a3d36dfSmrg#endif 48145a3d36dfSmrg 48155a3d36dfSmrg#ifdef __cplusplus 48165a3d36dfSmrg} 48175a3d36dfSmrg#endif\ 48185a3d36dfSmrg" 48195a3d36dfSmrg } # !$opt_dry_run 48205a3d36dfSmrg 48215a3d36dfSmrg pic_flag_for_symtable= 48225a3d36dfSmrg case "$compile_command " in 48235a3d36dfSmrg *" -static "*) ;; 48245a3d36dfSmrg *) 48255a3d36dfSmrg case $host in 48265a3d36dfSmrg # compiling the symbol table file with pic_flag works around 48275a3d36dfSmrg # a FreeBSD bug that causes programs to crash when -lm is 48285a3d36dfSmrg # linked before any other PIC object. But we must not use 48295a3d36dfSmrg # pic_flag when linking with -static. The problem exists in 48305a3d36dfSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831b020570bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 48325a3d36dfSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 48335a3d36dfSmrg *-*-hpux*) 48345a3d36dfSmrg pic_flag_for_symtable=" $pic_flag" ;; 48355a3d36dfSmrg *) 4836b43acbb4Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 48375a3d36dfSmrg ;; 48385a3d36dfSmrg esac 48395a3d36dfSmrg ;; 48405a3d36dfSmrg esac 48415a3d36dfSmrg symtab_cflags= 48425a3d36dfSmrg for arg in $LTCFLAGS; do 48435a3d36dfSmrg case $arg in 48445a3d36dfSmrg -pie | -fpie | -fPIE) ;; 484541c30155Smrg *) func_append symtab_cflags " $arg" ;; 48465a3d36dfSmrg esac 48475a3d36dfSmrg done 484823a0898aSmrg 48495a3d36dfSmrg # Now compile the dynamic symbol file. 48505a3d36dfSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 48517f7f5e4eSmrg 48525a3d36dfSmrg # Clean up the generated files. 4853b43acbb4Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 485423a0898aSmrg 48555a3d36dfSmrg # Transform the symbol file into the correct name. 4856b43acbb4Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 48575a3d36dfSmrg case $host in 48585a3d36dfSmrg *cygwin* | *mingw* | *cegcc* ) 48595a3d36dfSmrg if test -f "$output_objdir/$my_outputname.def"; then 486041c30155Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486141c30155Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48625a3d36dfSmrg else 486341c30155Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486441c30155Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865b3062210Smrg fi 48665a3d36dfSmrg ;; 48675a3d36dfSmrg *) 486841c30155Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486941c30155Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48705a3d36dfSmrg ;; 48715a3d36dfSmrg esac 48725a3d36dfSmrg ;; 48735a3d36dfSmrg *) 4874b43acbb4Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 48755a3d36dfSmrg ;; 48765a3d36dfSmrg esac 48775a3d36dfSmrg else 48785a3d36dfSmrg # We keep going just in case the user didn't refer to 48795a3d36dfSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 48805a3d36dfSmrg # really was required. 488123a0898aSmrg 48825a3d36dfSmrg # Nullify the symbol file. 488341c30155Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488441c30155Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 48855a3d36dfSmrg fi 48865a3d36dfSmrg} 48877f7f5e4eSmrg 4888b43acbb4Smrg# func_cygming_gnu_implib_p ARG 4889b43acbb4Smrg# This predicate returns with zero status (TRUE) if 4890b43acbb4Smrg# ARG is a GNU/binutils-style import library. Returns 4891b43acbb4Smrg# with nonzero status (FALSE) otherwise. 4892b43acbb4Smrgfunc_cygming_gnu_implib_p () 4893b43acbb4Smrg{ 4894b43acbb4Smrg $debug_cmd 4895b43acbb4Smrg 4896b43acbb4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897b43acbb4Smrg 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)$'` 4898b43acbb4Smrg test -n "$func_cygming_gnu_implib_tmp" 4899b43acbb4Smrg} 4900b43acbb4Smrg 4901b43acbb4Smrg# func_cygming_ms_implib_p ARG 4902b43acbb4Smrg# This predicate returns with zero status (TRUE) if 4903b43acbb4Smrg# ARG is an MS-style import library. Returns 4904b43acbb4Smrg# with nonzero status (FALSE) otherwise. 4905b43acbb4Smrgfunc_cygming_ms_implib_p () 4906b43acbb4Smrg{ 4907b43acbb4Smrg $debug_cmd 4908b43acbb4Smrg 4909b43acbb4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910b43acbb4Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911b43acbb4Smrg test -n "$func_cygming_ms_implib_tmp" 4912b43acbb4Smrg} 4913b43acbb4Smrg 49145a3d36dfSmrg# func_win32_libid arg 49155a3d36dfSmrg# return the library type of file 'arg' 49165a3d36dfSmrg# 49175a3d36dfSmrg# Need a lot of goo to handle *both* DLLs and import libs 49185a3d36dfSmrg# Has to be a shell function in order to 'eat' the argument 49195a3d36dfSmrg# that is supplied when $file_magic_command is called. 492041c30155Smrg# Despite the name, also deal with 64 bit binaries. 49215a3d36dfSmrgfunc_win32_libid () 49225a3d36dfSmrg{ 4923b43acbb4Smrg $debug_cmd 4924b43acbb4Smrg 4925b43acbb4Smrg win32_libid_type=unknown 49265a3d36dfSmrg win32_fileres=`file -L $1 2>/dev/null` 49275a3d36dfSmrg case $win32_fileres in 49285a3d36dfSmrg *ar\ archive\ import\ library*) # definitely import 49295a3d36dfSmrg win32_libid_type="x86 archive import" 49305a3d36dfSmrg ;; 49315a3d36dfSmrg *ar\ archive*) # could be an import, or static 493241c30155Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 49335a3d36dfSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493441c30155Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935b43acbb4Smrg case $nm_interface in 4936b43acbb4Smrg "MS dumpbin") 4937b43acbb4Smrg if func_cygming_ms_implib_p "$1" || 4938b43acbb4Smrg func_cygming_gnu_implib_p "$1" 4939b43acbb4Smrg then 4940b43acbb4Smrg win32_nmres=import 4941b43acbb4Smrg else 4942b43acbb4Smrg win32_nmres= 4943b43acbb4Smrg fi 4944b43acbb4Smrg ;; 4945b43acbb4Smrg *) 4946b43acbb4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947b43acbb4Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948b43acbb4Smrg $SED -n -e ' 49495a3d36dfSmrg 1,100{ 49505a3d36dfSmrg / I /{ 4951b43acbb4Smrg s|.*|import| 49525a3d36dfSmrg p 49535a3d36dfSmrg q 49545a3d36dfSmrg } 49555a3d36dfSmrg }'` 4956b43acbb4Smrg ;; 4957b43acbb4Smrg esac 49585a3d36dfSmrg case $win32_nmres in 49595a3d36dfSmrg import*) win32_libid_type="x86 archive import";; 49605a3d36dfSmrg *) win32_libid_type="x86 archive static";; 49615a3d36dfSmrg esac 49625a3d36dfSmrg fi 49635a3d36dfSmrg ;; 49645a3d36dfSmrg *DLL*) 49655a3d36dfSmrg win32_libid_type="x86 DLL" 49665a3d36dfSmrg ;; 49675a3d36dfSmrg *executable*) # but shell scripts are "executable" too... 49685a3d36dfSmrg case $win32_fileres in 49695a3d36dfSmrg *MS\ Windows\ PE\ Intel*) 49705a3d36dfSmrg win32_libid_type="x86 DLL" 49715a3d36dfSmrg ;; 49725a3d36dfSmrg esac 49735a3d36dfSmrg ;; 49745a3d36dfSmrg esac 49755a3d36dfSmrg $ECHO "$win32_libid_type" 49765a3d36dfSmrg} 49777f7f5e4eSmrg 497841c30155Smrg# func_cygming_dll_for_implib ARG 497941c30155Smrg# 498041c30155Smrg# Platform-specific function to extract the 498141c30155Smrg# name of the DLL associated with the specified 498241c30155Smrg# import library ARG. 498341c30155Smrg# Invoked by eval'ing the libtool variable 498441c30155Smrg# $sharedlib_from_linklib_cmd 498541c30155Smrg# Result is available in the variable 498641c30155Smrg# $sharedlib_from_linklib_result 498741c30155Smrgfunc_cygming_dll_for_implib () 498841c30155Smrg{ 4989b43acbb4Smrg $debug_cmd 4990b43acbb4Smrg 499141c30155Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 499241c30155Smrg} 499341c30155Smrg 499441c30155Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 499541c30155Smrg# 499641c30155Smrg# The is the core of a fallback implementation of a 499741c30155Smrg# platform-specific function to extract the name of the 499841c30155Smrg# DLL associated with the specified import library LIBNAME. 499941c30155Smrg# 500041c30155Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 500141c30155Smrg# on the platform and compiler that created the implib. 500241c30155Smrg# 500341c30155Smrg# Echos the name of the DLL associated with the 500441c30155Smrg# specified import library. 500541c30155Smrgfunc_cygming_dll_for_implib_fallback_core () 500641c30155Smrg{ 5007b43acbb4Smrg $debug_cmd 5008b43acbb4Smrg 500941c30155Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 501041c30155Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 501141c30155Smrg $SED '/^Contents of section '"$match_literal"':/{ 501241c30155Smrg # Place marker at beginning of archive member dllname section 501341c30155Smrg s/.*/====MARK====/ 501441c30155Smrg p 501541c30155Smrg d 501641c30155Smrg } 501741c30155Smrg # These lines can sometimes be longer than 43 characters, but 501841c30155Smrg # are always uninteresting 501941c30155Smrg /:[ ]*file format pe[i]\{,1\}-/d 502041c30155Smrg /^In archive [^:]*:/d 502141c30155Smrg # Ensure marker is printed 502241c30155Smrg /^====MARK====/p 502341c30155Smrg # Remove all lines with less than 43 characters 502441c30155Smrg /^.\{43\}/!d 502541c30155Smrg # From remaining lines, remove first 43 characters 502641c30155Smrg s/^.\{43\}//' | 502741c30155Smrg $SED -n ' 502841c30155Smrg # Join marker and all lines until next marker into a single line 502941c30155Smrg /^====MARK====/ b para 503041c30155Smrg H 503141c30155Smrg $ b para 503241c30155Smrg b 503341c30155Smrg :para 503441c30155Smrg x 503541c30155Smrg s/\n//g 503641c30155Smrg # Remove the marker 503741c30155Smrg s/^====MARK====// 503841c30155Smrg # Remove trailing dots and whitespace 503941c30155Smrg s/[\. \t]*$// 504041c30155Smrg # Print 504141c30155Smrg /./p' | 504241c30155Smrg # we now have a list, one entry per line, of the stringified 504341c30155Smrg # contents of the appropriate section of all members of the 5044b43acbb4Smrg # archive that possess that section. Heuristic: eliminate 5045b43acbb4Smrg # all those that have a first or second character that is 504641c30155Smrg # a '.' (that is, objdump's representation of an unprintable 504741c30155Smrg # character.) This should work for all archives with less than 504841c30155Smrg # 0x302f exports -- but will fail for DLLs whose name actually 504941c30155Smrg # begins with a literal '.' or a single character followed by 505041c30155Smrg # a '.'. 505141c30155Smrg # 505241c30155Smrg # Of those that remain, print the first one. 505341c30155Smrg $SED -e '/^\./d;/^.\./d;q' 505441c30155Smrg} 505541c30155Smrg 505641c30155Smrg# func_cygming_dll_for_implib_fallback ARG 505741c30155Smrg# Platform-specific function to extract the 505841c30155Smrg# name of the DLL associated with the specified 505941c30155Smrg# import library ARG. 506041c30155Smrg# 506141c30155Smrg# This fallback implementation is for use when $DLLTOOL 506241c30155Smrg# does not support the --identify-strict option. 506341c30155Smrg# Invoked by eval'ing the libtool variable 506441c30155Smrg# $sharedlib_from_linklib_cmd 506541c30155Smrg# Result is available in the variable 506641c30155Smrg# $sharedlib_from_linklib_result 506741c30155Smrgfunc_cygming_dll_for_implib_fallback () 506841c30155Smrg{ 5069b43acbb4Smrg $debug_cmd 5070b43acbb4Smrg 5071b43acbb4Smrg if func_cygming_gnu_implib_p "$1"; then 507241c30155Smrg # binutils import library 507341c30155Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074b43acbb4Smrg elif func_cygming_ms_implib_p "$1"; then 507541c30155Smrg # ms-generated import library 507641c30155Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 507741c30155Smrg else 507841c30155Smrg # unknown 5079b43acbb4Smrg sharedlib_from_linklib_result= 508041c30155Smrg fi 508141c30155Smrg} 50827f7f5e4eSmrg 50837f7f5e4eSmrg 50845a3d36dfSmrg# func_extract_an_archive dir oldlib 50855a3d36dfSmrgfunc_extract_an_archive () 50865a3d36dfSmrg{ 5087b43acbb4Smrg $debug_cmd 5088b43acbb4Smrg 5089b43acbb4Smrg f_ex_an_ar_dir=$1; shift 5090b43acbb4Smrg f_ex_an_ar_oldlib=$1 5091b43acbb4Smrg if test yes = "$lock_old_archive_extraction"; then 509241c30155Smrg lockfile=$f_ex_an_ar_oldlib.lock 509341c30155Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509441c30155Smrg func_echo "Waiting for $lockfile to be removed" 509541c30155Smrg sleep 2 509641c30155Smrg done 509741c30155Smrg fi 509841c30155Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509941c30155Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100b43acbb4Smrg if test yes = "$lock_old_archive_extraction"; then 510141c30155Smrg $opt_dry_run || rm -f "$lockfile" 510241c30155Smrg fi 51035a3d36dfSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 51045a3d36dfSmrg : 51055a3d36dfSmrg else 51065a3d36dfSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 51075a3d36dfSmrg fi 51085a3d36dfSmrg} 510923a0898aSmrg 511023a0898aSmrg 51115a3d36dfSmrg# func_extract_archives gentop oldlib ... 51125a3d36dfSmrgfunc_extract_archives () 51135a3d36dfSmrg{ 5114b43acbb4Smrg $debug_cmd 5115b43acbb4Smrg 5116b43acbb4Smrg my_gentop=$1; shift 51175a3d36dfSmrg my_oldlibs=${1+"$@"} 5118b43acbb4Smrg my_oldobjs= 5119b43acbb4Smrg my_xlib= 5120b43acbb4Smrg my_xabs= 5121b43acbb4Smrg my_xdir= 51227f7f5e4eSmrg 51235a3d36dfSmrg for my_xlib in $my_oldlibs; do 51245a3d36dfSmrg # Extract the objects. 51255a3d36dfSmrg case $my_xlib in 5126b43acbb4Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 51275a3d36dfSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 51285a3d36dfSmrg esac 51295a3d36dfSmrg func_basename "$my_xlib" 5130b43acbb4Smrg my_xlib=$func_basename_result 51315a3d36dfSmrg my_xlib_u=$my_xlib 51325a3d36dfSmrg while :; do 51335a3d36dfSmrg case " $extracted_archives " in 51345a3d36dfSmrg *" $my_xlib_u "*) 51355a3d36dfSmrg func_arith $extracted_serial + 1 51365a3d36dfSmrg extracted_serial=$func_arith_result 51375a3d36dfSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 51385a3d36dfSmrg *) break ;; 51395a3d36dfSmrg esac 51405a3d36dfSmrg done 51415a3d36dfSmrg extracted_archives="$extracted_archives $my_xlib_u" 5142b43acbb4Smrg my_xdir=$my_gentop/$my_xlib_u 51437f7f5e4eSmrg 51445a3d36dfSmrg func_mkdir_p "$my_xdir" 51457f7f5e4eSmrg 51465a3d36dfSmrg case $host in 51475a3d36dfSmrg *-darwin*) 51485a3d36dfSmrg func_verbose "Extracting $my_xabs" 51495a3d36dfSmrg # Do not bother doing anything if just a dry run 51505a3d36dfSmrg $opt_dry_run || { 51515a3d36dfSmrg darwin_orig_dir=`pwd` 51525a3d36dfSmrg cd $my_xdir || exit $? 51535a3d36dfSmrg darwin_archive=$my_xabs 51545a3d36dfSmrg darwin_curdir=`pwd` 5155b43acbb4Smrg func_basename "$darwin_archive" 5156b43acbb4Smrg darwin_base_archive=$func_basename_result 51575a3d36dfSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 51585a3d36dfSmrg if test -n "$darwin_arches"; then 51595a3d36dfSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 51605a3d36dfSmrg darwin_arch= 51615a3d36dfSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162b43acbb4Smrg for darwin_arch in $darwin_arches; do 5163b43acbb4Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164b43acbb4Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165b43acbb4Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166b43acbb4Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 51675a3d36dfSmrg cd "$darwin_curdir" 5168b43acbb4Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 51695a3d36dfSmrg done # $darwin_arches 51705a3d36dfSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171b43acbb4Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 51725a3d36dfSmrg darwin_file= 51735a3d36dfSmrg darwin_files= 51745a3d36dfSmrg for darwin_file in $darwin_filelist; do 517541c30155Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 51765a3d36dfSmrg $LIPO -create -output "$darwin_file" $darwin_files 51775a3d36dfSmrg done # $darwin_filelist 51785a3d36dfSmrg $RM -rf unfat-$$ 51795a3d36dfSmrg cd "$darwin_orig_dir" 5180b3062210Smrg else 51815a3d36dfSmrg cd $darwin_orig_dir 51825a3d36dfSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51835a3d36dfSmrg fi # $darwin_arches 51845a3d36dfSmrg } # !$opt_dry_run 51855a3d36dfSmrg ;; 51865a3d36dfSmrg *) 51875a3d36dfSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51885a3d36dfSmrg ;; 51895a3d36dfSmrg esac 519041c30155Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 51915a3d36dfSmrg done 51927f7f5e4eSmrg 5193b43acbb4Smrg func_extract_archives_result=$my_oldobjs 51945a3d36dfSmrg} 519523a0898aSmrg 519623a0898aSmrg 519741c30155Smrg# func_emit_wrapper [arg=no] 519841c30155Smrg# 519941c30155Smrg# Emit a libtool wrapper script on stdout. 520041c30155Smrg# Don't directly open a file because we may want to 520141c30155Smrg# incorporate the script contents within a cygwin/mingw 520241c30155Smrg# wrapper executable. Must ONLY be called from within 520341c30155Smrg# func_mode_link because it depends on a number of variables 520441c30155Smrg# set therein. 52055a3d36dfSmrg# 520641c30155Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520741c30155Smrg# variable will take. If 'yes', then the emitted script 5208b43acbb4Smrg# will assume that the directory where it is stored is 520941c30155Smrg# the $objdir directory. This is a cygwin/mingw-specific 521041c30155Smrg# behavior. 521141c30155Smrgfunc_emit_wrapper () 52125a3d36dfSmrg{ 521341c30155Smrg func_emit_wrapper_arg1=${1-no} 5214b3062210Smrg 52155a3d36dfSmrg $ECHO "\ 52165a3d36dfSmrg#! $SHELL 52177f7f5e4eSmrg 52185a3d36dfSmrg# $output - temporary wrapper script for $objdir/$outputname 5219b43acbb4Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 52205a3d36dfSmrg# 52215a3d36dfSmrg# The $output program cannot be directly executed until all the libtool 52225a3d36dfSmrg# libraries that it depends on are installed. 52235a3d36dfSmrg# 52245a3d36dfSmrg# This wrapper script should never be moved out of the build directory. 52255a3d36dfSmrg# If it is, it will not operate correctly. 522623a0898aSmrg 52275a3d36dfSmrg# Sed substitution that helps us do robust quoting. It backslashifies 52285a3d36dfSmrg# metacharacters that are still active within double-quoted strings. 52295a3d36dfSmrgsed_quote_subst='$sed_quote_subst' 523023a0898aSmrg 52315a3d36dfSmrg# Be Bourne compatible 52325a3d36dfSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 52335a3d36dfSmrg emulate sh 52345a3d36dfSmrg NULLCMD=: 52355a3d36dfSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 52365a3d36dfSmrg # is contrary to our usage. Disable this feature. 52375a3d36dfSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 52385a3d36dfSmrg setopt NO_GLOB_SUBST 52395a3d36dfSmrgelse 52405a3d36dfSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 52415a3d36dfSmrgfi 52425a3d36dfSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 52435a3d36dfSmrgDUALCASE=1; export DUALCASE # for MKS sh 524423a0898aSmrg 52455a3d36dfSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 52465a3d36dfSmrg# if CDPATH is set. 52475a3d36dfSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 524823a0898aSmrg 52495a3d36dfSmrgrelink_command=\"$relink_command\" 525023a0898aSmrg 52515a3d36dfSmrg# This environment variable determines our operation mode. 52525a3d36dfSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 52535a3d36dfSmrg # install mode needs the following variables: 52545a3d36dfSmrg generated_by_libtool_version='$macro_version' 52555a3d36dfSmrg notinst_deplibs='$notinst_deplibs' 52565a3d36dfSmrgelse 52575a3d36dfSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 52585a3d36dfSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525941c30155Smrg file=\"\$0\"" 526041c30155Smrg 526141c30155Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526241c30155Smrg $ECHO "\ 526341c30155Smrg 526441c30155Smrg# A function that is used when there is no print builtin or printf. 526541c30155Smrgfunc_fallback_echo () 526641c30155Smrg{ 526741c30155Smrg eval 'cat <<_LTECHO_EOF 526841c30155Smrg\$1 526941c30155Smrg_LTECHO_EOF' 527041c30155Smrg} 527141c30155Smrg ECHO=\"$qECHO\" 527241c30155Smrg fi 527341c30155Smrg 527441c30155Smrg# Very basic option parsing. These options are (a) specific to 527541c30155Smrg# the libtool wrapper, (b) are identical between the wrapper 5276b43acbb4Smrg# /script/ and the wrapper /executable/ that is used only on 527741c30155Smrg# windows platforms, and (c) all begin with the string "--lt-" 5278b43acbb4Smrg# (application programs are unlikely to have options that match 527941c30155Smrg# this pattern). 528041c30155Smrg# 528141c30155Smrg# There are only two supported options: --lt-debug and 528241c30155Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 528341c30155Smrg# 528441c30155Smrg# The first argument to this parsing function should be the 528541c30155Smrg# script's $0 value, followed by "$@". 528641c30155Smrglt_option_debug= 528741c30155Smrgfunc_parse_lt_options () 528841c30155Smrg{ 528941c30155Smrg lt_script_arg0=\$0 529041c30155Smrg shift 529141c30155Smrg for lt_opt 529241c30155Smrg do 529341c30155Smrg case \"\$lt_opt\" in 529441c30155Smrg --lt-debug) lt_option_debug=1 ;; 529541c30155Smrg --lt-dump-script) 529641c30155Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529741c30155Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529841c30155Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529941c30155Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 530041c30155Smrg exit 0 530141c30155Smrg ;; 530241c30155Smrg --lt-*) 530341c30155Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530441c30155Smrg exit 1 530541c30155Smrg ;; 530641c30155Smrg esac 530741c30155Smrg done 530841c30155Smrg 530941c30155Smrg # Print the debug banner immediately: 531041c30155Smrg if test -n \"\$lt_option_debug\"; then 5311b43acbb4Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531241c30155Smrg fi 531341c30155Smrg} 531441c30155Smrg 531541c30155Smrg# Used when --lt-debug. Prints its arguments to stdout 531641c30155Smrg# (redirection is the responsibility of the caller) 531741c30155Smrgfunc_lt_dump_args () 531841c30155Smrg{ 531941c30155Smrg lt_dump_args_N=1; 532041c30155Smrg for lt_arg 532141c30155Smrg do 5322b43acbb4Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532341c30155Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532441c30155Smrg done 532541c30155Smrg} 532641c30155Smrg 532741c30155Smrg# Core function for launching the target application 532841c30155Smrgfunc_exec_program_core () 532941c30155Smrg{ 53305a3d36dfSmrg" 533141c30155Smrg case $host in 533241c30155Smrg # Backslashes separate directories on plain windows 533341c30155Smrg *-*-mingw | *-*-os2* | *-cegcc*) 533441c30155Smrg $ECHO "\ 533541c30155Smrg if test -n \"\$lt_option_debug\"; then 5336b43acbb4Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533741c30155Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533841c30155Smrg fi 533941c30155Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534041c30155Smrg" 534141c30155Smrg ;; 534241c30155Smrg 534341c30155Smrg *) 534441c30155Smrg $ECHO "\ 534541c30155Smrg if test -n \"\$lt_option_debug\"; then 5346b43acbb4Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534741c30155Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534841c30155Smrg fi 534941c30155Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535041c30155Smrg" 535141c30155Smrg ;; 535241c30155Smrg esac 535341c30155Smrg $ECHO "\ 535441c30155Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535541c30155Smrg exit 1 535641c30155Smrg} 535741c30155Smrg 535841c30155Smrg# A function to encapsulate launching the target application 535941c30155Smrg# Strips options in the --lt-* namespace from \$@ and 536041c30155Smrg# launches target application with the remaining arguments. 536141c30155Smrgfunc_exec_program () 536241c30155Smrg{ 5363b020570bSmrg case \" \$* \" in 5364b020570bSmrg *\\ --lt-*) 5365b020570bSmrg for lt_wr_arg 5366b020570bSmrg do 5367b020570bSmrg case \$lt_wr_arg in 5368b020570bSmrg --lt-*) ;; 5369b020570bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370b020570bSmrg esac 5371b020570bSmrg shift 5372b020570bSmrg done ;; 5373b020570bSmrg esac 537441c30155Smrg func_exec_program_core \${1+\"\$@\"} 537541c30155Smrg} 537641c30155Smrg 537741c30155Smrg # Parse options 537841c30155Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 537923a0898aSmrg 53805a3d36dfSmrg # Find the directory that this script lives in. 538141c30155Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 53825a3d36dfSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 538323a0898aSmrg 53845a3d36dfSmrg # Follow symbolic links until we get to the real thisdir. 538541c30155Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 53865a3d36dfSmrg while test -n \"\$file\"; do 538741c30155Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 538823a0898aSmrg 53895a3d36dfSmrg # If there was a directory component, then change thisdir. 53905a3d36dfSmrg if test \"x\$destdir\" != \"x\$file\"; then 53915a3d36dfSmrg case \"\$destdir\" in 53925a3d36dfSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 53935a3d36dfSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394b3062210Smrg esac 53955a3d36dfSmrg fi 539623a0898aSmrg 539741c30155Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539841c30155Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 53995a3d36dfSmrg done 540023a0898aSmrg 54015a3d36dfSmrg # Usually 'no', except on cygwin/mingw when embedded into 54025a3d36dfSmrg # the cwrapper. 540341c30155Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 54045a3d36dfSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 54055a3d36dfSmrg # special case for '.' 54065a3d36dfSmrg if test \"\$thisdir\" = \".\"; then 54075a3d36dfSmrg thisdir=\`pwd\` 54085a3d36dfSmrg fi 54095a3d36dfSmrg # remove .libs from thisdir 54105a3d36dfSmrg case \"\$thisdir\" in 541141c30155Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 54125a3d36dfSmrg $objdir ) thisdir=. ;; 54135a3d36dfSmrg esac 54145a3d36dfSmrg fi 54155a3d36dfSmrg 54165a3d36dfSmrg # Try to get the absolute directory name. 54175a3d36dfSmrg absdir=\`cd \"\$thisdir\" && pwd\` 54185a3d36dfSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 54195a3d36dfSmrg" 54205a3d36dfSmrg 5421b43acbb4Smrg if test yes = "$fast_install"; then 54225a3d36dfSmrg $ECHO "\ 54235a3d36dfSmrg program=lt-'$outputname'$exeext 54245a3d36dfSmrg progdir=\"\$thisdir/$objdir\" 54255a3d36dfSmrg 54265a3d36dfSmrg if test ! -f \"\$progdir/\$program\" || 5427b43acbb4Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 54285a3d36dfSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 54295a3d36dfSmrg 54305a3d36dfSmrg file=\"\$\$-\$program\" 54315a3d36dfSmrg 54325a3d36dfSmrg if test ! -d \"\$progdir\"; then 54335a3d36dfSmrg $MKDIR \"\$progdir\" 54345a3d36dfSmrg else 54355a3d36dfSmrg $RM \"\$progdir/\$file\" 54365a3d36dfSmrg fi" 54375a3d36dfSmrg 54385a3d36dfSmrg $ECHO "\ 54395a3d36dfSmrg 54405a3d36dfSmrg # relink executable if necessary 54415a3d36dfSmrg if test -n \"\$relink_command\"; then 54425a3d36dfSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 54435a3d36dfSmrg else 5444b43acbb4Smrg \$ECHO \"\$relink_command_output\" >&2 54455a3d36dfSmrg $RM \"\$progdir/\$file\" 54465a3d36dfSmrg exit 1 5447b3062210Smrg fi 54485a3d36dfSmrg fi 544923a0898aSmrg 54505a3d36dfSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 54515a3d36dfSmrg { $RM \"\$progdir/\$program\"; 54525a3d36dfSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 54535a3d36dfSmrg $RM \"\$progdir/\$file\" 54545a3d36dfSmrg fi" 54555a3d36dfSmrg else 54565a3d36dfSmrg $ECHO "\ 54575a3d36dfSmrg program='$outputname' 54585a3d36dfSmrg progdir=\"\$thisdir/$objdir\" 54595a3d36dfSmrg" 5460b3062210Smrg fi 546123a0898aSmrg 54625a3d36dfSmrg $ECHO "\ 546323a0898aSmrg 54645a3d36dfSmrg if test -f \"\$progdir/\$program\"; then" 546523a0898aSmrg 546641c30155Smrg # fixup the dll searchpath if we need to. 546741c30155Smrg # 546841c30155Smrg # Fix the DLL searchpath if we need to. Do this before prepending 546941c30155Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 547041c30155Smrg # libraries must come first. 547141c30155Smrg if test -n "$dllsearchpath"; then 547241c30155Smrg $ECHO "\ 547341c30155Smrg # Add the dll search path components to the executable PATH 547441c30155Smrg PATH=$dllsearchpath:\$PATH 547541c30155Smrg" 547641c30155Smrg fi 547741c30155Smrg 54785a3d36dfSmrg # Export our shlibpath_var if we have one. 5479b43acbb4Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 54805a3d36dfSmrg $ECHO "\ 54815a3d36dfSmrg # Add our own library path to $shlibpath_var 54825a3d36dfSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 548323a0898aSmrg 54845a3d36dfSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 54855a3d36dfSmrg # The second colon is a workaround for a bug in BeOS R4 sed 548641c30155Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 54875a3d36dfSmrg 54885a3d36dfSmrg export $shlibpath_var 54895a3d36dfSmrg" 5490b3062210Smrg fi 549123a0898aSmrg 54925a3d36dfSmrg $ECHO "\ 54935a3d36dfSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 54945a3d36dfSmrg # Run the actual program with our arguments. 549541c30155Smrg func_exec_program \${1+\"\$@\"} 54965a3d36dfSmrg fi 54975a3d36dfSmrg else 54985a3d36dfSmrg # The program doesn't exist. 5499b43acbb4Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 55005a3d36dfSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550141c30155Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 55025a3d36dfSmrg exit 1 55035a3d36dfSmrg fi 55045a3d36dfSmrgfi\ 55055a3d36dfSmrg" 55065a3d36dfSmrg} 550723a0898aSmrg 550823a0898aSmrg 55095a3d36dfSmrg# func_emit_cwrapperexe_src 55105a3d36dfSmrg# emit the source code for a wrapper executable on stdout 55115a3d36dfSmrg# Must ONLY be called from within func_mode_link because 55125a3d36dfSmrg# it depends on a number of variable set therein. 55135a3d36dfSmrgfunc_emit_cwrapperexe_src () 55145a3d36dfSmrg{ 55155a3d36dfSmrg cat <<EOF 551623a0898aSmrg 55175a3d36dfSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518b43acbb4Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 551923a0898aSmrg 55205a3d36dfSmrg The $output program cannot be directly executed until all the libtool 55215a3d36dfSmrg libraries that it depends on are installed. 552223a0898aSmrg 55235a3d36dfSmrg This wrapper executable should never be moved out of the build directory. 55245a3d36dfSmrg If it is, it will not operate correctly. 55255a3d36dfSmrg*/ 55265a3d36dfSmrgEOF 55275a3d36dfSmrg cat <<"EOF" 552841c30155Smrg#ifdef _MSC_VER 552941c30155Smrg# define _CRT_SECURE_NO_DEPRECATE 1 553041c30155Smrg#endif 55315a3d36dfSmrg#include <stdio.h> 55325a3d36dfSmrg#include <stdlib.h> 55335a3d36dfSmrg#ifdef _MSC_VER 55345a3d36dfSmrg# include <direct.h> 55355a3d36dfSmrg# include <process.h> 55365a3d36dfSmrg# include <io.h> 55375a3d36dfSmrg#else 55385a3d36dfSmrg# include <unistd.h> 55395a3d36dfSmrg# include <stdint.h> 55405a3d36dfSmrg# ifdef __CYGWIN__ 55415a3d36dfSmrg# include <io.h> 55425a3d36dfSmrg# endif 55435a3d36dfSmrg#endif 55445a3d36dfSmrg#include <malloc.h> 55455a3d36dfSmrg#include <stdarg.h> 55465a3d36dfSmrg#include <assert.h> 55475a3d36dfSmrg#include <string.h> 55485a3d36dfSmrg#include <ctype.h> 55495a3d36dfSmrg#include <errno.h> 55505a3d36dfSmrg#include <fcntl.h> 55515a3d36dfSmrg#include <sys/stat.h> 55527f7f5e4eSmrg 5553b43acbb4Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554b43acbb4Smrg 555541c30155Smrg/* declarations of non-ANSI functions */ 5556b43acbb4Smrg#if defined __MINGW32__ 555741c30155Smrg# ifdef __STRICT_ANSI__ 555841c30155Smrgint _putenv (const char *); 555941c30155Smrg# endif 5560b43acbb4Smrg#elif defined __CYGWIN__ 556141c30155Smrg# ifdef __STRICT_ANSI__ 556241c30155Smrgchar *realpath (const char *, char *); 556341c30155Smrgint putenv (char *); 556441c30155Smrgint setenv (const char *, const char *, int); 556541c30155Smrg# endif 5566b43acbb4Smrg/* #elif defined other_platform || defined ... */ 556741c30155Smrg#endif 556841c30155Smrg 556941c30155Smrg/* portability defines, excluding path handling macros */ 5570b43acbb4Smrg#if defined _MSC_VER 557141c30155Smrg# define setmode _setmode 557241c30155Smrg# define stat _stat 557341c30155Smrg# define chmod _chmod 557441c30155Smrg# define getcwd _getcwd 557541c30155Smrg# define putenv _putenv 557641c30155Smrg# define S_IXUSR _S_IEXEC 5577b43acbb4Smrg#elif defined __MINGW32__ 557841c30155Smrg# define setmode _setmode 557941c30155Smrg# define stat _stat 558041c30155Smrg# define chmod _chmod 558141c30155Smrg# define getcwd _getcwd 558241c30155Smrg# define putenv _putenv 5583b43acbb4Smrg#elif defined __CYGWIN__ 558441c30155Smrg# define HAVE_SETENV 558541c30155Smrg# define FOPEN_WB "wb" 5586b43acbb4Smrg/* #elif defined other platforms ... */ 558741c30155Smrg#endif 558841c30155Smrg 5589b43acbb4Smrg#if defined PATH_MAX 55905a3d36dfSmrg# define LT_PATHMAX PATH_MAX 5591b43acbb4Smrg#elif defined MAXPATHLEN 55925a3d36dfSmrg# define LT_PATHMAX MAXPATHLEN 55935a3d36dfSmrg#else 55945a3d36dfSmrg# define LT_PATHMAX 1024 55955a3d36dfSmrg#endif 55967f7f5e4eSmrg 55975a3d36dfSmrg#ifndef S_IXOTH 55985a3d36dfSmrg# define S_IXOTH 0 55995a3d36dfSmrg#endif 56005a3d36dfSmrg#ifndef S_IXGRP 56015a3d36dfSmrg# define S_IXGRP 0 56025a3d36dfSmrg#endif 56037f7f5e4eSmrg 560441c30155Smrg/* path handling portability macros */ 56055a3d36dfSmrg#ifndef DIR_SEPARATOR 56065a3d36dfSmrg# define DIR_SEPARATOR '/' 56075a3d36dfSmrg# define PATH_SEPARATOR ':' 56085a3d36dfSmrg#endif 56097f7f5e4eSmrg 5610b43acbb4Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611b43acbb4Smrg defined __OS2__ 56125a3d36dfSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 56135a3d36dfSmrg# define FOPEN_WB "wb" 56145a3d36dfSmrg# ifndef DIR_SEPARATOR_2 56155a3d36dfSmrg# define DIR_SEPARATOR_2 '\\' 56165a3d36dfSmrg# endif 56175a3d36dfSmrg# ifndef PATH_SEPARATOR_2 56185a3d36dfSmrg# define PATH_SEPARATOR_2 ';' 56195a3d36dfSmrg# endif 56205a3d36dfSmrg#endif 56217f7f5e4eSmrg 56225a3d36dfSmrg#ifndef DIR_SEPARATOR_2 56235a3d36dfSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 56245a3d36dfSmrg#else /* DIR_SEPARATOR_2 */ 56255a3d36dfSmrg# define IS_DIR_SEPARATOR(ch) \ 56265a3d36dfSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 56275a3d36dfSmrg#endif /* DIR_SEPARATOR_2 */ 562823a0898aSmrg 56295a3d36dfSmrg#ifndef PATH_SEPARATOR_2 56305a3d36dfSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 56315a3d36dfSmrg#else /* PATH_SEPARATOR_2 */ 56325a3d36dfSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 56335a3d36dfSmrg#endif /* PATH_SEPARATOR_2 */ 563423a0898aSmrg 56355a3d36dfSmrg#ifndef FOPEN_WB 56365a3d36dfSmrg# define FOPEN_WB "w" 56375a3d36dfSmrg#endif 56385a3d36dfSmrg#ifndef _O_BINARY 56395a3d36dfSmrg# define _O_BINARY 0 56405a3d36dfSmrg#endif 564123a0898aSmrg 56425a3d36dfSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 56435a3d36dfSmrg#define XFREE(stale) do { \ 5644b43acbb4Smrg if (stale) { free (stale); stale = 0; } \ 56455a3d36dfSmrg} while (0) 564623a0898aSmrg 5647b43acbb4Smrg#if defined LT_DEBUGWRAPPER 564841c30155Smrgstatic int lt_debug = 1; 56495a3d36dfSmrg#else 565041c30155Smrgstatic int lt_debug = 0; 56515a3d36dfSmrg#endif 565223a0898aSmrg 565341c30155Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565423a0898aSmrg 56555a3d36dfSmrgvoid *xmalloc (size_t num); 56565a3d36dfSmrgchar *xstrdup (const char *string); 56575a3d36dfSmrgconst char *base_name (const char *name); 56585a3d36dfSmrgchar *find_executable (const char *wrapper); 56595a3d36dfSmrgchar *chase_symlinks (const char *pathspec); 56605a3d36dfSmrgint make_executable (const char *path); 56615a3d36dfSmrgint check_executable (const char *path); 56625a3d36dfSmrgchar *strendzap (char *str, const char *pat); 566341c30155Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566441c30155Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566541c30155Smrgstatic const char *nonnull (const char *s); 566641c30155Smrgstatic const char *nonempty (const char *s); 56675a3d36dfSmrgvoid lt_setenv (const char *name, const char *value); 56685a3d36dfSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 56695a3d36dfSmrgvoid lt_update_exe_path (const char *name, const char *value); 56705a3d36dfSmrgvoid lt_update_lib_path (const char *name, const char *value); 567141c30155Smrgchar **prepare_spawn (char **argv); 567241c30155Smrgvoid lt_dump_script (FILE *f); 56735a3d36dfSmrgEOF 56745a3d36dfSmrg 56755a3d36dfSmrg cat <<EOF 5676b43acbb4Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677b43acbb4Smrg# define externally_visible volatile 5678b43acbb4Smrg#else 5679b43acbb4Smrg# define externally_visible __attribute__((externally_visible)) volatile 5680b43acbb4Smrg#endif 5681b43acbb4Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 56825a3d36dfSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 56835a3d36dfSmrgEOF 568423a0898aSmrg 5685b43acbb4Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 568641c30155Smrg func_to_host_path "$temp_rpath" 56875a3d36dfSmrg cat <<EOF 568841c30155Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 56895a3d36dfSmrgEOF 56905a3d36dfSmrg else 56915a3d36dfSmrg cat <<"EOF" 56925a3d36dfSmrgconst char * LIB_PATH_VALUE = ""; 56935a3d36dfSmrgEOF 5694b3062210Smrg fi 569523a0898aSmrg 56965a3d36dfSmrg if test -n "$dllsearchpath"; then 569741c30155Smrg func_to_host_path "$dllsearchpath:" 56985a3d36dfSmrg cat <<EOF 56995a3d36dfSmrgconst char * EXE_PATH_VARNAME = "PATH"; 570041c30155Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701b3062210SmrgEOF 5702b3062210Smrg else 57035a3d36dfSmrg cat <<"EOF" 57045a3d36dfSmrgconst char * EXE_PATH_VARNAME = ""; 57055a3d36dfSmrgconst char * EXE_PATH_VALUE = ""; 57065a3d36dfSmrgEOF 5707b3062210Smrg fi 57085a3d36dfSmrg 5709b43acbb4Smrg if test yes = "$fast_install"; then 57105a3d36dfSmrg cat <<EOF 57115a3d36dfSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 57125a3d36dfSmrgEOF 5713b3062210Smrg else 57145a3d36dfSmrg cat <<EOF 57155a3d36dfSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 57165a3d36dfSmrgEOF 5717b3062210Smrg fi 571823a0898aSmrg 571923a0898aSmrg 57205a3d36dfSmrg cat <<"EOF" 572123a0898aSmrg 57225a3d36dfSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 572323a0898aSmrg 57245a3d36dfSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 57255a3d36dfSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572641c30155Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 572723a0898aSmrg 57285a3d36dfSmrgint 57295a3d36dfSmrgmain (int argc, char *argv[]) 57305a3d36dfSmrg{ 57315a3d36dfSmrg char **newargz; 57325a3d36dfSmrg int newargc; 57335a3d36dfSmrg char *tmp_pathspec; 57345a3d36dfSmrg char *actual_cwrapper_path; 57355a3d36dfSmrg char *actual_cwrapper_name; 57365a3d36dfSmrg char *target_name; 57375a3d36dfSmrg char *lt_argv_zero; 5738b43acbb4Smrg int rval = 127; 573923a0898aSmrg 57405a3d36dfSmrg int i; 574123a0898aSmrg 57425a3d36dfSmrg program_name = (char *) xstrdup (base_name (argv[0])); 5743b43acbb4Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 574423a0898aSmrg 574541c30155Smrg /* very simple arg parsing; don't want to rely on getopt 574641c30155Smrg * also, copy all non cwrapper options to newargz, except 574741c30155Smrg * argz[0], which is handled differently 574841c30155Smrg */ 574941c30155Smrg newargc=0; 57505a3d36dfSmrg for (i = 1; i < argc; i++) 57515a3d36dfSmrg { 5752b43acbb4Smrg if (STREQ (argv[i], dumpscript_opt)) 57535a3d36dfSmrg { 57545a3d36dfSmrgEOF 5755b43acbb4Smrg case $host in 57565a3d36dfSmrg *mingw* | *cygwin* ) 57575a3d36dfSmrg # make stdout use "unix" line endings 57585a3d36dfSmrg echo " setmode(1,_O_BINARY);" 57595a3d36dfSmrg ;; 57605a3d36dfSmrg esac 576123a0898aSmrg 57625a3d36dfSmrg cat <<"EOF" 576341c30155Smrg lt_dump_script (stdout); 57645a3d36dfSmrg return 0; 57655a3d36dfSmrg } 5766b43acbb4Smrg if (STREQ (argv[i], debug_opt)) 576741c30155Smrg { 576841c30155Smrg lt_debug = 1; 576941c30155Smrg continue; 577041c30155Smrg } 5771b43acbb4Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577241c30155Smrg { 577341c30155Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577441c30155Smrg namespace, but it is not one of the ones we know about and 577541c30155Smrg have already dealt with, above (inluding dump-script), then 577641c30155Smrg report an error. Otherwise, targets might begin to believe 577741c30155Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577841c30155Smrg namespace. The first time any user complains about this, we'll 577941c30155Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578041c30155Smrg or a configure.ac-settable value. 578141c30155Smrg */ 578241c30155Smrg lt_fatal (__FILE__, __LINE__, 578341c30155Smrg "unrecognized %s option: '%s'", 578441c30155Smrg ltwrapper_option_prefix, argv[i]); 578541c30155Smrg } 578641c30155Smrg /* otherwise ... */ 578741c30155Smrg newargz[++newargc] = xstrdup (argv[i]); 57885a3d36dfSmrg } 578941c30155Smrg newargz[++newargc] = NULL; 579041c30155Smrg 579141c30155SmrgEOF 579241c30155Smrg cat <<EOF 579341c30155Smrg /* The GNU banner must be the first non-error debug message */ 5794b43acbb4Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579541c30155SmrgEOF 579641c30155Smrg cat <<"EOF" 579741c30155Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579841c30155Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 579923a0898aSmrg 58005a3d36dfSmrg tmp_pathspec = find_executable (argv[0]); 58015a3d36dfSmrg if (tmp_pathspec == NULL) 580241c30155Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580341c30155Smrg lt_debugprintf (__FILE__, __LINE__, 580441c30155Smrg "(main) found exe (before symlink chase) at: %s\n", 580541c30155Smrg tmp_pathspec); 58065a3d36dfSmrg 58075a3d36dfSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580841c30155Smrg lt_debugprintf (__FILE__, __LINE__, 580941c30155Smrg "(main) found exe (after symlink chase) at: %s\n", 581041c30155Smrg actual_cwrapper_path); 58115a3d36dfSmrg XFREE (tmp_pathspec); 58125a3d36dfSmrg 581341c30155Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 58145a3d36dfSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 58155a3d36dfSmrg 58165a3d36dfSmrg /* wrapper name transforms */ 58175a3d36dfSmrg strendzap (actual_cwrapper_name, ".exe"); 58185a3d36dfSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 58195a3d36dfSmrg XFREE (actual_cwrapper_name); 58205a3d36dfSmrg actual_cwrapper_name = tmp_pathspec; 58215a3d36dfSmrg tmp_pathspec = 0; 58225a3d36dfSmrg 58235a3d36dfSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 58245a3d36dfSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 58255a3d36dfSmrg strendzap (target_name, ".exe"); 58265a3d36dfSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 58275a3d36dfSmrg XFREE (target_name); 58285a3d36dfSmrg target_name = tmp_pathspec; 58295a3d36dfSmrg tmp_pathspec = 0; 58305a3d36dfSmrg 583141c30155Smrg lt_debugprintf (__FILE__, __LINE__, 583241c30155Smrg "(main) libtool target name: %s\n", 583341c30155Smrg target_name); 58345a3d36dfSmrgEOF 583523a0898aSmrg 58365a3d36dfSmrg cat <<EOF 58375a3d36dfSmrg newargz[0] = 58385a3d36dfSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 58395a3d36dfSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 58405a3d36dfSmrg strcpy (newargz[0], actual_cwrapper_path); 58415a3d36dfSmrg strcat (newargz[0], "$objdir"); 58425a3d36dfSmrg strcat (newargz[0], "/"); 58435a3d36dfSmrgEOF 584423a0898aSmrg 58455a3d36dfSmrg cat <<"EOF" 58465a3d36dfSmrg /* stop here, and copy so we don't have to do this twice */ 58475a3d36dfSmrg tmp_pathspec = xstrdup (newargz[0]); 584823a0898aSmrg 58495a3d36dfSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 58505a3d36dfSmrg strcat (newargz[0], actual_cwrapper_name); 585123a0898aSmrg 58525a3d36dfSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 58535a3d36dfSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 58545a3d36dfSmrg XFREE (tmp_pathspec); 58555a3d36dfSmrg tmp_pathspec = NULL; 58565a3d36dfSmrgEOF 585723a0898aSmrg 58585a3d36dfSmrg case $host_os in 58595a3d36dfSmrg mingw*) 58605a3d36dfSmrg cat <<"EOF" 58615a3d36dfSmrg { 58625a3d36dfSmrg char* p; 58635a3d36dfSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 58645a3d36dfSmrg { 58655a3d36dfSmrg *p = '/'; 58665a3d36dfSmrg } 58675a3d36dfSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 58685a3d36dfSmrg { 58695a3d36dfSmrg *p = '/'; 58705a3d36dfSmrg } 58715a3d36dfSmrg } 58725a3d36dfSmrgEOF 58735a3d36dfSmrg ;; 58745a3d36dfSmrg esac 587523a0898aSmrg 58765a3d36dfSmrg cat <<"EOF" 58775a3d36dfSmrg XFREE (target_name); 58785a3d36dfSmrg XFREE (actual_cwrapper_path); 58795a3d36dfSmrg XFREE (actual_cwrapper_name); 588023a0898aSmrg 58815a3d36dfSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 58825a3d36dfSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 588341c30155Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 588441c30155Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 588541c30155Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 588641c30155Smrg libraries must come first. */ 58875a3d36dfSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 588841c30155Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 588923a0898aSmrg 589041c30155Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589141c30155Smrg nonnull (lt_argv_zero)); 58925a3d36dfSmrg for (i = 0; i < newargc; i++) 58935a3d36dfSmrg { 589441c30155Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589541c30155Smrg i, nonnull (newargz[i])); 58965a3d36dfSmrg } 589723a0898aSmrg 58985a3d36dfSmrgEOF 589923a0898aSmrg 59005a3d36dfSmrg case $host_os in 59015a3d36dfSmrg mingw*) 59025a3d36dfSmrg cat <<"EOF" 59035a3d36dfSmrg /* execv doesn't actually work on mingw as expected on unix */ 590441c30155Smrg newargz = prepare_spawn (newargz); 5905b43acbb4Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 59065a3d36dfSmrg if (rval == -1) 59075a3d36dfSmrg { 59085a3d36dfSmrg /* failed to start process */ 590941c30155Smrg lt_debugprintf (__FILE__, __LINE__, 591041c30155Smrg "(main) failed to launch target \"%s\": %s\n", 591141c30155Smrg lt_argv_zero, nonnull (strerror (errno))); 59125a3d36dfSmrg return 127; 59135a3d36dfSmrg } 59145a3d36dfSmrg return rval; 59155a3d36dfSmrgEOF 59165a3d36dfSmrg ;; 59175a3d36dfSmrg *) 59185a3d36dfSmrg cat <<"EOF" 59195a3d36dfSmrg execv (lt_argv_zero, newargz); 59205a3d36dfSmrg return rval; /* =127, but avoids unused variable warning */ 59215a3d36dfSmrgEOF 59225a3d36dfSmrg ;; 59235a3d36dfSmrg esac 592423a0898aSmrg 59255a3d36dfSmrg cat <<"EOF" 59265a3d36dfSmrg} 592723a0898aSmrg 59285a3d36dfSmrgvoid * 59295a3d36dfSmrgxmalloc (size_t num) 59305a3d36dfSmrg{ 59315a3d36dfSmrg void *p = (void *) malloc (num); 59325a3d36dfSmrg if (!p) 593341c30155Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 593423a0898aSmrg 59355a3d36dfSmrg return p; 59365a3d36dfSmrg} 593723a0898aSmrg 59385a3d36dfSmrgchar * 59395a3d36dfSmrgxstrdup (const char *string) 59405a3d36dfSmrg{ 59415a3d36dfSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 59425a3d36dfSmrg string) : NULL; 59435a3d36dfSmrg} 594423a0898aSmrg 59455a3d36dfSmrgconst char * 59465a3d36dfSmrgbase_name (const char *name) 59475a3d36dfSmrg{ 59485a3d36dfSmrg const char *base; 5949b3062210Smrg 5950b43acbb4Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 59515a3d36dfSmrg /* Skip over the disk name in MSDOS pathnames. */ 59525a3d36dfSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 59535a3d36dfSmrg name += 2; 59545a3d36dfSmrg#endif 5955b3062210Smrg 59565a3d36dfSmrg for (base = name; *name; name++) 59575a3d36dfSmrg if (IS_DIR_SEPARATOR (*name)) 59585a3d36dfSmrg base = name + 1; 59595a3d36dfSmrg return base; 59605a3d36dfSmrg} 5961b3062210Smrg 59625a3d36dfSmrgint 59635a3d36dfSmrgcheck_executable (const char *path) 59645a3d36dfSmrg{ 59655a3d36dfSmrg struct stat st; 5966b3062210Smrg 596741c30155Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596841c30155Smrg nonempty (path)); 59695a3d36dfSmrg if ((!path) || (!*path)) 59705a3d36dfSmrg return 0; 5971b3062210Smrg 59725a3d36dfSmrg if ((stat (path, &st) >= 0) 59735a3d36dfSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 59745a3d36dfSmrg return 1; 59755a3d36dfSmrg else 59765a3d36dfSmrg return 0; 59775a3d36dfSmrg} 597823a0898aSmrg 59795a3d36dfSmrgint 59805a3d36dfSmrgmake_executable (const char *path) 59815a3d36dfSmrg{ 59825a3d36dfSmrg int rval = 0; 59835a3d36dfSmrg struct stat st; 598423a0898aSmrg 598541c30155Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598641c30155Smrg nonempty (path)); 59875a3d36dfSmrg if ((!path) || (!*path)) 59885a3d36dfSmrg return 0; 598923a0898aSmrg 59905a3d36dfSmrg if (stat (path, &st) >= 0) 59915a3d36dfSmrg { 59925a3d36dfSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 59935a3d36dfSmrg } 59945a3d36dfSmrg return rval; 59955a3d36dfSmrg} 5996b3062210Smrg 59975a3d36dfSmrg/* Searches for the full path of the wrapper. Returns 59985a3d36dfSmrg newly allocated full path name if found, NULL otherwise 59995a3d36dfSmrg Does not chase symlinks, even on platforms that support them. 60005a3d36dfSmrg*/ 60015a3d36dfSmrgchar * 60025a3d36dfSmrgfind_executable (const char *wrapper) 60035a3d36dfSmrg{ 60045a3d36dfSmrg int has_slash = 0; 60055a3d36dfSmrg const char *p; 60065a3d36dfSmrg const char *p_next; 60075a3d36dfSmrg /* static buffer for getcwd */ 60085a3d36dfSmrg char tmp[LT_PATHMAX + 1]; 6009b43acbb4Smrg size_t tmp_len; 60105a3d36dfSmrg char *concat_name; 6011b3062210Smrg 601241c30155Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601341c30155Smrg nonempty (wrapper)); 6014b3062210Smrg 60155a3d36dfSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 60165a3d36dfSmrg return NULL; 6017b3062210Smrg 60185a3d36dfSmrg /* Absolute path? */ 6019b43acbb4Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60205a3d36dfSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 60215a3d36dfSmrg { 60225a3d36dfSmrg concat_name = xstrdup (wrapper); 60235a3d36dfSmrg if (check_executable (concat_name)) 60245a3d36dfSmrg return concat_name; 60255a3d36dfSmrg XFREE (concat_name); 60265a3d36dfSmrg } 60275a3d36dfSmrg else 60285a3d36dfSmrg { 60295a3d36dfSmrg#endif 60305a3d36dfSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 60315a3d36dfSmrg { 60325a3d36dfSmrg concat_name = xstrdup (wrapper); 60335a3d36dfSmrg if (check_executable (concat_name)) 60345a3d36dfSmrg return concat_name; 60355a3d36dfSmrg XFREE (concat_name); 60365a3d36dfSmrg } 6037b43acbb4Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60385a3d36dfSmrg } 60395a3d36dfSmrg#endif 604023a0898aSmrg 60415a3d36dfSmrg for (p = wrapper; *p; p++) 60425a3d36dfSmrg if (*p == '/') 60435a3d36dfSmrg { 60445a3d36dfSmrg has_slash = 1; 60455a3d36dfSmrg break; 60465a3d36dfSmrg } 60475a3d36dfSmrg if (!has_slash) 60485a3d36dfSmrg { 60495a3d36dfSmrg /* no slashes; search PATH */ 60505a3d36dfSmrg const char *path = getenv ("PATH"); 60515a3d36dfSmrg if (path != NULL) 60525a3d36dfSmrg { 60535a3d36dfSmrg for (p = path; *p; p = p_next) 60545a3d36dfSmrg { 60555a3d36dfSmrg const char *q; 60565a3d36dfSmrg size_t p_len; 60575a3d36dfSmrg for (q = p; *q; q++) 60585a3d36dfSmrg if (IS_PATH_SEPARATOR (*q)) 60595a3d36dfSmrg break; 6060b43acbb4Smrg p_len = (size_t) (q - p); 60615a3d36dfSmrg p_next = (*q == '\0' ? q : q + 1); 60625a3d36dfSmrg if (p_len == 0) 60635a3d36dfSmrg { 60645a3d36dfSmrg /* empty path: current directory */ 60655a3d36dfSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606641c30155Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606741c30155Smrg nonnull (strerror (errno))); 60685a3d36dfSmrg tmp_len = strlen (tmp); 60695a3d36dfSmrg concat_name = 60705a3d36dfSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60715a3d36dfSmrg memcpy (concat_name, tmp, tmp_len); 60725a3d36dfSmrg concat_name[tmp_len] = '/'; 60735a3d36dfSmrg strcpy (concat_name + tmp_len + 1, wrapper); 60745a3d36dfSmrg } 60755a3d36dfSmrg else 60765a3d36dfSmrg { 60775a3d36dfSmrg concat_name = 60785a3d36dfSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 60795a3d36dfSmrg memcpy (concat_name, p, p_len); 60805a3d36dfSmrg concat_name[p_len] = '/'; 60815a3d36dfSmrg strcpy (concat_name + p_len + 1, wrapper); 60825a3d36dfSmrg } 60835a3d36dfSmrg if (check_executable (concat_name)) 60845a3d36dfSmrg return concat_name; 60855a3d36dfSmrg XFREE (concat_name); 60865a3d36dfSmrg } 60875a3d36dfSmrg } 60885a3d36dfSmrg /* not found in PATH; assume curdir */ 60895a3d36dfSmrg } 60905a3d36dfSmrg /* Relative path | not found in path: prepend cwd */ 60915a3d36dfSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609241c30155Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609341c30155Smrg nonnull (strerror (errno))); 60945a3d36dfSmrg tmp_len = strlen (tmp); 60955a3d36dfSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60965a3d36dfSmrg memcpy (concat_name, tmp, tmp_len); 60975a3d36dfSmrg concat_name[tmp_len] = '/'; 60985a3d36dfSmrg strcpy (concat_name + tmp_len + 1, wrapper); 609923a0898aSmrg 61005a3d36dfSmrg if (check_executable (concat_name)) 61015a3d36dfSmrg return concat_name; 61025a3d36dfSmrg XFREE (concat_name); 61035a3d36dfSmrg return NULL; 61045a3d36dfSmrg} 610523a0898aSmrg 61065a3d36dfSmrgchar * 61075a3d36dfSmrgchase_symlinks (const char *pathspec) 61085a3d36dfSmrg{ 61095a3d36dfSmrg#ifndef S_ISLNK 61105a3d36dfSmrg return xstrdup (pathspec); 61115a3d36dfSmrg#else 61125a3d36dfSmrg char buf[LT_PATHMAX]; 61135a3d36dfSmrg struct stat s; 61145a3d36dfSmrg char *tmp_pathspec = xstrdup (pathspec); 61155a3d36dfSmrg char *p; 61165a3d36dfSmrg int has_symlinks = 0; 61175a3d36dfSmrg while (strlen (tmp_pathspec) && !has_symlinks) 61185a3d36dfSmrg { 611941c30155Smrg lt_debugprintf (__FILE__, __LINE__, 612041c30155Smrg "checking path component for symlinks: %s\n", 612141c30155Smrg tmp_pathspec); 61225a3d36dfSmrg if (lstat (tmp_pathspec, &s) == 0) 61235a3d36dfSmrg { 61245a3d36dfSmrg if (S_ISLNK (s.st_mode) != 0) 61255a3d36dfSmrg { 61265a3d36dfSmrg has_symlinks = 1; 61275a3d36dfSmrg break; 61285a3d36dfSmrg } 612923a0898aSmrg 61305a3d36dfSmrg /* search backwards for last DIR_SEPARATOR */ 61315a3d36dfSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 61325a3d36dfSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61335a3d36dfSmrg p--; 61345a3d36dfSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61355a3d36dfSmrg { 61365a3d36dfSmrg /* no more DIR_SEPARATORS left */ 61375a3d36dfSmrg break; 61385a3d36dfSmrg } 61395a3d36dfSmrg *p = '\0'; 61405a3d36dfSmrg } 61415a3d36dfSmrg else 61425a3d36dfSmrg { 614341c30155Smrg lt_fatal (__FILE__, __LINE__, 614441c30155Smrg "error accessing file \"%s\": %s", 614541c30155Smrg tmp_pathspec, nonnull (strerror (errno))); 61465a3d36dfSmrg } 61475a3d36dfSmrg } 61485a3d36dfSmrg XFREE (tmp_pathspec); 614923a0898aSmrg 61505a3d36dfSmrg if (!has_symlinks) 61515a3d36dfSmrg { 61525a3d36dfSmrg return xstrdup (pathspec); 61535a3d36dfSmrg } 615423a0898aSmrg 61555a3d36dfSmrg tmp_pathspec = realpath (pathspec, buf); 61565a3d36dfSmrg if (tmp_pathspec == 0) 61575a3d36dfSmrg { 615841c30155Smrg lt_fatal (__FILE__, __LINE__, 615941c30155Smrg "could not follow symlinks for %s", pathspec); 61605a3d36dfSmrg } 61615a3d36dfSmrg return xstrdup (tmp_pathspec); 61625a3d36dfSmrg#endif 61635a3d36dfSmrg} 616423a0898aSmrg 61655a3d36dfSmrgchar * 61665a3d36dfSmrgstrendzap (char *str, const char *pat) 61675a3d36dfSmrg{ 61685a3d36dfSmrg size_t len, patlen; 616923a0898aSmrg 61705a3d36dfSmrg assert (str != NULL); 61715a3d36dfSmrg assert (pat != NULL); 617223a0898aSmrg 61735a3d36dfSmrg len = strlen (str); 61745a3d36dfSmrg patlen = strlen (pat); 617523a0898aSmrg 61765a3d36dfSmrg if (patlen <= len) 61775a3d36dfSmrg { 61785a3d36dfSmrg str += len - patlen; 6179b43acbb4Smrg if (STREQ (str, pat)) 61805a3d36dfSmrg *str = '\0'; 61815a3d36dfSmrg } 61825a3d36dfSmrg return str; 61835a3d36dfSmrg} 618423a0898aSmrg 618541c30155Smrgvoid 618641c30155Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618741c30155Smrg{ 618841c30155Smrg va_list args; 618941c30155Smrg if (lt_debug) 619041c30155Smrg { 619141c30155Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619241c30155Smrg va_start (args, fmt); 619341c30155Smrg (void) vfprintf (stderr, fmt, args); 619441c30155Smrg va_end (args); 619541c30155Smrg } 619641c30155Smrg} 619741c30155Smrg 61985a3d36dfSmrgstatic void 619941c30155Smrglt_error_core (int exit_status, const char *file, 620041c30155Smrg int line, const char *mode, 62015a3d36dfSmrg const char *message, va_list ap) 62025a3d36dfSmrg{ 620341c30155Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 62045a3d36dfSmrg vfprintf (stderr, message, ap); 62055a3d36dfSmrg fprintf (stderr, ".\n"); 620623a0898aSmrg 62075a3d36dfSmrg if (exit_status >= 0) 62085a3d36dfSmrg exit (exit_status); 62095a3d36dfSmrg} 621023a0898aSmrg 62115a3d36dfSmrgvoid 621241c30155Smrglt_fatal (const char *file, int line, const char *message, ...) 62135a3d36dfSmrg{ 62145a3d36dfSmrg va_list ap; 62155a3d36dfSmrg va_start (ap, message); 621641c30155Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 62175a3d36dfSmrg va_end (ap); 62185a3d36dfSmrg} 621923a0898aSmrg 622041c30155Smrgstatic const char * 622141c30155Smrgnonnull (const char *s) 622241c30155Smrg{ 622341c30155Smrg return s ? s : "(null)"; 622441c30155Smrg} 622541c30155Smrg 622641c30155Smrgstatic const char * 622741c30155Smrgnonempty (const char *s) 622841c30155Smrg{ 622941c30155Smrg return (s && !*s) ? "(empty)" : nonnull (s); 623041c30155Smrg} 623141c30155Smrg 62325a3d36dfSmrgvoid 62335a3d36dfSmrglt_setenv (const char *name, const char *value) 62345a3d36dfSmrg{ 623541c30155Smrg lt_debugprintf (__FILE__, __LINE__, 623641c30155Smrg "(lt_setenv) setting '%s' to '%s'\n", 623741c30155Smrg nonnull (name), nonnull (value)); 62385a3d36dfSmrg { 62395a3d36dfSmrg#ifdef HAVE_SETENV 62405a3d36dfSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 62415a3d36dfSmrg char *str = xstrdup (value); 62425a3d36dfSmrg setenv (name, str, 1); 62435a3d36dfSmrg#else 6244b43acbb4Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 62455a3d36dfSmrg char *str = XMALLOC (char, len); 62465a3d36dfSmrg sprintf (str, "%s=%s", name, value); 62475a3d36dfSmrg if (putenv (str) != EXIT_SUCCESS) 62485a3d36dfSmrg { 62495a3d36dfSmrg XFREE (str); 62505a3d36dfSmrg } 62515a3d36dfSmrg#endif 62525a3d36dfSmrg } 62535a3d36dfSmrg} 625423a0898aSmrg 62555a3d36dfSmrgchar * 62565a3d36dfSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 62575a3d36dfSmrg{ 62585a3d36dfSmrg char *new_value; 62595a3d36dfSmrg if (orig_value && *orig_value) 62605a3d36dfSmrg { 6261b43acbb4Smrg size_t orig_value_len = strlen (orig_value); 6262b43acbb4Smrg size_t add_len = strlen (add); 62635a3d36dfSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 62645a3d36dfSmrg if (to_end) 62655a3d36dfSmrg { 62665a3d36dfSmrg strcpy (new_value, orig_value); 62675a3d36dfSmrg strcpy (new_value + orig_value_len, add); 62685a3d36dfSmrg } 62695a3d36dfSmrg else 62705a3d36dfSmrg { 62715a3d36dfSmrg strcpy (new_value, add); 62725a3d36dfSmrg strcpy (new_value + add_len, orig_value); 62735a3d36dfSmrg } 62745a3d36dfSmrg } 62755a3d36dfSmrg else 62765a3d36dfSmrg { 62775a3d36dfSmrg new_value = xstrdup (add); 62785a3d36dfSmrg } 62795a3d36dfSmrg return new_value; 62805a3d36dfSmrg} 628123a0898aSmrg 62825a3d36dfSmrgvoid 62835a3d36dfSmrglt_update_exe_path (const char *name, const char *value) 62845a3d36dfSmrg{ 628541c30155Smrg lt_debugprintf (__FILE__, __LINE__, 628641c30155Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628741c30155Smrg nonnull (name), nonnull (value)); 628823a0898aSmrg 62895a3d36dfSmrg if (name && *name && value && *value) 62905a3d36dfSmrg { 62915a3d36dfSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 62925a3d36dfSmrg /* some systems can't cope with a ':'-terminated path #' */ 6293b43acbb4Smrg size_t len = strlen (new_value); 6294b43acbb4Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 62955a3d36dfSmrg { 6296b43acbb4Smrg new_value[--len] = '\0'; 62975a3d36dfSmrg } 62985a3d36dfSmrg lt_setenv (name, new_value); 62995a3d36dfSmrg XFREE (new_value); 63005a3d36dfSmrg } 63015a3d36dfSmrg} 630223a0898aSmrg 63035a3d36dfSmrgvoid 63045a3d36dfSmrglt_update_lib_path (const char *name, const char *value) 63055a3d36dfSmrg{ 630641c30155Smrg lt_debugprintf (__FILE__, __LINE__, 630741c30155Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630841c30155Smrg nonnull (name), nonnull (value)); 630923a0898aSmrg 63105a3d36dfSmrg if (name && *name && value && *value) 63115a3d36dfSmrg { 63125a3d36dfSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 63135a3d36dfSmrg lt_setenv (name, new_value); 63145a3d36dfSmrg XFREE (new_value); 63155a3d36dfSmrg } 63165a3d36dfSmrg} 631723a0898aSmrg 631841c30155SmrgEOF 631941c30155Smrg case $host_os in 632041c30155Smrg mingw*) 632141c30155Smrg cat <<"EOF" 632241c30155Smrg 632341c30155Smrg/* Prepares an argument vector before calling spawn(). 632441c30155Smrg Note that spawn() does not by itself call the command interpreter 632541c30155Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632641c30155Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632741c30155Smrg GetVersionEx(&v); 632841c30155Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632941c30155Smrg }) ? "cmd.exe" : "command.com"). 633041c30155Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 633141c30155Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633241c30155Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633341c30155Smrg special way: 633441c30155Smrg - Space and tab are interpreted as delimiters. They are not treated as 633541c30155Smrg delimiters if they are surrounded by double quotes: "...". 633641c30155Smrg - Unescaped double quotes are removed from the input. Their only effect is 633741c30155Smrg that within double quotes, space and tab are treated like normal 633841c30155Smrg characters. 633941c30155Smrg - Backslashes not followed by double quotes are not special. 634041c30155Smrg - But 2*n+1 backslashes followed by a double quote become 634141c30155Smrg n backslashes followed by a double quote (n >= 0): 634241c30155Smrg \" -> " 634341c30155Smrg \\\" -> \" 634441c30155Smrg \\\\\" -> \\" 634541c30155Smrg */ 634641c30155Smrg#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" 634741c30155Smrg#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" 634841c30155Smrgchar ** 634941c30155Smrgprepare_spawn (char **argv) 635041c30155Smrg{ 635141c30155Smrg size_t argc; 635241c30155Smrg char **new_argv; 635341c30155Smrg size_t i; 635441c30155Smrg 635541c30155Smrg /* Count number of arguments. */ 635641c30155Smrg for (argc = 0; argv[argc] != NULL; argc++) 635741c30155Smrg ; 635841c30155Smrg 635941c30155Smrg /* Allocate new argument vector. */ 636041c30155Smrg new_argv = XMALLOC (char *, argc + 1); 636141c30155Smrg 636241c30155Smrg /* Put quoted arguments into the new argument vector. */ 636341c30155Smrg for (i = 0; i < argc; i++) 636441c30155Smrg { 636541c30155Smrg const char *string = argv[i]; 636641c30155Smrg 636741c30155Smrg if (string[0] == '\0') 636841c30155Smrg new_argv[i] = xstrdup ("\"\""); 636941c30155Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637041c30155Smrg { 637141c30155Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637241c30155Smrg size_t length; 637341c30155Smrg unsigned int backslashes; 637441c30155Smrg const char *s; 637541c30155Smrg char *quoted_string; 637641c30155Smrg char *p; 637741c30155Smrg 637841c30155Smrg length = 0; 637941c30155Smrg backslashes = 0; 638041c30155Smrg if (quote_around) 638141c30155Smrg length++; 638241c30155Smrg for (s = string; *s != '\0'; s++) 638341c30155Smrg { 638441c30155Smrg char c = *s; 638541c30155Smrg if (c == '"') 638641c30155Smrg length += backslashes + 1; 638741c30155Smrg length++; 638841c30155Smrg if (c == '\\') 638941c30155Smrg backslashes++; 639041c30155Smrg else 639141c30155Smrg backslashes = 0; 639241c30155Smrg } 639341c30155Smrg if (quote_around) 639441c30155Smrg length += backslashes + 1; 639541c30155Smrg 639641c30155Smrg quoted_string = XMALLOC (char, length + 1); 639741c30155Smrg 639841c30155Smrg p = quoted_string; 639941c30155Smrg backslashes = 0; 640041c30155Smrg if (quote_around) 640141c30155Smrg *p++ = '"'; 640241c30155Smrg for (s = string; *s != '\0'; s++) 640341c30155Smrg { 640441c30155Smrg char c = *s; 640541c30155Smrg if (c == '"') 640641c30155Smrg { 640741c30155Smrg unsigned int j; 640841c30155Smrg for (j = backslashes + 1; j > 0; j--) 640941c30155Smrg *p++ = '\\'; 641041c30155Smrg } 641141c30155Smrg *p++ = c; 641241c30155Smrg if (c == '\\') 641341c30155Smrg backslashes++; 641441c30155Smrg else 641541c30155Smrg backslashes = 0; 641641c30155Smrg } 641741c30155Smrg if (quote_around) 641841c30155Smrg { 641941c30155Smrg unsigned int j; 642041c30155Smrg for (j = backslashes; j > 0; j--) 642141c30155Smrg *p++ = '\\'; 642241c30155Smrg *p++ = '"'; 642341c30155Smrg } 642441c30155Smrg *p = '\0'; 642541c30155Smrg 642641c30155Smrg new_argv[i] = quoted_string; 642741c30155Smrg } 642841c30155Smrg else 642941c30155Smrg new_argv[i] = (char *) string; 643041c30155Smrg } 643141c30155Smrg new_argv[argc] = NULL; 643241c30155Smrg 643341c30155Smrg return new_argv; 643441c30155Smrg} 643541c30155SmrgEOF 643641c30155Smrg ;; 643741c30155Smrg esac 643841c30155Smrg 643941c30155Smrg cat <<"EOF" 644041c30155Smrgvoid lt_dump_script (FILE* f) 644141c30155Smrg{ 644241c30155SmrgEOF 644341c30155Smrg func_emit_wrapper yes | 6444b020570bSmrg $SED -n -e ' 6445b020570bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6446b020570bSmrg\2/ 6447b020570bSmrgh 6448b020570bSmrgs/\([\\"]\)/\\\1/g 6449b020570bSmrgs/$/\\n/ 6450b020570bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451b020570bSmrgg 6452b020570bSmrgD' 645341c30155Smrg cat <<"EOF" 645441c30155Smrg} 64555a3d36dfSmrgEOF 64565a3d36dfSmrg} 64575a3d36dfSmrg# end: func_emit_cwrapperexe_src 645823a0898aSmrg 645941c30155Smrg# func_win32_import_lib_p ARG 646041c30155Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646141c30155Smrgfunc_win32_import_lib_p () 646241c30155Smrg{ 6463b43acbb4Smrg $debug_cmd 6464b43acbb4Smrg 646541c30155Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646641c30155Smrg *import*) : ;; 646741c30155Smrg *) false ;; 646841c30155Smrg esac 646941c30155Smrg} 647041c30155Smrg 6471b43acbb4Smrg# func_suncc_cstd_abi 6472b43acbb4Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473b43acbb4Smrg# Several compiler flags select an ABI that is incompatible with the 6474b43acbb4Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475b43acbb4Smrgfunc_suncc_cstd_abi () 6476b43acbb4Smrg{ 6477b43acbb4Smrg $debug_cmd 6478b43acbb4Smrg 6479b43acbb4Smrg case " $compile_command " in 6480b43acbb4Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481b43acbb4Smrg suncc_use_cstd_abi=no 6482b43acbb4Smrg ;; 6483b43acbb4Smrg *) 6484b43acbb4Smrg suncc_use_cstd_abi=yes 6485b43acbb4Smrg ;; 6486b43acbb4Smrg esac 6487b43acbb4Smrg} 6488b43acbb4Smrg 64895a3d36dfSmrg# func_mode_link arg... 64905a3d36dfSmrgfunc_mode_link () 64915a3d36dfSmrg{ 6492b43acbb4Smrg $debug_cmd 6493b43acbb4Smrg 64945a3d36dfSmrg case $host in 64955a3d36dfSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 64965a3d36dfSmrg # It is impossible to link a dll without this setting, and 64975a3d36dfSmrg # we shouldn't force the makefile maintainer to figure out 6498b43acbb4Smrg # what system we are compiling for in order to pass an extra 64995a3d36dfSmrg # flag for every libtool invocation. 65005a3d36dfSmrg # allow_undefined=no 650123a0898aSmrg 65025a3d36dfSmrg # FIXME: Unfortunately, there are problems with the above when trying 6503b43acbb4Smrg # to make a dll that has undefined symbols, in which case not 65045a3d36dfSmrg # even a static library is built. For now, we need to specify 65055a3d36dfSmrg # -no-undefined on the libtool link line when we can be certain 65065a3d36dfSmrg # that all symbols are satisfied, otherwise we get a static library. 65075a3d36dfSmrg allow_undefined=yes 65085a3d36dfSmrg ;; 65095a3d36dfSmrg *) 65105a3d36dfSmrg allow_undefined=yes 65115a3d36dfSmrg ;; 65125a3d36dfSmrg esac 65135a3d36dfSmrg libtool_args=$nonopt 65145a3d36dfSmrg base_compile="$nonopt $@" 65155a3d36dfSmrg compile_command=$nonopt 65165a3d36dfSmrg finalize_command=$nonopt 651723a0898aSmrg 65185a3d36dfSmrg compile_rpath= 65195a3d36dfSmrg finalize_rpath= 65205a3d36dfSmrg compile_shlibpath= 65215a3d36dfSmrg finalize_shlibpath= 65225a3d36dfSmrg convenience= 65235a3d36dfSmrg old_convenience= 65245a3d36dfSmrg deplibs= 65255a3d36dfSmrg old_deplibs= 65265a3d36dfSmrg compiler_flags= 65275a3d36dfSmrg linker_flags= 65285a3d36dfSmrg dllsearchpath= 65295a3d36dfSmrg lib_search_path=`pwd` 65305a3d36dfSmrg inst_prefix_dir= 65315a3d36dfSmrg new_inherited_linker_flags= 653223a0898aSmrg 65335a3d36dfSmrg avoid_version=no 653441c30155Smrg bindir= 65355a3d36dfSmrg dlfiles= 65365a3d36dfSmrg dlprefiles= 65375a3d36dfSmrg dlself=no 65385a3d36dfSmrg export_dynamic=no 65395a3d36dfSmrg export_symbols= 65405a3d36dfSmrg export_symbols_regex= 65415a3d36dfSmrg generated= 65425a3d36dfSmrg libobjs= 65435a3d36dfSmrg ltlibs= 65445a3d36dfSmrg module=no 65455a3d36dfSmrg no_install=no 65465a3d36dfSmrg objs= 6547b43acbb4Smrg os2dllname= 65485a3d36dfSmrg non_pic_objects= 65495a3d36dfSmrg precious_files_regex= 65505a3d36dfSmrg prefer_static_libs=no 6551b43acbb4Smrg preload=false 65525a3d36dfSmrg prev= 65535a3d36dfSmrg prevarg= 65545a3d36dfSmrg release= 65555a3d36dfSmrg rpath= 65565a3d36dfSmrg xrpath= 65575a3d36dfSmrg perm_rpath= 65585a3d36dfSmrg temp_rpath= 65595a3d36dfSmrg thread_safe=no 65605a3d36dfSmrg vinfo= 65615a3d36dfSmrg vinfo_number=no 65625a3d36dfSmrg weak_libs= 6563b43acbb4Smrg single_module=$wl-single_module 65645a3d36dfSmrg func_infer_tag $base_compile 65655a3d36dfSmrg 65665a3d36dfSmrg # We need to know -static, to get the right output filenames. 65675a3d36dfSmrg for arg 65685a3d36dfSmrg do 65695a3d36dfSmrg case $arg in 65705a3d36dfSmrg -shared) 6571b43acbb4Smrg test yes != "$build_libtool_libs" \ 6572b43acbb4Smrg && func_fatal_configuration "cannot build a shared library" 65735a3d36dfSmrg build_old_libs=no 65745a3d36dfSmrg break 65755a3d36dfSmrg ;; 65765a3d36dfSmrg -all-static | -static | -static-libtool-libs) 65775a3d36dfSmrg case $arg in 65785a3d36dfSmrg -all-static) 6579b43acbb4Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 65805a3d36dfSmrg func_warning "complete static linking is impossible in this configuration" 65815a3d36dfSmrg fi 65825a3d36dfSmrg if test -n "$link_static_flag"; then 65835a3d36dfSmrg dlopen_self=$dlopen_self_static 65845a3d36dfSmrg fi 65855a3d36dfSmrg prefer_static_libs=yes 65865a3d36dfSmrg ;; 65875a3d36dfSmrg -static) 65885a3d36dfSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65895a3d36dfSmrg dlopen_self=$dlopen_self_static 6590b3062210Smrg fi 65915a3d36dfSmrg prefer_static_libs=built 65925a3d36dfSmrg ;; 65935a3d36dfSmrg -static-libtool-libs) 65945a3d36dfSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65955a3d36dfSmrg dlopen_self=$dlopen_self_static 65965a3d36dfSmrg fi 65975a3d36dfSmrg prefer_static_libs=yes 65985a3d36dfSmrg ;; 65995a3d36dfSmrg esac 66005a3d36dfSmrg build_libtool_libs=no 66015a3d36dfSmrg build_old_libs=yes 66025a3d36dfSmrg break 66035a3d36dfSmrg ;; 66045a3d36dfSmrg esac 66055a3d36dfSmrg done 660623a0898aSmrg 66075a3d36dfSmrg # See if our shared archives depend on static archives. 66085a3d36dfSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 660923a0898aSmrg 66105a3d36dfSmrg # Go through the arguments, transforming them on the way. 66115a3d36dfSmrg while test "$#" -gt 0; do 6612b43acbb4Smrg arg=$1 66135a3d36dfSmrg shift 66145a3d36dfSmrg func_quote_for_eval "$arg" 66155a3d36dfSmrg qarg=$func_quote_for_eval_unquoted_result 66165a3d36dfSmrg func_append libtool_args " $func_quote_for_eval_result" 661723a0898aSmrg 66185a3d36dfSmrg # If the previous option needs an argument, assign it. 66195a3d36dfSmrg if test -n "$prev"; then 66205a3d36dfSmrg case $prev in 66215a3d36dfSmrg output) 66225a3d36dfSmrg func_append compile_command " @OUTPUT@" 66235a3d36dfSmrg func_append finalize_command " @OUTPUT@" 66245a3d36dfSmrg ;; 66255a3d36dfSmrg esac 662623a0898aSmrg 66275a3d36dfSmrg case $prev in 662841c30155Smrg bindir) 6629b43acbb4Smrg bindir=$arg 663041c30155Smrg prev= 663141c30155Smrg continue 663241c30155Smrg ;; 66335a3d36dfSmrg dlfiles|dlprefiles) 6634b43acbb4Smrg $preload || { 66355a3d36dfSmrg # Add the symbol object into the linking commands. 66365a3d36dfSmrg func_append compile_command " @SYMFILE@" 66375a3d36dfSmrg func_append finalize_command " @SYMFILE@" 6638b43acbb4Smrg preload=: 6639b43acbb4Smrg } 66405a3d36dfSmrg case $arg in 66415a3d36dfSmrg *.la | *.lo) ;; # We handle these cases below. 66425a3d36dfSmrg force) 6643b43acbb4Smrg if test no = "$dlself"; then 66445a3d36dfSmrg dlself=needless 66455a3d36dfSmrg export_dynamic=yes 66465a3d36dfSmrg fi 66475a3d36dfSmrg prev= 66485a3d36dfSmrg continue 66495a3d36dfSmrg ;; 66505a3d36dfSmrg self) 6651b43acbb4Smrg if test dlprefiles = "$prev"; then 66525a3d36dfSmrg dlself=yes 6653b43acbb4Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 66545a3d36dfSmrg dlself=yes 6655b3062210Smrg else 66565a3d36dfSmrg dlself=needless 66575a3d36dfSmrg export_dynamic=yes 6658b3062210Smrg fi 66595a3d36dfSmrg prev= 66605a3d36dfSmrg continue 66615a3d36dfSmrg ;; 66625a3d36dfSmrg *) 6663b43acbb4Smrg if test dlfiles = "$prev"; then 666441c30155Smrg func_append dlfiles " $arg" 6665b3062210Smrg else 666641c30155Smrg func_append dlprefiles " $arg" 6667b3062210Smrg fi 66685a3d36dfSmrg prev= 66695a3d36dfSmrg continue 66705a3d36dfSmrg ;; 66715a3d36dfSmrg esac 66725a3d36dfSmrg ;; 66735a3d36dfSmrg expsyms) 6674b43acbb4Smrg export_symbols=$arg 66755a3d36dfSmrg test -f "$arg" \ 6676b43acbb4Smrg || func_fatal_error "symbol file '$arg' does not exist" 66775a3d36dfSmrg prev= 66785a3d36dfSmrg continue 66795a3d36dfSmrg ;; 66805a3d36dfSmrg expsyms_regex) 6681b43acbb4Smrg export_symbols_regex=$arg 66825a3d36dfSmrg prev= 66835a3d36dfSmrg continue 66845a3d36dfSmrg ;; 66855a3d36dfSmrg framework) 66865a3d36dfSmrg case $host in 66875a3d36dfSmrg *-*-darwin*) 66885a3d36dfSmrg case "$deplibs " in 66895a3d36dfSmrg *" $qarg.ltframework "*) ;; 669041c30155Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 66915a3d36dfSmrg ;; 66925a3d36dfSmrg esac 6693b3062210Smrg ;; 66945a3d36dfSmrg esac 66955a3d36dfSmrg prev= 66965a3d36dfSmrg continue 66975a3d36dfSmrg ;; 66985a3d36dfSmrg inst_prefix) 6699b43acbb4Smrg inst_prefix_dir=$arg 6700b43acbb4Smrg prev= 6701b43acbb4Smrg continue 6702b43acbb4Smrg ;; 6703b43acbb4Smrg mllvm) 6704b43acbb4Smrg # Clang does not use LLVM to link, so we can simply discard any 6705b43acbb4Smrg # '-mllvm $arg' options when doing the link step. 67065a3d36dfSmrg prev= 67075a3d36dfSmrg continue 67085a3d36dfSmrg ;; 67095a3d36dfSmrg objectlist) 67105a3d36dfSmrg if test -f "$arg"; then 67115a3d36dfSmrg save_arg=$arg 67125a3d36dfSmrg moreargs= 67135a3d36dfSmrg for fil in `cat "$save_arg"` 67145a3d36dfSmrg do 671541c30155Smrg# func_append moreargs " $fil" 67165a3d36dfSmrg arg=$fil 67175a3d36dfSmrg # A libtool-controlled object. 671823a0898aSmrg 67195a3d36dfSmrg # Check to see that this really is a libtool object. 67205a3d36dfSmrg if func_lalib_unsafe_p "$arg"; then 67215a3d36dfSmrg pic_object= 67225a3d36dfSmrg non_pic_object= 672323a0898aSmrg 67245a3d36dfSmrg # Read the .lo file 67255a3d36dfSmrg func_source "$arg" 672623a0898aSmrg 67275a3d36dfSmrg if test -z "$pic_object" || 67285a3d36dfSmrg test -z "$non_pic_object" || 6729b43acbb4Smrg test none = "$pic_object" && 6730b43acbb4Smrg test none = "$non_pic_object"; then 6731b43acbb4Smrg func_fatal_error "cannot find name of object for '$arg'" 67325a3d36dfSmrg fi 673323a0898aSmrg 67345a3d36dfSmrg # Extract subdirectory from the argument. 67355a3d36dfSmrg func_dirname "$arg" "/" "" 6736b43acbb4Smrg xdir=$func_dirname_result 673723a0898aSmrg 6738b43acbb4Smrg if test none != "$pic_object"; then 67395a3d36dfSmrg # Prepend the subdirectory the object is found in. 6740b43acbb4Smrg pic_object=$xdir$pic_object 674123a0898aSmrg 6742b43acbb4Smrg if test dlfiles = "$prev"; then 6743b43acbb4Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 674441c30155Smrg func_append dlfiles " $pic_object" 67455a3d36dfSmrg prev= 67465a3d36dfSmrg continue 67475a3d36dfSmrg else 67485a3d36dfSmrg # If libtool objects are unsupported, then we need to preload. 67495a3d36dfSmrg prev=dlprefiles 67505a3d36dfSmrg fi 67515a3d36dfSmrg fi 675223a0898aSmrg 67535a3d36dfSmrg # CHECK ME: I think I busted this. -Ossama 6754b43acbb4Smrg if test dlprefiles = "$prev"; then 67555a3d36dfSmrg # Preload the old-style object. 675641c30155Smrg func_append dlprefiles " $pic_object" 67575a3d36dfSmrg prev= 67585a3d36dfSmrg fi 675923a0898aSmrg 67605a3d36dfSmrg # A PIC object. 67615a3d36dfSmrg func_append libobjs " $pic_object" 6762b43acbb4Smrg arg=$pic_object 67635a3d36dfSmrg fi 676423a0898aSmrg 67655a3d36dfSmrg # Non-PIC object. 6766b43acbb4Smrg if test none != "$non_pic_object"; then 67675a3d36dfSmrg # Prepend the subdirectory the object is found in. 6768b43acbb4Smrg non_pic_object=$xdir$non_pic_object 676923a0898aSmrg 67705a3d36dfSmrg # A standard non-PIC object 67715a3d36dfSmrg func_append non_pic_objects " $non_pic_object" 6772b43acbb4Smrg if test -z "$pic_object" || test none = "$pic_object"; then 6773b43acbb4Smrg arg=$non_pic_object 67745a3d36dfSmrg fi 67755a3d36dfSmrg else 67765a3d36dfSmrg # If the PIC object exists, use it instead. 67775a3d36dfSmrg # $xdir was prepended to $pic_object above. 6778b43acbb4Smrg non_pic_object=$pic_object 67795a3d36dfSmrg func_append non_pic_objects " $non_pic_object" 67805a3d36dfSmrg fi 67815a3d36dfSmrg else 67825a3d36dfSmrg # Only an error if not doing a dry-run. 67835a3d36dfSmrg if $opt_dry_run; then 67845a3d36dfSmrg # Extract subdirectory from the argument. 67855a3d36dfSmrg func_dirname "$arg" "/" "" 6786b43acbb4Smrg xdir=$func_dirname_result 67875a3d36dfSmrg 67885a3d36dfSmrg func_lo2o "$arg" 67895a3d36dfSmrg pic_object=$xdir$objdir/$func_lo2o_result 67905a3d36dfSmrg non_pic_object=$xdir$func_lo2o_result 67915a3d36dfSmrg func_append libobjs " $pic_object" 67925a3d36dfSmrg func_append non_pic_objects " $non_pic_object" 67935a3d36dfSmrg else 6794b43acbb4Smrg func_fatal_error "'$arg' is not a valid libtool object" 67955a3d36dfSmrg fi 67965a3d36dfSmrg fi 67975a3d36dfSmrg done 67985a3d36dfSmrg else 6799b43acbb4Smrg func_fatal_error "link input file '$arg' does not exist" 68005a3d36dfSmrg fi 68015a3d36dfSmrg arg=$save_arg 68025a3d36dfSmrg prev= 68035a3d36dfSmrg continue 68045a3d36dfSmrg ;; 6805b43acbb4Smrg os2dllname) 6806b43acbb4Smrg os2dllname=$arg 6807b43acbb4Smrg prev= 6808b43acbb4Smrg continue 6809b43acbb4Smrg ;; 68105a3d36dfSmrg precious_regex) 6811b43acbb4Smrg precious_files_regex=$arg 68125a3d36dfSmrg prev= 68135a3d36dfSmrg continue 68145a3d36dfSmrg ;; 68155a3d36dfSmrg release) 6816b43acbb4Smrg release=-$arg 68175a3d36dfSmrg prev= 68185a3d36dfSmrg continue 68195a3d36dfSmrg ;; 68205a3d36dfSmrg rpath | xrpath) 68215a3d36dfSmrg # We need an absolute path. 68225a3d36dfSmrg case $arg in 68235a3d36dfSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 68245a3d36dfSmrg *) 68255a3d36dfSmrg func_fatal_error "only absolute run-paths are allowed" 68265a3d36dfSmrg ;; 68275a3d36dfSmrg esac 6828b43acbb4Smrg if test rpath = "$prev"; then 68295a3d36dfSmrg case "$rpath " in 68305a3d36dfSmrg *" $arg "*) ;; 683141c30155Smrg *) func_append rpath " $arg" ;; 68325a3d36dfSmrg esac 68335a3d36dfSmrg else 68345a3d36dfSmrg case "$xrpath " in 68355a3d36dfSmrg *" $arg "*) ;; 683641c30155Smrg *) func_append xrpath " $arg" ;; 68375a3d36dfSmrg esac 68385a3d36dfSmrg fi 68395a3d36dfSmrg prev= 68405a3d36dfSmrg continue 68415a3d36dfSmrg ;; 68425a3d36dfSmrg shrext) 6843b43acbb4Smrg shrext_cmds=$arg 68445a3d36dfSmrg prev= 68455a3d36dfSmrg continue 68465a3d36dfSmrg ;; 68475a3d36dfSmrg weak) 684841c30155Smrg func_append weak_libs " $arg" 68495a3d36dfSmrg prev= 68505a3d36dfSmrg continue 68515a3d36dfSmrg ;; 68525a3d36dfSmrg xcclinker) 685341c30155Smrg func_append linker_flags " $qarg" 685441c30155Smrg func_append compiler_flags " $qarg" 68555a3d36dfSmrg prev= 68565a3d36dfSmrg func_append compile_command " $qarg" 68575a3d36dfSmrg func_append finalize_command " $qarg" 68585a3d36dfSmrg continue 68595a3d36dfSmrg ;; 68605a3d36dfSmrg xcompiler) 686141c30155Smrg func_append compiler_flags " $qarg" 68625a3d36dfSmrg prev= 68635a3d36dfSmrg func_append compile_command " $qarg" 68645a3d36dfSmrg func_append finalize_command " $qarg" 68655a3d36dfSmrg continue 68665a3d36dfSmrg ;; 68675a3d36dfSmrg xlinker) 686841c30155Smrg func_append linker_flags " $qarg" 686941c30155Smrg func_append compiler_flags " $wl$qarg" 68705a3d36dfSmrg prev= 68715a3d36dfSmrg func_append compile_command " $wl$qarg" 68725a3d36dfSmrg func_append finalize_command " $wl$qarg" 68735a3d36dfSmrg continue 6874b3062210Smrg ;; 6875b3062210Smrg *) 68765a3d36dfSmrg eval "$prev=\"\$arg\"" 68775a3d36dfSmrg prev= 68785a3d36dfSmrg continue 6879b3062210Smrg ;; 6880b3062210Smrg esac 68815a3d36dfSmrg fi # test -n "$prev" 688223a0898aSmrg 6883b43acbb4Smrg prevarg=$arg 688423a0898aSmrg 68855a3d36dfSmrg case $arg in 68865a3d36dfSmrg -all-static) 68875a3d36dfSmrg if test -n "$link_static_flag"; then 68885a3d36dfSmrg # See comment for -static flag below, for more details. 68895a3d36dfSmrg func_append compile_command " $link_static_flag" 68905a3d36dfSmrg func_append finalize_command " $link_static_flag" 68917f7f5e4eSmrg fi 68925a3d36dfSmrg continue 68935a3d36dfSmrg ;; 689423a0898aSmrg 68955a3d36dfSmrg -allow-undefined) 68965a3d36dfSmrg # FIXME: remove this flag sometime in the future. 6897b43acbb4Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 68985a3d36dfSmrg ;; 689923a0898aSmrg 69005a3d36dfSmrg -avoid-version) 69015a3d36dfSmrg avoid_version=yes 69025a3d36dfSmrg continue 69035a3d36dfSmrg ;; 690423a0898aSmrg 690541c30155Smrg -bindir) 690641c30155Smrg prev=bindir 690741c30155Smrg continue 690841c30155Smrg ;; 690941c30155Smrg 69105a3d36dfSmrg -dlopen) 69115a3d36dfSmrg prev=dlfiles 69125a3d36dfSmrg continue 69135a3d36dfSmrg ;; 691423a0898aSmrg 69155a3d36dfSmrg -dlpreopen) 69165a3d36dfSmrg prev=dlprefiles 69175a3d36dfSmrg continue 69185a3d36dfSmrg ;; 69197f7f5e4eSmrg 69205a3d36dfSmrg -export-dynamic) 69215a3d36dfSmrg export_dynamic=yes 69225a3d36dfSmrg continue 69235a3d36dfSmrg ;; 69247f7f5e4eSmrg 69255a3d36dfSmrg -export-symbols | -export-symbols-regex) 69265a3d36dfSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 69275a3d36dfSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 69285a3d36dfSmrg fi 6929b43acbb4Smrg if test X-export-symbols = "X$arg"; then 69305a3d36dfSmrg prev=expsyms 6931b3062210Smrg else 69325a3d36dfSmrg prev=expsyms_regex 6933b3062210Smrg fi 69345a3d36dfSmrg continue 69355a3d36dfSmrg ;; 69367f7f5e4eSmrg 69375a3d36dfSmrg -framework) 69385a3d36dfSmrg prev=framework 69395a3d36dfSmrg continue 69405a3d36dfSmrg ;; 69417f7f5e4eSmrg 69425a3d36dfSmrg -inst-prefix-dir) 69435a3d36dfSmrg prev=inst_prefix 69445a3d36dfSmrg continue 69455a3d36dfSmrg ;; 69467f7f5e4eSmrg 69475a3d36dfSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 69485a3d36dfSmrg # so, if we see these flags be careful not to treat them like -L 69495a3d36dfSmrg -L[A-Z][A-Z]*:*) 69505a3d36dfSmrg case $with_gcc/$host in 69515a3d36dfSmrg no/*-*-irix* | /*-*-irix*) 69525a3d36dfSmrg func_append compile_command " $arg" 69535a3d36dfSmrg func_append finalize_command " $arg" 69545a3d36dfSmrg ;; 69555a3d36dfSmrg esac 69565a3d36dfSmrg continue 69575a3d36dfSmrg ;; 69587f7f5e4eSmrg 69595a3d36dfSmrg -L*) 696041c30155Smrg func_stripname "-L" '' "$arg" 696141c30155Smrg if test -z "$func_stripname_result"; then 69625a3d36dfSmrg if test "$#" -gt 0; then 6963b43acbb4Smrg func_fatal_error "require no space between '-L' and '$1'" 6964b3062210Smrg else 6965b43acbb4Smrg func_fatal_error "need path for '-L' option" 6966b3062210Smrg fi 69675a3d36dfSmrg fi 696841c30155Smrg func_resolve_sysroot "$func_stripname_result" 696941c30155Smrg dir=$func_resolve_sysroot_result 69705a3d36dfSmrg # We need an absolute path. 69715a3d36dfSmrg case $dir in 69725a3d36dfSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 69735a3d36dfSmrg *) 69745a3d36dfSmrg absdir=`cd "$dir" && pwd` 69755a3d36dfSmrg test -z "$absdir" && \ 6976b43acbb4Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977b43acbb4Smrg dir=$absdir 69785a3d36dfSmrg ;; 69797f7f5e4eSmrg esac 69805a3d36dfSmrg case "$deplibs " in 698141c30155Smrg *" -L$dir "* | *" $arg "*) 698241c30155Smrg # Will only happen for absolute or sysroot arguments 698341c30155Smrg ;; 69845a3d36dfSmrg *) 698541c30155Smrg # Preserve sysroot, but never include relative directories 698641c30155Smrg case $dir in 698741c30155Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 698841c30155Smrg *) func_append deplibs " -L$dir" ;; 698941c30155Smrg esac 699041c30155Smrg func_append lib_search_path " $dir" 69915a3d36dfSmrg ;; 6992b3062210Smrg esac 6993b3062210Smrg case $host in 69945a3d36dfSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699541c30155Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 69965a3d36dfSmrg case :$dllsearchpath: in 69975a3d36dfSmrg *":$dir:"*) ;; 69985a3d36dfSmrg ::) dllsearchpath=$dir;; 699941c30155Smrg *) func_append dllsearchpath ":$dir";; 70005a3d36dfSmrg esac 70015a3d36dfSmrg case :$dllsearchpath: in 70025a3d36dfSmrg *":$testbindir:"*) ;; 70035a3d36dfSmrg ::) dllsearchpath=$testbindir;; 700441c30155Smrg *) func_append dllsearchpath ":$testbindir";; 70055a3d36dfSmrg esac 70065a3d36dfSmrg ;; 7007b3062210Smrg esac 70085a3d36dfSmrg continue 70095a3d36dfSmrg ;; 70107f7f5e4eSmrg 70115a3d36dfSmrg -l*) 7012b43acbb4Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 70135a3d36dfSmrg case $host in 701441c30155Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 70155a3d36dfSmrg # These systems don't actually have a C or math library (as such) 70165a3d36dfSmrg continue 70175a3d36dfSmrg ;; 70185a3d36dfSmrg *-*-os2*) 70195a3d36dfSmrg # These systems don't actually have a C library (as such) 7020b43acbb4Smrg test X-lc = "X$arg" && continue 70215a3d36dfSmrg ;; 7022b43acbb4Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70235a3d36dfSmrg # Do not include libc due to us having libc/libc_r. 7024b43acbb4Smrg test X-lc = "X$arg" && continue 70255a3d36dfSmrg ;; 70265a3d36dfSmrg *-*-rhapsody* | *-*-darwin1.[012]) 70275a3d36dfSmrg # Rhapsody C and math libraries are in the System framework 702841c30155Smrg func_append deplibs " System.ltframework" 70295a3d36dfSmrg continue 70305a3d36dfSmrg ;; 70315a3d36dfSmrg *-*-sco3.2v5* | *-*-sco5v6*) 70325a3d36dfSmrg # Causes problems with __ctype 7033b43acbb4Smrg test X-lc = "X$arg" && continue 70345a3d36dfSmrg ;; 70355a3d36dfSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 70365a3d36dfSmrg # Compiler inserts libc in the correct place for threads to work 7037b43acbb4Smrg test X-lc = "X$arg" && continue 70385a3d36dfSmrg ;; 70395a3d36dfSmrg esac 7040b43acbb4Smrg elif test X-lc_r = "X$arg"; then 70415a3d36dfSmrg case $host in 7042b43acbb4Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70435a3d36dfSmrg # Do not include libc_r directly, use -pthread flag. 70445a3d36dfSmrg continue 70455a3d36dfSmrg ;; 70465a3d36dfSmrg esac 70475a3d36dfSmrg fi 704841c30155Smrg func_append deplibs " $arg" 70495a3d36dfSmrg continue 70505a3d36dfSmrg ;; 70517f7f5e4eSmrg 7052b43acbb4Smrg -mllvm) 7053b43acbb4Smrg prev=mllvm 7054b43acbb4Smrg continue 7055b43acbb4Smrg ;; 7056b43acbb4Smrg 70575a3d36dfSmrg -module) 70585a3d36dfSmrg module=yes 70595a3d36dfSmrg continue 70605a3d36dfSmrg ;; 70617f7f5e4eSmrg 70625a3d36dfSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 70635a3d36dfSmrg # classes, name mangling, and exception handling. 70645a3d36dfSmrg # Darwin uses the -arch flag to determine output architecture. 706541c30155Smrg -model|-arch|-isysroot|--sysroot) 706641c30155Smrg func_append compiler_flags " $arg" 70675a3d36dfSmrg func_append compile_command " $arg" 70685a3d36dfSmrg func_append finalize_command " $arg" 70695a3d36dfSmrg prev=xcompiler 70705a3d36dfSmrg continue 70715a3d36dfSmrg ;; 70727f7f5e4eSmrg 7073b020570bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074b020570bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 707541c30155Smrg func_append compiler_flags " $arg" 70765a3d36dfSmrg func_append compile_command " $arg" 70775a3d36dfSmrg func_append finalize_command " $arg" 70785a3d36dfSmrg case "$new_inherited_linker_flags " in 70795a3d36dfSmrg *" $arg "*) ;; 708041c30155Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 70815a3d36dfSmrg esac 70825a3d36dfSmrg continue 70835a3d36dfSmrg ;; 70847f7f5e4eSmrg 70855a3d36dfSmrg -multi_module) 7086b43acbb4Smrg single_module=$wl-multi_module 70875a3d36dfSmrg continue 70885a3d36dfSmrg ;; 70897f7f5e4eSmrg 70905a3d36dfSmrg -no-fast-install) 70915a3d36dfSmrg fast_install=no 70925a3d36dfSmrg continue 70935a3d36dfSmrg ;; 70947f7f5e4eSmrg 70955a3d36dfSmrg -no-install) 70965a3d36dfSmrg case $host in 70975a3d36dfSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 70985a3d36dfSmrg # The PATH hackery in wrapper scripts is required on Windows 70995a3d36dfSmrg # and Darwin in order for the loader to find any dlls it needs. 7100b43acbb4Smrg func_warning "'-no-install' is ignored for $host" 7101b43acbb4Smrg func_warning "assuming '-no-fast-install' instead" 71025a3d36dfSmrg fast_install=no 71035a3d36dfSmrg ;; 71045a3d36dfSmrg *) no_install=yes ;; 71055a3d36dfSmrg esac 71065a3d36dfSmrg continue 71075a3d36dfSmrg ;; 71087f7f5e4eSmrg 71095a3d36dfSmrg -no-undefined) 71105a3d36dfSmrg allow_undefined=no 71115a3d36dfSmrg continue 71125a3d36dfSmrg ;; 71137f7f5e4eSmrg 71145a3d36dfSmrg -objectlist) 71155a3d36dfSmrg prev=objectlist 71165a3d36dfSmrg continue 71175a3d36dfSmrg ;; 71187f7f5e4eSmrg 7119b43acbb4Smrg -os2dllname) 7120b43acbb4Smrg prev=os2dllname 7121b43acbb4Smrg continue 7122b43acbb4Smrg ;; 7123b43acbb4Smrg 71245a3d36dfSmrg -o) prev=output ;; 71257f7f5e4eSmrg 71265a3d36dfSmrg -precious-files-regex) 71275a3d36dfSmrg prev=precious_regex 71285a3d36dfSmrg continue 71295a3d36dfSmrg ;; 71307f7f5e4eSmrg 71315a3d36dfSmrg -release) 71325a3d36dfSmrg prev=release 71335a3d36dfSmrg continue 71345a3d36dfSmrg ;; 71357f7f5e4eSmrg 71365a3d36dfSmrg -rpath) 71375a3d36dfSmrg prev=rpath 71385a3d36dfSmrg continue 71395a3d36dfSmrg ;; 71407f7f5e4eSmrg 71415a3d36dfSmrg -R) 71425a3d36dfSmrg prev=xrpath 71435a3d36dfSmrg continue 71445a3d36dfSmrg ;; 71457f7f5e4eSmrg 71465a3d36dfSmrg -R*) 71475a3d36dfSmrg func_stripname '-R' '' "$arg" 71485a3d36dfSmrg dir=$func_stripname_result 71495a3d36dfSmrg # We need an absolute path. 71505a3d36dfSmrg case $dir in 71515a3d36dfSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 715241c30155Smrg =*) 715341c30155Smrg func_stripname '=' '' "$dir" 715441c30155Smrg dir=$lt_sysroot$func_stripname_result 715541c30155Smrg ;; 71565a3d36dfSmrg *) 71575a3d36dfSmrg func_fatal_error "only absolute run-paths are allowed" 71585a3d36dfSmrg ;; 71595a3d36dfSmrg esac 71605a3d36dfSmrg case "$xrpath " in 71615a3d36dfSmrg *" $dir "*) ;; 716241c30155Smrg *) func_append xrpath " $dir" ;; 71635a3d36dfSmrg esac 71645a3d36dfSmrg continue 71655a3d36dfSmrg ;; 71667f7f5e4eSmrg 71675a3d36dfSmrg -shared) 71685a3d36dfSmrg # The effects of -shared are defined in a previous loop. 71695a3d36dfSmrg continue 71705a3d36dfSmrg ;; 71717f7f5e4eSmrg 71725a3d36dfSmrg -shrext) 71735a3d36dfSmrg prev=shrext 71745a3d36dfSmrg continue 71755a3d36dfSmrg ;; 71767f7f5e4eSmrg 71775a3d36dfSmrg -static | -static-libtool-libs) 71785a3d36dfSmrg # The effects of -static are defined in a previous loop. 71795a3d36dfSmrg # We used to do the same as -all-static on platforms that 71805a3d36dfSmrg # didn't have a PIC flag, but the assumption that the effects 71815a3d36dfSmrg # would be equivalent was wrong. It would break on at least 71825a3d36dfSmrg # Digital Unix and AIX. 71835a3d36dfSmrg continue 71845a3d36dfSmrg ;; 71857f7f5e4eSmrg 71865a3d36dfSmrg -thread-safe) 71875a3d36dfSmrg thread_safe=yes 71885a3d36dfSmrg continue 71895a3d36dfSmrg ;; 71907f7f5e4eSmrg 71915a3d36dfSmrg -version-info) 71925a3d36dfSmrg prev=vinfo 71935a3d36dfSmrg continue 71945a3d36dfSmrg ;; 71957f7f5e4eSmrg 71965a3d36dfSmrg -version-number) 71975a3d36dfSmrg prev=vinfo 71985a3d36dfSmrg vinfo_number=yes 71995a3d36dfSmrg continue 72005a3d36dfSmrg ;; 72017f7f5e4eSmrg 72025a3d36dfSmrg -weak) 72035a3d36dfSmrg prev=weak 72045a3d36dfSmrg continue 72055a3d36dfSmrg ;; 72067f7f5e4eSmrg 72075a3d36dfSmrg -Wc,*) 72085a3d36dfSmrg func_stripname '-Wc,' '' "$arg" 72095a3d36dfSmrg args=$func_stripname_result 72105a3d36dfSmrg arg= 7211b43acbb4Smrg save_ifs=$IFS; IFS=, 72125a3d36dfSmrg for flag in $args; do 7213b43acbb4Smrg IFS=$save_ifs 72145a3d36dfSmrg func_quote_for_eval "$flag" 721541c30155Smrg func_append arg " $func_quote_for_eval_result" 721641c30155Smrg func_append compiler_flags " $func_quote_for_eval_result" 72175a3d36dfSmrg done 7218b43acbb4Smrg IFS=$save_ifs 72195a3d36dfSmrg func_stripname ' ' '' "$arg" 72205a3d36dfSmrg arg=$func_stripname_result 72215a3d36dfSmrg ;; 72227f7f5e4eSmrg 72235a3d36dfSmrg -Wl,*) 72245a3d36dfSmrg func_stripname '-Wl,' '' "$arg" 72255a3d36dfSmrg args=$func_stripname_result 72265a3d36dfSmrg arg= 7227b43acbb4Smrg save_ifs=$IFS; IFS=, 72285a3d36dfSmrg for flag in $args; do 7229b43acbb4Smrg IFS=$save_ifs 72305a3d36dfSmrg func_quote_for_eval "$flag" 723141c30155Smrg func_append arg " $wl$func_quote_for_eval_result" 723241c30155Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 723341c30155Smrg func_append linker_flags " $func_quote_for_eval_result" 72345a3d36dfSmrg done 7235b43acbb4Smrg IFS=$save_ifs 72365a3d36dfSmrg func_stripname ' ' '' "$arg" 72375a3d36dfSmrg arg=$func_stripname_result 72385a3d36dfSmrg ;; 72397f7f5e4eSmrg 72405a3d36dfSmrg -Xcompiler) 72415a3d36dfSmrg prev=xcompiler 72425a3d36dfSmrg continue 72435a3d36dfSmrg ;; 72447f7f5e4eSmrg 72455a3d36dfSmrg -Xlinker) 72465a3d36dfSmrg prev=xlinker 72475a3d36dfSmrg continue 72485a3d36dfSmrg ;; 72497f7f5e4eSmrg 72505a3d36dfSmrg -XCClinker) 72515a3d36dfSmrg prev=xcclinker 72525a3d36dfSmrg continue 72535a3d36dfSmrg ;; 72547f7f5e4eSmrg 72555a3d36dfSmrg # -msg_* for osf cc 72565a3d36dfSmrg -msg_*) 72575a3d36dfSmrg func_quote_for_eval "$arg" 7258b43acbb4Smrg arg=$func_quote_for_eval_result 72595a3d36dfSmrg ;; 72607f7f5e4eSmrg 726141c30155Smrg # Flags to be passed through unchanged, with rationale: 726241c30155Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726341c30155Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 726441c30155Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726541c30155Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726641c30155Smrg # -q* compiler args for the IBM compiler 726741c30155Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726841c30155Smrg # -F/path path to uninstalled frameworks, gcc on darwin 726941c30155Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270b43acbb4Smrg # -fstack-protector* stack protector flags for GCC 727141c30155Smrg # @file GCC response files 727241c30155Smrg # -tp=* Portland pgcc target processor selection 727341c30155Smrg # --sysroot=* for sysroot support 7274b43acbb4Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275a97c3f35Smrg # -specs=* GCC specs files 7276b43acbb4Smrg # -stdlib=* select c++ std lib with clang 7277a97c3f35Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 72785a3d36dfSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 727941c30155Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7280a97c3f35Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7281a97c3f35Smrg -specs=*|-fsanitize=*) 72825a3d36dfSmrg func_quote_for_eval "$arg" 7283b43acbb4Smrg arg=$func_quote_for_eval_result 72845a3d36dfSmrg func_append compile_command " $arg" 72855a3d36dfSmrg func_append finalize_command " $arg" 728641c30155Smrg func_append compiler_flags " $arg" 72875a3d36dfSmrg continue 72885a3d36dfSmrg ;; 728923a0898aSmrg 7290b43acbb4Smrg -Z*) 7291b43acbb4Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7292b43acbb4Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7293b43acbb4Smrg compiler_flags="$compiler_flags $arg" 7294b43acbb4Smrg func_append compile_command " $arg" 7295b43acbb4Smrg func_append finalize_command " $arg" 7296b43acbb4Smrg case $arg in 7297b43acbb4Smrg -Zlinker | -Zstack) 7298b43acbb4Smrg prev=xcompiler 7299b43acbb4Smrg ;; 7300b43acbb4Smrg esac 7301b43acbb4Smrg continue 7302b43acbb4Smrg else 7303b43acbb4Smrg # Otherwise treat like 'Some other compiler flag' below 7304b43acbb4Smrg func_quote_for_eval "$arg" 7305b43acbb4Smrg arg=$func_quote_for_eval_result 7306b43acbb4Smrg fi 7307b43acbb4Smrg ;; 7308b43acbb4Smrg 73095a3d36dfSmrg # Some other compiler flag. 73105a3d36dfSmrg -* | +*) 73115a3d36dfSmrg func_quote_for_eval "$arg" 7312b43acbb4Smrg arg=$func_quote_for_eval_result 73135a3d36dfSmrg ;; 7314b3062210Smrg 73155a3d36dfSmrg *.$objext) 73165a3d36dfSmrg # A standard object. 731741c30155Smrg func_append objs " $arg" 73185a3d36dfSmrg ;; 7319b3062210Smrg 73205a3d36dfSmrg *.lo) 73215a3d36dfSmrg # A libtool-controlled object. 7322b3062210Smrg 73235a3d36dfSmrg # Check to see that this really is a libtool object. 73245a3d36dfSmrg if func_lalib_unsafe_p "$arg"; then 73255a3d36dfSmrg pic_object= 73265a3d36dfSmrg non_pic_object= 7327b3062210Smrg 73285a3d36dfSmrg # Read the .lo file 73295a3d36dfSmrg func_source "$arg" 7330b3062210Smrg 73315a3d36dfSmrg if test -z "$pic_object" || 73325a3d36dfSmrg test -z "$non_pic_object" || 7333b43acbb4Smrg test none = "$pic_object" && 7334b43acbb4Smrg test none = "$non_pic_object"; then 7335b43acbb4Smrg func_fatal_error "cannot find name of object for '$arg'" 73365a3d36dfSmrg fi 7337b3062210Smrg 73385a3d36dfSmrg # Extract subdirectory from the argument. 73395a3d36dfSmrg func_dirname "$arg" "/" "" 7340b43acbb4Smrg xdir=$func_dirname_result 7341b3062210Smrg 7342b43acbb4Smrg test none = "$pic_object" || { 73435a3d36dfSmrg # Prepend the subdirectory the object is found in. 7344b43acbb4Smrg pic_object=$xdir$pic_object 7345b3062210Smrg 7346b43acbb4Smrg if test dlfiles = "$prev"; then 7347b43acbb4Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 734841c30155Smrg func_append dlfiles " $pic_object" 73495a3d36dfSmrg prev= 73505a3d36dfSmrg continue 73515a3d36dfSmrg else 73525a3d36dfSmrg # If libtool objects are unsupported, then we need to preload. 73535a3d36dfSmrg prev=dlprefiles 73545a3d36dfSmrg fi 73555a3d36dfSmrg fi 7356b3062210Smrg 73575a3d36dfSmrg # CHECK ME: I think I busted this. -Ossama 7358b43acbb4Smrg if test dlprefiles = "$prev"; then 73595a3d36dfSmrg # Preload the old-style object. 736041c30155Smrg func_append dlprefiles " $pic_object" 73615a3d36dfSmrg prev= 73625a3d36dfSmrg fi 7363b3062210Smrg 73645a3d36dfSmrg # A PIC object. 73655a3d36dfSmrg func_append libobjs " $pic_object" 7366b43acbb4Smrg arg=$pic_object 7367b43acbb4Smrg } 7368b3062210Smrg 73695a3d36dfSmrg # Non-PIC object. 7370b43acbb4Smrg if test none != "$non_pic_object"; then 73715a3d36dfSmrg # Prepend the subdirectory the object is found in. 7372b43acbb4Smrg non_pic_object=$xdir$non_pic_object 7373b3062210Smrg 73745a3d36dfSmrg # A standard non-PIC object 73755a3d36dfSmrg func_append non_pic_objects " $non_pic_object" 7376b43acbb4Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7377b43acbb4Smrg arg=$non_pic_object 73785a3d36dfSmrg fi 73795a3d36dfSmrg else 73805a3d36dfSmrg # If the PIC object exists, use it instead. 73815a3d36dfSmrg # $xdir was prepended to $pic_object above. 7382b43acbb4Smrg non_pic_object=$pic_object 73835a3d36dfSmrg func_append non_pic_objects " $non_pic_object" 73845a3d36dfSmrg fi 73855a3d36dfSmrg else 73865a3d36dfSmrg # Only an error if not doing a dry-run. 73875a3d36dfSmrg if $opt_dry_run; then 73885a3d36dfSmrg # Extract subdirectory from the argument. 73895a3d36dfSmrg func_dirname "$arg" "/" "" 7390b43acbb4Smrg xdir=$func_dirname_result 73915a3d36dfSmrg 73925a3d36dfSmrg func_lo2o "$arg" 73935a3d36dfSmrg pic_object=$xdir$objdir/$func_lo2o_result 73945a3d36dfSmrg non_pic_object=$xdir$func_lo2o_result 73955a3d36dfSmrg func_append libobjs " $pic_object" 73965a3d36dfSmrg func_append non_pic_objects " $non_pic_object" 73975a3d36dfSmrg else 7398b43acbb4Smrg func_fatal_error "'$arg' is not a valid libtool object" 73995a3d36dfSmrg fi 74005a3d36dfSmrg fi 74015a3d36dfSmrg ;; 7402b3062210Smrg 74035a3d36dfSmrg *.$libext) 74045a3d36dfSmrg # An archive. 740541c30155Smrg func_append deplibs " $arg" 740641c30155Smrg func_append old_deplibs " $arg" 74075a3d36dfSmrg continue 74085a3d36dfSmrg ;; 7409b3062210Smrg 74105a3d36dfSmrg *.la) 74115a3d36dfSmrg # A libtool-controlled library. 7412b3062210Smrg 741341c30155Smrg func_resolve_sysroot "$arg" 7414b43acbb4Smrg if test dlfiles = "$prev"; then 74155a3d36dfSmrg # This library was specified with -dlopen. 741641c30155Smrg func_append dlfiles " $func_resolve_sysroot_result" 74175a3d36dfSmrg prev= 7418b43acbb4Smrg elif test dlprefiles = "$prev"; then 74195a3d36dfSmrg # The library was specified with -dlpreopen. 742041c30155Smrg func_append dlprefiles " $func_resolve_sysroot_result" 74215a3d36dfSmrg prev= 74225a3d36dfSmrg else 742341c30155Smrg func_append deplibs " $func_resolve_sysroot_result" 74245a3d36dfSmrg fi 74255a3d36dfSmrg continue 74265a3d36dfSmrg ;; 7427b3062210Smrg 74285a3d36dfSmrg # Some other compiler argument. 74295a3d36dfSmrg *) 74305a3d36dfSmrg # Unknown arguments in both finalize_command and compile_command need 74315a3d36dfSmrg # to be aesthetically quoted because they are evaled later. 74325a3d36dfSmrg func_quote_for_eval "$arg" 7433b43acbb4Smrg arg=$func_quote_for_eval_result 74345a3d36dfSmrg ;; 74355a3d36dfSmrg esac # arg 743623a0898aSmrg 74375a3d36dfSmrg # Now actually substitute the argument into the commands. 74385a3d36dfSmrg if test -n "$arg"; then 74395a3d36dfSmrg func_append compile_command " $arg" 74405a3d36dfSmrg func_append finalize_command " $arg" 74415a3d36dfSmrg fi 74425a3d36dfSmrg done # argument parsing loop 744323a0898aSmrg 74445a3d36dfSmrg test -n "$prev" && \ 7445b43acbb4Smrg func_fatal_help "the '$prevarg' option requires an argument" 744623a0898aSmrg 7447b43acbb4Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 74485a3d36dfSmrg eval arg=\"$export_dynamic_flag_spec\" 74495a3d36dfSmrg func_append compile_command " $arg" 74505a3d36dfSmrg func_append finalize_command " $arg" 7451b3062210Smrg fi 745223a0898aSmrg 74535a3d36dfSmrg oldlibs= 74545a3d36dfSmrg # calculate the name of the file, without its directory 74555a3d36dfSmrg func_basename "$output" 7456b43acbb4Smrg outputname=$func_basename_result 7457b43acbb4Smrg libobjs_save=$libobjs 74585a3d36dfSmrg 74595a3d36dfSmrg if test -n "$shlibpath_var"; then 74605a3d36dfSmrg # get the directories listed in $shlibpath_var 7461b43acbb4Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 74625a3d36dfSmrg else 74635a3d36dfSmrg shlib_search_path= 74645a3d36dfSmrg fi 74655a3d36dfSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 74665a3d36dfSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 74675a3d36dfSmrg 7468b43acbb4Smrg # Definition is injected by LT_CONFIG during libtool generation. 7469b43acbb4Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7470b43acbb4Smrg 74715a3d36dfSmrg func_dirname "$output" "/" "" 7472b43acbb4Smrg output_objdir=$func_dirname_result$objdir 747341c30155Smrg func_to_tool_file "$output_objdir/" 747441c30155Smrg tool_output_objdir=$func_to_tool_file_result 74755a3d36dfSmrg # Create the object directory. 74765a3d36dfSmrg func_mkdir_p "$output_objdir" 74775a3d36dfSmrg 74785a3d36dfSmrg # Determine the type of output 74795a3d36dfSmrg case $output in 74805a3d36dfSmrg "") 74815a3d36dfSmrg func_fatal_help "you must specify an output file" 74825a3d36dfSmrg ;; 74835a3d36dfSmrg *.$libext) linkmode=oldlib ;; 74845a3d36dfSmrg *.lo | *.$objext) linkmode=obj ;; 74855a3d36dfSmrg *.la) linkmode=lib ;; 74865a3d36dfSmrg *) linkmode=prog ;; # Anything else should be a program. 74875a3d36dfSmrg esac 74885a3d36dfSmrg 74895a3d36dfSmrg specialdeplibs= 74905a3d36dfSmrg 74915a3d36dfSmrg libs= 74925a3d36dfSmrg # Find all interdependent deplibs by searching for libraries 74935a3d36dfSmrg # that are linked more than once (e.g. -la -lb -la) 74945a3d36dfSmrg for deplib in $deplibs; do 7495b43acbb4Smrg if $opt_preserve_dup_deps; then 74965a3d36dfSmrg case "$libs " in 749741c30155Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 74985a3d36dfSmrg esac 74995a3d36dfSmrg fi 750041c30155Smrg func_append libs " $deplib" 75015a3d36dfSmrg done 75025a3d36dfSmrg 7503b43acbb4Smrg if test lib = "$linkmode"; then 75045a3d36dfSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 75055a3d36dfSmrg 75065a3d36dfSmrg # Compute libraries that are listed more than once in $predeps 75075a3d36dfSmrg # $postdeps and mark them as special (i.e., whose duplicates are 75085a3d36dfSmrg # not to be eliminated). 75095a3d36dfSmrg pre_post_deps= 75105a3d36dfSmrg if $opt_duplicate_compiler_generated_deps; then 75115a3d36dfSmrg for pre_post_dep in $predeps $postdeps; do 75125a3d36dfSmrg case "$pre_post_deps " in 751341c30155Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 75145a3d36dfSmrg esac 751541c30155Smrg func_append pre_post_deps " $pre_post_dep" 75165a3d36dfSmrg done 75175a3d36dfSmrg fi 75185a3d36dfSmrg pre_post_deps= 75195a3d36dfSmrg fi 75205a3d36dfSmrg 75215a3d36dfSmrg deplibs= 75225a3d36dfSmrg newdependency_libs= 75235a3d36dfSmrg newlib_search_path= 75245a3d36dfSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 75255a3d36dfSmrg notinst_deplibs= # not-installed libtool libraries 75265a3d36dfSmrg notinst_path= # paths that contain not-installed libtool libraries 75275a3d36dfSmrg 75285a3d36dfSmrg case $linkmode in 75295a3d36dfSmrg lib) 75305a3d36dfSmrg passes="conv dlpreopen link" 75315a3d36dfSmrg for file in $dlfiles $dlprefiles; do 75325a3d36dfSmrg case $file in 75335a3d36dfSmrg *.la) ;; 75345a3d36dfSmrg *) 7535b43acbb4Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 75365a3d36dfSmrg ;; 75375a3d36dfSmrg esac 75385a3d36dfSmrg done 75395a3d36dfSmrg ;; 75405a3d36dfSmrg prog) 75415a3d36dfSmrg compile_deplibs= 75425a3d36dfSmrg finalize_deplibs= 7543b43acbb4Smrg alldeplibs=false 75445a3d36dfSmrg newdlfiles= 75455a3d36dfSmrg newdlprefiles= 75465a3d36dfSmrg passes="conv scan dlopen dlpreopen link" 75475a3d36dfSmrg ;; 75485a3d36dfSmrg *) passes="conv" 75495a3d36dfSmrg ;; 75505a3d36dfSmrg esac 75515a3d36dfSmrg 75525a3d36dfSmrg for pass in $passes; do 75535a3d36dfSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 75545a3d36dfSmrg # so that -L comes before libs that need it for instance... 7555b43acbb4Smrg if test lib,link = "$linkmode,$pass"; then 75565a3d36dfSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 75575a3d36dfSmrg ## order, and fix it there properly 75585a3d36dfSmrg tmp_deplibs= 75595a3d36dfSmrg for deplib in $deplibs; do 75605a3d36dfSmrg tmp_deplibs="$deplib $tmp_deplibs" 75615a3d36dfSmrg done 7562b43acbb4Smrg deplibs=$tmp_deplibs 75635a3d36dfSmrg fi 75645a3d36dfSmrg 7565b43acbb4Smrg if test lib,link = "$linkmode,$pass" || 7566b43acbb4Smrg test prog,scan = "$linkmode,$pass"; then 7567b43acbb4Smrg libs=$deplibs 75685a3d36dfSmrg deplibs= 75695a3d36dfSmrg fi 7570b43acbb4Smrg if test prog = "$linkmode"; then 75715a3d36dfSmrg case $pass in 7572b43acbb4Smrg dlopen) libs=$dlfiles ;; 7573b43acbb4Smrg dlpreopen) libs=$dlprefiles ;; 7574a97c3f35Smrg link) 7575a97c3f35Smrg libs="$deplibs %DEPLIBS%" 7576a97c3f35Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 7577a97c3f35Smrg ;; 75785a3d36dfSmrg esac 75795a3d36dfSmrg fi 7580b43acbb4Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 75815a3d36dfSmrg # Collect and forward deplibs of preopened libtool libs 75825a3d36dfSmrg for lib in $dlprefiles; do 75835a3d36dfSmrg # Ignore non-libtool-libs 75845a3d36dfSmrg dependency_libs= 758541c30155Smrg func_resolve_sysroot "$lib" 75865a3d36dfSmrg case $lib in 758741c30155Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 75885a3d36dfSmrg esac 75895a3d36dfSmrg 75905a3d36dfSmrg # Collect preopened libtool deplibs, except any this library 75915a3d36dfSmrg # has declared as weak libs 75925a3d36dfSmrg for deplib in $dependency_libs; do 759341c30155Smrg func_basename "$deplib" 759441c30155Smrg deplib_base=$func_basename_result 75955a3d36dfSmrg case " $weak_libs " in 75965a3d36dfSmrg *" $deplib_base "*) ;; 759741c30155Smrg *) func_append deplibs " $deplib" ;; 75985a3d36dfSmrg esac 75995a3d36dfSmrg done 76005a3d36dfSmrg done 7601b43acbb4Smrg libs=$dlprefiles 76025a3d36dfSmrg fi 7603b43acbb4Smrg if test dlopen = "$pass"; then 76045a3d36dfSmrg # Collect dlpreopened libraries 7605b43acbb4Smrg save_deplibs=$deplibs 76065a3d36dfSmrg deplibs= 76075a3d36dfSmrg fi 76085a3d36dfSmrg 76095a3d36dfSmrg for deplib in $libs; do 76105a3d36dfSmrg lib= 7611b43acbb4Smrg found=false 76125a3d36dfSmrg case $deplib in 7613b020570bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7614b020570bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7615b43acbb4Smrg if test prog,link = "$linkmode,$pass"; then 76165a3d36dfSmrg compile_deplibs="$deplib $compile_deplibs" 76175a3d36dfSmrg finalize_deplibs="$deplib $finalize_deplibs" 76185a3d36dfSmrg else 761941c30155Smrg func_append compiler_flags " $deplib" 7620b43acbb4Smrg if test lib = "$linkmode"; then 76215a3d36dfSmrg case "$new_inherited_linker_flags " in 76225a3d36dfSmrg *" $deplib "*) ;; 762341c30155Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 76245a3d36dfSmrg esac 76255a3d36dfSmrg fi 76265a3d36dfSmrg fi 76275a3d36dfSmrg continue 76285a3d36dfSmrg ;; 76295a3d36dfSmrg -l*) 7630b43acbb4Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7631b43acbb4Smrg func_warning "'-l' is ignored for archives/objects" 76325a3d36dfSmrg continue 76335a3d36dfSmrg fi 76345a3d36dfSmrg func_stripname '-l' '' "$deplib" 76355a3d36dfSmrg name=$func_stripname_result 7636b43acbb4Smrg if test lib = "$linkmode"; then 76375a3d36dfSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 76385a3d36dfSmrg else 76395a3d36dfSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 76405a3d36dfSmrg fi 76415a3d36dfSmrg for searchdir in $searchdirs; do 76425a3d36dfSmrg for search_ext in .la $std_shrext .so .a; do 76435a3d36dfSmrg # Search the libtool library 7644b43acbb4Smrg lib=$searchdir/lib$name$search_ext 76455a3d36dfSmrg if test -f "$lib"; then 7646b43acbb4Smrg if test .la = "$search_ext"; then 7647b43acbb4Smrg found=: 76485a3d36dfSmrg else 7649b43acbb4Smrg found=false 76505a3d36dfSmrg fi 76515a3d36dfSmrg break 2 76525a3d36dfSmrg fi 76535a3d36dfSmrg done 76545a3d36dfSmrg done 7655b43acbb4Smrg if $found; then 7656b43acbb4Smrg # deplib is a libtool library 76575a3d36dfSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 76585a3d36dfSmrg # We need to do some special things here, and not later. 7659b43acbb4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 76605a3d36dfSmrg case " $predeps $postdeps " in 76615a3d36dfSmrg *" $deplib "*) 76625a3d36dfSmrg if func_lalib_p "$lib"; then 76635a3d36dfSmrg library_names= 76645a3d36dfSmrg old_library= 76655a3d36dfSmrg func_source "$lib" 76665a3d36dfSmrg for l in $old_library $library_names; do 7667b43acbb4Smrg ll=$l 76685a3d36dfSmrg done 7669b43acbb4Smrg if test "X$ll" = "X$old_library"; then # only static version available 7670b43acbb4Smrg found=false 76715a3d36dfSmrg func_dirname "$lib" "" "." 7672b43acbb4Smrg ladir=$func_dirname_result 76735a3d36dfSmrg lib=$ladir/$old_library 7674b43acbb4Smrg if test prog,link = "$linkmode,$pass"; then 76755a3d36dfSmrg compile_deplibs="$deplib $compile_deplibs" 76765a3d36dfSmrg finalize_deplibs="$deplib $finalize_deplibs" 76775a3d36dfSmrg else 76785a3d36dfSmrg deplibs="$deplib $deplibs" 7679b43acbb4Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76805a3d36dfSmrg fi 76815a3d36dfSmrg continue 76825a3d36dfSmrg fi 76835a3d36dfSmrg fi 76845a3d36dfSmrg ;; 76855a3d36dfSmrg *) ;; 76865a3d36dfSmrg esac 76875a3d36dfSmrg fi 7688b43acbb4Smrg else 7689b43acbb4Smrg # deplib doesn't seem to be a libtool library 7690b43acbb4Smrg if test prog,link = "$linkmode,$pass"; then 7691b43acbb4Smrg compile_deplibs="$deplib $compile_deplibs" 7692b43acbb4Smrg finalize_deplibs="$deplib $finalize_deplibs" 7693b43acbb4Smrg else 7694b43acbb4Smrg deplibs="$deplib $deplibs" 7695b43acbb4Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7696b43acbb4Smrg fi 7697b43acbb4Smrg continue 76985a3d36dfSmrg fi 76995a3d36dfSmrg ;; # -l 77005a3d36dfSmrg *.ltframework) 7701b43acbb4Smrg if test prog,link = "$linkmode,$pass"; then 77025a3d36dfSmrg compile_deplibs="$deplib $compile_deplibs" 77035a3d36dfSmrg finalize_deplibs="$deplib $finalize_deplibs" 77045a3d36dfSmrg else 77055a3d36dfSmrg deplibs="$deplib $deplibs" 7706b43acbb4Smrg if test lib = "$linkmode"; then 77075a3d36dfSmrg case "$new_inherited_linker_flags " in 77085a3d36dfSmrg *" $deplib "*) ;; 770941c30155Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 77105a3d36dfSmrg esac 77115a3d36dfSmrg fi 77125a3d36dfSmrg fi 77135a3d36dfSmrg continue 77145a3d36dfSmrg ;; 77155a3d36dfSmrg -L*) 77165a3d36dfSmrg case $linkmode in 77175a3d36dfSmrg lib) 77185a3d36dfSmrg deplibs="$deplib $deplibs" 7719b43acbb4Smrg test conv = "$pass" && continue 77205a3d36dfSmrg newdependency_libs="$deplib $newdependency_libs" 77215a3d36dfSmrg func_stripname '-L' '' "$deplib" 772241c30155Smrg func_resolve_sysroot "$func_stripname_result" 772341c30155Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77245a3d36dfSmrg ;; 77255a3d36dfSmrg prog) 7726b43acbb4Smrg if test conv = "$pass"; then 77275a3d36dfSmrg deplibs="$deplib $deplibs" 77285a3d36dfSmrg continue 77295a3d36dfSmrg fi 7730b43acbb4Smrg if test scan = "$pass"; then 77315a3d36dfSmrg deplibs="$deplib $deplibs" 77325a3d36dfSmrg else 77335a3d36dfSmrg compile_deplibs="$deplib $compile_deplibs" 77345a3d36dfSmrg finalize_deplibs="$deplib $finalize_deplibs" 77355a3d36dfSmrg fi 77365a3d36dfSmrg func_stripname '-L' '' "$deplib" 773741c30155Smrg func_resolve_sysroot "$func_stripname_result" 773841c30155Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77395a3d36dfSmrg ;; 77405a3d36dfSmrg *) 7741b43acbb4Smrg func_warning "'-L' is ignored for archives/objects" 77425a3d36dfSmrg ;; 77435a3d36dfSmrg esac # linkmode 77445a3d36dfSmrg continue 77455a3d36dfSmrg ;; # -L 77465a3d36dfSmrg -R*) 7747b43acbb4Smrg if test link = "$pass"; then 77485a3d36dfSmrg func_stripname '-R' '' "$deplib" 774941c30155Smrg func_resolve_sysroot "$func_stripname_result" 775041c30155Smrg dir=$func_resolve_sysroot_result 77515a3d36dfSmrg # Make sure the xrpath contains only unique directories. 77525a3d36dfSmrg case "$xrpath " in 77535a3d36dfSmrg *" $dir "*) ;; 775441c30155Smrg *) func_append xrpath " $dir" ;; 77555a3d36dfSmrg esac 77565a3d36dfSmrg fi 77575a3d36dfSmrg deplibs="$deplib $deplibs" 77585a3d36dfSmrg continue 77595a3d36dfSmrg ;; 776041c30155Smrg *.la) 776141c30155Smrg func_resolve_sysroot "$deplib" 776241c30155Smrg lib=$func_resolve_sysroot_result 776341c30155Smrg ;; 77645a3d36dfSmrg *.$libext) 7765b43acbb4Smrg if test conv = "$pass"; then 77665a3d36dfSmrg deplibs="$deplib $deplibs" 77675a3d36dfSmrg continue 77685a3d36dfSmrg fi 77695a3d36dfSmrg case $linkmode in 77705a3d36dfSmrg lib) 77715a3d36dfSmrg # Linking convenience modules into shared libraries is allowed, 77725a3d36dfSmrg # but linking other static libraries is non-portable. 77735a3d36dfSmrg case " $dlpreconveniencelibs " in 77745a3d36dfSmrg *" $deplib "*) ;; 77755a3d36dfSmrg *) 7776b43acbb4Smrg valid_a_lib=false 77775a3d36dfSmrg case $deplibs_check_method in 77785a3d36dfSmrg match_pattern*) 77795a3d36dfSmrg set dummy $deplibs_check_method; shift 77805a3d36dfSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 778141c30155Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 77825a3d36dfSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 7783b43acbb4Smrg valid_a_lib=: 77845a3d36dfSmrg fi 77855a3d36dfSmrg ;; 77865a3d36dfSmrg pass_all) 7787b43acbb4Smrg valid_a_lib=: 77885a3d36dfSmrg ;; 77895a3d36dfSmrg esac 7790b43acbb4Smrg if $valid_a_lib; then 7791b43acbb4Smrg echo 7792b43acbb4Smrg $ECHO "*** Warning: Linking the shared library $output against the" 7793b43acbb4Smrg $ECHO "*** static library $deplib is not portable!" 7794b43acbb4Smrg deplibs="$deplib $deplibs" 7795b43acbb4Smrg else 779641c30155Smrg echo 77975a3d36dfSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779841c30155Smrg echo "*** I have the capability to make that library automatically link in when" 779941c30155Smrg echo "*** you link to this library. But I can only do this if you have a" 780041c30155Smrg echo "*** shared version of the library, which you do not appear to have" 780141c30155Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 780241c30155Smrg echo "*** that it is just a static archive that I should not use here." 78035a3d36dfSmrg fi 78045a3d36dfSmrg ;; 78055a3d36dfSmrg esac 78065a3d36dfSmrg continue 78075a3d36dfSmrg ;; 78085a3d36dfSmrg prog) 7809b43acbb4Smrg if test link != "$pass"; then 78105a3d36dfSmrg deplibs="$deplib $deplibs" 78115a3d36dfSmrg else 78125a3d36dfSmrg compile_deplibs="$deplib $compile_deplibs" 78135a3d36dfSmrg finalize_deplibs="$deplib $finalize_deplibs" 78145a3d36dfSmrg fi 78155a3d36dfSmrg continue 78165a3d36dfSmrg ;; 78175a3d36dfSmrg esac # linkmode 78185a3d36dfSmrg ;; # *.$libext 78195a3d36dfSmrg *.lo | *.$objext) 7820b43acbb4Smrg if test conv = "$pass"; then 78215a3d36dfSmrg deplibs="$deplib $deplibs" 7822b43acbb4Smrg elif test prog = "$linkmode"; then 7823b43acbb4Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 78245a3d36dfSmrg # If there is no dlopen support or we're linking statically, 78255a3d36dfSmrg # we need to preload. 782641c30155Smrg func_append newdlprefiles " $deplib" 78275a3d36dfSmrg compile_deplibs="$deplib $compile_deplibs" 78285a3d36dfSmrg finalize_deplibs="$deplib $finalize_deplibs" 78295a3d36dfSmrg else 783041c30155Smrg func_append newdlfiles " $deplib" 78315a3d36dfSmrg fi 78325a3d36dfSmrg fi 78335a3d36dfSmrg continue 78345a3d36dfSmrg ;; 78355a3d36dfSmrg %DEPLIBS%) 7836b43acbb4Smrg alldeplibs=: 78375a3d36dfSmrg continue 78385a3d36dfSmrg ;; 78395a3d36dfSmrg esac # case $deplib 78405a3d36dfSmrg 7841b43acbb4Smrg $found || test -f "$lib" \ 7842b43acbb4Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 78435a3d36dfSmrg 78445a3d36dfSmrg # Check to see that this really is a libtool archive. 78455a3d36dfSmrg func_lalib_unsafe_p "$lib" \ 7846b43acbb4Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 78475a3d36dfSmrg 78485a3d36dfSmrg func_dirname "$lib" "" "." 7849b43acbb4Smrg ladir=$func_dirname_result 78505a3d36dfSmrg 78515a3d36dfSmrg dlname= 78525a3d36dfSmrg dlopen= 78535a3d36dfSmrg dlpreopen= 78545a3d36dfSmrg libdir= 78555a3d36dfSmrg library_names= 78565a3d36dfSmrg old_library= 78575a3d36dfSmrg inherited_linker_flags= 78585a3d36dfSmrg # If the library was installed with an old release of libtool, 78595a3d36dfSmrg # it will not redefine variables installed, or shouldnotlink 78605a3d36dfSmrg installed=yes 78615a3d36dfSmrg shouldnotlink=no 78625a3d36dfSmrg avoidtemprpath= 78635a3d36dfSmrg 78645a3d36dfSmrg 78655a3d36dfSmrg # Read the .la file 78665a3d36dfSmrg func_source "$lib" 78675a3d36dfSmrg 78685a3d36dfSmrg # Convert "-framework foo" to "foo.ltframework" 78695a3d36dfSmrg if test -n "$inherited_linker_flags"; then 787041c30155Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 78715a3d36dfSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 78725a3d36dfSmrg case " $new_inherited_linker_flags " in 78735a3d36dfSmrg *" $tmp_inherited_linker_flag "*) ;; 787441c30155Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 78755a3d36dfSmrg esac 78765a3d36dfSmrg done 78775a3d36dfSmrg fi 787841c30155Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7879b43acbb4Smrg if test lib,link = "$linkmode,$pass" || 7880b43acbb4Smrg test prog,scan = "$linkmode,$pass" || 7881b43acbb4Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 788241c30155Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 788341c30155Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 78845a3d36dfSmrg fi 78855a3d36dfSmrg 7886b43acbb4Smrg if test conv = "$pass"; then 78875a3d36dfSmrg # Only check for convenience libraries 78885a3d36dfSmrg deplibs="$lib $deplibs" 78895a3d36dfSmrg if test -z "$libdir"; then 78905a3d36dfSmrg if test -z "$old_library"; then 7891b43acbb4Smrg func_fatal_error "cannot find name of link library for '$lib'" 78925a3d36dfSmrg fi 78935a3d36dfSmrg # It is a libtool convenience library, so add in its objects. 789441c30155Smrg func_append convenience " $ladir/$objdir/$old_library" 789541c30155Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7896a97c3f35Smrg tmp_libs= 7897a97c3f35Smrg for deplib in $dependency_libs; do 7898a97c3f35Smrg deplibs="$deplib $deplibs" 7899a97c3f35Smrg if $opt_preserve_dup_deps; then 7900a97c3f35Smrg case "$tmp_libs " in 7901a97c3f35Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7902a97c3f35Smrg esac 7903a97c3f35Smrg fi 7904a97c3f35Smrg func_append tmp_libs " $deplib" 7905a97c3f35Smrg done 7906b43acbb4Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7907b43acbb4Smrg func_fatal_error "'$lib' is not a convenience library" 79085a3d36dfSmrg fi 79095a3d36dfSmrg continue 79105a3d36dfSmrg fi # $pass = conv 79115a3d36dfSmrg 79125a3d36dfSmrg 79135a3d36dfSmrg # Get the name of the library we link against. 79145a3d36dfSmrg linklib= 791541c30155Smrg if test -n "$old_library" && 7916b43acbb4Smrg { test yes = "$prefer_static_libs" || 7917b43acbb4Smrg test built,no = "$prefer_static_libs,$installed"; }; then 791841c30155Smrg linklib=$old_library 791941c30155Smrg else 792041c30155Smrg for l in $old_library $library_names; do 7921b43acbb4Smrg linklib=$l 792241c30155Smrg done 792341c30155Smrg fi 79245a3d36dfSmrg if test -z "$linklib"; then 7925b43acbb4Smrg func_fatal_error "cannot find name of link library for '$lib'" 79265a3d36dfSmrg fi 79275a3d36dfSmrg 79285a3d36dfSmrg # This library was specified with -dlopen. 7929b43acbb4Smrg if test dlopen = "$pass"; then 7930b43acbb4Smrg test -z "$libdir" \ 7931b43acbb4Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 79325a3d36dfSmrg if test -z "$dlname" || 7933b43acbb4Smrg test yes != "$dlopen_support" || 7934b43acbb4Smrg test no = "$build_libtool_libs" 7935b43acbb4Smrg then 79365a3d36dfSmrg # If there is no dlname, no dlopen support or we're linking 79375a3d36dfSmrg # statically, we need to preload. We also need to preload any 79385a3d36dfSmrg # dependent libraries so libltdl's deplib preloader doesn't 79395a3d36dfSmrg # bomb out in the load deplibs phase. 794041c30155Smrg func_append dlprefiles " $lib $dependency_libs" 79415a3d36dfSmrg else 794241c30155Smrg func_append newdlfiles " $lib" 79435a3d36dfSmrg fi 79445a3d36dfSmrg continue 79455a3d36dfSmrg fi # $pass = dlopen 79465a3d36dfSmrg 79475a3d36dfSmrg # We need an absolute path. 79485a3d36dfSmrg case $ladir in 7949b43acbb4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 79505a3d36dfSmrg *) 79515a3d36dfSmrg abs_ladir=`cd "$ladir" && pwd` 79525a3d36dfSmrg if test -z "$abs_ladir"; then 7953b43acbb4Smrg func_warning "cannot determine absolute directory name of '$ladir'" 79545a3d36dfSmrg func_warning "passing it literally to the linker, although it might fail" 7955b43acbb4Smrg abs_ladir=$ladir 79565a3d36dfSmrg fi 79575a3d36dfSmrg ;; 79585a3d36dfSmrg esac 79595a3d36dfSmrg func_basename "$lib" 7960b43acbb4Smrg laname=$func_basename_result 79615a3d36dfSmrg 79625a3d36dfSmrg # Find the relevant object directory and library name. 7963b43acbb4Smrg if test yes = "$installed"; then 796441c30155Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7965b43acbb4Smrg func_warning "library '$lib' was moved." 7966b43acbb4Smrg dir=$ladir 7967b43acbb4Smrg absdir=$abs_ladir 7968b43acbb4Smrg libdir=$abs_ladir 79695a3d36dfSmrg else 7970b43acbb4Smrg dir=$lt_sysroot$libdir 7971b43acbb4Smrg absdir=$lt_sysroot$libdir 79725a3d36dfSmrg fi 7973b43acbb4Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 79745a3d36dfSmrg else 79755a3d36dfSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7976b43acbb4Smrg dir=$ladir 7977b43acbb4Smrg absdir=$abs_ladir 79785a3d36dfSmrg # Remove this search path later 797941c30155Smrg func_append notinst_path " $abs_ladir" 79805a3d36dfSmrg else 7981b43acbb4Smrg dir=$ladir/$objdir 7982b43acbb4Smrg absdir=$abs_ladir/$objdir 79835a3d36dfSmrg # Remove this search path later 798441c30155Smrg func_append notinst_path " $abs_ladir" 79855a3d36dfSmrg fi 79865a3d36dfSmrg fi # $installed = yes 79875a3d36dfSmrg func_stripname 'lib' '.la' "$laname" 79885a3d36dfSmrg name=$func_stripname_result 79895a3d36dfSmrg 79905a3d36dfSmrg # This library was specified with -dlpreopen. 7991b43acbb4Smrg if test dlpreopen = "$pass"; then 7992b43acbb4Smrg if test -z "$libdir" && test prog = "$linkmode"; then 7993b43acbb4Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 79945a3d36dfSmrg fi 7995b43acbb4Smrg case $host in 799641c30155Smrg # special handling for platforms with PE-DLLs. 799741c30155Smrg *cygwin* | *mingw* | *cegcc* ) 799841c30155Smrg # Linker will automatically link against shared library if both 799941c30155Smrg # static and shared are present. Therefore, ensure we extract 800041c30155Smrg # symbols from the import library if a shared library is present 800141c30155Smrg # (otherwise, the dlopen module name will be incorrect). We do 800241c30155Smrg # this by putting the import library name into $newdlprefiles. 800341c30155Smrg # We recover the dlopen module name by 'saving' the la file 800441c30155Smrg # name in a special purpose variable, and (later) extracting the 800541c30155Smrg # dlname from the la file. 800641c30155Smrg if test -n "$dlname"; then 800741c30155Smrg func_tr_sh "$dir/$linklib" 800841c30155Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 800941c30155Smrg func_append newdlprefiles " $dir/$linklib" 801041c30155Smrg else 801141c30155Smrg func_append newdlprefiles " $dir/$old_library" 801241c30155Smrg # Keep a list of preopened convenience libraries to check 801341c30155Smrg # that they are being used correctly in the link pass. 801441c30155Smrg test -z "$libdir" && \ 801541c30155Smrg func_append dlpreconveniencelibs " $dir/$old_library" 801641c30155Smrg fi 801741c30155Smrg ;; 801841c30155Smrg * ) 801941c30155Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 802041c30155Smrg # are required to link). 802141c30155Smrg if test -n "$old_library"; then 802241c30155Smrg func_append newdlprefiles " $dir/$old_library" 802341c30155Smrg # Keep a list of preopened convenience libraries to check 802441c30155Smrg # that they are being used correctly in the link pass. 802541c30155Smrg test -z "$libdir" && \ 802641c30155Smrg func_append dlpreconveniencelibs " $dir/$old_library" 802741c30155Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 802841c30155Smrg elif test -n "$dlname"; then 802941c30155Smrg func_append newdlprefiles " $dir/$dlname" 803041c30155Smrg else 803141c30155Smrg func_append newdlprefiles " $dir/$linklib" 803241c30155Smrg fi 803341c30155Smrg ;; 803441c30155Smrg esac 80355a3d36dfSmrg fi # $pass = dlpreopen 80365a3d36dfSmrg 80375a3d36dfSmrg if test -z "$libdir"; then 80385a3d36dfSmrg # Link the convenience library 8039b43acbb4Smrg if test lib = "$linkmode"; then 80405a3d36dfSmrg deplibs="$dir/$old_library $deplibs" 8041b43acbb4Smrg elif test prog,link = "$linkmode,$pass"; then 80425a3d36dfSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 80435a3d36dfSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 80445a3d36dfSmrg else 80455a3d36dfSmrg deplibs="$lib $deplibs" # used for prog,scan pass 80465a3d36dfSmrg fi 80475a3d36dfSmrg continue 80485a3d36dfSmrg fi 80495a3d36dfSmrg 80505a3d36dfSmrg 8051b43acbb4Smrg if test prog = "$linkmode" && test link != "$pass"; then 805241c30155Smrg func_append newlib_search_path " $ladir" 80535a3d36dfSmrg deplibs="$lib $deplibs" 80545a3d36dfSmrg 8055b43acbb4Smrg linkalldeplibs=false 8056b43acbb4Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8057b43acbb4Smrg test no = "$build_libtool_libs"; then 8058b43acbb4Smrg linkalldeplibs=: 80595a3d36dfSmrg fi 80605a3d36dfSmrg 80615a3d36dfSmrg tmp_libs= 80625a3d36dfSmrg for deplib in $dependency_libs; do 80635a3d36dfSmrg case $deplib in 80645a3d36dfSmrg -L*) func_stripname '-L' '' "$deplib" 806541c30155Smrg func_resolve_sysroot "$func_stripname_result" 806641c30155Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80675a3d36dfSmrg ;; 80685a3d36dfSmrg esac 80695a3d36dfSmrg # Need to link against all dependency_libs? 8070b43acbb4Smrg if $linkalldeplibs; then 80715a3d36dfSmrg deplibs="$deplib $deplibs" 80725a3d36dfSmrg else 80735a3d36dfSmrg # Need to hardcode shared library paths 80745a3d36dfSmrg # or/and link against static libraries 80755a3d36dfSmrg newdependency_libs="$deplib $newdependency_libs" 80765a3d36dfSmrg fi 8077b43acbb4Smrg if $opt_preserve_dup_deps; then 80785a3d36dfSmrg case "$tmp_libs " in 807941c30155Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 80805a3d36dfSmrg esac 80815a3d36dfSmrg fi 808241c30155Smrg func_append tmp_libs " $deplib" 80835a3d36dfSmrg done # for deplib 80845a3d36dfSmrg continue 80855a3d36dfSmrg fi # $linkmode = prog... 80865a3d36dfSmrg 8087b43acbb4Smrg if test prog,link = "$linkmode,$pass"; then 80885a3d36dfSmrg if test -n "$library_names" && 8089b43acbb4Smrg { { test no = "$prefer_static_libs" || 8090b43acbb4Smrg test built,yes = "$prefer_static_libs,$installed"; } || 80915a3d36dfSmrg test -z "$old_library"; }; then 80925a3d36dfSmrg # We need to hardcode the library path 8093b43acbb4Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 80945a3d36dfSmrg # Make sure the rpath contains only unique directories. 8095b43acbb4Smrg case $temp_rpath: in 80965a3d36dfSmrg *"$absdir:"*) ;; 809741c30155Smrg *) func_append temp_rpath "$absdir:" ;; 80985a3d36dfSmrg esac 80995a3d36dfSmrg fi 81005a3d36dfSmrg 81015a3d36dfSmrg # Hardcode the library path. 81025a3d36dfSmrg # Skip directories that are in the system default run-time 81035a3d36dfSmrg # search path. 81045a3d36dfSmrg case " $sys_lib_dlsearch_path " in 81055a3d36dfSmrg *" $absdir "*) ;; 81065a3d36dfSmrg *) 81075a3d36dfSmrg case "$compile_rpath " in 81085a3d36dfSmrg *" $absdir "*) ;; 810941c30155Smrg *) func_append compile_rpath " $absdir" ;; 81105a3d36dfSmrg esac 81115a3d36dfSmrg ;; 81125a3d36dfSmrg esac 81135a3d36dfSmrg case " $sys_lib_dlsearch_path " in 81145a3d36dfSmrg *" $libdir "*) ;; 81155a3d36dfSmrg *) 81165a3d36dfSmrg case "$finalize_rpath " in 81175a3d36dfSmrg *" $libdir "*) ;; 811841c30155Smrg *) func_append finalize_rpath " $libdir" ;; 81195a3d36dfSmrg esac 81205a3d36dfSmrg ;; 81215a3d36dfSmrg esac 81225a3d36dfSmrg fi # $linkmode,$pass = prog,link... 81235a3d36dfSmrg 8124b43acbb4Smrg if $alldeplibs && 8125b43acbb4Smrg { test pass_all = "$deplibs_check_method" || 8126b43acbb4Smrg { test yes = "$build_libtool_libs" && 81275a3d36dfSmrg test -n "$library_names"; }; }; then 81285a3d36dfSmrg # We only need to search for static libraries 81295a3d36dfSmrg continue 81305a3d36dfSmrg fi 81315a3d36dfSmrg fi 81325a3d36dfSmrg 81335a3d36dfSmrg link_static=no # Whether the deplib will be linked statically 81345a3d36dfSmrg use_static_libs=$prefer_static_libs 8135b43acbb4Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 81365a3d36dfSmrg use_static_libs=no 81375a3d36dfSmrg fi 81385a3d36dfSmrg if test -n "$library_names" && 8139b43acbb4Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 81405a3d36dfSmrg case $host in 8141b43acbb4Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 81425a3d36dfSmrg # No point in relinking DLLs because paths are not encoded 814341c30155Smrg func_append notinst_deplibs " $lib" 81445a3d36dfSmrg need_relink=no 81455a3d36dfSmrg ;; 81465a3d36dfSmrg *) 8147b43acbb4Smrg if test no = "$installed"; then 814841c30155Smrg func_append notinst_deplibs " $lib" 81495a3d36dfSmrg need_relink=yes 81505a3d36dfSmrg fi 81515a3d36dfSmrg ;; 81525a3d36dfSmrg esac 81535a3d36dfSmrg # This is a shared library 81545a3d36dfSmrg 81555a3d36dfSmrg # Warn about portability, can't link against -module's on some 81565a3d36dfSmrg # systems (darwin). Don't bleat about dlopened modules though! 8157b43acbb4Smrg dlopenmodule= 81585a3d36dfSmrg for dlpremoduletest in $dlprefiles; do 81595a3d36dfSmrg if test "X$dlpremoduletest" = "X$lib"; then 8160b43acbb4Smrg dlopenmodule=$dlpremoduletest 81615a3d36dfSmrg break 81625a3d36dfSmrg fi 81635a3d36dfSmrg done 8164b43acbb4Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 816541c30155Smrg echo 8166b43acbb4Smrg if test prog = "$linkmode"; then 81675a3d36dfSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 81685a3d36dfSmrg else 81695a3d36dfSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 81705a3d36dfSmrg fi 81715a3d36dfSmrg $ECHO "*** $linklib is not portable!" 81725a3d36dfSmrg fi 8173b43acbb4Smrg if test lib = "$linkmode" && 8174b43acbb4Smrg test yes = "$hardcode_into_libs"; then 81755a3d36dfSmrg # Hardcode the library path. 81765a3d36dfSmrg # Skip directories that are in the system default run-time 81775a3d36dfSmrg # search path. 81785a3d36dfSmrg case " $sys_lib_dlsearch_path " in 81795a3d36dfSmrg *" $absdir "*) ;; 81805a3d36dfSmrg *) 81815a3d36dfSmrg case "$compile_rpath " in 81825a3d36dfSmrg *" $absdir "*) ;; 818341c30155Smrg *) func_append compile_rpath " $absdir" ;; 81845a3d36dfSmrg esac 81855a3d36dfSmrg ;; 81865a3d36dfSmrg esac 81875a3d36dfSmrg case " $sys_lib_dlsearch_path " in 81885a3d36dfSmrg *" $libdir "*) ;; 81895a3d36dfSmrg *) 81905a3d36dfSmrg case "$finalize_rpath " in 81915a3d36dfSmrg *" $libdir "*) ;; 819241c30155Smrg *) func_append finalize_rpath " $libdir" ;; 81935a3d36dfSmrg esac 81945a3d36dfSmrg ;; 81955a3d36dfSmrg esac 81965a3d36dfSmrg fi 81975a3d36dfSmrg 81985a3d36dfSmrg if test -n "$old_archive_from_expsyms_cmds"; then 81995a3d36dfSmrg # figure out the soname 82005a3d36dfSmrg set dummy $library_names 82015a3d36dfSmrg shift 8202b43acbb4Smrg realname=$1 82035a3d36dfSmrg shift 82045a3d36dfSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 82055a3d36dfSmrg # use dlname if we got it. it's perfectly good, no? 82065a3d36dfSmrg if test -n "$dlname"; then 8207b43acbb4Smrg soname=$dlname 82085a3d36dfSmrg elif test -n "$soname_spec"; then 82095a3d36dfSmrg # bleh windows 82105a3d36dfSmrg case $host in 8211b43acbb4Smrg *cygwin* | mingw* | *cegcc* | *os2*) 82125a3d36dfSmrg func_arith $current - $age 82135a3d36dfSmrg major=$func_arith_result 8214b43acbb4Smrg versuffix=-$major 82155a3d36dfSmrg ;; 82165a3d36dfSmrg esac 82175a3d36dfSmrg eval soname=\"$soname_spec\" 82185a3d36dfSmrg else 8219b43acbb4Smrg soname=$realname 82205a3d36dfSmrg fi 82215a3d36dfSmrg 82225a3d36dfSmrg # Make a new name for the extract_expsyms_cmds to use 8223b43acbb4Smrg soroot=$soname 82245a3d36dfSmrg func_basename "$soroot" 8225b43acbb4Smrg soname=$func_basename_result 82265a3d36dfSmrg func_stripname 'lib' '.dll' "$soname" 82275a3d36dfSmrg newlib=libimp-$func_stripname_result.a 82285a3d36dfSmrg 82295a3d36dfSmrg # If the library has no export list, then create one now 82305a3d36dfSmrg if test -f "$output_objdir/$soname-def"; then : 82315a3d36dfSmrg else 8232b43acbb4Smrg func_verbose "extracting exported symbol list from '$soname'" 82335a3d36dfSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 82345a3d36dfSmrg fi 82355a3d36dfSmrg 82365a3d36dfSmrg # Create $newlib 82375a3d36dfSmrg if test -f "$output_objdir/$newlib"; then :; else 8238b43acbb4Smrg func_verbose "generating import library for '$soname'" 82395a3d36dfSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 82405a3d36dfSmrg fi 82415a3d36dfSmrg # make sure the library variables are pointing to the new library 82425a3d36dfSmrg dir=$output_objdir 82435a3d36dfSmrg linklib=$newlib 82445a3d36dfSmrg fi # test -n "$old_archive_from_expsyms_cmds" 82455a3d36dfSmrg 8246b43acbb4Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 82475a3d36dfSmrg add_shlibpath= 82485a3d36dfSmrg add_dir= 82495a3d36dfSmrg add= 82505a3d36dfSmrg lib_linked=yes 82515a3d36dfSmrg case $hardcode_action in 82525a3d36dfSmrg immediate | unsupported) 8253b43acbb4Smrg if test no = "$hardcode_direct"; then 8254b43acbb4Smrg add=$dir/$linklib 82555a3d36dfSmrg case $host in 8256b43acbb4Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8257b43acbb4Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 82585a3d36dfSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8259b43acbb4Smrg *-*-unixware7*) add_dir=-L$dir ;; 82605a3d36dfSmrg *-*-darwin* ) 8261b43acbb4Smrg # if the lib is a (non-dlopened) module then we cannot 82625a3d36dfSmrg # link against it, someone is ignoring the earlier warnings 82635a3d36dfSmrg if /usr/bin/file -L $add 2> /dev/null | 8264b43acbb4Smrg $GREP ": [^:]* bundle" >/dev/null; then 82655a3d36dfSmrg if test "X$dlopenmodule" != "X$lib"; then 82665a3d36dfSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8267b43acbb4Smrg if test -z "$old_library"; then 826841c30155Smrg echo 826941c30155Smrg echo "*** And there doesn't seem to be a static archive available" 827041c30155Smrg echo "*** The link will probably fail, sorry" 82715a3d36dfSmrg else 8272b43acbb4Smrg add=$dir/$old_library 82735a3d36dfSmrg fi 82745a3d36dfSmrg elif test -n "$old_library"; then 8275b43acbb4Smrg add=$dir/$old_library 82765a3d36dfSmrg fi 82775a3d36dfSmrg fi 82785a3d36dfSmrg esac 8279b43acbb4Smrg elif test no = "$hardcode_minus_L"; then 82805a3d36dfSmrg case $host in 8281b43acbb4Smrg *-*-sunos*) add_shlibpath=$dir ;; 82825a3d36dfSmrg esac 8283b43acbb4Smrg add_dir=-L$dir 8284b43acbb4Smrg add=-l$name 8285b43acbb4Smrg elif test no = "$hardcode_shlibpath_var"; then 8286b43acbb4Smrg add_shlibpath=$dir 8287b43acbb4Smrg add=-l$name 82885a3d36dfSmrg else 82895a3d36dfSmrg lib_linked=no 82905a3d36dfSmrg fi 82915a3d36dfSmrg ;; 82925a3d36dfSmrg relink) 8293b43acbb4Smrg if test yes = "$hardcode_direct" && 8294b43acbb4Smrg test no = "$hardcode_direct_absolute"; then 8295b43acbb4Smrg add=$dir/$linklib 8296b43acbb4Smrg elif test yes = "$hardcode_minus_L"; then 8297b43acbb4Smrg add_dir=-L$absdir 82985a3d36dfSmrg # Try looking first in the location we're being installed to. 82995a3d36dfSmrg if test -n "$inst_prefix_dir"; then 83005a3d36dfSmrg case $libdir in 83015a3d36dfSmrg [\\/]*) 830241c30155Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 83035a3d36dfSmrg ;; 83045a3d36dfSmrg esac 83055a3d36dfSmrg fi 8306b43acbb4Smrg add=-l$name 8307b43acbb4Smrg elif test yes = "$hardcode_shlibpath_var"; then 8308b43acbb4Smrg add_shlibpath=$dir 8309b43acbb4Smrg add=-l$name 83105a3d36dfSmrg else 83115a3d36dfSmrg lib_linked=no 83125a3d36dfSmrg fi 83135a3d36dfSmrg ;; 83145a3d36dfSmrg *) lib_linked=no ;; 83155a3d36dfSmrg esac 83165a3d36dfSmrg 8317b43acbb4Smrg if test yes != "$lib_linked"; then 83185a3d36dfSmrg func_fatal_configuration "unsupported hardcode properties" 83195a3d36dfSmrg fi 83205a3d36dfSmrg 83215a3d36dfSmrg if test -n "$add_shlibpath"; then 83225a3d36dfSmrg case :$compile_shlibpath: in 83235a3d36dfSmrg *":$add_shlibpath:"*) ;; 832441c30155Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 83255a3d36dfSmrg esac 83265a3d36dfSmrg fi 8327b43acbb4Smrg if test prog = "$linkmode"; then 83285a3d36dfSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 83295a3d36dfSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 83305a3d36dfSmrg else 83315a3d36dfSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83325a3d36dfSmrg test -n "$add" && deplibs="$add $deplibs" 8333b43acbb4Smrg if test yes != "$hardcode_direct" && 8334b43acbb4Smrg test yes != "$hardcode_minus_L" && 8335b43acbb4Smrg test yes = "$hardcode_shlibpath_var"; then 83365a3d36dfSmrg case :$finalize_shlibpath: in 83375a3d36dfSmrg *":$libdir:"*) ;; 833841c30155Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83395a3d36dfSmrg esac 83405a3d36dfSmrg fi 83415a3d36dfSmrg fi 83425a3d36dfSmrg fi 83435a3d36dfSmrg 8344b43acbb4Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 83455a3d36dfSmrg add_shlibpath= 83465a3d36dfSmrg add_dir= 83475a3d36dfSmrg add= 83485a3d36dfSmrg # Finalize command for both is simple: just hardcode it. 8349b43acbb4Smrg if test yes = "$hardcode_direct" && 8350b43acbb4Smrg test no = "$hardcode_direct_absolute"; then 8351b43acbb4Smrg add=$libdir/$linklib 8352b43acbb4Smrg elif test yes = "$hardcode_minus_L"; then 8353b43acbb4Smrg add_dir=-L$libdir 8354b43acbb4Smrg add=-l$name 8355b43acbb4Smrg elif test yes = "$hardcode_shlibpath_var"; then 83565a3d36dfSmrg case :$finalize_shlibpath: in 83575a3d36dfSmrg *":$libdir:"*) ;; 835841c30155Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83595a3d36dfSmrg esac 8360b43acbb4Smrg add=-l$name 8361b43acbb4Smrg elif test yes = "$hardcode_automatic"; then 83625a3d36dfSmrg if test -n "$inst_prefix_dir" && 8363b43acbb4Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8364b43acbb4Smrg add=$inst_prefix_dir$libdir/$linklib 83655a3d36dfSmrg else 8366b43acbb4Smrg add=$libdir/$linklib 83675a3d36dfSmrg fi 83685a3d36dfSmrg else 83695a3d36dfSmrg # We cannot seem to hardcode it, guess we'll fake it. 8370b43acbb4Smrg add_dir=-L$libdir 83715a3d36dfSmrg # Try looking first in the location we're being installed to. 83725a3d36dfSmrg if test -n "$inst_prefix_dir"; then 83735a3d36dfSmrg case $libdir in 83745a3d36dfSmrg [\\/]*) 837541c30155Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 83765a3d36dfSmrg ;; 83775a3d36dfSmrg esac 83785a3d36dfSmrg fi 8379b43acbb4Smrg add=-l$name 83805a3d36dfSmrg fi 83815a3d36dfSmrg 8382b43acbb4Smrg if test prog = "$linkmode"; then 83835a3d36dfSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 83845a3d36dfSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 83855a3d36dfSmrg else 83865a3d36dfSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83875a3d36dfSmrg test -n "$add" && deplibs="$add $deplibs" 83885a3d36dfSmrg fi 83895a3d36dfSmrg fi 8390b43acbb4Smrg elif test prog = "$linkmode"; then 83915a3d36dfSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 83925a3d36dfSmrg # is not unsupported. This is valid on all known static and 83935a3d36dfSmrg # shared platforms. 8394b43acbb4Smrg if test unsupported != "$hardcode_direct"; then 8395b43acbb4Smrg test -n "$old_library" && linklib=$old_library 83965a3d36dfSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 83975a3d36dfSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 83985a3d36dfSmrg else 83995a3d36dfSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 84005a3d36dfSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 84015a3d36dfSmrg fi 8402b43acbb4Smrg elif test yes = "$build_libtool_libs"; then 84035a3d36dfSmrg # Not a shared library 8404b43acbb4Smrg if test pass_all != "$deplibs_check_method"; then 84055a3d36dfSmrg # We're trying link a shared library against a static one 84065a3d36dfSmrg # but the system doesn't support it. 84075a3d36dfSmrg 84085a3d36dfSmrg # Just print a warning and add the library to dependency_libs so 84095a3d36dfSmrg # that the program can be linked against the static library. 841041c30155Smrg echo 8411b43acbb4Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 841241c30155Smrg echo "*** I have the capability to make that library automatically link in when" 841341c30155Smrg echo "*** you link to this library. But I can only do this if you have a" 841441c30155Smrg echo "*** shared version of the library, which you do not appear to have." 8415b43acbb4Smrg if test yes = "$module"; then 841641c30155Smrg echo "*** But as you try to build a module library, libtool will still create " 841741c30155Smrg echo "*** a static module, that should work as long as the dlopening application" 841841c30155Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 84195a3d36dfSmrg if test -z "$global_symbol_pipe"; then 842041c30155Smrg echo 842141c30155Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8422b43acbb4Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 842341c30155Smrg echo "*** not find such a program. So, this module is probably useless." 8424b43acbb4Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 84255a3d36dfSmrg fi 8426b43acbb4Smrg if test no = "$build_old_libs"; then 84275a3d36dfSmrg build_libtool_libs=module 84285a3d36dfSmrg build_old_libs=yes 84295a3d36dfSmrg else 84305a3d36dfSmrg build_libtool_libs=no 84315a3d36dfSmrg fi 84325a3d36dfSmrg fi 84335a3d36dfSmrg else 84345a3d36dfSmrg deplibs="$dir/$old_library $deplibs" 84355a3d36dfSmrg link_static=yes 84365a3d36dfSmrg fi 84375a3d36dfSmrg fi # link shared/static library? 84385a3d36dfSmrg 8439b43acbb4Smrg if test lib = "$linkmode"; then 84405a3d36dfSmrg if test -n "$dependency_libs" && 8441b43acbb4Smrg { test yes != "$hardcode_into_libs" || 8442b43acbb4Smrg test yes = "$build_old_libs" || 8443b43acbb4Smrg test yes = "$link_static"; }; then 84445a3d36dfSmrg # Extract -R from dependency_libs 84455a3d36dfSmrg temp_deplibs= 84465a3d36dfSmrg for libdir in $dependency_libs; do 84475a3d36dfSmrg case $libdir in 84485a3d36dfSmrg -R*) func_stripname '-R' '' "$libdir" 84495a3d36dfSmrg temp_xrpath=$func_stripname_result 84505a3d36dfSmrg case " $xrpath " in 84515a3d36dfSmrg *" $temp_xrpath "*) ;; 845241c30155Smrg *) func_append xrpath " $temp_xrpath";; 84535a3d36dfSmrg esac;; 845441c30155Smrg *) func_append temp_deplibs " $libdir";; 84555a3d36dfSmrg esac 84565a3d36dfSmrg done 8457b43acbb4Smrg dependency_libs=$temp_deplibs 84585a3d36dfSmrg fi 84595a3d36dfSmrg 846041c30155Smrg func_append newlib_search_path " $absdir" 84615a3d36dfSmrg # Link against this library 8462b43acbb4Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 84635a3d36dfSmrg # ... and its dependency_libs 84645a3d36dfSmrg tmp_libs= 84655a3d36dfSmrg for deplib in $dependency_libs; do 84665a3d36dfSmrg newdependency_libs="$deplib $newdependency_libs" 846741c30155Smrg case $deplib in 846841c30155Smrg -L*) func_stripname '-L' '' "$deplib" 846941c30155Smrg func_resolve_sysroot "$func_stripname_result";; 847041c30155Smrg *) func_resolve_sysroot "$deplib" ;; 847141c30155Smrg esac 8472b43acbb4Smrg if $opt_preserve_dup_deps; then 84735a3d36dfSmrg case "$tmp_libs " in 847441c30155Smrg *" $func_resolve_sysroot_result "*) 847541c30155Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 84765a3d36dfSmrg esac 84775a3d36dfSmrg fi 847841c30155Smrg func_append tmp_libs " $func_resolve_sysroot_result" 84795a3d36dfSmrg done 84805a3d36dfSmrg 8481b43acbb4Smrg if test no != "$link_all_deplibs"; then 84825a3d36dfSmrg # Add the search paths of all dependency libraries 84835a3d36dfSmrg for deplib in $dependency_libs; do 848441c30155Smrg path= 84855a3d36dfSmrg case $deplib in 8486b43acbb4Smrg -L*) path=$deplib ;; 84875a3d36dfSmrg *.la) 848841c30155Smrg func_resolve_sysroot "$deplib" 848941c30155Smrg deplib=$func_resolve_sysroot_result 84905a3d36dfSmrg func_dirname "$deplib" "" "." 849141c30155Smrg dir=$func_dirname_result 84925a3d36dfSmrg # We need an absolute path. 84935a3d36dfSmrg case $dir in 8494b43acbb4Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 84955a3d36dfSmrg *) 84965a3d36dfSmrg absdir=`cd "$dir" && pwd` 84975a3d36dfSmrg if test -z "$absdir"; then 8498b43acbb4Smrg func_warning "cannot determine absolute directory name of '$dir'" 8499b43acbb4Smrg absdir=$dir 85005a3d36dfSmrg fi 85015a3d36dfSmrg ;; 85025a3d36dfSmrg esac 85035a3d36dfSmrg if $GREP "^installed=no" $deplib > /dev/null; then 85045a3d36dfSmrg case $host in 85055a3d36dfSmrg *-*-darwin*) 85065a3d36dfSmrg depdepl= 8507b43acbb4Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8508b43acbb4Smrg if test -n "$deplibrary_names"; then 8509b43acbb4Smrg for tmp in $deplibrary_names; do 85105a3d36dfSmrg depdepl=$tmp 85115a3d36dfSmrg done 8512b43acbb4Smrg if test -f "$absdir/$objdir/$depdepl"; then 8513b43acbb4Smrg depdepl=$absdir/$objdir/$depdepl 8514b43acbb4Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85155a3d36dfSmrg if test -z "$darwin_install_name"; then 8516b43acbb4Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85175a3d36dfSmrg fi 8518b43acbb4Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8519b43acbb4Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 85205a3d36dfSmrg path= 85215a3d36dfSmrg fi 85225a3d36dfSmrg fi 85235a3d36dfSmrg ;; 85245a3d36dfSmrg *) 8525b43acbb4Smrg path=-L$absdir/$objdir 85265a3d36dfSmrg ;; 85275a3d36dfSmrg esac 85285a3d36dfSmrg else 8529b43acbb4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 85305a3d36dfSmrg test -z "$libdir" && \ 8531b43acbb4Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 85325a3d36dfSmrg test "$absdir" != "$libdir" && \ 8533b43acbb4Smrg func_warning "'$deplib' seems to be moved" 85345a3d36dfSmrg 8535b43acbb4Smrg path=-L$absdir 85365a3d36dfSmrg fi 85375a3d36dfSmrg ;; 85385a3d36dfSmrg esac 85395a3d36dfSmrg case " $deplibs " in 85405a3d36dfSmrg *" $path "*) ;; 85415a3d36dfSmrg *) deplibs="$path $deplibs" ;; 85425a3d36dfSmrg esac 85435a3d36dfSmrg done 85445a3d36dfSmrg fi # link_all_deplibs != no 85455a3d36dfSmrg fi # linkmode = lib 85465a3d36dfSmrg done # for deplib in $libs 8547b43acbb4Smrg if test link = "$pass"; then 8548b43acbb4Smrg if test prog = "$linkmode"; then 85495a3d36dfSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 85505a3d36dfSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 85515a3d36dfSmrg else 855241c30155Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 85535a3d36dfSmrg fi 85545a3d36dfSmrg fi 8555b43acbb4Smrg dependency_libs=$newdependency_libs 8556b43acbb4Smrg if test dlpreopen = "$pass"; then 85575a3d36dfSmrg # Link the dlpreopened libraries before other libraries 85585a3d36dfSmrg for deplib in $save_deplibs; do 85595a3d36dfSmrg deplibs="$deplib $deplibs" 85605a3d36dfSmrg done 85615a3d36dfSmrg fi 8562b43acbb4Smrg if test dlopen != "$pass"; then 8563b43acbb4Smrg test conv = "$pass" || { 85645a3d36dfSmrg # Make sure lib_search_path contains only unique directories. 85655a3d36dfSmrg lib_search_path= 85665a3d36dfSmrg for dir in $newlib_search_path; do 85675a3d36dfSmrg case "$lib_search_path " in 85685a3d36dfSmrg *" $dir "*) ;; 856941c30155Smrg *) func_append lib_search_path " $dir" ;; 85705a3d36dfSmrg esac 85715a3d36dfSmrg done 85725a3d36dfSmrg newlib_search_path= 8573b43acbb4Smrg } 85745a3d36dfSmrg 8575b43acbb4Smrg if test prog,link = "$linkmode,$pass"; then 85765a3d36dfSmrg vars="compile_deplibs finalize_deplibs" 8577b43acbb4Smrg else 8578b43acbb4Smrg vars=deplibs 85795a3d36dfSmrg fi 85805a3d36dfSmrg for var in $vars dependency_libs; do 85815a3d36dfSmrg # Add libraries to $var in reverse order 85825a3d36dfSmrg eval tmp_libs=\"\$$var\" 85835a3d36dfSmrg new_libs= 85845a3d36dfSmrg for deplib in $tmp_libs; do 85855a3d36dfSmrg # FIXME: Pedantically, this is the right thing to do, so 85865a3d36dfSmrg # that some nasty dependency loop isn't accidentally 85875a3d36dfSmrg # broken: 85885a3d36dfSmrg #new_libs="$deplib $new_libs" 85895a3d36dfSmrg # Pragmatically, this seems to cause very few problems in 85905a3d36dfSmrg # practice: 85915a3d36dfSmrg case $deplib in 85925a3d36dfSmrg -L*) new_libs="$deplib $new_libs" ;; 85935a3d36dfSmrg -R*) ;; 85945a3d36dfSmrg *) 85955a3d36dfSmrg # And here is the reason: when a library appears more 85965a3d36dfSmrg # than once as an explicit dependence of a library, or 85975a3d36dfSmrg # is implicitly linked in more than once by the 85985a3d36dfSmrg # compiler, it is considered special, and multiple 85995a3d36dfSmrg # occurrences thereof are not removed. Compare this 86005a3d36dfSmrg # with having the same library being listed as a 86015a3d36dfSmrg # dependency of multiple other libraries: in this case, 86025a3d36dfSmrg # we know (pedantically, we assume) the library does not 86035a3d36dfSmrg # need to be listed more than once, so we keep only the 86045a3d36dfSmrg # last copy. This is not always right, but it is rare 86055a3d36dfSmrg # enough that we require users that really mean to play 86065a3d36dfSmrg # such unportable linking tricks to link the library 86075a3d36dfSmrg # using -Wl,-lname, so that libtool does not consider it 86085a3d36dfSmrg # for duplicate removal. 86095a3d36dfSmrg case " $specialdeplibs " in 86105a3d36dfSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 86115a3d36dfSmrg *) 86125a3d36dfSmrg case " $new_libs " in 86135a3d36dfSmrg *" $deplib "*) ;; 86145a3d36dfSmrg *) new_libs="$deplib $new_libs" ;; 86155a3d36dfSmrg esac 86165a3d36dfSmrg ;; 86175a3d36dfSmrg esac 86185a3d36dfSmrg ;; 86195a3d36dfSmrg esac 86205a3d36dfSmrg done 86215a3d36dfSmrg tmp_libs= 86225a3d36dfSmrg for deplib in $new_libs; do 86235a3d36dfSmrg case $deplib in 86245a3d36dfSmrg -L*) 86255a3d36dfSmrg case " $tmp_libs " in 86265a3d36dfSmrg *" $deplib "*) ;; 862741c30155Smrg *) func_append tmp_libs " $deplib" ;; 86285a3d36dfSmrg esac 86295a3d36dfSmrg ;; 863041c30155Smrg *) func_append tmp_libs " $deplib" ;; 86315a3d36dfSmrg esac 86325a3d36dfSmrg done 86335a3d36dfSmrg eval $var=\"$tmp_libs\" 86345a3d36dfSmrg done # for var 86355a3d36dfSmrg fi 8636b43acbb4Smrg 8637b43acbb4Smrg # Add Sun CC postdeps if required: 8638b43acbb4Smrg test CXX = "$tagname" && { 8639b43acbb4Smrg case $host_os in 8640b43acbb4Smrg linux*) 8641b43acbb4Smrg case `$CC -V 2>&1 | sed 5q` in 8642b43acbb4Smrg *Sun\ C*) # Sun C++ 5.9 8643b43acbb4Smrg func_suncc_cstd_abi 8644b43acbb4Smrg 8645b43acbb4Smrg if test no != "$suncc_use_cstd_abi"; then 8646b43acbb4Smrg func_append postdeps ' -library=Cstd -library=Crun' 8647b43acbb4Smrg fi 8648b43acbb4Smrg ;; 8649b43acbb4Smrg esac 8650b43acbb4Smrg ;; 8651b43acbb4Smrg 8652b43acbb4Smrg solaris*) 8653b43acbb4Smrg func_cc_basename "$CC" 8654b43acbb4Smrg case $func_cc_basename_result in 8655b43acbb4Smrg CC* | sunCC*) 8656b43acbb4Smrg func_suncc_cstd_abi 8657b43acbb4Smrg 8658b43acbb4Smrg if test no != "$suncc_use_cstd_abi"; then 8659b43acbb4Smrg func_append postdeps ' -library=Cstd -library=Crun' 8660b43acbb4Smrg fi 8661b43acbb4Smrg ;; 8662b43acbb4Smrg esac 8663b43acbb4Smrg ;; 8664b43acbb4Smrg esac 8665b43acbb4Smrg } 8666b43acbb4Smrg 86675a3d36dfSmrg # Last step: remove runtime libs from dependency_libs 86685a3d36dfSmrg # (they stay in deplibs) 86695a3d36dfSmrg tmp_libs= 8670b43acbb4Smrg for i in $dependency_libs; do 86715a3d36dfSmrg case " $predeps $postdeps $compiler_lib_search_path " in 86725a3d36dfSmrg *" $i "*) 8673b43acbb4Smrg i= 86745a3d36dfSmrg ;; 86755a3d36dfSmrg esac 8676b43acbb4Smrg if test -n "$i"; then 867741c30155Smrg func_append tmp_libs " $i" 86785a3d36dfSmrg fi 86795a3d36dfSmrg done 86805a3d36dfSmrg dependency_libs=$tmp_libs 86815a3d36dfSmrg done # for pass 8682b43acbb4Smrg if test prog = "$linkmode"; then 8683b43acbb4Smrg dlfiles=$newdlfiles 86845a3d36dfSmrg fi 8685b43acbb4Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8686b43acbb4Smrg dlprefiles=$newdlprefiles 86875a3d36dfSmrg fi 86885a3d36dfSmrg 86895a3d36dfSmrg case $linkmode in 86905a3d36dfSmrg oldlib) 8691b43acbb4Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8692b43acbb4Smrg func_warning "'-dlopen' is ignored for archives" 86935a3d36dfSmrg fi 86945a3d36dfSmrg 86955a3d36dfSmrg case " $deplibs" in 86965a3d36dfSmrg *\ -l* | *\ -L*) 8697b43acbb4Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 86985a3d36dfSmrg esac 86995a3d36dfSmrg 87005a3d36dfSmrg test -n "$rpath" && \ 8701b43acbb4Smrg func_warning "'-rpath' is ignored for archives" 87025a3d36dfSmrg 87035a3d36dfSmrg test -n "$xrpath" && \ 8704b43acbb4Smrg func_warning "'-R' is ignored for archives" 87055a3d36dfSmrg 87065a3d36dfSmrg test -n "$vinfo" && \ 8707b43acbb4Smrg func_warning "'-version-info/-version-number' is ignored for archives" 87085a3d36dfSmrg 87095a3d36dfSmrg test -n "$release" && \ 8710b43acbb4Smrg func_warning "'-release' is ignored for archives" 87115a3d36dfSmrg 87125a3d36dfSmrg test -n "$export_symbols$export_symbols_regex" && \ 8713b43acbb4Smrg func_warning "'-export-symbols' is ignored for archives" 87145a3d36dfSmrg 87155a3d36dfSmrg # Now set the variables for building old libraries. 87165a3d36dfSmrg build_libtool_libs=no 8717b43acbb4Smrg oldlibs=$output 871841c30155Smrg func_append objs "$old_deplibs" 87195a3d36dfSmrg ;; 87205a3d36dfSmrg 87215a3d36dfSmrg lib) 8722b43acbb4Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 87235a3d36dfSmrg case $outputname in 87245a3d36dfSmrg lib*) 87255a3d36dfSmrg func_stripname 'lib' '.la' "$outputname" 87265a3d36dfSmrg name=$func_stripname_result 87275a3d36dfSmrg eval shared_ext=\"$shrext_cmds\" 87285a3d36dfSmrg eval libname=\"$libname_spec\" 87295a3d36dfSmrg ;; 87305a3d36dfSmrg *) 8731b43acbb4Smrg test no = "$module" \ 8732b43acbb4Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 87335a3d36dfSmrg 8734b43acbb4Smrg if test no != "$need_lib_prefix"; then 87355a3d36dfSmrg # Add the "lib" prefix for modules if required 87365a3d36dfSmrg func_stripname '' '.la' "$outputname" 87375a3d36dfSmrg name=$func_stripname_result 87385a3d36dfSmrg eval shared_ext=\"$shrext_cmds\" 87395a3d36dfSmrg eval libname=\"$libname_spec\" 87405a3d36dfSmrg else 87415a3d36dfSmrg func_stripname '' '.la' "$outputname" 87425a3d36dfSmrg libname=$func_stripname_result 87435a3d36dfSmrg fi 87445a3d36dfSmrg ;; 87455a3d36dfSmrg esac 87465a3d36dfSmrg 87475a3d36dfSmrg if test -n "$objs"; then 8748b43acbb4Smrg if test pass_all != "$deplibs_check_method"; then 8749b43acbb4Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 87505a3d36dfSmrg else 875141c30155Smrg echo 87525a3d36dfSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 87535a3d36dfSmrg $ECHO "*** objects $objs is not portable!" 875441c30155Smrg func_append libobjs " $objs" 87555a3d36dfSmrg fi 87565a3d36dfSmrg fi 87575a3d36dfSmrg 8758b43acbb4Smrg test no = "$dlself" \ 8759b43acbb4Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 87605a3d36dfSmrg 87615a3d36dfSmrg set dummy $rpath 87625a3d36dfSmrg shift 8763b43acbb4Smrg test 1 -lt "$#" \ 8764b43acbb4Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 87655a3d36dfSmrg 8766b43acbb4Smrg install_libdir=$1 87675a3d36dfSmrg 87685a3d36dfSmrg oldlibs= 87695a3d36dfSmrg if test -z "$rpath"; then 8770b43acbb4Smrg if test yes = "$build_libtool_libs"; then 87715a3d36dfSmrg # Building a libtool convenience library. 8772b43acbb4Smrg # Some compilers have problems with a '.al' extension so 87735a3d36dfSmrg # convenience libraries should have the same extension an 87745a3d36dfSmrg # archive normally would. 87755a3d36dfSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 87765a3d36dfSmrg build_libtool_libs=convenience 87775a3d36dfSmrg build_old_libs=yes 87785a3d36dfSmrg fi 87795a3d36dfSmrg 87805a3d36dfSmrg test -n "$vinfo" && \ 8781b43acbb4Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 87825a3d36dfSmrg 87835a3d36dfSmrg test -n "$release" && \ 8784b43acbb4Smrg func_warning "'-release' is ignored for convenience libraries" 87855a3d36dfSmrg else 87865a3d36dfSmrg 87875a3d36dfSmrg # Parse the version information argument. 8788b43acbb4Smrg save_ifs=$IFS; IFS=: 87895a3d36dfSmrg set dummy $vinfo 0 0 0 87905a3d36dfSmrg shift 8791b43acbb4Smrg IFS=$save_ifs 87925a3d36dfSmrg 87935a3d36dfSmrg test -n "$7" && \ 8794b43acbb4Smrg func_fatal_help "too many parameters to '-version-info'" 87955a3d36dfSmrg 87965a3d36dfSmrg # convert absolute version numbers to libtool ages 87975a3d36dfSmrg # this retains compatibility with .la files and attempts 87985a3d36dfSmrg # to make the code below a bit more comprehensible 87995a3d36dfSmrg 88005a3d36dfSmrg case $vinfo_number in 88015a3d36dfSmrg yes) 8802b43acbb4Smrg number_major=$1 8803b43acbb4Smrg number_minor=$2 8804b43acbb4Smrg number_revision=$3 88055a3d36dfSmrg # 88065a3d36dfSmrg # There are really only two kinds -- those that 88075a3d36dfSmrg # use the current revision as the major version 88085a3d36dfSmrg # and those that subtract age and use age as 88095a3d36dfSmrg # a minor version. But, then there is irix 8810b43acbb4Smrg # that has an extra 1 added just for fun 88115a3d36dfSmrg # 88125a3d36dfSmrg case $version_type in 8813b020570bSmrg # correct linux to gnu/linux during the next big refactor 8814b43acbb4Smrg darwin|freebsd-elf|linux|osf|windows|none) 88155a3d36dfSmrg func_arith $number_major + $number_minor 88165a3d36dfSmrg current=$func_arith_result 8817b43acbb4Smrg age=$number_minor 8818b43acbb4Smrg revision=$number_revision 88195a3d36dfSmrg ;; 8820b43acbb4Smrg freebsd-aout|qnx|sunos) 8821b43acbb4Smrg current=$number_major 8822b43acbb4Smrg revision=$number_minor 8823b43acbb4Smrg age=0 88245a3d36dfSmrg ;; 88255a3d36dfSmrg irix|nonstopux) 88265a3d36dfSmrg func_arith $number_major + $number_minor 88275a3d36dfSmrg current=$func_arith_result 8828b43acbb4Smrg age=$number_minor 8829b43acbb4Smrg revision=$number_minor 88305a3d36dfSmrg lt_irix_increment=no 88315a3d36dfSmrg ;; 8832a97c3f35Smrg *) 8833a97c3f35Smrg func_fatal_configuration "$modename: unknown library version type '$version_type'" 8834a97c3f35Smrg ;; 88355a3d36dfSmrg esac 88365a3d36dfSmrg ;; 88375a3d36dfSmrg no) 8838b43acbb4Smrg current=$1 8839b43acbb4Smrg revision=$2 8840b43acbb4Smrg age=$3 88415a3d36dfSmrg ;; 88425a3d36dfSmrg esac 88435a3d36dfSmrg 88445a3d36dfSmrg # Check that each of the things are valid numbers. 88455a3d36dfSmrg case $current in 88465a3d36dfSmrg 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]) ;; 88475a3d36dfSmrg *) 8848b43acbb4Smrg func_error "CURRENT '$current' must be a nonnegative integer" 8849b43acbb4Smrg func_fatal_error "'$vinfo' is not valid version information" 88505a3d36dfSmrg ;; 88515a3d36dfSmrg esac 88525a3d36dfSmrg 88535a3d36dfSmrg case $revision in 88545a3d36dfSmrg 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]) ;; 88555a3d36dfSmrg *) 8856b43acbb4Smrg func_error "REVISION '$revision' must be a nonnegative integer" 8857b43acbb4Smrg func_fatal_error "'$vinfo' is not valid version information" 88585a3d36dfSmrg ;; 88595a3d36dfSmrg esac 88605a3d36dfSmrg 88615a3d36dfSmrg case $age in 88625a3d36dfSmrg 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]) ;; 88635a3d36dfSmrg *) 8864b43acbb4Smrg func_error "AGE '$age' must be a nonnegative integer" 8865b43acbb4Smrg func_fatal_error "'$vinfo' is not valid version information" 88665a3d36dfSmrg ;; 88675a3d36dfSmrg esac 88685a3d36dfSmrg 88695a3d36dfSmrg if test "$age" -gt "$current"; then 8870b43acbb4Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 8871b43acbb4Smrg func_fatal_error "'$vinfo' is not valid version information" 88725a3d36dfSmrg fi 88735a3d36dfSmrg 88745a3d36dfSmrg # Calculate the version variables. 88755a3d36dfSmrg major= 88765a3d36dfSmrg versuffix= 88775a3d36dfSmrg verstring= 88785a3d36dfSmrg case $version_type in 88795a3d36dfSmrg none) ;; 88805a3d36dfSmrg 88815a3d36dfSmrg darwin) 88825a3d36dfSmrg # Like Linux, but with the current version available in 88835a3d36dfSmrg # verstring for coding it into the library header 88845a3d36dfSmrg func_arith $current - $age 88855a3d36dfSmrg major=.$func_arith_result 8886b43acbb4Smrg versuffix=$major.$age.$revision 88875a3d36dfSmrg # Darwin ld doesn't like 0 for these options... 88885a3d36dfSmrg func_arith $current + 1 88895a3d36dfSmrg minor_current=$func_arith_result 8890b43acbb4Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88915a3d36dfSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8892b43acbb4Smrg # On Darwin other compilers 8893b43acbb4Smrg case $CC in 8894b43acbb4Smrg nagfor*) 8895b43acbb4Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8896b43acbb4Smrg ;; 8897b43acbb4Smrg *) 8898b43acbb4Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8899b43acbb4Smrg ;; 8900b43acbb4Smrg esac 89015a3d36dfSmrg ;; 89025a3d36dfSmrg 89035a3d36dfSmrg freebsd-aout) 8904b43acbb4Smrg major=.$current 8905b43acbb4Smrg versuffix=.$current.$revision 89065a3d36dfSmrg ;; 89075a3d36dfSmrg 89085a3d36dfSmrg freebsd-elf) 8909b43acbb4Smrg func_arith $current - $age 8910b43acbb4Smrg major=.$func_arith_result 8911b43acbb4Smrg versuffix=$major.$age.$revision 89125a3d36dfSmrg ;; 89135a3d36dfSmrg 89145a3d36dfSmrg irix | nonstopux) 8915b43acbb4Smrg if test no = "$lt_irix_increment"; then 89165a3d36dfSmrg func_arith $current - $age 89175a3d36dfSmrg else 89185a3d36dfSmrg func_arith $current - $age + 1 89195a3d36dfSmrg fi 89205a3d36dfSmrg major=$func_arith_result 89215a3d36dfSmrg 89225a3d36dfSmrg case $version_type in 89235a3d36dfSmrg nonstopux) verstring_prefix=nonstopux ;; 89245a3d36dfSmrg *) verstring_prefix=sgi ;; 89255a3d36dfSmrg esac 8926b43acbb4Smrg verstring=$verstring_prefix$major.$revision 89275a3d36dfSmrg 89285a3d36dfSmrg # Add in all the interfaces that we are compatible with. 89295a3d36dfSmrg loop=$revision 8930b43acbb4Smrg while test 0 -ne "$loop"; do 89315a3d36dfSmrg func_arith $revision - $loop 89325a3d36dfSmrg iface=$func_arith_result 89335a3d36dfSmrg func_arith $loop - 1 89345a3d36dfSmrg loop=$func_arith_result 8935b43acbb4Smrg verstring=$verstring_prefix$major.$iface:$verstring 89365a3d36dfSmrg done 89375a3d36dfSmrg 8938b43acbb4Smrg # Before this point, $major must not contain '.'. 89395a3d36dfSmrg major=.$major 8940b43acbb4Smrg versuffix=$major.$revision 89415a3d36dfSmrg ;; 89425a3d36dfSmrg 8943b020570bSmrg linux) # correct to gnu/linux during the next big refactor 89445a3d36dfSmrg func_arith $current - $age 89455a3d36dfSmrg major=.$func_arith_result 8946b43acbb4Smrg versuffix=$major.$age.$revision 89475a3d36dfSmrg ;; 89485a3d36dfSmrg 89495a3d36dfSmrg osf) 89505a3d36dfSmrg func_arith $current - $age 89515a3d36dfSmrg major=.$func_arith_result 8952b43acbb4Smrg versuffix=.$current.$age.$revision 8953b43acbb4Smrg verstring=$current.$age.$revision 89545a3d36dfSmrg 89555a3d36dfSmrg # Add in all the interfaces that we are compatible with. 89565a3d36dfSmrg loop=$age 8957b43acbb4Smrg while test 0 -ne "$loop"; do 89585a3d36dfSmrg func_arith $current - $loop 89595a3d36dfSmrg iface=$func_arith_result 89605a3d36dfSmrg func_arith $loop - 1 89615a3d36dfSmrg loop=$func_arith_result 8962b43acbb4Smrg verstring=$verstring:$iface.0 89635a3d36dfSmrg done 89645a3d36dfSmrg 89655a3d36dfSmrg # Make executables depend on our current version. 8966b43acbb4Smrg func_append verstring ":$current.0" 89675a3d36dfSmrg ;; 89685a3d36dfSmrg 89695a3d36dfSmrg qnx) 8970b43acbb4Smrg major=.$current 8971b43acbb4Smrg versuffix=.$current 8972b43acbb4Smrg ;; 8973b43acbb4Smrg 8974b43acbb4Smrg sco) 8975b43acbb4Smrg major=.$current 8976b43acbb4Smrg versuffix=.$current 89775a3d36dfSmrg ;; 89785a3d36dfSmrg 89795a3d36dfSmrg sunos) 8980b43acbb4Smrg major=.$current 8981b43acbb4Smrg versuffix=.$current.$revision 89825a3d36dfSmrg ;; 89835a3d36dfSmrg 89845a3d36dfSmrg windows) 89855a3d36dfSmrg # Use '-' rather than '.', since we only want one 8986b43acbb4Smrg # extension on DOS 8.3 file systems. 89875a3d36dfSmrg func_arith $current - $age 89885a3d36dfSmrg major=$func_arith_result 8989b43acbb4Smrg versuffix=-$major 89905a3d36dfSmrg ;; 89915a3d36dfSmrg 89925a3d36dfSmrg *) 8993b43acbb4Smrg func_fatal_configuration "unknown library version type '$version_type'" 89945a3d36dfSmrg ;; 89955a3d36dfSmrg esac 89965a3d36dfSmrg 89975a3d36dfSmrg # Clear the version info if we defaulted, and they specified a release. 89985a3d36dfSmrg if test -z "$vinfo" && test -n "$release"; then 89995a3d36dfSmrg major= 90005a3d36dfSmrg case $version_type in 90015a3d36dfSmrg darwin) 90025a3d36dfSmrg # we can't check for "0.0" in archive_cmds due to quoting 90035a3d36dfSmrg # problems, so we reset it completely 90045a3d36dfSmrg verstring= 90055a3d36dfSmrg ;; 90065a3d36dfSmrg *) 9007b43acbb4Smrg verstring=0.0 90085a3d36dfSmrg ;; 90095a3d36dfSmrg esac 9010b43acbb4Smrg if test no = "$need_version"; then 90115a3d36dfSmrg versuffix= 90125a3d36dfSmrg else 9013b43acbb4Smrg versuffix=.0.0 90145a3d36dfSmrg fi 90155a3d36dfSmrg fi 90165a3d36dfSmrg 90175a3d36dfSmrg # Remove version info from name if versioning should be avoided 9018b43acbb4Smrg if test yes,no = "$avoid_version,$need_version"; then 90195a3d36dfSmrg major= 90205a3d36dfSmrg versuffix= 9021b43acbb4Smrg verstring= 90225a3d36dfSmrg fi 90235a3d36dfSmrg 90245a3d36dfSmrg # Check to see if the archive will have undefined symbols. 9025b43acbb4Smrg if test yes = "$allow_undefined"; then 9026b43acbb4Smrg if test unsupported = "$allow_undefined_flag"; then 9027b43acbb4Smrg if test yes = "$build_old_libs"; then 9028b43acbb4Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9029b43acbb4Smrg build_libtool_libs=no 9030b43acbb4Smrg else 9031b43acbb4Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9032b43acbb4Smrg fi 90335a3d36dfSmrg fi 90345a3d36dfSmrg else 90355a3d36dfSmrg # Don't allow undefined symbols. 9036b43acbb4Smrg allow_undefined_flag=$no_undefined_flag 90375a3d36dfSmrg fi 90385a3d36dfSmrg 90395a3d36dfSmrg fi 90405a3d36dfSmrg 9041b43acbb4Smrg func_generate_dlsyms "$libname" "$libname" : 904241c30155Smrg func_append libobjs " $symfileobj" 9043b43acbb4Smrg test " " = "$libobjs" && libobjs= 90445a3d36dfSmrg 9045b43acbb4Smrg if test relink != "$opt_mode"; then 90465a3d36dfSmrg # Remove our outputs, but don't remove object files since they 90475a3d36dfSmrg # may have been created when compiling PIC objects. 90485a3d36dfSmrg removelist= 90495a3d36dfSmrg tempremovelist=`$ECHO "$output_objdir/*"` 90505a3d36dfSmrg for p in $tempremovelist; do 90515a3d36dfSmrg case $p in 90525a3d36dfSmrg *.$objext | *.gcno) 90535a3d36dfSmrg ;; 9054b43acbb4Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9055b43acbb4Smrg if test -n "$precious_files_regex"; then 90565a3d36dfSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 90575a3d36dfSmrg then 90585a3d36dfSmrg continue 90595a3d36dfSmrg fi 90605a3d36dfSmrg fi 906141c30155Smrg func_append removelist " $p" 90625a3d36dfSmrg ;; 90635a3d36dfSmrg *) ;; 90645a3d36dfSmrg esac 90655a3d36dfSmrg done 90665a3d36dfSmrg test -n "$removelist" && \ 90675a3d36dfSmrg func_show_eval "${RM}r \$removelist" 90685a3d36dfSmrg fi 90695a3d36dfSmrg 90705a3d36dfSmrg # Now set the variables for building old libraries. 9071b43acbb4Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 907241c30155Smrg func_append oldlibs " $output_objdir/$libname.$libext" 90735a3d36dfSmrg 90745a3d36dfSmrg # Transform .lo files to .o files. 9075b43acbb4Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 90765a3d36dfSmrg fi 90775a3d36dfSmrg 90785a3d36dfSmrg # Eliminate all temporary directories. 90795a3d36dfSmrg #for path in $notinst_path; do 908041c30155Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 908141c30155Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 908241c30155Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 90835a3d36dfSmrg #done 90845a3d36dfSmrg 90855a3d36dfSmrg if test -n "$xrpath"; then 90865a3d36dfSmrg # If the user specified any rpath flags, then add them. 90875a3d36dfSmrg temp_xrpath= 90885a3d36dfSmrg for libdir in $xrpath; do 908941c30155Smrg func_replace_sysroot "$libdir" 909041c30155Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 90915a3d36dfSmrg case "$finalize_rpath " in 90925a3d36dfSmrg *" $libdir "*) ;; 909341c30155Smrg *) func_append finalize_rpath " $libdir" ;; 90945a3d36dfSmrg esac 90955a3d36dfSmrg done 9096b43acbb4Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 90975a3d36dfSmrg dependency_libs="$temp_xrpath $dependency_libs" 90985a3d36dfSmrg fi 90995a3d36dfSmrg fi 91005a3d36dfSmrg 91015a3d36dfSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9102b43acbb4Smrg old_dlfiles=$dlfiles 91035a3d36dfSmrg dlfiles= 91045a3d36dfSmrg for lib in $old_dlfiles; do 91055a3d36dfSmrg case " $dlprefiles $dlfiles " in 91065a3d36dfSmrg *" $lib "*) ;; 910741c30155Smrg *) func_append dlfiles " $lib" ;; 91085a3d36dfSmrg esac 91095a3d36dfSmrg done 91105a3d36dfSmrg 91115a3d36dfSmrg # Make sure dlprefiles contains only unique files 9112b43acbb4Smrg old_dlprefiles=$dlprefiles 91135a3d36dfSmrg dlprefiles= 91145a3d36dfSmrg for lib in $old_dlprefiles; do 91155a3d36dfSmrg case "$dlprefiles " in 91165a3d36dfSmrg *" $lib "*) ;; 911741c30155Smrg *) func_append dlprefiles " $lib" ;; 91185a3d36dfSmrg esac 91195a3d36dfSmrg done 91205a3d36dfSmrg 9121b43acbb4Smrg if test yes = "$build_libtool_libs"; then 91225a3d36dfSmrg if test -n "$rpath"; then 91235a3d36dfSmrg case $host in 912441c30155Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 91255a3d36dfSmrg # these systems don't actually have a c library (as such)! 91265a3d36dfSmrg ;; 91275a3d36dfSmrg *-*-rhapsody* | *-*-darwin1.[012]) 91285a3d36dfSmrg # Rhapsody C library is in the System framework 912941c30155Smrg func_append deplibs " System.ltframework" 91305a3d36dfSmrg ;; 91315a3d36dfSmrg *-*-netbsd*) 91325a3d36dfSmrg # Don't link with libc until the a.out ld.so is fixed. 91335a3d36dfSmrg ;; 91345a3d36dfSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 91355a3d36dfSmrg # Do not include libc due to us having libc/libc_r. 91365a3d36dfSmrg ;; 91375a3d36dfSmrg *-*-sco3.2v5* | *-*-sco5v6*) 91385a3d36dfSmrg # Causes problems with __ctype 91395a3d36dfSmrg ;; 91405a3d36dfSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 91415a3d36dfSmrg # Compiler inserts libc in the correct place for threads to work 91425a3d36dfSmrg ;; 91435a3d36dfSmrg *) 91445a3d36dfSmrg # Add libc to deplibs on all other systems if necessary. 9145b43acbb4Smrg if test yes = "$build_libtool_need_lc"; then 914641c30155Smrg func_append deplibs " -lc" 91475a3d36dfSmrg fi 91485a3d36dfSmrg ;; 91495a3d36dfSmrg esac 91505a3d36dfSmrg fi 91515a3d36dfSmrg 91525a3d36dfSmrg # Transform deplibs into only deplibs that can be linked in shared. 91535a3d36dfSmrg name_save=$name 91545a3d36dfSmrg libname_save=$libname 91555a3d36dfSmrg release_save=$release 91565a3d36dfSmrg versuffix_save=$versuffix 91575a3d36dfSmrg major_save=$major 91585a3d36dfSmrg # I'm not sure if I'm treating the release correctly. I think 91595a3d36dfSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 91605a3d36dfSmrg # add it in twice. Is that correct? 9161b43acbb4Smrg release= 9162b43acbb4Smrg versuffix= 9163b43acbb4Smrg major= 91645a3d36dfSmrg newdeplibs= 91655a3d36dfSmrg droppeddeps=no 91665a3d36dfSmrg case $deplibs_check_method in 91675a3d36dfSmrg pass_all) 91685a3d36dfSmrg # Don't check for shared/static. Everything works. 91695a3d36dfSmrg # This might be a little naive. We might want to check 91705a3d36dfSmrg # whether the library exists or not. But this is on 91715a3d36dfSmrg # osf3 & osf4 and I'm not really sure... Just 91725a3d36dfSmrg # implementing what was already the behavior. 91735a3d36dfSmrg newdeplibs=$deplibs 91745a3d36dfSmrg ;; 91755a3d36dfSmrg test_compile) 91765a3d36dfSmrg # This code stresses the "libraries are programs" paradigm to its 91775a3d36dfSmrg # limits. Maybe even breaks it. We compile a program, linking it 91785a3d36dfSmrg # against the deplibs as a proxy for the library. Then we can check 91795a3d36dfSmrg # whether they linked in statically or dynamically with ldd. 91805a3d36dfSmrg $opt_dry_run || $RM conftest.c 91815a3d36dfSmrg cat > conftest.c <<EOF 91825a3d36dfSmrg int main() { return 0; } 91835a3d36dfSmrgEOF 91845a3d36dfSmrg $opt_dry_run || $RM conftest 91855a3d36dfSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 91865a3d36dfSmrg ldd_output=`ldd conftest` 91875a3d36dfSmrg for i in $deplibs; do 91885a3d36dfSmrg case $i in 91895a3d36dfSmrg -l*) 91905a3d36dfSmrg func_stripname -l '' "$i" 91915a3d36dfSmrg name=$func_stripname_result 9192b43acbb4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 91935a3d36dfSmrg case " $predeps $postdeps " in 91945a3d36dfSmrg *" $i "*) 919541c30155Smrg func_append newdeplibs " $i" 9196b43acbb4Smrg i= 91975a3d36dfSmrg ;; 91985a3d36dfSmrg esac 91995a3d36dfSmrg fi 9200b43acbb4Smrg if test -n "$i"; then 92015a3d36dfSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92025a3d36dfSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92035a3d36dfSmrg set dummy $deplib_matches; shift 92045a3d36dfSmrg deplib_match=$1 9205b43acbb4Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 920641c30155Smrg func_append newdeplibs " $i" 92075a3d36dfSmrg else 92085a3d36dfSmrg droppeddeps=yes 920941c30155Smrg echo 92105a3d36dfSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 921141c30155Smrg echo "*** I have the capability to make that library automatically link in when" 921241c30155Smrg echo "*** you link to this library. But I can only do this if you have a" 921341c30155Smrg echo "*** shared version of the library, which I believe you do not have" 921441c30155Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 921541c30155Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 92165a3d36dfSmrg fi 92175a3d36dfSmrg fi 92185a3d36dfSmrg ;; 92195a3d36dfSmrg *) 922041c30155Smrg func_append newdeplibs " $i" 92215a3d36dfSmrg ;; 92225a3d36dfSmrg esac 92235a3d36dfSmrg done 92245a3d36dfSmrg else 92255a3d36dfSmrg # Error occurred in the first compile. Let's try to salvage 92265a3d36dfSmrg # the situation: Compile a separate program for each library. 92275a3d36dfSmrg for i in $deplibs; do 92285a3d36dfSmrg case $i in 92295a3d36dfSmrg -l*) 92305a3d36dfSmrg func_stripname -l '' "$i" 92315a3d36dfSmrg name=$func_stripname_result 92325a3d36dfSmrg $opt_dry_run || $RM conftest 92335a3d36dfSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 92345a3d36dfSmrg ldd_output=`ldd conftest` 9235b43acbb4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92365a3d36dfSmrg case " $predeps $postdeps " in 92375a3d36dfSmrg *" $i "*) 923841c30155Smrg func_append newdeplibs " $i" 9239b43acbb4Smrg i= 92405a3d36dfSmrg ;; 92415a3d36dfSmrg esac 92425a3d36dfSmrg fi 9243b43acbb4Smrg if test -n "$i"; then 92445a3d36dfSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92455a3d36dfSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92465a3d36dfSmrg set dummy $deplib_matches; shift 92475a3d36dfSmrg deplib_match=$1 9248b43acbb4Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 924941c30155Smrg func_append newdeplibs " $i" 92505a3d36dfSmrg else 92515a3d36dfSmrg droppeddeps=yes 925241c30155Smrg echo 92535a3d36dfSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 925441c30155Smrg echo "*** I have the capability to make that library automatically link in when" 925541c30155Smrg echo "*** you link to this library. But I can only do this if you have a" 925641c30155Smrg echo "*** shared version of the library, which you do not appear to have" 925741c30155Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 925841c30155Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 92595a3d36dfSmrg fi 92605a3d36dfSmrg fi 92615a3d36dfSmrg else 92625a3d36dfSmrg droppeddeps=yes 926341c30155Smrg echo 92645a3d36dfSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 926541c30155Smrg echo "*** make it link in! You will probably need to install it or some" 926641c30155Smrg echo "*** library that it depends on before this library will be fully" 926741c30155Smrg echo "*** functional. Installing it before continuing would be even better." 92685a3d36dfSmrg fi 92695a3d36dfSmrg ;; 92705a3d36dfSmrg *) 927141c30155Smrg func_append newdeplibs " $i" 92725a3d36dfSmrg ;; 92735a3d36dfSmrg esac 92745a3d36dfSmrg done 92755a3d36dfSmrg fi 92765a3d36dfSmrg ;; 92775a3d36dfSmrg file_magic*) 92785a3d36dfSmrg set dummy $deplibs_check_method; shift 92795a3d36dfSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 92805a3d36dfSmrg for a_deplib in $deplibs; do 92815a3d36dfSmrg case $a_deplib in 92825a3d36dfSmrg -l*) 92835a3d36dfSmrg func_stripname -l '' "$a_deplib" 92845a3d36dfSmrg name=$func_stripname_result 9285b43acbb4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92865a3d36dfSmrg case " $predeps $postdeps " in 92875a3d36dfSmrg *" $a_deplib "*) 928841c30155Smrg func_append newdeplibs " $a_deplib" 9289b43acbb4Smrg a_deplib= 92905a3d36dfSmrg ;; 92915a3d36dfSmrg esac 92925a3d36dfSmrg fi 9293b43acbb4Smrg if test -n "$a_deplib"; then 92945a3d36dfSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 929541c30155Smrg if test -n "$file_magic_glob"; then 929641c30155Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 929741c30155Smrg else 929841c30155Smrg libnameglob=$libname 929941c30155Smrg fi 9300b43acbb4Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 93015a3d36dfSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9302b43acbb4Smrg if test yes = "$want_nocaseglob"; then 930341c30155Smrg shopt -s nocaseglob 930441c30155Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 930541c30155Smrg $nocaseglob 930641c30155Smrg else 930741c30155Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 930841c30155Smrg fi 93095a3d36dfSmrg for potent_lib in $potential_libs; do 93105a3d36dfSmrg # Follow soft links. 93115a3d36dfSmrg if ls -lLd "$potent_lib" 2>/dev/null | 93125a3d36dfSmrg $GREP " -> " >/dev/null; then 93135a3d36dfSmrg continue 93145a3d36dfSmrg fi 93155a3d36dfSmrg # The statement above tries to avoid entering an 93165a3d36dfSmrg # endless loop below, in case of cyclic links. 93175a3d36dfSmrg # We might still enter an endless loop, since a link 93185a3d36dfSmrg # loop can be closed while we follow links, 93195a3d36dfSmrg # but so what? 9320b43acbb4Smrg potlib=$potent_lib 93215a3d36dfSmrg while test -h "$potlib" 2>/dev/null; do 9322b43acbb4Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 93235a3d36dfSmrg case $potliblink in 9324b43acbb4Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9325b43acbb4Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 93265a3d36dfSmrg esac 93275a3d36dfSmrg done 93285a3d36dfSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 93295a3d36dfSmrg $SED -e 10q | 93305a3d36dfSmrg $EGREP "$file_magic_regex" > /dev/null; then 933141c30155Smrg func_append newdeplibs " $a_deplib" 9332b43acbb4Smrg a_deplib= 93335a3d36dfSmrg break 2 93345a3d36dfSmrg fi 93355a3d36dfSmrg done 93365a3d36dfSmrg done 93375a3d36dfSmrg fi 9338b43acbb4Smrg if test -n "$a_deplib"; then 93395a3d36dfSmrg droppeddeps=yes 934041c30155Smrg echo 93415a3d36dfSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 934241c30155Smrg echo "*** I have the capability to make that library automatically link in when" 934341c30155Smrg echo "*** you link to this library. But I can only do this if you have a" 934441c30155Smrg echo "*** shared version of the library, which you do not appear to have" 934541c30155Smrg echo "*** because I did check the linker path looking for a file starting" 9346b43acbb4Smrg if test -z "$potlib"; then 93475a3d36dfSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 93485a3d36dfSmrg else 93495a3d36dfSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93505a3d36dfSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 93515a3d36dfSmrg fi 93525a3d36dfSmrg fi 93535a3d36dfSmrg ;; 93545a3d36dfSmrg *) 93555a3d36dfSmrg # Add a -L argument. 935641c30155Smrg func_append newdeplibs " $a_deplib" 93575a3d36dfSmrg ;; 93585a3d36dfSmrg esac 93595a3d36dfSmrg done # Gone through all deplibs. 93605a3d36dfSmrg ;; 93615a3d36dfSmrg match_pattern*) 93625a3d36dfSmrg set dummy $deplibs_check_method; shift 93635a3d36dfSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 93645a3d36dfSmrg for a_deplib in $deplibs; do 93655a3d36dfSmrg case $a_deplib in 93665a3d36dfSmrg -l*) 93675a3d36dfSmrg func_stripname -l '' "$a_deplib" 93685a3d36dfSmrg name=$func_stripname_result 9369b43acbb4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 93705a3d36dfSmrg case " $predeps $postdeps " in 93715a3d36dfSmrg *" $a_deplib "*) 937241c30155Smrg func_append newdeplibs " $a_deplib" 9373b43acbb4Smrg a_deplib= 93745a3d36dfSmrg ;; 93755a3d36dfSmrg esac 93765a3d36dfSmrg fi 9377b43acbb4Smrg if test -n "$a_deplib"; then 93785a3d36dfSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 93795a3d36dfSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93805a3d36dfSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 93815a3d36dfSmrg for potent_lib in $potential_libs; do 9382b43acbb4Smrg potlib=$potent_lib # see symlink-check above in file_magic test 938341c30155Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 93845a3d36dfSmrg $EGREP "$match_pattern_regex" > /dev/null; then 938541c30155Smrg func_append newdeplibs " $a_deplib" 9386b43acbb4Smrg a_deplib= 93875a3d36dfSmrg break 2 93885a3d36dfSmrg fi 93895a3d36dfSmrg done 93905a3d36dfSmrg done 93915a3d36dfSmrg fi 9392b43acbb4Smrg if test -n "$a_deplib"; then 93935a3d36dfSmrg droppeddeps=yes 939441c30155Smrg echo 93955a3d36dfSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 939641c30155Smrg echo "*** I have the capability to make that library automatically link in when" 939741c30155Smrg echo "*** you link to this library. But I can only do this if you have a" 939841c30155Smrg echo "*** shared version of the library, which you do not appear to have" 939941c30155Smrg echo "*** because I did check the linker path looking for a file starting" 9400b43acbb4Smrg if test -z "$potlib"; then 94015a3d36dfSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 94025a3d36dfSmrg else 94035a3d36dfSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 94045a3d36dfSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 94055a3d36dfSmrg fi 94065a3d36dfSmrg fi 94075a3d36dfSmrg ;; 94085a3d36dfSmrg *) 94095a3d36dfSmrg # Add a -L argument. 941041c30155Smrg func_append newdeplibs " $a_deplib" 94115a3d36dfSmrg ;; 94125a3d36dfSmrg esac 94135a3d36dfSmrg done # Gone through all deplibs. 94145a3d36dfSmrg ;; 94155a3d36dfSmrg none | unknown | *) 9416b43acbb4Smrg newdeplibs= 941741c30155Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9418b43acbb4Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9419b43acbb4Smrg for i in $predeps $postdeps; do 94205a3d36dfSmrg # can't use Xsed below, because $i might contain '/' 9421b43acbb4Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 94225a3d36dfSmrg done 94235a3d36dfSmrg fi 942441c30155Smrg case $tmp_deplibs in 942541c30155Smrg *[!\ \ ]*) 942641c30155Smrg echo 9427b43acbb4Smrg if test none = "$deplibs_check_method"; then 942841c30155Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 94295a3d36dfSmrg else 943041c30155Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 94315a3d36dfSmrg fi 943241c30155Smrg echo "*** All declared inter-library dependencies are being dropped." 94335a3d36dfSmrg droppeddeps=yes 943441c30155Smrg ;; 943541c30155Smrg esac 94365a3d36dfSmrg ;; 94375a3d36dfSmrg esac 94385a3d36dfSmrg versuffix=$versuffix_save 94395a3d36dfSmrg major=$major_save 94405a3d36dfSmrg release=$release_save 94415a3d36dfSmrg libname=$libname_save 94425a3d36dfSmrg name=$name_save 94435a3d36dfSmrg 94445a3d36dfSmrg case $host in 94455a3d36dfSmrg *-*-rhapsody* | *-*-darwin1.[012]) 94465a3d36dfSmrg # On Rhapsody replace the C library with the System framework 944741c30155Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 94485a3d36dfSmrg ;; 94495a3d36dfSmrg esac 94505a3d36dfSmrg 9451b43acbb4Smrg if test yes = "$droppeddeps"; then 9452b43acbb4Smrg if test yes = "$module"; then 945341c30155Smrg echo 945441c30155Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 94555a3d36dfSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 945641c30155Smrg echo "*** a static module, that should work as long as the dlopening" 945741c30155Smrg echo "*** application is linked with the -dlopen flag." 94585a3d36dfSmrg if test -z "$global_symbol_pipe"; then 945941c30155Smrg echo 946041c30155Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9461b43acbb4Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 946241c30155Smrg echo "*** not find such a program. So, this module is probably useless." 9463b43acbb4Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 94645a3d36dfSmrg fi 9465b43acbb4Smrg if test no = "$build_old_libs"; then 9466b43acbb4Smrg oldlibs=$output_objdir/$libname.$libext 94675a3d36dfSmrg build_libtool_libs=module 94685a3d36dfSmrg build_old_libs=yes 94695a3d36dfSmrg else 94705a3d36dfSmrg build_libtool_libs=no 94715a3d36dfSmrg fi 94725a3d36dfSmrg else 947341c30155Smrg echo "*** The inter-library dependencies that have been dropped here will be" 947441c30155Smrg echo "*** automatically added whenever a program is linked with this library" 947541c30155Smrg echo "*** or is declared to -dlopen it." 94765a3d36dfSmrg 9477b43acbb4Smrg if test no = "$allow_undefined"; then 947841c30155Smrg echo 947941c30155Smrg echo "*** Since this library must not contain undefined symbols," 948041c30155Smrg echo "*** because either the platform does not support them or" 948141c30155Smrg echo "*** it was explicitly requested with -no-undefined," 948241c30155Smrg echo "*** libtool will only create a static version of it." 9483b43acbb4Smrg if test no = "$build_old_libs"; then 9484b43acbb4Smrg oldlibs=$output_objdir/$libname.$libext 94855a3d36dfSmrg build_libtool_libs=module 94865a3d36dfSmrg build_old_libs=yes 94875a3d36dfSmrg else 94885a3d36dfSmrg build_libtool_libs=no 94895a3d36dfSmrg fi 94905a3d36dfSmrg fi 94915a3d36dfSmrg fi 94925a3d36dfSmrg fi 94935a3d36dfSmrg # Done checking deplibs! 94945a3d36dfSmrg deplibs=$newdeplibs 94955a3d36dfSmrg fi 94965a3d36dfSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 94975a3d36dfSmrg case $host in 94985a3d36dfSmrg *-*-darwin*) 949941c30155Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 950041c30155Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 950141c30155Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 95025a3d36dfSmrg ;; 95035a3d36dfSmrg esac 95045a3d36dfSmrg 95055a3d36dfSmrg # move library search paths that coincide with paths to not yet 95065a3d36dfSmrg # installed libraries to the beginning of the library search list 95075a3d36dfSmrg new_libs= 95085a3d36dfSmrg for path in $notinst_path; do 95095a3d36dfSmrg case " $new_libs " in 95105a3d36dfSmrg *" -L$path/$objdir "*) ;; 95115a3d36dfSmrg *) 95125a3d36dfSmrg case " $deplibs " in 95135a3d36dfSmrg *" -L$path/$objdir "*) 951441c30155Smrg func_append new_libs " -L$path/$objdir" ;; 95155a3d36dfSmrg esac 95165a3d36dfSmrg ;; 95175a3d36dfSmrg esac 95185a3d36dfSmrg done 95195a3d36dfSmrg for deplib in $deplibs; do 95205a3d36dfSmrg case $deplib in 95215a3d36dfSmrg -L*) 95225a3d36dfSmrg case " $new_libs " in 95235a3d36dfSmrg *" $deplib "*) ;; 952441c30155Smrg *) func_append new_libs " $deplib" ;; 95255a3d36dfSmrg esac 95265a3d36dfSmrg ;; 952741c30155Smrg *) func_append new_libs " $deplib" ;; 95285a3d36dfSmrg esac 95295a3d36dfSmrg done 9530b43acbb4Smrg deplibs=$new_libs 95315a3d36dfSmrg 95325a3d36dfSmrg # All the library-specific variables (install_libdir is set above). 95335a3d36dfSmrg library_names= 95345a3d36dfSmrg old_library= 95355a3d36dfSmrg dlname= 95365a3d36dfSmrg 95375a3d36dfSmrg # Test again, we may have decided not to build it any more 9538b43acbb4Smrg if test yes = "$build_libtool_libs"; then 9539b43acbb4Smrg # Remove $wl instances when linking with ld. 9540b020570bSmrg # FIXME: should test the right _cmds variable. 9541b020570bSmrg case $archive_cmds in 9542b020570bSmrg *\$LD\ *) wl= ;; 9543b020570bSmrg esac 9544b43acbb4Smrg if test yes = "$hardcode_into_libs"; then 95455a3d36dfSmrg # Hardcode the library paths 95465a3d36dfSmrg hardcode_libdirs= 95475a3d36dfSmrg dep_rpath= 9548b43acbb4Smrg rpath=$finalize_rpath 9549b43acbb4Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 95505a3d36dfSmrg for libdir in $rpath; do 95515a3d36dfSmrg if test -n "$hardcode_libdir_flag_spec"; then 95525a3d36dfSmrg if test -n "$hardcode_libdir_separator"; then 955341c30155Smrg func_replace_sysroot "$libdir" 955441c30155Smrg libdir=$func_replace_sysroot_result 95555a3d36dfSmrg if test -z "$hardcode_libdirs"; then 9556b43acbb4Smrg hardcode_libdirs=$libdir 95575a3d36dfSmrg else 95585a3d36dfSmrg # Just accumulate the unique libdirs. 95595a3d36dfSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 95605a3d36dfSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 95615a3d36dfSmrg ;; 95625a3d36dfSmrg *) 956341c30155Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 95645a3d36dfSmrg ;; 95655a3d36dfSmrg esac 95665a3d36dfSmrg fi 95675a3d36dfSmrg else 95685a3d36dfSmrg eval flag=\"$hardcode_libdir_flag_spec\" 956941c30155Smrg func_append dep_rpath " $flag" 95705a3d36dfSmrg fi 95715a3d36dfSmrg elif test -n "$runpath_var"; then 95725a3d36dfSmrg case "$perm_rpath " in 95735a3d36dfSmrg *" $libdir "*) ;; 9574b020570bSmrg *) func_append perm_rpath " $libdir" ;; 95755a3d36dfSmrg esac 95765a3d36dfSmrg fi 95775a3d36dfSmrg done 95785a3d36dfSmrg # Substitute the hardcoded libdirs into the rpath. 95795a3d36dfSmrg if test -n "$hardcode_libdir_separator" && 95805a3d36dfSmrg test -n "$hardcode_libdirs"; then 9581b43acbb4Smrg libdir=$hardcode_libdirs 9582b020570bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 95835a3d36dfSmrg fi 95845a3d36dfSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 95855a3d36dfSmrg # We should set the runpath_var. 95865a3d36dfSmrg rpath= 95875a3d36dfSmrg for dir in $perm_rpath; do 958841c30155Smrg func_append rpath "$dir:" 95895a3d36dfSmrg done 95905a3d36dfSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 95915a3d36dfSmrg fi 95925a3d36dfSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 95935a3d36dfSmrg fi 959423a0898aSmrg 9595b43acbb4Smrg shlibpath=$finalize_shlibpath 9596b43acbb4Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 95975a3d36dfSmrg if test -n "$shlibpath"; then 95985a3d36dfSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 95995a3d36dfSmrg fi 960023a0898aSmrg 96015a3d36dfSmrg # Get the real and link names of the library. 96025a3d36dfSmrg eval shared_ext=\"$shrext_cmds\" 96035a3d36dfSmrg eval library_names=\"$library_names_spec\" 96045a3d36dfSmrg set dummy $library_names 96055a3d36dfSmrg shift 9606b43acbb4Smrg realname=$1 96075a3d36dfSmrg shift 960823a0898aSmrg 96095a3d36dfSmrg if test -n "$soname_spec"; then 96105a3d36dfSmrg eval soname=\"$soname_spec\" 96115a3d36dfSmrg else 9612b43acbb4Smrg soname=$realname 96135a3d36dfSmrg fi 96145a3d36dfSmrg if test -z "$dlname"; then 96155a3d36dfSmrg dlname=$soname 96165a3d36dfSmrg fi 961723a0898aSmrg 9618b43acbb4Smrg lib=$output_objdir/$realname 96195a3d36dfSmrg linknames= 96205a3d36dfSmrg for link 96215a3d36dfSmrg do 962241c30155Smrg func_append linknames " $link" 96235a3d36dfSmrg done 962423a0898aSmrg 96255a3d36dfSmrg # Use standard objects if they are pic 962641c30155Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 96275a3d36dfSmrg test "X$libobjs" = "X " && libobjs= 962823a0898aSmrg 96295a3d36dfSmrg delfiles= 96305a3d36dfSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 96315a3d36dfSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9632b43acbb4Smrg export_symbols=$output_objdir/$libname.uexp 963341c30155Smrg func_append delfiles " $export_symbols" 96345a3d36dfSmrg fi 963523a0898aSmrg 96365a3d36dfSmrg orig_export_symbols= 96375a3d36dfSmrg case $host_os in 96385a3d36dfSmrg cygwin* | mingw* | cegcc*) 96395a3d36dfSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 96405a3d36dfSmrg # exporting using user supplied symfile 9641b43acbb4Smrg func_dll_def_p "$export_symbols" || { 96425a3d36dfSmrg # and it's NOT already a .def file. Must figure out 96435a3d36dfSmrg # which of the given symbols are data symbols and tag 96445a3d36dfSmrg # them as such. So, trigger use of export_symbols_cmds. 96455a3d36dfSmrg # export_symbols gets reassigned inside the "prepare 96465a3d36dfSmrg # the list of exported symbols" if statement, so the 96475a3d36dfSmrg # include_expsyms logic still works. 9648b43acbb4Smrg orig_export_symbols=$export_symbols 96495a3d36dfSmrg export_symbols= 96505a3d36dfSmrg always_export_symbols=yes 9651b43acbb4Smrg } 96525a3d36dfSmrg fi 96535a3d36dfSmrg ;; 96545a3d36dfSmrg esac 965523a0898aSmrg 96565a3d36dfSmrg # Prepare the list of exported symbols 96575a3d36dfSmrg if test -z "$export_symbols"; then 9658b43acbb4Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9659b43acbb4Smrg func_verbose "generating symbol list for '$libname.la'" 9660b43acbb4Smrg export_symbols=$output_objdir/$libname.exp 96615a3d36dfSmrg $opt_dry_run || $RM $export_symbols 96625a3d36dfSmrg cmds=$export_symbols_cmds 9663b43acbb4Smrg save_ifs=$IFS; IFS='~' 966441c30155Smrg for cmd1 in $cmds; do 9665b43acbb4Smrg IFS=$save_ifs 966641c30155Smrg # Take the normal branch if the nm_file_list_spec branch 966741c30155Smrg # doesn't work or if tool conversion is not needed. 966841c30155Smrg case $nm_file_list_spec~$to_tool_file_cmd in 966941c30155Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 967041c30155Smrg try_normal_branch=yes 967141c30155Smrg eval cmd=\"$cmd1\" 967241c30155Smrg func_len " $cmd" 967341c30155Smrg len=$func_len_result 967441c30155Smrg ;; 967541c30155Smrg *) 967641c30155Smrg try_normal_branch=no 967741c30155Smrg ;; 967841c30155Smrg esac 9679b43acbb4Smrg if test yes = "$try_normal_branch" \ 968041c30155Smrg && { test "$len" -lt "$max_cmd_len" \ 968141c30155Smrg || test "$max_cmd_len" -le -1; } 968241c30155Smrg then 968341c30155Smrg func_show_eval "$cmd" 'exit $?' 968441c30155Smrg skipped_export=false 968541c30155Smrg elif test -n "$nm_file_list_spec"; then 968641c30155Smrg func_basename "$output" 968741c30155Smrg output_la=$func_basename_result 968841c30155Smrg save_libobjs=$libobjs 968941c30155Smrg save_output=$output 9690b43acbb4Smrg output=$output_objdir/$output_la.nm 969141c30155Smrg func_to_tool_file "$output" 969241c30155Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 969341c30155Smrg func_append delfiles " $output" 969441c30155Smrg func_verbose "creating $NM input file list: $output" 969541c30155Smrg for obj in $save_libobjs; do 969641c30155Smrg func_to_tool_file "$obj" 969741c30155Smrg $ECHO "$func_to_tool_file_result" 969841c30155Smrg done > "$output" 969941c30155Smrg eval cmd=\"$cmd1\" 97005a3d36dfSmrg func_show_eval "$cmd" 'exit $?' 970141c30155Smrg output=$save_output 970241c30155Smrg libobjs=$save_libobjs 97035a3d36dfSmrg skipped_export=false 97045a3d36dfSmrg else 97055a3d36dfSmrg # The command line is too long to execute in one step. 97065a3d36dfSmrg func_verbose "using reloadable object file for export list..." 97075a3d36dfSmrg skipped_export=: 97085a3d36dfSmrg # Break out early, otherwise skipped_export may be 97095a3d36dfSmrg # set to false by a later but shorter cmd. 97105a3d36dfSmrg break 97115a3d36dfSmrg fi 97125a3d36dfSmrg done 9713b43acbb4Smrg IFS=$save_ifs 9714b43acbb4Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 97155a3d36dfSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 97165a3d36dfSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 97175a3d36dfSmrg fi 97185a3d36dfSmrg fi 97197f7f5e4eSmrg fi 972023a0898aSmrg 97215a3d36dfSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9722b43acbb4Smrg tmp_export_symbols=$export_symbols 9723b43acbb4Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 972441c30155Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 97255a3d36dfSmrg fi 972623a0898aSmrg 9727b43acbb4Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 97285a3d36dfSmrg # The given exports_symbols file has to be filtered, so filter it. 9729b43acbb4Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 97305a3d36dfSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9731b43acbb4Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 97325a3d36dfSmrg # though. Also, the filter scales superlinearly with the number of 97335a3d36dfSmrg # global variables. join(1) would be nice here, but unfortunately 97345a3d36dfSmrg # isn't a blessed tool. 97355a3d36dfSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 973641c30155Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 97375a3d36dfSmrg export_symbols=$output_objdir/$libname.def 97385a3d36dfSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 97395a3d36dfSmrg fi 974023a0898aSmrg 97415a3d36dfSmrg tmp_deplibs= 97425a3d36dfSmrg for test_deplib in $deplibs; do 97435a3d36dfSmrg case " $convenience " in 97445a3d36dfSmrg *" $test_deplib "*) ;; 97455a3d36dfSmrg *) 974641c30155Smrg func_append tmp_deplibs " $test_deplib" 97475a3d36dfSmrg ;; 97485a3d36dfSmrg esac 97495a3d36dfSmrg done 9750b43acbb4Smrg deplibs=$tmp_deplibs 975123a0898aSmrg 97525a3d36dfSmrg if test -n "$convenience"; then 97535a3d36dfSmrg if test -n "$whole_archive_flag_spec" && 9754b43acbb4Smrg test yes = "$compiler_needs_object" && 97555a3d36dfSmrg test -z "$libobjs"; then 97565a3d36dfSmrg # extract the archives, so we have objects to list. 97575a3d36dfSmrg # TODO: could optimize this to just extract one archive. 97585a3d36dfSmrg whole_archive_flag_spec= 97595a3d36dfSmrg fi 97605a3d36dfSmrg if test -n "$whole_archive_flag_spec"; then 97615a3d36dfSmrg save_libobjs=$libobjs 97625a3d36dfSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 97635a3d36dfSmrg test "X$libobjs" = "X " && libobjs= 97645a3d36dfSmrg else 9765b43acbb4Smrg gentop=$output_objdir/${outputname}x 976641c30155Smrg func_append generated " $gentop" 976723a0898aSmrg 97685a3d36dfSmrg func_extract_archives $gentop $convenience 976941c30155Smrg func_append libobjs " $func_extract_archives_result" 97705a3d36dfSmrg test "X$libobjs" = "X " && libobjs= 97715a3d36dfSmrg fi 9772b3062210Smrg fi 977323a0898aSmrg 9774b43acbb4Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 97755a3d36dfSmrg eval flag=\"$thread_safe_flag_spec\" 977641c30155Smrg func_append linker_flags " $flag" 9777b3062210Smrg fi 977823a0898aSmrg 97795a3d36dfSmrg # Make a backup of the uninstalled library when relinking 9780b43acbb4Smrg if test relink = "$opt_mode"; then 97815a3d36dfSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 97825a3d36dfSmrg fi 978323a0898aSmrg 97845a3d36dfSmrg # Do each of the archive commands. 9785b43acbb4Smrg if test yes = "$module" && test -n "$module_cmds"; then 97865a3d36dfSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 97875a3d36dfSmrg eval test_cmds=\"$module_expsym_cmds\" 97885a3d36dfSmrg cmds=$module_expsym_cmds 97895a3d36dfSmrg else 97905a3d36dfSmrg eval test_cmds=\"$module_cmds\" 97915a3d36dfSmrg cmds=$module_cmds 97925a3d36dfSmrg fi 9793b3062210Smrg else 97945a3d36dfSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 97955a3d36dfSmrg eval test_cmds=\"$archive_expsym_cmds\" 97965a3d36dfSmrg cmds=$archive_expsym_cmds 97975a3d36dfSmrg else 97985a3d36dfSmrg eval test_cmds=\"$archive_cmds\" 97995a3d36dfSmrg cmds=$archive_cmds 98005a3d36dfSmrg fi 9801b3062210Smrg fi 980223a0898aSmrg 9803b43acbb4Smrg if test : != "$skipped_export" && 98045a3d36dfSmrg func_len " $test_cmds" && 98055a3d36dfSmrg len=$func_len_result && 98065a3d36dfSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 98075a3d36dfSmrg : 98085a3d36dfSmrg else 98095a3d36dfSmrg # The command line is too long to link in one step, link piecewise 98105a3d36dfSmrg # or, if using GNU ld and skipped_export is not :, use a linker 98115a3d36dfSmrg # script. 981223a0898aSmrg 98135a3d36dfSmrg # Save the value of $output and $libobjs because we want to 98145a3d36dfSmrg # use them later. If we have whole_archive_flag_spec, we 98155a3d36dfSmrg # want to use save_libobjs as it was before 98165a3d36dfSmrg # whole_archive_flag_spec was expanded, because we can't 98175a3d36dfSmrg # assume the linker understands whole_archive_flag_spec. 98185a3d36dfSmrg # This may have to be revisited, in case too many 98195a3d36dfSmrg # convenience libraries get linked in and end up exceeding 98205a3d36dfSmrg # the spec. 98215a3d36dfSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 98225a3d36dfSmrg save_libobjs=$libobjs 98235a3d36dfSmrg fi 98245a3d36dfSmrg save_output=$output 982541c30155Smrg func_basename "$output" 982641c30155Smrg output_la=$func_basename_result 982723a0898aSmrg 98285a3d36dfSmrg # Clear the reloadable object creation command queue and 98295a3d36dfSmrg # initialize k to one. 98305a3d36dfSmrg test_cmds= 98315a3d36dfSmrg concat_cmds= 98325a3d36dfSmrg objlist= 98335a3d36dfSmrg last_robj= 98345a3d36dfSmrg k=1 98355a3d36dfSmrg 9836b43acbb4Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9837b43acbb4Smrg output=$output_objdir/$output_la.lnkscript 98385a3d36dfSmrg func_verbose "creating GNU ld script: $output" 983941c30155Smrg echo 'INPUT (' > $output 98405a3d36dfSmrg for obj in $save_libobjs 9841b3062210Smrg do 984241c30155Smrg func_to_tool_file "$obj" 984341c30155Smrg $ECHO "$func_to_tool_file_result" >> $output 98445a3d36dfSmrg done 984541c30155Smrg echo ')' >> $output 984641c30155Smrg func_append delfiles " $output" 984741c30155Smrg func_to_tool_file "$output" 984841c30155Smrg output=$func_to_tool_file_result 9849b43acbb4Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9850b43acbb4Smrg output=$output_objdir/$output_la.lnk 98515a3d36dfSmrg func_verbose "creating linker input file list: $output" 98525a3d36dfSmrg : > $output 98535a3d36dfSmrg set x $save_libobjs 98545a3d36dfSmrg shift 98555a3d36dfSmrg firstobj= 9856b43acbb4Smrg if test yes = "$compiler_needs_object"; then 98575a3d36dfSmrg firstobj="$1 " 98585a3d36dfSmrg shift 98595a3d36dfSmrg fi 98605a3d36dfSmrg for obj 98615a3d36dfSmrg do 986241c30155Smrg func_to_tool_file "$obj" 986341c30155Smrg $ECHO "$func_to_tool_file_result" >> $output 98645a3d36dfSmrg done 986541c30155Smrg func_append delfiles " $output" 986641c30155Smrg func_to_tool_file "$output" 986741c30155Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 98685a3d36dfSmrg else 98695a3d36dfSmrg if test -n "$save_libobjs"; then 98705a3d36dfSmrg func_verbose "creating reloadable object files..." 9871b43acbb4Smrg output=$output_objdir/$output_la-$k.$objext 98725a3d36dfSmrg eval test_cmds=\"$reload_cmds\" 98735a3d36dfSmrg func_len " $test_cmds" 98745a3d36dfSmrg len0=$func_len_result 98755a3d36dfSmrg len=$len0 98765a3d36dfSmrg 98775a3d36dfSmrg # Loop over the list of objects to be linked. 98785a3d36dfSmrg for obj in $save_libobjs 98795a3d36dfSmrg do 98805a3d36dfSmrg func_len " $obj" 98815a3d36dfSmrg func_arith $len + $func_len_result 98825a3d36dfSmrg len=$func_arith_result 9883b43acbb4Smrg if test -z "$objlist" || 98845a3d36dfSmrg test "$len" -lt "$max_cmd_len"; then 98855a3d36dfSmrg func_append objlist " $obj" 98865a3d36dfSmrg else 98875a3d36dfSmrg # The command $test_cmds is almost too long, add a 98885a3d36dfSmrg # command to the queue. 9889b43acbb4Smrg if test 1 -eq "$k"; then 98905a3d36dfSmrg # The first file doesn't have a previous command to add. 989141c30155Smrg reload_objs=$objlist 989241c30155Smrg eval concat_cmds=\"$reload_cmds\" 98935a3d36dfSmrg else 98945a3d36dfSmrg # All subsequent reloadable object files will link in 98955a3d36dfSmrg # the last one created. 989641c30155Smrg reload_objs="$objlist $last_robj" 989741c30155Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 98985a3d36dfSmrg fi 9899b43acbb4Smrg last_robj=$output_objdir/$output_la-$k.$objext 99005a3d36dfSmrg func_arith $k + 1 99015a3d36dfSmrg k=$func_arith_result 9902b43acbb4Smrg output=$output_objdir/$output_la-$k.$objext 990341c30155Smrg objlist=" $obj" 99045a3d36dfSmrg func_len " $last_robj" 99055a3d36dfSmrg func_arith $len0 + $func_len_result 99065a3d36dfSmrg len=$func_arith_result 99075a3d36dfSmrg fi 99085a3d36dfSmrg done 99095a3d36dfSmrg # Handle the remaining objects by creating one last 99105a3d36dfSmrg # reloadable object file. All subsequent reloadable object 99115a3d36dfSmrg # files will link in the last one created. 99125a3d36dfSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 991341c30155Smrg reload_objs="$objlist $last_robj" 9914b43acbb4Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 99155a3d36dfSmrg if test -n "$last_robj"; then 9916b43acbb4Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99175a3d36dfSmrg fi 991841c30155Smrg func_append delfiles " $output" 991923a0898aSmrg 99205a3d36dfSmrg else 99215a3d36dfSmrg output= 99225a3d36dfSmrg fi 992323a0898aSmrg 9924b43acbb4Smrg ${skipped_export-false} && { 9925b43acbb4Smrg func_verbose "generating symbol list for '$libname.la'" 9926b43acbb4Smrg export_symbols=$output_objdir/$libname.exp 99275a3d36dfSmrg $opt_dry_run || $RM $export_symbols 99285a3d36dfSmrg libobjs=$output 99295a3d36dfSmrg # Append the command to create the export file. 99305a3d36dfSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99315a3d36dfSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 99325a3d36dfSmrg if test -n "$last_robj"; then 99335a3d36dfSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99345a3d36dfSmrg fi 9935b43acbb4Smrg } 993623a0898aSmrg 99375a3d36dfSmrg test -n "$save_libobjs" && 99385a3d36dfSmrg func_verbose "creating a temporary reloadable object file: $output" 993923a0898aSmrg 99405a3d36dfSmrg # Loop through the commands generated above and execute them. 9941b43acbb4Smrg save_ifs=$IFS; IFS='~' 99425a3d36dfSmrg for cmd in $concat_cmds; do 9943b43acbb4Smrg IFS=$save_ifs 9944b43acbb4Smrg $opt_quiet || { 99455a3d36dfSmrg func_quote_for_expand "$cmd" 99465a3d36dfSmrg eval "func_echo $func_quote_for_expand_result" 99475a3d36dfSmrg } 99485a3d36dfSmrg $opt_dry_run || eval "$cmd" || { 99495a3d36dfSmrg lt_exit=$? 99505a3d36dfSmrg 99515a3d36dfSmrg # Restore the uninstalled library and exit 9952b43acbb4Smrg if test relink = "$opt_mode"; then 99535a3d36dfSmrg ( cd "$output_objdir" && \ 99545a3d36dfSmrg $RM "${realname}T" && \ 99555a3d36dfSmrg $MV "${realname}U" "$realname" ) 99565a3d36dfSmrg fi 99577f7f5e4eSmrg 99585a3d36dfSmrg exit $lt_exit 99595a3d36dfSmrg } 99605a3d36dfSmrg done 9961b43acbb4Smrg IFS=$save_ifs 9962b3062210Smrg 99635a3d36dfSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 99645a3d36dfSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99655a3d36dfSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 996623a0898aSmrg fi 996723a0898aSmrg fi 996823a0898aSmrg 9969b43acbb4Smrg ${skipped_export-false} && { 99705a3d36dfSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9971b43acbb4Smrg tmp_export_symbols=$export_symbols 9972b43acbb4Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 997341c30155Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 99745a3d36dfSmrg fi 997523a0898aSmrg 99765a3d36dfSmrg if test -n "$orig_export_symbols"; then 99775a3d36dfSmrg # The given exports_symbols file has to be filtered, so filter it. 9978b43acbb4Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 99795a3d36dfSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9980b43acbb4Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 99815a3d36dfSmrg # though. Also, the filter scales superlinearly with the number of 99825a3d36dfSmrg # global variables. join(1) would be nice here, but unfortunately 99835a3d36dfSmrg # isn't a blessed tool. 99845a3d36dfSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 998541c30155Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 99865a3d36dfSmrg export_symbols=$output_objdir/$libname.def 99875a3d36dfSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 99885a3d36dfSmrg fi 9989b43acbb4Smrg } 999023a0898aSmrg 99915a3d36dfSmrg libobjs=$output 99925a3d36dfSmrg # Restore the value of output. 99935a3d36dfSmrg output=$save_output 999423a0898aSmrg 99955a3d36dfSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 99965a3d36dfSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 99975a3d36dfSmrg test "X$libobjs" = "X " && libobjs= 99985a3d36dfSmrg fi 99995a3d36dfSmrg # Expand the library linking commands again to reset the 100005a3d36dfSmrg # value of $libobjs for piecewise linking. 1000123a0898aSmrg 100025a3d36dfSmrg # Do each of the archive commands. 10003b43acbb4Smrg if test yes = "$module" && test -n "$module_cmds"; then 100045a3d36dfSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100055a3d36dfSmrg cmds=$module_expsym_cmds 100065a3d36dfSmrg else 100075a3d36dfSmrg cmds=$module_cmds 10008b3062210Smrg fi 10009b3062210Smrg else 100105a3d36dfSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100115a3d36dfSmrg cmds=$archive_expsym_cmds 100125a3d36dfSmrg else 100135a3d36dfSmrg cmds=$archive_cmds 100145a3d36dfSmrg fi 10015b3062210Smrg fi 100165a3d36dfSmrg fi 1001723a0898aSmrg 100185a3d36dfSmrg if test -n "$delfiles"; then 100195a3d36dfSmrg # Append the command to remove temporary files to $cmds. 100205a3d36dfSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 100215a3d36dfSmrg fi 1002223a0898aSmrg 100235a3d36dfSmrg # Add any objects from preloaded convenience libraries 100245a3d36dfSmrg if test -n "$dlprefiles"; then 10025b43acbb4Smrg gentop=$output_objdir/${outputname}x 1002641c30155Smrg func_append generated " $gentop" 1002723a0898aSmrg 100285a3d36dfSmrg func_extract_archives $gentop $dlprefiles 1002941c30155Smrg func_append libobjs " $func_extract_archives_result" 100305a3d36dfSmrg test "X$libobjs" = "X " && libobjs= 100315a3d36dfSmrg fi 1003223a0898aSmrg 10033b43acbb4Smrg save_ifs=$IFS; IFS='~' 100345a3d36dfSmrg for cmd in $cmds; do 10035b43acbb4Smrg IFS=$sp$nl 100365a3d36dfSmrg eval cmd=\"$cmd\" 10037b43acbb4Smrg IFS=$save_ifs 10038b43acbb4Smrg $opt_quiet || { 100395a3d36dfSmrg func_quote_for_expand "$cmd" 100405a3d36dfSmrg eval "func_echo $func_quote_for_expand_result" 100415a3d36dfSmrg } 100425a3d36dfSmrg $opt_dry_run || eval "$cmd" || { 100435a3d36dfSmrg lt_exit=$? 100447f7f5e4eSmrg 100455a3d36dfSmrg # Restore the uninstalled library and exit 10046b43acbb4Smrg if test relink = "$opt_mode"; then 100475a3d36dfSmrg ( cd "$output_objdir" && \ 100485a3d36dfSmrg $RM "${realname}T" && \ 100495a3d36dfSmrg $MV "${realname}U" "$realname" ) 100505a3d36dfSmrg fi 100517f7f5e4eSmrg 100525a3d36dfSmrg exit $lt_exit 100535a3d36dfSmrg } 100545a3d36dfSmrg done 10055b43acbb4Smrg IFS=$save_ifs 100567f7f5e4eSmrg 100575a3d36dfSmrg # Restore the uninstalled library and exit 10058b43acbb4Smrg if test relink = "$opt_mode"; then 100595a3d36dfSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 100607f7f5e4eSmrg 100615a3d36dfSmrg if test -n "$convenience"; then 100625a3d36dfSmrg if test -z "$whole_archive_flag_spec"; then 100635a3d36dfSmrg func_show_eval '${RM}r "$gentop"' 100645a3d36dfSmrg fi 100655a3d36dfSmrg fi 100667f7f5e4eSmrg 100675a3d36dfSmrg exit $EXIT_SUCCESS 100685a3d36dfSmrg fi 100695a3d36dfSmrg 100705a3d36dfSmrg # Create links to the real library. 100715a3d36dfSmrg for linkname in $linknames; do 100725a3d36dfSmrg if test "$realname" != "$linkname"; then 100735a3d36dfSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10074b3062210Smrg fi 10075b3062210Smrg done 100767f7f5e4eSmrg 100775a3d36dfSmrg # If -module or -export-dynamic was specified, set the dlname. 10078b43acbb4Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 100795a3d36dfSmrg # On all known operating systems, these are identical. 10080b43acbb4Smrg dlname=$soname 100815a3d36dfSmrg fi 100825a3d36dfSmrg fi 1008323a0898aSmrg ;; 1008423a0898aSmrg 100855a3d36dfSmrg obj) 10086b43acbb4Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10087b43acbb4Smrg func_warning "'-dlopen' is ignored for objects" 100885a3d36dfSmrg fi 10089b3062210Smrg 100905a3d36dfSmrg case " $deplibs" in 100915a3d36dfSmrg *\ -l* | *\ -L*) 10092b43acbb4Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 100937f7f5e4eSmrg esac 1009423a0898aSmrg 100955a3d36dfSmrg test -n "$rpath" && \ 10096b43acbb4Smrg func_warning "'-rpath' is ignored for objects" 100975a3d36dfSmrg 100985a3d36dfSmrg test -n "$xrpath" && \ 10099b43acbb4Smrg func_warning "'-R' is ignored for objects" 1010023a0898aSmrg 101015a3d36dfSmrg test -n "$vinfo" && \ 10102b43acbb4Smrg func_warning "'-version-info' is ignored for objects" 101037f7f5e4eSmrg 101045a3d36dfSmrg test -n "$release" && \ 10105b43acbb4Smrg func_warning "'-release' is ignored for objects" 101065a3d36dfSmrg 101075a3d36dfSmrg case $output in 101085a3d36dfSmrg *.lo) 101095a3d36dfSmrg test -n "$objs$old_deplibs" && \ 10110b43acbb4Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 101115a3d36dfSmrg 101125a3d36dfSmrg libobj=$output 101135a3d36dfSmrg func_lo2o "$libobj" 101145a3d36dfSmrg obj=$func_lo2o_result 10115b3062210Smrg ;; 10116b3062210Smrg *) 101175a3d36dfSmrg libobj= 10118b43acbb4Smrg obj=$output 1011923a0898aSmrg ;; 101207f7f5e4eSmrg esac 1012123a0898aSmrg 101225a3d36dfSmrg # Delete the old objects. 101235a3d36dfSmrg $opt_dry_run || $RM $obj $libobj 1012423a0898aSmrg 101255a3d36dfSmrg # Objects from convenience libraries. This assumes 101265a3d36dfSmrg # single-version convenience libraries. Whenever we create 101275a3d36dfSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 101285a3d36dfSmrg # the extraction. 101295a3d36dfSmrg reload_conv_objs= 101305a3d36dfSmrg gentop= 10131b43acbb4Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10132b43acbb4Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10133b43acbb4Smrg # into space. 10134b43acbb4Smrg case $reload_cmds in 10135b43acbb4Smrg *\$LD[\ \$]*) wl= ;; 10136b43acbb4Smrg esac 101375a3d36dfSmrg if test -n "$convenience"; then 101385a3d36dfSmrg if test -n "$whole_archive_flag_spec"; then 101395a3d36dfSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10140b43acbb4Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10141b43acbb4Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 101425a3d36dfSmrg else 10143b43acbb4Smrg gentop=$output_objdir/${obj}x 1014441c30155Smrg func_append generated " $gentop" 10145b3062210Smrg 101465a3d36dfSmrg func_extract_archives $gentop $convenience 101475a3d36dfSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 101485a3d36dfSmrg fi 10149b3062210Smrg fi 10150b3062210Smrg 1015141c30155Smrg # If we're not building shared, we need to use non_pic_objs 10152b43acbb4Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1015341c30155Smrg 101545a3d36dfSmrg # Create the old-style object. 10155b43acbb4Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10156b3062210Smrg 10157b43acbb4Smrg output=$obj 101585a3d36dfSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10159b3062210Smrg 101605a3d36dfSmrg # Exit if we aren't doing a library object file. 101615a3d36dfSmrg if test -z "$libobj"; then 101625a3d36dfSmrg if test -n "$gentop"; then 101635a3d36dfSmrg func_show_eval '${RM}r "$gentop"' 101645a3d36dfSmrg fi 101655a3d36dfSmrg 101665a3d36dfSmrg exit $EXIT_SUCCESS 10167b3062210Smrg fi 101685a3d36dfSmrg 10169b43acbb4Smrg test yes = "$build_libtool_libs" || { 101705a3d36dfSmrg if test -n "$gentop"; then 101715a3d36dfSmrg func_show_eval '${RM}r "$gentop"' 101725a3d36dfSmrg fi 101735a3d36dfSmrg 101745a3d36dfSmrg # Create an invalid libtool object if no PIC, so that we don't 101755a3d36dfSmrg # accidentally link it into a program. 101765a3d36dfSmrg # $show "echo timestamp > $libobj" 101775a3d36dfSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 101785a3d36dfSmrg exit $EXIT_SUCCESS 10179b43acbb4Smrg } 101805a3d36dfSmrg 10181b43acbb4Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 101825a3d36dfSmrg # Only do commands if we really have different PIC objects. 101835a3d36dfSmrg reload_objs="$libobjs $reload_conv_objs" 10184b43acbb4Smrg output=$libobj 101855a3d36dfSmrg func_execute_cmds "$reload_cmds" 'exit $?' 101865a3d36dfSmrg fi 101875a3d36dfSmrg 101885a3d36dfSmrg if test -n "$gentop"; then 101895a3d36dfSmrg func_show_eval '${RM}r "$gentop"' 101905a3d36dfSmrg fi 101915a3d36dfSmrg 101925a3d36dfSmrg exit $EXIT_SUCCESS 10193b3062210Smrg ;; 1019423a0898aSmrg 101955a3d36dfSmrg prog) 101965a3d36dfSmrg case $host in 101975a3d36dfSmrg *cygwin*) func_stripname '' '.exe' "$output" 101985a3d36dfSmrg output=$func_stripname_result.exe;; 101995a3d36dfSmrg esac 102005a3d36dfSmrg test -n "$vinfo" && \ 10201b43acbb4Smrg func_warning "'-version-info' is ignored for programs" 1020223a0898aSmrg 102035a3d36dfSmrg test -n "$release" && \ 10204b43acbb4Smrg func_warning "'-release' is ignored for programs" 1020523a0898aSmrg 10206b43acbb4Smrg $preload \ 10207b43acbb4Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10208b43acbb4Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 102095a3d36dfSmrg 102105a3d36dfSmrg case $host in 102115a3d36dfSmrg *-*-rhapsody* | *-*-darwin1.[012]) 102125a3d36dfSmrg # On Rhapsody replace the C library is the System framework 1021341c30155Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1021441c30155Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10215b3062210Smrg ;; 102165a3d36dfSmrg esac 10217b3062210Smrg 102185a3d36dfSmrg case $host in 102195a3d36dfSmrg *-*-darwin*) 102205a3d36dfSmrg # Don't allow lazy linking, it breaks C++ global constructors 102215a3d36dfSmrg # But is supposedly fixed on 10.4 or later (yay!). 10222b43acbb4Smrg if test CXX = "$tagname"; then 102235a3d36dfSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 102245a3d36dfSmrg 10.[0123]) 10225b43acbb4Smrg func_append compile_command " $wl-bind_at_load" 10226b43acbb4Smrg func_append finalize_command " $wl-bind_at_load" 102275a3d36dfSmrg ;; 102285a3d36dfSmrg esac 10229b3062210Smrg fi 102305a3d36dfSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1023141c30155Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1023241c30155Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102335a3d36dfSmrg ;; 102345a3d36dfSmrg esac 10235b3062210Smrg 10236b3062210Smrg 102375a3d36dfSmrg # move library search paths that coincide with paths to not yet 102385a3d36dfSmrg # installed libraries to the beginning of the library search list 102395a3d36dfSmrg new_libs= 102405a3d36dfSmrg for path in $notinst_path; do 102415a3d36dfSmrg case " $new_libs " in 102425a3d36dfSmrg *" -L$path/$objdir "*) ;; 102435a3d36dfSmrg *) 102445a3d36dfSmrg case " $compile_deplibs " in 102455a3d36dfSmrg *" -L$path/$objdir "*) 1024641c30155Smrg func_append new_libs " -L$path/$objdir" ;; 102477f7f5e4eSmrg esac 102485a3d36dfSmrg ;; 102495a3d36dfSmrg esac 102505a3d36dfSmrg done 102515a3d36dfSmrg for deplib in $compile_deplibs; do 102525a3d36dfSmrg case $deplib in 102535a3d36dfSmrg -L*) 102545a3d36dfSmrg case " $new_libs " in 102555a3d36dfSmrg *" $deplib "*) ;; 1025641c30155Smrg *) func_append new_libs " $deplib" ;; 102577f7f5e4eSmrg esac 102585a3d36dfSmrg ;; 1025941c30155Smrg *) func_append new_libs " $deplib" ;; 102605a3d36dfSmrg esac 102615a3d36dfSmrg done 10262b43acbb4Smrg compile_deplibs=$new_libs 1026323a0898aSmrg 10264b3062210Smrg 1026541c30155Smrg func_append compile_command " $compile_deplibs" 1026641c30155Smrg func_append finalize_command " $finalize_deplibs" 10267b3062210Smrg 102685a3d36dfSmrg if test -n "$rpath$xrpath"; then 102695a3d36dfSmrg # If the user specified any rpath flags, then add them. 102705a3d36dfSmrg for libdir in $rpath $xrpath; do 102715a3d36dfSmrg # This is the magic to use -rpath. 102725a3d36dfSmrg case "$finalize_rpath " in 102735a3d36dfSmrg *" $libdir "*) ;; 1027441c30155Smrg *) func_append finalize_rpath " $libdir" ;; 102755a3d36dfSmrg esac 102765a3d36dfSmrg done 102775a3d36dfSmrg fi 10278b3062210Smrg 102795a3d36dfSmrg # Now hardcode the library paths 102805a3d36dfSmrg rpath= 102815a3d36dfSmrg hardcode_libdirs= 102825a3d36dfSmrg for libdir in $compile_rpath $finalize_rpath; do 102835a3d36dfSmrg if test -n "$hardcode_libdir_flag_spec"; then 102845a3d36dfSmrg if test -n "$hardcode_libdir_separator"; then 102855a3d36dfSmrg if test -z "$hardcode_libdirs"; then 10286b43acbb4Smrg hardcode_libdirs=$libdir 102875a3d36dfSmrg else 102885a3d36dfSmrg # Just accumulate the unique libdirs. 102895a3d36dfSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 102905a3d36dfSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 102915a3d36dfSmrg ;; 102925a3d36dfSmrg *) 1029341c30155Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 102945a3d36dfSmrg ;; 102955a3d36dfSmrg esac 102965a3d36dfSmrg fi 10297b3062210Smrg else 102985a3d36dfSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1029941c30155Smrg func_append rpath " $flag" 10300b3062210Smrg fi 103015a3d36dfSmrg elif test -n "$runpath_var"; then 103025a3d36dfSmrg case "$perm_rpath " in 103035a3d36dfSmrg *" $libdir "*) ;; 1030441c30155Smrg *) func_append perm_rpath " $libdir" ;; 103055a3d36dfSmrg esac 103065a3d36dfSmrg fi 103075a3d36dfSmrg case $host in 103085a3d36dfSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10309b43acbb4Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 103105a3d36dfSmrg case :$dllsearchpath: in 103115a3d36dfSmrg *":$libdir:"*) ;; 103125a3d36dfSmrg ::) dllsearchpath=$libdir;; 1031341c30155Smrg *) func_append dllsearchpath ":$libdir";; 103145a3d36dfSmrg esac 103155a3d36dfSmrg case :$dllsearchpath: in 103165a3d36dfSmrg *":$testbindir:"*) ;; 103175a3d36dfSmrg ::) dllsearchpath=$testbindir;; 1031841c30155Smrg *) func_append dllsearchpath ":$testbindir";; 103195a3d36dfSmrg esac 103205a3d36dfSmrg ;; 103215a3d36dfSmrg esac 103225a3d36dfSmrg done 103235a3d36dfSmrg # Substitute the hardcoded libdirs into the rpath. 103245a3d36dfSmrg if test -n "$hardcode_libdir_separator" && 103255a3d36dfSmrg test -n "$hardcode_libdirs"; then 10326b43acbb4Smrg libdir=$hardcode_libdirs 103275a3d36dfSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103285a3d36dfSmrg fi 10329b43acbb4Smrg compile_rpath=$rpath 10330b3062210Smrg 103315a3d36dfSmrg rpath= 103325a3d36dfSmrg hardcode_libdirs= 103335a3d36dfSmrg for libdir in $finalize_rpath; do 103345a3d36dfSmrg if test -n "$hardcode_libdir_flag_spec"; then 103355a3d36dfSmrg if test -n "$hardcode_libdir_separator"; then 103365a3d36dfSmrg if test -z "$hardcode_libdirs"; then 10337b43acbb4Smrg hardcode_libdirs=$libdir 103385a3d36dfSmrg else 103395a3d36dfSmrg # Just accumulate the unique libdirs. 103405a3d36dfSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 103415a3d36dfSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 103425a3d36dfSmrg ;; 103435a3d36dfSmrg *) 1034441c30155Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 103455a3d36dfSmrg ;; 103465a3d36dfSmrg esac 103475a3d36dfSmrg fi 1034823a0898aSmrg else 103495a3d36dfSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1035041c30155Smrg func_append rpath " $flag" 1035123a0898aSmrg fi 103525a3d36dfSmrg elif test -n "$runpath_var"; then 103535a3d36dfSmrg case "$finalize_perm_rpath " in 103545a3d36dfSmrg *" $libdir "*) ;; 1035541c30155Smrg *) func_append finalize_perm_rpath " $libdir" ;; 103565a3d36dfSmrg esac 1035723a0898aSmrg fi 103585a3d36dfSmrg done 103595a3d36dfSmrg # Substitute the hardcoded libdirs into the rpath. 103605a3d36dfSmrg if test -n "$hardcode_libdir_separator" && 103615a3d36dfSmrg test -n "$hardcode_libdirs"; then 10362b43acbb4Smrg libdir=$hardcode_libdirs 103635a3d36dfSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103645a3d36dfSmrg fi 10365b43acbb4Smrg finalize_rpath=$rpath 1036623a0898aSmrg 10367b43acbb4Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 103685a3d36dfSmrg # Transform all the library objects into standard objects. 1036941c30155Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1037041c30155Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103715a3d36dfSmrg fi 1037223a0898aSmrg 10373b43acbb4Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1037423a0898aSmrg 103755a3d36dfSmrg # template prelinking step 103765a3d36dfSmrg if test -n "$prelink_cmds"; then 103775a3d36dfSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 103785a3d36dfSmrg fi 1037923a0898aSmrg 10380b43acbb4Smrg wrappers_required=: 103815a3d36dfSmrg case $host in 1038241c30155Smrg *cegcc* | *mingw32ce*) 1038341c30155Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10384b43acbb4Smrg wrappers_required=false 1038541c30155Smrg ;; 103865a3d36dfSmrg *cygwin* | *mingw* ) 10387b43acbb4Smrg test yes = "$build_libtool_libs" || wrappers_required=false 103885a3d36dfSmrg ;; 103895a3d36dfSmrg *) 10390b43acbb4Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10391b43acbb4Smrg wrappers_required=false 103925a3d36dfSmrg fi 103935a3d36dfSmrg ;; 103945a3d36dfSmrg esac 10395b43acbb4Smrg $wrappers_required || { 103965a3d36dfSmrg # Replace the output file specification. 1039741c30155Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10398b43acbb4Smrg link_command=$compile_command$compile_rpath 1039923a0898aSmrg 104005a3d36dfSmrg # We have no uninstalled library dependencies, so finalize right now. 104015a3d36dfSmrg exit_status=0 104025a3d36dfSmrg func_show_eval "$link_command" 'exit_status=$?' 1040323a0898aSmrg 1040441c30155Smrg if test -n "$postlink_cmds"; then 1040541c30155Smrg func_to_tool_file "$output" 1040641c30155Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1040741c30155Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1040841c30155Smrg fi 1040941c30155Smrg 104105a3d36dfSmrg # Delete the generated files. 10411b43acbb4Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10412b43acbb4Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1041323a0898aSmrg fi 1041423a0898aSmrg 104155a3d36dfSmrg exit $exit_status 10416b43acbb4Smrg } 1041723a0898aSmrg 104185a3d36dfSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 104195a3d36dfSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 104205a3d36dfSmrg fi 104215a3d36dfSmrg if test -n "$finalize_shlibpath"; then 104225a3d36dfSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 104235a3d36dfSmrg fi 10424b3062210Smrg 104255a3d36dfSmrg compile_var= 104265a3d36dfSmrg finalize_var= 104275a3d36dfSmrg if test -n "$runpath_var"; then 104285a3d36dfSmrg if test -n "$perm_rpath"; then 104295a3d36dfSmrg # We should set the runpath_var. 104305a3d36dfSmrg rpath= 104315a3d36dfSmrg for dir in $perm_rpath; do 1043241c30155Smrg func_append rpath "$dir:" 104335a3d36dfSmrg done 104345a3d36dfSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1043523a0898aSmrg fi 104365a3d36dfSmrg if test -n "$finalize_perm_rpath"; then 104375a3d36dfSmrg # We should set the runpath_var. 104385a3d36dfSmrg rpath= 104395a3d36dfSmrg for dir in $finalize_perm_rpath; do 1044041c30155Smrg func_append rpath "$dir:" 104415a3d36dfSmrg done 104425a3d36dfSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1044323a0898aSmrg fi 104445a3d36dfSmrg fi 1044523a0898aSmrg 10446b43acbb4Smrg if test yes = "$no_install"; then 104475a3d36dfSmrg # We don't need to create a wrapper script. 10448b43acbb4Smrg link_command=$compile_var$compile_command$compile_rpath 104495a3d36dfSmrg # Replace the output file specification. 1045041c30155Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104515a3d36dfSmrg # Delete the old output file. 104525a3d36dfSmrg $opt_dry_run || $RM $output 104535a3d36dfSmrg # Link the executable and exit 104545a3d36dfSmrg func_show_eval "$link_command" 'exit $?' 1045541c30155Smrg 1045641c30155Smrg if test -n "$postlink_cmds"; then 1045741c30155Smrg func_to_tool_file "$output" 1045841c30155Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1045941c30155Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1046041c30155Smrg fi 1046141c30155Smrg 10462b3062210Smrg exit $EXIT_SUCCESS 104635a3d36dfSmrg fi 104647f7f5e4eSmrg 10465b43acbb4Smrg case $hardcode_action,$fast_install in 10466b43acbb4Smrg relink,*) 10467b43acbb4Smrg # Fast installation is not supported 10468b43acbb4Smrg link_command=$compile_var$compile_command$compile_rpath 10469b43acbb4Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 104705a3d36dfSmrg 10471b43acbb4Smrg func_warning "this platform does not like uninstalled shared libraries" 10472b43acbb4Smrg func_warning "'$output' will be relinked during installation" 10473b43acbb4Smrg ;; 10474b43acbb4Smrg *,yes) 10475b43acbb4Smrg link_command=$finalize_var$compile_command$finalize_rpath 10476b43acbb4Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10477b43acbb4Smrg ;; 10478b43acbb4Smrg *,no) 10479b43acbb4Smrg link_command=$compile_var$compile_command$compile_rpath 10480b43acbb4Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10481b43acbb4Smrg ;; 10482b43acbb4Smrg *,needless) 10483b43acbb4Smrg link_command=$finalize_var$compile_command$finalize_rpath 10484b43acbb4Smrg relink_command= 10485b43acbb4Smrg ;; 10486b43acbb4Smrg esac 1048723a0898aSmrg 104885a3d36dfSmrg # Replace the output file specification. 1048941c30155Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1049023a0898aSmrg 104915a3d36dfSmrg # Delete the old output files. 104925a3d36dfSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1049323a0898aSmrg 104945a3d36dfSmrg func_show_eval "$link_command" 'exit $?' 10495b3062210Smrg 1049641c30155Smrg if test -n "$postlink_cmds"; then 1049741c30155Smrg func_to_tool_file "$output_objdir/$outputname" 1049841c30155Smrg 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'` 1049941c30155Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1050041c30155Smrg fi 1050141c30155Smrg 105025a3d36dfSmrg # Now create the wrapper script. 105035a3d36dfSmrg func_verbose "creating $output" 10504b3062210Smrg 105055a3d36dfSmrg # Quote the relink command for shipping. 105065a3d36dfSmrg if test -n "$relink_command"; then 105075a3d36dfSmrg # Preserve any variables that may affect compiler behavior 105085a3d36dfSmrg for var in $variables_saved_for_relink; do 105095a3d36dfSmrg if eval test -z \"\${$var+set}\"; then 105105a3d36dfSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 105115a3d36dfSmrg elif eval var_value=\$$var; test -z "$var_value"; then 105125a3d36dfSmrg relink_command="$var=; export $var; $relink_command" 1051323a0898aSmrg else 105145a3d36dfSmrg func_quote_for_eval "$var_value" 105155a3d36dfSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1051623a0898aSmrg fi 105175a3d36dfSmrg done 105185a3d36dfSmrg relink_command="(cd `pwd`; $relink_command)" 1051941c30155Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 105205a3d36dfSmrg fi 105215a3d36dfSmrg 105225a3d36dfSmrg # Only actually do things if not in dry run mode. 105235a3d36dfSmrg $opt_dry_run || { 105245a3d36dfSmrg # win32 will think the script is a binary if it has 105255a3d36dfSmrg # a .exe suffix, so we strip it off here. 105265a3d36dfSmrg case $output in 105275a3d36dfSmrg *.exe) func_stripname '' '.exe' "$output" 105285a3d36dfSmrg output=$func_stripname_result ;; 105295a3d36dfSmrg esac 105305a3d36dfSmrg # test for cygwin because mv fails w/o .exe extensions 105315a3d36dfSmrg case $host in 105325a3d36dfSmrg *cygwin*) 105335a3d36dfSmrg exeext=.exe 105345a3d36dfSmrg func_stripname '' '.exe' "$outputname" 105355a3d36dfSmrg outputname=$func_stripname_result ;; 105365a3d36dfSmrg *) exeext= ;; 1053723a0898aSmrg esac 105385a3d36dfSmrg case $host in 105395a3d36dfSmrg *cygwin* | *mingw* ) 105405a3d36dfSmrg func_dirname_and_basename "$output" "" "." 105415a3d36dfSmrg output_name=$func_basename_result 105425a3d36dfSmrg output_path=$func_dirname_result 10543b43acbb4Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10544b43acbb4Smrg cwrapper=$output_path/$output_name.exe 105455a3d36dfSmrg $RM $cwrappersource $cwrapper 105465a3d36dfSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 105475a3d36dfSmrg 105485a3d36dfSmrg func_emit_cwrapperexe_src > $cwrappersource 105495a3d36dfSmrg 105505a3d36dfSmrg # The wrapper executable is built using the $host compiler, 105515a3d36dfSmrg # because it contains $host paths and files. If cross- 105525a3d36dfSmrg # compiling, it, like the target executable, must be 105535a3d36dfSmrg # executed on the $host or under an emulation environment. 105545a3d36dfSmrg $opt_dry_run || { 105555a3d36dfSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 105565a3d36dfSmrg $STRIP $cwrapper 105575a3d36dfSmrg } 1055823a0898aSmrg 105595a3d36dfSmrg # Now, create the wrapper script for func_source use: 105605a3d36dfSmrg func_ltwrapper_scriptname $cwrapper 105615a3d36dfSmrg $RM $func_ltwrapper_scriptname_result 105625a3d36dfSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 105635a3d36dfSmrg $opt_dry_run || { 105645a3d36dfSmrg # note: this script will not be executed, so do not chmod. 10565b43acbb4Smrg if test "x$build" = "x$host"; then 105665a3d36dfSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 105675a3d36dfSmrg else 105685a3d36dfSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 105695a3d36dfSmrg fi 105705a3d36dfSmrg } 105715a3d36dfSmrg ;; 105725a3d36dfSmrg * ) 105735a3d36dfSmrg $RM $output 105745a3d36dfSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1057523a0898aSmrg 105765a3d36dfSmrg func_emit_wrapper no > $output 105775a3d36dfSmrg chmod +x $output 105785a3d36dfSmrg ;; 105795a3d36dfSmrg esac 105805a3d36dfSmrg } 105815a3d36dfSmrg exit $EXIT_SUCCESS 105825a3d36dfSmrg ;; 105835a3d36dfSmrg esac 1058423a0898aSmrg 105855a3d36dfSmrg # See if we need to build an old-fashioned archive. 105865a3d36dfSmrg for oldlib in $oldlibs; do 1058723a0898aSmrg 10588b43acbb4Smrg case $build_libtool_libs in 10589b43acbb4Smrg convenience) 10590b43acbb4Smrg oldobjs="$libobjs_save $symfileobj" 10591b43acbb4Smrg addlibs=$convenience 105925a3d36dfSmrg build_libtool_libs=no 10593b43acbb4Smrg ;; 10594b43acbb4Smrg module) 10595b43acbb4Smrg oldobjs=$libobjs_save 10596b43acbb4Smrg addlibs=$old_convenience 10597b43acbb4Smrg build_libtool_libs=no 10598b43acbb4Smrg ;; 10599b43acbb4Smrg *) 106005a3d36dfSmrg oldobjs="$old_deplibs $non_pic_objects" 10601b43acbb4Smrg $preload && test -f "$symfileobj" \ 10602b43acbb4Smrg && func_append oldobjs " $symfileobj" 10603b43acbb4Smrg addlibs=$old_convenience 10604b43acbb4Smrg ;; 10605b43acbb4Smrg esac 1060623a0898aSmrg 106075a3d36dfSmrg if test -n "$addlibs"; then 10608b43acbb4Smrg gentop=$output_objdir/${outputname}x 1060941c30155Smrg func_append generated " $gentop" 1061023a0898aSmrg 106115a3d36dfSmrg func_extract_archives $gentop $addlibs 1061241c30155Smrg func_append oldobjs " $func_extract_archives_result" 106135a3d36dfSmrg fi 1061423a0898aSmrg 106155a3d36dfSmrg # Do each command in the archive commands. 10616b43acbb4Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 106175a3d36dfSmrg cmds=$old_archive_from_new_cmds 106185a3d36dfSmrg else 1061923a0898aSmrg 106205a3d36dfSmrg # Add any objects from preloaded convenience libraries 106215a3d36dfSmrg if test -n "$dlprefiles"; then 10622b43acbb4Smrg gentop=$output_objdir/${outputname}x 1062341c30155Smrg func_append generated " $gentop" 1062423a0898aSmrg 106255a3d36dfSmrg func_extract_archives $gentop $dlprefiles 1062641c30155Smrg func_append oldobjs " $func_extract_archives_result" 106275a3d36dfSmrg fi 1062823a0898aSmrg 106295a3d36dfSmrg # POSIX demands no paths to be encoded in archives. We have 106305a3d36dfSmrg # to avoid creating archives with duplicate basenames if we 106315a3d36dfSmrg # might have to extract them afterwards, e.g., when creating a 106325a3d36dfSmrg # static archive out of a convenience library, or when linking 106335a3d36dfSmrg # the entirety of a libtool archive into another (currently 106345a3d36dfSmrg # not supported by libtool). 106355a3d36dfSmrg if (for obj in $oldobjs 106365a3d36dfSmrg do 106375a3d36dfSmrg func_basename "$obj" 106385a3d36dfSmrg $ECHO "$func_basename_result" 106395a3d36dfSmrg done | sort | sort -uc >/dev/null 2>&1); then 106405a3d36dfSmrg : 106415a3d36dfSmrg else 1064241c30155Smrg echo "copying selected object files to avoid basename conflicts..." 10643b43acbb4Smrg gentop=$output_objdir/${outputname}x 1064441c30155Smrg func_append generated " $gentop" 106455a3d36dfSmrg func_mkdir_p "$gentop" 106465a3d36dfSmrg save_oldobjs=$oldobjs 106475a3d36dfSmrg oldobjs= 106485a3d36dfSmrg counter=1 106495a3d36dfSmrg for obj in $save_oldobjs 106505a3d36dfSmrg do 106515a3d36dfSmrg func_basename "$obj" 10652b43acbb4Smrg objbase=$func_basename_result 106535a3d36dfSmrg case " $oldobjs " in 106545a3d36dfSmrg " ") oldobjs=$obj ;; 106555a3d36dfSmrg *[\ /]"$objbase "*) 106565a3d36dfSmrg while :; do 106575a3d36dfSmrg # Make sure we don't pick an alternate name that also 106585a3d36dfSmrg # overlaps. 106595a3d36dfSmrg newobj=lt$counter-$objbase 106605a3d36dfSmrg func_arith $counter + 1 106615a3d36dfSmrg counter=$func_arith_result 106625a3d36dfSmrg case " $oldobjs " in 106635a3d36dfSmrg *[\ /]"$newobj "*) ;; 106645a3d36dfSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 106655a3d36dfSmrg esac 106665a3d36dfSmrg done 106675a3d36dfSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1066841c30155Smrg func_append oldobjs " $gentop/$newobj" 106695a3d36dfSmrg ;; 1067041c30155Smrg *) func_append oldobjs " $obj" ;; 106715a3d36dfSmrg esac 1067223a0898aSmrg done 106737f7f5e4eSmrg fi 10674b020570bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10675b020570bSmrg tool_oldlib=$func_to_tool_file_result 106765a3d36dfSmrg eval cmds=\"$old_archive_cmds\" 10677b3062210Smrg 106785a3d36dfSmrg func_len " $cmds" 106795a3d36dfSmrg len=$func_len_result 106805a3d36dfSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 106815a3d36dfSmrg cmds=$old_archive_cmds 1068241c30155Smrg elif test -n "$archiver_list_spec"; then 1068341c30155Smrg func_verbose "using command file archive linking..." 1068441c30155Smrg for obj in $oldobjs 1068541c30155Smrg do 1068641c30155Smrg func_to_tool_file "$obj" 1068741c30155Smrg $ECHO "$func_to_tool_file_result" 1068841c30155Smrg done > $output_objdir/$libname.libcmd 1068941c30155Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1069041c30155Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1069141c30155Smrg cmds=$old_archive_cmds 106925a3d36dfSmrg else 106935a3d36dfSmrg # the command line is too long to link in one step, link in parts 106945a3d36dfSmrg func_verbose "using piecewise archive linking..." 106955a3d36dfSmrg save_RANLIB=$RANLIB 106965a3d36dfSmrg RANLIB=: 106975a3d36dfSmrg objlist= 106985a3d36dfSmrg concat_cmds= 106995a3d36dfSmrg save_oldobjs=$oldobjs 107005a3d36dfSmrg oldobjs= 107015a3d36dfSmrg # Is there a better way of finding the last object in the list? 107025a3d36dfSmrg for obj in $save_oldobjs 107035a3d36dfSmrg do 107045a3d36dfSmrg last_oldobj=$obj 107055a3d36dfSmrg done 107065a3d36dfSmrg eval test_cmds=\"$old_archive_cmds\" 107075a3d36dfSmrg func_len " $test_cmds" 107085a3d36dfSmrg len0=$func_len_result 107095a3d36dfSmrg len=$len0 107105a3d36dfSmrg for obj in $save_oldobjs 107115a3d36dfSmrg do 107125a3d36dfSmrg func_len " $obj" 107135a3d36dfSmrg func_arith $len + $func_len_result 107145a3d36dfSmrg len=$func_arith_result 107155a3d36dfSmrg func_append objlist " $obj" 107165a3d36dfSmrg if test "$len" -lt "$max_cmd_len"; then 107175a3d36dfSmrg : 107185a3d36dfSmrg else 107195a3d36dfSmrg # the above command should be used before it gets too long 107205a3d36dfSmrg oldobjs=$objlist 10721b43acbb4Smrg if test "$obj" = "$last_oldobj"; then 107225a3d36dfSmrg RANLIB=$save_RANLIB 107235a3d36dfSmrg fi 107245a3d36dfSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10725b43acbb4Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 107265a3d36dfSmrg objlist= 107275a3d36dfSmrg len=$len0 107285a3d36dfSmrg fi 107295a3d36dfSmrg done 107305a3d36dfSmrg RANLIB=$save_RANLIB 107315a3d36dfSmrg oldobjs=$objlist 10732b43acbb4Smrg if test -z "$oldobjs"; then 107335a3d36dfSmrg eval cmds=\"\$concat_cmds\" 107345a3d36dfSmrg else 107355a3d36dfSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 107365a3d36dfSmrg fi 107375a3d36dfSmrg fi 107385a3d36dfSmrg fi 107395a3d36dfSmrg func_execute_cmds "$cmds" 'exit $?' 1074023a0898aSmrg done 1074123a0898aSmrg 107425a3d36dfSmrg test -n "$generated" && \ 107435a3d36dfSmrg func_show_eval "${RM}r$generated" 1074423a0898aSmrg 107455a3d36dfSmrg # Now create the libtool archive. 107465a3d36dfSmrg case $output in 107475a3d36dfSmrg *.la) 107485a3d36dfSmrg old_library= 10749b43acbb4Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 107505a3d36dfSmrg func_verbose "creating $output" 107517f7f5e4eSmrg 107525a3d36dfSmrg # Preserve any variables that may affect compiler behavior 107535a3d36dfSmrg for var in $variables_saved_for_relink; do 107545a3d36dfSmrg if eval test -z \"\${$var+set}\"; then 107555a3d36dfSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107565a3d36dfSmrg elif eval var_value=\$$var; test -z "$var_value"; then 107575a3d36dfSmrg relink_command="$var=; export $var; $relink_command" 10758b3062210Smrg else 107595a3d36dfSmrg func_quote_for_eval "$var_value" 107605a3d36dfSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10761b3062210Smrg fi 107625a3d36dfSmrg done 107635a3d36dfSmrg # Quote the link command for shipping. 10764b43acbb4Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1076541c30155Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10766b43acbb4Smrg if test yes = "$hardcode_automatic"; then 107675a3d36dfSmrg relink_command= 107685a3d36dfSmrg fi 1076923a0898aSmrg 107705a3d36dfSmrg # Only create the output if not a dry run. 107715a3d36dfSmrg $opt_dry_run || { 107725a3d36dfSmrg for installed in no yes; do 10773b43acbb4Smrg if test yes = "$installed"; then 107745a3d36dfSmrg if test -z "$install_libdir"; then 107755a3d36dfSmrg break 107765a3d36dfSmrg fi 10777b43acbb4Smrg output=$output_objdir/${outputname}i 107785a3d36dfSmrg # Replace all uninstalled libtool libraries with the installed ones 107795a3d36dfSmrg newdependency_libs= 107805a3d36dfSmrg for deplib in $dependency_libs; do 107815a3d36dfSmrg case $deplib in 107825a3d36dfSmrg *.la) 107835a3d36dfSmrg func_basename "$deplib" 10784b43acbb4Smrg name=$func_basename_result 10785b020570bSmrg func_resolve_sysroot "$deplib" 10786b43acbb4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 107875a3d36dfSmrg test -z "$libdir" && \ 10788b43acbb4Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 1078941c30155Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1079041c30155Smrg ;; 1079141c30155Smrg -L*) 1079241c30155Smrg func_stripname -L '' "$deplib" 1079341c30155Smrg func_replace_sysroot "$func_stripname_result" 1079441c30155Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 107955a3d36dfSmrg ;; 1079641c30155Smrg -R*) 1079741c30155Smrg func_stripname -R '' "$deplib" 1079841c30155Smrg func_replace_sysroot "$func_stripname_result" 1079941c30155Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1080041c30155Smrg ;; 1080141c30155Smrg *) func_append newdependency_libs " $deplib" ;; 108025a3d36dfSmrg esac 108035a3d36dfSmrg done 10804b43acbb4Smrg dependency_libs=$newdependency_libs 108055a3d36dfSmrg newdlfiles= 108065a3d36dfSmrg 108075a3d36dfSmrg for lib in $dlfiles; do 108085a3d36dfSmrg case $lib in 108095a3d36dfSmrg *.la) 108105a3d36dfSmrg func_basename "$lib" 10811b43acbb4Smrg name=$func_basename_result 10812b43acbb4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108135a3d36dfSmrg test -z "$libdir" && \ 10814b43acbb4Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1081541c30155Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 108165a3d36dfSmrg ;; 1081741c30155Smrg *) func_append newdlfiles " $lib" ;; 108185a3d36dfSmrg esac 108195a3d36dfSmrg done 10820b43acbb4Smrg dlfiles=$newdlfiles 108215a3d36dfSmrg newdlprefiles= 108225a3d36dfSmrg for lib in $dlprefiles; do 108235a3d36dfSmrg case $lib in 108245a3d36dfSmrg *.la) 108255a3d36dfSmrg # Only pass preopened files to the pseudo-archive (for 108265a3d36dfSmrg # eventual linking with the app. that links it) if we 108275a3d36dfSmrg # didn't already link the preopened objects directly into 108285a3d36dfSmrg # the library: 108295a3d36dfSmrg func_basename "$lib" 10830b43acbb4Smrg name=$func_basename_result 10831b43acbb4Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108325a3d36dfSmrg test -z "$libdir" && \ 10833b43acbb4Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1083441c30155Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 108355a3d36dfSmrg ;; 108365a3d36dfSmrg esac 108375a3d36dfSmrg done 10838b43acbb4Smrg dlprefiles=$newdlprefiles 108395a3d36dfSmrg else 108405a3d36dfSmrg newdlfiles= 108415a3d36dfSmrg for lib in $dlfiles; do 108425a3d36dfSmrg case $lib in 10843b43acbb4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108445a3d36dfSmrg *) abs=`pwd`"/$lib" ;; 108455a3d36dfSmrg esac 1084641c30155Smrg func_append newdlfiles " $abs" 108475a3d36dfSmrg done 10848b43acbb4Smrg dlfiles=$newdlfiles 108495a3d36dfSmrg newdlprefiles= 108505a3d36dfSmrg for lib in $dlprefiles; do 108515a3d36dfSmrg case $lib in 10852b43acbb4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108535a3d36dfSmrg *) abs=`pwd`"/$lib" ;; 108545a3d36dfSmrg esac 1085541c30155Smrg func_append newdlprefiles " $abs" 108565a3d36dfSmrg done 10857b43acbb4Smrg dlprefiles=$newdlprefiles 108585a3d36dfSmrg fi 108595a3d36dfSmrg $RM $output 108605a3d36dfSmrg # place dlname in correct position for cygwin 1086141c30155Smrg # In fact, it would be nice if we could use this code for all target 1086241c30155Smrg # systems that can't hard-code library paths into their executables 1086341c30155Smrg # and that have no shared library path variable independent of PATH, 1086441c30155Smrg # but it turns out we can't easily determine that from inspecting 1086541c30155Smrg # libtool variables, so we have to hard-code the OSs to which it 1086641c30155Smrg # applies here; at the moment, that means platforms that use the PE 1086741c30155Smrg # object format with DLL files. See the long comment at the top of 1086841c30155Smrg # tests/bindir.at for full details. 108695a3d36dfSmrg tdlname=$dlname 108705a3d36dfSmrg case $host,$output,$installed,$module,$dlname in 1087141c30155Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1087241c30155Smrg # If a -bindir argument was supplied, place the dll there. 10873b43acbb4Smrg if test -n "$bindir"; then 1087441c30155Smrg func_relative_path "$install_libdir" "$bindir" 10875b43acbb4Smrg tdlname=$func_relative_path_result/$dlname 1087641c30155Smrg else 1087741c30155Smrg # Otherwise fall back on heuristic. 1087841c30155Smrg tdlname=../bin/$dlname 1087941c30155Smrg fi 1088041c30155Smrg ;; 108815a3d36dfSmrg esac 108825a3d36dfSmrg $ECHO > $output "\ 108835a3d36dfSmrg# $outputname - a libtool library file 10884b43acbb4Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 108855a3d36dfSmrg# 108865a3d36dfSmrg# Please DO NOT delete this file! 108875a3d36dfSmrg# It is necessary for linking the library. 1088823a0898aSmrg 108895a3d36dfSmrg# The name that we can dlopen(3). 108905a3d36dfSmrgdlname='$tdlname' 1089123a0898aSmrg 108925a3d36dfSmrg# Names of this library. 108935a3d36dfSmrglibrary_names='$library_names' 1089423a0898aSmrg 108955a3d36dfSmrg# The name of the static archive. 108965a3d36dfSmrgold_library='$old_library' 1089723a0898aSmrg 10898b43acbb4Smrg# Linker flags that cannot go in dependency_libs. 108995a3d36dfSmrginherited_linker_flags='$new_inherited_linker_flags' 1090023a0898aSmrg 109015a3d36dfSmrg# Libraries that this one depends upon. 109025a3d36dfSmrgdependency_libs='$dependency_libs' 1090323a0898aSmrg 109045a3d36dfSmrg# Names of additional weak libraries provided by this library 109055a3d36dfSmrgweak_library_names='$weak_libs' 1090623a0898aSmrg 109075a3d36dfSmrg# Version information for $libname. 109085a3d36dfSmrgcurrent=$current 109095a3d36dfSmrgage=$age 109105a3d36dfSmrgrevision=$revision 1091123a0898aSmrg 109125a3d36dfSmrg# Is this an already installed library? 109135a3d36dfSmrginstalled=$installed 1091423a0898aSmrg 109155a3d36dfSmrg# Should we warn about portability when linking against -modules? 109165a3d36dfSmrgshouldnotlink=$module 1091723a0898aSmrg 109185a3d36dfSmrg# Files to dlopen/dlpreopen 109195a3d36dfSmrgdlopen='$dlfiles' 109205a3d36dfSmrgdlpreopen='$dlprefiles' 1092123a0898aSmrg 109225a3d36dfSmrg# Directory that this library needs to be installed in: 109235a3d36dfSmrglibdir='$install_libdir'" 10924b43acbb4Smrg if test no,yes = "$installed,$need_relink"; then 109255a3d36dfSmrg $ECHO >> $output "\ 109265a3d36dfSmrgrelink_command=\"$relink_command\"" 109275a3d36dfSmrg fi 109285a3d36dfSmrg done 109295a3d36dfSmrg } 1093023a0898aSmrg 109315a3d36dfSmrg # Do a symbolic link so that the libtool archive can be found in 109325a3d36dfSmrg # LD_LIBRARY_PATH before the program is installed. 109335a3d36dfSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 109345a3d36dfSmrg ;; 109355a3d36dfSmrg esac 109365a3d36dfSmrg exit $EXIT_SUCCESS 109375a3d36dfSmrg} 10938b3062210Smrg 10939b43acbb4Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10940b43acbb4Smrg func_mode_link ${1+"$@"} 10941b43acbb4Smrgfi 1094223a0898aSmrg 1094323a0898aSmrg 109445a3d36dfSmrg# func_mode_uninstall arg... 109455a3d36dfSmrgfunc_mode_uninstall () 109465a3d36dfSmrg{ 10947b43acbb4Smrg $debug_cmd 10948b43acbb4Smrg 10949b43acbb4Smrg RM=$nonopt 1095023a0898aSmrg files= 10951b43acbb4Smrg rmforce=false 1095223a0898aSmrg exit_status=0 1095323a0898aSmrg 1095423a0898aSmrg # This variable tells wrapper scripts just to set variables rather 1095523a0898aSmrg # than running their programs. 10956b43acbb4Smrg libtool_install_magic=$magic 1095723a0898aSmrg 1095823a0898aSmrg for arg 1095923a0898aSmrg do 1096023a0898aSmrg case $arg in 10961b43acbb4Smrg -f) func_append RM " $arg"; rmforce=: ;; 1096241c30155Smrg -*) func_append RM " $arg" ;; 1096341c30155Smrg *) func_append files " $arg" ;; 1096423a0898aSmrg esac 1096523a0898aSmrg done 1096623a0898aSmrg 109675a3d36dfSmrg test -z "$RM" && \ 109685a3d36dfSmrg func_fatal_help "you must specify an RM program" 1096923a0898aSmrg 1097023a0898aSmrg rmdirs= 1097123a0898aSmrg 1097223a0898aSmrg for file in $files; do 109735a3d36dfSmrg func_dirname "$file" "" "." 10974b43acbb4Smrg dir=$func_dirname_result 10975b43acbb4Smrg if test . = "$dir"; then 10976b43acbb4Smrg odir=$objdir 1097723a0898aSmrg else 10978b43acbb4Smrg odir=$dir/$objdir 1097923a0898aSmrg fi 109805a3d36dfSmrg func_basename "$file" 10981b43acbb4Smrg name=$func_basename_result 10982b43acbb4Smrg test uninstall = "$opt_mode" && odir=$dir 1098323a0898aSmrg 1098441c30155Smrg # Remember odir for removal later, being careful to avoid duplicates 10985b43acbb4Smrg if test clean = "$opt_mode"; then 1098623a0898aSmrg case " $rmdirs " in 1098741c30155Smrg *" $odir "*) ;; 1098841c30155Smrg *) func_append rmdirs " $odir" ;; 1098923a0898aSmrg esac 1099023a0898aSmrg fi 1099123a0898aSmrg 1099223a0898aSmrg # Don't error if the file doesn't exist and rm -f was used. 109935a3d36dfSmrg if { test -L "$file"; } >/dev/null 2>&1 || 109945a3d36dfSmrg { test -h "$file"; } >/dev/null 2>&1 || 109955a3d36dfSmrg test -f "$file"; then 1099623a0898aSmrg : 1099723a0898aSmrg elif test -d "$file"; then 1099823a0898aSmrg exit_status=1 1099923a0898aSmrg continue 11000b43acbb4Smrg elif $rmforce; then 1100123a0898aSmrg continue 1100223a0898aSmrg fi 1100323a0898aSmrg 11004b43acbb4Smrg rmfiles=$file 1100523a0898aSmrg 1100623a0898aSmrg case $name in 1100723a0898aSmrg *.la) 1100823a0898aSmrg # Possibly a libtool archive, so verify it. 110095a3d36dfSmrg if func_lalib_p "$file"; then 110105a3d36dfSmrg func_source $dir/$name 1101123a0898aSmrg 1101223a0898aSmrg # Delete the libtool libraries and symlinks. 1101323a0898aSmrg for n in $library_names; do 1101441c30155Smrg func_append rmfiles " $odir/$n" 1101523a0898aSmrg done 1101641c30155Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1101723a0898aSmrg 11018b43acbb4Smrg case $opt_mode in 1101923a0898aSmrg clean) 1102041c30155Smrg case " $library_names " in 1102123a0898aSmrg *" $dlname "*) ;; 1102241c30155Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1102323a0898aSmrg esac 1102441c30155Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1102523a0898aSmrg ;; 1102623a0898aSmrg uninstall) 1102723a0898aSmrg if test -n "$library_names"; then 1102823a0898aSmrg # Do each command in the postuninstall commands. 11029b43acbb4Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1103023a0898aSmrg fi 1103123a0898aSmrg 1103223a0898aSmrg if test -n "$old_library"; then 1103323a0898aSmrg # Do each command in the old_postuninstall commands. 11034b43acbb4Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1103523a0898aSmrg fi 1103623a0898aSmrg # FIXME: should reinstall the best remaining shared library. 1103723a0898aSmrg ;; 1103823a0898aSmrg esac 1103923a0898aSmrg fi 1104023a0898aSmrg ;; 1104123a0898aSmrg 1104223a0898aSmrg *.lo) 1104323a0898aSmrg # Possibly a libtool object, so verify it. 110445a3d36dfSmrg if func_lalib_p "$file"; then 1104523a0898aSmrg 1104623a0898aSmrg # Read the .lo file 110475a3d36dfSmrg func_source $dir/$name 1104823a0898aSmrg 1104923a0898aSmrg # Add PIC object to the list of files to remove. 11050b43acbb4Smrg if test -n "$pic_object" && test none != "$pic_object"; then 1105141c30155Smrg func_append rmfiles " $dir/$pic_object" 1105223a0898aSmrg fi 1105323a0898aSmrg 1105423a0898aSmrg # Add non-PIC object to the list of files to remove. 11055b43acbb4Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1105641c30155Smrg func_append rmfiles " $dir/$non_pic_object" 1105723a0898aSmrg fi 1105823a0898aSmrg fi 1105923a0898aSmrg ;; 1106023a0898aSmrg 1106123a0898aSmrg *) 11062b43acbb4Smrg if test clean = "$opt_mode"; then 1106323a0898aSmrg noexename=$name 1106423a0898aSmrg case $file in 1106523a0898aSmrg *.exe) 110665a3d36dfSmrg func_stripname '' '.exe' "$file" 110675a3d36dfSmrg file=$func_stripname_result 110685a3d36dfSmrg func_stripname '' '.exe' "$name" 110695a3d36dfSmrg noexename=$func_stripname_result 1107023a0898aSmrg # $file with .exe has already been added to rmfiles, 1107123a0898aSmrg # add $file without .exe 1107241c30155Smrg func_append rmfiles " $file" 1107323a0898aSmrg ;; 1107423a0898aSmrg esac 1107523a0898aSmrg # Do a test to see if this is a libtool program. 110765a3d36dfSmrg if func_ltwrapper_p "$file"; then 110775a3d36dfSmrg if func_ltwrapper_executable_p "$file"; then 110785a3d36dfSmrg func_ltwrapper_scriptname "$file" 110795a3d36dfSmrg relink_command= 110805a3d36dfSmrg func_source $func_ltwrapper_scriptname_result 1108141c30155Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 110825a3d36dfSmrg else 110835a3d36dfSmrg relink_command= 110845a3d36dfSmrg func_source $dir/$noexename 110855a3d36dfSmrg fi 1108623a0898aSmrg 1108723a0898aSmrg # note $name still contains .exe if it was in $file originally 1108823a0898aSmrg # as does the version of $file that was added into $rmfiles 11089b43acbb4Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11090b43acbb4Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 1109141c30155Smrg func_append rmfiles " $odir/lt-$name" 1109223a0898aSmrg fi 11093b43acbb4Smrg if test "X$noexename" != "X$name"; then 11094b43acbb4Smrg func_append rmfiles " $odir/lt-$noexename.c" 1109523a0898aSmrg fi 1109623a0898aSmrg fi 1109723a0898aSmrg fi 1109823a0898aSmrg ;; 1109923a0898aSmrg esac 111005a3d36dfSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1110123a0898aSmrg done 1110223a0898aSmrg 11103b43acbb4Smrg # Try to remove the $objdir's in the directories where we deleted files 1110423a0898aSmrg for dir in $rmdirs; do 1110523a0898aSmrg if test -d "$dir"; then 111065a3d36dfSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1110723a0898aSmrg fi 1110823a0898aSmrg done 1110923a0898aSmrg 1111023a0898aSmrg exit $exit_status 111115a3d36dfSmrg} 1111223a0898aSmrg 11113b43acbb4Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11114b43acbb4Smrg func_mode_uninstall ${1+"$@"} 11115b43acbb4Smrgfi 111167f7f5e4eSmrg 1111741c30155Smrgtest -z "$opt_mode" && { 11118b43acbb4Smrg help=$generic_help 111195a3d36dfSmrg func_fatal_help "you must specify a MODE" 111205a3d36dfSmrg} 111215a3d36dfSmrg 111225a3d36dfSmrgtest -z "$exec_cmd" && \ 11123b43acbb4Smrg func_fatal_help "invalid operation mode '$opt_mode'" 1112423a0898aSmrg 1112523a0898aSmrgif test -n "$exec_cmd"; then 111265a3d36dfSmrg eval exec "$exec_cmd" 1112723a0898aSmrg exit $EXIT_FAILURE 1112823a0898aSmrgfi 1112923a0898aSmrg 111305a3d36dfSmrgexit $exit_status 1113123a0898aSmrg 1113223a0898aSmrg 1113323a0898aSmrg# The TAGs below are defined such that we never get into a situation 11134b43acbb4Smrg# where we disable both kinds of libraries. Given conflicting 1113523a0898aSmrg# choices, we go for a static library, that is the most portable, 1113623a0898aSmrg# since we can't tell whether shared libraries were disabled because 1113723a0898aSmrg# the user asked for that or because the platform doesn't support 1113823a0898aSmrg# them. This is particularly important on AIX, because we don't 1113923a0898aSmrg# support having both static and shared libraries enabled at the same 1114023a0898aSmrg# time on that platform, so we default to a shared-only configuration. 1114123a0898aSmrg# If a disable-shared tag is given, we'll fallback to a static-only 1114223a0898aSmrg# configuration. But we'll never go from static-only to shared-only. 1114323a0898aSmrg 1114423a0898aSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 111455a3d36dfSmrgbuild_libtool_libs=no 111465a3d36dfSmrgbuild_old_libs=yes 1114723a0898aSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 1114823a0898aSmrg 1114923a0898aSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 111505a3d36dfSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1115123a0898aSmrg# ### END LIBTOOL TAG CONFIG: disable-static 1115223a0898aSmrg 1115323a0898aSmrg# Local Variables: 1115423a0898aSmrg# mode:shell-script 1115523a0898aSmrg# sh-indentation:2 1115623a0898aSmrg# End: 11157