121525869Smrg#! /bin/sh 221525869Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 321525869Smrg## by inline-source v2014-01-03.01 4e35772b2Smrg 521525869Smrg# libtool (GNU libtool) 2.4.6 621525869Smrg# Provide generalized library-building support services. 7e35772b2Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8e35772b2Smrg 921525869Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10e35772b2Smrg# This is free software; see the source for copying conditions. There is NO 11e35772b2Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12e35772b2Smrg 13e35772b2Smrg# GNU Libtool is free software; you can redistribute it and/or modify 1472b676d7Smrg# it under the terms of the GNU General Public License as published by 1572b676d7Smrg# the Free Software Foundation; either version 2 of the License, or 1672b676d7Smrg# (at your option) any later version. 1772b676d7Smrg# 18e35772b2Smrg# As a special exception to the GNU General Public License, 19e35772b2Smrg# if you distribute this file as part of a program or library that 20e35772b2Smrg# is built using GNU Libtool, you may include this file under the 21e35772b2Smrg# same distribution terms that you use for the rest of that program. 22e35772b2Smrg# 23e35772b2Smrg# GNU Libtool is distributed in the hope that it will be useful, but 2472b676d7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2572b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2672b676d7Smrg# General Public License for more details. 2772b676d7Smrg# 2872b676d7Smrg# You should have received a copy of the GNU General Public License 2921525869Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3072b676d7Smrg 3172b676d7Smrg 3274c14cd6SmrgPROGRAM=libtool 3372b676d7SmrgPACKAGE=libtool 3474fcc364SmrgVERSION="2.4.6 Debian-2.4.6-2" 3521525869Smrgpackage_revision=2.4.6 361fd23544Smrg 3721525869Smrg 3821525869Smrg## ------ ## 3921525869Smrg## Usage. ## 4021525869Smrg## ------ ## 4121525869Smrg 4221525869Smrg# Run './libtool --help' for help with using this script from the 4321525869Smrg# command line. 4421525869Smrg 4521525869Smrg 4621525869Smrg## ------------------------------- ## 4721525869Smrg## User overridable command paths. ## 4821525869Smrg## ------------------------------- ## 4921525869Smrg 5021525869Smrg# After configure completes, it has a better idea of some of the 5121525869Smrg# shell tools we need than the defaults used by the functions shared 5221525869Smrg# with bootstrap, so set those here where they can still be over- 5321525869Smrg# ridden by the user, but otherwise take precedence. 5421525869Smrg 5521525869Smrg: ${AUTOCONF="autoconf"} 5621525869Smrg: ${AUTOMAKE="automake"} 5721525869Smrg 5821525869Smrg 5921525869Smrg## -------------------------- ## 6021525869Smrg## Source external libraries. ## 6121525869Smrg## -------------------------- ## 6221525869Smrg 6321525869Smrg# Much of our low-level functionality needs to be sourced from external 6421525869Smrg# libraries, which are installed to $pkgauxdir. 6521525869Smrg 6621525869Smrg# Set a version string for this script. 6721525869Smrgscriptversion=2015-01-20.17; # UTC 6821525869Smrg 6921525869Smrg# General shell script boiler plate, and helper functions. 7021525869Smrg# Written by Gary V. Vaughan, 2004 7121525869Smrg 7221525869Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7321525869Smrg# This is free software; see the source for copying conditions. There is NO 7421525869Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7521525869Smrg 7621525869Smrg# This program is free software; you can redistribute it and/or modify 7721525869Smrg# it under the terms of the GNU General Public License as published by 7821525869Smrg# the Free Software Foundation; either version 3 of the License, or 7921525869Smrg# (at your option) any later version. 8021525869Smrg 8121525869Smrg# As a special exception to the GNU General Public License, if you distribute 8221525869Smrg# this file as part of a program or library that is built using GNU Libtool, 8321525869Smrg# you may include this file under the same distribution terms that you use 8421525869Smrg# for the rest of that program. 8521525869Smrg 8621525869Smrg# This program is distributed in the hope that it will be useful, 8721525869Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8821525869Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8921525869Smrg# General Public License for more details. 9021525869Smrg 9121525869Smrg# You should have received a copy of the GNU General Public License 9221525869Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9321525869Smrg 9421525869Smrg# Please report bugs or propose patches to gary@gnu.org. 9521525869Smrg 9621525869Smrg 9721525869Smrg## ------ ## 9821525869Smrg## Usage. ## 9921525869Smrg## ------ ## 10021525869Smrg 10121525869Smrg# Evaluate this file near the top of your script to gain access to 10221525869Smrg# the functions and variables defined here: 10321525869Smrg# 10421525869Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10521525869Smrg# 10621525869Smrg# If you need to override any of the default environment variable 10721525869Smrg# settings, do that before evaluating this file. 10821525869Smrg 10921525869Smrg 11021525869Smrg## -------------------- ## 11121525869Smrg## Shell normalisation. ## 11221525869Smrg## -------------------- ## 11321525869Smrg 11421525869Smrg# Some shells need a little help to be as Bourne compatible as possible. 11521525869Smrg# Before doing anything else, make sure all that help has been provided! 11621525869Smrg 11721525869SmrgDUALCASE=1; export DUALCASE # for MKS sh 11821525869Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1191fd23544Smrg emulate sh 1201fd23544Smrg NULLCMD=: 12121525869Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1221fd23544Smrg # is contrary to our usage. Disable this feature. 1231fd23544Smrg alias -g '${1+"$@"}'='"$@"' 12472b676d7Smrg setopt NO_GLOB_SUBST 1251fd23544Smrgelse 12621525869Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 12772b676d7Smrgfi 12874c14cd6Smrg 12921525869Smrg# NLS nuisances: We save the old values in case they are required later. 13021525869Smrg_G_user_locale= 13121525869Smrg_G_safe_locale= 13221525869Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1331fd23544Smrgdo 13421525869Smrg eval "if test set = \"\${$_G_var+set}\"; then 13521525869Smrg save_$_G_var=\$$_G_var 13621525869Smrg $_G_var=C 13721525869Smrg export $_G_var 13821525869Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13921525869Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1401fd23544Smrg fi" 1411fd23544Smrgdone 1421fd23544Smrg 14321525869Smrg# CDPATH. 14421525869Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145e35772b2Smrg 14621525869Smrg# Make sure IFS has a sensible default 14721525869Smrgsp=' ' 14821525869Smrgnl=' 14921525869Smrg' 15021525869SmrgIFS="$sp $nl" 15121525869Smrg 15221525869Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 15321525869Smrgif test "${PATH_SEPARATOR+set}" != set; then 15421525869Smrg PATH_SEPARATOR=: 15521525869Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15621525869Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15721525869Smrg PATH_SEPARATOR=';' 15821525869Smrg } 15921525869Smrgfi 160e35772b2Smrg 161e35772b2Smrg 162e35772b2Smrg 16321525869Smrg## ------------------------- ## 16421525869Smrg## Locate command utilities. ## 16521525869Smrg## ------------------------- ## 16621525869Smrg 16721525869Smrg 16821525869Smrg# func_executable_p FILE 16921525869Smrg# ---------------------- 17021525869Smrg# Check that FILE is an executable regular file. 17121525869Smrgfunc_executable_p () 17221525869Smrg{ 17321525869Smrg test -f "$1" && test -x "$1" 17421525869Smrg} 17521525869Smrg 17621525869Smrg 17721525869Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17821525869Smrg# -------------------------------------------- 17921525869Smrg# Search for either a program that responds to --version with output 18021525869Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18121525869Smrg# trying all the directories in PATH with each of the elements of 18221525869Smrg# PROGS_LIST. 18321525869Smrg# 18421525869Smrg# CHECK_FUNC should accept the path to a candidate program, and 18521525869Smrg# set $func_check_prog_result if it truncates its output less than 18621525869Smrg# $_G_path_prog_max characters. 18721525869Smrgfunc_path_progs () 18821525869Smrg{ 18921525869Smrg _G_progs_list=$1 19021525869Smrg _G_check_func=$2 19121525869Smrg _G_PATH=${3-"$PATH"} 19221525869Smrg 19321525869Smrg _G_path_prog_max=0 19421525869Smrg _G_path_prog_found=false 19521525869Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19621525869Smrg for _G_dir in $_G_PATH; do 19721525869Smrg IFS=$_G_save_IFS 19821525869Smrg test -z "$_G_dir" && _G_dir=. 19921525869Smrg for _G_prog_name in $_G_progs_list; do 20021525869Smrg for _exeext in '' .EXE; do 20121525869Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20221525869Smrg func_executable_p "$_G_path_prog" || continue 20321525869Smrg case `"$_G_path_prog" --version 2>&1` in 20421525869Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20521525869Smrg *) $_G_check_func $_G_path_prog 20621525869Smrg func_path_progs_result=$func_check_prog_result 20721525869Smrg ;; 20821525869Smrg esac 20921525869Smrg $_G_path_prog_found && break 3 21021525869Smrg done 21121525869Smrg done 21221525869Smrg done 21321525869Smrg IFS=$_G_save_IFS 21421525869Smrg test -z "$func_path_progs_result" && { 21521525869Smrg echo "no acceptable sed could be found in \$PATH" >&2 21621525869Smrg exit 1 21721525869Smrg } 21821525869Smrg} 21921525869Smrg 22021525869Smrg 22121525869Smrg# We want to be able to use the functions in this file before configure 22221525869Smrg# has figured out where the best binaries are kept, which means we have 22321525869Smrg# to search for them ourselves - except when the results are already set 22421525869Smrg# where we skip the searches. 22521525869Smrg 22621525869Smrg# Unless the user overrides by setting SED, search the path for either GNU 22721525869Smrg# sed, or the sed that truncates its output the least. 22821525869Smrgtest -z "$SED" && { 22921525869Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23021525869Smrg for _G_i in 1 2 3 4 5 6 7; do 23121525869Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23221525869Smrg done 23321525869Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23421525869Smrg _G_sed_script= 23521525869Smrg 23621525869Smrg func_check_prog_sed () 23721525869Smrg { 23821525869Smrg _G_path_prog=$1 23921525869Smrg 24021525869Smrg _G_count=0 24121525869Smrg printf 0123456789 >conftest.in 24221525869Smrg while : 24321525869Smrg do 24421525869Smrg cat conftest.in conftest.in >conftest.tmp 24521525869Smrg mv conftest.tmp conftest.in 24621525869Smrg cp conftest.in conftest.nl 24721525869Smrg echo '' >> conftest.nl 24821525869Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24921525869Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25021525869Smrg _G_count=`expr $_G_count + 1` 25121525869Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25221525869Smrg # Best one so far, save it but keep looking for a better one 25321525869Smrg func_check_prog_result=$_G_path_prog 25421525869Smrg _G_path_prog_max=$_G_count 25521525869Smrg fi 25621525869Smrg # 10*(2^10) chars as input seems more than enough 25721525869Smrg test 10 -lt "$_G_count" && break 25821525869Smrg done 25921525869Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26021525869Smrg } 26121525869Smrg 26221525869Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26321525869Smrg rm -f conftest.sed 26421525869Smrg SED=$func_path_progs_result 26521525869Smrg} 26621525869Smrg 26721525869Smrg 26821525869Smrg# Unless the user overrides by setting GREP, search the path for either GNU 26921525869Smrg# grep, or the grep that truncates its output the least. 27021525869Smrgtest -z "$GREP" && { 27121525869Smrg func_check_prog_grep () 27221525869Smrg { 27321525869Smrg _G_path_prog=$1 27421525869Smrg 27521525869Smrg _G_count=0 27621525869Smrg _G_path_prog_max=0 27721525869Smrg printf 0123456789 >conftest.in 27821525869Smrg while : 27921525869Smrg do 28021525869Smrg cat conftest.in conftest.in >conftest.tmp 28121525869Smrg mv conftest.tmp conftest.in 28221525869Smrg cp conftest.in conftest.nl 28321525869Smrg echo 'GREP' >> conftest.nl 28421525869Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28521525869Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28621525869Smrg _G_count=`expr $_G_count + 1` 28721525869Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28821525869Smrg # Best one so far, save it but keep looking for a better one 28921525869Smrg func_check_prog_result=$_G_path_prog 29021525869Smrg _G_path_prog_max=$_G_count 29121525869Smrg fi 29221525869Smrg # 10*(2^10) chars as input seems more than enough 29321525869Smrg test 10 -lt "$_G_count" && break 29421525869Smrg done 29521525869Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29621525869Smrg } 29721525869Smrg 29821525869Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29921525869Smrg GREP=$func_path_progs_result 30021525869Smrg} 30121525869Smrg 30221525869Smrg 30321525869Smrg## ------------------------------- ## 30421525869Smrg## User overridable command paths. ## 30521525869Smrg## ------------------------------- ## 30621525869Smrg 30721525869Smrg# All uppercase variable names are used for environment variables. These 30821525869Smrg# variables can be overridden by the user before calling a script that 30921525869Smrg# uses them if a suitable command of that name is not already available 31021525869Smrg# in the command search PATH. 311e35772b2Smrg 312e35772b2Smrg: ${CP="cp -f"} 31321525869Smrg: ${ECHO="printf %s\n"} 31421525869Smrg: ${EGREP="$GREP -E"} 31521525869Smrg: ${FGREP="$GREP -F"} 31621525869Smrg: ${LN_S="ln -s"} 317e35772b2Smrg: ${MAKE="make"} 318e35772b2Smrg: ${MKDIR="mkdir"} 319e35772b2Smrg: ${MV="mv -f"} 320e35772b2Smrg: ${RM="rm -f"} 321e35772b2Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 32272b676d7Smrg 323e35772b2Smrg 32421525869Smrg## -------------------- ## 32521525869Smrg## Useful sed snippets. ## 32621525869Smrg## -------------------- ## 32774c14cd6Smrg 32821525869Smrgsed_dirname='s|/[^/]*$||' 32921525869Smrgsed_basename='s|^.*/||' 33074c14cd6Smrg 33121525869Smrg# Sed substitution that helps us do robust quoting. It backslashifies 33221525869Smrg# metacharacters that are still active within double-quoted strings. 33321525869Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 33474c14cd6Smrg 33521525869Smrg# Same as above, but do not quote variable references. 33621525869Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 33774c14cd6Smrg 33821525869Smrg# Sed substitution that turns a string into a regex matching for the 33921525869Smrg# string literally. 34021525869Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 34174c14cd6Smrg 34221525869Smrg# Sed substitution that converts a w32 file name or path 34321525869Smrg# that contains forward slashes, into one that contains 34421525869Smrg# (escaped) backslashes. A very naive implementation. 34521525869Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34621525869Smrg 34721525869Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34821525869Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34921525869Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35021525869Smrg# expansion. Since each input '\' is now two '\'s, look for any number 35121525869Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35221525869Smrg_G_bs='\\' 35321525869Smrg_G_bs2='\\\\' 35421525869Smrg_G_bs4='\\\\\\\\' 35521525869Smrg_G_dollar='\$' 35621525869Smrgsed_double_backslash="\ 35721525869Smrg s/$_G_bs4/&\\ 35821525869Smrg/g 35921525869Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36021525869Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36121525869Smrg s/\n//g" 36274c14cd6Smrg 36374c14cd6Smrg 36421525869Smrg## ----------------- ## 36521525869Smrg## Global variables. ## 36621525869Smrg## ----------------- ## 36774c14cd6Smrg 36821525869Smrg# Except for the global variables explicitly listed below, the following 36921525869Smrg# functions in the '^func_' namespace, and the '^require_' namespace 37021525869Smrg# variables initialised in the 'Resource management' section, sourcing 37121525869Smrg# this file will not pollute your global namespace with anything 37221525869Smrg# else. There's no portable way to scope variables in Bourne shell 37321525869Smrg# though, so actually running these functions will sometimes place 37421525869Smrg# results into a variable named after the function, and often use 37521525869Smrg# temporary variables in the '^_G_' namespace. If you are careful to 37621525869Smrg# avoid using those namespaces casually in your sourcing script, things 37721525869Smrg# should continue to work as you expect. And, of course, you can freely 37821525869Smrg# overwrite any of the functions or variables defined here before 37921525869Smrg# calling anything to customize them. 38074c14cd6Smrg 38121525869SmrgEXIT_SUCCESS=0 38221525869SmrgEXIT_FAILURE=1 38321525869SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38421525869SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38572b676d7Smrg 38621525869Smrg# Allow overriding, eg assuming that you follow the convention of 38721525869Smrg# putting '$debug_cmd' at the start of all your functions, you can get 38821525869Smrg# bash to show function call trace with: 38921525869Smrg# 39021525869Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39121525869Smrgdebug_cmd=${debug_cmd-":"} 39221525869Smrgexit_cmd=: 393e35772b2Smrg 39421525869Smrg# By convention, finish your script with: 39521525869Smrg# 39621525869Smrg# exit $exit_status 39721525869Smrg# 39821525869Smrg# so that you can set exit_status to non-zero if you want to indicate 39921525869Smrg# something went wrong during execution without actually bailing out at 40021525869Smrg# the point of failure. 40121525869Smrgexit_status=$EXIT_SUCCESS 40274c14cd6Smrg 40321525869Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40421525869Smrg# is ksh but when the shell is invoked as "sh" and the current value of 40521525869Smrg# the _XPG environment variable is not equal to 1 (one), the special 40621525869Smrg# positional parameter $0, within a function call, is the name of the 40721525869Smrg# function. 40821525869Smrgprogpath=$0 409e35772b2Smrg 41021525869Smrg# The name of this program. 41121525869Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412e35772b2Smrg 41321525869Smrg# Make sure we have an absolute progpath for reexecution: 414e35772b2Smrgcase $progpath in 415e35772b2Smrg [\\/]*|[A-Za-z]:\\*) ;; 416e35772b2Smrg *[\\/]*) 41721525869Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418e35772b2Smrg progdir=`cd "$progdir" && pwd` 41921525869Smrg progpath=$progdir/$progname 420e35772b2Smrg ;; 421e35772b2Smrg *) 42221525869Smrg _G_IFS=$IFS 42374c14cd6Smrg IFS=${PATH_SEPARATOR-:} 424e35772b2Smrg for progdir in $PATH; do 42521525869Smrg IFS=$_G_IFS 426e35772b2Smrg test -x "$progdir/$progname" && break 427e35772b2Smrg done 42821525869Smrg IFS=$_G_IFS 429e35772b2Smrg test -n "$progdir" || progdir=`pwd` 43021525869Smrg progpath=$progdir/$progname 431e35772b2Smrg ;; 432e35772b2Smrgesac 433e35772b2Smrg 434e35772b2Smrg 43521525869Smrg## ----------------- ## 43621525869Smrg## Standard options. ## 43721525869Smrg## ----------------- ## 43874c14cd6Smrg 43921525869Smrg# The following options affect the operation of the functions defined 44021525869Smrg# below, and should be set appropriately depending on run-time para- 44121525869Smrg# meters passed on the command line. 442e35772b2Smrg 443e35772b2Smrgopt_dry_run=false 444e35772b2Smrgopt_quiet=false 445e35772b2Smrgopt_verbose=false 446e35772b2Smrg 44721525869Smrg# Categories 'all' and 'none' are always available. Append any others 44821525869Smrg# you will pass as the first argument to func_warning from your own 44921525869Smrg# code. 45021525869Smrgwarning_categories= 451e35772b2Smrg 45221525869Smrg# By default, display warnings according to 'opt_warning_types'. Set 45321525869Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45421525869Smrg# treat the next displayed warning as a fatal error. 45521525869Smrgwarning_func=func_warn_and_continue 456e35772b2Smrg 45721525869Smrg# Set to 'all' to display all warnings, 'none' to suppress all 45821525869Smrg# warnings, or a space delimited list of some subset of 45921525869Smrg# 'warning_categories' to display only the listed warnings. 46021525869Smrgopt_warning_types=all 461e35772b2Smrg 46274c14cd6Smrg 46321525869Smrg## -------------------- ## 46421525869Smrg## Resource management. ## 46521525869Smrg## -------------------- ## 466e35772b2Smrg 46721525869Smrg# This section contains definitions for functions that each ensure a 46821525869Smrg# particular resource (a file, or a non-empty configuration variable for 46921525869Smrg# example) is available, and if appropriate to extract default values 47021525869Smrg# from pertinent package files. Call them using their associated 47121525869Smrg# 'require_*' variable to ensure that they are executed, at most, once. 47221525869Smrg# 47321525869Smrg# It's entirely deliberate that calling these functions can set 47421525869Smrg# variables that don't obey the namespace limitations obeyed by the rest 47521525869Smrg# of this file, in order that that they be as useful as possible to 47621525869Smrg# callers. 477e35772b2Smrg 478e35772b2Smrg 47921525869Smrg# require_term_colors 48021525869Smrg# ------------------- 48121525869Smrg# Allow display of bold text on terminals that support it. 48221525869Smrgrequire_term_colors=func_require_term_colors 48321525869Smrgfunc_require_term_colors () 484e35772b2Smrg{ 48521525869Smrg $debug_cmd 48621525869Smrg 48721525869Smrg test -t 1 && { 48821525869Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 48921525869Smrg # precedence, because most terminfo databases neglect to describe 49021525869Smrg # whether color sequences are supported. 49121525869Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49221525869Smrg 49321525869Smrg if test 1 = "$USE_ANSI_COLORS"; then 49421525869Smrg # Standard ANSI escape sequences 49521525869Smrg tc_reset='[0m' 49621525869Smrg tc_bold='[1m'; tc_standout='[7m' 49721525869Smrg tc_red='[31m'; tc_green='[32m' 49821525869Smrg tc_blue='[34m'; tc_cyan='[36m' 49921525869Smrg else 50021525869Smrg # Otherwise trust the terminfo database after all. 50121525869Smrg test -n "`tput sgr0 2>/dev/null`" && { 50221525869Smrg tc_reset=`tput sgr0` 50321525869Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50421525869Smrg tc_standout=$tc_bold 50521525869Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50621525869Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50721525869Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50821525869Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50921525869Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51021525869Smrg } 51121525869Smrg fi 51221525869Smrg } 513e35772b2Smrg 51421525869Smrg require_term_colors=: 515e35772b2Smrg} 516e35772b2Smrg 517e35772b2Smrg 51821525869Smrg## ----------------- ## 51921525869Smrg## Function library. ## 52021525869Smrg## ----------------- ## 52121525869Smrg 52221525869Smrg# This section contains a variety of useful functions to call in your 52321525869Smrg# scripts. Take note of the portable wrappers for features provided by 52421525869Smrg# some modern shells, which will fall back to slower equivalents on 52521525869Smrg# less featureful shells. 52621525869Smrg 52721525869Smrg 52821525869Smrg# func_append VAR VALUE 52921525869Smrg# --------------------- 53021525869Smrg# Append VALUE onto the existing contents of VAR. 53121525869Smrg 53221525869Smrg # We should try to minimise forks, especially on Windows where they are 53321525869Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 53421525869Smrg # being used: 53521525869Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53621525869Smrg : ${_G_HAVE_ARITH_OP="yes"} 53721525869Smrg : ${_G_HAVE_XSI_OPS="yes"} 53821525869Smrg # The += operator was introduced in bash 3.1 53921525869Smrg case $BASH_VERSION in 54021525869Smrg [12].* | 3.0 | 3.0*) ;; 54121525869Smrg *) 54221525869Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54321525869Smrg ;; 54421525869Smrg esac 54521525869Smrg fi 54621525869Smrg 54721525869Smrg # _G_HAVE_PLUSEQ_OP 54821525869Smrg # Can be empty, in which case the shell is probed, "yes" if += is 54921525869Smrg # useable or anything else if it does not work. 55021525869Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55121525869Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55221525869Smrg && _G_HAVE_PLUSEQ_OP=yes 55321525869Smrg 55421525869Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55521525869Smrgthen 55621525869Smrg # This is an XSI compatible shell, allowing a faster implementation... 55721525869Smrg eval 'func_append () 55821525869Smrg { 55921525869Smrg $debug_cmd 56021525869Smrg 56121525869Smrg eval "$1+=\$2" 56221525869Smrg }' 56321525869Smrgelse 56421525869Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 56521525869Smrg func_append () 56621525869Smrg { 56721525869Smrg $debug_cmd 56821525869Smrg 56921525869Smrg eval "$1=\$$1\$2" 57021525869Smrg } 57121525869Smrgfi 57221525869Smrg 57321525869Smrg 57421525869Smrg# func_append_quoted VAR VALUE 57521525869Smrg# ---------------------------- 57621525869Smrg# Quote VALUE and append to the end of shell variable VAR, separated 57721525869Smrg# by a space. 57821525869Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57921525869Smrg eval 'func_append_quoted () 58021525869Smrg { 58121525869Smrg $debug_cmd 58221525869Smrg 58321525869Smrg func_quote_for_eval "$2" 58421525869Smrg eval "$1+=\\ \$func_quote_for_eval_result" 58521525869Smrg }' 58621525869Smrgelse 58721525869Smrg func_append_quoted () 58821525869Smrg { 58921525869Smrg $debug_cmd 59021525869Smrg 59121525869Smrg func_quote_for_eval "$2" 59221525869Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59321525869Smrg } 59421525869Smrgfi 59521525869Smrg 59621525869Smrg 59721525869Smrg# func_append_uniq VAR VALUE 59821525869Smrg# -------------------------- 59921525869Smrg# Append unique VALUE onto the existing contents of VAR, assuming 60021525869Smrg# entries are delimited by the first character of VALUE. For example: 60121525869Smrg# 60221525869Smrg# func_append_uniq options " --another-option option-argument" 60321525869Smrg# 60421525869Smrg# will only append to $options if " --another-option option-argument " 60521525869Smrg# is not already present somewhere in $options already (note spaces at 60621525869Smrg# each end implied by leading space in second argument). 60721525869Smrgfunc_append_uniq () 60821525869Smrg{ 60921525869Smrg $debug_cmd 61021525869Smrg 61121525869Smrg eval _G_current_value='`$ECHO $'$1'`' 61221525869Smrg _G_delim=`expr "$2" : '\(.\)'` 61321525869Smrg 61421525869Smrg case $_G_delim$_G_current_value$_G_delim in 61521525869Smrg *"$2$_G_delim"*) ;; 61621525869Smrg *) func_append "$@" ;; 61721525869Smrg esac 61821525869Smrg} 61921525869Smrg 62021525869Smrg 62121525869Smrg# func_arith TERM... 62221525869Smrg# ------------------ 62321525869Smrg# Set func_arith_result to the result of evaluating TERMs. 62421525869Smrg test -z "$_G_HAVE_ARITH_OP" \ 62521525869Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62621525869Smrg && _G_HAVE_ARITH_OP=yes 62721525869Smrg 62821525869Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 62921525869Smrg eval 'func_arith () 63021525869Smrg { 63121525869Smrg $debug_cmd 63221525869Smrg 63321525869Smrg func_arith_result=$(( $* )) 63421525869Smrg }' 63521525869Smrgelse 63621525869Smrg func_arith () 63721525869Smrg { 63821525869Smrg $debug_cmd 63921525869Smrg 64021525869Smrg func_arith_result=`expr "$@"` 64121525869Smrg } 64221525869Smrgfi 64321525869Smrg 64421525869Smrg 64521525869Smrg# func_basename FILE 64621525869Smrg# ------------------ 64721525869Smrg# Set func_basename_result to FILE with everything up to and including 64821525869Smrg# the last / stripped. 64921525869Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 65021525869Smrg # If this shell supports suffix pattern removal, then use it to avoid 65121525869Smrg # forking. Hide the definitions single quotes in case the shell chokes 65221525869Smrg # on unsupported syntax... 65321525869Smrg _b='func_basename_result=${1##*/}' 65421525869Smrg _d='case $1 in 65521525869Smrg */*) func_dirname_result=${1%/*}$2 ;; 65621525869Smrg * ) func_dirname_result=$3 ;; 65721525869Smrg esac' 65821525869Smrg 65921525869Smrgelse 66021525869Smrg # ...otherwise fall back to using sed. 66121525869Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66221525869Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66321525869Smrg if test "X$func_dirname_result" = "X$1"; then 66421525869Smrg func_dirname_result=$3 66521525869Smrg else 66621525869Smrg func_append func_dirname_result "$2" 66721525869Smrg fi' 66821525869Smrgfi 66921525869Smrg 67021525869Smrgeval 'func_basename () 67121525869Smrg{ 67221525869Smrg $debug_cmd 67321525869Smrg 67421525869Smrg '"$_b"' 67521525869Smrg}' 67621525869Smrg 67721525869Smrg 67821525869Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67921525869Smrg# ------------------------------------------- 68021525869Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68121525869Smrg# otherwise set result to NONDIR_REPLACEMENT. 68221525869Smrgeval 'func_dirname () 68321525869Smrg{ 68421525869Smrg $debug_cmd 68521525869Smrg 68621525869Smrg '"$_d"' 68721525869Smrg}' 68821525869Smrg 68921525869Smrg 69021525869Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69121525869Smrg# -------------------------------------------------------- 69221525869Smrg# Perform func_basename and func_dirname in a single function 69321525869Smrg# call: 69421525869Smrg# dirname: Compute the dirname of FILE. If nonempty, 69521525869Smrg# add APPEND to the result, otherwise set result 69621525869Smrg# to NONDIR_REPLACEMENT. 69721525869Smrg# value returned in "$func_dirname_result" 69821525869Smrg# basename: Compute filename of FILE. 69921525869Smrg# value retuned in "$func_basename_result" 70021525869Smrg# For efficiency, we do not delegate to the functions above but instead 70121525869Smrg# duplicate the functionality here. 70221525869Smrgeval 'func_dirname_and_basename () 70321525869Smrg{ 70421525869Smrg $debug_cmd 70521525869Smrg 70621525869Smrg '"$_b"' 70721525869Smrg '"$_d"' 70821525869Smrg}' 70921525869Smrg 71021525869Smrg 71121525869Smrg# func_echo ARG... 71221525869Smrg# ---------------- 71321525869Smrg# Echo program name prefixed message. 71421525869Smrgfunc_echo () 71521525869Smrg{ 71621525869Smrg $debug_cmd 71721525869Smrg 71821525869Smrg _G_message=$* 71921525869Smrg 72021525869Smrg func_echo_IFS=$IFS 72121525869Smrg IFS=$nl 72221525869Smrg for _G_line in $_G_message; do 72321525869Smrg IFS=$func_echo_IFS 72421525869Smrg $ECHO "$progname: $_G_line" 72521525869Smrg done 72621525869Smrg IFS=$func_echo_IFS 72721525869Smrg} 72821525869Smrg 72921525869Smrg 73021525869Smrg# func_echo_all ARG... 73121525869Smrg# -------------------- 73221525869Smrg# Invoke $ECHO with all args, space-separated. 73321525869Smrgfunc_echo_all () 73421525869Smrg{ 73521525869Smrg $ECHO "$*" 73621525869Smrg} 73721525869Smrg 73821525869Smrg 73921525869Smrg# func_echo_infix_1 INFIX ARG... 74021525869Smrg# ------------------------------ 74121525869Smrg# Echo program name, followed by INFIX on the first line, with any 74221525869Smrg# additional lines not showing INFIX. 74321525869Smrgfunc_echo_infix_1 () 74421525869Smrg{ 74521525869Smrg $debug_cmd 74621525869Smrg 74721525869Smrg $require_term_colors 74821525869Smrg 74921525869Smrg _G_infix=$1; shift 75021525869Smrg _G_indent=$_G_infix 75121525869Smrg _G_prefix="$progname: $_G_infix: " 75221525869Smrg _G_message=$* 75321525869Smrg 75421525869Smrg # Strip color escape sequences before counting printable length 75521525869Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75621525869Smrg do 75721525869Smrg test -n "$_G_tc" && { 75821525869Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75921525869Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76021525869Smrg } 76121525869Smrg done 76221525869Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76321525869Smrg 76421525869Smrg func_echo_infix_1_IFS=$IFS 76521525869Smrg IFS=$nl 76621525869Smrg for _G_line in $_G_message; do 76721525869Smrg IFS=$func_echo_infix_1_IFS 76821525869Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76921525869Smrg _G_prefix=$_G_indent 77021525869Smrg done 77121525869Smrg IFS=$func_echo_infix_1_IFS 77221525869Smrg} 77321525869Smrg 77421525869Smrg 77521525869Smrg# func_error ARG... 77621525869Smrg# ----------------- 77721525869Smrg# Echo program name prefixed message to standard error. 77821525869Smrgfunc_error () 77921525869Smrg{ 78021525869Smrg $debug_cmd 78121525869Smrg 78221525869Smrg $require_term_colors 78321525869Smrg 78421525869Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78521525869Smrg} 78621525869Smrg 78721525869Smrg 78821525869Smrg# func_fatal_error ARG... 78921525869Smrg# ----------------------- 79021525869Smrg# Echo program name prefixed message to standard error, and exit. 79121525869Smrgfunc_fatal_error () 79221525869Smrg{ 79321525869Smrg $debug_cmd 79421525869Smrg 79521525869Smrg func_error "$*" 79621525869Smrg exit $EXIT_FAILURE 79721525869Smrg} 79821525869Smrg 79921525869Smrg 80021525869Smrg# func_grep EXPRESSION FILENAME 80121525869Smrg# ----------------------------- 802e35772b2Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803e35772b2Smrgfunc_grep () 804e35772b2Smrg{ 80521525869Smrg $debug_cmd 80621525869Smrg 807e35772b2Smrg $GREP "$1" "$2" >/dev/null 2>&1 808e35772b2Smrg} 809e35772b2Smrg 810e35772b2Smrg 81121525869Smrg# func_len STRING 81221525869Smrg# --------------- 81321525869Smrg# Set func_len_result to the length of STRING. STRING may not 81421525869Smrg# start with a hyphen. 81521525869Smrg test -z "$_G_HAVE_XSI_OPS" \ 81621525869Smrg && (eval 'x=a/b/c; 81721525869Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81821525869Smrg && _G_HAVE_XSI_OPS=yes 81921525869Smrg 82021525869Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 82121525869Smrg eval 'func_len () 82221525869Smrg { 82321525869Smrg $debug_cmd 82421525869Smrg 82521525869Smrg func_len_result=${#1} 82621525869Smrg }' 82721525869Smrgelse 82821525869Smrg func_len () 82921525869Smrg { 83021525869Smrg $debug_cmd 83121525869Smrg 83221525869Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83321525869Smrg } 83421525869Smrgfi 83521525869Smrg 83621525869Smrg 83721525869Smrg# func_mkdir_p DIRECTORY-PATH 83821525869Smrg# --------------------------- 839e35772b2Smrg# Make sure the entire path to DIRECTORY-PATH is available. 840e35772b2Smrgfunc_mkdir_p () 841e35772b2Smrg{ 84221525869Smrg $debug_cmd 843e35772b2Smrg 84421525869Smrg _G_directory_path=$1 84521525869Smrg _G_dir_list= 846e35772b2Smrg 84721525869Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84821525869Smrg 84921525869Smrg # Protect directory names starting with '-' 85021525869Smrg case $_G_directory_path in 85121525869Smrg -*) _G_directory_path=./$_G_directory_path ;; 852e35772b2Smrg esac 853e35772b2Smrg 854e35772b2Smrg # While some portion of DIR does not yet exist... 85521525869Smrg while test ! -d "$_G_directory_path"; do 856e35772b2Smrg # ...make a list in topmost first order. Use a colon delimited 857e35772b2Smrg # list incase some portion of path contains whitespace. 85821525869Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 859e35772b2Smrg 860e35772b2Smrg # If the last portion added has no slash in it, the list is done 86121525869Smrg case $_G_directory_path in */*) ;; *) break ;; esac 862e35772b2Smrg 863e35772b2Smrg # ...otherwise throw away the child directory and loop 86421525869Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865e35772b2Smrg done 86621525869Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867e35772b2Smrg 86821525869Smrg func_mkdir_p_IFS=$IFS; IFS=: 86921525869Smrg for _G_dir in $_G_dir_list; do 87021525869Smrg IFS=$func_mkdir_p_IFS 87121525869Smrg # mkdir can fail with a 'File exist' error if two processes 872e35772b2Smrg # try to create one of the directories concurrently. Don't 873e35772b2Smrg # stop in that case! 87421525869Smrg $MKDIR "$_G_dir" 2>/dev/null || : 875e35772b2Smrg done 87621525869Smrg IFS=$func_mkdir_p_IFS 877e35772b2Smrg 878e35772b2Smrg # Bail out if we (or some other process) failed to create a directory. 87921525869Smrg test -d "$_G_directory_path" || \ 88021525869Smrg func_fatal_error "Failed to create '$1'" 881e35772b2Smrg fi 882e35772b2Smrg} 88372b676d7Smrg 88472b676d7Smrg 88521525869Smrg# func_mktempdir [BASENAME] 88621525869Smrg# ------------------------- 88772b676d7Smrg# Make a temporary directory that won't clash with other running 88872b676d7Smrg# libtool processes, and avoids race conditions if possible. If 88921525869Smrg# given, BASENAME is the basename for that directory. 89072b676d7Smrgfunc_mktempdir () 89172b676d7Smrg{ 89221525869Smrg $debug_cmd 89321525869Smrg 89421525869Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 89572b676d7Smrg 89621525869Smrg if test : = "$opt_dry_run"; then 89772b676d7Smrg # Return a directory name, but don't create it in dry-run mode 89821525869Smrg _G_tmpdir=$_G_template-$$ 89972b676d7Smrg else 90072b676d7Smrg 90172b676d7Smrg # If mktemp works, use that first and foremost 90221525869Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 90372b676d7Smrg 90421525869Smrg if test ! -d "$_G_tmpdir"; then 905e35772b2Smrg # Failing that, at least try and use $RANDOM to avoid a race 90621525869Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 90772b676d7Smrg 90821525869Smrg func_mktempdir_umask=`umask` 909e35772b2Smrg umask 0077 91021525869Smrg $MKDIR "$_G_tmpdir" 91121525869Smrg umask $func_mktempdir_umask 91272b676d7Smrg fi 91372b676d7Smrg 91472b676d7Smrg # If we're not in dry-run mode, bomb out on failure 91521525869Smrg test -d "$_G_tmpdir" || \ 91621525869Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91721525869Smrg fi 91821525869Smrg 91921525869Smrg $ECHO "$_G_tmpdir" 92021525869Smrg} 92121525869Smrg 92221525869Smrg 92321525869Smrg# func_normal_abspath PATH 92421525869Smrg# ------------------------ 92521525869Smrg# Remove doubled-up and trailing slashes, "." path components, 92621525869Smrg# and cancel out any ".." path components in PATH after making 92721525869Smrg# it an absolute path. 92821525869Smrgfunc_normal_abspath () 92921525869Smrg{ 93021525869Smrg $debug_cmd 93121525869Smrg 93221525869Smrg # These SED scripts presuppose an absolute path with a trailing slash. 93321525869Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93421525869Smrg _G_pathcdr='s|^/[^/]*||' 93521525869Smrg _G_removedotparts=':dotsl 93621525869Smrg s|/\./|/|g 93721525869Smrg t dotsl 93821525869Smrg s|/\.$|/|' 93921525869Smrg _G_collapseslashes='s|/\{1,\}|/|g' 94021525869Smrg _G_finalslash='s|/*$|/|' 94121525869Smrg 94221525869Smrg # Start from root dir and reassemble the path. 94321525869Smrg func_normal_abspath_result= 94421525869Smrg func_normal_abspath_tpath=$1 94521525869Smrg func_normal_abspath_altnamespace= 94621525869Smrg case $func_normal_abspath_tpath in 94721525869Smrg "") 94821525869Smrg # Empty path, that just means $cwd. 94921525869Smrg func_stripname '' '/' "`pwd`" 95021525869Smrg func_normal_abspath_result=$func_stripname_result 95121525869Smrg return 95221525869Smrg ;; 95321525869Smrg # The next three entries are used to spot a run of precisely 95421525869Smrg # two leading slashes without using negated character classes; 95521525869Smrg # we take advantage of case's first-match behaviour. 95621525869Smrg ///*) 95721525869Smrg # Unusual form of absolute path, do nothing. 95821525869Smrg ;; 95921525869Smrg //*) 96021525869Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96121525869Smrg # and for example Cygwin uses it to access remote file shares 96221525869Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 96321525869Smrg func_normal_abspath_altnamespace=/ 96421525869Smrg ;; 96521525869Smrg /*) 96621525869Smrg # Absolute path, do nothing. 96721525869Smrg ;; 96821525869Smrg *) 96921525869Smrg # Relative path, prepend $cwd. 97021525869Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97121525869Smrg ;; 97221525869Smrg esac 97321525869Smrg 97421525869Smrg # Cancel out all the simple stuff to save iterations. We also want 97521525869Smrg # the path to end with a slash for ease of parsing, so make sure 97621525869Smrg # there is one (and only one) here. 97721525869Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97821525869Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97921525869Smrg while :; do 98021525869Smrg # Processed it all yet? 98121525869Smrg if test / = "$func_normal_abspath_tpath"; then 98221525869Smrg # If we ascended to the root using ".." the result may be empty now. 98321525869Smrg if test -z "$func_normal_abspath_result"; then 98421525869Smrg func_normal_abspath_result=/ 98521525869Smrg fi 98621525869Smrg break 98721525869Smrg fi 98821525869Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98921525869Smrg -e "$_G_pathcar"` 99021525869Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99121525869Smrg -e "$_G_pathcdr"` 99221525869Smrg # Figure out what to do with it 99321525869Smrg case $func_normal_abspath_tcomponent in 99421525869Smrg "") 99521525869Smrg # Trailing empty path component, ignore it. 99621525869Smrg ;; 99721525869Smrg ..) 99821525869Smrg # Parent dir; strip last assembled component from result. 99921525869Smrg func_dirname "$func_normal_abspath_result" 100021525869Smrg func_normal_abspath_result=$func_dirname_result 100121525869Smrg ;; 100221525869Smrg *) 100321525869Smrg # Actual path component, append it. 100421525869Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100521525869Smrg ;; 100621525869Smrg esac 100721525869Smrg done 100821525869Smrg # Restore leading double-slash if one was found on entry. 100921525869Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101021525869Smrg} 101121525869Smrg 101221525869Smrg 101321525869Smrg# func_notquiet ARG... 101421525869Smrg# -------------------- 101521525869Smrg# Echo program name prefixed message only when not in quiet mode. 101621525869Smrgfunc_notquiet () 101721525869Smrg{ 101821525869Smrg $debug_cmd 101921525869Smrg 102021525869Smrg $opt_quiet || func_echo ${1+"$@"} 102121525869Smrg 102221525869Smrg # A bug in bash halts the script if the last line of a function 102321525869Smrg # fails when set -e is in force, so we need another command to 102421525869Smrg # work around that: 102521525869Smrg : 102621525869Smrg} 102721525869Smrg 102821525869Smrg 102921525869Smrg# func_relative_path SRCDIR DSTDIR 103021525869Smrg# -------------------------------- 103121525869Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103221525869Smrgfunc_relative_path () 103321525869Smrg{ 103421525869Smrg $debug_cmd 103521525869Smrg 103621525869Smrg func_relative_path_result= 103721525869Smrg func_normal_abspath "$1" 103821525869Smrg func_relative_path_tlibdir=$func_normal_abspath_result 103921525869Smrg func_normal_abspath "$2" 104021525869Smrg func_relative_path_tbindir=$func_normal_abspath_result 104121525869Smrg 104221525869Smrg # Ascend the tree starting from libdir 104321525869Smrg while :; do 104421525869Smrg # check if we have found a prefix of bindir 104521525869Smrg case $func_relative_path_tbindir in 104621525869Smrg $func_relative_path_tlibdir) 104721525869Smrg # found an exact match 104821525869Smrg func_relative_path_tcancelled= 104921525869Smrg break 105021525869Smrg ;; 105121525869Smrg $func_relative_path_tlibdir*) 105221525869Smrg # found a matching prefix 105321525869Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105421525869Smrg func_relative_path_tcancelled=$func_stripname_result 105521525869Smrg if test -z "$func_relative_path_result"; then 105621525869Smrg func_relative_path_result=. 105721525869Smrg fi 105821525869Smrg break 105921525869Smrg ;; 106021525869Smrg *) 106121525869Smrg func_dirname $func_relative_path_tlibdir 106221525869Smrg func_relative_path_tlibdir=$func_dirname_result 106321525869Smrg if test -z "$func_relative_path_tlibdir"; then 106421525869Smrg # Have to descend all the way to the root! 106521525869Smrg func_relative_path_result=../$func_relative_path_result 106621525869Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 106721525869Smrg break 106821525869Smrg fi 106921525869Smrg func_relative_path_result=../$func_relative_path_result 107021525869Smrg ;; 107121525869Smrg esac 107221525869Smrg done 107321525869Smrg 107421525869Smrg # Now calculate path; take care to avoid doubling-up slashes. 107521525869Smrg func_stripname '' '/' "$func_relative_path_result" 107621525869Smrg func_relative_path_result=$func_stripname_result 107721525869Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107821525869Smrg if test -n "$func_stripname_result"; then 107921525869Smrg func_append func_relative_path_result "/$func_stripname_result" 108021525869Smrg fi 108121525869Smrg 108221525869Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 108321525869Smrg if test -n "$func_relative_path_result"; then 108421525869Smrg func_stripname './' '' "$func_relative_path_result" 108521525869Smrg func_relative_path_result=$func_stripname_result 108672b676d7Smrg fi 108772b676d7Smrg 108821525869Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 108921525869Smrg 109021525869Smrg : 109121525869Smrg} 109221525869Smrg 109321525869Smrg 109421525869Smrg# func_quote_for_eval ARG... 109521525869Smrg# -------------------------- 109621525869Smrg# Aesthetically quote ARGs to be evaled later. 109721525869Smrg# This function returns two values: 109821525869Smrg# i) func_quote_for_eval_result 109921525869Smrg# double-quoted, suitable for a subsequent eval 110021525869Smrg# ii) func_quote_for_eval_unquoted_result 110121525869Smrg# has all characters that are still active within double 110221525869Smrg# quotes backslashified. 110321525869Smrgfunc_quote_for_eval () 110421525869Smrg{ 110521525869Smrg $debug_cmd 110621525869Smrg 110721525869Smrg func_quote_for_eval_unquoted_result= 110821525869Smrg func_quote_for_eval_result= 110921525869Smrg while test 0 -lt $#; do 111021525869Smrg case $1 in 111121525869Smrg *[\\\`\"\$]*) 111221525869Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111321525869Smrg *) 111421525869Smrg _G_unquoted_arg=$1 ;; 111521525869Smrg esac 111621525869Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 111721525869Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111821525869Smrg else 111921525869Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112021525869Smrg fi 112121525869Smrg 112221525869Smrg case $_G_unquoted_arg in 112321525869Smrg # Double-quote args containing shell metacharacters to delay 112421525869Smrg # word splitting, command substitution and variable expansion 112521525869Smrg # for a subsequent eval. 112621525869Smrg # Many Bourne shells cannot handle close brackets correctly 112721525869Smrg # in scan sets, so we specify it separately. 112821525869Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112921525869Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 113021525869Smrg ;; 113121525869Smrg *) 113221525869Smrg _G_quoted_arg=$_G_unquoted_arg 113321525869Smrg ;; 113421525869Smrg esac 113521525869Smrg 113621525869Smrg if test -n "$func_quote_for_eval_result"; then 113721525869Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113821525869Smrg else 113921525869Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114021525869Smrg fi 114121525869Smrg shift 114221525869Smrg done 114321525869Smrg} 114421525869Smrg 114521525869Smrg 114621525869Smrg# func_quote_for_expand ARG 114721525869Smrg# ------------------------- 114821525869Smrg# Aesthetically quote ARG to be evaled later; same as above, 114921525869Smrg# but do not quote variable references. 115021525869Smrgfunc_quote_for_expand () 115121525869Smrg{ 115221525869Smrg $debug_cmd 115321525869Smrg 115421525869Smrg case $1 in 115521525869Smrg *[\\\`\"]*) 115621525869Smrg _G_arg=`$ECHO "$1" | $SED \ 115721525869Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115821525869Smrg *) 115921525869Smrg _G_arg=$1 ;; 116021525869Smrg esac 116121525869Smrg 116221525869Smrg case $_G_arg in 116321525869Smrg # Double-quote args containing shell metacharacters to delay 116421525869Smrg # word splitting and command substitution for a subsequent eval. 116521525869Smrg # Many Bourne shells cannot handle close brackets correctly 116621525869Smrg # in scan sets, so we specify it separately. 116721525869Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116821525869Smrg _G_arg=\"$_G_arg\" 116921525869Smrg ;; 117021525869Smrg esac 117121525869Smrg 117221525869Smrg func_quote_for_expand_result=$_G_arg 117321525869Smrg} 117421525869Smrg 117521525869Smrg 117621525869Smrg# func_stripname PREFIX SUFFIX NAME 117721525869Smrg# --------------------------------- 117821525869Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117921525869Smrg# PREFIX and SUFFIX must not contain globbing or regex special 118021525869Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118121525869Smrg# dot (in which case that matches only a dot). 118221525869Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 118321525869Smrg eval 'func_stripname () 118421525869Smrg { 118521525869Smrg $debug_cmd 118621525869Smrg 118721525869Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118821525869Smrg # positional parameters, so assign one to ordinary variable first. 118921525869Smrg func_stripname_result=$3 119021525869Smrg func_stripname_result=${func_stripname_result#"$1"} 119121525869Smrg func_stripname_result=${func_stripname_result%"$2"} 119221525869Smrg }' 119321525869Smrgelse 119421525869Smrg func_stripname () 119521525869Smrg { 119621525869Smrg $debug_cmd 119721525869Smrg 119821525869Smrg case $2 in 119921525869Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120021525869Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120121525869Smrg esac 120221525869Smrg } 120321525869Smrgfi 120421525869Smrg 120521525869Smrg 120621525869Smrg# func_show_eval CMD [FAIL_EXP] 120721525869Smrg# ----------------------------- 120821525869Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120921525869Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121021525869Smrg# is given, then evaluate it. 121121525869Smrgfunc_show_eval () 121221525869Smrg{ 121321525869Smrg $debug_cmd 121421525869Smrg 121521525869Smrg _G_cmd=$1 121621525869Smrg _G_fail_exp=${2-':'} 121721525869Smrg 121821525869Smrg func_quote_for_expand "$_G_cmd" 121921525869Smrg eval "func_notquiet $func_quote_for_expand_result" 122021525869Smrg 122121525869Smrg $opt_dry_run || { 122221525869Smrg eval "$_G_cmd" 122321525869Smrg _G_status=$? 122421525869Smrg if test 0 -ne "$_G_status"; then 122521525869Smrg eval "(exit $_G_status); $_G_fail_exp" 122621525869Smrg fi 122721525869Smrg } 122821525869Smrg} 122921525869Smrg 123021525869Smrg 123121525869Smrg# func_show_eval_locale CMD [FAIL_EXP] 123221525869Smrg# ------------------------------------ 123321525869Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123421525869Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123521525869Smrg# is given, then evaluate it. Use the saved locale for evaluation. 123621525869Smrgfunc_show_eval_locale () 123721525869Smrg{ 123821525869Smrg $debug_cmd 123921525869Smrg 124021525869Smrg _G_cmd=$1 124121525869Smrg _G_fail_exp=${2-':'} 124221525869Smrg 124321525869Smrg $opt_quiet || { 124421525869Smrg func_quote_for_expand "$_G_cmd" 124521525869Smrg eval "func_echo $func_quote_for_expand_result" 124621525869Smrg } 124721525869Smrg 124821525869Smrg $opt_dry_run || { 124921525869Smrg eval "$_G_user_locale 125021525869Smrg $_G_cmd" 125121525869Smrg _G_status=$? 125221525869Smrg eval "$_G_safe_locale" 125321525869Smrg if test 0 -ne "$_G_status"; then 125421525869Smrg eval "(exit $_G_status); $_G_fail_exp" 125521525869Smrg fi 125621525869Smrg } 125721525869Smrg} 125821525869Smrg 125921525869Smrg 126021525869Smrg# func_tr_sh 126121525869Smrg# ---------- 126221525869Smrg# Turn $1 into a string suitable for a shell variable name. 126321525869Smrg# Result is stored in $func_tr_sh_result. All characters 126421525869Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126521525869Smrg# if $1 begins with a digit, a '_' is prepended as well. 126621525869Smrgfunc_tr_sh () 126721525869Smrg{ 126821525869Smrg $debug_cmd 126921525869Smrg 127021525869Smrg case $1 in 127121525869Smrg [0-9]* | *[!a-zA-Z0-9_]*) 127221525869Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127321525869Smrg ;; 127421525869Smrg * ) 127521525869Smrg func_tr_sh_result=$1 127621525869Smrg ;; 127721525869Smrg esac 127821525869Smrg} 127921525869Smrg 128021525869Smrg 128121525869Smrg# func_verbose ARG... 128221525869Smrg# ------------------- 128321525869Smrg# Echo program name prefixed message in verbose mode only. 128421525869Smrgfunc_verbose () 128521525869Smrg{ 128621525869Smrg $debug_cmd 128721525869Smrg 128821525869Smrg $opt_verbose && func_echo "$*" 128921525869Smrg 129021525869Smrg : 129121525869Smrg} 129221525869Smrg 129321525869Smrg 129421525869Smrg# func_warn_and_continue ARG... 129521525869Smrg# ----------------------------- 129621525869Smrg# Echo program name prefixed warning message to standard error. 129721525869Smrgfunc_warn_and_continue () 129821525869Smrg{ 129921525869Smrg $debug_cmd 130021525869Smrg 130121525869Smrg $require_term_colors 130221525869Smrg 130321525869Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130421525869Smrg} 130521525869Smrg 130621525869Smrg 130721525869Smrg# func_warning CATEGORY ARG... 130821525869Smrg# ---------------------------- 130921525869Smrg# Echo program name prefixed warning message to standard error. Warning 131021525869Smrg# messages can be filtered according to CATEGORY, where this function 131121525869Smrg# elides messages where CATEGORY is not listed in the global variable 131221525869Smrg# 'opt_warning_types'. 131321525869Smrgfunc_warning () 131421525869Smrg{ 131521525869Smrg $debug_cmd 131621525869Smrg 131721525869Smrg # CATEGORY must be in the warning_categories list! 131821525869Smrg case " $warning_categories " in 131921525869Smrg *" $1 "*) ;; 132021525869Smrg *) func_internal_error "invalid warning category '$1'" ;; 132121525869Smrg esac 132221525869Smrg 132321525869Smrg _G_category=$1 132421525869Smrg shift 132521525869Smrg 132621525869Smrg case " $opt_warning_types " in 132721525869Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132821525869Smrg esac 132921525869Smrg} 133021525869Smrg 133121525869Smrg 133221525869Smrg# func_sort_ver VER1 VER2 133321525869Smrg# ----------------------- 133421525869Smrg# 'sort -V' is not generally available. 133521525869Smrg# Note this deviates from the version comparison in automake 133621525869Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133721525869Smrg# but this should suffice as we won't be specifying old 133821525869Smrg# version formats or redundant trailing .0 in bootstrap.conf. 133921525869Smrg# If we did want full compatibility then we should probably 134021525869Smrg# use m4_version_compare from autoconf. 134121525869Smrgfunc_sort_ver () 134221525869Smrg{ 134321525869Smrg $debug_cmd 134421525869Smrg 134521525869Smrg printf '%s\n%s\n' "$1" "$2" \ 134621525869Smrg | 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 134721525869Smrg} 134821525869Smrg 134921525869Smrg# func_lt_ver PREV CURR 135021525869Smrg# --------------------- 135121525869Smrg# Return true if PREV and CURR are in the correct order according to 135221525869Smrg# func_sort_ver, otherwise false. Use it like this: 135321525869Smrg# 135421525869Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135521525869Smrgfunc_lt_ver () 135621525869Smrg{ 135721525869Smrg $debug_cmd 135821525869Smrg 135921525869Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136021525869Smrg} 136121525869Smrg 136221525869Smrg 136321525869Smrg# Local variables: 136421525869Smrg# mode: shell-script 136521525869Smrg# sh-indentation: 2 136621525869Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 136721525869Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136821525869Smrg# time-stamp-time-zone: "UTC" 136921525869Smrg# End: 137021525869Smrg#! /bin/sh 137121525869Smrg 137221525869Smrg# Set a version string for this script. 137321525869Smrgscriptversion=2014-01-07.03; # UTC 137421525869Smrg 137521525869Smrg# A portable, pluggable option parser for Bourne shell. 137621525869Smrg# Written by Gary V. Vaughan, 2010 137721525869Smrg 137821525869Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137921525869Smrg# This is free software; see the source for copying conditions. There is NO 138021525869Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138121525869Smrg 138221525869Smrg# This program is free software: you can redistribute it and/or modify 138321525869Smrg# it under the terms of the GNU General Public License as published by 138421525869Smrg# the Free Software Foundation, either version 3 of the License, or 138521525869Smrg# (at your option) any later version. 138621525869Smrg 138721525869Smrg# This program is distributed in the hope that it will be useful, 138821525869Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138921525869Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139021525869Smrg# GNU General Public License for more details. 139121525869Smrg 139221525869Smrg# You should have received a copy of the GNU General Public License 139321525869Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139421525869Smrg 139521525869Smrg# Please report bugs or propose patches to gary@gnu.org. 139621525869Smrg 139721525869Smrg 139821525869Smrg## ------ ## 139921525869Smrg## Usage. ## 140021525869Smrg## ------ ## 140121525869Smrg 140221525869Smrg# This file is a library for parsing options in your shell scripts along 140321525869Smrg# with assorted other useful supporting features that you can make use 140421525869Smrg# of too. 140521525869Smrg# 140621525869Smrg# For the simplest scripts you might need only: 140721525869Smrg# 140821525869Smrg# #!/bin/sh 140921525869Smrg# . relative/path/to/funclib.sh 141021525869Smrg# . relative/path/to/options-parser 141121525869Smrg# scriptversion=1.0 141221525869Smrg# func_options ${1+"$@"} 141321525869Smrg# eval set dummy "$func_options_result"; shift 141421525869Smrg# ...rest of your script... 141521525869Smrg# 141621525869Smrg# In order for the '--version' option to work, you will need to have a 141721525869Smrg# suitably formatted comment like the one at the top of this file 141821525869Smrg# starting with '# Written by ' and ending with '# warranty; '. 141921525869Smrg# 142021525869Smrg# For '-h' and '--help' to work, you will also need a one line 142121525869Smrg# description of your script's purpose in a comment directly above the 142221525869Smrg# '# Written by ' line, like the one at the top of this file. 142321525869Smrg# 142421525869Smrg# The default options also support '--debug', which will turn on shell 142521525869Smrg# execution tracing (see the comment above debug_cmd below for another 142621525869Smrg# use), and '--verbose' and the func_verbose function to allow your script 142721525869Smrg# to display verbose messages only when your user has specified 142821525869Smrg# '--verbose'. 142921525869Smrg# 143021525869Smrg# After sourcing this file, you can plug processing for additional 143121525869Smrg# options by amending the variables from the 'Configuration' section 143221525869Smrg# below, and following the instructions in the 'Option parsing' 143321525869Smrg# section further down. 143421525869Smrg 143521525869Smrg## -------------- ## 143621525869Smrg## Configuration. ## 143721525869Smrg## -------------- ## 143821525869Smrg 143921525869Smrg# You should override these variables in your script after sourcing this 144021525869Smrg# file so that they reflect the customisations you have added to the 144121525869Smrg# option parser. 144221525869Smrg 144321525869Smrg# The usage line for option parsing errors and the start of '-h' and 144421525869Smrg# '--help' output messages. You can embed shell variables for delayed 144521525869Smrg# expansion at the time the message is displayed, but you will need to 144621525869Smrg# quote other shell meta-characters carefully to prevent them being 144721525869Smrg# expanded when the contents are evaled. 144821525869Smrgusage='$progpath [OPTION]...' 144921525869Smrg 145021525869Smrg# Short help message in response to '-h' and '--help'. Add to this or 145121525869Smrg# override it after sourcing this library to reflect the full set of 145221525869Smrg# options your script accepts. 145321525869Smrgusage_message="\ 145421525869Smrg --debug enable verbose shell tracing 145521525869Smrg -W, --warnings=CATEGORY 145621525869Smrg report the warnings falling in CATEGORY [all] 145721525869Smrg -v, --verbose verbosely report processing 145821525869Smrg --version print version information and exit 145921525869Smrg -h, --help print short or long help message and exit 146021525869Smrg" 146121525869Smrg 146221525869Smrg# Additional text appended to 'usage_message' in response to '--help'. 146321525869Smrglong_help_message=" 146421525869SmrgWarning categories include: 146521525869Smrg 'all' show all warnings 146621525869Smrg 'none' turn off all the warnings 146721525869Smrg 'error' warnings are treated as fatal errors" 146821525869Smrg 146921525869Smrg# Help message printed before fatal option parsing errors. 147021525869Smrgfatal_help="Try '\$progname --help' for more information." 147121525869Smrg 147221525869Smrg 147321525869Smrg 147421525869Smrg## ------------------------- ## 147521525869Smrg## Hook function management. ## 147621525869Smrg## ------------------------- ## 147721525869Smrg 147821525869Smrg# This section contains functions for adding, removing, and running hooks 147921525869Smrg# to the main code. A hook is just a named list of of function, that can 148021525869Smrg# be run in order later on. 148121525869Smrg 148221525869Smrg# func_hookable FUNC_NAME 148321525869Smrg# ----------------------- 148421525869Smrg# Declare that FUNC_NAME will run hooks added with 148521525869Smrg# 'func_add_hook FUNC_NAME ...'. 148621525869Smrgfunc_hookable () 148721525869Smrg{ 148821525869Smrg $debug_cmd 148921525869Smrg 149021525869Smrg func_append hookable_fns " $1" 149121525869Smrg} 149221525869Smrg 149321525869Smrg 149421525869Smrg# func_add_hook FUNC_NAME HOOK_FUNC 149521525869Smrg# --------------------------------- 149621525869Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149721525869Smrg# first have been declared "hookable" by a call to 'func_hookable'. 149821525869Smrgfunc_add_hook () 149921525869Smrg{ 150021525869Smrg $debug_cmd 150121525869Smrg 150221525869Smrg case " $hookable_fns " in 150321525869Smrg *" $1 "*) ;; 150421525869Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150521525869Smrg esac 150621525869Smrg 150721525869Smrg eval func_append ${1}_hooks '" $2"' 150821525869Smrg} 150921525869Smrg 151021525869Smrg 151121525869Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 151221525869Smrg# ------------------------------------ 151321525869Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151421525869Smrgfunc_remove_hook () 151521525869Smrg{ 151621525869Smrg $debug_cmd 151721525869Smrg 151821525869Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151921525869Smrg} 152021525869Smrg 152121525869Smrg 152221525869Smrg# func_run_hooks FUNC_NAME [ARG]... 152321525869Smrg# --------------------------------- 152421525869Smrg# Run all hook functions registered to FUNC_NAME. 152521525869Smrg# It is assumed that the list of hook functions contains nothing more 152621525869Smrg# than a whitespace-delimited list of legal shell function names, and 152721525869Smrg# no effort is wasted trying to catch shell meta-characters or preserve 152821525869Smrg# whitespace. 152921525869Smrgfunc_run_hooks () 153021525869Smrg{ 153121525869Smrg $debug_cmd 153221525869Smrg 153321525869Smrg case " $hookable_fns " in 153421525869Smrg *" $1 "*) ;; 153521525869Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153621525869Smrg esac 153721525869Smrg 153821525869Smrg eval _G_hook_fns=\$$1_hooks; shift 153921525869Smrg 154021525869Smrg for _G_hook in $_G_hook_fns; do 154121525869Smrg eval $_G_hook '"$@"' 154221525869Smrg 154321525869Smrg # store returned options list back into positional 154421525869Smrg # parameters for next 'cmd' execution. 154521525869Smrg eval _G_hook_result=\$${_G_hook}_result 154621525869Smrg eval set dummy "$_G_hook_result"; shift 154721525869Smrg done 154821525869Smrg 154921525869Smrg func_quote_for_eval ${1+"$@"} 155021525869Smrg func_run_hooks_result=$func_quote_for_eval_result 155121525869Smrg} 155221525869Smrg 155321525869Smrg 155421525869Smrg 155521525869Smrg## --------------- ## 155621525869Smrg## Option parsing. ## 155721525869Smrg## --------------- ## 155821525869Smrg 155921525869Smrg# In order to add your own option parsing hooks, you must accept the 156021525869Smrg# full positional parameter list in your hook function, remove any 156121525869Smrg# options that you action, and then pass back the remaining unprocessed 156221525869Smrg# options in '<hooked_function_name>_result', escaped suitably for 156321525869Smrg# 'eval'. Like this: 156421525869Smrg# 156521525869Smrg# my_options_prep () 156621525869Smrg# { 156721525869Smrg# $debug_cmd 156821525869Smrg# 156921525869Smrg# # Extend the existing usage message. 157021525869Smrg# usage_message=$usage_message' 157121525869Smrg# -s, --silent don'\''t print informational messages 157221525869Smrg# ' 157321525869Smrg# 157421525869Smrg# func_quote_for_eval ${1+"$@"} 157521525869Smrg# my_options_prep_result=$func_quote_for_eval_result 157621525869Smrg# } 157721525869Smrg# func_add_hook func_options_prep my_options_prep 157821525869Smrg# 157921525869Smrg# 158021525869Smrg# my_silent_option () 158121525869Smrg# { 158221525869Smrg# $debug_cmd 158321525869Smrg# 158421525869Smrg# # Note that for efficiency, we parse as many options as we can 158521525869Smrg# # recognise in a loop before passing the remainder back to the 158621525869Smrg# # caller on the first unrecognised argument we encounter. 158721525869Smrg# while test $# -gt 0; do 158821525869Smrg# opt=$1; shift 158921525869Smrg# case $opt in 159021525869Smrg# --silent|-s) opt_silent=: ;; 159121525869Smrg# # Separate non-argument short options: 159221525869Smrg# -s*) func_split_short_opt "$_G_opt" 159321525869Smrg# set dummy "$func_split_short_opt_name" \ 159421525869Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 159521525869Smrg# shift 159621525869Smrg# ;; 159721525869Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159821525869Smrg# esac 159921525869Smrg# done 160021525869Smrg# 160121525869Smrg# func_quote_for_eval ${1+"$@"} 160221525869Smrg# my_silent_option_result=$func_quote_for_eval_result 160321525869Smrg# } 160421525869Smrg# func_add_hook func_parse_options my_silent_option 160521525869Smrg# 160621525869Smrg# 160721525869Smrg# my_option_validation () 160821525869Smrg# { 160921525869Smrg# $debug_cmd 161021525869Smrg# 161121525869Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161221525869Smrg# '--silent' and '--verbose' options are mutually exclusive." 161321525869Smrg# 161421525869Smrg# func_quote_for_eval ${1+"$@"} 161521525869Smrg# my_option_validation_result=$func_quote_for_eval_result 161621525869Smrg# } 161721525869Smrg# func_add_hook func_validate_options my_option_validation 161821525869Smrg# 161921525869Smrg# You'll alse need to manually amend $usage_message to reflect the extra 162021525869Smrg# options you parse. It's preferable to append if you can, so that 162121525869Smrg# multiple option parsing hooks can be added safely. 162221525869Smrg 162321525869Smrg 162421525869Smrg# func_options [ARG]... 162521525869Smrg# --------------------- 162621525869Smrg# All the functions called inside func_options are hookable. See the 162721525869Smrg# individual implementations for details. 162821525869Smrgfunc_hookable func_options 162921525869Smrgfunc_options () 163021525869Smrg{ 163121525869Smrg $debug_cmd 163221525869Smrg 163321525869Smrg func_options_prep ${1+"$@"} 163421525869Smrg eval func_parse_options \ 163521525869Smrg ${func_options_prep_result+"$func_options_prep_result"} 163621525869Smrg eval func_validate_options \ 163721525869Smrg ${func_parse_options_result+"$func_parse_options_result"} 163821525869Smrg 163921525869Smrg eval func_run_hooks func_options \ 164021525869Smrg ${func_validate_options_result+"$func_validate_options_result"} 164121525869Smrg 164221525869Smrg # save modified positional parameters for caller 164321525869Smrg func_options_result=$func_run_hooks_result 164472b676d7Smrg} 164572b676d7Smrg 164672b676d7Smrg 164721525869Smrg# func_options_prep [ARG]... 164821525869Smrg# -------------------------- 164921525869Smrg# All initialisations required before starting the option parse loop. 165021525869Smrg# Note that when calling hook functions, we pass through the list of 165121525869Smrg# positional parameters. If a hook function modifies that list, and 165221525869Smrg# needs to propogate that back to rest of this script, then the complete 165321525869Smrg# modified list must be put in 'func_run_hooks_result' before 165421525869Smrg# returning. 165521525869Smrgfunc_hookable func_options_prep 165621525869Smrgfunc_options_prep () 165772b676d7Smrg{ 165821525869Smrg $debug_cmd 1659e35772b2Smrg 166021525869Smrg # Option defaults: 166121525869Smrg opt_verbose=false 166221525869Smrg opt_warning_types= 166321525869Smrg 166421525869Smrg func_run_hooks func_options_prep ${1+"$@"} 166521525869Smrg 166621525869Smrg # save modified positional parameters for caller 166721525869Smrg func_options_prep_result=$func_run_hooks_result 166872b676d7Smrg} 166972b676d7Smrg 167072b676d7Smrg 167121525869Smrg# func_parse_options [ARG]... 167221525869Smrg# --------------------------- 167321525869Smrg# The main option parsing loop. 167421525869Smrgfunc_hookable func_parse_options 167521525869Smrgfunc_parse_options () 167672b676d7Smrg{ 167721525869Smrg $debug_cmd 1678e35772b2Smrg 167921525869Smrg func_parse_options_result= 1680e35772b2Smrg 168121525869Smrg # this just eases exit handling 168221525869Smrg while test $# -gt 0; do 168321525869Smrg # Defer to hook functions for initial option parsing, so they 168421525869Smrg # get priority in the event of reusing an option name. 168521525869Smrg func_run_hooks func_parse_options ${1+"$@"} 168672b676d7Smrg 168721525869Smrg # Adjust func_parse_options positional parameters to match 168821525869Smrg eval set dummy "$func_run_hooks_result"; shift 168972b676d7Smrg 169021525869Smrg # Break out of the loop if we already parsed every option. 169121525869Smrg test $# -gt 0 || break 169272b676d7Smrg 169321525869Smrg _G_opt=$1 169421525869Smrg shift 169521525869Smrg case $_G_opt in 169621525869Smrg --debug|-x) debug_cmd='set -x' 169721525869Smrg func_echo "enabling shell trace mode" 169821525869Smrg $debug_cmd 169921525869Smrg ;; 170021525869Smrg 170121525869Smrg --no-warnings|--no-warning|--no-warn) 170221525869Smrg set dummy --warnings none ${1+"$@"} 170321525869Smrg shift 170421525869Smrg ;; 1705e35772b2Smrg 170621525869Smrg --warnings|--warning|-W) 170721525869Smrg test $# = 0 && func_missing_arg $_G_opt && break 170821525869Smrg case " $warning_categories $1" in 170921525869Smrg *" $1 "*) 171021525869Smrg # trailing space prevents matching last $1 above 171121525869Smrg func_append_uniq opt_warning_types " $1" 171221525869Smrg ;; 171321525869Smrg *all) 171421525869Smrg opt_warning_types=$warning_categories 171521525869Smrg ;; 171621525869Smrg *none) 171721525869Smrg opt_warning_types=none 171821525869Smrg warning_func=: 171921525869Smrg ;; 172021525869Smrg *error) 172121525869Smrg opt_warning_types=$warning_categories 172221525869Smrg warning_func=func_fatal_error 172321525869Smrg ;; 172421525869Smrg *) 172521525869Smrg func_fatal_error \ 172621525869Smrg "unsupported warning category: '$1'" 172721525869Smrg ;; 172821525869Smrg esac 172921525869Smrg shift 173021525869Smrg ;; 173121525869Smrg 173221525869Smrg --verbose|-v) opt_verbose=: ;; 173321525869Smrg --version) func_version ;; 173421525869Smrg -\?|-h) func_usage ;; 173521525869Smrg --help) func_help ;; 173621525869Smrg 173721525869Smrg # Separate optargs to long options (plugins may need this): 173821525869Smrg --*=*) func_split_equals "$_G_opt" 173921525869Smrg set dummy "$func_split_equals_lhs" \ 174021525869Smrg "$func_split_equals_rhs" ${1+"$@"} 174121525869Smrg shift 174221525869Smrg ;; 174321525869Smrg 174421525869Smrg # Separate optargs to short options: 174521525869Smrg -W*) 174621525869Smrg func_split_short_opt "$_G_opt" 174721525869Smrg set dummy "$func_split_short_opt_name" \ 174821525869Smrg "$func_split_short_opt_arg" ${1+"$@"} 174921525869Smrg shift 175021525869Smrg ;; 175121525869Smrg 175221525869Smrg # Separate non-argument short options: 175321525869Smrg -\?*|-h*|-v*|-x*) 175421525869Smrg func_split_short_opt "$_G_opt" 175521525869Smrg set dummy "$func_split_short_opt_name" \ 175621525869Smrg "-$func_split_short_opt_arg" ${1+"$@"} 175721525869Smrg shift 175821525869Smrg ;; 175921525869Smrg 176021525869Smrg --) break ;; 176121525869Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176221525869Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176321525869Smrg esac 176421525869Smrg done 176521525869Smrg 176621525869Smrg # save modified positional parameters for caller 176721525869Smrg func_quote_for_eval ${1+"$@"} 176821525869Smrg func_parse_options_result=$func_quote_for_eval_result 176972b676d7Smrg} 177072b676d7Smrg 1771e35772b2Smrg 177221525869Smrg# func_validate_options [ARG]... 177321525869Smrg# ------------------------------ 177421525869Smrg# Perform any sanity checks on option settings and/or unconsumed 177521525869Smrg# arguments. 177621525869Smrgfunc_hookable func_validate_options 177721525869Smrgfunc_validate_options () 177872b676d7Smrg{ 177921525869Smrg $debug_cmd 1780e35772b2Smrg 178121525869Smrg # Display all warnings if -W was not given. 178221525869Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783e35772b2Smrg 178421525869Smrg func_run_hooks func_validate_options ${1+"$@"} 178572b676d7Smrg 178621525869Smrg # Bail if the options were screwed! 178721525869Smrg $exit_cmd $EXIT_FAILURE 178821525869Smrg 178921525869Smrg # save modified positional parameters for caller 179021525869Smrg func_validate_options_result=$func_run_hooks_result 179174c14cd6Smrg} 1792e35772b2Smrg 1793e35772b2Smrg 179474c14cd6Smrg 179521525869Smrg## ----------------- ## 179621525869Smrg## Helper functions. ## 179721525869Smrg## ----------------- ## 1798e35772b2Smrg 179921525869Smrg# This section contains the helper functions used by the rest of the 180021525869Smrg# hookable option parser framework in ascii-betical order. 180121525869Smrg 180221525869Smrg 180321525869Smrg# func_fatal_help ARG... 180421525869Smrg# ---------------------- 180521525869Smrg# Echo program name prefixed message to standard error, followed by 180621525869Smrg# a help hint, and exit. 180721525869Smrgfunc_fatal_help () 1808e35772b2Smrg{ 180921525869Smrg $debug_cmd 181074c14cd6Smrg 181121525869Smrg eval \$ECHO \""Usage: $usage"\" 181221525869Smrg eval \$ECHO \""$fatal_help"\" 181321525869Smrg func_error ${1+"$@"} 181421525869Smrg exit $EXIT_FAILURE 1815e35772b2Smrg} 1816e35772b2Smrg 181721525869Smrg 181821525869Smrg# func_help 181921525869Smrg# --------- 182021525869Smrg# Echo long help message to standard output and exit. 1821e35772b2Smrgfunc_help () 1822e35772b2Smrg{ 182321525869Smrg $debug_cmd 182421525869Smrg 182521525869Smrg func_usage_message 182621525869Smrg $ECHO "$long_help_message" 182721525869Smrg exit 0 1828e35772b2Smrg} 1829e35772b2Smrg 183021525869Smrg 183121525869Smrg# func_missing_arg ARGNAME 183221525869Smrg# ------------------------ 1833e35772b2Smrg# Echo program name prefixed message to standard error and set global 1834e35772b2Smrg# exit_cmd. 1835e35772b2Smrgfunc_missing_arg () 1836e35772b2Smrg{ 183721525869Smrg $debug_cmd 183874c14cd6Smrg 183921525869Smrg func_error "Missing argument for '$1'." 1840e35772b2Smrg exit_cmd=exit 184172b676d7Smrg} 184272b676d7Smrg 184372b676d7Smrg 184421525869Smrg# func_split_equals STRING 184521525869Smrg# ------------------------ 184621525869Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184721525869Smrg# splitting STRING at the '=' sign. 184821525869Smrgtest -z "$_G_HAVE_XSI_OPS" \ 184921525869Smrg && (eval 'x=a/b/c; 185021525869Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185121525869Smrg && _G_HAVE_XSI_OPS=yes 185221525869Smrg 185321525869Smrgif test yes = "$_G_HAVE_XSI_OPS" 185421525869Smrgthen 185521525869Smrg # This is an XSI compatible shell, allowing a faster implementation... 185621525869Smrg eval 'func_split_equals () 185721525869Smrg { 185821525869Smrg $debug_cmd 185921525869Smrg 186021525869Smrg func_split_equals_lhs=${1%%=*} 186121525869Smrg func_split_equals_rhs=${1#*=} 186221525869Smrg test "x$func_split_equals_lhs" = "x$1" \ 186321525869Smrg && func_split_equals_rhs= 186421525869Smrg }' 186521525869Smrgelse 186621525869Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 186721525869Smrg func_split_equals () 186821525869Smrg { 186921525869Smrg $debug_cmd 187021525869Smrg 187121525869Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187221525869Smrg func_split_equals_rhs= 187321525869Smrg test "x$func_split_equals_lhs" = "x$1" \ 187421525869Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187521525869Smrg } 187621525869Smrgfi #func_split_equals 187721525869Smrg 187821525869Smrg 187921525869Smrg# func_split_short_opt SHORTOPT 188021525869Smrg# ----------------------------- 188174c14cd6Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 188274c14cd6Smrg# variables after splitting SHORTOPT after the 2nd character. 188321525869Smrgif test yes = "$_G_HAVE_XSI_OPS" 188421525869Smrgthen 188521525869Smrg # This is an XSI compatible shell, allowing a faster implementation... 188621525869Smrg eval 'func_split_short_opt () 188721525869Smrg { 188821525869Smrg $debug_cmd 188921525869Smrg 189021525869Smrg func_split_short_opt_arg=${1#??} 189121525869Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189221525869Smrg }' 189321525869Smrgelse 189421525869Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 189521525869Smrg func_split_short_opt () 189621525869Smrg { 189721525869Smrg $debug_cmd 189821525869Smrg 189921525869Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190021525869Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190121525869Smrg } 190221525869Smrgfi #func_split_short_opt 190321525869Smrg 190421525869Smrg 190521525869Smrg# func_usage 190621525869Smrg# ---------- 190721525869Smrg# Echo short help message to standard output and exit. 190821525869Smrgfunc_usage () 190974c14cd6Smrg{ 191021525869Smrg $debug_cmd 191172b676d7Smrg 191221525869Smrg func_usage_message 191321525869Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191421525869Smrg exit 0 191521525869Smrg} 191674c14cd6Smrg 191774c14cd6Smrg 191821525869Smrg# func_usage_message 191921525869Smrg# ------------------ 192021525869Smrg# Echo short help message to standard output. 192121525869Smrgfunc_usage_message () 192274c14cd6Smrg{ 192321525869Smrg $debug_cmd 192474c14cd6Smrg 192521525869Smrg eval \$ECHO \""Usage: $usage"\" 192621525869Smrg echo 192721525869Smrg $SED -n 's|^# || 192821525869Smrg /^Written by/{ 192921525869Smrg x;p;x 193021525869Smrg } 193121525869Smrg h 193221525869Smrg /^Written by/q' < "$progpath" 193321525869Smrg echo 193421525869Smrg eval \$ECHO \""$usage_message"\" 193521525869Smrg} 193674c14cd6Smrg 1937e35772b2Smrg 193821525869Smrg# func_version 193921525869Smrg# ------------ 194021525869Smrg# Echo version message to standard output and exit. 194121525869Smrgfunc_version () 194221525869Smrg{ 194321525869Smrg $debug_cmd 1944e35772b2Smrg 194521525869Smrg printf '%s\n' "$progname $scriptversion" 194621525869Smrg $SED -n ' 194721525869Smrg /(C)/!b go 194821525869Smrg :more 194921525869Smrg /\./!{ 195021525869Smrg N 195121525869Smrg s|\n# | | 195221525869Smrg b more 195321525869Smrg } 195421525869Smrg :go 195521525869Smrg /^# Written by /,/# warranty; / { 195621525869Smrg s|^# || 195721525869Smrg s|^# *$|| 195821525869Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195921525869Smrg p 196021525869Smrg } 196121525869Smrg /^# Written by / { 196221525869Smrg s|^# || 196321525869Smrg p 196421525869Smrg } 196521525869Smrg /^warranty; /q' < "$progpath" 1966e35772b2Smrg 196721525869Smrg exit $? 196821525869Smrg} 196972b676d7Smrg 197072b676d7Smrg 197121525869Smrg# Local variables: 197221525869Smrg# mode: shell-script 197321525869Smrg# sh-indentation: 2 197421525869Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 197521525869Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197621525869Smrg# time-stamp-time-zone: "UTC" 197721525869Smrg# End: 197872b676d7Smrg 197921525869Smrg# Set a version string. 198021525869Smrgscriptversion='(GNU libtool) 2.4.6' 198172b676d7Smrg 1982e35772b2Smrg 198321525869Smrg# func_echo ARG... 198421525869Smrg# ---------------- 198521525869Smrg# Libtool also displays the current mode in messages, so override 198621525869Smrg# funclib.sh func_echo with this custom definition. 198721525869Smrgfunc_echo () 198874c14cd6Smrg{ 198921525869Smrg $debug_cmd 199074c14cd6Smrg 199121525869Smrg _G_message=$* 199274c14cd6Smrg 199321525869Smrg func_echo_IFS=$IFS 199421525869Smrg IFS=$nl 199521525869Smrg for _G_line in $_G_message; do 199621525869Smrg IFS=$func_echo_IFS 199721525869Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199821525869Smrg done 199921525869Smrg IFS=$func_echo_IFS 200021525869Smrg} 200174c14cd6Smrg 200221525869Smrg 200321525869Smrg# func_warning ARG... 200421525869Smrg# ------------------- 200521525869Smrg# Libtool warnings are not categorized, so override funclib.sh 200621525869Smrg# func_warning with this simpler definition. 200721525869Smrgfunc_warning () 200874c14cd6Smrg{ 200921525869Smrg $debug_cmd 201074c14cd6Smrg 201121525869Smrg $warning_func ${1+"$@"} 201221525869Smrg} 201374c14cd6Smrg 201474c14cd6Smrg 201521525869Smrg## ---------------- ## 201621525869Smrg## Options parsing. ## 201721525869Smrg## ---------------- ## 201821525869Smrg 201921525869Smrg# Hook in the functions to make sure our own options are parsed during 202021525869Smrg# the option parsing loop. 202121525869Smrg 202221525869Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 202321525869Smrg 202421525869Smrg# Short help message in response to '-h'. 202521525869Smrgusage_message="Options: 202621525869Smrg --config show all configuration variables 202721525869Smrg --debug enable verbose shell tracing 202821525869Smrg -n, --dry-run display commands without modifying any files 202921525869Smrg --features display basic configuration information and exit 203021525869Smrg --mode=MODE use operation mode MODE 203121525869Smrg --no-warnings equivalent to '-Wnone' 203221525869Smrg --preserve-dup-deps don't remove duplicate dependency libraries 203321525869Smrg --quiet, --silent don't print informational messages 203421525869Smrg --tag=TAG use configuration variables from tag TAG 203521525869Smrg -v, --verbose print more informational messages than default 203621525869Smrg --version print version information 203721525869Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203821525869Smrg -h, --help, --help-all print short, long, or detailed help message 203921525869Smrg" 204074c14cd6Smrg 204121525869Smrg# Additional text appended to 'usage_message' in response to '--help'. 204221525869Smrgfunc_help () 204374c14cd6Smrg{ 204421525869Smrg $debug_cmd 204521525869Smrg 204621525869Smrg func_usage_message 204721525869Smrg $ECHO "$long_help_message 204821525869Smrg 204921525869SmrgMODE must be one of the following: 205021525869Smrg 205121525869Smrg clean remove files from the build directory 205221525869Smrg compile compile a source file into a libtool object 205321525869Smrg execute automatically set library path, then run a program 205421525869Smrg finish complete the installation of libtool libraries 205521525869Smrg install install libraries or executables 205621525869Smrg link create a library or an executable 205721525869Smrg uninstall remove libraries from an installed directory 205821525869Smrg 205921525869SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206021525869Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206121525869SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206221525869Smrg 206321525869SmrgWhen reporting a bug, please describe a test case to reproduce it and 206421525869Smrginclude the following information: 206521525869Smrg 206621525869Smrg host-triplet: $host 206721525869Smrg shell: $SHELL 206821525869Smrg compiler: $LTCC 206921525869Smrg compiler flags: $LTCFLAGS 207021525869Smrg linker: $LD (gnu? $with_gnu_ld) 207174fcc364Smrg version: $progname $scriptversion Debian-2.4.6-2 207221525869Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207321525869Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207421525869Smrg 207521525869SmrgReport bugs to <bug-libtool@gnu.org>. 207674fcc364SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 207721525869SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207821525869Smrg exit 0 207921525869Smrg} 208074c14cd6Smrg 208174c14cd6Smrg 208221525869Smrg# func_lo2o OBJECT-NAME 208321525869Smrg# --------------------- 208421525869Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208521525869Smrg# object suffix. 208621525869Smrg 208721525869Smrglo2o=s/\\.lo\$/.$objext/ 208821525869Smrgo2lo=s/\\.$objext\$/.lo/ 208921525869Smrg 209021525869Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 209121525869Smrg eval 'func_lo2o () 209221525869Smrg { 209321525869Smrg case $1 in 209421525869Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209521525869Smrg * ) func_lo2o_result=$1 ;; 209621525869Smrg esac 209721525869Smrg }' 209821525869Smrg 209921525869Smrg # func_xform LIBOBJ-OR-SOURCE 210021525869Smrg # --------------------------- 210121525869Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210221525869Smrg # suffix to a '.lo' libtool-object suffix. 210321525869Smrg eval 'func_xform () 210421525869Smrg { 210521525869Smrg func_xform_result=${1%.*}.lo 210621525869Smrg }' 210721525869Smrgelse 210821525869Smrg # ...otherwise fall back to using sed. 210921525869Smrg func_lo2o () 211021525869Smrg { 211121525869Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211221525869Smrg } 211321525869Smrg 211421525869Smrg func_xform () 211521525869Smrg { 211621525869Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211721525869Smrg } 211821525869Smrgfi 211974c14cd6Smrg 212074c14cd6Smrg 212121525869Smrg# func_fatal_configuration ARG... 212221525869Smrg# ------------------------------- 2123e35772b2Smrg# Echo program name prefixed message to standard error, followed by 2124e35772b2Smrg# a configuration failure hint, and exit. 2125e35772b2Smrgfunc_fatal_configuration () 2126e35772b2Smrg{ 212721525869Smrg func__fatal_error ${1+"$@"} \ 212821525869Smrg "See the $PACKAGE documentation for more information." \ 212921525869Smrg "Fatal configuration error." 2130e35772b2Smrg} 213172b676d7Smrg 21321fd23544Smrg 2133e35772b2Smrg# func_config 213421525869Smrg# ----------- 2135e35772b2Smrg# Display the configuration for all the tags in this script. 2136e35772b2Smrgfunc_config () 2137e35772b2Smrg{ 2138e35772b2Smrg re_begincf='^# ### BEGIN LIBTOOL' 2139e35772b2Smrg re_endcf='^# ### END LIBTOOL' 2140e35772b2Smrg 2141e35772b2Smrg # Default configuration. 2142e35772b2Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 214372b676d7Smrg 214472b676d7Smrg # Now print the configurations for the tags. 214572b676d7Smrg for tagname in $taglist; do 2146e35772b2Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 214772b676d7Smrg done 214872b676d7Smrg 2149e35772b2Smrg exit $? 2150e35772b2Smrg} 215172b676d7Smrg 215221525869Smrg 2153e35772b2Smrg# func_features 215421525869Smrg# ------------- 2155e35772b2Smrg# Display the features supported by this script. 2156e35772b2Smrgfunc_features () 2157e35772b2Smrg{ 215874c14cd6Smrg echo "host: $host" 215921525869Smrg if test yes = "$build_libtool_libs"; then 216074c14cd6Smrg echo "enable shared libraries" 216172b676d7Smrg else 216274c14cd6Smrg echo "disable shared libraries" 216372b676d7Smrg fi 216421525869Smrg if test yes = "$build_old_libs"; then 216574c14cd6Smrg echo "enable static libraries" 216672b676d7Smrg else 216774c14cd6Smrg echo "disable static libraries" 216872b676d7Smrg fi 2169e35772b2Smrg 217072b676d7Smrg exit $? 2171e35772b2Smrg} 217272b676d7Smrg 217321525869Smrg 217421525869Smrg# func_enable_tag TAGNAME 217521525869Smrg# ----------------------- 2176e35772b2Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177e35772b2Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178e35772b2Smrg# variable here. 2179e35772b2Smrgfunc_enable_tag () 2180e35772b2Smrg{ 218121525869Smrg # Global variable: 218221525869Smrg tagname=$1 218372b676d7Smrg 218421525869Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218521525869Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218621525869Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 218772b676d7Smrg 218821525869Smrg # Validate tagname. 218921525869Smrg case $tagname in 219021525869Smrg *[!-_A-Za-z0-9,/]*) 219121525869Smrg func_fatal_error "invalid tag name: $tagname" 219221525869Smrg ;; 219321525869Smrg esac 219472b676d7Smrg 219521525869Smrg # Don't test for the "default" C tag, as we know it's 219621525869Smrg # there but not specially marked. 219721525869Smrg case $tagname in 219821525869Smrg CC) ;; 2199e35772b2Smrg *) 220021525869Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220121525869Smrg taglist="$taglist $tagname" 220221525869Smrg 220321525869Smrg # Evaluate the configuration. Be careful to quote the path 220421525869Smrg # and the sed script, to avoid splitting on whitespace, but 220521525869Smrg # also don't use non-portable quotes within backquotes within 220621525869Smrg # quotes we have to do it in 2 steps: 220721525869Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220821525869Smrg eval "$extractedcf" 220921525869Smrg else 221021525869Smrg func_error "ignoring unknown tag $tagname" 221121525869Smrg fi 221221525869Smrg ;; 221321525869Smrg esac 2214e35772b2Smrg} 2215e35772b2Smrg 221621525869Smrg 221774c14cd6Smrg# func_check_version_match 221821525869Smrg# ------------------------ 221974c14cd6Smrg# Ensure that we are using m4 macros, and libtool script from the same 222074c14cd6Smrg# release of libtool. 222174c14cd6Smrgfunc_check_version_match () 2222e35772b2Smrg{ 222321525869Smrg if test "$package_revision" != "$macro_revision"; then 222421525869Smrg if test "$VERSION" != "$macro_version"; then 222521525869Smrg if test -z "$macro_version"; then 222621525869Smrg cat >&2 <<_LT_EOF 222774c14cd6Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 222874c14cd6Smrg$progname: definition of this LT_INIT comes from an older release. 222974c14cd6Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223074c14cd6Smrg$progname: and run autoconf again. 223174c14cd6Smrg_LT_EOF 223221525869Smrg else 223321525869Smrg cat >&2 <<_LT_EOF 223474c14cd6Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 223574c14cd6Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 223674c14cd6Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223774c14cd6Smrg$progname: and run autoconf again. 223874c14cd6Smrg_LT_EOF 223921525869Smrg fi 224021525869Smrg else 224121525869Smrg cat >&2 <<_LT_EOF 224274c14cd6Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 224374c14cd6Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 224474c14cd6Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 224574c14cd6Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 224674c14cd6Smrg_LT_EOF 224721525869Smrg fi 224874c14cd6Smrg 224921525869Smrg exit $EXIT_MISMATCH 225021525869Smrg fi 225174c14cd6Smrg} 225274c14cd6Smrg 225374c14cd6Smrg 225421525869Smrg# libtool_options_prep [ARG]... 225521525869Smrg# ----------------------------- 225621525869Smrg# Preparation for options parsed by libtool. 225721525869Smrglibtool_options_prep () 225821525869Smrg{ 225921525869Smrg $debug_mode 226074c14cd6Smrg 226121525869Smrg # Option defaults: 226221525869Smrg opt_config=false 226321525869Smrg opt_dlopen= 226421525869Smrg opt_dry_run=false 226521525869Smrg opt_help=false 226621525869Smrg opt_mode= 226721525869Smrg opt_preserve_dup_deps=false 226821525869Smrg opt_quiet=false 226974c14cd6Smrg 227021525869Smrg nonopt= 227121525869Smrg preserve_args= 227274c14cd6Smrg 227321525869Smrg # Shorthand for --mode=foo, only valid as the first argument 227421525869Smrg case $1 in 227521525869Smrg clean|clea|cle|cl) 227621525869Smrg shift; set dummy --mode clean ${1+"$@"}; shift 227721525869Smrg ;; 227821525869Smrg compile|compil|compi|comp|com|co|c) 227921525869Smrg shift; set dummy --mode compile ${1+"$@"}; shift 228021525869Smrg ;; 228121525869Smrg execute|execut|execu|exec|exe|ex|e) 228221525869Smrg shift; set dummy --mode execute ${1+"$@"}; shift 228321525869Smrg ;; 228421525869Smrg finish|finis|fini|fin|fi|f) 228521525869Smrg shift; set dummy --mode finish ${1+"$@"}; shift 228621525869Smrg ;; 228721525869Smrg install|instal|insta|inst|ins|in|i) 228821525869Smrg shift; set dummy --mode install ${1+"$@"}; shift 228921525869Smrg ;; 229021525869Smrg link|lin|li|l) 229121525869Smrg shift; set dummy --mode link ${1+"$@"}; shift 229221525869Smrg ;; 229321525869Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229421525869Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229521525869Smrg ;; 229621525869Smrg esac 229721525869Smrg 229821525869Smrg # Pass back the list of options. 229921525869Smrg func_quote_for_eval ${1+"$@"} 230021525869Smrg libtool_options_prep_result=$func_quote_for_eval_result 230121525869Smrg} 230221525869Smrgfunc_add_hook func_options_prep libtool_options_prep 230372b676d7Smrg 230472b676d7Smrg 230521525869Smrg# libtool_parse_options [ARG]... 230621525869Smrg# --------------------------------- 230721525869Smrg# Provide handling for libtool specific options. 230821525869Smrglibtool_parse_options () 230974c14cd6Smrg{ 231021525869Smrg $debug_cmd 2311e35772b2Smrg 231221525869Smrg # Perform our own loop to consume as many options as possible in 231321525869Smrg # each iteration. 231421525869Smrg while test $# -gt 0; do 231521525869Smrg _G_opt=$1 231621525869Smrg shift 231721525869Smrg case $_G_opt in 231821525869Smrg --dry-run|--dryrun|-n) 231921525869Smrg opt_dry_run=: 232021525869Smrg ;; 232121525869Smrg 232221525869Smrg --config) func_config ;; 232321525869Smrg 232421525869Smrg --dlopen|-dlopen) 232521525869Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 232621525869Smrg}$1" 232721525869Smrg shift 232821525869Smrg ;; 232921525869Smrg 233021525869Smrg --preserve-dup-deps) 233121525869Smrg opt_preserve_dup_deps=: ;; 233221525869Smrg 233321525869Smrg --features) func_features ;; 233421525869Smrg 233521525869Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233621525869Smrg 233721525869Smrg --help) opt_help=: ;; 233821525869Smrg 233921525869Smrg --help-all) opt_help=': help-all' ;; 234021525869Smrg 234121525869Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234221525869Smrg opt_mode=$1 234321525869Smrg case $1 in 234421525869Smrg # Valid mode arguments: 234521525869Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234621525869Smrg 234721525869Smrg # Catch anything else as an error 234821525869Smrg *) func_error "invalid argument for $_G_opt" 234921525869Smrg exit_cmd=exit 235021525869Smrg break 235121525869Smrg ;; 235221525869Smrg esac 235321525869Smrg shift 235421525869Smrg ;; 235521525869Smrg 235621525869Smrg --no-silent|--no-quiet) 235721525869Smrg opt_quiet=false 235821525869Smrg func_append preserve_args " $_G_opt" 235921525869Smrg ;; 236021525869Smrg 236121525869Smrg --no-warnings|--no-warning|--no-warn) 236221525869Smrg opt_warning=false 236321525869Smrg func_append preserve_args " $_G_opt" 236421525869Smrg ;; 236521525869Smrg 236621525869Smrg --no-verbose) 236721525869Smrg opt_verbose=false 236821525869Smrg func_append preserve_args " $_G_opt" 236921525869Smrg ;; 237021525869Smrg 237121525869Smrg --silent|--quiet) 237221525869Smrg opt_quiet=: 237321525869Smrg opt_verbose=false 237421525869Smrg func_append preserve_args " $_G_opt" 237521525869Smrg ;; 237621525869Smrg 237721525869Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237821525869Smrg opt_tag=$1 237921525869Smrg func_append preserve_args " $_G_opt $1" 238021525869Smrg func_enable_tag "$1" 238121525869Smrg shift 238221525869Smrg ;; 238321525869Smrg 238421525869Smrg --verbose|-v) opt_quiet=false 238521525869Smrg opt_verbose=: 238621525869Smrg func_append preserve_args " $_G_opt" 238721525869Smrg ;; 238821525869Smrg 238921525869Smrg # An option not handled by this hook function: 239021525869Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239121525869Smrg esac 239221525869Smrg done 239374c14cd6Smrg 239474c14cd6Smrg 239521525869Smrg # save modified positional parameters for caller 239621525869Smrg func_quote_for_eval ${1+"$@"} 239721525869Smrg libtool_parse_options_result=$func_quote_for_eval_result 239821525869Smrg} 239921525869Smrgfunc_add_hook func_parse_options libtool_parse_options 2400e35772b2Smrg 240172b676d7Smrg 2402e35772b2Smrg 240321525869Smrg# libtool_validate_options [ARG]... 240421525869Smrg# --------------------------------- 240521525869Smrg# Perform any sanity checks on option settings and/or unconsumed 240621525869Smrg# arguments. 240721525869Smrglibtool_validate_options () 240821525869Smrg{ 240921525869Smrg # save first non-option argument 241021525869Smrg if test 0 -lt $#; then 241121525869Smrg nonopt=$1 241221525869Smrg shift 2413e35772b2Smrg fi 2414e35772b2Smrg 241521525869Smrg # preserve --debug 241621525869Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417e35772b2Smrg 241821525869Smrg case $host in 241921525869Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242021525869Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242121525869Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242221525869Smrg # don't eliminate duplications in $postdeps and $predeps 242321525869Smrg opt_duplicate_compiler_generated_deps=: 242421525869Smrg ;; 242521525869Smrg *) 242621525869Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242721525869Smrg ;; 242821525869Smrg esac 242972b676d7Smrg 243021525869Smrg $opt_help || { 243121525869Smrg # Sanity checks first: 243221525869Smrg func_check_version_match 243321525869Smrg 243421525869Smrg test yes != "$build_libtool_libs" \ 243521525869Smrg && test yes != "$build_old_libs" \ 243621525869Smrg && func_fatal_configuration "not configured to build any kind of library" 243721525869Smrg 243821525869Smrg # Darwin sucks 243921525869Smrg eval std_shrext=\"$shrext_cmds\" 244021525869Smrg 244121525869Smrg # Only execute mode is allowed to have -dlopen flags. 244221525869Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244321525869Smrg func_error "unrecognized option '-dlopen'" 244421525869Smrg $ECHO "$help" 1>&2 244521525869Smrg exit $EXIT_FAILURE 244621525869Smrg fi 2447e35772b2Smrg 244821525869Smrg # Change the help message to a mode-specific one. 244921525869Smrg generic_help=$help 245021525869Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 245121525869Smrg } 2452e35772b2Smrg 245321525869Smrg # Pass back the unparsed argument list 245421525869Smrg func_quote_for_eval ${1+"$@"} 245521525869Smrg libtool_validate_options_result=$func_quote_for_eval_result 245674c14cd6Smrg} 245721525869Smrgfunc_add_hook func_validate_options libtool_validate_options 2458e35772b2Smrg 2459e35772b2Smrg 246021525869Smrg# Process options as early as possible so that --help and --version 246121525869Smrg# can return quickly. 246221525869Smrgfunc_options ${1+"$@"} 246321525869Smrgeval set dummy "$func_options_result"; shift 246421525869Smrg 246572b676d7Smrg 246672b676d7Smrg 246774c14cd6Smrg## ----------- ## 246874c14cd6Smrg## Main. ## 246974c14cd6Smrg## ----------- ## 247072b676d7Smrg 247121525869Smrgmagic='%%%MAGIC variable%%%' 247221525869Smrgmagic_exe='%%%MAGIC EXE variable%%%' 247321525869Smrg 247421525869Smrg# Global variables. 247521525869Smrgextracted_archives= 247621525869Smrgextracted_serial=0 247721525869Smrg 247821525869Smrg# If this variable is set in any of the actions, the command in it 247921525869Smrg# will be execed at the end. This prevents here-documents from being 248021525869Smrg# left over by shells. 248121525869Smrgexec_cmd= 248221525869Smrg 248321525869Smrg 248421525869Smrg# A function that is used when there is no print builtin or printf. 248521525869Smrgfunc_fallback_echo () 248621525869Smrg{ 248721525869Smrg eval 'cat <<_LTECHO_EOF 248821525869Smrg$1 248921525869Smrg_LTECHO_EOF' 249021525869Smrg} 249121525869Smrg 249221525869Smrg# func_generated_by_libtool 249321525869Smrg# True iff stdin has been generated by Libtool. This function is only 249421525869Smrg# a basic sanity check; it will hardly flush out determined imposters. 249521525869Smrgfunc_generated_by_libtool_p () 249621525869Smrg{ 249721525869Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249821525869Smrg} 249921525869Smrg 2500e35772b2Smrg# func_lalib_p file 250121525869Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502e35772b2Smrg# This function is only a basic sanity check; it will hardly flush out 2503e35772b2Smrg# determined imposters. 2504e35772b2Smrgfunc_lalib_p () 2505e35772b2Smrg{ 2506e35772b2Smrg test -f "$1" && 250721525869Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508e35772b2Smrg} 250972b676d7Smrg 2510e35772b2Smrg# func_lalib_unsafe_p file 251121525869Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512e35772b2Smrg# This function implements the same check as func_lalib_p without 2513e35772b2Smrg# resorting to external programs. To this end, it redirects stdin and 2514e35772b2Smrg# closes it afterwards, without saving the original file descriptor. 2515e35772b2Smrg# As a safety measure, use it only where a negative result would be 251621525869Smrg# fatal anyway. Works if 'file' does not exist. 2517e35772b2Smrgfunc_lalib_unsafe_p () 2518e35772b2Smrg{ 2519e35772b2Smrg lalib_p=no 2520e35772b2Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521e35772b2Smrg for lalib_p_l in 1 2 3 4 2522e35772b2Smrg do 2523e35772b2Smrg read lalib_p_line 252421525869Smrg case $lalib_p_line in 2525e35772b2Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526e35772b2Smrg esac 2527e35772b2Smrg done 2528e35772b2Smrg exec 0<&5 5<&- 2529e35772b2Smrg fi 253021525869Smrg test yes = "$lalib_p" 2531e35772b2Smrg} 253272b676d7Smrg 2533e35772b2Smrg# func_ltwrapper_script_p file 2534e35772b2Smrg# True iff FILE is a libtool wrapper script 2535e35772b2Smrg# This function is only a basic sanity check; it will hardly flush out 2536e35772b2Smrg# determined imposters. 2537e35772b2Smrgfunc_ltwrapper_script_p () 2538e35772b2Smrg{ 253921525869Smrg test -f "$1" && 254021525869Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541e35772b2Smrg} 254272b676d7Smrg 2543e35772b2Smrg# func_ltwrapper_executable_p file 2544e35772b2Smrg# True iff FILE is a libtool wrapper executable 2545e35772b2Smrg# This function is only a basic sanity check; it will hardly flush out 2546e35772b2Smrg# determined imposters. 2547e35772b2Smrgfunc_ltwrapper_executable_p () 2548e35772b2Smrg{ 2549e35772b2Smrg func_ltwrapper_exec_suffix= 2550e35772b2Smrg case $1 in 2551e35772b2Smrg *.exe) ;; 2552e35772b2Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553e35772b2Smrg esac 2554e35772b2Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555e35772b2Smrg} 255672b676d7Smrg 2557e35772b2Smrg# func_ltwrapper_scriptname file 2558e35772b2Smrg# Assumes file is an ltwrapper_executable 2559e35772b2Smrg# uses $file to determine the appropriate filename for a 2560e35772b2Smrg# temporary ltwrapper_script. 2561e35772b2Smrgfunc_ltwrapper_scriptname () 2562e35772b2Smrg{ 256374c14cd6Smrg func_dirname_and_basename "$1" "" "." 256474c14cd6Smrg func_stripname '' '.exe' "$func_basename_result" 256521525869Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566e35772b2Smrg} 2567e35772b2Smrg 2568e35772b2Smrg# func_ltwrapper_p file 2569e35772b2Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2570e35772b2Smrg# This function is only a basic sanity check; it will hardly flush out 2571e35772b2Smrg# determined imposters. 2572e35772b2Smrgfunc_ltwrapper_p () 2573e35772b2Smrg{ 2574e35772b2Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575e35772b2Smrg} 2576e35772b2Smrg 2577e35772b2Smrg 2578e35772b2Smrg# func_execute_cmds commands fail_cmd 2579e35772b2Smrg# Execute tilde-delimited COMMANDS. 2580e35772b2Smrg# If FAIL_CMD is given, eval that upon failure. 2581e35772b2Smrg# FAIL_CMD may read-access the current command in variable CMD! 2582e35772b2Smrgfunc_execute_cmds () 2583e35772b2Smrg{ 258421525869Smrg $debug_cmd 258521525869Smrg 2586e35772b2Smrg save_ifs=$IFS; IFS='~' 2587e35772b2Smrg for cmd in $1; do 258821525869Smrg IFS=$sp$nl 2589e35772b2Smrg eval cmd=\"$cmd\" 259021525869Smrg IFS=$save_ifs 2591e35772b2Smrg func_show_eval "$cmd" "${2-:}" 2592e35772b2Smrg done 2593e35772b2Smrg IFS=$save_ifs 2594e35772b2Smrg} 2595e35772b2Smrg 2596e35772b2Smrg 2597e35772b2Smrg# func_source file 2598e35772b2Smrg# Source FILE, adding directory component if necessary. 2599e35772b2Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600e35772b2Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601e35772b2Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260221525869Smrg# 'FILE.' does not work on cygwin managed mounts. 2603e35772b2Smrgfunc_source () 2604e35772b2Smrg{ 260521525869Smrg $debug_cmd 260621525869Smrg 2607e35772b2Smrg case $1 in 2608e35772b2Smrg */* | *\\*) . "$1" ;; 2609e35772b2Smrg *) . "./$1" ;; 2610e35772b2Smrg esac 2611e35772b2Smrg} 2612e35772b2Smrg 2613e35772b2Smrg 261474c14cd6Smrg# func_resolve_sysroot PATH 261574c14cd6Smrg# Replace a leading = in PATH with a sysroot. Store the result into 261674c14cd6Smrg# func_resolve_sysroot_result 261774c14cd6Smrgfunc_resolve_sysroot () 261874c14cd6Smrg{ 261974c14cd6Smrg func_resolve_sysroot_result=$1 262074c14cd6Smrg case $func_resolve_sysroot_result in 262174c14cd6Smrg =*) 262274c14cd6Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 262374c14cd6Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 262474c14cd6Smrg ;; 262574c14cd6Smrg esac 262674c14cd6Smrg} 262774c14cd6Smrg 262874c14cd6Smrg# func_replace_sysroot PATH 262974c14cd6Smrg# If PATH begins with the sysroot, replace it with = and 263074c14cd6Smrg# store the result into func_replace_sysroot_result. 263174c14cd6Smrgfunc_replace_sysroot () 263274c14cd6Smrg{ 263321525869Smrg case $lt_sysroot:$1 in 263474c14cd6Smrg ?*:"$lt_sysroot"*) 263574c14cd6Smrg func_stripname "$lt_sysroot" '' "$1" 263621525869Smrg func_replace_sysroot_result='='$func_stripname_result 263774c14cd6Smrg ;; 263874c14cd6Smrg *) 263974c14cd6Smrg # Including no sysroot. 264074c14cd6Smrg func_replace_sysroot_result=$1 264174c14cd6Smrg ;; 264274c14cd6Smrg esac 264374c14cd6Smrg} 264474c14cd6Smrg 2645e35772b2Smrg# func_infer_tag arg 2646e35772b2Smrg# Infer tagged configuration to use if any are available and 2647e35772b2Smrg# if one wasn't chosen via the "--tag" command line option. 2648e35772b2Smrg# Only attempt this if the compiler in the base compile 2649e35772b2Smrg# command doesn't match the default compiler. 2650e35772b2Smrg# arg is usually of the form 'gcc ...' 2651e35772b2Smrgfunc_infer_tag () 2652e35772b2Smrg{ 265321525869Smrg $debug_cmd 265421525869Smrg 2655e35772b2Smrg if test -n "$available_tags" && test -z "$tagname"; then 2656e35772b2Smrg CC_quoted= 2657e35772b2Smrg for arg in $CC; do 265874c14cd6Smrg func_append_quoted CC_quoted "$arg" 2659e35772b2Smrg done 266074c14cd6Smrg CC_expanded=`func_echo_all $CC` 266174c14cd6Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662e35772b2Smrg case $@ in 2663e35772b2Smrg # Blanks in the command may have been stripped by the calling shell, 2664e35772b2Smrg # but not from the CC environment variable when configure was run. 266574c14cd6Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266674c14cd6Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667e35772b2Smrg # Blanks at the start of $base_compile will cause this to fail 2668e35772b2Smrg # if we don't check for them as well. 2669e35772b2Smrg *) 2670e35772b2Smrg for z in $available_tags; do 2671e35772b2Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672e35772b2Smrg # Evaluate the configuration. 267321525869Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674e35772b2Smrg CC_quoted= 2675e35772b2Smrg for arg in $CC; do 2676e35772b2Smrg # Double-quote args containing other shell metacharacters. 267774c14cd6Smrg func_append_quoted CC_quoted "$arg" 2678e35772b2Smrg done 267974c14cd6Smrg CC_expanded=`func_echo_all $CC` 268074c14cd6Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681e35772b2Smrg case "$@ " in 268274c14cd6Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268374c14cd6Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684e35772b2Smrg # The compiler in the base compile command matches 2685e35772b2Smrg # the one in the tagged configuration. 2686e35772b2Smrg # Assume this is the tagged configuration we want. 2687e35772b2Smrg tagname=$z 2688e35772b2Smrg break 2689e35772b2Smrg ;; 2690e35772b2Smrg esac 2691e35772b2Smrg fi 2692e35772b2Smrg done 2693e35772b2Smrg # If $tagname still isn't set, then no tagged configuration 2694e35772b2Smrg # was found and let the user know that the "--tag" command 2695e35772b2Smrg # line option must be used. 2696e35772b2Smrg if test -z "$tagname"; then 2697e35772b2Smrg func_echo "unable to infer tagged configuration" 269821525869Smrg func_fatal_error "specify a tag with '--tag'" 2699e35772b2Smrg# else 2700e35772b2Smrg# func_verbose "using $tagname tagged configuration" 2701e35772b2Smrg fi 2702e35772b2Smrg ;; 2703e35772b2Smrg esac 2704e35772b2Smrg fi 2705e35772b2Smrg} 2706e35772b2Smrg 2707e35772b2Smrg 2708e35772b2Smrg 2709e35772b2Smrg# func_write_libtool_object output_name pic_name nonpic_name 2710e35772b2Smrg# Create a libtool object file (analogous to a ".la" file), 2711e35772b2Smrg# but don't create it if we're doing a dry run. 2712e35772b2Smrgfunc_write_libtool_object () 2713e35772b2Smrg{ 271421525869Smrg write_libobj=$1 271521525869Smrg if test yes = "$build_libtool_libs"; then 271621525869Smrg write_lobj=\'$2\' 2717e35772b2Smrg else 2718e35772b2Smrg write_lobj=none 2719e35772b2Smrg fi 2720e35772b2Smrg 272121525869Smrg if test yes = "$build_old_libs"; then 272221525869Smrg write_oldobj=\'$3\' 2723e35772b2Smrg else 2724e35772b2Smrg write_oldobj=none 2725e35772b2Smrg fi 2726e35772b2Smrg 2727e35772b2Smrg $opt_dry_run || { 2728e35772b2Smrg cat >${write_libobj}T <<EOF 2729e35772b2Smrg# $write_libobj - a libtool object file 273021525869Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731e35772b2Smrg# 2732e35772b2Smrg# Please DO NOT delete this file! 2733e35772b2Smrg# It is necessary for linking the library. 2734e35772b2Smrg 2735e35772b2Smrg# Name of the PIC object. 2736e35772b2Smrgpic_object=$write_lobj 2737e35772b2Smrg 2738e35772b2Smrg# Name of the non-PIC object 2739e35772b2Smrgnon_pic_object=$write_oldobj 2740e35772b2Smrg 2741e35772b2SmrgEOF 274221525869Smrg $MV "${write_libobj}T" "$write_libobj" 2743e35772b2Smrg } 2744e35772b2Smrg} 2745e35772b2Smrg 274674c14cd6Smrg 274774c14cd6Smrg################################################## 274874c14cd6Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 274974c14cd6Smrg################################################## 275074c14cd6Smrg 275174c14cd6Smrg# func_convert_core_file_wine_to_w32 ARG 275274c14cd6Smrg# Helper function used by file name conversion functions when $build is *nix, 275374c14cd6Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 275474c14cd6Smrg# correctly configured wine environment available, with the winepath program 275574c14cd6Smrg# in $build's $PATH. 275674c14cd6Smrg# 275774c14cd6Smrg# ARG is the $build file name to be converted to w32 format. 275874c14cd6Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 275974c14cd6Smrg# be empty on error (or when ARG is empty) 276074c14cd6Smrgfunc_convert_core_file_wine_to_w32 () 276174c14cd6Smrg{ 276221525869Smrg $debug_cmd 276321525869Smrg 276421525869Smrg func_convert_core_file_wine_to_w32_result=$1 276574c14cd6Smrg if test -n "$1"; then 276674c14cd6Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 276774c14cd6Smrg # are forced to check the contents of stdout. On the other hand, if the 276874c14cd6Smrg # command is not found, the shell will set an exit code of 127 and print 276974c14cd6Smrg # *an error message* to stdout. So we must check for both error code of 277074c14cd6Smrg # zero AND non-empty stdout, which explains the odd construction: 277174c14cd6Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277221525869Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 277374c14cd6Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277421525869Smrg $SED -e "$sed_naive_backslashify"` 277574c14cd6Smrg else 277674c14cd6Smrg func_convert_core_file_wine_to_w32_result= 277774c14cd6Smrg fi 277874c14cd6Smrg fi 277974c14cd6Smrg} 278074c14cd6Smrg# end: func_convert_core_file_wine_to_w32 278174c14cd6Smrg 278274c14cd6Smrg 278374c14cd6Smrg# func_convert_core_path_wine_to_w32 ARG 278474c14cd6Smrg# Helper function used by path conversion functions when $build is *nix, and 278574c14cd6Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 278674c14cd6Smrg# configured wine environment available, with the winepath program in $build's 278774c14cd6Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 278874c14cd6Smrg# 278974c14cd6Smrg# ARG is path to be converted from $build format to win32. 279074c14cd6Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 279174c14cd6Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 279274c14cd6Smrg# are convertible, then the result may be empty. 279374c14cd6Smrgfunc_convert_core_path_wine_to_w32 () 279474c14cd6Smrg{ 279521525869Smrg $debug_cmd 279621525869Smrg 279774c14cd6Smrg # unfortunately, winepath doesn't convert paths, only file names 279821525869Smrg func_convert_core_path_wine_to_w32_result= 279974c14cd6Smrg if test -n "$1"; then 280074c14cd6Smrg oldIFS=$IFS 280174c14cd6Smrg IFS=: 280274c14cd6Smrg for func_convert_core_path_wine_to_w32_f in $1; do 280374c14cd6Smrg IFS=$oldIFS 280474c14cd6Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280521525869Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 280674c14cd6Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280721525869Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 280874c14cd6Smrg else 280974c14cd6Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 281074c14cd6Smrg fi 281174c14cd6Smrg fi 281274c14cd6Smrg done 281374c14cd6Smrg IFS=$oldIFS 281474c14cd6Smrg fi 281574c14cd6Smrg} 281674c14cd6Smrg# end: func_convert_core_path_wine_to_w32 281774c14cd6Smrg 281874c14cd6Smrg 281974c14cd6Smrg# func_cygpath ARGS... 282074c14cd6Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 282174c14cd6Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 282274c14cd6Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 282374c14cd6Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 282474c14cd6Smrg# file name or path is assumed to be in w32 format, as previously converted 282574c14cd6Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 282674c14cd6Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 282774c14cd6Smrg# Cygwin format). Returns an empty string on error. 282874c14cd6Smrg# 282974c14cd6Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 283074c14cd6Smrg# be converted. 283174c14cd6Smrg# 283274c14cd6Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 283374c14cd6Smrg# environment variable; do not put it in $PATH. 283474c14cd6Smrgfunc_cygpath () 283574c14cd6Smrg{ 283621525869Smrg $debug_cmd 283721525869Smrg 283874c14cd6Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 283974c14cd6Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 284074c14cd6Smrg if test "$?" -ne 0; then 284174c14cd6Smrg # on failure, ensure result is empty 284274c14cd6Smrg func_cygpath_result= 284374c14cd6Smrg fi 284474c14cd6Smrg else 284574c14cd6Smrg func_cygpath_result= 284621525869Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 284774c14cd6Smrg fi 284874c14cd6Smrg} 284974c14cd6Smrg#end: func_cygpath 285074c14cd6Smrg 285174c14cd6Smrg 285274c14cd6Smrg# func_convert_core_msys_to_w32 ARG 285374c14cd6Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 285474c14cd6Smrg# result in func_convert_core_msys_to_w32_result. 285574c14cd6Smrgfunc_convert_core_msys_to_w32 () 285674c14cd6Smrg{ 285721525869Smrg $debug_cmd 285821525869Smrg 285974c14cd6Smrg # awkward: cmd appends spaces to result 286074c14cd6Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286121525869Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 286274c14cd6Smrg} 286374c14cd6Smrg#end: func_convert_core_msys_to_w32 286474c14cd6Smrg 286574c14cd6Smrg 286674c14cd6Smrg# func_convert_file_check ARG1 ARG2 286774c14cd6Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 286874c14cd6Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 286974c14cd6Smrg# func_to_host_file_result to ARG1). 287074c14cd6Smrgfunc_convert_file_check () 287174c14cd6Smrg{ 287221525869Smrg $debug_cmd 287321525869Smrg 287421525869Smrg if test -z "$2" && test -n "$1"; then 287574c14cd6Smrg func_error "Could not determine host file name corresponding to" 287621525869Smrg func_error " '$1'" 287774c14cd6Smrg func_error "Continuing, but uninstalled executables may not work." 287874c14cd6Smrg # Fallback: 287921525869Smrg func_to_host_file_result=$1 288074c14cd6Smrg fi 288174c14cd6Smrg} 288274c14cd6Smrg# end func_convert_file_check 288374c14cd6Smrg 288474c14cd6Smrg 288574c14cd6Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 288674c14cd6Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 288774c14cd6Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 288874c14cd6Smrg# func_to_host_file_result to a simplistic fallback value (see below). 288974c14cd6Smrgfunc_convert_path_check () 289074c14cd6Smrg{ 289121525869Smrg $debug_cmd 289221525869Smrg 289374c14cd6Smrg if test -z "$4" && test -n "$3"; then 289474c14cd6Smrg func_error "Could not determine the host path corresponding to" 289521525869Smrg func_error " '$3'" 289674c14cd6Smrg func_error "Continuing, but uninstalled executables may not work." 289774c14cd6Smrg # Fallback. This is a deliberately simplistic "conversion" and 289874c14cd6Smrg # should not be "improved". See libtool.info. 289974c14cd6Smrg if test "x$1" != "x$2"; then 290074c14cd6Smrg lt_replace_pathsep_chars="s|$1|$2|g" 290174c14cd6Smrg func_to_host_path_result=`echo "$3" | 290274c14cd6Smrg $SED -e "$lt_replace_pathsep_chars"` 290374c14cd6Smrg else 290421525869Smrg func_to_host_path_result=$3 290574c14cd6Smrg fi 290674c14cd6Smrg fi 290774c14cd6Smrg} 290874c14cd6Smrg# end func_convert_path_check 290974c14cd6Smrg 291074c14cd6Smrg 291174c14cd6Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 291274c14cd6Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 291374c14cd6Smrg# and appending REPL if ORIG matches BACKPAT. 291474c14cd6Smrgfunc_convert_path_front_back_pathsep () 291574c14cd6Smrg{ 291621525869Smrg $debug_cmd 291721525869Smrg 291874c14cd6Smrg case $4 in 291921525869Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 292074c14cd6Smrg ;; 292174c14cd6Smrg esac 292274c14cd6Smrg case $4 in 292374c14cd6Smrg $2 ) func_append func_to_host_path_result "$3" 292474c14cd6Smrg ;; 292574c14cd6Smrg esac 292674c14cd6Smrg} 292774c14cd6Smrg# end func_convert_path_front_back_pathsep 292874c14cd6Smrg 292974c14cd6Smrg 293074c14cd6Smrg################################################## 293174c14cd6Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 293274c14cd6Smrg################################################## 293321525869Smrg# invoked via '$to_host_file_cmd ARG' 293474c14cd6Smrg# 293574c14cd6Smrg# In each case, ARG is the path to be converted from $build to $host format. 293674c14cd6Smrg# Result will be available in $func_to_host_file_result. 293774c14cd6Smrg 293874c14cd6Smrg 293974c14cd6Smrg# func_to_host_file ARG 294074c14cd6Smrg# Converts the file name ARG from $build format to $host format. Return result 294174c14cd6Smrg# in func_to_host_file_result. 294274c14cd6Smrgfunc_to_host_file () 294374c14cd6Smrg{ 294421525869Smrg $debug_cmd 294521525869Smrg 294674c14cd6Smrg $to_host_file_cmd "$1" 294774c14cd6Smrg} 294874c14cd6Smrg# end func_to_host_file 294974c14cd6Smrg 295074c14cd6Smrg 295174c14cd6Smrg# func_to_tool_file ARG LAZY 295274c14cd6Smrg# converts the file name ARG from $build format to toolchain format. Return 295374c14cd6Smrg# result in func_to_tool_file_result. If the conversion in use is listed 295474c14cd6Smrg# in (the comma separated) LAZY, no conversion takes place. 295574c14cd6Smrgfunc_to_tool_file () 295674c14cd6Smrg{ 295721525869Smrg $debug_cmd 295821525869Smrg 295974c14cd6Smrg case ,$2, in 296074c14cd6Smrg *,"$to_tool_file_cmd",*) 296174c14cd6Smrg func_to_tool_file_result=$1 296274c14cd6Smrg ;; 296374c14cd6Smrg *) 296474c14cd6Smrg $to_tool_file_cmd "$1" 296574c14cd6Smrg func_to_tool_file_result=$func_to_host_file_result 296674c14cd6Smrg ;; 296774c14cd6Smrg esac 296874c14cd6Smrg} 296974c14cd6Smrg# end func_to_tool_file 297074c14cd6Smrg 297174c14cd6Smrg 297274c14cd6Smrg# func_convert_file_noop ARG 297374c14cd6Smrg# Copy ARG to func_to_host_file_result. 297474c14cd6Smrgfunc_convert_file_noop () 297574c14cd6Smrg{ 297621525869Smrg func_to_host_file_result=$1 297774c14cd6Smrg} 297874c14cd6Smrg# end func_convert_file_noop 297974c14cd6Smrg 298074c14cd6Smrg 298174c14cd6Smrg# func_convert_file_msys_to_w32 ARG 298274c14cd6Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 298374c14cd6Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 298474c14cd6Smrg# func_to_host_file_result. 298574c14cd6Smrgfunc_convert_file_msys_to_w32 () 298674c14cd6Smrg{ 298721525869Smrg $debug_cmd 298821525869Smrg 298921525869Smrg func_to_host_file_result=$1 299074c14cd6Smrg if test -n "$1"; then 299174c14cd6Smrg func_convert_core_msys_to_w32 "$1" 299221525869Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 299374c14cd6Smrg fi 299474c14cd6Smrg func_convert_file_check "$1" "$func_to_host_file_result" 299574c14cd6Smrg} 299674c14cd6Smrg# end func_convert_file_msys_to_w32 299774c14cd6Smrg 299874c14cd6Smrg 299974c14cd6Smrg# func_convert_file_cygwin_to_w32 ARG 300074c14cd6Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 300174c14cd6Smrg# func_to_host_file_result. 300274c14cd6Smrgfunc_convert_file_cygwin_to_w32 () 300374c14cd6Smrg{ 300421525869Smrg $debug_cmd 300521525869Smrg 300621525869Smrg func_to_host_file_result=$1 300774c14cd6Smrg if test -n "$1"; then 300874c14cd6Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 300974c14cd6Smrg # LT_CYGPATH in this case. 301074c14cd6Smrg func_to_host_file_result=`cygpath -m "$1"` 301174c14cd6Smrg fi 301274c14cd6Smrg func_convert_file_check "$1" "$func_to_host_file_result" 301374c14cd6Smrg} 301474c14cd6Smrg# end func_convert_file_cygwin_to_w32 301574c14cd6Smrg 301674c14cd6Smrg 301774c14cd6Smrg# func_convert_file_nix_to_w32 ARG 301874c14cd6Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 301974c14cd6Smrg# and a working winepath. Returns result in func_to_host_file_result. 302074c14cd6Smrgfunc_convert_file_nix_to_w32 () 302174c14cd6Smrg{ 302221525869Smrg $debug_cmd 302321525869Smrg 302421525869Smrg func_to_host_file_result=$1 302574c14cd6Smrg if test -n "$1"; then 302674c14cd6Smrg func_convert_core_file_wine_to_w32 "$1" 302721525869Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 302874c14cd6Smrg fi 302974c14cd6Smrg func_convert_file_check "$1" "$func_to_host_file_result" 303074c14cd6Smrg} 303174c14cd6Smrg# end func_convert_file_nix_to_w32 303274c14cd6Smrg 303374c14cd6Smrg 303474c14cd6Smrg# func_convert_file_msys_to_cygwin ARG 303574c14cd6Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 303674c14cd6Smrg# Returns result in func_to_host_file_result. 303774c14cd6Smrgfunc_convert_file_msys_to_cygwin () 303874c14cd6Smrg{ 303921525869Smrg $debug_cmd 304021525869Smrg 304121525869Smrg func_to_host_file_result=$1 304274c14cd6Smrg if test -n "$1"; then 304374c14cd6Smrg func_convert_core_msys_to_w32 "$1" 304474c14cd6Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304521525869Smrg func_to_host_file_result=$func_cygpath_result 304674c14cd6Smrg fi 304774c14cd6Smrg func_convert_file_check "$1" "$func_to_host_file_result" 304874c14cd6Smrg} 304974c14cd6Smrg# end func_convert_file_msys_to_cygwin 305074c14cd6Smrg 305174c14cd6Smrg 305274c14cd6Smrg# func_convert_file_nix_to_cygwin ARG 305374c14cd6Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 305474c14cd6Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 305574c14cd6Smrg# in func_to_host_file_result. 305674c14cd6Smrgfunc_convert_file_nix_to_cygwin () 305774c14cd6Smrg{ 305821525869Smrg $debug_cmd 305921525869Smrg 306021525869Smrg func_to_host_file_result=$1 306174c14cd6Smrg if test -n "$1"; then 306274c14cd6Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 306374c14cd6Smrg func_convert_core_file_wine_to_w32 "$1" 306474c14cd6Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306521525869Smrg func_to_host_file_result=$func_cygpath_result 306674c14cd6Smrg fi 306774c14cd6Smrg func_convert_file_check "$1" "$func_to_host_file_result" 306874c14cd6Smrg} 306974c14cd6Smrg# end func_convert_file_nix_to_cygwin 307074c14cd6Smrg 307174c14cd6Smrg 307274c14cd6Smrg############################################# 307374c14cd6Smrg# $build to $host PATH CONVERSION FUNCTIONS # 307474c14cd6Smrg############################################# 307521525869Smrg# invoked via '$to_host_path_cmd ARG' 307674c14cd6Smrg# 307774c14cd6Smrg# In each case, ARG is the path to be converted from $build to $host format. 307874c14cd6Smrg# The result will be available in $func_to_host_path_result. 307974c14cd6Smrg# 308074c14cd6Smrg# Path separators are also converted from $build format to $host format. If 308174c14cd6Smrg# ARG begins or ends with a path separator character, it is preserved (but 308274c14cd6Smrg# converted to $host format) on output. 308374c14cd6Smrg# 308474c14cd6Smrg# All path conversion functions are named using the following convention: 308574c14cd6Smrg# file name conversion function : func_convert_file_X_to_Y () 308674c14cd6Smrg# path conversion function : func_convert_path_X_to_Y () 308774c14cd6Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 308874c14cd6Smrg# same. If conversion functions are added for new $build/$host combinations, 308974c14cd6Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 309074c14cd6Smrg# will break. 309174c14cd6Smrg 309274c14cd6Smrg 309374c14cd6Smrg# func_init_to_host_path_cmd 309474c14cd6Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 309574c14cd6Smrg# appropriate value, based on the value of $to_host_file_cmd. 309674c14cd6Smrgto_host_path_cmd= 309774c14cd6Smrgfunc_init_to_host_path_cmd () 309874c14cd6Smrg{ 309921525869Smrg $debug_cmd 310021525869Smrg 310174c14cd6Smrg if test -z "$to_host_path_cmd"; then 310274c14cd6Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310321525869Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 310474c14cd6Smrg fi 310574c14cd6Smrg} 310674c14cd6Smrg 310774c14cd6Smrg 310874c14cd6Smrg# func_to_host_path ARG 310974c14cd6Smrg# Converts the path ARG from $build format to $host format. Return result 311074c14cd6Smrg# in func_to_host_path_result. 311174c14cd6Smrgfunc_to_host_path () 311274c14cd6Smrg{ 311321525869Smrg $debug_cmd 311421525869Smrg 311574c14cd6Smrg func_init_to_host_path_cmd 311674c14cd6Smrg $to_host_path_cmd "$1" 311774c14cd6Smrg} 311874c14cd6Smrg# end func_to_host_path 311974c14cd6Smrg 312074c14cd6Smrg 312174c14cd6Smrg# func_convert_path_noop ARG 312274c14cd6Smrg# Copy ARG to func_to_host_path_result. 312374c14cd6Smrgfunc_convert_path_noop () 312474c14cd6Smrg{ 312521525869Smrg func_to_host_path_result=$1 312674c14cd6Smrg} 312774c14cd6Smrg# end func_convert_path_noop 312874c14cd6Smrg 312974c14cd6Smrg 313074c14cd6Smrg# func_convert_path_msys_to_w32 ARG 313174c14cd6Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 313274c14cd6Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 313374c14cd6Smrg# func_to_host_path_result. 313474c14cd6Smrgfunc_convert_path_msys_to_w32 () 313574c14cd6Smrg{ 313621525869Smrg $debug_cmd 313721525869Smrg 313821525869Smrg func_to_host_path_result=$1 313974c14cd6Smrg if test -n "$1"; then 314074c14cd6Smrg # Remove leading and trailing path separator characters from ARG. MSYS 314174c14cd6Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 314274c14cd6Smrg # and winepath ignores them completely. 314374c14cd6Smrg func_stripname : : "$1" 314474c14cd6Smrg func_to_host_path_tmp1=$func_stripname_result 314574c14cd6Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314621525869Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 314774c14cd6Smrg func_convert_path_check : ";" \ 314874c14cd6Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 314974c14cd6Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 315074c14cd6Smrg fi 315174c14cd6Smrg} 315274c14cd6Smrg# end func_convert_path_msys_to_w32 315374c14cd6Smrg 315474c14cd6Smrg 315574c14cd6Smrg# func_convert_path_cygwin_to_w32 ARG 315674c14cd6Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 315774c14cd6Smrg# func_to_host_file_result. 315874c14cd6Smrgfunc_convert_path_cygwin_to_w32 () 315974c14cd6Smrg{ 316021525869Smrg $debug_cmd 316121525869Smrg 316221525869Smrg func_to_host_path_result=$1 316374c14cd6Smrg if test -n "$1"; then 316474c14cd6Smrg # See func_convert_path_msys_to_w32: 316574c14cd6Smrg func_stripname : : "$1" 316674c14cd6Smrg func_to_host_path_tmp1=$func_stripname_result 316774c14cd6Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 316874c14cd6Smrg func_convert_path_check : ";" \ 316974c14cd6Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 317074c14cd6Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 317174c14cd6Smrg fi 317274c14cd6Smrg} 317374c14cd6Smrg# end func_convert_path_cygwin_to_w32 317474c14cd6Smrg 317574c14cd6Smrg 317674c14cd6Smrg# func_convert_path_nix_to_w32 ARG 317774c14cd6Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 317874c14cd6Smrg# a working winepath. Returns result in func_to_host_file_result. 317974c14cd6Smrgfunc_convert_path_nix_to_w32 () 318074c14cd6Smrg{ 318121525869Smrg $debug_cmd 318221525869Smrg 318321525869Smrg func_to_host_path_result=$1 318474c14cd6Smrg if test -n "$1"; then 318574c14cd6Smrg # See func_convert_path_msys_to_w32: 318674c14cd6Smrg func_stripname : : "$1" 318774c14cd6Smrg func_to_host_path_tmp1=$func_stripname_result 318874c14cd6Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318921525869Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 319074c14cd6Smrg func_convert_path_check : ";" \ 319174c14cd6Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 319274c14cd6Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 319374c14cd6Smrg fi 319474c14cd6Smrg} 319574c14cd6Smrg# end func_convert_path_nix_to_w32 319674c14cd6Smrg 319774c14cd6Smrg 319874c14cd6Smrg# func_convert_path_msys_to_cygwin ARG 319974c14cd6Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 320074c14cd6Smrg# Returns result in func_to_host_file_result. 320174c14cd6Smrgfunc_convert_path_msys_to_cygwin () 320274c14cd6Smrg{ 320321525869Smrg $debug_cmd 320421525869Smrg 320521525869Smrg func_to_host_path_result=$1 320674c14cd6Smrg if test -n "$1"; then 320774c14cd6Smrg # See func_convert_path_msys_to_w32: 320874c14cd6Smrg func_stripname : : "$1" 320974c14cd6Smrg func_to_host_path_tmp1=$func_stripname_result 321074c14cd6Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 321174c14cd6Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321221525869Smrg func_to_host_path_result=$func_cygpath_result 321374c14cd6Smrg func_convert_path_check : : \ 321474c14cd6Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 321574c14cd6Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 321674c14cd6Smrg fi 321774c14cd6Smrg} 321874c14cd6Smrg# end func_convert_path_msys_to_cygwin 321974c14cd6Smrg 322074c14cd6Smrg 322174c14cd6Smrg# func_convert_path_nix_to_cygwin ARG 322274c14cd6Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 322374c14cd6Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 322474c14cd6Smrg# func_to_host_file_result. 322574c14cd6Smrgfunc_convert_path_nix_to_cygwin () 322674c14cd6Smrg{ 322721525869Smrg $debug_cmd 322821525869Smrg 322921525869Smrg func_to_host_path_result=$1 323074c14cd6Smrg if test -n "$1"; then 323174c14cd6Smrg # Remove leading and trailing path separator characters from 323274c14cd6Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 323374c14cd6Smrg # into '.;' and ';.', and winepath ignores them completely. 323474c14cd6Smrg func_stripname : : "$1" 323574c14cd6Smrg func_to_host_path_tmp1=$func_stripname_result 323674c14cd6Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323774c14cd6Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323821525869Smrg func_to_host_path_result=$func_cygpath_result 323974c14cd6Smrg func_convert_path_check : : \ 324074c14cd6Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 324174c14cd6Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 324274c14cd6Smrg fi 324374c14cd6Smrg} 324474c14cd6Smrg# end func_convert_path_nix_to_cygwin 324574c14cd6Smrg 324674c14cd6Smrg 324721525869Smrg# func_dll_def_p FILE 324821525869Smrg# True iff FILE is a Windows DLL '.def' file. 324921525869Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325021525869Smrgfunc_dll_def_p () 325121525869Smrg{ 325221525869Smrg $debug_cmd 325321525869Smrg 325421525869Smrg func_dll_def_p_tmp=`$SED -n \ 325521525869Smrg -e 's/^[ ]*//' \ 325621525869Smrg -e '/^\(;.*\)*$/d' \ 325721525869Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325821525869Smrg -e q \ 325921525869Smrg "$1"` 326021525869Smrg test DEF = "$func_dll_def_p_tmp" 326121525869Smrg} 326221525869Smrg 326321525869Smrg 3264e35772b2Smrg# func_mode_compile arg... 3265e35772b2Smrgfunc_mode_compile () 3266e35772b2Smrg{ 326721525869Smrg $debug_cmd 326821525869Smrg 3269e35772b2Smrg # Get the compilation command and the source file. 3270e35772b2Smrg base_compile= 327121525869Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272e35772b2Smrg suppress_opt=yes 3273e35772b2Smrg suppress_output= 3274e35772b2Smrg arg_mode=normal 3275e35772b2Smrg libobj= 3276e35772b2Smrg later= 3277e35772b2Smrg pie_flag= 3278e35772b2Smrg 3279e35772b2Smrg for arg 3280e35772b2Smrg do 3281e35772b2Smrg case $arg_mode in 3282e35772b2Smrg arg ) 3283e35772b2Smrg # do not "continue". Instead, add this to base_compile 328421525869Smrg lastarg=$arg 3285e35772b2Smrg arg_mode=normal 3286e35772b2Smrg ;; 3287e35772b2Smrg 3288e35772b2Smrg target ) 328921525869Smrg libobj=$arg 3290e35772b2Smrg arg_mode=normal 3291e35772b2Smrg continue 3292e35772b2Smrg ;; 3293e35772b2Smrg 3294e35772b2Smrg normal ) 3295e35772b2Smrg # Accept any command-line options. 3296e35772b2Smrg case $arg in 3297e35772b2Smrg -o) 3298e35772b2Smrg test -n "$libobj" && \ 329921525869Smrg func_fatal_error "you cannot specify '-o' more than once" 3300e35772b2Smrg arg_mode=target 3301e35772b2Smrg continue 3302e35772b2Smrg ;; 3303e35772b2Smrg 3304e35772b2Smrg -pie | -fpie | -fPIE) 330574c14cd6Smrg func_append pie_flag " $arg" 3306e35772b2Smrg continue 3307e35772b2Smrg ;; 3308e35772b2Smrg 3309e35772b2Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 331074c14cd6Smrg func_append later " $arg" 3311e35772b2Smrg continue 3312e35772b2Smrg ;; 3313e35772b2Smrg 3314e35772b2Smrg -no-suppress) 331572b676d7Smrg suppress_opt=no 331672b676d7Smrg continue 331772b676d7Smrg ;; 331872b676d7Smrg 331972b676d7Smrg -Xcompiler) 332072b676d7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 332172b676d7Smrg continue # The current "srcfile" will either be retained or 332272b676d7Smrg ;; # replaced later. I would guess that would be a bug. 332372b676d7Smrg 332472b676d7Smrg -Wc,*) 3325e35772b2Smrg func_stripname '-Wc,' '' "$arg" 3326e35772b2Smrg args=$func_stripname_result 332772b676d7Smrg lastarg= 332821525869Smrg save_ifs=$IFS; IFS=, 3329e35772b2Smrg for arg in $args; do 333021525869Smrg IFS=$save_ifs 333174c14cd6Smrg func_append_quoted lastarg "$arg" 333272b676d7Smrg done 333321525869Smrg IFS=$save_ifs 3334e35772b2Smrg func_stripname ' ' '' "$lastarg" 3335e35772b2Smrg lastarg=$func_stripname_result 333672b676d7Smrg 333772b676d7Smrg # Add the arguments to base_compile. 333874c14cd6Smrg func_append base_compile " $lastarg" 333972b676d7Smrg continue 334072b676d7Smrg ;; 334172b676d7Smrg 3342e35772b2Smrg *) 334372b676d7Smrg # Accept the current argument as the source file. 334472b676d7Smrg # The previous "srcfile" becomes the current argument. 334572b676d7Smrg # 334621525869Smrg lastarg=$srcfile 334721525869Smrg srcfile=$arg 334872b676d7Smrg ;; 334972b676d7Smrg esac # case $arg 335072b676d7Smrg ;; 335172b676d7Smrg esac # case $arg_mode 335272b676d7Smrg 335372b676d7Smrg # Aesthetically quote the previous argument. 335474c14cd6Smrg func_append_quoted base_compile "$lastarg" 335572b676d7Smrg done # for arg 335672b676d7Smrg 335772b676d7Smrg case $arg_mode in 335872b676d7Smrg arg) 3359e35772b2Smrg func_fatal_error "you must specify an argument for -Xcompile" 336072b676d7Smrg ;; 336172b676d7Smrg target) 336221525869Smrg func_fatal_error "you must specify a target with '-o'" 336372b676d7Smrg ;; 336472b676d7Smrg *) 336572b676d7Smrg # Get the name of the library object. 3366e35772b2Smrg test -z "$libobj" && { 3367e35772b2Smrg func_basename "$srcfile" 336821525869Smrg libobj=$func_basename_result 3369e35772b2Smrg } 337072b676d7Smrg ;; 337172b676d7Smrg esac 337272b676d7Smrg 337372b676d7Smrg # Recognize several different file suffixes. 337472b676d7Smrg # If the user specifies -o file.o, it is replaced with file.lo 337572b676d7Smrg case $libobj in 3376e35772b2Smrg *.[cCFSifmso] | \ 3377e35772b2Smrg *.ada | *.adb | *.ads | *.asm | \ 3378e35772b2Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 337974c14cd6Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380e35772b2Smrg func_xform "$libobj" 3381e35772b2Smrg libobj=$func_xform_result 3382e35772b2Smrg ;; 338372b676d7Smrg esac 338472b676d7Smrg 338572b676d7Smrg case $libobj in 3386e35772b2Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 338772b676d7Smrg *) 338821525869Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 338972b676d7Smrg ;; 339072b676d7Smrg esac 339172b676d7Smrg 339272b676d7Smrg func_infer_tag $base_compile 339372b676d7Smrg 339472b676d7Smrg for arg in $later; do 339572b676d7Smrg case $arg in 3396e35772b2Smrg -shared) 339721525869Smrg test yes = "$build_libtool_libs" \ 339821525869Smrg || func_fatal_configuration "cannot build a shared library" 3399e35772b2Smrg build_old_libs=no 3400e35772b2Smrg continue 3401e35772b2Smrg ;; 3402e35772b2Smrg 340372b676d7Smrg -static) 3404e35772b2Smrg build_libtool_libs=no 340572b676d7Smrg build_old_libs=yes 340672b676d7Smrg continue 340772b676d7Smrg ;; 340872b676d7Smrg 340972b676d7Smrg -prefer-pic) 341072b676d7Smrg pic_mode=yes 341172b676d7Smrg continue 341272b676d7Smrg ;; 341372b676d7Smrg 341472b676d7Smrg -prefer-non-pic) 341572b676d7Smrg pic_mode=no 341672b676d7Smrg continue 341772b676d7Smrg ;; 341872b676d7Smrg esac 341972b676d7Smrg done 342072b676d7Smrg 3421e35772b2Smrg func_quote_for_eval "$libobj" 3422e35772b2Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423e35772b2Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342421525869Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425e35772b2Smrg func_dirname_and_basename "$obj" "/" "" 342621525869Smrg objname=$func_basename_result 342721525869Smrg xdir=$func_dirname_result 342821525869Smrg lobj=$xdir$objdir/$objname 342972b676d7Smrg 3430e35772b2Smrg test -z "$base_compile" && \ 3431e35772b2Smrg func_fatal_help "you must specify a compilation command" 343272b676d7Smrg 343372b676d7Smrg # Delete any leftover library objects. 343421525869Smrg if test yes = "$build_old_libs"; then 343572b676d7Smrg removelist="$obj $lobj $libobj ${libobj}T" 343672b676d7Smrg else 343772b676d7Smrg removelist="$lobj $libobj ${libobj}T" 343872b676d7Smrg fi 343972b676d7Smrg 344072b676d7Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 344172b676d7Smrg case $host_os in 3442e35772b2Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 344372b676d7Smrg pic_mode=default 344472b676d7Smrg ;; 344572b676d7Smrg esac 344621525869Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 344772b676d7Smrg # non-PIC code in shared libraries is not supported 344872b676d7Smrg pic_mode=default 344972b676d7Smrg fi 345072b676d7Smrg 345172b676d7Smrg # Calculate the filename of the output object if compiler does 345272b676d7Smrg # not support -o with -c 345321525869Smrg if test no = "$compiler_c_o"; then 345421525869Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345521525869Smrg lockfile=$output_obj.lock 345672b676d7Smrg else 345772b676d7Smrg output_obj= 345872b676d7Smrg need_locks=no 345972b676d7Smrg lockfile= 346072b676d7Smrg fi 346172b676d7Smrg 346272b676d7Smrg # Lock this critical section if it is needed 346372b676d7Smrg # We use this script file to make the link, it avoids creating a new file 346421525869Smrg if test yes = "$need_locks"; then 3465e35772b2Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466e35772b2Smrg func_echo "Waiting for $lockfile to be removed" 346772b676d7Smrg sleep 2 346872b676d7Smrg done 346921525869Smrg elif test warn = "$need_locks"; then 347072b676d7Smrg if test -f "$lockfile"; then 3471e35772b2Smrg $ECHO "\ 347272b676d7Smrg*** ERROR, $lockfile exists and contains: 347372b676d7Smrg`cat $lockfile 2>/dev/null` 347472b676d7Smrg 347572b676d7SmrgThis indicates that another process is trying to use the same 347672b676d7Smrgtemporary object file, and libtool could not work around it because 347721525869Smrgyour compiler does not support '-c' and '-o' together. If you 347872b676d7Smrgrepeat this compilation, it may succeed, by chance, but you had better 347972b676d7Smrgavoid parallel builds (make -j) in this platform, or get a better 348072b676d7Smrgcompiler." 348172b676d7Smrg 3482e35772b2Smrg $opt_dry_run || $RM $removelist 348372b676d7Smrg exit $EXIT_FAILURE 348472b676d7Smrg fi 348574c14cd6Smrg func_append removelist " $output_obj" 3486e35772b2Smrg $ECHO "$srcfile" > "$lockfile" 348772b676d7Smrg fi 348872b676d7Smrg 3489e35772b2Smrg $opt_dry_run || $RM $removelist 349074c14cd6Smrg func_append removelist " $lockfile" 3491e35772b2Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492e35772b2Smrg 349374c14cd6Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 349474c14cd6Smrg srcfile=$func_to_tool_file_result 3495e35772b2Smrg func_quote_for_eval "$srcfile" 3496e35772b2Smrg qsrcfile=$func_quote_for_eval_result 349772b676d7Smrg 349872b676d7Smrg # Only build a PIC object if we are building libtool libraries. 349921525869Smrg if test yes = "$build_libtool_libs"; then 350072b676d7Smrg # Without this assignment, base_compile gets emptied. 350172b676d7Smrg fbsd_hideous_sh_bug=$base_compile 350272b676d7Smrg 350321525869Smrg if test no != "$pic_mode"; then 350472b676d7Smrg command="$base_compile $qsrcfile $pic_flag" 350572b676d7Smrg else 350672b676d7Smrg # Don't build PIC code 350772b676d7Smrg command="$base_compile $qsrcfile" 350872b676d7Smrg fi 350972b676d7Smrg 3510e35772b2Smrg func_mkdir_p "$xdir$objdir" 351172b676d7Smrg 351272b676d7Smrg if test -z "$output_obj"; then 351372b676d7Smrg # Place PIC objects in $objdir 351474c14cd6Smrg func_append command " -o $lobj" 351572b676d7Smrg fi 351672b676d7Smrg 3517e35772b2Smrg func_show_eval_locale "$command" \ 3518e35772b2Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 351972b676d7Smrg 352021525869Smrg if test warn = "$need_locks" && 352172b676d7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522e35772b2Smrg $ECHO "\ 352372b676d7Smrg*** ERROR, $lockfile contains: 352472b676d7Smrg`cat $lockfile 2>/dev/null` 352572b676d7Smrg 352672b676d7Smrgbut it should contain: 352772b676d7Smrg$srcfile 352872b676d7Smrg 352972b676d7SmrgThis indicates that another process is trying to use the same 353072b676d7Smrgtemporary object file, and libtool could not work around it because 353121525869Smrgyour compiler does not support '-c' and '-o' together. If you 353272b676d7Smrgrepeat this compilation, it may succeed, by chance, but you had better 353372b676d7Smrgavoid parallel builds (make -j) in this platform, or get a better 353472b676d7Smrgcompiler." 353572b676d7Smrg 3536e35772b2Smrg $opt_dry_run || $RM $removelist 353772b676d7Smrg exit $EXIT_FAILURE 353872b676d7Smrg fi 353972b676d7Smrg 354072b676d7Smrg # Just move the object if needed, then go on to compile the next one 354172b676d7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542e35772b2Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543e35772b2Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 354472b676d7Smrg fi 354572b676d7Smrg 354672b676d7Smrg # Allow error messages only from the first compilation. 354721525869Smrg if test yes = "$suppress_opt"; then 3548e35772b2Smrg suppress_output=' >/dev/null 2>&1' 354972b676d7Smrg fi 355072b676d7Smrg fi 355172b676d7Smrg 355272b676d7Smrg # Only build a position-dependent object if we build old libraries. 355321525869Smrg if test yes = "$build_old_libs"; then 355421525869Smrg if test yes != "$pic_mode"; then 355572b676d7Smrg # Don't build PIC code 3556e35772b2Smrg command="$base_compile $qsrcfile$pie_flag" 355772b676d7Smrg else 355872b676d7Smrg command="$base_compile $qsrcfile $pic_flag" 355972b676d7Smrg fi 356021525869Smrg if test yes = "$compiler_c_o"; then 356174c14cd6Smrg func_append command " -o $obj" 356272b676d7Smrg fi 356372b676d7Smrg 356472b676d7Smrg # Suppress compiler output if we already did a PIC compilation. 356574c14cd6Smrg func_append command "$suppress_output" 3566e35772b2Smrg func_show_eval_locale "$command" \ 3567e35772b2Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 356872b676d7Smrg 356921525869Smrg if test warn = "$need_locks" && 357072b676d7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571e35772b2Smrg $ECHO "\ 357272b676d7Smrg*** ERROR, $lockfile contains: 357372b676d7Smrg`cat $lockfile 2>/dev/null` 357472b676d7Smrg 357572b676d7Smrgbut it should contain: 357672b676d7Smrg$srcfile 357772b676d7Smrg 357872b676d7SmrgThis indicates that another process is trying to use the same 357972b676d7Smrgtemporary object file, and libtool could not work around it because 358021525869Smrgyour compiler does not support '-c' and '-o' together. If you 358172b676d7Smrgrepeat this compilation, it may succeed, by chance, but you had better 358272b676d7Smrgavoid parallel builds (make -j) in this platform, or get a better 358372b676d7Smrgcompiler." 358472b676d7Smrg 3585e35772b2Smrg $opt_dry_run || $RM $removelist 358672b676d7Smrg exit $EXIT_FAILURE 358772b676d7Smrg fi 358872b676d7Smrg 358972b676d7Smrg # Just move the object if needed 359072b676d7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591e35772b2Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592e35772b2Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 359372b676d7Smrg fi 359472b676d7Smrg fi 359572b676d7Smrg 3596e35772b2Smrg $opt_dry_run || { 3597e35772b2Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 359872b676d7Smrg 3599e35772b2Smrg # Unlock the critical section if it was locked 360021525869Smrg if test no != "$need_locks"; then 3601e35772b2Smrg removelist=$lockfile 3602e35772b2Smrg $RM "$lockfile" 3603e35772b2Smrg fi 3604e35772b2Smrg } 360572b676d7Smrg 360672b676d7Smrg exit $EXIT_SUCCESS 3607e35772b2Smrg} 360872b676d7Smrg 3609e35772b2Smrg$opt_help || { 361021525869Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611e35772b2Smrg} 361272b676d7Smrg 3613e35772b2Smrgfunc_mode_help () 3614e35772b2Smrg{ 3615e35772b2Smrg # We need to display help for each of the modes. 361674c14cd6Smrg case $opt_mode in 3617e35772b2Smrg "") 3618e35772b2Smrg # Generic help is extracted from the usage comments 3619e35772b2Smrg # at the start of this file. 3620e35772b2Smrg func_help 3621e35772b2Smrg ;; 362272b676d7Smrg 3623e35772b2Smrg clean) 3624e35772b2Smrg $ECHO \ 3625e35772b2Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 362672b676d7Smrg 3627e35772b2SmrgRemove files from the build directory. 362872b676d7Smrg 3629e35772b2SmrgRM is the name of the program to use to delete files associated with each FILE 363021525869Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631e35772b2Smrgto RM. 363272b676d7Smrg 3633e35772b2SmrgIf FILE is a libtool library, object or program, all the files associated 3634e35772b2Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635e35772b2Smrg ;; 363672b676d7Smrg 3637e35772b2Smrg compile) 3638e35772b2Smrg $ECHO \ 3639e35772b2Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 364072b676d7Smrg 3641e35772b2SmrgCompile a source file into a libtool library object. 364272b676d7Smrg 3643e35772b2SmrgThis mode accepts the following additional options: 364472b676d7Smrg 3645e35772b2Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646e35772b2Smrg -no-suppress do not suppress compiler output for multiple passes 364774c14cd6Smrg -prefer-pic try to build PIC objects only 364874c14cd6Smrg -prefer-non-pic try to build non-PIC objects only 364921525869Smrg -shared do not build a '.o' file suitable for static linking 365021525869Smrg -static only build a '.o' file suitable for static linking 365174c14cd6Smrg -Wc,FLAG pass FLAG directly to the compiler 365272b676d7Smrg 365321525869SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654e35772b2Smrgfrom the given SOURCEFILE. 365572b676d7Smrg 3656e35772b2SmrgThe output file name is determined by removing the directory component from 365721525869SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365821525869Smrglibrary object suffix, '.lo'." 3659e35772b2Smrg ;; 366072b676d7Smrg 3661e35772b2Smrg execute) 3662e35772b2Smrg $ECHO \ 3663e35772b2Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 366472b676d7Smrg 3665e35772b2SmrgAutomatically set library path, then run a program. 366672b676d7Smrg 3667e35772b2SmrgThis mode accepts the following additional options: 366872b676d7Smrg 3669e35772b2Smrg -dlopen FILE add the directory containing FILE to the library path 367072b676d7Smrg 367121525869SmrgThis mode sets the library path environment variable according to '-dlopen' 3672e35772b2Smrgflags. 367372b676d7Smrg 3674e35772b2SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675e35772b2Smrginto their corresponding uninstalled binary, and any of their required library 3676e35772b2Smrgdirectories are added to the library path. 367772b676d7Smrg 3678e35772b2SmrgThen, COMMAND is executed, with ARGS as arguments." 3679e35772b2Smrg ;; 368072b676d7Smrg 3681e35772b2Smrg finish) 3682e35772b2Smrg $ECHO \ 3683e35772b2Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 368472b676d7Smrg 3685e35772b2SmrgComplete the installation of libtool libraries. 368672b676d7Smrg 3687e35772b2SmrgEach LIBDIR is a directory that contains libtool libraries. 368872b676d7Smrg 3689e35772b2SmrgThe commands that this mode executes may require superuser privileges. Use 369021525869Smrgthe '--dry-run' option if you just want to see what would be executed." 3691e35772b2Smrg ;; 369272b676d7Smrg 3693e35772b2Smrg install) 3694e35772b2Smrg $ECHO \ 3695e35772b2Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 369672b676d7Smrg 3697e35772b2SmrgInstall executables or libraries. 369872b676d7Smrg 3699e35772b2SmrgINSTALL-COMMAND is the installation command. The first component should be 370021525869Smrgeither the 'install' or 'cp' program. 370172b676d7Smrg 3702e35772b2SmrgThe following components of INSTALL-COMMAND are treated specially: 370372b676d7Smrg 370474c14cd6Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 370572b676d7Smrg 3706e35772b2SmrgThe rest of the components are interpreted as arguments to that command (only 3707e35772b2SmrgBSD-compatible install options are recognized)." 3708e35772b2Smrg ;; 370972b676d7Smrg 3710e35772b2Smrg link) 3711e35772b2Smrg $ECHO \ 3712e35772b2Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 371372b676d7Smrg 3714e35772b2SmrgLink object files or libraries together to form another library, or to 3715e35772b2Smrgcreate an executable program. 371672b676d7Smrg 3717e35772b2SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718e35772b2Smrga program from several object files. 371972b676d7Smrg 3720e35772b2SmrgThe following components of LINK-COMMAND are treated specially: 372172b676d7Smrg 3722e35772b2Smrg -all-static do not do any dynamic linking at all 3723e35772b2Smrg -avoid-version do not add a version suffix if possible 372474c14cd6Smrg -bindir BINDIR specify path to binaries directory (for systems where 372574c14cd6Smrg libraries must be found in the PATH setting at runtime) 372621525869Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727e35772b2Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728e35772b2Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729e35772b2Smrg -export-symbols SYMFILE 3730e35772b2Smrg try to export only the symbols listed in SYMFILE 3731e35772b2Smrg -export-symbols-regex REGEX 3732e35772b2Smrg try to export only the symbols matching REGEX 3733e35772b2Smrg -LLIBDIR search LIBDIR for required installed libraries 3734e35772b2Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735e35772b2Smrg -module build a library that can dlopened 3736e35772b2Smrg -no-fast-install disable the fast-install mode 3737e35772b2Smrg -no-install link a not-installable executable 3738e35772b2Smrg -no-undefined declare that a library does not refer to external symbols 3739e35772b2Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374021525869Smrg -objectlist FILE use a list of object files found in FILE to specify objects 374121525869Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742e35772b2Smrg -precious-files-regex REGEX 3743e35772b2Smrg don't remove output files matching REGEX 3744e35772b2Smrg -release RELEASE specify package release information 3745e35772b2Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746e35772b2Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747e35772b2Smrg -shared only do dynamic linking of libtool libraries 3748e35772b2Smrg -shrext SUFFIX override the standard shared library file extension 3749e35772b2Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3750e35772b2Smrg -static-libtool-libs 3751e35772b2Smrg do not do any dynamic linking of libtool libraries 3752e35772b2Smrg -version-info CURRENT[:REVISION[:AGE]] 3753e35772b2Smrg specify library version info [each variable defaults to 0] 3754e35772b2Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 375574c14cd6Smrg -Wc,FLAG 375674c14cd6Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375774c14cd6Smrg -Wl,FLAG 375874c14cd6Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375974c14cd6Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 376072b676d7Smrg 376121525869SmrgAll other options (arguments beginning with '-') are ignored. 376272b676d7Smrg 376321525869SmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764e35772b2Smrgtreated as uninstalled libtool libraries, other files are standard or library 3765e35772b2Smrgobject files. 37661fd23544Smrg 376721525869SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376821525869Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769e35772b2Smrgrequired, except when creating a convenience library. 377072b676d7Smrg 377121525869SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377221525869Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 377372b676d7Smrg 377421525869SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775e35772b2Smrgis created, otherwise an executable program is created." 377672b676d7Smrg ;; 377772b676d7Smrg 3778e35772b2Smrg uninstall) 3779e35772b2Smrg $ECHO \ 3780e35772b2Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 378172b676d7Smrg 3782e35772b2SmrgRemove libraries from an installation directory. 378372b676d7Smrg 3784e35772b2SmrgRM is the name of the program to use to delete files associated with each FILE 378521525869Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786e35772b2Smrgto RM. 378772b676d7Smrg 3788e35772b2SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789e35772b2SmrgOtherwise, only FILE itself is deleted using RM." 3790e35772b2Smrg ;; 379172b676d7Smrg 3792e35772b2Smrg *) 379321525869Smrg func_fatal_help "invalid operation mode '$opt_mode'" 3794e35772b2Smrg ;; 3795e35772b2Smrg esac 379672b676d7Smrg 379774c14cd6Smrg echo 379821525869Smrg $ECHO "Try '$progname --help' for more information about other modes." 3799e35772b2Smrg} 380072b676d7Smrg 380174c14cd6Smrg# Now that we've collected a possible --mode arg, show help if necessary 380274c14cd6Smrgif $opt_help; then 380321525869Smrg if test : = "$opt_help"; then 380474c14cd6Smrg func_mode_help 380574c14cd6Smrg else 380674c14cd6Smrg { 380774c14cd6Smrg func_help noexit 380874c14cd6Smrg for opt_mode in compile link execute install finish uninstall clean; do 380974c14cd6Smrg func_mode_help 381074c14cd6Smrg done 381121525869Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381274c14cd6Smrg { 381374c14cd6Smrg func_help noexit 381474c14cd6Smrg for opt_mode in compile link execute install finish uninstall clean; do 381574c14cd6Smrg echo 381674c14cd6Smrg func_mode_help 381774c14cd6Smrg done 381874c14cd6Smrg } | 381921525869Smrg $SED '1d 382074c14cd6Smrg /^When reporting/,/^Report/{ 382174c14cd6Smrg H 382274c14cd6Smrg d 382374c14cd6Smrg } 382474c14cd6Smrg $x 382574c14cd6Smrg /information about other modes/d 382674c14cd6Smrg /more detailed .*MODE/d 382774c14cd6Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382874c14cd6Smrg fi 382974c14cd6Smrg exit $? 383074c14cd6Smrgfi 383172b676d7Smrg 383272b676d7Smrg 3833e35772b2Smrg# func_mode_execute arg... 3834e35772b2Smrgfunc_mode_execute () 3835e35772b2Smrg{ 383621525869Smrg $debug_cmd 383721525869Smrg 3838e35772b2Smrg # The first argument is the command name. 383921525869Smrg cmd=$nonopt 3840e35772b2Smrg test -z "$cmd" && \ 3841e35772b2Smrg func_fatal_help "you must specify a COMMAND" 384272b676d7Smrg 3843e35772b2Smrg # Handle -dlopen flags immediately. 384474c14cd6Smrg for file in $opt_dlopen; do 3845e35772b2Smrg test -f "$file" \ 384621525869Smrg || func_fatal_help "'$file' is not a file" 384772b676d7Smrg 3848e35772b2Smrg dir= 3849e35772b2Smrg case $file in 3850e35772b2Smrg *.la) 385174c14cd6Smrg func_resolve_sysroot "$file" 385274c14cd6Smrg file=$func_resolve_sysroot_result 385374c14cd6Smrg 3854e35772b2Smrg # Check to see that this really is a libtool archive. 3855e35772b2Smrg func_lalib_unsafe_p "$file" \ 385621525869Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 385772b676d7Smrg 3858e35772b2Smrg # Read the libtool library. 3859e35772b2Smrg dlname= 3860e35772b2Smrg library_names= 3861e35772b2Smrg func_source "$file" 386272b676d7Smrg 3863e35772b2Smrg # Skip this library if it cannot be dlopened. 3864e35772b2Smrg if test -z "$dlname"; then 3865e35772b2Smrg # Warn if it was a shared library. 3866e35772b2Smrg test -n "$library_names" && \ 386721525869Smrg func_warning "'$file' was not linked with '-export-dynamic'" 3868e35772b2Smrg continue 3869e35772b2Smrg fi 387072b676d7Smrg 3871e35772b2Smrg func_dirname "$file" "" "." 387221525869Smrg dir=$func_dirname_result 387372b676d7Smrg 3874e35772b2Smrg if test -f "$dir/$objdir/$dlname"; then 387574c14cd6Smrg func_append dir "/$objdir" 3876e35772b2Smrg else 3877e35772b2Smrg if test ! -f "$dir/$dlname"; then 387821525869Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879e35772b2Smrg fi 3880e35772b2Smrg fi 388172b676d7Smrg ;; 388272b676d7Smrg 3883e35772b2Smrg *.lo) 3884e35772b2Smrg # Just add the directory containing the .lo file. 3885e35772b2Smrg func_dirname "$file" "" "." 388621525869Smrg dir=$func_dirname_result 388772b676d7Smrg ;; 388872b676d7Smrg 3889e35772b2Smrg *) 389021525869Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 389172b676d7Smrg continue 389272b676d7Smrg ;; 3893e35772b2Smrg esac 389472b676d7Smrg 3895e35772b2Smrg # Get the absolute pathname. 3896e35772b2Smrg absdir=`cd "$dir" && pwd` 389721525869Smrg test -n "$absdir" && dir=$absdir 389872b676d7Smrg 3899e35772b2Smrg # Now add the directory to shlibpath_var. 3900e35772b2Smrg if eval "test -z \"\$$shlibpath_var\""; then 3901e35772b2Smrg eval "$shlibpath_var=\"\$dir\"" 3902e35772b2Smrg else 3903e35772b2Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904e35772b2Smrg fi 3905e35772b2Smrg done 390672b676d7Smrg 3907e35772b2Smrg # This variable tells wrapper scripts just to set shlibpath_var 3908e35772b2Smrg # rather than running their programs. 390921525869Smrg libtool_execute_magic=$magic 391072b676d7Smrg 3911e35772b2Smrg # Check if any of the arguments is a wrapper script. 3912e35772b2Smrg args= 3913e35772b2Smrg for file 3914e35772b2Smrg do 3915e35772b2Smrg case $file in 391674c14cd6Smrg -* | *.la | *.lo ) ;; 3917e35772b2Smrg *) 3918e35772b2Smrg # Do a test to see if this is really a libtool program. 3919e35772b2Smrg if func_ltwrapper_script_p "$file"; then 3920e35772b2Smrg func_source "$file" 3921e35772b2Smrg # Transform arg to wrapped name. 392221525869Smrg file=$progdir/$program 3923e35772b2Smrg elif func_ltwrapper_executable_p "$file"; then 3924e35772b2Smrg func_ltwrapper_scriptname "$file" 3925e35772b2Smrg func_source "$func_ltwrapper_scriptname_result" 3926e35772b2Smrg # Transform arg to wrapped name. 392721525869Smrg file=$progdir/$program 3928e35772b2Smrg fi 3929e35772b2Smrg ;; 3930e35772b2Smrg esac 3931e35772b2Smrg # Quote arguments (to preserve shell metacharacters). 393274c14cd6Smrg func_append_quoted args "$file" 3933e35772b2Smrg done 393472b676d7Smrg 393521525869Smrg if $opt_dry_run; then 393621525869Smrg # Display what would be done. 393721525869Smrg if test -n "$shlibpath_var"; then 393821525869Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393921525869Smrg echo "export $shlibpath_var" 394021525869Smrg fi 394121525869Smrg $ECHO "$cmd$args" 394221525869Smrg exit $EXIT_SUCCESS 394321525869Smrg else 3944e35772b2Smrg if test -n "$shlibpath_var"; then 3945e35772b2Smrg # Export the shlibpath_var. 3946e35772b2Smrg eval "export $shlibpath_var" 3947e35772b2Smrg fi 394872b676d7Smrg 3949e35772b2Smrg # Restore saved environment variables 3950e35772b2Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951e35772b2Smrg do 3952e35772b2Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953e35772b2Smrg $lt_var=\$save_$lt_var; export $lt_var 395472b676d7Smrg else 3955e35772b2Smrg $lt_unset $lt_var 3956e35772b2Smrg fi" 3957e35772b2Smrg done 395872b676d7Smrg 3959e35772b2Smrg # Now prepare to actually exec the command. 396021525869Smrg exec_cmd=\$cmd$args 3961e35772b2Smrg fi 3962e35772b2Smrg} 396372b676d7Smrg 396421525869Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 396572b676d7Smrg 396672b676d7Smrg 3967e35772b2Smrg# func_mode_finish arg... 3968e35772b2Smrgfunc_mode_finish () 3969e35772b2Smrg{ 397021525869Smrg $debug_cmd 397121525869Smrg 397274c14cd6Smrg libs= 397374c14cd6Smrg libdirs= 3974e35772b2Smrg admincmds= 397572b676d7Smrg 397674c14cd6Smrg for opt in "$nonopt" ${1+"$@"} 397774c14cd6Smrg do 397874c14cd6Smrg if test -d "$opt"; then 397974c14cd6Smrg func_append libdirs " $opt" 398074c14cd6Smrg 398174c14cd6Smrg elif test -f "$opt"; then 398274c14cd6Smrg if func_lalib_unsafe_p "$opt"; then 398374c14cd6Smrg func_append libs " $opt" 398474c14cd6Smrg else 398521525869Smrg func_warning "'$opt' is not a valid libtool archive" 398674c14cd6Smrg fi 398774c14cd6Smrg 398874c14cd6Smrg else 398921525869Smrg func_fatal_error "invalid argument '$opt'" 399074c14cd6Smrg fi 399174c14cd6Smrg done 399274c14cd6Smrg 399374c14cd6Smrg if test -n "$libs"; then 399474c14cd6Smrg if test -n "$lt_sysroot"; then 399574c14cd6Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 399674c14cd6Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 399774c14cd6Smrg else 399874c14cd6Smrg sysroot_cmd= 399974c14cd6Smrg fi 400074c14cd6Smrg 400174c14cd6Smrg # Remove sysroot references 400274c14cd6Smrg if $opt_dry_run; then 400374c14cd6Smrg for lib in $libs; do 400421525869Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 400574c14cd6Smrg done 400674c14cd6Smrg else 400774c14cd6Smrg tmpdir=`func_mktempdir` 400874c14cd6Smrg for lib in $libs; do 400921525869Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 401074c14cd6Smrg > $tmpdir/tmp-la 401174c14cd6Smrg mv -f $tmpdir/tmp-la $lib 401274c14cd6Smrg done 401374c14cd6Smrg ${RM}r "$tmpdir" 401474c14cd6Smrg fi 401574c14cd6Smrg fi 401672b676d7Smrg 401774c14cd6Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018e35772b2Smrg for libdir in $libdirs; do 4019e35772b2Smrg if test -n "$finish_cmds"; then 4020e35772b2Smrg # Do each command in the finish commands. 4021e35772b2Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022e35772b2Smrg'"$cmd"'"' 402372b676d7Smrg fi 4024e35772b2Smrg if test -n "$finish_eval"; then 4025e35772b2Smrg # Do the single finish_eval. 4026e35772b2Smrg eval cmds=\"$finish_eval\" 402774c14cd6Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028e35772b2Smrg $cmds" 4029e35772b2Smrg fi 4030e35772b2Smrg done 4031e35772b2Smrg fi 403272b676d7Smrg 4033e35772b2Smrg # Exit here if they wanted silent mode. 403421525869Smrg $opt_quiet && exit $EXIT_SUCCESS 403572b676d7Smrg 403674c14cd6Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 403774c14cd6Smrg echo "----------------------------------------------------------------------" 403874c14cd6Smrg echo "Libraries have been installed in:" 403974c14cd6Smrg for libdir in $libdirs; do 404074c14cd6Smrg $ECHO " $libdir" 404174c14cd6Smrg done 404274c14cd6Smrg echo 404374c14cd6Smrg echo "If you ever happen to want to link against installed libraries" 404474c14cd6Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404521525869Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 404674c14cd6Smrg echo "flag during linking and do at least one of the following:" 404774c14cd6Smrg if test -n "$shlibpath_var"; then 404821525869Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 404974c14cd6Smrg echo " during execution" 405074c14cd6Smrg fi 405174c14cd6Smrg if test -n "$runpath_var"; then 405221525869Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 405374c14cd6Smrg echo " during linking" 405474c14cd6Smrg fi 405574c14cd6Smrg if test -n "$hardcode_libdir_flag_spec"; then 405674c14cd6Smrg libdir=LIBDIR 405774c14cd6Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4058e35772b2Smrg 405921525869Smrg $ECHO " - use the '$flag' linker flag" 406074c14cd6Smrg fi 406174c14cd6Smrg if test -n "$admincmds"; then 406274c14cd6Smrg $ECHO " - have your system administrator run these commands:$admincmds" 406374c14cd6Smrg fi 406474c14cd6Smrg if test -f /etc/ld.so.conf; then 406521525869Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 406674c14cd6Smrg fi 406774c14cd6Smrg echo 4068e35772b2Smrg 406974c14cd6Smrg echo "See any operating system documentation about shared libraries for" 407074c14cd6Smrg case $host in 407174c14cd6Smrg solaris2.[6789]|solaris2.1[0-9]) 407274c14cd6Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 407374c14cd6Smrg echo "pages." 407474c14cd6Smrg ;; 407574c14cd6Smrg *) 407674c14cd6Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 407774c14cd6Smrg ;; 407874c14cd6Smrg esac 407974c14cd6Smrg echo "----------------------------------------------------------------------" 408074c14cd6Smrg fi 4081e35772b2Smrg exit $EXIT_SUCCESS 4082e35772b2Smrg} 4083e35772b2Smrg 408421525869Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085e35772b2Smrg 4086e35772b2Smrg 4087e35772b2Smrg# func_mode_install arg... 4088e35772b2Smrgfunc_mode_install () 4089e35772b2Smrg{ 409021525869Smrg $debug_cmd 409121525869Smrg 4092e35772b2Smrg # There may be an optional sh(1) argument at the beginning of 4093e35772b2Smrg # install_prog (especially on Windows NT). 409421525869Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095e35772b2Smrg # Allow the use of GNU shtool's install command. 409621525869Smrg case $nonopt in *shtool*) :;; *) false;; esac 409721525869Smrg then 4098e35772b2Smrg # Aesthetically quote it. 4099e35772b2Smrg func_quote_for_eval "$nonopt" 4100e35772b2Smrg install_prog="$func_quote_for_eval_result " 4101e35772b2Smrg arg=$1 4102e35772b2Smrg shift 4103e35772b2Smrg else 4104e35772b2Smrg install_prog= 4105e35772b2Smrg arg=$nonopt 4106e35772b2Smrg fi 4107e35772b2Smrg 4108e35772b2Smrg # The real first argument should be the name of the installation program. 4109e35772b2Smrg # Aesthetically quote it. 4110e35772b2Smrg func_quote_for_eval "$arg" 411174c14cd6Smrg func_append install_prog "$func_quote_for_eval_result" 411274c14cd6Smrg install_shared_prog=$install_prog 411374c14cd6Smrg case " $install_prog " in 411474c14cd6Smrg *[\\\ /]cp\ *) install_cp=: ;; 411574c14cd6Smrg *) install_cp=false ;; 411674c14cd6Smrg esac 4117e35772b2Smrg 4118e35772b2Smrg # We need to accept at least all the BSD install flags. 4119e35772b2Smrg dest= 4120e35772b2Smrg files= 4121e35772b2Smrg opts= 4122e35772b2Smrg prev= 4123e35772b2Smrg install_type= 412421525869Smrg isdir=false 4125e35772b2Smrg stripme= 412674c14cd6Smrg no_mode=: 4127e35772b2Smrg for arg 4128e35772b2Smrg do 412974c14cd6Smrg arg2= 4130e35772b2Smrg if test -n "$dest"; then 413174c14cd6Smrg func_append files " $dest" 4132e35772b2Smrg dest=$arg 4133e35772b2Smrg continue 4134e35772b2Smrg fi 4135e35772b2Smrg 4136e35772b2Smrg case $arg in 413721525869Smrg -d) isdir=: ;; 4138e35772b2Smrg -f) 413974c14cd6Smrg if $install_cp; then :; else 414074c14cd6Smrg prev=$arg 414174c14cd6Smrg fi 4142e35772b2Smrg ;; 4143e35772b2Smrg -g | -m | -o) 4144e35772b2Smrg prev=$arg 4145e35772b2Smrg ;; 4146e35772b2Smrg -s) 4147e35772b2Smrg stripme=" -s" 4148e35772b2Smrg continue 4149e35772b2Smrg ;; 4150e35772b2Smrg -*) 4151e35772b2Smrg ;; 4152e35772b2Smrg *) 4153e35772b2Smrg # If the previous option needed an argument, then skip it. 4154e35772b2Smrg if test -n "$prev"; then 415521525869Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415674c14cd6Smrg arg2=$install_override_mode 415774c14cd6Smrg no_mode=false 415874c14cd6Smrg fi 415972b676d7Smrg prev= 416072b676d7Smrg else 4161e35772b2Smrg dest=$arg 4162e35772b2Smrg continue 416372b676d7Smrg fi 416472b676d7Smrg ;; 4165e35772b2Smrg esac 416672b676d7Smrg 4167e35772b2Smrg # Aesthetically quote the argument. 4168e35772b2Smrg func_quote_for_eval "$arg" 416974c14cd6Smrg func_append install_prog " $func_quote_for_eval_result" 417074c14cd6Smrg if test -n "$arg2"; then 417174c14cd6Smrg func_quote_for_eval "$arg2" 417274c14cd6Smrg fi 417374c14cd6Smrg func_append install_shared_prog " $func_quote_for_eval_result" 4174e35772b2Smrg done 417572b676d7Smrg 4176e35772b2Smrg test -z "$install_prog" && \ 4177e35772b2Smrg func_fatal_help "you must specify an install program" 417872b676d7Smrg 4179e35772b2Smrg test -n "$prev" && \ 418021525869Smrg func_fatal_help "the '$prev' option requires an argument" 418172b676d7Smrg 418274c14cd6Smrg if test -n "$install_override_mode" && $no_mode; then 418374c14cd6Smrg if $install_cp; then :; else 418474c14cd6Smrg func_quote_for_eval "$install_override_mode" 418574c14cd6Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418674c14cd6Smrg fi 418774c14cd6Smrg fi 418874c14cd6Smrg 4189e35772b2Smrg if test -z "$files"; then 4190e35772b2Smrg if test -z "$dest"; then 4191e35772b2Smrg func_fatal_help "no file or destination specified" 4192e35772b2Smrg else 4193e35772b2Smrg func_fatal_help "you must specify a destination" 4194e35772b2Smrg fi 419572b676d7Smrg fi 419672b676d7Smrg 4197e35772b2Smrg # Strip any trailing slash from the destination. 4198e35772b2Smrg func_stripname '' '/' "$dest" 4199e35772b2Smrg dest=$func_stripname_result 420072b676d7Smrg 4201e35772b2Smrg # Check to see that the destination is a directory. 420221525869Smrg test -d "$dest" && isdir=: 420321525869Smrg if $isdir; then 420421525869Smrg destdir=$dest 4205e35772b2Smrg destname= 420672b676d7Smrg else 4207e35772b2Smrg func_dirname_and_basename "$dest" "" "." 420821525869Smrg destdir=$func_dirname_result 420921525869Smrg destname=$func_basename_result 421072b676d7Smrg 4211e35772b2Smrg # Not a directory, so check to see that there is only one file specified. 4212e35772b2Smrg set dummy $files; shift 4213e35772b2Smrg test "$#" -gt 1 && \ 421421525869Smrg func_fatal_help "'$dest' is not a directory" 421572b676d7Smrg fi 4216e35772b2Smrg case $destdir in 4217e35772b2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 421872b676d7Smrg *) 4219e35772b2Smrg for file in $files; do 4220e35772b2Smrg case $file in 4221e35772b2Smrg *.lo) ;; 4222e35772b2Smrg *) 422321525869Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4224e35772b2Smrg ;; 4225e35772b2Smrg esac 4226e35772b2Smrg done 422772b676d7Smrg ;; 422872b676d7Smrg esac 422972b676d7Smrg 4230e35772b2Smrg # This variable tells wrapper scripts just to set variables rather 4231e35772b2Smrg # than running their programs. 423221525869Smrg libtool_install_magic=$magic 423372b676d7Smrg 4234e35772b2Smrg staticlibs= 4235e35772b2Smrg future_libdirs= 4236e35772b2Smrg current_libdirs= 4237e35772b2Smrg for file in $files; do 423872b676d7Smrg 4239e35772b2Smrg # Do each installation. 4240e35772b2Smrg case $file in 4241e35772b2Smrg *.$libext) 4242e35772b2Smrg # Do the static libraries later. 424374c14cd6Smrg func_append staticlibs " $file" 4244e35772b2Smrg ;; 4245e35772b2Smrg 4246e35772b2Smrg *.la) 424774c14cd6Smrg func_resolve_sysroot "$file" 424874c14cd6Smrg file=$func_resolve_sysroot_result 424974c14cd6Smrg 4250e35772b2Smrg # Check to see that this really is a libtool archive. 4251e35772b2Smrg func_lalib_unsafe_p "$file" \ 425221525869Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4253e35772b2Smrg 4254e35772b2Smrg library_names= 4255e35772b2Smrg old_library= 4256e35772b2Smrg relink_command= 4257e35772b2Smrg func_source "$file" 4258e35772b2Smrg 4259e35772b2Smrg # Add the libdir to current_libdirs if it is the destination. 4260e35772b2Smrg if test "X$destdir" = "X$libdir"; then 4261e35772b2Smrg case "$current_libdirs " in 4262e35772b2Smrg *" $libdir "*) ;; 426374c14cd6Smrg *) func_append current_libdirs " $libdir" ;; 426472b676d7Smrg esac 4265e35772b2Smrg else 4266e35772b2Smrg # Note the libdir as a future libdir. 4267e35772b2Smrg case "$future_libdirs " in 4268e35772b2Smrg *" $libdir "*) ;; 426974c14cd6Smrg *) func_append future_libdirs " $libdir" ;; 4270e35772b2Smrg esac 4271e35772b2Smrg fi 427272b676d7Smrg 4273e35772b2Smrg func_dirname "$file" "/" "" 427421525869Smrg dir=$func_dirname_result 427574c14cd6Smrg func_append dir "$objdir" 4276e35772b2Smrg 4277e35772b2Smrg if test -n "$relink_command"; then 4278e35772b2Smrg # Determine the prefix the user has applied to our future dir. 427974c14cd6Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280e35772b2Smrg 4281e35772b2Smrg # Don't allow the user to place us outside of our expected 4282e35772b2Smrg # location b/c this prevents finding dependent libraries that 4283e35772b2Smrg # are installed to the same prefix. 4284e35772b2Smrg # At present, this check doesn't affect windows .dll's that 4285e35772b2Smrg # are installed into $libdir/../bin (currently, that works fine) 4286e35772b2Smrg # but it's something to keep an eye on. 4287e35772b2Smrg test "$inst_prefix_dir" = "$destdir" && \ 428821525869Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289e35772b2Smrg 4290e35772b2Smrg if test -n "$inst_prefix_dir"; then 4291e35772b2Smrg # Stick the inst_prefix_dir data into the link command. 429274c14cd6Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293e35772b2Smrg else 429474c14cd6Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295e35772b2Smrg fi 4296e35772b2Smrg 429721525869Smrg func_warning "relinking '$file'" 4298e35772b2Smrg func_show_eval "$relink_command" \ 429921525869Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300e35772b2Smrg fi 4301e35772b2Smrg 4302e35772b2Smrg # See the names of the shared library. 4303e35772b2Smrg set dummy $library_names; shift 4304e35772b2Smrg if test -n "$1"; then 430521525869Smrg realname=$1 4306e35772b2Smrg shift 4307e35772b2Smrg 430821525869Smrg srcname=$realname 430921525869Smrg test -n "$relink_command" && srcname=${realname}T 4310e35772b2Smrg 4311e35772b2Smrg # Install the shared library and build the symlinks. 431274c14cd6Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313e35772b2Smrg 'exit $?' 431421525869Smrg tstripme=$stripme 4315e35772b2Smrg case $host_os in 4316e35772b2Smrg cygwin* | mingw* | pw32* | cegcc*) 4317e35772b2Smrg case $realname in 4318e35772b2Smrg *.dll.a) 431921525869Smrg tstripme= 432021525869Smrg ;; 432121525869Smrg esac 432221525869Smrg ;; 432321525869Smrg os2*) 432421525869Smrg case $realname in 432521525869Smrg *_dll.a) 432621525869Smrg tstripme= 4327e35772b2Smrg ;; 4328e35772b2Smrg esac 432972b676d7Smrg ;; 433072b676d7Smrg esac 4331e35772b2Smrg if test -n "$tstripme" && test -n "$striplib"; then 4332e35772b2Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 433372b676d7Smrg fi 4334e35772b2Smrg 4335e35772b2Smrg if test "$#" -gt 0; then 4336e35772b2Smrg # Delete the old symlinks, and create new ones. 433721525869Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338e35772b2Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339e35772b2Smrg # so we also need to try rm && ln -s. 4340e35772b2Smrg for linkname 4341e35772b2Smrg do 4342e35772b2Smrg test "$linkname" != "$realname" \ 4343e35772b2Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 434472b676d7Smrg done 434572b676d7Smrg fi 434672b676d7Smrg 4347e35772b2Smrg # Do each command in the postinstall commands. 434821525869Smrg lib=$destdir/$realname 4349e35772b2Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 435072b676d7Smrg fi 435172b676d7Smrg 4352e35772b2Smrg # Install the pseudo-library for information purposes. 4353e35772b2Smrg func_basename "$file" 435421525869Smrg name=$func_basename_result 435521525869Smrg instname=$dir/${name}i 4356e35772b2Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 435772b676d7Smrg 4358e35772b2Smrg # Maybe install the static library, too. 435974c14cd6Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360e35772b2Smrg ;; 436172b676d7Smrg 4362e35772b2Smrg *.lo) 4363e35772b2Smrg # Install (i.e. copy) a libtool object. 436472b676d7Smrg 4365e35772b2Smrg # Figure out destination file name, if it wasn't already specified. 4366e35772b2Smrg if test -n "$destname"; then 436721525869Smrg destfile=$destdir/$destname 4368e35772b2Smrg else 4369e35772b2Smrg func_basename "$file" 437021525869Smrg destfile=$func_basename_result 437121525869Smrg destfile=$destdir/$destfile 437272b676d7Smrg fi 437372b676d7Smrg 4374e35772b2Smrg # Deduce the name of the destination old-style object file. 4375e35772b2Smrg case $destfile in 4376e35772b2Smrg *.lo) 4377e35772b2Smrg func_lo2o "$destfile" 4378e35772b2Smrg staticdest=$func_lo2o_result 4379e35772b2Smrg ;; 4380e35772b2Smrg *.$objext) 438121525869Smrg staticdest=$destfile 4382e35772b2Smrg destfile= 4383e35772b2Smrg ;; 4384e35772b2Smrg *) 438521525869Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386e35772b2Smrg ;; 4387e35772b2Smrg esac 438872b676d7Smrg 4389e35772b2Smrg # Install the libtool object if requested. 4390e35772b2Smrg test -n "$destfile" && \ 4391e35772b2Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 439272b676d7Smrg 4393e35772b2Smrg # Install the old object if enabled. 439421525869Smrg if test yes = "$build_old_libs"; then 4395e35772b2Smrg # Deduce the name of the old-style object file. 4396e35772b2Smrg func_lo2o "$file" 4397e35772b2Smrg staticobj=$func_lo2o_result 4398e35772b2Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 439972b676d7Smrg fi 4400e35772b2Smrg exit $EXIT_SUCCESS 4401e35772b2Smrg ;; 440272b676d7Smrg 4403e35772b2Smrg *) 4404e35772b2Smrg # Figure out destination file name, if it wasn't already specified. 4405e35772b2Smrg if test -n "$destname"; then 440621525869Smrg destfile=$destdir/$destname 4407e35772b2Smrg else 4408e35772b2Smrg func_basename "$file" 440921525869Smrg destfile=$func_basename_result 441021525869Smrg destfile=$destdir/$destfile 4411e35772b2Smrg fi 441272b676d7Smrg 4413e35772b2Smrg # If the file is missing, and there is a .exe on the end, strip it 4414e35772b2Smrg # because it is most likely a libtool script we actually want to 4415e35772b2Smrg # install 441621525869Smrg stripped_ext= 4417e35772b2Smrg case $file in 4418e35772b2Smrg *.exe) 4419e35772b2Smrg if test ! -f "$file"; then 4420e35772b2Smrg func_stripname '' '.exe' "$file" 4421e35772b2Smrg file=$func_stripname_result 442221525869Smrg stripped_ext=.exe 4423e35772b2Smrg fi 4424e35772b2Smrg ;; 4425e35772b2Smrg esac 4426e35772b2Smrg 4427e35772b2Smrg # Do a test to see if this is really a libtool program. 4428e35772b2Smrg case $host in 4429e35772b2Smrg *cygwin* | *mingw*) 4430e35772b2Smrg if func_ltwrapper_executable_p "$file"; then 4431e35772b2Smrg func_ltwrapper_scriptname "$file" 4432e35772b2Smrg wrapper=$func_ltwrapper_scriptname_result 4433e35772b2Smrg else 4434e35772b2Smrg func_stripname '' '.exe' "$file" 4435e35772b2Smrg wrapper=$func_stripname_result 4436e35772b2Smrg fi 4437e35772b2Smrg ;; 443872b676d7Smrg *) 4439e35772b2Smrg wrapper=$file 4440e35772b2Smrg ;; 4441e35772b2Smrg esac 4442e35772b2Smrg if func_ltwrapper_script_p "$wrapper"; then 4443e35772b2Smrg notinst_deplibs= 4444e35772b2Smrg relink_command= 4445e35772b2Smrg 4446e35772b2Smrg func_source "$wrapper" 4447e35772b2Smrg 4448e35772b2Smrg # Check the variables that should have been set. 4449e35772b2Smrg test -z "$generated_by_libtool_version" && \ 445021525869Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451e35772b2Smrg 445221525869Smrg finalize=: 4453e35772b2Smrg for lib in $notinst_deplibs; do 4454e35772b2Smrg # Check to see that each library is installed. 4455e35772b2Smrg libdir= 4456e35772b2Smrg if test -f "$lib"; then 4457e35772b2Smrg func_source "$lib" 4458e35772b2Smrg fi 445921525869Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460e35772b2Smrg if test -n "$libdir" && test ! -f "$libfile"; then 446121525869Smrg func_warning "'$lib' has not been installed in '$libdir'" 446221525869Smrg finalize=false 4463e35772b2Smrg fi 4464e35772b2Smrg done 4465e35772b2Smrg 4466e35772b2Smrg relink_command= 4467e35772b2Smrg func_source "$wrapper" 4468e35772b2Smrg 4469e35772b2Smrg outputname= 447021525869Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4471e35772b2Smrg $opt_dry_run || { 447221525869Smrg if $finalize; then 4473e35772b2Smrg tmpdir=`func_mktempdir` 4474e35772b2Smrg func_basename "$file$stripped_ext" 447521525869Smrg file=$func_basename_result 447621525869Smrg outputname=$tmpdir/$file 4477e35772b2Smrg # Replace the output file specification. 447874c14cd6Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479e35772b2Smrg 448021525869Smrg $opt_quiet || { 4481e35772b2Smrg func_quote_for_expand "$relink_command" 4482e35772b2Smrg eval "func_echo $func_quote_for_expand_result" 4483e35772b2Smrg } 4484e35772b2Smrg if eval "$relink_command"; then : 4485e35772b2Smrg else 448621525869Smrg func_error "error: relink '$file' with the above command before installing it" 4487e35772b2Smrg $opt_dry_run || ${RM}r "$tmpdir" 4488e35772b2Smrg continue 4489e35772b2Smrg fi 449021525869Smrg file=$outputname 4491e35772b2Smrg else 449221525869Smrg func_warning "cannot relink '$file'" 4493e35772b2Smrg fi 4494e35772b2Smrg } 4495e35772b2Smrg else 4496e35772b2Smrg # Install the binary that we compiled earlier. 449774c14cd6Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 449872b676d7Smrg fi 4499e35772b2Smrg fi 4500e35772b2Smrg 4501e35772b2Smrg # remove .exe since cygwin /usr/bin/install will append another 4502e35772b2Smrg # one anyway 4503e35772b2Smrg case $install_prog,$host in 4504e35772b2Smrg */usr/bin/install*,*cygwin*) 4505e35772b2Smrg case $file:$destfile in 4506e35772b2Smrg *.exe:*.exe) 4507e35772b2Smrg # this is ok 4508e35772b2Smrg ;; 4509e35772b2Smrg *.exe:*) 4510e35772b2Smrg destfile=$destfile.exe 4511e35772b2Smrg ;; 4512e35772b2Smrg *:*.exe) 4513e35772b2Smrg func_stripname '' '.exe' "$destfile" 4514e35772b2Smrg destfile=$func_stripname_result 4515e35772b2Smrg ;; 4516e35772b2Smrg esac 451772b676d7Smrg ;; 451872b676d7Smrg esac 4519e35772b2Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520e35772b2Smrg $opt_dry_run || if test -n "$outputname"; then 4521e35772b2Smrg ${RM}r "$tmpdir" 4522e35772b2Smrg fi 4523e35772b2Smrg ;; 4524e35772b2Smrg esac 4525e35772b2Smrg done 452672b676d7Smrg 4527e35772b2Smrg for file in $staticlibs; do 4528e35772b2Smrg func_basename "$file" 452921525869Smrg name=$func_basename_result 4530e35772b2Smrg 4531e35772b2Smrg # Set up the ranlib parameters. 453221525869Smrg oldlib=$destdir/$name 453374c14cd6Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 453474c14cd6Smrg tool_oldlib=$func_to_tool_file_result 4535e35772b2Smrg 4536e35772b2Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537e35772b2Smrg 4538e35772b2Smrg if test -n "$stripme" && test -n "$old_striplib"; then 453974c14cd6Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540e35772b2Smrg fi 4541e35772b2Smrg 4542e35772b2Smrg # Do each command in the postinstall commands. 4543e35772b2Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544e35772b2Smrg done 4545e35772b2Smrg 4546e35772b2Smrg test -n "$future_libdirs" && \ 454721525869Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548e35772b2Smrg 4549e35772b2Smrg if test -n "$current_libdirs"; then 4550e35772b2Smrg # Maybe just do a dry run. 4551e35772b2Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455221525869Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553e35772b2Smrg else 4554e35772b2Smrg exit $EXIT_SUCCESS 4555e35772b2Smrg fi 4556e35772b2Smrg} 4557e35772b2Smrg 455821525869Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559e35772b2Smrg 4560e35772b2Smrg 4561e35772b2Smrg# func_generate_dlsyms outputname originator pic_p 4562e35772b2Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563e35772b2Smrg# a dlpreopen symbol table. 4564e35772b2Smrgfunc_generate_dlsyms () 4565e35772b2Smrg{ 456621525869Smrg $debug_cmd 456721525869Smrg 456821525869Smrg my_outputname=$1 456921525869Smrg my_originator=$2 457021525869Smrg my_pic_p=${3-false} 457121525869Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572e35772b2Smrg my_dlsyms= 4573e35772b2Smrg 457421525869Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575e35772b2Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457621525869Smrg my_dlsyms=${my_outputname}S.c 4577e35772b2Smrg else 4578e35772b2Smrg func_error "not configured to extract global symbols from dlpreopened files" 4579e35772b2Smrg fi 4580e35772b2Smrg fi 4581e35772b2Smrg 4582e35772b2Smrg if test -n "$my_dlsyms"; then 4583e35772b2Smrg case $my_dlsyms in 4584e35772b2Smrg "") ;; 4585e35772b2Smrg *.c) 4586e35772b2Smrg # Discover the nlist of each of the dlfiles. 458721525869Smrg nlist=$output_objdir/$my_outputname.nm 4588e35772b2Smrg 4589e35772b2Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590e35772b2Smrg 4591e35772b2Smrg # Parse the name list into a source file. 4592e35772b2Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4593e35772b2Smrg 4594e35772b2Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459521525869Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459621525869Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597e35772b2Smrg 4598e35772b2Smrg#ifdef __cplusplus 4599e35772b2Smrgextern \"C\" { 4600e35772b2Smrg#endif 4601e35772b2Smrg 460221525869Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460374c14cd6Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460474c14cd6Smrg#endif 460574c14cd6Smrg 460674c14cd6Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460721525869Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460821525869Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 460974c14cd6Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 461074c14cd6Smrg# define LT_DLSYM_CONST 461121525869Smrg#elif defined __osf__ 461274c14cd6Smrg/* This system does not cope well with relocations in const data. */ 461374c14cd6Smrg# define LT_DLSYM_CONST 461474c14cd6Smrg#else 461574c14cd6Smrg# define LT_DLSYM_CONST const 461674c14cd6Smrg#endif 461774c14cd6Smrg 461821525869Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461921525869Smrg 4620e35772b2Smrg/* External symbol declarations for the compiler. */\ 4621e35772b2Smrg" 4622e35772b2Smrg 462321525869Smrg if test yes = "$dlself"; then 462421525869Smrg func_verbose "generating symbol list for '$output'" 4625e35772b2Smrg 4626e35772b2Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627e35772b2Smrg 4628e35772b2Smrg # Add our own program objects to the symbol list. 462974c14cd6Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630e35772b2Smrg for progfile in $progfiles; do 463174c14cd6Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463221525869Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 463374c14cd6Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634e35772b2Smrg done 4635e35772b2Smrg 4636e35772b2Smrg if test -n "$exclude_expsyms"; then 4637e35772b2Smrg $opt_dry_run || { 4638e35772b2Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639e35772b2Smrg eval '$MV "$nlist"T "$nlist"' 4640e35772b2Smrg } 464172b676d7Smrg fi 4642e35772b2Smrg 4643e35772b2Smrg if test -n "$export_symbols_regex"; then 4644e35772b2Smrg $opt_dry_run || { 4645e35772b2Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646e35772b2Smrg eval '$MV "$nlist"T "$nlist"' 4647e35772b2Smrg } 4648e35772b2Smrg fi 4649e35772b2Smrg 4650e35772b2Smrg # Prepare the list of exported symbols 4651e35772b2Smrg if test -z "$export_symbols"; then 465221525869Smrg export_symbols=$output_objdir/$outputname.exp 4653e35772b2Smrg $opt_dry_run || { 4654e35772b2Smrg $RM $export_symbols 465521525869Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656e35772b2Smrg case $host in 4657e35772b2Smrg *cygwin* | *mingw* | *cegcc* ) 4658e35772b2Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659e35772b2Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660e35772b2Smrg ;; 4661e35772b2Smrg esac 4662e35772b2Smrg } 466372b676d7Smrg else 4664e35772b2Smrg $opt_dry_run || { 466521525869Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666e35772b2Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667e35772b2Smrg eval '$MV "$nlist"T "$nlist"' 4668e35772b2Smrg case $host in 466974c14cd6Smrg *cygwin* | *mingw* | *cegcc* ) 4670e35772b2Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671e35772b2Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672e35772b2Smrg ;; 4673e35772b2Smrg esac 4674e35772b2Smrg } 467572b676d7Smrg fi 4676e35772b2Smrg fi 467772b676d7Smrg 4678e35772b2Smrg for dlprefile in $dlprefiles; do 467921525869Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4680e35772b2Smrg func_basename "$dlprefile" 468121525869Smrg name=$func_basename_result 468274c14cd6Smrg case $host in 468374c14cd6Smrg *cygwin* | *mingw* | *cegcc* ) 468474c14cd6Smrg # if an import library, we need to obtain dlname 468574c14cd6Smrg if func_win32_import_lib_p "$dlprefile"; then 468674c14cd6Smrg func_tr_sh "$dlprefile" 468774c14cd6Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468821525869Smrg dlprefile_dlbasename= 468974c14cd6Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 469074c14cd6Smrg # Use subshell, to avoid clobbering current variable values 469174c14cd6Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469221525869Smrg if test -n "$dlprefile_dlname"; then 469374c14cd6Smrg func_basename "$dlprefile_dlname" 469421525869Smrg dlprefile_dlbasename=$func_basename_result 469574c14cd6Smrg else 469674c14cd6Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 469774c14cd6Smrg $sharedlib_from_linklib_cmd "$dlprefile" 469874c14cd6Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 469974c14cd6Smrg fi 470074c14cd6Smrg fi 470174c14cd6Smrg $opt_dry_run || { 470221525869Smrg if test -n "$dlprefile_dlbasename"; then 470374c14cd6Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 470474c14cd6Smrg else 470574c14cd6Smrg func_warning "Could not compute DLL name from $name" 470674c14cd6Smrg eval '$ECHO ": $name " >> "$nlist"' 470774c14cd6Smrg fi 470874c14cd6Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 470974c14cd6Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 471074c14cd6Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 471174c14cd6Smrg } 471274c14cd6Smrg else # not an import lib 471374c14cd6Smrg $opt_dry_run || { 471474c14cd6Smrg eval '$ECHO ": $name " >> "$nlist"' 471574c14cd6Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 471674c14cd6Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 471774c14cd6Smrg } 471874c14cd6Smrg fi 471974c14cd6Smrg ;; 472074c14cd6Smrg *) 472174c14cd6Smrg $opt_dry_run || { 472274c14cd6Smrg eval '$ECHO ": $name " >> "$nlist"' 472374c14cd6Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 472474c14cd6Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 472574c14cd6Smrg } 472674c14cd6Smrg ;; 472774c14cd6Smrg esac 4728e35772b2Smrg done 4729e35772b2Smrg 4730e35772b2Smrg $opt_dry_run || { 4731e35772b2Smrg # Make sure we have at least an empty file. 4732e35772b2Smrg test -f "$nlist" || : > "$nlist" 4733e35772b2Smrg 4734e35772b2Smrg if test -n "$exclude_expsyms"; then 4735e35772b2Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736e35772b2Smrg $MV "$nlist"T "$nlist" 473772b676d7Smrg fi 4738e35772b2Smrg 4739e35772b2Smrg # Try sorting and uniquifying the output. 4740e35772b2Smrg if $GREP -v "^: " < "$nlist" | 4741e35772b2Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742e35772b2Smrg sort -k 3 4743e35772b2Smrg else 4744e35772b2Smrg sort +2 4745e35772b2Smrg fi | 4746e35772b2Smrg uniq > "$nlist"S; then 4747e35772b2Smrg : 474872b676d7Smrg else 4749e35772b2Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 475072b676d7Smrg fi 475172b676d7Smrg 4752e35772b2Smrg if test -f "$nlist"S; then 4753e35772b2Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 475472b676d7Smrg else 475574c14cd6Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 475672b676d7Smrg fi 475772b676d7Smrg 475821525869Smrg func_show_eval '$RM "${nlist}I"' 475921525869Smrg if test -n "$global_symbol_to_import"; then 476021525869Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476121525869Smrg fi 476221525869Smrg 476374c14cd6Smrg echo >> "$output_objdir/$my_dlsyms" "\ 476472b676d7Smrg 4765e35772b2Smrg/* The mapping between symbol names and symbols. */ 4766e35772b2Smrgtypedef struct { 4767e35772b2Smrg const char *name; 4768e35772b2Smrg void *address; 4769e35772b2Smrg} lt_dlsymlist; 477074c14cd6Smrgextern LT_DLSYM_CONST lt_dlsymlist 477121525869Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477221525869Smrg" 477321525869Smrg 477421525869Smrg if test -s "$nlist"I; then 477521525869Smrg echo >> "$output_objdir/$my_dlsyms" "\ 477621525869Smrgstatic void lt_syminit(void) 477721525869Smrg{ 477821525869Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477921525869Smrg for (; symbol->name; ++symbol) 478021525869Smrg {" 478121525869Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478221525869Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478321525869Smrg } 478421525869Smrg}" 478521525869Smrg fi 478621525869Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478774c14cd6SmrgLT_DLSYM_CONST lt_dlsymlist 4788e35772b2Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 478921525869Smrg{ {\"$my_originator\", (void *) 0}," 479021525869Smrg 479121525869Smrg if test -s "$nlist"I; then 479221525869Smrg echo >> "$output_objdir/$my_dlsyms" "\ 479321525869Smrg {\"@INIT@\", (void *) <_syminit}," 479421525869Smrg fi 479572b676d7Smrg 4796e35772b2Smrg case $need_lib_prefix in 4797e35772b2Smrg no) 4798e35772b2Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799e35772b2Smrg ;; 4800e35772b2Smrg *) 4801e35772b2Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802e35772b2Smrg ;; 4803e35772b2Smrg esac 480474c14cd6Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4805e35772b2Smrg {0, (void *) 0} 4806e35772b2Smrg}; 480772b676d7Smrg 4808e35772b2Smrg/* This works around a problem in FreeBSD linker */ 4809e35772b2Smrg#ifdef FREEBSD_WORKAROUND 4810e35772b2Smrgstatic const void *lt_preloaded_setup() { 4811e35772b2Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812e35772b2Smrg} 4813e35772b2Smrg#endif 4814e35772b2Smrg 4815e35772b2Smrg#ifdef __cplusplus 4816e35772b2Smrg} 4817e35772b2Smrg#endif\ 4818e35772b2Smrg" 4819e35772b2Smrg } # !$opt_dry_run 4820e35772b2Smrg 4821e35772b2Smrg pic_flag_for_symtable= 4822e35772b2Smrg case "$compile_command " in 4823e35772b2Smrg *" -static "*) ;; 4824e35772b2Smrg *) 4825e35772b2Smrg case $host in 4826e35772b2Smrg # compiling the symbol table file with pic_flag works around 4827e35772b2Smrg # a FreeBSD bug that causes programs to crash when -lm is 4828e35772b2Smrg # linked before any other PIC object. But we must not use 4829e35772b2Smrg # pic_flag when linking with -static. The problem exists in 4830e35772b2Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 483174c14cd6Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832e35772b2Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833e35772b2Smrg *-*-hpux*) 4834e35772b2Smrg pic_flag_for_symtable=" $pic_flag" ;; 4835e35772b2Smrg *) 483621525869Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837e35772b2Smrg ;; 4838e35772b2Smrg esac 4839e35772b2Smrg ;; 4840e35772b2Smrg esac 4841e35772b2Smrg symtab_cflags= 4842e35772b2Smrg for arg in $LTCFLAGS; do 4843e35772b2Smrg case $arg in 4844e35772b2Smrg -pie | -fpie | -fPIE) ;; 484574c14cd6Smrg *) func_append symtab_cflags " $arg" ;; 4846e35772b2Smrg esac 4847e35772b2Smrg done 484872b676d7Smrg 4849e35772b2Smrg # Now compile the dynamic symbol file. 4850e35772b2Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 485172b676d7Smrg 4852e35772b2Smrg # Clean up the generated files. 485321525869Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 485472b676d7Smrg 4855e35772b2Smrg # Transform the symbol file into the correct name. 485621525869Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857e35772b2Smrg case $host in 4858e35772b2Smrg *cygwin* | *mingw* | *cegcc* ) 4859e35772b2Smrg if test -f "$output_objdir/$my_outputname.def"; then 486074c14cd6Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486174c14cd6Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862e35772b2Smrg else 486374c14cd6Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486474c14cd6Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486572b676d7Smrg fi 4866e35772b2Smrg ;; 4867e35772b2Smrg *) 486874c14cd6Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486974c14cd6Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870e35772b2Smrg ;; 4871e35772b2Smrg esac 4872e35772b2Smrg ;; 4873e35772b2Smrg *) 487421525869Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875e35772b2Smrg ;; 4876e35772b2Smrg esac 4877e35772b2Smrg else 4878e35772b2Smrg # We keep going just in case the user didn't refer to 4879e35772b2Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880e35772b2Smrg # really was required. 488172b676d7Smrg 4882e35772b2Smrg # Nullify the symbol file. 488374c14cd6Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488474c14cd6Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885e35772b2Smrg fi 4886e35772b2Smrg} 488772b676d7Smrg 488821525869Smrg# func_cygming_gnu_implib_p ARG 488921525869Smrg# This predicate returns with zero status (TRUE) if 489021525869Smrg# ARG is a GNU/binutils-style import library. Returns 489121525869Smrg# with nonzero status (FALSE) otherwise. 489221525869Smrgfunc_cygming_gnu_implib_p () 489321525869Smrg{ 489421525869Smrg $debug_cmd 489521525869Smrg 489621525869Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489721525869Smrg 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)$'` 489821525869Smrg test -n "$func_cygming_gnu_implib_tmp" 489921525869Smrg} 490021525869Smrg 490121525869Smrg# func_cygming_ms_implib_p ARG 490221525869Smrg# This predicate returns with zero status (TRUE) if 490321525869Smrg# ARG is an MS-style import library. Returns 490421525869Smrg# with nonzero status (FALSE) otherwise. 490521525869Smrgfunc_cygming_ms_implib_p () 490621525869Smrg{ 490721525869Smrg $debug_cmd 490821525869Smrg 490921525869Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491021525869Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491121525869Smrg test -n "$func_cygming_ms_implib_tmp" 491221525869Smrg} 491321525869Smrg 4914e35772b2Smrg# func_win32_libid arg 4915e35772b2Smrg# return the library type of file 'arg' 4916e35772b2Smrg# 4917e35772b2Smrg# Need a lot of goo to handle *both* DLLs and import libs 4918e35772b2Smrg# Has to be a shell function in order to 'eat' the argument 4919e35772b2Smrg# that is supplied when $file_magic_command is called. 492074c14cd6Smrg# Despite the name, also deal with 64 bit binaries. 4921e35772b2Smrgfunc_win32_libid () 4922e35772b2Smrg{ 492321525869Smrg $debug_cmd 492421525869Smrg 492521525869Smrg win32_libid_type=unknown 4926e35772b2Smrg win32_fileres=`file -L $1 2>/dev/null` 4927e35772b2Smrg case $win32_fileres in 4928e35772b2Smrg *ar\ archive\ import\ library*) # definitely import 4929e35772b2Smrg win32_libid_type="x86 archive import" 4930e35772b2Smrg ;; 4931e35772b2Smrg *ar\ archive*) # could be an import, or static 493274c14cd6Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933e35772b2Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493474c14cd6Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493521525869Smrg case $nm_interface in 493621525869Smrg "MS dumpbin") 493721525869Smrg if func_cygming_ms_implib_p "$1" || 493821525869Smrg func_cygming_gnu_implib_p "$1" 493921525869Smrg then 494021525869Smrg win32_nmres=import 494121525869Smrg else 494221525869Smrg win32_nmres= 494321525869Smrg fi 494421525869Smrg ;; 494521525869Smrg *) 494621525869Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494721525869Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494821525869Smrg $SED -n -e ' 4949e35772b2Smrg 1,100{ 4950e35772b2Smrg / I /{ 495121525869Smrg s|.*|import| 4952e35772b2Smrg p 4953e35772b2Smrg q 4954e35772b2Smrg } 4955e35772b2Smrg }'` 495621525869Smrg ;; 495721525869Smrg esac 4958e35772b2Smrg case $win32_nmres in 4959e35772b2Smrg import*) win32_libid_type="x86 archive import";; 4960e35772b2Smrg *) win32_libid_type="x86 archive static";; 4961e35772b2Smrg esac 4962e35772b2Smrg fi 4963e35772b2Smrg ;; 4964e35772b2Smrg *DLL*) 4965e35772b2Smrg win32_libid_type="x86 DLL" 4966e35772b2Smrg ;; 4967e35772b2Smrg *executable*) # but shell scripts are "executable" too... 4968e35772b2Smrg case $win32_fileres in 4969e35772b2Smrg *MS\ Windows\ PE\ Intel*) 4970e35772b2Smrg win32_libid_type="x86 DLL" 4971e35772b2Smrg ;; 4972e35772b2Smrg esac 4973e35772b2Smrg ;; 4974e35772b2Smrg esac 4975e35772b2Smrg $ECHO "$win32_libid_type" 4976e35772b2Smrg} 497772b676d7Smrg 497874c14cd6Smrg# func_cygming_dll_for_implib ARG 497974c14cd6Smrg# 498074c14cd6Smrg# Platform-specific function to extract the 498174c14cd6Smrg# name of the DLL associated with the specified 498274c14cd6Smrg# import library ARG. 498374c14cd6Smrg# Invoked by eval'ing the libtool variable 498474c14cd6Smrg# $sharedlib_from_linklib_cmd 498574c14cd6Smrg# Result is available in the variable 498674c14cd6Smrg# $sharedlib_from_linklib_result 498774c14cd6Smrgfunc_cygming_dll_for_implib () 498874c14cd6Smrg{ 498921525869Smrg $debug_cmd 499021525869Smrg 499174c14cd6Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 499274c14cd6Smrg} 499374c14cd6Smrg 499474c14cd6Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 499574c14cd6Smrg# 499674c14cd6Smrg# The is the core of a fallback implementation of a 499774c14cd6Smrg# platform-specific function to extract the name of the 499874c14cd6Smrg# DLL associated with the specified import library LIBNAME. 499974c14cd6Smrg# 500074c14cd6Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 500174c14cd6Smrg# on the platform and compiler that created the implib. 500274c14cd6Smrg# 500374c14cd6Smrg# Echos the name of the DLL associated with the 500474c14cd6Smrg# specified import library. 500574c14cd6Smrgfunc_cygming_dll_for_implib_fallback_core () 500674c14cd6Smrg{ 500721525869Smrg $debug_cmd 500821525869Smrg 500974c14cd6Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 501074c14cd6Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 501174c14cd6Smrg $SED '/^Contents of section '"$match_literal"':/{ 501274c14cd6Smrg # Place marker at beginning of archive member dllname section 501374c14cd6Smrg s/.*/====MARK====/ 501474c14cd6Smrg p 501574c14cd6Smrg d 501674c14cd6Smrg } 501774c14cd6Smrg # These lines can sometimes be longer than 43 characters, but 501874c14cd6Smrg # are always uninteresting 501974c14cd6Smrg /:[ ]*file format pe[i]\{,1\}-/d 502074c14cd6Smrg /^In archive [^:]*:/d 502174c14cd6Smrg # Ensure marker is printed 502274c14cd6Smrg /^====MARK====/p 502374c14cd6Smrg # Remove all lines with less than 43 characters 502474c14cd6Smrg /^.\{43\}/!d 502574c14cd6Smrg # From remaining lines, remove first 43 characters 502674c14cd6Smrg s/^.\{43\}//' | 502774c14cd6Smrg $SED -n ' 502874c14cd6Smrg # Join marker and all lines until next marker into a single line 502974c14cd6Smrg /^====MARK====/ b para 503074c14cd6Smrg H 503174c14cd6Smrg $ b para 503274c14cd6Smrg b 503374c14cd6Smrg :para 503474c14cd6Smrg x 503574c14cd6Smrg s/\n//g 503674c14cd6Smrg # Remove the marker 503774c14cd6Smrg s/^====MARK====// 503874c14cd6Smrg # Remove trailing dots and whitespace 503974c14cd6Smrg s/[\. \t]*$// 504074c14cd6Smrg # Print 504174c14cd6Smrg /./p' | 504274c14cd6Smrg # we now have a list, one entry per line, of the stringified 504374c14cd6Smrg # contents of the appropriate section of all members of the 504421525869Smrg # archive that possess that section. Heuristic: eliminate 504521525869Smrg # all those that have a first or second character that is 504674c14cd6Smrg # a '.' (that is, objdump's representation of an unprintable 504774c14cd6Smrg # character.) This should work for all archives with less than 504874c14cd6Smrg # 0x302f exports -- but will fail for DLLs whose name actually 504974c14cd6Smrg # begins with a literal '.' or a single character followed by 505074c14cd6Smrg # a '.'. 505174c14cd6Smrg # 505274c14cd6Smrg # Of those that remain, print the first one. 505374c14cd6Smrg $SED -e '/^\./d;/^.\./d;q' 505474c14cd6Smrg} 505574c14cd6Smrg 505674c14cd6Smrg# func_cygming_dll_for_implib_fallback ARG 505774c14cd6Smrg# Platform-specific function to extract the 505874c14cd6Smrg# name of the DLL associated with the specified 505974c14cd6Smrg# import library ARG. 506074c14cd6Smrg# 506174c14cd6Smrg# This fallback implementation is for use when $DLLTOOL 506274c14cd6Smrg# does not support the --identify-strict option. 506374c14cd6Smrg# Invoked by eval'ing the libtool variable 506474c14cd6Smrg# $sharedlib_from_linklib_cmd 506574c14cd6Smrg# Result is available in the variable 506674c14cd6Smrg# $sharedlib_from_linklib_result 506774c14cd6Smrgfunc_cygming_dll_for_implib_fallback () 506874c14cd6Smrg{ 506921525869Smrg $debug_cmd 507021525869Smrg 507121525869Smrg if func_cygming_gnu_implib_p "$1"; then 507274c14cd6Smrg # binutils import library 507374c14cd6Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507421525869Smrg elif func_cygming_ms_implib_p "$1"; then 507574c14cd6Smrg # ms-generated import library 507674c14cd6Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 507774c14cd6Smrg else 507874c14cd6Smrg # unknown 507921525869Smrg sharedlib_from_linklib_result= 508074c14cd6Smrg fi 508174c14cd6Smrg} 508272b676d7Smrg 508372b676d7Smrg 5084e35772b2Smrg# func_extract_an_archive dir oldlib 5085e35772b2Smrgfunc_extract_an_archive () 5086e35772b2Smrg{ 508721525869Smrg $debug_cmd 508821525869Smrg 508921525869Smrg f_ex_an_ar_dir=$1; shift 509021525869Smrg f_ex_an_ar_oldlib=$1 509121525869Smrg if test yes = "$lock_old_archive_extraction"; then 509274c14cd6Smrg lockfile=$f_ex_an_ar_oldlib.lock 509374c14cd6Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509474c14cd6Smrg func_echo "Waiting for $lockfile to be removed" 509574c14cd6Smrg sleep 2 509674c14cd6Smrg done 509774c14cd6Smrg fi 509874c14cd6Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509974c14cd6Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510021525869Smrg if test yes = "$lock_old_archive_extraction"; then 510174c14cd6Smrg $opt_dry_run || rm -f "$lockfile" 510274c14cd6Smrg fi 5103e35772b2Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104e35772b2Smrg : 5105e35772b2Smrg else 5106e35772b2Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107e35772b2Smrg fi 5108e35772b2Smrg} 510972b676d7Smrg 511072b676d7Smrg 5111e35772b2Smrg# func_extract_archives gentop oldlib ... 5112e35772b2Smrgfunc_extract_archives () 5113e35772b2Smrg{ 511421525869Smrg $debug_cmd 511521525869Smrg 511621525869Smrg my_gentop=$1; shift 5117e35772b2Smrg my_oldlibs=${1+"$@"} 511821525869Smrg my_oldobjs= 511921525869Smrg my_xlib= 512021525869Smrg my_xabs= 512121525869Smrg my_xdir= 512272b676d7Smrg 5123e35772b2Smrg for my_xlib in $my_oldlibs; do 5124e35772b2Smrg # Extract the objects. 5125e35772b2Smrg case $my_xlib in 512621525869Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127e35772b2Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128e35772b2Smrg esac 5129e35772b2Smrg func_basename "$my_xlib" 513021525869Smrg my_xlib=$func_basename_result 5131e35772b2Smrg my_xlib_u=$my_xlib 5132e35772b2Smrg while :; do 5133e35772b2Smrg case " $extracted_archives " in 5134e35772b2Smrg *" $my_xlib_u "*) 5135e35772b2Smrg func_arith $extracted_serial + 1 5136e35772b2Smrg extracted_serial=$func_arith_result 5137e35772b2Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138e35772b2Smrg *) break ;; 5139e35772b2Smrg esac 5140e35772b2Smrg done 5141e35772b2Smrg extracted_archives="$extracted_archives $my_xlib_u" 514221525869Smrg my_xdir=$my_gentop/$my_xlib_u 514372b676d7Smrg 5144e35772b2Smrg func_mkdir_p "$my_xdir" 514572b676d7Smrg 5146e35772b2Smrg case $host in 5147e35772b2Smrg *-darwin*) 5148e35772b2Smrg func_verbose "Extracting $my_xabs" 5149e35772b2Smrg # Do not bother doing anything if just a dry run 5150e35772b2Smrg $opt_dry_run || { 5151e35772b2Smrg darwin_orig_dir=`pwd` 5152e35772b2Smrg cd $my_xdir || exit $? 5153e35772b2Smrg darwin_archive=$my_xabs 5154e35772b2Smrg darwin_curdir=`pwd` 515521525869Smrg func_basename "$darwin_archive" 515621525869Smrg darwin_base_archive=$func_basename_result 5157e35772b2Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158e35772b2Smrg if test -n "$darwin_arches"; then 5159e35772b2Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160e35772b2Smrg darwin_arch= 5161e35772b2Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516221525869Smrg for darwin_arch in $darwin_arches; do 516321525869Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516421525869Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516521525869Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516621525869Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167e35772b2Smrg cd "$darwin_curdir" 516821525869Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169e35772b2Smrg done # $darwin_arches 5170e35772b2Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517121525869Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172e35772b2Smrg darwin_file= 5173e35772b2Smrg darwin_files= 5174e35772b2Smrg for darwin_file in $darwin_filelist; do 517574c14cd6Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176e35772b2Smrg $LIPO -create -output "$darwin_file" $darwin_files 5177e35772b2Smrg done # $darwin_filelist 5178e35772b2Smrg $RM -rf unfat-$$ 5179e35772b2Smrg cd "$darwin_orig_dir" 518072b676d7Smrg else 5181e35772b2Smrg cd $darwin_orig_dir 5182e35772b2Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183e35772b2Smrg fi # $darwin_arches 5184e35772b2Smrg } # !$opt_dry_run 5185e35772b2Smrg ;; 5186e35772b2Smrg *) 5187e35772b2Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188e35772b2Smrg ;; 5189e35772b2Smrg esac 519074c14cd6Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191e35772b2Smrg done 519272b676d7Smrg 519321525869Smrg func_extract_archives_result=$my_oldobjs 5194e35772b2Smrg} 519572b676d7Smrg 519672b676d7Smrg 519774c14cd6Smrg# func_emit_wrapper [arg=no] 519874c14cd6Smrg# 519974c14cd6Smrg# Emit a libtool wrapper script on stdout. 520074c14cd6Smrg# Don't directly open a file because we may want to 520174c14cd6Smrg# incorporate the script contents within a cygwin/mingw 520274c14cd6Smrg# wrapper executable. Must ONLY be called from within 520374c14cd6Smrg# func_mode_link because it depends on a number of variables 520474c14cd6Smrg# set therein. 5205e35772b2Smrg# 520674c14cd6Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520774c14cd6Smrg# variable will take. If 'yes', then the emitted script 520821525869Smrg# will assume that the directory where it is stored is 520974c14cd6Smrg# the $objdir directory. This is a cygwin/mingw-specific 521074c14cd6Smrg# behavior. 521174c14cd6Smrgfunc_emit_wrapper () 5212e35772b2Smrg{ 521374c14cd6Smrg func_emit_wrapper_arg1=${1-no} 521472b676d7Smrg 5215e35772b2Smrg $ECHO "\ 5216e35772b2Smrg#! $SHELL 521772b676d7Smrg 5218e35772b2Smrg# $output - temporary wrapper script for $objdir/$outputname 521921525869Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220e35772b2Smrg# 5221e35772b2Smrg# The $output program cannot be directly executed until all the libtool 5222e35772b2Smrg# libraries that it depends on are installed. 5223e35772b2Smrg# 5224e35772b2Smrg# This wrapper script should never be moved out of the build directory. 5225e35772b2Smrg# If it is, it will not operate correctly. 522672b676d7Smrg 5227e35772b2Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5228e35772b2Smrg# metacharacters that are still active within double-quoted strings. 5229e35772b2Smrgsed_quote_subst='$sed_quote_subst' 523072b676d7Smrg 5231e35772b2Smrg# Be Bourne compatible 5232e35772b2Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233e35772b2Smrg emulate sh 5234e35772b2Smrg NULLCMD=: 5235e35772b2Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236e35772b2Smrg # is contrary to our usage. Disable this feature. 5237e35772b2Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238e35772b2Smrg setopt NO_GLOB_SUBST 5239e35772b2Smrgelse 5240e35772b2Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241e35772b2Smrgfi 5242e35772b2SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243e35772b2SmrgDUALCASE=1; export DUALCASE # for MKS sh 524472b676d7Smrg 5245e35772b2Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246e35772b2Smrg# if CDPATH is set. 5247e35772b2Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 524872b676d7Smrg 5249e35772b2Smrgrelink_command=\"$relink_command\" 525072b676d7Smrg 5251e35772b2Smrg# This environment variable determines our operation mode. 5252e35772b2Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253e35772b2Smrg # install mode needs the following variables: 5254e35772b2Smrg generated_by_libtool_version='$macro_version' 5255e35772b2Smrg notinst_deplibs='$notinst_deplibs' 5256e35772b2Smrgelse 5257e35772b2Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258e35772b2Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525974c14cd6Smrg file=\"\$0\"" 526074c14cd6Smrg 526174c14cd6Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526274c14cd6Smrg $ECHO "\ 526374c14cd6Smrg 526474c14cd6Smrg# A function that is used when there is no print builtin or printf. 526574c14cd6Smrgfunc_fallback_echo () 526674c14cd6Smrg{ 526774c14cd6Smrg eval 'cat <<_LTECHO_EOF 526874c14cd6Smrg\$1 526974c14cd6Smrg_LTECHO_EOF' 527074c14cd6Smrg} 527174c14cd6Smrg ECHO=\"$qECHO\" 527274c14cd6Smrg fi 527374c14cd6Smrg 527474c14cd6Smrg# Very basic option parsing. These options are (a) specific to 527574c14cd6Smrg# the libtool wrapper, (b) are identical between the wrapper 527621525869Smrg# /script/ and the wrapper /executable/ that is used only on 527774c14cd6Smrg# windows platforms, and (c) all begin with the string "--lt-" 527821525869Smrg# (application programs are unlikely to have options that match 527974c14cd6Smrg# this pattern). 528074c14cd6Smrg# 528174c14cd6Smrg# There are only two supported options: --lt-debug and 528274c14cd6Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 528374c14cd6Smrg# 528474c14cd6Smrg# The first argument to this parsing function should be the 528574c14cd6Smrg# script's $0 value, followed by "$@". 528674c14cd6Smrglt_option_debug= 528774c14cd6Smrgfunc_parse_lt_options () 528874c14cd6Smrg{ 528974c14cd6Smrg lt_script_arg0=\$0 529074c14cd6Smrg shift 529174c14cd6Smrg for lt_opt 529274c14cd6Smrg do 529374c14cd6Smrg case \"\$lt_opt\" in 529474c14cd6Smrg --lt-debug) lt_option_debug=1 ;; 529574c14cd6Smrg --lt-dump-script) 529674c14cd6Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529774c14cd6Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529874c14cd6Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529974c14cd6Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 530074c14cd6Smrg exit 0 530174c14cd6Smrg ;; 530274c14cd6Smrg --lt-*) 530374c14cd6Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530474c14cd6Smrg exit 1 530574c14cd6Smrg ;; 530674c14cd6Smrg esac 530774c14cd6Smrg done 530874c14cd6Smrg 530974c14cd6Smrg # Print the debug banner immediately: 531074c14cd6Smrg if test -n \"\$lt_option_debug\"; then 531121525869Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531274c14cd6Smrg fi 531374c14cd6Smrg} 531474c14cd6Smrg 531574c14cd6Smrg# Used when --lt-debug. Prints its arguments to stdout 531674c14cd6Smrg# (redirection is the responsibility of the caller) 531774c14cd6Smrgfunc_lt_dump_args () 531874c14cd6Smrg{ 531974c14cd6Smrg lt_dump_args_N=1; 532074c14cd6Smrg for lt_arg 532174c14cd6Smrg do 532221525869Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532374c14cd6Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532474c14cd6Smrg done 532574c14cd6Smrg} 532674c14cd6Smrg 532774c14cd6Smrg# Core function for launching the target application 532874c14cd6Smrgfunc_exec_program_core () 532974c14cd6Smrg{ 5330e35772b2Smrg" 533174c14cd6Smrg case $host in 533274c14cd6Smrg # Backslashes separate directories on plain windows 533374c14cd6Smrg *-*-mingw | *-*-os2* | *-cegcc*) 533474c14cd6Smrg $ECHO "\ 533574c14cd6Smrg if test -n \"\$lt_option_debug\"; then 533621525869Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533774c14cd6Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533874c14cd6Smrg fi 533974c14cd6Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534074c14cd6Smrg" 534174c14cd6Smrg ;; 534274c14cd6Smrg 534374c14cd6Smrg *) 534474c14cd6Smrg $ECHO "\ 534574c14cd6Smrg if test -n \"\$lt_option_debug\"; then 534621525869Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534774c14cd6Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534874c14cd6Smrg fi 534974c14cd6Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535074c14cd6Smrg" 535174c14cd6Smrg ;; 535274c14cd6Smrg esac 535374c14cd6Smrg $ECHO "\ 535474c14cd6Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535574c14cd6Smrg exit 1 535674c14cd6Smrg} 535774c14cd6Smrg 535874c14cd6Smrg# A function to encapsulate launching the target application 535974c14cd6Smrg# Strips options in the --lt-* namespace from \$@ and 536074c14cd6Smrg# launches target application with the remaining arguments. 536174c14cd6Smrgfunc_exec_program () 536274c14cd6Smrg{ 536374c14cd6Smrg case \" \$* \" in 536474c14cd6Smrg *\\ --lt-*) 536574c14cd6Smrg for lt_wr_arg 536674c14cd6Smrg do 536774c14cd6Smrg case \$lt_wr_arg in 536874c14cd6Smrg --lt-*) ;; 536974c14cd6Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 537074c14cd6Smrg esac 537174c14cd6Smrg shift 537274c14cd6Smrg done ;; 537374c14cd6Smrg esac 537474c14cd6Smrg func_exec_program_core \${1+\"\$@\"} 537574c14cd6Smrg} 537674c14cd6Smrg 537774c14cd6Smrg # Parse options 537874c14cd6Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 537972b676d7Smrg 5380e35772b2Smrg # Find the directory that this script lives in. 538174c14cd6Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382e35772b2Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 538372b676d7Smrg 5384e35772b2Smrg # Follow symbolic links until we get to the real thisdir. 538574c14cd6Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386e35772b2Smrg while test -n \"\$file\"; do 538774c14cd6Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 538872b676d7Smrg 5389e35772b2Smrg # If there was a directory component, then change thisdir. 5390e35772b2Smrg if test \"x\$destdir\" != \"x\$file\"; then 5391e35772b2Smrg case \"\$destdir\" in 5392e35772b2Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393e35772b2Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 539472b676d7Smrg esac 5395e35772b2Smrg fi 539672b676d7Smrg 539774c14cd6Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539874c14cd6Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399e35772b2Smrg done 540072b676d7Smrg 5401e35772b2Smrg # Usually 'no', except on cygwin/mingw when embedded into 5402e35772b2Smrg # the cwrapper. 540374c14cd6Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404e35772b2Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405e35772b2Smrg # special case for '.' 5406e35772b2Smrg if test \"\$thisdir\" = \".\"; then 5407e35772b2Smrg thisdir=\`pwd\` 5408e35772b2Smrg fi 5409e35772b2Smrg # remove .libs from thisdir 5410e35772b2Smrg case \"\$thisdir\" in 541174c14cd6Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412e35772b2Smrg $objdir ) thisdir=. ;; 5413e35772b2Smrg esac 5414e35772b2Smrg fi 5415e35772b2Smrg 5416e35772b2Smrg # Try to get the absolute directory name. 5417e35772b2Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5418e35772b2Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419e35772b2Smrg" 5420e35772b2Smrg 542121525869Smrg if test yes = "$fast_install"; then 5422e35772b2Smrg $ECHO "\ 5423e35772b2Smrg program=lt-'$outputname'$exeext 5424e35772b2Smrg progdir=\"\$thisdir/$objdir\" 5425e35772b2Smrg 5426e35772b2Smrg if test ! -f \"\$progdir/\$program\" || 542721525869Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428e35772b2Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429e35772b2Smrg 5430e35772b2Smrg file=\"\$\$-\$program\" 5431e35772b2Smrg 5432e35772b2Smrg if test ! -d \"\$progdir\"; then 5433e35772b2Smrg $MKDIR \"\$progdir\" 5434e35772b2Smrg else 5435e35772b2Smrg $RM \"\$progdir/\$file\" 5436e35772b2Smrg fi" 5437e35772b2Smrg 5438e35772b2Smrg $ECHO "\ 5439e35772b2Smrg 5440e35772b2Smrg # relink executable if necessary 5441e35772b2Smrg if test -n \"\$relink_command\"; then 5442e35772b2Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443e35772b2Smrg else 544421525869Smrg \$ECHO \"\$relink_command_output\" >&2 5445e35772b2Smrg $RM \"\$progdir/\$file\" 5446e35772b2Smrg exit 1 544772b676d7Smrg fi 5448e35772b2Smrg fi 544972b676d7Smrg 5450e35772b2Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451e35772b2Smrg { $RM \"\$progdir/\$program\"; 5452e35772b2Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453e35772b2Smrg $RM \"\$progdir/\$file\" 5454e35772b2Smrg fi" 5455e35772b2Smrg else 5456e35772b2Smrg $ECHO "\ 5457e35772b2Smrg program='$outputname' 5458e35772b2Smrg progdir=\"\$thisdir/$objdir\" 5459e35772b2Smrg" 546072b676d7Smrg fi 546172b676d7Smrg 5462e35772b2Smrg $ECHO "\ 546372b676d7Smrg 5464e35772b2Smrg if test -f \"\$progdir/\$program\"; then" 546572b676d7Smrg 546674c14cd6Smrg # fixup the dll searchpath if we need to. 546774c14cd6Smrg # 546874c14cd6Smrg # Fix the DLL searchpath if we need to. Do this before prepending 546974c14cd6Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 547074c14cd6Smrg # libraries must come first. 547174c14cd6Smrg if test -n "$dllsearchpath"; then 547274c14cd6Smrg $ECHO "\ 547374c14cd6Smrg # Add the dll search path components to the executable PATH 547474c14cd6Smrg PATH=$dllsearchpath:\$PATH 547574c14cd6Smrg" 547674c14cd6Smrg fi 547774c14cd6Smrg 5478e35772b2Smrg # Export our shlibpath_var if we have one. 547921525869Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480e35772b2Smrg $ECHO "\ 5481e35772b2Smrg # Add our own library path to $shlibpath_var 5482e35772b2Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483e35772b2Smrg 5484e35772b2Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485e35772b2Smrg # The second colon is a workaround for a bug in BeOS R4 sed 548674c14cd6Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 548772b676d7Smrg 5488e35772b2Smrg export $shlibpath_var 5489e35772b2Smrg" 549072b676d7Smrg fi 549172b676d7Smrg 5492e35772b2Smrg $ECHO "\ 5493e35772b2Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494e35772b2Smrg # Run the actual program with our arguments. 549574c14cd6Smrg func_exec_program \${1+\"\$@\"} 5496e35772b2Smrg fi 5497e35772b2Smrg else 5498e35772b2Smrg # The program doesn't exist. 549921525869Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500e35772b2Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550174c14cd6Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502e35772b2Smrg exit 1 5503e35772b2Smrg fi 5504e35772b2Smrgfi\ 5505e35772b2Smrg" 5506e35772b2Smrg} 550772b676d7Smrg 550872b676d7Smrg 5509e35772b2Smrg# func_emit_cwrapperexe_src 5510e35772b2Smrg# emit the source code for a wrapper executable on stdout 5511e35772b2Smrg# Must ONLY be called from within func_mode_link because 5512e35772b2Smrg# it depends on a number of variable set therein. 5513e35772b2Smrgfunc_emit_cwrapperexe_src () 5514e35772b2Smrg{ 5515e35772b2Smrg cat <<EOF 551672b676d7Smrg 5517e35772b2Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551821525869Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 551972b676d7Smrg 5520e35772b2Smrg The $output program cannot be directly executed until all the libtool 5521e35772b2Smrg libraries that it depends on are installed. 552272b676d7Smrg 5523e35772b2Smrg This wrapper executable should never be moved out of the build directory. 5524e35772b2Smrg If it is, it will not operate correctly. 5525e35772b2Smrg*/ 5526e35772b2SmrgEOF 5527e35772b2Smrg cat <<"EOF" 552874c14cd6Smrg#ifdef _MSC_VER 552974c14cd6Smrg# define _CRT_SECURE_NO_DEPRECATE 1 553074c14cd6Smrg#endif 5531e35772b2Smrg#include <stdio.h> 5532e35772b2Smrg#include <stdlib.h> 5533e35772b2Smrg#ifdef _MSC_VER 5534e35772b2Smrg# include <direct.h> 5535e35772b2Smrg# include <process.h> 5536e35772b2Smrg# include <io.h> 5537e35772b2Smrg#else 5538e35772b2Smrg# include <unistd.h> 5539e35772b2Smrg# include <stdint.h> 5540e35772b2Smrg# ifdef __CYGWIN__ 5541e35772b2Smrg# include <io.h> 5542e35772b2Smrg# endif 5543e35772b2Smrg#endif 5544e35772b2Smrg#include <malloc.h> 5545e35772b2Smrg#include <stdarg.h> 5546e35772b2Smrg#include <assert.h> 5547e35772b2Smrg#include <string.h> 5548e35772b2Smrg#include <ctype.h> 5549e35772b2Smrg#include <errno.h> 5550e35772b2Smrg#include <fcntl.h> 5551e35772b2Smrg#include <sys/stat.h> 555272b676d7Smrg 555321525869Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555421525869Smrg 555574c14cd6Smrg/* declarations of non-ANSI functions */ 555621525869Smrg#if defined __MINGW32__ 555774c14cd6Smrg# ifdef __STRICT_ANSI__ 555874c14cd6Smrgint _putenv (const char *); 555974c14cd6Smrg# endif 556021525869Smrg#elif defined __CYGWIN__ 556174c14cd6Smrg# ifdef __STRICT_ANSI__ 556274c14cd6Smrgchar *realpath (const char *, char *); 556374c14cd6Smrgint putenv (char *); 556474c14cd6Smrgint setenv (const char *, const char *, int); 556574c14cd6Smrg# endif 556621525869Smrg/* #elif defined other_platform || defined ... */ 556774c14cd6Smrg#endif 556874c14cd6Smrg 556974c14cd6Smrg/* portability defines, excluding path handling macros */ 557021525869Smrg#if defined _MSC_VER 557174c14cd6Smrg# define setmode _setmode 557274c14cd6Smrg# define stat _stat 557374c14cd6Smrg# define chmod _chmod 557474c14cd6Smrg# define getcwd _getcwd 557574c14cd6Smrg# define putenv _putenv 557674c14cd6Smrg# define S_IXUSR _S_IEXEC 557721525869Smrg#elif defined __MINGW32__ 557874c14cd6Smrg# define setmode _setmode 557974c14cd6Smrg# define stat _stat 558074c14cd6Smrg# define chmod _chmod 558174c14cd6Smrg# define getcwd _getcwd 558274c14cd6Smrg# define putenv _putenv 558321525869Smrg#elif defined __CYGWIN__ 558474c14cd6Smrg# define HAVE_SETENV 558574c14cd6Smrg# define FOPEN_WB "wb" 558621525869Smrg/* #elif defined other platforms ... */ 558774c14cd6Smrg#endif 558874c14cd6Smrg 558921525869Smrg#if defined PATH_MAX 5590e35772b2Smrg# define LT_PATHMAX PATH_MAX 559121525869Smrg#elif defined MAXPATHLEN 5592e35772b2Smrg# define LT_PATHMAX MAXPATHLEN 5593e35772b2Smrg#else 5594e35772b2Smrg# define LT_PATHMAX 1024 5595e35772b2Smrg#endif 559672b676d7Smrg 5597e35772b2Smrg#ifndef S_IXOTH 5598e35772b2Smrg# define S_IXOTH 0 5599e35772b2Smrg#endif 5600e35772b2Smrg#ifndef S_IXGRP 5601e35772b2Smrg# define S_IXGRP 0 5602e35772b2Smrg#endif 560372b676d7Smrg 560474c14cd6Smrg/* path handling portability macros */ 5605e35772b2Smrg#ifndef DIR_SEPARATOR 5606e35772b2Smrg# define DIR_SEPARATOR '/' 5607e35772b2Smrg# define PATH_SEPARATOR ':' 5608e35772b2Smrg#endif 560972b676d7Smrg 561021525869Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561121525869Smrg defined __OS2__ 5612e35772b2Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613e35772b2Smrg# define FOPEN_WB "wb" 5614e35772b2Smrg# ifndef DIR_SEPARATOR_2 5615e35772b2Smrg# define DIR_SEPARATOR_2 '\\' 5616e35772b2Smrg# endif 5617e35772b2Smrg# ifndef PATH_SEPARATOR_2 5618e35772b2Smrg# define PATH_SEPARATOR_2 ';' 5619e35772b2Smrg# endif 5620e35772b2Smrg#endif 562172b676d7Smrg 5622e35772b2Smrg#ifndef DIR_SEPARATOR_2 5623e35772b2Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624e35772b2Smrg#else /* DIR_SEPARATOR_2 */ 5625e35772b2Smrg# define IS_DIR_SEPARATOR(ch) \ 5626e35772b2Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627e35772b2Smrg#endif /* DIR_SEPARATOR_2 */ 562872b676d7Smrg 5629e35772b2Smrg#ifndef PATH_SEPARATOR_2 5630e35772b2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631e35772b2Smrg#else /* PATH_SEPARATOR_2 */ 5632e35772b2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633e35772b2Smrg#endif /* PATH_SEPARATOR_2 */ 563472b676d7Smrg 5635e35772b2Smrg#ifndef FOPEN_WB 5636e35772b2Smrg# define FOPEN_WB "w" 5637e35772b2Smrg#endif 5638e35772b2Smrg#ifndef _O_BINARY 5639e35772b2Smrg# define _O_BINARY 0 5640e35772b2Smrg#endif 564172b676d7Smrg 5642e35772b2Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643e35772b2Smrg#define XFREE(stale) do { \ 564421525869Smrg if (stale) { free (stale); stale = 0; } \ 5645e35772b2Smrg} while (0) 564672b676d7Smrg 564721525869Smrg#if defined LT_DEBUGWRAPPER 564874c14cd6Smrgstatic int lt_debug = 1; 5649e35772b2Smrg#else 565074c14cd6Smrgstatic int lt_debug = 0; 5651e35772b2Smrg#endif 565272b676d7Smrg 565374c14cd6Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565472b676d7Smrg 5655e35772b2Smrgvoid *xmalloc (size_t num); 5656e35772b2Smrgchar *xstrdup (const char *string); 5657e35772b2Smrgconst char *base_name (const char *name); 5658e35772b2Smrgchar *find_executable (const char *wrapper); 5659e35772b2Smrgchar *chase_symlinks (const char *pathspec); 5660e35772b2Smrgint make_executable (const char *path); 5661e35772b2Smrgint check_executable (const char *path); 5662e35772b2Smrgchar *strendzap (char *str, const char *pat); 566374c14cd6Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566474c14cd6Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566574c14cd6Smrgstatic const char *nonnull (const char *s); 566674c14cd6Smrgstatic const char *nonempty (const char *s); 5667e35772b2Smrgvoid lt_setenv (const char *name, const char *value); 5668e35772b2Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669e35772b2Smrgvoid lt_update_exe_path (const char *name, const char *value); 5670e35772b2Smrgvoid lt_update_lib_path (const char *name, const char *value); 567174c14cd6Smrgchar **prepare_spawn (char **argv); 567274c14cd6Smrgvoid lt_dump_script (FILE *f); 5673e35772b2SmrgEOF 5674e35772b2Smrg 5675e35772b2Smrg cat <<EOF 567621525869Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567721525869Smrg# define externally_visible volatile 567821525869Smrg#else 567921525869Smrg# define externally_visible __attribute__((externally_visible)) volatile 568021525869Smrg#endif 568121525869Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682e35772b2Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683e35772b2SmrgEOF 568472b676d7Smrg 568521525869Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 568674c14cd6Smrg func_to_host_path "$temp_rpath" 5687e35772b2Smrg cat <<EOF 568874c14cd6Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689e35772b2SmrgEOF 5690e35772b2Smrg else 5691e35772b2Smrg cat <<"EOF" 5692e35772b2Smrgconst char * LIB_PATH_VALUE = ""; 5693e35772b2SmrgEOF 569472b676d7Smrg fi 569572b676d7Smrg 5696e35772b2Smrg if test -n "$dllsearchpath"; then 569774c14cd6Smrg func_to_host_path "$dllsearchpath:" 5698e35772b2Smrg cat <<EOF 5699e35772b2Smrgconst char * EXE_PATH_VARNAME = "PATH"; 570074c14cd6Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 570172b676d7SmrgEOF 570272b676d7Smrg else 5703e35772b2Smrg cat <<"EOF" 5704e35772b2Smrgconst char * EXE_PATH_VARNAME = ""; 5705e35772b2Smrgconst char * EXE_PATH_VALUE = ""; 5706e35772b2SmrgEOF 570772b676d7Smrg fi 5708e35772b2Smrg 570921525869Smrg if test yes = "$fast_install"; then 5710e35772b2Smrg cat <<EOF 5711e35772b2Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712e35772b2SmrgEOF 571372b676d7Smrg else 5714e35772b2Smrg cat <<EOF 5715e35772b2Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716e35772b2SmrgEOF 571772b676d7Smrg fi 571872b676d7Smrg 571972b676d7Smrg 5720e35772b2Smrg cat <<"EOF" 572172b676d7Smrg 5722e35772b2Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 572372b676d7Smrg 5724e35772b2Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725e35772b2Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572674c14cd6Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 572772b676d7Smrg 5728e35772b2Smrgint 5729e35772b2Smrgmain (int argc, char *argv[]) 5730e35772b2Smrg{ 5731e35772b2Smrg char **newargz; 5732e35772b2Smrg int newargc; 5733e35772b2Smrg char *tmp_pathspec; 5734e35772b2Smrg char *actual_cwrapper_path; 5735e35772b2Smrg char *actual_cwrapper_name; 5736e35772b2Smrg char *target_name; 5737e35772b2Smrg char *lt_argv_zero; 573821525869Smrg int rval = 127; 573972b676d7Smrg 5740e35772b2Smrg int i; 574172b676d7Smrg 5742e35772b2Smrg program_name = (char *) xstrdup (base_name (argv[0])); 574321525869Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 574472b676d7Smrg 574574c14cd6Smrg /* very simple arg parsing; don't want to rely on getopt 574674c14cd6Smrg * also, copy all non cwrapper options to newargz, except 574774c14cd6Smrg * argz[0], which is handled differently 574874c14cd6Smrg */ 574974c14cd6Smrg newargc=0; 5750e35772b2Smrg for (i = 1; i < argc; i++) 5751e35772b2Smrg { 575221525869Smrg if (STREQ (argv[i], dumpscript_opt)) 5753e35772b2Smrg { 5754e35772b2SmrgEOF 575521525869Smrg case $host in 5756e35772b2Smrg *mingw* | *cygwin* ) 5757e35772b2Smrg # make stdout use "unix" line endings 5758e35772b2Smrg echo " setmode(1,_O_BINARY);" 5759e35772b2Smrg ;; 5760e35772b2Smrg esac 576172b676d7Smrg 5762e35772b2Smrg cat <<"EOF" 576374c14cd6Smrg lt_dump_script (stdout); 5764e35772b2Smrg return 0; 5765e35772b2Smrg } 576621525869Smrg if (STREQ (argv[i], debug_opt)) 576774c14cd6Smrg { 576874c14cd6Smrg lt_debug = 1; 576974c14cd6Smrg continue; 577074c14cd6Smrg } 577121525869Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577274c14cd6Smrg { 577374c14cd6Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577474c14cd6Smrg namespace, but it is not one of the ones we know about and 577574c14cd6Smrg have already dealt with, above (inluding dump-script), then 577674c14cd6Smrg report an error. Otherwise, targets might begin to believe 577774c14cd6Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577874c14cd6Smrg namespace. The first time any user complains about this, we'll 577974c14cd6Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578074c14cd6Smrg or a configure.ac-settable value. 578174c14cd6Smrg */ 578274c14cd6Smrg lt_fatal (__FILE__, __LINE__, 578374c14cd6Smrg "unrecognized %s option: '%s'", 578474c14cd6Smrg ltwrapper_option_prefix, argv[i]); 578574c14cd6Smrg } 578674c14cd6Smrg /* otherwise ... */ 578774c14cd6Smrg newargz[++newargc] = xstrdup (argv[i]); 5788e35772b2Smrg } 578974c14cd6Smrg newargz[++newargc] = NULL; 579074c14cd6Smrg 579174c14cd6SmrgEOF 579274c14cd6Smrg cat <<EOF 579374c14cd6Smrg /* The GNU banner must be the first non-error debug message */ 579421525869Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579574c14cd6SmrgEOF 579674c14cd6Smrg cat <<"EOF" 579774c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579874c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 579972b676d7Smrg 5800e35772b2Smrg tmp_pathspec = find_executable (argv[0]); 5801e35772b2Smrg if (tmp_pathspec == NULL) 580274c14cd6Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580374c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 580474c14cd6Smrg "(main) found exe (before symlink chase) at: %s\n", 580574c14cd6Smrg tmp_pathspec); 5806e35772b2Smrg 5807e35772b2Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580874c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 580974c14cd6Smrg "(main) found exe (after symlink chase) at: %s\n", 581074c14cd6Smrg actual_cwrapper_path); 5811e35772b2Smrg XFREE (tmp_pathspec); 5812e35772b2Smrg 581374c14cd6Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814e35772b2Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815e35772b2Smrg 5816e35772b2Smrg /* wrapper name transforms */ 5817e35772b2Smrg strendzap (actual_cwrapper_name, ".exe"); 5818e35772b2Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819e35772b2Smrg XFREE (actual_cwrapper_name); 5820e35772b2Smrg actual_cwrapper_name = tmp_pathspec; 5821e35772b2Smrg tmp_pathspec = 0; 5822e35772b2Smrg 5823e35772b2Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824e35772b2Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825e35772b2Smrg strendzap (target_name, ".exe"); 5826e35772b2Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827e35772b2Smrg XFREE (target_name); 5828e35772b2Smrg target_name = tmp_pathspec; 5829e35772b2Smrg tmp_pathspec = 0; 5830e35772b2Smrg 583174c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 583274c14cd6Smrg "(main) libtool target name: %s\n", 583374c14cd6Smrg target_name); 5834e35772b2SmrgEOF 583572b676d7Smrg 5836e35772b2Smrg cat <<EOF 5837e35772b2Smrg newargz[0] = 5838e35772b2Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839e35772b2Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840e35772b2Smrg strcpy (newargz[0], actual_cwrapper_path); 5841e35772b2Smrg strcat (newargz[0], "$objdir"); 5842e35772b2Smrg strcat (newargz[0], "/"); 5843e35772b2SmrgEOF 584472b676d7Smrg 5845e35772b2Smrg cat <<"EOF" 5846e35772b2Smrg /* stop here, and copy so we don't have to do this twice */ 5847e35772b2Smrg tmp_pathspec = xstrdup (newargz[0]); 584872b676d7Smrg 5849e35772b2Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850e35772b2Smrg strcat (newargz[0], actual_cwrapper_name); 585172b676d7Smrg 5852e35772b2Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853e35772b2Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854e35772b2Smrg XFREE (tmp_pathspec); 5855e35772b2Smrg tmp_pathspec = NULL; 5856e35772b2SmrgEOF 585772b676d7Smrg 5858e35772b2Smrg case $host_os in 5859e35772b2Smrg mingw*) 5860e35772b2Smrg cat <<"EOF" 5861e35772b2Smrg { 5862e35772b2Smrg char* p; 5863e35772b2Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864e35772b2Smrg { 5865e35772b2Smrg *p = '/'; 5866e35772b2Smrg } 5867e35772b2Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868e35772b2Smrg { 5869e35772b2Smrg *p = '/'; 5870e35772b2Smrg } 5871e35772b2Smrg } 5872e35772b2SmrgEOF 5873e35772b2Smrg ;; 5874e35772b2Smrg esac 587572b676d7Smrg 5876e35772b2Smrg cat <<"EOF" 5877e35772b2Smrg XFREE (target_name); 5878e35772b2Smrg XFREE (actual_cwrapper_path); 5879e35772b2Smrg XFREE (actual_cwrapper_name); 588072b676d7Smrg 5881e35772b2Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882e35772b2Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 588374c14cd6Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 588474c14cd6Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 588574c14cd6Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 588674c14cd6Smrg libraries must come first. */ 5887e35772b2Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 588874c14cd6Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 588972b676d7Smrg 589074c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589174c14cd6Smrg nonnull (lt_argv_zero)); 5892e35772b2Smrg for (i = 0; i < newargc; i++) 5893e35772b2Smrg { 589474c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589574c14cd6Smrg i, nonnull (newargz[i])); 5896e35772b2Smrg } 589772b676d7Smrg 5898e35772b2SmrgEOF 589972b676d7Smrg 5900e35772b2Smrg case $host_os in 5901e35772b2Smrg mingw*) 5902e35772b2Smrg cat <<"EOF" 5903e35772b2Smrg /* execv doesn't actually work on mingw as expected on unix */ 590474c14cd6Smrg newargz = prepare_spawn (newargz); 590521525869Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906e35772b2Smrg if (rval == -1) 5907e35772b2Smrg { 5908e35772b2Smrg /* failed to start process */ 590974c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 591074c14cd6Smrg "(main) failed to launch target \"%s\": %s\n", 591174c14cd6Smrg lt_argv_zero, nonnull (strerror (errno))); 5912e35772b2Smrg return 127; 5913e35772b2Smrg } 5914e35772b2Smrg return rval; 5915e35772b2SmrgEOF 5916e35772b2Smrg ;; 5917e35772b2Smrg *) 5918e35772b2Smrg cat <<"EOF" 5919e35772b2Smrg execv (lt_argv_zero, newargz); 5920e35772b2Smrg return rval; /* =127, but avoids unused variable warning */ 5921e35772b2SmrgEOF 5922e35772b2Smrg ;; 5923e35772b2Smrg esac 592472b676d7Smrg 5925e35772b2Smrg cat <<"EOF" 5926e35772b2Smrg} 592772b676d7Smrg 5928e35772b2Smrgvoid * 5929e35772b2Smrgxmalloc (size_t num) 5930e35772b2Smrg{ 5931e35772b2Smrg void *p = (void *) malloc (num); 5932e35772b2Smrg if (!p) 593374c14cd6Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 593472b676d7Smrg 5935e35772b2Smrg return p; 5936e35772b2Smrg} 593772b676d7Smrg 5938e35772b2Smrgchar * 5939e35772b2Smrgxstrdup (const char *string) 5940e35772b2Smrg{ 5941e35772b2Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942e35772b2Smrg string) : NULL; 5943e35772b2Smrg} 594472b676d7Smrg 5945e35772b2Smrgconst char * 5946e35772b2Smrgbase_name (const char *name) 5947e35772b2Smrg{ 5948e35772b2Smrg const char *base; 594972b676d7Smrg 595021525869Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951e35772b2Smrg /* Skip over the disk name in MSDOS pathnames. */ 5952e35772b2Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953e35772b2Smrg name += 2; 5954e35772b2Smrg#endif 595572b676d7Smrg 5956e35772b2Smrg for (base = name; *name; name++) 5957e35772b2Smrg if (IS_DIR_SEPARATOR (*name)) 5958e35772b2Smrg base = name + 1; 5959e35772b2Smrg return base; 5960e35772b2Smrg} 596172b676d7Smrg 5962e35772b2Smrgint 5963e35772b2Smrgcheck_executable (const char *path) 5964e35772b2Smrg{ 5965e35772b2Smrg struct stat st; 596672b676d7Smrg 596774c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596874c14cd6Smrg nonempty (path)); 5969e35772b2Smrg if ((!path) || (!*path)) 5970e35772b2Smrg return 0; 597172b676d7Smrg 5972e35772b2Smrg if ((stat (path, &st) >= 0) 5973e35772b2Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974e35772b2Smrg return 1; 5975e35772b2Smrg else 5976e35772b2Smrg return 0; 5977e35772b2Smrg} 597872b676d7Smrg 5979e35772b2Smrgint 5980e35772b2Smrgmake_executable (const char *path) 5981e35772b2Smrg{ 5982e35772b2Smrg int rval = 0; 5983e35772b2Smrg struct stat st; 598472b676d7Smrg 598574c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598674c14cd6Smrg nonempty (path)); 5987e35772b2Smrg if ((!path) || (!*path)) 5988e35772b2Smrg return 0; 598972b676d7Smrg 5990e35772b2Smrg if (stat (path, &st) >= 0) 5991e35772b2Smrg { 5992e35772b2Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993e35772b2Smrg } 5994e35772b2Smrg return rval; 5995e35772b2Smrg} 599672b676d7Smrg 5997e35772b2Smrg/* Searches for the full path of the wrapper. Returns 5998e35772b2Smrg newly allocated full path name if found, NULL otherwise 5999e35772b2Smrg Does not chase symlinks, even on platforms that support them. 6000e35772b2Smrg*/ 6001e35772b2Smrgchar * 6002e35772b2Smrgfind_executable (const char *wrapper) 6003e35772b2Smrg{ 6004e35772b2Smrg int has_slash = 0; 6005e35772b2Smrg const char *p; 6006e35772b2Smrg const char *p_next; 6007e35772b2Smrg /* static buffer for getcwd */ 6008e35772b2Smrg char tmp[LT_PATHMAX + 1]; 600921525869Smrg size_t tmp_len; 6010e35772b2Smrg char *concat_name; 601172b676d7Smrg 601274c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601374c14cd6Smrg nonempty (wrapper)); 601472b676d7Smrg 6015e35772b2Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016e35772b2Smrg return NULL; 601772b676d7Smrg 6018e35772b2Smrg /* Absolute path? */ 601921525869Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020e35772b2Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021e35772b2Smrg { 6022e35772b2Smrg concat_name = xstrdup (wrapper); 6023e35772b2Smrg if (check_executable (concat_name)) 6024e35772b2Smrg return concat_name; 6025e35772b2Smrg XFREE (concat_name); 6026e35772b2Smrg } 6027e35772b2Smrg else 6028e35772b2Smrg { 6029e35772b2Smrg#endif 6030e35772b2Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031e35772b2Smrg { 6032e35772b2Smrg concat_name = xstrdup (wrapper); 6033e35772b2Smrg if (check_executable (concat_name)) 6034e35772b2Smrg return concat_name; 6035e35772b2Smrg XFREE (concat_name); 6036e35772b2Smrg } 603721525869Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038e35772b2Smrg } 6039e35772b2Smrg#endif 604072b676d7Smrg 6041e35772b2Smrg for (p = wrapper; *p; p++) 6042e35772b2Smrg if (*p == '/') 6043e35772b2Smrg { 6044e35772b2Smrg has_slash = 1; 6045e35772b2Smrg break; 6046e35772b2Smrg } 6047e35772b2Smrg if (!has_slash) 6048e35772b2Smrg { 6049e35772b2Smrg /* no slashes; search PATH */ 6050e35772b2Smrg const char *path = getenv ("PATH"); 6051e35772b2Smrg if (path != NULL) 6052e35772b2Smrg { 6053e35772b2Smrg for (p = path; *p; p = p_next) 6054e35772b2Smrg { 6055e35772b2Smrg const char *q; 6056e35772b2Smrg size_t p_len; 6057e35772b2Smrg for (q = p; *q; q++) 6058e35772b2Smrg if (IS_PATH_SEPARATOR (*q)) 6059e35772b2Smrg break; 606021525869Smrg p_len = (size_t) (q - p); 6061e35772b2Smrg p_next = (*q == '\0' ? q : q + 1); 6062e35772b2Smrg if (p_len == 0) 6063e35772b2Smrg { 6064e35772b2Smrg /* empty path: current directory */ 6065e35772b2Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606674c14cd6Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606774c14cd6Smrg nonnull (strerror (errno))); 6068e35772b2Smrg tmp_len = strlen (tmp); 6069e35772b2Smrg concat_name = 6070e35772b2Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071e35772b2Smrg memcpy (concat_name, tmp, tmp_len); 6072e35772b2Smrg concat_name[tmp_len] = '/'; 6073e35772b2Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6074e35772b2Smrg } 6075e35772b2Smrg else 6076e35772b2Smrg { 6077e35772b2Smrg concat_name = 6078e35772b2Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079e35772b2Smrg memcpy (concat_name, p, p_len); 6080e35772b2Smrg concat_name[p_len] = '/'; 6081e35772b2Smrg strcpy (concat_name + p_len + 1, wrapper); 6082e35772b2Smrg } 6083e35772b2Smrg if (check_executable (concat_name)) 6084e35772b2Smrg return concat_name; 6085e35772b2Smrg XFREE (concat_name); 6086e35772b2Smrg } 6087e35772b2Smrg } 6088e35772b2Smrg /* not found in PATH; assume curdir */ 6089e35772b2Smrg } 6090e35772b2Smrg /* Relative path | not found in path: prepend cwd */ 6091e35772b2Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609274c14cd6Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609374c14cd6Smrg nonnull (strerror (errno))); 6094e35772b2Smrg tmp_len = strlen (tmp); 6095e35772b2Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096e35772b2Smrg memcpy (concat_name, tmp, tmp_len); 6097e35772b2Smrg concat_name[tmp_len] = '/'; 6098e35772b2Smrg strcpy (concat_name + tmp_len + 1, wrapper); 609972b676d7Smrg 6100e35772b2Smrg if (check_executable (concat_name)) 6101e35772b2Smrg return concat_name; 6102e35772b2Smrg XFREE (concat_name); 6103e35772b2Smrg return NULL; 6104e35772b2Smrg} 610572b676d7Smrg 6106e35772b2Smrgchar * 6107e35772b2Smrgchase_symlinks (const char *pathspec) 6108e35772b2Smrg{ 6109e35772b2Smrg#ifndef S_ISLNK 6110e35772b2Smrg return xstrdup (pathspec); 6111e35772b2Smrg#else 6112e35772b2Smrg char buf[LT_PATHMAX]; 6113e35772b2Smrg struct stat s; 6114e35772b2Smrg char *tmp_pathspec = xstrdup (pathspec); 6115e35772b2Smrg char *p; 6116e35772b2Smrg int has_symlinks = 0; 6117e35772b2Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6118e35772b2Smrg { 611974c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 612074c14cd6Smrg "checking path component for symlinks: %s\n", 612174c14cd6Smrg tmp_pathspec); 6122e35772b2Smrg if (lstat (tmp_pathspec, &s) == 0) 6123e35772b2Smrg { 6124e35772b2Smrg if (S_ISLNK (s.st_mode) != 0) 6125e35772b2Smrg { 6126e35772b2Smrg has_symlinks = 1; 6127e35772b2Smrg break; 6128e35772b2Smrg } 612972b676d7Smrg 6130e35772b2Smrg /* search backwards for last DIR_SEPARATOR */ 6131e35772b2Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132e35772b2Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133e35772b2Smrg p--; 6134e35772b2Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135e35772b2Smrg { 6136e35772b2Smrg /* no more DIR_SEPARATORS left */ 6137e35772b2Smrg break; 6138e35772b2Smrg } 6139e35772b2Smrg *p = '\0'; 6140e35772b2Smrg } 6141e35772b2Smrg else 6142e35772b2Smrg { 614374c14cd6Smrg lt_fatal (__FILE__, __LINE__, 614474c14cd6Smrg "error accessing file \"%s\": %s", 614574c14cd6Smrg tmp_pathspec, nonnull (strerror (errno))); 6146e35772b2Smrg } 6147e35772b2Smrg } 6148e35772b2Smrg XFREE (tmp_pathspec); 614972b676d7Smrg 6150e35772b2Smrg if (!has_symlinks) 6151e35772b2Smrg { 6152e35772b2Smrg return xstrdup (pathspec); 6153e35772b2Smrg } 615472b676d7Smrg 6155e35772b2Smrg tmp_pathspec = realpath (pathspec, buf); 6156e35772b2Smrg if (tmp_pathspec == 0) 6157e35772b2Smrg { 615874c14cd6Smrg lt_fatal (__FILE__, __LINE__, 615974c14cd6Smrg "could not follow symlinks for %s", pathspec); 6160e35772b2Smrg } 6161e35772b2Smrg return xstrdup (tmp_pathspec); 6162e35772b2Smrg#endif 6163e35772b2Smrg} 616472b676d7Smrg 6165e35772b2Smrgchar * 6166e35772b2Smrgstrendzap (char *str, const char *pat) 6167e35772b2Smrg{ 6168e35772b2Smrg size_t len, patlen; 616972b676d7Smrg 6170e35772b2Smrg assert (str != NULL); 6171e35772b2Smrg assert (pat != NULL); 617272b676d7Smrg 6173e35772b2Smrg len = strlen (str); 6174e35772b2Smrg patlen = strlen (pat); 617572b676d7Smrg 6176e35772b2Smrg if (patlen <= len) 6177e35772b2Smrg { 6178e35772b2Smrg str += len - patlen; 617921525869Smrg if (STREQ (str, pat)) 6180e35772b2Smrg *str = '\0'; 6181e35772b2Smrg } 6182e35772b2Smrg return str; 6183e35772b2Smrg} 618472b676d7Smrg 618574c14cd6Smrgvoid 618674c14cd6Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618774c14cd6Smrg{ 618874c14cd6Smrg va_list args; 618974c14cd6Smrg if (lt_debug) 619074c14cd6Smrg { 619174c14cd6Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619274c14cd6Smrg va_start (args, fmt); 619374c14cd6Smrg (void) vfprintf (stderr, fmt, args); 619474c14cd6Smrg va_end (args); 619574c14cd6Smrg } 619674c14cd6Smrg} 619774c14cd6Smrg 6198e35772b2Smrgstatic void 619974c14cd6Smrglt_error_core (int exit_status, const char *file, 620074c14cd6Smrg int line, const char *mode, 6201e35772b2Smrg const char *message, va_list ap) 6202e35772b2Smrg{ 620374c14cd6Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204e35772b2Smrg vfprintf (stderr, message, ap); 6205e35772b2Smrg fprintf (stderr, ".\n"); 620672b676d7Smrg 6207e35772b2Smrg if (exit_status >= 0) 6208e35772b2Smrg exit (exit_status); 6209e35772b2Smrg} 621072b676d7Smrg 6211e35772b2Smrgvoid 621274c14cd6Smrglt_fatal (const char *file, int line, const char *message, ...) 6213e35772b2Smrg{ 6214e35772b2Smrg va_list ap; 6215e35772b2Smrg va_start (ap, message); 621674c14cd6Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217e35772b2Smrg va_end (ap); 6218e35772b2Smrg} 621972b676d7Smrg 622074c14cd6Smrgstatic const char * 622174c14cd6Smrgnonnull (const char *s) 622274c14cd6Smrg{ 622374c14cd6Smrg return s ? s : "(null)"; 622474c14cd6Smrg} 622574c14cd6Smrg 622674c14cd6Smrgstatic const char * 622774c14cd6Smrgnonempty (const char *s) 622874c14cd6Smrg{ 622974c14cd6Smrg return (s && !*s) ? "(empty)" : nonnull (s); 623074c14cd6Smrg} 623174c14cd6Smrg 6232e35772b2Smrgvoid 6233e35772b2Smrglt_setenv (const char *name, const char *value) 6234e35772b2Smrg{ 623574c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 623674c14cd6Smrg "(lt_setenv) setting '%s' to '%s'\n", 623774c14cd6Smrg nonnull (name), nonnull (value)); 6238e35772b2Smrg { 6239e35772b2Smrg#ifdef HAVE_SETENV 6240e35772b2Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241e35772b2Smrg char *str = xstrdup (value); 6242e35772b2Smrg setenv (name, str, 1); 6243e35772b2Smrg#else 624421525869Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245e35772b2Smrg char *str = XMALLOC (char, len); 6246e35772b2Smrg sprintf (str, "%s=%s", name, value); 6247e35772b2Smrg if (putenv (str) != EXIT_SUCCESS) 6248e35772b2Smrg { 6249e35772b2Smrg XFREE (str); 6250e35772b2Smrg } 6251e35772b2Smrg#endif 6252e35772b2Smrg } 6253e35772b2Smrg} 625472b676d7Smrg 6255e35772b2Smrgchar * 6256e35772b2Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257e35772b2Smrg{ 6258e35772b2Smrg char *new_value; 6259e35772b2Smrg if (orig_value && *orig_value) 6260e35772b2Smrg { 626121525869Smrg size_t orig_value_len = strlen (orig_value); 626221525869Smrg size_t add_len = strlen (add); 6263e35772b2Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264e35772b2Smrg if (to_end) 6265e35772b2Smrg { 6266e35772b2Smrg strcpy (new_value, orig_value); 6267e35772b2Smrg strcpy (new_value + orig_value_len, add); 6268e35772b2Smrg } 6269e35772b2Smrg else 6270e35772b2Smrg { 6271e35772b2Smrg strcpy (new_value, add); 6272e35772b2Smrg strcpy (new_value + add_len, orig_value); 6273e35772b2Smrg } 6274e35772b2Smrg } 6275e35772b2Smrg else 6276e35772b2Smrg { 6277e35772b2Smrg new_value = xstrdup (add); 6278e35772b2Smrg } 6279e35772b2Smrg return new_value; 6280e35772b2Smrg} 628172b676d7Smrg 6282e35772b2Smrgvoid 6283e35772b2Smrglt_update_exe_path (const char *name, const char *value) 6284e35772b2Smrg{ 628574c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 628674c14cd6Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628774c14cd6Smrg nonnull (name), nonnull (value)); 628872b676d7Smrg 6289e35772b2Smrg if (name && *name && value && *value) 6290e35772b2Smrg { 6291e35772b2Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292e35772b2Smrg /* some systems can't cope with a ':'-terminated path #' */ 629321525869Smrg size_t len = strlen (new_value); 629421525869Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295e35772b2Smrg { 629621525869Smrg new_value[--len] = '\0'; 6297e35772b2Smrg } 6298e35772b2Smrg lt_setenv (name, new_value); 6299e35772b2Smrg XFREE (new_value); 6300e35772b2Smrg } 6301e35772b2Smrg} 630272b676d7Smrg 6303e35772b2Smrgvoid 6304e35772b2Smrglt_update_lib_path (const char *name, const char *value) 6305e35772b2Smrg{ 630674c14cd6Smrg lt_debugprintf (__FILE__, __LINE__, 630774c14cd6Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630874c14cd6Smrg nonnull (name), nonnull (value)); 630972b676d7Smrg 6310e35772b2Smrg if (name && *name && value && *value) 6311e35772b2Smrg { 6312e35772b2Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313e35772b2Smrg lt_setenv (name, new_value); 6314e35772b2Smrg XFREE (new_value); 6315e35772b2Smrg } 6316e35772b2Smrg} 631772b676d7Smrg 631874c14cd6SmrgEOF 631974c14cd6Smrg case $host_os in 632074c14cd6Smrg mingw*) 632174c14cd6Smrg cat <<"EOF" 632274c14cd6Smrg 632374c14cd6Smrg/* Prepares an argument vector before calling spawn(). 632474c14cd6Smrg Note that spawn() does not by itself call the command interpreter 632574c14cd6Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632674c14cd6Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632774c14cd6Smrg GetVersionEx(&v); 632874c14cd6Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632974c14cd6Smrg }) ? "cmd.exe" : "command.com"). 633074c14cd6Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 633174c14cd6Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633274c14cd6Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633374c14cd6Smrg special way: 633474c14cd6Smrg - Space and tab are interpreted as delimiters. They are not treated as 633574c14cd6Smrg delimiters if they are surrounded by double quotes: "...". 633674c14cd6Smrg - Unescaped double quotes are removed from the input. Their only effect is 633774c14cd6Smrg that within double quotes, space and tab are treated like normal 633874c14cd6Smrg characters. 633974c14cd6Smrg - Backslashes not followed by double quotes are not special. 634074c14cd6Smrg - But 2*n+1 backslashes followed by a double quote become 634174c14cd6Smrg n backslashes followed by a double quote (n >= 0): 634274c14cd6Smrg \" -> " 634374c14cd6Smrg \\\" -> \" 634474c14cd6Smrg \\\\\" -> \\" 634574c14cd6Smrg */ 634674c14cd6Smrg#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" 634774c14cd6Smrg#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" 634874c14cd6Smrgchar ** 634974c14cd6Smrgprepare_spawn (char **argv) 635074c14cd6Smrg{ 635174c14cd6Smrg size_t argc; 635274c14cd6Smrg char **new_argv; 635374c14cd6Smrg size_t i; 635474c14cd6Smrg 635574c14cd6Smrg /* Count number of arguments. */ 635674c14cd6Smrg for (argc = 0; argv[argc] != NULL; argc++) 635774c14cd6Smrg ; 635874c14cd6Smrg 635974c14cd6Smrg /* Allocate new argument vector. */ 636074c14cd6Smrg new_argv = XMALLOC (char *, argc + 1); 636174c14cd6Smrg 636274c14cd6Smrg /* Put quoted arguments into the new argument vector. */ 636374c14cd6Smrg for (i = 0; i < argc; i++) 636474c14cd6Smrg { 636574c14cd6Smrg const char *string = argv[i]; 636674c14cd6Smrg 636774c14cd6Smrg if (string[0] == '\0') 636874c14cd6Smrg new_argv[i] = xstrdup ("\"\""); 636974c14cd6Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637074c14cd6Smrg { 637174c14cd6Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637274c14cd6Smrg size_t length; 637374c14cd6Smrg unsigned int backslashes; 637474c14cd6Smrg const char *s; 637574c14cd6Smrg char *quoted_string; 637674c14cd6Smrg char *p; 637774c14cd6Smrg 637874c14cd6Smrg length = 0; 637974c14cd6Smrg backslashes = 0; 638074c14cd6Smrg if (quote_around) 638174c14cd6Smrg length++; 638274c14cd6Smrg for (s = string; *s != '\0'; s++) 638374c14cd6Smrg { 638474c14cd6Smrg char c = *s; 638574c14cd6Smrg if (c == '"') 638674c14cd6Smrg length += backslashes + 1; 638774c14cd6Smrg length++; 638874c14cd6Smrg if (c == '\\') 638974c14cd6Smrg backslashes++; 639074c14cd6Smrg else 639174c14cd6Smrg backslashes = 0; 639274c14cd6Smrg } 639374c14cd6Smrg if (quote_around) 639474c14cd6Smrg length += backslashes + 1; 639574c14cd6Smrg 639674c14cd6Smrg quoted_string = XMALLOC (char, length + 1); 639774c14cd6Smrg 639874c14cd6Smrg p = quoted_string; 639974c14cd6Smrg backslashes = 0; 640074c14cd6Smrg if (quote_around) 640174c14cd6Smrg *p++ = '"'; 640274c14cd6Smrg for (s = string; *s != '\0'; s++) 640374c14cd6Smrg { 640474c14cd6Smrg char c = *s; 640574c14cd6Smrg if (c == '"') 640674c14cd6Smrg { 640774c14cd6Smrg unsigned int j; 640874c14cd6Smrg for (j = backslashes + 1; j > 0; j--) 640974c14cd6Smrg *p++ = '\\'; 641074c14cd6Smrg } 641174c14cd6Smrg *p++ = c; 641274c14cd6Smrg if (c == '\\') 641374c14cd6Smrg backslashes++; 641474c14cd6Smrg else 641574c14cd6Smrg backslashes = 0; 641674c14cd6Smrg } 641774c14cd6Smrg if (quote_around) 641874c14cd6Smrg { 641974c14cd6Smrg unsigned int j; 642074c14cd6Smrg for (j = backslashes; j > 0; j--) 642174c14cd6Smrg *p++ = '\\'; 642274c14cd6Smrg *p++ = '"'; 642374c14cd6Smrg } 642474c14cd6Smrg *p = '\0'; 642574c14cd6Smrg 642674c14cd6Smrg new_argv[i] = quoted_string; 642774c14cd6Smrg } 642874c14cd6Smrg else 642974c14cd6Smrg new_argv[i] = (char *) string; 643074c14cd6Smrg } 643174c14cd6Smrg new_argv[argc] = NULL; 643274c14cd6Smrg 643374c14cd6Smrg return new_argv; 643474c14cd6Smrg} 643574c14cd6SmrgEOF 643674c14cd6Smrg ;; 643774c14cd6Smrg esac 643872b676d7Smrg 643974c14cd6Smrg cat <<"EOF" 644074c14cd6Smrgvoid lt_dump_script (FILE* f) 644174c14cd6Smrg{ 644274c14cd6SmrgEOF 644374c14cd6Smrg func_emit_wrapper yes | 644474c14cd6Smrg $SED -n -e ' 644574c14cd6Smrgs/^\(.\{79\}\)\(..*\)/\1\ 644674c14cd6Smrg\2/ 644774c14cd6Smrgh 644874c14cd6Smrgs/\([\\"]\)/\\\1/g 644974c14cd6Smrgs/$/\\n/ 645074c14cd6Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 645174c14cd6Smrgg 645274c14cd6SmrgD' 645374c14cd6Smrg cat <<"EOF" 645474c14cd6Smrg} 6455e35772b2SmrgEOF 6456e35772b2Smrg} 6457e35772b2Smrg# end: func_emit_cwrapperexe_src 645872b676d7Smrg 645974c14cd6Smrg# func_win32_import_lib_p ARG 646074c14cd6Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646174c14cd6Smrgfunc_win32_import_lib_p () 646274c14cd6Smrg{ 646321525869Smrg $debug_cmd 646421525869Smrg 646574c14cd6Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646674c14cd6Smrg *import*) : ;; 646774c14cd6Smrg *) false ;; 646874c14cd6Smrg esac 646974c14cd6Smrg} 647074c14cd6Smrg 647121525869Smrg# func_suncc_cstd_abi 647221525869Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647321525869Smrg# Several compiler flags select an ABI that is incompatible with the 647421525869Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647521525869Smrgfunc_suncc_cstd_abi () 647621525869Smrg{ 647721525869Smrg $debug_cmd 647821525869Smrg 647921525869Smrg case " $compile_command " in 648021525869Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648121525869Smrg suncc_use_cstd_abi=no 648221525869Smrg ;; 648321525869Smrg *) 648421525869Smrg suncc_use_cstd_abi=yes 648521525869Smrg ;; 648621525869Smrg esac 648721525869Smrg} 648821525869Smrg 6489e35772b2Smrg# func_mode_link arg... 6490e35772b2Smrgfunc_mode_link () 6491e35772b2Smrg{ 649221525869Smrg $debug_cmd 649321525869Smrg 6494e35772b2Smrg case $host in 6495e35772b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496e35772b2Smrg # It is impossible to link a dll without this setting, and 6497e35772b2Smrg # we shouldn't force the makefile maintainer to figure out 649821525869Smrg # what system we are compiling for in order to pass an extra 6499e35772b2Smrg # flag for every libtool invocation. 6500e35772b2Smrg # allow_undefined=no 650172b676d7Smrg 6502e35772b2Smrg # FIXME: Unfortunately, there are problems with the above when trying 650321525869Smrg # to make a dll that has undefined symbols, in which case not 6504e35772b2Smrg # even a static library is built. For now, we need to specify 6505e35772b2Smrg # -no-undefined on the libtool link line when we can be certain 6506e35772b2Smrg # that all symbols are satisfied, otherwise we get a static library. 6507e35772b2Smrg allow_undefined=yes 6508e35772b2Smrg ;; 6509e35772b2Smrg *) 6510e35772b2Smrg allow_undefined=yes 6511e35772b2Smrg ;; 6512e35772b2Smrg esac 6513e35772b2Smrg libtool_args=$nonopt 6514e35772b2Smrg base_compile="$nonopt $@" 6515e35772b2Smrg compile_command=$nonopt 6516e35772b2Smrg finalize_command=$nonopt 651772b676d7Smrg 6518e35772b2Smrg compile_rpath= 6519e35772b2Smrg finalize_rpath= 6520e35772b2Smrg compile_shlibpath= 6521e35772b2Smrg finalize_shlibpath= 6522e35772b2Smrg convenience= 6523e35772b2Smrg old_convenience= 6524e35772b2Smrg deplibs= 6525e35772b2Smrg old_deplibs= 6526e35772b2Smrg compiler_flags= 6527e35772b2Smrg linker_flags= 6528e35772b2Smrg dllsearchpath= 6529e35772b2Smrg lib_search_path=`pwd` 6530e35772b2Smrg inst_prefix_dir= 6531e35772b2Smrg new_inherited_linker_flags= 653272b676d7Smrg 6533e35772b2Smrg avoid_version=no 653474c14cd6Smrg bindir= 6535e35772b2Smrg dlfiles= 6536e35772b2Smrg dlprefiles= 6537e35772b2Smrg dlself=no 6538e35772b2Smrg export_dynamic=no 6539e35772b2Smrg export_symbols= 6540e35772b2Smrg export_symbols_regex= 6541e35772b2Smrg generated= 6542e35772b2Smrg libobjs= 6543e35772b2Smrg ltlibs= 6544e35772b2Smrg module=no 6545e35772b2Smrg no_install=no 6546e35772b2Smrg objs= 654721525869Smrg os2dllname= 6548e35772b2Smrg non_pic_objects= 6549e35772b2Smrg precious_files_regex= 6550e35772b2Smrg prefer_static_libs=no 655121525869Smrg preload=false 6552e35772b2Smrg prev= 6553e35772b2Smrg prevarg= 6554e35772b2Smrg release= 6555e35772b2Smrg rpath= 6556e35772b2Smrg xrpath= 6557e35772b2Smrg perm_rpath= 6558e35772b2Smrg temp_rpath= 6559e35772b2Smrg thread_safe=no 6560e35772b2Smrg vinfo= 6561e35772b2Smrg vinfo_number=no 6562e35772b2Smrg weak_libs= 656321525869Smrg single_module=$wl-single_module 6564e35772b2Smrg func_infer_tag $base_compile 6565e35772b2Smrg 6566e35772b2Smrg # We need to know -static, to get the right output filenames. 6567e35772b2Smrg for arg 6568e35772b2Smrg do 6569e35772b2Smrg case $arg in 6570e35772b2Smrg -shared) 657121525869Smrg test yes != "$build_libtool_libs" \ 657221525869Smrg && func_fatal_configuration "cannot build a shared library" 6573e35772b2Smrg build_old_libs=no 6574e35772b2Smrg break 6575e35772b2Smrg ;; 6576e35772b2Smrg -all-static | -static | -static-libtool-libs) 6577e35772b2Smrg case $arg in 6578e35772b2Smrg -all-static) 657921525869Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580e35772b2Smrg func_warning "complete static linking is impossible in this configuration" 6581e35772b2Smrg fi 6582e35772b2Smrg if test -n "$link_static_flag"; then 6583e35772b2Smrg dlopen_self=$dlopen_self_static 6584e35772b2Smrg fi 6585e35772b2Smrg prefer_static_libs=yes 6586e35772b2Smrg ;; 6587e35772b2Smrg -static) 6588e35772b2Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589e35772b2Smrg dlopen_self=$dlopen_self_static 6590e35772b2Smrg fi 6591e35772b2Smrg prefer_static_libs=built 6592e35772b2Smrg ;; 6593e35772b2Smrg -static-libtool-libs) 6594e35772b2Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595e35772b2Smrg dlopen_self=$dlopen_self_static 659672b676d7Smrg fi 6597e35772b2Smrg prefer_static_libs=yes 6598e35772b2Smrg ;; 6599e35772b2Smrg esac 6600e35772b2Smrg build_libtool_libs=no 6601e35772b2Smrg build_old_libs=yes 6602e35772b2Smrg break 6603e35772b2Smrg ;; 6604e35772b2Smrg esac 6605e35772b2Smrg done 660672b676d7Smrg 6607e35772b2Smrg # See if our shared archives depend on static archives. 6608e35772b2Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 660972b676d7Smrg 6610e35772b2Smrg # Go through the arguments, transforming them on the way. 6611e35772b2Smrg while test "$#" -gt 0; do 661221525869Smrg arg=$1 6613e35772b2Smrg shift 6614e35772b2Smrg func_quote_for_eval "$arg" 6615e35772b2Smrg qarg=$func_quote_for_eval_unquoted_result 6616e35772b2Smrg func_append libtool_args " $func_quote_for_eval_result" 661772b676d7Smrg 6618e35772b2Smrg # If the previous option needs an argument, assign it. 6619e35772b2Smrg if test -n "$prev"; then 6620e35772b2Smrg case $prev in 6621e35772b2Smrg output) 6622e35772b2Smrg func_append compile_command " @OUTPUT@" 6623e35772b2Smrg func_append finalize_command " @OUTPUT@" 6624e35772b2Smrg ;; 6625e35772b2Smrg esac 662672b676d7Smrg 6627e35772b2Smrg case $prev in 662874c14cd6Smrg bindir) 662921525869Smrg bindir=$arg 663074c14cd6Smrg prev= 663174c14cd6Smrg continue 663274c14cd6Smrg ;; 6633e35772b2Smrg dlfiles|dlprefiles) 663421525869Smrg $preload || { 6635e35772b2Smrg # Add the symbol object into the linking commands. 6636e35772b2Smrg func_append compile_command " @SYMFILE@" 6637e35772b2Smrg func_append finalize_command " @SYMFILE@" 663821525869Smrg preload=: 663921525869Smrg } 6640e35772b2Smrg case $arg in 6641e35772b2Smrg *.la | *.lo) ;; # We handle these cases below. 6642e35772b2Smrg force) 664321525869Smrg if test no = "$dlself"; then 6644e35772b2Smrg dlself=needless 6645e35772b2Smrg export_dynamic=yes 6646e35772b2Smrg fi 6647e35772b2Smrg prev= 6648e35772b2Smrg continue 6649e35772b2Smrg ;; 6650e35772b2Smrg self) 665121525869Smrg if test dlprefiles = "$prev"; then 6652e35772b2Smrg dlself=yes 665321525869Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654e35772b2Smrg dlself=yes 665572b676d7Smrg else 6656e35772b2Smrg dlself=needless 6657e35772b2Smrg export_dynamic=yes 665872b676d7Smrg fi 6659e35772b2Smrg prev= 6660e35772b2Smrg continue 6661e35772b2Smrg ;; 6662e35772b2Smrg *) 666321525869Smrg if test dlfiles = "$prev"; then 666474c14cd6Smrg func_append dlfiles " $arg" 666572b676d7Smrg else 666674c14cd6Smrg func_append dlprefiles " $arg" 666772b676d7Smrg fi 6668e35772b2Smrg prev= 6669e35772b2Smrg continue 6670e35772b2Smrg ;; 6671e35772b2Smrg esac 6672e35772b2Smrg ;; 6673e35772b2Smrg expsyms) 667421525869Smrg export_symbols=$arg 6675e35772b2Smrg test -f "$arg" \ 667621525869Smrg || func_fatal_error "symbol file '$arg' does not exist" 6677e35772b2Smrg prev= 6678e35772b2Smrg continue 6679e35772b2Smrg ;; 6680e35772b2Smrg expsyms_regex) 668121525869Smrg export_symbols_regex=$arg 6682e35772b2Smrg prev= 6683e35772b2Smrg continue 6684e35772b2Smrg ;; 6685e35772b2Smrg framework) 668672b676d7Smrg case $host in 6687e35772b2Smrg *-*-darwin*) 6688e35772b2Smrg case "$deplibs " in 6689e35772b2Smrg *" $qarg.ltframework "*) ;; 669074c14cd6Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691e35772b2Smrg ;; 6692e35772b2Smrg esac 6693e35772b2Smrg ;; 669472b676d7Smrg esac 6695e35772b2Smrg prev= 6696e35772b2Smrg continue 669772b676d7Smrg ;; 6698e35772b2Smrg inst_prefix) 669921525869Smrg inst_prefix_dir=$arg 670021525869Smrg prev= 670121525869Smrg continue 670221525869Smrg ;; 670321525869Smrg mllvm) 670421525869Smrg # Clang does not use LLVM to link, so we can simply discard any 670521525869Smrg # '-mllvm $arg' options when doing the link step. 6706e35772b2Smrg prev= 6707e35772b2Smrg continue 670872b676d7Smrg ;; 6709e35772b2Smrg objectlist) 6710e35772b2Smrg if test -f "$arg"; then 6711e35772b2Smrg save_arg=$arg 6712e35772b2Smrg moreargs= 6713e35772b2Smrg for fil in `cat "$save_arg"` 6714e35772b2Smrg do 671574c14cd6Smrg# func_append moreargs " $fil" 6716e35772b2Smrg arg=$fil 6717e35772b2Smrg # A libtool-controlled object. 671872b676d7Smrg 6719e35772b2Smrg # Check to see that this really is a libtool object. 6720e35772b2Smrg if func_lalib_unsafe_p "$arg"; then 6721e35772b2Smrg pic_object= 6722e35772b2Smrg non_pic_object= 672372b676d7Smrg 6724e35772b2Smrg # Read the .lo file 6725e35772b2Smrg func_source "$arg" 672672b676d7Smrg 6727e35772b2Smrg if test -z "$pic_object" || 6728e35772b2Smrg test -z "$non_pic_object" || 672921525869Smrg test none = "$pic_object" && 673021525869Smrg test none = "$non_pic_object"; then 673121525869Smrg func_fatal_error "cannot find name of object for '$arg'" 6732e35772b2Smrg fi 673372b676d7Smrg 6734e35772b2Smrg # Extract subdirectory from the argument. 6735e35772b2Smrg func_dirname "$arg" "/" "" 673621525869Smrg xdir=$func_dirname_result 673772b676d7Smrg 673821525869Smrg if test none != "$pic_object"; then 6739e35772b2Smrg # Prepend the subdirectory the object is found in. 674021525869Smrg pic_object=$xdir$pic_object 674172b676d7Smrg 674221525869Smrg if test dlfiles = "$prev"; then 674321525869Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 674474c14cd6Smrg func_append dlfiles " $pic_object" 6745e35772b2Smrg prev= 6746e35772b2Smrg continue 6747e35772b2Smrg else 6748e35772b2Smrg # If libtool objects are unsupported, then we need to preload. 6749e35772b2Smrg prev=dlprefiles 6750e35772b2Smrg fi 6751e35772b2Smrg fi 675272b676d7Smrg 6753e35772b2Smrg # CHECK ME: I think I busted this. -Ossama 675421525869Smrg if test dlprefiles = "$prev"; then 6755e35772b2Smrg # Preload the old-style object. 675674c14cd6Smrg func_append dlprefiles " $pic_object" 6757e35772b2Smrg prev= 6758e35772b2Smrg fi 675972b676d7Smrg 6760e35772b2Smrg # A PIC object. 6761e35772b2Smrg func_append libobjs " $pic_object" 676221525869Smrg arg=$pic_object 6763e35772b2Smrg fi 676472b676d7Smrg 6765e35772b2Smrg # Non-PIC object. 676621525869Smrg if test none != "$non_pic_object"; then 6767e35772b2Smrg # Prepend the subdirectory the object is found in. 676821525869Smrg non_pic_object=$xdir$non_pic_object 676972b676d7Smrg 6770e35772b2Smrg # A standard non-PIC object 6771e35772b2Smrg func_append non_pic_objects " $non_pic_object" 677221525869Smrg if test -z "$pic_object" || test none = "$pic_object"; then 677321525869Smrg arg=$non_pic_object 6774e35772b2Smrg fi 6775e35772b2Smrg else 6776e35772b2Smrg # If the PIC object exists, use it instead. 6777e35772b2Smrg # $xdir was prepended to $pic_object above. 677821525869Smrg non_pic_object=$pic_object 6779e35772b2Smrg func_append non_pic_objects " $non_pic_object" 6780e35772b2Smrg fi 6781e35772b2Smrg else 6782e35772b2Smrg # Only an error if not doing a dry-run. 6783e35772b2Smrg if $opt_dry_run; then 6784e35772b2Smrg # Extract subdirectory from the argument. 6785e35772b2Smrg func_dirname "$arg" "/" "" 678621525869Smrg xdir=$func_dirname_result 6787e35772b2Smrg 6788e35772b2Smrg func_lo2o "$arg" 6789e35772b2Smrg pic_object=$xdir$objdir/$func_lo2o_result 6790e35772b2Smrg non_pic_object=$xdir$func_lo2o_result 6791e35772b2Smrg func_append libobjs " $pic_object" 6792e35772b2Smrg func_append non_pic_objects " $non_pic_object" 6793e35772b2Smrg else 679421525869Smrg func_fatal_error "'$arg' is not a valid libtool object" 6795e35772b2Smrg fi 6796e35772b2Smrg fi 6797e35772b2Smrg done 679872b676d7Smrg else 679921525869Smrg func_fatal_error "link input file '$arg' does not exist" 680072b676d7Smrg fi 6801e35772b2Smrg arg=$save_arg 6802e35772b2Smrg prev= 6803e35772b2Smrg continue 6804e35772b2Smrg ;; 680521525869Smrg os2dllname) 680621525869Smrg os2dllname=$arg 680721525869Smrg prev= 680821525869Smrg continue 680921525869Smrg ;; 6810e35772b2Smrg precious_regex) 681121525869Smrg precious_files_regex=$arg 6812e35772b2Smrg prev= 6813e35772b2Smrg continue 6814e35772b2Smrg ;; 6815e35772b2Smrg release) 681621525869Smrg release=-$arg 6817e35772b2Smrg prev= 6818e35772b2Smrg continue 6819e35772b2Smrg ;; 6820e35772b2Smrg rpath | xrpath) 6821e35772b2Smrg # We need an absolute path. 6822e35772b2Smrg case $arg in 6823e35772b2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824e35772b2Smrg *) 6825e35772b2Smrg func_fatal_error "only absolute run-paths are allowed" 6826e35772b2Smrg ;; 6827e35772b2Smrg esac 682821525869Smrg if test rpath = "$prev"; then 6829e35772b2Smrg case "$rpath " in 6830e35772b2Smrg *" $arg "*) ;; 683174c14cd6Smrg *) func_append rpath " $arg" ;; 6832e35772b2Smrg esac 683372b676d7Smrg else 6834e35772b2Smrg case "$xrpath " in 6835e35772b2Smrg *" $arg "*) ;; 683674c14cd6Smrg *) func_append xrpath " $arg" ;; 6837e35772b2Smrg esac 683872b676d7Smrg fi 6839e35772b2Smrg prev= 6840e35772b2Smrg continue 6841e35772b2Smrg ;; 6842e35772b2Smrg shrext) 684321525869Smrg shrext_cmds=$arg 6844e35772b2Smrg prev= 6845e35772b2Smrg continue 6846e35772b2Smrg ;; 6847e35772b2Smrg weak) 684874c14cd6Smrg func_append weak_libs " $arg" 6849e35772b2Smrg prev= 6850e35772b2Smrg continue 6851e35772b2Smrg ;; 6852e35772b2Smrg xcclinker) 685374c14cd6Smrg func_append linker_flags " $qarg" 685474c14cd6Smrg func_append compiler_flags " $qarg" 6855e35772b2Smrg prev= 6856e35772b2Smrg func_append compile_command " $qarg" 6857e35772b2Smrg func_append finalize_command " $qarg" 6858e35772b2Smrg continue 6859e35772b2Smrg ;; 6860e35772b2Smrg xcompiler) 686174c14cd6Smrg func_append compiler_flags " $qarg" 6862e35772b2Smrg prev= 6863e35772b2Smrg func_append compile_command " $qarg" 6864e35772b2Smrg func_append finalize_command " $qarg" 6865e35772b2Smrg continue 6866e35772b2Smrg ;; 6867e35772b2Smrg xlinker) 686874c14cd6Smrg func_append linker_flags " $qarg" 686974c14cd6Smrg func_append compiler_flags " $wl$qarg" 6870e35772b2Smrg prev= 6871e35772b2Smrg func_append compile_command " $wl$qarg" 6872e35772b2Smrg func_append finalize_command " $wl$qarg" 6873e35772b2Smrg continue 6874e35772b2Smrg ;; 6875e35772b2Smrg *) 6876e35772b2Smrg eval "$prev=\"\$arg\"" 6877e35772b2Smrg prev= 6878e35772b2Smrg continue 6879e35772b2Smrg ;; 688072b676d7Smrg esac 6881e35772b2Smrg fi # test -n "$prev" 688272b676d7Smrg 688321525869Smrg prevarg=$arg 688472b676d7Smrg 6885e35772b2Smrg case $arg in 6886e35772b2Smrg -all-static) 6887e35772b2Smrg if test -n "$link_static_flag"; then 6888e35772b2Smrg # See comment for -static flag below, for more details. 6889e35772b2Smrg func_append compile_command " $link_static_flag" 6890e35772b2Smrg func_append finalize_command " $link_static_flag" 6891e35772b2Smrg fi 6892e35772b2Smrg continue 6893e35772b2Smrg ;; 689472b676d7Smrg 6895e35772b2Smrg -allow-undefined) 6896e35772b2Smrg # FIXME: remove this flag sometime in the future. 689721525869Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898e35772b2Smrg ;; 689972b676d7Smrg 6900e35772b2Smrg -avoid-version) 6901e35772b2Smrg avoid_version=yes 6902e35772b2Smrg continue 6903e35772b2Smrg ;; 690472b676d7Smrg 690574c14cd6Smrg -bindir) 690674c14cd6Smrg prev=bindir 690774c14cd6Smrg continue 690874c14cd6Smrg ;; 690974c14cd6Smrg 6910e35772b2Smrg -dlopen) 6911e35772b2Smrg prev=dlfiles 6912e35772b2Smrg continue 6913e35772b2Smrg ;; 691472b676d7Smrg 6915e35772b2Smrg -dlpreopen) 6916e35772b2Smrg prev=dlprefiles 6917e35772b2Smrg continue 6918e35772b2Smrg ;; 691972b676d7Smrg 6920e35772b2Smrg -export-dynamic) 6921e35772b2Smrg export_dynamic=yes 6922e35772b2Smrg continue 6923e35772b2Smrg ;; 692472b676d7Smrg 6925e35772b2Smrg -export-symbols | -export-symbols-regex) 6926e35772b2Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927e35772b2Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928e35772b2Smrg fi 692921525869Smrg if test X-export-symbols = "X$arg"; then 6930e35772b2Smrg prev=expsyms 6931e35772b2Smrg else 6932e35772b2Smrg prev=expsyms_regex 6933e35772b2Smrg fi 6934e35772b2Smrg continue 6935e35772b2Smrg ;; 693672b676d7Smrg 6937e35772b2Smrg -framework) 6938e35772b2Smrg prev=framework 6939e35772b2Smrg continue 6940e35772b2Smrg ;; 694172b676d7Smrg 6942e35772b2Smrg -inst-prefix-dir) 6943e35772b2Smrg prev=inst_prefix 6944e35772b2Smrg continue 6945e35772b2Smrg ;; 694672b676d7Smrg 6947e35772b2Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948e35772b2Smrg # so, if we see these flags be careful not to treat them like -L 6949e35772b2Smrg -L[A-Z][A-Z]*:*) 6950e35772b2Smrg case $with_gcc/$host in 6951e35772b2Smrg no/*-*-irix* | /*-*-irix*) 6952e35772b2Smrg func_append compile_command " $arg" 6953e35772b2Smrg func_append finalize_command " $arg" 6954e35772b2Smrg ;; 6955e35772b2Smrg esac 6956e35772b2Smrg continue 6957e35772b2Smrg ;; 695872b676d7Smrg 6959e35772b2Smrg -L*) 696074c14cd6Smrg func_stripname "-L" '' "$arg" 696174c14cd6Smrg if test -z "$func_stripname_result"; then 6962e35772b2Smrg if test "$#" -gt 0; then 696321525869Smrg func_fatal_error "require no space between '-L' and '$1'" 6964e35772b2Smrg else 696521525869Smrg func_fatal_error "need path for '-L' option" 6966e35772b2Smrg fi 6967e35772b2Smrg fi 696874c14cd6Smrg func_resolve_sysroot "$func_stripname_result" 696974c14cd6Smrg dir=$func_resolve_sysroot_result 6970e35772b2Smrg # We need an absolute path. 6971e35772b2Smrg case $dir in 6972e35772b2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973e35772b2Smrg *) 6974e35772b2Smrg absdir=`cd "$dir" && pwd` 6975e35772b2Smrg test -z "$absdir" && \ 697621525869Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697721525869Smrg dir=$absdir 6978e35772b2Smrg ;; 6979e35772b2Smrg esac 6980e35772b2Smrg case "$deplibs " in 698174c14cd6Smrg *" -L$dir "* | *" $arg "*) 698274c14cd6Smrg # Will only happen for absolute or sysroot arguments 698374c14cd6Smrg ;; 6984e35772b2Smrg *) 698574c14cd6Smrg # Preserve sysroot, but never include relative directories 698674c14cd6Smrg case $dir in 698774c14cd6Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 698874c14cd6Smrg *) func_append deplibs " -L$dir" ;; 698974c14cd6Smrg esac 699074c14cd6Smrg func_append lib_search_path " $dir" 6991e35772b2Smrg ;; 6992e35772b2Smrg esac 6993e35772b2Smrg case $host in 6994e35772b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699574c14cd6Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996e35772b2Smrg case :$dllsearchpath: in 6997e35772b2Smrg *":$dir:"*) ;; 6998e35772b2Smrg ::) dllsearchpath=$dir;; 699974c14cd6Smrg *) func_append dllsearchpath ":$dir";; 7000e35772b2Smrg esac 7001e35772b2Smrg case :$dllsearchpath: in 7002e35772b2Smrg *":$testbindir:"*) ;; 7003e35772b2Smrg ::) dllsearchpath=$testbindir;; 700474c14cd6Smrg *) func_append dllsearchpath ":$testbindir";; 7005e35772b2Smrg esac 7006e35772b2Smrg ;; 7007e35772b2Smrg esac 7008e35772b2Smrg continue 7009e35772b2Smrg ;; 701072b676d7Smrg 7011e35772b2Smrg -l*) 701221525869Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013e35772b2Smrg case $host in 701474c14cd6Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015e35772b2Smrg # These systems don't actually have a C or math library (as such) 7016e35772b2Smrg continue 7017e35772b2Smrg ;; 7018e35772b2Smrg *-*-os2*) 7019e35772b2Smrg # These systems don't actually have a C library (as such) 702021525869Smrg test X-lc = "X$arg" && continue 7021e35772b2Smrg ;; 702221525869Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023e35772b2Smrg # Do not include libc due to us having libc/libc_r. 702421525869Smrg test X-lc = "X$arg" && continue 7025e35772b2Smrg ;; 7026e35772b2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7027e35772b2Smrg # Rhapsody C and math libraries are in the System framework 702874c14cd6Smrg func_append deplibs " System.ltframework" 7029e35772b2Smrg continue 7030e35772b2Smrg ;; 7031e35772b2Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7032e35772b2Smrg # Causes problems with __ctype 703321525869Smrg test X-lc = "X$arg" && continue 7034e35772b2Smrg ;; 7035e35772b2Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036e35772b2Smrg # Compiler inserts libc in the correct place for threads to work 703721525869Smrg test X-lc = "X$arg" && continue 7038e35772b2Smrg ;; 7039e35772b2Smrg esac 704021525869Smrg elif test X-lc_r = "X$arg"; then 7041e35772b2Smrg case $host in 704221525869Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043e35772b2Smrg # Do not include libc_r directly, use -pthread flag. 7044e35772b2Smrg continue 7045e35772b2Smrg ;; 7046e35772b2Smrg esac 7047e35772b2Smrg fi 704874c14cd6Smrg func_append deplibs " $arg" 7049e35772b2Smrg continue 7050e35772b2Smrg ;; 705172b676d7Smrg 705221525869Smrg -mllvm) 705321525869Smrg prev=mllvm 705421525869Smrg continue 705521525869Smrg ;; 705621525869Smrg 7057e35772b2Smrg -module) 7058e35772b2Smrg module=yes 7059e35772b2Smrg continue 7060e35772b2Smrg ;; 706172b676d7Smrg 7062e35772b2Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063e35772b2Smrg # classes, name mangling, and exception handling. 7064e35772b2Smrg # Darwin uses the -arch flag to determine output architecture. 706574c14cd6Smrg -model|-arch|-isysroot|--sysroot) 706674c14cd6Smrg func_append compiler_flags " $arg" 7067e35772b2Smrg func_append compile_command " $arg" 7068e35772b2Smrg func_append finalize_command " $arg" 7069e35772b2Smrg prev=xcompiler 7070e35772b2Smrg continue 7071e35772b2Smrg ;; 707272b676d7Smrg 707374c14cd6Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 707474c14cd6Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 707574c14cd6Smrg func_append compiler_flags " $arg" 7076e35772b2Smrg func_append compile_command " $arg" 7077e35772b2Smrg func_append finalize_command " $arg" 7078e35772b2Smrg case "$new_inherited_linker_flags " in 7079e35772b2Smrg *" $arg "*) ;; 708074c14cd6Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081e35772b2Smrg esac 7082e35772b2Smrg continue 7083e35772b2Smrg ;; 708472b676d7Smrg 7085e35772b2Smrg -multi_module) 708621525869Smrg single_module=$wl-multi_module 7087e35772b2Smrg continue 7088e35772b2Smrg ;; 708972b676d7Smrg 7090e35772b2Smrg -no-fast-install) 7091e35772b2Smrg fast_install=no 7092e35772b2Smrg continue 7093e35772b2Smrg ;; 709472b676d7Smrg 7095e35772b2Smrg -no-install) 7096e35772b2Smrg case $host in 7097e35772b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098e35772b2Smrg # The PATH hackery in wrapper scripts is required on Windows 7099e35772b2Smrg # and Darwin in order for the loader to find any dlls it needs. 710021525869Smrg func_warning "'-no-install' is ignored for $host" 710121525869Smrg func_warning "assuming '-no-fast-install' instead" 7102e35772b2Smrg fast_install=no 7103e35772b2Smrg ;; 7104e35772b2Smrg *) no_install=yes ;; 7105e35772b2Smrg esac 7106e35772b2Smrg continue 7107e35772b2Smrg ;; 710872b676d7Smrg 7109e35772b2Smrg -no-undefined) 7110e35772b2Smrg allow_undefined=no 7111e35772b2Smrg continue 7112e35772b2Smrg ;; 711372b676d7Smrg 7114e35772b2Smrg -objectlist) 7115e35772b2Smrg prev=objectlist 7116e35772b2Smrg continue 7117e35772b2Smrg ;; 711872b676d7Smrg 711921525869Smrg -os2dllname) 712021525869Smrg prev=os2dllname 712121525869Smrg continue 712221525869Smrg ;; 712321525869Smrg 7124e35772b2Smrg -o) prev=output ;; 712572b676d7Smrg 7126e35772b2Smrg -precious-files-regex) 7127e35772b2Smrg prev=precious_regex 7128e35772b2Smrg continue 7129e35772b2Smrg ;; 713072b676d7Smrg 7131e35772b2Smrg -release) 7132e35772b2Smrg prev=release 7133e35772b2Smrg continue 7134e35772b2Smrg ;; 713572b676d7Smrg 7136e35772b2Smrg -rpath) 7137e35772b2Smrg prev=rpath 7138e35772b2Smrg continue 7139e35772b2Smrg ;; 714072b676d7Smrg 7141e35772b2Smrg -R) 7142e35772b2Smrg prev=xrpath 7143e35772b2Smrg continue 7144e35772b2Smrg ;; 714572b676d7Smrg 7146e35772b2Smrg -R*) 7147e35772b2Smrg func_stripname '-R' '' "$arg" 7148e35772b2Smrg dir=$func_stripname_result 7149e35772b2Smrg # We need an absolute path. 7150e35772b2Smrg case $dir in 7151e35772b2Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 715274c14cd6Smrg =*) 715374c14cd6Smrg func_stripname '=' '' "$dir" 715474c14cd6Smrg dir=$lt_sysroot$func_stripname_result 715574c14cd6Smrg ;; 7156e35772b2Smrg *) 7157e35772b2Smrg func_fatal_error "only absolute run-paths are allowed" 7158e35772b2Smrg ;; 7159e35772b2Smrg esac 7160e35772b2Smrg case "$xrpath " in 7161e35772b2Smrg *" $dir "*) ;; 716274c14cd6Smrg *) func_append xrpath " $dir" ;; 7163e35772b2Smrg esac 7164e35772b2Smrg continue 7165e35772b2Smrg ;; 716672b676d7Smrg 7167e35772b2Smrg -shared) 7168e35772b2Smrg # The effects of -shared are defined in a previous loop. 7169e35772b2Smrg continue 7170e35772b2Smrg ;; 717172b676d7Smrg 7172e35772b2Smrg -shrext) 7173e35772b2Smrg prev=shrext 7174e35772b2Smrg continue 7175e35772b2Smrg ;; 717672b676d7Smrg 7177e35772b2Smrg -static | -static-libtool-libs) 7178e35772b2Smrg # The effects of -static are defined in a previous loop. 7179e35772b2Smrg # We used to do the same as -all-static on platforms that 7180e35772b2Smrg # didn't have a PIC flag, but the assumption that the effects 7181e35772b2Smrg # would be equivalent was wrong. It would break on at least 7182e35772b2Smrg # Digital Unix and AIX. 7183e35772b2Smrg continue 7184e35772b2Smrg ;; 718572b676d7Smrg 7186e35772b2Smrg -thread-safe) 7187e35772b2Smrg thread_safe=yes 7188e35772b2Smrg continue 7189e35772b2Smrg ;; 719072b676d7Smrg 7191e35772b2Smrg -version-info) 7192e35772b2Smrg prev=vinfo 7193e35772b2Smrg continue 7194e35772b2Smrg ;; 719572b676d7Smrg 7196e35772b2Smrg -version-number) 7197e35772b2Smrg prev=vinfo 7198e35772b2Smrg vinfo_number=yes 7199e35772b2Smrg continue 7200e35772b2Smrg ;; 720172b676d7Smrg 7202e35772b2Smrg -weak) 7203e35772b2Smrg prev=weak 7204e35772b2Smrg continue 7205e35772b2Smrg ;; 720672b676d7Smrg 7207e35772b2Smrg -Wc,*) 7208e35772b2Smrg func_stripname '-Wc,' '' "$arg" 7209e35772b2Smrg args=$func_stripname_result 7210e35772b2Smrg arg= 721121525869Smrg save_ifs=$IFS; IFS=, 7212e35772b2Smrg for flag in $args; do 721321525869Smrg IFS=$save_ifs 7214e35772b2Smrg func_quote_for_eval "$flag" 721574c14cd6Smrg func_append arg " $func_quote_for_eval_result" 721674c14cd6Smrg func_append compiler_flags " $func_quote_for_eval_result" 7217e35772b2Smrg done 721821525869Smrg IFS=$save_ifs 7219e35772b2Smrg func_stripname ' ' '' "$arg" 7220e35772b2Smrg arg=$func_stripname_result 7221e35772b2Smrg ;; 722272b676d7Smrg 7223e35772b2Smrg -Wl,*) 7224e35772b2Smrg func_stripname '-Wl,' '' "$arg" 7225e35772b2Smrg args=$func_stripname_result 7226e35772b2Smrg arg= 722721525869Smrg save_ifs=$IFS; IFS=, 7228e35772b2Smrg for flag in $args; do 722921525869Smrg IFS=$save_ifs 7230e35772b2Smrg func_quote_for_eval "$flag" 723174c14cd6Smrg func_append arg " $wl$func_quote_for_eval_result" 723274c14cd6Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 723374c14cd6Smrg func_append linker_flags " $func_quote_for_eval_result" 7234e35772b2Smrg done 723521525869Smrg IFS=$save_ifs 7236e35772b2Smrg func_stripname ' ' '' "$arg" 7237e35772b2Smrg arg=$func_stripname_result 7238e35772b2Smrg ;; 723972b676d7Smrg 7240e35772b2Smrg -Xcompiler) 7241e35772b2Smrg prev=xcompiler 7242e35772b2Smrg continue 7243e35772b2Smrg ;; 724472b676d7Smrg 7245e35772b2Smrg -Xlinker) 7246e35772b2Smrg prev=xlinker 7247e35772b2Smrg continue 7248e35772b2Smrg ;; 724972b676d7Smrg 7250e35772b2Smrg -XCClinker) 7251e35772b2Smrg prev=xcclinker 7252e35772b2Smrg continue 7253e35772b2Smrg ;; 725472b676d7Smrg 7255e35772b2Smrg # -msg_* for osf cc 7256e35772b2Smrg -msg_*) 7257e35772b2Smrg func_quote_for_eval "$arg" 725821525869Smrg arg=$func_quote_for_eval_result 7259e35772b2Smrg ;; 726072b676d7Smrg 726174c14cd6Smrg # Flags to be passed through unchanged, with rationale: 726274c14cd6Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726374c14cd6Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 726474c14cd6Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726574c14cd6Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726674c14cd6Smrg # -q* compiler args for the IBM compiler 726774c14cd6Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726874c14cd6Smrg # -F/path path to uninstalled frameworks, gcc on darwin 726974c14cd6Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727021525869Smrg # -fstack-protector* stack protector flags for GCC 727174c14cd6Smrg # @file GCC response files 727274c14cd6Smrg # -tp=* Portland pgcc target processor selection 727374c14cd6Smrg # --sysroot=* for sysroot support 727421525869Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 727574fcc364Smrg # -specs=* GCC specs files 727621525869Smrg # -stdlib=* select c++ std lib with clang 727774fcc364Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7278e35772b2Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 727974c14cd6Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 728074fcc364Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 728174fcc364Smrg -specs=*|-fsanitize=*) 7282e35772b2Smrg func_quote_for_eval "$arg" 728321525869Smrg arg=$func_quote_for_eval_result 7284e35772b2Smrg func_append compile_command " $arg" 7285e35772b2Smrg func_append finalize_command " $arg" 728674c14cd6Smrg func_append compiler_flags " $arg" 7287e35772b2Smrg continue 7288e35772b2Smrg ;; 728972b676d7Smrg 729021525869Smrg -Z*) 729121525869Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 729221525869Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 729321525869Smrg compiler_flags="$compiler_flags $arg" 729421525869Smrg func_append compile_command " $arg" 729521525869Smrg func_append finalize_command " $arg" 729621525869Smrg case $arg in 729721525869Smrg -Zlinker | -Zstack) 729821525869Smrg prev=xcompiler 729921525869Smrg ;; 730021525869Smrg esac 730121525869Smrg continue 730221525869Smrg else 730321525869Smrg # Otherwise treat like 'Some other compiler flag' below 730421525869Smrg func_quote_for_eval "$arg" 730521525869Smrg arg=$func_quote_for_eval_result 730621525869Smrg fi 730721525869Smrg ;; 730821525869Smrg 7309e35772b2Smrg # Some other compiler flag. 7310e35772b2Smrg -* | +*) 7311e35772b2Smrg func_quote_for_eval "$arg" 731221525869Smrg arg=$func_quote_for_eval_result 7313e35772b2Smrg ;; 731472b676d7Smrg 7315e35772b2Smrg *.$objext) 7316e35772b2Smrg # A standard object. 731774c14cd6Smrg func_append objs " $arg" 7318e35772b2Smrg ;; 731972b676d7Smrg 7320e35772b2Smrg *.lo) 7321e35772b2Smrg # A libtool-controlled object. 732272b676d7Smrg 7323e35772b2Smrg # Check to see that this really is a libtool object. 7324e35772b2Smrg if func_lalib_unsafe_p "$arg"; then 7325e35772b2Smrg pic_object= 7326e35772b2Smrg non_pic_object= 732772b676d7Smrg 7328e35772b2Smrg # Read the .lo file 7329e35772b2Smrg func_source "$arg" 733072b676d7Smrg 7331e35772b2Smrg if test -z "$pic_object" || 7332e35772b2Smrg test -z "$non_pic_object" || 733321525869Smrg test none = "$pic_object" && 733421525869Smrg test none = "$non_pic_object"; then 733521525869Smrg func_fatal_error "cannot find name of object for '$arg'" 7336e35772b2Smrg fi 733772b676d7Smrg 7338e35772b2Smrg # Extract subdirectory from the argument. 7339e35772b2Smrg func_dirname "$arg" "/" "" 734021525869Smrg xdir=$func_dirname_result 73411fd23544Smrg 734221525869Smrg test none = "$pic_object" || { 7343e35772b2Smrg # Prepend the subdirectory the object is found in. 734421525869Smrg pic_object=$xdir$pic_object 734572b676d7Smrg 734621525869Smrg if test dlfiles = "$prev"; then 734721525869Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 734874c14cd6Smrg func_append dlfiles " $pic_object" 7349e35772b2Smrg prev= 7350e35772b2Smrg continue 7351e35772b2Smrg else 7352e35772b2Smrg # If libtool objects are unsupported, then we need to preload. 7353e35772b2Smrg prev=dlprefiles 7354e35772b2Smrg fi 7355e35772b2Smrg fi 735672b676d7Smrg 7357e35772b2Smrg # CHECK ME: I think I busted this. -Ossama 735821525869Smrg if test dlprefiles = "$prev"; then 7359e35772b2Smrg # Preload the old-style object. 736074c14cd6Smrg func_append dlprefiles " $pic_object" 7361e35772b2Smrg prev= 7362e35772b2Smrg fi 736372b676d7Smrg 7364e35772b2Smrg # A PIC object. 7365e35772b2Smrg func_append libobjs " $pic_object" 736621525869Smrg arg=$pic_object 736721525869Smrg } 736872b676d7Smrg 7369e35772b2Smrg # Non-PIC object. 737021525869Smrg if test none != "$non_pic_object"; then 7371e35772b2Smrg # Prepend the subdirectory the object is found in. 737221525869Smrg non_pic_object=$xdir$non_pic_object 737372b676d7Smrg 7374e35772b2Smrg # A standard non-PIC object 7375e35772b2Smrg func_append non_pic_objects " $non_pic_object" 737621525869Smrg if test -z "$pic_object" || test none = "$pic_object"; then 737721525869Smrg arg=$non_pic_object 7378e35772b2Smrg fi 7379e35772b2Smrg else 7380e35772b2Smrg # If the PIC object exists, use it instead. 7381e35772b2Smrg # $xdir was prepended to $pic_object above. 738221525869Smrg non_pic_object=$pic_object 7383e35772b2Smrg func_append non_pic_objects " $non_pic_object" 7384e35772b2Smrg fi 7385e35772b2Smrg else 7386e35772b2Smrg # Only an error if not doing a dry-run. 7387e35772b2Smrg if $opt_dry_run; then 7388e35772b2Smrg # Extract subdirectory from the argument. 7389e35772b2Smrg func_dirname "$arg" "/" "" 739021525869Smrg xdir=$func_dirname_result 7391e35772b2Smrg 7392e35772b2Smrg func_lo2o "$arg" 7393e35772b2Smrg pic_object=$xdir$objdir/$func_lo2o_result 7394e35772b2Smrg non_pic_object=$xdir$func_lo2o_result 7395e35772b2Smrg func_append libobjs " $pic_object" 7396e35772b2Smrg func_append non_pic_objects " $non_pic_object" 7397e35772b2Smrg else 739821525869Smrg func_fatal_error "'$arg' is not a valid libtool object" 7399e35772b2Smrg fi 7400e35772b2Smrg fi 7401e35772b2Smrg ;; 740272b676d7Smrg 7403e35772b2Smrg *.$libext) 7404e35772b2Smrg # An archive. 740574c14cd6Smrg func_append deplibs " $arg" 740674c14cd6Smrg func_append old_deplibs " $arg" 7407e35772b2Smrg continue 7408e35772b2Smrg ;; 7409e35772b2Smrg 7410e35772b2Smrg *.la) 7411e35772b2Smrg # A libtool-controlled library. 7412e35772b2Smrg 741374c14cd6Smrg func_resolve_sysroot "$arg" 741421525869Smrg if test dlfiles = "$prev"; then 7415e35772b2Smrg # This library was specified with -dlopen. 741674c14cd6Smrg func_append dlfiles " $func_resolve_sysroot_result" 7417e35772b2Smrg prev= 741821525869Smrg elif test dlprefiles = "$prev"; then 7419e35772b2Smrg # The library was specified with -dlpreopen. 742074c14cd6Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7421e35772b2Smrg prev= 7422e35772b2Smrg else 742374c14cd6Smrg func_append deplibs " $func_resolve_sysroot_result" 7424e35772b2Smrg fi 7425e35772b2Smrg continue 7426e35772b2Smrg ;; 7427e35772b2Smrg 7428e35772b2Smrg # Some other compiler argument. 7429e35772b2Smrg *) 7430e35772b2Smrg # Unknown arguments in both finalize_command and compile_command need 7431e35772b2Smrg # to be aesthetically quoted because they are evaled later. 7432e35772b2Smrg func_quote_for_eval "$arg" 743321525869Smrg arg=$func_quote_for_eval_result 7434e35772b2Smrg ;; 7435e35772b2Smrg esac # arg 7436e35772b2Smrg 7437e35772b2Smrg # Now actually substitute the argument into the commands. 7438e35772b2Smrg if test -n "$arg"; then 7439e35772b2Smrg func_append compile_command " $arg" 7440e35772b2Smrg func_append finalize_command " $arg" 7441e35772b2Smrg fi 7442e35772b2Smrg done # argument parsing loop 7443e35772b2Smrg 7444e35772b2Smrg test -n "$prev" && \ 744521525869Smrg func_fatal_help "the '$prevarg' option requires an argument" 7446e35772b2Smrg 744721525869Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7448e35772b2Smrg eval arg=\"$export_dynamic_flag_spec\" 7449e35772b2Smrg func_append compile_command " $arg" 7450e35772b2Smrg func_append finalize_command " $arg" 7451e35772b2Smrg fi 7452e35772b2Smrg 7453e35772b2Smrg oldlibs= 7454e35772b2Smrg # calculate the name of the file, without its directory 7455e35772b2Smrg func_basename "$output" 745621525869Smrg outputname=$func_basename_result 745721525869Smrg libobjs_save=$libobjs 7458e35772b2Smrg 7459e35772b2Smrg if test -n "$shlibpath_var"; then 7460e35772b2Smrg # get the directories listed in $shlibpath_var 746121525869Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7462e35772b2Smrg else 7463e35772b2Smrg shlib_search_path= 7464e35772b2Smrg fi 7465e35772b2Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7466e35772b2Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7467e35772b2Smrg 746821525869Smrg # Definition is injected by LT_CONFIG during libtool generation. 746921525869Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 747021525869Smrg 7471e35772b2Smrg func_dirname "$output" "/" "" 747221525869Smrg output_objdir=$func_dirname_result$objdir 747374c14cd6Smrg func_to_tool_file "$output_objdir/" 747474c14cd6Smrg tool_output_objdir=$func_to_tool_file_result 7475e35772b2Smrg # Create the object directory. 7476e35772b2Smrg func_mkdir_p "$output_objdir" 7477e35772b2Smrg 7478e35772b2Smrg # Determine the type of output 7479e35772b2Smrg case $output in 7480e35772b2Smrg "") 7481e35772b2Smrg func_fatal_help "you must specify an output file" 7482e35772b2Smrg ;; 7483e35772b2Smrg *.$libext) linkmode=oldlib ;; 7484e35772b2Smrg *.lo | *.$objext) linkmode=obj ;; 7485e35772b2Smrg *.la) linkmode=lib ;; 7486e35772b2Smrg *) linkmode=prog ;; # Anything else should be a program. 7487e35772b2Smrg esac 7488e35772b2Smrg 7489e35772b2Smrg specialdeplibs= 7490e35772b2Smrg 7491e35772b2Smrg libs= 7492e35772b2Smrg # Find all interdependent deplibs by searching for libraries 7493e35772b2Smrg # that are linked more than once (e.g. -la -lb -la) 7494e35772b2Smrg for deplib in $deplibs; do 749521525869Smrg if $opt_preserve_dup_deps; then 7496e35772b2Smrg case "$libs " in 749774c14cd6Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7498e35772b2Smrg esac 7499e35772b2Smrg fi 750074c14cd6Smrg func_append libs " $deplib" 7501e35772b2Smrg done 7502e35772b2Smrg 750321525869Smrg if test lib = "$linkmode"; then 7504e35772b2Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7505e35772b2Smrg 7506e35772b2Smrg # Compute libraries that are listed more than once in $predeps 7507e35772b2Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7508e35772b2Smrg # not to be eliminated). 7509e35772b2Smrg pre_post_deps= 7510e35772b2Smrg if $opt_duplicate_compiler_generated_deps; then 7511e35772b2Smrg for pre_post_dep in $predeps $postdeps; do 7512e35772b2Smrg case "$pre_post_deps " in 751374c14cd6Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7514e35772b2Smrg esac 751574c14cd6Smrg func_append pre_post_deps " $pre_post_dep" 7516e35772b2Smrg done 7517e35772b2Smrg fi 7518e35772b2Smrg pre_post_deps= 7519e35772b2Smrg fi 7520e35772b2Smrg 7521e35772b2Smrg deplibs= 7522e35772b2Smrg newdependency_libs= 7523e35772b2Smrg newlib_search_path= 7524e35772b2Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7525e35772b2Smrg notinst_deplibs= # not-installed libtool libraries 7526e35772b2Smrg notinst_path= # paths that contain not-installed libtool libraries 7527e35772b2Smrg 7528e35772b2Smrg case $linkmode in 7529e35772b2Smrg lib) 7530e35772b2Smrg passes="conv dlpreopen link" 7531e35772b2Smrg for file in $dlfiles $dlprefiles; do 7532e35772b2Smrg case $file in 7533e35772b2Smrg *.la) ;; 7534e35772b2Smrg *) 753521525869Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7536e35772b2Smrg ;; 7537e35772b2Smrg esac 7538e35772b2Smrg done 7539e35772b2Smrg ;; 7540e35772b2Smrg prog) 7541e35772b2Smrg compile_deplibs= 7542e35772b2Smrg finalize_deplibs= 754321525869Smrg alldeplibs=false 7544e35772b2Smrg newdlfiles= 7545e35772b2Smrg newdlprefiles= 7546e35772b2Smrg passes="conv scan dlopen dlpreopen link" 7547e35772b2Smrg ;; 7548e35772b2Smrg *) passes="conv" 7549e35772b2Smrg ;; 7550e35772b2Smrg esac 7551e35772b2Smrg 7552e35772b2Smrg for pass in $passes; do 7553e35772b2Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7554e35772b2Smrg # so that -L comes before libs that need it for instance... 755521525869Smrg if test lib,link = "$linkmode,$pass"; then 7556e35772b2Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7557e35772b2Smrg ## order, and fix it there properly 7558e35772b2Smrg tmp_deplibs= 7559e35772b2Smrg for deplib in $deplibs; do 7560e35772b2Smrg tmp_deplibs="$deplib $tmp_deplibs" 7561e35772b2Smrg done 756221525869Smrg deplibs=$tmp_deplibs 7563e35772b2Smrg fi 7564e35772b2Smrg 756521525869Smrg if test lib,link = "$linkmode,$pass" || 756621525869Smrg test prog,scan = "$linkmode,$pass"; then 756721525869Smrg libs=$deplibs 7568e35772b2Smrg deplibs= 7569e35772b2Smrg fi 757021525869Smrg if test prog = "$linkmode"; then 7571e35772b2Smrg case $pass in 757221525869Smrg dlopen) libs=$dlfiles ;; 757321525869Smrg dlpreopen) libs=$dlprefiles ;; 757474fcc364Smrg link) 757574fcc364Smrg libs="$deplibs %DEPLIBS%" 757674fcc364Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 757774fcc364Smrg ;; 7578e35772b2Smrg esac 7579e35772b2Smrg fi 758021525869Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7581e35772b2Smrg # Collect and forward deplibs of preopened libtool libs 7582e35772b2Smrg for lib in $dlprefiles; do 7583e35772b2Smrg # Ignore non-libtool-libs 7584e35772b2Smrg dependency_libs= 758574c14cd6Smrg func_resolve_sysroot "$lib" 7586e35772b2Smrg case $lib in 758774c14cd6Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7588e35772b2Smrg esac 7589e35772b2Smrg 7590e35772b2Smrg # Collect preopened libtool deplibs, except any this library 7591e35772b2Smrg # has declared as weak libs 7592e35772b2Smrg for deplib in $dependency_libs; do 759374c14cd6Smrg func_basename "$deplib" 759474c14cd6Smrg deplib_base=$func_basename_result 7595e35772b2Smrg case " $weak_libs " in 7596e35772b2Smrg *" $deplib_base "*) ;; 759774c14cd6Smrg *) func_append deplibs " $deplib" ;; 7598e35772b2Smrg esac 7599e35772b2Smrg done 7600e35772b2Smrg done 760121525869Smrg libs=$dlprefiles 7602e35772b2Smrg fi 760321525869Smrg if test dlopen = "$pass"; then 7604e35772b2Smrg # Collect dlpreopened libraries 760521525869Smrg save_deplibs=$deplibs 7606e35772b2Smrg deplibs= 7607e35772b2Smrg fi 7608e35772b2Smrg 7609e35772b2Smrg for deplib in $libs; do 7610e35772b2Smrg lib= 761121525869Smrg found=false 7612e35772b2Smrg case $deplib in 761374c14cd6Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 761474c14cd6Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 761521525869Smrg if test prog,link = "$linkmode,$pass"; then 7616e35772b2Smrg compile_deplibs="$deplib $compile_deplibs" 7617e35772b2Smrg finalize_deplibs="$deplib $finalize_deplibs" 7618e35772b2Smrg else 761974c14cd6Smrg func_append compiler_flags " $deplib" 762021525869Smrg if test lib = "$linkmode"; then 7621e35772b2Smrg case "$new_inherited_linker_flags " in 7622e35772b2Smrg *" $deplib "*) ;; 762374c14cd6Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7624e35772b2Smrg esac 7625e35772b2Smrg fi 7626e35772b2Smrg fi 7627e35772b2Smrg continue 7628e35772b2Smrg ;; 7629e35772b2Smrg -l*) 763021525869Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 763121525869Smrg func_warning "'-l' is ignored for archives/objects" 7632e35772b2Smrg continue 7633e35772b2Smrg fi 7634e35772b2Smrg func_stripname '-l' '' "$deplib" 7635e35772b2Smrg name=$func_stripname_result 763621525869Smrg if test lib = "$linkmode"; then 7637e35772b2Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7638e35772b2Smrg else 7639e35772b2Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7640e35772b2Smrg fi 7641e35772b2Smrg for searchdir in $searchdirs; do 7642e35772b2Smrg for search_ext in .la $std_shrext .so .a; do 7643e35772b2Smrg # Search the libtool library 764421525869Smrg lib=$searchdir/lib$name$search_ext 7645e35772b2Smrg if test -f "$lib"; then 764621525869Smrg if test .la = "$search_ext"; then 764721525869Smrg found=: 7648e35772b2Smrg else 764921525869Smrg found=false 7650e35772b2Smrg fi 7651e35772b2Smrg break 2 7652e35772b2Smrg fi 7653e35772b2Smrg done 7654e35772b2Smrg done 765521525869Smrg if $found; then 765621525869Smrg # deplib is a libtool library 7657e35772b2Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7658e35772b2Smrg # We need to do some special things here, and not later. 765921525869Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7660e35772b2Smrg case " $predeps $postdeps " in 7661e35772b2Smrg *" $deplib "*) 7662e35772b2Smrg if func_lalib_p "$lib"; then 7663e35772b2Smrg library_names= 7664e35772b2Smrg old_library= 7665e35772b2Smrg func_source "$lib" 7666e35772b2Smrg for l in $old_library $library_names; do 766721525869Smrg ll=$l 7668e35772b2Smrg done 766921525869Smrg if test "X$ll" = "X$old_library"; then # only static version available 767021525869Smrg found=false 7671e35772b2Smrg func_dirname "$lib" "" "." 767221525869Smrg ladir=$func_dirname_result 7673e35772b2Smrg lib=$ladir/$old_library 767421525869Smrg if test prog,link = "$linkmode,$pass"; then 7675e35772b2Smrg compile_deplibs="$deplib $compile_deplibs" 7676e35772b2Smrg finalize_deplibs="$deplib $finalize_deplibs" 7677e35772b2Smrg else 7678e35772b2Smrg deplibs="$deplib $deplibs" 767921525869Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7680e35772b2Smrg fi 7681e35772b2Smrg continue 7682e35772b2Smrg fi 7683e35772b2Smrg fi 7684e35772b2Smrg ;; 7685e35772b2Smrg *) ;; 7686e35772b2Smrg esac 7687e35772b2Smrg fi 768821525869Smrg else 768921525869Smrg # deplib doesn't seem to be a libtool library 769021525869Smrg if test prog,link = "$linkmode,$pass"; then 769121525869Smrg compile_deplibs="$deplib $compile_deplibs" 769221525869Smrg finalize_deplibs="$deplib $finalize_deplibs" 769321525869Smrg else 769421525869Smrg deplibs="$deplib $deplibs" 769521525869Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769621525869Smrg fi 769721525869Smrg continue 7698e35772b2Smrg fi 7699e35772b2Smrg ;; # -l 7700e35772b2Smrg *.ltframework) 770121525869Smrg if test prog,link = "$linkmode,$pass"; then 7702e35772b2Smrg compile_deplibs="$deplib $compile_deplibs" 7703e35772b2Smrg finalize_deplibs="$deplib $finalize_deplibs" 7704e35772b2Smrg else 7705e35772b2Smrg deplibs="$deplib $deplibs" 770621525869Smrg if test lib = "$linkmode"; then 7707e35772b2Smrg case "$new_inherited_linker_flags " in 7708e35772b2Smrg *" $deplib "*) ;; 770974c14cd6Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7710e35772b2Smrg esac 7711e35772b2Smrg fi 7712e35772b2Smrg fi 7713e35772b2Smrg continue 7714e35772b2Smrg ;; 7715e35772b2Smrg -L*) 7716e35772b2Smrg case $linkmode in 7717e35772b2Smrg lib) 7718e35772b2Smrg deplibs="$deplib $deplibs" 771921525869Smrg test conv = "$pass" && continue 7720e35772b2Smrg newdependency_libs="$deplib $newdependency_libs" 7721e35772b2Smrg func_stripname '-L' '' "$deplib" 772274c14cd6Smrg func_resolve_sysroot "$func_stripname_result" 772374c14cd6Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7724e35772b2Smrg ;; 7725e35772b2Smrg prog) 772621525869Smrg if test conv = "$pass"; then 7727e35772b2Smrg deplibs="$deplib $deplibs" 7728e35772b2Smrg continue 7729e35772b2Smrg fi 773021525869Smrg if test scan = "$pass"; then 7731e35772b2Smrg deplibs="$deplib $deplibs" 7732e35772b2Smrg else 7733e35772b2Smrg compile_deplibs="$deplib $compile_deplibs" 7734e35772b2Smrg finalize_deplibs="$deplib $finalize_deplibs" 7735e35772b2Smrg fi 7736e35772b2Smrg func_stripname '-L' '' "$deplib" 773774c14cd6Smrg func_resolve_sysroot "$func_stripname_result" 773874c14cd6Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7739e35772b2Smrg ;; 7740e35772b2Smrg *) 774121525869Smrg func_warning "'-L' is ignored for archives/objects" 7742e35772b2Smrg ;; 7743e35772b2Smrg esac # linkmode 7744e35772b2Smrg continue 7745e35772b2Smrg ;; # -L 7746e35772b2Smrg -R*) 774721525869Smrg if test link = "$pass"; then 7748e35772b2Smrg func_stripname '-R' '' "$deplib" 774974c14cd6Smrg func_resolve_sysroot "$func_stripname_result" 775074c14cd6Smrg dir=$func_resolve_sysroot_result 7751e35772b2Smrg # Make sure the xrpath contains only unique directories. 7752e35772b2Smrg case "$xrpath " in 7753e35772b2Smrg *" $dir "*) ;; 775474c14cd6Smrg *) func_append xrpath " $dir" ;; 7755e35772b2Smrg esac 7756e35772b2Smrg fi 7757e35772b2Smrg deplibs="$deplib $deplibs" 7758e35772b2Smrg continue 7759e35772b2Smrg ;; 776074c14cd6Smrg *.la) 776174c14cd6Smrg func_resolve_sysroot "$deplib" 776274c14cd6Smrg lib=$func_resolve_sysroot_result 776374c14cd6Smrg ;; 7764e35772b2Smrg *.$libext) 776521525869Smrg if test conv = "$pass"; then 7766e35772b2Smrg deplibs="$deplib $deplibs" 7767e35772b2Smrg continue 7768e35772b2Smrg fi 7769e35772b2Smrg case $linkmode in 7770e35772b2Smrg lib) 7771e35772b2Smrg # Linking convenience modules into shared libraries is allowed, 7772e35772b2Smrg # but linking other static libraries is non-portable. 7773e35772b2Smrg case " $dlpreconveniencelibs " in 7774e35772b2Smrg *" $deplib "*) ;; 7775e35772b2Smrg *) 777621525869Smrg valid_a_lib=false 7777e35772b2Smrg case $deplibs_check_method in 7778e35772b2Smrg match_pattern*) 7779e35772b2Smrg set dummy $deplibs_check_method; shift 7780e35772b2Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 778174c14cd6Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7782e35772b2Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 778321525869Smrg valid_a_lib=: 7784e35772b2Smrg fi 7785e35772b2Smrg ;; 7786e35772b2Smrg pass_all) 778721525869Smrg valid_a_lib=: 7788e35772b2Smrg ;; 7789e35772b2Smrg esac 779021525869Smrg if $valid_a_lib; then 779121525869Smrg echo 779221525869Smrg $ECHO "*** Warning: Linking the shared library $output against the" 779321525869Smrg $ECHO "*** static library $deplib is not portable!" 779421525869Smrg deplibs="$deplib $deplibs" 779521525869Smrg else 779674c14cd6Smrg echo 7797e35772b2Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779874c14cd6Smrg echo "*** I have the capability to make that library automatically link in when" 779974c14cd6Smrg echo "*** you link to this library. But I can only do this if you have a" 780074c14cd6Smrg echo "*** shared version of the library, which you do not appear to have" 780174c14cd6Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 780274c14cd6Smrg echo "*** that it is just a static archive that I should not use here." 7803e35772b2Smrg fi 7804e35772b2Smrg ;; 7805e35772b2Smrg esac 7806e35772b2Smrg continue 7807e35772b2Smrg ;; 7808e35772b2Smrg prog) 780921525869Smrg if test link != "$pass"; then 7810e35772b2Smrg deplibs="$deplib $deplibs" 7811e35772b2Smrg else 7812e35772b2Smrg compile_deplibs="$deplib $compile_deplibs" 7813e35772b2Smrg finalize_deplibs="$deplib $finalize_deplibs" 7814e35772b2Smrg fi 7815e35772b2Smrg continue 7816e35772b2Smrg ;; 7817e35772b2Smrg esac # linkmode 7818e35772b2Smrg ;; # *.$libext 7819e35772b2Smrg *.lo | *.$objext) 782021525869Smrg if test conv = "$pass"; then 7821e35772b2Smrg deplibs="$deplib $deplibs" 782221525869Smrg elif test prog = "$linkmode"; then 782321525869Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7824e35772b2Smrg # If there is no dlopen support or we're linking statically, 7825e35772b2Smrg # we need to preload. 782674c14cd6Smrg func_append newdlprefiles " $deplib" 7827e35772b2Smrg compile_deplibs="$deplib $compile_deplibs" 7828e35772b2Smrg finalize_deplibs="$deplib $finalize_deplibs" 7829e35772b2Smrg else 783074c14cd6Smrg func_append newdlfiles " $deplib" 7831e35772b2Smrg fi 7832e35772b2Smrg fi 7833e35772b2Smrg continue 7834e35772b2Smrg ;; 7835e35772b2Smrg %DEPLIBS%) 783621525869Smrg alldeplibs=: 7837e35772b2Smrg continue 7838e35772b2Smrg ;; 7839e35772b2Smrg esac # case $deplib 7840e35772b2Smrg 784121525869Smrg $found || test -f "$lib" \ 784221525869Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7843e35772b2Smrg 7844e35772b2Smrg # Check to see that this really is a libtool archive. 7845e35772b2Smrg func_lalib_unsafe_p "$lib" \ 784621525869Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 7847e35772b2Smrg 7848e35772b2Smrg func_dirname "$lib" "" "." 784921525869Smrg ladir=$func_dirname_result 7850e35772b2Smrg 7851e35772b2Smrg dlname= 7852e35772b2Smrg dlopen= 7853e35772b2Smrg dlpreopen= 7854e35772b2Smrg libdir= 7855e35772b2Smrg library_names= 7856e35772b2Smrg old_library= 7857e35772b2Smrg inherited_linker_flags= 7858e35772b2Smrg # If the library was installed with an old release of libtool, 7859e35772b2Smrg # it will not redefine variables installed, or shouldnotlink 7860e35772b2Smrg installed=yes 7861e35772b2Smrg shouldnotlink=no 7862e35772b2Smrg avoidtemprpath= 7863e35772b2Smrg 7864e35772b2Smrg 7865e35772b2Smrg # Read the .la file 7866e35772b2Smrg func_source "$lib" 7867e35772b2Smrg 7868e35772b2Smrg # Convert "-framework foo" to "foo.ltframework" 7869e35772b2Smrg if test -n "$inherited_linker_flags"; then 787074c14cd6Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7871e35772b2Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7872e35772b2Smrg case " $new_inherited_linker_flags " in 7873e35772b2Smrg *" $tmp_inherited_linker_flag "*) ;; 787474c14cd6Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7875e35772b2Smrg esac 7876e35772b2Smrg done 7877e35772b2Smrg fi 787874c14cd6Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787921525869Smrg if test lib,link = "$linkmode,$pass" || 788021525869Smrg test prog,scan = "$linkmode,$pass" || 788121525869Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 788274c14cd6Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 788374c14cd6Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7884e35772b2Smrg fi 7885e35772b2Smrg 788621525869Smrg if test conv = "$pass"; then 7887e35772b2Smrg # Only check for convenience libraries 7888e35772b2Smrg deplibs="$lib $deplibs" 7889e35772b2Smrg if test -z "$libdir"; then 7890e35772b2Smrg if test -z "$old_library"; then 789121525869Smrg func_fatal_error "cannot find name of link library for '$lib'" 7892e35772b2Smrg fi 7893e35772b2Smrg # It is a libtool convenience library, so add in its objects. 789474c14cd6Smrg func_append convenience " $ladir/$objdir/$old_library" 789574c14cd6Smrg func_append old_convenience " $ladir/$objdir/$old_library" 789674fcc364Smrg tmp_libs= 789774fcc364Smrg for deplib in $dependency_libs; do 789874fcc364Smrg deplibs="$deplib $deplibs" 789974fcc364Smrg if $opt_preserve_dup_deps; then 790074fcc364Smrg case "$tmp_libs " in 790174fcc364Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 790274fcc364Smrg esac 790374fcc364Smrg fi 790474fcc364Smrg func_append tmp_libs " $deplib" 790574fcc364Smrg done 790621525869Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 790721525869Smrg func_fatal_error "'$lib' is not a convenience library" 7908e35772b2Smrg fi 7909e35772b2Smrg continue 7910e35772b2Smrg fi # $pass = conv 7911e35772b2Smrg 7912e35772b2Smrg 7913e35772b2Smrg # Get the name of the library we link against. 7914e35772b2Smrg linklib= 791574c14cd6Smrg if test -n "$old_library" && 791621525869Smrg { test yes = "$prefer_static_libs" || 791721525869Smrg test built,no = "$prefer_static_libs,$installed"; }; then 791874c14cd6Smrg linklib=$old_library 791974c14cd6Smrg else 792074c14cd6Smrg for l in $old_library $library_names; do 792121525869Smrg linklib=$l 792274c14cd6Smrg done 792374c14cd6Smrg fi 7924e35772b2Smrg if test -z "$linklib"; then 792521525869Smrg func_fatal_error "cannot find name of link library for '$lib'" 7926e35772b2Smrg fi 7927e35772b2Smrg 7928e35772b2Smrg # This library was specified with -dlopen. 792921525869Smrg if test dlopen = "$pass"; then 793021525869Smrg test -z "$libdir" \ 793121525869Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7932e35772b2Smrg if test -z "$dlname" || 793321525869Smrg test yes != "$dlopen_support" || 793421525869Smrg test no = "$build_libtool_libs" 793521525869Smrg then 7936e35772b2Smrg # If there is no dlname, no dlopen support or we're linking 7937e35772b2Smrg # statically, we need to preload. We also need to preload any 7938e35772b2Smrg # dependent libraries so libltdl's deplib preloader doesn't 7939e35772b2Smrg # bomb out in the load deplibs phase. 794074c14cd6Smrg func_append dlprefiles " $lib $dependency_libs" 7941e35772b2Smrg else 794274c14cd6Smrg func_append newdlfiles " $lib" 7943e35772b2Smrg fi 7944e35772b2Smrg continue 7945e35772b2Smrg fi # $pass = dlopen 7946e35772b2Smrg 7947e35772b2Smrg # We need an absolute path. 7948e35772b2Smrg case $ladir in 794921525869Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7950e35772b2Smrg *) 7951e35772b2Smrg abs_ladir=`cd "$ladir" && pwd` 7952e35772b2Smrg if test -z "$abs_ladir"; then 795321525869Smrg func_warning "cannot determine absolute directory name of '$ladir'" 7954e35772b2Smrg func_warning "passing it literally to the linker, although it might fail" 795521525869Smrg abs_ladir=$ladir 7956e35772b2Smrg fi 7957e35772b2Smrg ;; 7958e35772b2Smrg esac 7959e35772b2Smrg func_basename "$lib" 796021525869Smrg laname=$func_basename_result 7961e35772b2Smrg 7962e35772b2Smrg # Find the relevant object directory and library name. 796321525869Smrg if test yes = "$installed"; then 796474c14cd6Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 796521525869Smrg func_warning "library '$lib' was moved." 796621525869Smrg dir=$ladir 796721525869Smrg absdir=$abs_ladir 796821525869Smrg libdir=$abs_ladir 7969e35772b2Smrg else 797021525869Smrg dir=$lt_sysroot$libdir 797121525869Smrg absdir=$lt_sysroot$libdir 7972e35772b2Smrg fi 797321525869Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7974e35772b2Smrg else 7975e35772b2Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797621525869Smrg dir=$ladir 797721525869Smrg absdir=$abs_ladir 7978e35772b2Smrg # Remove this search path later 797974c14cd6Smrg func_append notinst_path " $abs_ladir" 7980e35772b2Smrg else 798121525869Smrg dir=$ladir/$objdir 798221525869Smrg absdir=$abs_ladir/$objdir 7983e35772b2Smrg # Remove this search path later 798474c14cd6Smrg func_append notinst_path " $abs_ladir" 7985e35772b2Smrg fi 7986e35772b2Smrg fi # $installed = yes 7987e35772b2Smrg func_stripname 'lib' '.la' "$laname" 7988e35772b2Smrg name=$func_stripname_result 7989e35772b2Smrg 7990e35772b2Smrg # This library was specified with -dlpreopen. 799121525869Smrg if test dlpreopen = "$pass"; then 799221525869Smrg if test -z "$libdir" && test prog = "$linkmode"; then 799321525869Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7994e35772b2Smrg fi 799521525869Smrg case $host in 799674c14cd6Smrg # special handling for platforms with PE-DLLs. 799774c14cd6Smrg *cygwin* | *mingw* | *cegcc* ) 799874c14cd6Smrg # Linker will automatically link against shared library if both 799974c14cd6Smrg # static and shared are present. Therefore, ensure we extract 800074c14cd6Smrg # symbols from the import library if a shared library is present 800174c14cd6Smrg # (otherwise, the dlopen module name will be incorrect). We do 800274c14cd6Smrg # this by putting the import library name into $newdlprefiles. 800374c14cd6Smrg # We recover the dlopen module name by 'saving' the la file 800474c14cd6Smrg # name in a special purpose variable, and (later) extracting the 800574c14cd6Smrg # dlname from the la file. 800674c14cd6Smrg if test -n "$dlname"; then 800774c14cd6Smrg func_tr_sh "$dir/$linklib" 800874c14cd6Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 800974c14cd6Smrg func_append newdlprefiles " $dir/$linklib" 801074c14cd6Smrg else 801174c14cd6Smrg func_append newdlprefiles " $dir/$old_library" 801274c14cd6Smrg # Keep a list of preopened convenience libraries to check 801374c14cd6Smrg # that they are being used correctly in the link pass. 801474c14cd6Smrg test -z "$libdir" && \ 801574c14cd6Smrg func_append dlpreconveniencelibs " $dir/$old_library" 801674c14cd6Smrg fi 801774c14cd6Smrg ;; 801874c14cd6Smrg * ) 801974c14cd6Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 802074c14cd6Smrg # are required to link). 802174c14cd6Smrg if test -n "$old_library"; then 802274c14cd6Smrg func_append newdlprefiles " $dir/$old_library" 802374c14cd6Smrg # Keep a list of preopened convenience libraries to check 802474c14cd6Smrg # that they are being used correctly in the link pass. 802574c14cd6Smrg test -z "$libdir" && \ 802674c14cd6Smrg func_append dlpreconveniencelibs " $dir/$old_library" 802774c14cd6Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 802874c14cd6Smrg elif test -n "$dlname"; then 802974c14cd6Smrg func_append newdlprefiles " $dir/$dlname" 803074c14cd6Smrg else 803174c14cd6Smrg func_append newdlprefiles " $dir/$linklib" 803274c14cd6Smrg fi 803374c14cd6Smrg ;; 803474c14cd6Smrg esac 8035e35772b2Smrg fi # $pass = dlpreopen 8036e35772b2Smrg 8037e35772b2Smrg if test -z "$libdir"; then 8038e35772b2Smrg # Link the convenience library 803921525869Smrg if test lib = "$linkmode"; then 8040e35772b2Smrg deplibs="$dir/$old_library $deplibs" 804121525869Smrg elif test prog,link = "$linkmode,$pass"; then 8042e35772b2Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8043e35772b2Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8044e35772b2Smrg else 8045e35772b2Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8046e35772b2Smrg fi 8047e35772b2Smrg continue 8048e35772b2Smrg fi 8049e35772b2Smrg 8050e35772b2Smrg 805121525869Smrg if test prog = "$linkmode" && test link != "$pass"; then 805274c14cd6Smrg func_append newlib_search_path " $ladir" 8053e35772b2Smrg deplibs="$lib $deplibs" 8054e35772b2Smrg 805521525869Smrg linkalldeplibs=false 805621525869Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805721525869Smrg test no = "$build_libtool_libs"; then 805821525869Smrg linkalldeplibs=: 8059e35772b2Smrg fi 8060e35772b2Smrg 8061e35772b2Smrg tmp_libs= 8062e35772b2Smrg for deplib in $dependency_libs; do 8063e35772b2Smrg case $deplib in 8064e35772b2Smrg -L*) func_stripname '-L' '' "$deplib" 806574c14cd6Smrg func_resolve_sysroot "$func_stripname_result" 806674c14cd6Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8067e35772b2Smrg ;; 8068e35772b2Smrg esac 8069e35772b2Smrg # Need to link against all dependency_libs? 807021525869Smrg if $linkalldeplibs; then 8071e35772b2Smrg deplibs="$deplib $deplibs" 8072e35772b2Smrg else 8073e35772b2Smrg # Need to hardcode shared library paths 8074e35772b2Smrg # or/and link against static libraries 8075e35772b2Smrg newdependency_libs="$deplib $newdependency_libs" 8076e35772b2Smrg fi 807721525869Smrg if $opt_preserve_dup_deps; then 8078e35772b2Smrg case "$tmp_libs " in 807974c14cd6Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8080e35772b2Smrg esac 8081e35772b2Smrg fi 808274c14cd6Smrg func_append tmp_libs " $deplib" 8083e35772b2Smrg done # for deplib 8084e35772b2Smrg continue 8085e35772b2Smrg fi # $linkmode = prog... 8086e35772b2Smrg 808721525869Smrg if test prog,link = "$linkmode,$pass"; then 8088e35772b2Smrg if test -n "$library_names" && 808921525869Smrg { { test no = "$prefer_static_libs" || 809021525869Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8091e35772b2Smrg test -z "$old_library"; }; then 8092e35772b2Smrg # We need to hardcode the library path 809321525869Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8094e35772b2Smrg # Make sure the rpath contains only unique directories. 809521525869Smrg case $temp_rpath: in 8096e35772b2Smrg *"$absdir:"*) ;; 809774c14cd6Smrg *) func_append temp_rpath "$absdir:" ;; 8098e35772b2Smrg esac 8099e35772b2Smrg fi 8100e35772b2Smrg 8101e35772b2Smrg # Hardcode the library path. 8102e35772b2Smrg # Skip directories that are in the system default run-time 8103e35772b2Smrg # search path. 8104e35772b2Smrg case " $sys_lib_dlsearch_path " in 8105e35772b2Smrg *" $absdir "*) ;; 8106e35772b2Smrg *) 8107e35772b2Smrg case "$compile_rpath " in 8108e35772b2Smrg *" $absdir "*) ;; 810974c14cd6Smrg *) func_append compile_rpath " $absdir" ;; 8110e35772b2Smrg esac 8111e35772b2Smrg ;; 8112e35772b2Smrg esac 8113e35772b2Smrg case " $sys_lib_dlsearch_path " in 8114e35772b2Smrg *" $libdir "*) ;; 8115e35772b2Smrg *) 8116e35772b2Smrg case "$finalize_rpath " in 8117e35772b2Smrg *" $libdir "*) ;; 811874c14cd6Smrg *) func_append finalize_rpath " $libdir" ;; 8119e35772b2Smrg esac 8120e35772b2Smrg ;; 8121e35772b2Smrg esac 8122e35772b2Smrg fi # $linkmode,$pass = prog,link... 8123e35772b2Smrg 812421525869Smrg if $alldeplibs && 812521525869Smrg { test pass_all = "$deplibs_check_method" || 812621525869Smrg { test yes = "$build_libtool_libs" && 8127e35772b2Smrg test -n "$library_names"; }; }; then 8128e35772b2Smrg # We only need to search for static libraries 8129e35772b2Smrg continue 8130e35772b2Smrg fi 8131e35772b2Smrg fi 8132e35772b2Smrg 8133e35772b2Smrg link_static=no # Whether the deplib will be linked statically 8134e35772b2Smrg use_static_libs=$prefer_static_libs 813521525869Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8136e35772b2Smrg use_static_libs=no 8137e35772b2Smrg fi 8138e35772b2Smrg if test -n "$library_names" && 813921525869Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8140e35772b2Smrg case $host in 814121525869Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8142e35772b2Smrg # No point in relinking DLLs because paths are not encoded 814374c14cd6Smrg func_append notinst_deplibs " $lib" 8144e35772b2Smrg need_relink=no 8145e35772b2Smrg ;; 8146e35772b2Smrg *) 814721525869Smrg if test no = "$installed"; then 814874c14cd6Smrg func_append notinst_deplibs " $lib" 8149e35772b2Smrg need_relink=yes 8150e35772b2Smrg fi 8151e35772b2Smrg ;; 8152e35772b2Smrg esac 8153e35772b2Smrg # This is a shared library 8154e35772b2Smrg 8155e35772b2Smrg # Warn about portability, can't link against -module's on some 8156e35772b2Smrg # systems (darwin). Don't bleat about dlopened modules though! 815721525869Smrg dlopenmodule= 8158e35772b2Smrg for dlpremoduletest in $dlprefiles; do 8159e35772b2Smrg if test "X$dlpremoduletest" = "X$lib"; then 816021525869Smrg dlopenmodule=$dlpremoduletest 8161e35772b2Smrg break 8162e35772b2Smrg fi 8163e35772b2Smrg done 816421525869Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 816574c14cd6Smrg echo 816621525869Smrg if test prog = "$linkmode"; then 8167e35772b2Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8168e35772b2Smrg else 8169e35772b2Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8170e35772b2Smrg fi 8171e35772b2Smrg $ECHO "*** $linklib is not portable!" 8172e35772b2Smrg fi 817321525869Smrg if test lib = "$linkmode" && 817421525869Smrg test yes = "$hardcode_into_libs"; then 8175e35772b2Smrg # Hardcode the library path. 8176e35772b2Smrg # Skip directories that are in the system default run-time 8177e35772b2Smrg # search path. 8178e35772b2Smrg case " $sys_lib_dlsearch_path " in 8179e35772b2Smrg *" $absdir "*) ;; 8180e35772b2Smrg *) 8181e35772b2Smrg case "$compile_rpath " in 8182e35772b2Smrg *" $absdir "*) ;; 818374c14cd6Smrg *) func_append compile_rpath " $absdir" ;; 8184e35772b2Smrg esac 8185e35772b2Smrg ;; 8186e35772b2Smrg esac 8187e35772b2Smrg case " $sys_lib_dlsearch_path " in 8188e35772b2Smrg *" $libdir "*) ;; 8189e35772b2Smrg *) 8190e35772b2Smrg case "$finalize_rpath " in 8191e35772b2Smrg *" $libdir "*) ;; 819274c14cd6Smrg *) func_append finalize_rpath " $libdir" ;; 8193e35772b2Smrg esac 8194e35772b2Smrg ;; 8195e35772b2Smrg esac 8196e35772b2Smrg fi 8197e35772b2Smrg 8198e35772b2Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8199e35772b2Smrg # figure out the soname 8200e35772b2Smrg set dummy $library_names 8201e35772b2Smrg shift 820221525869Smrg realname=$1 8203e35772b2Smrg shift 8204e35772b2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8205e35772b2Smrg # use dlname if we got it. it's perfectly good, no? 8206e35772b2Smrg if test -n "$dlname"; then 820721525869Smrg soname=$dlname 8208e35772b2Smrg elif test -n "$soname_spec"; then 8209e35772b2Smrg # bleh windows 8210e35772b2Smrg case $host in 821121525869Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8212e35772b2Smrg func_arith $current - $age 8213e35772b2Smrg major=$func_arith_result 821421525869Smrg versuffix=-$major 8215e35772b2Smrg ;; 8216e35772b2Smrg esac 8217e35772b2Smrg eval soname=\"$soname_spec\" 8218e35772b2Smrg else 821921525869Smrg soname=$realname 8220e35772b2Smrg fi 8221e35772b2Smrg 8222e35772b2Smrg # Make a new name for the extract_expsyms_cmds to use 822321525869Smrg soroot=$soname 8224e35772b2Smrg func_basename "$soroot" 822521525869Smrg soname=$func_basename_result 8226e35772b2Smrg func_stripname 'lib' '.dll' "$soname" 8227e35772b2Smrg newlib=libimp-$func_stripname_result.a 8228e35772b2Smrg 8229e35772b2Smrg # If the library has no export list, then create one now 8230e35772b2Smrg if test -f "$output_objdir/$soname-def"; then : 8231e35772b2Smrg else 823221525869Smrg func_verbose "extracting exported symbol list from '$soname'" 8233e35772b2Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8234e35772b2Smrg fi 8235e35772b2Smrg 8236e35772b2Smrg # Create $newlib 8237e35772b2Smrg if test -f "$output_objdir/$newlib"; then :; else 823821525869Smrg func_verbose "generating import library for '$soname'" 8239e35772b2Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8240e35772b2Smrg fi 8241e35772b2Smrg # make sure the library variables are pointing to the new library 8242e35772b2Smrg dir=$output_objdir 8243e35772b2Smrg linklib=$newlib 8244e35772b2Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8245e35772b2Smrg 824621525869Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8247e35772b2Smrg add_shlibpath= 8248e35772b2Smrg add_dir= 8249e35772b2Smrg add= 8250e35772b2Smrg lib_linked=yes 8251e35772b2Smrg case $hardcode_action in 8252e35772b2Smrg immediate | unsupported) 825321525869Smrg if test no = "$hardcode_direct"; then 825421525869Smrg add=$dir/$linklib 8255e35772b2Smrg case $host in 825621525869Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825721525869Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8258e35772b2Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825921525869Smrg *-*-unixware7*) add_dir=-L$dir ;; 8260e35772b2Smrg *-*-darwin* ) 826121525869Smrg # if the lib is a (non-dlopened) module then we cannot 8262e35772b2Smrg # link against it, someone is ignoring the earlier warnings 8263e35772b2Smrg if /usr/bin/file -L $add 2> /dev/null | 826421525869Smrg $GREP ": [^:]* bundle" >/dev/null; then 8265e35772b2Smrg if test "X$dlopenmodule" != "X$lib"; then 8266e35772b2Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826721525869Smrg if test -z "$old_library"; then 826874c14cd6Smrg echo 826974c14cd6Smrg echo "*** And there doesn't seem to be a static archive available" 827074c14cd6Smrg echo "*** The link will probably fail, sorry" 8271e35772b2Smrg else 827221525869Smrg add=$dir/$old_library 8273e35772b2Smrg fi 8274e35772b2Smrg elif test -n "$old_library"; then 827521525869Smrg add=$dir/$old_library 8276e35772b2Smrg fi 8277e35772b2Smrg fi 8278e35772b2Smrg esac 827921525869Smrg elif test no = "$hardcode_minus_L"; then 8280e35772b2Smrg case $host in 828121525869Smrg *-*-sunos*) add_shlibpath=$dir ;; 8282e35772b2Smrg esac 828321525869Smrg add_dir=-L$dir 828421525869Smrg add=-l$name 828521525869Smrg elif test no = "$hardcode_shlibpath_var"; then 828621525869Smrg add_shlibpath=$dir 828721525869Smrg add=-l$name 8288e35772b2Smrg else 8289e35772b2Smrg lib_linked=no 8290e35772b2Smrg fi 8291e35772b2Smrg ;; 8292e35772b2Smrg relink) 829321525869Smrg if test yes = "$hardcode_direct" && 829421525869Smrg test no = "$hardcode_direct_absolute"; then 829521525869Smrg add=$dir/$linklib 829621525869Smrg elif test yes = "$hardcode_minus_L"; then 829721525869Smrg add_dir=-L$absdir 8298e35772b2Smrg # Try looking first in the location we're being installed to. 8299e35772b2Smrg if test -n "$inst_prefix_dir"; then 8300e35772b2Smrg case $libdir in 8301e35772b2Smrg [\\/]*) 830274c14cd6Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8303e35772b2Smrg ;; 8304e35772b2Smrg esac 8305e35772b2Smrg fi 830621525869Smrg add=-l$name 830721525869Smrg elif test yes = "$hardcode_shlibpath_var"; then 830821525869Smrg add_shlibpath=$dir 830921525869Smrg add=-l$name 8310e35772b2Smrg else 8311e35772b2Smrg lib_linked=no 8312e35772b2Smrg fi 8313e35772b2Smrg ;; 8314e35772b2Smrg *) lib_linked=no ;; 8315e35772b2Smrg esac 8316e35772b2Smrg 831721525869Smrg if test yes != "$lib_linked"; then 8318e35772b2Smrg func_fatal_configuration "unsupported hardcode properties" 8319e35772b2Smrg fi 8320e35772b2Smrg 8321e35772b2Smrg if test -n "$add_shlibpath"; then 8322e35772b2Smrg case :$compile_shlibpath: in 8323e35772b2Smrg *":$add_shlibpath:"*) ;; 832474c14cd6Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8325e35772b2Smrg esac 8326e35772b2Smrg fi 832721525869Smrg if test prog = "$linkmode"; then 8328e35772b2Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8329e35772b2Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8330e35772b2Smrg else 8331e35772b2Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8332e35772b2Smrg test -n "$add" && deplibs="$add $deplibs" 833321525869Smrg if test yes != "$hardcode_direct" && 833421525869Smrg test yes != "$hardcode_minus_L" && 833521525869Smrg test yes = "$hardcode_shlibpath_var"; then 8336e35772b2Smrg case :$finalize_shlibpath: in 8337e35772b2Smrg *":$libdir:"*) ;; 833874c14cd6Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8339e35772b2Smrg esac 8340e35772b2Smrg fi 8341e35772b2Smrg fi 8342e35772b2Smrg fi 8343e35772b2Smrg 834421525869Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8345e35772b2Smrg add_shlibpath= 8346e35772b2Smrg add_dir= 8347e35772b2Smrg add= 8348e35772b2Smrg # Finalize command for both is simple: just hardcode it. 834921525869Smrg if test yes = "$hardcode_direct" && 835021525869Smrg test no = "$hardcode_direct_absolute"; then 835121525869Smrg add=$libdir/$linklib 835221525869Smrg elif test yes = "$hardcode_minus_L"; then 835321525869Smrg add_dir=-L$libdir 835421525869Smrg add=-l$name 835521525869Smrg elif test yes = "$hardcode_shlibpath_var"; then 8356e35772b2Smrg case :$finalize_shlibpath: in 8357e35772b2Smrg *":$libdir:"*) ;; 835874c14cd6Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8359e35772b2Smrg esac 836021525869Smrg add=-l$name 836121525869Smrg elif test yes = "$hardcode_automatic"; then 8362e35772b2Smrg if test -n "$inst_prefix_dir" && 836321525869Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 836421525869Smrg add=$inst_prefix_dir$libdir/$linklib 8365e35772b2Smrg else 836621525869Smrg add=$libdir/$linklib 8367e35772b2Smrg fi 8368e35772b2Smrg else 8369e35772b2Smrg # We cannot seem to hardcode it, guess we'll fake it. 837021525869Smrg add_dir=-L$libdir 8371e35772b2Smrg # Try looking first in the location we're being installed to. 8372e35772b2Smrg if test -n "$inst_prefix_dir"; then 8373e35772b2Smrg case $libdir in 8374e35772b2Smrg [\\/]*) 837574c14cd6Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8376e35772b2Smrg ;; 8377e35772b2Smrg esac 8378e35772b2Smrg fi 837921525869Smrg add=-l$name 8380e35772b2Smrg fi 8381e35772b2Smrg 838221525869Smrg if test prog = "$linkmode"; then 8383e35772b2Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8384e35772b2Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8385e35772b2Smrg else 8386e35772b2Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8387e35772b2Smrg test -n "$add" && deplibs="$add $deplibs" 8388e35772b2Smrg fi 8389e35772b2Smrg fi 839021525869Smrg elif test prog = "$linkmode"; then 8391e35772b2Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8392e35772b2Smrg # is not unsupported. This is valid on all known static and 8393e35772b2Smrg # shared platforms. 839421525869Smrg if test unsupported != "$hardcode_direct"; then 839521525869Smrg test -n "$old_library" && linklib=$old_library 8396e35772b2Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8397e35772b2Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8398e35772b2Smrg else 8399e35772b2Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8400e35772b2Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8401e35772b2Smrg fi 840221525869Smrg elif test yes = "$build_libtool_libs"; then 8403e35772b2Smrg # Not a shared library 840421525869Smrg if test pass_all != "$deplibs_check_method"; then 8405e35772b2Smrg # We're trying link a shared library against a static one 8406e35772b2Smrg # but the system doesn't support it. 8407e35772b2Smrg 8408e35772b2Smrg # Just print a warning and add the library to dependency_libs so 8409e35772b2Smrg # that the program can be linked against the static library. 841074c14cd6Smrg echo 841121525869Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 841274c14cd6Smrg echo "*** I have the capability to make that library automatically link in when" 841374c14cd6Smrg echo "*** you link to this library. But I can only do this if you have a" 841474c14cd6Smrg echo "*** shared version of the library, which you do not appear to have." 841521525869Smrg if test yes = "$module"; then 841674c14cd6Smrg echo "*** But as you try to build a module library, libtool will still create " 841774c14cd6Smrg echo "*** a static module, that should work as long as the dlopening application" 841874c14cd6Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8419e35772b2Smrg if test -z "$global_symbol_pipe"; then 842074c14cd6Smrg echo 842174c14cd6Smrg echo "*** However, this would only work if libtool was able to extract symbol" 842221525869Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 842374c14cd6Smrg echo "*** not find such a program. So, this module is probably useless." 842421525869Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8425e35772b2Smrg fi 842621525869Smrg if test no = "$build_old_libs"; then 8427e35772b2Smrg build_libtool_libs=module 8428e35772b2Smrg build_old_libs=yes 8429e35772b2Smrg else 8430e35772b2Smrg build_libtool_libs=no 8431e35772b2Smrg fi 8432e35772b2Smrg fi 8433e35772b2Smrg else 8434e35772b2Smrg deplibs="$dir/$old_library $deplibs" 8435e35772b2Smrg link_static=yes 8436e35772b2Smrg fi 8437e35772b2Smrg fi # link shared/static library? 8438e35772b2Smrg 843921525869Smrg if test lib = "$linkmode"; then 8440e35772b2Smrg if test -n "$dependency_libs" && 844121525869Smrg { test yes != "$hardcode_into_libs" || 844221525869Smrg test yes = "$build_old_libs" || 844321525869Smrg test yes = "$link_static"; }; then 8444e35772b2Smrg # Extract -R from dependency_libs 8445e35772b2Smrg temp_deplibs= 8446e35772b2Smrg for libdir in $dependency_libs; do 8447e35772b2Smrg case $libdir in 8448e35772b2Smrg -R*) func_stripname '-R' '' "$libdir" 8449e35772b2Smrg temp_xrpath=$func_stripname_result 8450e35772b2Smrg case " $xrpath " in 8451e35772b2Smrg *" $temp_xrpath "*) ;; 845274c14cd6Smrg *) func_append xrpath " $temp_xrpath";; 8453e35772b2Smrg esac;; 845474c14cd6Smrg *) func_append temp_deplibs " $libdir";; 8455e35772b2Smrg esac 8456e35772b2Smrg done 845721525869Smrg dependency_libs=$temp_deplibs 8458e35772b2Smrg fi 8459e35772b2Smrg 846074c14cd6Smrg func_append newlib_search_path " $absdir" 8461e35772b2Smrg # Link against this library 846221525869Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8463e35772b2Smrg # ... and its dependency_libs 8464e35772b2Smrg tmp_libs= 8465e35772b2Smrg for deplib in $dependency_libs; do 8466e35772b2Smrg newdependency_libs="$deplib $newdependency_libs" 846774c14cd6Smrg case $deplib in 846874c14cd6Smrg -L*) func_stripname '-L' '' "$deplib" 846974c14cd6Smrg func_resolve_sysroot "$func_stripname_result";; 847074c14cd6Smrg *) func_resolve_sysroot "$deplib" ;; 847174c14cd6Smrg esac 847221525869Smrg if $opt_preserve_dup_deps; then 8473e35772b2Smrg case "$tmp_libs " in 847474c14cd6Smrg *" $func_resolve_sysroot_result "*) 847574c14cd6Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8476e35772b2Smrg esac 8477e35772b2Smrg fi 847874c14cd6Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8479e35772b2Smrg done 8480e35772b2Smrg 848121525869Smrg if test no != "$link_all_deplibs"; then 8482e35772b2Smrg # Add the search paths of all dependency libraries 8483e35772b2Smrg for deplib in $dependency_libs; do 848474c14cd6Smrg path= 8485e35772b2Smrg case $deplib in 848621525869Smrg -L*) path=$deplib ;; 8487e35772b2Smrg *.la) 848874c14cd6Smrg func_resolve_sysroot "$deplib" 848974c14cd6Smrg deplib=$func_resolve_sysroot_result 8490e35772b2Smrg func_dirname "$deplib" "" "." 849174c14cd6Smrg dir=$func_dirname_result 8492e35772b2Smrg # We need an absolute path. 8493e35772b2Smrg case $dir in 849421525869Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8495e35772b2Smrg *) 8496e35772b2Smrg absdir=`cd "$dir" && pwd` 8497e35772b2Smrg if test -z "$absdir"; then 849821525869Smrg func_warning "cannot determine absolute directory name of '$dir'" 849921525869Smrg absdir=$dir 8500e35772b2Smrg fi 8501e35772b2Smrg ;; 8502e35772b2Smrg esac 8503e35772b2Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8504e35772b2Smrg case $host in 8505e35772b2Smrg *-*-darwin*) 8506e35772b2Smrg depdepl= 850721525869Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850821525869Smrg if test -n "$deplibrary_names"; then 850921525869Smrg for tmp in $deplibrary_names; do 8510e35772b2Smrg depdepl=$tmp 8511e35772b2Smrg done 851221525869Smrg if test -f "$absdir/$objdir/$depdepl"; then 851321525869Smrg depdepl=$absdir/$objdir/$depdepl 851421525869Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8515e35772b2Smrg if test -z "$darwin_install_name"; then 851621525869Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8517e35772b2Smrg fi 851821525869Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851921525869Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8520e35772b2Smrg path= 8521e35772b2Smrg fi 8522e35772b2Smrg fi 8523e35772b2Smrg ;; 8524e35772b2Smrg *) 852521525869Smrg path=-L$absdir/$objdir 8526e35772b2Smrg ;; 8527e35772b2Smrg esac 8528e35772b2Smrg else 852921525869Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8530e35772b2Smrg test -z "$libdir" && \ 853121525869Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8532e35772b2Smrg test "$absdir" != "$libdir" && \ 853321525869Smrg func_warning "'$deplib' seems to be moved" 8534e35772b2Smrg 853521525869Smrg path=-L$absdir 8536e35772b2Smrg fi 8537e35772b2Smrg ;; 8538e35772b2Smrg esac 8539e35772b2Smrg case " $deplibs " in 8540e35772b2Smrg *" $path "*) ;; 8541e35772b2Smrg *) deplibs="$path $deplibs" ;; 8542e35772b2Smrg esac 8543e35772b2Smrg done 8544e35772b2Smrg fi # link_all_deplibs != no 8545e35772b2Smrg fi # linkmode = lib 8546e35772b2Smrg done # for deplib in $libs 854721525869Smrg if test link = "$pass"; then 854821525869Smrg if test prog = "$linkmode"; then 8549e35772b2Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8550e35772b2Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8551e35772b2Smrg else 855274c14cd6Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8553e35772b2Smrg fi 8554e35772b2Smrg fi 855521525869Smrg dependency_libs=$newdependency_libs 855621525869Smrg if test dlpreopen = "$pass"; then 8557e35772b2Smrg # Link the dlpreopened libraries before other libraries 8558e35772b2Smrg for deplib in $save_deplibs; do 8559e35772b2Smrg deplibs="$deplib $deplibs" 8560e35772b2Smrg done 8561e35772b2Smrg fi 856221525869Smrg if test dlopen != "$pass"; then 856321525869Smrg test conv = "$pass" || { 8564e35772b2Smrg # Make sure lib_search_path contains only unique directories. 8565e35772b2Smrg lib_search_path= 8566e35772b2Smrg for dir in $newlib_search_path; do 8567e35772b2Smrg case "$lib_search_path " in 8568e35772b2Smrg *" $dir "*) ;; 856974c14cd6Smrg *) func_append lib_search_path " $dir" ;; 8570e35772b2Smrg esac 8571e35772b2Smrg done 8572e35772b2Smrg newlib_search_path= 857321525869Smrg } 8574e35772b2Smrg 857521525869Smrg if test prog,link = "$linkmode,$pass"; then 8576e35772b2Smrg vars="compile_deplibs finalize_deplibs" 857721525869Smrg else 857821525869Smrg vars=deplibs 8579e35772b2Smrg fi 8580e35772b2Smrg for var in $vars dependency_libs; do 8581e35772b2Smrg # Add libraries to $var in reverse order 8582e35772b2Smrg eval tmp_libs=\"\$$var\" 8583e35772b2Smrg new_libs= 8584e35772b2Smrg for deplib in $tmp_libs; do 8585e35772b2Smrg # FIXME: Pedantically, this is the right thing to do, so 8586e35772b2Smrg # that some nasty dependency loop isn't accidentally 8587e35772b2Smrg # broken: 8588e35772b2Smrg #new_libs="$deplib $new_libs" 8589e35772b2Smrg # Pragmatically, this seems to cause very few problems in 8590e35772b2Smrg # practice: 8591e35772b2Smrg case $deplib in 8592e35772b2Smrg -L*) new_libs="$deplib $new_libs" ;; 8593e35772b2Smrg -R*) ;; 8594e35772b2Smrg *) 8595e35772b2Smrg # And here is the reason: when a library appears more 8596e35772b2Smrg # than once as an explicit dependence of a library, or 8597e35772b2Smrg # is implicitly linked in more than once by the 8598e35772b2Smrg # compiler, it is considered special, and multiple 8599e35772b2Smrg # occurrences thereof are not removed. Compare this 8600e35772b2Smrg # with having the same library being listed as a 8601e35772b2Smrg # dependency of multiple other libraries: in this case, 8602e35772b2Smrg # we know (pedantically, we assume) the library does not 8603e35772b2Smrg # need to be listed more than once, so we keep only the 8604e35772b2Smrg # last copy. This is not always right, but it is rare 8605e35772b2Smrg # enough that we require users that really mean to play 8606e35772b2Smrg # such unportable linking tricks to link the library 8607e35772b2Smrg # using -Wl,-lname, so that libtool does not consider it 8608e35772b2Smrg # for duplicate removal. 8609e35772b2Smrg case " $specialdeplibs " in 8610e35772b2Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8611e35772b2Smrg *) 8612e35772b2Smrg case " $new_libs " in 8613e35772b2Smrg *" $deplib "*) ;; 8614e35772b2Smrg *) new_libs="$deplib $new_libs" ;; 8615e35772b2Smrg esac 8616e35772b2Smrg ;; 8617e35772b2Smrg esac 8618e35772b2Smrg ;; 8619e35772b2Smrg esac 8620e35772b2Smrg done 8621e35772b2Smrg tmp_libs= 8622e35772b2Smrg for deplib in $new_libs; do 8623e35772b2Smrg case $deplib in 8624e35772b2Smrg -L*) 8625e35772b2Smrg case " $tmp_libs " in 8626e35772b2Smrg *" $deplib "*) ;; 862774c14cd6Smrg *) func_append tmp_libs " $deplib" ;; 8628e35772b2Smrg esac 8629e35772b2Smrg ;; 863074c14cd6Smrg *) func_append tmp_libs " $deplib" ;; 8631e35772b2Smrg esac 8632e35772b2Smrg done 8633e35772b2Smrg eval $var=\"$tmp_libs\" 8634e35772b2Smrg done # for var 8635e35772b2Smrg fi 863621525869Smrg 863721525869Smrg # Add Sun CC postdeps if required: 863821525869Smrg test CXX = "$tagname" && { 863921525869Smrg case $host_os in 864021525869Smrg linux*) 864121525869Smrg case `$CC -V 2>&1 | sed 5q` in 864221525869Smrg *Sun\ C*) # Sun C++ 5.9 864321525869Smrg func_suncc_cstd_abi 864421525869Smrg 864521525869Smrg if test no != "$suncc_use_cstd_abi"; then 864621525869Smrg func_append postdeps ' -library=Cstd -library=Crun' 864721525869Smrg fi 864821525869Smrg ;; 864921525869Smrg esac 865021525869Smrg ;; 865121525869Smrg 865221525869Smrg solaris*) 865321525869Smrg func_cc_basename "$CC" 865421525869Smrg case $func_cc_basename_result in 865521525869Smrg CC* | sunCC*) 865621525869Smrg func_suncc_cstd_abi 865721525869Smrg 865821525869Smrg if test no != "$suncc_use_cstd_abi"; then 865921525869Smrg func_append postdeps ' -library=Cstd -library=Crun' 866021525869Smrg fi 866121525869Smrg ;; 866221525869Smrg esac 866321525869Smrg ;; 866421525869Smrg esac 866521525869Smrg } 866621525869Smrg 8667e35772b2Smrg # Last step: remove runtime libs from dependency_libs 8668e35772b2Smrg # (they stay in deplibs) 8669e35772b2Smrg tmp_libs= 867021525869Smrg for i in $dependency_libs; do 8671e35772b2Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8672e35772b2Smrg *" $i "*) 867321525869Smrg i= 8674e35772b2Smrg ;; 8675e35772b2Smrg esac 867621525869Smrg if test -n "$i"; then 867774c14cd6Smrg func_append tmp_libs " $i" 8678e35772b2Smrg fi 8679e35772b2Smrg done 8680e35772b2Smrg dependency_libs=$tmp_libs 8681e35772b2Smrg done # for pass 868221525869Smrg if test prog = "$linkmode"; then 868321525869Smrg dlfiles=$newdlfiles 8684e35772b2Smrg fi 868521525869Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868621525869Smrg dlprefiles=$newdlprefiles 8687e35772b2Smrg fi 8688e35772b2Smrg 8689e35772b2Smrg case $linkmode in 8690e35772b2Smrg oldlib) 869121525869Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 869221525869Smrg func_warning "'-dlopen' is ignored for archives" 8693e35772b2Smrg fi 8694e35772b2Smrg 8695e35772b2Smrg case " $deplibs" in 8696e35772b2Smrg *\ -l* | *\ -L*) 869721525869Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8698e35772b2Smrg esac 8699e35772b2Smrg 8700e35772b2Smrg test -n "$rpath" && \ 870121525869Smrg func_warning "'-rpath' is ignored for archives" 8702e35772b2Smrg 8703e35772b2Smrg test -n "$xrpath" && \ 870421525869Smrg func_warning "'-R' is ignored for archives" 8705e35772b2Smrg 8706e35772b2Smrg test -n "$vinfo" && \ 870721525869Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8708e35772b2Smrg 8709e35772b2Smrg test -n "$release" && \ 871021525869Smrg func_warning "'-release' is ignored for archives" 8711e35772b2Smrg 8712e35772b2Smrg test -n "$export_symbols$export_symbols_regex" && \ 871321525869Smrg func_warning "'-export-symbols' is ignored for archives" 8714e35772b2Smrg 8715e35772b2Smrg # Now set the variables for building old libraries. 8716e35772b2Smrg build_libtool_libs=no 871721525869Smrg oldlibs=$output 871874c14cd6Smrg func_append objs "$old_deplibs" 8719e35772b2Smrg ;; 8720e35772b2Smrg 8721e35772b2Smrg lib) 872221525869Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 8723e35772b2Smrg case $outputname in 8724e35772b2Smrg lib*) 8725e35772b2Smrg func_stripname 'lib' '.la' "$outputname" 8726e35772b2Smrg name=$func_stripname_result 8727e35772b2Smrg eval shared_ext=\"$shrext_cmds\" 8728e35772b2Smrg eval libname=\"$libname_spec\" 8729e35772b2Smrg ;; 8730e35772b2Smrg *) 873121525869Smrg test no = "$module" \ 873221525869Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8733e35772b2Smrg 873421525869Smrg if test no != "$need_lib_prefix"; then 8735e35772b2Smrg # Add the "lib" prefix for modules if required 8736e35772b2Smrg func_stripname '' '.la' "$outputname" 8737e35772b2Smrg name=$func_stripname_result 8738e35772b2Smrg eval shared_ext=\"$shrext_cmds\" 8739e35772b2Smrg eval libname=\"$libname_spec\" 8740e35772b2Smrg else 8741e35772b2Smrg func_stripname '' '.la' "$outputname" 8742e35772b2Smrg libname=$func_stripname_result 8743e35772b2Smrg fi 8744e35772b2Smrg ;; 8745e35772b2Smrg esac 8746e35772b2Smrg 8747e35772b2Smrg if test -n "$objs"; then 874821525869Smrg if test pass_all != "$deplibs_check_method"; then 874921525869Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8750e35772b2Smrg else 875174c14cd6Smrg echo 8752e35772b2Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8753e35772b2Smrg $ECHO "*** objects $objs is not portable!" 875474c14cd6Smrg func_append libobjs " $objs" 8755e35772b2Smrg fi 8756e35772b2Smrg fi 8757e35772b2Smrg 875821525869Smrg test no = "$dlself" \ 875921525869Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8760e35772b2Smrg 8761e35772b2Smrg set dummy $rpath 8762e35772b2Smrg shift 876321525869Smrg test 1 -lt "$#" \ 876421525869Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8765e35772b2Smrg 876621525869Smrg install_libdir=$1 8767e35772b2Smrg 8768e35772b2Smrg oldlibs= 8769e35772b2Smrg if test -z "$rpath"; then 877021525869Smrg if test yes = "$build_libtool_libs"; then 8771e35772b2Smrg # Building a libtool convenience library. 877221525869Smrg # Some compilers have problems with a '.al' extension so 8773e35772b2Smrg # convenience libraries should have the same extension an 8774e35772b2Smrg # archive normally would. 8775e35772b2Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8776e35772b2Smrg build_libtool_libs=convenience 8777e35772b2Smrg build_old_libs=yes 8778e35772b2Smrg fi 8779e35772b2Smrg 8780e35772b2Smrg test -n "$vinfo" && \ 878121525869Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8782e35772b2Smrg 8783e35772b2Smrg test -n "$release" && \ 878421525869Smrg func_warning "'-release' is ignored for convenience libraries" 8785e35772b2Smrg else 8786e35772b2Smrg 8787e35772b2Smrg # Parse the version information argument. 878821525869Smrg save_ifs=$IFS; IFS=: 8789e35772b2Smrg set dummy $vinfo 0 0 0 8790e35772b2Smrg shift 879121525869Smrg IFS=$save_ifs 8792e35772b2Smrg 8793e35772b2Smrg test -n "$7" && \ 879421525869Smrg func_fatal_help "too many parameters to '-version-info'" 8795e35772b2Smrg 8796e35772b2Smrg # convert absolute version numbers to libtool ages 8797e35772b2Smrg # this retains compatibility with .la files and attempts 8798e35772b2Smrg # to make the code below a bit more comprehensible 8799e35772b2Smrg 8800e35772b2Smrg case $vinfo_number in 8801e35772b2Smrg yes) 880221525869Smrg number_major=$1 880321525869Smrg number_minor=$2 880421525869Smrg number_revision=$3 8805e35772b2Smrg # 8806e35772b2Smrg # There are really only two kinds -- those that 8807e35772b2Smrg # use the current revision as the major version 8808e35772b2Smrg # and those that subtract age and use age as 8809e35772b2Smrg # a minor version. But, then there is irix 881021525869Smrg # that has an extra 1 added just for fun 8811e35772b2Smrg # 8812e35772b2Smrg case $version_type in 881374c14cd6Smrg # correct linux to gnu/linux during the next big refactor 881421525869Smrg darwin|freebsd-elf|linux|osf|windows|none) 8815e35772b2Smrg func_arith $number_major + $number_minor 8816e35772b2Smrg current=$func_arith_result 881721525869Smrg age=$number_minor 881821525869Smrg revision=$number_revision 8819e35772b2Smrg ;; 882021525869Smrg freebsd-aout|qnx|sunos) 882121525869Smrg current=$number_major 882221525869Smrg revision=$number_minor 882321525869Smrg age=0 8824e35772b2Smrg ;; 8825e35772b2Smrg irix|nonstopux) 8826e35772b2Smrg func_arith $number_major + $number_minor 8827e35772b2Smrg current=$func_arith_result 882821525869Smrg age=$number_minor 882921525869Smrg revision=$number_minor 8830e35772b2Smrg lt_irix_increment=no 8831e35772b2Smrg ;; 883274fcc364Smrg *) 883374fcc364Smrg func_fatal_configuration "$modename: unknown library version type '$version_type'" 883474fcc364Smrg ;; 8835e35772b2Smrg esac 8836e35772b2Smrg ;; 8837e35772b2Smrg no) 883821525869Smrg current=$1 883921525869Smrg revision=$2 884021525869Smrg age=$3 8841e35772b2Smrg ;; 8842e35772b2Smrg esac 8843e35772b2Smrg 8844e35772b2Smrg # Check that each of the things are valid numbers. 8845e35772b2Smrg case $current in 8846e35772b2Smrg 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]) ;; 8847e35772b2Smrg *) 884821525869Smrg func_error "CURRENT '$current' must be a nonnegative integer" 884921525869Smrg func_fatal_error "'$vinfo' is not valid version information" 8850e35772b2Smrg ;; 8851e35772b2Smrg esac 8852e35772b2Smrg 8853e35772b2Smrg case $revision in 8854e35772b2Smrg 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]) ;; 8855e35772b2Smrg *) 885621525869Smrg func_error "REVISION '$revision' must be a nonnegative integer" 885721525869Smrg func_fatal_error "'$vinfo' is not valid version information" 8858e35772b2Smrg ;; 8859e35772b2Smrg esac 8860e35772b2Smrg 8861e35772b2Smrg case $age in 8862e35772b2Smrg 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]) ;; 8863e35772b2Smrg *) 886421525869Smrg func_error "AGE '$age' must be a nonnegative integer" 886521525869Smrg func_fatal_error "'$vinfo' is not valid version information" 8866e35772b2Smrg ;; 8867e35772b2Smrg esac 8868e35772b2Smrg 8869e35772b2Smrg if test "$age" -gt "$current"; then 887021525869Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 887121525869Smrg func_fatal_error "'$vinfo' is not valid version information" 8872e35772b2Smrg fi 8873e35772b2Smrg 8874e35772b2Smrg # Calculate the version variables. 8875e35772b2Smrg major= 8876e35772b2Smrg versuffix= 8877e35772b2Smrg verstring= 8878e35772b2Smrg case $version_type in 8879e35772b2Smrg none) ;; 8880e35772b2Smrg 8881e35772b2Smrg darwin) 8882e35772b2Smrg # Like Linux, but with the current version available in 8883e35772b2Smrg # verstring for coding it into the library header 8884e35772b2Smrg func_arith $current - $age 8885e35772b2Smrg major=.$func_arith_result 888621525869Smrg versuffix=$major.$age.$revision 8887e35772b2Smrg # Darwin ld doesn't like 0 for these options... 8888e35772b2Smrg func_arith $current + 1 8889e35772b2Smrg minor_current=$func_arith_result 889021525869Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8891e35772b2Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889221525869Smrg # On Darwin other compilers 889321525869Smrg case $CC in 889421525869Smrg nagfor*) 889521525869Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 889621525869Smrg ;; 889721525869Smrg *) 889821525869Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889921525869Smrg ;; 890021525869Smrg esac 8901e35772b2Smrg ;; 8902e35772b2Smrg 8903e35772b2Smrg freebsd-aout) 890421525869Smrg major=.$current 890521525869Smrg versuffix=.$current.$revision 8906e35772b2Smrg ;; 8907e35772b2Smrg 8908e35772b2Smrg freebsd-elf) 890921525869Smrg func_arith $current - $age 891021525869Smrg major=.$func_arith_result 891121525869Smrg versuffix=$major.$age.$revision 8912e35772b2Smrg ;; 8913e35772b2Smrg 8914e35772b2Smrg irix | nonstopux) 891521525869Smrg if test no = "$lt_irix_increment"; then 8916e35772b2Smrg func_arith $current - $age 8917e35772b2Smrg else 8918e35772b2Smrg func_arith $current - $age + 1 8919e35772b2Smrg fi 8920e35772b2Smrg major=$func_arith_result 8921e35772b2Smrg 8922e35772b2Smrg case $version_type in 8923e35772b2Smrg nonstopux) verstring_prefix=nonstopux ;; 8924e35772b2Smrg *) verstring_prefix=sgi ;; 8925e35772b2Smrg esac 892621525869Smrg verstring=$verstring_prefix$major.$revision 8927e35772b2Smrg 8928e35772b2Smrg # Add in all the interfaces that we are compatible with. 8929e35772b2Smrg loop=$revision 893021525869Smrg while test 0 -ne "$loop"; do 8931e35772b2Smrg func_arith $revision - $loop 8932e35772b2Smrg iface=$func_arith_result 8933e35772b2Smrg func_arith $loop - 1 8934e35772b2Smrg loop=$func_arith_result 893521525869Smrg verstring=$verstring_prefix$major.$iface:$verstring 8936e35772b2Smrg done 8937e35772b2Smrg 893821525869Smrg # Before this point, $major must not contain '.'. 8939e35772b2Smrg major=.$major 894021525869Smrg versuffix=$major.$revision 8941e35772b2Smrg ;; 8942e35772b2Smrg 894374c14cd6Smrg linux) # correct to gnu/linux during the next big refactor 8944e35772b2Smrg func_arith $current - $age 8945e35772b2Smrg major=.$func_arith_result 894621525869Smrg versuffix=$major.$age.$revision 8947e35772b2Smrg ;; 8948e35772b2Smrg 8949e35772b2Smrg osf) 8950e35772b2Smrg func_arith $current - $age 8951e35772b2Smrg major=.$func_arith_result 895221525869Smrg versuffix=.$current.$age.$revision 895321525869Smrg verstring=$current.$age.$revision 8954e35772b2Smrg 8955e35772b2Smrg # Add in all the interfaces that we are compatible with. 8956e35772b2Smrg loop=$age 895721525869Smrg while test 0 -ne "$loop"; do 8958e35772b2Smrg func_arith $current - $loop 8959e35772b2Smrg iface=$func_arith_result 8960e35772b2Smrg func_arith $loop - 1 8961e35772b2Smrg loop=$func_arith_result 896221525869Smrg verstring=$verstring:$iface.0 8963e35772b2Smrg done 8964e35772b2Smrg 8965e35772b2Smrg # Make executables depend on our current version. 896621525869Smrg func_append verstring ":$current.0" 8967e35772b2Smrg ;; 8968e35772b2Smrg 8969e35772b2Smrg qnx) 897021525869Smrg major=.$current 897121525869Smrg versuffix=.$current 897221525869Smrg ;; 897321525869Smrg 897421525869Smrg sco) 897521525869Smrg major=.$current 897621525869Smrg versuffix=.$current 8977e35772b2Smrg ;; 8978e35772b2Smrg 8979e35772b2Smrg sunos) 898021525869Smrg major=.$current 898121525869Smrg versuffix=.$current.$revision 8982e35772b2Smrg ;; 8983e35772b2Smrg 8984e35772b2Smrg windows) 8985e35772b2Smrg # Use '-' rather than '.', since we only want one 898621525869Smrg # extension on DOS 8.3 file systems. 8987e35772b2Smrg func_arith $current - $age 8988e35772b2Smrg major=$func_arith_result 898921525869Smrg versuffix=-$major 8990e35772b2Smrg ;; 8991e35772b2Smrg 8992e35772b2Smrg *) 899321525869Smrg func_fatal_configuration "unknown library version type '$version_type'" 8994e35772b2Smrg ;; 8995e35772b2Smrg esac 8996e35772b2Smrg 8997e35772b2Smrg # Clear the version info if we defaulted, and they specified a release. 8998e35772b2Smrg if test -z "$vinfo" && test -n "$release"; then 8999e35772b2Smrg major= 9000e35772b2Smrg case $version_type in 9001e35772b2Smrg darwin) 9002e35772b2Smrg # we can't check for "0.0" in archive_cmds due to quoting 9003e35772b2Smrg # problems, so we reset it completely 9004e35772b2Smrg verstring= 9005e35772b2Smrg ;; 9006e35772b2Smrg *) 900721525869Smrg verstring=0.0 9008e35772b2Smrg ;; 9009e35772b2Smrg esac 901021525869Smrg if test no = "$need_version"; then 9011e35772b2Smrg versuffix= 9012e35772b2Smrg else 901321525869Smrg versuffix=.0.0 9014e35772b2Smrg fi 9015e35772b2Smrg fi 9016e35772b2Smrg 9017e35772b2Smrg # Remove version info from name if versioning should be avoided 901821525869Smrg if test yes,no = "$avoid_version,$need_version"; then 9019e35772b2Smrg major= 9020e35772b2Smrg versuffix= 902121525869Smrg verstring= 9022e35772b2Smrg fi 9023e35772b2Smrg 9024e35772b2Smrg # Check to see if the archive will have undefined symbols. 902521525869Smrg if test yes = "$allow_undefined"; then 902621525869Smrg if test unsupported = "$allow_undefined_flag"; then 902721525869Smrg if test yes = "$build_old_libs"; then 902821525869Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902921525869Smrg build_libtool_libs=no 903021525869Smrg else 903121525869Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 903221525869Smrg fi 9033e35772b2Smrg fi 9034e35772b2Smrg else 9035e35772b2Smrg # Don't allow undefined symbols. 903621525869Smrg allow_undefined_flag=$no_undefined_flag 9037e35772b2Smrg fi 9038e35772b2Smrg 9039e35772b2Smrg fi 9040e35772b2Smrg 904121525869Smrg func_generate_dlsyms "$libname" "$libname" : 904274c14cd6Smrg func_append libobjs " $symfileobj" 904321525869Smrg test " " = "$libobjs" && libobjs= 9044e35772b2Smrg 904521525869Smrg if test relink != "$opt_mode"; then 9046e35772b2Smrg # Remove our outputs, but don't remove object files since they 9047e35772b2Smrg # may have been created when compiling PIC objects. 9048e35772b2Smrg removelist= 9049e35772b2Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9050e35772b2Smrg for p in $tempremovelist; do 9051e35772b2Smrg case $p in 9052e35772b2Smrg *.$objext | *.gcno) 9053e35772b2Smrg ;; 905421525869Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 905521525869Smrg if test -n "$precious_files_regex"; then 9056e35772b2Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9057e35772b2Smrg then 9058e35772b2Smrg continue 9059e35772b2Smrg fi 9060e35772b2Smrg fi 906174c14cd6Smrg func_append removelist " $p" 9062e35772b2Smrg ;; 9063e35772b2Smrg *) ;; 9064e35772b2Smrg esac 9065e35772b2Smrg done 9066e35772b2Smrg test -n "$removelist" && \ 9067e35772b2Smrg func_show_eval "${RM}r \$removelist" 9068e35772b2Smrg fi 9069e35772b2Smrg 9070e35772b2Smrg # Now set the variables for building old libraries. 907121525869Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 907274c14cd6Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9073e35772b2Smrg 9074e35772b2Smrg # Transform .lo files to .o files. 907521525869Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9076e35772b2Smrg fi 9077e35772b2Smrg 9078e35772b2Smrg # Eliminate all temporary directories. 9079e35772b2Smrg #for path in $notinst_path; do 908074c14cd6Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 908174c14cd6Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 908274c14cd6Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9083e35772b2Smrg #done 9084e35772b2Smrg 9085e35772b2Smrg if test -n "$xrpath"; then 9086e35772b2Smrg # If the user specified any rpath flags, then add them. 9087e35772b2Smrg temp_xrpath= 9088e35772b2Smrg for libdir in $xrpath; do 908974c14cd6Smrg func_replace_sysroot "$libdir" 909074c14cd6Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9091e35772b2Smrg case "$finalize_rpath " in 9092e35772b2Smrg *" $libdir "*) ;; 909374c14cd6Smrg *) func_append finalize_rpath " $libdir" ;; 9094e35772b2Smrg esac 9095e35772b2Smrg done 909621525869Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9097e35772b2Smrg dependency_libs="$temp_xrpath $dependency_libs" 9098e35772b2Smrg fi 9099e35772b2Smrg fi 9100e35772b2Smrg 9101e35772b2Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 910221525869Smrg old_dlfiles=$dlfiles 9103e35772b2Smrg dlfiles= 9104e35772b2Smrg for lib in $old_dlfiles; do 9105e35772b2Smrg case " $dlprefiles $dlfiles " in 9106e35772b2Smrg *" $lib "*) ;; 910774c14cd6Smrg *) func_append dlfiles " $lib" ;; 9108e35772b2Smrg esac 9109e35772b2Smrg done 9110e35772b2Smrg 9111e35772b2Smrg # Make sure dlprefiles contains only unique files 911221525869Smrg old_dlprefiles=$dlprefiles 9113e35772b2Smrg dlprefiles= 9114e35772b2Smrg for lib in $old_dlprefiles; do 9115e35772b2Smrg case "$dlprefiles " in 9116e35772b2Smrg *" $lib "*) ;; 911774c14cd6Smrg *) func_append dlprefiles " $lib" ;; 9118e35772b2Smrg esac 9119e35772b2Smrg done 9120e35772b2Smrg 912121525869Smrg if test yes = "$build_libtool_libs"; then 9122e35772b2Smrg if test -n "$rpath"; then 9123e35772b2Smrg case $host in 912474c14cd6Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9125e35772b2Smrg # these systems don't actually have a c library (as such)! 9126e35772b2Smrg ;; 9127e35772b2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9128e35772b2Smrg # Rhapsody C library is in the System framework 912974c14cd6Smrg func_append deplibs " System.ltframework" 9130e35772b2Smrg ;; 9131e35772b2Smrg *-*-netbsd*) 9132e35772b2Smrg # Don't link with libc until the a.out ld.so is fixed. 9133e35772b2Smrg ;; 9134e35772b2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9135e35772b2Smrg # Do not include libc due to us having libc/libc_r. 9136e35772b2Smrg ;; 9137e35772b2Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9138e35772b2Smrg # Causes problems with __ctype 9139e35772b2Smrg ;; 9140e35772b2Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9141e35772b2Smrg # Compiler inserts libc in the correct place for threads to work 9142e35772b2Smrg ;; 9143e35772b2Smrg *) 9144e35772b2Smrg # Add libc to deplibs on all other systems if necessary. 914521525869Smrg if test yes = "$build_libtool_need_lc"; then 914674c14cd6Smrg func_append deplibs " -lc" 9147e35772b2Smrg fi 9148e35772b2Smrg ;; 9149e35772b2Smrg esac 9150e35772b2Smrg fi 9151e35772b2Smrg 9152e35772b2Smrg # Transform deplibs into only deplibs that can be linked in shared. 9153e35772b2Smrg name_save=$name 9154e35772b2Smrg libname_save=$libname 9155e35772b2Smrg release_save=$release 9156e35772b2Smrg versuffix_save=$versuffix 9157e35772b2Smrg major_save=$major 9158e35772b2Smrg # I'm not sure if I'm treating the release correctly. I think 9159e35772b2Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9160e35772b2Smrg # add it in twice. Is that correct? 916121525869Smrg release= 916221525869Smrg versuffix= 916321525869Smrg major= 9164e35772b2Smrg newdeplibs= 9165e35772b2Smrg droppeddeps=no 9166e35772b2Smrg case $deplibs_check_method in 9167e35772b2Smrg pass_all) 9168e35772b2Smrg # Don't check for shared/static. Everything works. 9169e35772b2Smrg # This might be a little naive. We might want to check 9170e35772b2Smrg # whether the library exists or not. But this is on 9171e35772b2Smrg # osf3 & osf4 and I'm not really sure... Just 9172e35772b2Smrg # implementing what was already the behavior. 9173e35772b2Smrg newdeplibs=$deplibs 9174e35772b2Smrg ;; 9175e35772b2Smrg test_compile) 9176e35772b2Smrg # This code stresses the "libraries are programs" paradigm to its 9177e35772b2Smrg # limits. Maybe even breaks it. We compile a program, linking it 9178e35772b2Smrg # against the deplibs as a proxy for the library. Then we can check 9179e35772b2Smrg # whether they linked in statically or dynamically with ldd. 9180e35772b2Smrg $opt_dry_run || $RM conftest.c 9181e35772b2Smrg cat > conftest.c <<EOF 9182e35772b2Smrg int main() { return 0; } 9183e35772b2SmrgEOF 9184e35772b2Smrg $opt_dry_run || $RM conftest 9185e35772b2Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9186e35772b2Smrg ldd_output=`ldd conftest` 9187e35772b2Smrg for i in $deplibs; do 9188e35772b2Smrg case $i in 9189e35772b2Smrg -l*) 9190e35772b2Smrg func_stripname -l '' "$i" 9191e35772b2Smrg name=$func_stripname_result 919221525869Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9193e35772b2Smrg case " $predeps $postdeps " in 9194e35772b2Smrg *" $i "*) 919574c14cd6Smrg func_append newdeplibs " $i" 919621525869Smrg i= 9197e35772b2Smrg ;; 9198e35772b2Smrg esac 9199e35772b2Smrg fi 920021525869Smrg if test -n "$i"; then 9201e35772b2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9202e35772b2Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9203e35772b2Smrg set dummy $deplib_matches; shift 9204e35772b2Smrg deplib_match=$1 920521525869Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 920674c14cd6Smrg func_append newdeplibs " $i" 9207e35772b2Smrg else 9208e35772b2Smrg droppeddeps=yes 920974c14cd6Smrg echo 9210e35772b2Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 921174c14cd6Smrg echo "*** I have the capability to make that library automatically link in when" 921274c14cd6Smrg echo "*** you link to this library. But I can only do this if you have a" 921374c14cd6Smrg echo "*** shared version of the library, which I believe you do not have" 921474c14cd6Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 921574c14cd6Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9216e35772b2Smrg fi 9217e35772b2Smrg fi 9218e35772b2Smrg ;; 9219e35772b2Smrg *) 922074c14cd6Smrg func_append newdeplibs " $i" 9221e35772b2Smrg ;; 9222e35772b2Smrg esac 9223e35772b2Smrg done 9224e35772b2Smrg else 9225e35772b2Smrg # Error occurred in the first compile. Let's try to salvage 9226e35772b2Smrg # the situation: Compile a separate program for each library. 9227e35772b2Smrg for i in $deplibs; do 9228e35772b2Smrg case $i in 9229e35772b2Smrg -l*) 9230e35772b2Smrg func_stripname -l '' "$i" 9231e35772b2Smrg name=$func_stripname_result 9232e35772b2Smrg $opt_dry_run || $RM conftest 9233e35772b2Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9234e35772b2Smrg ldd_output=`ldd conftest` 923521525869Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9236e35772b2Smrg case " $predeps $postdeps " in 9237e35772b2Smrg *" $i "*) 923874c14cd6Smrg func_append newdeplibs " $i" 923921525869Smrg i= 9240e35772b2Smrg ;; 9241e35772b2Smrg esac 9242e35772b2Smrg fi 924321525869Smrg if test -n "$i"; then 9244e35772b2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9245e35772b2Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9246e35772b2Smrg set dummy $deplib_matches; shift 9247e35772b2Smrg deplib_match=$1 924821525869Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 924974c14cd6Smrg func_append newdeplibs " $i" 9250e35772b2Smrg else 9251e35772b2Smrg droppeddeps=yes 925274c14cd6Smrg echo 9253e35772b2Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 925474c14cd6Smrg echo "*** I have the capability to make that library automatically link in when" 925574c14cd6Smrg echo "*** you link to this library. But I can only do this if you have a" 925674c14cd6Smrg echo "*** shared version of the library, which you do not appear to have" 925774c14cd6Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 925874c14cd6Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9259e35772b2Smrg fi 9260e35772b2Smrg fi 9261e35772b2Smrg else 9262e35772b2Smrg droppeddeps=yes 926374c14cd6Smrg echo 9264e35772b2Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 926574c14cd6Smrg echo "*** make it link in! You will probably need to install it or some" 926674c14cd6Smrg echo "*** library that it depends on before this library will be fully" 926774c14cd6Smrg echo "*** functional. Installing it before continuing would be even better." 9268e35772b2Smrg fi 9269e35772b2Smrg ;; 9270e35772b2Smrg *) 927174c14cd6Smrg func_append newdeplibs " $i" 9272e35772b2Smrg ;; 9273e35772b2Smrg esac 9274e35772b2Smrg done 9275e35772b2Smrg fi 9276e35772b2Smrg ;; 9277e35772b2Smrg file_magic*) 9278e35772b2Smrg set dummy $deplibs_check_method; shift 9279e35772b2Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9280e35772b2Smrg for a_deplib in $deplibs; do 9281e35772b2Smrg case $a_deplib in 9282e35772b2Smrg -l*) 9283e35772b2Smrg func_stripname -l '' "$a_deplib" 9284e35772b2Smrg name=$func_stripname_result 928521525869Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9286e35772b2Smrg case " $predeps $postdeps " in 9287e35772b2Smrg *" $a_deplib "*) 928874c14cd6Smrg func_append newdeplibs " $a_deplib" 928921525869Smrg a_deplib= 9290e35772b2Smrg ;; 9291e35772b2Smrg esac 9292e35772b2Smrg fi 929321525869Smrg if test -n "$a_deplib"; then 9294e35772b2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 929574c14cd6Smrg if test -n "$file_magic_glob"; then 929674c14cd6Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 929774c14cd6Smrg else 929874c14cd6Smrg libnameglob=$libname 929974c14cd6Smrg fi 930021525869Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9301e35772b2Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 930221525869Smrg if test yes = "$want_nocaseglob"; then 930374c14cd6Smrg shopt -s nocaseglob 930474c14cd6Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 930574c14cd6Smrg $nocaseglob 930674c14cd6Smrg else 930774c14cd6Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 930874c14cd6Smrg fi 9309e35772b2Smrg for potent_lib in $potential_libs; do 9310e35772b2Smrg # Follow soft links. 9311e35772b2Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9312e35772b2Smrg $GREP " -> " >/dev/null; then 9313e35772b2Smrg continue 9314e35772b2Smrg fi 9315e35772b2Smrg # The statement above tries to avoid entering an 9316e35772b2Smrg # endless loop below, in case of cyclic links. 9317e35772b2Smrg # We might still enter an endless loop, since a link 9318e35772b2Smrg # loop can be closed while we follow links, 9319e35772b2Smrg # but so what? 932021525869Smrg potlib=$potent_lib 9321e35772b2Smrg while test -h "$potlib" 2>/dev/null; do 932221525869Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9323e35772b2Smrg case $potliblink in 932421525869Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 932521525869Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9326e35772b2Smrg esac 9327e35772b2Smrg done 9328e35772b2Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9329e35772b2Smrg $SED -e 10q | 9330e35772b2Smrg $EGREP "$file_magic_regex" > /dev/null; then 933174c14cd6Smrg func_append newdeplibs " $a_deplib" 933221525869Smrg a_deplib= 9333e35772b2Smrg break 2 9334e35772b2Smrg fi 9335e35772b2Smrg done 9336e35772b2Smrg done 9337e35772b2Smrg fi 933821525869Smrg if test -n "$a_deplib"; then 9339e35772b2Smrg droppeddeps=yes 934074c14cd6Smrg echo 9341e35772b2Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 934274c14cd6Smrg echo "*** I have the capability to make that library automatically link in when" 934374c14cd6Smrg echo "*** you link to this library. But I can only do this if you have a" 934474c14cd6Smrg echo "*** shared version of the library, which you do not appear to have" 934574c14cd6Smrg echo "*** because I did check the linker path looking for a file starting" 934621525869Smrg if test -z "$potlib"; then 9347e35772b2Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9348e35772b2Smrg else 9349e35772b2Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9350e35772b2Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9351e35772b2Smrg fi 9352e35772b2Smrg fi 9353e35772b2Smrg ;; 9354e35772b2Smrg *) 9355e35772b2Smrg # Add a -L argument. 935674c14cd6Smrg func_append newdeplibs " $a_deplib" 9357e35772b2Smrg ;; 9358e35772b2Smrg esac 9359e35772b2Smrg done # Gone through all deplibs. 9360e35772b2Smrg ;; 9361e35772b2Smrg match_pattern*) 9362e35772b2Smrg set dummy $deplibs_check_method; shift 9363e35772b2Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9364e35772b2Smrg for a_deplib in $deplibs; do 9365e35772b2Smrg case $a_deplib in 9366e35772b2Smrg -l*) 9367e35772b2Smrg func_stripname -l '' "$a_deplib" 9368e35772b2Smrg name=$func_stripname_result 936921525869Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9370e35772b2Smrg case " $predeps $postdeps " in 9371e35772b2Smrg *" $a_deplib "*) 937274c14cd6Smrg func_append newdeplibs " $a_deplib" 937321525869Smrg a_deplib= 9374e35772b2Smrg ;; 9375e35772b2Smrg esac 9376e35772b2Smrg fi 937721525869Smrg if test -n "$a_deplib"; then 9378e35772b2Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9379e35772b2Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9380e35772b2Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9381e35772b2Smrg for potent_lib in $potential_libs; do 938221525869Smrg potlib=$potent_lib # see symlink-check above in file_magic test 938374c14cd6Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9384e35772b2Smrg $EGREP "$match_pattern_regex" > /dev/null; then 938574c14cd6Smrg func_append newdeplibs " $a_deplib" 938621525869Smrg a_deplib= 9387e35772b2Smrg break 2 9388e35772b2Smrg fi 9389e35772b2Smrg done 9390e35772b2Smrg done 9391e35772b2Smrg fi 939221525869Smrg if test -n "$a_deplib"; then 9393e35772b2Smrg droppeddeps=yes 939474c14cd6Smrg echo 9395e35772b2Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 939674c14cd6Smrg echo "*** I have the capability to make that library automatically link in when" 939774c14cd6Smrg echo "*** you link to this library. But I can only do this if you have a" 939874c14cd6Smrg echo "*** shared version of the library, which you do not appear to have" 939974c14cd6Smrg echo "*** because I did check the linker path looking for a file starting" 940021525869Smrg if test -z "$potlib"; then 9401e35772b2Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9402e35772b2Smrg else 9403e35772b2Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9404e35772b2Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9405e35772b2Smrg fi 9406e35772b2Smrg fi 9407e35772b2Smrg ;; 9408e35772b2Smrg *) 9409e35772b2Smrg # Add a -L argument. 941074c14cd6Smrg func_append newdeplibs " $a_deplib" 9411e35772b2Smrg ;; 9412e35772b2Smrg esac 9413e35772b2Smrg done # Gone through all deplibs. 9414e35772b2Smrg ;; 9415e35772b2Smrg none | unknown | *) 941621525869Smrg newdeplibs= 941774c14cd6Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 941821525869Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941921525869Smrg for i in $predeps $postdeps; do 9420e35772b2Smrg # can't use Xsed below, because $i might contain '/' 942121525869Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9422e35772b2Smrg done 9423e35772b2Smrg fi 942474c14cd6Smrg case $tmp_deplibs in 942574c14cd6Smrg *[!\ \ ]*) 942674c14cd6Smrg echo 942721525869Smrg if test none = "$deplibs_check_method"; then 942874c14cd6Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9429e35772b2Smrg else 943074c14cd6Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9431e35772b2Smrg fi 943274c14cd6Smrg echo "*** All declared inter-library dependencies are being dropped." 9433e35772b2Smrg droppeddeps=yes 943474c14cd6Smrg ;; 943574c14cd6Smrg esac 9436e35772b2Smrg ;; 9437e35772b2Smrg esac 9438e35772b2Smrg versuffix=$versuffix_save 9439e35772b2Smrg major=$major_save 9440e35772b2Smrg release=$release_save 9441e35772b2Smrg libname=$libname_save 9442e35772b2Smrg name=$name_save 9443e35772b2Smrg 9444e35772b2Smrg case $host in 9445e35772b2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9446e35772b2Smrg # On Rhapsody replace the C library with the System framework 944774c14cd6Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9448e35772b2Smrg ;; 9449e35772b2Smrg esac 9450e35772b2Smrg 945121525869Smrg if test yes = "$droppeddeps"; then 945221525869Smrg if test yes = "$module"; then 945374c14cd6Smrg echo 945474c14cd6Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9455e35772b2Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 945674c14cd6Smrg echo "*** a static module, that should work as long as the dlopening" 945774c14cd6Smrg echo "*** application is linked with the -dlopen flag." 9458e35772b2Smrg if test -z "$global_symbol_pipe"; then 945974c14cd6Smrg echo 946074c14cd6Smrg echo "*** However, this would only work if libtool was able to extract symbol" 946121525869Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 946274c14cd6Smrg echo "*** not find such a program. So, this module is probably useless." 946321525869Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9464e35772b2Smrg fi 946521525869Smrg if test no = "$build_old_libs"; then 946621525869Smrg oldlibs=$output_objdir/$libname.$libext 9467e35772b2Smrg build_libtool_libs=module 9468e35772b2Smrg build_old_libs=yes 9469e35772b2Smrg else 9470e35772b2Smrg build_libtool_libs=no 9471e35772b2Smrg fi 9472e35772b2Smrg else 947374c14cd6Smrg echo "*** The inter-library dependencies that have been dropped here will be" 947474c14cd6Smrg echo "*** automatically added whenever a program is linked with this library" 947574c14cd6Smrg echo "*** or is declared to -dlopen it." 9476e35772b2Smrg 947721525869Smrg if test no = "$allow_undefined"; then 947874c14cd6Smrg echo 947974c14cd6Smrg echo "*** Since this library must not contain undefined symbols," 948074c14cd6Smrg echo "*** because either the platform does not support them or" 948174c14cd6Smrg echo "*** it was explicitly requested with -no-undefined," 948274c14cd6Smrg echo "*** libtool will only create a static version of it." 948321525869Smrg if test no = "$build_old_libs"; then 948421525869Smrg oldlibs=$output_objdir/$libname.$libext 9485e35772b2Smrg build_libtool_libs=module 9486e35772b2Smrg build_old_libs=yes 9487e35772b2Smrg else 9488e35772b2Smrg build_libtool_libs=no 9489e35772b2Smrg fi 9490e35772b2Smrg fi 9491e35772b2Smrg fi 9492e35772b2Smrg fi 9493e35772b2Smrg # Done checking deplibs! 9494e35772b2Smrg deplibs=$newdeplibs 9495e35772b2Smrg fi 9496e35772b2Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9497e35772b2Smrg case $host in 9498e35772b2Smrg *-*-darwin*) 949974c14cd6Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 950074c14cd6Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 950174c14cd6Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9502e35772b2Smrg ;; 9503e35772b2Smrg esac 9504e35772b2Smrg 9505e35772b2Smrg # move library search paths that coincide with paths to not yet 9506e35772b2Smrg # installed libraries to the beginning of the library search list 9507e35772b2Smrg new_libs= 9508e35772b2Smrg for path in $notinst_path; do 9509e35772b2Smrg case " $new_libs " in 9510e35772b2Smrg *" -L$path/$objdir "*) ;; 9511e35772b2Smrg *) 9512e35772b2Smrg case " $deplibs " in 9513e35772b2Smrg *" -L$path/$objdir "*) 951474c14cd6Smrg func_append new_libs " -L$path/$objdir" ;; 9515e35772b2Smrg esac 9516e35772b2Smrg ;; 9517e35772b2Smrg esac 9518e35772b2Smrg done 9519e35772b2Smrg for deplib in $deplibs; do 9520e35772b2Smrg case $deplib in 9521e35772b2Smrg -L*) 9522e35772b2Smrg case " $new_libs " in 9523e35772b2Smrg *" $deplib "*) ;; 952474c14cd6Smrg *) func_append new_libs " $deplib" ;; 9525e35772b2Smrg esac 9526e35772b2Smrg ;; 952774c14cd6Smrg *) func_append new_libs " $deplib" ;; 9528e35772b2Smrg esac 9529e35772b2Smrg done 953021525869Smrg deplibs=$new_libs 9531e35772b2Smrg 9532e35772b2Smrg # All the library-specific variables (install_libdir is set above). 9533e35772b2Smrg library_names= 9534e35772b2Smrg old_library= 9535e35772b2Smrg dlname= 9536e35772b2Smrg 9537e35772b2Smrg # Test again, we may have decided not to build it any more 953821525869Smrg if test yes = "$build_libtool_libs"; then 953921525869Smrg # Remove $wl instances when linking with ld. 954074c14cd6Smrg # FIXME: should test the right _cmds variable. 954174c14cd6Smrg case $archive_cmds in 954274c14cd6Smrg *\$LD\ *) wl= ;; 954374c14cd6Smrg esac 954421525869Smrg if test yes = "$hardcode_into_libs"; then 9545e35772b2Smrg # Hardcode the library paths 9546e35772b2Smrg hardcode_libdirs= 9547e35772b2Smrg dep_rpath= 954821525869Smrg rpath=$finalize_rpath 954921525869Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9550e35772b2Smrg for libdir in $rpath; do 9551e35772b2Smrg if test -n "$hardcode_libdir_flag_spec"; then 9552e35772b2Smrg if test -n "$hardcode_libdir_separator"; then 955374c14cd6Smrg func_replace_sysroot "$libdir" 955474c14cd6Smrg libdir=$func_replace_sysroot_result 9555e35772b2Smrg if test -z "$hardcode_libdirs"; then 955621525869Smrg hardcode_libdirs=$libdir 9557e35772b2Smrg else 9558e35772b2Smrg # Just accumulate the unique libdirs. 9559e35772b2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9560e35772b2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9561e35772b2Smrg ;; 9562e35772b2Smrg *) 956374c14cd6Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9564e35772b2Smrg ;; 9565e35772b2Smrg esac 9566e35772b2Smrg fi 9567e35772b2Smrg else 9568e35772b2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 956974c14cd6Smrg func_append dep_rpath " $flag" 9570e35772b2Smrg fi 9571e35772b2Smrg elif test -n "$runpath_var"; then 9572e35772b2Smrg case "$perm_rpath " in 9573e35772b2Smrg *" $libdir "*) ;; 957474c14cd6Smrg *) func_append perm_rpath " $libdir" ;; 9575e35772b2Smrg esac 9576e35772b2Smrg fi 9577e35772b2Smrg done 9578e35772b2Smrg # Substitute the hardcoded libdirs into the rpath. 9579e35772b2Smrg if test -n "$hardcode_libdir_separator" && 9580e35772b2Smrg test -n "$hardcode_libdirs"; then 958121525869Smrg libdir=$hardcode_libdirs 958274c14cd6Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9583e35772b2Smrg fi 9584e35772b2Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9585e35772b2Smrg # We should set the runpath_var. 9586e35772b2Smrg rpath= 9587e35772b2Smrg for dir in $perm_rpath; do 958874c14cd6Smrg func_append rpath "$dir:" 9589e35772b2Smrg done 9590e35772b2Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9591e35772b2Smrg fi 9592e35772b2Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9593e35772b2Smrg fi 959472b676d7Smrg 959521525869Smrg shlibpath=$finalize_shlibpath 959621525869Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9597e35772b2Smrg if test -n "$shlibpath"; then 9598e35772b2Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9599e35772b2Smrg fi 960072b676d7Smrg 9601e35772b2Smrg # Get the real and link names of the library. 9602e35772b2Smrg eval shared_ext=\"$shrext_cmds\" 9603e35772b2Smrg eval library_names=\"$library_names_spec\" 9604e35772b2Smrg set dummy $library_names 9605e35772b2Smrg shift 960621525869Smrg realname=$1 9607e35772b2Smrg shift 960872b676d7Smrg 9609e35772b2Smrg if test -n "$soname_spec"; then 9610e35772b2Smrg eval soname=\"$soname_spec\" 9611e35772b2Smrg else 961221525869Smrg soname=$realname 9613e35772b2Smrg fi 9614e35772b2Smrg if test -z "$dlname"; then 9615e35772b2Smrg dlname=$soname 9616e35772b2Smrg fi 961772b676d7Smrg 961821525869Smrg lib=$output_objdir/$realname 9619e35772b2Smrg linknames= 9620e35772b2Smrg for link 9621e35772b2Smrg do 962274c14cd6Smrg func_append linknames " $link" 9623e35772b2Smrg done 962472b676d7Smrg 9625e35772b2Smrg # Use standard objects if they are pic 962674c14cd6Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9627e35772b2Smrg test "X$libobjs" = "X " && libobjs= 962872b676d7Smrg 9629e35772b2Smrg delfiles= 9630e35772b2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9631e35772b2Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 963221525869Smrg export_symbols=$output_objdir/$libname.uexp 963374c14cd6Smrg func_append delfiles " $export_symbols" 9634e35772b2Smrg fi 963572b676d7Smrg 9636e35772b2Smrg orig_export_symbols= 9637e35772b2Smrg case $host_os in 9638e35772b2Smrg cygwin* | mingw* | cegcc*) 9639e35772b2Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9640e35772b2Smrg # exporting using user supplied symfile 964121525869Smrg func_dll_def_p "$export_symbols" || { 9642e35772b2Smrg # and it's NOT already a .def file. Must figure out 9643e35772b2Smrg # which of the given symbols are data symbols and tag 9644e35772b2Smrg # them as such. So, trigger use of export_symbols_cmds. 9645e35772b2Smrg # export_symbols gets reassigned inside the "prepare 9646e35772b2Smrg # the list of exported symbols" if statement, so the 9647e35772b2Smrg # include_expsyms logic still works. 964821525869Smrg orig_export_symbols=$export_symbols 9649e35772b2Smrg export_symbols= 9650e35772b2Smrg always_export_symbols=yes 965121525869Smrg } 9652e35772b2Smrg fi 9653e35772b2Smrg ;; 9654e35772b2Smrg esac 965572b676d7Smrg 9656e35772b2Smrg # Prepare the list of exported symbols 9657e35772b2Smrg if test -z "$export_symbols"; then 965821525869Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965921525869Smrg func_verbose "generating symbol list for '$libname.la'" 966021525869Smrg export_symbols=$output_objdir/$libname.exp 9661e35772b2Smrg $opt_dry_run || $RM $export_symbols 9662e35772b2Smrg cmds=$export_symbols_cmds 966321525869Smrg save_ifs=$IFS; IFS='~' 966474c14cd6Smrg for cmd1 in $cmds; do 966521525869Smrg IFS=$save_ifs 966674c14cd6Smrg # Take the normal branch if the nm_file_list_spec branch 966774c14cd6Smrg # doesn't work or if tool conversion is not needed. 966874c14cd6Smrg case $nm_file_list_spec~$to_tool_file_cmd in 966974c14cd6Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 967074c14cd6Smrg try_normal_branch=yes 967174c14cd6Smrg eval cmd=\"$cmd1\" 967274c14cd6Smrg func_len " $cmd" 967374c14cd6Smrg len=$func_len_result 967474c14cd6Smrg ;; 967574c14cd6Smrg *) 967674c14cd6Smrg try_normal_branch=no 967774c14cd6Smrg ;; 967874c14cd6Smrg esac 967921525869Smrg if test yes = "$try_normal_branch" \ 968074c14cd6Smrg && { test "$len" -lt "$max_cmd_len" \ 968174c14cd6Smrg || test "$max_cmd_len" -le -1; } 968274c14cd6Smrg then 968374c14cd6Smrg func_show_eval "$cmd" 'exit $?' 968474c14cd6Smrg skipped_export=false 968574c14cd6Smrg elif test -n "$nm_file_list_spec"; then 968674c14cd6Smrg func_basename "$output" 968774c14cd6Smrg output_la=$func_basename_result 968874c14cd6Smrg save_libobjs=$libobjs 968974c14cd6Smrg save_output=$output 969021525869Smrg output=$output_objdir/$output_la.nm 969174c14cd6Smrg func_to_tool_file "$output" 969274c14cd6Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 969374c14cd6Smrg func_append delfiles " $output" 969474c14cd6Smrg func_verbose "creating $NM input file list: $output" 969574c14cd6Smrg for obj in $save_libobjs; do 969674c14cd6Smrg func_to_tool_file "$obj" 969774c14cd6Smrg $ECHO "$func_to_tool_file_result" 969874c14cd6Smrg done > "$output" 969974c14cd6Smrg eval cmd=\"$cmd1\" 9700e35772b2Smrg func_show_eval "$cmd" 'exit $?' 970174c14cd6Smrg output=$save_output 970274c14cd6Smrg libobjs=$save_libobjs 9703e35772b2Smrg skipped_export=false 9704e35772b2Smrg else 9705e35772b2Smrg # The command line is too long to execute in one step. 9706e35772b2Smrg func_verbose "using reloadable object file for export list..." 9707e35772b2Smrg skipped_export=: 9708e35772b2Smrg # Break out early, otherwise skipped_export may be 9709e35772b2Smrg # set to false by a later but shorter cmd. 9710e35772b2Smrg break 9711e35772b2Smrg fi 9712e35772b2Smrg done 971321525869Smrg IFS=$save_ifs 971421525869Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9715e35772b2Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9716e35772b2Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9717e35772b2Smrg fi 9718e35772b2Smrg fi 971972b676d7Smrg fi 972072b676d7Smrg 9721e35772b2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 972221525869Smrg tmp_export_symbols=$export_symbols 972321525869Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 972474c14cd6Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9725e35772b2Smrg fi 972672b676d7Smrg 972721525869Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9728e35772b2Smrg # The given exports_symbols file has to be filtered, so filter it. 972921525869Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9730e35772b2Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 973121525869Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9732e35772b2Smrg # though. Also, the filter scales superlinearly with the number of 9733e35772b2Smrg # global variables. join(1) would be nice here, but unfortunately 9734e35772b2Smrg # isn't a blessed tool. 9735e35772b2Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 973674c14cd6Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9737e35772b2Smrg export_symbols=$output_objdir/$libname.def 9738e35772b2Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9739e35772b2Smrg fi 974072b676d7Smrg 9741e35772b2Smrg tmp_deplibs= 9742e35772b2Smrg for test_deplib in $deplibs; do 9743e35772b2Smrg case " $convenience " in 9744e35772b2Smrg *" $test_deplib "*) ;; 9745e35772b2Smrg *) 974674c14cd6Smrg func_append tmp_deplibs " $test_deplib" 9747e35772b2Smrg ;; 9748e35772b2Smrg esac 9749e35772b2Smrg done 975021525869Smrg deplibs=$tmp_deplibs 975172b676d7Smrg 9752e35772b2Smrg if test -n "$convenience"; then 9753e35772b2Smrg if test -n "$whole_archive_flag_spec" && 975421525869Smrg test yes = "$compiler_needs_object" && 9755e35772b2Smrg test -z "$libobjs"; then 9756e35772b2Smrg # extract the archives, so we have objects to list. 9757e35772b2Smrg # TODO: could optimize this to just extract one archive. 9758e35772b2Smrg whole_archive_flag_spec= 9759e35772b2Smrg fi 9760e35772b2Smrg if test -n "$whole_archive_flag_spec"; then 9761e35772b2Smrg save_libobjs=$libobjs 9762e35772b2Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9763e35772b2Smrg test "X$libobjs" = "X " && libobjs= 9764e35772b2Smrg else 976521525869Smrg gentop=$output_objdir/${outputname}x 976674c14cd6Smrg func_append generated " $gentop" 976772b676d7Smrg 9768e35772b2Smrg func_extract_archives $gentop $convenience 976974c14cd6Smrg func_append libobjs " $func_extract_archives_result" 9770e35772b2Smrg test "X$libobjs" = "X " && libobjs= 9771e35772b2Smrg fi 977272b676d7Smrg fi 977372b676d7Smrg 977421525869Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9775e35772b2Smrg eval flag=\"$thread_safe_flag_spec\" 977674c14cd6Smrg func_append linker_flags " $flag" 977772b676d7Smrg fi 977872b676d7Smrg 9779e35772b2Smrg # Make a backup of the uninstalled library when relinking 978021525869Smrg if test relink = "$opt_mode"; then 9781e35772b2Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9782e35772b2Smrg fi 978372b676d7Smrg 9784e35772b2Smrg # Do each of the archive commands. 978521525869Smrg if test yes = "$module" && test -n "$module_cmds"; then 9786e35772b2Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9787e35772b2Smrg eval test_cmds=\"$module_expsym_cmds\" 9788e35772b2Smrg cmds=$module_expsym_cmds 9789e35772b2Smrg else 9790e35772b2Smrg eval test_cmds=\"$module_cmds\" 9791e35772b2Smrg cmds=$module_cmds 9792e35772b2Smrg fi 979372b676d7Smrg else 9794e35772b2Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9795e35772b2Smrg eval test_cmds=\"$archive_expsym_cmds\" 9796e35772b2Smrg cmds=$archive_expsym_cmds 9797e35772b2Smrg else 9798e35772b2Smrg eval test_cmds=\"$archive_cmds\" 9799e35772b2Smrg cmds=$archive_cmds 9800e35772b2Smrg fi 980172b676d7Smrg fi 980272b676d7Smrg 980321525869Smrg if test : != "$skipped_export" && 9804e35772b2Smrg func_len " $test_cmds" && 9805e35772b2Smrg len=$func_len_result && 9806e35772b2Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9807e35772b2Smrg : 9808e35772b2Smrg else 9809e35772b2Smrg # The command line is too long to link in one step, link piecewise 9810e35772b2Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9811e35772b2Smrg # script. 981272b676d7Smrg 9813e35772b2Smrg # Save the value of $output and $libobjs because we want to 9814e35772b2Smrg # use them later. If we have whole_archive_flag_spec, we 9815e35772b2Smrg # want to use save_libobjs as it was before 9816e35772b2Smrg # whole_archive_flag_spec was expanded, because we can't 9817e35772b2Smrg # assume the linker understands whole_archive_flag_spec. 9818e35772b2Smrg # This may have to be revisited, in case too many 9819e35772b2Smrg # convenience libraries get linked in and end up exceeding 9820e35772b2Smrg # the spec. 9821e35772b2Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9822e35772b2Smrg save_libobjs=$libobjs 9823e35772b2Smrg fi 9824e35772b2Smrg save_output=$output 982574c14cd6Smrg func_basename "$output" 982674c14cd6Smrg output_la=$func_basename_result 982772b676d7Smrg 9828e35772b2Smrg # Clear the reloadable object creation command queue and 9829e35772b2Smrg # initialize k to one. 9830e35772b2Smrg test_cmds= 9831e35772b2Smrg concat_cmds= 9832e35772b2Smrg objlist= 9833e35772b2Smrg last_robj= 9834e35772b2Smrg k=1 9835e35772b2Smrg 983621525869Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 983721525869Smrg output=$output_objdir/$output_la.lnkscript 9838e35772b2Smrg func_verbose "creating GNU ld script: $output" 983974c14cd6Smrg echo 'INPUT (' > $output 9840e35772b2Smrg for obj in $save_libobjs 984172b676d7Smrg do 984274c14cd6Smrg func_to_tool_file "$obj" 984374c14cd6Smrg $ECHO "$func_to_tool_file_result" >> $output 9844e35772b2Smrg done 984574c14cd6Smrg echo ')' >> $output 984674c14cd6Smrg func_append delfiles " $output" 984774c14cd6Smrg func_to_tool_file "$output" 984874c14cd6Smrg output=$func_to_tool_file_result 984921525869Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 985021525869Smrg output=$output_objdir/$output_la.lnk 9851e35772b2Smrg func_verbose "creating linker input file list: $output" 9852e35772b2Smrg : > $output 9853e35772b2Smrg set x $save_libobjs 9854e35772b2Smrg shift 9855e35772b2Smrg firstobj= 985621525869Smrg if test yes = "$compiler_needs_object"; then 9857e35772b2Smrg firstobj="$1 " 9858e35772b2Smrg shift 9859e35772b2Smrg fi 9860e35772b2Smrg for obj 9861e35772b2Smrg do 986274c14cd6Smrg func_to_tool_file "$obj" 986374c14cd6Smrg $ECHO "$func_to_tool_file_result" >> $output 9864e35772b2Smrg done 986574c14cd6Smrg func_append delfiles " $output" 986674c14cd6Smrg func_to_tool_file "$output" 986774c14cd6Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9868e35772b2Smrg else 9869e35772b2Smrg if test -n "$save_libobjs"; then 9870e35772b2Smrg func_verbose "creating reloadable object files..." 987121525869Smrg output=$output_objdir/$output_la-$k.$objext 9872e35772b2Smrg eval test_cmds=\"$reload_cmds\" 9873e35772b2Smrg func_len " $test_cmds" 9874e35772b2Smrg len0=$func_len_result 9875e35772b2Smrg len=$len0 9876e35772b2Smrg 9877e35772b2Smrg # Loop over the list of objects to be linked. 9878e35772b2Smrg for obj in $save_libobjs 9879e35772b2Smrg do 9880e35772b2Smrg func_len " $obj" 9881e35772b2Smrg func_arith $len + $func_len_result 9882e35772b2Smrg len=$func_arith_result 988321525869Smrg if test -z "$objlist" || 9884e35772b2Smrg test "$len" -lt "$max_cmd_len"; then 9885e35772b2Smrg func_append objlist " $obj" 9886e35772b2Smrg else 9887e35772b2Smrg # The command $test_cmds is almost too long, add a 9888e35772b2Smrg # command to the queue. 988921525869Smrg if test 1 -eq "$k"; then 9890e35772b2Smrg # The first file doesn't have a previous command to add. 989174c14cd6Smrg reload_objs=$objlist 989274c14cd6Smrg eval concat_cmds=\"$reload_cmds\" 9893e35772b2Smrg else 9894e35772b2Smrg # All subsequent reloadable object files will link in 9895e35772b2Smrg # the last one created. 989674c14cd6Smrg reload_objs="$objlist $last_robj" 989774c14cd6Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9898e35772b2Smrg fi 989921525869Smrg last_robj=$output_objdir/$output_la-$k.$objext 9900e35772b2Smrg func_arith $k + 1 9901e35772b2Smrg k=$func_arith_result 990221525869Smrg output=$output_objdir/$output_la-$k.$objext 990374c14cd6Smrg objlist=" $obj" 9904e35772b2Smrg func_len " $last_robj" 9905e35772b2Smrg func_arith $len0 + $func_len_result 9906e35772b2Smrg len=$func_arith_result 9907e35772b2Smrg fi 9908e35772b2Smrg done 9909e35772b2Smrg # Handle the remaining objects by creating one last 9910e35772b2Smrg # reloadable object file. All subsequent reloadable object 9911e35772b2Smrg # files will link in the last one created. 9912e35772b2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 991374c14cd6Smrg reload_objs="$objlist $last_robj" 991421525869Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9915e35772b2Smrg if test -n "$last_robj"; then 991621525869Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9917e35772b2Smrg fi 991874c14cd6Smrg func_append delfiles " $output" 991972b676d7Smrg 9920e35772b2Smrg else 9921e35772b2Smrg output= 9922e35772b2Smrg fi 992372b676d7Smrg 992421525869Smrg ${skipped_export-false} && { 992521525869Smrg func_verbose "generating symbol list for '$libname.la'" 992621525869Smrg export_symbols=$output_objdir/$libname.exp 9927e35772b2Smrg $opt_dry_run || $RM $export_symbols 9928e35772b2Smrg libobjs=$output 9929e35772b2Smrg # Append the command to create the export file. 9930e35772b2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9931e35772b2Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9932e35772b2Smrg if test -n "$last_robj"; then 9933e35772b2Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9934e35772b2Smrg fi 993521525869Smrg } 993672b676d7Smrg 9937e35772b2Smrg test -n "$save_libobjs" && 9938e35772b2Smrg func_verbose "creating a temporary reloadable object file: $output" 993972b676d7Smrg 9940e35772b2Smrg # Loop through the commands generated above and execute them. 994121525869Smrg save_ifs=$IFS; IFS='~' 9942e35772b2Smrg for cmd in $concat_cmds; do 994321525869Smrg IFS=$save_ifs 994421525869Smrg $opt_quiet || { 9945e35772b2Smrg func_quote_for_expand "$cmd" 9946e35772b2Smrg eval "func_echo $func_quote_for_expand_result" 9947e35772b2Smrg } 9948e35772b2Smrg $opt_dry_run || eval "$cmd" || { 9949e35772b2Smrg lt_exit=$? 9950e35772b2Smrg 9951e35772b2Smrg # Restore the uninstalled library and exit 995221525869Smrg if test relink = "$opt_mode"; then 9953e35772b2Smrg ( cd "$output_objdir" && \ 9954e35772b2Smrg $RM "${realname}T" && \ 9955e35772b2Smrg $MV "${realname}U" "$realname" ) 9956e35772b2Smrg fi 995772b676d7Smrg 9958e35772b2Smrg exit $lt_exit 9959e35772b2Smrg } 9960e35772b2Smrg done 996121525869Smrg IFS=$save_ifs 996272b676d7Smrg 9963e35772b2Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9964e35772b2Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9965e35772b2Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 996672b676d7Smrg fi 996772b676d7Smrg fi 996872b676d7Smrg 996921525869Smrg ${skipped_export-false} && { 9970e35772b2Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 997121525869Smrg tmp_export_symbols=$export_symbols 997221525869Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 997374c14cd6Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9974e35772b2Smrg fi 997572b676d7Smrg 9976e35772b2Smrg if test -n "$orig_export_symbols"; then 9977e35772b2Smrg # The given exports_symbols file has to be filtered, so filter it. 997821525869Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9979e35772b2Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 998021525869Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9981e35772b2Smrg # though. Also, the filter scales superlinearly with the number of 9982e35772b2Smrg # global variables. join(1) would be nice here, but unfortunately 9983e35772b2Smrg # isn't a blessed tool. 9984e35772b2Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 998574c14cd6Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9986e35772b2Smrg export_symbols=$output_objdir/$libname.def 9987e35772b2Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9988e35772b2Smrg fi 998921525869Smrg } 999072b676d7Smrg 9991e35772b2Smrg libobjs=$output 9992e35772b2Smrg # Restore the value of output. 9993e35772b2Smrg output=$save_output 999472b676d7Smrg 9995e35772b2Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9996e35772b2Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9997e35772b2Smrg test "X$libobjs" = "X " && libobjs= 9998e35772b2Smrg fi 9999e35772b2Smrg # Expand the library linking commands again to reset the 10000e35772b2Smrg # value of $libobjs for piecewise linking. 1000172b676d7Smrg 10002e35772b2Smrg # Do each of the archive commands. 1000321525869Smrg if test yes = "$module" && test -n "$module_cmds"; then 10004e35772b2Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10005e35772b2Smrg cmds=$module_expsym_cmds 10006e35772b2Smrg else 10007e35772b2Smrg cmds=$module_cmds 1000872b676d7Smrg fi 1000972b676d7Smrg else 10010e35772b2Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10011e35772b2Smrg cmds=$archive_expsym_cmds 10012e35772b2Smrg else 10013e35772b2Smrg cmds=$archive_cmds 10014e35772b2Smrg fi 1001572b676d7Smrg fi 10016e35772b2Smrg fi 1001772b676d7Smrg 10018e35772b2Smrg if test -n "$delfiles"; then 10019e35772b2Smrg # Append the command to remove temporary files to $cmds. 10020e35772b2Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10021e35772b2Smrg fi 1002272b676d7Smrg 10023e35772b2Smrg # Add any objects from preloaded convenience libraries 10024e35772b2Smrg if test -n "$dlprefiles"; then 1002521525869Smrg gentop=$output_objdir/${outputname}x 1002674c14cd6Smrg func_append generated " $gentop" 1002772b676d7Smrg 10028e35772b2Smrg func_extract_archives $gentop $dlprefiles 1002974c14cd6Smrg func_append libobjs " $func_extract_archives_result" 10030e35772b2Smrg test "X$libobjs" = "X " && libobjs= 10031e35772b2Smrg fi 1003272b676d7Smrg 1003321525869Smrg save_ifs=$IFS; IFS='~' 10034e35772b2Smrg for cmd in $cmds; do 1003521525869Smrg IFS=$sp$nl 10036e35772b2Smrg eval cmd=\"$cmd\" 1003721525869Smrg IFS=$save_ifs 1003821525869Smrg $opt_quiet || { 10039e35772b2Smrg func_quote_for_expand "$cmd" 10040e35772b2Smrg eval "func_echo $func_quote_for_expand_result" 10041e35772b2Smrg } 10042e35772b2Smrg $opt_dry_run || eval "$cmd" || { 10043e35772b2Smrg lt_exit=$? 1004472b676d7Smrg 10045e35772b2Smrg # Restore the uninstalled library and exit 1004621525869Smrg if test relink = "$opt_mode"; then 10047e35772b2Smrg ( cd "$output_objdir" && \ 10048e35772b2Smrg $RM "${realname}T" && \ 10049e35772b2Smrg $MV "${realname}U" "$realname" ) 10050e35772b2Smrg fi 1005172b676d7Smrg 10052e35772b2Smrg exit $lt_exit 10053e35772b2Smrg } 10054e35772b2Smrg done 1005521525869Smrg IFS=$save_ifs 1005672b676d7Smrg 10057e35772b2Smrg # Restore the uninstalled library and exit 1005821525869Smrg if test relink = "$opt_mode"; then 10059e35772b2Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1006072b676d7Smrg 10061e35772b2Smrg if test -n "$convenience"; then 10062e35772b2Smrg if test -z "$whole_archive_flag_spec"; then 10063e35772b2Smrg func_show_eval '${RM}r "$gentop"' 10064e35772b2Smrg fi 10065e35772b2Smrg fi 1006672b676d7Smrg 10067e35772b2Smrg exit $EXIT_SUCCESS 10068e35772b2Smrg fi 10069e35772b2Smrg 10070e35772b2Smrg # Create links to the real library. 10071e35772b2Smrg for linkname in $linknames; do 10072e35772b2Smrg if test "$realname" != "$linkname"; then 10073e35772b2Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1007472b676d7Smrg fi 1007572b676d7Smrg done 1007672b676d7Smrg 10077e35772b2Smrg # If -module or -export-dynamic was specified, set the dlname. 1007821525869Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10079e35772b2Smrg # On all known operating systems, these are identical. 1008021525869Smrg dlname=$soname 10081e35772b2Smrg fi 10082e35772b2Smrg fi 1008372b676d7Smrg ;; 1008472b676d7Smrg 10085e35772b2Smrg obj) 1008621525869Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1008721525869Smrg func_warning "'-dlopen' is ignored for objects" 10088e35772b2Smrg fi 1008972b676d7Smrg 10090e35772b2Smrg case " $deplibs" in 10091e35772b2Smrg *\ -l* | *\ -L*) 1009221525869Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 1009372b676d7Smrg esac 1009472b676d7Smrg 10095e35772b2Smrg test -n "$rpath" && \ 1009621525869Smrg func_warning "'-rpath' is ignored for objects" 10097e35772b2Smrg 10098e35772b2Smrg test -n "$xrpath" && \ 1009921525869Smrg func_warning "'-R' is ignored for objects" 1010072b676d7Smrg 10101e35772b2Smrg test -n "$vinfo" && \ 1010221525869Smrg func_warning "'-version-info' is ignored for objects" 1010372b676d7Smrg 10104e35772b2Smrg test -n "$release" && \ 1010521525869Smrg func_warning "'-release' is ignored for objects" 10106e35772b2Smrg 10107e35772b2Smrg case $output in 10108e35772b2Smrg *.lo) 10109e35772b2Smrg test -n "$objs$old_deplibs" && \ 1011021525869Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10111e35772b2Smrg 10112e35772b2Smrg libobj=$output 10113e35772b2Smrg func_lo2o "$libobj" 10114e35772b2Smrg obj=$func_lo2o_result 1011572b676d7Smrg ;; 1011672b676d7Smrg *) 10117e35772b2Smrg libobj= 1011821525869Smrg obj=$output 1011972b676d7Smrg ;; 1012072b676d7Smrg esac 1012172b676d7Smrg 10122e35772b2Smrg # Delete the old objects. 10123e35772b2Smrg $opt_dry_run || $RM $obj $libobj 1012472b676d7Smrg 10125e35772b2Smrg # Objects from convenience libraries. This assumes 10126e35772b2Smrg # single-version convenience libraries. Whenever we create 10127e35772b2Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10128e35772b2Smrg # the extraction. 10129e35772b2Smrg reload_conv_objs= 10130e35772b2Smrg gentop= 1013121525869Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 1013221525869Smrg # whole_archive_flag_spec and hope we can get by with turning comma 1013321525869Smrg # into space. 1013421525869Smrg case $reload_cmds in 1013521525869Smrg *\$LD[\ \$]*) wl= ;; 1013621525869Smrg esac 10137e35772b2Smrg if test -n "$convenience"; then 10138e35772b2Smrg if test -n "$whole_archive_flag_spec"; then 10139e35772b2Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1014021525869Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1014121525869Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10142e35772b2Smrg else 1014321525869Smrg gentop=$output_objdir/${obj}x 1014474c14cd6Smrg func_append generated " $gentop" 1014572b676d7Smrg 10146e35772b2Smrg func_extract_archives $gentop $convenience 10147e35772b2Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10148e35772b2Smrg fi 1014972b676d7Smrg fi 1015072b676d7Smrg 1015174c14cd6Smrg # If we're not building shared, we need to use non_pic_objs 1015221525869Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1015374c14cd6Smrg 10154e35772b2Smrg # Create the old-style object. 1015521525869Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 1015672b676d7Smrg 1015721525869Smrg output=$obj 10158e35772b2Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1015972b676d7Smrg 10160e35772b2Smrg # Exit if we aren't doing a library object file. 10161e35772b2Smrg if test -z "$libobj"; then 10162e35772b2Smrg if test -n "$gentop"; then 10163e35772b2Smrg func_show_eval '${RM}r "$gentop"' 10164e35772b2Smrg fi 10165e35772b2Smrg 10166e35772b2Smrg exit $EXIT_SUCCESS 1016772b676d7Smrg fi 10168e35772b2Smrg 1016921525869Smrg test yes = "$build_libtool_libs" || { 10170e35772b2Smrg if test -n "$gentop"; then 10171e35772b2Smrg func_show_eval '${RM}r "$gentop"' 10172e35772b2Smrg fi 10173e35772b2Smrg 10174e35772b2Smrg # Create an invalid libtool object if no PIC, so that we don't 10175e35772b2Smrg # accidentally link it into a program. 10176e35772b2Smrg # $show "echo timestamp > $libobj" 10177e35772b2Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10178e35772b2Smrg exit $EXIT_SUCCESS 1017921525869Smrg } 10180e35772b2Smrg 1018121525869Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10182e35772b2Smrg # Only do commands if we really have different PIC objects. 10183e35772b2Smrg reload_objs="$libobjs $reload_conv_objs" 1018421525869Smrg output=$libobj 10185e35772b2Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10186e35772b2Smrg fi 10187e35772b2Smrg 10188e35772b2Smrg if test -n "$gentop"; then 10189e35772b2Smrg func_show_eval '${RM}r "$gentop"' 10190e35772b2Smrg fi 10191e35772b2Smrg 10192e35772b2Smrg exit $EXIT_SUCCESS 1019372b676d7Smrg ;; 1019472b676d7Smrg 10195e35772b2Smrg prog) 10196e35772b2Smrg case $host in 10197e35772b2Smrg *cygwin*) func_stripname '' '.exe' "$output" 10198e35772b2Smrg output=$func_stripname_result.exe;; 10199e35772b2Smrg esac 10200e35772b2Smrg test -n "$vinfo" && \ 1020121525869Smrg func_warning "'-version-info' is ignored for programs" 1020272b676d7Smrg 10203e35772b2Smrg test -n "$release" && \ 1020421525869Smrg func_warning "'-release' is ignored for programs" 1020572b676d7Smrg 1020621525869Smrg $preload \ 1020721525869Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1020821525869Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10209e35772b2Smrg 10210e35772b2Smrg case $host in 10211e35772b2Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10212e35772b2Smrg # On Rhapsody replace the C library is the System framework 1021374c14cd6Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1021474c14cd6Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 1021572b676d7Smrg ;; 10216e35772b2Smrg esac 1021772b676d7Smrg 10218e35772b2Smrg case $host in 10219e35772b2Smrg *-*-darwin*) 10220e35772b2Smrg # Don't allow lazy linking, it breaks C++ global constructors 10221e35772b2Smrg # But is supposedly fixed on 10.4 or later (yay!). 1022221525869Smrg if test CXX = "$tagname"; then 10223e35772b2Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10224e35772b2Smrg 10.[0123]) 1022521525869Smrg func_append compile_command " $wl-bind_at_load" 1022621525869Smrg func_append finalize_command " $wl-bind_at_load" 10227e35772b2Smrg ;; 10228e35772b2Smrg esac 1022972b676d7Smrg fi 10230e35772b2Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1023174c14cd6Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1023274c14cd6Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10233e35772b2Smrg ;; 10234e35772b2Smrg esac 1023572b676d7Smrg 1023672b676d7Smrg 10237e35772b2Smrg # move library search paths that coincide with paths to not yet 10238e35772b2Smrg # installed libraries to the beginning of the library search list 10239e35772b2Smrg new_libs= 10240e35772b2Smrg for path in $notinst_path; do 10241e35772b2Smrg case " $new_libs " in 10242e35772b2Smrg *" -L$path/$objdir "*) ;; 10243e35772b2Smrg *) 10244e35772b2Smrg case " $compile_deplibs " in 10245e35772b2Smrg *" -L$path/$objdir "*) 1024674c14cd6Smrg func_append new_libs " -L$path/$objdir" ;; 1024772b676d7Smrg esac 10248e35772b2Smrg ;; 10249e35772b2Smrg esac 10250e35772b2Smrg done 10251e35772b2Smrg for deplib in $compile_deplibs; do 10252e35772b2Smrg case $deplib in 10253e35772b2Smrg -L*) 10254e35772b2Smrg case " $new_libs " in 10255e35772b2Smrg *" $deplib "*) ;; 1025674c14cd6Smrg *) func_append new_libs " $deplib" ;; 1025772b676d7Smrg esac 10258e35772b2Smrg ;; 1025974c14cd6Smrg *) func_append new_libs " $deplib" ;; 10260e35772b2Smrg esac 10261e35772b2Smrg done 1026221525869Smrg compile_deplibs=$new_libs 1026372b676d7Smrg 1026472b676d7Smrg 1026574c14cd6Smrg func_append compile_command " $compile_deplibs" 1026674c14cd6Smrg func_append finalize_command " $finalize_deplibs" 1026772b676d7Smrg 10268e35772b2Smrg if test -n "$rpath$xrpath"; then 10269e35772b2Smrg # If the user specified any rpath flags, then add them. 10270e35772b2Smrg for libdir in $rpath $xrpath; do 10271e35772b2Smrg # This is the magic to use -rpath. 10272e35772b2Smrg case "$finalize_rpath " in 10273e35772b2Smrg *" $libdir "*) ;; 1027474c14cd6Smrg *) func_append finalize_rpath " $libdir" ;; 10275e35772b2Smrg esac 10276e35772b2Smrg done 10277e35772b2Smrg fi 1027872b676d7Smrg 10279e35772b2Smrg # Now hardcode the library paths 10280e35772b2Smrg rpath= 10281e35772b2Smrg hardcode_libdirs= 10282e35772b2Smrg for libdir in $compile_rpath $finalize_rpath; do 10283e35772b2Smrg if test -n "$hardcode_libdir_flag_spec"; then 10284e35772b2Smrg if test -n "$hardcode_libdir_separator"; then 10285e35772b2Smrg if test -z "$hardcode_libdirs"; then 1028621525869Smrg hardcode_libdirs=$libdir 10287e35772b2Smrg else 10288e35772b2Smrg # Just accumulate the unique libdirs. 10289e35772b2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10290e35772b2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10291e35772b2Smrg ;; 10292e35772b2Smrg *) 1029374c14cd6Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10294e35772b2Smrg ;; 10295e35772b2Smrg esac 10296e35772b2Smrg fi 1029772b676d7Smrg else 10298e35772b2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1029974c14cd6Smrg func_append rpath " $flag" 1030072b676d7Smrg fi 10301e35772b2Smrg elif test -n "$runpath_var"; then 10302e35772b2Smrg case "$perm_rpath " in 10303e35772b2Smrg *" $libdir "*) ;; 1030474c14cd6Smrg *) func_append perm_rpath " $libdir" ;; 10305e35772b2Smrg esac 10306e35772b2Smrg fi 10307e35772b2Smrg case $host in 10308e35772b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030921525869Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10310e35772b2Smrg case :$dllsearchpath: in 10311e35772b2Smrg *":$libdir:"*) ;; 10312e35772b2Smrg ::) dllsearchpath=$libdir;; 1031374c14cd6Smrg *) func_append dllsearchpath ":$libdir";; 10314e35772b2Smrg esac 10315e35772b2Smrg case :$dllsearchpath: in 10316e35772b2Smrg *":$testbindir:"*) ;; 10317e35772b2Smrg ::) dllsearchpath=$testbindir;; 1031874c14cd6Smrg *) func_append dllsearchpath ":$testbindir";; 10319e35772b2Smrg esac 10320e35772b2Smrg ;; 10321e35772b2Smrg esac 10322e35772b2Smrg done 10323e35772b2Smrg # Substitute the hardcoded libdirs into the rpath. 10324e35772b2Smrg if test -n "$hardcode_libdir_separator" && 10325e35772b2Smrg test -n "$hardcode_libdirs"; then 1032621525869Smrg libdir=$hardcode_libdirs 10327e35772b2Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10328e35772b2Smrg fi 1032921525869Smrg compile_rpath=$rpath 1033072b676d7Smrg 10331e35772b2Smrg rpath= 10332e35772b2Smrg hardcode_libdirs= 10333e35772b2Smrg for libdir in $finalize_rpath; do 10334e35772b2Smrg if test -n "$hardcode_libdir_flag_spec"; then 10335e35772b2Smrg if test -n "$hardcode_libdir_separator"; then 10336e35772b2Smrg if test -z "$hardcode_libdirs"; then 1033721525869Smrg hardcode_libdirs=$libdir 10338e35772b2Smrg else 10339e35772b2Smrg # Just accumulate the unique libdirs. 10340e35772b2Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10341e35772b2Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10342e35772b2Smrg ;; 10343e35772b2Smrg *) 1034474c14cd6Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10345e35772b2Smrg ;; 10346e35772b2Smrg esac 10347e35772b2Smrg fi 1034872b676d7Smrg else 10349e35772b2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1035074c14cd6Smrg func_append rpath " $flag" 1035172b676d7Smrg fi 10352e35772b2Smrg elif test -n "$runpath_var"; then 10353e35772b2Smrg case "$finalize_perm_rpath " in 10354e35772b2Smrg *" $libdir "*) ;; 1035574c14cd6Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10356e35772b2Smrg esac 1035772b676d7Smrg fi 10358e35772b2Smrg done 10359e35772b2Smrg # Substitute the hardcoded libdirs into the rpath. 10360e35772b2Smrg if test -n "$hardcode_libdir_separator" && 10361e35772b2Smrg test -n "$hardcode_libdirs"; then 1036221525869Smrg libdir=$hardcode_libdirs 10363e35772b2Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10364e35772b2Smrg fi 1036521525869Smrg finalize_rpath=$rpath 1036672b676d7Smrg 1036721525869Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10368e35772b2Smrg # Transform all the library objects into standard objects. 1036974c14cd6Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1037074c14cd6Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10371e35772b2Smrg fi 1037272b676d7Smrg 1037321525869Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1037472b676d7Smrg 10375e35772b2Smrg # template prelinking step 10376e35772b2Smrg if test -n "$prelink_cmds"; then 10377e35772b2Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10378e35772b2Smrg fi 1037972b676d7Smrg 1038021525869Smrg wrappers_required=: 10381e35772b2Smrg case $host in 1038274c14cd6Smrg *cegcc* | *mingw32ce*) 1038374c14cd6Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1038421525869Smrg wrappers_required=false 1038574c14cd6Smrg ;; 10386e35772b2Smrg *cygwin* | *mingw* ) 1038721525869Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10388e35772b2Smrg ;; 10389e35772b2Smrg *) 1039021525869Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1039121525869Smrg wrappers_required=false 10392e35772b2Smrg fi 10393e35772b2Smrg ;; 10394e35772b2Smrg esac 1039521525869Smrg $wrappers_required || { 10396e35772b2Smrg # Replace the output file specification. 1039774c14cd6Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1039821525869Smrg link_command=$compile_command$compile_rpath 1039972b676d7Smrg 10400e35772b2Smrg # We have no uninstalled library dependencies, so finalize right now. 10401e35772b2Smrg exit_status=0 10402e35772b2Smrg func_show_eval "$link_command" 'exit_status=$?' 1040372b676d7Smrg 1040474c14cd6Smrg if test -n "$postlink_cmds"; then 1040574c14cd6Smrg func_to_tool_file "$output" 1040674c14cd6Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1040774c14cd6Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1040874c14cd6Smrg fi 1040974c14cd6Smrg 10410e35772b2Smrg # Delete the generated files. 1041121525869Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 1041221525869Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1041372b676d7Smrg fi 1041472b676d7Smrg 10415e35772b2Smrg exit $exit_status 1041621525869Smrg } 1041772b676d7Smrg 10418e35772b2Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10419e35772b2Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10420e35772b2Smrg fi 10421e35772b2Smrg if test -n "$finalize_shlibpath"; then 10422e35772b2Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10423e35772b2Smrg fi 1042472b676d7Smrg 10425e35772b2Smrg compile_var= 10426e35772b2Smrg finalize_var= 10427e35772b2Smrg if test -n "$runpath_var"; then 10428e35772b2Smrg if test -n "$perm_rpath"; then 10429e35772b2Smrg # We should set the runpath_var. 10430e35772b2Smrg rpath= 10431e35772b2Smrg for dir in $perm_rpath; do 1043274c14cd6Smrg func_append rpath "$dir:" 10433e35772b2Smrg done 10434e35772b2Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1043572b676d7Smrg fi 10436e35772b2Smrg if test -n "$finalize_perm_rpath"; then 10437e35772b2Smrg # We should set the runpath_var. 10438e35772b2Smrg rpath= 10439e35772b2Smrg for dir in $finalize_perm_rpath; do 1044074c14cd6Smrg func_append rpath "$dir:" 10441e35772b2Smrg done 10442e35772b2Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1044372b676d7Smrg fi 10444e35772b2Smrg fi 1044572b676d7Smrg 1044621525869Smrg if test yes = "$no_install"; then 10447e35772b2Smrg # We don't need to create a wrapper script. 1044821525869Smrg link_command=$compile_var$compile_command$compile_rpath 10449e35772b2Smrg # Replace the output file specification. 1045074c14cd6Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10451e35772b2Smrg # Delete the old output file. 10452e35772b2Smrg $opt_dry_run || $RM $output 10453e35772b2Smrg # Link the executable and exit 10454e35772b2Smrg func_show_eval "$link_command" 'exit $?' 1045574c14cd6Smrg 1045674c14cd6Smrg if test -n "$postlink_cmds"; then 1045774c14cd6Smrg func_to_tool_file "$output" 1045874c14cd6Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1045974c14cd6Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1046074c14cd6Smrg fi 1046174c14cd6Smrg 1046272b676d7Smrg exit $EXIT_SUCCESS 10463e35772b2Smrg fi 1046472b676d7Smrg 1046521525869Smrg case $hardcode_action,$fast_install in 1046621525869Smrg relink,*) 1046721525869Smrg # Fast installation is not supported 1046821525869Smrg link_command=$compile_var$compile_command$compile_rpath 1046921525869Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10470e35772b2Smrg 1047121525869Smrg func_warning "this platform does not like uninstalled shared libraries" 1047221525869Smrg func_warning "'$output' will be relinked during installation" 1047321525869Smrg ;; 1047421525869Smrg *,yes) 1047521525869Smrg link_command=$finalize_var$compile_command$finalize_rpath 1047621525869Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1047721525869Smrg ;; 1047821525869Smrg *,no) 1047921525869Smrg link_command=$compile_var$compile_command$compile_rpath 1048021525869Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1048121525869Smrg ;; 1048221525869Smrg *,needless) 1048321525869Smrg link_command=$finalize_var$compile_command$finalize_rpath 1048421525869Smrg relink_command= 1048521525869Smrg ;; 1048621525869Smrg esac 1048772b676d7Smrg 10488e35772b2Smrg # Replace the output file specification. 1048974c14cd6Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1049072b676d7Smrg 10491e35772b2Smrg # Delete the old output files. 10492e35772b2Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1049372b676d7Smrg 10494e35772b2Smrg func_show_eval "$link_command" 'exit $?' 1049572b676d7Smrg 1049674c14cd6Smrg if test -n "$postlink_cmds"; then 1049774c14cd6Smrg func_to_tool_file "$output_objdir/$outputname" 1049874c14cd6Smrg 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'` 1049974c14cd6Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1050074c14cd6Smrg fi 1050174c14cd6Smrg 10502e35772b2Smrg # Now create the wrapper script. 10503e35772b2Smrg func_verbose "creating $output" 1050472b676d7Smrg 10505e35772b2Smrg # Quote the relink command for shipping. 10506e35772b2Smrg if test -n "$relink_command"; then 10507e35772b2Smrg # Preserve any variables that may affect compiler behavior 10508e35772b2Smrg for var in $variables_saved_for_relink; do 10509e35772b2Smrg if eval test -z \"\${$var+set}\"; then 10510e35772b2Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10511e35772b2Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10512e35772b2Smrg relink_command="$var=; export $var; $relink_command" 1051372b676d7Smrg else 10514e35772b2Smrg func_quote_for_eval "$var_value" 10515e35772b2Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1051672b676d7Smrg fi 10517e35772b2Smrg done 10518e35772b2Smrg relink_command="(cd `pwd`; $relink_command)" 1051974c14cd6Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10520e35772b2Smrg fi 10521e35772b2Smrg 10522e35772b2Smrg # Only actually do things if not in dry run mode. 10523e35772b2Smrg $opt_dry_run || { 10524e35772b2Smrg # win32 will think the script is a binary if it has 10525e35772b2Smrg # a .exe suffix, so we strip it off here. 10526e35772b2Smrg case $output in 10527e35772b2Smrg *.exe) func_stripname '' '.exe' "$output" 10528e35772b2Smrg output=$func_stripname_result ;; 10529e35772b2Smrg esac 10530e35772b2Smrg # test for cygwin because mv fails w/o .exe extensions 10531e35772b2Smrg case $host in 10532e35772b2Smrg *cygwin*) 10533e35772b2Smrg exeext=.exe 10534e35772b2Smrg func_stripname '' '.exe' "$outputname" 10535e35772b2Smrg outputname=$func_stripname_result ;; 10536e35772b2Smrg *) exeext= ;; 1053772b676d7Smrg esac 10538e35772b2Smrg case $host in 10539e35772b2Smrg *cygwin* | *mingw* ) 10540e35772b2Smrg func_dirname_and_basename "$output" "" "." 10541e35772b2Smrg output_name=$func_basename_result 10542e35772b2Smrg output_path=$func_dirname_result 1054321525869Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1054421525869Smrg cwrapper=$output_path/$output_name.exe 10545e35772b2Smrg $RM $cwrappersource $cwrapper 10546e35772b2Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10547e35772b2Smrg 10548e35772b2Smrg func_emit_cwrapperexe_src > $cwrappersource 10549e35772b2Smrg 10550e35772b2Smrg # The wrapper executable is built using the $host compiler, 10551e35772b2Smrg # because it contains $host paths and files. If cross- 10552e35772b2Smrg # compiling, it, like the target executable, must be 10553e35772b2Smrg # executed on the $host or under an emulation environment. 10554e35772b2Smrg $opt_dry_run || { 10555e35772b2Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10556e35772b2Smrg $STRIP $cwrapper 10557e35772b2Smrg } 1055872b676d7Smrg 10559e35772b2Smrg # Now, create the wrapper script for func_source use: 10560e35772b2Smrg func_ltwrapper_scriptname $cwrapper 10561e35772b2Smrg $RM $func_ltwrapper_scriptname_result 10562e35772b2Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10563e35772b2Smrg $opt_dry_run || { 10564e35772b2Smrg # note: this script will not be executed, so do not chmod. 1056521525869Smrg if test "x$build" = "x$host"; then 10566e35772b2Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10567e35772b2Smrg else 10568e35772b2Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10569e35772b2Smrg fi 10570e35772b2Smrg } 10571e35772b2Smrg ;; 10572e35772b2Smrg * ) 10573e35772b2Smrg $RM $output 10574e35772b2Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1057572b676d7Smrg 10576e35772b2Smrg func_emit_wrapper no > $output 10577e35772b2Smrg chmod +x $output 10578e35772b2Smrg ;; 10579e35772b2Smrg esac 10580e35772b2Smrg } 10581e35772b2Smrg exit $EXIT_SUCCESS 10582e35772b2Smrg ;; 10583e35772b2Smrg esac 1058472b676d7Smrg 10585e35772b2Smrg # See if we need to build an old-fashioned archive. 10586e35772b2Smrg for oldlib in $oldlibs; do 1058772b676d7Smrg 1058821525869Smrg case $build_libtool_libs in 1058921525869Smrg convenience) 1059021525869Smrg oldobjs="$libobjs_save $symfileobj" 1059121525869Smrg addlibs=$convenience 10592e35772b2Smrg build_libtool_libs=no 1059321525869Smrg ;; 1059421525869Smrg module) 1059521525869Smrg oldobjs=$libobjs_save 1059621525869Smrg addlibs=$old_convenience 1059721525869Smrg build_libtool_libs=no 1059821525869Smrg ;; 1059921525869Smrg *) 10600e35772b2Smrg oldobjs="$old_deplibs $non_pic_objects" 1060121525869Smrg $preload && test -f "$symfileobj" \ 1060221525869Smrg && func_append oldobjs " $symfileobj" 1060321525869Smrg addlibs=$old_convenience 1060421525869Smrg ;; 1060521525869Smrg esac 1060672b676d7Smrg 10607e35772b2Smrg if test -n "$addlibs"; then 1060821525869Smrg gentop=$output_objdir/${outputname}x 1060974c14cd6Smrg func_append generated " $gentop" 1061072b676d7Smrg 10611e35772b2Smrg func_extract_archives $gentop $addlibs 1061274c14cd6Smrg func_append oldobjs " $func_extract_archives_result" 10613e35772b2Smrg fi 1061472b676d7Smrg 10615e35772b2Smrg # Do each command in the archive commands. 1061621525869Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10617e35772b2Smrg cmds=$old_archive_from_new_cmds 10618e35772b2Smrg else 1061972b676d7Smrg 10620e35772b2Smrg # Add any objects from preloaded convenience libraries 10621e35772b2Smrg if test -n "$dlprefiles"; then 1062221525869Smrg gentop=$output_objdir/${outputname}x 1062374c14cd6Smrg func_append generated " $gentop" 1062472b676d7Smrg 10625e35772b2Smrg func_extract_archives $gentop $dlprefiles 1062674c14cd6Smrg func_append oldobjs " $func_extract_archives_result" 10627e35772b2Smrg fi 1062872b676d7Smrg 10629e35772b2Smrg # POSIX demands no paths to be encoded in archives. We have 10630e35772b2Smrg # to avoid creating archives with duplicate basenames if we 10631e35772b2Smrg # might have to extract them afterwards, e.g., when creating a 10632e35772b2Smrg # static archive out of a convenience library, or when linking 10633e35772b2Smrg # the entirety of a libtool archive into another (currently 10634e35772b2Smrg # not supported by libtool). 10635e35772b2Smrg if (for obj in $oldobjs 10636e35772b2Smrg do 10637e35772b2Smrg func_basename "$obj" 10638e35772b2Smrg $ECHO "$func_basename_result" 10639e35772b2Smrg done | sort | sort -uc >/dev/null 2>&1); then 10640e35772b2Smrg : 10641e35772b2Smrg else 1064274c14cd6Smrg echo "copying selected object files to avoid basename conflicts..." 1064321525869Smrg gentop=$output_objdir/${outputname}x 1064474c14cd6Smrg func_append generated " $gentop" 10645e35772b2Smrg func_mkdir_p "$gentop" 10646e35772b2Smrg save_oldobjs=$oldobjs 10647e35772b2Smrg oldobjs= 10648e35772b2Smrg counter=1 10649e35772b2Smrg for obj in $save_oldobjs 10650e35772b2Smrg do 10651e35772b2Smrg func_basename "$obj" 1065221525869Smrg objbase=$func_basename_result 10653e35772b2Smrg case " $oldobjs " in 10654e35772b2Smrg " ") oldobjs=$obj ;; 10655e35772b2Smrg *[\ /]"$objbase "*) 10656e35772b2Smrg while :; do 10657e35772b2Smrg # Make sure we don't pick an alternate name that also 10658e35772b2Smrg # overlaps. 10659e35772b2Smrg newobj=lt$counter-$objbase 10660e35772b2Smrg func_arith $counter + 1 10661e35772b2Smrg counter=$func_arith_result 10662e35772b2Smrg case " $oldobjs " in 10663e35772b2Smrg *[\ /]"$newobj "*) ;; 10664e35772b2Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10665e35772b2Smrg esac 10666e35772b2Smrg done 10667e35772b2Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1066874c14cd6Smrg func_append oldobjs " $gentop/$newobj" 10669e35772b2Smrg ;; 1067074c14cd6Smrg *) func_append oldobjs " $obj" ;; 10671e35772b2Smrg esac 1067272b676d7Smrg done 1067372b676d7Smrg fi 1067474c14cd6Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1067574c14cd6Smrg tool_oldlib=$func_to_tool_file_result 10676e35772b2Smrg eval cmds=\"$old_archive_cmds\" 1067772b676d7Smrg 10678e35772b2Smrg func_len " $cmds" 10679e35772b2Smrg len=$func_len_result 10680e35772b2Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10681e35772b2Smrg cmds=$old_archive_cmds 1068274c14cd6Smrg elif test -n "$archiver_list_spec"; then 1068374c14cd6Smrg func_verbose "using command file archive linking..." 1068474c14cd6Smrg for obj in $oldobjs 1068574c14cd6Smrg do 1068674c14cd6Smrg func_to_tool_file "$obj" 1068774c14cd6Smrg $ECHO "$func_to_tool_file_result" 1068874c14cd6Smrg done > $output_objdir/$libname.libcmd 1068974c14cd6Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1069074c14cd6Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1069174c14cd6Smrg cmds=$old_archive_cmds 10692e35772b2Smrg else 10693e35772b2Smrg # the command line is too long to link in one step, link in parts 10694e35772b2Smrg func_verbose "using piecewise archive linking..." 10695e35772b2Smrg save_RANLIB=$RANLIB 10696e35772b2Smrg RANLIB=: 10697e35772b2Smrg objlist= 10698e35772b2Smrg concat_cmds= 10699e35772b2Smrg save_oldobjs=$oldobjs 10700e35772b2Smrg oldobjs= 10701e35772b2Smrg # Is there a better way of finding the last object in the list? 10702e35772b2Smrg for obj in $save_oldobjs 10703e35772b2Smrg do 10704e35772b2Smrg last_oldobj=$obj 10705e35772b2Smrg done 10706e35772b2Smrg eval test_cmds=\"$old_archive_cmds\" 10707e35772b2Smrg func_len " $test_cmds" 10708e35772b2Smrg len0=$func_len_result 10709e35772b2Smrg len=$len0 10710e35772b2Smrg for obj in $save_oldobjs 10711e35772b2Smrg do 10712e35772b2Smrg func_len " $obj" 10713e35772b2Smrg func_arith $len + $func_len_result 10714e35772b2Smrg len=$func_arith_result 10715e35772b2Smrg func_append objlist " $obj" 10716e35772b2Smrg if test "$len" -lt "$max_cmd_len"; then 10717e35772b2Smrg : 10718e35772b2Smrg else 10719e35772b2Smrg # the above command should be used before it gets too long 10720e35772b2Smrg oldobjs=$objlist 1072121525869Smrg if test "$obj" = "$last_oldobj"; then 10722e35772b2Smrg RANLIB=$save_RANLIB 10723e35772b2Smrg fi 10724e35772b2Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1072521525869Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10726e35772b2Smrg objlist= 10727e35772b2Smrg len=$len0 10728e35772b2Smrg fi 10729e35772b2Smrg done 10730e35772b2Smrg RANLIB=$save_RANLIB 10731e35772b2Smrg oldobjs=$objlist 1073221525869Smrg if test -z "$oldobjs"; then 10733e35772b2Smrg eval cmds=\"\$concat_cmds\" 10734e35772b2Smrg else 10735e35772b2Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10736e35772b2Smrg fi 10737e35772b2Smrg fi 10738e35772b2Smrg fi 10739e35772b2Smrg func_execute_cmds "$cmds" 'exit $?' 1074072b676d7Smrg done 1074172b676d7Smrg 10742e35772b2Smrg test -n "$generated" && \ 10743e35772b2Smrg func_show_eval "${RM}r$generated" 1074472b676d7Smrg 10745e35772b2Smrg # Now create the libtool archive. 10746e35772b2Smrg case $output in 10747e35772b2Smrg *.la) 10748e35772b2Smrg old_library= 1074921525869Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 10750e35772b2Smrg func_verbose "creating $output" 1075172b676d7Smrg 10752e35772b2Smrg # Preserve any variables that may affect compiler behavior 10753e35772b2Smrg for var in $variables_saved_for_relink; do 10754e35772b2Smrg if eval test -z \"\${$var+set}\"; then 10755e35772b2Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10756e35772b2Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10757e35772b2Smrg relink_command="$var=; export $var; $relink_command" 1075872b676d7Smrg else 10759e35772b2Smrg func_quote_for_eval "$var_value" 10760e35772b2Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1076172b676d7Smrg fi 10762e35772b2Smrg done 10763e35772b2Smrg # Quote the link command for shipping. 1076421525869Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1076574c14cd6Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1076621525869Smrg if test yes = "$hardcode_automatic"; then 10767e35772b2Smrg relink_command= 10768e35772b2Smrg fi 1076972b676d7Smrg 10770e35772b2Smrg # Only create the output if not a dry run. 10771e35772b2Smrg $opt_dry_run || { 10772e35772b2Smrg for installed in no yes; do 1077321525869Smrg if test yes = "$installed"; then 10774e35772b2Smrg if test -z "$install_libdir"; then 10775e35772b2Smrg break 10776e35772b2Smrg fi 1077721525869Smrg output=$output_objdir/${outputname}i 10778e35772b2Smrg # Replace all uninstalled libtool libraries with the installed ones 10779e35772b2Smrg newdependency_libs= 10780e35772b2Smrg for deplib in $dependency_libs; do 10781e35772b2Smrg case $deplib in 10782e35772b2Smrg *.la) 10783e35772b2Smrg func_basename "$deplib" 1078421525869Smrg name=$func_basename_result 1078574c14cd6Smrg func_resolve_sysroot "$deplib" 1078621525869Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10787e35772b2Smrg test -z "$libdir" && \ 1078821525869Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 1078974c14cd6Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1079074c14cd6Smrg ;; 1079174c14cd6Smrg -L*) 1079274c14cd6Smrg func_stripname -L '' "$deplib" 1079374c14cd6Smrg func_replace_sysroot "$func_stripname_result" 1079474c14cd6Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10795e35772b2Smrg ;; 1079674c14cd6Smrg -R*) 1079774c14cd6Smrg func_stripname -R '' "$deplib" 1079874c14cd6Smrg func_replace_sysroot "$func_stripname_result" 1079974c14cd6Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1080074c14cd6Smrg ;; 1080174c14cd6Smrg *) func_append newdependency_libs " $deplib" ;; 10802e35772b2Smrg esac 10803e35772b2Smrg done 1080421525869Smrg dependency_libs=$newdependency_libs 10805e35772b2Smrg newdlfiles= 10806e35772b2Smrg 10807e35772b2Smrg for lib in $dlfiles; do 10808e35772b2Smrg case $lib in 10809e35772b2Smrg *.la) 10810e35772b2Smrg func_basename "$lib" 1081121525869Smrg name=$func_basename_result 1081221525869Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10813e35772b2Smrg test -z "$libdir" && \ 1081421525869Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1081574c14cd6Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10816e35772b2Smrg ;; 1081774c14cd6Smrg *) func_append newdlfiles " $lib" ;; 10818e35772b2Smrg esac 10819e35772b2Smrg done 1082021525869Smrg dlfiles=$newdlfiles 10821e35772b2Smrg newdlprefiles= 10822e35772b2Smrg for lib in $dlprefiles; do 10823e35772b2Smrg case $lib in 10824e35772b2Smrg *.la) 10825e35772b2Smrg # Only pass preopened files to the pseudo-archive (for 10826e35772b2Smrg # eventual linking with the app. that links it) if we 10827e35772b2Smrg # didn't already link the preopened objects directly into 10828e35772b2Smrg # the library: 10829e35772b2Smrg func_basename "$lib" 1083021525869Smrg name=$func_basename_result 1083121525869Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10832e35772b2Smrg test -z "$libdir" && \ 1083321525869Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1083474c14cd6Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10835e35772b2Smrg ;; 10836e35772b2Smrg esac 10837e35772b2Smrg done 1083821525869Smrg dlprefiles=$newdlprefiles 10839e35772b2Smrg else 10840e35772b2Smrg newdlfiles= 10841e35772b2Smrg for lib in $dlfiles; do 10842e35772b2Smrg case $lib in 1084321525869Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844e35772b2Smrg *) abs=`pwd`"/$lib" ;; 10845e35772b2Smrg esac 1084674c14cd6Smrg func_append newdlfiles " $abs" 10847e35772b2Smrg done 1084821525869Smrg dlfiles=$newdlfiles 10849e35772b2Smrg newdlprefiles= 10850e35772b2Smrg for lib in $dlprefiles; do 10851e35772b2Smrg case $lib in 1085221525869Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10853e35772b2Smrg *) abs=`pwd`"/$lib" ;; 10854e35772b2Smrg esac 1085574c14cd6Smrg func_append newdlprefiles " $abs" 10856e35772b2Smrg done 1085721525869Smrg dlprefiles=$newdlprefiles 10858e35772b2Smrg fi 10859e35772b2Smrg $RM $output 10860e35772b2Smrg # place dlname in correct position for cygwin 1086174c14cd6Smrg # In fact, it would be nice if we could use this code for all target 1086274c14cd6Smrg # systems that can't hard-code library paths into their executables 1086374c14cd6Smrg # and that have no shared library path variable independent of PATH, 1086474c14cd6Smrg # but it turns out we can't easily determine that from inspecting 1086574c14cd6Smrg # libtool variables, so we have to hard-code the OSs to which it 1086674c14cd6Smrg # applies here; at the moment, that means platforms that use the PE 1086774c14cd6Smrg # object format with DLL files. See the long comment at the top of 1086874c14cd6Smrg # tests/bindir.at for full details. 10869e35772b2Smrg tdlname=$dlname 10870e35772b2Smrg case $host,$output,$installed,$module,$dlname in 1087174c14cd6Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1087274c14cd6Smrg # If a -bindir argument was supplied, place the dll there. 1087321525869Smrg if test -n "$bindir"; then 1087474c14cd6Smrg func_relative_path "$install_libdir" "$bindir" 1087521525869Smrg tdlname=$func_relative_path_result/$dlname 1087674c14cd6Smrg else 1087774c14cd6Smrg # Otherwise fall back on heuristic. 1087874c14cd6Smrg tdlname=../bin/$dlname 1087974c14cd6Smrg fi 1088074c14cd6Smrg ;; 10881e35772b2Smrg esac 10882e35772b2Smrg $ECHO > $output "\ 10883e35772b2Smrg# $outputname - a libtool library file 1088421525869Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10885e35772b2Smrg# 10886e35772b2Smrg# Please DO NOT delete this file! 10887e35772b2Smrg# It is necessary for linking the library. 1088872b676d7Smrg 10889e35772b2Smrg# The name that we can dlopen(3). 10890e35772b2Smrgdlname='$tdlname' 1089172b676d7Smrg 10892e35772b2Smrg# Names of this library. 10893e35772b2Smrglibrary_names='$library_names' 1089472b676d7Smrg 10895e35772b2Smrg# The name of the static archive. 10896e35772b2Smrgold_library='$old_library' 1089772b676d7Smrg 1089821525869Smrg# Linker flags that cannot go in dependency_libs. 10899e35772b2Smrginherited_linker_flags='$new_inherited_linker_flags' 1090072b676d7Smrg 10901e35772b2Smrg# Libraries that this one depends upon. 10902e35772b2Smrgdependency_libs='$dependency_libs' 1090372b676d7Smrg 10904e35772b2Smrg# Names of additional weak libraries provided by this library 10905e35772b2Smrgweak_library_names='$weak_libs' 1090672b676d7Smrg 10907e35772b2Smrg# Version information for $libname. 10908e35772b2Smrgcurrent=$current 10909e35772b2Smrgage=$age 10910e35772b2Smrgrevision=$revision 1091172b676d7Smrg 10912e35772b2Smrg# Is this an already installed library? 10913e35772b2Smrginstalled=$installed 1091472b676d7Smrg 10915e35772b2Smrg# Should we warn about portability when linking against -modules? 10916e35772b2Smrgshouldnotlink=$module 1091772b676d7Smrg 10918e35772b2Smrg# Files to dlopen/dlpreopen 10919e35772b2Smrgdlopen='$dlfiles' 10920e35772b2Smrgdlpreopen='$dlprefiles' 1092172b676d7Smrg 10922e35772b2Smrg# Directory that this library needs to be installed in: 10923e35772b2Smrglibdir='$install_libdir'" 1092421525869Smrg if test no,yes = "$installed,$need_relink"; then 10925e35772b2Smrg $ECHO >> $output "\ 10926e35772b2Smrgrelink_command=\"$relink_command\"" 10927e35772b2Smrg fi 10928e35772b2Smrg done 10929e35772b2Smrg } 1093072b676d7Smrg 10931e35772b2Smrg # Do a symbolic link so that the libtool archive can be found in 10932e35772b2Smrg # LD_LIBRARY_PATH before the program is installed. 10933e35772b2Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10934e35772b2Smrg ;; 10935e35772b2Smrg esac 10936e35772b2Smrg exit $EXIT_SUCCESS 10937e35772b2Smrg} 1093872b676d7Smrg 1093921525869Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1094021525869Smrg func_mode_link ${1+"$@"} 1094121525869Smrgfi 1094272b676d7Smrg 1094372b676d7Smrg 10944e35772b2Smrg# func_mode_uninstall arg... 10945e35772b2Smrgfunc_mode_uninstall () 10946e35772b2Smrg{ 1094721525869Smrg $debug_cmd 1094821525869Smrg 1094921525869Smrg RM=$nonopt 1095072b676d7Smrg files= 1095121525869Smrg rmforce=false 1095272b676d7Smrg exit_status=0 1095372b676d7Smrg 1095472b676d7Smrg # This variable tells wrapper scripts just to set variables rather 1095572b676d7Smrg # than running their programs. 1095621525869Smrg libtool_install_magic=$magic 1095772b676d7Smrg 1095872b676d7Smrg for arg 1095972b676d7Smrg do 1096072b676d7Smrg case $arg in 1096121525869Smrg -f) func_append RM " $arg"; rmforce=: ;; 1096274c14cd6Smrg -*) func_append RM " $arg" ;; 1096374c14cd6Smrg *) func_append files " $arg" ;; 1096472b676d7Smrg esac 1096572b676d7Smrg done 1096672b676d7Smrg 10967e35772b2Smrg test -z "$RM" && \ 10968e35772b2Smrg func_fatal_help "you must specify an RM program" 1096972b676d7Smrg 1097072b676d7Smrg rmdirs= 1097172b676d7Smrg 1097272b676d7Smrg for file in $files; do 10973e35772b2Smrg func_dirname "$file" "" "." 1097421525869Smrg dir=$func_dirname_result 1097521525869Smrg if test . = "$dir"; then 1097621525869Smrg odir=$objdir 1097772b676d7Smrg else 1097821525869Smrg odir=$dir/$objdir 1097972b676d7Smrg fi 10980e35772b2Smrg func_basename "$file" 1098121525869Smrg name=$func_basename_result 1098221525869Smrg test uninstall = "$opt_mode" && odir=$dir 1098372b676d7Smrg 1098474c14cd6Smrg # Remember odir for removal later, being careful to avoid duplicates 1098521525869Smrg if test clean = "$opt_mode"; then 1098672b676d7Smrg case " $rmdirs " in 1098774c14cd6Smrg *" $odir "*) ;; 1098874c14cd6Smrg *) func_append rmdirs " $odir" ;; 1098972b676d7Smrg esac 1099072b676d7Smrg fi 1099172b676d7Smrg 1099272b676d7Smrg # Don't error if the file doesn't exist and rm -f was used. 10993e35772b2Smrg if { test -L "$file"; } >/dev/null 2>&1 || 10994e35772b2Smrg { test -h "$file"; } >/dev/null 2>&1 || 10995e35772b2Smrg test -f "$file"; then 1099672b676d7Smrg : 1099772b676d7Smrg elif test -d "$file"; then 1099872b676d7Smrg exit_status=1 1099972b676d7Smrg continue 1100021525869Smrg elif $rmforce; then 1100172b676d7Smrg continue 1100272b676d7Smrg fi 1100372b676d7Smrg 1100421525869Smrg rmfiles=$file 1100572b676d7Smrg 1100672b676d7Smrg case $name in 1100772b676d7Smrg *.la) 1100872b676d7Smrg # Possibly a libtool archive, so verify it. 11009e35772b2Smrg if func_lalib_p "$file"; then 11010e35772b2Smrg func_source $dir/$name 1101172b676d7Smrg 1101272b676d7Smrg # Delete the libtool libraries and symlinks. 1101372b676d7Smrg for n in $library_names; do 1101474c14cd6Smrg func_append rmfiles " $odir/$n" 1101572b676d7Smrg done 1101674c14cd6Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1101772b676d7Smrg 1101821525869Smrg case $opt_mode in 1101972b676d7Smrg clean) 1102074c14cd6Smrg case " $library_names " in 1102172b676d7Smrg *" $dlname "*) ;; 1102274c14cd6Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1102372b676d7Smrg esac 1102474c14cd6Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1102572b676d7Smrg ;; 1102672b676d7Smrg uninstall) 1102772b676d7Smrg if test -n "$library_names"; then 1102872b676d7Smrg # Do each command in the postuninstall commands. 1102921525869Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1103072b676d7Smrg fi 1103172b676d7Smrg 1103272b676d7Smrg if test -n "$old_library"; then 1103372b676d7Smrg # Do each command in the old_postuninstall commands. 1103421525869Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1103572b676d7Smrg fi 1103672b676d7Smrg # FIXME: should reinstall the best remaining shared library. 1103772b676d7Smrg ;; 1103872b676d7Smrg esac 1103972b676d7Smrg fi 1104072b676d7Smrg ;; 1104172b676d7Smrg 1104272b676d7Smrg *.lo) 1104372b676d7Smrg # Possibly a libtool object, so verify it. 11044e35772b2Smrg if func_lalib_p "$file"; then 1104572b676d7Smrg 1104672b676d7Smrg # Read the .lo file 11047e35772b2Smrg func_source $dir/$name 1104872b676d7Smrg 1104972b676d7Smrg # Add PIC object to the list of files to remove. 1105021525869Smrg if test -n "$pic_object" && test none != "$pic_object"; then 1105174c14cd6Smrg func_append rmfiles " $dir/$pic_object" 1105272b676d7Smrg fi 1105372b676d7Smrg 1105472b676d7Smrg # Add non-PIC object to the list of files to remove. 1105521525869Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1105674c14cd6Smrg func_append rmfiles " $dir/$non_pic_object" 1105772b676d7Smrg fi 1105872b676d7Smrg fi 1105972b676d7Smrg ;; 1106072b676d7Smrg 1106172b676d7Smrg *) 1106221525869Smrg if test clean = "$opt_mode"; then 1106372b676d7Smrg noexename=$name 1106472b676d7Smrg case $file in 1106572b676d7Smrg *.exe) 11066e35772b2Smrg func_stripname '' '.exe' "$file" 11067e35772b2Smrg file=$func_stripname_result 11068e35772b2Smrg func_stripname '' '.exe' "$name" 11069e35772b2Smrg noexename=$func_stripname_result 1107072b676d7Smrg # $file with .exe has already been added to rmfiles, 1107172b676d7Smrg # add $file without .exe 1107274c14cd6Smrg func_append rmfiles " $file" 1107372b676d7Smrg ;; 1107472b676d7Smrg esac 1107572b676d7Smrg # Do a test to see if this is a libtool program. 11076e35772b2Smrg if func_ltwrapper_p "$file"; then 11077e35772b2Smrg if func_ltwrapper_executable_p "$file"; then 11078e35772b2Smrg func_ltwrapper_scriptname "$file" 11079e35772b2Smrg relink_command= 11080e35772b2Smrg func_source $func_ltwrapper_scriptname_result 1108174c14cd6Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11082e35772b2Smrg else 11083e35772b2Smrg relink_command= 11084e35772b2Smrg func_source $dir/$noexename 11085e35772b2Smrg fi 1108672b676d7Smrg 1108772b676d7Smrg # note $name still contains .exe if it was in $file originally 1108872b676d7Smrg # as does the version of $file that was added into $rmfiles 1108921525869Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1109021525869Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 1109174c14cd6Smrg func_append rmfiles " $odir/lt-$name" 1109272b676d7Smrg fi 1109321525869Smrg if test "X$noexename" != "X$name"; then 1109421525869Smrg func_append rmfiles " $odir/lt-$noexename.c" 1109572b676d7Smrg fi 1109672b676d7Smrg fi 1109772b676d7Smrg fi 1109872b676d7Smrg ;; 1109972b676d7Smrg esac 11100e35772b2Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1110172b676d7Smrg done 1110272b676d7Smrg 1110321525869Smrg # Try to remove the $objdir's in the directories where we deleted files 1110472b676d7Smrg for dir in $rmdirs; do 1110572b676d7Smrg if test -d "$dir"; then 11106e35772b2Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1110772b676d7Smrg fi 1110872b676d7Smrg done 1110972b676d7Smrg 1111072b676d7Smrg exit $exit_status 11111e35772b2Smrg} 1111272b676d7Smrg 1111321525869Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1111421525869Smrg func_mode_uninstall ${1+"$@"} 1111521525869Smrgfi 1111672b676d7Smrg 1111774c14cd6Smrgtest -z "$opt_mode" && { 1111821525869Smrg help=$generic_help 11119e35772b2Smrg func_fatal_help "you must specify a MODE" 11120e35772b2Smrg} 11121e35772b2Smrg 11122e35772b2Smrgtest -z "$exec_cmd" && \ 1112321525869Smrg func_fatal_help "invalid operation mode '$opt_mode'" 1112472b676d7Smrg 1112572b676d7Smrgif test -n "$exec_cmd"; then 11126e35772b2Smrg eval exec "$exec_cmd" 1112772b676d7Smrg exit $EXIT_FAILURE 1112872b676d7Smrgfi 1112972b676d7Smrg 11130e35772b2Smrgexit $exit_status 1113172b676d7Smrg 1113272b676d7Smrg 1113372b676d7Smrg# The TAGs below are defined such that we never get into a situation 1113421525869Smrg# where we disable both kinds of libraries. Given conflicting 1113572b676d7Smrg# choices, we go for a static library, that is the most portable, 1113672b676d7Smrg# since we can't tell whether shared libraries were disabled because 1113772b676d7Smrg# the user asked for that or because the platform doesn't support 1113872b676d7Smrg# them. This is particularly important on AIX, because we don't 1113972b676d7Smrg# support having both static and shared libraries enabled at the same 1114072b676d7Smrg# time on that platform, so we default to a shared-only configuration. 1114172b676d7Smrg# If a disable-shared tag is given, we'll fallback to a static-only 1114272b676d7Smrg# configuration. But we'll never go from static-only to shared-only. 1114372b676d7Smrg 1114472b676d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11145e35772b2Smrgbuild_libtool_libs=no 11146e35772b2Smrgbuild_old_libs=yes 1114772b676d7Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 1114872b676d7Smrg 1114972b676d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11150e35772b2Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1115172b676d7Smrg# ### END LIBTOOL TAG CONFIG: disable-static 1115272b676d7Smrg 1115372b676d7Smrg# Local Variables: 1115472b676d7Smrg# mode:shell-script 1115572b676d7Smrg# sh-indentation:2 1115672b676d7Smrg# End: 11157