114210e8eSmrg#! /bin/sh 214210e8eSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 314210e8eSmrg## by inline-source v2014-01-03.01 41fb744b4Smrg 514210e8eSmrg# libtool (GNU libtool) 2.4.6 614210e8eSmrg# Provide generalized library-building support services. 71fb744b4Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 81fb744b4Smrg 914210e8eSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 101fb744b4Smrg# This is free software; see the source for copying conditions. There is NO 111fb744b4Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 121fb744b4Smrg 131fb744b4Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14c35d236eSmrg# it under the terms of the GNU General Public License as published by 15c35d236eSmrg# the Free Software Foundation; either version 2 of the License, or 16c35d236eSmrg# (at your option) any later version. 17c35d236eSmrg# 181fb744b4Smrg# As a special exception to the GNU General Public License, 191fb744b4Smrg# if you distribute this file as part of a program or library that 201fb744b4Smrg# is built using GNU Libtool, you may include this file under the 211fb744b4Smrg# same distribution terms that you use for the rest of that program. 221fb744b4Smrg# 231fb744b4Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24c35d236eSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25c35d236eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26c35d236eSmrg# General Public License for more details. 27c35d236eSmrg# 28c35d236eSmrg# You should have received a copy of the GNU General Public License 2914210e8eSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30518bcf38Smrg 31c35d236eSmrg 321fb744b4SmrgPROGRAM=libtool 33c35d236eSmrgPACKAGE=libtool 3414210e8eSmrgVERSION=2.4.6 3514210e8eSmrgpackage_revision=2.4.6 36c35d236eSmrg 3714210e8eSmrg 3814210e8eSmrg## ------ ## 3914210e8eSmrg## Usage. ## 4014210e8eSmrg## ------ ## 4114210e8eSmrg 4214210e8eSmrg# Run './libtool --help' for help with using this script from the 4314210e8eSmrg# command line. 4414210e8eSmrg 4514210e8eSmrg 4614210e8eSmrg## ------------------------------- ## 4714210e8eSmrg## User overridable command paths. ## 4814210e8eSmrg## ------------------------------- ## 4914210e8eSmrg 5014210e8eSmrg# After configure completes, it has a better idea of some of the 5114210e8eSmrg# shell tools we need than the defaults used by the functions shared 5214210e8eSmrg# with bootstrap, so set those here where they can still be over- 5314210e8eSmrg# ridden by the user, but otherwise take precedence. 5414210e8eSmrg 5514210e8eSmrg: ${AUTOCONF="autoconf"} 5614210e8eSmrg: ${AUTOMAKE="automake"} 5714210e8eSmrg 5814210e8eSmrg 5914210e8eSmrg## -------------------------- ## 6014210e8eSmrg## Source external libraries. ## 6114210e8eSmrg## -------------------------- ## 6214210e8eSmrg 6314210e8eSmrg# Much of our low-level functionality needs to be sourced from external 6414210e8eSmrg# libraries, which are installed to $pkgauxdir. 6514210e8eSmrg 6614210e8eSmrg# Set a version string for this script. 6714210e8eSmrgscriptversion=2015-01-20.17; # UTC 6814210e8eSmrg 6914210e8eSmrg# General shell script boiler plate, and helper functions. 7014210e8eSmrg# Written by Gary V. Vaughan, 2004 7114210e8eSmrg 7214210e8eSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7314210e8eSmrg# This is free software; see the source for copying conditions. There is NO 7414210e8eSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7514210e8eSmrg 7614210e8eSmrg# This program is free software; you can redistribute it and/or modify 7714210e8eSmrg# it under the terms of the GNU General Public License as published by 7814210e8eSmrg# the Free Software Foundation; either version 3 of the License, or 7914210e8eSmrg# (at your option) any later version. 8014210e8eSmrg 8114210e8eSmrg# As a special exception to the GNU General Public License, if you distribute 8214210e8eSmrg# this file as part of a program or library that is built using GNU Libtool, 8314210e8eSmrg# you may include this file under the same distribution terms that you use 8414210e8eSmrg# for the rest of that program. 8514210e8eSmrg 8614210e8eSmrg# This program is distributed in the hope that it will be useful, 8714210e8eSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8814210e8eSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8914210e8eSmrg# General Public License for more details. 9014210e8eSmrg 9114210e8eSmrg# You should have received a copy of the GNU General Public License 9214210e8eSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9314210e8eSmrg 9414210e8eSmrg# Please report bugs or propose patches to gary@gnu.org. 9514210e8eSmrg 9614210e8eSmrg 9714210e8eSmrg## ------ ## 9814210e8eSmrg## Usage. ## 9914210e8eSmrg## ------ ## 10014210e8eSmrg 10114210e8eSmrg# Evaluate this file near the top of your script to gain access to 10214210e8eSmrg# the functions and variables defined here: 10314210e8eSmrg# 10414210e8eSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10514210e8eSmrg# 10614210e8eSmrg# If you need to override any of the default environment variable 10714210e8eSmrg# settings, do that before evaluating this file. 10814210e8eSmrg 10914210e8eSmrg 11014210e8eSmrg## -------------------- ## 11114210e8eSmrg## Shell normalisation. ## 11214210e8eSmrg## -------------------- ## 11314210e8eSmrg 11414210e8eSmrg# Some shells need a little help to be as Bourne compatible as possible. 11514210e8eSmrg# Before doing anything else, make sure all that help has been provided! 11614210e8eSmrg 11714210e8eSmrgDUALCASE=1; export DUALCASE # for MKS sh 11814210e8eSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1194f6cd06fSmrg emulate sh 1204f6cd06fSmrg NULLCMD=: 12114210e8eSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1224f6cd06fSmrg # is contrary to our usage. Disable this feature. 1234f6cd06fSmrg alias -g '${1+"$@"}'='"$@"' 124c35d236eSmrg setopt NO_GLOB_SUBST 1254f6cd06fSmrgelse 12614210e8eSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127c35d236eSmrgfi 128518bcf38Smrg 12914210e8eSmrg# NLS nuisances: We save the old values in case they are required later. 13014210e8eSmrg_G_user_locale= 13114210e8eSmrg_G_safe_locale= 13214210e8eSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1334f6cd06fSmrgdo 13414210e8eSmrg eval "if test set = \"\${$_G_var+set}\"; then 13514210e8eSmrg save_$_G_var=\$$_G_var 13614210e8eSmrg $_G_var=C 13714210e8eSmrg export $_G_var 13814210e8eSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13914210e8eSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140f55e6a01Smrg fi" 1414f6cd06fSmrgdone 1421fb744b4Smrg 14314210e8eSmrg# CDPATH. 14414210e8eSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145c35d236eSmrg 14614210e8eSmrg# Make sure IFS has a sensible default 14714210e8eSmrgsp=' ' 14814210e8eSmrgnl=' 14914210e8eSmrg' 15014210e8eSmrgIFS="$sp $nl" 15114210e8eSmrg 15214210e8eSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 15314210e8eSmrgif test "${PATH_SEPARATOR+set}" != set; then 15414210e8eSmrg PATH_SEPARATOR=: 15514210e8eSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15614210e8eSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15714210e8eSmrg PATH_SEPARATOR=';' 15814210e8eSmrg } 15914210e8eSmrgfi 1601fb744b4Smrg 1611fb744b4Smrg 1621fb744b4Smrg 16314210e8eSmrg## ------------------------- ## 16414210e8eSmrg## Locate command utilities. ## 16514210e8eSmrg## ------------------------- ## 16614210e8eSmrg 16714210e8eSmrg 16814210e8eSmrg# func_executable_p FILE 16914210e8eSmrg# ---------------------- 17014210e8eSmrg# Check that FILE is an executable regular file. 17114210e8eSmrgfunc_executable_p () 17214210e8eSmrg{ 17314210e8eSmrg test -f "$1" && test -x "$1" 17414210e8eSmrg} 17514210e8eSmrg 17614210e8eSmrg 17714210e8eSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17814210e8eSmrg# -------------------------------------------- 17914210e8eSmrg# Search for either a program that responds to --version with output 18014210e8eSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18114210e8eSmrg# trying all the directories in PATH with each of the elements of 18214210e8eSmrg# PROGS_LIST. 18314210e8eSmrg# 18414210e8eSmrg# CHECK_FUNC should accept the path to a candidate program, and 18514210e8eSmrg# set $func_check_prog_result if it truncates its output less than 18614210e8eSmrg# $_G_path_prog_max characters. 18714210e8eSmrgfunc_path_progs () 18814210e8eSmrg{ 18914210e8eSmrg _G_progs_list=$1 19014210e8eSmrg _G_check_func=$2 19114210e8eSmrg _G_PATH=${3-"$PATH"} 19214210e8eSmrg 19314210e8eSmrg _G_path_prog_max=0 19414210e8eSmrg _G_path_prog_found=false 19514210e8eSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19614210e8eSmrg for _G_dir in $_G_PATH; do 19714210e8eSmrg IFS=$_G_save_IFS 19814210e8eSmrg test -z "$_G_dir" && _G_dir=. 19914210e8eSmrg for _G_prog_name in $_G_progs_list; do 20014210e8eSmrg for _exeext in '' .EXE; do 20114210e8eSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20214210e8eSmrg func_executable_p "$_G_path_prog" || continue 20314210e8eSmrg case `"$_G_path_prog" --version 2>&1` in 20414210e8eSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20514210e8eSmrg *) $_G_check_func $_G_path_prog 20614210e8eSmrg func_path_progs_result=$func_check_prog_result 20714210e8eSmrg ;; 20814210e8eSmrg esac 20914210e8eSmrg $_G_path_prog_found && break 3 21014210e8eSmrg done 21114210e8eSmrg done 21214210e8eSmrg done 21314210e8eSmrg IFS=$_G_save_IFS 21414210e8eSmrg test -z "$func_path_progs_result" && { 21514210e8eSmrg echo "no acceptable sed could be found in \$PATH" >&2 21614210e8eSmrg exit 1 21714210e8eSmrg } 21814210e8eSmrg} 21914210e8eSmrg 22014210e8eSmrg 22114210e8eSmrg# We want to be able to use the functions in this file before configure 22214210e8eSmrg# has figured out where the best binaries are kept, which means we have 22314210e8eSmrg# to search for them ourselves - except when the results are already set 22414210e8eSmrg# where we skip the searches. 22514210e8eSmrg 22614210e8eSmrg# Unless the user overrides by setting SED, search the path for either GNU 22714210e8eSmrg# sed, or the sed that truncates its output the least. 22814210e8eSmrgtest -z "$SED" && { 22914210e8eSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23014210e8eSmrg for _G_i in 1 2 3 4 5 6 7; do 23114210e8eSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23214210e8eSmrg done 23314210e8eSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23414210e8eSmrg _G_sed_script= 23514210e8eSmrg 23614210e8eSmrg func_check_prog_sed () 23714210e8eSmrg { 23814210e8eSmrg _G_path_prog=$1 23914210e8eSmrg 24014210e8eSmrg _G_count=0 24114210e8eSmrg printf 0123456789 >conftest.in 24214210e8eSmrg while : 24314210e8eSmrg do 24414210e8eSmrg cat conftest.in conftest.in >conftest.tmp 24514210e8eSmrg mv conftest.tmp conftest.in 24614210e8eSmrg cp conftest.in conftest.nl 24714210e8eSmrg echo '' >> conftest.nl 24814210e8eSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24914210e8eSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25014210e8eSmrg _G_count=`expr $_G_count + 1` 25114210e8eSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25214210e8eSmrg # Best one so far, save it but keep looking for a better one 25314210e8eSmrg func_check_prog_result=$_G_path_prog 25414210e8eSmrg _G_path_prog_max=$_G_count 25514210e8eSmrg fi 25614210e8eSmrg # 10*(2^10) chars as input seems more than enough 25714210e8eSmrg test 10 -lt "$_G_count" && break 25814210e8eSmrg done 25914210e8eSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26014210e8eSmrg } 26114210e8eSmrg 26214210e8eSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26314210e8eSmrg rm -f conftest.sed 26414210e8eSmrg SED=$func_path_progs_result 26514210e8eSmrg} 26614210e8eSmrg 26714210e8eSmrg 26814210e8eSmrg# Unless the user overrides by setting GREP, search the path for either GNU 26914210e8eSmrg# grep, or the grep that truncates its output the least. 27014210e8eSmrgtest -z "$GREP" && { 27114210e8eSmrg func_check_prog_grep () 27214210e8eSmrg { 27314210e8eSmrg _G_path_prog=$1 27414210e8eSmrg 27514210e8eSmrg _G_count=0 27614210e8eSmrg _G_path_prog_max=0 27714210e8eSmrg printf 0123456789 >conftest.in 27814210e8eSmrg while : 27914210e8eSmrg do 28014210e8eSmrg cat conftest.in conftest.in >conftest.tmp 28114210e8eSmrg mv conftest.tmp conftest.in 28214210e8eSmrg cp conftest.in conftest.nl 28314210e8eSmrg echo 'GREP' >> conftest.nl 28414210e8eSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28514210e8eSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28614210e8eSmrg _G_count=`expr $_G_count + 1` 28714210e8eSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28814210e8eSmrg # Best one so far, save it but keep looking for a better one 28914210e8eSmrg func_check_prog_result=$_G_path_prog 29014210e8eSmrg _G_path_prog_max=$_G_count 29114210e8eSmrg fi 29214210e8eSmrg # 10*(2^10) chars as input seems more than enough 29314210e8eSmrg test 10 -lt "$_G_count" && break 29414210e8eSmrg done 29514210e8eSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29614210e8eSmrg } 29714210e8eSmrg 29814210e8eSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29914210e8eSmrg GREP=$func_path_progs_result 30014210e8eSmrg} 30114210e8eSmrg 30214210e8eSmrg 30314210e8eSmrg## ------------------------------- ## 30414210e8eSmrg## User overridable command paths. ## 30514210e8eSmrg## ------------------------------- ## 30614210e8eSmrg 30714210e8eSmrg# All uppercase variable names are used for environment variables. These 30814210e8eSmrg# variables can be overridden by the user before calling a script that 30914210e8eSmrg# uses them if a suitable command of that name is not already available 31014210e8eSmrg# in the command search PATH. 3111fb744b4Smrg 3121fb744b4Smrg: ${CP="cp -f"} 31314210e8eSmrg: ${ECHO="printf %s\n"} 31414210e8eSmrg: ${EGREP="$GREP -E"} 31514210e8eSmrg: ${FGREP="$GREP -F"} 31614210e8eSmrg: ${LN_S="ln -s"} 3171fb744b4Smrg: ${MAKE="make"} 3181fb744b4Smrg: ${MKDIR="mkdir"} 3191fb744b4Smrg: ${MV="mv -f"} 3201fb744b4Smrg: ${RM="rm -f"} 3211fb744b4Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322c35d236eSmrg 323f55e6a01Smrg 32414210e8eSmrg## -------------------- ## 32514210e8eSmrg## Useful sed snippets. ## 32614210e8eSmrg## -------------------- ## 3271fb744b4Smrg 32814210e8eSmrgsed_dirname='s|/[^/]*$||' 32914210e8eSmrgsed_basename='s|^.*/||' 3301fb744b4Smrg 33114210e8eSmrg# Sed substitution that helps us do robust quoting. It backslashifies 33214210e8eSmrg# metacharacters that are still active within double-quoted strings. 33314210e8eSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3341fb744b4Smrg 33514210e8eSmrg# Same as above, but do not quote variable references. 33614210e8eSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3371fb744b4Smrg 33814210e8eSmrg# Sed substitution that turns a string into a regex matching for the 33914210e8eSmrg# string literally. 34014210e8eSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3411fb744b4Smrg 34214210e8eSmrg# Sed substitution that converts a w32 file name or path 34314210e8eSmrg# that contains forward slashes, into one that contains 34414210e8eSmrg# (escaped) backslashes. A very naive implementation. 34514210e8eSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34614210e8eSmrg 34714210e8eSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34814210e8eSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34914210e8eSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35014210e8eSmrg# expansion. Since each input '\' is now two '\'s, look for any number 35114210e8eSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35214210e8eSmrg_G_bs='\\' 35314210e8eSmrg_G_bs2='\\\\' 35414210e8eSmrg_G_bs4='\\\\\\\\' 35514210e8eSmrg_G_dollar='\$' 35614210e8eSmrgsed_double_backslash="\ 35714210e8eSmrg s/$_G_bs4/&\\ 35814210e8eSmrg/g 35914210e8eSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36014210e8eSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36114210e8eSmrg s/\n//g" 3621fb744b4Smrg 3631fb744b4Smrg 36414210e8eSmrg## ----------------- ## 36514210e8eSmrg## Global variables. ## 36614210e8eSmrg## ----------------- ## 3671fb744b4Smrg 36814210e8eSmrg# Except for the global variables explicitly listed below, the following 36914210e8eSmrg# functions in the '^func_' namespace, and the '^require_' namespace 37014210e8eSmrg# variables initialised in the 'Resource management' section, sourcing 37114210e8eSmrg# this file will not pollute your global namespace with anything 37214210e8eSmrg# else. There's no portable way to scope variables in Bourne shell 37314210e8eSmrg# though, so actually running these functions will sometimes place 37414210e8eSmrg# results into a variable named after the function, and often use 37514210e8eSmrg# temporary variables in the '^_G_' namespace. If you are careful to 37614210e8eSmrg# avoid using those namespaces casually in your sourcing script, things 37714210e8eSmrg# should continue to work as you expect. And, of course, you can freely 37814210e8eSmrg# overwrite any of the functions or variables defined here before 37914210e8eSmrg# calling anything to customize them. 3801fb744b4Smrg 38114210e8eSmrgEXIT_SUCCESS=0 38214210e8eSmrgEXIT_FAILURE=1 38314210e8eSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38414210e8eSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 3851fb744b4Smrg 38614210e8eSmrg# Allow overriding, eg assuming that you follow the convention of 38714210e8eSmrg# putting '$debug_cmd' at the start of all your functions, you can get 38814210e8eSmrg# bash to show function call trace with: 38914210e8eSmrg# 39014210e8eSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39114210e8eSmrgdebug_cmd=${debug_cmd-":"} 39214210e8eSmrgexit_cmd=: 3931fb744b4Smrg 39414210e8eSmrg# By convention, finish your script with: 39514210e8eSmrg# 39614210e8eSmrg# exit $exit_status 39714210e8eSmrg# 39814210e8eSmrg# so that you can set exit_status to non-zero if you want to indicate 39914210e8eSmrg# something went wrong during execution without actually bailing out at 40014210e8eSmrg# the point of failure. 40114210e8eSmrgexit_status=$EXIT_SUCCESS 4021fb744b4Smrg 40314210e8eSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40414210e8eSmrg# is ksh but when the shell is invoked as "sh" and the current value of 40514210e8eSmrg# the _XPG environment variable is not equal to 1 (one), the special 40614210e8eSmrg# positional parameter $0, within a function call, is the name of the 40714210e8eSmrg# function. 40814210e8eSmrgprogpath=$0 4091fb744b4Smrg 41014210e8eSmrg# The name of this program. 41114210e8eSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4121fb744b4Smrg 41314210e8eSmrg# Make sure we have an absolute progpath for reexecution: 4141fb744b4Smrgcase $progpath in 4151fb744b4Smrg [\\/]*|[A-Za-z]:\\*) ;; 4161fb744b4Smrg *[\\/]*) 41714210e8eSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4181fb744b4Smrg progdir=`cd "$progdir" && pwd` 41914210e8eSmrg progpath=$progdir/$progname 4201fb744b4Smrg ;; 4211fb744b4Smrg *) 42214210e8eSmrg _G_IFS=$IFS 4231fb744b4Smrg IFS=${PATH_SEPARATOR-:} 4241fb744b4Smrg for progdir in $PATH; do 42514210e8eSmrg IFS=$_G_IFS 4261fb744b4Smrg test -x "$progdir/$progname" && break 4271fb744b4Smrg done 42814210e8eSmrg IFS=$_G_IFS 4291fb744b4Smrg test -n "$progdir" || progdir=`pwd` 43014210e8eSmrg progpath=$progdir/$progname 4311fb744b4Smrg ;; 4321fb744b4Smrgesac 4331fb744b4Smrg 4341fb744b4Smrg 43514210e8eSmrg## ----------------- ## 43614210e8eSmrg## Standard options. ## 43714210e8eSmrg## ----------------- ## 4381fb744b4Smrg 43914210e8eSmrg# The following options affect the operation of the functions defined 44014210e8eSmrg# below, and should be set appropriately depending on run-time para- 44114210e8eSmrg# meters passed on the command line. 4421fb744b4Smrg 4431fb744b4Smrgopt_dry_run=false 4441fb744b4Smrgopt_quiet=false 4451fb744b4Smrgopt_verbose=false 4461fb744b4Smrg 44714210e8eSmrg# Categories 'all' and 'none' are always available. Append any others 44814210e8eSmrg# you will pass as the first argument to func_warning from your own 44914210e8eSmrg# code. 45014210e8eSmrgwarning_categories= 4511fb744b4Smrg 45214210e8eSmrg# By default, display warnings according to 'opt_warning_types'. Set 45314210e8eSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45414210e8eSmrg# treat the next displayed warning as a fatal error. 45514210e8eSmrgwarning_func=func_warn_and_continue 4561fb744b4Smrg 45714210e8eSmrg# Set to 'all' to display all warnings, 'none' to suppress all 45814210e8eSmrg# warnings, or a space delimited list of some subset of 45914210e8eSmrg# 'warning_categories' to display only the listed warnings. 46014210e8eSmrgopt_warning_types=all 4611fb744b4Smrg 4621fb744b4Smrg 46314210e8eSmrg## -------------------- ## 46414210e8eSmrg## Resource management. ## 46514210e8eSmrg## -------------------- ## 4661fb744b4Smrg 46714210e8eSmrg# This section contains definitions for functions that each ensure a 46814210e8eSmrg# particular resource (a file, or a non-empty configuration variable for 46914210e8eSmrg# example) is available, and if appropriate to extract default values 47014210e8eSmrg# from pertinent package files. Call them using their associated 47114210e8eSmrg# 'require_*' variable to ensure that they are executed, at most, once. 47214210e8eSmrg# 47314210e8eSmrg# It's entirely deliberate that calling these functions can set 47414210e8eSmrg# variables that don't obey the namespace limitations obeyed by the rest 47514210e8eSmrg# of this file, in order that that they be as useful as possible to 47614210e8eSmrg# callers. 4771fb744b4Smrg 4781fb744b4Smrg 47914210e8eSmrg# require_term_colors 48014210e8eSmrg# ------------------- 48114210e8eSmrg# Allow display of bold text on terminals that support it. 48214210e8eSmrgrequire_term_colors=func_require_term_colors 48314210e8eSmrgfunc_require_term_colors () 4841fb744b4Smrg{ 48514210e8eSmrg $debug_cmd 48614210e8eSmrg 48714210e8eSmrg test -t 1 && { 48814210e8eSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 48914210e8eSmrg # precedence, because most terminfo databases neglect to describe 49014210e8eSmrg # whether color sequences are supported. 49114210e8eSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49214210e8eSmrg 49314210e8eSmrg if test 1 = "$USE_ANSI_COLORS"; then 49414210e8eSmrg # Standard ANSI escape sequences 49514210e8eSmrg tc_reset='[0m' 49614210e8eSmrg tc_bold='[1m'; tc_standout='[7m' 49714210e8eSmrg tc_red='[31m'; tc_green='[32m' 49814210e8eSmrg tc_blue='[34m'; tc_cyan='[36m' 49914210e8eSmrg else 50014210e8eSmrg # Otherwise trust the terminfo database after all. 50114210e8eSmrg test -n "`tput sgr0 2>/dev/null`" && { 50214210e8eSmrg tc_reset=`tput sgr0` 50314210e8eSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50414210e8eSmrg tc_standout=$tc_bold 50514210e8eSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50614210e8eSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50714210e8eSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50814210e8eSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50914210e8eSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51014210e8eSmrg } 51114210e8eSmrg fi 51214210e8eSmrg } 5131fb744b4Smrg 51414210e8eSmrg require_term_colors=: 5151fb744b4Smrg} 5161fb744b4Smrg 5171fb744b4Smrg 51814210e8eSmrg## ----------------- ## 51914210e8eSmrg## Function library. ## 52014210e8eSmrg## ----------------- ## 52114210e8eSmrg 52214210e8eSmrg# This section contains a variety of useful functions to call in your 52314210e8eSmrg# scripts. Take note of the portable wrappers for features provided by 52414210e8eSmrg# some modern shells, which will fall back to slower equivalents on 52514210e8eSmrg# less featureful shells. 52614210e8eSmrg 52714210e8eSmrg 52814210e8eSmrg# func_append VAR VALUE 52914210e8eSmrg# --------------------- 53014210e8eSmrg# Append VALUE onto the existing contents of VAR. 53114210e8eSmrg 53214210e8eSmrg # We should try to minimise forks, especially on Windows where they are 53314210e8eSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 53414210e8eSmrg # being used: 53514210e8eSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53614210e8eSmrg : ${_G_HAVE_ARITH_OP="yes"} 53714210e8eSmrg : ${_G_HAVE_XSI_OPS="yes"} 53814210e8eSmrg # The += operator was introduced in bash 3.1 53914210e8eSmrg case $BASH_VERSION in 54014210e8eSmrg [12].* | 3.0 | 3.0*) ;; 54114210e8eSmrg *) 54214210e8eSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54314210e8eSmrg ;; 54414210e8eSmrg esac 54514210e8eSmrg fi 54614210e8eSmrg 54714210e8eSmrg # _G_HAVE_PLUSEQ_OP 54814210e8eSmrg # Can be empty, in which case the shell is probed, "yes" if += is 54914210e8eSmrg # useable or anything else if it does not work. 55014210e8eSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55114210e8eSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55214210e8eSmrg && _G_HAVE_PLUSEQ_OP=yes 55314210e8eSmrg 55414210e8eSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55514210e8eSmrgthen 55614210e8eSmrg # This is an XSI compatible shell, allowing a faster implementation... 55714210e8eSmrg eval 'func_append () 55814210e8eSmrg { 55914210e8eSmrg $debug_cmd 56014210e8eSmrg 56114210e8eSmrg eval "$1+=\$2" 56214210e8eSmrg }' 56314210e8eSmrgelse 56414210e8eSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 56514210e8eSmrg func_append () 56614210e8eSmrg { 56714210e8eSmrg $debug_cmd 56814210e8eSmrg 56914210e8eSmrg eval "$1=\$$1\$2" 57014210e8eSmrg } 57114210e8eSmrgfi 57214210e8eSmrg 57314210e8eSmrg 57414210e8eSmrg# func_append_quoted VAR VALUE 57514210e8eSmrg# ---------------------------- 57614210e8eSmrg# Quote VALUE and append to the end of shell variable VAR, separated 57714210e8eSmrg# by a space. 57814210e8eSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57914210e8eSmrg eval 'func_append_quoted () 58014210e8eSmrg { 58114210e8eSmrg $debug_cmd 58214210e8eSmrg 58314210e8eSmrg func_quote_for_eval "$2" 58414210e8eSmrg eval "$1+=\\ \$func_quote_for_eval_result" 58514210e8eSmrg }' 58614210e8eSmrgelse 58714210e8eSmrg func_append_quoted () 58814210e8eSmrg { 58914210e8eSmrg $debug_cmd 59014210e8eSmrg 59114210e8eSmrg func_quote_for_eval "$2" 59214210e8eSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59314210e8eSmrg } 59414210e8eSmrgfi 59514210e8eSmrg 59614210e8eSmrg 59714210e8eSmrg# func_append_uniq VAR VALUE 59814210e8eSmrg# -------------------------- 59914210e8eSmrg# Append unique VALUE onto the existing contents of VAR, assuming 60014210e8eSmrg# entries are delimited by the first character of VALUE. For example: 60114210e8eSmrg# 60214210e8eSmrg# func_append_uniq options " --another-option option-argument" 60314210e8eSmrg# 60414210e8eSmrg# will only append to $options if " --another-option option-argument " 60514210e8eSmrg# is not already present somewhere in $options already (note spaces at 60614210e8eSmrg# each end implied by leading space in second argument). 60714210e8eSmrgfunc_append_uniq () 60814210e8eSmrg{ 60914210e8eSmrg $debug_cmd 61014210e8eSmrg 61114210e8eSmrg eval _G_current_value='`$ECHO $'$1'`' 61214210e8eSmrg _G_delim=`expr "$2" : '\(.\)'` 61314210e8eSmrg 61414210e8eSmrg case $_G_delim$_G_current_value$_G_delim in 61514210e8eSmrg *"$2$_G_delim"*) ;; 61614210e8eSmrg *) func_append "$@" ;; 61714210e8eSmrg esac 61814210e8eSmrg} 61914210e8eSmrg 62014210e8eSmrg 62114210e8eSmrg# func_arith TERM... 62214210e8eSmrg# ------------------ 62314210e8eSmrg# Set func_arith_result to the result of evaluating TERMs. 62414210e8eSmrg test -z "$_G_HAVE_ARITH_OP" \ 62514210e8eSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62614210e8eSmrg && _G_HAVE_ARITH_OP=yes 62714210e8eSmrg 62814210e8eSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 62914210e8eSmrg eval 'func_arith () 63014210e8eSmrg { 63114210e8eSmrg $debug_cmd 63214210e8eSmrg 63314210e8eSmrg func_arith_result=$(( $* )) 63414210e8eSmrg }' 63514210e8eSmrgelse 63614210e8eSmrg func_arith () 63714210e8eSmrg { 63814210e8eSmrg $debug_cmd 63914210e8eSmrg 64014210e8eSmrg func_arith_result=`expr "$@"` 64114210e8eSmrg } 64214210e8eSmrgfi 64314210e8eSmrg 64414210e8eSmrg 64514210e8eSmrg# func_basename FILE 64614210e8eSmrg# ------------------ 64714210e8eSmrg# Set func_basename_result to FILE with everything up to and including 64814210e8eSmrg# the last / stripped. 64914210e8eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 65014210e8eSmrg # If this shell supports suffix pattern removal, then use it to avoid 65114210e8eSmrg # forking. Hide the definitions single quotes in case the shell chokes 65214210e8eSmrg # on unsupported syntax... 65314210e8eSmrg _b='func_basename_result=${1##*/}' 65414210e8eSmrg _d='case $1 in 65514210e8eSmrg */*) func_dirname_result=${1%/*}$2 ;; 65614210e8eSmrg * ) func_dirname_result=$3 ;; 65714210e8eSmrg esac' 65814210e8eSmrg 65914210e8eSmrgelse 66014210e8eSmrg # ...otherwise fall back to using sed. 66114210e8eSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66214210e8eSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66314210e8eSmrg if test "X$func_dirname_result" = "X$1"; then 66414210e8eSmrg func_dirname_result=$3 66514210e8eSmrg else 66614210e8eSmrg func_append func_dirname_result "$2" 66714210e8eSmrg fi' 66814210e8eSmrgfi 66914210e8eSmrg 67014210e8eSmrgeval 'func_basename () 67114210e8eSmrg{ 67214210e8eSmrg $debug_cmd 67314210e8eSmrg 67414210e8eSmrg '"$_b"' 67514210e8eSmrg}' 67614210e8eSmrg 67714210e8eSmrg 67814210e8eSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67914210e8eSmrg# ------------------------------------------- 68014210e8eSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68114210e8eSmrg# otherwise set result to NONDIR_REPLACEMENT. 68214210e8eSmrgeval 'func_dirname () 68314210e8eSmrg{ 68414210e8eSmrg $debug_cmd 68514210e8eSmrg 68614210e8eSmrg '"$_d"' 68714210e8eSmrg}' 68814210e8eSmrg 68914210e8eSmrg 69014210e8eSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69114210e8eSmrg# -------------------------------------------------------- 69214210e8eSmrg# Perform func_basename and func_dirname in a single function 69314210e8eSmrg# call: 69414210e8eSmrg# dirname: Compute the dirname of FILE. If nonempty, 69514210e8eSmrg# add APPEND to the result, otherwise set result 69614210e8eSmrg# to NONDIR_REPLACEMENT. 69714210e8eSmrg# value returned in "$func_dirname_result" 69814210e8eSmrg# basename: Compute filename of FILE. 69914210e8eSmrg# value retuned in "$func_basename_result" 70014210e8eSmrg# For efficiency, we do not delegate to the functions above but instead 70114210e8eSmrg# duplicate the functionality here. 70214210e8eSmrgeval 'func_dirname_and_basename () 70314210e8eSmrg{ 70414210e8eSmrg $debug_cmd 70514210e8eSmrg 70614210e8eSmrg '"$_b"' 70714210e8eSmrg '"$_d"' 70814210e8eSmrg}' 70914210e8eSmrg 71014210e8eSmrg 71114210e8eSmrg# func_echo ARG... 71214210e8eSmrg# ---------------- 71314210e8eSmrg# Echo program name prefixed message. 71414210e8eSmrgfunc_echo () 71514210e8eSmrg{ 71614210e8eSmrg $debug_cmd 71714210e8eSmrg 71814210e8eSmrg _G_message=$* 71914210e8eSmrg 72014210e8eSmrg func_echo_IFS=$IFS 72114210e8eSmrg IFS=$nl 72214210e8eSmrg for _G_line in $_G_message; do 72314210e8eSmrg IFS=$func_echo_IFS 72414210e8eSmrg $ECHO "$progname: $_G_line" 72514210e8eSmrg done 72614210e8eSmrg IFS=$func_echo_IFS 72714210e8eSmrg} 72814210e8eSmrg 72914210e8eSmrg 73014210e8eSmrg# func_echo_all ARG... 73114210e8eSmrg# -------------------- 73214210e8eSmrg# Invoke $ECHO with all args, space-separated. 73314210e8eSmrgfunc_echo_all () 73414210e8eSmrg{ 73514210e8eSmrg $ECHO "$*" 73614210e8eSmrg} 73714210e8eSmrg 73814210e8eSmrg 73914210e8eSmrg# func_echo_infix_1 INFIX ARG... 74014210e8eSmrg# ------------------------------ 74114210e8eSmrg# Echo program name, followed by INFIX on the first line, with any 74214210e8eSmrg# additional lines not showing INFIX. 74314210e8eSmrgfunc_echo_infix_1 () 74414210e8eSmrg{ 74514210e8eSmrg $debug_cmd 74614210e8eSmrg 74714210e8eSmrg $require_term_colors 74814210e8eSmrg 74914210e8eSmrg _G_infix=$1; shift 75014210e8eSmrg _G_indent=$_G_infix 75114210e8eSmrg _G_prefix="$progname: $_G_infix: " 75214210e8eSmrg _G_message=$* 75314210e8eSmrg 75414210e8eSmrg # Strip color escape sequences before counting printable length 75514210e8eSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75614210e8eSmrg do 75714210e8eSmrg test -n "$_G_tc" && { 75814210e8eSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75914210e8eSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76014210e8eSmrg } 76114210e8eSmrg done 76214210e8eSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76314210e8eSmrg 76414210e8eSmrg func_echo_infix_1_IFS=$IFS 76514210e8eSmrg IFS=$nl 76614210e8eSmrg for _G_line in $_G_message; do 76714210e8eSmrg IFS=$func_echo_infix_1_IFS 76814210e8eSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76914210e8eSmrg _G_prefix=$_G_indent 77014210e8eSmrg done 77114210e8eSmrg IFS=$func_echo_infix_1_IFS 77214210e8eSmrg} 77314210e8eSmrg 77414210e8eSmrg 77514210e8eSmrg# func_error ARG... 77614210e8eSmrg# ----------------- 77714210e8eSmrg# Echo program name prefixed message to standard error. 77814210e8eSmrgfunc_error () 77914210e8eSmrg{ 78014210e8eSmrg $debug_cmd 78114210e8eSmrg 78214210e8eSmrg $require_term_colors 78314210e8eSmrg 78414210e8eSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78514210e8eSmrg} 78614210e8eSmrg 78714210e8eSmrg 78814210e8eSmrg# func_fatal_error ARG... 78914210e8eSmrg# ----------------------- 79014210e8eSmrg# Echo program name prefixed message to standard error, and exit. 79114210e8eSmrgfunc_fatal_error () 79214210e8eSmrg{ 79314210e8eSmrg $debug_cmd 79414210e8eSmrg 79514210e8eSmrg func_error "$*" 79614210e8eSmrg exit $EXIT_FAILURE 79714210e8eSmrg} 79814210e8eSmrg 79914210e8eSmrg 80014210e8eSmrg# func_grep EXPRESSION FILENAME 80114210e8eSmrg# ----------------------------- 8021fb744b4Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8031fb744b4Smrgfunc_grep () 8041fb744b4Smrg{ 80514210e8eSmrg $debug_cmd 80614210e8eSmrg 8071fb744b4Smrg $GREP "$1" "$2" >/dev/null 2>&1 8081fb744b4Smrg} 8091fb744b4Smrg 8101fb744b4Smrg 81114210e8eSmrg# func_len STRING 81214210e8eSmrg# --------------- 81314210e8eSmrg# Set func_len_result to the length of STRING. STRING may not 81414210e8eSmrg# start with a hyphen. 81514210e8eSmrg test -z "$_G_HAVE_XSI_OPS" \ 81614210e8eSmrg && (eval 'x=a/b/c; 81714210e8eSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81814210e8eSmrg && _G_HAVE_XSI_OPS=yes 81914210e8eSmrg 82014210e8eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 82114210e8eSmrg eval 'func_len () 82214210e8eSmrg { 82314210e8eSmrg $debug_cmd 82414210e8eSmrg 82514210e8eSmrg func_len_result=${#1} 82614210e8eSmrg }' 82714210e8eSmrgelse 82814210e8eSmrg func_len () 82914210e8eSmrg { 83014210e8eSmrg $debug_cmd 83114210e8eSmrg 83214210e8eSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83314210e8eSmrg } 83414210e8eSmrgfi 83514210e8eSmrg 83614210e8eSmrg 83714210e8eSmrg# func_mkdir_p DIRECTORY-PATH 83814210e8eSmrg# --------------------------- 8391fb744b4Smrg# Make sure the entire path to DIRECTORY-PATH is available. 8401fb744b4Smrgfunc_mkdir_p () 8411fb744b4Smrg{ 84214210e8eSmrg $debug_cmd 8431fb744b4Smrg 84414210e8eSmrg _G_directory_path=$1 84514210e8eSmrg _G_dir_list= 8461fb744b4Smrg 84714210e8eSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84814210e8eSmrg 84914210e8eSmrg # Protect directory names starting with '-' 85014210e8eSmrg case $_G_directory_path in 85114210e8eSmrg -*) _G_directory_path=./$_G_directory_path ;; 8521fb744b4Smrg esac 8531fb744b4Smrg 8541fb744b4Smrg # While some portion of DIR does not yet exist... 85514210e8eSmrg while test ! -d "$_G_directory_path"; do 8561fb744b4Smrg # ...make a list in topmost first order. Use a colon delimited 8571fb744b4Smrg # list incase some portion of path contains whitespace. 85814210e8eSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 8591fb744b4Smrg 8601fb744b4Smrg # If the last portion added has no slash in it, the list is done 86114210e8eSmrg case $_G_directory_path in */*) ;; *) break ;; esac 8621fb744b4Smrg 8631fb744b4Smrg # ...otherwise throw away the child directory and loop 86414210e8eSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 8651fb744b4Smrg done 86614210e8eSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 8671fb744b4Smrg 86814210e8eSmrg func_mkdir_p_IFS=$IFS; IFS=: 86914210e8eSmrg for _G_dir in $_G_dir_list; do 87014210e8eSmrg IFS=$func_mkdir_p_IFS 87114210e8eSmrg # mkdir can fail with a 'File exist' error if two processes 8721fb744b4Smrg # try to create one of the directories concurrently. Don't 8731fb744b4Smrg # stop in that case! 87414210e8eSmrg $MKDIR "$_G_dir" 2>/dev/null || : 8751fb744b4Smrg done 87614210e8eSmrg IFS=$func_mkdir_p_IFS 8771fb744b4Smrg 8781fb744b4Smrg # Bail out if we (or some other process) failed to create a directory. 87914210e8eSmrg test -d "$_G_directory_path" || \ 88014210e8eSmrg func_fatal_error "Failed to create '$1'" 8811fb744b4Smrg fi 8821fb744b4Smrg} 883c35d236eSmrg 884c35d236eSmrg 88514210e8eSmrg# func_mktempdir [BASENAME] 88614210e8eSmrg# ------------------------- 887c35d236eSmrg# Make a temporary directory that won't clash with other running 888c35d236eSmrg# libtool processes, and avoids race conditions if possible. If 88914210e8eSmrg# given, BASENAME is the basename for that directory. 890c35d236eSmrgfunc_mktempdir () 891c35d236eSmrg{ 89214210e8eSmrg $debug_cmd 89314210e8eSmrg 89414210e8eSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895c35d236eSmrg 89614210e8eSmrg if test : = "$opt_dry_run"; then 897c35d236eSmrg # Return a directory name, but don't create it in dry-run mode 89814210e8eSmrg _G_tmpdir=$_G_template-$$ 899c35d236eSmrg else 900c35d236eSmrg 901c35d236eSmrg # If mktemp works, use that first and foremost 90214210e8eSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903c35d236eSmrg 90414210e8eSmrg if test ! -d "$_G_tmpdir"; then 9051fb744b4Smrg # Failing that, at least try and use $RANDOM to avoid a race 90614210e8eSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907c35d236eSmrg 90814210e8eSmrg func_mktempdir_umask=`umask` 9091fb744b4Smrg umask 0077 91014210e8eSmrg $MKDIR "$_G_tmpdir" 91114210e8eSmrg umask $func_mktempdir_umask 912c35d236eSmrg fi 913c35d236eSmrg 914c35d236eSmrg # If we're not in dry-run mode, bomb out on failure 91514210e8eSmrg test -d "$_G_tmpdir" || \ 91614210e8eSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91714210e8eSmrg fi 91814210e8eSmrg 91914210e8eSmrg $ECHO "$_G_tmpdir" 92014210e8eSmrg} 92114210e8eSmrg 92214210e8eSmrg 92314210e8eSmrg# func_normal_abspath PATH 92414210e8eSmrg# ------------------------ 92514210e8eSmrg# Remove doubled-up and trailing slashes, "." path components, 92614210e8eSmrg# and cancel out any ".." path components in PATH after making 92714210e8eSmrg# it an absolute path. 92814210e8eSmrgfunc_normal_abspath () 92914210e8eSmrg{ 93014210e8eSmrg $debug_cmd 93114210e8eSmrg 93214210e8eSmrg # These SED scripts presuppose an absolute path with a trailing slash. 93314210e8eSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93414210e8eSmrg _G_pathcdr='s|^/[^/]*||' 93514210e8eSmrg _G_removedotparts=':dotsl 93614210e8eSmrg s|/\./|/|g 93714210e8eSmrg t dotsl 93814210e8eSmrg s|/\.$|/|' 93914210e8eSmrg _G_collapseslashes='s|/\{1,\}|/|g' 94014210e8eSmrg _G_finalslash='s|/*$|/|' 94114210e8eSmrg 94214210e8eSmrg # Start from root dir and reassemble the path. 94314210e8eSmrg func_normal_abspath_result= 94414210e8eSmrg func_normal_abspath_tpath=$1 94514210e8eSmrg func_normal_abspath_altnamespace= 94614210e8eSmrg case $func_normal_abspath_tpath in 94714210e8eSmrg "") 94814210e8eSmrg # Empty path, that just means $cwd. 94914210e8eSmrg func_stripname '' '/' "`pwd`" 95014210e8eSmrg func_normal_abspath_result=$func_stripname_result 95114210e8eSmrg return 95214210e8eSmrg ;; 95314210e8eSmrg # The next three entries are used to spot a run of precisely 95414210e8eSmrg # two leading slashes without using negated character classes; 95514210e8eSmrg # we take advantage of case's first-match behaviour. 95614210e8eSmrg ///*) 95714210e8eSmrg # Unusual form of absolute path, do nothing. 95814210e8eSmrg ;; 95914210e8eSmrg //*) 96014210e8eSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96114210e8eSmrg # and for example Cygwin uses it to access remote file shares 96214210e8eSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 96314210e8eSmrg func_normal_abspath_altnamespace=/ 96414210e8eSmrg ;; 96514210e8eSmrg /*) 96614210e8eSmrg # Absolute path, do nothing. 96714210e8eSmrg ;; 96814210e8eSmrg *) 96914210e8eSmrg # Relative path, prepend $cwd. 97014210e8eSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97114210e8eSmrg ;; 97214210e8eSmrg esac 97314210e8eSmrg 97414210e8eSmrg # Cancel out all the simple stuff to save iterations. We also want 97514210e8eSmrg # the path to end with a slash for ease of parsing, so make sure 97614210e8eSmrg # there is one (and only one) here. 97714210e8eSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97814210e8eSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97914210e8eSmrg while :; do 98014210e8eSmrg # Processed it all yet? 98114210e8eSmrg if test / = "$func_normal_abspath_tpath"; then 98214210e8eSmrg # If we ascended to the root using ".." the result may be empty now. 98314210e8eSmrg if test -z "$func_normal_abspath_result"; then 98414210e8eSmrg func_normal_abspath_result=/ 98514210e8eSmrg fi 98614210e8eSmrg break 98714210e8eSmrg fi 98814210e8eSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98914210e8eSmrg -e "$_G_pathcar"` 99014210e8eSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99114210e8eSmrg -e "$_G_pathcdr"` 99214210e8eSmrg # Figure out what to do with it 99314210e8eSmrg case $func_normal_abspath_tcomponent in 99414210e8eSmrg "") 99514210e8eSmrg # Trailing empty path component, ignore it. 99614210e8eSmrg ;; 99714210e8eSmrg ..) 99814210e8eSmrg # Parent dir; strip last assembled component from result. 99914210e8eSmrg func_dirname "$func_normal_abspath_result" 100014210e8eSmrg func_normal_abspath_result=$func_dirname_result 100114210e8eSmrg ;; 100214210e8eSmrg *) 100314210e8eSmrg # Actual path component, append it. 100414210e8eSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100514210e8eSmrg ;; 100614210e8eSmrg esac 100714210e8eSmrg done 100814210e8eSmrg # Restore leading double-slash if one was found on entry. 100914210e8eSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101014210e8eSmrg} 101114210e8eSmrg 101214210e8eSmrg 101314210e8eSmrg# func_notquiet ARG... 101414210e8eSmrg# -------------------- 101514210e8eSmrg# Echo program name prefixed message only when not in quiet mode. 101614210e8eSmrgfunc_notquiet () 101714210e8eSmrg{ 101814210e8eSmrg $debug_cmd 101914210e8eSmrg 102014210e8eSmrg $opt_quiet || func_echo ${1+"$@"} 102114210e8eSmrg 102214210e8eSmrg # A bug in bash halts the script if the last line of a function 102314210e8eSmrg # fails when set -e is in force, so we need another command to 102414210e8eSmrg # work around that: 102514210e8eSmrg : 102614210e8eSmrg} 102714210e8eSmrg 102814210e8eSmrg 102914210e8eSmrg# func_relative_path SRCDIR DSTDIR 103014210e8eSmrg# -------------------------------- 103114210e8eSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103214210e8eSmrgfunc_relative_path () 103314210e8eSmrg{ 103414210e8eSmrg $debug_cmd 103514210e8eSmrg 103614210e8eSmrg func_relative_path_result= 103714210e8eSmrg func_normal_abspath "$1" 103814210e8eSmrg func_relative_path_tlibdir=$func_normal_abspath_result 103914210e8eSmrg func_normal_abspath "$2" 104014210e8eSmrg func_relative_path_tbindir=$func_normal_abspath_result 104114210e8eSmrg 104214210e8eSmrg # Ascend the tree starting from libdir 104314210e8eSmrg while :; do 104414210e8eSmrg # check if we have found a prefix of bindir 104514210e8eSmrg case $func_relative_path_tbindir in 104614210e8eSmrg $func_relative_path_tlibdir) 104714210e8eSmrg # found an exact match 104814210e8eSmrg func_relative_path_tcancelled= 104914210e8eSmrg break 105014210e8eSmrg ;; 105114210e8eSmrg $func_relative_path_tlibdir*) 105214210e8eSmrg # found a matching prefix 105314210e8eSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105414210e8eSmrg func_relative_path_tcancelled=$func_stripname_result 105514210e8eSmrg if test -z "$func_relative_path_result"; then 105614210e8eSmrg func_relative_path_result=. 105714210e8eSmrg fi 105814210e8eSmrg break 105914210e8eSmrg ;; 106014210e8eSmrg *) 106114210e8eSmrg func_dirname $func_relative_path_tlibdir 106214210e8eSmrg func_relative_path_tlibdir=$func_dirname_result 106314210e8eSmrg if test -z "$func_relative_path_tlibdir"; then 106414210e8eSmrg # Have to descend all the way to the root! 106514210e8eSmrg func_relative_path_result=../$func_relative_path_result 106614210e8eSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 106714210e8eSmrg break 106814210e8eSmrg fi 106914210e8eSmrg func_relative_path_result=../$func_relative_path_result 107014210e8eSmrg ;; 107114210e8eSmrg esac 107214210e8eSmrg done 107314210e8eSmrg 107414210e8eSmrg # Now calculate path; take care to avoid doubling-up slashes. 107514210e8eSmrg func_stripname '' '/' "$func_relative_path_result" 107614210e8eSmrg func_relative_path_result=$func_stripname_result 107714210e8eSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107814210e8eSmrg if test -n "$func_stripname_result"; then 107914210e8eSmrg func_append func_relative_path_result "/$func_stripname_result" 108014210e8eSmrg fi 108114210e8eSmrg 108214210e8eSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 108314210e8eSmrg if test -n "$func_relative_path_result"; then 108414210e8eSmrg func_stripname './' '' "$func_relative_path_result" 108514210e8eSmrg func_relative_path_result=$func_stripname_result 1086c35d236eSmrg fi 1087c35d236eSmrg 108814210e8eSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 108914210e8eSmrg 109014210e8eSmrg : 109114210e8eSmrg} 109214210e8eSmrg 109314210e8eSmrg 109414210e8eSmrg# func_quote_for_eval ARG... 109514210e8eSmrg# -------------------------- 109614210e8eSmrg# Aesthetically quote ARGs to be evaled later. 109714210e8eSmrg# This function returns two values: 109814210e8eSmrg# i) func_quote_for_eval_result 109914210e8eSmrg# double-quoted, suitable for a subsequent eval 110014210e8eSmrg# ii) func_quote_for_eval_unquoted_result 110114210e8eSmrg# has all characters that are still active within double 110214210e8eSmrg# quotes backslashified. 110314210e8eSmrgfunc_quote_for_eval () 110414210e8eSmrg{ 110514210e8eSmrg $debug_cmd 110614210e8eSmrg 110714210e8eSmrg func_quote_for_eval_unquoted_result= 110814210e8eSmrg func_quote_for_eval_result= 110914210e8eSmrg while test 0 -lt $#; do 111014210e8eSmrg case $1 in 111114210e8eSmrg *[\\\`\"\$]*) 111214210e8eSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111314210e8eSmrg *) 111414210e8eSmrg _G_unquoted_arg=$1 ;; 111514210e8eSmrg esac 111614210e8eSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 111714210e8eSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111814210e8eSmrg else 111914210e8eSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112014210e8eSmrg fi 112114210e8eSmrg 112214210e8eSmrg case $_G_unquoted_arg in 112314210e8eSmrg # Double-quote args containing shell metacharacters to delay 112414210e8eSmrg # word splitting, command substitution and variable expansion 112514210e8eSmrg # for a subsequent eval. 112614210e8eSmrg # Many Bourne shells cannot handle close brackets correctly 112714210e8eSmrg # in scan sets, so we specify it separately. 112814210e8eSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112914210e8eSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 113014210e8eSmrg ;; 113114210e8eSmrg *) 113214210e8eSmrg _G_quoted_arg=$_G_unquoted_arg 113314210e8eSmrg ;; 113414210e8eSmrg esac 113514210e8eSmrg 113614210e8eSmrg if test -n "$func_quote_for_eval_result"; then 113714210e8eSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113814210e8eSmrg else 113914210e8eSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114014210e8eSmrg fi 114114210e8eSmrg shift 114214210e8eSmrg done 114314210e8eSmrg} 114414210e8eSmrg 114514210e8eSmrg 114614210e8eSmrg# func_quote_for_expand ARG 114714210e8eSmrg# ------------------------- 114814210e8eSmrg# Aesthetically quote ARG to be evaled later; same as above, 114914210e8eSmrg# but do not quote variable references. 115014210e8eSmrgfunc_quote_for_expand () 115114210e8eSmrg{ 115214210e8eSmrg $debug_cmd 115314210e8eSmrg 115414210e8eSmrg case $1 in 115514210e8eSmrg *[\\\`\"]*) 115614210e8eSmrg _G_arg=`$ECHO "$1" | $SED \ 115714210e8eSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115814210e8eSmrg *) 115914210e8eSmrg _G_arg=$1 ;; 116014210e8eSmrg esac 116114210e8eSmrg 116214210e8eSmrg case $_G_arg in 116314210e8eSmrg # Double-quote args containing shell metacharacters to delay 116414210e8eSmrg # word splitting and command substitution for a subsequent eval. 116514210e8eSmrg # Many Bourne shells cannot handle close brackets correctly 116614210e8eSmrg # in scan sets, so we specify it separately. 116714210e8eSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116814210e8eSmrg _G_arg=\"$_G_arg\" 116914210e8eSmrg ;; 117014210e8eSmrg esac 117114210e8eSmrg 117214210e8eSmrg func_quote_for_expand_result=$_G_arg 117314210e8eSmrg} 117414210e8eSmrg 117514210e8eSmrg 117614210e8eSmrg# func_stripname PREFIX SUFFIX NAME 117714210e8eSmrg# --------------------------------- 117814210e8eSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117914210e8eSmrg# PREFIX and SUFFIX must not contain globbing or regex special 118014210e8eSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118114210e8eSmrg# dot (in which case that matches only a dot). 118214210e8eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 118314210e8eSmrg eval 'func_stripname () 118414210e8eSmrg { 118514210e8eSmrg $debug_cmd 118614210e8eSmrg 118714210e8eSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118814210e8eSmrg # positional parameters, so assign one to ordinary variable first. 118914210e8eSmrg func_stripname_result=$3 119014210e8eSmrg func_stripname_result=${func_stripname_result#"$1"} 119114210e8eSmrg func_stripname_result=${func_stripname_result%"$2"} 119214210e8eSmrg }' 119314210e8eSmrgelse 119414210e8eSmrg func_stripname () 119514210e8eSmrg { 119614210e8eSmrg $debug_cmd 119714210e8eSmrg 119814210e8eSmrg case $2 in 119914210e8eSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120014210e8eSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120114210e8eSmrg esac 120214210e8eSmrg } 120314210e8eSmrgfi 120414210e8eSmrg 120514210e8eSmrg 120614210e8eSmrg# func_show_eval CMD [FAIL_EXP] 120714210e8eSmrg# ----------------------------- 120814210e8eSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120914210e8eSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121014210e8eSmrg# is given, then evaluate it. 121114210e8eSmrgfunc_show_eval () 121214210e8eSmrg{ 121314210e8eSmrg $debug_cmd 121414210e8eSmrg 121514210e8eSmrg _G_cmd=$1 121614210e8eSmrg _G_fail_exp=${2-':'} 121714210e8eSmrg 121814210e8eSmrg func_quote_for_expand "$_G_cmd" 121914210e8eSmrg eval "func_notquiet $func_quote_for_expand_result" 122014210e8eSmrg 122114210e8eSmrg $opt_dry_run || { 122214210e8eSmrg eval "$_G_cmd" 122314210e8eSmrg _G_status=$? 122414210e8eSmrg if test 0 -ne "$_G_status"; then 122514210e8eSmrg eval "(exit $_G_status); $_G_fail_exp" 122614210e8eSmrg fi 122714210e8eSmrg } 122814210e8eSmrg} 122914210e8eSmrg 123014210e8eSmrg 123114210e8eSmrg# func_show_eval_locale CMD [FAIL_EXP] 123214210e8eSmrg# ------------------------------------ 123314210e8eSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123414210e8eSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123514210e8eSmrg# is given, then evaluate it. Use the saved locale for evaluation. 123614210e8eSmrgfunc_show_eval_locale () 123714210e8eSmrg{ 123814210e8eSmrg $debug_cmd 123914210e8eSmrg 124014210e8eSmrg _G_cmd=$1 124114210e8eSmrg _G_fail_exp=${2-':'} 124214210e8eSmrg 124314210e8eSmrg $opt_quiet || { 124414210e8eSmrg func_quote_for_expand "$_G_cmd" 124514210e8eSmrg eval "func_echo $func_quote_for_expand_result" 124614210e8eSmrg } 124714210e8eSmrg 124814210e8eSmrg $opt_dry_run || { 124914210e8eSmrg eval "$_G_user_locale 125014210e8eSmrg $_G_cmd" 125114210e8eSmrg _G_status=$? 125214210e8eSmrg eval "$_G_safe_locale" 125314210e8eSmrg if test 0 -ne "$_G_status"; then 125414210e8eSmrg eval "(exit $_G_status); $_G_fail_exp" 125514210e8eSmrg fi 125614210e8eSmrg } 125714210e8eSmrg} 125814210e8eSmrg 125914210e8eSmrg 126014210e8eSmrg# func_tr_sh 126114210e8eSmrg# ---------- 126214210e8eSmrg# Turn $1 into a string suitable for a shell variable name. 126314210e8eSmrg# Result is stored in $func_tr_sh_result. All characters 126414210e8eSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126514210e8eSmrg# if $1 begins with a digit, a '_' is prepended as well. 126614210e8eSmrgfunc_tr_sh () 126714210e8eSmrg{ 126814210e8eSmrg $debug_cmd 126914210e8eSmrg 127014210e8eSmrg case $1 in 127114210e8eSmrg [0-9]* | *[!a-zA-Z0-9_]*) 127214210e8eSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127314210e8eSmrg ;; 127414210e8eSmrg * ) 127514210e8eSmrg func_tr_sh_result=$1 127614210e8eSmrg ;; 127714210e8eSmrg esac 127814210e8eSmrg} 127914210e8eSmrg 128014210e8eSmrg 128114210e8eSmrg# func_verbose ARG... 128214210e8eSmrg# ------------------- 128314210e8eSmrg# Echo program name prefixed message in verbose mode only. 128414210e8eSmrgfunc_verbose () 128514210e8eSmrg{ 128614210e8eSmrg $debug_cmd 128714210e8eSmrg 128814210e8eSmrg $opt_verbose && func_echo "$*" 128914210e8eSmrg 129014210e8eSmrg : 129114210e8eSmrg} 129214210e8eSmrg 129314210e8eSmrg 129414210e8eSmrg# func_warn_and_continue ARG... 129514210e8eSmrg# ----------------------------- 129614210e8eSmrg# Echo program name prefixed warning message to standard error. 129714210e8eSmrgfunc_warn_and_continue () 129814210e8eSmrg{ 129914210e8eSmrg $debug_cmd 130014210e8eSmrg 130114210e8eSmrg $require_term_colors 130214210e8eSmrg 130314210e8eSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130414210e8eSmrg} 130514210e8eSmrg 130614210e8eSmrg 130714210e8eSmrg# func_warning CATEGORY ARG... 130814210e8eSmrg# ---------------------------- 130914210e8eSmrg# Echo program name prefixed warning message to standard error. Warning 131014210e8eSmrg# messages can be filtered according to CATEGORY, where this function 131114210e8eSmrg# elides messages where CATEGORY is not listed in the global variable 131214210e8eSmrg# 'opt_warning_types'. 131314210e8eSmrgfunc_warning () 131414210e8eSmrg{ 131514210e8eSmrg $debug_cmd 131614210e8eSmrg 131714210e8eSmrg # CATEGORY must be in the warning_categories list! 131814210e8eSmrg case " $warning_categories " in 131914210e8eSmrg *" $1 "*) ;; 132014210e8eSmrg *) func_internal_error "invalid warning category '$1'" ;; 132114210e8eSmrg esac 132214210e8eSmrg 132314210e8eSmrg _G_category=$1 132414210e8eSmrg shift 132514210e8eSmrg 132614210e8eSmrg case " $opt_warning_types " in 132714210e8eSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132814210e8eSmrg esac 132914210e8eSmrg} 133014210e8eSmrg 133114210e8eSmrg 133214210e8eSmrg# func_sort_ver VER1 VER2 133314210e8eSmrg# ----------------------- 133414210e8eSmrg# 'sort -V' is not generally available. 133514210e8eSmrg# Note this deviates from the version comparison in automake 133614210e8eSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133714210e8eSmrg# but this should suffice as we won't be specifying old 133814210e8eSmrg# version formats or redundant trailing .0 in bootstrap.conf. 133914210e8eSmrg# If we did want full compatibility then we should probably 134014210e8eSmrg# use m4_version_compare from autoconf. 134114210e8eSmrgfunc_sort_ver () 134214210e8eSmrg{ 134314210e8eSmrg $debug_cmd 134414210e8eSmrg 134514210e8eSmrg printf '%s\n%s\n' "$1" "$2" \ 134614210e8eSmrg | 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 134714210e8eSmrg} 134814210e8eSmrg 134914210e8eSmrg# func_lt_ver PREV CURR 135014210e8eSmrg# --------------------- 135114210e8eSmrg# Return true if PREV and CURR are in the correct order according to 135214210e8eSmrg# func_sort_ver, otherwise false. Use it like this: 135314210e8eSmrg# 135414210e8eSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135514210e8eSmrgfunc_lt_ver () 135614210e8eSmrg{ 135714210e8eSmrg $debug_cmd 135814210e8eSmrg 135914210e8eSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136014210e8eSmrg} 136114210e8eSmrg 136214210e8eSmrg 136314210e8eSmrg# Local variables: 136414210e8eSmrg# mode: shell-script 136514210e8eSmrg# sh-indentation: 2 136614210e8eSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 136714210e8eSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136814210e8eSmrg# time-stamp-time-zone: "UTC" 136914210e8eSmrg# End: 137014210e8eSmrg#! /bin/sh 137114210e8eSmrg 137214210e8eSmrg# Set a version string for this script. 137314210e8eSmrgscriptversion=2014-01-07.03; # UTC 137414210e8eSmrg 137514210e8eSmrg# A portable, pluggable option parser for Bourne shell. 137614210e8eSmrg# Written by Gary V. Vaughan, 2010 137714210e8eSmrg 137814210e8eSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137914210e8eSmrg# This is free software; see the source for copying conditions. There is NO 138014210e8eSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138114210e8eSmrg 138214210e8eSmrg# This program is free software: you can redistribute it and/or modify 138314210e8eSmrg# it under the terms of the GNU General Public License as published by 138414210e8eSmrg# the Free Software Foundation, either version 3 of the License, or 138514210e8eSmrg# (at your option) any later version. 138614210e8eSmrg 138714210e8eSmrg# This program is distributed in the hope that it will be useful, 138814210e8eSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138914210e8eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139014210e8eSmrg# GNU General Public License for more details. 139114210e8eSmrg 139214210e8eSmrg# You should have received a copy of the GNU General Public License 139314210e8eSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139414210e8eSmrg 139514210e8eSmrg# Please report bugs or propose patches to gary@gnu.org. 139614210e8eSmrg 139714210e8eSmrg 139814210e8eSmrg## ------ ## 139914210e8eSmrg## Usage. ## 140014210e8eSmrg## ------ ## 140114210e8eSmrg 140214210e8eSmrg# This file is a library for parsing options in your shell scripts along 140314210e8eSmrg# with assorted other useful supporting features that you can make use 140414210e8eSmrg# of too. 140514210e8eSmrg# 140614210e8eSmrg# For the simplest scripts you might need only: 140714210e8eSmrg# 140814210e8eSmrg# #!/bin/sh 140914210e8eSmrg# . relative/path/to/funclib.sh 141014210e8eSmrg# . relative/path/to/options-parser 141114210e8eSmrg# scriptversion=1.0 141214210e8eSmrg# func_options ${1+"$@"} 141314210e8eSmrg# eval set dummy "$func_options_result"; shift 141414210e8eSmrg# ...rest of your script... 141514210e8eSmrg# 141614210e8eSmrg# In order for the '--version' option to work, you will need to have a 141714210e8eSmrg# suitably formatted comment like the one at the top of this file 141814210e8eSmrg# starting with '# Written by ' and ending with '# warranty; '. 141914210e8eSmrg# 142014210e8eSmrg# For '-h' and '--help' to work, you will also need a one line 142114210e8eSmrg# description of your script's purpose in a comment directly above the 142214210e8eSmrg# '# Written by ' line, like the one at the top of this file. 142314210e8eSmrg# 142414210e8eSmrg# The default options also support '--debug', which will turn on shell 142514210e8eSmrg# execution tracing (see the comment above debug_cmd below for another 142614210e8eSmrg# use), and '--verbose' and the func_verbose function to allow your script 142714210e8eSmrg# to display verbose messages only when your user has specified 142814210e8eSmrg# '--verbose'. 142914210e8eSmrg# 143014210e8eSmrg# After sourcing this file, you can plug processing for additional 143114210e8eSmrg# options by amending the variables from the 'Configuration' section 143214210e8eSmrg# below, and following the instructions in the 'Option parsing' 143314210e8eSmrg# section further down. 143414210e8eSmrg 143514210e8eSmrg## -------------- ## 143614210e8eSmrg## Configuration. ## 143714210e8eSmrg## -------------- ## 143814210e8eSmrg 143914210e8eSmrg# You should override these variables in your script after sourcing this 144014210e8eSmrg# file so that they reflect the customisations you have added to the 144114210e8eSmrg# option parser. 144214210e8eSmrg 144314210e8eSmrg# The usage line for option parsing errors and the start of '-h' and 144414210e8eSmrg# '--help' output messages. You can embed shell variables for delayed 144514210e8eSmrg# expansion at the time the message is displayed, but you will need to 144614210e8eSmrg# quote other shell meta-characters carefully to prevent them being 144714210e8eSmrg# expanded when the contents are evaled. 144814210e8eSmrgusage='$progpath [OPTION]...' 144914210e8eSmrg 145014210e8eSmrg# Short help message in response to '-h' and '--help'. Add to this or 145114210e8eSmrg# override it after sourcing this library to reflect the full set of 145214210e8eSmrg# options your script accepts. 145314210e8eSmrgusage_message="\ 145414210e8eSmrg --debug enable verbose shell tracing 145514210e8eSmrg -W, --warnings=CATEGORY 145614210e8eSmrg report the warnings falling in CATEGORY [all] 145714210e8eSmrg -v, --verbose verbosely report processing 145814210e8eSmrg --version print version information and exit 145914210e8eSmrg -h, --help print short or long help message and exit 146014210e8eSmrg" 146114210e8eSmrg 146214210e8eSmrg# Additional text appended to 'usage_message' in response to '--help'. 146314210e8eSmrglong_help_message=" 146414210e8eSmrgWarning categories include: 146514210e8eSmrg 'all' show all warnings 146614210e8eSmrg 'none' turn off all the warnings 146714210e8eSmrg 'error' warnings are treated as fatal errors" 146814210e8eSmrg 146914210e8eSmrg# Help message printed before fatal option parsing errors. 147014210e8eSmrgfatal_help="Try '\$progname --help' for more information." 147114210e8eSmrg 147214210e8eSmrg 147314210e8eSmrg 147414210e8eSmrg## ------------------------- ## 147514210e8eSmrg## Hook function management. ## 147614210e8eSmrg## ------------------------- ## 147714210e8eSmrg 147814210e8eSmrg# This section contains functions for adding, removing, and running hooks 147914210e8eSmrg# to the main code. A hook is just a named list of of function, that can 148014210e8eSmrg# be run in order later on. 148114210e8eSmrg 148214210e8eSmrg# func_hookable FUNC_NAME 148314210e8eSmrg# ----------------------- 148414210e8eSmrg# Declare that FUNC_NAME will run hooks added with 148514210e8eSmrg# 'func_add_hook FUNC_NAME ...'. 148614210e8eSmrgfunc_hookable () 148714210e8eSmrg{ 148814210e8eSmrg $debug_cmd 148914210e8eSmrg 149014210e8eSmrg func_append hookable_fns " $1" 149114210e8eSmrg} 149214210e8eSmrg 149314210e8eSmrg 149414210e8eSmrg# func_add_hook FUNC_NAME HOOK_FUNC 149514210e8eSmrg# --------------------------------- 149614210e8eSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149714210e8eSmrg# first have been declared "hookable" by a call to 'func_hookable'. 149814210e8eSmrgfunc_add_hook () 149914210e8eSmrg{ 150014210e8eSmrg $debug_cmd 150114210e8eSmrg 150214210e8eSmrg case " $hookable_fns " in 150314210e8eSmrg *" $1 "*) ;; 150414210e8eSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150514210e8eSmrg esac 150614210e8eSmrg 150714210e8eSmrg eval func_append ${1}_hooks '" $2"' 150814210e8eSmrg} 150914210e8eSmrg 151014210e8eSmrg 151114210e8eSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 151214210e8eSmrg# ------------------------------------ 151314210e8eSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151414210e8eSmrgfunc_remove_hook () 151514210e8eSmrg{ 151614210e8eSmrg $debug_cmd 151714210e8eSmrg 151814210e8eSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151914210e8eSmrg} 152014210e8eSmrg 152114210e8eSmrg 152214210e8eSmrg# func_run_hooks FUNC_NAME [ARG]... 152314210e8eSmrg# --------------------------------- 152414210e8eSmrg# Run all hook functions registered to FUNC_NAME. 152514210e8eSmrg# It is assumed that the list of hook functions contains nothing more 152614210e8eSmrg# than a whitespace-delimited list of legal shell function names, and 152714210e8eSmrg# no effort is wasted trying to catch shell meta-characters or preserve 152814210e8eSmrg# whitespace. 152914210e8eSmrgfunc_run_hooks () 153014210e8eSmrg{ 153114210e8eSmrg $debug_cmd 153214210e8eSmrg 153314210e8eSmrg case " $hookable_fns " in 153414210e8eSmrg *" $1 "*) ;; 153514210e8eSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153614210e8eSmrg esac 153714210e8eSmrg 153814210e8eSmrg eval _G_hook_fns=\$$1_hooks; shift 153914210e8eSmrg 154014210e8eSmrg for _G_hook in $_G_hook_fns; do 154114210e8eSmrg eval $_G_hook '"$@"' 154214210e8eSmrg 154314210e8eSmrg # store returned options list back into positional 154414210e8eSmrg # parameters for next 'cmd' execution. 154514210e8eSmrg eval _G_hook_result=\$${_G_hook}_result 154614210e8eSmrg eval set dummy "$_G_hook_result"; shift 154714210e8eSmrg done 154814210e8eSmrg 154914210e8eSmrg func_quote_for_eval ${1+"$@"} 155014210e8eSmrg func_run_hooks_result=$func_quote_for_eval_result 155114210e8eSmrg} 155214210e8eSmrg 155314210e8eSmrg 155414210e8eSmrg 155514210e8eSmrg## --------------- ## 155614210e8eSmrg## Option parsing. ## 155714210e8eSmrg## --------------- ## 155814210e8eSmrg 155914210e8eSmrg# In order to add your own option parsing hooks, you must accept the 156014210e8eSmrg# full positional parameter list in your hook function, remove any 156114210e8eSmrg# options that you action, and then pass back the remaining unprocessed 156214210e8eSmrg# options in '<hooked_function_name>_result', escaped suitably for 156314210e8eSmrg# 'eval'. Like this: 156414210e8eSmrg# 156514210e8eSmrg# my_options_prep () 156614210e8eSmrg# { 156714210e8eSmrg# $debug_cmd 156814210e8eSmrg# 156914210e8eSmrg# # Extend the existing usage message. 157014210e8eSmrg# usage_message=$usage_message' 157114210e8eSmrg# -s, --silent don'\''t print informational messages 157214210e8eSmrg# ' 157314210e8eSmrg# 157414210e8eSmrg# func_quote_for_eval ${1+"$@"} 157514210e8eSmrg# my_options_prep_result=$func_quote_for_eval_result 157614210e8eSmrg# } 157714210e8eSmrg# func_add_hook func_options_prep my_options_prep 157814210e8eSmrg# 157914210e8eSmrg# 158014210e8eSmrg# my_silent_option () 158114210e8eSmrg# { 158214210e8eSmrg# $debug_cmd 158314210e8eSmrg# 158414210e8eSmrg# # Note that for efficiency, we parse as many options as we can 158514210e8eSmrg# # recognise in a loop before passing the remainder back to the 158614210e8eSmrg# # caller on the first unrecognised argument we encounter. 158714210e8eSmrg# while test $# -gt 0; do 158814210e8eSmrg# opt=$1; shift 158914210e8eSmrg# case $opt in 159014210e8eSmrg# --silent|-s) opt_silent=: ;; 159114210e8eSmrg# # Separate non-argument short options: 159214210e8eSmrg# -s*) func_split_short_opt "$_G_opt" 159314210e8eSmrg# set dummy "$func_split_short_opt_name" \ 159414210e8eSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 159514210e8eSmrg# shift 159614210e8eSmrg# ;; 159714210e8eSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159814210e8eSmrg# esac 159914210e8eSmrg# done 160014210e8eSmrg# 160114210e8eSmrg# func_quote_for_eval ${1+"$@"} 160214210e8eSmrg# my_silent_option_result=$func_quote_for_eval_result 160314210e8eSmrg# } 160414210e8eSmrg# func_add_hook func_parse_options my_silent_option 160514210e8eSmrg# 160614210e8eSmrg# 160714210e8eSmrg# my_option_validation () 160814210e8eSmrg# { 160914210e8eSmrg# $debug_cmd 161014210e8eSmrg# 161114210e8eSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161214210e8eSmrg# '--silent' and '--verbose' options are mutually exclusive." 161314210e8eSmrg# 161414210e8eSmrg# func_quote_for_eval ${1+"$@"} 161514210e8eSmrg# my_option_validation_result=$func_quote_for_eval_result 161614210e8eSmrg# } 161714210e8eSmrg# func_add_hook func_validate_options my_option_validation 161814210e8eSmrg# 161914210e8eSmrg# You'll alse need to manually amend $usage_message to reflect the extra 162014210e8eSmrg# options you parse. It's preferable to append if you can, so that 162114210e8eSmrg# multiple option parsing hooks can be added safely. 162214210e8eSmrg 162314210e8eSmrg 162414210e8eSmrg# func_options [ARG]... 162514210e8eSmrg# --------------------- 162614210e8eSmrg# All the functions called inside func_options are hookable. See the 162714210e8eSmrg# individual implementations for details. 162814210e8eSmrgfunc_hookable func_options 162914210e8eSmrgfunc_options () 163014210e8eSmrg{ 163114210e8eSmrg $debug_cmd 163214210e8eSmrg 163314210e8eSmrg func_options_prep ${1+"$@"} 163414210e8eSmrg eval func_parse_options \ 163514210e8eSmrg ${func_options_prep_result+"$func_options_prep_result"} 163614210e8eSmrg eval func_validate_options \ 163714210e8eSmrg ${func_parse_options_result+"$func_parse_options_result"} 163814210e8eSmrg 163914210e8eSmrg eval func_run_hooks func_options \ 164014210e8eSmrg ${func_validate_options_result+"$func_validate_options_result"} 164114210e8eSmrg 164214210e8eSmrg # save modified positional parameters for caller 164314210e8eSmrg func_options_result=$func_run_hooks_result 1644c35d236eSmrg} 1645c35d236eSmrg 1646c35d236eSmrg 164714210e8eSmrg# func_options_prep [ARG]... 164814210e8eSmrg# -------------------------- 164914210e8eSmrg# All initialisations required before starting the option parse loop. 165014210e8eSmrg# Note that when calling hook functions, we pass through the list of 165114210e8eSmrg# positional parameters. If a hook function modifies that list, and 165214210e8eSmrg# needs to propogate that back to rest of this script, then the complete 165314210e8eSmrg# modified list must be put in 'func_run_hooks_result' before 165414210e8eSmrg# returning. 165514210e8eSmrgfunc_hookable func_options_prep 165614210e8eSmrgfunc_options_prep () 1657c35d236eSmrg{ 165814210e8eSmrg $debug_cmd 16591fb744b4Smrg 166014210e8eSmrg # Option defaults: 166114210e8eSmrg opt_verbose=false 166214210e8eSmrg opt_warning_types= 166314210e8eSmrg 166414210e8eSmrg func_run_hooks func_options_prep ${1+"$@"} 166514210e8eSmrg 166614210e8eSmrg # save modified positional parameters for caller 166714210e8eSmrg func_options_prep_result=$func_run_hooks_result 16681fb744b4Smrg} 16691fb744b4Smrg 16701fb744b4Smrg 167114210e8eSmrg# func_parse_options [ARG]... 167214210e8eSmrg# --------------------------- 167314210e8eSmrg# The main option parsing loop. 167414210e8eSmrgfunc_hookable func_parse_options 167514210e8eSmrgfunc_parse_options () 16761fb744b4Smrg{ 167714210e8eSmrg $debug_cmd 16781fb744b4Smrg 167914210e8eSmrg func_parse_options_result= 16801fb744b4Smrg 168114210e8eSmrg # this just eases exit handling 168214210e8eSmrg while test $# -gt 0; do 168314210e8eSmrg # Defer to hook functions for initial option parsing, so they 168414210e8eSmrg # get priority in the event of reusing an option name. 168514210e8eSmrg func_run_hooks func_parse_options ${1+"$@"} 16861fb744b4Smrg 168714210e8eSmrg # Adjust func_parse_options positional parameters to match 168814210e8eSmrg eval set dummy "$func_run_hooks_result"; shift 16891fb744b4Smrg 169014210e8eSmrg # Break out of the loop if we already parsed every option. 169114210e8eSmrg test $# -gt 0 || break 16921fb744b4Smrg 169314210e8eSmrg _G_opt=$1 169414210e8eSmrg shift 169514210e8eSmrg case $_G_opt in 169614210e8eSmrg --debug|-x) debug_cmd='set -x' 169714210e8eSmrg func_echo "enabling shell trace mode" 169814210e8eSmrg $debug_cmd 169914210e8eSmrg ;; 170014210e8eSmrg 170114210e8eSmrg --no-warnings|--no-warning|--no-warn) 170214210e8eSmrg set dummy --warnings none ${1+"$@"} 170314210e8eSmrg shift 170414210e8eSmrg ;; 17051fb744b4Smrg 170614210e8eSmrg --warnings|--warning|-W) 170714210e8eSmrg test $# = 0 && func_missing_arg $_G_opt && break 170814210e8eSmrg case " $warning_categories $1" in 170914210e8eSmrg *" $1 "*) 171014210e8eSmrg # trailing space prevents matching last $1 above 171114210e8eSmrg func_append_uniq opt_warning_types " $1" 171214210e8eSmrg ;; 171314210e8eSmrg *all) 171414210e8eSmrg opt_warning_types=$warning_categories 171514210e8eSmrg ;; 171614210e8eSmrg *none) 171714210e8eSmrg opt_warning_types=none 171814210e8eSmrg warning_func=: 171914210e8eSmrg ;; 172014210e8eSmrg *error) 172114210e8eSmrg opt_warning_types=$warning_categories 172214210e8eSmrg warning_func=func_fatal_error 172314210e8eSmrg ;; 172414210e8eSmrg *) 172514210e8eSmrg func_fatal_error \ 172614210e8eSmrg "unsupported warning category: '$1'" 172714210e8eSmrg ;; 172814210e8eSmrg esac 172914210e8eSmrg shift 173014210e8eSmrg ;; 173114210e8eSmrg 173214210e8eSmrg --verbose|-v) opt_verbose=: ;; 173314210e8eSmrg --version) func_version ;; 173414210e8eSmrg -\?|-h) func_usage ;; 173514210e8eSmrg --help) func_help ;; 173614210e8eSmrg 173714210e8eSmrg # Separate optargs to long options (plugins may need this): 173814210e8eSmrg --*=*) func_split_equals "$_G_opt" 173914210e8eSmrg set dummy "$func_split_equals_lhs" \ 174014210e8eSmrg "$func_split_equals_rhs" ${1+"$@"} 174114210e8eSmrg shift 174214210e8eSmrg ;; 174314210e8eSmrg 174414210e8eSmrg # Separate optargs to short options: 174514210e8eSmrg -W*) 174614210e8eSmrg func_split_short_opt "$_G_opt" 174714210e8eSmrg set dummy "$func_split_short_opt_name" \ 174814210e8eSmrg "$func_split_short_opt_arg" ${1+"$@"} 174914210e8eSmrg shift 175014210e8eSmrg ;; 175114210e8eSmrg 175214210e8eSmrg # Separate non-argument short options: 175314210e8eSmrg -\?*|-h*|-v*|-x*) 175414210e8eSmrg func_split_short_opt "$_G_opt" 175514210e8eSmrg set dummy "$func_split_short_opt_name" \ 175614210e8eSmrg "-$func_split_short_opt_arg" ${1+"$@"} 175714210e8eSmrg shift 175814210e8eSmrg ;; 175914210e8eSmrg 176014210e8eSmrg --) break ;; 176114210e8eSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176214210e8eSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176314210e8eSmrg esac 176414210e8eSmrg done 176514210e8eSmrg 176614210e8eSmrg # save modified positional parameters for caller 176714210e8eSmrg func_quote_for_eval ${1+"$@"} 176814210e8eSmrg func_parse_options_result=$func_quote_for_eval_result 17691fb744b4Smrg} 17701fb744b4Smrg 17711fb744b4Smrg 177214210e8eSmrg# func_validate_options [ARG]... 177314210e8eSmrg# ------------------------------ 177414210e8eSmrg# Perform any sanity checks on option settings and/or unconsumed 177514210e8eSmrg# arguments. 177614210e8eSmrgfunc_hookable func_validate_options 177714210e8eSmrgfunc_validate_options () 17781fb744b4Smrg{ 177914210e8eSmrg $debug_cmd 17801fb744b4Smrg 178114210e8eSmrg # Display all warnings if -W was not given. 178214210e8eSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 17831fb744b4Smrg 178414210e8eSmrg func_run_hooks func_validate_options ${1+"$@"} 17851fb744b4Smrg 178614210e8eSmrg # Bail if the options were screwed! 178714210e8eSmrg $exit_cmd $EXIT_FAILURE 178814210e8eSmrg 178914210e8eSmrg # save modified positional parameters for caller 179014210e8eSmrg func_validate_options_result=$func_run_hooks_result 1791c35d236eSmrg} 1792c35d236eSmrg 1793c35d236eSmrg 17941fb744b4Smrg 179514210e8eSmrg## ----------------- ## 179614210e8eSmrg## Helper functions. ## 179714210e8eSmrg## ----------------- ## 1798c35d236eSmrg 179914210e8eSmrg# This section contains the helper functions used by the rest of the 180014210e8eSmrg# hookable option parser framework in ascii-betical order. 180114210e8eSmrg 180214210e8eSmrg 180314210e8eSmrg# func_fatal_help ARG... 180414210e8eSmrg# ---------------------- 180514210e8eSmrg# Echo program name prefixed message to standard error, followed by 180614210e8eSmrg# a help hint, and exit. 180714210e8eSmrgfunc_fatal_help () 1808c35d236eSmrg{ 180914210e8eSmrg $debug_cmd 18101fb744b4Smrg 181114210e8eSmrg eval \$ECHO \""Usage: $usage"\" 181214210e8eSmrg eval \$ECHO \""$fatal_help"\" 181314210e8eSmrg func_error ${1+"$@"} 181414210e8eSmrg exit $EXIT_FAILURE 1815c35d236eSmrg} 1816c35d236eSmrg 181714210e8eSmrg 181814210e8eSmrg# func_help 181914210e8eSmrg# --------- 182014210e8eSmrg# Echo long help message to standard output and exit. 18211fb744b4Smrgfunc_help () 1822c35d236eSmrg{ 182314210e8eSmrg $debug_cmd 182414210e8eSmrg 182514210e8eSmrg func_usage_message 182614210e8eSmrg $ECHO "$long_help_message" 182714210e8eSmrg exit 0 18281fb744b4Smrg} 1829c35d236eSmrg 183014210e8eSmrg 183114210e8eSmrg# func_missing_arg ARGNAME 183214210e8eSmrg# ------------------------ 18331fb744b4Smrg# Echo program name prefixed message to standard error and set global 18341fb744b4Smrg# exit_cmd. 18351fb744b4Smrgfunc_missing_arg () 18361fb744b4Smrg{ 183714210e8eSmrg $debug_cmd 1838f55e6a01Smrg 183914210e8eSmrg func_error "Missing argument for '$1'." 18401fb744b4Smrg exit_cmd=exit 1841c35d236eSmrg} 1842c35d236eSmrg 1843f55e6a01Smrg 184414210e8eSmrg# func_split_equals STRING 184514210e8eSmrg# ------------------------ 184614210e8eSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184714210e8eSmrg# splitting STRING at the '=' sign. 184814210e8eSmrgtest -z "$_G_HAVE_XSI_OPS" \ 184914210e8eSmrg && (eval 'x=a/b/c; 185014210e8eSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185114210e8eSmrg && _G_HAVE_XSI_OPS=yes 185214210e8eSmrg 185314210e8eSmrgif test yes = "$_G_HAVE_XSI_OPS" 185414210e8eSmrgthen 185514210e8eSmrg # This is an XSI compatible shell, allowing a faster implementation... 185614210e8eSmrg eval 'func_split_equals () 185714210e8eSmrg { 185814210e8eSmrg $debug_cmd 185914210e8eSmrg 186014210e8eSmrg func_split_equals_lhs=${1%%=*} 186114210e8eSmrg func_split_equals_rhs=${1#*=} 186214210e8eSmrg test "x$func_split_equals_lhs" = "x$1" \ 186314210e8eSmrg && func_split_equals_rhs= 186414210e8eSmrg }' 186514210e8eSmrgelse 186614210e8eSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 186714210e8eSmrg func_split_equals () 186814210e8eSmrg { 186914210e8eSmrg $debug_cmd 187014210e8eSmrg 187114210e8eSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187214210e8eSmrg func_split_equals_rhs= 187314210e8eSmrg test "x$func_split_equals_lhs" = "x$1" \ 187414210e8eSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187514210e8eSmrg } 187614210e8eSmrgfi #func_split_equals 187714210e8eSmrg 187814210e8eSmrg 187914210e8eSmrg# func_split_short_opt SHORTOPT 188014210e8eSmrg# ----------------------------- 18811fb744b4Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 18821fb744b4Smrg# variables after splitting SHORTOPT after the 2nd character. 188314210e8eSmrgif test yes = "$_G_HAVE_XSI_OPS" 188414210e8eSmrgthen 188514210e8eSmrg # This is an XSI compatible shell, allowing a faster implementation... 188614210e8eSmrg eval 'func_split_short_opt () 188714210e8eSmrg { 188814210e8eSmrg $debug_cmd 188914210e8eSmrg 189014210e8eSmrg func_split_short_opt_arg=${1#??} 189114210e8eSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189214210e8eSmrg }' 189314210e8eSmrgelse 189414210e8eSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 189514210e8eSmrg func_split_short_opt () 189614210e8eSmrg { 189714210e8eSmrg $debug_cmd 189814210e8eSmrg 189914210e8eSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190014210e8eSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190114210e8eSmrg } 190214210e8eSmrgfi #func_split_short_opt 190314210e8eSmrg 190414210e8eSmrg 190514210e8eSmrg# func_usage 190614210e8eSmrg# ---------- 190714210e8eSmrg# Echo short help message to standard output and exit. 190814210e8eSmrgfunc_usage () 19091fb744b4Smrg{ 191014210e8eSmrg $debug_cmd 19111fb744b4Smrg 191214210e8eSmrg func_usage_message 191314210e8eSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191414210e8eSmrg exit 0 191514210e8eSmrg} 1916f55e6a01Smrg 1917c35d236eSmrg 191814210e8eSmrg# func_usage_message 191914210e8eSmrg# ------------------ 192014210e8eSmrg# Echo short help message to standard output. 192114210e8eSmrgfunc_usage_message () 19221fb744b4Smrg{ 192314210e8eSmrg $debug_cmd 1924c35d236eSmrg 192514210e8eSmrg eval \$ECHO \""Usage: $usage"\" 192614210e8eSmrg echo 192714210e8eSmrg $SED -n 's|^# || 192814210e8eSmrg /^Written by/{ 192914210e8eSmrg x;p;x 193014210e8eSmrg } 193114210e8eSmrg h 193214210e8eSmrg /^Written by/q' < "$progpath" 193314210e8eSmrg echo 193414210e8eSmrg eval \$ECHO \""$usage_message"\" 193514210e8eSmrg} 1936c35d236eSmrg 1937c35d236eSmrg 193814210e8eSmrg# func_version 193914210e8eSmrg# ------------ 194014210e8eSmrg# Echo version message to standard output and exit. 194114210e8eSmrgfunc_version () 194214210e8eSmrg{ 194314210e8eSmrg $debug_cmd 1944c35d236eSmrg 194514210e8eSmrg printf '%s\n' "$progname $scriptversion" 194614210e8eSmrg $SED -n ' 194714210e8eSmrg /(C)/!b go 194814210e8eSmrg :more 194914210e8eSmrg /\./!{ 195014210e8eSmrg N 195114210e8eSmrg s|\n# | | 195214210e8eSmrg b more 195314210e8eSmrg } 195414210e8eSmrg :go 195514210e8eSmrg /^# Written by /,/# warranty; / { 195614210e8eSmrg s|^# || 195714210e8eSmrg s|^# *$|| 195814210e8eSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195914210e8eSmrg p 196014210e8eSmrg } 196114210e8eSmrg /^# Written by / { 196214210e8eSmrg s|^# || 196314210e8eSmrg p 196414210e8eSmrg } 196514210e8eSmrg /^warranty; /q' < "$progpath" 1966c35d236eSmrg 196714210e8eSmrg exit $? 196814210e8eSmrg} 1969f55e6a01Smrg 1970f55e6a01Smrg 197114210e8eSmrg# Local variables: 197214210e8eSmrg# mode: shell-script 197314210e8eSmrg# sh-indentation: 2 197414210e8eSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 197514210e8eSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197614210e8eSmrg# time-stamp-time-zone: "UTC" 197714210e8eSmrg# End: 19781fb744b4Smrg 197914210e8eSmrg# Set a version string. 198014210e8eSmrgscriptversion='(GNU libtool) 2.4.6' 19811fb744b4Smrg 19821fb744b4Smrg 198314210e8eSmrg# func_echo ARG... 198414210e8eSmrg# ---------------- 198514210e8eSmrg# Libtool also displays the current mode in messages, so override 198614210e8eSmrg# funclib.sh func_echo with this custom definition. 198714210e8eSmrgfunc_echo () 19881fb744b4Smrg{ 198914210e8eSmrg $debug_cmd 19901fb744b4Smrg 199114210e8eSmrg _G_message=$* 19921fb744b4Smrg 199314210e8eSmrg func_echo_IFS=$IFS 199414210e8eSmrg IFS=$nl 199514210e8eSmrg for _G_line in $_G_message; do 199614210e8eSmrg IFS=$func_echo_IFS 199714210e8eSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199814210e8eSmrg done 199914210e8eSmrg IFS=$func_echo_IFS 200014210e8eSmrg} 20011fb744b4Smrg 200214210e8eSmrg 200314210e8eSmrg# func_warning ARG... 200414210e8eSmrg# ------------------- 200514210e8eSmrg# Libtool warnings are not categorized, so override funclib.sh 200614210e8eSmrg# func_warning with this simpler definition. 200714210e8eSmrgfunc_warning () 20081fb744b4Smrg{ 200914210e8eSmrg $debug_cmd 20101fb744b4Smrg 201114210e8eSmrg $warning_func ${1+"$@"} 201214210e8eSmrg} 20131fb744b4Smrg 20141fb744b4Smrg 201514210e8eSmrg## ---------------- ## 201614210e8eSmrg## Options parsing. ## 201714210e8eSmrg## ---------------- ## 201814210e8eSmrg 201914210e8eSmrg# Hook in the functions to make sure our own options are parsed during 202014210e8eSmrg# the option parsing loop. 202114210e8eSmrg 202214210e8eSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 202314210e8eSmrg 202414210e8eSmrg# Short help message in response to '-h'. 202514210e8eSmrgusage_message="Options: 202614210e8eSmrg --config show all configuration variables 202714210e8eSmrg --debug enable verbose shell tracing 202814210e8eSmrg -n, --dry-run display commands without modifying any files 202914210e8eSmrg --features display basic configuration information and exit 203014210e8eSmrg --mode=MODE use operation mode MODE 203114210e8eSmrg --no-warnings equivalent to '-Wnone' 203214210e8eSmrg --preserve-dup-deps don't remove duplicate dependency libraries 203314210e8eSmrg --quiet, --silent don't print informational messages 203414210e8eSmrg --tag=TAG use configuration variables from tag TAG 203514210e8eSmrg -v, --verbose print more informational messages than default 203614210e8eSmrg --version print version information 203714210e8eSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203814210e8eSmrg -h, --help, --help-all print short, long, or detailed help message 203914210e8eSmrg" 20401fb744b4Smrg 204114210e8eSmrg# Additional text appended to 'usage_message' in response to '--help'. 204214210e8eSmrgfunc_help () 20431fb744b4Smrg{ 204414210e8eSmrg $debug_cmd 204514210e8eSmrg 204614210e8eSmrg func_usage_message 204714210e8eSmrg $ECHO "$long_help_message 204814210e8eSmrg 204914210e8eSmrgMODE must be one of the following: 205014210e8eSmrg 205114210e8eSmrg clean remove files from the build directory 205214210e8eSmrg compile compile a source file into a libtool object 205314210e8eSmrg execute automatically set library path, then run a program 205414210e8eSmrg finish complete the installation of libtool libraries 205514210e8eSmrg install install libraries or executables 205614210e8eSmrg link create a library or an executable 205714210e8eSmrg uninstall remove libraries from an installed directory 205814210e8eSmrg 205914210e8eSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206014210e8eSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206114210e8eSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206214210e8eSmrg 206314210e8eSmrgWhen reporting a bug, please describe a test case to reproduce it and 206414210e8eSmrginclude the following information: 206514210e8eSmrg 206614210e8eSmrg host-triplet: $host 206714210e8eSmrg shell: $SHELL 206814210e8eSmrg compiler: $LTCC 206914210e8eSmrg compiler flags: $LTCFLAGS 207014210e8eSmrg linker: $LD (gnu? $with_gnu_ld) 207114210e8eSmrg version: $progname (GNU libtool) 2.4.6 207214210e8eSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207314210e8eSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207414210e8eSmrg 207514210e8eSmrgReport bugs to <bug-libtool@gnu.org>. 207614210e8eSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 207714210e8eSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207814210e8eSmrg exit 0 207914210e8eSmrg} 20801fb744b4Smrg 20811fb744b4Smrg 208214210e8eSmrg# func_lo2o OBJECT-NAME 208314210e8eSmrg# --------------------- 208414210e8eSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208514210e8eSmrg# object suffix. 208614210e8eSmrg 208714210e8eSmrglo2o=s/\\.lo\$/.$objext/ 208814210e8eSmrgo2lo=s/\\.$objext\$/.lo/ 208914210e8eSmrg 209014210e8eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 209114210e8eSmrg eval 'func_lo2o () 209214210e8eSmrg { 209314210e8eSmrg case $1 in 209414210e8eSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209514210e8eSmrg * ) func_lo2o_result=$1 ;; 209614210e8eSmrg esac 209714210e8eSmrg }' 209814210e8eSmrg 209914210e8eSmrg # func_xform LIBOBJ-OR-SOURCE 210014210e8eSmrg # --------------------------- 210114210e8eSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210214210e8eSmrg # suffix to a '.lo' libtool-object suffix. 210314210e8eSmrg eval 'func_xform () 210414210e8eSmrg { 210514210e8eSmrg func_xform_result=${1%.*}.lo 210614210e8eSmrg }' 210714210e8eSmrgelse 210814210e8eSmrg # ...otherwise fall back to using sed. 210914210e8eSmrg func_lo2o () 211014210e8eSmrg { 211114210e8eSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211214210e8eSmrg } 211314210e8eSmrg 211414210e8eSmrg func_xform () 211514210e8eSmrg { 211614210e8eSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211714210e8eSmrg } 211814210e8eSmrgfi 21191fb744b4Smrg 21201fb744b4Smrg 212114210e8eSmrg# func_fatal_configuration ARG... 212214210e8eSmrg# ------------------------------- 21231fb744b4Smrg# Echo program name prefixed message to standard error, followed by 21241fb744b4Smrg# a configuration failure hint, and exit. 21251fb744b4Smrgfunc_fatal_configuration () 21261fb744b4Smrg{ 212714210e8eSmrg func__fatal_error ${1+"$@"} \ 212814210e8eSmrg "See the $PACKAGE documentation for more information." \ 212914210e8eSmrg "Fatal configuration error." 21301fb744b4Smrg} 21311fb744b4Smrg 21321fb744b4Smrg 21331fb744b4Smrg# func_config 213414210e8eSmrg# ----------- 21351fb744b4Smrg# Display the configuration for all the tags in this script. 21361fb744b4Smrgfunc_config () 21371fb744b4Smrg{ 21381fb744b4Smrg re_begincf='^# ### BEGIN LIBTOOL' 21391fb744b4Smrg re_endcf='^# ### END LIBTOOL' 21401fb744b4Smrg 21411fb744b4Smrg # Default configuration. 21421fb744b4Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 21431fb744b4Smrg 2144c35d236eSmrg # Now print the configurations for the tags. 2145c35d236eSmrg for tagname in $taglist; do 21461fb744b4Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147c35d236eSmrg done 2148518bcf38Smrg 21491fb744b4Smrg exit $? 21501fb744b4Smrg} 2151518bcf38Smrg 215214210e8eSmrg 21531fb744b4Smrg# func_features 215414210e8eSmrg# ------------- 21551fb744b4Smrg# Display the features supported by this script. 21561fb744b4Smrgfunc_features () 21571fb744b4Smrg{ 21581fb744b4Smrg echo "host: $host" 215914210e8eSmrg if test yes = "$build_libtool_libs"; then 21601fb744b4Smrg echo "enable shared libraries" 2161c35d236eSmrg else 21621fb744b4Smrg echo "disable shared libraries" 2163c35d236eSmrg fi 216414210e8eSmrg if test yes = "$build_old_libs"; then 21651fb744b4Smrg echo "enable static libraries" 2166c35d236eSmrg else 21671fb744b4Smrg echo "disable static libraries" 2168c35d236eSmrg fi 2169c35d236eSmrg 21701fb744b4Smrg exit $? 21711fb744b4Smrg} 2172f55e6a01Smrg 217314210e8eSmrg 217414210e8eSmrg# func_enable_tag TAGNAME 217514210e8eSmrg# ----------------------- 21761fb744b4Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 21771fb744b4Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 21781fb744b4Smrg# variable here. 21791fb744b4Smrgfunc_enable_tag () 21801fb744b4Smrg{ 218114210e8eSmrg # Global variable: 218214210e8eSmrg tagname=$1 2183c35d236eSmrg 218414210e8eSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218514210e8eSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218614210e8eSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187518bcf38Smrg 218814210e8eSmrg # Validate tagname. 218914210e8eSmrg case $tagname in 219014210e8eSmrg *[!-_A-Za-z0-9,/]*) 219114210e8eSmrg func_fatal_error "invalid tag name: $tagname" 219214210e8eSmrg ;; 219314210e8eSmrg esac 2194518bcf38Smrg 219514210e8eSmrg # Don't test for the "default" C tag, as we know it's 219614210e8eSmrg # there but not specially marked. 219714210e8eSmrg case $tagname in 219814210e8eSmrg CC) ;; 21991fb744b4Smrg *) 220014210e8eSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220114210e8eSmrg taglist="$taglist $tagname" 220214210e8eSmrg 220314210e8eSmrg # Evaluate the configuration. Be careful to quote the path 220414210e8eSmrg # and the sed script, to avoid splitting on whitespace, but 220514210e8eSmrg # also don't use non-portable quotes within backquotes within 220614210e8eSmrg # quotes we have to do it in 2 steps: 220714210e8eSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220814210e8eSmrg eval "$extractedcf" 220914210e8eSmrg else 221014210e8eSmrg func_error "ignoring unknown tag $tagname" 221114210e8eSmrg fi 221214210e8eSmrg ;; 221314210e8eSmrg esac 22141fb744b4Smrg} 2215518bcf38Smrg 221614210e8eSmrg 22171fb744b4Smrg# func_check_version_match 221814210e8eSmrg# ------------------------ 22191fb744b4Smrg# Ensure that we are using m4 macros, and libtool script from the same 22201fb744b4Smrg# release of libtool. 22211fb744b4Smrgfunc_check_version_match () 22221fb744b4Smrg{ 222314210e8eSmrg if test "$package_revision" != "$macro_revision"; then 222414210e8eSmrg if test "$VERSION" != "$macro_version"; then 222514210e8eSmrg if test -z "$macro_version"; then 222614210e8eSmrg cat >&2 <<_LT_EOF 22271fb744b4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22281fb744b4Smrg$progname: definition of this LT_INIT comes from an older release. 22291fb744b4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22301fb744b4Smrg$progname: and run autoconf again. 22311fb744b4Smrg_LT_EOF 223214210e8eSmrg else 223314210e8eSmrg cat >&2 <<_LT_EOF 22341fb744b4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22351fb744b4Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 22361fb744b4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22371fb744b4Smrg$progname: and run autoconf again. 22381fb744b4Smrg_LT_EOF 223914210e8eSmrg fi 224014210e8eSmrg else 224114210e8eSmrg cat >&2 <<_LT_EOF 22421fb744b4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 22431fb744b4Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 22441fb744b4Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 22451fb744b4Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 22461fb744b4Smrg_LT_EOF 224714210e8eSmrg fi 2248518bcf38Smrg 224914210e8eSmrg exit $EXIT_MISMATCH 225014210e8eSmrg fi 22511fb744b4Smrg} 2252c35d236eSmrg 2253f55e6a01Smrg 225414210e8eSmrg# libtool_options_prep [ARG]... 225514210e8eSmrg# ----------------------------- 225614210e8eSmrg# Preparation for options parsed by libtool. 225714210e8eSmrglibtool_options_prep () 225814210e8eSmrg{ 225914210e8eSmrg $debug_mode 2260f55e6a01Smrg 226114210e8eSmrg # Option defaults: 226214210e8eSmrg opt_config=false 226314210e8eSmrg opt_dlopen= 226414210e8eSmrg opt_dry_run=false 226514210e8eSmrg opt_help=false 226614210e8eSmrg opt_mode= 226714210e8eSmrg opt_preserve_dup_deps=false 226814210e8eSmrg opt_quiet=false 2269f55e6a01Smrg 227014210e8eSmrg nonopt= 227114210e8eSmrg preserve_args= 2272f55e6a01Smrg 227314210e8eSmrg # Shorthand for --mode=foo, only valid as the first argument 227414210e8eSmrg case $1 in 227514210e8eSmrg clean|clea|cle|cl) 227614210e8eSmrg shift; set dummy --mode clean ${1+"$@"}; shift 227714210e8eSmrg ;; 227814210e8eSmrg compile|compil|compi|comp|com|co|c) 227914210e8eSmrg shift; set dummy --mode compile ${1+"$@"}; shift 228014210e8eSmrg ;; 228114210e8eSmrg execute|execut|execu|exec|exe|ex|e) 228214210e8eSmrg shift; set dummy --mode execute ${1+"$@"}; shift 228314210e8eSmrg ;; 228414210e8eSmrg finish|finis|fini|fin|fi|f) 228514210e8eSmrg shift; set dummy --mode finish ${1+"$@"}; shift 228614210e8eSmrg ;; 228714210e8eSmrg install|instal|insta|inst|ins|in|i) 228814210e8eSmrg shift; set dummy --mode install ${1+"$@"}; shift 228914210e8eSmrg ;; 229014210e8eSmrg link|lin|li|l) 229114210e8eSmrg shift; set dummy --mode link ${1+"$@"}; shift 229214210e8eSmrg ;; 229314210e8eSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229414210e8eSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229514210e8eSmrg ;; 229614210e8eSmrg esac 229714210e8eSmrg 229814210e8eSmrg # Pass back the list of options. 229914210e8eSmrg func_quote_for_eval ${1+"$@"} 230014210e8eSmrg libtool_options_prep_result=$func_quote_for_eval_result 230114210e8eSmrg} 230214210e8eSmrgfunc_add_hook func_options_prep libtool_options_prep 2303f55e6a01Smrg 23041fb744b4Smrg 230514210e8eSmrg# libtool_parse_options [ARG]... 230614210e8eSmrg# --------------------------------- 230714210e8eSmrg# Provide handling for libtool specific options. 230814210e8eSmrglibtool_parse_options () 23091fb744b4Smrg{ 231014210e8eSmrg $debug_cmd 2311c35d236eSmrg 231214210e8eSmrg # Perform our own loop to consume as many options as possible in 231314210e8eSmrg # each iteration. 231414210e8eSmrg while test $# -gt 0; do 231514210e8eSmrg _G_opt=$1 231614210e8eSmrg shift 231714210e8eSmrg case $_G_opt in 231814210e8eSmrg --dry-run|--dryrun|-n) 231914210e8eSmrg opt_dry_run=: 232014210e8eSmrg ;; 232114210e8eSmrg 232214210e8eSmrg --config) func_config ;; 232314210e8eSmrg 232414210e8eSmrg --dlopen|-dlopen) 232514210e8eSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 232614210e8eSmrg}$1" 232714210e8eSmrg shift 232814210e8eSmrg ;; 232914210e8eSmrg 233014210e8eSmrg --preserve-dup-deps) 233114210e8eSmrg opt_preserve_dup_deps=: ;; 233214210e8eSmrg 233314210e8eSmrg --features) func_features ;; 233414210e8eSmrg 233514210e8eSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233614210e8eSmrg 233714210e8eSmrg --help) opt_help=: ;; 233814210e8eSmrg 233914210e8eSmrg --help-all) opt_help=': help-all' ;; 234014210e8eSmrg 234114210e8eSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234214210e8eSmrg opt_mode=$1 234314210e8eSmrg case $1 in 234414210e8eSmrg # Valid mode arguments: 234514210e8eSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234614210e8eSmrg 234714210e8eSmrg # Catch anything else as an error 234814210e8eSmrg *) func_error "invalid argument for $_G_opt" 234914210e8eSmrg exit_cmd=exit 235014210e8eSmrg break 235114210e8eSmrg ;; 235214210e8eSmrg esac 235314210e8eSmrg shift 235414210e8eSmrg ;; 235514210e8eSmrg 235614210e8eSmrg --no-silent|--no-quiet) 235714210e8eSmrg opt_quiet=false 235814210e8eSmrg func_append preserve_args " $_G_opt" 235914210e8eSmrg ;; 236014210e8eSmrg 236114210e8eSmrg --no-warnings|--no-warning|--no-warn) 236214210e8eSmrg opt_warning=false 236314210e8eSmrg func_append preserve_args " $_G_opt" 236414210e8eSmrg ;; 236514210e8eSmrg 236614210e8eSmrg --no-verbose) 236714210e8eSmrg opt_verbose=false 236814210e8eSmrg func_append preserve_args " $_G_opt" 236914210e8eSmrg ;; 237014210e8eSmrg 237114210e8eSmrg --silent|--quiet) 237214210e8eSmrg opt_quiet=: 237314210e8eSmrg opt_verbose=false 237414210e8eSmrg func_append preserve_args " $_G_opt" 237514210e8eSmrg ;; 237614210e8eSmrg 237714210e8eSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237814210e8eSmrg opt_tag=$1 237914210e8eSmrg func_append preserve_args " $_G_opt $1" 238014210e8eSmrg func_enable_tag "$1" 238114210e8eSmrg shift 238214210e8eSmrg ;; 238314210e8eSmrg 238414210e8eSmrg --verbose|-v) opt_quiet=false 238514210e8eSmrg opt_verbose=: 238614210e8eSmrg func_append preserve_args " $_G_opt" 238714210e8eSmrg ;; 238814210e8eSmrg 238914210e8eSmrg # An option not handled by this hook function: 239014210e8eSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239114210e8eSmrg esac 239214210e8eSmrg done 23931fb744b4Smrg 2394c35d236eSmrg 239514210e8eSmrg # save modified positional parameters for caller 239614210e8eSmrg func_quote_for_eval ${1+"$@"} 239714210e8eSmrg libtool_parse_options_result=$func_quote_for_eval_result 239814210e8eSmrg} 239914210e8eSmrgfunc_add_hook func_parse_options libtool_parse_options 2400c35d236eSmrg 2401c35d236eSmrg 2402c35d236eSmrg 240314210e8eSmrg# libtool_validate_options [ARG]... 240414210e8eSmrg# --------------------------------- 240514210e8eSmrg# Perform any sanity checks on option settings and/or unconsumed 240614210e8eSmrg# arguments. 240714210e8eSmrglibtool_validate_options () 240814210e8eSmrg{ 240914210e8eSmrg # save first non-option argument 241014210e8eSmrg if test 0 -lt $#; then 241114210e8eSmrg nonopt=$1 241214210e8eSmrg shift 24131fb744b4Smrg fi 2414f55e6a01Smrg 241514210e8eSmrg # preserve --debug 241614210e8eSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417c35d236eSmrg 241814210e8eSmrg case $host in 241914210e8eSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242014210e8eSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242114210e8eSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242214210e8eSmrg # don't eliminate duplications in $postdeps and $predeps 242314210e8eSmrg opt_duplicate_compiler_generated_deps=: 242414210e8eSmrg ;; 242514210e8eSmrg *) 242614210e8eSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242714210e8eSmrg ;; 242814210e8eSmrg esac 2429c35d236eSmrg 243014210e8eSmrg $opt_help || { 243114210e8eSmrg # Sanity checks first: 243214210e8eSmrg func_check_version_match 243314210e8eSmrg 243414210e8eSmrg test yes != "$build_libtool_libs" \ 243514210e8eSmrg && test yes != "$build_old_libs" \ 243614210e8eSmrg && func_fatal_configuration "not configured to build any kind of library" 243714210e8eSmrg 243814210e8eSmrg # Darwin sucks 243914210e8eSmrg eval std_shrext=\"$shrext_cmds\" 244014210e8eSmrg 244114210e8eSmrg # Only execute mode is allowed to have -dlopen flags. 244214210e8eSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244314210e8eSmrg func_error "unrecognized option '-dlopen'" 244414210e8eSmrg $ECHO "$help" 1>&2 244514210e8eSmrg exit $EXIT_FAILURE 244614210e8eSmrg fi 2447518bcf38Smrg 244814210e8eSmrg # Change the help message to a mode-specific one. 244914210e8eSmrg generic_help=$help 245014210e8eSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 245114210e8eSmrg } 2452c35d236eSmrg 245314210e8eSmrg # Pass back the unparsed argument list 245414210e8eSmrg func_quote_for_eval ${1+"$@"} 245514210e8eSmrg libtool_validate_options_result=$func_quote_for_eval_result 24561fb744b4Smrg} 245714210e8eSmrgfunc_add_hook func_validate_options libtool_validate_options 2458c35d236eSmrg 2459c35d236eSmrg 246014210e8eSmrg# Process options as early as possible so that --help and --version 246114210e8eSmrg# can return quickly. 246214210e8eSmrgfunc_options ${1+"$@"} 246314210e8eSmrgeval set dummy "$func_options_result"; shift 246414210e8eSmrg 2465518bcf38Smrg 2466518bcf38Smrg 24671fb744b4Smrg## ----------- ## 24681fb744b4Smrg## Main. ## 24691fb744b4Smrg## ----------- ## 2470c35d236eSmrg 247114210e8eSmrgmagic='%%%MAGIC variable%%%' 247214210e8eSmrgmagic_exe='%%%MAGIC EXE variable%%%' 247314210e8eSmrg 247414210e8eSmrg# Global variables. 247514210e8eSmrgextracted_archives= 247614210e8eSmrgextracted_serial=0 247714210e8eSmrg 247814210e8eSmrg# If this variable is set in any of the actions, the command in it 247914210e8eSmrg# will be execed at the end. This prevents here-documents from being 248014210e8eSmrg# left over by shells. 248114210e8eSmrgexec_cmd= 248214210e8eSmrg 248314210e8eSmrg 248414210e8eSmrg# A function that is used when there is no print builtin or printf. 248514210e8eSmrgfunc_fallback_echo () 248614210e8eSmrg{ 248714210e8eSmrg eval 'cat <<_LTECHO_EOF 248814210e8eSmrg$1 248914210e8eSmrg_LTECHO_EOF' 249014210e8eSmrg} 249114210e8eSmrg 249214210e8eSmrg# func_generated_by_libtool 249314210e8eSmrg# True iff stdin has been generated by Libtool. This function is only 249414210e8eSmrg# a basic sanity check; it will hardly flush out determined imposters. 249514210e8eSmrgfunc_generated_by_libtool_p () 249614210e8eSmrg{ 249714210e8eSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249814210e8eSmrg} 249914210e8eSmrg 25001fb744b4Smrg# func_lalib_p file 250114210e8eSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25021fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out 25031fb744b4Smrg# determined imposters. 25041fb744b4Smrgfunc_lalib_p () 25051fb744b4Smrg{ 25061fb744b4Smrg test -f "$1" && 250714210e8eSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 25081fb744b4Smrg} 2509c35d236eSmrg 25101fb744b4Smrg# func_lalib_unsafe_p file 251114210e8eSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25121fb744b4Smrg# This function implements the same check as func_lalib_p without 25131fb744b4Smrg# resorting to external programs. To this end, it redirects stdin and 25141fb744b4Smrg# closes it afterwards, without saving the original file descriptor. 25151fb744b4Smrg# As a safety measure, use it only where a negative result would be 251614210e8eSmrg# fatal anyway. Works if 'file' does not exist. 25171fb744b4Smrgfunc_lalib_unsafe_p () 25181fb744b4Smrg{ 25191fb744b4Smrg lalib_p=no 25201fb744b4Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 25211fb744b4Smrg for lalib_p_l in 1 2 3 4 25221fb744b4Smrg do 25231fb744b4Smrg read lalib_p_line 252414210e8eSmrg case $lalib_p_line in 25251fb744b4Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 25261fb744b4Smrg esac 25271fb744b4Smrg done 25281fb744b4Smrg exec 0<&5 5<&- 25291fb744b4Smrg fi 253014210e8eSmrg test yes = "$lalib_p" 25311fb744b4Smrg} 2532c35d236eSmrg 25331fb744b4Smrg# func_ltwrapper_script_p file 25341fb744b4Smrg# True iff FILE is a libtool wrapper script 25351fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out 25361fb744b4Smrg# determined imposters. 25371fb744b4Smrgfunc_ltwrapper_script_p () 25381fb744b4Smrg{ 253914210e8eSmrg test -f "$1" && 254014210e8eSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 25411fb744b4Smrg} 2542518bcf38Smrg 25431fb744b4Smrg# func_ltwrapper_executable_p file 25441fb744b4Smrg# True iff FILE is a libtool wrapper executable 25451fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out 25461fb744b4Smrg# determined imposters. 25471fb744b4Smrgfunc_ltwrapper_executable_p () 25481fb744b4Smrg{ 25491fb744b4Smrg func_ltwrapper_exec_suffix= 25501fb744b4Smrg case $1 in 25511fb744b4Smrg *.exe) ;; 25521fb744b4Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553c35d236eSmrg esac 25541fb744b4Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 25551fb744b4Smrg} 2556c35d236eSmrg 25571fb744b4Smrg# func_ltwrapper_scriptname file 25581fb744b4Smrg# Assumes file is an ltwrapper_executable 25591fb744b4Smrg# uses $file to determine the appropriate filename for a 25601fb744b4Smrg# temporary ltwrapper_script. 25611fb744b4Smrgfunc_ltwrapper_scriptname () 25621fb744b4Smrg{ 25631fb744b4Smrg func_dirname_and_basename "$1" "" "." 25641fb744b4Smrg func_stripname '' '.exe' "$func_basename_result" 256514210e8eSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 25661fb744b4Smrg} 2567c35d236eSmrg 25681fb744b4Smrg# func_ltwrapper_p file 25691fb744b4Smrg# True iff FILE is a libtool wrapper script or wrapper executable 25701fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out 25711fb744b4Smrg# determined imposters. 25721fb744b4Smrgfunc_ltwrapper_p () 25731fb744b4Smrg{ 25741fb744b4Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 25751fb744b4Smrg} 2576c35d236eSmrg 2577c35d236eSmrg 25781fb744b4Smrg# func_execute_cmds commands fail_cmd 25791fb744b4Smrg# Execute tilde-delimited COMMANDS. 25801fb744b4Smrg# If FAIL_CMD is given, eval that upon failure. 25811fb744b4Smrg# FAIL_CMD may read-access the current command in variable CMD! 25821fb744b4Smrgfunc_execute_cmds () 25831fb744b4Smrg{ 258414210e8eSmrg $debug_cmd 258514210e8eSmrg 25861fb744b4Smrg save_ifs=$IFS; IFS='~' 25871fb744b4Smrg for cmd in $1; do 258814210e8eSmrg IFS=$sp$nl 25891fb744b4Smrg eval cmd=\"$cmd\" 259014210e8eSmrg IFS=$save_ifs 25911fb744b4Smrg func_show_eval "$cmd" "${2-:}" 2592c35d236eSmrg done 25931fb744b4Smrg IFS=$save_ifs 25941fb744b4Smrg} 2595c35d236eSmrg 2596c35d236eSmrg 25971fb744b4Smrg# func_source file 25981fb744b4Smrg# Source FILE, adding directory component if necessary. 25991fb744b4Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 26001fb744b4Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 26011fb744b4Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260214210e8eSmrg# 'FILE.' does not work on cygwin managed mounts. 26031fb744b4Smrgfunc_source () 26041fb744b4Smrg{ 260514210e8eSmrg $debug_cmd 260614210e8eSmrg 26071fb744b4Smrg case $1 in 26081fb744b4Smrg */* | *\\*) . "$1" ;; 26091fb744b4Smrg *) . "./$1" ;; 26101fb744b4Smrg esac 26111fb744b4Smrg} 2612c35d236eSmrg 2613c35d236eSmrg 26141fb744b4Smrg# func_resolve_sysroot PATH 26151fb744b4Smrg# Replace a leading = in PATH with a sysroot. Store the result into 26161fb744b4Smrg# func_resolve_sysroot_result 26171fb744b4Smrgfunc_resolve_sysroot () 26181fb744b4Smrg{ 26191fb744b4Smrg func_resolve_sysroot_result=$1 26201fb744b4Smrg case $func_resolve_sysroot_result in 26211fb744b4Smrg =*) 26221fb744b4Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 26231fb744b4Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 26241fb744b4Smrg ;; 26251fb744b4Smrg esac 26261fb744b4Smrg} 2627518bcf38Smrg 26281fb744b4Smrg# func_replace_sysroot PATH 26291fb744b4Smrg# If PATH begins with the sysroot, replace it with = and 26301fb744b4Smrg# store the result into func_replace_sysroot_result. 26311fb744b4Smrgfunc_replace_sysroot () 26321fb744b4Smrg{ 263314210e8eSmrg case $lt_sysroot:$1 in 26341fb744b4Smrg ?*:"$lt_sysroot"*) 26351fb744b4Smrg func_stripname "$lt_sysroot" '' "$1" 263614210e8eSmrg func_replace_sysroot_result='='$func_stripname_result 26371fb744b4Smrg ;; 26381fb744b4Smrg *) 26391fb744b4Smrg # Including no sysroot. 26401fb744b4Smrg func_replace_sysroot_result=$1 26411fb744b4Smrg ;; 26421fb744b4Smrg esac 26431fb744b4Smrg} 2644c35d236eSmrg 26451fb744b4Smrg# func_infer_tag arg 26461fb744b4Smrg# Infer tagged configuration to use if any are available and 26471fb744b4Smrg# if one wasn't chosen via the "--tag" command line option. 26481fb744b4Smrg# Only attempt this if the compiler in the base compile 26491fb744b4Smrg# command doesn't match the default compiler. 26501fb744b4Smrg# arg is usually of the form 'gcc ...' 26511fb744b4Smrgfunc_infer_tag () 26521fb744b4Smrg{ 265314210e8eSmrg $debug_cmd 265414210e8eSmrg 26551fb744b4Smrg if test -n "$available_tags" && test -z "$tagname"; then 26561fb744b4Smrg CC_quoted= 26571fb744b4Smrg for arg in $CC; do 26581fb744b4Smrg func_append_quoted CC_quoted "$arg" 26591fb744b4Smrg done 26601fb744b4Smrg CC_expanded=`func_echo_all $CC` 26611fb744b4Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26621fb744b4Smrg case $@ in 26631fb744b4Smrg # Blanks in the command may have been stripped by the calling shell, 26641fb744b4Smrg # but not from the CC environment variable when configure was run. 26651fb744b4Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26661fb744b4Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 26671fb744b4Smrg # Blanks at the start of $base_compile will cause this to fail 26681fb744b4Smrg # if we don't check for them as well. 26691fb744b4Smrg *) 26701fb744b4Smrg for z in $available_tags; do 26711fb744b4Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 26721fb744b4Smrg # Evaluate the configuration. 267314210e8eSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 26741fb744b4Smrg CC_quoted= 26751fb744b4Smrg for arg in $CC; do 26761fb744b4Smrg # Double-quote args containing other shell metacharacters. 26771fb744b4Smrg func_append_quoted CC_quoted "$arg" 26781fb744b4Smrg done 26791fb744b4Smrg CC_expanded=`func_echo_all $CC` 26801fb744b4Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26811fb744b4Smrg case "$@ " in 26821fb744b4Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26831fb744b4Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 26841fb744b4Smrg # The compiler in the base compile command matches 26851fb744b4Smrg # the one in the tagged configuration. 26861fb744b4Smrg # Assume this is the tagged configuration we want. 26871fb744b4Smrg tagname=$z 26881fb744b4Smrg break 26891fb744b4Smrg ;; 26901fb744b4Smrg esac 26911fb744b4Smrg fi 26921fb744b4Smrg done 26931fb744b4Smrg # If $tagname still isn't set, then no tagged configuration 26941fb744b4Smrg # was found and let the user know that the "--tag" command 26951fb744b4Smrg # line option must be used. 26961fb744b4Smrg if test -z "$tagname"; then 26971fb744b4Smrg func_echo "unable to infer tagged configuration" 269814210e8eSmrg func_fatal_error "specify a tag with '--tag'" 26991fb744b4Smrg# else 27001fb744b4Smrg# func_verbose "using $tagname tagged configuration" 27011fb744b4Smrg fi 27021fb744b4Smrg ;; 27031fb744b4Smrg esac 2704c35d236eSmrg fi 27051fb744b4Smrg} 2706c35d236eSmrg 2707c35d236eSmrg 2708c35d236eSmrg 27091fb744b4Smrg# func_write_libtool_object output_name pic_name nonpic_name 27101fb744b4Smrg# Create a libtool object file (analogous to a ".la" file), 27111fb744b4Smrg# but don't create it if we're doing a dry run. 27121fb744b4Smrgfunc_write_libtool_object () 27131fb744b4Smrg{ 271414210e8eSmrg write_libobj=$1 271514210e8eSmrg if test yes = "$build_libtool_libs"; then 271614210e8eSmrg write_lobj=\'$2\' 27171fb744b4Smrg else 27181fb744b4Smrg write_lobj=none 2719c35d236eSmrg fi 2720c35d236eSmrg 272114210e8eSmrg if test yes = "$build_old_libs"; then 272214210e8eSmrg write_oldobj=\'$3\' 27231fb744b4Smrg else 27241fb744b4Smrg write_oldobj=none 2725c35d236eSmrg fi 2726518bcf38Smrg 27271fb744b4Smrg $opt_dry_run || { 27281fb744b4Smrg cat >${write_libobj}T <<EOF 27291fb744b4Smrg# $write_libobj - a libtool object file 273014210e8eSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731518bcf38Smrg# 2732518bcf38Smrg# Please DO NOT delete this file! 2733518bcf38Smrg# It is necessary for linking the library. 2734518bcf38Smrg 2735518bcf38Smrg# Name of the PIC object. 27361fb744b4Smrgpic_object=$write_lobj 2737c35d236eSmrg 27381fb744b4Smrg# Name of the non-PIC object 27391fb744b4Smrgnon_pic_object=$write_oldobj 2740c35d236eSmrg 27411fb744b4SmrgEOF 274214210e8eSmrg $MV "${write_libobj}T" "$write_libobj" 27431fb744b4Smrg } 27441fb744b4Smrg} 2745c35d236eSmrg 2746c35d236eSmrg 27471fb744b4Smrg################################################## 27481fb744b4Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 27491fb744b4Smrg################################################## 2750c35d236eSmrg 27511fb744b4Smrg# func_convert_core_file_wine_to_w32 ARG 27521fb744b4Smrg# Helper function used by file name conversion functions when $build is *nix, 27531fb744b4Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 27541fb744b4Smrg# correctly configured wine environment available, with the winepath program 27551fb744b4Smrg# in $build's $PATH. 27561fb744b4Smrg# 27571fb744b4Smrg# ARG is the $build file name to be converted to w32 format. 27581fb744b4Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 27591fb744b4Smrg# be empty on error (or when ARG is empty) 27601fb744b4Smrgfunc_convert_core_file_wine_to_w32 () 27611fb744b4Smrg{ 276214210e8eSmrg $debug_cmd 276314210e8eSmrg 276414210e8eSmrg func_convert_core_file_wine_to_w32_result=$1 27651fb744b4Smrg if test -n "$1"; then 27661fb744b4Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 27671fb744b4Smrg # are forced to check the contents of stdout. On the other hand, if the 27681fb744b4Smrg # command is not found, the shell will set an exit code of 127 and print 27691fb744b4Smrg # *an error message* to stdout. So we must check for both error code of 27701fb744b4Smrg # zero AND non-empty stdout, which explains the odd construction: 27711fb744b4Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277214210e8eSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 27731fb744b4Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277414210e8eSmrg $SED -e "$sed_naive_backslashify"` 27751fb744b4Smrg else 27761fb744b4Smrg func_convert_core_file_wine_to_w32_result= 27771fb744b4Smrg fi 27781fb744b4Smrg fi 27791fb744b4Smrg} 27801fb744b4Smrg# end: func_convert_core_file_wine_to_w32 2781518bcf38Smrg 27821fb744b4Smrg 27831fb744b4Smrg# func_convert_core_path_wine_to_w32 ARG 27841fb744b4Smrg# Helper function used by path conversion functions when $build is *nix, and 27851fb744b4Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 27861fb744b4Smrg# configured wine environment available, with the winepath program in $build's 27871fb744b4Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 27881fb744b4Smrg# 27891fb744b4Smrg# ARG is path to be converted from $build format to win32. 27901fb744b4Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 27911fb744b4Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 27921fb744b4Smrg# are convertible, then the result may be empty. 27931fb744b4Smrgfunc_convert_core_path_wine_to_w32 () 27941fb744b4Smrg{ 279514210e8eSmrg $debug_cmd 279614210e8eSmrg 27971fb744b4Smrg # unfortunately, winepath doesn't convert paths, only file names 279814210e8eSmrg func_convert_core_path_wine_to_w32_result= 27991fb744b4Smrg if test -n "$1"; then 28001fb744b4Smrg oldIFS=$IFS 28011fb744b4Smrg IFS=: 28021fb744b4Smrg for func_convert_core_path_wine_to_w32_f in $1; do 28031fb744b4Smrg IFS=$oldIFS 28041fb744b4Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280514210e8eSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 28061fb744b4Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280714210e8eSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 28081fb744b4Smrg else 28091fb744b4Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 28101fb744b4Smrg fi 2811518bcf38Smrg fi 28121fb744b4Smrg done 28131fb744b4Smrg IFS=$oldIFS 28141fb744b4Smrg fi 28151fb744b4Smrg} 28161fb744b4Smrg# end: func_convert_core_path_wine_to_w32 28171fb744b4Smrg 28181fb744b4Smrg 28191fb744b4Smrg# func_cygpath ARGS... 28201fb744b4Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 28211fb744b4Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 28221fb744b4Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 28231fb744b4Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 28241fb744b4Smrg# file name or path is assumed to be in w32 format, as previously converted 28251fb744b4Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 28261fb744b4Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 28271fb744b4Smrg# Cygwin format). Returns an empty string on error. 28281fb744b4Smrg# 28291fb744b4Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 28301fb744b4Smrg# be converted. 28311fb744b4Smrg# 28321fb744b4Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 28331fb744b4Smrg# environment variable; do not put it in $PATH. 28341fb744b4Smrgfunc_cygpath () 28351fb744b4Smrg{ 283614210e8eSmrg $debug_cmd 283714210e8eSmrg 28381fb744b4Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 28391fb744b4Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 28401fb744b4Smrg if test "$?" -ne 0; then 28411fb744b4Smrg # on failure, ensure result is empty 28421fb744b4Smrg func_cygpath_result= 28431fb744b4Smrg fi 28441fb744b4Smrg else 28451fb744b4Smrg func_cygpath_result= 284614210e8eSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 28471fb744b4Smrg fi 28481fb744b4Smrg} 28491fb744b4Smrg#end: func_cygpath 2850c35d236eSmrg 2851c35d236eSmrg 28521fb744b4Smrg# func_convert_core_msys_to_w32 ARG 28531fb744b4Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 28541fb744b4Smrg# result in func_convert_core_msys_to_w32_result. 28551fb744b4Smrgfunc_convert_core_msys_to_w32 () 28561fb744b4Smrg{ 285714210e8eSmrg $debug_cmd 285814210e8eSmrg 28591fb744b4Smrg # awkward: cmd appends spaces to result 28601fb744b4Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286114210e8eSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 28621fb744b4Smrg} 28631fb744b4Smrg#end: func_convert_core_msys_to_w32 2864c35d236eSmrg 2865c35d236eSmrg 28661fb744b4Smrg# func_convert_file_check ARG1 ARG2 28671fb744b4Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 28681fb744b4Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 28691fb744b4Smrg# func_to_host_file_result to ARG1). 28701fb744b4Smrgfunc_convert_file_check () 28711fb744b4Smrg{ 287214210e8eSmrg $debug_cmd 287314210e8eSmrg 287414210e8eSmrg if test -z "$2" && test -n "$1"; then 28751fb744b4Smrg func_error "Could not determine host file name corresponding to" 287614210e8eSmrg func_error " '$1'" 28771fb744b4Smrg func_error "Continuing, but uninstalled executables may not work." 28781fb744b4Smrg # Fallback: 287914210e8eSmrg func_to_host_file_result=$1 28801fb744b4Smrg fi 28811fb744b4Smrg} 28821fb744b4Smrg# end func_convert_file_check 2883c35d236eSmrg 2884c35d236eSmrg 28851fb744b4Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 28861fb744b4Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 28871fb744b4Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 28881fb744b4Smrg# func_to_host_file_result to a simplistic fallback value (see below). 28891fb744b4Smrgfunc_convert_path_check () 28901fb744b4Smrg{ 289114210e8eSmrg $debug_cmd 289214210e8eSmrg 28931fb744b4Smrg if test -z "$4" && test -n "$3"; then 28941fb744b4Smrg func_error "Could not determine the host path corresponding to" 289514210e8eSmrg func_error " '$3'" 28961fb744b4Smrg func_error "Continuing, but uninstalled executables may not work." 28971fb744b4Smrg # Fallback. This is a deliberately simplistic "conversion" and 28981fb744b4Smrg # should not be "improved". See libtool.info. 28991fb744b4Smrg if test "x$1" != "x$2"; then 29001fb744b4Smrg lt_replace_pathsep_chars="s|$1|$2|g" 29011fb744b4Smrg func_to_host_path_result=`echo "$3" | 29021fb744b4Smrg $SED -e "$lt_replace_pathsep_chars"` 29031fb744b4Smrg else 290414210e8eSmrg func_to_host_path_result=$3 29051fb744b4Smrg fi 29061fb744b4Smrg fi 29071fb744b4Smrg} 29081fb744b4Smrg# end func_convert_path_check 2909518bcf38Smrg 2910518bcf38Smrg 29111fb744b4Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 29121fb744b4Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 29131fb744b4Smrg# and appending REPL if ORIG matches BACKPAT. 29141fb744b4Smrgfunc_convert_path_front_back_pathsep () 29151fb744b4Smrg{ 291614210e8eSmrg $debug_cmd 291714210e8eSmrg 29181fb744b4Smrg case $4 in 291914210e8eSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 29201fb744b4Smrg ;; 29211fb744b4Smrg esac 29221fb744b4Smrg case $4 in 29231fb744b4Smrg $2 ) func_append func_to_host_path_result "$3" 29241fb744b4Smrg ;; 29251fb744b4Smrg esac 29261fb744b4Smrg} 29271fb744b4Smrg# end func_convert_path_front_back_pathsep 2928518bcf38Smrg 2929c35d236eSmrg 29301fb744b4Smrg################################################## 29311fb744b4Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 29321fb744b4Smrg################################################## 293314210e8eSmrg# invoked via '$to_host_file_cmd ARG' 29341fb744b4Smrg# 29351fb744b4Smrg# In each case, ARG is the path to be converted from $build to $host format. 29361fb744b4Smrg# Result will be available in $func_to_host_file_result. 2937c35d236eSmrg 2938c35d236eSmrg 29391fb744b4Smrg# func_to_host_file ARG 29401fb744b4Smrg# Converts the file name ARG from $build format to $host format. Return result 29411fb744b4Smrg# in func_to_host_file_result. 29421fb744b4Smrgfunc_to_host_file () 29431fb744b4Smrg{ 294414210e8eSmrg $debug_cmd 294514210e8eSmrg 29461fb744b4Smrg $to_host_file_cmd "$1" 29471fb744b4Smrg} 29481fb744b4Smrg# end func_to_host_file 2949c35d236eSmrg 2950c35d236eSmrg 29511fb744b4Smrg# func_to_tool_file ARG LAZY 29521fb744b4Smrg# converts the file name ARG from $build format to toolchain format. Return 29531fb744b4Smrg# result in func_to_tool_file_result. If the conversion in use is listed 29541fb744b4Smrg# in (the comma separated) LAZY, no conversion takes place. 29551fb744b4Smrgfunc_to_tool_file () 29561fb744b4Smrg{ 295714210e8eSmrg $debug_cmd 295814210e8eSmrg 29591fb744b4Smrg case ,$2, in 29601fb744b4Smrg *,"$to_tool_file_cmd",*) 29611fb744b4Smrg func_to_tool_file_result=$1 29621fb744b4Smrg ;; 29631fb744b4Smrg *) 29641fb744b4Smrg $to_tool_file_cmd "$1" 29651fb744b4Smrg func_to_tool_file_result=$func_to_host_file_result 29661fb744b4Smrg ;; 29671fb744b4Smrg esac 29681fb744b4Smrg} 29691fb744b4Smrg# end func_to_tool_file 2970c35d236eSmrg 2971c35d236eSmrg 29721fb744b4Smrg# func_convert_file_noop ARG 29731fb744b4Smrg# Copy ARG to func_to_host_file_result. 29741fb744b4Smrgfunc_convert_file_noop () 29751fb744b4Smrg{ 297614210e8eSmrg func_to_host_file_result=$1 29771fb744b4Smrg} 29781fb744b4Smrg# end func_convert_file_noop 2979518bcf38Smrg 2980518bcf38Smrg 29811fb744b4Smrg# func_convert_file_msys_to_w32 ARG 29821fb744b4Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 29831fb744b4Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 29841fb744b4Smrg# func_to_host_file_result. 29851fb744b4Smrgfunc_convert_file_msys_to_w32 () 29861fb744b4Smrg{ 298714210e8eSmrg $debug_cmd 298814210e8eSmrg 298914210e8eSmrg func_to_host_file_result=$1 29901fb744b4Smrg if test -n "$1"; then 29911fb744b4Smrg func_convert_core_msys_to_w32 "$1" 299214210e8eSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 29931fb744b4Smrg fi 29941fb744b4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 29951fb744b4Smrg} 29961fb744b4Smrg# end func_convert_file_msys_to_w32 2997518bcf38Smrg 2998c35d236eSmrg 29991fb744b4Smrg# func_convert_file_cygwin_to_w32 ARG 30001fb744b4Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 30011fb744b4Smrg# func_to_host_file_result. 30021fb744b4Smrgfunc_convert_file_cygwin_to_w32 () 30031fb744b4Smrg{ 300414210e8eSmrg $debug_cmd 300514210e8eSmrg 300614210e8eSmrg func_to_host_file_result=$1 30071fb744b4Smrg if test -n "$1"; then 30081fb744b4Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 30091fb744b4Smrg # LT_CYGPATH in this case. 30101fb744b4Smrg func_to_host_file_result=`cygpath -m "$1"` 30111fb744b4Smrg fi 30121fb744b4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30131fb744b4Smrg} 30141fb744b4Smrg# end func_convert_file_cygwin_to_w32 3015c35d236eSmrg 3016c35d236eSmrg 30171fb744b4Smrg# func_convert_file_nix_to_w32 ARG 30181fb744b4Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 30191fb744b4Smrg# and a working winepath. Returns result in func_to_host_file_result. 30201fb744b4Smrgfunc_convert_file_nix_to_w32 () 30211fb744b4Smrg{ 302214210e8eSmrg $debug_cmd 302314210e8eSmrg 302414210e8eSmrg func_to_host_file_result=$1 30251fb744b4Smrg if test -n "$1"; then 30261fb744b4Smrg func_convert_core_file_wine_to_w32 "$1" 302714210e8eSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 30281fb744b4Smrg fi 30291fb744b4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30301fb744b4Smrg} 30311fb744b4Smrg# end func_convert_file_nix_to_w32 3032c35d236eSmrg 3033c35d236eSmrg 30341fb744b4Smrg# func_convert_file_msys_to_cygwin ARG 30351fb744b4Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 30361fb744b4Smrg# Returns result in func_to_host_file_result. 30371fb744b4Smrgfunc_convert_file_msys_to_cygwin () 30381fb744b4Smrg{ 303914210e8eSmrg $debug_cmd 304014210e8eSmrg 304114210e8eSmrg func_to_host_file_result=$1 30421fb744b4Smrg if test -n "$1"; then 30431fb744b4Smrg func_convert_core_msys_to_w32 "$1" 30441fb744b4Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304514210e8eSmrg func_to_host_file_result=$func_cygpath_result 30461fb744b4Smrg fi 30471fb744b4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30481fb744b4Smrg} 30491fb744b4Smrg# end func_convert_file_msys_to_cygwin 3050c35d236eSmrg 3051c35d236eSmrg 30521fb744b4Smrg# func_convert_file_nix_to_cygwin ARG 30531fb744b4Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 30541fb744b4Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 30551fb744b4Smrg# in func_to_host_file_result. 30561fb744b4Smrgfunc_convert_file_nix_to_cygwin () 30571fb744b4Smrg{ 305814210e8eSmrg $debug_cmd 305914210e8eSmrg 306014210e8eSmrg func_to_host_file_result=$1 30611fb744b4Smrg if test -n "$1"; then 30621fb744b4Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 30631fb744b4Smrg func_convert_core_file_wine_to_w32 "$1" 30641fb744b4Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306514210e8eSmrg func_to_host_file_result=$func_cygpath_result 30661fb744b4Smrg fi 30671fb744b4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30681fb744b4Smrg} 30691fb744b4Smrg# end func_convert_file_nix_to_cygwin 3070c35d236eSmrg 3071c35d236eSmrg 30721fb744b4Smrg############################################# 30731fb744b4Smrg# $build to $host PATH CONVERSION FUNCTIONS # 30741fb744b4Smrg############################################# 307514210e8eSmrg# invoked via '$to_host_path_cmd ARG' 30761fb744b4Smrg# 30771fb744b4Smrg# In each case, ARG is the path to be converted from $build to $host format. 30781fb744b4Smrg# The result will be available in $func_to_host_path_result. 30791fb744b4Smrg# 30801fb744b4Smrg# Path separators are also converted from $build format to $host format. If 30811fb744b4Smrg# ARG begins or ends with a path separator character, it is preserved (but 30821fb744b4Smrg# converted to $host format) on output. 30831fb744b4Smrg# 30841fb744b4Smrg# All path conversion functions are named using the following convention: 30851fb744b4Smrg# file name conversion function : func_convert_file_X_to_Y () 30861fb744b4Smrg# path conversion function : func_convert_path_X_to_Y () 30871fb744b4Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 30881fb744b4Smrg# same. If conversion functions are added for new $build/$host combinations, 30891fb744b4Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 30901fb744b4Smrg# will break. 30911fb744b4Smrg 30921fb744b4Smrg 30931fb744b4Smrg# func_init_to_host_path_cmd 30941fb744b4Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 30951fb744b4Smrg# appropriate value, based on the value of $to_host_file_cmd. 30961fb744b4Smrgto_host_path_cmd= 30971fb744b4Smrgfunc_init_to_host_path_cmd () 30981fb744b4Smrg{ 309914210e8eSmrg $debug_cmd 310014210e8eSmrg 31011fb744b4Smrg if test -z "$to_host_path_cmd"; then 31021fb744b4Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310314210e8eSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 31041fb744b4Smrg fi 31051fb744b4Smrg} 3106c35d236eSmrg 3107c35d236eSmrg 31081fb744b4Smrg# func_to_host_path ARG 31091fb744b4Smrg# Converts the path ARG from $build format to $host format. Return result 31101fb744b4Smrg# in func_to_host_path_result. 31111fb744b4Smrgfunc_to_host_path () 31121fb744b4Smrg{ 311314210e8eSmrg $debug_cmd 311414210e8eSmrg 31151fb744b4Smrg func_init_to_host_path_cmd 31161fb744b4Smrg $to_host_path_cmd "$1" 31171fb744b4Smrg} 31181fb744b4Smrg# end func_to_host_path 3119c35d236eSmrg 3120c35d236eSmrg 31211fb744b4Smrg# func_convert_path_noop ARG 31221fb744b4Smrg# Copy ARG to func_to_host_path_result. 31231fb744b4Smrgfunc_convert_path_noop () 31241fb744b4Smrg{ 312514210e8eSmrg func_to_host_path_result=$1 31261fb744b4Smrg} 31271fb744b4Smrg# end func_convert_path_noop 3128c35d236eSmrg 3129c35d236eSmrg 31301fb744b4Smrg# func_convert_path_msys_to_w32 ARG 31311fb744b4Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 31321fb744b4Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 31331fb744b4Smrg# func_to_host_path_result. 31341fb744b4Smrgfunc_convert_path_msys_to_w32 () 31351fb744b4Smrg{ 313614210e8eSmrg $debug_cmd 313714210e8eSmrg 313814210e8eSmrg func_to_host_path_result=$1 31391fb744b4Smrg if test -n "$1"; then 31401fb744b4Smrg # Remove leading and trailing path separator characters from ARG. MSYS 31411fb744b4Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 31421fb744b4Smrg # and winepath ignores them completely. 31431fb744b4Smrg func_stripname : : "$1" 31441fb744b4Smrg func_to_host_path_tmp1=$func_stripname_result 31451fb744b4Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314614210e8eSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 31471fb744b4Smrg func_convert_path_check : ";" \ 31481fb744b4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31491fb744b4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31501fb744b4Smrg fi 31511fb744b4Smrg} 31521fb744b4Smrg# end func_convert_path_msys_to_w32 3153c35d236eSmrg 3154c35d236eSmrg 31551fb744b4Smrg# func_convert_path_cygwin_to_w32 ARG 31561fb744b4Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 31571fb744b4Smrg# func_to_host_file_result. 31581fb744b4Smrgfunc_convert_path_cygwin_to_w32 () 31591fb744b4Smrg{ 316014210e8eSmrg $debug_cmd 316114210e8eSmrg 316214210e8eSmrg func_to_host_path_result=$1 31631fb744b4Smrg if test -n "$1"; then 31641fb744b4Smrg # See func_convert_path_msys_to_w32: 31651fb744b4Smrg func_stripname : : "$1" 31661fb744b4Smrg func_to_host_path_tmp1=$func_stripname_result 31671fb744b4Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 31681fb744b4Smrg func_convert_path_check : ";" \ 31691fb744b4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31701fb744b4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31711fb744b4Smrg fi 31721fb744b4Smrg} 31731fb744b4Smrg# end func_convert_path_cygwin_to_w32 3174c35d236eSmrg 3175c35d236eSmrg 31761fb744b4Smrg# func_convert_path_nix_to_w32 ARG 31771fb744b4Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 31781fb744b4Smrg# a working winepath. Returns result in func_to_host_file_result. 31791fb744b4Smrgfunc_convert_path_nix_to_w32 () 31801fb744b4Smrg{ 318114210e8eSmrg $debug_cmd 318214210e8eSmrg 318314210e8eSmrg func_to_host_path_result=$1 31841fb744b4Smrg if test -n "$1"; then 31851fb744b4Smrg # See func_convert_path_msys_to_w32: 31861fb744b4Smrg func_stripname : : "$1" 31871fb744b4Smrg func_to_host_path_tmp1=$func_stripname_result 31881fb744b4Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318914210e8eSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 31901fb744b4Smrg func_convert_path_check : ";" \ 31911fb744b4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31921fb744b4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31931fb744b4Smrg fi 31941fb744b4Smrg} 31951fb744b4Smrg# end func_convert_path_nix_to_w32 3196c35d236eSmrg 3197c35d236eSmrg 31981fb744b4Smrg# func_convert_path_msys_to_cygwin ARG 31991fb744b4Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32001fb744b4Smrg# Returns result in func_to_host_file_result. 32011fb744b4Smrgfunc_convert_path_msys_to_cygwin () 32021fb744b4Smrg{ 320314210e8eSmrg $debug_cmd 320414210e8eSmrg 320514210e8eSmrg func_to_host_path_result=$1 32061fb744b4Smrg if test -n "$1"; then 32071fb744b4Smrg # See func_convert_path_msys_to_w32: 32081fb744b4Smrg func_stripname : : "$1" 32091fb744b4Smrg func_to_host_path_tmp1=$func_stripname_result 32101fb744b4Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 32111fb744b4Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321214210e8eSmrg func_to_host_path_result=$func_cygpath_result 32131fb744b4Smrg func_convert_path_check : : \ 32141fb744b4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32151fb744b4Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32161fb744b4Smrg fi 32171fb744b4Smrg} 32181fb744b4Smrg# end func_convert_path_msys_to_cygwin 3219c35d236eSmrg 3220c35d236eSmrg 32211fb744b4Smrg# func_convert_path_nix_to_cygwin ARG 32221fb744b4Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 32231fb744b4Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 32241fb744b4Smrg# func_to_host_file_result. 32251fb744b4Smrgfunc_convert_path_nix_to_cygwin () 32261fb744b4Smrg{ 322714210e8eSmrg $debug_cmd 322814210e8eSmrg 322914210e8eSmrg func_to_host_path_result=$1 32301fb744b4Smrg if test -n "$1"; then 32311fb744b4Smrg # Remove leading and trailing path separator characters from 32321fb744b4Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 32331fb744b4Smrg # into '.;' and ';.', and winepath ignores them completely. 32341fb744b4Smrg func_stripname : : "$1" 32351fb744b4Smrg func_to_host_path_tmp1=$func_stripname_result 32361fb744b4Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 32371fb744b4Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323814210e8eSmrg func_to_host_path_result=$func_cygpath_result 32391fb744b4Smrg func_convert_path_check : : \ 32401fb744b4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32411fb744b4Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32421fb744b4Smrg fi 32431fb744b4Smrg} 32441fb744b4Smrg# end func_convert_path_nix_to_cygwin 3245c35d236eSmrg 3246c35d236eSmrg 324714210e8eSmrg# func_dll_def_p FILE 324814210e8eSmrg# True iff FILE is a Windows DLL '.def' file. 324914210e8eSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325014210e8eSmrgfunc_dll_def_p () 325114210e8eSmrg{ 325214210e8eSmrg $debug_cmd 325314210e8eSmrg 325414210e8eSmrg func_dll_def_p_tmp=`$SED -n \ 325514210e8eSmrg -e 's/^[ ]*//' \ 325614210e8eSmrg -e '/^\(;.*\)*$/d' \ 325714210e8eSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325814210e8eSmrg -e q \ 325914210e8eSmrg "$1"` 326014210e8eSmrg test DEF = "$func_dll_def_p_tmp" 326114210e8eSmrg} 326214210e8eSmrg 326314210e8eSmrg 32641fb744b4Smrg# func_mode_compile arg... 32651fb744b4Smrgfunc_mode_compile () 32661fb744b4Smrg{ 326714210e8eSmrg $debug_cmd 326814210e8eSmrg 32691fb744b4Smrg # Get the compilation command and the source file. 32701fb744b4Smrg base_compile= 327114210e8eSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 32721fb744b4Smrg suppress_opt=yes 32731fb744b4Smrg suppress_output= 32741fb744b4Smrg arg_mode=normal 32751fb744b4Smrg libobj= 32761fb744b4Smrg later= 32771fb744b4Smrg pie_flag= 32781fb744b4Smrg 32791fb744b4Smrg for arg 32801fb744b4Smrg do 32811fb744b4Smrg case $arg_mode in 32821fb744b4Smrg arg ) 32831fb744b4Smrg # do not "continue". Instead, add this to base_compile 328414210e8eSmrg lastarg=$arg 32851fb744b4Smrg arg_mode=normal 32861fb744b4Smrg ;; 32871fb744b4Smrg 32881fb744b4Smrg target ) 328914210e8eSmrg libobj=$arg 32901fb744b4Smrg arg_mode=normal 32911fb744b4Smrg continue 32921fb744b4Smrg ;; 32931fb744b4Smrg 32941fb744b4Smrg normal ) 32951fb744b4Smrg # Accept any command-line options. 32961fb744b4Smrg case $arg in 32971fb744b4Smrg -o) 32981fb744b4Smrg test -n "$libobj" && \ 329914210e8eSmrg func_fatal_error "you cannot specify '-o' more than once" 33001fb744b4Smrg arg_mode=target 3301518bcf38Smrg continue 3302518bcf38Smrg ;; 33031fb744b4Smrg 33041fb744b4Smrg -pie | -fpie | -fPIE) 33051fb744b4Smrg func_append pie_flag " $arg" 3306518bcf38Smrg continue 3307518bcf38Smrg ;; 33081fb744b4Smrg 33091fb744b4Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 33101fb744b4Smrg func_append later " $arg" 3311518bcf38Smrg continue 3312518bcf38Smrg ;; 33131fb744b4Smrg 33141fb744b4Smrg -no-suppress) 33151fb744b4Smrg suppress_opt=no 3316518bcf38Smrg continue 3317518bcf38Smrg ;; 3318c35d236eSmrg 33191fb744b4Smrg -Xcompiler) 33201fb744b4Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 33211fb744b4Smrg continue # The current "srcfile" will either be retained or 33221fb744b4Smrg ;; # replaced later. I would guess that would be a bug. 3323c35d236eSmrg 33241fb744b4Smrg -Wc,*) 33251fb744b4Smrg func_stripname '-Wc,' '' "$arg" 33261fb744b4Smrg args=$func_stripname_result 33271fb744b4Smrg lastarg= 332814210e8eSmrg save_ifs=$IFS; IFS=, 33291fb744b4Smrg for arg in $args; do 333014210e8eSmrg IFS=$save_ifs 33311fb744b4Smrg func_append_quoted lastarg "$arg" 33321fb744b4Smrg done 333314210e8eSmrg IFS=$save_ifs 33341fb744b4Smrg func_stripname ' ' '' "$lastarg" 33351fb744b4Smrg lastarg=$func_stripname_result 3336c35d236eSmrg 33371fb744b4Smrg # Add the arguments to base_compile. 33381fb744b4Smrg func_append base_compile " $lastarg" 33391fb744b4Smrg continue 33401fb744b4Smrg ;; 3341c35d236eSmrg 33421fb744b4Smrg *) 33431fb744b4Smrg # Accept the current argument as the source file. 33441fb744b4Smrg # The previous "srcfile" becomes the current argument. 33451fb744b4Smrg # 334614210e8eSmrg lastarg=$srcfile 334714210e8eSmrg srcfile=$arg 33481fb744b4Smrg ;; 33491fb744b4Smrg esac # case $arg 3350518bcf38Smrg ;; 33511fb744b4Smrg esac # case $arg_mode 3352c35d236eSmrg 33531fb744b4Smrg # Aesthetically quote the previous argument. 33541fb744b4Smrg func_append_quoted base_compile "$lastarg" 33551fb744b4Smrg done # for arg 3356c35d236eSmrg 33571fb744b4Smrg case $arg_mode in 33581fb744b4Smrg arg) 33591fb744b4Smrg func_fatal_error "you must specify an argument for -Xcompile" 33601fb744b4Smrg ;; 33611fb744b4Smrg target) 336214210e8eSmrg func_fatal_error "you must specify a target with '-o'" 33631fb744b4Smrg ;; 33641fb744b4Smrg *) 33651fb744b4Smrg # Get the name of the library object. 33661fb744b4Smrg test -z "$libobj" && { 33671fb744b4Smrg func_basename "$srcfile" 336814210e8eSmrg libobj=$func_basename_result 33691fb744b4Smrg } 33701fb744b4Smrg ;; 33711fb744b4Smrg esac 3372c35d236eSmrg 33731fb744b4Smrg # Recognize several different file suffixes. 33741fb744b4Smrg # If the user specifies -o file.o, it is replaced with file.lo 33751fb744b4Smrg case $libobj in 33761fb744b4Smrg *.[cCFSifmso] | \ 33771fb744b4Smrg *.ada | *.adb | *.ads | *.asm | \ 33781fb744b4Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 33791fb744b4Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 33801fb744b4Smrg func_xform "$libobj" 33811fb744b4Smrg libobj=$func_xform_result 33821fb744b4Smrg ;; 33831fb744b4Smrg esac 3384c35d236eSmrg 33851fb744b4Smrg case $libobj in 33861fb744b4Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 33871fb744b4Smrg *) 338814210e8eSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 33891fb744b4Smrg ;; 33901fb744b4Smrg esac 3391c35d236eSmrg 33921fb744b4Smrg func_infer_tag $base_compile 3393c35d236eSmrg 33941fb744b4Smrg for arg in $later; do 33951fb744b4Smrg case $arg in 33961fb744b4Smrg -shared) 339714210e8eSmrg test yes = "$build_libtool_libs" \ 339814210e8eSmrg || func_fatal_configuration "cannot build a shared library" 33991fb744b4Smrg build_old_libs=no 3400518bcf38Smrg continue 3401518bcf38Smrg ;; 3402c35d236eSmrg 34031fb744b4Smrg -static) 34041fb744b4Smrg build_libtool_libs=no 34051fb744b4Smrg build_old_libs=yes 3406518bcf38Smrg continue 3407518bcf38Smrg ;; 3408c35d236eSmrg 34091fb744b4Smrg -prefer-pic) 34101fb744b4Smrg pic_mode=yes 3411518bcf38Smrg continue 3412518bcf38Smrg ;; 3413c35d236eSmrg 34141fb744b4Smrg -prefer-non-pic) 34151fb744b4Smrg pic_mode=no 3416518bcf38Smrg continue 3417c35d236eSmrg ;; 34181fb744b4Smrg esac 34191fb744b4Smrg done 3420c35d236eSmrg 34211fb744b4Smrg func_quote_for_eval "$libobj" 34221fb744b4Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 34231fb744b4Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342414210e8eSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 34251fb744b4Smrg func_dirname_and_basename "$obj" "/" "" 342614210e8eSmrg objname=$func_basename_result 342714210e8eSmrg xdir=$func_dirname_result 342814210e8eSmrg lobj=$xdir$objdir/$objname 3429c35d236eSmrg 34301fb744b4Smrg test -z "$base_compile" && \ 34311fb744b4Smrg func_fatal_help "you must specify a compilation command" 3432c35d236eSmrg 34331fb744b4Smrg # Delete any leftover library objects. 343414210e8eSmrg if test yes = "$build_old_libs"; then 34351fb744b4Smrg removelist="$obj $lobj $libobj ${libobj}T" 34361fb744b4Smrg else 34371fb744b4Smrg removelist="$lobj $libobj ${libobj}T" 34381fb744b4Smrg fi 3439c35d236eSmrg 34401fb744b4Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 34411fb744b4Smrg case $host_os in 34421fb744b4Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 34431fb744b4Smrg pic_mode=default 34441fb744b4Smrg ;; 34451fb744b4Smrg esac 344614210e8eSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 34471fb744b4Smrg # non-PIC code in shared libraries is not supported 34481fb744b4Smrg pic_mode=default 34491fb744b4Smrg fi 3450c35d236eSmrg 34511fb744b4Smrg # Calculate the filename of the output object if compiler does 34521fb744b4Smrg # not support -o with -c 345314210e8eSmrg if test no = "$compiler_c_o"; then 345414210e8eSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345514210e8eSmrg lockfile=$output_obj.lock 34561fb744b4Smrg else 34571fb744b4Smrg output_obj= 34581fb744b4Smrg need_locks=no 34591fb744b4Smrg lockfile= 34601fb744b4Smrg fi 3461c35d236eSmrg 34621fb744b4Smrg # Lock this critical section if it is needed 34631fb744b4Smrg # We use this script file to make the link, it avoids creating a new file 346414210e8eSmrg if test yes = "$need_locks"; then 34651fb744b4Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 34661fb744b4Smrg func_echo "Waiting for $lockfile to be removed" 34671fb744b4Smrg sleep 2 34681fb744b4Smrg done 346914210e8eSmrg elif test warn = "$need_locks"; then 34701fb744b4Smrg if test -f "$lockfile"; then 34711fb744b4Smrg $ECHO "\ 34721fb744b4Smrg*** ERROR, $lockfile exists and contains: 34731fb744b4Smrg`cat $lockfile 2>/dev/null` 3474c35d236eSmrg 34751fb744b4SmrgThis indicates that another process is trying to use the same 34761fb744b4Smrgtemporary object file, and libtool could not work around it because 347714210e8eSmrgyour compiler does not support '-c' and '-o' together. If you 34781fb744b4Smrgrepeat this compilation, it may succeed, by chance, but you had better 34791fb744b4Smrgavoid parallel builds (make -j) in this platform, or get a better 34801fb744b4Smrgcompiler." 3481c35d236eSmrg 34821fb744b4Smrg $opt_dry_run || $RM $removelist 34831fb744b4Smrg exit $EXIT_FAILURE 34841fb744b4Smrg fi 34851fb744b4Smrg func_append removelist " $output_obj" 34861fb744b4Smrg $ECHO "$srcfile" > "$lockfile" 34871fb744b4Smrg fi 3488c35d236eSmrg 34891fb744b4Smrg $opt_dry_run || $RM $removelist 34901fb744b4Smrg func_append removelist " $lockfile" 34911fb744b4Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492c35d236eSmrg 34931fb744b4Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 34941fb744b4Smrg srcfile=$func_to_tool_file_result 34951fb744b4Smrg func_quote_for_eval "$srcfile" 34961fb744b4Smrg qsrcfile=$func_quote_for_eval_result 3497c35d236eSmrg 34981fb744b4Smrg # Only build a PIC object if we are building libtool libraries. 349914210e8eSmrg if test yes = "$build_libtool_libs"; then 35001fb744b4Smrg # Without this assignment, base_compile gets emptied. 35011fb744b4Smrg fbsd_hideous_sh_bug=$base_compile 3502c35d236eSmrg 350314210e8eSmrg if test no != "$pic_mode"; then 35041fb744b4Smrg command="$base_compile $qsrcfile $pic_flag" 35051fb744b4Smrg else 35061fb744b4Smrg # Don't build PIC code 35071fb744b4Smrg command="$base_compile $qsrcfile" 35081fb744b4Smrg fi 3509c35d236eSmrg 35101fb744b4Smrg func_mkdir_p "$xdir$objdir" 3511c35d236eSmrg 35121fb744b4Smrg if test -z "$output_obj"; then 35131fb744b4Smrg # Place PIC objects in $objdir 35141fb744b4Smrg func_append command " -o $lobj" 35151fb744b4Smrg fi 3516c35d236eSmrg 35171fb744b4Smrg func_show_eval_locale "$command" \ 35181fb744b4Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519c35d236eSmrg 352014210e8eSmrg if test warn = "$need_locks" && 35211fb744b4Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35221fb744b4Smrg $ECHO "\ 35231fb744b4Smrg*** ERROR, $lockfile contains: 35241fb744b4Smrg`cat $lockfile 2>/dev/null` 3525518bcf38Smrg 35261fb744b4Smrgbut it should contain: 35271fb744b4Smrg$srcfile 3528518bcf38Smrg 35291fb744b4SmrgThis indicates that another process is trying to use the same 35301fb744b4Smrgtemporary object file, and libtool could not work around it because 353114210e8eSmrgyour compiler does not support '-c' and '-o' together. If you 35321fb744b4Smrgrepeat this compilation, it may succeed, by chance, but you had better 35331fb744b4Smrgavoid parallel builds (make -j) in this platform, or get a better 35341fb744b4Smrgcompiler." 3535c35d236eSmrg 35361fb744b4Smrg $opt_dry_run || $RM $removelist 35371fb744b4Smrg exit $EXIT_FAILURE 35381fb744b4Smrg fi 3539c35d236eSmrg 35401fb744b4Smrg # Just move the object if needed, then go on to compile the next one 35411fb744b4Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 35421fb744b4Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 35431fb744b4Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 35441fb744b4Smrg fi 3545c35d236eSmrg 35461fb744b4Smrg # Allow error messages only from the first compilation. 354714210e8eSmrg if test yes = "$suppress_opt"; then 35481fb744b4Smrg suppress_output=' >/dev/null 2>&1' 35491fb744b4Smrg fi 35501fb744b4Smrg fi 3551c35d236eSmrg 35521fb744b4Smrg # Only build a position-dependent object if we build old libraries. 355314210e8eSmrg if test yes = "$build_old_libs"; then 355414210e8eSmrg if test yes != "$pic_mode"; then 35551fb744b4Smrg # Don't build PIC code 35561fb744b4Smrg command="$base_compile $qsrcfile$pie_flag" 35571fb744b4Smrg else 35581fb744b4Smrg command="$base_compile $qsrcfile $pic_flag" 35591fb744b4Smrg fi 356014210e8eSmrg if test yes = "$compiler_c_o"; then 35611fb744b4Smrg func_append command " -o $obj" 35621fb744b4Smrg fi 3563c35d236eSmrg 35641fb744b4Smrg # Suppress compiler output if we already did a PIC compilation. 35651fb744b4Smrg func_append command "$suppress_output" 35661fb744b4Smrg func_show_eval_locale "$command" \ 35671fb744b4Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568c35d236eSmrg 356914210e8eSmrg if test warn = "$need_locks" && 35701fb744b4Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35711fb744b4Smrg $ECHO "\ 35721fb744b4Smrg*** ERROR, $lockfile contains: 35731fb744b4Smrg`cat $lockfile 2>/dev/null` 3574c35d236eSmrg 35751fb744b4Smrgbut it should contain: 35761fb744b4Smrg$srcfile 3577f55e6a01Smrg 35781fb744b4SmrgThis indicates that another process is trying to use the same 35791fb744b4Smrgtemporary object file, and libtool could not work around it because 358014210e8eSmrgyour compiler does not support '-c' and '-o' together. If you 35811fb744b4Smrgrepeat this compilation, it may succeed, by chance, but you had better 35821fb744b4Smrgavoid parallel builds (make -j) in this platform, or get a better 35831fb744b4Smrgcompiler." 3584f55e6a01Smrg 35851fb744b4Smrg $opt_dry_run || $RM $removelist 35861fb744b4Smrg exit $EXIT_FAILURE 35871fb744b4Smrg fi 3588f55e6a01Smrg 35891fb744b4Smrg # Just move the object if needed 35901fb744b4Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 35911fb744b4Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 35921fb744b4Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 35931fb744b4Smrg fi 35941fb744b4Smrg fi 3595f55e6a01Smrg 35961fb744b4Smrg $opt_dry_run || { 35971fb744b4Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598f55e6a01Smrg 35991fb744b4Smrg # Unlock the critical section if it was locked 360014210e8eSmrg if test no != "$need_locks"; then 36011fb744b4Smrg removelist=$lockfile 36021fb744b4Smrg $RM "$lockfile" 36031fb744b4Smrg fi 36041fb744b4Smrg } 3605f55e6a01Smrg 36061fb744b4Smrg exit $EXIT_SUCCESS 36071fb744b4Smrg} 3608f55e6a01Smrg 36091fb744b4Smrg$opt_help || { 361014210e8eSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 36111fb744b4Smrg} 3612f55e6a01Smrg 36131fb744b4Smrgfunc_mode_help () 36141fb744b4Smrg{ 36151fb744b4Smrg # We need to display help for each of the modes. 36161fb744b4Smrg case $opt_mode in 36171fb744b4Smrg "") 36181fb744b4Smrg # Generic help is extracted from the usage comments 36191fb744b4Smrg # at the start of this file. 36201fb744b4Smrg func_help 36211fb744b4Smrg ;; 3622f55e6a01Smrg 36231fb744b4Smrg clean) 36241fb744b4Smrg $ECHO \ 36251fb744b4Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626f55e6a01Smrg 36271fb744b4SmrgRemove files from the build directory. 3628518bcf38Smrg 36291fb744b4SmrgRM is the name of the program to use to delete files associated with each FILE 363014210e8eSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 36311fb744b4Smrgto RM. 3632f55e6a01Smrg 36331fb744b4SmrgIf FILE is a libtool library, object or program, all the files associated 36341fb744b4Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 36351fb744b4Smrg ;; 3636f55e6a01Smrg 36371fb744b4Smrg compile) 36381fb744b4Smrg $ECHO \ 36391fb744b4Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640f55e6a01Smrg 36411fb744b4SmrgCompile a source file into a libtool library object. 3642f55e6a01Smrg 36431fb744b4SmrgThis mode accepts the following additional options: 3644f55e6a01Smrg 36451fb744b4Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 36461fb744b4Smrg -no-suppress do not suppress compiler output for multiple passes 36471fb744b4Smrg -prefer-pic try to build PIC objects only 36481fb744b4Smrg -prefer-non-pic try to build non-PIC objects only 364914210e8eSmrg -shared do not build a '.o' file suitable for static linking 365014210e8eSmrg -static only build a '.o' file suitable for static linking 36511fb744b4Smrg -Wc,FLAG pass FLAG directly to the compiler 3652f55e6a01Smrg 365314210e8eSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 36541fb744b4Smrgfrom the given SOURCEFILE. 3655c35d236eSmrg 36561fb744b4SmrgThe output file name is determined by removing the directory component from 365714210e8eSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365814210e8eSmrglibrary object suffix, '.lo'." 36591fb744b4Smrg ;; 3660c35d236eSmrg 36611fb744b4Smrg execute) 36621fb744b4Smrg $ECHO \ 36631fb744b4Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664c35d236eSmrg 36651fb744b4SmrgAutomatically set library path, then run a program. 3666c35d236eSmrg 36671fb744b4SmrgThis mode accepts the following additional options: 3668c35d236eSmrg 36691fb744b4Smrg -dlopen FILE add the directory containing FILE to the library path 3670f55e6a01Smrg 367114210e8eSmrgThis mode sets the library path environment variable according to '-dlopen' 36721fb744b4Smrgflags. 3673f55e6a01Smrg 36741fb744b4SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 36751fb744b4Smrginto their corresponding uninstalled binary, and any of their required library 36761fb744b4Smrgdirectories are added to the library path. 3677c35d236eSmrg 36781fb744b4SmrgThen, COMMAND is executed, with ARGS as arguments." 36791fb744b4Smrg ;; 36801fb744b4Smrg 36811fb744b4Smrg finish) 36821fb744b4Smrg $ECHO \ 36831fb744b4Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 36841fb744b4Smrg 36851fb744b4SmrgComplete the installation of libtool libraries. 36861fb744b4Smrg 36871fb744b4SmrgEach LIBDIR is a directory that contains libtool libraries. 36881fb744b4Smrg 36891fb744b4SmrgThe commands that this mode executes may require superuser privileges. Use 369014210e8eSmrgthe '--dry-run' option if you just want to see what would be executed." 36911fb744b4Smrg ;; 36921fb744b4Smrg 36931fb744b4Smrg install) 36941fb744b4Smrg $ECHO \ 36951fb744b4Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 36961fb744b4Smrg 36971fb744b4SmrgInstall executables or libraries. 36981fb744b4Smrg 36991fb744b4SmrgINSTALL-COMMAND is the installation command. The first component should be 370014210e8eSmrgeither the 'install' or 'cp' program. 37011fb744b4Smrg 37021fb744b4SmrgThe following components of INSTALL-COMMAND are treated specially: 37031fb744b4Smrg 37041fb744b4Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 37051fb744b4Smrg 37061fb744b4SmrgThe rest of the components are interpreted as arguments to that command (only 37071fb744b4SmrgBSD-compatible install options are recognized)." 37081fb744b4Smrg ;; 37091fb744b4Smrg 37101fb744b4Smrg link) 37111fb744b4Smrg $ECHO \ 37121fb744b4Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 37131fb744b4Smrg 37141fb744b4SmrgLink object files or libraries together to form another library, or to 37151fb744b4Smrgcreate an executable program. 37161fb744b4Smrg 37171fb744b4SmrgLINK-COMMAND is a command using the C compiler that you would use to create 37181fb744b4Smrga program from several object files. 37191fb744b4Smrg 37201fb744b4SmrgThe following components of LINK-COMMAND are treated specially: 37211fb744b4Smrg 37221fb744b4Smrg -all-static do not do any dynamic linking at all 37231fb744b4Smrg -avoid-version do not add a version suffix if possible 37241fb744b4Smrg -bindir BINDIR specify path to binaries directory (for systems where 37251fb744b4Smrg libraries must be found in the PATH setting at runtime) 372614210e8eSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 37271fb744b4Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 37281fb744b4Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 37291fb744b4Smrg -export-symbols SYMFILE 37301fb744b4Smrg try to export only the symbols listed in SYMFILE 37311fb744b4Smrg -export-symbols-regex REGEX 37321fb744b4Smrg try to export only the symbols matching REGEX 37331fb744b4Smrg -LLIBDIR search LIBDIR for required installed libraries 37341fb744b4Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 37351fb744b4Smrg -module build a library that can dlopened 37361fb744b4Smrg -no-fast-install disable the fast-install mode 37371fb744b4Smrg -no-install link a not-installable executable 37381fb744b4Smrg -no-undefined declare that a library does not refer to external symbols 37391fb744b4Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374014210e8eSmrg -objectlist FILE use a list of object files found in FILE to specify objects 374114210e8eSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 37421fb744b4Smrg -precious-files-regex REGEX 37431fb744b4Smrg don't remove output files matching REGEX 37441fb744b4Smrg -release RELEASE specify package release information 37451fb744b4Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 37461fb744b4Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 37471fb744b4Smrg -shared only do dynamic linking of libtool libraries 37481fb744b4Smrg -shrext SUFFIX override the standard shared library file extension 37491fb744b4Smrg -static do not do any dynamic linking of uninstalled libtool libraries 37501fb744b4Smrg -static-libtool-libs 37511fb744b4Smrg do not do any dynamic linking of libtool libraries 37521fb744b4Smrg -version-info CURRENT[:REVISION[:AGE]] 37531fb744b4Smrg specify library version info [each variable defaults to 0] 37541fb744b4Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 37551fb744b4Smrg -Wc,FLAG 37561fb744b4Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 37571fb744b4Smrg -Wl,FLAG 37581fb744b4Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 37591fb744b4Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 37601fb744b4Smrg 376114210e8eSmrgAll other options (arguments beginning with '-') are ignored. 37621fb744b4Smrg 376314210e8eSmrgEvery other argument is treated as a filename. Files ending in '.la' are 37641fb744b4Smrgtreated as uninstalled libtool libraries, other files are standard or library 37651fb744b4Smrgobject files. 37661fb744b4Smrg 376714210e8eSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376814210e8eSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 37691fb744b4Smrgrequired, except when creating a convenience library. 37701fb744b4Smrg 377114210e8eSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377214210e8eSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 37731fb744b4Smrg 377414210e8eSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 37751fb744b4Smrgis created, otherwise an executable program is created." 37761fb744b4Smrg ;; 37771fb744b4Smrg 37781fb744b4Smrg uninstall) 37791fb744b4Smrg $ECHO \ 37801fb744b4Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 37811fb744b4Smrg 37821fb744b4SmrgRemove libraries from an installation directory. 37831fb744b4Smrg 37841fb744b4SmrgRM is the name of the program to use to delete files associated with each FILE 378514210e8eSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 37861fb744b4Smrgto RM. 37871fb744b4Smrg 37881fb744b4SmrgIf FILE is a libtool library, all the files associated with it are deleted. 37891fb744b4SmrgOtherwise, only FILE itself is deleted using RM." 37901fb744b4Smrg ;; 37911fb744b4Smrg 37921fb744b4Smrg *) 379314210e8eSmrg func_fatal_help "invalid operation mode '$opt_mode'" 37941fb744b4Smrg ;; 3795518bcf38Smrg esac 3796c35d236eSmrg 37971fb744b4Smrg echo 379814210e8eSmrg $ECHO "Try '$progname --help' for more information about other modes." 37991fb744b4Smrg} 3800c35d236eSmrg 38011fb744b4Smrg# Now that we've collected a possible --mode arg, show help if necessary 38021fb744b4Smrgif $opt_help; then 380314210e8eSmrg if test : = "$opt_help"; then 38041fb744b4Smrg func_mode_help 38051fb744b4Smrg else 38061fb744b4Smrg { 38071fb744b4Smrg func_help noexit 38081fb744b4Smrg for opt_mode in compile link execute install finish uninstall clean; do 38091fb744b4Smrg func_mode_help 38101fb744b4Smrg done 381114210e8eSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 38121fb744b4Smrg { 38131fb744b4Smrg func_help noexit 38141fb744b4Smrg for opt_mode in compile link execute install finish uninstall clean; do 38151fb744b4Smrg echo 38161fb744b4Smrg func_mode_help 38171fb744b4Smrg done 38181fb744b4Smrg } | 381914210e8eSmrg $SED '1d 38201fb744b4Smrg /^When reporting/,/^Report/{ 38211fb744b4Smrg H 38221fb744b4Smrg d 38231fb744b4Smrg } 38241fb744b4Smrg $x 38251fb744b4Smrg /information about other modes/d 38261fb744b4Smrg /more detailed .*MODE/d 38271fb744b4Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 38281fb744b4Smrg fi 38291fb744b4Smrg exit $? 38301fb744b4Smrgfi 3831c35d236eSmrg 3832c35d236eSmrg 38331fb744b4Smrg# func_mode_execute arg... 38341fb744b4Smrgfunc_mode_execute () 38351fb744b4Smrg{ 383614210e8eSmrg $debug_cmd 383714210e8eSmrg 38381fb744b4Smrg # The first argument is the command name. 383914210e8eSmrg cmd=$nonopt 38401fb744b4Smrg test -z "$cmd" && \ 38411fb744b4Smrg func_fatal_help "you must specify a COMMAND" 38421fb744b4Smrg 38431fb744b4Smrg # Handle -dlopen flags immediately. 38441fb744b4Smrg for file in $opt_dlopen; do 38451fb744b4Smrg test -f "$file" \ 384614210e8eSmrg || func_fatal_help "'$file' is not a file" 38471fb744b4Smrg 38481fb744b4Smrg dir= 38491fb744b4Smrg case $file in 38501fb744b4Smrg *.la) 38511fb744b4Smrg func_resolve_sysroot "$file" 38521fb744b4Smrg file=$func_resolve_sysroot_result 38531fb744b4Smrg 38541fb744b4Smrg # Check to see that this really is a libtool archive. 38551fb744b4Smrg func_lalib_unsafe_p "$file" \ 385614210e8eSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 38571fb744b4Smrg 38581fb744b4Smrg # Read the libtool library. 38591fb744b4Smrg dlname= 38601fb744b4Smrg library_names= 38611fb744b4Smrg func_source "$file" 38621fb744b4Smrg 38631fb744b4Smrg # Skip this library if it cannot be dlopened. 38641fb744b4Smrg if test -z "$dlname"; then 38651fb744b4Smrg # Warn if it was a shared library. 38661fb744b4Smrg test -n "$library_names" && \ 386714210e8eSmrg func_warning "'$file' was not linked with '-export-dynamic'" 38681fb744b4Smrg continue 38691fb744b4Smrg fi 38701fb744b4Smrg 38711fb744b4Smrg func_dirname "$file" "" "." 387214210e8eSmrg dir=$func_dirname_result 38731fb744b4Smrg 38741fb744b4Smrg if test -f "$dir/$objdir/$dlname"; then 38751fb744b4Smrg func_append dir "/$objdir" 38761fb744b4Smrg else 38771fb744b4Smrg if test ! -f "$dir/$dlname"; then 387814210e8eSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 38791fb744b4Smrg fi 38801fb744b4Smrg fi 3881f55e6a01Smrg ;; 38821fb744b4Smrg 38831fb744b4Smrg *.lo) 38841fb744b4Smrg # Just add the directory containing the .lo file. 38851fb744b4Smrg func_dirname "$file" "" "." 388614210e8eSmrg dir=$func_dirname_result 3887518bcf38Smrg ;; 38881fb744b4Smrg 38891fb744b4Smrg *) 389014210e8eSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 38911fb744b4Smrg continue 3892f55e6a01Smrg ;; 38931fb744b4Smrg esac 38941fb744b4Smrg 38951fb744b4Smrg # Get the absolute pathname. 38961fb744b4Smrg absdir=`cd "$dir" && pwd` 389714210e8eSmrg test -n "$absdir" && dir=$absdir 38981fb744b4Smrg 38991fb744b4Smrg # Now add the directory to shlibpath_var. 39001fb744b4Smrg if eval "test -z \"\$$shlibpath_var\""; then 39011fb744b4Smrg eval "$shlibpath_var=\"\$dir\"" 39021fb744b4Smrg else 39031fb744b4Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904518bcf38Smrg fi 39051fb744b4Smrg done 39061fb744b4Smrg 39071fb744b4Smrg # This variable tells wrapper scripts just to set shlibpath_var 39081fb744b4Smrg # rather than running their programs. 390914210e8eSmrg libtool_execute_magic=$magic 39101fb744b4Smrg 39111fb744b4Smrg # Check if any of the arguments is a wrapper script. 39121fb744b4Smrg args= 39131fb744b4Smrg for file 39141fb744b4Smrg do 39151fb744b4Smrg case $file in 39161fb744b4Smrg -* | *.la | *.lo ) ;; 39171fb744b4Smrg *) 39181fb744b4Smrg # Do a test to see if this is really a libtool program. 39191fb744b4Smrg if func_ltwrapper_script_p "$file"; then 39201fb744b4Smrg func_source "$file" 39211fb744b4Smrg # Transform arg to wrapped name. 392214210e8eSmrg file=$progdir/$program 39231fb744b4Smrg elif func_ltwrapper_executable_p "$file"; then 39241fb744b4Smrg func_ltwrapper_scriptname "$file" 39251fb744b4Smrg func_source "$func_ltwrapper_scriptname_result" 39261fb744b4Smrg # Transform arg to wrapped name. 392714210e8eSmrg file=$progdir/$program 39281fb744b4Smrg fi 39291fb744b4Smrg ;; 39301fb744b4Smrg esac 39311fb744b4Smrg # Quote arguments (to preserve shell metacharacters). 39321fb744b4Smrg func_append_quoted args "$file" 39331fb744b4Smrg done 39341fb744b4Smrg 393514210e8eSmrg if $opt_dry_run; then 393614210e8eSmrg # Display what would be done. 393714210e8eSmrg if test -n "$shlibpath_var"; then 393814210e8eSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393914210e8eSmrg echo "export $shlibpath_var" 394014210e8eSmrg fi 394114210e8eSmrg $ECHO "$cmd$args" 394214210e8eSmrg exit $EXIT_SUCCESS 394314210e8eSmrg else 39441fb744b4Smrg if test -n "$shlibpath_var"; then 39451fb744b4Smrg # Export the shlibpath_var. 39461fb744b4Smrg eval "export $shlibpath_var" 3947518bcf38Smrg fi 39481fb744b4Smrg 39491fb744b4Smrg # Restore saved environment variables 39501fb744b4Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 39511fb744b4Smrg do 39521fb744b4Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 39531fb744b4Smrg $lt_var=\$save_$lt_var; export $lt_var 39541fb744b4Smrg else 39551fb744b4Smrg $lt_unset $lt_var 39561fb744b4Smrg fi" 39571fb744b4Smrg done 39581fb744b4Smrg 39591fb744b4Smrg # Now prepare to actually exec the command. 396014210e8eSmrg exec_cmd=\$cmd$args 39611fb744b4Smrg fi 39621fb744b4Smrg} 3963c35d236eSmrg 396414210e8eSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965c35d236eSmrg 3966c35d236eSmrg 39671fb744b4Smrg# func_mode_finish arg... 39681fb744b4Smrgfunc_mode_finish () 39691fb744b4Smrg{ 397014210e8eSmrg $debug_cmd 397114210e8eSmrg 39721fb744b4Smrg libs= 39731fb744b4Smrg libdirs= 39741fb744b4Smrg admincmds= 3975c35d236eSmrg 39761fb744b4Smrg for opt in "$nonopt" ${1+"$@"} 39771fb744b4Smrg do 39781fb744b4Smrg if test -d "$opt"; then 39791fb744b4Smrg func_append libdirs " $opt" 3980c35d236eSmrg 39811fb744b4Smrg elif test -f "$opt"; then 39821fb744b4Smrg if func_lalib_unsafe_p "$opt"; then 39831fb744b4Smrg func_append libs " $opt" 39841fb744b4Smrg else 398514210e8eSmrg func_warning "'$opt' is not a valid libtool archive" 3986518bcf38Smrg fi 3987c35d236eSmrg 39881fb744b4Smrg else 398914210e8eSmrg func_fatal_error "invalid argument '$opt'" 39901fb744b4Smrg fi 39911fb744b4Smrg done 3992c35d236eSmrg 39931fb744b4Smrg if test -n "$libs"; then 39941fb744b4Smrg if test -n "$lt_sysroot"; then 39951fb744b4Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 39961fb744b4Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 39971fb744b4Smrg else 39981fb744b4Smrg sysroot_cmd= 39991fb744b4Smrg fi 4000c35d236eSmrg 40011fb744b4Smrg # Remove sysroot references 40021fb744b4Smrg if $opt_dry_run; then 40031fb744b4Smrg for lib in $libs; do 400414210e8eSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 40051fb744b4Smrg done 40061fb744b4Smrg else 40071fb744b4Smrg tmpdir=`func_mktempdir` 40081fb744b4Smrg for lib in $libs; do 400914210e8eSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 40101fb744b4Smrg > $tmpdir/tmp-la 40111fb744b4Smrg mv -f $tmpdir/tmp-la $lib 4012518bcf38Smrg done 40131fb744b4Smrg ${RM}r "$tmpdir" 40141fb744b4Smrg fi 40151fb744b4Smrg fi 40161fb744b4Smrg 40171fb744b4Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40181fb744b4Smrg for libdir in $libdirs; do 40191fb744b4Smrg if test -n "$finish_cmds"; then 40201fb744b4Smrg # Do each command in the finish commands. 40211fb744b4Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 40221fb744b4Smrg'"$cmd"'"' 40231fb744b4Smrg fi 40241fb744b4Smrg if test -n "$finish_eval"; then 40251fb744b4Smrg # Do the single finish_eval. 40261fb744b4Smrg eval cmds=\"$finish_eval\" 40271fb744b4Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 40281fb744b4Smrg $cmds" 4029c35d236eSmrg fi 40301fb744b4Smrg done 40311fb744b4Smrg fi 4032c35d236eSmrg 40331fb744b4Smrg # Exit here if they wanted silent mode. 403414210e8eSmrg $opt_quiet && exit $EXIT_SUCCESS 4035c35d236eSmrg 40361fb744b4Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40371fb744b4Smrg echo "----------------------------------------------------------------------" 40381fb744b4Smrg echo "Libraries have been installed in:" 40391fb744b4Smrg for libdir in $libdirs; do 40401fb744b4Smrg $ECHO " $libdir" 40411fb744b4Smrg done 40421fb744b4Smrg echo 40431fb744b4Smrg echo "If you ever happen to want to link against installed libraries" 40441fb744b4Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404514210e8eSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 40461fb744b4Smrg echo "flag during linking and do at least one of the following:" 40471fb744b4Smrg if test -n "$shlibpath_var"; then 404814210e8eSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 40491fb744b4Smrg echo " during execution" 40501fb744b4Smrg fi 40511fb744b4Smrg if test -n "$runpath_var"; then 405214210e8eSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 40531fb744b4Smrg echo " during linking" 40541fb744b4Smrg fi 40551fb744b4Smrg if test -n "$hardcode_libdir_flag_spec"; then 40561fb744b4Smrg libdir=LIBDIR 40571fb744b4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 40581fb744b4Smrg 405914210e8eSmrg $ECHO " - use the '$flag' linker flag" 40601fb744b4Smrg fi 40611fb744b4Smrg if test -n "$admincmds"; then 40621fb744b4Smrg $ECHO " - have your system administrator run these commands:$admincmds" 40631fb744b4Smrg fi 40641fb744b4Smrg if test -f /etc/ld.so.conf; then 406514210e8eSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 40661fb744b4Smrg fi 40671fb744b4Smrg echo 40681fb744b4Smrg 40691fb744b4Smrg echo "See any operating system documentation about shared libraries for" 40701fb744b4Smrg case $host in 40711fb744b4Smrg solaris2.[6789]|solaris2.1[0-9]) 40721fb744b4Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 40731fb744b4Smrg echo "pages." 40741fb744b4Smrg ;; 4075518bcf38Smrg *) 40761fb744b4Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077518bcf38Smrg ;; 40781fb744b4Smrg esac 40791fb744b4Smrg echo "----------------------------------------------------------------------" 40801fb744b4Smrg fi 40811fb744b4Smrg exit $EXIT_SUCCESS 40821fb744b4Smrg} 4083c35d236eSmrg 408414210e8eSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085c35d236eSmrg 4086c35d236eSmrg 40871fb744b4Smrg# func_mode_install arg... 40881fb744b4Smrgfunc_mode_install () 40891fb744b4Smrg{ 409014210e8eSmrg $debug_cmd 409114210e8eSmrg 40921fb744b4Smrg # There may be an optional sh(1) argument at the beginning of 40931fb744b4Smrg # install_prog (especially on Windows NT). 409414210e8eSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 40951fb744b4Smrg # Allow the use of GNU shtool's install command. 409614210e8eSmrg case $nonopt in *shtool*) :;; *) false;; esac 409714210e8eSmrg then 40981fb744b4Smrg # Aesthetically quote it. 40991fb744b4Smrg func_quote_for_eval "$nonopt" 41001fb744b4Smrg install_prog="$func_quote_for_eval_result " 41011fb744b4Smrg arg=$1 41021fb744b4Smrg shift 41031fb744b4Smrg else 41041fb744b4Smrg install_prog= 41051fb744b4Smrg arg=$nonopt 41061fb744b4Smrg fi 41071fb744b4Smrg 41081fb744b4Smrg # The real first argument should be the name of the installation program. 41091fb744b4Smrg # Aesthetically quote it. 41101fb744b4Smrg func_quote_for_eval "$arg" 41111fb744b4Smrg func_append install_prog "$func_quote_for_eval_result" 41121fb744b4Smrg install_shared_prog=$install_prog 41131fb744b4Smrg case " $install_prog " in 41141fb744b4Smrg *[\\\ /]cp\ *) install_cp=: ;; 41151fb744b4Smrg *) install_cp=false ;; 41161fb744b4Smrg esac 41171fb744b4Smrg 41181fb744b4Smrg # We need to accept at least all the BSD install flags. 41191fb744b4Smrg dest= 41201fb744b4Smrg files= 41211fb744b4Smrg opts= 41221fb744b4Smrg prev= 41231fb744b4Smrg install_type= 412414210e8eSmrg isdir=false 41251fb744b4Smrg stripme= 41261fb744b4Smrg no_mode=: 41271fb744b4Smrg for arg 41281fb744b4Smrg do 41291fb744b4Smrg arg2= 41301fb744b4Smrg if test -n "$dest"; then 41311fb744b4Smrg func_append files " $dest" 41321fb744b4Smrg dest=$arg 41331fb744b4Smrg continue 41341fb744b4Smrg fi 41351fb744b4Smrg 41361fb744b4Smrg case $arg in 413714210e8eSmrg -d) isdir=: ;; 41381fb744b4Smrg -f) 41391fb744b4Smrg if $install_cp; then :; else 41401fb744b4Smrg prev=$arg 41411fb744b4Smrg fi 41421fb744b4Smrg ;; 41431fb744b4Smrg -g | -m | -o) 41441fb744b4Smrg prev=$arg 41451fb744b4Smrg ;; 41461fb744b4Smrg -s) 41471fb744b4Smrg stripme=" -s" 41481fb744b4Smrg continue 41491fb744b4Smrg ;; 41501fb744b4Smrg -*) 41511fb744b4Smrg ;; 41521fb744b4Smrg *) 41531fb744b4Smrg # If the previous option needed an argument, then skip it. 41541fb744b4Smrg if test -n "$prev"; then 415514210e8eSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 41561fb744b4Smrg arg2=$install_override_mode 41571fb744b4Smrg no_mode=false 4158518bcf38Smrg fi 41591fb744b4Smrg prev= 41601fb744b4Smrg else 41611fb744b4Smrg dest=$arg 4162518bcf38Smrg continue 4163518bcf38Smrg fi 41641fb744b4Smrg ;; 41651fb744b4Smrg esac 4166c35d236eSmrg 41671fb744b4Smrg # Aesthetically quote the argument. 41681fb744b4Smrg func_quote_for_eval "$arg" 41691fb744b4Smrg func_append install_prog " $func_quote_for_eval_result" 41701fb744b4Smrg if test -n "$arg2"; then 41711fb744b4Smrg func_quote_for_eval "$arg2" 41721fb744b4Smrg fi 41731fb744b4Smrg func_append install_shared_prog " $func_quote_for_eval_result" 41741fb744b4Smrg done 4175c35d236eSmrg 41761fb744b4Smrg test -z "$install_prog" && \ 41771fb744b4Smrg func_fatal_help "you must specify an install program" 4178c35d236eSmrg 41791fb744b4Smrg test -n "$prev" && \ 418014210e8eSmrg func_fatal_help "the '$prev' option requires an argument" 4181c35d236eSmrg 41821fb744b4Smrg if test -n "$install_override_mode" && $no_mode; then 41831fb744b4Smrg if $install_cp; then :; else 41841fb744b4Smrg func_quote_for_eval "$install_override_mode" 41851fb744b4Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 41861fb744b4Smrg fi 41871fb744b4Smrg fi 4188c35d236eSmrg 41891fb744b4Smrg if test -z "$files"; then 41901fb744b4Smrg if test -z "$dest"; then 41911fb744b4Smrg func_fatal_help "no file or destination specified" 41921fb744b4Smrg else 41931fb744b4Smrg func_fatal_help "you must specify a destination" 41941fb744b4Smrg fi 41951fb744b4Smrg fi 4196c35d236eSmrg 41971fb744b4Smrg # Strip any trailing slash from the destination. 41981fb744b4Smrg func_stripname '' '/' "$dest" 41991fb744b4Smrg dest=$func_stripname_result 4200c35d236eSmrg 42011fb744b4Smrg # Check to see that the destination is a directory. 420214210e8eSmrg test -d "$dest" && isdir=: 420314210e8eSmrg if $isdir; then 420414210e8eSmrg destdir=$dest 42051fb744b4Smrg destname= 42061fb744b4Smrg else 42071fb744b4Smrg func_dirname_and_basename "$dest" "" "." 420814210e8eSmrg destdir=$func_dirname_result 420914210e8eSmrg destname=$func_basename_result 4210c35d236eSmrg 42111fb744b4Smrg # Not a directory, so check to see that there is only one file specified. 42121fb744b4Smrg set dummy $files; shift 42131fb744b4Smrg test "$#" -gt 1 && \ 421414210e8eSmrg func_fatal_help "'$dest' is not a directory" 42151fb744b4Smrg fi 42161fb744b4Smrg case $destdir in 42171fb744b4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 42181fb744b4Smrg *) 42191fb744b4Smrg for file in $files; do 42201fb744b4Smrg case $file in 42211fb744b4Smrg *.lo) ;; 42221fb744b4Smrg *) 422314210e8eSmrg func_fatal_help "'$destdir' must be an absolute directory name" 42241fb744b4Smrg ;; 42251fb744b4Smrg esac 42261fb744b4Smrg done 42271fb744b4Smrg ;; 42281fb744b4Smrg esac 4229c35d236eSmrg 42301fb744b4Smrg # This variable tells wrapper scripts just to set variables rather 42311fb744b4Smrg # than running their programs. 423214210e8eSmrg libtool_install_magic=$magic 4233c35d236eSmrg 42341fb744b4Smrg staticlibs= 42351fb744b4Smrg future_libdirs= 42361fb744b4Smrg current_libdirs= 42371fb744b4Smrg for file in $files; do 4238c35d236eSmrg 42391fb744b4Smrg # Do each installation. 42401fb744b4Smrg case $file in 42411fb744b4Smrg *.$libext) 42421fb744b4Smrg # Do the static libraries later. 42431fb744b4Smrg func_append staticlibs " $file" 42441fb744b4Smrg ;; 4245c35d236eSmrg 42461fb744b4Smrg *.la) 42471fb744b4Smrg func_resolve_sysroot "$file" 42481fb744b4Smrg file=$func_resolve_sysroot_result 4249c35d236eSmrg 42501fb744b4Smrg # Check to see that this really is a libtool archive. 42511fb744b4Smrg func_lalib_unsafe_p "$file" \ 425214210e8eSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4253c35d236eSmrg 42541fb744b4Smrg library_names= 42551fb744b4Smrg old_library= 42561fb744b4Smrg relink_command= 42571fb744b4Smrg func_source "$file" 4258c35d236eSmrg 42591fb744b4Smrg # Add the libdir to current_libdirs if it is the destination. 42601fb744b4Smrg if test "X$destdir" = "X$libdir"; then 42611fb744b4Smrg case "$current_libdirs " in 42621fb744b4Smrg *" $libdir "*) ;; 42631fb744b4Smrg *) func_append current_libdirs " $libdir" ;; 42641fb744b4Smrg esac 42651fb744b4Smrg else 42661fb744b4Smrg # Note the libdir as a future libdir. 42671fb744b4Smrg case "$future_libdirs " in 42681fb744b4Smrg *" $libdir "*) ;; 42691fb744b4Smrg *) func_append future_libdirs " $libdir" ;; 42701fb744b4Smrg esac 42711fb744b4Smrg fi 4272c35d236eSmrg 42731fb744b4Smrg func_dirname "$file" "/" "" 427414210e8eSmrg dir=$func_dirname_result 42751fb744b4Smrg func_append dir "$objdir" 4276f55e6a01Smrg 42771fb744b4Smrg if test -n "$relink_command"; then 42781fb744b4Smrg # Determine the prefix the user has applied to our future dir. 42791fb744b4Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280f55e6a01Smrg 42811fb744b4Smrg # Don't allow the user to place us outside of our expected 42821fb744b4Smrg # location b/c this prevents finding dependent libraries that 42831fb744b4Smrg # are installed to the same prefix. 42841fb744b4Smrg # At present, this check doesn't affect windows .dll's that 42851fb744b4Smrg # are installed into $libdir/../bin (currently, that works fine) 42861fb744b4Smrg # but it's something to keep an eye on. 42871fb744b4Smrg test "$inst_prefix_dir" = "$destdir" && \ 428814210e8eSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 42891fb744b4Smrg 42901fb744b4Smrg if test -n "$inst_prefix_dir"; then 42911fb744b4Smrg # Stick the inst_prefix_dir data into the link command. 42921fb744b4Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293518bcf38Smrg else 42941fb744b4Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295518bcf38Smrg fi 4296f55e6a01Smrg 429714210e8eSmrg func_warning "relinking '$file'" 42981fb744b4Smrg func_show_eval "$relink_command" \ 429914210e8eSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 43001fb744b4Smrg fi 43011fb744b4Smrg 43021fb744b4Smrg # See the names of the shared library. 43031fb744b4Smrg set dummy $library_names; shift 43041fb744b4Smrg if test -n "$1"; then 430514210e8eSmrg realname=$1 43061fb744b4Smrg shift 43071fb744b4Smrg 430814210e8eSmrg srcname=$realname 430914210e8eSmrg test -n "$relink_command" && srcname=${realname}T 43101fb744b4Smrg 43111fb744b4Smrg # Install the shared library and build the symlinks. 43121fb744b4Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 43131fb744b4Smrg 'exit $?' 431414210e8eSmrg tstripme=$stripme 43151fb744b4Smrg case $host_os in 43161fb744b4Smrg cygwin* | mingw* | pw32* | cegcc*) 43171fb744b4Smrg case $realname in 43181fb744b4Smrg *.dll.a) 431914210e8eSmrg tstripme= 432014210e8eSmrg ;; 432114210e8eSmrg esac 432214210e8eSmrg ;; 432314210e8eSmrg os2*) 432414210e8eSmrg case $realname in 432514210e8eSmrg *_dll.a) 432614210e8eSmrg tstripme= 43271fb744b4Smrg ;; 43281fb744b4Smrg esac 43291fb744b4Smrg ;; 43301fb744b4Smrg esac 43311fb744b4Smrg if test -n "$tstripme" && test -n "$striplib"; then 43321fb744b4Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333518bcf38Smrg fi 4334f55e6a01Smrg 43351fb744b4Smrg if test "$#" -gt 0; then 43361fb744b4Smrg # Delete the old symlinks, and create new ones. 433714210e8eSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 43381fb744b4Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 43391fb744b4Smrg # so we also need to try rm && ln -s. 43401fb744b4Smrg for linkname 43411fb744b4Smrg do 43421fb744b4Smrg test "$linkname" != "$realname" \ 43431fb744b4Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344518bcf38Smrg done 4345518bcf38Smrg fi 4346f55e6a01Smrg 43471fb744b4Smrg # Do each command in the postinstall commands. 434814210e8eSmrg lib=$destdir/$realname 43491fb744b4Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 43501fb744b4Smrg fi 4351c35d236eSmrg 43521fb744b4Smrg # Install the pseudo-library for information purposes. 43531fb744b4Smrg func_basename "$file" 435414210e8eSmrg name=$func_basename_result 435514210e8eSmrg instname=$dir/${name}i 43561fb744b4Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357518bcf38Smrg 43581fb744b4Smrg # Maybe install the static library, too. 43591fb744b4Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 43601fb744b4Smrg ;; 43611fb744b4Smrg 43621fb744b4Smrg *.lo) 43631fb744b4Smrg # Install (i.e. copy) a libtool object. 43641fb744b4Smrg 43651fb744b4Smrg # Figure out destination file name, if it wasn't already specified. 43661fb744b4Smrg if test -n "$destname"; then 436714210e8eSmrg destfile=$destdir/$destname 4368518bcf38Smrg else 43691fb744b4Smrg func_basename "$file" 437014210e8eSmrg destfile=$func_basename_result 437114210e8eSmrg destfile=$destdir/$destfile 4372518bcf38Smrg fi 43731fb744b4Smrg 43741fb744b4Smrg # Deduce the name of the destination old-style object file. 43751fb744b4Smrg case $destfile in 43761fb744b4Smrg *.lo) 43771fb744b4Smrg func_lo2o "$destfile" 43781fb744b4Smrg staticdest=$func_lo2o_result 43791fb744b4Smrg ;; 43801fb744b4Smrg *.$objext) 438114210e8eSmrg staticdest=$destfile 43821fb744b4Smrg destfile= 43831fb744b4Smrg ;; 43841fb744b4Smrg *) 438514210e8eSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386c35d236eSmrg ;; 4387c35d236eSmrg esac 4388c35d236eSmrg 43891fb744b4Smrg # Install the libtool object if requested. 43901fb744b4Smrg test -n "$destfile" && \ 43911fb744b4Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392c35d236eSmrg 43931fb744b4Smrg # Install the old object if enabled. 439414210e8eSmrg if test yes = "$build_old_libs"; then 43951fb744b4Smrg # Deduce the name of the old-style object file. 43961fb744b4Smrg func_lo2o "$file" 43971fb744b4Smrg staticobj=$func_lo2o_result 43981fb744b4Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 43991fb744b4Smrg fi 44001fb744b4Smrg exit $EXIT_SUCCESS 44011fb744b4Smrg ;; 4402c35d236eSmrg 44031fb744b4Smrg *) 44041fb744b4Smrg # Figure out destination file name, if it wasn't already specified. 44051fb744b4Smrg if test -n "$destname"; then 440614210e8eSmrg destfile=$destdir/$destname 44071fb744b4Smrg else 44081fb744b4Smrg func_basename "$file" 440914210e8eSmrg destfile=$func_basename_result 441014210e8eSmrg destfile=$destdir/$destfile 44111fb744b4Smrg fi 4412c35d236eSmrg 44131fb744b4Smrg # If the file is missing, and there is a .exe on the end, strip it 44141fb744b4Smrg # because it is most likely a libtool script we actually want to 44151fb744b4Smrg # install 441614210e8eSmrg stripped_ext= 44171fb744b4Smrg case $file in 44181fb744b4Smrg *.exe) 44191fb744b4Smrg if test ! -f "$file"; then 44201fb744b4Smrg func_stripname '' '.exe' "$file" 44211fb744b4Smrg file=$func_stripname_result 442214210e8eSmrg stripped_ext=.exe 44231fb744b4Smrg fi 44241fb744b4Smrg ;; 44251fb744b4Smrg esac 4426c35d236eSmrg 44271fb744b4Smrg # Do a test to see if this is really a libtool program. 44281fb744b4Smrg case $host in 44291fb744b4Smrg *cygwin* | *mingw*) 44301fb744b4Smrg if func_ltwrapper_executable_p "$file"; then 44311fb744b4Smrg func_ltwrapper_scriptname "$file" 44321fb744b4Smrg wrapper=$func_ltwrapper_scriptname_result 44331fb744b4Smrg else 44341fb744b4Smrg func_stripname '' '.exe' "$file" 44351fb744b4Smrg wrapper=$func_stripname_result 44361fb744b4Smrg fi 44371fb744b4Smrg ;; 44381fb744b4Smrg *) 44391fb744b4Smrg wrapper=$file 44401fb744b4Smrg ;; 44411fb744b4Smrg esac 44421fb744b4Smrg if func_ltwrapper_script_p "$wrapper"; then 44431fb744b4Smrg notinst_deplibs= 44441fb744b4Smrg relink_command= 4445c35d236eSmrg 44461fb744b4Smrg func_source "$wrapper" 4447c35d236eSmrg 44481fb744b4Smrg # Check the variables that should have been set. 44491fb744b4Smrg test -z "$generated_by_libtool_version" && \ 445014210e8eSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451c35d236eSmrg 445214210e8eSmrg finalize=: 44531fb744b4Smrg for lib in $notinst_deplibs; do 44541fb744b4Smrg # Check to see that each library is installed. 44551fb744b4Smrg libdir= 44561fb744b4Smrg if test -f "$lib"; then 44571fb744b4Smrg func_source "$lib" 44581fb744b4Smrg fi 445914210e8eSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 44601fb744b4Smrg if test -n "$libdir" && test ! -f "$libfile"; then 446114210e8eSmrg func_warning "'$lib' has not been installed in '$libdir'" 446214210e8eSmrg finalize=false 44631fb744b4Smrg fi 44641fb744b4Smrg done 4465c35d236eSmrg 44661fb744b4Smrg relink_command= 44671fb744b4Smrg func_source "$wrapper" 44681fb744b4Smrg 44691fb744b4Smrg outputname= 447014210e8eSmrg if test no = "$fast_install" && test -n "$relink_command"; then 44711fb744b4Smrg $opt_dry_run || { 447214210e8eSmrg if $finalize; then 44731fb744b4Smrg tmpdir=`func_mktempdir` 44741fb744b4Smrg func_basename "$file$stripped_ext" 447514210e8eSmrg file=$func_basename_result 447614210e8eSmrg outputname=$tmpdir/$file 44771fb744b4Smrg # Replace the output file specification. 44781fb744b4Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 44791fb744b4Smrg 448014210e8eSmrg $opt_quiet || { 44811fb744b4Smrg func_quote_for_expand "$relink_command" 44821fb744b4Smrg eval "func_echo $func_quote_for_expand_result" 44831fb744b4Smrg } 44841fb744b4Smrg if eval "$relink_command"; then : 44851fb744b4Smrg else 448614210e8eSmrg func_error "error: relink '$file' with the above command before installing it" 44871fb744b4Smrg $opt_dry_run || ${RM}r "$tmpdir" 44881fb744b4Smrg continue 44891fb744b4Smrg fi 449014210e8eSmrg file=$outputname 44911fb744b4Smrg else 449214210e8eSmrg func_warning "cannot relink '$file'" 44931fb744b4Smrg fi 44941fb744b4Smrg } 44951fb744b4Smrg else 44961fb744b4Smrg # Install the binary that we compiled earlier. 44971fb744b4Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 44981fb744b4Smrg fi 4499518bcf38Smrg fi 45001fb744b4Smrg 45011fb744b4Smrg # remove .exe since cygwin /usr/bin/install will append another 45021fb744b4Smrg # one anyway 45031fb744b4Smrg case $install_prog,$host in 45041fb744b4Smrg */usr/bin/install*,*cygwin*) 45051fb744b4Smrg case $file:$destfile in 45061fb744b4Smrg *.exe:*.exe) 45071fb744b4Smrg # this is ok 45081fb744b4Smrg ;; 45091fb744b4Smrg *.exe:*) 45101fb744b4Smrg destfile=$destfile.exe 45111fb744b4Smrg ;; 45121fb744b4Smrg *:*.exe) 45131fb744b4Smrg func_stripname '' '.exe' "$destfile" 45141fb744b4Smrg destfile=$func_stripname_result 45151fb744b4Smrg ;; 45161fb744b4Smrg esac 45171fb744b4Smrg ;; 45181fb744b4Smrg esac 45191fb744b4Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 45201fb744b4Smrg $opt_dry_run || if test -n "$outputname"; then 45211fb744b4Smrg ${RM}r "$tmpdir" 4522518bcf38Smrg fi 4523518bcf38Smrg ;; 4524518bcf38Smrg esac 45251fb744b4Smrg done 4526c35d236eSmrg 45271fb744b4Smrg for file in $staticlibs; do 45281fb744b4Smrg func_basename "$file" 452914210e8eSmrg name=$func_basename_result 4530f55e6a01Smrg 45311fb744b4Smrg # Set up the ranlib parameters. 453214210e8eSmrg oldlib=$destdir/$name 45331fb744b4Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 45341fb744b4Smrg tool_oldlib=$func_to_tool_file_result 4535f55e6a01Smrg 45361fb744b4Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 45371fb744b4Smrg 45381fb744b4Smrg if test -n "$stripme" && test -n "$old_striplib"; then 45391fb744b4Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540518bcf38Smrg fi 4541f55e6a01Smrg 45421fb744b4Smrg # Do each command in the postinstall commands. 45431fb744b4Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 45441fb744b4Smrg done 4545f55e6a01Smrg 45461fb744b4Smrg test -n "$future_libdirs" && \ 454714210e8eSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548f55e6a01Smrg 45491fb744b4Smrg if test -n "$current_libdirs"; then 45501fb744b4Smrg # Maybe just do a dry run. 45511fb744b4Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455214210e8eSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 45531fb744b4Smrg else 45541fb744b4Smrg exit $EXIT_SUCCESS 45551fb744b4Smrg fi 45561fb744b4Smrg} 4557f55e6a01Smrg 455814210e8eSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559f55e6a01Smrg 4560f55e6a01Smrg 45611fb744b4Smrg# func_generate_dlsyms outputname originator pic_p 45621fb744b4Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 45631fb744b4Smrg# a dlpreopen symbol table. 45641fb744b4Smrgfunc_generate_dlsyms () 45651fb744b4Smrg{ 456614210e8eSmrg $debug_cmd 456714210e8eSmrg 456814210e8eSmrg my_outputname=$1 456914210e8eSmrg my_originator=$2 457014210e8eSmrg my_pic_p=${3-false} 457114210e8eSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 45721fb744b4Smrg my_dlsyms= 45731fb744b4Smrg 457414210e8eSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 45751fb744b4Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457614210e8eSmrg my_dlsyms=${my_outputname}S.c 45771fb744b4Smrg else 45781fb744b4Smrg func_error "not configured to extract global symbols from dlpreopened files" 45791fb744b4Smrg fi 45801fb744b4Smrg fi 4581f55e6a01Smrg 45821fb744b4Smrg if test -n "$my_dlsyms"; then 45831fb744b4Smrg case $my_dlsyms in 45841fb744b4Smrg "") ;; 45851fb744b4Smrg *.c) 45861fb744b4Smrg # Discover the nlist of each of the dlfiles. 458714210e8eSmrg nlist=$output_objdir/$my_outputname.nm 4588f55e6a01Smrg 45891fb744b4Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590f55e6a01Smrg 45911fb744b4Smrg # Parse the name list into a source file. 45921fb744b4Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4593f55e6a01Smrg 45941fb744b4Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459514210e8eSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459614210e8eSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597f55e6a01Smrg 45981fb744b4Smrg#ifdef __cplusplus 45991fb744b4Smrgextern \"C\" { 46001fb744b4Smrg#endif 4601f55e6a01Smrg 460214210e8eSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 46031fb744b4Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 46041fb744b4Smrg#endif 4605f55e6a01Smrg 46061fb744b4Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460714210e8eSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460814210e8eSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 46091fb744b4Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 46101fb744b4Smrg# define LT_DLSYM_CONST 461114210e8eSmrg#elif defined __osf__ 46121fb744b4Smrg/* This system does not cope well with relocations in const data. */ 46131fb744b4Smrg# define LT_DLSYM_CONST 46141fb744b4Smrg#else 46151fb744b4Smrg# define LT_DLSYM_CONST const 46161fb744b4Smrg#endif 4617f55e6a01Smrg 461814210e8eSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461914210e8eSmrg 46201fb744b4Smrg/* External symbol declarations for the compiler. */\ 46211fb744b4Smrg" 4622f55e6a01Smrg 462314210e8eSmrg if test yes = "$dlself"; then 462414210e8eSmrg func_verbose "generating symbol list for '$output'" 4625f55e6a01Smrg 46261fb744b4Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627c35d236eSmrg 46281fb744b4Smrg # Add our own program objects to the symbol list. 46291fb744b4Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 46301fb744b4Smrg for progfile in $progfiles; do 46311fb744b4Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463214210e8eSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 46331fb744b4Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634518bcf38Smrg done 4635c35d236eSmrg 46361fb744b4Smrg if test -n "$exclude_expsyms"; then 46371fb744b4Smrg $opt_dry_run || { 46381fb744b4Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 46391fb744b4Smrg eval '$MV "$nlist"T "$nlist"' 46401fb744b4Smrg } 46411fb744b4Smrg fi 4642c35d236eSmrg 46431fb744b4Smrg if test -n "$export_symbols_regex"; then 46441fb744b4Smrg $opt_dry_run || { 46451fb744b4Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 46461fb744b4Smrg eval '$MV "$nlist"T "$nlist"' 46471fb744b4Smrg } 46481fb744b4Smrg fi 4649c35d236eSmrg 46501fb744b4Smrg # Prepare the list of exported symbols 46511fb744b4Smrg if test -z "$export_symbols"; then 465214210e8eSmrg export_symbols=$output_objdir/$outputname.exp 46531fb744b4Smrg $opt_dry_run || { 46541fb744b4Smrg $RM $export_symbols 465514210e8eSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 46561fb744b4Smrg case $host in 46571fb744b4Smrg *cygwin* | *mingw* | *cegcc* ) 46581fb744b4Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46591fb744b4Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 46601fb744b4Smrg ;; 46611fb744b4Smrg esac 46621fb744b4Smrg } 46631fb744b4Smrg else 46641fb744b4Smrg $opt_dry_run || { 466514210e8eSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 46661fb744b4Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 46671fb744b4Smrg eval '$MV "$nlist"T "$nlist"' 46681fb744b4Smrg case $host in 46691fb744b4Smrg *cygwin* | *mingw* | *cegcc* ) 46701fb744b4Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46711fb744b4Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 46721fb744b4Smrg ;; 46731fb744b4Smrg esac 46741fb744b4Smrg } 46751fb744b4Smrg fi 46761fb744b4Smrg fi 4677c35d236eSmrg 46781fb744b4Smrg for dlprefile in $dlprefiles; do 467914210e8eSmrg func_verbose "extracting global C symbols from '$dlprefile'" 46801fb744b4Smrg func_basename "$dlprefile" 468114210e8eSmrg name=$func_basename_result 46821fb744b4Smrg case $host in 46831fb744b4Smrg *cygwin* | *mingw* | *cegcc* ) 46841fb744b4Smrg # if an import library, we need to obtain dlname 46851fb744b4Smrg if func_win32_import_lib_p "$dlprefile"; then 46861fb744b4Smrg func_tr_sh "$dlprefile" 46871fb744b4Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468814210e8eSmrg dlprefile_dlbasename= 46891fb744b4Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 46901fb744b4Smrg # Use subshell, to avoid clobbering current variable values 46911fb744b4Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469214210e8eSmrg if test -n "$dlprefile_dlname"; then 46931fb744b4Smrg func_basename "$dlprefile_dlname" 469414210e8eSmrg dlprefile_dlbasename=$func_basename_result 46951fb744b4Smrg else 46961fb744b4Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 46971fb744b4Smrg $sharedlib_from_linklib_cmd "$dlprefile" 46981fb744b4Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 46991fb744b4Smrg fi 47001fb744b4Smrg fi 47011fb744b4Smrg $opt_dry_run || { 470214210e8eSmrg if test -n "$dlprefile_dlbasename"; then 47031fb744b4Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 47041fb744b4Smrg else 47051fb744b4Smrg func_warning "Could not compute DLL name from $name" 47061fb744b4Smrg eval '$ECHO ": $name " >> "$nlist"' 47071fb744b4Smrg fi 47081fb744b4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47091fb744b4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 47101fb744b4Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 47111fb744b4Smrg } 47121fb744b4Smrg else # not an import lib 47131fb744b4Smrg $opt_dry_run || { 47141fb744b4Smrg eval '$ECHO ": $name " >> "$nlist"' 47151fb744b4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47161fb744b4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47171fb744b4Smrg } 47181fb744b4Smrg fi 47191fb744b4Smrg ;; 47201fb744b4Smrg *) 47211fb744b4Smrg $opt_dry_run || { 47221fb744b4Smrg eval '$ECHO ": $name " >> "$nlist"' 47231fb744b4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47241fb744b4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47251fb744b4Smrg } 47261fb744b4Smrg ;; 47271fb744b4Smrg esac 47281fb744b4Smrg done 4729c35d236eSmrg 47301fb744b4Smrg $opt_dry_run || { 47311fb744b4Smrg # Make sure we have at least an empty file. 47321fb744b4Smrg test -f "$nlist" || : > "$nlist" 4733c35d236eSmrg 47341fb744b4Smrg if test -n "$exclude_expsyms"; then 47351fb744b4Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 47361fb744b4Smrg $MV "$nlist"T "$nlist" 47371fb744b4Smrg fi 4738c35d236eSmrg 47391fb744b4Smrg # Try sorting and uniquifying the output. 47401fb744b4Smrg if $GREP -v "^: " < "$nlist" | 47411fb744b4Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 47421fb744b4Smrg sort -k 3 47431fb744b4Smrg else 47441fb744b4Smrg sort +2 47451fb744b4Smrg fi | 47461fb744b4Smrg uniq > "$nlist"S; then 47471fb744b4Smrg : 47481fb744b4Smrg else 47491fb744b4Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 47501fb744b4Smrg fi 4751c35d236eSmrg 47521fb744b4Smrg if test -f "$nlist"S; then 47531fb744b4Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 47541fb744b4Smrg else 47551fb744b4Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 47561fb744b4Smrg fi 4757c35d236eSmrg 475814210e8eSmrg func_show_eval '$RM "${nlist}I"' 475914210e8eSmrg if test -n "$global_symbol_to_import"; then 476014210e8eSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476114210e8eSmrg fi 476214210e8eSmrg 47631fb744b4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 47641fb744b4Smrg 47651fb744b4Smrg/* The mapping between symbol names and symbols. */ 47661fb744b4Smrgtypedef struct { 47671fb744b4Smrg const char *name; 47681fb744b4Smrg void *address; 47691fb744b4Smrg} lt_dlsymlist; 47701fb744b4Smrgextern LT_DLSYM_CONST lt_dlsymlist 477114210e8eSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477214210e8eSmrg" 477314210e8eSmrg 477414210e8eSmrg if test -s "$nlist"I; then 477514210e8eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 477614210e8eSmrgstatic void lt_syminit(void) 477714210e8eSmrg{ 477814210e8eSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477914210e8eSmrg for (; symbol->name; ++symbol) 478014210e8eSmrg {" 478114210e8eSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478214210e8eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 478314210e8eSmrg } 478414210e8eSmrg}" 478514210e8eSmrg fi 478614210e8eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47871fb744b4SmrgLT_DLSYM_CONST lt_dlsymlist 47881fb744b4Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 478914210e8eSmrg{ {\"$my_originator\", (void *) 0}," 479014210e8eSmrg 479114210e8eSmrg if test -s "$nlist"I; then 479214210e8eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 479314210e8eSmrg {\"@INIT@\", (void *) <_syminit}," 479414210e8eSmrg fi 47951fb744b4Smrg 47961fb744b4Smrg case $need_lib_prefix in 47971fb744b4Smrg no) 47981fb744b4Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799f55e6a01Smrg ;; 4800518bcf38Smrg *) 48011fb744b4Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802518bcf38Smrg ;; 4803518bcf38Smrg esac 48041fb744b4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 48051fb744b4Smrg {0, (void *) 0} 48061fb744b4Smrg}; 4807c35d236eSmrg 48081fb744b4Smrg/* This works around a problem in FreeBSD linker */ 48091fb744b4Smrg#ifdef FREEBSD_WORKAROUND 48101fb744b4Smrgstatic const void *lt_preloaded_setup() { 48111fb744b4Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 48121fb744b4Smrg} 48131fb744b4Smrg#endif 4814c35d236eSmrg 48151fb744b4Smrg#ifdef __cplusplus 48161fb744b4Smrg} 48171fb744b4Smrg#endif\ 48181fb744b4Smrg" 48191fb744b4Smrg } # !$opt_dry_run 4820c35d236eSmrg 48211fb744b4Smrg pic_flag_for_symtable= 48221fb744b4Smrg case "$compile_command " in 48231fb744b4Smrg *" -static "*) ;; 48241fb744b4Smrg *) 48251fb744b4Smrg case $host in 48261fb744b4Smrg # compiling the symbol table file with pic_flag works around 48271fb744b4Smrg # a FreeBSD bug that causes programs to crash when -lm is 48281fb744b4Smrg # linked before any other PIC object. But we must not use 48291fb744b4Smrg # pic_flag when linking with -static. The problem exists in 48301fb744b4Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 48311fb744b4Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 48321fb744b4Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 48331fb744b4Smrg *-*-hpux*) 48341fb744b4Smrg pic_flag_for_symtable=" $pic_flag" ;; 48351fb744b4Smrg *) 483614210e8eSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 48371fb744b4Smrg ;; 48381fb744b4Smrg esac 48391fb744b4Smrg ;; 48401fb744b4Smrg esac 48411fb744b4Smrg symtab_cflags= 48421fb744b4Smrg for arg in $LTCFLAGS; do 48431fb744b4Smrg case $arg in 48441fb744b4Smrg -pie | -fpie | -fPIE) ;; 48451fb744b4Smrg *) func_append symtab_cflags " $arg" ;; 4846518bcf38Smrg esac 4847518bcf38Smrg done 4848c35d236eSmrg 48491fb744b4Smrg # Now compile the dynamic symbol file. 48501fb744b4Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851c35d236eSmrg 48521fb744b4Smrg # Clean up the generated files. 485314210e8eSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854c35d236eSmrg 48551fb744b4Smrg # Transform the symbol file into the correct name. 485614210e8eSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 48571fb744b4Smrg case $host in 48581fb744b4Smrg *cygwin* | *mingw* | *cegcc* ) 48591fb744b4Smrg if test -f "$output_objdir/$my_outputname.def"; then 48601fb744b4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48611fb744b4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48621fb744b4Smrg else 48631fb744b4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48641fb744b4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48651fb744b4Smrg fi 48661fb744b4Smrg ;; 48671fb744b4Smrg *) 48681fb744b4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48691fb744b4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48701fb744b4Smrg ;; 48711fb744b4Smrg esac 48721fb744b4Smrg ;; 48731fb744b4Smrg *) 487414210e8eSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 48751fb744b4Smrg ;; 48761fb744b4Smrg esac 48771fb744b4Smrg else 48781fb744b4Smrg # We keep going just in case the user didn't refer to 48791fb744b4Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 48801fb744b4Smrg # really was required. 4881c35d236eSmrg 48821fb744b4Smrg # Nullify the symbol file. 48831fb744b4Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 48841fb744b4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 48851fb744b4Smrg fi 48861fb744b4Smrg} 4887c35d236eSmrg 488814210e8eSmrg# func_cygming_gnu_implib_p ARG 488914210e8eSmrg# This predicate returns with zero status (TRUE) if 489014210e8eSmrg# ARG is a GNU/binutils-style import library. Returns 489114210e8eSmrg# with nonzero status (FALSE) otherwise. 489214210e8eSmrgfunc_cygming_gnu_implib_p () 489314210e8eSmrg{ 489414210e8eSmrg $debug_cmd 489514210e8eSmrg 489614210e8eSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489714210e8eSmrg 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)$'` 489814210e8eSmrg test -n "$func_cygming_gnu_implib_tmp" 489914210e8eSmrg} 490014210e8eSmrg 490114210e8eSmrg# func_cygming_ms_implib_p ARG 490214210e8eSmrg# This predicate returns with zero status (TRUE) if 490314210e8eSmrg# ARG is an MS-style import library. Returns 490414210e8eSmrg# with nonzero status (FALSE) otherwise. 490514210e8eSmrgfunc_cygming_ms_implib_p () 490614210e8eSmrg{ 490714210e8eSmrg $debug_cmd 490814210e8eSmrg 490914210e8eSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491014210e8eSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491114210e8eSmrg test -n "$func_cygming_ms_implib_tmp" 491214210e8eSmrg} 491314210e8eSmrg 49141fb744b4Smrg# func_win32_libid arg 49151fb744b4Smrg# return the library type of file 'arg' 49161fb744b4Smrg# 49171fb744b4Smrg# Need a lot of goo to handle *both* DLLs and import libs 49181fb744b4Smrg# Has to be a shell function in order to 'eat' the argument 49191fb744b4Smrg# that is supplied when $file_magic_command is called. 49201fb744b4Smrg# Despite the name, also deal with 64 bit binaries. 49211fb744b4Smrgfunc_win32_libid () 49221fb744b4Smrg{ 492314210e8eSmrg $debug_cmd 492414210e8eSmrg 492514210e8eSmrg win32_libid_type=unknown 49261fb744b4Smrg win32_fileres=`file -L $1 2>/dev/null` 49271fb744b4Smrg case $win32_fileres in 49281fb744b4Smrg *ar\ archive\ import\ library*) # definitely import 49291fb744b4Smrg win32_libid_type="x86 archive import" 49301fb744b4Smrg ;; 49311fb744b4Smrg *ar\ archive*) # could be an import, or static 49321fb744b4Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 49331fb744b4Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 49341fb744b4Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493514210e8eSmrg case $nm_interface in 493614210e8eSmrg "MS dumpbin") 493714210e8eSmrg if func_cygming_ms_implib_p "$1" || 493814210e8eSmrg func_cygming_gnu_implib_p "$1" 493914210e8eSmrg then 494014210e8eSmrg win32_nmres=import 494114210e8eSmrg else 494214210e8eSmrg win32_nmres= 494314210e8eSmrg fi 494414210e8eSmrg ;; 494514210e8eSmrg *) 494614210e8eSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494714210e8eSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494814210e8eSmrg $SED -n -e ' 49491fb744b4Smrg 1,100{ 49501fb744b4Smrg / I /{ 495114210e8eSmrg s|.*|import| 49521fb744b4Smrg p 49531fb744b4Smrg q 49541fb744b4Smrg } 49551fb744b4Smrg }'` 495614210e8eSmrg ;; 495714210e8eSmrg esac 49581fb744b4Smrg case $win32_nmres in 49591fb744b4Smrg import*) win32_libid_type="x86 archive import";; 49601fb744b4Smrg *) win32_libid_type="x86 archive static";; 49611fb744b4Smrg esac 49621fb744b4Smrg fi 49631fb744b4Smrg ;; 49641fb744b4Smrg *DLL*) 49651fb744b4Smrg win32_libid_type="x86 DLL" 49661fb744b4Smrg ;; 49671fb744b4Smrg *executable*) # but shell scripts are "executable" too... 49681fb744b4Smrg case $win32_fileres in 49691fb744b4Smrg *MS\ Windows\ PE\ Intel*) 49701fb744b4Smrg win32_libid_type="x86 DLL" 49711fb744b4Smrg ;; 49721fb744b4Smrg esac 49731fb744b4Smrg ;; 49741fb744b4Smrg esac 49751fb744b4Smrg $ECHO "$win32_libid_type" 49761fb744b4Smrg} 49771fb744b4Smrg 49781fb744b4Smrg# func_cygming_dll_for_implib ARG 49791fb744b4Smrg# 49801fb744b4Smrg# Platform-specific function to extract the 49811fb744b4Smrg# name of the DLL associated with the specified 49821fb744b4Smrg# import library ARG. 49831fb744b4Smrg# Invoked by eval'ing the libtool variable 49841fb744b4Smrg# $sharedlib_from_linklib_cmd 49851fb744b4Smrg# Result is available in the variable 49861fb744b4Smrg# $sharedlib_from_linklib_result 49871fb744b4Smrgfunc_cygming_dll_for_implib () 49881fb744b4Smrg{ 498914210e8eSmrg $debug_cmd 499014210e8eSmrg 49911fb744b4Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 49921fb744b4Smrg} 49931fb744b4Smrg 49941fb744b4Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 49951fb744b4Smrg# 49961fb744b4Smrg# The is the core of a fallback implementation of a 49971fb744b4Smrg# platform-specific function to extract the name of the 49981fb744b4Smrg# DLL associated with the specified import library LIBNAME. 49991fb744b4Smrg# 50001fb744b4Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 50011fb744b4Smrg# on the platform and compiler that created the implib. 50021fb744b4Smrg# 50031fb744b4Smrg# Echos the name of the DLL associated with the 50041fb744b4Smrg# specified import library. 50051fb744b4Smrgfunc_cygming_dll_for_implib_fallback_core () 50061fb744b4Smrg{ 500714210e8eSmrg $debug_cmd 500814210e8eSmrg 50091fb744b4Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 50101fb744b4Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 50111fb744b4Smrg $SED '/^Contents of section '"$match_literal"':/{ 50121fb744b4Smrg # Place marker at beginning of archive member dllname section 50131fb744b4Smrg s/.*/====MARK====/ 50141fb744b4Smrg p 50151fb744b4Smrg d 50161fb744b4Smrg } 50171fb744b4Smrg # These lines can sometimes be longer than 43 characters, but 50181fb744b4Smrg # are always uninteresting 50191fb744b4Smrg /:[ ]*file format pe[i]\{,1\}-/d 50201fb744b4Smrg /^In archive [^:]*:/d 50211fb744b4Smrg # Ensure marker is printed 50221fb744b4Smrg /^====MARK====/p 50231fb744b4Smrg # Remove all lines with less than 43 characters 50241fb744b4Smrg /^.\{43\}/!d 50251fb744b4Smrg # From remaining lines, remove first 43 characters 50261fb744b4Smrg s/^.\{43\}//' | 50271fb744b4Smrg $SED -n ' 50281fb744b4Smrg # Join marker and all lines until next marker into a single line 50291fb744b4Smrg /^====MARK====/ b para 50301fb744b4Smrg H 50311fb744b4Smrg $ b para 50321fb744b4Smrg b 50331fb744b4Smrg :para 50341fb744b4Smrg x 50351fb744b4Smrg s/\n//g 50361fb744b4Smrg # Remove the marker 50371fb744b4Smrg s/^====MARK====// 50381fb744b4Smrg # Remove trailing dots and whitespace 50391fb744b4Smrg s/[\. \t]*$// 50401fb744b4Smrg # Print 50411fb744b4Smrg /./p' | 50421fb744b4Smrg # we now have a list, one entry per line, of the stringified 50431fb744b4Smrg # contents of the appropriate section of all members of the 504414210e8eSmrg # archive that possess that section. Heuristic: eliminate 504514210e8eSmrg # all those that have a first or second character that is 50461fb744b4Smrg # a '.' (that is, objdump's representation of an unprintable 50471fb744b4Smrg # character.) This should work for all archives with less than 50481fb744b4Smrg # 0x302f exports -- but will fail for DLLs whose name actually 50491fb744b4Smrg # begins with a literal '.' or a single character followed by 50501fb744b4Smrg # a '.'. 50511fb744b4Smrg # 50521fb744b4Smrg # Of those that remain, print the first one. 50531fb744b4Smrg $SED -e '/^\./d;/^.\./d;q' 50541fb744b4Smrg} 50551fb744b4Smrg 50561fb744b4Smrg# func_cygming_dll_for_implib_fallback ARG 50571fb744b4Smrg# Platform-specific function to extract the 50581fb744b4Smrg# name of the DLL associated with the specified 50591fb744b4Smrg# import library ARG. 50601fb744b4Smrg# 50611fb744b4Smrg# This fallback implementation is for use when $DLLTOOL 50621fb744b4Smrg# does not support the --identify-strict option. 50631fb744b4Smrg# Invoked by eval'ing the libtool variable 50641fb744b4Smrg# $sharedlib_from_linklib_cmd 50651fb744b4Smrg# Result is available in the variable 50661fb744b4Smrg# $sharedlib_from_linklib_result 50671fb744b4Smrgfunc_cygming_dll_for_implib_fallback () 50681fb744b4Smrg{ 506914210e8eSmrg $debug_cmd 507014210e8eSmrg 507114210e8eSmrg if func_cygming_gnu_implib_p "$1"; then 50721fb744b4Smrg # binutils import library 50731fb744b4Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507414210e8eSmrg elif func_cygming_ms_implib_p "$1"; then 50751fb744b4Smrg # ms-generated import library 50761fb744b4Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 50771fb744b4Smrg else 50781fb744b4Smrg # unknown 507914210e8eSmrg sharedlib_from_linklib_result= 50801fb744b4Smrg fi 50811fb744b4Smrg} 50821fb744b4Smrg 50831fb744b4Smrg 50841fb744b4Smrg# func_extract_an_archive dir oldlib 50851fb744b4Smrgfunc_extract_an_archive () 50861fb744b4Smrg{ 508714210e8eSmrg $debug_cmd 508814210e8eSmrg 508914210e8eSmrg f_ex_an_ar_dir=$1; shift 509014210e8eSmrg f_ex_an_ar_oldlib=$1 509114210e8eSmrg if test yes = "$lock_old_archive_extraction"; then 50921fb744b4Smrg lockfile=$f_ex_an_ar_oldlib.lock 50931fb744b4Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 50941fb744b4Smrg func_echo "Waiting for $lockfile to be removed" 50951fb744b4Smrg sleep 2 5096518bcf38Smrg done 50971fb744b4Smrg fi 50981fb744b4Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 50991fb744b4Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510014210e8eSmrg if test yes = "$lock_old_archive_extraction"; then 51011fb744b4Smrg $opt_dry_run || rm -f "$lockfile" 51021fb744b4Smrg fi 51031fb744b4Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 51041fb744b4Smrg : 51051fb744b4Smrg else 51061fb744b4Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 51071fb744b4Smrg fi 51081fb744b4Smrg} 5109c35d236eSmrg 51101fb744b4Smrg 51111fb744b4Smrg# func_extract_archives gentop oldlib ... 51121fb744b4Smrgfunc_extract_archives () 51131fb744b4Smrg{ 511414210e8eSmrg $debug_cmd 511514210e8eSmrg 511614210e8eSmrg my_gentop=$1; shift 51171fb744b4Smrg my_oldlibs=${1+"$@"} 511814210e8eSmrg my_oldobjs= 511914210e8eSmrg my_xlib= 512014210e8eSmrg my_xabs= 512114210e8eSmrg my_xdir= 51221fb744b4Smrg 51231fb744b4Smrg for my_xlib in $my_oldlibs; do 51241fb744b4Smrg # Extract the objects. 51251fb744b4Smrg case $my_xlib in 512614210e8eSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 51271fb744b4Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 51281fb744b4Smrg esac 51291fb744b4Smrg func_basename "$my_xlib" 513014210e8eSmrg my_xlib=$func_basename_result 51311fb744b4Smrg my_xlib_u=$my_xlib 51321fb744b4Smrg while :; do 51331fb744b4Smrg case " $extracted_archives " in 51341fb744b4Smrg *" $my_xlib_u "*) 51351fb744b4Smrg func_arith $extracted_serial + 1 51361fb744b4Smrg extracted_serial=$func_arith_result 51371fb744b4Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 51381fb744b4Smrg *) break ;; 5139518bcf38Smrg esac 5140518bcf38Smrg done 51411fb744b4Smrg extracted_archives="$extracted_archives $my_xlib_u" 514214210e8eSmrg my_xdir=$my_gentop/$my_xlib_u 5143c35d236eSmrg 51441fb744b4Smrg func_mkdir_p "$my_xdir" 5145c35d236eSmrg 51461fb744b4Smrg case $host in 51471fb744b4Smrg *-darwin*) 51481fb744b4Smrg func_verbose "Extracting $my_xabs" 51491fb744b4Smrg # Do not bother doing anything if just a dry run 51501fb744b4Smrg $opt_dry_run || { 51511fb744b4Smrg darwin_orig_dir=`pwd` 51521fb744b4Smrg cd $my_xdir || exit $? 51531fb744b4Smrg darwin_archive=$my_xabs 51541fb744b4Smrg darwin_curdir=`pwd` 515514210e8eSmrg func_basename "$darwin_archive" 515614210e8eSmrg darwin_base_archive=$func_basename_result 51571fb744b4Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 51581fb744b4Smrg if test -n "$darwin_arches"; then 51591fb744b4Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 51601fb744b4Smrg darwin_arch= 51611fb744b4Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516214210e8eSmrg for darwin_arch in $darwin_arches; do 516314210e8eSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516414210e8eSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516514210e8eSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516614210e8eSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 51671fb744b4Smrg cd "$darwin_curdir" 516814210e8eSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 51691fb744b4Smrg done # $darwin_arches 51701fb744b4Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517114210e8eSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 51721fb744b4Smrg darwin_file= 51731fb744b4Smrg darwin_files= 51741fb744b4Smrg for darwin_file in $darwin_filelist; do 51751fb744b4Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 51761fb744b4Smrg $LIPO -create -output "$darwin_file" $darwin_files 51771fb744b4Smrg done # $darwin_filelist 51781fb744b4Smrg $RM -rf unfat-$$ 51791fb744b4Smrg cd "$darwin_orig_dir" 5180518bcf38Smrg else 51811fb744b4Smrg cd $darwin_orig_dir 51821fb744b4Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 51831fb744b4Smrg fi # $darwin_arches 51841fb744b4Smrg } # !$opt_dry_run 51851fb744b4Smrg ;; 51861fb744b4Smrg *) 51871fb744b4Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 51881fb744b4Smrg ;; 51891fb744b4Smrg esac 51901fb744b4Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 51911fb744b4Smrg done 5192c35d236eSmrg 519314210e8eSmrg func_extract_archives_result=$my_oldobjs 51941fb744b4Smrg} 5195c35d236eSmrg 5196c35d236eSmrg 51971fb744b4Smrg# func_emit_wrapper [arg=no] 51981fb744b4Smrg# 51991fb744b4Smrg# Emit a libtool wrapper script on stdout. 52001fb744b4Smrg# Don't directly open a file because we may want to 52011fb744b4Smrg# incorporate the script contents within a cygwin/mingw 52021fb744b4Smrg# wrapper executable. Must ONLY be called from within 52031fb744b4Smrg# func_mode_link because it depends on a number of variables 52041fb744b4Smrg# set therein. 52051fb744b4Smrg# 52061fb744b4Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 52071fb744b4Smrg# variable will take. If 'yes', then the emitted script 520814210e8eSmrg# will assume that the directory where it is stored is 52091fb744b4Smrg# the $objdir directory. This is a cygwin/mingw-specific 52101fb744b4Smrg# behavior. 52111fb744b4Smrgfunc_emit_wrapper () 52121fb744b4Smrg{ 52131fb744b4Smrg func_emit_wrapper_arg1=${1-no} 5214c35d236eSmrg 52151fb744b4Smrg $ECHO "\ 52161fb744b4Smrg#! $SHELL 5217c35d236eSmrg 52181fb744b4Smrg# $output - temporary wrapper script for $objdir/$outputname 521914210e8eSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 52201fb744b4Smrg# 52211fb744b4Smrg# The $output program cannot be directly executed until all the libtool 52221fb744b4Smrg# libraries that it depends on are installed. 52231fb744b4Smrg# 52241fb744b4Smrg# This wrapper script should never be moved out of the build directory. 52251fb744b4Smrg# If it is, it will not operate correctly. 5226c35d236eSmrg 52271fb744b4Smrg# Sed substitution that helps us do robust quoting. It backslashifies 52281fb744b4Smrg# metacharacters that are still active within double-quoted strings. 52291fb744b4Smrgsed_quote_subst='$sed_quote_subst' 5230c35d236eSmrg 52311fb744b4Smrg# Be Bourne compatible 52321fb744b4Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 52331fb744b4Smrg emulate sh 52341fb744b4Smrg NULLCMD=: 52351fb744b4Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 52361fb744b4Smrg # is contrary to our usage. Disable this feature. 52371fb744b4Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 52381fb744b4Smrg setopt NO_GLOB_SUBST 52391fb744b4Smrgelse 52401fb744b4Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 52411fb744b4Smrgfi 52421fb744b4SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 52431fb744b4SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244c35d236eSmrg 52451fb744b4Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 52461fb744b4Smrg# if CDPATH is set. 52471fb744b4Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248c35d236eSmrg 52491fb744b4Smrgrelink_command=\"$relink_command\" 5250c35d236eSmrg 52511fb744b4Smrg# This environment variable determines our operation mode. 52521fb744b4Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 52531fb744b4Smrg # install mode needs the following variables: 52541fb744b4Smrg generated_by_libtool_version='$macro_version' 52551fb744b4Smrg notinst_deplibs='$notinst_deplibs' 52561fb744b4Smrgelse 52571fb744b4Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 52581fb744b4Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 52591fb744b4Smrg file=\"\$0\"" 5260c35d236eSmrg 52611fb744b4Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 52621fb744b4Smrg $ECHO "\ 5263c35d236eSmrg 52641fb744b4Smrg# A function that is used when there is no print builtin or printf. 52651fb744b4Smrgfunc_fallback_echo () 52661fb744b4Smrg{ 52671fb744b4Smrg eval 'cat <<_LTECHO_EOF 52681fb744b4Smrg\$1 52691fb744b4Smrg_LTECHO_EOF' 52701fb744b4Smrg} 52711fb744b4Smrg ECHO=\"$qECHO\" 52721fb744b4Smrg fi 5273c35d236eSmrg 52741fb744b4Smrg# Very basic option parsing. These options are (a) specific to 52751fb744b4Smrg# the libtool wrapper, (b) are identical between the wrapper 527614210e8eSmrg# /script/ and the wrapper /executable/ that is used only on 52771fb744b4Smrg# windows platforms, and (c) all begin with the string "--lt-" 527814210e8eSmrg# (application programs are unlikely to have options that match 52791fb744b4Smrg# this pattern). 52801fb744b4Smrg# 52811fb744b4Smrg# There are only two supported options: --lt-debug and 52821fb744b4Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 52831fb744b4Smrg# 52841fb744b4Smrg# The first argument to this parsing function should be the 52851fb744b4Smrg# script's $0 value, followed by "$@". 52861fb744b4Smrglt_option_debug= 52871fb744b4Smrgfunc_parse_lt_options () 52881fb744b4Smrg{ 52891fb744b4Smrg lt_script_arg0=\$0 52901fb744b4Smrg shift 52911fb744b4Smrg for lt_opt 52921fb744b4Smrg do 52931fb744b4Smrg case \"\$lt_opt\" in 52941fb744b4Smrg --lt-debug) lt_option_debug=1 ;; 52951fb744b4Smrg --lt-dump-script) 52961fb744b4Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 52971fb744b4Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 52981fb744b4Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 52991fb744b4Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 53001fb744b4Smrg exit 0 53011fb744b4Smrg ;; 53021fb744b4Smrg --lt-*) 53031fb744b4Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 53041fb744b4Smrg exit 1 53051fb744b4Smrg ;; 53061fb744b4Smrg esac 53071fb744b4Smrg done 5308c35d236eSmrg 53091fb744b4Smrg # Print the debug banner immediately: 53101fb744b4Smrg if test -n \"\$lt_option_debug\"; then 531114210e8eSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 53121fb744b4Smrg fi 53131fb744b4Smrg} 5314c35d236eSmrg 53151fb744b4Smrg# Used when --lt-debug. Prints its arguments to stdout 53161fb744b4Smrg# (redirection is the responsibility of the caller) 53171fb744b4Smrgfunc_lt_dump_args () 53181fb744b4Smrg{ 53191fb744b4Smrg lt_dump_args_N=1; 53201fb744b4Smrg for lt_arg 53211fb744b4Smrg do 532214210e8eSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 53231fb744b4Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 53241fb744b4Smrg done 53251fb744b4Smrg} 5326c35d236eSmrg 53271fb744b4Smrg# Core function for launching the target application 53281fb744b4Smrgfunc_exec_program_core () 53291fb744b4Smrg{ 53301fb744b4Smrg" 53311fb744b4Smrg case $host in 53321fb744b4Smrg # Backslashes separate directories on plain windows 53331fb744b4Smrg *-*-mingw | *-*-os2* | *-cegcc*) 53341fb744b4Smrg $ECHO "\ 53351fb744b4Smrg if test -n \"\$lt_option_debug\"; then 533614210e8eSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 53371fb744b4Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 53381fb744b4Smrg fi 53391fb744b4Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 53401fb744b4Smrg" 53411fb744b4Smrg ;; 5342c35d236eSmrg 53431fb744b4Smrg *) 53441fb744b4Smrg $ECHO "\ 53451fb744b4Smrg if test -n \"\$lt_option_debug\"; then 534614210e8eSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 53471fb744b4Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 53481fb744b4Smrg fi 53491fb744b4Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 53501fb744b4Smrg" 53511fb744b4Smrg ;; 53521fb744b4Smrg esac 53531fb744b4Smrg $ECHO "\ 53541fb744b4Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 53551fb744b4Smrg exit 1 53561fb744b4Smrg} 5357c35d236eSmrg 53581fb744b4Smrg# A function to encapsulate launching the target application 53591fb744b4Smrg# Strips options in the --lt-* namespace from \$@ and 53601fb744b4Smrg# launches target application with the remaining arguments. 53611fb744b4Smrgfunc_exec_program () 53621fb744b4Smrg{ 53631fb744b4Smrg case \" \$* \" in 53641fb744b4Smrg *\\ --lt-*) 53651fb744b4Smrg for lt_wr_arg 53661fb744b4Smrg do 53671fb744b4Smrg case \$lt_wr_arg in 53681fb744b4Smrg --lt-*) ;; 53691fb744b4Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 53701fb744b4Smrg esac 53711fb744b4Smrg shift 53721fb744b4Smrg done ;; 53731fb744b4Smrg esac 53741fb744b4Smrg func_exec_program_core \${1+\"\$@\"} 53751fb744b4Smrg} 5376c35d236eSmrg 53771fb744b4Smrg # Parse options 53781fb744b4Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379c35d236eSmrg 53801fb744b4Smrg # Find the directory that this script lives in. 53811fb744b4Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 53821fb744b4Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383c35d236eSmrg 53841fb744b4Smrg # Follow symbolic links until we get to the real thisdir. 53851fb744b4Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 53861fb744b4Smrg while test -n \"\$file\"; do 53871fb744b4Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388c35d236eSmrg 53891fb744b4Smrg # If there was a directory component, then change thisdir. 53901fb744b4Smrg if test \"x\$destdir\" != \"x\$file\"; then 53911fb744b4Smrg case \"\$destdir\" in 53921fb744b4Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 53931fb744b4Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 53941fb744b4Smrg esac 53951fb744b4Smrg fi 5396c35d236eSmrg 53971fb744b4Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 53981fb744b4Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 53991fb744b4Smrg done 5400c35d236eSmrg 54011fb744b4Smrg # Usually 'no', except on cygwin/mingw when embedded into 54021fb744b4Smrg # the cwrapper. 54031fb744b4Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 54041fb744b4Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 54051fb744b4Smrg # special case for '.' 54061fb744b4Smrg if test \"\$thisdir\" = \".\"; then 54071fb744b4Smrg thisdir=\`pwd\` 54081fb744b4Smrg fi 54091fb744b4Smrg # remove .libs from thisdir 54101fb744b4Smrg case \"\$thisdir\" in 54111fb744b4Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 54121fb744b4Smrg $objdir ) thisdir=. ;; 54131fb744b4Smrg esac 54141fb744b4Smrg fi 5415c35d236eSmrg 54161fb744b4Smrg # Try to get the absolute directory name. 54171fb744b4Smrg absdir=\`cd \"\$thisdir\" && pwd\` 54181fb744b4Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 54191fb744b4Smrg" 5420c35d236eSmrg 542114210e8eSmrg if test yes = "$fast_install"; then 54221fb744b4Smrg $ECHO "\ 54231fb744b4Smrg program=lt-'$outputname'$exeext 54241fb744b4Smrg progdir=\"\$thisdir/$objdir\" 5425c35d236eSmrg 54261fb744b4Smrg if test ! -f \"\$progdir/\$program\" || 542714210e8eSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 54281fb744b4Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429c35d236eSmrg 54301fb744b4Smrg file=\"\$\$-\$program\" 5431c35d236eSmrg 54321fb744b4Smrg if test ! -d \"\$progdir\"; then 54331fb744b4Smrg $MKDIR \"\$progdir\" 54341fb744b4Smrg else 54351fb744b4Smrg $RM \"\$progdir/\$file\" 54361fb744b4Smrg fi" 5437c35d236eSmrg 54381fb744b4Smrg $ECHO "\ 5439c35d236eSmrg 54401fb744b4Smrg # relink executable if necessary 54411fb744b4Smrg if test -n \"\$relink_command\"; then 54421fb744b4Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 54431fb744b4Smrg else 544414210e8eSmrg \$ECHO \"\$relink_command_output\" >&2 54451fb744b4Smrg $RM \"\$progdir/\$file\" 54461fb744b4Smrg exit 1 54471fb744b4Smrg fi 54481fb744b4Smrg fi 5449518bcf38Smrg 54501fb744b4Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 54511fb744b4Smrg { $RM \"\$progdir/\$program\"; 54521fb744b4Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 54531fb744b4Smrg $RM \"\$progdir/\$file\" 54541fb744b4Smrg fi" 54551fb744b4Smrg else 54561fb744b4Smrg $ECHO "\ 54571fb744b4Smrg program='$outputname' 54581fb744b4Smrg progdir=\"\$thisdir/$objdir\" 54591fb744b4Smrg" 54601fb744b4Smrg fi 5461518bcf38Smrg 54621fb744b4Smrg $ECHO "\ 5463518bcf38Smrg 54641fb744b4Smrg if test -f \"\$progdir/\$program\"; then" 54651fb744b4Smrg 54661fb744b4Smrg # fixup the dll searchpath if we need to. 54671fb744b4Smrg # 54681fb744b4Smrg # Fix the DLL searchpath if we need to. Do this before prepending 54691fb744b4Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 54701fb744b4Smrg # libraries must come first. 54711fb744b4Smrg if test -n "$dllsearchpath"; then 54721fb744b4Smrg $ECHO "\ 54731fb744b4Smrg # Add the dll search path components to the executable PATH 54741fb744b4Smrg PATH=$dllsearchpath:\$PATH 54751fb744b4Smrg" 5476518bcf38Smrg fi 5477518bcf38Smrg 54781fb744b4Smrg # Export our shlibpath_var if we have one. 547914210e8eSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 54801fb744b4Smrg $ECHO "\ 54811fb744b4Smrg # Add our own library path to $shlibpath_var 54821fb744b4Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483518bcf38Smrg 54841fb744b4Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 54851fb744b4Smrg # The second colon is a workaround for a bug in BeOS R4 sed 54861fb744b4Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 54871fb744b4Smrg 54881fb744b4Smrg export $shlibpath_var 54891fb744b4Smrg" 5490518bcf38Smrg fi 5491c35d236eSmrg 54921fb744b4Smrg $ECHO "\ 54931fb744b4Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 54941fb744b4Smrg # Run the actual program with our arguments. 54951fb744b4Smrg func_exec_program \${1+\"\$@\"} 54961fb744b4Smrg fi 54971fb744b4Smrg else 54981fb744b4Smrg # The program doesn't exist. 549914210e8eSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 55001fb744b4Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 55011fb744b4Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 55021fb744b4Smrg exit 1 55031fb744b4Smrg fi 55041fb744b4Smrgfi\ 55051fb744b4Smrg" 55061fb744b4Smrg} 5507c35d236eSmrg 5508c35d236eSmrg 55091fb744b4Smrg# func_emit_cwrapperexe_src 55101fb744b4Smrg# emit the source code for a wrapper executable on stdout 55111fb744b4Smrg# Must ONLY be called from within func_mode_link because 55121fb744b4Smrg# it depends on a number of variable set therein. 55131fb744b4Smrgfunc_emit_cwrapperexe_src () 55141fb744b4Smrg{ 55151fb744b4Smrg cat <<EOF 5516518bcf38Smrg 55171fb744b4Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551814210e8eSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519518bcf38Smrg 55201fb744b4Smrg The $output program cannot be directly executed until all the libtool 55211fb744b4Smrg libraries that it depends on are installed. 5522518bcf38Smrg 55231fb744b4Smrg This wrapper executable should never be moved out of the build directory. 55241fb744b4Smrg If it is, it will not operate correctly. 55251fb744b4Smrg*/ 55261fb744b4SmrgEOF 55271fb744b4Smrg cat <<"EOF" 55281fb744b4Smrg#ifdef _MSC_VER 55291fb744b4Smrg# define _CRT_SECURE_NO_DEPRECATE 1 55301fb744b4Smrg#endif 55311fb744b4Smrg#include <stdio.h> 55321fb744b4Smrg#include <stdlib.h> 55331fb744b4Smrg#ifdef _MSC_VER 55341fb744b4Smrg# include <direct.h> 55351fb744b4Smrg# include <process.h> 55361fb744b4Smrg# include <io.h> 55371fb744b4Smrg#else 55381fb744b4Smrg# include <unistd.h> 55391fb744b4Smrg# include <stdint.h> 55401fb744b4Smrg# ifdef __CYGWIN__ 55411fb744b4Smrg# include <io.h> 55421fb744b4Smrg# endif 55431fb744b4Smrg#endif 55441fb744b4Smrg#include <malloc.h> 55451fb744b4Smrg#include <stdarg.h> 55461fb744b4Smrg#include <assert.h> 55471fb744b4Smrg#include <string.h> 55481fb744b4Smrg#include <ctype.h> 55491fb744b4Smrg#include <errno.h> 55501fb744b4Smrg#include <fcntl.h> 55511fb744b4Smrg#include <sys/stat.h> 5552518bcf38Smrg 555314210e8eSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555414210e8eSmrg 55551fb744b4Smrg/* declarations of non-ANSI functions */ 555614210e8eSmrg#if defined __MINGW32__ 55571fb744b4Smrg# ifdef __STRICT_ANSI__ 55581fb744b4Smrgint _putenv (const char *); 55591fb744b4Smrg# endif 556014210e8eSmrg#elif defined __CYGWIN__ 55611fb744b4Smrg# ifdef __STRICT_ANSI__ 55621fb744b4Smrgchar *realpath (const char *, char *); 55631fb744b4Smrgint putenv (char *); 55641fb744b4Smrgint setenv (const char *, const char *, int); 55651fb744b4Smrg# endif 556614210e8eSmrg/* #elif defined other_platform || defined ... */ 55671fb744b4Smrg#endif 5568c35d236eSmrg 55691fb744b4Smrg/* portability defines, excluding path handling macros */ 557014210e8eSmrg#if defined _MSC_VER 55711fb744b4Smrg# define setmode _setmode 55721fb744b4Smrg# define stat _stat 55731fb744b4Smrg# define chmod _chmod 55741fb744b4Smrg# define getcwd _getcwd 55751fb744b4Smrg# define putenv _putenv 55761fb744b4Smrg# define S_IXUSR _S_IEXEC 557714210e8eSmrg#elif defined __MINGW32__ 55781fb744b4Smrg# define setmode _setmode 55791fb744b4Smrg# define stat _stat 55801fb744b4Smrg# define chmod _chmod 55811fb744b4Smrg# define getcwd _getcwd 55821fb744b4Smrg# define putenv _putenv 558314210e8eSmrg#elif defined __CYGWIN__ 55841fb744b4Smrg# define HAVE_SETENV 55851fb744b4Smrg# define FOPEN_WB "wb" 558614210e8eSmrg/* #elif defined other platforms ... */ 55871fb744b4Smrg#endif 5588c35d236eSmrg 558914210e8eSmrg#if defined PATH_MAX 55901fb744b4Smrg# define LT_PATHMAX PATH_MAX 559114210e8eSmrg#elif defined MAXPATHLEN 55921fb744b4Smrg# define LT_PATHMAX MAXPATHLEN 55931fb744b4Smrg#else 55941fb744b4Smrg# define LT_PATHMAX 1024 55951fb744b4Smrg#endif 5596c35d236eSmrg 55971fb744b4Smrg#ifndef S_IXOTH 55981fb744b4Smrg# define S_IXOTH 0 55991fb744b4Smrg#endif 56001fb744b4Smrg#ifndef S_IXGRP 56011fb744b4Smrg# define S_IXGRP 0 56021fb744b4Smrg#endif 5603c35d236eSmrg 56041fb744b4Smrg/* path handling portability macros */ 56051fb744b4Smrg#ifndef DIR_SEPARATOR 56061fb744b4Smrg# define DIR_SEPARATOR '/' 56071fb744b4Smrg# define PATH_SEPARATOR ':' 56081fb744b4Smrg#endif 5609c35d236eSmrg 561014210e8eSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561114210e8eSmrg defined __OS2__ 56121fb744b4Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 56131fb744b4Smrg# define FOPEN_WB "wb" 56141fb744b4Smrg# ifndef DIR_SEPARATOR_2 56151fb744b4Smrg# define DIR_SEPARATOR_2 '\\' 56161fb744b4Smrg# endif 56171fb744b4Smrg# ifndef PATH_SEPARATOR_2 56181fb744b4Smrg# define PATH_SEPARATOR_2 ';' 56191fb744b4Smrg# endif 56201fb744b4Smrg#endif 5621c35d236eSmrg 56221fb744b4Smrg#ifndef DIR_SEPARATOR_2 56231fb744b4Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 56241fb744b4Smrg#else /* DIR_SEPARATOR_2 */ 56251fb744b4Smrg# define IS_DIR_SEPARATOR(ch) \ 56261fb744b4Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 56271fb744b4Smrg#endif /* DIR_SEPARATOR_2 */ 5628c35d236eSmrg 56291fb744b4Smrg#ifndef PATH_SEPARATOR_2 56301fb744b4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 56311fb744b4Smrg#else /* PATH_SEPARATOR_2 */ 56321fb744b4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 56331fb744b4Smrg#endif /* PATH_SEPARATOR_2 */ 5634c35d236eSmrg 56351fb744b4Smrg#ifndef FOPEN_WB 56361fb744b4Smrg# define FOPEN_WB "w" 56371fb744b4Smrg#endif 56381fb744b4Smrg#ifndef _O_BINARY 56391fb744b4Smrg# define _O_BINARY 0 56401fb744b4Smrg#endif 5641c35d236eSmrg 56421fb744b4Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 56431fb744b4Smrg#define XFREE(stale) do { \ 564414210e8eSmrg if (stale) { free (stale); stale = 0; } \ 56451fb744b4Smrg} while (0) 5646c35d236eSmrg 564714210e8eSmrg#if defined LT_DEBUGWRAPPER 56481fb744b4Smrgstatic int lt_debug = 1; 56491fb744b4Smrg#else 56501fb744b4Smrgstatic int lt_debug = 0; 56511fb744b4Smrg#endif 5652c35d236eSmrg 56531fb744b4Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 56541fb744b4Smrg 56551fb744b4Smrgvoid *xmalloc (size_t num); 56561fb744b4Smrgchar *xstrdup (const char *string); 56571fb744b4Smrgconst char *base_name (const char *name); 56581fb744b4Smrgchar *find_executable (const char *wrapper); 56591fb744b4Smrgchar *chase_symlinks (const char *pathspec); 56601fb744b4Smrgint make_executable (const char *path); 56611fb744b4Smrgint check_executable (const char *path); 56621fb744b4Smrgchar *strendzap (char *str, const char *pat); 56631fb744b4Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 56641fb744b4Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 56651fb744b4Smrgstatic const char *nonnull (const char *s); 56661fb744b4Smrgstatic const char *nonempty (const char *s); 56671fb744b4Smrgvoid lt_setenv (const char *name, const char *value); 56681fb744b4Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 56691fb744b4Smrgvoid lt_update_exe_path (const char *name, const char *value); 56701fb744b4Smrgvoid lt_update_lib_path (const char *name, const char *value); 56711fb744b4Smrgchar **prepare_spawn (char **argv); 56721fb744b4Smrgvoid lt_dump_script (FILE *f); 56731fb744b4SmrgEOF 5674c35d236eSmrg 56751fb744b4Smrg cat <<EOF 567614210e8eSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567714210e8eSmrg# define externally_visible volatile 567814210e8eSmrg#else 567914210e8eSmrg# define externally_visible __attribute__((externally_visible)) volatile 568014210e8eSmrg#endif 568114210e8eSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 56821fb744b4Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 56831fb744b4SmrgEOF 5684c35d236eSmrg 568514210e8eSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 56861fb744b4Smrg func_to_host_path "$temp_rpath" 56871fb744b4Smrg cat <<EOF 56881fb744b4Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 56891fb744b4SmrgEOF 56901fb744b4Smrg else 56911fb744b4Smrg cat <<"EOF" 56921fb744b4Smrgconst char * LIB_PATH_VALUE = ""; 56931fb744b4SmrgEOF 56941fb744b4Smrg fi 5695c35d236eSmrg 56961fb744b4Smrg if test -n "$dllsearchpath"; then 56971fb744b4Smrg func_to_host_path "$dllsearchpath:" 56981fb744b4Smrg cat <<EOF 56991fb744b4Smrgconst char * EXE_PATH_VARNAME = "PATH"; 57001fb744b4Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 57011fb744b4SmrgEOF 57021fb744b4Smrg else 57031fb744b4Smrg cat <<"EOF" 57041fb744b4Smrgconst char * EXE_PATH_VARNAME = ""; 57051fb744b4Smrgconst char * EXE_PATH_VALUE = ""; 57061fb744b4SmrgEOF 57071fb744b4Smrg fi 5708c35d236eSmrg 570914210e8eSmrg if test yes = "$fast_install"; then 57101fb744b4Smrg cat <<EOF 57111fb744b4Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 57121fb744b4SmrgEOF 57131fb744b4Smrg else 57141fb744b4Smrg cat <<EOF 57151fb744b4Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 57161fb744b4SmrgEOF 57171fb744b4Smrg fi 5718c35d236eSmrg 5719c35d236eSmrg 57201fb744b4Smrg cat <<"EOF" 5721c35d236eSmrg 57221fb744b4Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723c35d236eSmrg 57241fb744b4Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 57251fb744b4Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 57261fb744b4Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727c35d236eSmrg 57281fb744b4Smrgint 57291fb744b4Smrgmain (int argc, char *argv[]) 57301fb744b4Smrg{ 57311fb744b4Smrg char **newargz; 57321fb744b4Smrg int newargc; 57331fb744b4Smrg char *tmp_pathspec; 57341fb744b4Smrg char *actual_cwrapper_path; 57351fb744b4Smrg char *actual_cwrapper_name; 57361fb744b4Smrg char *target_name; 57371fb744b4Smrg char *lt_argv_zero; 573814210e8eSmrg int rval = 127; 57391fb744b4Smrg 57401fb744b4Smrg int i; 5741c35d236eSmrg 57421fb744b4Smrg program_name = (char *) xstrdup (base_name (argv[0])); 574314210e8eSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744c35d236eSmrg 57451fb744b4Smrg /* very simple arg parsing; don't want to rely on getopt 57461fb744b4Smrg * also, copy all non cwrapper options to newargz, except 57471fb744b4Smrg * argz[0], which is handled differently 57481fb744b4Smrg */ 57491fb744b4Smrg newargc=0; 57501fb744b4Smrg for (i = 1; i < argc; i++) 57511fb744b4Smrg { 575214210e8eSmrg if (STREQ (argv[i], dumpscript_opt)) 57531fb744b4Smrg { 57541fb744b4SmrgEOF 575514210e8eSmrg case $host in 57561fb744b4Smrg *mingw* | *cygwin* ) 57571fb744b4Smrg # make stdout use "unix" line endings 57581fb744b4Smrg echo " setmode(1,_O_BINARY);" 57591fb744b4Smrg ;; 57601fb744b4Smrg esac 5761c35d236eSmrg 57621fb744b4Smrg cat <<"EOF" 57631fb744b4Smrg lt_dump_script (stdout); 57641fb744b4Smrg return 0; 57651fb744b4Smrg } 576614210e8eSmrg if (STREQ (argv[i], debug_opt)) 57671fb744b4Smrg { 57681fb744b4Smrg lt_debug = 1; 57691fb744b4Smrg continue; 57701fb744b4Smrg } 577114210e8eSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 57721fb744b4Smrg { 57731fb744b4Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 57741fb744b4Smrg namespace, but it is not one of the ones we know about and 57751fb744b4Smrg have already dealt with, above (inluding dump-script), then 57761fb744b4Smrg report an error. Otherwise, targets might begin to believe 57771fb744b4Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 57781fb744b4Smrg namespace. The first time any user complains about this, we'll 57791fb744b4Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 57801fb744b4Smrg or a configure.ac-settable value. 57811fb744b4Smrg */ 57821fb744b4Smrg lt_fatal (__FILE__, __LINE__, 57831fb744b4Smrg "unrecognized %s option: '%s'", 57841fb744b4Smrg ltwrapper_option_prefix, argv[i]); 57851fb744b4Smrg } 57861fb744b4Smrg /* otherwise ... */ 57871fb744b4Smrg newargz[++newargc] = xstrdup (argv[i]); 57881fb744b4Smrg } 57891fb744b4Smrg newargz[++newargc] = NULL; 5790c35d236eSmrg 57911fb744b4SmrgEOF 57921fb744b4Smrg cat <<EOF 57931fb744b4Smrg /* The GNU banner must be the first non-error debug message */ 579414210e8eSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 57951fb744b4SmrgEOF 57961fb744b4Smrg cat <<"EOF" 57971fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 57981fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 57991fb744b4Smrg 58001fb744b4Smrg tmp_pathspec = find_executable (argv[0]); 58011fb744b4Smrg if (tmp_pathspec == NULL) 58021fb744b4Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 58031fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 58041fb744b4Smrg "(main) found exe (before symlink chase) at: %s\n", 58051fb744b4Smrg tmp_pathspec); 58061fb744b4Smrg 58071fb744b4Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 58081fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 58091fb744b4Smrg "(main) found exe (after symlink chase) at: %s\n", 58101fb744b4Smrg actual_cwrapper_path); 58111fb744b4Smrg XFREE (tmp_pathspec); 58121fb744b4Smrg 58131fb744b4Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 58141fb744b4Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 58151fb744b4Smrg 58161fb744b4Smrg /* wrapper name transforms */ 58171fb744b4Smrg strendzap (actual_cwrapper_name, ".exe"); 58181fb744b4Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 58191fb744b4Smrg XFREE (actual_cwrapper_name); 58201fb744b4Smrg actual_cwrapper_name = tmp_pathspec; 58211fb744b4Smrg tmp_pathspec = 0; 58221fb744b4Smrg 58231fb744b4Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 58241fb744b4Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 58251fb744b4Smrg strendzap (target_name, ".exe"); 58261fb744b4Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 58271fb744b4Smrg XFREE (target_name); 58281fb744b4Smrg target_name = tmp_pathspec; 58291fb744b4Smrg tmp_pathspec = 0; 58301fb744b4Smrg 58311fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 58321fb744b4Smrg "(main) libtool target name: %s\n", 58331fb744b4Smrg target_name); 58341fb744b4SmrgEOF 58351fb744b4Smrg 58361fb744b4Smrg cat <<EOF 58371fb744b4Smrg newargz[0] = 58381fb744b4Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 58391fb744b4Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 58401fb744b4Smrg strcpy (newargz[0], actual_cwrapper_path); 58411fb744b4Smrg strcat (newargz[0], "$objdir"); 58421fb744b4Smrg strcat (newargz[0], "/"); 58431fb744b4SmrgEOF 58441fb744b4Smrg 58451fb744b4Smrg cat <<"EOF" 58461fb744b4Smrg /* stop here, and copy so we don't have to do this twice */ 58471fb744b4Smrg tmp_pathspec = xstrdup (newargz[0]); 58481fb744b4Smrg 58491fb744b4Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 58501fb744b4Smrg strcat (newargz[0], actual_cwrapper_name); 58511fb744b4Smrg 58521fb744b4Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 58531fb744b4Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 58541fb744b4Smrg XFREE (tmp_pathspec); 58551fb744b4Smrg tmp_pathspec = NULL; 58561fb744b4SmrgEOF 58571fb744b4Smrg 58581fb744b4Smrg case $host_os in 58591fb744b4Smrg mingw*) 58601fb744b4Smrg cat <<"EOF" 58611fb744b4Smrg { 58621fb744b4Smrg char* p; 58631fb744b4Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 58641fb744b4Smrg { 58651fb744b4Smrg *p = '/'; 58661fb744b4Smrg } 58671fb744b4Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 58681fb744b4Smrg { 58691fb744b4Smrg *p = '/'; 58701fb744b4Smrg } 58711fb744b4Smrg } 58721fb744b4SmrgEOF 58731fb744b4Smrg ;; 58741fb744b4Smrg esac 58751fb744b4Smrg 58761fb744b4Smrg cat <<"EOF" 58771fb744b4Smrg XFREE (target_name); 58781fb744b4Smrg XFREE (actual_cwrapper_path); 58791fb744b4Smrg XFREE (actual_cwrapper_name); 58801fb744b4Smrg 58811fb744b4Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 58821fb744b4Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 58831fb744b4Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 58841fb744b4Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 58851fb744b4Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 58861fb744b4Smrg libraries must come first. */ 58871fb744b4Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 58881fb744b4Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 58891fb744b4Smrg 58901fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 58911fb744b4Smrg nonnull (lt_argv_zero)); 58921fb744b4Smrg for (i = 0; i < newargc; i++) 58931fb744b4Smrg { 58941fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 58951fb744b4Smrg i, nonnull (newargz[i])); 58961fb744b4Smrg } 58971fb744b4Smrg 58981fb744b4SmrgEOF 58991fb744b4Smrg 59001fb744b4Smrg case $host_os in 59011fb744b4Smrg mingw*) 59021fb744b4Smrg cat <<"EOF" 59031fb744b4Smrg /* execv doesn't actually work on mingw as expected on unix */ 59041fb744b4Smrg newargz = prepare_spawn (newargz); 590514210e8eSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 59061fb744b4Smrg if (rval == -1) 59071fb744b4Smrg { 59081fb744b4Smrg /* failed to start process */ 59091fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 59101fb744b4Smrg "(main) failed to launch target \"%s\": %s\n", 59111fb744b4Smrg lt_argv_zero, nonnull (strerror (errno))); 59121fb744b4Smrg return 127; 59131fb744b4Smrg } 59141fb744b4Smrg return rval; 59151fb744b4SmrgEOF 5916518bcf38Smrg ;; 5917518bcf38Smrg *) 59181fb744b4Smrg cat <<"EOF" 59191fb744b4Smrg execv (lt_argv_zero, newargz); 59201fb744b4Smrg return rval; /* =127, but avoids unused variable warning */ 59211fb744b4SmrgEOF 5922518bcf38Smrg ;; 59231fb744b4Smrg esac 5924c35d236eSmrg 59251fb744b4Smrg cat <<"EOF" 59261fb744b4Smrg} 5927c35d236eSmrg 59281fb744b4Smrgvoid * 59291fb744b4Smrgxmalloc (size_t num) 59301fb744b4Smrg{ 59311fb744b4Smrg void *p = (void *) malloc (num); 59321fb744b4Smrg if (!p) 59331fb744b4Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934c35d236eSmrg 59351fb744b4Smrg return p; 59361fb744b4Smrg} 5937c35d236eSmrg 59381fb744b4Smrgchar * 59391fb744b4Smrgxstrdup (const char *string) 59401fb744b4Smrg{ 59411fb744b4Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 59421fb744b4Smrg string) : NULL; 59431fb744b4Smrg} 5944c35d236eSmrg 59451fb744b4Smrgconst char * 59461fb744b4Smrgbase_name (const char *name) 59471fb744b4Smrg{ 59481fb744b4Smrg const char *base; 5949c35d236eSmrg 595014210e8eSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 59511fb744b4Smrg /* Skip over the disk name in MSDOS pathnames. */ 59521fb744b4Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 59531fb744b4Smrg name += 2; 5954518bcf38Smrg#endif 5955c35d236eSmrg 59561fb744b4Smrg for (base = name; *name; name++) 59571fb744b4Smrg if (IS_DIR_SEPARATOR (*name)) 59581fb744b4Smrg base = name + 1; 59591fb744b4Smrg return base; 59601fb744b4Smrg} 5961c35d236eSmrg 59621fb744b4Smrgint 59631fb744b4Smrgcheck_executable (const char *path) 59641fb744b4Smrg{ 59651fb744b4Smrg struct stat st; 5966c35d236eSmrg 59671fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 59681fb744b4Smrg nonempty (path)); 59691fb744b4Smrg if ((!path) || (!*path)) 59701fb744b4Smrg return 0; 5971c35d236eSmrg 59721fb744b4Smrg if ((stat (path, &st) >= 0) 59731fb744b4Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 59741fb744b4Smrg return 1; 59751fb744b4Smrg else 59761fb744b4Smrg return 0; 59771fb744b4Smrg} 5978c35d236eSmrg 59791fb744b4Smrgint 59801fb744b4Smrgmake_executable (const char *path) 59811fb744b4Smrg{ 59821fb744b4Smrg int rval = 0; 59831fb744b4Smrg struct stat st; 5984c35d236eSmrg 59851fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 59861fb744b4Smrg nonempty (path)); 59871fb744b4Smrg if ((!path) || (!*path)) 59881fb744b4Smrg return 0; 5989c35d236eSmrg 59901fb744b4Smrg if (stat (path, &st) >= 0) 59911fb744b4Smrg { 59921fb744b4Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 59931fb744b4Smrg } 59941fb744b4Smrg return rval; 59951fb744b4Smrg} 5996c35d236eSmrg 59971fb744b4Smrg/* Searches for the full path of the wrapper. Returns 59981fb744b4Smrg newly allocated full path name if found, NULL otherwise 59991fb744b4Smrg Does not chase symlinks, even on platforms that support them. 60001fb744b4Smrg*/ 60011fb744b4Smrgchar * 60021fb744b4Smrgfind_executable (const char *wrapper) 60031fb744b4Smrg{ 60041fb744b4Smrg int has_slash = 0; 60051fb744b4Smrg const char *p; 60061fb744b4Smrg const char *p_next; 60071fb744b4Smrg /* static buffer for getcwd */ 60081fb744b4Smrg char tmp[LT_PATHMAX + 1]; 600914210e8eSmrg size_t tmp_len; 60101fb744b4Smrg char *concat_name; 6011c35d236eSmrg 60121fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 60131fb744b4Smrg nonempty (wrapper)); 6014c35d236eSmrg 60151fb744b4Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 60161fb744b4Smrg return NULL; 6017c35d236eSmrg 60181fb744b4Smrg /* Absolute path? */ 601914210e8eSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60201fb744b4Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 60211fb744b4Smrg { 60221fb744b4Smrg concat_name = xstrdup (wrapper); 60231fb744b4Smrg if (check_executable (concat_name)) 60241fb744b4Smrg return concat_name; 60251fb744b4Smrg XFREE (concat_name); 60261fb744b4Smrg } 60271fb744b4Smrg else 60281fb744b4Smrg { 60291fb744b4Smrg#endif 60301fb744b4Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 60311fb744b4Smrg { 60321fb744b4Smrg concat_name = xstrdup (wrapper); 60331fb744b4Smrg if (check_executable (concat_name)) 60341fb744b4Smrg return concat_name; 60351fb744b4Smrg XFREE (concat_name); 60361fb744b4Smrg } 603714210e8eSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60381fb744b4Smrg } 60391fb744b4Smrg#endif 6040c35d236eSmrg 60411fb744b4Smrg for (p = wrapper; *p; p++) 60421fb744b4Smrg if (*p == '/') 60431fb744b4Smrg { 60441fb744b4Smrg has_slash = 1; 60451fb744b4Smrg break; 60461fb744b4Smrg } 60471fb744b4Smrg if (!has_slash) 60481fb744b4Smrg { 60491fb744b4Smrg /* no slashes; search PATH */ 60501fb744b4Smrg const char *path = getenv ("PATH"); 60511fb744b4Smrg if (path != NULL) 60521fb744b4Smrg { 60531fb744b4Smrg for (p = path; *p; p = p_next) 60541fb744b4Smrg { 60551fb744b4Smrg const char *q; 60561fb744b4Smrg size_t p_len; 60571fb744b4Smrg for (q = p; *q; q++) 60581fb744b4Smrg if (IS_PATH_SEPARATOR (*q)) 60591fb744b4Smrg break; 606014210e8eSmrg p_len = (size_t) (q - p); 60611fb744b4Smrg p_next = (*q == '\0' ? q : q + 1); 60621fb744b4Smrg if (p_len == 0) 60631fb744b4Smrg { 60641fb744b4Smrg /* empty path: current directory */ 60651fb744b4Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60661fb744b4Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60671fb744b4Smrg nonnull (strerror (errno))); 60681fb744b4Smrg tmp_len = strlen (tmp); 60691fb744b4Smrg concat_name = 60701fb744b4Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60711fb744b4Smrg memcpy (concat_name, tmp, tmp_len); 60721fb744b4Smrg concat_name[tmp_len] = '/'; 60731fb744b4Smrg strcpy (concat_name + tmp_len + 1, wrapper); 60741fb744b4Smrg } 60751fb744b4Smrg else 60761fb744b4Smrg { 60771fb744b4Smrg concat_name = 60781fb744b4Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 60791fb744b4Smrg memcpy (concat_name, p, p_len); 60801fb744b4Smrg concat_name[p_len] = '/'; 60811fb744b4Smrg strcpy (concat_name + p_len + 1, wrapper); 60821fb744b4Smrg } 60831fb744b4Smrg if (check_executable (concat_name)) 60841fb744b4Smrg return concat_name; 60851fb744b4Smrg XFREE (concat_name); 60861fb744b4Smrg } 60871fb744b4Smrg } 60881fb744b4Smrg /* not found in PATH; assume curdir */ 60891fb744b4Smrg } 60901fb744b4Smrg /* Relative path | not found in path: prepend cwd */ 60911fb744b4Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60921fb744b4Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60931fb744b4Smrg nonnull (strerror (errno))); 60941fb744b4Smrg tmp_len = strlen (tmp); 60951fb744b4Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60961fb744b4Smrg memcpy (concat_name, tmp, tmp_len); 60971fb744b4Smrg concat_name[tmp_len] = '/'; 60981fb744b4Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099c35d236eSmrg 61001fb744b4Smrg if (check_executable (concat_name)) 61011fb744b4Smrg return concat_name; 61021fb744b4Smrg XFREE (concat_name); 61031fb744b4Smrg return NULL; 61041fb744b4Smrg} 6105c35d236eSmrg 61061fb744b4Smrgchar * 61071fb744b4Smrgchase_symlinks (const char *pathspec) 61081fb744b4Smrg{ 61091fb744b4Smrg#ifndef S_ISLNK 61101fb744b4Smrg return xstrdup (pathspec); 61111fb744b4Smrg#else 61121fb744b4Smrg char buf[LT_PATHMAX]; 61131fb744b4Smrg struct stat s; 61141fb744b4Smrg char *tmp_pathspec = xstrdup (pathspec); 61151fb744b4Smrg char *p; 61161fb744b4Smrg int has_symlinks = 0; 61171fb744b4Smrg while (strlen (tmp_pathspec) && !has_symlinks) 61181fb744b4Smrg { 61191fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 61201fb744b4Smrg "checking path component for symlinks: %s\n", 61211fb744b4Smrg tmp_pathspec); 61221fb744b4Smrg if (lstat (tmp_pathspec, &s) == 0) 61231fb744b4Smrg { 61241fb744b4Smrg if (S_ISLNK (s.st_mode) != 0) 61251fb744b4Smrg { 61261fb744b4Smrg has_symlinks = 1; 61271fb744b4Smrg break; 61281fb744b4Smrg } 61291fb744b4Smrg 61301fb744b4Smrg /* search backwards for last DIR_SEPARATOR */ 61311fb744b4Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 61321fb744b4Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61331fb744b4Smrg p--; 61341fb744b4Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61351fb744b4Smrg { 61361fb744b4Smrg /* no more DIR_SEPARATORS left */ 61371fb744b4Smrg break; 61381fb744b4Smrg } 61391fb744b4Smrg *p = '\0'; 61401fb744b4Smrg } 61411fb744b4Smrg else 61421fb744b4Smrg { 61431fb744b4Smrg lt_fatal (__FILE__, __LINE__, 61441fb744b4Smrg "error accessing file \"%s\": %s", 61451fb744b4Smrg tmp_pathspec, nonnull (strerror (errno))); 61461fb744b4Smrg } 61471fb744b4Smrg } 61481fb744b4Smrg XFREE (tmp_pathspec); 6149c35d236eSmrg 61501fb744b4Smrg if (!has_symlinks) 61511fb744b4Smrg { 61521fb744b4Smrg return xstrdup (pathspec); 61531fb744b4Smrg } 61544f6cd06fSmrg 61551fb744b4Smrg tmp_pathspec = realpath (pathspec, buf); 61561fb744b4Smrg if (tmp_pathspec == 0) 61571fb744b4Smrg { 61581fb744b4Smrg lt_fatal (__FILE__, __LINE__, 61591fb744b4Smrg "could not follow symlinks for %s", pathspec); 61601fb744b4Smrg } 61611fb744b4Smrg return xstrdup (tmp_pathspec); 6162518bcf38Smrg#endif 61631fb744b4Smrg} 6164c35d236eSmrg 61651fb744b4Smrgchar * 61661fb744b4Smrgstrendzap (char *str, const char *pat) 61671fb744b4Smrg{ 61681fb744b4Smrg size_t len, patlen; 6169c35d236eSmrg 61701fb744b4Smrg assert (str != NULL); 61711fb744b4Smrg assert (pat != NULL); 6172c35d236eSmrg 61731fb744b4Smrg len = strlen (str); 61741fb744b4Smrg patlen = strlen (pat); 6175c35d236eSmrg 61761fb744b4Smrg if (patlen <= len) 61771fb744b4Smrg { 61781fb744b4Smrg str += len - patlen; 617914210e8eSmrg if (STREQ (str, pat)) 61801fb744b4Smrg *str = '\0'; 61811fb744b4Smrg } 61821fb744b4Smrg return str; 6183518bcf38Smrg} 6184c35d236eSmrg 61851fb744b4Smrgvoid 61861fb744b4Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 61871fb744b4Smrg{ 61881fb744b4Smrg va_list args; 61891fb744b4Smrg if (lt_debug) 61901fb744b4Smrg { 61911fb744b4Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 61921fb744b4Smrg va_start (args, fmt); 61931fb744b4Smrg (void) vfprintf (stderr, fmt, args); 61941fb744b4Smrg va_end (args); 61951fb744b4Smrg } 61961fb744b4Smrg} 6197c35d236eSmrg 61981fb744b4Smrgstatic void 61991fb744b4Smrglt_error_core (int exit_status, const char *file, 62001fb744b4Smrg int line, const char *mode, 62011fb744b4Smrg const char *message, va_list ap) 62021fb744b4Smrg{ 62031fb744b4Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 62041fb744b4Smrg vfprintf (stderr, message, ap); 62051fb744b4Smrg fprintf (stderr, ".\n"); 6206c35d236eSmrg 62071fb744b4Smrg if (exit_status >= 0) 62081fb744b4Smrg exit (exit_status); 6209518bcf38Smrg} 6210c35d236eSmrg 62111fb744b4Smrgvoid 62121fb744b4Smrglt_fatal (const char *file, int line, const char *message, ...) 62131fb744b4Smrg{ 62141fb744b4Smrg va_list ap; 62151fb744b4Smrg va_start (ap, message); 62161fb744b4Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 62171fb744b4Smrg va_end (ap); 6218518bcf38Smrg} 6219c35d236eSmrg 62201fb744b4Smrgstatic const char * 62211fb744b4Smrgnonnull (const char *s) 62221fb744b4Smrg{ 62231fb744b4Smrg return s ? s : "(null)"; 62241fb744b4Smrg} 6225f55e6a01Smrg 62261fb744b4Smrgstatic const char * 62271fb744b4Smrgnonempty (const char *s) 62281fb744b4Smrg{ 62291fb744b4Smrg return (s && !*s) ? "(empty)" : nonnull (s); 62301fb744b4Smrg} 6231c35d236eSmrg 62321fb744b4Smrgvoid 62331fb744b4Smrglt_setenv (const char *name, const char *value) 62341fb744b4Smrg{ 62351fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 62361fb744b4Smrg "(lt_setenv) setting '%s' to '%s'\n", 62371fb744b4Smrg nonnull (name), nonnull (value)); 62381fb744b4Smrg { 62391fb744b4Smrg#ifdef HAVE_SETENV 62401fb744b4Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 62411fb744b4Smrg char *str = xstrdup (value); 62421fb744b4Smrg setenv (name, str, 1); 62431fb744b4Smrg#else 624414210e8eSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 62451fb744b4Smrg char *str = XMALLOC (char, len); 62461fb744b4Smrg sprintf (str, "%s=%s", name, value); 62471fb744b4Smrg if (putenv (str) != EXIT_SUCCESS) 62481fb744b4Smrg { 62491fb744b4Smrg XFREE (str); 62501fb744b4Smrg } 62511fb744b4Smrg#endif 62521fb744b4Smrg } 62531fb744b4Smrg} 6254c35d236eSmrg 62551fb744b4Smrgchar * 62561fb744b4Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 62571fb744b4Smrg{ 62581fb744b4Smrg char *new_value; 62591fb744b4Smrg if (orig_value && *orig_value) 62601fb744b4Smrg { 626114210e8eSmrg size_t orig_value_len = strlen (orig_value); 626214210e8eSmrg size_t add_len = strlen (add); 62631fb744b4Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 62641fb744b4Smrg if (to_end) 62651fb744b4Smrg { 62661fb744b4Smrg strcpy (new_value, orig_value); 62671fb744b4Smrg strcpy (new_value + orig_value_len, add); 62681fb744b4Smrg } 6269518bcf38Smrg else 62701fb744b4Smrg { 62711fb744b4Smrg strcpy (new_value, add); 62721fb744b4Smrg strcpy (new_value + add_len, orig_value); 62731fb744b4Smrg } 62741fb744b4Smrg } 62751fb744b4Smrg else 62761fb744b4Smrg { 62771fb744b4Smrg new_value = xstrdup (add); 62781fb744b4Smrg } 62791fb744b4Smrg return new_value; 62801fb744b4Smrg} 6281f55e6a01Smrg 62821fb744b4Smrgvoid 62831fb744b4Smrglt_update_exe_path (const char *name, const char *value) 62841fb744b4Smrg{ 62851fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 62861fb744b4Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 62871fb744b4Smrg nonnull (name), nonnull (value)); 6288f55e6a01Smrg 62891fb744b4Smrg if (name && *name && value && *value) 62901fb744b4Smrg { 62911fb744b4Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 62921fb744b4Smrg /* some systems can't cope with a ':'-terminated path #' */ 629314210e8eSmrg size_t len = strlen (new_value); 629414210e8eSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 62951fb744b4Smrg { 629614210e8eSmrg new_value[--len] = '\0'; 62971fb744b4Smrg } 62981fb744b4Smrg lt_setenv (name, new_value); 62991fb744b4Smrg XFREE (new_value); 63001fb744b4Smrg } 63011fb744b4Smrg} 6302f55e6a01Smrg 63031fb744b4Smrgvoid 63041fb744b4Smrglt_update_lib_path (const char *name, const char *value) 63051fb744b4Smrg{ 63061fb744b4Smrg lt_debugprintf (__FILE__, __LINE__, 63071fb744b4Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 63081fb744b4Smrg nonnull (name), nonnull (value)); 6309f55e6a01Smrg 63101fb744b4Smrg if (name && *name && value && *value) 63111fb744b4Smrg { 63121fb744b4Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 63131fb744b4Smrg lt_setenv (name, new_value); 63141fb744b4Smrg XFREE (new_value); 63151fb744b4Smrg } 63161fb744b4Smrg} 6317f55e6a01Smrg 6318518bcf38SmrgEOF 63191fb744b4Smrg case $host_os in 63201fb744b4Smrg mingw*) 63211fb744b4Smrg cat <<"EOF" 63221fb744b4Smrg 63231fb744b4Smrg/* Prepares an argument vector before calling spawn(). 63241fb744b4Smrg Note that spawn() does not by itself call the command interpreter 63251fb744b4Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 63261fb744b4Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 63271fb744b4Smrg GetVersionEx(&v); 63281fb744b4Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 63291fb744b4Smrg }) ? "cmd.exe" : "command.com"). 63301fb744b4Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 63311fb744b4Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 63321fb744b4Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 63331fb744b4Smrg special way: 63341fb744b4Smrg - Space and tab are interpreted as delimiters. They are not treated as 63351fb744b4Smrg delimiters if they are surrounded by double quotes: "...". 63361fb744b4Smrg - Unescaped double quotes are removed from the input. Their only effect is 63371fb744b4Smrg that within double quotes, space and tab are treated like normal 63381fb744b4Smrg characters. 63391fb744b4Smrg - Backslashes not followed by double quotes are not special. 63401fb744b4Smrg - But 2*n+1 backslashes followed by a double quote become 63411fb744b4Smrg n backslashes followed by a double quote (n >= 0): 63421fb744b4Smrg \" -> " 63431fb744b4Smrg \\\" -> \" 63441fb744b4Smrg \\\\\" -> \\" 63451fb744b4Smrg */ 63461fb744b4Smrg#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" 63471fb744b4Smrg#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" 63481fb744b4Smrgchar ** 63491fb744b4Smrgprepare_spawn (char **argv) 6350518bcf38Smrg{ 63511fb744b4Smrg size_t argc; 63521fb744b4Smrg char **new_argv; 63531fb744b4Smrg size_t i; 6354f55e6a01Smrg 63551fb744b4Smrg /* Count number of arguments. */ 63561fb744b4Smrg for (argc = 0; argv[argc] != NULL; argc++) 63571fb744b4Smrg ; 6358f55e6a01Smrg 63591fb744b4Smrg /* Allocate new argument vector. */ 63601fb744b4Smrg new_argv = XMALLOC (char *, argc + 1); 6361f55e6a01Smrg 63621fb744b4Smrg /* Put quoted arguments into the new argument vector. */ 63631fb744b4Smrg for (i = 0; i < argc; i++) 63641fb744b4Smrg { 63651fb744b4Smrg const char *string = argv[i]; 63661fb744b4Smrg 63671fb744b4Smrg if (string[0] == '\0') 63681fb744b4Smrg new_argv[i] = xstrdup ("\"\""); 63691fb744b4Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 63701fb744b4Smrg { 63711fb744b4Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 63721fb744b4Smrg size_t length; 63731fb744b4Smrg unsigned int backslashes; 63741fb744b4Smrg const char *s; 63751fb744b4Smrg char *quoted_string; 63761fb744b4Smrg char *p; 63771fb744b4Smrg 63781fb744b4Smrg length = 0; 63791fb744b4Smrg backslashes = 0; 63801fb744b4Smrg if (quote_around) 63811fb744b4Smrg length++; 63821fb744b4Smrg for (s = string; *s != '\0'; s++) 63831fb744b4Smrg { 63841fb744b4Smrg char c = *s; 63851fb744b4Smrg if (c == '"') 63861fb744b4Smrg length += backslashes + 1; 63871fb744b4Smrg length++; 63881fb744b4Smrg if (c == '\\') 63891fb744b4Smrg backslashes++; 63901fb744b4Smrg else 63911fb744b4Smrg backslashes = 0; 63921fb744b4Smrg } 63931fb744b4Smrg if (quote_around) 63941fb744b4Smrg length += backslashes + 1; 63951fb744b4Smrg 63961fb744b4Smrg quoted_string = XMALLOC (char, length + 1); 63971fb744b4Smrg 63981fb744b4Smrg p = quoted_string; 63991fb744b4Smrg backslashes = 0; 64001fb744b4Smrg if (quote_around) 64011fb744b4Smrg *p++ = '"'; 64021fb744b4Smrg for (s = string; *s != '\0'; s++) 64031fb744b4Smrg { 64041fb744b4Smrg char c = *s; 64051fb744b4Smrg if (c == '"') 64061fb744b4Smrg { 64071fb744b4Smrg unsigned int j; 64081fb744b4Smrg for (j = backslashes + 1; j > 0; j--) 64091fb744b4Smrg *p++ = '\\'; 64101fb744b4Smrg } 64111fb744b4Smrg *p++ = c; 64121fb744b4Smrg if (c == '\\') 64131fb744b4Smrg backslashes++; 64141fb744b4Smrg else 64151fb744b4Smrg backslashes = 0; 64161fb744b4Smrg } 64171fb744b4Smrg if (quote_around) 64181fb744b4Smrg { 64191fb744b4Smrg unsigned int j; 64201fb744b4Smrg for (j = backslashes; j > 0; j--) 64211fb744b4Smrg *p++ = '\\'; 64221fb744b4Smrg *p++ = '"'; 64231fb744b4Smrg } 64241fb744b4Smrg *p = '\0'; 6425f55e6a01Smrg 64261fb744b4Smrg new_argv[i] = quoted_string; 64271fb744b4Smrg } 64281fb744b4Smrg else 64291fb744b4Smrg new_argv[i] = (char *) string; 64301fb744b4Smrg } 64311fb744b4Smrg new_argv[argc] = NULL; 6432f55e6a01Smrg 64331fb744b4Smrg return new_argv; 64341fb744b4Smrg} 6435518bcf38SmrgEOF 64361fb744b4Smrg ;; 64371fb744b4Smrg esac 6438f55e6a01Smrg 64391fb744b4Smrg cat <<"EOF" 64401fb744b4Smrgvoid lt_dump_script (FILE* f) 64411fb744b4Smrg{ 6442518bcf38SmrgEOF 64431fb744b4Smrg func_emit_wrapper yes | 64441fb744b4Smrg $SED -n -e ' 64451fb744b4Smrgs/^\(.\{79\}\)\(..*\)/\1\ 64461fb744b4Smrg\2/ 64471fb744b4Smrgh 64481fb744b4Smrgs/\([\\"]\)/\\\1/g 64491fb744b4Smrgs/$/\\n/ 64501fb744b4Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 64511fb744b4Smrgg 64521fb744b4SmrgD' 64531fb744b4Smrg cat <<"EOF" 6454518bcf38Smrg} 64551fb744b4SmrgEOF 6456518bcf38Smrg} 64571fb744b4Smrg# end: func_emit_cwrapperexe_src 6458f55e6a01Smrg 64591fb744b4Smrg# func_win32_import_lib_p ARG 64601fb744b4Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 64611fb744b4Smrgfunc_win32_import_lib_p () 6462518bcf38Smrg{ 646314210e8eSmrg $debug_cmd 646414210e8eSmrg 64651fb744b4Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 64661fb744b4Smrg *import*) : ;; 64671fb744b4Smrg *) false ;; 64681fb744b4Smrg esac 6469518bcf38Smrg} 6470f55e6a01Smrg 647114210e8eSmrg# func_suncc_cstd_abi 647214210e8eSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647314210e8eSmrg# Several compiler flags select an ABI that is incompatible with the 647414210e8eSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647514210e8eSmrgfunc_suncc_cstd_abi () 647614210e8eSmrg{ 647714210e8eSmrg $debug_cmd 647814210e8eSmrg 647914210e8eSmrg case " $compile_command " in 648014210e8eSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648114210e8eSmrg suncc_use_cstd_abi=no 648214210e8eSmrg ;; 648314210e8eSmrg *) 648414210e8eSmrg suncc_use_cstd_abi=yes 648514210e8eSmrg ;; 648614210e8eSmrg esac 648714210e8eSmrg} 648814210e8eSmrg 64891fb744b4Smrg# func_mode_link arg... 64901fb744b4Smrgfunc_mode_link () 6491518bcf38Smrg{ 649214210e8eSmrg $debug_cmd 649314210e8eSmrg 64941fb744b4Smrg case $host in 64951fb744b4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 64961fb744b4Smrg # It is impossible to link a dll without this setting, and 64971fb744b4Smrg # we shouldn't force the makefile maintainer to figure out 649814210e8eSmrg # what system we are compiling for in order to pass an extra 64991fb744b4Smrg # flag for every libtool invocation. 65001fb744b4Smrg # allow_undefined=no 6501f55e6a01Smrg 65021fb744b4Smrg # FIXME: Unfortunately, there are problems with the above when trying 650314210e8eSmrg # to make a dll that has undefined symbols, in which case not 65041fb744b4Smrg # even a static library is built. For now, we need to specify 65051fb744b4Smrg # -no-undefined on the libtool link line when we can be certain 65061fb744b4Smrg # that all symbols are satisfied, otherwise we get a static library. 65071fb744b4Smrg allow_undefined=yes 65081fb744b4Smrg ;; 65091fb744b4Smrg *) 65101fb744b4Smrg allow_undefined=yes 65111fb744b4Smrg ;; 65121fb744b4Smrg esac 65131fb744b4Smrg libtool_args=$nonopt 65141fb744b4Smrg base_compile="$nonopt $@" 65151fb744b4Smrg compile_command=$nonopt 65161fb744b4Smrg finalize_command=$nonopt 6517f55e6a01Smrg 65181fb744b4Smrg compile_rpath= 65191fb744b4Smrg finalize_rpath= 65201fb744b4Smrg compile_shlibpath= 65211fb744b4Smrg finalize_shlibpath= 65221fb744b4Smrg convenience= 65231fb744b4Smrg old_convenience= 65241fb744b4Smrg deplibs= 65251fb744b4Smrg old_deplibs= 65261fb744b4Smrg compiler_flags= 65271fb744b4Smrg linker_flags= 65281fb744b4Smrg dllsearchpath= 65291fb744b4Smrg lib_search_path=`pwd` 65301fb744b4Smrg inst_prefix_dir= 65311fb744b4Smrg new_inherited_linker_flags= 6532f55e6a01Smrg 65331fb744b4Smrg avoid_version=no 65341fb744b4Smrg bindir= 65351fb744b4Smrg dlfiles= 65361fb744b4Smrg dlprefiles= 65371fb744b4Smrg dlself=no 65381fb744b4Smrg export_dynamic=no 65391fb744b4Smrg export_symbols= 65401fb744b4Smrg export_symbols_regex= 65411fb744b4Smrg generated= 65421fb744b4Smrg libobjs= 65431fb744b4Smrg ltlibs= 65441fb744b4Smrg module=no 65451fb744b4Smrg no_install=no 65461fb744b4Smrg objs= 654714210e8eSmrg os2dllname= 65481fb744b4Smrg non_pic_objects= 65491fb744b4Smrg precious_files_regex= 65501fb744b4Smrg prefer_static_libs=no 655114210e8eSmrg preload=false 65521fb744b4Smrg prev= 65531fb744b4Smrg prevarg= 65541fb744b4Smrg release= 65551fb744b4Smrg rpath= 65561fb744b4Smrg xrpath= 65571fb744b4Smrg perm_rpath= 65581fb744b4Smrg temp_rpath= 65591fb744b4Smrg thread_safe=no 65601fb744b4Smrg vinfo= 65611fb744b4Smrg vinfo_number=no 65621fb744b4Smrg weak_libs= 656314210e8eSmrg single_module=$wl-single_module 65641fb744b4Smrg func_infer_tag $base_compile 6565c35d236eSmrg 65661fb744b4Smrg # We need to know -static, to get the right output filenames. 65671fb744b4Smrg for arg 65681fb744b4Smrg do 65691fb744b4Smrg case $arg in 65701fb744b4Smrg -shared) 657114210e8eSmrg test yes != "$build_libtool_libs" \ 657214210e8eSmrg && func_fatal_configuration "cannot build a shared library" 65731fb744b4Smrg build_old_libs=no 65741fb744b4Smrg break 65751fb744b4Smrg ;; 65761fb744b4Smrg -all-static | -static | -static-libtool-libs) 65771fb744b4Smrg case $arg in 65781fb744b4Smrg -all-static) 657914210e8eSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 65801fb744b4Smrg func_warning "complete static linking is impossible in this configuration" 65811fb744b4Smrg fi 65821fb744b4Smrg if test -n "$link_static_flag"; then 65831fb744b4Smrg dlopen_self=$dlopen_self_static 65841fb744b4Smrg fi 65851fb744b4Smrg prefer_static_libs=yes 65861fb744b4Smrg ;; 65871fb744b4Smrg -static) 65881fb744b4Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65891fb744b4Smrg dlopen_self=$dlopen_self_static 65901fb744b4Smrg fi 65911fb744b4Smrg prefer_static_libs=built 65921fb744b4Smrg ;; 65931fb744b4Smrg -static-libtool-libs) 65941fb744b4Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65951fb744b4Smrg dlopen_self=$dlopen_self_static 65961fb744b4Smrg fi 65971fb744b4Smrg prefer_static_libs=yes 65981fb744b4Smrg ;; 65991fb744b4Smrg esac 66001fb744b4Smrg build_libtool_libs=no 66011fb744b4Smrg build_old_libs=yes 66021fb744b4Smrg break 66031fb744b4Smrg ;; 66041fb744b4Smrg esac 66051fb744b4Smrg done 6606c35d236eSmrg 66071fb744b4Smrg # See if our shared archives depend on static archives. 66081fb744b4Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609c35d236eSmrg 66101fb744b4Smrg # Go through the arguments, transforming them on the way. 66111fb744b4Smrg while test "$#" -gt 0; do 661214210e8eSmrg arg=$1 66131fb744b4Smrg shift 66141fb744b4Smrg func_quote_for_eval "$arg" 66151fb744b4Smrg qarg=$func_quote_for_eval_unquoted_result 66161fb744b4Smrg func_append libtool_args " $func_quote_for_eval_result" 6617c35d236eSmrg 66181fb744b4Smrg # If the previous option needs an argument, assign it. 66191fb744b4Smrg if test -n "$prev"; then 66201fb744b4Smrg case $prev in 66211fb744b4Smrg output) 66221fb744b4Smrg func_append compile_command " @OUTPUT@" 66231fb744b4Smrg func_append finalize_command " @OUTPUT@" 66241fb744b4Smrg ;; 66251fb744b4Smrg esac 6626518bcf38Smrg 66271fb744b4Smrg case $prev in 66281fb744b4Smrg bindir) 662914210e8eSmrg bindir=$arg 66301fb744b4Smrg prev= 66311fb744b4Smrg continue 66321fb744b4Smrg ;; 66331fb744b4Smrg dlfiles|dlprefiles) 663414210e8eSmrg $preload || { 66351fb744b4Smrg # Add the symbol object into the linking commands. 66361fb744b4Smrg func_append compile_command " @SYMFILE@" 66371fb744b4Smrg func_append finalize_command " @SYMFILE@" 663814210e8eSmrg preload=: 663914210e8eSmrg } 66401fb744b4Smrg case $arg in 66411fb744b4Smrg *.la | *.lo) ;; # We handle these cases below. 66421fb744b4Smrg force) 664314210e8eSmrg if test no = "$dlself"; then 66441fb744b4Smrg dlself=needless 66451fb744b4Smrg export_dynamic=yes 66461fb744b4Smrg fi 66471fb744b4Smrg prev= 66481fb744b4Smrg continue 66491fb744b4Smrg ;; 66501fb744b4Smrg self) 665114210e8eSmrg if test dlprefiles = "$prev"; then 66521fb744b4Smrg dlself=yes 665314210e8eSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 66541fb744b4Smrg dlself=yes 66551fb744b4Smrg else 66561fb744b4Smrg dlself=needless 66571fb744b4Smrg export_dynamic=yes 66581fb744b4Smrg fi 66591fb744b4Smrg prev= 66601fb744b4Smrg continue 66611fb744b4Smrg ;; 66621fb744b4Smrg *) 666314210e8eSmrg if test dlfiles = "$prev"; then 66641fb744b4Smrg func_append dlfiles " $arg" 66651fb744b4Smrg else 66661fb744b4Smrg func_append dlprefiles " $arg" 66671fb744b4Smrg fi 66681fb744b4Smrg prev= 66691fb744b4Smrg continue 66701fb744b4Smrg ;; 66711fb744b4Smrg esac 66721fb744b4Smrg ;; 66731fb744b4Smrg expsyms) 667414210e8eSmrg export_symbols=$arg 66751fb744b4Smrg test -f "$arg" \ 667614210e8eSmrg || func_fatal_error "symbol file '$arg' does not exist" 66771fb744b4Smrg prev= 66781fb744b4Smrg continue 66791fb744b4Smrg ;; 66801fb744b4Smrg expsyms_regex) 668114210e8eSmrg export_symbols_regex=$arg 66821fb744b4Smrg prev= 66831fb744b4Smrg continue 66841fb744b4Smrg ;; 66851fb744b4Smrg framework) 66861fb744b4Smrg case $host in 66871fb744b4Smrg *-*-darwin*) 66881fb744b4Smrg case "$deplibs " in 66891fb744b4Smrg *" $qarg.ltframework "*) ;; 66901fb744b4Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 66911fb744b4Smrg ;; 66921fb744b4Smrg esac 66931fb744b4Smrg ;; 66941fb744b4Smrg esac 66951fb744b4Smrg prev= 66961fb744b4Smrg continue 66971fb744b4Smrg ;; 66981fb744b4Smrg inst_prefix) 669914210e8eSmrg inst_prefix_dir=$arg 670014210e8eSmrg prev= 670114210e8eSmrg continue 670214210e8eSmrg ;; 670314210e8eSmrg mllvm) 670414210e8eSmrg # Clang does not use LLVM to link, so we can simply discard any 670514210e8eSmrg # '-mllvm $arg' options when doing the link step. 67061fb744b4Smrg prev= 67071fb744b4Smrg continue 67081fb744b4Smrg ;; 67091fb744b4Smrg objectlist) 67101fb744b4Smrg if test -f "$arg"; then 67111fb744b4Smrg save_arg=$arg 67121fb744b4Smrg moreargs= 67131fb744b4Smrg for fil in `cat "$save_arg"` 67141fb744b4Smrg do 67151fb744b4Smrg# func_append moreargs " $fil" 67161fb744b4Smrg arg=$fil 67171fb744b4Smrg # A libtool-controlled object. 6718518bcf38Smrg 67191fb744b4Smrg # Check to see that this really is a libtool object. 67201fb744b4Smrg if func_lalib_unsafe_p "$arg"; then 67211fb744b4Smrg pic_object= 67221fb744b4Smrg non_pic_object= 6723518bcf38Smrg 67241fb744b4Smrg # Read the .lo file 67251fb744b4Smrg func_source "$arg" 6726518bcf38Smrg 67271fb744b4Smrg if test -z "$pic_object" || 67281fb744b4Smrg test -z "$non_pic_object" || 672914210e8eSmrg test none = "$pic_object" && 673014210e8eSmrg test none = "$non_pic_object"; then 673114210e8eSmrg func_fatal_error "cannot find name of object for '$arg'" 67321fb744b4Smrg fi 6733518bcf38Smrg 67341fb744b4Smrg # Extract subdirectory from the argument. 67351fb744b4Smrg func_dirname "$arg" "/" "" 673614210e8eSmrg xdir=$func_dirname_result 6737518bcf38Smrg 673814210e8eSmrg if test none != "$pic_object"; then 67391fb744b4Smrg # Prepend the subdirectory the object is found in. 674014210e8eSmrg pic_object=$xdir$pic_object 6741518bcf38Smrg 674214210e8eSmrg if test dlfiles = "$prev"; then 674314210e8eSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 67441fb744b4Smrg func_append dlfiles " $pic_object" 67451fb744b4Smrg prev= 67461fb744b4Smrg continue 67471fb744b4Smrg else 67481fb744b4Smrg # If libtool objects are unsupported, then we need to preload. 67491fb744b4Smrg prev=dlprefiles 67501fb744b4Smrg fi 67511fb744b4Smrg fi 6752518bcf38Smrg 67531fb744b4Smrg # CHECK ME: I think I busted this. -Ossama 675414210e8eSmrg if test dlprefiles = "$prev"; then 67551fb744b4Smrg # Preload the old-style object. 67561fb744b4Smrg func_append dlprefiles " $pic_object" 67571fb744b4Smrg prev= 67581fb744b4Smrg fi 6759518bcf38Smrg 67601fb744b4Smrg # A PIC object. 67611fb744b4Smrg func_append libobjs " $pic_object" 676214210e8eSmrg arg=$pic_object 67631fb744b4Smrg fi 6764518bcf38Smrg 67651fb744b4Smrg # Non-PIC object. 676614210e8eSmrg if test none != "$non_pic_object"; then 67671fb744b4Smrg # Prepend the subdirectory the object is found in. 676814210e8eSmrg non_pic_object=$xdir$non_pic_object 6769518bcf38Smrg 67701fb744b4Smrg # A standard non-PIC object 67711fb744b4Smrg func_append non_pic_objects " $non_pic_object" 677214210e8eSmrg if test -z "$pic_object" || test none = "$pic_object"; then 677314210e8eSmrg arg=$non_pic_object 67741fb744b4Smrg fi 67751fb744b4Smrg else 67761fb744b4Smrg # If the PIC object exists, use it instead. 67771fb744b4Smrg # $xdir was prepended to $pic_object above. 677814210e8eSmrg non_pic_object=$pic_object 67791fb744b4Smrg func_append non_pic_objects " $non_pic_object" 67801fb744b4Smrg fi 67811fb744b4Smrg else 67821fb744b4Smrg # Only an error if not doing a dry-run. 67831fb744b4Smrg if $opt_dry_run; then 67841fb744b4Smrg # Extract subdirectory from the argument. 67851fb744b4Smrg func_dirname "$arg" "/" "" 678614210e8eSmrg xdir=$func_dirname_result 67871fb744b4Smrg 67881fb744b4Smrg func_lo2o "$arg" 67891fb744b4Smrg pic_object=$xdir$objdir/$func_lo2o_result 67901fb744b4Smrg non_pic_object=$xdir$func_lo2o_result 67911fb744b4Smrg func_append libobjs " $pic_object" 67921fb744b4Smrg func_append non_pic_objects " $non_pic_object" 67931fb744b4Smrg else 679414210e8eSmrg func_fatal_error "'$arg' is not a valid libtool object" 67951fb744b4Smrg fi 67961fb744b4Smrg fi 67971fb744b4Smrg done 67981fb744b4Smrg else 679914210e8eSmrg func_fatal_error "link input file '$arg' does not exist" 68001fb744b4Smrg fi 68011fb744b4Smrg arg=$save_arg 68021fb744b4Smrg prev= 68031fb744b4Smrg continue 68041fb744b4Smrg ;; 680514210e8eSmrg os2dllname) 680614210e8eSmrg os2dllname=$arg 680714210e8eSmrg prev= 680814210e8eSmrg continue 680914210e8eSmrg ;; 68101fb744b4Smrg precious_regex) 681114210e8eSmrg precious_files_regex=$arg 68121fb744b4Smrg prev= 68131fb744b4Smrg continue 68141fb744b4Smrg ;; 68151fb744b4Smrg release) 681614210e8eSmrg release=-$arg 68171fb744b4Smrg prev= 68181fb744b4Smrg continue 68191fb744b4Smrg ;; 68201fb744b4Smrg rpath | xrpath) 68211fb744b4Smrg # We need an absolute path. 68221fb744b4Smrg case $arg in 68231fb744b4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 68241fb744b4Smrg *) 68251fb744b4Smrg func_fatal_error "only absolute run-paths are allowed" 68261fb744b4Smrg ;; 68271fb744b4Smrg esac 682814210e8eSmrg if test rpath = "$prev"; then 68291fb744b4Smrg case "$rpath " in 68301fb744b4Smrg *" $arg "*) ;; 68311fb744b4Smrg *) func_append rpath " $arg" ;; 68321fb744b4Smrg esac 68331fb744b4Smrg else 68341fb744b4Smrg case "$xrpath " in 68351fb744b4Smrg *" $arg "*) ;; 68361fb744b4Smrg *) func_append xrpath " $arg" ;; 68371fb744b4Smrg esac 68381fb744b4Smrg fi 68391fb744b4Smrg prev= 68401fb744b4Smrg continue 68411fb744b4Smrg ;; 68421fb744b4Smrg shrext) 684314210e8eSmrg shrext_cmds=$arg 68441fb744b4Smrg prev= 68451fb744b4Smrg continue 68461fb744b4Smrg ;; 68471fb744b4Smrg weak) 68481fb744b4Smrg func_append weak_libs " $arg" 68491fb744b4Smrg prev= 68501fb744b4Smrg continue 68511fb744b4Smrg ;; 68521fb744b4Smrg xcclinker) 68531fb744b4Smrg func_append linker_flags " $qarg" 68541fb744b4Smrg func_append compiler_flags " $qarg" 68551fb744b4Smrg prev= 68561fb744b4Smrg func_append compile_command " $qarg" 68571fb744b4Smrg func_append finalize_command " $qarg" 68581fb744b4Smrg continue 68591fb744b4Smrg ;; 68601fb744b4Smrg xcompiler) 68611fb744b4Smrg func_append compiler_flags " $qarg" 68621fb744b4Smrg prev= 68631fb744b4Smrg func_append compile_command " $qarg" 68641fb744b4Smrg func_append finalize_command " $qarg" 68651fb744b4Smrg continue 68661fb744b4Smrg ;; 68671fb744b4Smrg xlinker) 68681fb744b4Smrg func_append linker_flags " $qarg" 68691fb744b4Smrg func_append compiler_flags " $wl$qarg" 68701fb744b4Smrg prev= 68711fb744b4Smrg func_append compile_command " $wl$qarg" 68721fb744b4Smrg func_append finalize_command " $wl$qarg" 68731fb744b4Smrg continue 68741fb744b4Smrg ;; 68751fb744b4Smrg *) 68761fb744b4Smrg eval "$prev=\"\$arg\"" 68771fb744b4Smrg prev= 68781fb744b4Smrg continue 68791fb744b4Smrg ;; 68801fb744b4Smrg esac 68811fb744b4Smrg fi # test -n "$prev" 6882518bcf38Smrg 688314210e8eSmrg prevarg=$arg 6884518bcf38Smrg 68851fb744b4Smrg case $arg in 68861fb744b4Smrg -all-static) 68871fb744b4Smrg if test -n "$link_static_flag"; then 68881fb744b4Smrg # See comment for -static flag below, for more details. 68891fb744b4Smrg func_append compile_command " $link_static_flag" 68901fb744b4Smrg func_append finalize_command " $link_static_flag" 68911fb744b4Smrg fi 68921fb744b4Smrg continue 68931fb744b4Smrg ;; 6894518bcf38Smrg 68951fb744b4Smrg -allow-undefined) 68961fb744b4Smrg # FIXME: remove this flag sometime in the future. 689714210e8eSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 68981fb744b4Smrg ;; 6899518bcf38Smrg 69001fb744b4Smrg -avoid-version) 69011fb744b4Smrg avoid_version=yes 69021fb744b4Smrg continue 69031fb744b4Smrg ;; 6904518bcf38Smrg 69051fb744b4Smrg -bindir) 69061fb744b4Smrg prev=bindir 69071fb744b4Smrg continue 69081fb744b4Smrg ;; 6909c35d236eSmrg 69101fb744b4Smrg -dlopen) 69111fb744b4Smrg prev=dlfiles 69121fb744b4Smrg continue 69131fb744b4Smrg ;; 6914c35d236eSmrg 69151fb744b4Smrg -dlpreopen) 69161fb744b4Smrg prev=dlprefiles 69171fb744b4Smrg continue 69181fb744b4Smrg ;; 6919c35d236eSmrg 69201fb744b4Smrg -export-dynamic) 69211fb744b4Smrg export_dynamic=yes 69221fb744b4Smrg continue 69231fb744b4Smrg ;; 6924f55e6a01Smrg 69251fb744b4Smrg -export-symbols | -export-symbols-regex) 69261fb744b4Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 69271fb744b4Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 69281fb744b4Smrg fi 692914210e8eSmrg if test X-export-symbols = "X$arg"; then 69301fb744b4Smrg prev=expsyms 69311fb744b4Smrg else 69321fb744b4Smrg prev=expsyms_regex 69331fb744b4Smrg fi 69341fb744b4Smrg continue 69351fb744b4Smrg ;; 6936f55e6a01Smrg 69371fb744b4Smrg -framework) 69381fb744b4Smrg prev=framework 69391fb744b4Smrg continue 69401fb744b4Smrg ;; 6941c35d236eSmrg 69421fb744b4Smrg -inst-prefix-dir) 69431fb744b4Smrg prev=inst_prefix 69441fb744b4Smrg continue 69451fb744b4Smrg ;; 6946c35d236eSmrg 69471fb744b4Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 69481fb744b4Smrg # so, if we see these flags be careful not to treat them like -L 69491fb744b4Smrg -L[A-Z][A-Z]*:*) 69501fb744b4Smrg case $with_gcc/$host in 69511fb744b4Smrg no/*-*-irix* | /*-*-irix*) 69521fb744b4Smrg func_append compile_command " $arg" 69531fb744b4Smrg func_append finalize_command " $arg" 69541fb744b4Smrg ;; 69551fb744b4Smrg esac 69561fb744b4Smrg continue 69571fb744b4Smrg ;; 6958c35d236eSmrg 69591fb744b4Smrg -L*) 69601fb744b4Smrg func_stripname "-L" '' "$arg" 69611fb744b4Smrg if test -z "$func_stripname_result"; then 69621fb744b4Smrg if test "$#" -gt 0; then 696314210e8eSmrg func_fatal_error "require no space between '-L' and '$1'" 69641fb744b4Smrg else 696514210e8eSmrg func_fatal_error "need path for '-L' option" 69661fb744b4Smrg fi 69671fb744b4Smrg fi 69681fb744b4Smrg func_resolve_sysroot "$func_stripname_result" 69691fb744b4Smrg dir=$func_resolve_sysroot_result 69701fb744b4Smrg # We need an absolute path. 69711fb744b4Smrg case $dir in 69721fb744b4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 69731fb744b4Smrg *) 69741fb744b4Smrg absdir=`cd "$dir" && pwd` 69751fb744b4Smrg test -z "$absdir" && \ 697614210e8eSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697714210e8eSmrg dir=$absdir 69781fb744b4Smrg ;; 69791fb744b4Smrg esac 69801fb744b4Smrg case "$deplibs " in 69811fb744b4Smrg *" -L$dir "* | *" $arg "*) 69821fb744b4Smrg # Will only happen for absolute or sysroot arguments 69831fb744b4Smrg ;; 69841fb744b4Smrg *) 69851fb744b4Smrg # Preserve sysroot, but never include relative directories 69861fb744b4Smrg case $dir in 69871fb744b4Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 69881fb744b4Smrg *) func_append deplibs " -L$dir" ;; 69891fb744b4Smrg esac 69901fb744b4Smrg func_append lib_search_path " $dir" 69911fb744b4Smrg ;; 69921fb744b4Smrg esac 69931fb744b4Smrg case $host in 69941fb744b4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 69951fb744b4Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 69961fb744b4Smrg case :$dllsearchpath: in 69971fb744b4Smrg *":$dir:"*) ;; 69981fb744b4Smrg ::) dllsearchpath=$dir;; 69991fb744b4Smrg *) func_append dllsearchpath ":$dir";; 70001fb744b4Smrg esac 70011fb744b4Smrg case :$dllsearchpath: in 70021fb744b4Smrg *":$testbindir:"*) ;; 70031fb744b4Smrg ::) dllsearchpath=$testbindir;; 70041fb744b4Smrg *) func_append dllsearchpath ":$testbindir";; 70051fb744b4Smrg esac 70061fb744b4Smrg ;; 70071fb744b4Smrg esac 70081fb744b4Smrg continue 70091fb744b4Smrg ;; 7010c35d236eSmrg 70111fb744b4Smrg -l*) 701214210e8eSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 70131fb744b4Smrg case $host in 70141fb744b4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 70151fb744b4Smrg # These systems don't actually have a C or math library (as such) 70161fb744b4Smrg continue 70171fb744b4Smrg ;; 70181fb744b4Smrg *-*-os2*) 70191fb744b4Smrg # These systems don't actually have a C library (as such) 702014210e8eSmrg test X-lc = "X$arg" && continue 70211fb744b4Smrg ;; 702214210e8eSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70231fb744b4Smrg # Do not include libc due to us having libc/libc_r. 702414210e8eSmrg test X-lc = "X$arg" && continue 70251fb744b4Smrg ;; 70261fb744b4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 70271fb744b4Smrg # Rhapsody C and math libraries are in the System framework 70281fb744b4Smrg func_append deplibs " System.ltframework" 70291fb744b4Smrg continue 70301fb744b4Smrg ;; 70311fb744b4Smrg *-*-sco3.2v5* | *-*-sco5v6*) 70321fb744b4Smrg # Causes problems with __ctype 703314210e8eSmrg test X-lc = "X$arg" && continue 70341fb744b4Smrg ;; 70351fb744b4Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 70361fb744b4Smrg # Compiler inserts libc in the correct place for threads to work 703714210e8eSmrg test X-lc = "X$arg" && continue 70381fb744b4Smrg ;; 70391fb744b4Smrg esac 704014210e8eSmrg elif test X-lc_r = "X$arg"; then 70411fb744b4Smrg case $host in 704214210e8eSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70431fb744b4Smrg # Do not include libc_r directly, use -pthread flag. 70441fb744b4Smrg continue 70451fb744b4Smrg ;; 70461fb744b4Smrg esac 70471fb744b4Smrg fi 70481fb744b4Smrg func_append deplibs " $arg" 70491fb744b4Smrg continue 70501fb744b4Smrg ;; 70511fb744b4Smrg 705214210e8eSmrg -mllvm) 705314210e8eSmrg prev=mllvm 705414210e8eSmrg continue 705514210e8eSmrg ;; 705614210e8eSmrg 70571fb744b4Smrg -module) 70581fb744b4Smrg module=yes 70591fb744b4Smrg continue 70601fb744b4Smrg ;; 70611fb744b4Smrg 70621fb744b4Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 70631fb744b4Smrg # classes, name mangling, and exception handling. 70641fb744b4Smrg # Darwin uses the -arch flag to determine output architecture. 70651fb744b4Smrg -model|-arch|-isysroot|--sysroot) 70661fb744b4Smrg func_append compiler_flags " $arg" 70671fb744b4Smrg func_append compile_command " $arg" 70681fb744b4Smrg func_append finalize_command " $arg" 70691fb744b4Smrg prev=xcompiler 70701fb744b4Smrg continue 70711fb744b4Smrg ;; 70721fb744b4Smrg 70731fb744b4Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 70741fb744b4Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 70751fb744b4Smrg func_append compiler_flags " $arg" 70761fb744b4Smrg func_append compile_command " $arg" 70771fb744b4Smrg func_append finalize_command " $arg" 70781fb744b4Smrg case "$new_inherited_linker_flags " in 70791fb744b4Smrg *" $arg "*) ;; 70801fb744b4Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 70811fb744b4Smrg esac 70821fb744b4Smrg continue 70831fb744b4Smrg ;; 70841fb744b4Smrg 70851fb744b4Smrg -multi_module) 708614210e8eSmrg single_module=$wl-multi_module 70871fb744b4Smrg continue 70881fb744b4Smrg ;; 70891fb744b4Smrg 70901fb744b4Smrg -no-fast-install) 70911fb744b4Smrg fast_install=no 70921fb744b4Smrg continue 70931fb744b4Smrg ;; 70941fb744b4Smrg 70951fb744b4Smrg -no-install) 70961fb744b4Smrg case $host in 70971fb744b4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 70981fb744b4Smrg # The PATH hackery in wrapper scripts is required on Windows 70991fb744b4Smrg # and Darwin in order for the loader to find any dlls it needs. 710014210e8eSmrg func_warning "'-no-install' is ignored for $host" 710114210e8eSmrg func_warning "assuming '-no-fast-install' instead" 71021fb744b4Smrg fast_install=no 71031fb744b4Smrg ;; 71041fb744b4Smrg *) no_install=yes ;; 71051fb744b4Smrg esac 71061fb744b4Smrg continue 71071fb744b4Smrg ;; 71081fb744b4Smrg 71091fb744b4Smrg -no-undefined) 71101fb744b4Smrg allow_undefined=no 71111fb744b4Smrg continue 71121fb744b4Smrg ;; 71131fb744b4Smrg 71141fb744b4Smrg -objectlist) 71151fb744b4Smrg prev=objectlist 71161fb744b4Smrg continue 71171fb744b4Smrg ;; 71181fb744b4Smrg 711914210e8eSmrg -os2dllname) 712014210e8eSmrg prev=os2dllname 712114210e8eSmrg continue 712214210e8eSmrg ;; 712314210e8eSmrg 71241fb744b4Smrg -o) prev=output ;; 71251fb744b4Smrg 71261fb744b4Smrg -precious-files-regex) 71271fb744b4Smrg prev=precious_regex 71281fb744b4Smrg continue 71291fb744b4Smrg ;; 71301fb744b4Smrg 71311fb744b4Smrg -release) 71321fb744b4Smrg prev=release 71331fb744b4Smrg continue 71341fb744b4Smrg ;; 71351fb744b4Smrg 71361fb744b4Smrg -rpath) 71371fb744b4Smrg prev=rpath 71381fb744b4Smrg continue 71391fb744b4Smrg ;; 71401fb744b4Smrg 71411fb744b4Smrg -R) 71421fb744b4Smrg prev=xrpath 71431fb744b4Smrg continue 71441fb744b4Smrg ;; 71451fb744b4Smrg 71461fb744b4Smrg -R*) 71471fb744b4Smrg func_stripname '-R' '' "$arg" 71481fb744b4Smrg dir=$func_stripname_result 71491fb744b4Smrg # We need an absolute path. 71501fb744b4Smrg case $dir in 71511fb744b4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 71521fb744b4Smrg =*) 71531fb744b4Smrg func_stripname '=' '' "$dir" 71541fb744b4Smrg dir=$lt_sysroot$func_stripname_result 71551fb744b4Smrg ;; 71561fb744b4Smrg *) 71571fb744b4Smrg func_fatal_error "only absolute run-paths are allowed" 71581fb744b4Smrg ;; 71591fb744b4Smrg esac 71601fb744b4Smrg case "$xrpath " in 71611fb744b4Smrg *" $dir "*) ;; 71621fb744b4Smrg *) func_append xrpath " $dir" ;; 71631fb744b4Smrg esac 71641fb744b4Smrg continue 71651fb744b4Smrg ;; 71661fb744b4Smrg 71671fb744b4Smrg -shared) 71681fb744b4Smrg # The effects of -shared are defined in a previous loop. 71691fb744b4Smrg continue 71701fb744b4Smrg ;; 71711fb744b4Smrg 71721fb744b4Smrg -shrext) 71731fb744b4Smrg prev=shrext 71741fb744b4Smrg continue 71751fb744b4Smrg ;; 71761fb744b4Smrg 71771fb744b4Smrg -static | -static-libtool-libs) 71781fb744b4Smrg # The effects of -static are defined in a previous loop. 71791fb744b4Smrg # We used to do the same as -all-static on platforms that 71801fb744b4Smrg # didn't have a PIC flag, but the assumption that the effects 71811fb744b4Smrg # would be equivalent was wrong. It would break on at least 71821fb744b4Smrg # Digital Unix and AIX. 71831fb744b4Smrg continue 71841fb744b4Smrg ;; 71851fb744b4Smrg 71861fb744b4Smrg -thread-safe) 71871fb744b4Smrg thread_safe=yes 71881fb744b4Smrg continue 71891fb744b4Smrg ;; 71901fb744b4Smrg 71911fb744b4Smrg -version-info) 71921fb744b4Smrg prev=vinfo 71931fb744b4Smrg continue 71941fb744b4Smrg ;; 71951fb744b4Smrg 71961fb744b4Smrg -version-number) 71971fb744b4Smrg prev=vinfo 71981fb744b4Smrg vinfo_number=yes 71991fb744b4Smrg continue 72001fb744b4Smrg ;; 72011fb744b4Smrg 72021fb744b4Smrg -weak) 72031fb744b4Smrg prev=weak 72041fb744b4Smrg continue 72051fb744b4Smrg ;; 72061fb744b4Smrg 72071fb744b4Smrg -Wc,*) 72081fb744b4Smrg func_stripname '-Wc,' '' "$arg" 72091fb744b4Smrg args=$func_stripname_result 72101fb744b4Smrg arg= 721114210e8eSmrg save_ifs=$IFS; IFS=, 72121fb744b4Smrg for flag in $args; do 721314210e8eSmrg IFS=$save_ifs 72141fb744b4Smrg func_quote_for_eval "$flag" 72151fb744b4Smrg func_append arg " $func_quote_for_eval_result" 72161fb744b4Smrg func_append compiler_flags " $func_quote_for_eval_result" 72171fb744b4Smrg done 721814210e8eSmrg IFS=$save_ifs 72191fb744b4Smrg func_stripname ' ' '' "$arg" 72201fb744b4Smrg arg=$func_stripname_result 72211fb744b4Smrg ;; 72221fb744b4Smrg 72231fb744b4Smrg -Wl,*) 72241fb744b4Smrg func_stripname '-Wl,' '' "$arg" 72251fb744b4Smrg args=$func_stripname_result 72261fb744b4Smrg arg= 722714210e8eSmrg save_ifs=$IFS; IFS=, 72281fb744b4Smrg for flag in $args; do 722914210e8eSmrg IFS=$save_ifs 72301fb744b4Smrg func_quote_for_eval "$flag" 72311fb744b4Smrg func_append arg " $wl$func_quote_for_eval_result" 72321fb744b4Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 72331fb744b4Smrg func_append linker_flags " $func_quote_for_eval_result" 72341fb744b4Smrg done 723514210e8eSmrg IFS=$save_ifs 72361fb744b4Smrg func_stripname ' ' '' "$arg" 72371fb744b4Smrg arg=$func_stripname_result 72381fb744b4Smrg ;; 72391fb744b4Smrg 72401fb744b4Smrg -Xcompiler) 72411fb744b4Smrg prev=xcompiler 72421fb744b4Smrg continue 72431fb744b4Smrg ;; 72441fb744b4Smrg 72451fb744b4Smrg -Xlinker) 72461fb744b4Smrg prev=xlinker 72471fb744b4Smrg continue 72481fb744b4Smrg ;; 72491fb744b4Smrg 72501fb744b4Smrg -XCClinker) 72511fb744b4Smrg prev=xcclinker 72521fb744b4Smrg continue 72531fb744b4Smrg ;; 72541fb744b4Smrg 72551fb744b4Smrg # -msg_* for osf cc 72561fb744b4Smrg -msg_*) 72571fb744b4Smrg func_quote_for_eval "$arg" 725814210e8eSmrg arg=$func_quote_for_eval_result 72591fb744b4Smrg ;; 72601fb744b4Smrg 72611fb744b4Smrg # Flags to be passed through unchanged, with rationale: 72621fb744b4Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 72631fb744b4Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 72641fb744b4Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 72651fb744b4Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 72661fb744b4Smrg # -q* compiler args for the IBM compiler 72671fb744b4Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 72681fb744b4Smrg # -F/path path to uninstalled frameworks, gcc on darwin 72691fb744b4Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727014210e8eSmrg # -fstack-protector* stack protector flags for GCC 72711fb744b4Smrg # @file GCC response files 72721fb744b4Smrg # -tp=* Portland pgcc target processor selection 72731fb744b4Smrg # --sysroot=* for sysroot support 727414210e8eSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 727514210e8eSmrg # -stdlib=* select c++ std lib with clang 72761fb744b4Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 72771fb744b4Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 727814210e8eSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 72791fb744b4Smrg func_quote_for_eval "$arg" 728014210e8eSmrg arg=$func_quote_for_eval_result 72811fb744b4Smrg func_append compile_command " $arg" 72821fb744b4Smrg func_append finalize_command " $arg" 72831fb744b4Smrg func_append compiler_flags " $arg" 72841fb744b4Smrg continue 72851fb744b4Smrg ;; 72861fb744b4Smrg 728714210e8eSmrg -Z*) 728814210e8eSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 728914210e8eSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 729014210e8eSmrg compiler_flags="$compiler_flags $arg" 729114210e8eSmrg func_append compile_command " $arg" 729214210e8eSmrg func_append finalize_command " $arg" 729314210e8eSmrg case $arg in 729414210e8eSmrg -Zlinker | -Zstack) 729514210e8eSmrg prev=xcompiler 729614210e8eSmrg ;; 729714210e8eSmrg esac 729814210e8eSmrg continue 729914210e8eSmrg else 730014210e8eSmrg # Otherwise treat like 'Some other compiler flag' below 730114210e8eSmrg func_quote_for_eval "$arg" 730214210e8eSmrg arg=$func_quote_for_eval_result 730314210e8eSmrg fi 730414210e8eSmrg ;; 730514210e8eSmrg 73061fb744b4Smrg # Some other compiler flag. 73071fb744b4Smrg -* | +*) 73081fb744b4Smrg func_quote_for_eval "$arg" 730914210e8eSmrg arg=$func_quote_for_eval_result 73101fb744b4Smrg ;; 73111fb744b4Smrg 73121fb744b4Smrg *.$objext) 73131fb744b4Smrg # A standard object. 73141fb744b4Smrg func_append objs " $arg" 73151fb744b4Smrg ;; 73161fb744b4Smrg 73171fb744b4Smrg *.lo) 73181fb744b4Smrg # A libtool-controlled object. 73191fb744b4Smrg 73201fb744b4Smrg # Check to see that this really is a libtool object. 73211fb744b4Smrg if func_lalib_unsafe_p "$arg"; then 73221fb744b4Smrg pic_object= 73231fb744b4Smrg non_pic_object= 73241fb744b4Smrg 73251fb744b4Smrg # Read the .lo file 73261fb744b4Smrg func_source "$arg" 73271fb744b4Smrg 73281fb744b4Smrg if test -z "$pic_object" || 73291fb744b4Smrg test -z "$non_pic_object" || 733014210e8eSmrg test none = "$pic_object" && 733114210e8eSmrg test none = "$non_pic_object"; then 733214210e8eSmrg func_fatal_error "cannot find name of object for '$arg'" 73331fb744b4Smrg fi 73341fb744b4Smrg 73351fb744b4Smrg # Extract subdirectory from the argument. 73361fb744b4Smrg func_dirname "$arg" "/" "" 733714210e8eSmrg xdir=$func_dirname_result 73381fb744b4Smrg 733914210e8eSmrg test none = "$pic_object" || { 73401fb744b4Smrg # Prepend the subdirectory the object is found in. 734114210e8eSmrg pic_object=$xdir$pic_object 73421fb744b4Smrg 734314210e8eSmrg if test dlfiles = "$prev"; then 734414210e8eSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 73451fb744b4Smrg func_append dlfiles " $pic_object" 73461fb744b4Smrg prev= 73471fb744b4Smrg continue 73481fb744b4Smrg else 73491fb744b4Smrg # If libtool objects are unsupported, then we need to preload. 73501fb744b4Smrg prev=dlprefiles 73511fb744b4Smrg fi 73521fb744b4Smrg fi 73531fb744b4Smrg 73541fb744b4Smrg # CHECK ME: I think I busted this. -Ossama 735514210e8eSmrg if test dlprefiles = "$prev"; then 73561fb744b4Smrg # Preload the old-style object. 73571fb744b4Smrg func_append dlprefiles " $pic_object" 73581fb744b4Smrg prev= 73591fb744b4Smrg fi 73601fb744b4Smrg 73611fb744b4Smrg # A PIC object. 73621fb744b4Smrg func_append libobjs " $pic_object" 736314210e8eSmrg arg=$pic_object 736414210e8eSmrg } 73651fb744b4Smrg 73661fb744b4Smrg # Non-PIC object. 736714210e8eSmrg if test none != "$non_pic_object"; then 73681fb744b4Smrg # Prepend the subdirectory the object is found in. 736914210e8eSmrg non_pic_object=$xdir$non_pic_object 73701fb744b4Smrg 73711fb744b4Smrg # A standard non-PIC object 73721fb744b4Smrg func_append non_pic_objects " $non_pic_object" 737314210e8eSmrg if test -z "$pic_object" || test none = "$pic_object"; then 737414210e8eSmrg arg=$non_pic_object 73751fb744b4Smrg fi 73761fb744b4Smrg else 73771fb744b4Smrg # If the PIC object exists, use it instead. 73781fb744b4Smrg # $xdir was prepended to $pic_object above. 737914210e8eSmrg non_pic_object=$pic_object 73801fb744b4Smrg func_append non_pic_objects " $non_pic_object" 73811fb744b4Smrg fi 73821fb744b4Smrg else 73831fb744b4Smrg # Only an error if not doing a dry-run. 73841fb744b4Smrg if $opt_dry_run; then 73851fb744b4Smrg # Extract subdirectory from the argument. 73861fb744b4Smrg func_dirname "$arg" "/" "" 738714210e8eSmrg xdir=$func_dirname_result 73881fb744b4Smrg 73891fb744b4Smrg func_lo2o "$arg" 73901fb744b4Smrg pic_object=$xdir$objdir/$func_lo2o_result 73911fb744b4Smrg non_pic_object=$xdir$func_lo2o_result 73921fb744b4Smrg func_append libobjs " $pic_object" 73931fb744b4Smrg func_append non_pic_objects " $non_pic_object" 73941fb744b4Smrg else 739514210e8eSmrg func_fatal_error "'$arg' is not a valid libtool object" 73961fb744b4Smrg fi 73971fb744b4Smrg fi 73981fb744b4Smrg ;; 73991fb744b4Smrg 74001fb744b4Smrg *.$libext) 74011fb744b4Smrg # An archive. 74021fb744b4Smrg func_append deplibs " $arg" 74031fb744b4Smrg func_append old_deplibs " $arg" 74041fb744b4Smrg continue 74051fb744b4Smrg ;; 74061fb744b4Smrg 74071fb744b4Smrg *.la) 74081fb744b4Smrg # A libtool-controlled library. 74091fb744b4Smrg 74101fb744b4Smrg func_resolve_sysroot "$arg" 741114210e8eSmrg if test dlfiles = "$prev"; then 74121fb744b4Smrg # This library was specified with -dlopen. 74131fb744b4Smrg func_append dlfiles " $func_resolve_sysroot_result" 74141fb744b4Smrg prev= 741514210e8eSmrg elif test dlprefiles = "$prev"; then 74161fb744b4Smrg # The library was specified with -dlpreopen. 74171fb744b4Smrg func_append dlprefiles " $func_resolve_sysroot_result" 74181fb744b4Smrg prev= 74191fb744b4Smrg else 74201fb744b4Smrg func_append deplibs " $func_resolve_sysroot_result" 74211fb744b4Smrg fi 74221fb744b4Smrg continue 74231fb744b4Smrg ;; 74241fb744b4Smrg 74251fb744b4Smrg # Some other compiler argument. 74261fb744b4Smrg *) 74271fb744b4Smrg # Unknown arguments in both finalize_command and compile_command need 74281fb744b4Smrg # to be aesthetically quoted because they are evaled later. 74291fb744b4Smrg func_quote_for_eval "$arg" 743014210e8eSmrg arg=$func_quote_for_eval_result 74311fb744b4Smrg ;; 74321fb744b4Smrg esac # arg 74331fb744b4Smrg 74341fb744b4Smrg # Now actually substitute the argument into the commands. 74351fb744b4Smrg if test -n "$arg"; then 74361fb744b4Smrg func_append compile_command " $arg" 74371fb744b4Smrg func_append finalize_command " $arg" 74381fb744b4Smrg fi 74391fb744b4Smrg done # argument parsing loop 74401fb744b4Smrg 74411fb744b4Smrg test -n "$prev" && \ 744214210e8eSmrg func_fatal_help "the '$prevarg' option requires an argument" 74431fb744b4Smrg 744414210e8eSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 74451fb744b4Smrg eval arg=\"$export_dynamic_flag_spec\" 74461fb744b4Smrg func_append compile_command " $arg" 74471fb744b4Smrg func_append finalize_command " $arg" 74481fb744b4Smrg fi 74491fb744b4Smrg 74501fb744b4Smrg oldlibs= 74511fb744b4Smrg # calculate the name of the file, without its directory 74521fb744b4Smrg func_basename "$output" 745314210e8eSmrg outputname=$func_basename_result 745414210e8eSmrg libobjs_save=$libobjs 74551fb744b4Smrg 74561fb744b4Smrg if test -n "$shlibpath_var"; then 74571fb744b4Smrg # get the directories listed in $shlibpath_var 745814210e8eSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 74591fb744b4Smrg else 74601fb744b4Smrg shlib_search_path= 74611fb744b4Smrg fi 74621fb744b4Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 74631fb744b4Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 74641fb744b4Smrg 746514210e8eSmrg # Definition is injected by LT_CONFIG during libtool generation. 746614210e8eSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 746714210e8eSmrg 74681fb744b4Smrg func_dirname "$output" "/" "" 746914210e8eSmrg output_objdir=$func_dirname_result$objdir 74701fb744b4Smrg func_to_tool_file "$output_objdir/" 74711fb744b4Smrg tool_output_objdir=$func_to_tool_file_result 74721fb744b4Smrg # Create the object directory. 74731fb744b4Smrg func_mkdir_p "$output_objdir" 74741fb744b4Smrg 74751fb744b4Smrg # Determine the type of output 74761fb744b4Smrg case $output in 74771fb744b4Smrg "") 74781fb744b4Smrg func_fatal_help "you must specify an output file" 74791fb744b4Smrg ;; 74801fb744b4Smrg *.$libext) linkmode=oldlib ;; 74811fb744b4Smrg *.lo | *.$objext) linkmode=obj ;; 74821fb744b4Smrg *.la) linkmode=lib ;; 74831fb744b4Smrg *) linkmode=prog ;; # Anything else should be a program. 74841fb744b4Smrg esac 74851fb744b4Smrg 74861fb744b4Smrg specialdeplibs= 74871fb744b4Smrg 74881fb744b4Smrg libs= 74891fb744b4Smrg # Find all interdependent deplibs by searching for libraries 74901fb744b4Smrg # that are linked more than once (e.g. -la -lb -la) 74911fb744b4Smrg for deplib in $deplibs; do 749214210e8eSmrg if $opt_preserve_dup_deps; then 74931fb744b4Smrg case "$libs " in 74941fb744b4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 74951fb744b4Smrg esac 74961fb744b4Smrg fi 74971fb744b4Smrg func_append libs " $deplib" 74981fb744b4Smrg done 74991fb744b4Smrg 750014210e8eSmrg if test lib = "$linkmode"; then 75011fb744b4Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 75021fb744b4Smrg 75031fb744b4Smrg # Compute libraries that are listed more than once in $predeps 75041fb744b4Smrg # $postdeps and mark them as special (i.e., whose duplicates are 75051fb744b4Smrg # not to be eliminated). 75061fb744b4Smrg pre_post_deps= 75071fb744b4Smrg if $opt_duplicate_compiler_generated_deps; then 75081fb744b4Smrg for pre_post_dep in $predeps $postdeps; do 75091fb744b4Smrg case "$pre_post_deps " in 75101fb744b4Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 75111fb744b4Smrg esac 75121fb744b4Smrg func_append pre_post_deps " $pre_post_dep" 75131fb744b4Smrg done 75141fb744b4Smrg fi 75151fb744b4Smrg pre_post_deps= 75161fb744b4Smrg fi 75171fb744b4Smrg 75181fb744b4Smrg deplibs= 75191fb744b4Smrg newdependency_libs= 75201fb744b4Smrg newlib_search_path= 75211fb744b4Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 75221fb744b4Smrg notinst_deplibs= # not-installed libtool libraries 75231fb744b4Smrg notinst_path= # paths that contain not-installed libtool libraries 75241fb744b4Smrg 75251fb744b4Smrg case $linkmode in 75261fb744b4Smrg lib) 75271fb744b4Smrg passes="conv dlpreopen link" 75281fb744b4Smrg for file in $dlfiles $dlprefiles; do 75291fb744b4Smrg case $file in 75301fb744b4Smrg *.la) ;; 75311fb744b4Smrg *) 753214210e8eSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 75331fb744b4Smrg ;; 75341fb744b4Smrg esac 75351fb744b4Smrg done 75361fb744b4Smrg ;; 75371fb744b4Smrg prog) 75381fb744b4Smrg compile_deplibs= 75391fb744b4Smrg finalize_deplibs= 754014210e8eSmrg alldeplibs=false 75411fb744b4Smrg newdlfiles= 75421fb744b4Smrg newdlprefiles= 75431fb744b4Smrg passes="conv scan dlopen dlpreopen link" 75441fb744b4Smrg ;; 75451fb744b4Smrg *) passes="conv" 75461fb744b4Smrg ;; 75471fb744b4Smrg esac 75481fb744b4Smrg 75491fb744b4Smrg for pass in $passes; do 75501fb744b4Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 75511fb744b4Smrg # so that -L comes before libs that need it for instance... 755214210e8eSmrg if test lib,link = "$linkmode,$pass"; then 75531fb744b4Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 75541fb744b4Smrg ## order, and fix it there properly 75551fb744b4Smrg tmp_deplibs= 75561fb744b4Smrg for deplib in $deplibs; do 75571fb744b4Smrg tmp_deplibs="$deplib $tmp_deplibs" 75581fb744b4Smrg done 755914210e8eSmrg deplibs=$tmp_deplibs 75601fb744b4Smrg fi 75611fb744b4Smrg 756214210e8eSmrg if test lib,link = "$linkmode,$pass" || 756314210e8eSmrg test prog,scan = "$linkmode,$pass"; then 756414210e8eSmrg libs=$deplibs 75651fb744b4Smrg deplibs= 75661fb744b4Smrg fi 756714210e8eSmrg if test prog = "$linkmode"; then 75681fb744b4Smrg case $pass in 756914210e8eSmrg dlopen) libs=$dlfiles ;; 757014210e8eSmrg dlpreopen) libs=$dlprefiles ;; 75711fb744b4Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 75721fb744b4Smrg esac 75731fb744b4Smrg fi 757414210e8eSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 75751fb744b4Smrg # Collect and forward deplibs of preopened libtool libs 75761fb744b4Smrg for lib in $dlprefiles; do 75771fb744b4Smrg # Ignore non-libtool-libs 75781fb744b4Smrg dependency_libs= 75791fb744b4Smrg func_resolve_sysroot "$lib" 75801fb744b4Smrg case $lib in 75811fb744b4Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 75821fb744b4Smrg esac 75831fb744b4Smrg 75841fb744b4Smrg # Collect preopened libtool deplibs, except any this library 75851fb744b4Smrg # has declared as weak libs 75861fb744b4Smrg for deplib in $dependency_libs; do 75871fb744b4Smrg func_basename "$deplib" 75881fb744b4Smrg deplib_base=$func_basename_result 75891fb744b4Smrg case " $weak_libs " in 75901fb744b4Smrg *" $deplib_base "*) ;; 75911fb744b4Smrg *) func_append deplibs " $deplib" ;; 75921fb744b4Smrg esac 75931fb744b4Smrg done 75941fb744b4Smrg done 759514210e8eSmrg libs=$dlprefiles 75961fb744b4Smrg fi 759714210e8eSmrg if test dlopen = "$pass"; then 75981fb744b4Smrg # Collect dlpreopened libraries 759914210e8eSmrg save_deplibs=$deplibs 76001fb744b4Smrg deplibs= 76011fb744b4Smrg fi 76021fb744b4Smrg 76031fb744b4Smrg for deplib in $libs; do 76041fb744b4Smrg lib= 760514210e8eSmrg found=false 76061fb744b4Smrg case $deplib in 76071fb744b4Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 76081fb744b4Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 760914210e8eSmrg if test prog,link = "$linkmode,$pass"; then 76101fb744b4Smrg compile_deplibs="$deplib $compile_deplibs" 76111fb744b4Smrg finalize_deplibs="$deplib $finalize_deplibs" 76121fb744b4Smrg else 76131fb744b4Smrg func_append compiler_flags " $deplib" 761414210e8eSmrg if test lib = "$linkmode"; then 76151fb744b4Smrg case "$new_inherited_linker_flags " in 76161fb744b4Smrg *" $deplib "*) ;; 76171fb744b4Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 76181fb744b4Smrg esac 76191fb744b4Smrg fi 76201fb744b4Smrg fi 76211fb744b4Smrg continue 76221fb744b4Smrg ;; 76231fb744b4Smrg -l*) 762414210e8eSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 762514210e8eSmrg func_warning "'-l' is ignored for archives/objects" 76261fb744b4Smrg continue 76271fb744b4Smrg fi 76281fb744b4Smrg func_stripname '-l' '' "$deplib" 76291fb744b4Smrg name=$func_stripname_result 763014210e8eSmrg if test lib = "$linkmode"; then 76311fb744b4Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 76321fb744b4Smrg else 76331fb744b4Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 76341fb744b4Smrg fi 76351fb744b4Smrg for searchdir in $searchdirs; do 76361fb744b4Smrg for search_ext in .la $std_shrext .so .a; do 76371fb744b4Smrg # Search the libtool library 763814210e8eSmrg lib=$searchdir/lib$name$search_ext 76391fb744b4Smrg if test -f "$lib"; then 764014210e8eSmrg if test .la = "$search_ext"; then 764114210e8eSmrg found=: 76421fb744b4Smrg else 764314210e8eSmrg found=false 76441fb744b4Smrg fi 76451fb744b4Smrg break 2 76461fb744b4Smrg fi 76471fb744b4Smrg done 76481fb744b4Smrg done 764914210e8eSmrg if $found; then 765014210e8eSmrg # deplib is a libtool library 76511fb744b4Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 76521fb744b4Smrg # We need to do some special things here, and not later. 765314210e8eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 76541fb744b4Smrg case " $predeps $postdeps " in 76551fb744b4Smrg *" $deplib "*) 76561fb744b4Smrg if func_lalib_p "$lib"; then 76571fb744b4Smrg library_names= 76581fb744b4Smrg old_library= 76591fb744b4Smrg func_source "$lib" 76601fb744b4Smrg for l in $old_library $library_names; do 766114210e8eSmrg ll=$l 76621fb744b4Smrg done 766314210e8eSmrg if test "X$ll" = "X$old_library"; then # only static version available 766414210e8eSmrg found=false 76651fb744b4Smrg func_dirname "$lib" "" "." 766614210e8eSmrg ladir=$func_dirname_result 76671fb744b4Smrg lib=$ladir/$old_library 766814210e8eSmrg if test prog,link = "$linkmode,$pass"; then 76691fb744b4Smrg compile_deplibs="$deplib $compile_deplibs" 76701fb744b4Smrg finalize_deplibs="$deplib $finalize_deplibs" 76711fb744b4Smrg else 76721fb744b4Smrg deplibs="$deplib $deplibs" 767314210e8eSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76741fb744b4Smrg fi 76751fb744b4Smrg continue 76761fb744b4Smrg fi 76771fb744b4Smrg fi 76781fb744b4Smrg ;; 76791fb744b4Smrg *) ;; 76801fb744b4Smrg esac 76811fb744b4Smrg fi 768214210e8eSmrg else 768314210e8eSmrg # deplib doesn't seem to be a libtool library 768414210e8eSmrg if test prog,link = "$linkmode,$pass"; then 768514210e8eSmrg compile_deplibs="$deplib $compile_deplibs" 768614210e8eSmrg finalize_deplibs="$deplib $finalize_deplibs" 768714210e8eSmrg else 768814210e8eSmrg deplibs="$deplib $deplibs" 768914210e8eSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769014210e8eSmrg fi 769114210e8eSmrg continue 76921fb744b4Smrg fi 76931fb744b4Smrg ;; # -l 76941fb744b4Smrg *.ltframework) 769514210e8eSmrg if test prog,link = "$linkmode,$pass"; then 76961fb744b4Smrg compile_deplibs="$deplib $compile_deplibs" 76971fb744b4Smrg finalize_deplibs="$deplib $finalize_deplibs" 76981fb744b4Smrg else 76991fb744b4Smrg deplibs="$deplib $deplibs" 770014210e8eSmrg if test lib = "$linkmode"; then 77011fb744b4Smrg case "$new_inherited_linker_flags " in 77021fb744b4Smrg *" $deplib "*) ;; 77031fb744b4Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 77041fb744b4Smrg esac 77051fb744b4Smrg fi 77061fb744b4Smrg fi 77071fb744b4Smrg continue 77081fb744b4Smrg ;; 77091fb744b4Smrg -L*) 77101fb744b4Smrg case $linkmode in 77111fb744b4Smrg lib) 77121fb744b4Smrg deplibs="$deplib $deplibs" 771314210e8eSmrg test conv = "$pass" && continue 77141fb744b4Smrg newdependency_libs="$deplib $newdependency_libs" 77151fb744b4Smrg func_stripname '-L' '' "$deplib" 77161fb744b4Smrg func_resolve_sysroot "$func_stripname_result" 77171fb744b4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77181fb744b4Smrg ;; 77191fb744b4Smrg prog) 772014210e8eSmrg if test conv = "$pass"; then 77211fb744b4Smrg deplibs="$deplib $deplibs" 77221fb744b4Smrg continue 77231fb744b4Smrg fi 772414210e8eSmrg if test scan = "$pass"; then 77251fb744b4Smrg deplibs="$deplib $deplibs" 77261fb744b4Smrg else 77271fb744b4Smrg compile_deplibs="$deplib $compile_deplibs" 77281fb744b4Smrg finalize_deplibs="$deplib $finalize_deplibs" 77291fb744b4Smrg fi 77301fb744b4Smrg func_stripname '-L' '' "$deplib" 77311fb744b4Smrg func_resolve_sysroot "$func_stripname_result" 77321fb744b4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77331fb744b4Smrg ;; 77341fb744b4Smrg *) 773514210e8eSmrg func_warning "'-L' is ignored for archives/objects" 77361fb744b4Smrg ;; 77371fb744b4Smrg esac # linkmode 77381fb744b4Smrg continue 77391fb744b4Smrg ;; # -L 77401fb744b4Smrg -R*) 774114210e8eSmrg if test link = "$pass"; then 77421fb744b4Smrg func_stripname '-R' '' "$deplib" 77431fb744b4Smrg func_resolve_sysroot "$func_stripname_result" 77441fb744b4Smrg dir=$func_resolve_sysroot_result 77451fb744b4Smrg # Make sure the xrpath contains only unique directories. 77461fb744b4Smrg case "$xrpath " in 77471fb744b4Smrg *" $dir "*) ;; 77481fb744b4Smrg *) func_append xrpath " $dir" ;; 77491fb744b4Smrg esac 77501fb744b4Smrg fi 77511fb744b4Smrg deplibs="$deplib $deplibs" 77521fb744b4Smrg continue 77531fb744b4Smrg ;; 77541fb744b4Smrg *.la) 77551fb744b4Smrg func_resolve_sysroot "$deplib" 77561fb744b4Smrg lib=$func_resolve_sysroot_result 77571fb744b4Smrg ;; 77581fb744b4Smrg *.$libext) 775914210e8eSmrg if test conv = "$pass"; then 77601fb744b4Smrg deplibs="$deplib $deplibs" 77611fb744b4Smrg continue 77621fb744b4Smrg fi 77631fb744b4Smrg case $linkmode in 77641fb744b4Smrg lib) 77651fb744b4Smrg # Linking convenience modules into shared libraries is allowed, 77661fb744b4Smrg # but linking other static libraries is non-portable. 77671fb744b4Smrg case " $dlpreconveniencelibs " in 77681fb744b4Smrg *" $deplib "*) ;; 77691fb744b4Smrg *) 777014210e8eSmrg valid_a_lib=false 77711fb744b4Smrg case $deplibs_check_method in 77721fb744b4Smrg match_pattern*) 77731fb744b4Smrg set dummy $deplibs_check_method; shift 77741fb744b4Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77751fb744b4Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 77761fb744b4Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 777714210e8eSmrg valid_a_lib=: 77781fb744b4Smrg fi 77791fb744b4Smrg ;; 77801fb744b4Smrg pass_all) 778114210e8eSmrg valid_a_lib=: 77821fb744b4Smrg ;; 77831fb744b4Smrg esac 778414210e8eSmrg if $valid_a_lib; then 778514210e8eSmrg echo 778614210e8eSmrg $ECHO "*** Warning: Linking the shared library $output against the" 778714210e8eSmrg $ECHO "*** static library $deplib is not portable!" 778814210e8eSmrg deplibs="$deplib $deplibs" 778914210e8eSmrg else 77901fb744b4Smrg echo 77911fb744b4Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 77921fb744b4Smrg echo "*** I have the capability to make that library automatically link in when" 77931fb744b4Smrg echo "*** you link to this library. But I can only do this if you have a" 77941fb744b4Smrg echo "*** shared version of the library, which you do not appear to have" 77951fb744b4Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 77961fb744b4Smrg echo "*** that it is just a static archive that I should not use here." 77971fb744b4Smrg fi 77981fb744b4Smrg ;; 77991fb744b4Smrg esac 78001fb744b4Smrg continue 78011fb744b4Smrg ;; 78021fb744b4Smrg prog) 780314210e8eSmrg if test link != "$pass"; then 78041fb744b4Smrg deplibs="$deplib $deplibs" 78051fb744b4Smrg else 78061fb744b4Smrg compile_deplibs="$deplib $compile_deplibs" 78071fb744b4Smrg finalize_deplibs="$deplib $finalize_deplibs" 78081fb744b4Smrg fi 78091fb744b4Smrg continue 78101fb744b4Smrg ;; 78111fb744b4Smrg esac # linkmode 78121fb744b4Smrg ;; # *.$libext 78131fb744b4Smrg *.lo | *.$objext) 781414210e8eSmrg if test conv = "$pass"; then 78151fb744b4Smrg deplibs="$deplib $deplibs" 781614210e8eSmrg elif test prog = "$linkmode"; then 781714210e8eSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 78181fb744b4Smrg # If there is no dlopen support or we're linking statically, 78191fb744b4Smrg # we need to preload. 78201fb744b4Smrg func_append newdlprefiles " $deplib" 78211fb744b4Smrg compile_deplibs="$deplib $compile_deplibs" 78221fb744b4Smrg finalize_deplibs="$deplib $finalize_deplibs" 78231fb744b4Smrg else 78241fb744b4Smrg func_append newdlfiles " $deplib" 78251fb744b4Smrg fi 78261fb744b4Smrg fi 78271fb744b4Smrg continue 78281fb744b4Smrg ;; 78291fb744b4Smrg %DEPLIBS%) 783014210e8eSmrg alldeplibs=: 78311fb744b4Smrg continue 78321fb744b4Smrg ;; 78331fb744b4Smrg esac # case $deplib 78341fb744b4Smrg 783514210e8eSmrg $found || test -f "$lib" \ 783614210e8eSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 78371fb744b4Smrg 78381fb744b4Smrg # Check to see that this really is a libtool archive. 78391fb744b4Smrg func_lalib_unsafe_p "$lib" \ 784014210e8eSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 78411fb744b4Smrg 78421fb744b4Smrg func_dirname "$lib" "" "." 784314210e8eSmrg ladir=$func_dirname_result 78441fb744b4Smrg 78451fb744b4Smrg dlname= 78461fb744b4Smrg dlopen= 78471fb744b4Smrg dlpreopen= 78481fb744b4Smrg libdir= 78491fb744b4Smrg library_names= 78501fb744b4Smrg old_library= 78511fb744b4Smrg inherited_linker_flags= 78521fb744b4Smrg # If the library was installed with an old release of libtool, 78531fb744b4Smrg # it will not redefine variables installed, or shouldnotlink 78541fb744b4Smrg installed=yes 78551fb744b4Smrg shouldnotlink=no 78561fb744b4Smrg avoidtemprpath= 78571fb744b4Smrg 78581fb744b4Smrg 78591fb744b4Smrg # Read the .la file 78601fb744b4Smrg func_source "$lib" 78611fb744b4Smrg 78621fb744b4Smrg # Convert "-framework foo" to "foo.ltframework" 78631fb744b4Smrg if test -n "$inherited_linker_flags"; then 78641fb744b4Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 78651fb744b4Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 78661fb744b4Smrg case " $new_inherited_linker_flags " in 78671fb744b4Smrg *" $tmp_inherited_linker_flag "*) ;; 78681fb744b4Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 78691fb744b4Smrg esac 78701fb744b4Smrg done 78711fb744b4Smrg fi 78721fb744b4Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787314210e8eSmrg if test lib,link = "$linkmode,$pass" || 787414210e8eSmrg test prog,scan = "$linkmode,$pass" || 787514210e8eSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 78761fb744b4Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 78771fb744b4Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 78781fb744b4Smrg fi 78791fb744b4Smrg 788014210e8eSmrg if test conv = "$pass"; then 78811fb744b4Smrg # Only check for convenience libraries 78821fb744b4Smrg deplibs="$lib $deplibs" 78831fb744b4Smrg if test -z "$libdir"; then 78841fb744b4Smrg if test -z "$old_library"; then 788514210e8eSmrg func_fatal_error "cannot find name of link library for '$lib'" 78861fb744b4Smrg fi 78871fb744b4Smrg # It is a libtool convenience library, so add in its objects. 78881fb744b4Smrg func_append convenience " $ladir/$objdir/$old_library" 78891fb744b4Smrg func_append old_convenience " $ladir/$objdir/$old_library" 789014210e8eSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 789114210e8eSmrg func_fatal_error "'$lib' is not a convenience library" 78921fb744b4Smrg fi 78931fb744b4Smrg tmp_libs= 78941fb744b4Smrg for deplib in $dependency_libs; do 78951fb744b4Smrg deplibs="$deplib $deplibs" 789614210e8eSmrg if $opt_preserve_dup_deps; then 78971fb744b4Smrg case "$tmp_libs " in 78981fb744b4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 78991fb744b4Smrg esac 79001fb744b4Smrg fi 79011fb744b4Smrg func_append tmp_libs " $deplib" 79021fb744b4Smrg done 79031fb744b4Smrg continue 79041fb744b4Smrg fi # $pass = conv 79051fb744b4Smrg 79061fb744b4Smrg 79071fb744b4Smrg # Get the name of the library we link against. 79081fb744b4Smrg linklib= 79091fb744b4Smrg if test -n "$old_library" && 791014210e8eSmrg { test yes = "$prefer_static_libs" || 791114210e8eSmrg test built,no = "$prefer_static_libs,$installed"; }; then 79121fb744b4Smrg linklib=$old_library 79131fb744b4Smrg else 79141fb744b4Smrg for l in $old_library $library_names; do 791514210e8eSmrg linklib=$l 79161fb744b4Smrg done 79171fb744b4Smrg fi 79181fb744b4Smrg if test -z "$linklib"; then 791914210e8eSmrg func_fatal_error "cannot find name of link library for '$lib'" 79201fb744b4Smrg fi 79211fb744b4Smrg 79221fb744b4Smrg # This library was specified with -dlopen. 792314210e8eSmrg if test dlopen = "$pass"; then 792414210e8eSmrg test -z "$libdir" \ 792514210e8eSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 79261fb744b4Smrg if test -z "$dlname" || 792714210e8eSmrg test yes != "$dlopen_support" || 792814210e8eSmrg test no = "$build_libtool_libs" 792914210e8eSmrg then 79301fb744b4Smrg # If there is no dlname, no dlopen support or we're linking 79311fb744b4Smrg # statically, we need to preload. We also need to preload any 79321fb744b4Smrg # dependent libraries so libltdl's deplib preloader doesn't 79331fb744b4Smrg # bomb out in the load deplibs phase. 79341fb744b4Smrg func_append dlprefiles " $lib $dependency_libs" 79351fb744b4Smrg else 79361fb744b4Smrg func_append newdlfiles " $lib" 79371fb744b4Smrg fi 79381fb744b4Smrg continue 79391fb744b4Smrg fi # $pass = dlopen 79401fb744b4Smrg 79411fb744b4Smrg # We need an absolute path. 79421fb744b4Smrg case $ladir in 794314210e8eSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 79441fb744b4Smrg *) 79451fb744b4Smrg abs_ladir=`cd "$ladir" && pwd` 79461fb744b4Smrg if test -z "$abs_ladir"; then 794714210e8eSmrg func_warning "cannot determine absolute directory name of '$ladir'" 79481fb744b4Smrg func_warning "passing it literally to the linker, although it might fail" 794914210e8eSmrg abs_ladir=$ladir 79501fb744b4Smrg fi 79511fb744b4Smrg ;; 79521fb744b4Smrg esac 79531fb744b4Smrg func_basename "$lib" 795414210e8eSmrg laname=$func_basename_result 79551fb744b4Smrg 79561fb744b4Smrg # Find the relevant object directory and library name. 795714210e8eSmrg if test yes = "$installed"; then 79581fb744b4Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 795914210e8eSmrg func_warning "library '$lib' was moved." 796014210e8eSmrg dir=$ladir 796114210e8eSmrg absdir=$abs_ladir 796214210e8eSmrg libdir=$abs_ladir 79631fb744b4Smrg else 796414210e8eSmrg dir=$lt_sysroot$libdir 796514210e8eSmrg absdir=$lt_sysroot$libdir 79661fb744b4Smrg fi 796714210e8eSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 79681fb744b4Smrg else 79691fb744b4Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797014210e8eSmrg dir=$ladir 797114210e8eSmrg absdir=$abs_ladir 79721fb744b4Smrg # Remove this search path later 79731fb744b4Smrg func_append notinst_path " $abs_ladir" 79741fb744b4Smrg else 797514210e8eSmrg dir=$ladir/$objdir 797614210e8eSmrg absdir=$abs_ladir/$objdir 79771fb744b4Smrg # Remove this search path later 79781fb744b4Smrg func_append notinst_path " $abs_ladir" 79791fb744b4Smrg fi 79801fb744b4Smrg fi # $installed = yes 79811fb744b4Smrg func_stripname 'lib' '.la' "$laname" 79821fb744b4Smrg name=$func_stripname_result 79831fb744b4Smrg 79841fb744b4Smrg # This library was specified with -dlpreopen. 798514210e8eSmrg if test dlpreopen = "$pass"; then 798614210e8eSmrg if test -z "$libdir" && test prog = "$linkmode"; then 798714210e8eSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 79881fb744b4Smrg fi 798914210e8eSmrg case $host in 79901fb744b4Smrg # special handling for platforms with PE-DLLs. 79911fb744b4Smrg *cygwin* | *mingw* | *cegcc* ) 79921fb744b4Smrg # Linker will automatically link against shared library if both 79931fb744b4Smrg # static and shared are present. Therefore, ensure we extract 79941fb744b4Smrg # symbols from the import library if a shared library is present 79951fb744b4Smrg # (otherwise, the dlopen module name will be incorrect). We do 79961fb744b4Smrg # this by putting the import library name into $newdlprefiles. 79971fb744b4Smrg # We recover the dlopen module name by 'saving' the la file 79981fb744b4Smrg # name in a special purpose variable, and (later) extracting the 79991fb744b4Smrg # dlname from the la file. 80001fb744b4Smrg if test -n "$dlname"; then 80011fb744b4Smrg func_tr_sh "$dir/$linklib" 80021fb744b4Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 80031fb744b4Smrg func_append newdlprefiles " $dir/$linklib" 80041fb744b4Smrg else 80051fb744b4Smrg func_append newdlprefiles " $dir/$old_library" 80061fb744b4Smrg # Keep a list of preopened convenience libraries to check 80071fb744b4Smrg # that they are being used correctly in the link pass. 80081fb744b4Smrg test -z "$libdir" && \ 80091fb744b4Smrg func_append dlpreconveniencelibs " $dir/$old_library" 80101fb744b4Smrg fi 80111fb744b4Smrg ;; 80121fb744b4Smrg * ) 80131fb744b4Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 80141fb744b4Smrg # are required to link). 80151fb744b4Smrg if test -n "$old_library"; then 80161fb744b4Smrg func_append newdlprefiles " $dir/$old_library" 80171fb744b4Smrg # Keep a list of preopened convenience libraries to check 80181fb744b4Smrg # that they are being used correctly in the link pass. 80191fb744b4Smrg test -z "$libdir" && \ 80201fb744b4Smrg func_append dlpreconveniencelibs " $dir/$old_library" 80211fb744b4Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 80221fb744b4Smrg elif test -n "$dlname"; then 80231fb744b4Smrg func_append newdlprefiles " $dir/$dlname" 80241fb744b4Smrg else 80251fb744b4Smrg func_append newdlprefiles " $dir/$linklib" 80261fb744b4Smrg fi 80271fb744b4Smrg ;; 80281fb744b4Smrg esac 80291fb744b4Smrg fi # $pass = dlpreopen 80301fb744b4Smrg 80311fb744b4Smrg if test -z "$libdir"; then 80321fb744b4Smrg # Link the convenience library 803314210e8eSmrg if test lib = "$linkmode"; then 80341fb744b4Smrg deplibs="$dir/$old_library $deplibs" 803514210e8eSmrg elif test prog,link = "$linkmode,$pass"; then 80361fb744b4Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 80371fb744b4Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 80381fb744b4Smrg else 80391fb744b4Smrg deplibs="$lib $deplibs" # used for prog,scan pass 80401fb744b4Smrg fi 80411fb744b4Smrg continue 80421fb744b4Smrg fi 80431fb744b4Smrg 80441fb744b4Smrg 804514210e8eSmrg if test prog = "$linkmode" && test link != "$pass"; then 80461fb744b4Smrg func_append newlib_search_path " $ladir" 80471fb744b4Smrg deplibs="$lib $deplibs" 80481fb744b4Smrg 804914210e8eSmrg linkalldeplibs=false 805014210e8eSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805114210e8eSmrg test no = "$build_libtool_libs"; then 805214210e8eSmrg linkalldeplibs=: 80531fb744b4Smrg fi 80541fb744b4Smrg 80551fb744b4Smrg tmp_libs= 80561fb744b4Smrg for deplib in $dependency_libs; do 80571fb744b4Smrg case $deplib in 80581fb744b4Smrg -L*) func_stripname '-L' '' "$deplib" 80591fb744b4Smrg func_resolve_sysroot "$func_stripname_result" 80601fb744b4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80611fb744b4Smrg ;; 80621fb744b4Smrg esac 80631fb744b4Smrg # Need to link against all dependency_libs? 806414210e8eSmrg if $linkalldeplibs; then 80651fb744b4Smrg deplibs="$deplib $deplibs" 80661fb744b4Smrg else 80671fb744b4Smrg # Need to hardcode shared library paths 80681fb744b4Smrg # or/and link against static libraries 80691fb744b4Smrg newdependency_libs="$deplib $newdependency_libs" 80701fb744b4Smrg fi 807114210e8eSmrg if $opt_preserve_dup_deps; then 80721fb744b4Smrg case "$tmp_libs " in 80731fb744b4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 80741fb744b4Smrg esac 80751fb744b4Smrg fi 80761fb744b4Smrg func_append tmp_libs " $deplib" 80771fb744b4Smrg done # for deplib 80781fb744b4Smrg continue 80791fb744b4Smrg fi # $linkmode = prog... 80801fb744b4Smrg 808114210e8eSmrg if test prog,link = "$linkmode,$pass"; then 80821fb744b4Smrg if test -n "$library_names" && 808314210e8eSmrg { { test no = "$prefer_static_libs" || 808414210e8eSmrg test built,yes = "$prefer_static_libs,$installed"; } || 80851fb744b4Smrg test -z "$old_library"; }; then 80861fb744b4Smrg # We need to hardcode the library path 808714210e8eSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 80881fb744b4Smrg # Make sure the rpath contains only unique directories. 808914210e8eSmrg case $temp_rpath: in 80901fb744b4Smrg *"$absdir:"*) ;; 80911fb744b4Smrg *) func_append temp_rpath "$absdir:" ;; 80921fb744b4Smrg esac 80931fb744b4Smrg fi 80941fb744b4Smrg 80951fb744b4Smrg # Hardcode the library path. 80961fb744b4Smrg # Skip directories that are in the system default run-time 80971fb744b4Smrg # search path. 80981fb744b4Smrg case " $sys_lib_dlsearch_path " in 80991fb744b4Smrg *" $absdir "*) ;; 81001fb744b4Smrg *) 81011fb744b4Smrg case "$compile_rpath " in 81021fb744b4Smrg *" $absdir "*) ;; 81031fb744b4Smrg *) func_append compile_rpath " $absdir" ;; 81041fb744b4Smrg esac 81051fb744b4Smrg ;; 81061fb744b4Smrg esac 81071fb744b4Smrg case " $sys_lib_dlsearch_path " in 81081fb744b4Smrg *" $libdir "*) ;; 81091fb744b4Smrg *) 81101fb744b4Smrg case "$finalize_rpath " in 81111fb744b4Smrg *" $libdir "*) ;; 81121fb744b4Smrg *) func_append finalize_rpath " $libdir" ;; 81131fb744b4Smrg esac 81141fb744b4Smrg ;; 81151fb744b4Smrg esac 81161fb744b4Smrg fi # $linkmode,$pass = prog,link... 81171fb744b4Smrg 811814210e8eSmrg if $alldeplibs && 811914210e8eSmrg { test pass_all = "$deplibs_check_method" || 812014210e8eSmrg { test yes = "$build_libtool_libs" && 81211fb744b4Smrg test -n "$library_names"; }; }; then 81221fb744b4Smrg # We only need to search for static libraries 81231fb744b4Smrg continue 81241fb744b4Smrg fi 81251fb744b4Smrg fi 81261fb744b4Smrg 81271fb744b4Smrg link_static=no # Whether the deplib will be linked statically 81281fb744b4Smrg use_static_libs=$prefer_static_libs 812914210e8eSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 81301fb744b4Smrg use_static_libs=no 81311fb744b4Smrg fi 81321fb744b4Smrg if test -n "$library_names" && 813314210e8eSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 81341fb744b4Smrg case $host in 813514210e8eSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 81361fb744b4Smrg # No point in relinking DLLs because paths are not encoded 81371fb744b4Smrg func_append notinst_deplibs " $lib" 81381fb744b4Smrg need_relink=no 81391fb744b4Smrg ;; 81401fb744b4Smrg *) 814114210e8eSmrg if test no = "$installed"; then 81421fb744b4Smrg func_append notinst_deplibs " $lib" 81431fb744b4Smrg need_relink=yes 81441fb744b4Smrg fi 81451fb744b4Smrg ;; 81461fb744b4Smrg esac 81471fb744b4Smrg # This is a shared library 81481fb744b4Smrg 81491fb744b4Smrg # Warn about portability, can't link against -module's on some 81501fb744b4Smrg # systems (darwin). Don't bleat about dlopened modules though! 815114210e8eSmrg dlopenmodule= 81521fb744b4Smrg for dlpremoduletest in $dlprefiles; do 81531fb744b4Smrg if test "X$dlpremoduletest" = "X$lib"; then 815414210e8eSmrg dlopenmodule=$dlpremoduletest 81551fb744b4Smrg break 81561fb744b4Smrg fi 81571fb744b4Smrg done 815814210e8eSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 81591fb744b4Smrg echo 816014210e8eSmrg if test prog = "$linkmode"; then 81611fb744b4Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 81621fb744b4Smrg else 81631fb744b4Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 81641fb744b4Smrg fi 81651fb744b4Smrg $ECHO "*** $linklib is not portable!" 81661fb744b4Smrg fi 816714210e8eSmrg if test lib = "$linkmode" && 816814210e8eSmrg test yes = "$hardcode_into_libs"; then 81691fb744b4Smrg # Hardcode the library path. 81701fb744b4Smrg # Skip directories that are in the system default run-time 81711fb744b4Smrg # search path. 81721fb744b4Smrg case " $sys_lib_dlsearch_path " in 81731fb744b4Smrg *" $absdir "*) ;; 81741fb744b4Smrg *) 81751fb744b4Smrg case "$compile_rpath " in 81761fb744b4Smrg *" $absdir "*) ;; 81771fb744b4Smrg *) func_append compile_rpath " $absdir" ;; 81781fb744b4Smrg esac 81791fb744b4Smrg ;; 81801fb744b4Smrg esac 81811fb744b4Smrg case " $sys_lib_dlsearch_path " in 81821fb744b4Smrg *" $libdir "*) ;; 81831fb744b4Smrg *) 81841fb744b4Smrg case "$finalize_rpath " in 81851fb744b4Smrg *" $libdir "*) ;; 81861fb744b4Smrg *) func_append finalize_rpath " $libdir" ;; 81871fb744b4Smrg esac 81881fb744b4Smrg ;; 81891fb744b4Smrg esac 81901fb744b4Smrg fi 81911fb744b4Smrg 81921fb744b4Smrg if test -n "$old_archive_from_expsyms_cmds"; then 81931fb744b4Smrg # figure out the soname 81941fb744b4Smrg set dummy $library_names 81951fb744b4Smrg shift 819614210e8eSmrg realname=$1 81971fb744b4Smrg shift 81981fb744b4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 81991fb744b4Smrg # use dlname if we got it. it's perfectly good, no? 82001fb744b4Smrg if test -n "$dlname"; then 820114210e8eSmrg soname=$dlname 82021fb744b4Smrg elif test -n "$soname_spec"; then 82031fb744b4Smrg # bleh windows 82041fb744b4Smrg case $host in 820514210e8eSmrg *cygwin* | mingw* | *cegcc* | *os2*) 82061fb744b4Smrg func_arith $current - $age 82071fb744b4Smrg major=$func_arith_result 820814210e8eSmrg versuffix=-$major 82091fb744b4Smrg ;; 82101fb744b4Smrg esac 82111fb744b4Smrg eval soname=\"$soname_spec\" 82121fb744b4Smrg else 821314210e8eSmrg soname=$realname 82141fb744b4Smrg fi 82151fb744b4Smrg 82161fb744b4Smrg # Make a new name for the extract_expsyms_cmds to use 821714210e8eSmrg soroot=$soname 82181fb744b4Smrg func_basename "$soroot" 821914210e8eSmrg soname=$func_basename_result 82201fb744b4Smrg func_stripname 'lib' '.dll' "$soname" 82211fb744b4Smrg newlib=libimp-$func_stripname_result.a 82221fb744b4Smrg 82231fb744b4Smrg # If the library has no export list, then create one now 82241fb744b4Smrg if test -f "$output_objdir/$soname-def"; then : 82251fb744b4Smrg else 822614210e8eSmrg func_verbose "extracting exported symbol list from '$soname'" 82271fb744b4Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 82281fb744b4Smrg fi 82291fb744b4Smrg 82301fb744b4Smrg # Create $newlib 82311fb744b4Smrg if test -f "$output_objdir/$newlib"; then :; else 823214210e8eSmrg func_verbose "generating import library for '$soname'" 82331fb744b4Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 82341fb744b4Smrg fi 82351fb744b4Smrg # make sure the library variables are pointing to the new library 82361fb744b4Smrg dir=$output_objdir 82371fb744b4Smrg linklib=$newlib 82381fb744b4Smrg fi # test -n "$old_archive_from_expsyms_cmds" 82391fb744b4Smrg 824014210e8eSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 82411fb744b4Smrg add_shlibpath= 82421fb744b4Smrg add_dir= 82431fb744b4Smrg add= 82441fb744b4Smrg lib_linked=yes 82451fb744b4Smrg case $hardcode_action in 82461fb744b4Smrg immediate | unsupported) 824714210e8eSmrg if test no = "$hardcode_direct"; then 824814210e8eSmrg add=$dir/$linklib 82491fb744b4Smrg case $host in 825014210e8eSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825114210e8eSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 82521fb744b4Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825314210e8eSmrg *-*-unixware7*) add_dir=-L$dir ;; 82541fb744b4Smrg *-*-darwin* ) 825514210e8eSmrg # if the lib is a (non-dlopened) module then we cannot 82561fb744b4Smrg # link against it, someone is ignoring the earlier warnings 82571fb744b4Smrg if /usr/bin/file -L $add 2> /dev/null | 825814210e8eSmrg $GREP ": [^:]* bundle" >/dev/null; then 82591fb744b4Smrg if test "X$dlopenmodule" != "X$lib"; then 82601fb744b4Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826114210e8eSmrg if test -z "$old_library"; then 82621fb744b4Smrg echo 82631fb744b4Smrg echo "*** And there doesn't seem to be a static archive available" 82641fb744b4Smrg echo "*** The link will probably fail, sorry" 82651fb744b4Smrg else 826614210e8eSmrg add=$dir/$old_library 82671fb744b4Smrg fi 82681fb744b4Smrg elif test -n "$old_library"; then 826914210e8eSmrg add=$dir/$old_library 82701fb744b4Smrg fi 82711fb744b4Smrg fi 82721fb744b4Smrg esac 827314210e8eSmrg elif test no = "$hardcode_minus_L"; then 82741fb744b4Smrg case $host in 827514210e8eSmrg *-*-sunos*) add_shlibpath=$dir ;; 82761fb744b4Smrg esac 827714210e8eSmrg add_dir=-L$dir 827814210e8eSmrg add=-l$name 827914210e8eSmrg elif test no = "$hardcode_shlibpath_var"; then 828014210e8eSmrg add_shlibpath=$dir 828114210e8eSmrg add=-l$name 82821fb744b4Smrg else 82831fb744b4Smrg lib_linked=no 82841fb744b4Smrg fi 82851fb744b4Smrg ;; 82861fb744b4Smrg relink) 828714210e8eSmrg if test yes = "$hardcode_direct" && 828814210e8eSmrg test no = "$hardcode_direct_absolute"; then 828914210e8eSmrg add=$dir/$linklib 829014210e8eSmrg elif test yes = "$hardcode_minus_L"; then 829114210e8eSmrg add_dir=-L$absdir 82921fb744b4Smrg # Try looking first in the location we're being installed to. 82931fb744b4Smrg if test -n "$inst_prefix_dir"; then 82941fb744b4Smrg case $libdir in 82951fb744b4Smrg [\\/]*) 82961fb744b4Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 82971fb744b4Smrg ;; 82981fb744b4Smrg esac 82991fb744b4Smrg fi 830014210e8eSmrg add=-l$name 830114210e8eSmrg elif test yes = "$hardcode_shlibpath_var"; then 830214210e8eSmrg add_shlibpath=$dir 830314210e8eSmrg add=-l$name 83041fb744b4Smrg else 83051fb744b4Smrg lib_linked=no 83061fb744b4Smrg fi 83071fb744b4Smrg ;; 83081fb744b4Smrg *) lib_linked=no ;; 83091fb744b4Smrg esac 83101fb744b4Smrg 831114210e8eSmrg if test yes != "$lib_linked"; then 83121fb744b4Smrg func_fatal_configuration "unsupported hardcode properties" 83131fb744b4Smrg fi 83141fb744b4Smrg 83151fb744b4Smrg if test -n "$add_shlibpath"; then 83161fb744b4Smrg case :$compile_shlibpath: in 83171fb744b4Smrg *":$add_shlibpath:"*) ;; 83181fb744b4Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 83191fb744b4Smrg esac 83201fb744b4Smrg fi 832114210e8eSmrg if test prog = "$linkmode"; then 83221fb744b4Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 83231fb744b4Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 83241fb744b4Smrg else 83251fb744b4Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83261fb744b4Smrg test -n "$add" && deplibs="$add $deplibs" 832714210e8eSmrg if test yes != "$hardcode_direct" && 832814210e8eSmrg test yes != "$hardcode_minus_L" && 832914210e8eSmrg test yes = "$hardcode_shlibpath_var"; then 83301fb744b4Smrg case :$finalize_shlibpath: in 83311fb744b4Smrg *":$libdir:"*) ;; 83321fb744b4Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83331fb744b4Smrg esac 83341fb744b4Smrg fi 83351fb744b4Smrg fi 83361fb744b4Smrg fi 83371fb744b4Smrg 833814210e8eSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 83391fb744b4Smrg add_shlibpath= 83401fb744b4Smrg add_dir= 83411fb744b4Smrg add= 83421fb744b4Smrg # Finalize command for both is simple: just hardcode it. 834314210e8eSmrg if test yes = "$hardcode_direct" && 834414210e8eSmrg test no = "$hardcode_direct_absolute"; then 834514210e8eSmrg add=$libdir/$linklib 834614210e8eSmrg elif test yes = "$hardcode_minus_L"; then 834714210e8eSmrg add_dir=-L$libdir 834814210e8eSmrg add=-l$name 834914210e8eSmrg elif test yes = "$hardcode_shlibpath_var"; then 83501fb744b4Smrg case :$finalize_shlibpath: in 83511fb744b4Smrg *":$libdir:"*) ;; 83521fb744b4Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83531fb744b4Smrg esac 835414210e8eSmrg add=-l$name 835514210e8eSmrg elif test yes = "$hardcode_automatic"; then 83561fb744b4Smrg if test -n "$inst_prefix_dir" && 835714210e8eSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 835814210e8eSmrg add=$inst_prefix_dir$libdir/$linklib 83591fb744b4Smrg else 836014210e8eSmrg add=$libdir/$linklib 83611fb744b4Smrg fi 83621fb744b4Smrg else 83631fb744b4Smrg # We cannot seem to hardcode it, guess we'll fake it. 836414210e8eSmrg add_dir=-L$libdir 83651fb744b4Smrg # Try looking first in the location we're being installed to. 83661fb744b4Smrg if test -n "$inst_prefix_dir"; then 83671fb744b4Smrg case $libdir in 83681fb744b4Smrg [\\/]*) 83691fb744b4Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 83701fb744b4Smrg ;; 83711fb744b4Smrg esac 83721fb744b4Smrg fi 837314210e8eSmrg add=-l$name 83741fb744b4Smrg fi 83751fb744b4Smrg 837614210e8eSmrg if test prog = "$linkmode"; then 83771fb744b4Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 83781fb744b4Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 83791fb744b4Smrg else 83801fb744b4Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83811fb744b4Smrg test -n "$add" && deplibs="$add $deplibs" 83821fb744b4Smrg fi 83831fb744b4Smrg fi 838414210e8eSmrg elif test prog = "$linkmode"; then 83851fb744b4Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 83861fb744b4Smrg # is not unsupported. This is valid on all known static and 83871fb744b4Smrg # shared platforms. 838814210e8eSmrg if test unsupported != "$hardcode_direct"; then 838914210e8eSmrg test -n "$old_library" && linklib=$old_library 83901fb744b4Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 83911fb744b4Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 83921fb744b4Smrg else 83931fb744b4Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 83941fb744b4Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 83951fb744b4Smrg fi 839614210e8eSmrg elif test yes = "$build_libtool_libs"; then 83971fb744b4Smrg # Not a shared library 839814210e8eSmrg if test pass_all != "$deplibs_check_method"; then 83991fb744b4Smrg # We're trying link a shared library against a static one 84001fb744b4Smrg # but the system doesn't support it. 84011fb744b4Smrg 84021fb744b4Smrg # Just print a warning and add the library to dependency_libs so 84031fb744b4Smrg # that the program can be linked against the static library. 84041fb744b4Smrg echo 840514210e8eSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 84061fb744b4Smrg echo "*** I have the capability to make that library automatically link in when" 84071fb744b4Smrg echo "*** you link to this library. But I can only do this if you have a" 84081fb744b4Smrg echo "*** shared version of the library, which you do not appear to have." 840914210e8eSmrg if test yes = "$module"; then 84101fb744b4Smrg echo "*** But as you try to build a module library, libtool will still create " 84111fb744b4Smrg echo "*** a static module, that should work as long as the dlopening application" 84121fb744b4Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 84131fb744b4Smrg if test -z "$global_symbol_pipe"; then 84141fb744b4Smrg echo 84151fb744b4Smrg echo "*** However, this would only work if libtool was able to extract symbol" 841614210e8eSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 84171fb744b4Smrg echo "*** not find such a program. So, this module is probably useless." 841814210e8eSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 84191fb744b4Smrg fi 842014210e8eSmrg if test no = "$build_old_libs"; then 84211fb744b4Smrg build_libtool_libs=module 84221fb744b4Smrg build_old_libs=yes 84231fb744b4Smrg else 84241fb744b4Smrg build_libtool_libs=no 84251fb744b4Smrg fi 84261fb744b4Smrg fi 84271fb744b4Smrg else 84281fb744b4Smrg deplibs="$dir/$old_library $deplibs" 84291fb744b4Smrg link_static=yes 84301fb744b4Smrg fi 84311fb744b4Smrg fi # link shared/static library? 84321fb744b4Smrg 843314210e8eSmrg if test lib = "$linkmode"; then 84341fb744b4Smrg if test -n "$dependency_libs" && 843514210e8eSmrg { test yes != "$hardcode_into_libs" || 843614210e8eSmrg test yes = "$build_old_libs" || 843714210e8eSmrg test yes = "$link_static"; }; then 84381fb744b4Smrg # Extract -R from dependency_libs 84391fb744b4Smrg temp_deplibs= 84401fb744b4Smrg for libdir in $dependency_libs; do 84411fb744b4Smrg case $libdir in 84421fb744b4Smrg -R*) func_stripname '-R' '' "$libdir" 84431fb744b4Smrg temp_xrpath=$func_stripname_result 84441fb744b4Smrg case " $xrpath " in 84451fb744b4Smrg *" $temp_xrpath "*) ;; 84461fb744b4Smrg *) func_append xrpath " $temp_xrpath";; 84471fb744b4Smrg esac;; 84481fb744b4Smrg *) func_append temp_deplibs " $libdir";; 84491fb744b4Smrg esac 84501fb744b4Smrg done 845114210e8eSmrg dependency_libs=$temp_deplibs 84521fb744b4Smrg fi 84531fb744b4Smrg 84541fb744b4Smrg func_append newlib_search_path " $absdir" 84551fb744b4Smrg # Link against this library 845614210e8eSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 84571fb744b4Smrg # ... and its dependency_libs 84581fb744b4Smrg tmp_libs= 84591fb744b4Smrg for deplib in $dependency_libs; do 84601fb744b4Smrg newdependency_libs="$deplib $newdependency_libs" 84611fb744b4Smrg case $deplib in 84621fb744b4Smrg -L*) func_stripname '-L' '' "$deplib" 84631fb744b4Smrg func_resolve_sysroot "$func_stripname_result";; 84641fb744b4Smrg *) func_resolve_sysroot "$deplib" ;; 84651fb744b4Smrg esac 846614210e8eSmrg if $opt_preserve_dup_deps; then 84671fb744b4Smrg case "$tmp_libs " in 84681fb744b4Smrg *" $func_resolve_sysroot_result "*) 84691fb744b4Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 84701fb744b4Smrg esac 84711fb744b4Smrg fi 84721fb744b4Smrg func_append tmp_libs " $func_resolve_sysroot_result" 84731fb744b4Smrg done 84741fb744b4Smrg 847514210e8eSmrg if test no != "$link_all_deplibs"; then 84761fb744b4Smrg # Add the search paths of all dependency libraries 84771fb744b4Smrg for deplib in $dependency_libs; do 84781fb744b4Smrg path= 84791fb744b4Smrg case $deplib in 848014210e8eSmrg -L*) path=$deplib ;; 84811fb744b4Smrg *.la) 84821fb744b4Smrg func_resolve_sysroot "$deplib" 84831fb744b4Smrg deplib=$func_resolve_sysroot_result 84841fb744b4Smrg func_dirname "$deplib" "" "." 84851fb744b4Smrg dir=$func_dirname_result 84861fb744b4Smrg # We need an absolute path. 84871fb744b4Smrg case $dir in 848814210e8eSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 84891fb744b4Smrg *) 84901fb744b4Smrg absdir=`cd "$dir" && pwd` 84911fb744b4Smrg if test -z "$absdir"; then 849214210e8eSmrg func_warning "cannot determine absolute directory name of '$dir'" 849314210e8eSmrg absdir=$dir 84941fb744b4Smrg fi 84951fb744b4Smrg ;; 84961fb744b4Smrg esac 84971fb744b4Smrg if $GREP "^installed=no" $deplib > /dev/null; then 84981fb744b4Smrg case $host in 84991fb744b4Smrg *-*-darwin*) 85001fb744b4Smrg depdepl= 850114210e8eSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850214210e8eSmrg if test -n "$deplibrary_names"; then 850314210e8eSmrg for tmp in $deplibrary_names; do 85041fb744b4Smrg depdepl=$tmp 85051fb744b4Smrg done 850614210e8eSmrg if test -f "$absdir/$objdir/$depdepl"; then 850714210e8eSmrg depdepl=$absdir/$objdir/$depdepl 850814210e8eSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85091fb744b4Smrg if test -z "$darwin_install_name"; then 851014210e8eSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85111fb744b4Smrg fi 851214210e8eSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851314210e8eSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 85141fb744b4Smrg path= 85151fb744b4Smrg fi 85161fb744b4Smrg fi 85171fb744b4Smrg ;; 85181fb744b4Smrg *) 851914210e8eSmrg path=-L$absdir/$objdir 85201fb744b4Smrg ;; 85211fb744b4Smrg esac 85221fb744b4Smrg else 852314210e8eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 85241fb744b4Smrg test -z "$libdir" && \ 852514210e8eSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 85261fb744b4Smrg test "$absdir" != "$libdir" && \ 852714210e8eSmrg func_warning "'$deplib' seems to be moved" 85281fb744b4Smrg 852914210e8eSmrg path=-L$absdir 85301fb744b4Smrg fi 85311fb744b4Smrg ;; 85321fb744b4Smrg esac 85331fb744b4Smrg case " $deplibs " in 85341fb744b4Smrg *" $path "*) ;; 85351fb744b4Smrg *) deplibs="$path $deplibs" ;; 85361fb744b4Smrg esac 85371fb744b4Smrg done 85381fb744b4Smrg fi # link_all_deplibs != no 85391fb744b4Smrg fi # linkmode = lib 85401fb744b4Smrg done # for deplib in $libs 854114210e8eSmrg if test link = "$pass"; then 854214210e8eSmrg if test prog = "$linkmode"; then 85431fb744b4Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 85441fb744b4Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 85451fb744b4Smrg else 85461fb744b4Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 85471fb744b4Smrg fi 85481fb744b4Smrg fi 854914210e8eSmrg dependency_libs=$newdependency_libs 855014210e8eSmrg if test dlpreopen = "$pass"; then 85511fb744b4Smrg # Link the dlpreopened libraries before other libraries 85521fb744b4Smrg for deplib in $save_deplibs; do 85531fb744b4Smrg deplibs="$deplib $deplibs" 85541fb744b4Smrg done 85551fb744b4Smrg fi 855614210e8eSmrg if test dlopen != "$pass"; then 855714210e8eSmrg test conv = "$pass" || { 85581fb744b4Smrg # Make sure lib_search_path contains only unique directories. 85591fb744b4Smrg lib_search_path= 85601fb744b4Smrg for dir in $newlib_search_path; do 85611fb744b4Smrg case "$lib_search_path " in 85621fb744b4Smrg *" $dir "*) ;; 85631fb744b4Smrg *) func_append lib_search_path " $dir" ;; 85641fb744b4Smrg esac 85651fb744b4Smrg done 85661fb744b4Smrg newlib_search_path= 856714210e8eSmrg } 85681fb744b4Smrg 856914210e8eSmrg if test prog,link = "$linkmode,$pass"; then 85701fb744b4Smrg vars="compile_deplibs finalize_deplibs" 857114210e8eSmrg else 857214210e8eSmrg vars=deplibs 85731fb744b4Smrg fi 85741fb744b4Smrg for var in $vars dependency_libs; do 85751fb744b4Smrg # Add libraries to $var in reverse order 85761fb744b4Smrg eval tmp_libs=\"\$$var\" 85771fb744b4Smrg new_libs= 85781fb744b4Smrg for deplib in $tmp_libs; do 85791fb744b4Smrg # FIXME: Pedantically, this is the right thing to do, so 85801fb744b4Smrg # that some nasty dependency loop isn't accidentally 85811fb744b4Smrg # broken: 85821fb744b4Smrg #new_libs="$deplib $new_libs" 85831fb744b4Smrg # Pragmatically, this seems to cause very few problems in 85841fb744b4Smrg # practice: 85851fb744b4Smrg case $deplib in 85861fb744b4Smrg -L*) new_libs="$deplib $new_libs" ;; 85871fb744b4Smrg -R*) ;; 85881fb744b4Smrg *) 85891fb744b4Smrg # And here is the reason: when a library appears more 85901fb744b4Smrg # than once as an explicit dependence of a library, or 85911fb744b4Smrg # is implicitly linked in more than once by the 85921fb744b4Smrg # compiler, it is considered special, and multiple 85931fb744b4Smrg # occurrences thereof are not removed. Compare this 85941fb744b4Smrg # with having the same library being listed as a 85951fb744b4Smrg # dependency of multiple other libraries: in this case, 85961fb744b4Smrg # we know (pedantically, we assume) the library does not 85971fb744b4Smrg # need to be listed more than once, so we keep only the 85981fb744b4Smrg # last copy. This is not always right, but it is rare 85991fb744b4Smrg # enough that we require users that really mean to play 86001fb744b4Smrg # such unportable linking tricks to link the library 86011fb744b4Smrg # using -Wl,-lname, so that libtool does not consider it 86021fb744b4Smrg # for duplicate removal. 86031fb744b4Smrg case " $specialdeplibs " in 86041fb744b4Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 86051fb744b4Smrg *) 86061fb744b4Smrg case " $new_libs " in 86071fb744b4Smrg *" $deplib "*) ;; 86081fb744b4Smrg *) new_libs="$deplib $new_libs" ;; 86091fb744b4Smrg esac 86101fb744b4Smrg ;; 86111fb744b4Smrg esac 86121fb744b4Smrg ;; 86131fb744b4Smrg esac 86141fb744b4Smrg done 86151fb744b4Smrg tmp_libs= 86161fb744b4Smrg for deplib in $new_libs; do 86171fb744b4Smrg case $deplib in 86181fb744b4Smrg -L*) 86191fb744b4Smrg case " $tmp_libs " in 86201fb744b4Smrg *" $deplib "*) ;; 86211fb744b4Smrg *) func_append tmp_libs " $deplib" ;; 86221fb744b4Smrg esac 86231fb744b4Smrg ;; 86241fb744b4Smrg *) func_append tmp_libs " $deplib" ;; 86251fb744b4Smrg esac 86261fb744b4Smrg done 86271fb744b4Smrg eval $var=\"$tmp_libs\" 86281fb744b4Smrg done # for var 86291fb744b4Smrg fi 863014210e8eSmrg 863114210e8eSmrg # Add Sun CC postdeps if required: 863214210e8eSmrg test CXX = "$tagname" && { 863314210e8eSmrg case $host_os in 863414210e8eSmrg linux*) 863514210e8eSmrg case `$CC -V 2>&1 | sed 5q` in 863614210e8eSmrg *Sun\ C*) # Sun C++ 5.9 863714210e8eSmrg func_suncc_cstd_abi 863814210e8eSmrg 863914210e8eSmrg if test no != "$suncc_use_cstd_abi"; then 864014210e8eSmrg func_append postdeps ' -library=Cstd -library=Crun' 864114210e8eSmrg fi 864214210e8eSmrg ;; 864314210e8eSmrg esac 864414210e8eSmrg ;; 864514210e8eSmrg 864614210e8eSmrg solaris*) 864714210e8eSmrg func_cc_basename "$CC" 864814210e8eSmrg case $func_cc_basename_result in 864914210e8eSmrg CC* | sunCC*) 865014210e8eSmrg func_suncc_cstd_abi 865114210e8eSmrg 865214210e8eSmrg if test no != "$suncc_use_cstd_abi"; then 865314210e8eSmrg func_append postdeps ' -library=Cstd -library=Crun' 865414210e8eSmrg fi 865514210e8eSmrg ;; 865614210e8eSmrg esac 865714210e8eSmrg ;; 865814210e8eSmrg esac 865914210e8eSmrg } 866014210e8eSmrg 86611fb744b4Smrg # Last step: remove runtime libs from dependency_libs 86621fb744b4Smrg # (they stay in deplibs) 86631fb744b4Smrg tmp_libs= 866414210e8eSmrg for i in $dependency_libs; do 86651fb744b4Smrg case " $predeps $postdeps $compiler_lib_search_path " in 86661fb744b4Smrg *" $i "*) 866714210e8eSmrg i= 86681fb744b4Smrg ;; 86691fb744b4Smrg esac 867014210e8eSmrg if test -n "$i"; then 86711fb744b4Smrg func_append tmp_libs " $i" 86721fb744b4Smrg fi 86731fb744b4Smrg done 86741fb744b4Smrg dependency_libs=$tmp_libs 86751fb744b4Smrg done # for pass 867614210e8eSmrg if test prog = "$linkmode"; then 867714210e8eSmrg dlfiles=$newdlfiles 86781fb744b4Smrg fi 867914210e8eSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868014210e8eSmrg dlprefiles=$newdlprefiles 86811fb744b4Smrg fi 86821fb744b4Smrg 86831fb744b4Smrg case $linkmode in 86841fb744b4Smrg oldlib) 868514210e8eSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 868614210e8eSmrg func_warning "'-dlopen' is ignored for archives" 86871fb744b4Smrg fi 86881fb744b4Smrg 86891fb744b4Smrg case " $deplibs" in 86901fb744b4Smrg *\ -l* | *\ -L*) 869114210e8eSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 86921fb744b4Smrg esac 86931fb744b4Smrg 86941fb744b4Smrg test -n "$rpath" && \ 869514210e8eSmrg func_warning "'-rpath' is ignored for archives" 86961fb744b4Smrg 86971fb744b4Smrg test -n "$xrpath" && \ 869814210e8eSmrg func_warning "'-R' is ignored for archives" 86991fb744b4Smrg 87001fb744b4Smrg test -n "$vinfo" && \ 870114210e8eSmrg func_warning "'-version-info/-version-number' is ignored for archives" 87021fb744b4Smrg 87031fb744b4Smrg test -n "$release" && \ 870414210e8eSmrg func_warning "'-release' is ignored for archives" 87051fb744b4Smrg 87061fb744b4Smrg test -n "$export_symbols$export_symbols_regex" && \ 870714210e8eSmrg func_warning "'-export-symbols' is ignored for archives" 87081fb744b4Smrg 87091fb744b4Smrg # Now set the variables for building old libraries. 87101fb744b4Smrg build_libtool_libs=no 871114210e8eSmrg oldlibs=$output 87121fb744b4Smrg func_append objs "$old_deplibs" 87131fb744b4Smrg ;; 87141fb744b4Smrg 87151fb744b4Smrg lib) 871614210e8eSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 87171fb744b4Smrg case $outputname in 87181fb744b4Smrg lib*) 87191fb744b4Smrg func_stripname 'lib' '.la' "$outputname" 87201fb744b4Smrg name=$func_stripname_result 87211fb744b4Smrg eval shared_ext=\"$shrext_cmds\" 87221fb744b4Smrg eval libname=\"$libname_spec\" 87231fb744b4Smrg ;; 87241fb744b4Smrg *) 872514210e8eSmrg test no = "$module" \ 872614210e8eSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 87271fb744b4Smrg 872814210e8eSmrg if test no != "$need_lib_prefix"; then 87291fb744b4Smrg # Add the "lib" prefix for modules if required 87301fb744b4Smrg func_stripname '' '.la' "$outputname" 87311fb744b4Smrg name=$func_stripname_result 87321fb744b4Smrg eval shared_ext=\"$shrext_cmds\" 87331fb744b4Smrg eval libname=\"$libname_spec\" 87341fb744b4Smrg else 87351fb744b4Smrg func_stripname '' '.la' "$outputname" 87361fb744b4Smrg libname=$func_stripname_result 87371fb744b4Smrg fi 87381fb744b4Smrg ;; 87391fb744b4Smrg esac 87401fb744b4Smrg 87411fb744b4Smrg if test -n "$objs"; then 874214210e8eSmrg if test pass_all != "$deplibs_check_method"; then 874314210e8eSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 87441fb744b4Smrg else 87451fb744b4Smrg echo 87461fb744b4Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 87471fb744b4Smrg $ECHO "*** objects $objs is not portable!" 87481fb744b4Smrg func_append libobjs " $objs" 87491fb744b4Smrg fi 87501fb744b4Smrg fi 87511fb744b4Smrg 875214210e8eSmrg test no = "$dlself" \ 875314210e8eSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 87541fb744b4Smrg 87551fb744b4Smrg set dummy $rpath 87561fb744b4Smrg shift 875714210e8eSmrg test 1 -lt "$#" \ 875814210e8eSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 87591fb744b4Smrg 876014210e8eSmrg install_libdir=$1 87611fb744b4Smrg 87621fb744b4Smrg oldlibs= 87631fb744b4Smrg if test -z "$rpath"; then 876414210e8eSmrg if test yes = "$build_libtool_libs"; then 87651fb744b4Smrg # Building a libtool convenience library. 876614210e8eSmrg # Some compilers have problems with a '.al' extension so 87671fb744b4Smrg # convenience libraries should have the same extension an 87681fb744b4Smrg # archive normally would. 87691fb744b4Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 87701fb744b4Smrg build_libtool_libs=convenience 87711fb744b4Smrg build_old_libs=yes 87721fb744b4Smrg fi 87731fb744b4Smrg 87741fb744b4Smrg test -n "$vinfo" && \ 877514210e8eSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 87761fb744b4Smrg 87771fb744b4Smrg test -n "$release" && \ 877814210e8eSmrg func_warning "'-release' is ignored for convenience libraries" 87791fb744b4Smrg else 87801fb744b4Smrg 87811fb744b4Smrg # Parse the version information argument. 878214210e8eSmrg save_ifs=$IFS; IFS=: 87831fb744b4Smrg set dummy $vinfo 0 0 0 87841fb744b4Smrg shift 878514210e8eSmrg IFS=$save_ifs 87861fb744b4Smrg 87871fb744b4Smrg test -n "$7" && \ 878814210e8eSmrg func_fatal_help "too many parameters to '-version-info'" 87891fb744b4Smrg 87901fb744b4Smrg # convert absolute version numbers to libtool ages 87911fb744b4Smrg # this retains compatibility with .la files and attempts 87921fb744b4Smrg # to make the code below a bit more comprehensible 87931fb744b4Smrg 87941fb744b4Smrg case $vinfo_number in 87951fb744b4Smrg yes) 879614210e8eSmrg number_major=$1 879714210e8eSmrg number_minor=$2 879814210e8eSmrg number_revision=$3 87991fb744b4Smrg # 88001fb744b4Smrg # There are really only two kinds -- those that 88011fb744b4Smrg # use the current revision as the major version 88021fb744b4Smrg # and those that subtract age and use age as 88031fb744b4Smrg # a minor version. But, then there is irix 880414210e8eSmrg # that has an extra 1 added just for fun 88051fb744b4Smrg # 88061fb744b4Smrg case $version_type in 88071fb744b4Smrg # correct linux to gnu/linux during the next big refactor 880814210e8eSmrg darwin|freebsd-elf|linux|osf|windows|none) 88091fb744b4Smrg func_arith $number_major + $number_minor 88101fb744b4Smrg current=$func_arith_result 881114210e8eSmrg age=$number_minor 881214210e8eSmrg revision=$number_revision 88131fb744b4Smrg ;; 881414210e8eSmrg freebsd-aout|qnx|sunos) 881514210e8eSmrg current=$number_major 881614210e8eSmrg revision=$number_minor 881714210e8eSmrg age=0 88181fb744b4Smrg ;; 88191fb744b4Smrg irix|nonstopux) 88201fb744b4Smrg func_arith $number_major + $number_minor 88211fb744b4Smrg current=$func_arith_result 882214210e8eSmrg age=$number_minor 882314210e8eSmrg revision=$number_minor 88241fb744b4Smrg lt_irix_increment=no 88251fb744b4Smrg ;; 88261fb744b4Smrg esac 88271fb744b4Smrg ;; 88281fb744b4Smrg no) 882914210e8eSmrg current=$1 883014210e8eSmrg revision=$2 883114210e8eSmrg age=$3 88321fb744b4Smrg ;; 88331fb744b4Smrg esac 88341fb744b4Smrg 88351fb744b4Smrg # Check that each of the things are valid numbers. 88361fb744b4Smrg case $current in 88371fb744b4Smrg 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]) ;; 88381fb744b4Smrg *) 883914210e8eSmrg func_error "CURRENT '$current' must be a nonnegative integer" 884014210e8eSmrg func_fatal_error "'$vinfo' is not valid version information" 88411fb744b4Smrg ;; 88421fb744b4Smrg esac 88431fb744b4Smrg 88441fb744b4Smrg case $revision in 88451fb744b4Smrg 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]) ;; 88461fb744b4Smrg *) 884714210e8eSmrg func_error "REVISION '$revision' must be a nonnegative integer" 884814210e8eSmrg func_fatal_error "'$vinfo' is not valid version information" 88491fb744b4Smrg ;; 88501fb744b4Smrg esac 88511fb744b4Smrg 88521fb744b4Smrg case $age in 88531fb744b4Smrg 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]) ;; 88541fb744b4Smrg *) 885514210e8eSmrg func_error "AGE '$age' must be a nonnegative integer" 885614210e8eSmrg func_fatal_error "'$vinfo' is not valid version information" 88571fb744b4Smrg ;; 88581fb744b4Smrg esac 88591fb744b4Smrg 88601fb744b4Smrg if test "$age" -gt "$current"; then 886114210e8eSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 886214210e8eSmrg func_fatal_error "'$vinfo' is not valid version information" 88631fb744b4Smrg fi 88641fb744b4Smrg 88651fb744b4Smrg # Calculate the version variables. 88661fb744b4Smrg major= 88671fb744b4Smrg versuffix= 88681fb744b4Smrg verstring= 88691fb744b4Smrg case $version_type in 88701fb744b4Smrg none) ;; 88711fb744b4Smrg 88721fb744b4Smrg darwin) 88731fb744b4Smrg # Like Linux, but with the current version available in 88741fb744b4Smrg # verstring for coding it into the library header 88751fb744b4Smrg func_arith $current - $age 88761fb744b4Smrg major=.$func_arith_result 887714210e8eSmrg versuffix=$major.$age.$revision 88781fb744b4Smrg # Darwin ld doesn't like 0 for these options... 88791fb744b4Smrg func_arith $current + 1 88801fb744b4Smrg minor_current=$func_arith_result 888114210e8eSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88821fb744b4Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 888314210e8eSmrg # On Darwin other compilers 888414210e8eSmrg case $CC in 888514210e8eSmrg nagfor*) 888614210e8eSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888714210e8eSmrg ;; 888814210e8eSmrg *) 888914210e8eSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889014210e8eSmrg ;; 889114210e8eSmrg esac 88921fb744b4Smrg ;; 88931fb744b4Smrg 88941fb744b4Smrg freebsd-aout) 889514210e8eSmrg major=.$current 889614210e8eSmrg versuffix=.$current.$revision 88971fb744b4Smrg ;; 88981fb744b4Smrg 88991fb744b4Smrg freebsd-elf) 890014210e8eSmrg func_arith $current - $age 890114210e8eSmrg major=.$func_arith_result 890214210e8eSmrg versuffix=$major.$age.$revision 89031fb744b4Smrg ;; 89041fb744b4Smrg 89051fb744b4Smrg irix | nonstopux) 890614210e8eSmrg if test no = "$lt_irix_increment"; then 89071fb744b4Smrg func_arith $current - $age 89081fb744b4Smrg else 89091fb744b4Smrg func_arith $current - $age + 1 89101fb744b4Smrg fi 89111fb744b4Smrg major=$func_arith_result 89121fb744b4Smrg 89131fb744b4Smrg case $version_type in 89141fb744b4Smrg nonstopux) verstring_prefix=nonstopux ;; 89151fb744b4Smrg *) verstring_prefix=sgi ;; 89161fb744b4Smrg esac 891714210e8eSmrg verstring=$verstring_prefix$major.$revision 89181fb744b4Smrg 89191fb744b4Smrg # Add in all the interfaces that we are compatible with. 89201fb744b4Smrg loop=$revision 892114210e8eSmrg while test 0 -ne "$loop"; do 89221fb744b4Smrg func_arith $revision - $loop 89231fb744b4Smrg iface=$func_arith_result 89241fb744b4Smrg func_arith $loop - 1 89251fb744b4Smrg loop=$func_arith_result 892614210e8eSmrg verstring=$verstring_prefix$major.$iface:$verstring 89271fb744b4Smrg done 89281fb744b4Smrg 892914210e8eSmrg # Before this point, $major must not contain '.'. 89301fb744b4Smrg major=.$major 893114210e8eSmrg versuffix=$major.$revision 89321fb744b4Smrg ;; 89331fb744b4Smrg 89341fb744b4Smrg linux) # correct to gnu/linux during the next big refactor 89351fb744b4Smrg func_arith $current - $age 89361fb744b4Smrg major=.$func_arith_result 893714210e8eSmrg versuffix=$major.$age.$revision 89381fb744b4Smrg ;; 89391fb744b4Smrg 89401fb744b4Smrg osf) 89411fb744b4Smrg func_arith $current - $age 89421fb744b4Smrg major=.$func_arith_result 894314210e8eSmrg versuffix=.$current.$age.$revision 894414210e8eSmrg verstring=$current.$age.$revision 89451fb744b4Smrg 89461fb744b4Smrg # Add in all the interfaces that we are compatible with. 89471fb744b4Smrg loop=$age 894814210e8eSmrg while test 0 -ne "$loop"; do 89491fb744b4Smrg func_arith $current - $loop 89501fb744b4Smrg iface=$func_arith_result 89511fb744b4Smrg func_arith $loop - 1 89521fb744b4Smrg loop=$func_arith_result 895314210e8eSmrg verstring=$verstring:$iface.0 89541fb744b4Smrg done 89551fb744b4Smrg 89561fb744b4Smrg # Make executables depend on our current version. 895714210e8eSmrg func_append verstring ":$current.0" 89581fb744b4Smrg ;; 89591fb744b4Smrg 89601fb744b4Smrg qnx) 896114210e8eSmrg major=.$current 896214210e8eSmrg versuffix=.$current 896314210e8eSmrg ;; 896414210e8eSmrg 896514210e8eSmrg sco) 896614210e8eSmrg major=.$current 896714210e8eSmrg versuffix=.$current 89681fb744b4Smrg ;; 89691fb744b4Smrg 89701fb744b4Smrg sunos) 897114210e8eSmrg major=.$current 897214210e8eSmrg versuffix=.$current.$revision 89731fb744b4Smrg ;; 89741fb744b4Smrg 89751fb744b4Smrg windows) 89761fb744b4Smrg # Use '-' rather than '.', since we only want one 897714210e8eSmrg # extension on DOS 8.3 file systems. 89781fb744b4Smrg func_arith $current - $age 89791fb744b4Smrg major=$func_arith_result 898014210e8eSmrg versuffix=-$major 89811fb744b4Smrg ;; 89821fb744b4Smrg 89831fb744b4Smrg *) 898414210e8eSmrg func_fatal_configuration "unknown library version type '$version_type'" 89851fb744b4Smrg ;; 89861fb744b4Smrg esac 89871fb744b4Smrg 89881fb744b4Smrg # Clear the version info if we defaulted, and they specified a release. 89891fb744b4Smrg if test -z "$vinfo" && test -n "$release"; then 89901fb744b4Smrg major= 89911fb744b4Smrg case $version_type in 89921fb744b4Smrg darwin) 89931fb744b4Smrg # we can't check for "0.0" in archive_cmds due to quoting 89941fb744b4Smrg # problems, so we reset it completely 89951fb744b4Smrg verstring= 89961fb744b4Smrg ;; 89971fb744b4Smrg *) 899814210e8eSmrg verstring=0.0 89991fb744b4Smrg ;; 90001fb744b4Smrg esac 900114210e8eSmrg if test no = "$need_version"; then 90021fb744b4Smrg versuffix= 90031fb744b4Smrg else 900414210e8eSmrg versuffix=.0.0 90051fb744b4Smrg fi 90061fb744b4Smrg fi 90071fb744b4Smrg 90081fb744b4Smrg # Remove version info from name if versioning should be avoided 900914210e8eSmrg if test yes,no = "$avoid_version,$need_version"; then 90101fb744b4Smrg major= 90111fb744b4Smrg versuffix= 901214210e8eSmrg verstring= 90131fb744b4Smrg fi 90141fb744b4Smrg 90151fb744b4Smrg # Check to see if the archive will have undefined symbols. 901614210e8eSmrg if test yes = "$allow_undefined"; then 901714210e8eSmrg if test unsupported = "$allow_undefined_flag"; then 901814210e8eSmrg if test yes = "$build_old_libs"; then 901914210e8eSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902014210e8eSmrg build_libtool_libs=no 902114210e8eSmrg else 902214210e8eSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 902314210e8eSmrg fi 90241fb744b4Smrg fi 90251fb744b4Smrg else 90261fb744b4Smrg # Don't allow undefined symbols. 902714210e8eSmrg allow_undefined_flag=$no_undefined_flag 90281fb744b4Smrg fi 90291fb744b4Smrg 90301fb744b4Smrg fi 90311fb744b4Smrg 903214210e8eSmrg func_generate_dlsyms "$libname" "$libname" : 90331fb744b4Smrg func_append libobjs " $symfileobj" 903414210e8eSmrg test " " = "$libobjs" && libobjs= 90351fb744b4Smrg 903614210e8eSmrg if test relink != "$opt_mode"; then 90371fb744b4Smrg # Remove our outputs, but don't remove object files since they 90381fb744b4Smrg # may have been created when compiling PIC objects. 90391fb744b4Smrg removelist= 90401fb744b4Smrg tempremovelist=`$ECHO "$output_objdir/*"` 90411fb744b4Smrg for p in $tempremovelist; do 90421fb744b4Smrg case $p in 90431fb744b4Smrg *.$objext | *.gcno) 90441fb744b4Smrg ;; 904514210e8eSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 904614210e8eSmrg if test -n "$precious_files_regex"; then 90471fb744b4Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 90481fb744b4Smrg then 90491fb744b4Smrg continue 90501fb744b4Smrg fi 90511fb744b4Smrg fi 90521fb744b4Smrg func_append removelist " $p" 90531fb744b4Smrg ;; 90541fb744b4Smrg *) ;; 90551fb744b4Smrg esac 90561fb744b4Smrg done 90571fb744b4Smrg test -n "$removelist" && \ 90581fb744b4Smrg func_show_eval "${RM}r \$removelist" 90591fb744b4Smrg fi 90601fb744b4Smrg 90611fb744b4Smrg # Now set the variables for building old libraries. 906214210e8eSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 90631fb744b4Smrg func_append oldlibs " $output_objdir/$libname.$libext" 90641fb744b4Smrg 90651fb744b4Smrg # Transform .lo files to .o files. 906614210e8eSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 90671fb744b4Smrg fi 90681fb744b4Smrg 90691fb744b4Smrg # Eliminate all temporary directories. 90701fb744b4Smrg #for path in $notinst_path; do 90711fb744b4Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 90721fb744b4Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 90731fb744b4Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 90741fb744b4Smrg #done 90751fb744b4Smrg 90761fb744b4Smrg if test -n "$xrpath"; then 90771fb744b4Smrg # If the user specified any rpath flags, then add them. 90781fb744b4Smrg temp_xrpath= 90791fb744b4Smrg for libdir in $xrpath; do 90801fb744b4Smrg func_replace_sysroot "$libdir" 90811fb744b4Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 90821fb744b4Smrg case "$finalize_rpath " in 90831fb744b4Smrg *" $libdir "*) ;; 90841fb744b4Smrg *) func_append finalize_rpath " $libdir" ;; 90851fb744b4Smrg esac 90861fb744b4Smrg done 908714210e8eSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 90881fb744b4Smrg dependency_libs="$temp_xrpath $dependency_libs" 90891fb744b4Smrg fi 90901fb744b4Smrg fi 90911fb744b4Smrg 90921fb744b4Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 909314210e8eSmrg old_dlfiles=$dlfiles 90941fb744b4Smrg dlfiles= 90951fb744b4Smrg for lib in $old_dlfiles; do 90961fb744b4Smrg case " $dlprefiles $dlfiles " in 90971fb744b4Smrg *" $lib "*) ;; 90981fb744b4Smrg *) func_append dlfiles " $lib" ;; 90991fb744b4Smrg esac 91001fb744b4Smrg done 91011fb744b4Smrg 91021fb744b4Smrg # Make sure dlprefiles contains only unique files 910314210e8eSmrg old_dlprefiles=$dlprefiles 91041fb744b4Smrg dlprefiles= 91051fb744b4Smrg for lib in $old_dlprefiles; do 91061fb744b4Smrg case "$dlprefiles " in 91071fb744b4Smrg *" $lib "*) ;; 91081fb744b4Smrg *) func_append dlprefiles " $lib" ;; 91091fb744b4Smrg esac 91101fb744b4Smrg done 91111fb744b4Smrg 911214210e8eSmrg if test yes = "$build_libtool_libs"; then 91131fb744b4Smrg if test -n "$rpath"; then 91141fb744b4Smrg case $host in 91151fb744b4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 91161fb744b4Smrg # these systems don't actually have a c library (as such)! 91171fb744b4Smrg ;; 91181fb744b4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 91191fb744b4Smrg # Rhapsody C library is in the System framework 91201fb744b4Smrg func_append deplibs " System.ltframework" 91211fb744b4Smrg ;; 91221fb744b4Smrg *-*-netbsd*) 91231fb744b4Smrg # Don't link with libc until the a.out ld.so is fixed. 91241fb744b4Smrg ;; 91251fb744b4Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 91261fb744b4Smrg # Do not include libc due to us having libc/libc_r. 91271fb744b4Smrg ;; 91281fb744b4Smrg *-*-sco3.2v5* | *-*-sco5v6*) 91291fb744b4Smrg # Causes problems with __ctype 91301fb744b4Smrg ;; 91311fb744b4Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 91321fb744b4Smrg # Compiler inserts libc in the correct place for threads to work 91331fb744b4Smrg ;; 91341fb744b4Smrg *) 91351fb744b4Smrg # Add libc to deplibs on all other systems if necessary. 913614210e8eSmrg if test yes = "$build_libtool_need_lc"; then 91371fb744b4Smrg func_append deplibs " -lc" 91381fb744b4Smrg fi 91391fb744b4Smrg ;; 91401fb744b4Smrg esac 91411fb744b4Smrg fi 91421fb744b4Smrg 91431fb744b4Smrg # Transform deplibs into only deplibs that can be linked in shared. 91441fb744b4Smrg name_save=$name 91451fb744b4Smrg libname_save=$libname 91461fb744b4Smrg release_save=$release 91471fb744b4Smrg versuffix_save=$versuffix 91481fb744b4Smrg major_save=$major 91491fb744b4Smrg # I'm not sure if I'm treating the release correctly. I think 91501fb744b4Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 91511fb744b4Smrg # add it in twice. Is that correct? 915214210e8eSmrg release= 915314210e8eSmrg versuffix= 915414210e8eSmrg major= 91551fb744b4Smrg newdeplibs= 91561fb744b4Smrg droppeddeps=no 91571fb744b4Smrg case $deplibs_check_method in 91581fb744b4Smrg pass_all) 91591fb744b4Smrg # Don't check for shared/static. Everything works. 91601fb744b4Smrg # This might be a little naive. We might want to check 91611fb744b4Smrg # whether the library exists or not. But this is on 91621fb744b4Smrg # osf3 & osf4 and I'm not really sure... Just 91631fb744b4Smrg # implementing what was already the behavior. 91641fb744b4Smrg newdeplibs=$deplibs 91651fb744b4Smrg ;; 91661fb744b4Smrg test_compile) 91671fb744b4Smrg # This code stresses the "libraries are programs" paradigm to its 91681fb744b4Smrg # limits. Maybe even breaks it. We compile a program, linking it 91691fb744b4Smrg # against the deplibs as a proxy for the library. Then we can check 91701fb744b4Smrg # whether they linked in statically or dynamically with ldd. 91711fb744b4Smrg $opt_dry_run || $RM conftest.c 91721fb744b4Smrg cat > conftest.c <<EOF 91731fb744b4Smrg int main() { return 0; } 91741fb744b4SmrgEOF 91751fb744b4Smrg $opt_dry_run || $RM conftest 91761fb744b4Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 91771fb744b4Smrg ldd_output=`ldd conftest` 91781fb744b4Smrg for i in $deplibs; do 91791fb744b4Smrg case $i in 91801fb744b4Smrg -l*) 91811fb744b4Smrg func_stripname -l '' "$i" 91821fb744b4Smrg name=$func_stripname_result 918314210e8eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 91841fb744b4Smrg case " $predeps $postdeps " in 91851fb744b4Smrg *" $i "*) 91861fb744b4Smrg func_append newdeplibs " $i" 918714210e8eSmrg i= 91881fb744b4Smrg ;; 91891fb744b4Smrg esac 91901fb744b4Smrg fi 919114210e8eSmrg if test -n "$i"; then 91921fb744b4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 91931fb744b4Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 91941fb744b4Smrg set dummy $deplib_matches; shift 91951fb744b4Smrg deplib_match=$1 919614210e8eSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 91971fb744b4Smrg func_append newdeplibs " $i" 91981fb744b4Smrg else 91991fb744b4Smrg droppeddeps=yes 92001fb744b4Smrg echo 92011fb744b4Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92021fb744b4Smrg echo "*** I have the capability to make that library automatically link in when" 92031fb744b4Smrg echo "*** you link to this library. But I can only do this if you have a" 92041fb744b4Smrg echo "*** shared version of the library, which I believe you do not have" 92051fb744b4Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 92061fb744b4Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 92071fb744b4Smrg fi 92081fb744b4Smrg fi 92091fb744b4Smrg ;; 92101fb744b4Smrg *) 92111fb744b4Smrg func_append newdeplibs " $i" 92121fb744b4Smrg ;; 92131fb744b4Smrg esac 92141fb744b4Smrg done 92151fb744b4Smrg else 92161fb744b4Smrg # Error occurred in the first compile. Let's try to salvage 92171fb744b4Smrg # the situation: Compile a separate program for each library. 92181fb744b4Smrg for i in $deplibs; do 92191fb744b4Smrg case $i in 92201fb744b4Smrg -l*) 92211fb744b4Smrg func_stripname -l '' "$i" 92221fb744b4Smrg name=$func_stripname_result 92231fb744b4Smrg $opt_dry_run || $RM conftest 92241fb744b4Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 92251fb744b4Smrg ldd_output=`ldd conftest` 922614210e8eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92271fb744b4Smrg case " $predeps $postdeps " in 92281fb744b4Smrg *" $i "*) 92291fb744b4Smrg func_append newdeplibs " $i" 923014210e8eSmrg i= 92311fb744b4Smrg ;; 92321fb744b4Smrg esac 92331fb744b4Smrg fi 923414210e8eSmrg if test -n "$i"; then 92351fb744b4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 92361fb744b4Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92371fb744b4Smrg set dummy $deplib_matches; shift 92381fb744b4Smrg deplib_match=$1 923914210e8eSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 92401fb744b4Smrg func_append newdeplibs " $i" 92411fb744b4Smrg else 92421fb744b4Smrg droppeddeps=yes 92431fb744b4Smrg echo 92441fb744b4Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92451fb744b4Smrg echo "*** I have the capability to make that library automatically link in when" 92461fb744b4Smrg echo "*** you link to this library. But I can only do this if you have a" 92471fb744b4Smrg echo "*** shared version of the library, which you do not appear to have" 92481fb744b4Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 92491fb744b4Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 92501fb744b4Smrg fi 92511fb744b4Smrg fi 92521fb744b4Smrg else 92531fb744b4Smrg droppeddeps=yes 92541fb744b4Smrg echo 92551fb744b4Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 92561fb744b4Smrg echo "*** make it link in! You will probably need to install it or some" 92571fb744b4Smrg echo "*** library that it depends on before this library will be fully" 92581fb744b4Smrg echo "*** functional. Installing it before continuing would be even better." 92591fb744b4Smrg fi 92601fb744b4Smrg ;; 92611fb744b4Smrg *) 92621fb744b4Smrg func_append newdeplibs " $i" 92631fb744b4Smrg ;; 92641fb744b4Smrg esac 92651fb744b4Smrg done 92661fb744b4Smrg fi 92671fb744b4Smrg ;; 92681fb744b4Smrg file_magic*) 92691fb744b4Smrg set dummy $deplibs_check_method; shift 92701fb744b4Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 92711fb744b4Smrg for a_deplib in $deplibs; do 92721fb744b4Smrg case $a_deplib in 92731fb744b4Smrg -l*) 92741fb744b4Smrg func_stripname -l '' "$a_deplib" 92751fb744b4Smrg name=$func_stripname_result 927614210e8eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92771fb744b4Smrg case " $predeps $postdeps " in 92781fb744b4Smrg *" $a_deplib "*) 92791fb744b4Smrg func_append newdeplibs " $a_deplib" 928014210e8eSmrg a_deplib= 92811fb744b4Smrg ;; 92821fb744b4Smrg esac 92831fb744b4Smrg fi 928414210e8eSmrg if test -n "$a_deplib"; then 92851fb744b4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 92861fb744b4Smrg if test -n "$file_magic_glob"; then 92871fb744b4Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 92881fb744b4Smrg else 92891fb744b4Smrg libnameglob=$libname 92901fb744b4Smrg fi 929114210e8eSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 92921fb744b4Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 929314210e8eSmrg if test yes = "$want_nocaseglob"; then 92941fb744b4Smrg shopt -s nocaseglob 92951fb744b4Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 92961fb744b4Smrg $nocaseglob 92971fb744b4Smrg else 92981fb744b4Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 92991fb744b4Smrg fi 93001fb744b4Smrg for potent_lib in $potential_libs; do 93011fb744b4Smrg # Follow soft links. 93021fb744b4Smrg if ls -lLd "$potent_lib" 2>/dev/null | 93031fb744b4Smrg $GREP " -> " >/dev/null; then 93041fb744b4Smrg continue 93051fb744b4Smrg fi 93061fb744b4Smrg # The statement above tries to avoid entering an 93071fb744b4Smrg # endless loop below, in case of cyclic links. 93081fb744b4Smrg # We might still enter an endless loop, since a link 93091fb744b4Smrg # loop can be closed while we follow links, 93101fb744b4Smrg # but so what? 931114210e8eSmrg potlib=$potent_lib 93121fb744b4Smrg while test -h "$potlib" 2>/dev/null; do 931314210e8eSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 93141fb744b4Smrg case $potliblink in 931514210e8eSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 931614210e8eSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 93171fb744b4Smrg esac 93181fb744b4Smrg done 93191fb744b4Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 93201fb744b4Smrg $SED -e 10q | 93211fb744b4Smrg $EGREP "$file_magic_regex" > /dev/null; then 93221fb744b4Smrg func_append newdeplibs " $a_deplib" 932314210e8eSmrg a_deplib= 93241fb744b4Smrg break 2 93251fb744b4Smrg fi 93261fb744b4Smrg done 93271fb744b4Smrg done 93281fb744b4Smrg fi 932914210e8eSmrg if test -n "$a_deplib"; then 93301fb744b4Smrg droppeddeps=yes 93311fb744b4Smrg echo 93321fb744b4Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93331fb744b4Smrg echo "*** I have the capability to make that library automatically link in when" 93341fb744b4Smrg echo "*** you link to this library. But I can only do this if you have a" 93351fb744b4Smrg echo "*** shared version of the library, which you do not appear to have" 93361fb744b4Smrg echo "*** because I did check the linker path looking for a file starting" 933714210e8eSmrg if test -z "$potlib"; then 93381fb744b4Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 93391fb744b4Smrg else 93401fb744b4Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93411fb744b4Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 93421fb744b4Smrg fi 93431fb744b4Smrg fi 93441fb744b4Smrg ;; 93451fb744b4Smrg *) 93461fb744b4Smrg # Add a -L argument. 93471fb744b4Smrg func_append newdeplibs " $a_deplib" 93481fb744b4Smrg ;; 93491fb744b4Smrg esac 93501fb744b4Smrg done # Gone through all deplibs. 93511fb744b4Smrg ;; 93521fb744b4Smrg match_pattern*) 93531fb744b4Smrg set dummy $deplibs_check_method; shift 93541fb744b4Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 93551fb744b4Smrg for a_deplib in $deplibs; do 93561fb744b4Smrg case $a_deplib in 93571fb744b4Smrg -l*) 93581fb744b4Smrg func_stripname -l '' "$a_deplib" 93591fb744b4Smrg name=$func_stripname_result 936014210e8eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 93611fb744b4Smrg case " $predeps $postdeps " in 93621fb744b4Smrg *" $a_deplib "*) 93631fb744b4Smrg func_append newdeplibs " $a_deplib" 936414210e8eSmrg a_deplib= 93651fb744b4Smrg ;; 93661fb744b4Smrg esac 93671fb744b4Smrg fi 936814210e8eSmrg if test -n "$a_deplib"; then 93691fb744b4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 93701fb744b4Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93711fb744b4Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 93721fb744b4Smrg for potent_lib in $potential_libs; do 937314210e8eSmrg potlib=$potent_lib # see symlink-check above in file_magic test 93741fb744b4Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 93751fb744b4Smrg $EGREP "$match_pattern_regex" > /dev/null; then 93761fb744b4Smrg func_append newdeplibs " $a_deplib" 937714210e8eSmrg a_deplib= 93781fb744b4Smrg break 2 93791fb744b4Smrg fi 93801fb744b4Smrg done 93811fb744b4Smrg done 93821fb744b4Smrg fi 938314210e8eSmrg if test -n "$a_deplib"; then 93841fb744b4Smrg droppeddeps=yes 93851fb744b4Smrg echo 93861fb744b4Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93871fb744b4Smrg echo "*** I have the capability to make that library automatically link in when" 93881fb744b4Smrg echo "*** you link to this library. But I can only do this if you have a" 93891fb744b4Smrg echo "*** shared version of the library, which you do not appear to have" 93901fb744b4Smrg echo "*** because I did check the linker path looking for a file starting" 939114210e8eSmrg if test -z "$potlib"; then 93921fb744b4Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 93931fb744b4Smrg else 93941fb744b4Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93951fb744b4Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 93961fb744b4Smrg fi 93971fb744b4Smrg fi 93981fb744b4Smrg ;; 93991fb744b4Smrg *) 94001fb744b4Smrg # Add a -L argument. 94011fb744b4Smrg func_append newdeplibs " $a_deplib" 94021fb744b4Smrg ;; 94031fb744b4Smrg esac 94041fb744b4Smrg done # Gone through all deplibs. 94051fb744b4Smrg ;; 94061fb744b4Smrg none | unknown | *) 940714210e8eSmrg newdeplibs= 94081fb744b4Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 940914210e8eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941014210e8eSmrg for i in $predeps $postdeps; do 94111fb744b4Smrg # can't use Xsed below, because $i might contain '/' 941214210e8eSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 94131fb744b4Smrg done 94141fb744b4Smrg fi 94151fb744b4Smrg case $tmp_deplibs in 94161fb744b4Smrg *[!\ \ ]*) 94171fb744b4Smrg echo 941814210e8eSmrg if test none = "$deplibs_check_method"; then 94191fb744b4Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 94201fb744b4Smrg else 94211fb744b4Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 94221fb744b4Smrg fi 94231fb744b4Smrg echo "*** All declared inter-library dependencies are being dropped." 94241fb744b4Smrg droppeddeps=yes 94251fb744b4Smrg ;; 94261fb744b4Smrg esac 94271fb744b4Smrg ;; 94281fb744b4Smrg esac 94291fb744b4Smrg versuffix=$versuffix_save 94301fb744b4Smrg major=$major_save 94311fb744b4Smrg release=$release_save 94321fb744b4Smrg libname=$libname_save 94331fb744b4Smrg name=$name_save 9434c35d236eSmrg 94351fb744b4Smrg case $host in 94361fb744b4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 94371fb744b4Smrg # On Rhapsody replace the C library with the System framework 94381fb744b4Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 94391fb744b4Smrg ;; 94401fb744b4Smrg esac 9441f55e6a01Smrg 944214210e8eSmrg if test yes = "$droppeddeps"; then 944314210e8eSmrg if test yes = "$module"; then 94441fb744b4Smrg echo 94451fb744b4Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 94461fb744b4Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 94471fb744b4Smrg echo "*** a static module, that should work as long as the dlopening" 94481fb744b4Smrg echo "*** application is linked with the -dlopen flag." 94491fb744b4Smrg if test -z "$global_symbol_pipe"; then 94501fb744b4Smrg echo 94511fb744b4Smrg echo "*** However, this would only work if libtool was able to extract symbol" 945214210e8eSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 94531fb744b4Smrg echo "*** not find such a program. So, this module is probably useless." 945414210e8eSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 94551fb744b4Smrg fi 945614210e8eSmrg if test no = "$build_old_libs"; then 945714210e8eSmrg oldlibs=$output_objdir/$libname.$libext 94581fb744b4Smrg build_libtool_libs=module 94591fb744b4Smrg build_old_libs=yes 94601fb744b4Smrg else 94611fb744b4Smrg build_libtool_libs=no 94621fb744b4Smrg fi 94631fb744b4Smrg else 94641fb744b4Smrg echo "*** The inter-library dependencies that have been dropped here will be" 94651fb744b4Smrg echo "*** automatically added whenever a program is linked with this library" 94661fb744b4Smrg echo "*** or is declared to -dlopen it." 9467f55e6a01Smrg 946814210e8eSmrg if test no = "$allow_undefined"; then 94691fb744b4Smrg echo 94701fb744b4Smrg echo "*** Since this library must not contain undefined symbols," 94711fb744b4Smrg echo "*** because either the platform does not support them or" 94721fb744b4Smrg echo "*** it was explicitly requested with -no-undefined," 94731fb744b4Smrg echo "*** libtool will only create a static version of it." 947414210e8eSmrg if test no = "$build_old_libs"; then 947514210e8eSmrg oldlibs=$output_objdir/$libname.$libext 94761fb744b4Smrg build_libtool_libs=module 94771fb744b4Smrg build_old_libs=yes 94781fb744b4Smrg else 94791fb744b4Smrg build_libtool_libs=no 94801fb744b4Smrg fi 94811fb744b4Smrg fi 94821fb744b4Smrg fi 9483c35d236eSmrg fi 94841fb744b4Smrg # Done checking deplibs! 94851fb744b4Smrg deplibs=$newdeplibs 94861fb744b4Smrg fi 94871fb744b4Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 94881fb744b4Smrg case $host in 94891fb744b4Smrg *-*-darwin*) 94901fb744b4Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94911fb744b4Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94921fb744b4Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94931fb744b4Smrg ;; 94941fb744b4Smrg esac 9495c35d236eSmrg 94961fb744b4Smrg # move library search paths that coincide with paths to not yet 94971fb744b4Smrg # installed libraries to the beginning of the library search list 94981fb744b4Smrg new_libs= 94991fb744b4Smrg for path in $notinst_path; do 95001fb744b4Smrg case " $new_libs " in 95011fb744b4Smrg *" -L$path/$objdir "*) ;; 95021fb744b4Smrg *) 95031fb744b4Smrg case " $deplibs " in 95041fb744b4Smrg *" -L$path/$objdir "*) 95051fb744b4Smrg func_append new_libs " -L$path/$objdir" ;; 95061fb744b4Smrg esac 95071fb744b4Smrg ;; 95081fb744b4Smrg esac 95091fb744b4Smrg done 95101fb744b4Smrg for deplib in $deplibs; do 95111fb744b4Smrg case $deplib in 95121fb744b4Smrg -L*) 95131fb744b4Smrg case " $new_libs " in 95141fb744b4Smrg *" $deplib "*) ;; 95151fb744b4Smrg *) func_append new_libs " $deplib" ;; 95161fb744b4Smrg esac 95171fb744b4Smrg ;; 95181fb744b4Smrg *) func_append new_libs " $deplib" ;; 95191fb744b4Smrg esac 95201fb744b4Smrg done 952114210e8eSmrg deplibs=$new_libs 9522c35d236eSmrg 95231fb744b4Smrg # All the library-specific variables (install_libdir is set above). 95241fb744b4Smrg library_names= 95251fb744b4Smrg old_library= 95261fb744b4Smrg dlname= 9527c35d236eSmrg 95281fb744b4Smrg # Test again, we may have decided not to build it any more 952914210e8eSmrg if test yes = "$build_libtool_libs"; then 953014210e8eSmrg # Remove $wl instances when linking with ld. 95311fb744b4Smrg # FIXME: should test the right _cmds variable. 95321fb744b4Smrg case $archive_cmds in 95331fb744b4Smrg *\$LD\ *) wl= ;; 95341fb744b4Smrg esac 953514210e8eSmrg if test yes = "$hardcode_into_libs"; then 95361fb744b4Smrg # Hardcode the library paths 95371fb744b4Smrg hardcode_libdirs= 95381fb744b4Smrg dep_rpath= 953914210e8eSmrg rpath=$finalize_rpath 954014210e8eSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 95411fb744b4Smrg for libdir in $rpath; do 95421fb744b4Smrg if test -n "$hardcode_libdir_flag_spec"; then 95431fb744b4Smrg if test -n "$hardcode_libdir_separator"; then 95441fb744b4Smrg func_replace_sysroot "$libdir" 95451fb744b4Smrg libdir=$func_replace_sysroot_result 95461fb744b4Smrg if test -z "$hardcode_libdirs"; then 954714210e8eSmrg hardcode_libdirs=$libdir 95481fb744b4Smrg else 95491fb744b4Smrg # Just accumulate the unique libdirs. 95501fb744b4Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 95511fb744b4Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 95521fb744b4Smrg ;; 95531fb744b4Smrg *) 95541fb744b4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 95551fb744b4Smrg ;; 95561fb744b4Smrg esac 95571fb744b4Smrg fi 95581fb744b4Smrg else 95591fb744b4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 95601fb744b4Smrg func_append dep_rpath " $flag" 95611fb744b4Smrg fi 95621fb744b4Smrg elif test -n "$runpath_var"; then 95631fb744b4Smrg case "$perm_rpath " in 95641fb744b4Smrg *" $libdir "*) ;; 95651fb744b4Smrg *) func_append perm_rpath " $libdir" ;; 95661fb744b4Smrg esac 95671fb744b4Smrg fi 95681fb744b4Smrg done 95691fb744b4Smrg # Substitute the hardcoded libdirs into the rpath. 95701fb744b4Smrg if test -n "$hardcode_libdir_separator" && 95711fb744b4Smrg test -n "$hardcode_libdirs"; then 957214210e8eSmrg libdir=$hardcode_libdirs 95731fb744b4Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 95741fb744b4Smrg fi 95751fb744b4Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 95761fb744b4Smrg # We should set the runpath_var. 95771fb744b4Smrg rpath= 95781fb744b4Smrg for dir in $perm_rpath; do 95791fb744b4Smrg func_append rpath "$dir:" 95801fb744b4Smrg done 95811fb744b4Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 95821fb744b4Smrg fi 95831fb744b4Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584518bcf38Smrg fi 9585f55e6a01Smrg 958614210e8eSmrg shlibpath=$finalize_shlibpath 958714210e8eSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 95881fb744b4Smrg if test -n "$shlibpath"; then 95891fb744b4Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590518bcf38Smrg fi 9591f55e6a01Smrg 95921fb744b4Smrg # Get the real and link names of the library. 95931fb744b4Smrg eval shared_ext=\"$shrext_cmds\" 95941fb744b4Smrg eval library_names=\"$library_names_spec\" 95951fb744b4Smrg set dummy $library_names 95961fb744b4Smrg shift 959714210e8eSmrg realname=$1 95981fb744b4Smrg shift 9599f55e6a01Smrg 96001fb744b4Smrg if test -n "$soname_spec"; then 96011fb744b4Smrg eval soname=\"$soname_spec\" 9602518bcf38Smrg else 960314210e8eSmrg soname=$realname 96041fb744b4Smrg fi 96051fb744b4Smrg if test -z "$dlname"; then 96061fb744b4Smrg dlname=$soname 9607518bcf38Smrg fi 9608f55e6a01Smrg 960914210e8eSmrg lib=$output_objdir/$realname 96101fb744b4Smrg linknames= 96111fb744b4Smrg for link 96121fb744b4Smrg do 96131fb744b4Smrg func_append linknames " $link" 96141fb744b4Smrg done 9615f55e6a01Smrg 96161fb744b4Smrg # Use standard objects if they are pic 96171fb744b4Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 96181fb744b4Smrg test "X$libobjs" = "X " && libobjs= 9619f55e6a01Smrg 96201fb744b4Smrg delfiles= 96211fb744b4Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 96221fb744b4Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 962314210e8eSmrg export_symbols=$output_objdir/$libname.uexp 96241fb744b4Smrg func_append delfiles " $export_symbols" 96251fb744b4Smrg fi 9626c35d236eSmrg 96271fb744b4Smrg orig_export_symbols= 96281fb744b4Smrg case $host_os in 96291fb744b4Smrg cygwin* | mingw* | cegcc*) 96301fb744b4Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 96311fb744b4Smrg # exporting using user supplied symfile 963214210e8eSmrg func_dll_def_p "$export_symbols" || { 96331fb744b4Smrg # and it's NOT already a .def file. Must figure out 96341fb744b4Smrg # which of the given symbols are data symbols and tag 96351fb744b4Smrg # them as such. So, trigger use of export_symbols_cmds. 96361fb744b4Smrg # export_symbols gets reassigned inside the "prepare 96371fb744b4Smrg # the list of exported symbols" if statement, so the 96381fb744b4Smrg # include_expsyms logic still works. 963914210e8eSmrg orig_export_symbols=$export_symbols 96401fb744b4Smrg export_symbols= 96411fb744b4Smrg always_export_symbols=yes 964214210e8eSmrg } 9643f55e6a01Smrg fi 96441fb744b4Smrg ;; 96451fb744b4Smrg esac 9646c35d236eSmrg 96471fb744b4Smrg # Prepare the list of exported symbols 96481fb744b4Smrg if test -z "$export_symbols"; then 964914210e8eSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965014210e8eSmrg func_verbose "generating symbol list for '$libname.la'" 965114210e8eSmrg export_symbols=$output_objdir/$libname.exp 96521fb744b4Smrg $opt_dry_run || $RM $export_symbols 96531fb744b4Smrg cmds=$export_symbols_cmds 965414210e8eSmrg save_ifs=$IFS; IFS='~' 96551fb744b4Smrg for cmd1 in $cmds; do 965614210e8eSmrg IFS=$save_ifs 96571fb744b4Smrg # Take the normal branch if the nm_file_list_spec branch 96581fb744b4Smrg # doesn't work or if tool conversion is not needed. 96591fb744b4Smrg case $nm_file_list_spec~$to_tool_file_cmd in 96601fb744b4Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 96611fb744b4Smrg try_normal_branch=yes 96621fb744b4Smrg eval cmd=\"$cmd1\" 96631fb744b4Smrg func_len " $cmd" 96641fb744b4Smrg len=$func_len_result 96651fb744b4Smrg ;; 96661fb744b4Smrg *) 96671fb744b4Smrg try_normal_branch=no 96681fb744b4Smrg ;; 96691fb744b4Smrg esac 967014210e8eSmrg if test yes = "$try_normal_branch" \ 96711fb744b4Smrg && { test "$len" -lt "$max_cmd_len" \ 96721fb744b4Smrg || test "$max_cmd_len" -le -1; } 96731fb744b4Smrg then 96741fb744b4Smrg func_show_eval "$cmd" 'exit $?' 96751fb744b4Smrg skipped_export=false 96761fb744b4Smrg elif test -n "$nm_file_list_spec"; then 96771fb744b4Smrg func_basename "$output" 96781fb744b4Smrg output_la=$func_basename_result 96791fb744b4Smrg save_libobjs=$libobjs 96801fb744b4Smrg save_output=$output 968114210e8eSmrg output=$output_objdir/$output_la.nm 96821fb744b4Smrg func_to_tool_file "$output" 96831fb744b4Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 96841fb744b4Smrg func_append delfiles " $output" 96851fb744b4Smrg func_verbose "creating $NM input file list: $output" 96861fb744b4Smrg for obj in $save_libobjs; do 96871fb744b4Smrg func_to_tool_file "$obj" 96881fb744b4Smrg $ECHO "$func_to_tool_file_result" 96891fb744b4Smrg done > "$output" 96901fb744b4Smrg eval cmd=\"$cmd1\" 96911fb744b4Smrg func_show_eval "$cmd" 'exit $?' 96921fb744b4Smrg output=$save_output 96931fb744b4Smrg libobjs=$save_libobjs 96941fb744b4Smrg skipped_export=false 96951fb744b4Smrg else 96961fb744b4Smrg # The command line is too long to execute in one step. 96971fb744b4Smrg func_verbose "using reloadable object file for export list..." 96981fb744b4Smrg skipped_export=: 96991fb744b4Smrg # Break out early, otherwise skipped_export may be 97001fb744b4Smrg # set to false by a later but shorter cmd. 97011fb744b4Smrg break 97021fb744b4Smrg fi 97031fb744b4Smrg done 970414210e8eSmrg IFS=$save_ifs 970514210e8eSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 97061fb744b4Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 97071fb744b4Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 97081fb744b4Smrg fi 97091fb744b4Smrg fi 97101fb744b4Smrg fi 97111fb744b4Smrg 97121fb744b4Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 971314210e8eSmrg tmp_export_symbols=$export_symbols 971414210e8eSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 97151fb744b4Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716518bcf38Smrg fi 9717c35d236eSmrg 971814210e8eSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 97191fb744b4Smrg # The given exports_symbols file has to be filtered, so filter it. 972014210e8eSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 97211fb744b4Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 972214210e8eSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 97231fb744b4Smrg # though. Also, the filter scales superlinearly with the number of 97241fb744b4Smrg # global variables. join(1) would be nice here, but unfortunately 97251fb744b4Smrg # isn't a blessed tool. 97261fb744b4Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 97271fb744b4Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 97281fb744b4Smrg export_symbols=$output_objdir/$libname.def 97291fb744b4Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 97301fb744b4Smrg fi 9731c35d236eSmrg 97321fb744b4Smrg tmp_deplibs= 97331fb744b4Smrg for test_deplib in $deplibs; do 97341fb744b4Smrg case " $convenience " in 97351fb744b4Smrg *" $test_deplib "*) ;; 97361fb744b4Smrg *) 97371fb744b4Smrg func_append tmp_deplibs " $test_deplib" 97381fb744b4Smrg ;; 97391fb744b4Smrg esac 97401fb744b4Smrg done 974114210e8eSmrg deplibs=$tmp_deplibs 9742518bcf38Smrg 97431fb744b4Smrg if test -n "$convenience"; then 97441fb744b4Smrg if test -n "$whole_archive_flag_spec" && 974514210e8eSmrg test yes = "$compiler_needs_object" && 97461fb744b4Smrg test -z "$libobjs"; then 97471fb744b4Smrg # extract the archives, so we have objects to list. 97481fb744b4Smrg # TODO: could optimize this to just extract one archive. 97491fb744b4Smrg whole_archive_flag_spec= 97501fb744b4Smrg fi 97511fb744b4Smrg if test -n "$whole_archive_flag_spec"; then 97521fb744b4Smrg save_libobjs=$libobjs 97531fb744b4Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 97541fb744b4Smrg test "X$libobjs" = "X " && libobjs= 9755f55e6a01Smrg else 975614210e8eSmrg gentop=$output_objdir/${outputname}x 97571fb744b4Smrg func_append generated " $gentop" 97581fb744b4Smrg 97591fb744b4Smrg func_extract_archives $gentop $convenience 97601fb744b4Smrg func_append libobjs " $func_extract_archives_result" 97611fb744b4Smrg test "X$libobjs" = "X " && libobjs= 9762f55e6a01Smrg fi 9763f55e6a01Smrg fi 9764c35d236eSmrg 976514210e8eSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 97661fb744b4Smrg eval flag=\"$thread_safe_flag_spec\" 97671fb744b4Smrg func_append linker_flags " $flag" 97681fb744b4Smrg fi 9769c35d236eSmrg 97701fb744b4Smrg # Make a backup of the uninstalled library when relinking 977114210e8eSmrg if test relink = "$opt_mode"; then 97721fb744b4Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 97731fb744b4Smrg fi 9774f55e6a01Smrg 97751fb744b4Smrg # Do each of the archive commands. 977614210e8eSmrg if test yes = "$module" && test -n "$module_cmds"; then 97771fb744b4Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 97781fb744b4Smrg eval test_cmds=\"$module_expsym_cmds\" 97791fb744b4Smrg cmds=$module_expsym_cmds 97801fb744b4Smrg else 97811fb744b4Smrg eval test_cmds=\"$module_cmds\" 97821fb744b4Smrg cmds=$module_cmds 97831fb744b4Smrg fi 9784518bcf38Smrg else 97851fb744b4Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 97861fb744b4Smrg eval test_cmds=\"$archive_expsym_cmds\" 97871fb744b4Smrg cmds=$archive_expsym_cmds 97881fb744b4Smrg else 97891fb744b4Smrg eval test_cmds=\"$archive_cmds\" 97901fb744b4Smrg cmds=$archive_cmds 97911fb744b4Smrg fi 9792f55e6a01Smrg fi 9793c35d236eSmrg 979414210e8eSmrg if test : != "$skipped_export" && 97951fb744b4Smrg func_len " $test_cmds" && 97961fb744b4Smrg len=$func_len_result && 97971fb744b4Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 97981fb744b4Smrg : 97991fb744b4Smrg else 98001fb744b4Smrg # The command line is too long to link in one step, link piecewise 98011fb744b4Smrg # or, if using GNU ld and skipped_export is not :, use a linker 98021fb744b4Smrg # script. 9803c35d236eSmrg 98041fb744b4Smrg # Save the value of $output and $libobjs because we want to 98051fb744b4Smrg # use them later. If we have whole_archive_flag_spec, we 98061fb744b4Smrg # want to use save_libobjs as it was before 98071fb744b4Smrg # whole_archive_flag_spec was expanded, because we can't 98081fb744b4Smrg # assume the linker understands whole_archive_flag_spec. 98091fb744b4Smrg # This may have to be revisited, in case too many 98101fb744b4Smrg # convenience libraries get linked in and end up exceeding 98111fb744b4Smrg # the spec. 98121fb744b4Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 98131fb744b4Smrg save_libobjs=$libobjs 98141fb744b4Smrg fi 98151fb744b4Smrg save_output=$output 98161fb744b4Smrg func_basename "$output" 98171fb744b4Smrg output_la=$func_basename_result 98181fb744b4Smrg 98191fb744b4Smrg # Clear the reloadable object creation command queue and 98201fb744b4Smrg # initialize k to one. 98211fb744b4Smrg test_cmds= 98221fb744b4Smrg concat_cmds= 98231fb744b4Smrg objlist= 98241fb744b4Smrg last_robj= 98251fb744b4Smrg k=1 98261fb744b4Smrg 982714210e8eSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 982814210e8eSmrg output=$output_objdir/$output_la.lnkscript 98291fb744b4Smrg func_verbose "creating GNU ld script: $output" 98301fb744b4Smrg echo 'INPUT (' > $output 98311fb744b4Smrg for obj in $save_libobjs 98321fb744b4Smrg do 98331fb744b4Smrg func_to_tool_file "$obj" 98341fb744b4Smrg $ECHO "$func_to_tool_file_result" >> $output 98351fb744b4Smrg done 98361fb744b4Smrg echo ')' >> $output 98371fb744b4Smrg func_append delfiles " $output" 98381fb744b4Smrg func_to_tool_file "$output" 98391fb744b4Smrg output=$func_to_tool_file_result 984014210e8eSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 984114210e8eSmrg output=$output_objdir/$output_la.lnk 98421fb744b4Smrg func_verbose "creating linker input file list: $output" 98431fb744b4Smrg : > $output 98441fb744b4Smrg set x $save_libobjs 98451fb744b4Smrg shift 98461fb744b4Smrg firstobj= 984714210e8eSmrg if test yes = "$compiler_needs_object"; then 98481fb744b4Smrg firstobj="$1 " 98491fb744b4Smrg shift 9850518bcf38Smrg fi 98511fb744b4Smrg for obj 98521fb744b4Smrg do 98531fb744b4Smrg func_to_tool_file "$obj" 98541fb744b4Smrg $ECHO "$func_to_tool_file_result" >> $output 9855518bcf38Smrg done 98561fb744b4Smrg func_append delfiles " $output" 98571fb744b4Smrg func_to_tool_file "$output" 98581fb744b4Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 98591fb744b4Smrg else 98601fb744b4Smrg if test -n "$save_libobjs"; then 98611fb744b4Smrg func_verbose "creating reloadable object files..." 986214210e8eSmrg output=$output_objdir/$output_la-$k.$objext 98631fb744b4Smrg eval test_cmds=\"$reload_cmds\" 98641fb744b4Smrg func_len " $test_cmds" 98651fb744b4Smrg len0=$func_len_result 98661fb744b4Smrg len=$len0 98671fb744b4Smrg 98681fb744b4Smrg # Loop over the list of objects to be linked. 98691fb744b4Smrg for obj in $save_libobjs 98701fb744b4Smrg do 98711fb744b4Smrg func_len " $obj" 98721fb744b4Smrg func_arith $len + $func_len_result 98731fb744b4Smrg len=$func_arith_result 987414210e8eSmrg if test -z "$objlist" || 98751fb744b4Smrg test "$len" -lt "$max_cmd_len"; then 98761fb744b4Smrg func_append objlist " $obj" 98771fb744b4Smrg else 98781fb744b4Smrg # The command $test_cmds is almost too long, add a 98791fb744b4Smrg # command to the queue. 988014210e8eSmrg if test 1 -eq "$k"; then 98811fb744b4Smrg # The first file doesn't have a previous command to add. 98821fb744b4Smrg reload_objs=$objlist 98831fb744b4Smrg eval concat_cmds=\"$reload_cmds\" 98841fb744b4Smrg else 98851fb744b4Smrg # All subsequent reloadable object files will link in 98861fb744b4Smrg # the last one created. 98871fb744b4Smrg reload_objs="$objlist $last_robj" 98881fb744b4Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 98891fb744b4Smrg fi 989014210e8eSmrg last_robj=$output_objdir/$output_la-$k.$objext 98911fb744b4Smrg func_arith $k + 1 98921fb744b4Smrg k=$func_arith_result 989314210e8eSmrg output=$output_objdir/$output_la-$k.$objext 98941fb744b4Smrg objlist=" $obj" 98951fb744b4Smrg func_len " $last_robj" 98961fb744b4Smrg func_arith $len0 + $func_len_result 98971fb744b4Smrg len=$func_arith_result 98981fb744b4Smrg fi 98991fb744b4Smrg done 99001fb744b4Smrg # Handle the remaining objects by creating one last 99011fb744b4Smrg # reloadable object file. All subsequent reloadable object 99021fb744b4Smrg # files will link in the last one created. 99031fb744b4Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99041fb744b4Smrg reload_objs="$objlist $last_robj" 990514210e8eSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 99061fb744b4Smrg if test -n "$last_robj"; then 990714210e8eSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908518bcf38Smrg fi 99091fb744b4Smrg func_append delfiles " $output" 99101fb744b4Smrg 99111fb744b4Smrg else 99121fb744b4Smrg output= 99131fb744b4Smrg fi 99141fb744b4Smrg 991514210e8eSmrg ${skipped_export-false} && { 991614210e8eSmrg func_verbose "generating symbol list for '$libname.la'" 991714210e8eSmrg export_symbols=$output_objdir/$libname.exp 99181fb744b4Smrg $opt_dry_run || $RM $export_symbols 99191fb744b4Smrg libobjs=$output 99201fb744b4Smrg # Append the command to create the export file. 99211fb744b4Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99221fb744b4Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 99231fb744b4Smrg if test -n "$last_robj"; then 99241fb744b4Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925518bcf38Smrg fi 992614210e8eSmrg } 99271fb744b4Smrg 99281fb744b4Smrg test -n "$save_libobjs" && 99291fb744b4Smrg func_verbose "creating a temporary reloadable object file: $output" 99301fb744b4Smrg 99311fb744b4Smrg # Loop through the commands generated above and execute them. 993214210e8eSmrg save_ifs=$IFS; IFS='~' 99331fb744b4Smrg for cmd in $concat_cmds; do 993414210e8eSmrg IFS=$save_ifs 993514210e8eSmrg $opt_quiet || { 99361fb744b4Smrg func_quote_for_expand "$cmd" 99371fb744b4Smrg eval "func_echo $func_quote_for_expand_result" 99381fb744b4Smrg } 99391fb744b4Smrg $opt_dry_run || eval "$cmd" || { 99401fb744b4Smrg lt_exit=$? 99411fb744b4Smrg 99421fb744b4Smrg # Restore the uninstalled library and exit 994314210e8eSmrg if test relink = "$opt_mode"; then 99441fb744b4Smrg ( cd "$output_objdir" && \ 99451fb744b4Smrg $RM "${realname}T" && \ 99461fb744b4Smrg $MV "${realname}U" "$realname" ) 99471fb744b4Smrg fi 99481fb744b4Smrg 99491fb744b4Smrg exit $lt_exit 99501fb744b4Smrg } 9951518bcf38Smrg done 995214210e8eSmrg IFS=$save_ifs 99531fb744b4Smrg 99541fb744b4Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 99551fb744b4Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99561fb744b4Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 99571fb744b4Smrg fi 99581fb744b4Smrg fi 99591fb744b4Smrg 996014210e8eSmrg ${skipped_export-false} && { 99611fb744b4Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 996214210e8eSmrg tmp_export_symbols=$export_symbols 996314210e8eSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 99641fb744b4Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 99651fb744b4Smrg fi 99661fb744b4Smrg 99671fb744b4Smrg if test -n "$orig_export_symbols"; then 99681fb744b4Smrg # The given exports_symbols file has to be filtered, so filter it. 996914210e8eSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 99701fb744b4Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 997114210e8eSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 99721fb744b4Smrg # though. Also, the filter scales superlinearly with the number of 99731fb744b4Smrg # global variables. join(1) would be nice here, but unfortunately 99741fb744b4Smrg # isn't a blessed tool. 99751fb744b4Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 99761fb744b4Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 99771fb744b4Smrg export_symbols=$output_objdir/$libname.def 99781fb744b4Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 99791fb744b4Smrg fi 998014210e8eSmrg } 99811fb744b4Smrg 99821fb744b4Smrg libobjs=$output 99831fb744b4Smrg # Restore the value of output. 99841fb744b4Smrg output=$save_output 99851fb744b4Smrg 99861fb744b4Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 99871fb744b4Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 99881fb744b4Smrg test "X$libobjs" = "X " && libobjs= 99891fb744b4Smrg fi 99901fb744b4Smrg # Expand the library linking commands again to reset the 99911fb744b4Smrg # value of $libobjs for piecewise linking. 99921fb744b4Smrg 99931fb744b4Smrg # Do each of the archive commands. 999414210e8eSmrg if test yes = "$module" && test -n "$module_cmds"; then 99951fb744b4Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 99961fb744b4Smrg cmds=$module_expsym_cmds 99971fb744b4Smrg else 99981fb744b4Smrg cmds=$module_cmds 99991fb744b4Smrg fi 10000518bcf38Smrg else 100011fb744b4Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100021fb744b4Smrg cmds=$archive_expsym_cmds 100031fb744b4Smrg else 100041fb744b4Smrg cmds=$archive_cmds 100051fb744b4Smrg fi 10006518bcf38Smrg fi 100071fb744b4Smrg fi 10008c35d236eSmrg 100091fb744b4Smrg if test -n "$delfiles"; then 100101fb744b4Smrg # Append the command to remove temporary files to $cmds. 100111fb744b4Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 100121fb744b4Smrg fi 10013c35d236eSmrg 100141fb744b4Smrg # Add any objects from preloaded convenience libraries 100151fb744b4Smrg if test -n "$dlprefiles"; then 1001614210e8eSmrg gentop=$output_objdir/${outputname}x 100171fb744b4Smrg func_append generated " $gentop" 10018c35d236eSmrg 100191fb744b4Smrg func_extract_archives $gentop $dlprefiles 100201fb744b4Smrg func_append libobjs " $func_extract_archives_result" 100211fb744b4Smrg test "X$libobjs" = "X " && libobjs= 100221fb744b4Smrg fi 10023c35d236eSmrg 1002414210e8eSmrg save_ifs=$IFS; IFS='~' 100251fb744b4Smrg for cmd in $cmds; do 1002614210e8eSmrg IFS=$sp$nl 100271fb744b4Smrg eval cmd=\"$cmd\" 1002814210e8eSmrg IFS=$save_ifs 1002914210e8eSmrg $opt_quiet || { 100301fb744b4Smrg func_quote_for_expand "$cmd" 100311fb744b4Smrg eval "func_echo $func_quote_for_expand_result" 100321fb744b4Smrg } 100331fb744b4Smrg $opt_dry_run || eval "$cmd" || { 100341fb744b4Smrg lt_exit=$? 10035f55e6a01Smrg 100361fb744b4Smrg # Restore the uninstalled library and exit 1003714210e8eSmrg if test relink = "$opt_mode"; then 100381fb744b4Smrg ( cd "$output_objdir" && \ 100391fb744b4Smrg $RM "${realname}T" && \ 100401fb744b4Smrg $MV "${realname}U" "$realname" ) 100411fb744b4Smrg fi 10042f55e6a01Smrg 100431fb744b4Smrg exit $lt_exit 100441fb744b4Smrg } 100451fb744b4Smrg done 1004614210e8eSmrg IFS=$save_ifs 10047f55e6a01Smrg 100481fb744b4Smrg # Restore the uninstalled library and exit 1004914210e8eSmrg if test relink = "$opt_mode"; then 100501fb744b4Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051f55e6a01Smrg 100521fb744b4Smrg if test -n "$convenience"; then 100531fb744b4Smrg if test -z "$whole_archive_flag_spec"; then 100541fb744b4Smrg func_show_eval '${RM}r "$gentop"' 100551fb744b4Smrg fi 100561fb744b4Smrg fi 10057f55e6a01Smrg 100581fb744b4Smrg exit $EXIT_SUCCESS 100591fb744b4Smrg fi 100601fb744b4Smrg 100611fb744b4Smrg # Create links to the real library. 100621fb744b4Smrg for linkname in $linknames; do 100631fb744b4Smrg if test "$realname" != "$linkname"; then 100641fb744b4Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065518bcf38Smrg fi 10066518bcf38Smrg done 10067f55e6a01Smrg 100681fb744b4Smrg # If -module or -export-dynamic was specified, set the dlname. 1006914210e8eSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 100701fb744b4Smrg # On all known operating systems, these are identical. 1007114210e8eSmrg dlname=$soname 100721fb744b4Smrg fi 100731fb744b4Smrg fi 10074c35d236eSmrg ;; 10075c35d236eSmrg 100761fb744b4Smrg obj) 1007714210e8eSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1007814210e8eSmrg func_warning "'-dlopen' is ignored for objects" 100791fb744b4Smrg fi 10080518bcf38Smrg 100811fb744b4Smrg case " $deplibs" in 100821fb744b4Smrg *\ -l* | *\ -L*) 1008314210e8eSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084f55e6a01Smrg esac 10085c35d236eSmrg 100861fb744b4Smrg test -n "$rpath" && \ 1008714210e8eSmrg func_warning "'-rpath' is ignored for objects" 10088c35d236eSmrg 100891fb744b4Smrg test -n "$xrpath" && \ 1009014210e8eSmrg func_warning "'-R' is ignored for objects" 10091f55e6a01Smrg 100921fb744b4Smrg test -n "$vinfo" && \ 1009314210e8eSmrg func_warning "'-version-info' is ignored for objects" 100941fb744b4Smrg 100951fb744b4Smrg test -n "$release" && \ 1009614210e8eSmrg func_warning "'-release' is ignored for objects" 100971fb744b4Smrg 100981fb744b4Smrg case $output in 100991fb744b4Smrg *.lo) 101001fb744b4Smrg test -n "$objs$old_deplibs" && \ 1010114210e8eSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 101021fb744b4Smrg 101031fb744b4Smrg libobj=$output 101041fb744b4Smrg func_lo2o "$libobj" 101051fb744b4Smrg obj=$func_lo2o_result 10106518bcf38Smrg ;; 10107518bcf38Smrg *) 101081fb744b4Smrg libobj= 1010914210e8eSmrg obj=$output 10110c35d236eSmrg ;; 10111f55e6a01Smrg esac 10112c35d236eSmrg 101131fb744b4Smrg # Delete the old objects. 101141fb744b4Smrg $opt_dry_run || $RM $obj $libobj 10115c35d236eSmrg 101161fb744b4Smrg # Objects from convenience libraries. This assumes 101171fb744b4Smrg # single-version convenience libraries. Whenever we create 101181fb744b4Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 101191fb744b4Smrg # the extraction. 101201fb744b4Smrg reload_conv_objs= 101211fb744b4Smrg gentop= 1012214210e8eSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 1012314210e8eSmrg # whole_archive_flag_spec and hope we can get by with turning comma 1012414210e8eSmrg # into space. 1012514210e8eSmrg case $reload_cmds in 1012614210e8eSmrg *\$LD[\ \$]*) wl= ;; 1012714210e8eSmrg esac 101281fb744b4Smrg if test -n "$convenience"; then 101291fb744b4Smrg if test -n "$whole_archive_flag_spec"; then 101301fb744b4Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1013114210e8eSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1013214210e8eSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 101331fb744b4Smrg else 1013414210e8eSmrg gentop=$output_objdir/${obj}x 101351fb744b4Smrg func_append generated " $gentop" 10136518bcf38Smrg 101371fb744b4Smrg func_extract_archives $gentop $convenience 101381fb744b4Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 101391fb744b4Smrg fi 10140518bcf38Smrg fi 10141518bcf38Smrg 101421fb744b4Smrg # If we're not building shared, we need to use non_pic_objs 1014314210e8eSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144518bcf38Smrg 101451fb744b4Smrg # Create the old-style object. 1014614210e8eSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147518bcf38Smrg 1014814210e8eSmrg output=$obj 101491fb744b4Smrg func_execute_cmds "$reload_cmds" 'exit $?' 101501fb744b4Smrg 101511fb744b4Smrg # Exit if we aren't doing a library object file. 101521fb744b4Smrg if test -z "$libobj"; then 101531fb744b4Smrg if test -n "$gentop"; then 101541fb744b4Smrg func_show_eval '${RM}r "$gentop"' 101551fb744b4Smrg fi 101561fb744b4Smrg 101571fb744b4Smrg exit $EXIT_SUCCESS 10158518bcf38Smrg fi 101591fb744b4Smrg 1016014210e8eSmrg test yes = "$build_libtool_libs" || { 101611fb744b4Smrg if test -n "$gentop"; then 101621fb744b4Smrg func_show_eval '${RM}r "$gentop"' 101631fb744b4Smrg fi 101641fb744b4Smrg 101651fb744b4Smrg # Create an invalid libtool object if no PIC, so that we don't 101661fb744b4Smrg # accidentally link it into a program. 101671fb744b4Smrg # $show "echo timestamp > $libobj" 101681fb744b4Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 101691fb744b4Smrg exit $EXIT_SUCCESS 1017014210e8eSmrg } 101711fb744b4Smrg 1017214210e8eSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 101731fb744b4Smrg # Only do commands if we really have different PIC objects. 101741fb744b4Smrg reload_objs="$libobjs $reload_conv_objs" 1017514210e8eSmrg output=$libobj 101761fb744b4Smrg func_execute_cmds "$reload_cmds" 'exit $?' 101771fb744b4Smrg fi 101781fb744b4Smrg 101791fb744b4Smrg if test -n "$gentop"; then 101801fb744b4Smrg func_show_eval '${RM}r "$gentop"' 101811fb744b4Smrg fi 101821fb744b4Smrg 101831fb744b4Smrg exit $EXIT_SUCCESS 10184518bcf38Smrg ;; 10185c35d236eSmrg 101861fb744b4Smrg prog) 101871fb744b4Smrg case $host in 101881fb744b4Smrg *cygwin*) func_stripname '' '.exe' "$output" 101891fb744b4Smrg output=$func_stripname_result.exe;; 101901fb744b4Smrg esac 101911fb744b4Smrg test -n "$vinfo" && \ 1019214210e8eSmrg func_warning "'-version-info' is ignored for programs" 10193c35d236eSmrg 101941fb744b4Smrg test -n "$release" && \ 1019514210e8eSmrg func_warning "'-release' is ignored for programs" 10196c35d236eSmrg 1019714210e8eSmrg $preload \ 1019814210e8eSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1019914210e8eSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 102001fb744b4Smrg 102011fb744b4Smrg case $host in 102021fb744b4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 102031fb744b4Smrg # On Rhapsody replace the C library is the System framework 102041fb744b4Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 102051fb744b4Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206518bcf38Smrg ;; 102071fb744b4Smrg esac 10208518bcf38Smrg 102091fb744b4Smrg case $host in 102101fb744b4Smrg *-*-darwin*) 102111fb744b4Smrg # Don't allow lazy linking, it breaks C++ global constructors 102121fb744b4Smrg # But is supposedly fixed on 10.4 or later (yay!). 1021314210e8eSmrg if test CXX = "$tagname"; then 102141fb744b4Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 102151fb744b4Smrg 10.[0123]) 1021614210e8eSmrg func_append compile_command " $wl-bind_at_load" 1021714210e8eSmrg func_append finalize_command " $wl-bind_at_load" 102181fb744b4Smrg ;; 102191fb744b4Smrg esac 10220518bcf38Smrg fi 102211fb744b4Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 102221fb744b4Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102231fb744b4Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102241fb744b4Smrg ;; 102251fb744b4Smrg esac 10226518bcf38Smrg 10227518bcf38Smrg 102281fb744b4Smrg # move library search paths that coincide with paths to not yet 102291fb744b4Smrg # installed libraries to the beginning of the library search list 102301fb744b4Smrg new_libs= 102311fb744b4Smrg for path in $notinst_path; do 102321fb744b4Smrg case " $new_libs " in 102331fb744b4Smrg *" -L$path/$objdir "*) ;; 102341fb744b4Smrg *) 102351fb744b4Smrg case " $compile_deplibs " in 102361fb744b4Smrg *" -L$path/$objdir "*) 102371fb744b4Smrg func_append new_libs " -L$path/$objdir" ;; 10238f55e6a01Smrg esac 102391fb744b4Smrg ;; 102401fb744b4Smrg esac 102411fb744b4Smrg done 102421fb744b4Smrg for deplib in $compile_deplibs; do 102431fb744b4Smrg case $deplib in 102441fb744b4Smrg -L*) 102451fb744b4Smrg case " $new_libs " in 102461fb744b4Smrg *" $deplib "*) ;; 102471fb744b4Smrg *) func_append new_libs " $deplib" ;; 10248f55e6a01Smrg esac 102491fb744b4Smrg ;; 102501fb744b4Smrg *) func_append new_libs " $deplib" ;; 102511fb744b4Smrg esac 102521fb744b4Smrg done 1025314210e8eSmrg compile_deplibs=$new_libs 10254c35d236eSmrg 10255518bcf38Smrg 102561fb744b4Smrg func_append compile_command " $compile_deplibs" 102571fb744b4Smrg func_append finalize_command " $finalize_deplibs" 10258518bcf38Smrg 102591fb744b4Smrg if test -n "$rpath$xrpath"; then 102601fb744b4Smrg # If the user specified any rpath flags, then add them. 102611fb744b4Smrg for libdir in $rpath $xrpath; do 102621fb744b4Smrg # This is the magic to use -rpath. 102631fb744b4Smrg case "$finalize_rpath " in 102641fb744b4Smrg *" $libdir "*) ;; 102651fb744b4Smrg *) func_append finalize_rpath " $libdir" ;; 102661fb744b4Smrg esac 102671fb744b4Smrg done 102681fb744b4Smrg fi 10269518bcf38Smrg 102701fb744b4Smrg # Now hardcode the library paths 102711fb744b4Smrg rpath= 102721fb744b4Smrg hardcode_libdirs= 102731fb744b4Smrg for libdir in $compile_rpath $finalize_rpath; do 102741fb744b4Smrg if test -n "$hardcode_libdir_flag_spec"; then 102751fb744b4Smrg if test -n "$hardcode_libdir_separator"; then 102761fb744b4Smrg if test -z "$hardcode_libdirs"; then 1027714210e8eSmrg hardcode_libdirs=$libdir 102781fb744b4Smrg else 102791fb744b4Smrg # Just accumulate the unique libdirs. 102801fb744b4Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 102811fb744b4Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 102821fb744b4Smrg ;; 102831fb744b4Smrg *) 102841fb744b4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 102851fb744b4Smrg ;; 102861fb744b4Smrg esac 102871fb744b4Smrg fi 10288518bcf38Smrg else 102891fb744b4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 102901fb744b4Smrg func_append rpath " $flag" 10291518bcf38Smrg fi 102921fb744b4Smrg elif test -n "$runpath_var"; then 102931fb744b4Smrg case "$perm_rpath " in 102941fb744b4Smrg *" $libdir "*) ;; 102951fb744b4Smrg *) func_append perm_rpath " $libdir" ;; 102961fb744b4Smrg esac 102971fb744b4Smrg fi 102981fb744b4Smrg case $host in 102991fb744b4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030014210e8eSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 103011fb744b4Smrg case :$dllsearchpath: in 103021fb744b4Smrg *":$libdir:"*) ;; 103031fb744b4Smrg ::) dllsearchpath=$libdir;; 103041fb744b4Smrg *) func_append dllsearchpath ":$libdir";; 103051fb744b4Smrg esac 103061fb744b4Smrg case :$dllsearchpath: in 103071fb744b4Smrg *":$testbindir:"*) ;; 103081fb744b4Smrg ::) dllsearchpath=$testbindir;; 103091fb744b4Smrg *) func_append dllsearchpath ":$testbindir";; 103101fb744b4Smrg esac 103111fb744b4Smrg ;; 103121fb744b4Smrg esac 103131fb744b4Smrg done 103141fb744b4Smrg # Substitute the hardcoded libdirs into the rpath. 103151fb744b4Smrg if test -n "$hardcode_libdir_separator" && 103161fb744b4Smrg test -n "$hardcode_libdirs"; then 1031714210e8eSmrg libdir=$hardcode_libdirs 103181fb744b4Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 103191fb744b4Smrg fi 1032014210e8eSmrg compile_rpath=$rpath 10321518bcf38Smrg 103221fb744b4Smrg rpath= 103231fb744b4Smrg hardcode_libdirs= 103241fb744b4Smrg for libdir in $finalize_rpath; do 103251fb744b4Smrg if test -n "$hardcode_libdir_flag_spec"; then 103261fb744b4Smrg if test -n "$hardcode_libdir_separator"; then 103271fb744b4Smrg if test -z "$hardcode_libdirs"; then 1032814210e8eSmrg hardcode_libdirs=$libdir 103291fb744b4Smrg else 103301fb744b4Smrg # Just accumulate the unique libdirs. 103311fb744b4Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 103321fb744b4Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 103331fb744b4Smrg ;; 103341fb744b4Smrg *) 103351fb744b4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 103361fb744b4Smrg ;; 103371fb744b4Smrg esac 103381fb744b4Smrg fi 10339c35d236eSmrg else 103401fb744b4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 103411fb744b4Smrg func_append rpath " $flag" 10342c35d236eSmrg fi 103431fb744b4Smrg elif test -n "$runpath_var"; then 103441fb744b4Smrg case "$finalize_perm_rpath " in 103451fb744b4Smrg *" $libdir "*) ;; 103461fb744b4Smrg *) func_append finalize_perm_rpath " $libdir" ;; 103471fb744b4Smrg esac 10348c35d236eSmrg fi 103491fb744b4Smrg done 103501fb744b4Smrg # Substitute the hardcoded libdirs into the rpath. 103511fb744b4Smrg if test -n "$hardcode_libdir_separator" && 103521fb744b4Smrg test -n "$hardcode_libdirs"; then 1035314210e8eSmrg libdir=$hardcode_libdirs 103541fb744b4Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 103551fb744b4Smrg fi 1035614210e8eSmrg finalize_rpath=$rpath 10357c35d236eSmrg 1035814210e8eSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 103591fb744b4Smrg # Transform all the library objects into standard objects. 103601fb744b4Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103611fb744b4Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103621fb744b4Smrg fi 10363c35d236eSmrg 1036414210e8eSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365c35d236eSmrg 103661fb744b4Smrg # template prelinking step 103671fb744b4Smrg if test -n "$prelink_cmds"; then 103681fb744b4Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 103691fb744b4Smrg fi 10370c35d236eSmrg 1037114210e8eSmrg wrappers_required=: 103721fb744b4Smrg case $host in 103731fb744b4Smrg *cegcc* | *mingw32ce*) 103741fb744b4Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1037514210e8eSmrg wrappers_required=false 103761fb744b4Smrg ;; 103771fb744b4Smrg *cygwin* | *mingw* ) 1037814210e8eSmrg test yes = "$build_libtool_libs" || wrappers_required=false 103791fb744b4Smrg ;; 103801fb744b4Smrg *) 1038114210e8eSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1038214210e8eSmrg wrappers_required=false 103831fb744b4Smrg fi 103841fb744b4Smrg ;; 103851fb744b4Smrg esac 1038614210e8eSmrg $wrappers_required || { 103871fb744b4Smrg # Replace the output file specification. 103881fb744b4Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1038914210e8eSmrg link_command=$compile_command$compile_rpath 10390c35d236eSmrg 103911fb744b4Smrg # We have no uninstalled library dependencies, so finalize right now. 103921fb744b4Smrg exit_status=0 103931fb744b4Smrg func_show_eval "$link_command" 'exit_status=$?' 10394c35d236eSmrg 103951fb744b4Smrg if test -n "$postlink_cmds"; then 103961fb744b4Smrg func_to_tool_file "$output" 103971fb744b4Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 103981fb744b4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10399c35d236eSmrg fi 10400c35d236eSmrg 104011fb744b4Smrg # Delete the generated files. 1040214210e8eSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 1040314210e8eSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 104041fb744b4Smrg fi 10405c35d236eSmrg 104061fb744b4Smrg exit $exit_status 1040714210e8eSmrg } 10408c35d236eSmrg 104091fb744b4Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 104101fb744b4Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 104111fb744b4Smrg fi 104121fb744b4Smrg if test -n "$finalize_shlibpath"; then 104131fb744b4Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 104141fb744b4Smrg fi 10415518bcf38Smrg 104161fb744b4Smrg compile_var= 104171fb744b4Smrg finalize_var= 104181fb744b4Smrg if test -n "$runpath_var"; then 104191fb744b4Smrg if test -n "$perm_rpath"; then 104201fb744b4Smrg # We should set the runpath_var. 104211fb744b4Smrg rpath= 104221fb744b4Smrg for dir in $perm_rpath; do 104231fb744b4Smrg func_append rpath "$dir:" 104241fb744b4Smrg done 104251fb744b4Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426c35d236eSmrg fi 104271fb744b4Smrg if test -n "$finalize_perm_rpath"; then 104281fb744b4Smrg # We should set the runpath_var. 104291fb744b4Smrg rpath= 104301fb744b4Smrg for dir in $finalize_perm_rpath; do 104311fb744b4Smrg func_append rpath "$dir:" 104321fb744b4Smrg done 104331fb744b4Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434c35d236eSmrg fi 104351fb744b4Smrg fi 10436c35d236eSmrg 1043714210e8eSmrg if test yes = "$no_install"; then 104381fb744b4Smrg # We don't need to create a wrapper script. 1043914210e8eSmrg link_command=$compile_var$compile_command$compile_rpath 104401fb744b4Smrg # Replace the output file specification. 104411fb744b4Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104421fb744b4Smrg # Delete the old output file. 104431fb744b4Smrg $opt_dry_run || $RM $output 104441fb744b4Smrg # Link the executable and exit 104451fb744b4Smrg func_show_eval "$link_command" 'exit $?' 10446c35d236eSmrg 104471fb744b4Smrg if test -n "$postlink_cmds"; then 104481fb744b4Smrg func_to_tool_file "$output" 104491fb744b4Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 104501fb744b4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10451518bcf38Smrg fi 104521fb744b4Smrg 10453518bcf38Smrg exit $EXIT_SUCCESS 104541fb744b4Smrg fi 10455f55e6a01Smrg 1045614210e8eSmrg case $hardcode_action,$fast_install in 1045714210e8eSmrg relink,*) 1045814210e8eSmrg # Fast installation is not supported 1045914210e8eSmrg link_command=$compile_var$compile_command$compile_rpath 1046014210e8eSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 104611fb744b4Smrg 1046214210e8eSmrg func_warning "this platform does not like uninstalled shared libraries" 1046314210e8eSmrg func_warning "'$output' will be relinked during installation" 1046414210e8eSmrg ;; 1046514210e8eSmrg *,yes) 1046614210e8eSmrg link_command=$finalize_var$compile_command$finalize_rpath 1046714210e8eSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1046814210e8eSmrg ;; 1046914210e8eSmrg *,no) 1047014210e8eSmrg link_command=$compile_var$compile_command$compile_rpath 1047114210e8eSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1047214210e8eSmrg ;; 1047314210e8eSmrg *,needless) 1047414210e8eSmrg link_command=$finalize_var$compile_command$finalize_rpath 1047514210e8eSmrg relink_command= 1047614210e8eSmrg ;; 1047714210e8eSmrg esac 10478c35d236eSmrg 104791fb744b4Smrg # Replace the output file specification. 104801fb744b4Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481c35d236eSmrg 104821fb744b4Smrg # Delete the old output files. 104831fb744b4Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484c35d236eSmrg 104851fb744b4Smrg func_show_eval "$link_command" 'exit $?' 10486c35d236eSmrg 104871fb744b4Smrg if test -n "$postlink_cmds"; then 104881fb744b4Smrg func_to_tool_file "$output_objdir/$outputname" 104891fb744b4Smrg 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'` 104901fb744b4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 104911fb744b4Smrg fi 10492518bcf38Smrg 104931fb744b4Smrg # Now create the wrapper script. 104941fb744b4Smrg func_verbose "creating $output" 10495518bcf38Smrg 104961fb744b4Smrg # Quote the relink command for shipping. 104971fb744b4Smrg if test -n "$relink_command"; then 104981fb744b4Smrg # Preserve any variables that may affect compiler behavior 104991fb744b4Smrg for var in $variables_saved_for_relink; do 105001fb744b4Smrg if eval test -z \"\${$var+set}\"; then 105011fb744b4Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 105021fb744b4Smrg elif eval var_value=\$$var; test -z "$var_value"; then 105031fb744b4Smrg relink_command="$var=; export $var; $relink_command" 10504c35d236eSmrg else 105051fb744b4Smrg func_quote_for_eval "$var_value" 105061fb744b4Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507c35d236eSmrg fi 105081fb744b4Smrg done 105091fb744b4Smrg relink_command="(cd `pwd`; $relink_command)" 105101fb744b4Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 105111fb744b4Smrg fi 105121fb744b4Smrg 105131fb744b4Smrg # Only actually do things if not in dry run mode. 105141fb744b4Smrg $opt_dry_run || { 105151fb744b4Smrg # win32 will think the script is a binary if it has 105161fb744b4Smrg # a .exe suffix, so we strip it off here. 105171fb744b4Smrg case $output in 105181fb744b4Smrg *.exe) func_stripname '' '.exe' "$output" 105191fb744b4Smrg output=$func_stripname_result ;; 10520f55e6a01Smrg esac 105211fb744b4Smrg # test for cygwin because mv fails w/o .exe extensions 105221fb744b4Smrg case $host in 105231fb744b4Smrg *cygwin*) 105241fb744b4Smrg exeext=.exe 105251fb744b4Smrg func_stripname '' '.exe' "$outputname" 105261fb744b4Smrg outputname=$func_stripname_result ;; 105271fb744b4Smrg *) exeext= ;; 105281fb744b4Smrg esac 105291fb744b4Smrg case $host in 105301fb744b4Smrg *cygwin* | *mingw* ) 105311fb744b4Smrg func_dirname_and_basename "$output" "" "." 105321fb744b4Smrg output_name=$func_basename_result 105331fb744b4Smrg output_path=$func_dirname_result 1053414210e8eSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1053514210e8eSmrg cwrapper=$output_path/$output_name.exe 105361fb744b4Smrg $RM $cwrappersource $cwrapper 105371fb744b4Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 105381fb744b4Smrg 105391fb744b4Smrg func_emit_cwrapperexe_src > $cwrappersource 105401fb744b4Smrg 105411fb744b4Smrg # The wrapper executable is built using the $host compiler, 105421fb744b4Smrg # because it contains $host paths and files. If cross- 105431fb744b4Smrg # compiling, it, like the target executable, must be 105441fb744b4Smrg # executed on the $host or under an emulation environment. 105451fb744b4Smrg $opt_dry_run || { 105461fb744b4Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 105471fb744b4Smrg $STRIP $cwrapper 105481fb744b4Smrg } 10549c35d236eSmrg 105501fb744b4Smrg # Now, create the wrapper script for func_source use: 105511fb744b4Smrg func_ltwrapper_scriptname $cwrapper 105521fb744b4Smrg $RM $func_ltwrapper_scriptname_result 105531fb744b4Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 105541fb744b4Smrg $opt_dry_run || { 105551fb744b4Smrg # note: this script will not be executed, so do not chmod. 1055614210e8eSmrg if test "x$build" = "x$host"; then 105571fb744b4Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 105581fb744b4Smrg else 105591fb744b4Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 105601fb744b4Smrg fi 105611fb744b4Smrg } 105621fb744b4Smrg ;; 105631fb744b4Smrg * ) 105641fb744b4Smrg $RM $output 105651fb744b4Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566c35d236eSmrg 105671fb744b4Smrg func_emit_wrapper no > $output 105681fb744b4Smrg chmod +x $output 105691fb744b4Smrg ;; 105701fb744b4Smrg esac 105711fb744b4Smrg } 105721fb744b4Smrg exit $EXIT_SUCCESS 105731fb744b4Smrg ;; 105741fb744b4Smrg esac 10575c35d236eSmrg 105761fb744b4Smrg # See if we need to build an old-fashioned archive. 105771fb744b4Smrg for oldlib in $oldlibs; do 10578c35d236eSmrg 1057914210e8eSmrg case $build_libtool_libs in 1058014210e8eSmrg convenience) 1058114210e8eSmrg oldobjs="$libobjs_save $symfileobj" 1058214210e8eSmrg addlibs=$convenience 105831fb744b4Smrg build_libtool_libs=no 1058414210e8eSmrg ;; 1058514210e8eSmrg module) 1058614210e8eSmrg oldobjs=$libobjs_save 1058714210e8eSmrg addlibs=$old_convenience 1058814210e8eSmrg build_libtool_libs=no 1058914210e8eSmrg ;; 1059014210e8eSmrg *) 105911fb744b4Smrg oldobjs="$old_deplibs $non_pic_objects" 1059214210e8eSmrg $preload && test -f "$symfileobj" \ 1059314210e8eSmrg && func_append oldobjs " $symfileobj" 1059414210e8eSmrg addlibs=$old_convenience 1059514210e8eSmrg ;; 1059614210e8eSmrg esac 10597c35d236eSmrg 105981fb744b4Smrg if test -n "$addlibs"; then 1059914210e8eSmrg gentop=$output_objdir/${outputname}x 106001fb744b4Smrg func_append generated " $gentop" 10601c35d236eSmrg 106021fb744b4Smrg func_extract_archives $gentop $addlibs 106031fb744b4Smrg func_append oldobjs " $func_extract_archives_result" 106041fb744b4Smrg fi 10605c35d236eSmrg 106061fb744b4Smrg # Do each command in the archive commands. 1060714210e8eSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 106081fb744b4Smrg cmds=$old_archive_from_new_cmds 106091fb744b4Smrg else 10610c35d236eSmrg 106111fb744b4Smrg # Add any objects from preloaded convenience libraries 106121fb744b4Smrg if test -n "$dlprefiles"; then 1061314210e8eSmrg gentop=$output_objdir/${outputname}x 106141fb744b4Smrg func_append generated " $gentop" 10615c35d236eSmrg 106161fb744b4Smrg func_extract_archives $gentop $dlprefiles 106171fb744b4Smrg func_append oldobjs " $func_extract_archives_result" 106181fb744b4Smrg fi 10619c35d236eSmrg 106201fb744b4Smrg # POSIX demands no paths to be encoded in archives. We have 106211fb744b4Smrg # to avoid creating archives with duplicate basenames if we 106221fb744b4Smrg # might have to extract them afterwards, e.g., when creating a 106231fb744b4Smrg # static archive out of a convenience library, or when linking 106241fb744b4Smrg # the entirety of a libtool archive into another (currently 106251fb744b4Smrg # not supported by libtool). 106261fb744b4Smrg if (for obj in $oldobjs 106271fb744b4Smrg do 106281fb744b4Smrg func_basename "$obj" 106291fb744b4Smrg $ECHO "$func_basename_result" 106301fb744b4Smrg done | sort | sort -uc >/dev/null 2>&1); then 106311fb744b4Smrg : 106321fb744b4Smrg else 106331fb744b4Smrg echo "copying selected object files to avoid basename conflicts..." 1063414210e8eSmrg gentop=$output_objdir/${outputname}x 106351fb744b4Smrg func_append generated " $gentop" 106361fb744b4Smrg func_mkdir_p "$gentop" 106371fb744b4Smrg save_oldobjs=$oldobjs 106381fb744b4Smrg oldobjs= 106391fb744b4Smrg counter=1 106401fb744b4Smrg for obj in $save_oldobjs 106411fb744b4Smrg do 106421fb744b4Smrg func_basename "$obj" 1064314210e8eSmrg objbase=$func_basename_result 106441fb744b4Smrg case " $oldobjs " in 106451fb744b4Smrg " ") oldobjs=$obj ;; 106461fb744b4Smrg *[\ /]"$objbase "*) 106471fb744b4Smrg while :; do 106481fb744b4Smrg # Make sure we don't pick an alternate name that also 106491fb744b4Smrg # overlaps. 106501fb744b4Smrg newobj=lt$counter-$objbase 106511fb744b4Smrg func_arith $counter + 1 106521fb744b4Smrg counter=$func_arith_result 106531fb744b4Smrg case " $oldobjs " in 106541fb744b4Smrg *[\ /]"$newobj "*) ;; 106551fb744b4Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 106561fb744b4Smrg esac 106571fb744b4Smrg done 106581fb744b4Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 106591fb744b4Smrg func_append oldobjs " $gentop/$newobj" 106601fb744b4Smrg ;; 106611fb744b4Smrg *) func_append oldobjs " $obj" ;; 106621fb744b4Smrg esac 10663c35d236eSmrg done 10664f55e6a01Smrg fi 106651fb744b4Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 106661fb744b4Smrg tool_oldlib=$func_to_tool_file_result 106671fb744b4Smrg eval cmds=\"$old_archive_cmds\" 10668518bcf38Smrg 106691fb744b4Smrg func_len " $cmds" 106701fb744b4Smrg len=$func_len_result 106711fb744b4Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 106721fb744b4Smrg cmds=$old_archive_cmds 106731fb744b4Smrg elif test -n "$archiver_list_spec"; then 106741fb744b4Smrg func_verbose "using command file archive linking..." 106751fb744b4Smrg for obj in $oldobjs 106761fb744b4Smrg do 106771fb744b4Smrg func_to_tool_file "$obj" 106781fb744b4Smrg $ECHO "$func_to_tool_file_result" 106791fb744b4Smrg done > $output_objdir/$libname.libcmd 106801fb744b4Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 106811fb744b4Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 106821fb744b4Smrg cmds=$old_archive_cmds 106831fb744b4Smrg else 106841fb744b4Smrg # the command line is too long to link in one step, link in parts 106851fb744b4Smrg func_verbose "using piecewise archive linking..." 106861fb744b4Smrg save_RANLIB=$RANLIB 106871fb744b4Smrg RANLIB=: 106881fb744b4Smrg objlist= 106891fb744b4Smrg concat_cmds= 106901fb744b4Smrg save_oldobjs=$oldobjs 106911fb744b4Smrg oldobjs= 106921fb744b4Smrg # Is there a better way of finding the last object in the list? 106931fb744b4Smrg for obj in $save_oldobjs 106941fb744b4Smrg do 106951fb744b4Smrg last_oldobj=$obj 106961fb744b4Smrg done 106971fb744b4Smrg eval test_cmds=\"$old_archive_cmds\" 106981fb744b4Smrg func_len " $test_cmds" 106991fb744b4Smrg len0=$func_len_result 107001fb744b4Smrg len=$len0 107011fb744b4Smrg for obj in $save_oldobjs 107021fb744b4Smrg do 107031fb744b4Smrg func_len " $obj" 107041fb744b4Smrg func_arith $len + $func_len_result 107051fb744b4Smrg len=$func_arith_result 107061fb744b4Smrg func_append objlist " $obj" 107071fb744b4Smrg if test "$len" -lt "$max_cmd_len"; then 107081fb744b4Smrg : 107091fb744b4Smrg else 107101fb744b4Smrg # the above command should be used before it gets too long 107111fb744b4Smrg oldobjs=$objlist 1071214210e8eSmrg if test "$obj" = "$last_oldobj"; then 107131fb744b4Smrg RANLIB=$save_RANLIB 107141fb744b4Smrg fi 107151fb744b4Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1071614210e8eSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 107171fb744b4Smrg objlist= 107181fb744b4Smrg len=$len0 107191fb744b4Smrg fi 107201fb744b4Smrg done 107211fb744b4Smrg RANLIB=$save_RANLIB 107221fb744b4Smrg oldobjs=$objlist 1072314210e8eSmrg if test -z "$oldobjs"; then 107241fb744b4Smrg eval cmds=\"\$concat_cmds\" 107251fb744b4Smrg else 107261fb744b4Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 107271fb744b4Smrg fi 107281fb744b4Smrg fi 107291fb744b4Smrg fi 107301fb744b4Smrg func_execute_cmds "$cmds" 'exit $?' 10731c35d236eSmrg done 10732c35d236eSmrg 107331fb744b4Smrg test -n "$generated" && \ 107341fb744b4Smrg func_show_eval "${RM}r$generated" 10735c35d236eSmrg 107361fb744b4Smrg # Now create the libtool archive. 107371fb744b4Smrg case $output in 107381fb744b4Smrg *.la) 107391fb744b4Smrg old_library= 1074014210e8eSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 107411fb744b4Smrg func_verbose "creating $output" 10742c35d236eSmrg 107431fb744b4Smrg # Preserve any variables that may affect compiler behavior 107441fb744b4Smrg for var in $variables_saved_for_relink; do 107451fb744b4Smrg if eval test -z \"\${$var+set}\"; then 107461fb744b4Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107471fb744b4Smrg elif eval var_value=\$$var; test -z "$var_value"; then 107481fb744b4Smrg relink_command="$var=; export $var; $relink_command" 10749518bcf38Smrg else 107501fb744b4Smrg func_quote_for_eval "$var_value" 107511fb744b4Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752518bcf38Smrg fi 107531fb744b4Smrg done 107541fb744b4Smrg # Quote the link command for shipping. 1075514210e8eSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 107561fb744b4Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1075714210e8eSmrg if test yes = "$hardcode_automatic"; then 107581fb744b4Smrg relink_command= 107591fb744b4Smrg fi 10760c35d236eSmrg 107611fb744b4Smrg # Only create the output if not a dry run. 107621fb744b4Smrg $opt_dry_run || { 107631fb744b4Smrg for installed in no yes; do 1076414210e8eSmrg if test yes = "$installed"; then 107651fb744b4Smrg if test -z "$install_libdir"; then 107661fb744b4Smrg break 107671fb744b4Smrg fi 1076814210e8eSmrg output=$output_objdir/${outputname}i 107691fb744b4Smrg # Replace all uninstalled libtool libraries with the installed ones 107701fb744b4Smrg newdependency_libs= 107711fb744b4Smrg for deplib in $dependency_libs; do 107721fb744b4Smrg case $deplib in 107731fb744b4Smrg *.la) 107741fb744b4Smrg func_basename "$deplib" 1077514210e8eSmrg name=$func_basename_result 107761fb744b4Smrg func_resolve_sysroot "$deplib" 1077714210e8eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 107781fb744b4Smrg test -z "$libdir" && \ 1077914210e8eSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 107801fb744b4Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 107811fb744b4Smrg ;; 107821fb744b4Smrg -L*) 107831fb744b4Smrg func_stripname -L '' "$deplib" 107841fb744b4Smrg func_replace_sysroot "$func_stripname_result" 107851fb744b4Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 107861fb744b4Smrg ;; 107871fb744b4Smrg -R*) 107881fb744b4Smrg func_stripname -R '' "$deplib" 107891fb744b4Smrg func_replace_sysroot "$func_stripname_result" 107901fb744b4Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 107911fb744b4Smrg ;; 107921fb744b4Smrg *) func_append newdependency_libs " $deplib" ;; 107931fb744b4Smrg esac 107941fb744b4Smrg done 1079514210e8eSmrg dependency_libs=$newdependency_libs 107961fb744b4Smrg newdlfiles= 107971fb744b4Smrg 107981fb744b4Smrg for lib in $dlfiles; do 107991fb744b4Smrg case $lib in 108001fb744b4Smrg *.la) 108011fb744b4Smrg func_basename "$lib" 1080214210e8eSmrg name=$func_basename_result 1080314210e8eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108041fb744b4Smrg test -z "$libdir" && \ 1080514210e8eSmrg func_fatal_error "'$lib' is not a valid libtool archive" 108061fb744b4Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 108071fb744b4Smrg ;; 108081fb744b4Smrg *) func_append newdlfiles " $lib" ;; 108091fb744b4Smrg esac 108101fb744b4Smrg done 1081114210e8eSmrg dlfiles=$newdlfiles 108121fb744b4Smrg newdlprefiles= 108131fb744b4Smrg for lib in $dlprefiles; do 108141fb744b4Smrg case $lib in 108151fb744b4Smrg *.la) 108161fb744b4Smrg # Only pass preopened files to the pseudo-archive (for 108171fb744b4Smrg # eventual linking with the app. that links it) if we 108181fb744b4Smrg # didn't already link the preopened objects directly into 108191fb744b4Smrg # the library: 108201fb744b4Smrg func_basename "$lib" 1082114210e8eSmrg name=$func_basename_result 1082214210e8eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108231fb744b4Smrg test -z "$libdir" && \ 1082414210e8eSmrg func_fatal_error "'$lib' is not a valid libtool archive" 108251fb744b4Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 108261fb744b4Smrg ;; 108271fb744b4Smrg esac 108281fb744b4Smrg done 1082914210e8eSmrg dlprefiles=$newdlprefiles 108301fb744b4Smrg else 108311fb744b4Smrg newdlfiles= 108321fb744b4Smrg for lib in $dlfiles; do 108331fb744b4Smrg case $lib in 1083414210e8eSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108351fb744b4Smrg *) abs=`pwd`"/$lib" ;; 108361fb744b4Smrg esac 108371fb744b4Smrg func_append newdlfiles " $abs" 108381fb744b4Smrg done 1083914210e8eSmrg dlfiles=$newdlfiles 108401fb744b4Smrg newdlprefiles= 108411fb744b4Smrg for lib in $dlprefiles; do 108421fb744b4Smrg case $lib in 1084314210e8eSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108441fb744b4Smrg *) abs=`pwd`"/$lib" ;; 108451fb744b4Smrg esac 108461fb744b4Smrg func_append newdlprefiles " $abs" 108471fb744b4Smrg done 1084814210e8eSmrg dlprefiles=$newdlprefiles 108491fb744b4Smrg fi 108501fb744b4Smrg $RM $output 108511fb744b4Smrg # place dlname in correct position for cygwin 108521fb744b4Smrg # In fact, it would be nice if we could use this code for all target 108531fb744b4Smrg # systems that can't hard-code library paths into their executables 108541fb744b4Smrg # and that have no shared library path variable independent of PATH, 108551fb744b4Smrg # but it turns out we can't easily determine that from inspecting 108561fb744b4Smrg # libtool variables, so we have to hard-code the OSs to which it 108571fb744b4Smrg # applies here; at the moment, that means platforms that use the PE 108581fb744b4Smrg # object format with DLL files. See the long comment at the top of 108591fb744b4Smrg # tests/bindir.at for full details. 108601fb744b4Smrg tdlname=$dlname 108611fb744b4Smrg case $host,$output,$installed,$module,$dlname in 108621fb744b4Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 108631fb744b4Smrg # If a -bindir argument was supplied, place the dll there. 1086414210e8eSmrg if test -n "$bindir"; then 108651fb744b4Smrg func_relative_path "$install_libdir" "$bindir" 1086614210e8eSmrg tdlname=$func_relative_path_result/$dlname 108671fb744b4Smrg else 108681fb744b4Smrg # Otherwise fall back on heuristic. 108691fb744b4Smrg tdlname=../bin/$dlname 108701fb744b4Smrg fi 108711fb744b4Smrg ;; 108721fb744b4Smrg esac 108731fb744b4Smrg $ECHO > $output "\ 108741fb744b4Smrg# $outputname - a libtool library file 1087514210e8eSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 108761fb744b4Smrg# 108771fb744b4Smrg# Please DO NOT delete this file! 108781fb744b4Smrg# It is necessary for linking the library. 10879c35d236eSmrg 108801fb744b4Smrg# The name that we can dlopen(3). 108811fb744b4Smrgdlname='$tdlname' 10882c35d236eSmrg 108831fb744b4Smrg# Names of this library. 108841fb744b4Smrglibrary_names='$library_names' 10885c35d236eSmrg 108861fb744b4Smrg# The name of the static archive. 108871fb744b4Smrgold_library='$old_library' 10888c35d236eSmrg 1088914210e8eSmrg# Linker flags that cannot go in dependency_libs. 108901fb744b4Smrginherited_linker_flags='$new_inherited_linker_flags' 10891c35d236eSmrg 108921fb744b4Smrg# Libraries that this one depends upon. 108931fb744b4Smrgdependency_libs='$dependency_libs' 10894c35d236eSmrg 108951fb744b4Smrg# Names of additional weak libraries provided by this library 108961fb744b4Smrgweak_library_names='$weak_libs' 10897c35d236eSmrg 108981fb744b4Smrg# Version information for $libname. 108991fb744b4Smrgcurrent=$current 109001fb744b4Smrgage=$age 109011fb744b4Smrgrevision=$revision 10902c35d236eSmrg 109031fb744b4Smrg# Is this an already installed library? 109041fb744b4Smrginstalled=$installed 10905c35d236eSmrg 109061fb744b4Smrg# Should we warn about portability when linking against -modules? 109071fb744b4Smrgshouldnotlink=$module 10908c35d236eSmrg 109091fb744b4Smrg# Files to dlopen/dlpreopen 109101fb744b4Smrgdlopen='$dlfiles' 109111fb744b4Smrgdlpreopen='$dlprefiles' 10912c35d236eSmrg 109131fb744b4Smrg# Directory that this library needs to be installed in: 109141fb744b4Smrglibdir='$install_libdir'" 1091514210e8eSmrg if test no,yes = "$installed,$need_relink"; then 109161fb744b4Smrg $ECHO >> $output "\ 109171fb744b4Smrgrelink_command=\"$relink_command\"" 109181fb744b4Smrg fi 109191fb744b4Smrg done 109201fb744b4Smrg } 109214f6cd06fSmrg 109221fb744b4Smrg # Do a symbolic link so that the libtool archive can be found in 109231fb744b4Smrg # LD_LIBRARY_PATH before the program is installed. 109241fb744b4Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 109251fb744b4Smrg ;; 109261fb744b4Smrg esac 109271fb744b4Smrg exit $EXIT_SUCCESS 109281fb744b4Smrg} 10929518bcf38Smrg 1093014210e8eSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1093114210e8eSmrg func_mode_link ${1+"$@"} 1093214210e8eSmrgfi 10933c35d236eSmrg 10934c35d236eSmrg 109351fb744b4Smrg# func_mode_uninstall arg... 109361fb744b4Smrgfunc_mode_uninstall () 109371fb744b4Smrg{ 1093814210e8eSmrg $debug_cmd 1093914210e8eSmrg 1094014210e8eSmrg RM=$nonopt 10941c35d236eSmrg files= 1094214210e8eSmrg rmforce=false 10943c35d236eSmrg exit_status=0 10944c35d236eSmrg 10945c35d236eSmrg # This variable tells wrapper scripts just to set variables rather 10946c35d236eSmrg # than running their programs. 1094714210e8eSmrg libtool_install_magic=$magic 10948c35d236eSmrg 10949c35d236eSmrg for arg 10950c35d236eSmrg do 10951c35d236eSmrg case $arg in 1095214210e8eSmrg -f) func_append RM " $arg"; rmforce=: ;; 109531fb744b4Smrg -*) func_append RM " $arg" ;; 109541fb744b4Smrg *) func_append files " $arg" ;; 10955c35d236eSmrg esac 10956c35d236eSmrg done 10957c35d236eSmrg 109581fb744b4Smrg test -z "$RM" && \ 109591fb744b4Smrg func_fatal_help "you must specify an RM program" 10960c35d236eSmrg 10961c35d236eSmrg rmdirs= 10962c35d236eSmrg 10963c35d236eSmrg for file in $files; do 109641fb744b4Smrg func_dirname "$file" "" "." 1096514210e8eSmrg dir=$func_dirname_result 1096614210e8eSmrg if test . = "$dir"; then 1096714210e8eSmrg odir=$objdir 10968c35d236eSmrg else 1096914210e8eSmrg odir=$dir/$objdir 10970c35d236eSmrg fi 109711fb744b4Smrg func_basename "$file" 1097214210e8eSmrg name=$func_basename_result 1097314210e8eSmrg test uninstall = "$opt_mode" && odir=$dir 10974c35d236eSmrg 109751fb744b4Smrg # Remember odir for removal later, being careful to avoid duplicates 1097614210e8eSmrg if test clean = "$opt_mode"; then 10977c35d236eSmrg case " $rmdirs " in 109781fb744b4Smrg *" $odir "*) ;; 109791fb744b4Smrg *) func_append rmdirs " $odir" ;; 10980c35d236eSmrg esac 10981c35d236eSmrg fi 10982c35d236eSmrg 10983c35d236eSmrg # Don't error if the file doesn't exist and rm -f was used. 109841fb744b4Smrg if { test -L "$file"; } >/dev/null 2>&1 || 109851fb744b4Smrg { test -h "$file"; } >/dev/null 2>&1 || 109861fb744b4Smrg test -f "$file"; then 10987c35d236eSmrg : 10988c35d236eSmrg elif test -d "$file"; then 10989c35d236eSmrg exit_status=1 10990c35d236eSmrg continue 1099114210e8eSmrg elif $rmforce; then 10992c35d236eSmrg continue 10993c35d236eSmrg fi 10994c35d236eSmrg 1099514210e8eSmrg rmfiles=$file 10996c35d236eSmrg 10997c35d236eSmrg case $name in 10998c35d236eSmrg *.la) 10999c35d236eSmrg # Possibly a libtool archive, so verify it. 110001fb744b4Smrg if func_lalib_p "$file"; then 110011fb744b4Smrg func_source $dir/$name 11002c35d236eSmrg 11003c35d236eSmrg # Delete the libtool libraries and symlinks. 11004c35d236eSmrg for n in $library_names; do 110051fb744b4Smrg func_append rmfiles " $odir/$n" 11006c35d236eSmrg done 110071fb744b4Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008c35d236eSmrg 1100914210e8eSmrg case $opt_mode in 11010c35d236eSmrg clean) 110111fb744b4Smrg case " $library_names " in 11012c35d236eSmrg *" $dlname "*) ;; 110131fb744b4Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014c35d236eSmrg esac 110151fb744b4Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016c35d236eSmrg ;; 11017c35d236eSmrg uninstall) 11018c35d236eSmrg if test -n "$library_names"; then 11019c35d236eSmrg # Do each command in the postuninstall commands. 1102014210e8eSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021c35d236eSmrg fi 11022c35d236eSmrg 11023c35d236eSmrg if test -n "$old_library"; then 11024c35d236eSmrg # Do each command in the old_postuninstall commands. 1102514210e8eSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026c35d236eSmrg fi 11027c35d236eSmrg # FIXME: should reinstall the best remaining shared library. 11028c35d236eSmrg ;; 11029c35d236eSmrg esac 11030c35d236eSmrg fi 11031c35d236eSmrg ;; 11032c35d236eSmrg 11033c35d236eSmrg *.lo) 11034c35d236eSmrg # Possibly a libtool object, so verify it. 110351fb744b4Smrg if func_lalib_p "$file"; then 11036c35d236eSmrg 11037c35d236eSmrg # Read the .lo file 110381fb744b4Smrg func_source $dir/$name 11039c35d236eSmrg 11040c35d236eSmrg # Add PIC object to the list of files to remove. 1104114210e8eSmrg if test -n "$pic_object" && test none != "$pic_object"; then 110421fb744b4Smrg func_append rmfiles " $dir/$pic_object" 11043c35d236eSmrg fi 11044c35d236eSmrg 11045c35d236eSmrg # Add non-PIC object to the list of files to remove. 1104614210e8eSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 110471fb744b4Smrg func_append rmfiles " $dir/$non_pic_object" 11048c35d236eSmrg fi 11049c35d236eSmrg fi 11050c35d236eSmrg ;; 11051c35d236eSmrg 11052c35d236eSmrg *) 1105314210e8eSmrg if test clean = "$opt_mode"; then 11054c35d236eSmrg noexename=$name 11055c35d236eSmrg case $file in 11056c35d236eSmrg *.exe) 110571fb744b4Smrg func_stripname '' '.exe' "$file" 110581fb744b4Smrg file=$func_stripname_result 110591fb744b4Smrg func_stripname '' '.exe' "$name" 110601fb744b4Smrg noexename=$func_stripname_result 11061c35d236eSmrg # $file with .exe has already been added to rmfiles, 11062c35d236eSmrg # add $file without .exe 110631fb744b4Smrg func_append rmfiles " $file" 11064c35d236eSmrg ;; 11065c35d236eSmrg esac 11066c35d236eSmrg # Do a test to see if this is a libtool program. 110671fb744b4Smrg if func_ltwrapper_p "$file"; then 110681fb744b4Smrg if func_ltwrapper_executable_p "$file"; then 110691fb744b4Smrg func_ltwrapper_scriptname "$file" 110701fb744b4Smrg relink_command= 110711fb744b4Smrg func_source $func_ltwrapper_scriptname_result 110721fb744b4Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 110731fb744b4Smrg else 110741fb744b4Smrg relink_command= 110751fb744b4Smrg func_source $dir/$noexename 110761fb744b4Smrg fi 11077c35d236eSmrg 11078c35d236eSmrg # note $name still contains .exe if it was in $file originally 11079c35d236eSmrg # as does the version of $file that was added into $rmfiles 1108014210e8eSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1108114210e8eSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 110821fb744b4Smrg func_append rmfiles " $odir/lt-$name" 11083c35d236eSmrg fi 1108414210e8eSmrg if test "X$noexename" != "X$name"; then 1108514210e8eSmrg func_append rmfiles " $odir/lt-$noexename.c" 11086c35d236eSmrg fi 11087c35d236eSmrg fi 11088c35d236eSmrg fi 11089c35d236eSmrg ;; 11090c35d236eSmrg esac 110911fb744b4Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092c35d236eSmrg done 11093c35d236eSmrg 1109414210e8eSmrg # Try to remove the $objdir's in the directories where we deleted files 11095c35d236eSmrg for dir in $rmdirs; do 11096c35d236eSmrg if test -d "$dir"; then 110971fb744b4Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098c35d236eSmrg fi 11099c35d236eSmrg done 11100c35d236eSmrg 11101c35d236eSmrg exit $exit_status 111021fb744b4Smrg} 11103c35d236eSmrg 1110414210e8eSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1110514210e8eSmrg func_mode_uninstall ${1+"$@"} 1110614210e8eSmrgfi 11107f55e6a01Smrg 111081fb744b4Smrgtest -z "$opt_mode" && { 1110914210e8eSmrg help=$generic_help 111101fb744b4Smrg func_fatal_help "you must specify a MODE" 111111fb744b4Smrg} 111121fb744b4Smrg 111131fb744b4Smrgtest -z "$exec_cmd" && \ 1111414210e8eSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11115c35d236eSmrg 11116c35d236eSmrgif test -n "$exec_cmd"; then 111171fb744b4Smrg eval exec "$exec_cmd" 11118c35d236eSmrg exit $EXIT_FAILURE 11119c35d236eSmrgfi 11120c35d236eSmrg 111211fb744b4Smrgexit $exit_status 11122518bcf38Smrg 11123c35d236eSmrg 11124c35d236eSmrg# The TAGs below are defined such that we never get into a situation 1112514210e8eSmrg# where we disable both kinds of libraries. Given conflicting 11126c35d236eSmrg# choices, we go for a static library, that is the most portable, 11127c35d236eSmrg# since we can't tell whether shared libraries were disabled because 11128c35d236eSmrg# the user asked for that or because the platform doesn't support 11129c35d236eSmrg# them. This is particularly important on AIX, because we don't 11130c35d236eSmrg# support having both static and shared libraries enabled at the same 11131c35d236eSmrg# time on that platform, so we default to a shared-only configuration. 11132c35d236eSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11133c35d236eSmrg# configuration. But we'll never go from static-only to shared-only. 11134c35d236eSmrg 11135c35d236eSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 111361fb744b4Smrgbuild_libtool_libs=no 111371fb744b4Smrgbuild_old_libs=yes 11138c35d236eSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139c35d236eSmrg 11140c35d236eSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 111411fb744b4Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142c35d236eSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11143c35d236eSmrg 11144c35d236eSmrg# Local Variables: 11145c35d236eSmrg# mode:shell-script 11146c35d236eSmrg# sh-indentation:2 11147c35d236eSmrg# End: 11148