ltmain.sh revision d94624a0
197ee6427Smrg#! /bin/sh 297ee6427Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 397ee6427Smrg## by inline-source v2014-01-03.01 4213fdd94Smrg 597ee6427Smrg# libtool (GNU libtool) 2.4.6 697ee6427Smrg# Provide generalized library-building support services. 7213fdd94Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8213fdd94Smrg 997ee6427Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10213fdd94Smrg# This is free software; see the source for copying conditions. There is NO 11213fdd94Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12213fdd94Smrg 13213fdd94Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14301ea0f4Smrg# it under the terms of the GNU General Public License as published by 15301ea0f4Smrg# the Free Software Foundation; either version 2 of the License, or 16301ea0f4Smrg# (at your option) any later version. 17301ea0f4Smrg# 18213fdd94Smrg# As a special exception to the GNU General Public License, 19213fdd94Smrg# if you distribute this file as part of a program or library that 20213fdd94Smrg# is built using GNU Libtool, you may include this file under the 21213fdd94Smrg# same distribution terms that you use for the rest of that program. 22213fdd94Smrg# 23213fdd94Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24301ea0f4Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25301ea0f4Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26301ea0f4Smrg# General Public License for more details. 27301ea0f4Smrg# 28301ea0f4Smrg# You should have received a copy of the GNU General Public License 2997ee6427Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30ef6fb4a5Smrg 310cc67336Smrg 32213fdd94SmrgPROGRAM=libtool 330cc67336SmrgPACKAGE=libtool 34d94624a0SmrgVERSION="2.4.6 Debian-2.4.6-0.1" 3597ee6427Smrgpackage_revision=2.4.6 360cc67336Smrg 3797ee6427Smrg 3897ee6427Smrg## ------ ## 3997ee6427Smrg## Usage. ## 4097ee6427Smrg## ------ ## 4197ee6427Smrg 4297ee6427Smrg# Run './libtool --help' for help with using this script from the 4397ee6427Smrg# command line. 4497ee6427Smrg 4597ee6427Smrg 4697ee6427Smrg## ------------------------------- ## 4797ee6427Smrg## User overridable command paths. ## 4897ee6427Smrg## ------------------------------- ## 4997ee6427Smrg 5097ee6427Smrg# After configure completes, it has a better idea of some of the 5197ee6427Smrg# shell tools we need than the defaults used by the functions shared 5297ee6427Smrg# with bootstrap, so set those here where they can still be over- 5397ee6427Smrg# ridden by the user, but otherwise take precedence. 5497ee6427Smrg 5597ee6427Smrg: ${AUTOCONF="autoconf"} 5697ee6427Smrg: ${AUTOMAKE="automake"} 5797ee6427Smrg 5897ee6427Smrg 5997ee6427Smrg## -------------------------- ## 6097ee6427Smrg## Source external libraries. ## 6197ee6427Smrg## -------------------------- ## 6297ee6427Smrg 6397ee6427Smrg# Much of our low-level functionality needs to be sourced from external 6497ee6427Smrg# libraries, which are installed to $pkgauxdir. 6597ee6427Smrg 6697ee6427Smrg# Set a version string for this script. 6797ee6427Smrgscriptversion=2015-01-20.17; # UTC 6897ee6427Smrg 6997ee6427Smrg# General shell script boiler plate, and helper functions. 7097ee6427Smrg# Written by Gary V. Vaughan, 2004 7197ee6427Smrg 7297ee6427Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7397ee6427Smrg# This is free software; see the source for copying conditions. There is NO 7497ee6427Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7597ee6427Smrg 7697ee6427Smrg# This program is free software; you can redistribute it and/or modify 7797ee6427Smrg# it under the terms of the GNU General Public License as published by 7897ee6427Smrg# the Free Software Foundation; either version 3 of the License, or 7997ee6427Smrg# (at your option) any later version. 8097ee6427Smrg 8197ee6427Smrg# As a special exception to the GNU General Public License, if you distribute 8297ee6427Smrg# this file as part of a program or library that is built using GNU Libtool, 8397ee6427Smrg# you may include this file under the same distribution terms that you use 8497ee6427Smrg# for the rest of that program. 8597ee6427Smrg 8697ee6427Smrg# This program is distributed in the hope that it will be useful, 8797ee6427Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8897ee6427Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8997ee6427Smrg# General Public License for more details. 9097ee6427Smrg 9197ee6427Smrg# You should have received a copy of the GNU General Public License 9297ee6427Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9397ee6427Smrg 9497ee6427Smrg# Please report bugs or propose patches to gary@gnu.org. 9597ee6427Smrg 9697ee6427Smrg 9797ee6427Smrg## ------ ## 9897ee6427Smrg## Usage. ## 9997ee6427Smrg## ------ ## 10097ee6427Smrg 10197ee6427Smrg# Evaluate this file near the top of your script to gain access to 10297ee6427Smrg# the functions and variables defined here: 10397ee6427Smrg# 10497ee6427Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10597ee6427Smrg# 10697ee6427Smrg# If you need to override any of the default environment variable 10797ee6427Smrg# settings, do that before evaluating this file. 10897ee6427Smrg 10997ee6427Smrg 11097ee6427Smrg## -------------------- ## 11197ee6427Smrg## Shell normalisation. ## 11297ee6427Smrg## -------------------- ## 11397ee6427Smrg 11497ee6427Smrg# Some shells need a little help to be as Bourne compatible as possible. 11597ee6427Smrg# Before doing anything else, make sure all that help has been provided! 11697ee6427Smrg 11797ee6427SmrgDUALCASE=1; export DUALCASE # for MKS sh 11897ee6427Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1190cc67336Smrg emulate sh 1200cc67336Smrg NULLCMD=: 12197ee6427Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1220cc67336Smrg # is contrary to our usage. Disable this feature. 1230cc67336Smrg alias -g '${1+"$@"}'='"$@"' 1240cc67336Smrg setopt NO_GLOB_SUBST 1250cc67336Smrgelse 12697ee6427Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1270cc67336Smrgfi 128ef6fb4a5Smrg 12997ee6427Smrg# NLS nuisances: We save the old values in case they are required later. 13097ee6427Smrg_G_user_locale= 13197ee6427Smrg_G_safe_locale= 13297ee6427Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1330cc67336Smrgdo 13497ee6427Smrg eval "if test set = \"\${$_G_var+set}\"; then 13597ee6427Smrg save_$_G_var=\$$_G_var 13697ee6427Smrg $_G_var=C 13797ee6427Smrg export $_G_var 13897ee6427Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13997ee6427Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1400cc67336Smrg fi" 1410cc67336Smrgdone 142213fdd94Smrg 14397ee6427Smrg# CDPATH. 14497ee6427Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 1450cc67336Smrg 14697ee6427Smrg# Make sure IFS has a sensible default 14797ee6427Smrgsp=' ' 14897ee6427Smrgnl=' 14997ee6427Smrg' 15097ee6427SmrgIFS="$sp $nl" 15197ee6427Smrg 15297ee6427Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 15397ee6427Smrgif test "${PATH_SEPARATOR+set}" != set; then 15497ee6427Smrg PATH_SEPARATOR=: 15597ee6427Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15697ee6427Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15797ee6427Smrg PATH_SEPARATOR=';' 15897ee6427Smrg } 15997ee6427Smrgfi 160213fdd94Smrg 161213fdd94Smrg 162213fdd94Smrg 16397ee6427Smrg## ------------------------- ## 16497ee6427Smrg## Locate command utilities. ## 16597ee6427Smrg## ------------------------- ## 16697ee6427Smrg 16797ee6427Smrg 16897ee6427Smrg# func_executable_p FILE 16997ee6427Smrg# ---------------------- 17097ee6427Smrg# Check that FILE is an executable regular file. 17197ee6427Smrgfunc_executable_p () 17297ee6427Smrg{ 17397ee6427Smrg test -f "$1" && test -x "$1" 17497ee6427Smrg} 17597ee6427Smrg 17697ee6427Smrg 17797ee6427Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17897ee6427Smrg# -------------------------------------------- 17997ee6427Smrg# Search for either a program that responds to --version with output 18097ee6427Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18197ee6427Smrg# trying all the directories in PATH with each of the elements of 18297ee6427Smrg# PROGS_LIST. 18397ee6427Smrg# 18497ee6427Smrg# CHECK_FUNC should accept the path to a candidate program, and 18597ee6427Smrg# set $func_check_prog_result if it truncates its output less than 18697ee6427Smrg# $_G_path_prog_max characters. 18797ee6427Smrgfunc_path_progs () 18897ee6427Smrg{ 18997ee6427Smrg _G_progs_list=$1 19097ee6427Smrg _G_check_func=$2 19197ee6427Smrg _G_PATH=${3-"$PATH"} 19297ee6427Smrg 19397ee6427Smrg _G_path_prog_max=0 19497ee6427Smrg _G_path_prog_found=false 19597ee6427Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19697ee6427Smrg for _G_dir in $_G_PATH; do 19797ee6427Smrg IFS=$_G_save_IFS 19897ee6427Smrg test -z "$_G_dir" && _G_dir=. 19997ee6427Smrg for _G_prog_name in $_G_progs_list; do 20097ee6427Smrg for _exeext in '' .EXE; do 20197ee6427Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20297ee6427Smrg func_executable_p "$_G_path_prog" || continue 20397ee6427Smrg case `"$_G_path_prog" --version 2>&1` in 20497ee6427Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20597ee6427Smrg *) $_G_check_func $_G_path_prog 20697ee6427Smrg func_path_progs_result=$func_check_prog_result 20797ee6427Smrg ;; 20897ee6427Smrg esac 20997ee6427Smrg $_G_path_prog_found && break 3 21097ee6427Smrg done 21197ee6427Smrg done 21297ee6427Smrg done 21397ee6427Smrg IFS=$_G_save_IFS 21497ee6427Smrg test -z "$func_path_progs_result" && { 21597ee6427Smrg echo "no acceptable sed could be found in \$PATH" >&2 21697ee6427Smrg exit 1 21797ee6427Smrg } 21897ee6427Smrg} 21997ee6427Smrg 22097ee6427Smrg 22197ee6427Smrg# We want to be able to use the functions in this file before configure 22297ee6427Smrg# has figured out where the best binaries are kept, which means we have 22397ee6427Smrg# to search for them ourselves - except when the results are already set 22497ee6427Smrg# where we skip the searches. 22597ee6427Smrg 22697ee6427Smrg# Unless the user overrides by setting SED, search the path for either GNU 22797ee6427Smrg# sed, or the sed that truncates its output the least. 22897ee6427Smrgtest -z "$SED" && { 22997ee6427Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23097ee6427Smrg for _G_i in 1 2 3 4 5 6 7; do 23197ee6427Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23297ee6427Smrg done 23397ee6427Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23497ee6427Smrg _G_sed_script= 23597ee6427Smrg 23697ee6427Smrg func_check_prog_sed () 23797ee6427Smrg { 23897ee6427Smrg _G_path_prog=$1 23997ee6427Smrg 24097ee6427Smrg _G_count=0 24197ee6427Smrg printf 0123456789 >conftest.in 24297ee6427Smrg while : 24397ee6427Smrg do 24497ee6427Smrg cat conftest.in conftest.in >conftest.tmp 24597ee6427Smrg mv conftest.tmp conftest.in 24697ee6427Smrg cp conftest.in conftest.nl 24797ee6427Smrg echo '' >> conftest.nl 24897ee6427Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24997ee6427Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25097ee6427Smrg _G_count=`expr $_G_count + 1` 25197ee6427Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25297ee6427Smrg # Best one so far, save it but keep looking for a better one 25397ee6427Smrg func_check_prog_result=$_G_path_prog 25497ee6427Smrg _G_path_prog_max=$_G_count 25597ee6427Smrg fi 25697ee6427Smrg # 10*(2^10) chars as input seems more than enough 25797ee6427Smrg test 10 -lt "$_G_count" && break 25897ee6427Smrg done 25997ee6427Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26097ee6427Smrg } 26197ee6427Smrg 26297ee6427Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26397ee6427Smrg rm -f conftest.sed 26497ee6427Smrg SED=$func_path_progs_result 26597ee6427Smrg} 26697ee6427Smrg 26797ee6427Smrg 26897ee6427Smrg# Unless the user overrides by setting GREP, search the path for either GNU 26997ee6427Smrg# grep, or the grep that truncates its output the least. 27097ee6427Smrgtest -z "$GREP" && { 27197ee6427Smrg func_check_prog_grep () 27297ee6427Smrg { 27397ee6427Smrg _G_path_prog=$1 27497ee6427Smrg 27597ee6427Smrg _G_count=0 27697ee6427Smrg _G_path_prog_max=0 27797ee6427Smrg printf 0123456789 >conftest.in 27897ee6427Smrg while : 27997ee6427Smrg do 28097ee6427Smrg cat conftest.in conftest.in >conftest.tmp 28197ee6427Smrg mv conftest.tmp conftest.in 28297ee6427Smrg cp conftest.in conftest.nl 28397ee6427Smrg echo 'GREP' >> conftest.nl 28497ee6427Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28597ee6427Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28697ee6427Smrg _G_count=`expr $_G_count + 1` 28797ee6427Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28897ee6427Smrg # Best one so far, save it but keep looking for a better one 28997ee6427Smrg func_check_prog_result=$_G_path_prog 29097ee6427Smrg _G_path_prog_max=$_G_count 29197ee6427Smrg fi 29297ee6427Smrg # 10*(2^10) chars as input seems more than enough 29397ee6427Smrg test 10 -lt "$_G_count" && break 29497ee6427Smrg done 29597ee6427Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29697ee6427Smrg } 29797ee6427Smrg 29897ee6427Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29997ee6427Smrg GREP=$func_path_progs_result 30097ee6427Smrg} 30197ee6427Smrg 30297ee6427Smrg 30397ee6427Smrg## ------------------------------- ## 30497ee6427Smrg## User overridable command paths. ## 30597ee6427Smrg## ------------------------------- ## 30697ee6427Smrg 30797ee6427Smrg# All uppercase variable names are used for environment variables. These 30897ee6427Smrg# variables can be overridden by the user before calling a script that 30997ee6427Smrg# uses them if a suitable command of that name is not already available 31097ee6427Smrg# in the command search PATH. 311213fdd94Smrg 312213fdd94Smrg: ${CP="cp -f"} 31397ee6427Smrg: ${ECHO="printf %s\n"} 31497ee6427Smrg: ${EGREP="$GREP -E"} 31597ee6427Smrg: ${FGREP="$GREP -F"} 31697ee6427Smrg: ${LN_S="ln -s"} 317213fdd94Smrg: ${MAKE="make"} 318213fdd94Smrg: ${MKDIR="mkdir"} 319213fdd94Smrg: ${MV="mv -f"} 320213fdd94Smrg: ${RM="rm -f"} 321213fdd94Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3220cc67336Smrg 3230cc67336Smrg 32497ee6427Smrg## -------------------- ## 32597ee6427Smrg## Useful sed snippets. ## 32697ee6427Smrg## -------------------- ## 327213fdd94Smrg 32897ee6427Smrgsed_dirname='s|/[^/]*$||' 32997ee6427Smrgsed_basename='s|^.*/||' 330213fdd94Smrg 33197ee6427Smrg# Sed substitution that helps us do robust quoting. It backslashifies 33297ee6427Smrg# metacharacters that are still active within double-quoted strings. 33397ee6427Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334213fdd94Smrg 33597ee6427Smrg# Same as above, but do not quote variable references. 33697ee6427Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337213fdd94Smrg 33897ee6427Smrg# Sed substitution that turns a string into a regex matching for the 33997ee6427Smrg# string literally. 34097ee6427Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341213fdd94Smrg 34297ee6427Smrg# Sed substitution that converts a w32 file name or path 34397ee6427Smrg# that contains forward slashes, into one that contains 34497ee6427Smrg# (escaped) backslashes. A very naive implementation. 34597ee6427Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34697ee6427Smrg 34797ee6427Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34897ee6427Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34997ee6427Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35097ee6427Smrg# expansion. Since each input '\' is now two '\'s, look for any number 35197ee6427Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35297ee6427Smrg_G_bs='\\' 35397ee6427Smrg_G_bs2='\\\\' 35497ee6427Smrg_G_bs4='\\\\\\\\' 35597ee6427Smrg_G_dollar='\$' 35697ee6427Smrgsed_double_backslash="\ 35797ee6427Smrg s/$_G_bs4/&\\ 35897ee6427Smrg/g 35997ee6427Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36097ee6427Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36197ee6427Smrg s/\n//g" 362213fdd94Smrg 363213fdd94Smrg 36497ee6427Smrg## ----------------- ## 36597ee6427Smrg## Global variables. ## 36697ee6427Smrg## ----------------- ## 367213fdd94Smrg 36897ee6427Smrg# Except for the global variables explicitly listed below, the following 36997ee6427Smrg# functions in the '^func_' namespace, and the '^require_' namespace 37097ee6427Smrg# variables initialised in the 'Resource management' section, sourcing 37197ee6427Smrg# this file will not pollute your global namespace with anything 37297ee6427Smrg# else. There's no portable way to scope variables in Bourne shell 37397ee6427Smrg# though, so actually running these functions will sometimes place 37497ee6427Smrg# results into a variable named after the function, and often use 37597ee6427Smrg# temporary variables in the '^_G_' namespace. If you are careful to 37697ee6427Smrg# avoid using those namespaces casually in your sourcing script, things 37797ee6427Smrg# should continue to work as you expect. And, of course, you can freely 37897ee6427Smrg# overwrite any of the functions or variables defined here before 37997ee6427Smrg# calling anything to customize them. 380213fdd94Smrg 38197ee6427SmrgEXIT_SUCCESS=0 38297ee6427SmrgEXIT_FAILURE=1 38397ee6427SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38497ee6427SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385213fdd94Smrg 38697ee6427Smrg# Allow overriding, eg assuming that you follow the convention of 38797ee6427Smrg# putting '$debug_cmd' at the start of all your functions, you can get 38897ee6427Smrg# bash to show function call trace with: 38997ee6427Smrg# 39097ee6427Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39197ee6427Smrgdebug_cmd=${debug_cmd-":"} 39297ee6427Smrgexit_cmd=: 393213fdd94Smrg 39497ee6427Smrg# By convention, finish your script with: 39597ee6427Smrg# 39697ee6427Smrg# exit $exit_status 39797ee6427Smrg# 39897ee6427Smrg# so that you can set exit_status to non-zero if you want to indicate 39997ee6427Smrg# something went wrong during execution without actually bailing out at 40097ee6427Smrg# the point of failure. 40197ee6427Smrgexit_status=$EXIT_SUCCESS 402213fdd94Smrg 40397ee6427Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40497ee6427Smrg# is ksh but when the shell is invoked as "sh" and the current value of 40597ee6427Smrg# the _XPG environment variable is not equal to 1 (one), the special 40697ee6427Smrg# positional parameter $0, within a function call, is the name of the 40797ee6427Smrg# function. 40897ee6427Smrgprogpath=$0 409213fdd94Smrg 41097ee6427Smrg# The name of this program. 41197ee6427Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412213fdd94Smrg 41397ee6427Smrg# Make sure we have an absolute progpath for reexecution: 414213fdd94Smrgcase $progpath in 415213fdd94Smrg [\\/]*|[A-Za-z]:\\*) ;; 416213fdd94Smrg *[\\/]*) 41797ee6427Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418213fdd94Smrg progdir=`cd "$progdir" && pwd` 41997ee6427Smrg progpath=$progdir/$progname 420213fdd94Smrg ;; 421213fdd94Smrg *) 42297ee6427Smrg _G_IFS=$IFS 423213fdd94Smrg IFS=${PATH_SEPARATOR-:} 424213fdd94Smrg for progdir in $PATH; do 42597ee6427Smrg IFS=$_G_IFS 426213fdd94Smrg test -x "$progdir/$progname" && break 427213fdd94Smrg done 42897ee6427Smrg IFS=$_G_IFS 429213fdd94Smrg test -n "$progdir" || progdir=`pwd` 43097ee6427Smrg progpath=$progdir/$progname 431213fdd94Smrg ;; 432213fdd94Smrgesac 433213fdd94Smrg 434213fdd94Smrg 43597ee6427Smrg## ----------------- ## 43697ee6427Smrg## Standard options. ## 43797ee6427Smrg## ----------------- ## 438213fdd94Smrg 43997ee6427Smrg# The following options affect the operation of the functions defined 44097ee6427Smrg# below, and should be set appropriately depending on run-time para- 44197ee6427Smrg# meters passed on the command line. 442213fdd94Smrg 443213fdd94Smrgopt_dry_run=false 444213fdd94Smrgopt_quiet=false 445213fdd94Smrgopt_verbose=false 446213fdd94Smrg 44797ee6427Smrg# Categories 'all' and 'none' are always available. Append any others 44897ee6427Smrg# you will pass as the first argument to func_warning from your own 44997ee6427Smrg# code. 45097ee6427Smrgwarning_categories= 451213fdd94Smrg 45297ee6427Smrg# By default, display warnings according to 'opt_warning_types'. Set 45397ee6427Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45497ee6427Smrg# treat the next displayed warning as a fatal error. 45597ee6427Smrgwarning_func=func_warn_and_continue 456213fdd94Smrg 45797ee6427Smrg# Set to 'all' to display all warnings, 'none' to suppress all 45897ee6427Smrg# warnings, or a space delimited list of some subset of 45997ee6427Smrg# 'warning_categories' to display only the listed warnings. 46097ee6427Smrgopt_warning_types=all 461213fdd94Smrg 462213fdd94Smrg 46397ee6427Smrg## -------------------- ## 46497ee6427Smrg## Resource management. ## 46597ee6427Smrg## -------------------- ## 466213fdd94Smrg 46797ee6427Smrg# This section contains definitions for functions that each ensure a 46897ee6427Smrg# particular resource (a file, or a non-empty configuration variable for 46997ee6427Smrg# example) is available, and if appropriate to extract default values 47097ee6427Smrg# from pertinent package files. Call them using their associated 47197ee6427Smrg# 'require_*' variable to ensure that they are executed, at most, once. 47297ee6427Smrg# 47397ee6427Smrg# It's entirely deliberate that calling these functions can set 47497ee6427Smrg# variables that don't obey the namespace limitations obeyed by the rest 47597ee6427Smrg# of this file, in order that that they be as useful as possible to 47697ee6427Smrg# callers. 477213fdd94Smrg 478213fdd94Smrg 47997ee6427Smrg# require_term_colors 48097ee6427Smrg# ------------------- 48197ee6427Smrg# Allow display of bold text on terminals that support it. 48297ee6427Smrgrequire_term_colors=func_require_term_colors 48397ee6427Smrgfunc_require_term_colors () 484213fdd94Smrg{ 48597ee6427Smrg $debug_cmd 48697ee6427Smrg 48797ee6427Smrg test -t 1 && { 48897ee6427Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 48997ee6427Smrg # precedence, because most terminfo databases neglect to describe 49097ee6427Smrg # whether color sequences are supported. 49197ee6427Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49297ee6427Smrg 49397ee6427Smrg if test 1 = "$USE_ANSI_COLORS"; then 49497ee6427Smrg # Standard ANSI escape sequences 49597ee6427Smrg tc_reset='[0m' 49697ee6427Smrg tc_bold='[1m'; tc_standout='[7m' 49797ee6427Smrg tc_red='[31m'; tc_green='[32m' 49897ee6427Smrg tc_blue='[34m'; tc_cyan='[36m' 49997ee6427Smrg else 50097ee6427Smrg # Otherwise trust the terminfo database after all. 50197ee6427Smrg test -n "`tput sgr0 2>/dev/null`" && { 50297ee6427Smrg tc_reset=`tput sgr0` 50397ee6427Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50497ee6427Smrg tc_standout=$tc_bold 50597ee6427Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50697ee6427Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50797ee6427Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50897ee6427Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50997ee6427Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51097ee6427Smrg } 51197ee6427Smrg fi 51297ee6427Smrg } 513213fdd94Smrg 51497ee6427Smrg require_term_colors=: 515213fdd94Smrg} 516213fdd94Smrg 517213fdd94Smrg 51897ee6427Smrg## ----------------- ## 51997ee6427Smrg## Function library. ## 52097ee6427Smrg## ----------------- ## 52197ee6427Smrg 52297ee6427Smrg# This section contains a variety of useful functions to call in your 52397ee6427Smrg# scripts. Take note of the portable wrappers for features provided by 52497ee6427Smrg# some modern shells, which will fall back to slower equivalents on 52597ee6427Smrg# less featureful shells. 52697ee6427Smrg 52797ee6427Smrg 52897ee6427Smrg# func_append VAR VALUE 52997ee6427Smrg# --------------------- 53097ee6427Smrg# Append VALUE onto the existing contents of VAR. 53197ee6427Smrg 53297ee6427Smrg # We should try to minimise forks, especially on Windows where they are 53397ee6427Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 53497ee6427Smrg # being used: 53597ee6427Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53697ee6427Smrg : ${_G_HAVE_ARITH_OP="yes"} 53797ee6427Smrg : ${_G_HAVE_XSI_OPS="yes"} 53897ee6427Smrg # The += operator was introduced in bash 3.1 53997ee6427Smrg case $BASH_VERSION in 54097ee6427Smrg [12].* | 3.0 | 3.0*) ;; 54197ee6427Smrg *) 54297ee6427Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54397ee6427Smrg ;; 54497ee6427Smrg esac 54597ee6427Smrg fi 54697ee6427Smrg 54797ee6427Smrg # _G_HAVE_PLUSEQ_OP 54897ee6427Smrg # Can be empty, in which case the shell is probed, "yes" if += is 54997ee6427Smrg # useable or anything else if it does not work. 55097ee6427Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55197ee6427Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55297ee6427Smrg && _G_HAVE_PLUSEQ_OP=yes 55397ee6427Smrg 55497ee6427Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55597ee6427Smrgthen 55697ee6427Smrg # This is an XSI compatible shell, allowing a faster implementation... 55797ee6427Smrg eval 'func_append () 55897ee6427Smrg { 55997ee6427Smrg $debug_cmd 56097ee6427Smrg 56197ee6427Smrg eval "$1+=\$2" 56297ee6427Smrg }' 56397ee6427Smrgelse 56497ee6427Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 56597ee6427Smrg func_append () 56697ee6427Smrg { 56797ee6427Smrg $debug_cmd 56897ee6427Smrg 56997ee6427Smrg eval "$1=\$$1\$2" 57097ee6427Smrg } 57197ee6427Smrgfi 57297ee6427Smrg 57397ee6427Smrg 57497ee6427Smrg# func_append_quoted VAR VALUE 57597ee6427Smrg# ---------------------------- 57697ee6427Smrg# Quote VALUE and append to the end of shell variable VAR, separated 57797ee6427Smrg# by a space. 57897ee6427Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57997ee6427Smrg eval 'func_append_quoted () 58097ee6427Smrg { 58197ee6427Smrg $debug_cmd 58297ee6427Smrg 58397ee6427Smrg func_quote_for_eval "$2" 58497ee6427Smrg eval "$1+=\\ \$func_quote_for_eval_result" 58597ee6427Smrg }' 58697ee6427Smrgelse 58797ee6427Smrg func_append_quoted () 58897ee6427Smrg { 58997ee6427Smrg $debug_cmd 59097ee6427Smrg 59197ee6427Smrg func_quote_for_eval "$2" 59297ee6427Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59397ee6427Smrg } 59497ee6427Smrgfi 59597ee6427Smrg 59697ee6427Smrg 59797ee6427Smrg# func_append_uniq VAR VALUE 59897ee6427Smrg# -------------------------- 59997ee6427Smrg# Append unique VALUE onto the existing contents of VAR, assuming 60097ee6427Smrg# entries are delimited by the first character of VALUE. For example: 60197ee6427Smrg# 60297ee6427Smrg# func_append_uniq options " --another-option option-argument" 60397ee6427Smrg# 60497ee6427Smrg# will only append to $options if " --another-option option-argument " 60597ee6427Smrg# is not already present somewhere in $options already (note spaces at 60697ee6427Smrg# each end implied by leading space in second argument). 60797ee6427Smrgfunc_append_uniq () 60897ee6427Smrg{ 60997ee6427Smrg $debug_cmd 61097ee6427Smrg 61197ee6427Smrg eval _G_current_value='`$ECHO $'$1'`' 61297ee6427Smrg _G_delim=`expr "$2" : '\(.\)'` 61397ee6427Smrg 61497ee6427Smrg case $_G_delim$_G_current_value$_G_delim in 61597ee6427Smrg *"$2$_G_delim"*) ;; 61697ee6427Smrg *) func_append "$@" ;; 61797ee6427Smrg esac 61897ee6427Smrg} 61997ee6427Smrg 62097ee6427Smrg 62197ee6427Smrg# func_arith TERM... 62297ee6427Smrg# ------------------ 62397ee6427Smrg# Set func_arith_result to the result of evaluating TERMs. 62497ee6427Smrg test -z "$_G_HAVE_ARITH_OP" \ 62597ee6427Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62697ee6427Smrg && _G_HAVE_ARITH_OP=yes 62797ee6427Smrg 62897ee6427Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 62997ee6427Smrg eval 'func_arith () 63097ee6427Smrg { 63197ee6427Smrg $debug_cmd 63297ee6427Smrg 63397ee6427Smrg func_arith_result=$(( $* )) 63497ee6427Smrg }' 63597ee6427Smrgelse 63697ee6427Smrg func_arith () 63797ee6427Smrg { 63897ee6427Smrg $debug_cmd 63997ee6427Smrg 64097ee6427Smrg func_arith_result=`expr "$@"` 64197ee6427Smrg } 64297ee6427Smrgfi 64397ee6427Smrg 64497ee6427Smrg 64597ee6427Smrg# func_basename FILE 64697ee6427Smrg# ------------------ 64797ee6427Smrg# Set func_basename_result to FILE with everything up to and including 64897ee6427Smrg# the last / stripped. 64997ee6427Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 65097ee6427Smrg # If this shell supports suffix pattern removal, then use it to avoid 65197ee6427Smrg # forking. Hide the definitions single quotes in case the shell chokes 65297ee6427Smrg # on unsupported syntax... 65397ee6427Smrg _b='func_basename_result=${1##*/}' 65497ee6427Smrg _d='case $1 in 65597ee6427Smrg */*) func_dirname_result=${1%/*}$2 ;; 65697ee6427Smrg * ) func_dirname_result=$3 ;; 65797ee6427Smrg esac' 65897ee6427Smrg 65997ee6427Smrgelse 66097ee6427Smrg # ...otherwise fall back to using sed. 66197ee6427Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66297ee6427Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66397ee6427Smrg if test "X$func_dirname_result" = "X$1"; then 66497ee6427Smrg func_dirname_result=$3 66597ee6427Smrg else 66697ee6427Smrg func_append func_dirname_result "$2" 66797ee6427Smrg fi' 66897ee6427Smrgfi 66997ee6427Smrg 67097ee6427Smrgeval 'func_basename () 67197ee6427Smrg{ 67297ee6427Smrg $debug_cmd 67397ee6427Smrg 67497ee6427Smrg '"$_b"' 67597ee6427Smrg}' 67697ee6427Smrg 67797ee6427Smrg 67897ee6427Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67997ee6427Smrg# ------------------------------------------- 68097ee6427Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68197ee6427Smrg# otherwise set result to NONDIR_REPLACEMENT. 68297ee6427Smrgeval 'func_dirname () 68397ee6427Smrg{ 68497ee6427Smrg $debug_cmd 68597ee6427Smrg 68697ee6427Smrg '"$_d"' 68797ee6427Smrg}' 68897ee6427Smrg 68997ee6427Smrg 69097ee6427Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69197ee6427Smrg# -------------------------------------------------------- 69297ee6427Smrg# Perform func_basename and func_dirname in a single function 69397ee6427Smrg# call: 69497ee6427Smrg# dirname: Compute the dirname of FILE. If nonempty, 69597ee6427Smrg# add APPEND to the result, otherwise set result 69697ee6427Smrg# to NONDIR_REPLACEMENT. 69797ee6427Smrg# value returned in "$func_dirname_result" 69897ee6427Smrg# basename: Compute filename of FILE. 69997ee6427Smrg# value retuned in "$func_basename_result" 70097ee6427Smrg# For efficiency, we do not delegate to the functions above but instead 70197ee6427Smrg# duplicate the functionality here. 70297ee6427Smrgeval 'func_dirname_and_basename () 70397ee6427Smrg{ 70497ee6427Smrg $debug_cmd 70597ee6427Smrg 70697ee6427Smrg '"$_b"' 70797ee6427Smrg '"$_d"' 70897ee6427Smrg}' 70997ee6427Smrg 71097ee6427Smrg 71197ee6427Smrg# func_echo ARG... 71297ee6427Smrg# ---------------- 71397ee6427Smrg# Echo program name prefixed message. 71497ee6427Smrgfunc_echo () 71597ee6427Smrg{ 71697ee6427Smrg $debug_cmd 71797ee6427Smrg 71897ee6427Smrg _G_message=$* 71997ee6427Smrg 72097ee6427Smrg func_echo_IFS=$IFS 72197ee6427Smrg IFS=$nl 72297ee6427Smrg for _G_line in $_G_message; do 72397ee6427Smrg IFS=$func_echo_IFS 72497ee6427Smrg $ECHO "$progname: $_G_line" 72597ee6427Smrg done 72697ee6427Smrg IFS=$func_echo_IFS 72797ee6427Smrg} 72897ee6427Smrg 72997ee6427Smrg 73097ee6427Smrg# func_echo_all ARG... 73197ee6427Smrg# -------------------- 73297ee6427Smrg# Invoke $ECHO with all args, space-separated. 73397ee6427Smrgfunc_echo_all () 73497ee6427Smrg{ 73597ee6427Smrg $ECHO "$*" 73697ee6427Smrg} 73797ee6427Smrg 73897ee6427Smrg 73997ee6427Smrg# func_echo_infix_1 INFIX ARG... 74097ee6427Smrg# ------------------------------ 74197ee6427Smrg# Echo program name, followed by INFIX on the first line, with any 74297ee6427Smrg# additional lines not showing INFIX. 74397ee6427Smrgfunc_echo_infix_1 () 74497ee6427Smrg{ 74597ee6427Smrg $debug_cmd 74697ee6427Smrg 74797ee6427Smrg $require_term_colors 74897ee6427Smrg 74997ee6427Smrg _G_infix=$1; shift 75097ee6427Smrg _G_indent=$_G_infix 75197ee6427Smrg _G_prefix="$progname: $_G_infix: " 75297ee6427Smrg _G_message=$* 75397ee6427Smrg 75497ee6427Smrg # Strip color escape sequences before counting printable length 75597ee6427Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75697ee6427Smrg do 75797ee6427Smrg test -n "$_G_tc" && { 75897ee6427Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75997ee6427Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76097ee6427Smrg } 76197ee6427Smrg done 76297ee6427Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76397ee6427Smrg 76497ee6427Smrg func_echo_infix_1_IFS=$IFS 76597ee6427Smrg IFS=$nl 76697ee6427Smrg for _G_line in $_G_message; do 76797ee6427Smrg IFS=$func_echo_infix_1_IFS 76897ee6427Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76997ee6427Smrg _G_prefix=$_G_indent 77097ee6427Smrg done 77197ee6427Smrg IFS=$func_echo_infix_1_IFS 77297ee6427Smrg} 77397ee6427Smrg 77497ee6427Smrg 77597ee6427Smrg# func_error ARG... 77697ee6427Smrg# ----------------- 77797ee6427Smrg# Echo program name prefixed message to standard error. 77897ee6427Smrgfunc_error () 77997ee6427Smrg{ 78097ee6427Smrg $debug_cmd 78197ee6427Smrg 78297ee6427Smrg $require_term_colors 78397ee6427Smrg 78497ee6427Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78597ee6427Smrg} 78697ee6427Smrg 78797ee6427Smrg 78897ee6427Smrg# func_fatal_error ARG... 78997ee6427Smrg# ----------------------- 79097ee6427Smrg# Echo program name prefixed message to standard error, and exit. 79197ee6427Smrgfunc_fatal_error () 79297ee6427Smrg{ 79397ee6427Smrg $debug_cmd 79497ee6427Smrg 79597ee6427Smrg func_error "$*" 79697ee6427Smrg exit $EXIT_FAILURE 79797ee6427Smrg} 79897ee6427Smrg 79997ee6427Smrg 80097ee6427Smrg# func_grep EXPRESSION FILENAME 80197ee6427Smrg# ----------------------------- 802213fdd94Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803213fdd94Smrgfunc_grep () 804213fdd94Smrg{ 80597ee6427Smrg $debug_cmd 80697ee6427Smrg 807213fdd94Smrg $GREP "$1" "$2" >/dev/null 2>&1 808213fdd94Smrg} 809213fdd94Smrg 810213fdd94Smrg 81197ee6427Smrg# func_len STRING 81297ee6427Smrg# --------------- 81397ee6427Smrg# Set func_len_result to the length of STRING. STRING may not 81497ee6427Smrg# start with a hyphen. 81597ee6427Smrg test -z "$_G_HAVE_XSI_OPS" \ 81697ee6427Smrg && (eval 'x=a/b/c; 81797ee6427Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81897ee6427Smrg && _G_HAVE_XSI_OPS=yes 81997ee6427Smrg 82097ee6427Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 82197ee6427Smrg eval 'func_len () 82297ee6427Smrg { 82397ee6427Smrg $debug_cmd 82497ee6427Smrg 82597ee6427Smrg func_len_result=${#1} 82697ee6427Smrg }' 82797ee6427Smrgelse 82897ee6427Smrg func_len () 82997ee6427Smrg { 83097ee6427Smrg $debug_cmd 83197ee6427Smrg 83297ee6427Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83397ee6427Smrg } 83497ee6427Smrgfi 83597ee6427Smrg 83697ee6427Smrg 83797ee6427Smrg# func_mkdir_p DIRECTORY-PATH 83897ee6427Smrg# --------------------------- 839213fdd94Smrg# Make sure the entire path to DIRECTORY-PATH is available. 840213fdd94Smrgfunc_mkdir_p () 841213fdd94Smrg{ 84297ee6427Smrg $debug_cmd 843213fdd94Smrg 84497ee6427Smrg _G_directory_path=$1 84597ee6427Smrg _G_dir_list= 846213fdd94Smrg 84797ee6427Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84897ee6427Smrg 84997ee6427Smrg # Protect directory names starting with '-' 85097ee6427Smrg case $_G_directory_path in 85197ee6427Smrg -*) _G_directory_path=./$_G_directory_path ;; 852213fdd94Smrg esac 853213fdd94Smrg 854213fdd94Smrg # While some portion of DIR does not yet exist... 85597ee6427Smrg while test ! -d "$_G_directory_path"; do 856213fdd94Smrg # ...make a list in topmost first order. Use a colon delimited 857213fdd94Smrg # list incase some portion of path contains whitespace. 85897ee6427Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 859213fdd94Smrg 860213fdd94Smrg # If the last portion added has no slash in it, the list is done 86197ee6427Smrg case $_G_directory_path in */*) ;; *) break ;; esac 862213fdd94Smrg 863213fdd94Smrg # ...otherwise throw away the child directory and loop 86497ee6427Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865213fdd94Smrg done 86697ee6427Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867213fdd94Smrg 86897ee6427Smrg func_mkdir_p_IFS=$IFS; IFS=: 86997ee6427Smrg for _G_dir in $_G_dir_list; do 87097ee6427Smrg IFS=$func_mkdir_p_IFS 87197ee6427Smrg # mkdir can fail with a 'File exist' error if two processes 872213fdd94Smrg # try to create one of the directories concurrently. Don't 873213fdd94Smrg # stop in that case! 87497ee6427Smrg $MKDIR "$_G_dir" 2>/dev/null || : 875213fdd94Smrg done 87697ee6427Smrg IFS=$func_mkdir_p_IFS 877213fdd94Smrg 878213fdd94Smrg # Bail out if we (or some other process) failed to create a directory. 87997ee6427Smrg test -d "$_G_directory_path" || \ 88097ee6427Smrg func_fatal_error "Failed to create '$1'" 881213fdd94Smrg fi 882213fdd94Smrg} 883301ea0f4Smrg 884301ea0f4Smrg 88597ee6427Smrg# func_mktempdir [BASENAME] 88697ee6427Smrg# ------------------------- 887301ea0f4Smrg# Make a temporary directory that won't clash with other running 888301ea0f4Smrg# libtool processes, and avoids race conditions if possible. If 88997ee6427Smrg# given, BASENAME is the basename for that directory. 890301ea0f4Smrgfunc_mktempdir () 891301ea0f4Smrg{ 89297ee6427Smrg $debug_cmd 89397ee6427Smrg 89497ee6427Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895301ea0f4Smrg 89697ee6427Smrg if test : = "$opt_dry_run"; then 897301ea0f4Smrg # Return a directory name, but don't create it in dry-run mode 89897ee6427Smrg _G_tmpdir=$_G_template-$$ 899301ea0f4Smrg else 900301ea0f4Smrg 901301ea0f4Smrg # If mktemp works, use that first and foremost 90297ee6427Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903301ea0f4Smrg 90497ee6427Smrg if test ! -d "$_G_tmpdir"; then 905213fdd94Smrg # Failing that, at least try and use $RANDOM to avoid a race 90697ee6427Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907301ea0f4Smrg 90897ee6427Smrg func_mktempdir_umask=`umask` 909213fdd94Smrg umask 0077 91097ee6427Smrg $MKDIR "$_G_tmpdir" 91197ee6427Smrg umask $func_mktempdir_umask 912301ea0f4Smrg fi 913301ea0f4Smrg 914301ea0f4Smrg # If we're not in dry-run mode, bomb out on failure 91597ee6427Smrg test -d "$_G_tmpdir" || \ 91697ee6427Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91797ee6427Smrg fi 91897ee6427Smrg 91997ee6427Smrg $ECHO "$_G_tmpdir" 92097ee6427Smrg} 92197ee6427Smrg 92297ee6427Smrg 92397ee6427Smrg# func_normal_abspath PATH 92497ee6427Smrg# ------------------------ 92597ee6427Smrg# Remove doubled-up and trailing slashes, "." path components, 92697ee6427Smrg# and cancel out any ".." path components in PATH after making 92797ee6427Smrg# it an absolute path. 92897ee6427Smrgfunc_normal_abspath () 92997ee6427Smrg{ 93097ee6427Smrg $debug_cmd 93197ee6427Smrg 93297ee6427Smrg # These SED scripts presuppose an absolute path with a trailing slash. 93397ee6427Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93497ee6427Smrg _G_pathcdr='s|^/[^/]*||' 93597ee6427Smrg _G_removedotparts=':dotsl 93697ee6427Smrg s|/\./|/|g 93797ee6427Smrg t dotsl 93897ee6427Smrg s|/\.$|/|' 93997ee6427Smrg _G_collapseslashes='s|/\{1,\}|/|g' 94097ee6427Smrg _G_finalslash='s|/*$|/|' 94197ee6427Smrg 94297ee6427Smrg # Start from root dir and reassemble the path. 94397ee6427Smrg func_normal_abspath_result= 94497ee6427Smrg func_normal_abspath_tpath=$1 94597ee6427Smrg func_normal_abspath_altnamespace= 94697ee6427Smrg case $func_normal_abspath_tpath in 94797ee6427Smrg "") 94897ee6427Smrg # Empty path, that just means $cwd. 94997ee6427Smrg func_stripname '' '/' "`pwd`" 95097ee6427Smrg func_normal_abspath_result=$func_stripname_result 95197ee6427Smrg return 95297ee6427Smrg ;; 95397ee6427Smrg # The next three entries are used to spot a run of precisely 95497ee6427Smrg # two leading slashes without using negated character classes; 95597ee6427Smrg # we take advantage of case's first-match behaviour. 95697ee6427Smrg ///*) 95797ee6427Smrg # Unusual form of absolute path, do nothing. 95897ee6427Smrg ;; 95997ee6427Smrg //*) 96097ee6427Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96197ee6427Smrg # and for example Cygwin uses it to access remote file shares 96297ee6427Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 96397ee6427Smrg func_normal_abspath_altnamespace=/ 96497ee6427Smrg ;; 96597ee6427Smrg /*) 96697ee6427Smrg # Absolute path, do nothing. 96797ee6427Smrg ;; 96897ee6427Smrg *) 96997ee6427Smrg # Relative path, prepend $cwd. 97097ee6427Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97197ee6427Smrg ;; 97297ee6427Smrg esac 97397ee6427Smrg 97497ee6427Smrg # Cancel out all the simple stuff to save iterations. We also want 97597ee6427Smrg # the path to end with a slash for ease of parsing, so make sure 97697ee6427Smrg # there is one (and only one) here. 97797ee6427Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97897ee6427Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97997ee6427Smrg while :; do 98097ee6427Smrg # Processed it all yet? 98197ee6427Smrg if test / = "$func_normal_abspath_tpath"; then 98297ee6427Smrg # If we ascended to the root using ".." the result may be empty now. 98397ee6427Smrg if test -z "$func_normal_abspath_result"; then 98497ee6427Smrg func_normal_abspath_result=/ 98597ee6427Smrg fi 98697ee6427Smrg break 98797ee6427Smrg fi 98897ee6427Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98997ee6427Smrg -e "$_G_pathcar"` 99097ee6427Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99197ee6427Smrg -e "$_G_pathcdr"` 99297ee6427Smrg # Figure out what to do with it 99397ee6427Smrg case $func_normal_abspath_tcomponent in 99497ee6427Smrg "") 99597ee6427Smrg # Trailing empty path component, ignore it. 99697ee6427Smrg ;; 99797ee6427Smrg ..) 99897ee6427Smrg # Parent dir; strip last assembled component from result. 99997ee6427Smrg func_dirname "$func_normal_abspath_result" 100097ee6427Smrg func_normal_abspath_result=$func_dirname_result 100197ee6427Smrg ;; 100297ee6427Smrg *) 100397ee6427Smrg # Actual path component, append it. 100497ee6427Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100597ee6427Smrg ;; 100697ee6427Smrg esac 100797ee6427Smrg done 100897ee6427Smrg # Restore leading double-slash if one was found on entry. 100997ee6427Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101097ee6427Smrg} 101197ee6427Smrg 101297ee6427Smrg 101397ee6427Smrg# func_notquiet ARG... 101497ee6427Smrg# -------------------- 101597ee6427Smrg# Echo program name prefixed message only when not in quiet mode. 101697ee6427Smrgfunc_notquiet () 101797ee6427Smrg{ 101897ee6427Smrg $debug_cmd 101997ee6427Smrg 102097ee6427Smrg $opt_quiet || func_echo ${1+"$@"} 102197ee6427Smrg 102297ee6427Smrg # A bug in bash halts the script if the last line of a function 102397ee6427Smrg # fails when set -e is in force, so we need another command to 102497ee6427Smrg # work around that: 102597ee6427Smrg : 102697ee6427Smrg} 102797ee6427Smrg 102897ee6427Smrg 102997ee6427Smrg# func_relative_path SRCDIR DSTDIR 103097ee6427Smrg# -------------------------------- 103197ee6427Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103297ee6427Smrgfunc_relative_path () 103397ee6427Smrg{ 103497ee6427Smrg $debug_cmd 103597ee6427Smrg 103697ee6427Smrg func_relative_path_result= 103797ee6427Smrg func_normal_abspath "$1" 103897ee6427Smrg func_relative_path_tlibdir=$func_normal_abspath_result 103997ee6427Smrg func_normal_abspath "$2" 104097ee6427Smrg func_relative_path_tbindir=$func_normal_abspath_result 104197ee6427Smrg 104297ee6427Smrg # Ascend the tree starting from libdir 104397ee6427Smrg while :; do 104497ee6427Smrg # check if we have found a prefix of bindir 104597ee6427Smrg case $func_relative_path_tbindir in 104697ee6427Smrg $func_relative_path_tlibdir) 104797ee6427Smrg # found an exact match 104897ee6427Smrg func_relative_path_tcancelled= 104997ee6427Smrg break 105097ee6427Smrg ;; 105197ee6427Smrg $func_relative_path_tlibdir*) 105297ee6427Smrg # found a matching prefix 105397ee6427Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105497ee6427Smrg func_relative_path_tcancelled=$func_stripname_result 105597ee6427Smrg if test -z "$func_relative_path_result"; then 105697ee6427Smrg func_relative_path_result=. 105797ee6427Smrg fi 105897ee6427Smrg break 105997ee6427Smrg ;; 106097ee6427Smrg *) 106197ee6427Smrg func_dirname $func_relative_path_tlibdir 106297ee6427Smrg func_relative_path_tlibdir=$func_dirname_result 106397ee6427Smrg if test -z "$func_relative_path_tlibdir"; then 106497ee6427Smrg # Have to descend all the way to the root! 106597ee6427Smrg func_relative_path_result=../$func_relative_path_result 106697ee6427Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 106797ee6427Smrg break 106897ee6427Smrg fi 106997ee6427Smrg func_relative_path_result=../$func_relative_path_result 107097ee6427Smrg ;; 107197ee6427Smrg esac 107297ee6427Smrg done 107397ee6427Smrg 107497ee6427Smrg # Now calculate path; take care to avoid doubling-up slashes. 107597ee6427Smrg func_stripname '' '/' "$func_relative_path_result" 107697ee6427Smrg func_relative_path_result=$func_stripname_result 107797ee6427Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107897ee6427Smrg if test -n "$func_stripname_result"; then 107997ee6427Smrg func_append func_relative_path_result "/$func_stripname_result" 108097ee6427Smrg fi 108197ee6427Smrg 108297ee6427Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 108397ee6427Smrg if test -n "$func_relative_path_result"; then 108497ee6427Smrg func_stripname './' '' "$func_relative_path_result" 108597ee6427Smrg func_relative_path_result=$func_stripname_result 1086301ea0f4Smrg fi 1087301ea0f4Smrg 108897ee6427Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 108997ee6427Smrg 109097ee6427Smrg : 109197ee6427Smrg} 109297ee6427Smrg 109397ee6427Smrg 109497ee6427Smrg# func_quote_for_eval ARG... 109597ee6427Smrg# -------------------------- 109697ee6427Smrg# Aesthetically quote ARGs to be evaled later. 109797ee6427Smrg# This function returns two values: 109897ee6427Smrg# i) func_quote_for_eval_result 109997ee6427Smrg# double-quoted, suitable for a subsequent eval 110097ee6427Smrg# ii) func_quote_for_eval_unquoted_result 110197ee6427Smrg# has all characters that are still active within double 110297ee6427Smrg# quotes backslashified. 110397ee6427Smrgfunc_quote_for_eval () 110497ee6427Smrg{ 110597ee6427Smrg $debug_cmd 110697ee6427Smrg 110797ee6427Smrg func_quote_for_eval_unquoted_result= 110897ee6427Smrg func_quote_for_eval_result= 110997ee6427Smrg while test 0 -lt $#; do 111097ee6427Smrg case $1 in 111197ee6427Smrg *[\\\`\"\$]*) 111297ee6427Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111397ee6427Smrg *) 111497ee6427Smrg _G_unquoted_arg=$1 ;; 111597ee6427Smrg esac 111697ee6427Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 111797ee6427Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111897ee6427Smrg else 111997ee6427Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112097ee6427Smrg fi 112197ee6427Smrg 112297ee6427Smrg case $_G_unquoted_arg in 112397ee6427Smrg # Double-quote args containing shell metacharacters to delay 112497ee6427Smrg # word splitting, command substitution and variable expansion 112597ee6427Smrg # for a subsequent eval. 112697ee6427Smrg # Many Bourne shells cannot handle close brackets correctly 112797ee6427Smrg # in scan sets, so we specify it separately. 112897ee6427Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112997ee6427Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 113097ee6427Smrg ;; 113197ee6427Smrg *) 113297ee6427Smrg _G_quoted_arg=$_G_unquoted_arg 113397ee6427Smrg ;; 113497ee6427Smrg esac 113597ee6427Smrg 113697ee6427Smrg if test -n "$func_quote_for_eval_result"; then 113797ee6427Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113897ee6427Smrg else 113997ee6427Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114097ee6427Smrg fi 114197ee6427Smrg shift 114297ee6427Smrg done 114397ee6427Smrg} 114497ee6427Smrg 114597ee6427Smrg 114697ee6427Smrg# func_quote_for_expand ARG 114797ee6427Smrg# ------------------------- 114897ee6427Smrg# Aesthetically quote ARG to be evaled later; same as above, 114997ee6427Smrg# but do not quote variable references. 115097ee6427Smrgfunc_quote_for_expand () 115197ee6427Smrg{ 115297ee6427Smrg $debug_cmd 115397ee6427Smrg 115497ee6427Smrg case $1 in 115597ee6427Smrg *[\\\`\"]*) 115697ee6427Smrg _G_arg=`$ECHO "$1" | $SED \ 115797ee6427Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115897ee6427Smrg *) 115997ee6427Smrg _G_arg=$1 ;; 116097ee6427Smrg esac 116197ee6427Smrg 116297ee6427Smrg case $_G_arg in 116397ee6427Smrg # Double-quote args containing shell metacharacters to delay 116497ee6427Smrg # word splitting and command substitution for a subsequent eval. 116597ee6427Smrg # Many Bourne shells cannot handle close brackets correctly 116697ee6427Smrg # in scan sets, so we specify it separately. 116797ee6427Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116897ee6427Smrg _G_arg=\"$_G_arg\" 116997ee6427Smrg ;; 117097ee6427Smrg esac 117197ee6427Smrg 117297ee6427Smrg func_quote_for_expand_result=$_G_arg 117397ee6427Smrg} 117497ee6427Smrg 117597ee6427Smrg 117697ee6427Smrg# func_stripname PREFIX SUFFIX NAME 117797ee6427Smrg# --------------------------------- 117897ee6427Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117997ee6427Smrg# PREFIX and SUFFIX must not contain globbing or regex special 118097ee6427Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118197ee6427Smrg# dot (in which case that matches only a dot). 118297ee6427Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 118397ee6427Smrg eval 'func_stripname () 118497ee6427Smrg { 118597ee6427Smrg $debug_cmd 118697ee6427Smrg 118797ee6427Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118897ee6427Smrg # positional parameters, so assign one to ordinary variable first. 118997ee6427Smrg func_stripname_result=$3 119097ee6427Smrg func_stripname_result=${func_stripname_result#"$1"} 119197ee6427Smrg func_stripname_result=${func_stripname_result%"$2"} 119297ee6427Smrg }' 119397ee6427Smrgelse 119497ee6427Smrg func_stripname () 119597ee6427Smrg { 119697ee6427Smrg $debug_cmd 119797ee6427Smrg 119897ee6427Smrg case $2 in 119997ee6427Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120097ee6427Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120197ee6427Smrg esac 120297ee6427Smrg } 120397ee6427Smrgfi 120497ee6427Smrg 120597ee6427Smrg 120697ee6427Smrg# func_show_eval CMD [FAIL_EXP] 120797ee6427Smrg# ----------------------------- 120897ee6427Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120997ee6427Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121097ee6427Smrg# is given, then evaluate it. 121197ee6427Smrgfunc_show_eval () 121297ee6427Smrg{ 121397ee6427Smrg $debug_cmd 121497ee6427Smrg 121597ee6427Smrg _G_cmd=$1 121697ee6427Smrg _G_fail_exp=${2-':'} 121797ee6427Smrg 121897ee6427Smrg func_quote_for_expand "$_G_cmd" 121997ee6427Smrg eval "func_notquiet $func_quote_for_expand_result" 122097ee6427Smrg 122197ee6427Smrg $opt_dry_run || { 122297ee6427Smrg eval "$_G_cmd" 122397ee6427Smrg _G_status=$? 122497ee6427Smrg if test 0 -ne "$_G_status"; then 122597ee6427Smrg eval "(exit $_G_status); $_G_fail_exp" 122697ee6427Smrg fi 122797ee6427Smrg } 122897ee6427Smrg} 122997ee6427Smrg 123097ee6427Smrg 123197ee6427Smrg# func_show_eval_locale CMD [FAIL_EXP] 123297ee6427Smrg# ------------------------------------ 123397ee6427Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123497ee6427Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123597ee6427Smrg# is given, then evaluate it. Use the saved locale for evaluation. 123697ee6427Smrgfunc_show_eval_locale () 123797ee6427Smrg{ 123897ee6427Smrg $debug_cmd 123997ee6427Smrg 124097ee6427Smrg _G_cmd=$1 124197ee6427Smrg _G_fail_exp=${2-':'} 124297ee6427Smrg 124397ee6427Smrg $opt_quiet || { 124497ee6427Smrg func_quote_for_expand "$_G_cmd" 124597ee6427Smrg eval "func_echo $func_quote_for_expand_result" 124697ee6427Smrg } 124797ee6427Smrg 124897ee6427Smrg $opt_dry_run || { 124997ee6427Smrg eval "$_G_user_locale 125097ee6427Smrg $_G_cmd" 125197ee6427Smrg _G_status=$? 125297ee6427Smrg eval "$_G_safe_locale" 125397ee6427Smrg if test 0 -ne "$_G_status"; then 125497ee6427Smrg eval "(exit $_G_status); $_G_fail_exp" 125597ee6427Smrg fi 125697ee6427Smrg } 125797ee6427Smrg} 125897ee6427Smrg 125997ee6427Smrg 126097ee6427Smrg# func_tr_sh 126197ee6427Smrg# ---------- 126297ee6427Smrg# Turn $1 into a string suitable for a shell variable name. 126397ee6427Smrg# Result is stored in $func_tr_sh_result. All characters 126497ee6427Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126597ee6427Smrg# if $1 begins with a digit, a '_' is prepended as well. 126697ee6427Smrgfunc_tr_sh () 126797ee6427Smrg{ 126897ee6427Smrg $debug_cmd 126997ee6427Smrg 127097ee6427Smrg case $1 in 127197ee6427Smrg [0-9]* | *[!a-zA-Z0-9_]*) 127297ee6427Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127397ee6427Smrg ;; 127497ee6427Smrg * ) 127597ee6427Smrg func_tr_sh_result=$1 127697ee6427Smrg ;; 127797ee6427Smrg esac 127897ee6427Smrg} 127997ee6427Smrg 128097ee6427Smrg 128197ee6427Smrg# func_verbose ARG... 128297ee6427Smrg# ------------------- 128397ee6427Smrg# Echo program name prefixed message in verbose mode only. 128497ee6427Smrgfunc_verbose () 128597ee6427Smrg{ 128697ee6427Smrg $debug_cmd 128797ee6427Smrg 128897ee6427Smrg $opt_verbose && func_echo "$*" 128997ee6427Smrg 129097ee6427Smrg : 129197ee6427Smrg} 129297ee6427Smrg 129397ee6427Smrg 129497ee6427Smrg# func_warn_and_continue ARG... 129597ee6427Smrg# ----------------------------- 129697ee6427Smrg# Echo program name prefixed warning message to standard error. 129797ee6427Smrgfunc_warn_and_continue () 129897ee6427Smrg{ 129997ee6427Smrg $debug_cmd 130097ee6427Smrg 130197ee6427Smrg $require_term_colors 130297ee6427Smrg 130397ee6427Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130497ee6427Smrg} 130597ee6427Smrg 130697ee6427Smrg 130797ee6427Smrg# func_warning CATEGORY ARG... 130897ee6427Smrg# ---------------------------- 130997ee6427Smrg# Echo program name prefixed warning message to standard error. Warning 131097ee6427Smrg# messages can be filtered according to CATEGORY, where this function 131197ee6427Smrg# elides messages where CATEGORY is not listed in the global variable 131297ee6427Smrg# 'opt_warning_types'. 131397ee6427Smrgfunc_warning () 131497ee6427Smrg{ 131597ee6427Smrg $debug_cmd 131697ee6427Smrg 131797ee6427Smrg # CATEGORY must be in the warning_categories list! 131897ee6427Smrg case " $warning_categories " in 131997ee6427Smrg *" $1 "*) ;; 132097ee6427Smrg *) func_internal_error "invalid warning category '$1'" ;; 132197ee6427Smrg esac 132297ee6427Smrg 132397ee6427Smrg _G_category=$1 132497ee6427Smrg shift 132597ee6427Smrg 132697ee6427Smrg case " $opt_warning_types " in 132797ee6427Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132897ee6427Smrg esac 132997ee6427Smrg} 133097ee6427Smrg 133197ee6427Smrg 133297ee6427Smrg# func_sort_ver VER1 VER2 133397ee6427Smrg# ----------------------- 133497ee6427Smrg# 'sort -V' is not generally available. 133597ee6427Smrg# Note this deviates from the version comparison in automake 133697ee6427Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133797ee6427Smrg# but this should suffice as we won't be specifying old 133897ee6427Smrg# version formats or redundant trailing .0 in bootstrap.conf. 133997ee6427Smrg# If we did want full compatibility then we should probably 134097ee6427Smrg# use m4_version_compare from autoconf. 134197ee6427Smrgfunc_sort_ver () 134297ee6427Smrg{ 134397ee6427Smrg $debug_cmd 134497ee6427Smrg 134597ee6427Smrg printf '%s\n%s\n' "$1" "$2" \ 134697ee6427Smrg | 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 134797ee6427Smrg} 134897ee6427Smrg 134997ee6427Smrg# func_lt_ver PREV CURR 135097ee6427Smrg# --------------------- 135197ee6427Smrg# Return true if PREV and CURR are in the correct order according to 135297ee6427Smrg# func_sort_ver, otherwise false. Use it like this: 135397ee6427Smrg# 135497ee6427Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135597ee6427Smrgfunc_lt_ver () 135697ee6427Smrg{ 135797ee6427Smrg $debug_cmd 135897ee6427Smrg 135997ee6427Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136097ee6427Smrg} 136197ee6427Smrg 136297ee6427Smrg 136397ee6427Smrg# Local variables: 136497ee6427Smrg# mode: shell-script 136597ee6427Smrg# sh-indentation: 2 136697ee6427Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 136797ee6427Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136897ee6427Smrg# time-stamp-time-zone: "UTC" 136997ee6427Smrg# End: 137097ee6427Smrg#! /bin/sh 137197ee6427Smrg 137297ee6427Smrg# Set a version string for this script. 137397ee6427Smrgscriptversion=2014-01-07.03; # UTC 137497ee6427Smrg 137597ee6427Smrg# A portable, pluggable option parser for Bourne shell. 137697ee6427Smrg# Written by Gary V. Vaughan, 2010 137797ee6427Smrg 137897ee6427Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137997ee6427Smrg# This is free software; see the source for copying conditions. There is NO 138097ee6427Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138197ee6427Smrg 138297ee6427Smrg# This program is free software: you can redistribute it and/or modify 138397ee6427Smrg# it under the terms of the GNU General Public License as published by 138497ee6427Smrg# the Free Software Foundation, either version 3 of the License, or 138597ee6427Smrg# (at your option) any later version. 138697ee6427Smrg 138797ee6427Smrg# This program is distributed in the hope that it will be useful, 138897ee6427Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138997ee6427Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139097ee6427Smrg# GNU General Public License for more details. 139197ee6427Smrg 139297ee6427Smrg# You should have received a copy of the GNU General Public License 139397ee6427Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139497ee6427Smrg 139597ee6427Smrg# Please report bugs or propose patches to gary@gnu.org. 139697ee6427Smrg 139797ee6427Smrg 139897ee6427Smrg## ------ ## 139997ee6427Smrg## Usage. ## 140097ee6427Smrg## ------ ## 140197ee6427Smrg 140297ee6427Smrg# This file is a library for parsing options in your shell scripts along 140397ee6427Smrg# with assorted other useful supporting features that you can make use 140497ee6427Smrg# of too. 140597ee6427Smrg# 140697ee6427Smrg# For the simplest scripts you might need only: 140797ee6427Smrg# 140897ee6427Smrg# #!/bin/sh 140997ee6427Smrg# . relative/path/to/funclib.sh 141097ee6427Smrg# . relative/path/to/options-parser 141197ee6427Smrg# scriptversion=1.0 141297ee6427Smrg# func_options ${1+"$@"} 141397ee6427Smrg# eval set dummy "$func_options_result"; shift 141497ee6427Smrg# ...rest of your script... 141597ee6427Smrg# 141697ee6427Smrg# In order for the '--version' option to work, you will need to have a 141797ee6427Smrg# suitably formatted comment like the one at the top of this file 141897ee6427Smrg# starting with '# Written by ' and ending with '# warranty; '. 141997ee6427Smrg# 142097ee6427Smrg# For '-h' and '--help' to work, you will also need a one line 142197ee6427Smrg# description of your script's purpose in a comment directly above the 142297ee6427Smrg# '# Written by ' line, like the one at the top of this file. 142397ee6427Smrg# 142497ee6427Smrg# The default options also support '--debug', which will turn on shell 142597ee6427Smrg# execution tracing (see the comment above debug_cmd below for another 142697ee6427Smrg# use), and '--verbose' and the func_verbose function to allow your script 142797ee6427Smrg# to display verbose messages only when your user has specified 142897ee6427Smrg# '--verbose'. 142997ee6427Smrg# 143097ee6427Smrg# After sourcing this file, you can plug processing for additional 143197ee6427Smrg# options by amending the variables from the 'Configuration' section 143297ee6427Smrg# below, and following the instructions in the 'Option parsing' 143397ee6427Smrg# section further down. 143497ee6427Smrg 143597ee6427Smrg## -------------- ## 143697ee6427Smrg## Configuration. ## 143797ee6427Smrg## -------------- ## 143897ee6427Smrg 143997ee6427Smrg# You should override these variables in your script after sourcing this 144097ee6427Smrg# file so that they reflect the customisations you have added to the 144197ee6427Smrg# option parser. 144297ee6427Smrg 144397ee6427Smrg# The usage line for option parsing errors and the start of '-h' and 144497ee6427Smrg# '--help' output messages. You can embed shell variables for delayed 144597ee6427Smrg# expansion at the time the message is displayed, but you will need to 144697ee6427Smrg# quote other shell meta-characters carefully to prevent them being 144797ee6427Smrg# expanded when the contents are evaled. 144897ee6427Smrgusage='$progpath [OPTION]...' 144997ee6427Smrg 145097ee6427Smrg# Short help message in response to '-h' and '--help'. Add to this or 145197ee6427Smrg# override it after sourcing this library to reflect the full set of 145297ee6427Smrg# options your script accepts. 145397ee6427Smrgusage_message="\ 145497ee6427Smrg --debug enable verbose shell tracing 145597ee6427Smrg -W, --warnings=CATEGORY 145697ee6427Smrg report the warnings falling in CATEGORY [all] 145797ee6427Smrg -v, --verbose verbosely report processing 145897ee6427Smrg --version print version information and exit 145997ee6427Smrg -h, --help print short or long help message and exit 146097ee6427Smrg" 146197ee6427Smrg 146297ee6427Smrg# Additional text appended to 'usage_message' in response to '--help'. 146397ee6427Smrglong_help_message=" 146497ee6427SmrgWarning categories include: 146597ee6427Smrg 'all' show all warnings 146697ee6427Smrg 'none' turn off all the warnings 146797ee6427Smrg 'error' warnings are treated as fatal errors" 146897ee6427Smrg 146997ee6427Smrg# Help message printed before fatal option parsing errors. 147097ee6427Smrgfatal_help="Try '\$progname --help' for more information." 147197ee6427Smrg 147297ee6427Smrg 147397ee6427Smrg 147497ee6427Smrg## ------------------------- ## 147597ee6427Smrg## Hook function management. ## 147697ee6427Smrg## ------------------------- ## 147797ee6427Smrg 147897ee6427Smrg# This section contains functions for adding, removing, and running hooks 147997ee6427Smrg# to the main code. A hook is just a named list of of function, that can 148097ee6427Smrg# be run in order later on. 148197ee6427Smrg 148297ee6427Smrg# func_hookable FUNC_NAME 148397ee6427Smrg# ----------------------- 148497ee6427Smrg# Declare that FUNC_NAME will run hooks added with 148597ee6427Smrg# 'func_add_hook FUNC_NAME ...'. 148697ee6427Smrgfunc_hookable () 148797ee6427Smrg{ 148897ee6427Smrg $debug_cmd 148997ee6427Smrg 149097ee6427Smrg func_append hookable_fns " $1" 149197ee6427Smrg} 149297ee6427Smrg 149397ee6427Smrg 149497ee6427Smrg# func_add_hook FUNC_NAME HOOK_FUNC 149597ee6427Smrg# --------------------------------- 149697ee6427Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149797ee6427Smrg# first have been declared "hookable" by a call to 'func_hookable'. 149897ee6427Smrgfunc_add_hook () 149997ee6427Smrg{ 150097ee6427Smrg $debug_cmd 150197ee6427Smrg 150297ee6427Smrg case " $hookable_fns " in 150397ee6427Smrg *" $1 "*) ;; 150497ee6427Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150597ee6427Smrg esac 150697ee6427Smrg 150797ee6427Smrg eval func_append ${1}_hooks '" $2"' 150897ee6427Smrg} 150997ee6427Smrg 151097ee6427Smrg 151197ee6427Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 151297ee6427Smrg# ------------------------------------ 151397ee6427Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151497ee6427Smrgfunc_remove_hook () 151597ee6427Smrg{ 151697ee6427Smrg $debug_cmd 151797ee6427Smrg 151897ee6427Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151997ee6427Smrg} 152097ee6427Smrg 152197ee6427Smrg 152297ee6427Smrg# func_run_hooks FUNC_NAME [ARG]... 152397ee6427Smrg# --------------------------------- 152497ee6427Smrg# Run all hook functions registered to FUNC_NAME. 152597ee6427Smrg# It is assumed that the list of hook functions contains nothing more 152697ee6427Smrg# than a whitespace-delimited list of legal shell function names, and 152797ee6427Smrg# no effort is wasted trying to catch shell meta-characters or preserve 152897ee6427Smrg# whitespace. 152997ee6427Smrgfunc_run_hooks () 153097ee6427Smrg{ 153197ee6427Smrg $debug_cmd 153297ee6427Smrg 153397ee6427Smrg case " $hookable_fns " in 153497ee6427Smrg *" $1 "*) ;; 153597ee6427Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153697ee6427Smrg esac 153797ee6427Smrg 153897ee6427Smrg eval _G_hook_fns=\$$1_hooks; shift 153997ee6427Smrg 154097ee6427Smrg for _G_hook in $_G_hook_fns; do 154197ee6427Smrg eval $_G_hook '"$@"' 154297ee6427Smrg 154397ee6427Smrg # store returned options list back into positional 154497ee6427Smrg # parameters for next 'cmd' execution. 154597ee6427Smrg eval _G_hook_result=\$${_G_hook}_result 154697ee6427Smrg eval set dummy "$_G_hook_result"; shift 154797ee6427Smrg done 154897ee6427Smrg 154997ee6427Smrg func_quote_for_eval ${1+"$@"} 155097ee6427Smrg func_run_hooks_result=$func_quote_for_eval_result 155197ee6427Smrg} 155297ee6427Smrg 155397ee6427Smrg 155497ee6427Smrg 155597ee6427Smrg## --------------- ## 155697ee6427Smrg## Option parsing. ## 155797ee6427Smrg## --------------- ## 155897ee6427Smrg 155997ee6427Smrg# In order to add your own option parsing hooks, you must accept the 156097ee6427Smrg# full positional parameter list in your hook function, remove any 156197ee6427Smrg# options that you action, and then pass back the remaining unprocessed 156297ee6427Smrg# options in '<hooked_function_name>_result', escaped suitably for 156397ee6427Smrg# 'eval'. Like this: 156497ee6427Smrg# 156597ee6427Smrg# my_options_prep () 156697ee6427Smrg# { 156797ee6427Smrg# $debug_cmd 156897ee6427Smrg# 156997ee6427Smrg# # Extend the existing usage message. 157097ee6427Smrg# usage_message=$usage_message' 157197ee6427Smrg# -s, --silent don'\''t print informational messages 157297ee6427Smrg# ' 157397ee6427Smrg# 157497ee6427Smrg# func_quote_for_eval ${1+"$@"} 157597ee6427Smrg# my_options_prep_result=$func_quote_for_eval_result 157697ee6427Smrg# } 157797ee6427Smrg# func_add_hook func_options_prep my_options_prep 157897ee6427Smrg# 157997ee6427Smrg# 158097ee6427Smrg# my_silent_option () 158197ee6427Smrg# { 158297ee6427Smrg# $debug_cmd 158397ee6427Smrg# 158497ee6427Smrg# # Note that for efficiency, we parse as many options as we can 158597ee6427Smrg# # recognise in a loop before passing the remainder back to the 158697ee6427Smrg# # caller on the first unrecognised argument we encounter. 158797ee6427Smrg# while test $# -gt 0; do 158897ee6427Smrg# opt=$1; shift 158997ee6427Smrg# case $opt in 159097ee6427Smrg# --silent|-s) opt_silent=: ;; 159197ee6427Smrg# # Separate non-argument short options: 159297ee6427Smrg# -s*) func_split_short_opt "$_G_opt" 159397ee6427Smrg# set dummy "$func_split_short_opt_name" \ 159497ee6427Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 159597ee6427Smrg# shift 159697ee6427Smrg# ;; 159797ee6427Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159897ee6427Smrg# esac 159997ee6427Smrg# done 160097ee6427Smrg# 160197ee6427Smrg# func_quote_for_eval ${1+"$@"} 160297ee6427Smrg# my_silent_option_result=$func_quote_for_eval_result 160397ee6427Smrg# } 160497ee6427Smrg# func_add_hook func_parse_options my_silent_option 160597ee6427Smrg# 160697ee6427Smrg# 160797ee6427Smrg# my_option_validation () 160897ee6427Smrg# { 160997ee6427Smrg# $debug_cmd 161097ee6427Smrg# 161197ee6427Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161297ee6427Smrg# '--silent' and '--verbose' options are mutually exclusive." 161397ee6427Smrg# 161497ee6427Smrg# func_quote_for_eval ${1+"$@"} 161597ee6427Smrg# my_option_validation_result=$func_quote_for_eval_result 161697ee6427Smrg# } 161797ee6427Smrg# func_add_hook func_validate_options my_option_validation 161897ee6427Smrg# 161997ee6427Smrg# You'll alse need to manually amend $usage_message to reflect the extra 162097ee6427Smrg# options you parse. It's preferable to append if you can, so that 162197ee6427Smrg# multiple option parsing hooks can be added safely. 162297ee6427Smrg 162397ee6427Smrg 162497ee6427Smrg# func_options [ARG]... 162597ee6427Smrg# --------------------- 162697ee6427Smrg# All the functions called inside func_options are hookable. See the 162797ee6427Smrg# individual implementations for details. 162897ee6427Smrgfunc_hookable func_options 162997ee6427Smrgfunc_options () 163097ee6427Smrg{ 163197ee6427Smrg $debug_cmd 163297ee6427Smrg 163397ee6427Smrg func_options_prep ${1+"$@"} 163497ee6427Smrg eval func_parse_options \ 163597ee6427Smrg ${func_options_prep_result+"$func_options_prep_result"} 163697ee6427Smrg eval func_validate_options \ 163797ee6427Smrg ${func_parse_options_result+"$func_parse_options_result"} 163897ee6427Smrg 163997ee6427Smrg eval func_run_hooks func_options \ 164097ee6427Smrg ${func_validate_options_result+"$func_validate_options_result"} 164197ee6427Smrg 164297ee6427Smrg # save modified positional parameters for caller 164397ee6427Smrg func_options_result=$func_run_hooks_result 1644301ea0f4Smrg} 1645301ea0f4Smrg 1646301ea0f4Smrg 164797ee6427Smrg# func_options_prep [ARG]... 164897ee6427Smrg# -------------------------- 164997ee6427Smrg# All initialisations required before starting the option parse loop. 165097ee6427Smrg# Note that when calling hook functions, we pass through the list of 165197ee6427Smrg# positional parameters. If a hook function modifies that list, and 165297ee6427Smrg# needs to propogate that back to rest of this script, then the complete 165397ee6427Smrg# modified list must be put in 'func_run_hooks_result' before 165497ee6427Smrg# returning. 165597ee6427Smrgfunc_hookable func_options_prep 165697ee6427Smrgfunc_options_prep () 1657301ea0f4Smrg{ 165897ee6427Smrg $debug_cmd 1659213fdd94Smrg 166097ee6427Smrg # Option defaults: 166197ee6427Smrg opt_verbose=false 166297ee6427Smrg opt_warning_types= 166397ee6427Smrg 166497ee6427Smrg func_run_hooks func_options_prep ${1+"$@"} 166597ee6427Smrg 166697ee6427Smrg # save modified positional parameters for caller 166797ee6427Smrg func_options_prep_result=$func_run_hooks_result 1668213fdd94Smrg} 1669213fdd94Smrg 1670213fdd94Smrg 167197ee6427Smrg# func_parse_options [ARG]... 167297ee6427Smrg# --------------------------- 167397ee6427Smrg# The main option parsing loop. 167497ee6427Smrgfunc_hookable func_parse_options 167597ee6427Smrgfunc_parse_options () 1676213fdd94Smrg{ 167797ee6427Smrg $debug_cmd 1678213fdd94Smrg 167997ee6427Smrg func_parse_options_result= 1680213fdd94Smrg 168197ee6427Smrg # this just eases exit handling 168297ee6427Smrg while test $# -gt 0; do 168397ee6427Smrg # Defer to hook functions for initial option parsing, so they 168497ee6427Smrg # get priority in the event of reusing an option name. 168597ee6427Smrg func_run_hooks func_parse_options ${1+"$@"} 1686213fdd94Smrg 168797ee6427Smrg # Adjust func_parse_options positional parameters to match 168897ee6427Smrg eval set dummy "$func_run_hooks_result"; shift 1689213fdd94Smrg 169097ee6427Smrg # Break out of the loop if we already parsed every option. 169197ee6427Smrg test $# -gt 0 || break 1692213fdd94Smrg 169397ee6427Smrg _G_opt=$1 169497ee6427Smrg shift 169597ee6427Smrg case $_G_opt in 169697ee6427Smrg --debug|-x) debug_cmd='set -x' 169797ee6427Smrg func_echo "enabling shell trace mode" 169897ee6427Smrg $debug_cmd 169997ee6427Smrg ;; 170097ee6427Smrg 170197ee6427Smrg --no-warnings|--no-warning|--no-warn) 170297ee6427Smrg set dummy --warnings none ${1+"$@"} 170397ee6427Smrg shift 170497ee6427Smrg ;; 1705213fdd94Smrg 170697ee6427Smrg --warnings|--warning|-W) 170797ee6427Smrg test $# = 0 && func_missing_arg $_G_opt && break 170897ee6427Smrg case " $warning_categories $1" in 170997ee6427Smrg *" $1 "*) 171097ee6427Smrg # trailing space prevents matching last $1 above 171197ee6427Smrg func_append_uniq opt_warning_types " $1" 171297ee6427Smrg ;; 171397ee6427Smrg *all) 171497ee6427Smrg opt_warning_types=$warning_categories 171597ee6427Smrg ;; 171697ee6427Smrg *none) 171797ee6427Smrg opt_warning_types=none 171897ee6427Smrg warning_func=: 171997ee6427Smrg ;; 172097ee6427Smrg *error) 172197ee6427Smrg opt_warning_types=$warning_categories 172297ee6427Smrg warning_func=func_fatal_error 172397ee6427Smrg ;; 172497ee6427Smrg *) 172597ee6427Smrg func_fatal_error \ 172697ee6427Smrg "unsupported warning category: '$1'" 172797ee6427Smrg ;; 172897ee6427Smrg esac 172997ee6427Smrg shift 173097ee6427Smrg ;; 173197ee6427Smrg 173297ee6427Smrg --verbose|-v) opt_verbose=: ;; 173397ee6427Smrg --version) func_version ;; 173497ee6427Smrg -\?|-h) func_usage ;; 173597ee6427Smrg --help) func_help ;; 173697ee6427Smrg 173797ee6427Smrg # Separate optargs to long options (plugins may need this): 173897ee6427Smrg --*=*) func_split_equals "$_G_opt" 173997ee6427Smrg set dummy "$func_split_equals_lhs" \ 174097ee6427Smrg "$func_split_equals_rhs" ${1+"$@"} 174197ee6427Smrg shift 174297ee6427Smrg ;; 174397ee6427Smrg 174497ee6427Smrg # Separate optargs to short options: 174597ee6427Smrg -W*) 174697ee6427Smrg func_split_short_opt "$_G_opt" 174797ee6427Smrg set dummy "$func_split_short_opt_name" \ 174897ee6427Smrg "$func_split_short_opt_arg" ${1+"$@"} 174997ee6427Smrg shift 175097ee6427Smrg ;; 175197ee6427Smrg 175297ee6427Smrg # Separate non-argument short options: 175397ee6427Smrg -\?*|-h*|-v*|-x*) 175497ee6427Smrg func_split_short_opt "$_G_opt" 175597ee6427Smrg set dummy "$func_split_short_opt_name" \ 175697ee6427Smrg "-$func_split_short_opt_arg" ${1+"$@"} 175797ee6427Smrg shift 175897ee6427Smrg ;; 175997ee6427Smrg 176097ee6427Smrg --) break ;; 176197ee6427Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176297ee6427Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176397ee6427Smrg esac 176497ee6427Smrg done 176597ee6427Smrg 176697ee6427Smrg # save modified positional parameters for caller 176797ee6427Smrg func_quote_for_eval ${1+"$@"} 176897ee6427Smrg func_parse_options_result=$func_quote_for_eval_result 1769213fdd94Smrg} 1770213fdd94Smrg 1771213fdd94Smrg 177297ee6427Smrg# func_validate_options [ARG]... 177397ee6427Smrg# ------------------------------ 177497ee6427Smrg# Perform any sanity checks on option settings and/or unconsumed 177597ee6427Smrg# arguments. 177697ee6427Smrgfunc_hookable func_validate_options 177797ee6427Smrgfunc_validate_options () 1778213fdd94Smrg{ 177997ee6427Smrg $debug_cmd 1780213fdd94Smrg 178197ee6427Smrg # Display all warnings if -W was not given. 178297ee6427Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783213fdd94Smrg 178497ee6427Smrg func_run_hooks func_validate_options ${1+"$@"} 1785213fdd94Smrg 178697ee6427Smrg # Bail if the options were screwed! 178797ee6427Smrg $exit_cmd $EXIT_FAILURE 178897ee6427Smrg 178997ee6427Smrg # save modified positional parameters for caller 179097ee6427Smrg func_validate_options_result=$func_run_hooks_result 1791301ea0f4Smrg} 1792301ea0f4Smrg 1793301ea0f4Smrg 1794213fdd94Smrg 179597ee6427Smrg## ----------------- ## 179697ee6427Smrg## Helper functions. ## 179797ee6427Smrg## ----------------- ## 1798301ea0f4Smrg 179997ee6427Smrg# This section contains the helper functions used by the rest of the 180097ee6427Smrg# hookable option parser framework in ascii-betical order. 180197ee6427Smrg 180297ee6427Smrg 180397ee6427Smrg# func_fatal_help ARG... 180497ee6427Smrg# ---------------------- 180597ee6427Smrg# Echo program name prefixed message to standard error, followed by 180697ee6427Smrg# a help hint, and exit. 180797ee6427Smrgfunc_fatal_help () 1808301ea0f4Smrg{ 180997ee6427Smrg $debug_cmd 1810213fdd94Smrg 181197ee6427Smrg eval \$ECHO \""Usage: $usage"\" 181297ee6427Smrg eval \$ECHO \""$fatal_help"\" 181397ee6427Smrg func_error ${1+"$@"} 181497ee6427Smrg exit $EXIT_FAILURE 1815301ea0f4Smrg} 1816301ea0f4Smrg 181797ee6427Smrg 181897ee6427Smrg# func_help 181997ee6427Smrg# --------- 182097ee6427Smrg# Echo long help message to standard output and exit. 1821213fdd94Smrgfunc_help () 1822301ea0f4Smrg{ 182397ee6427Smrg $debug_cmd 182497ee6427Smrg 182597ee6427Smrg func_usage_message 182697ee6427Smrg $ECHO "$long_help_message" 182797ee6427Smrg exit 0 1828213fdd94Smrg} 1829301ea0f4Smrg 183097ee6427Smrg 183197ee6427Smrg# func_missing_arg ARGNAME 183297ee6427Smrg# ------------------------ 1833213fdd94Smrg# Echo program name prefixed message to standard error and set global 1834213fdd94Smrg# exit_cmd. 1835213fdd94Smrgfunc_missing_arg () 1836213fdd94Smrg{ 183797ee6427Smrg $debug_cmd 1838301ea0f4Smrg 183997ee6427Smrg func_error "Missing argument for '$1'." 1840213fdd94Smrg exit_cmd=exit 18410cc67336Smrg} 18420cc67336Smrg 18430cc67336Smrg 184497ee6427Smrg# func_split_equals STRING 184597ee6427Smrg# ------------------------ 184697ee6427Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184797ee6427Smrg# splitting STRING at the '=' sign. 184897ee6427Smrgtest -z "$_G_HAVE_XSI_OPS" \ 184997ee6427Smrg && (eval 'x=a/b/c; 185097ee6427Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185197ee6427Smrg && _G_HAVE_XSI_OPS=yes 185297ee6427Smrg 185397ee6427Smrgif test yes = "$_G_HAVE_XSI_OPS" 185497ee6427Smrgthen 185597ee6427Smrg # This is an XSI compatible shell, allowing a faster implementation... 185697ee6427Smrg eval 'func_split_equals () 185797ee6427Smrg { 185897ee6427Smrg $debug_cmd 185997ee6427Smrg 186097ee6427Smrg func_split_equals_lhs=${1%%=*} 186197ee6427Smrg func_split_equals_rhs=${1#*=} 186297ee6427Smrg test "x$func_split_equals_lhs" = "x$1" \ 186397ee6427Smrg && func_split_equals_rhs= 186497ee6427Smrg }' 186597ee6427Smrgelse 186697ee6427Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 186797ee6427Smrg func_split_equals () 186897ee6427Smrg { 186997ee6427Smrg $debug_cmd 187097ee6427Smrg 187197ee6427Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187297ee6427Smrg func_split_equals_rhs= 187397ee6427Smrg test "x$func_split_equals_lhs" = "x$1" \ 187497ee6427Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187597ee6427Smrg } 187697ee6427Smrgfi #func_split_equals 187797ee6427Smrg 187897ee6427Smrg 187997ee6427Smrg# func_split_short_opt SHORTOPT 188097ee6427Smrg# ----------------------------- 1881213fdd94Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882213fdd94Smrg# variables after splitting SHORTOPT after the 2nd character. 188397ee6427Smrgif test yes = "$_G_HAVE_XSI_OPS" 188497ee6427Smrgthen 188597ee6427Smrg # This is an XSI compatible shell, allowing a faster implementation... 188697ee6427Smrg eval 'func_split_short_opt () 188797ee6427Smrg { 188897ee6427Smrg $debug_cmd 188997ee6427Smrg 189097ee6427Smrg func_split_short_opt_arg=${1#??} 189197ee6427Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189297ee6427Smrg }' 189397ee6427Smrgelse 189497ee6427Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 189597ee6427Smrg func_split_short_opt () 189697ee6427Smrg { 189797ee6427Smrg $debug_cmd 189897ee6427Smrg 189997ee6427Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190097ee6427Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190197ee6427Smrg } 190297ee6427Smrgfi #func_split_short_opt 190397ee6427Smrg 190497ee6427Smrg 190597ee6427Smrg# func_usage 190697ee6427Smrg# ---------- 190797ee6427Smrg# Echo short help message to standard output and exit. 190897ee6427Smrgfunc_usage () 1909213fdd94Smrg{ 191097ee6427Smrg $debug_cmd 1911213fdd94Smrg 191297ee6427Smrg func_usage_message 191397ee6427Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191497ee6427Smrg exit 0 191597ee6427Smrg} 19160cc67336Smrg 1917301ea0f4Smrg 191897ee6427Smrg# func_usage_message 191997ee6427Smrg# ------------------ 192097ee6427Smrg# Echo short help message to standard output. 192197ee6427Smrgfunc_usage_message () 1922213fdd94Smrg{ 192397ee6427Smrg $debug_cmd 1924301ea0f4Smrg 192597ee6427Smrg eval \$ECHO \""Usage: $usage"\" 192697ee6427Smrg echo 192797ee6427Smrg $SED -n 's|^# || 192897ee6427Smrg /^Written by/{ 192997ee6427Smrg x;p;x 193097ee6427Smrg } 193197ee6427Smrg h 193297ee6427Smrg /^Written by/q' < "$progpath" 193397ee6427Smrg echo 193497ee6427Smrg eval \$ECHO \""$usage_message"\" 193597ee6427Smrg} 1936301ea0f4Smrg 1937301ea0f4Smrg 193897ee6427Smrg# func_version 193997ee6427Smrg# ------------ 194097ee6427Smrg# Echo version message to standard output and exit. 194197ee6427Smrgfunc_version () 194297ee6427Smrg{ 194397ee6427Smrg $debug_cmd 19440cc67336Smrg 194597ee6427Smrg printf '%s\n' "$progname $scriptversion" 194697ee6427Smrg $SED -n ' 194797ee6427Smrg /(C)/!b go 194897ee6427Smrg :more 194997ee6427Smrg /\./!{ 195097ee6427Smrg N 195197ee6427Smrg s|\n# | | 195297ee6427Smrg b more 195397ee6427Smrg } 195497ee6427Smrg :go 195597ee6427Smrg /^# Written by /,/# warranty; / { 195697ee6427Smrg s|^# || 195797ee6427Smrg s|^# *$|| 195897ee6427Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195997ee6427Smrg p 196097ee6427Smrg } 196197ee6427Smrg /^# Written by / { 196297ee6427Smrg s|^# || 196397ee6427Smrg p 196497ee6427Smrg } 196597ee6427Smrg /^warranty; /q' < "$progpath" 19660cc67336Smrg 196797ee6427Smrg exit $? 196897ee6427Smrg} 19690cc67336Smrg 1970301ea0f4Smrg 197197ee6427Smrg# Local variables: 197297ee6427Smrg# mode: shell-script 197397ee6427Smrg# sh-indentation: 2 197497ee6427Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 197597ee6427Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197697ee6427Smrg# time-stamp-time-zone: "UTC" 197797ee6427Smrg# End: 1978213fdd94Smrg 197997ee6427Smrg# Set a version string. 198097ee6427Smrgscriptversion='(GNU libtool) 2.4.6' 1981213fdd94Smrg 1982213fdd94Smrg 198397ee6427Smrg# func_echo ARG... 198497ee6427Smrg# ---------------- 198597ee6427Smrg# Libtool also displays the current mode in messages, so override 198697ee6427Smrg# funclib.sh func_echo with this custom definition. 198797ee6427Smrgfunc_echo () 1988213fdd94Smrg{ 198997ee6427Smrg $debug_cmd 1990213fdd94Smrg 199197ee6427Smrg _G_message=$* 1992213fdd94Smrg 199397ee6427Smrg func_echo_IFS=$IFS 199497ee6427Smrg IFS=$nl 199597ee6427Smrg for _G_line in $_G_message; do 199697ee6427Smrg IFS=$func_echo_IFS 199797ee6427Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199897ee6427Smrg done 199997ee6427Smrg IFS=$func_echo_IFS 200097ee6427Smrg} 2001213fdd94Smrg 200297ee6427Smrg 200397ee6427Smrg# func_warning ARG... 200497ee6427Smrg# ------------------- 200597ee6427Smrg# Libtool warnings are not categorized, so override funclib.sh 200697ee6427Smrg# func_warning with this simpler definition. 200797ee6427Smrgfunc_warning () 2008213fdd94Smrg{ 200997ee6427Smrg $debug_cmd 2010213fdd94Smrg 201197ee6427Smrg $warning_func ${1+"$@"} 201297ee6427Smrg} 2013213fdd94Smrg 2014213fdd94Smrg 201597ee6427Smrg## ---------------- ## 201697ee6427Smrg## Options parsing. ## 201797ee6427Smrg## ---------------- ## 201897ee6427Smrg 201997ee6427Smrg# Hook in the functions to make sure our own options are parsed during 202097ee6427Smrg# the option parsing loop. 202197ee6427Smrg 202297ee6427Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 202397ee6427Smrg 202497ee6427Smrg# Short help message in response to '-h'. 202597ee6427Smrgusage_message="Options: 202697ee6427Smrg --config show all configuration variables 202797ee6427Smrg --debug enable verbose shell tracing 202897ee6427Smrg -n, --dry-run display commands without modifying any files 202997ee6427Smrg --features display basic configuration information and exit 203097ee6427Smrg --mode=MODE use operation mode MODE 203197ee6427Smrg --no-warnings equivalent to '-Wnone' 203297ee6427Smrg --preserve-dup-deps don't remove duplicate dependency libraries 203397ee6427Smrg --quiet, --silent don't print informational messages 203497ee6427Smrg --tag=TAG use configuration variables from tag TAG 203597ee6427Smrg -v, --verbose print more informational messages than default 203697ee6427Smrg --version print version information 203797ee6427Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203897ee6427Smrg -h, --help, --help-all print short, long, or detailed help message 203997ee6427Smrg" 2040213fdd94Smrg 204197ee6427Smrg# Additional text appended to 'usage_message' in response to '--help'. 204297ee6427Smrgfunc_help () 2043213fdd94Smrg{ 204497ee6427Smrg $debug_cmd 204597ee6427Smrg 204697ee6427Smrg func_usage_message 204797ee6427Smrg $ECHO "$long_help_message 204897ee6427Smrg 204997ee6427SmrgMODE must be one of the following: 205097ee6427Smrg 205197ee6427Smrg clean remove files from the build directory 205297ee6427Smrg compile compile a source file into a libtool object 205397ee6427Smrg execute automatically set library path, then run a program 205497ee6427Smrg finish complete the installation of libtool libraries 205597ee6427Smrg install install libraries or executables 205697ee6427Smrg link create a library or an executable 205797ee6427Smrg uninstall remove libraries from an installed directory 205897ee6427Smrg 205997ee6427SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206097ee6427Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206197ee6427SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206297ee6427Smrg 206397ee6427SmrgWhen reporting a bug, please describe a test case to reproduce it and 206497ee6427Smrginclude the following information: 206597ee6427Smrg 206697ee6427Smrg host-triplet: $host 206797ee6427Smrg shell: $SHELL 206897ee6427Smrg compiler: $LTCC 206997ee6427Smrg compiler flags: $LTCFLAGS 207097ee6427Smrg linker: $LD (gnu? $with_gnu_ld) 207197ee6427Smrg version: $progname (GNU libtool) 2.4.6 207297ee6427Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207397ee6427Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207497ee6427Smrg 207597ee6427SmrgReport bugs to <bug-libtool@gnu.org>. 2076d94624a0SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 207797ee6427SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207897ee6427Smrg exit 0 207997ee6427Smrg} 2080213fdd94Smrg 2081213fdd94Smrg 208297ee6427Smrg# func_lo2o OBJECT-NAME 208397ee6427Smrg# --------------------- 208497ee6427Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208597ee6427Smrg# object suffix. 208697ee6427Smrg 208797ee6427Smrglo2o=s/\\.lo\$/.$objext/ 208897ee6427Smrgo2lo=s/\\.$objext\$/.lo/ 208997ee6427Smrg 209097ee6427Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 209197ee6427Smrg eval 'func_lo2o () 209297ee6427Smrg { 209397ee6427Smrg case $1 in 209497ee6427Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209597ee6427Smrg * ) func_lo2o_result=$1 ;; 209697ee6427Smrg esac 209797ee6427Smrg }' 209897ee6427Smrg 209997ee6427Smrg # func_xform LIBOBJ-OR-SOURCE 210097ee6427Smrg # --------------------------- 210197ee6427Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210297ee6427Smrg # suffix to a '.lo' libtool-object suffix. 210397ee6427Smrg eval 'func_xform () 210497ee6427Smrg { 210597ee6427Smrg func_xform_result=${1%.*}.lo 210697ee6427Smrg }' 210797ee6427Smrgelse 210897ee6427Smrg # ...otherwise fall back to using sed. 210997ee6427Smrg func_lo2o () 211097ee6427Smrg { 211197ee6427Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211297ee6427Smrg } 211397ee6427Smrg 211497ee6427Smrg func_xform () 211597ee6427Smrg { 211697ee6427Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211797ee6427Smrg } 211897ee6427Smrgfi 2119213fdd94Smrg 2120213fdd94Smrg 212197ee6427Smrg# func_fatal_configuration ARG... 212297ee6427Smrg# ------------------------------- 2123213fdd94Smrg# Echo program name prefixed message to standard error, followed by 2124213fdd94Smrg# a configuration failure hint, and exit. 2125213fdd94Smrgfunc_fatal_configuration () 2126213fdd94Smrg{ 212797ee6427Smrg func__fatal_error ${1+"$@"} \ 212897ee6427Smrg "See the $PACKAGE documentation for more information." \ 212997ee6427Smrg "Fatal configuration error." 2130213fdd94Smrg} 2131213fdd94Smrg 2132213fdd94Smrg 2133213fdd94Smrg# func_config 213497ee6427Smrg# ----------- 2135213fdd94Smrg# Display the configuration for all the tags in this script. 2136213fdd94Smrgfunc_config () 2137213fdd94Smrg{ 2138213fdd94Smrg re_begincf='^# ### BEGIN LIBTOOL' 2139213fdd94Smrg re_endcf='^# ### END LIBTOOL' 2140213fdd94Smrg 2141213fdd94Smrg # Default configuration. 2142213fdd94Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143213fdd94Smrg 2144301ea0f4Smrg # Now print the configurations for the tags. 2145301ea0f4Smrg for tagname in $taglist; do 2146213fdd94Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147301ea0f4Smrg done 2148ef6fb4a5Smrg 2149213fdd94Smrg exit $? 2150213fdd94Smrg} 2151ef6fb4a5Smrg 215297ee6427Smrg 2153213fdd94Smrg# func_features 215497ee6427Smrg# ------------- 2155213fdd94Smrg# Display the features supported by this script. 2156213fdd94Smrgfunc_features () 2157213fdd94Smrg{ 2158213fdd94Smrg echo "host: $host" 215997ee6427Smrg if test yes = "$build_libtool_libs"; then 2160213fdd94Smrg echo "enable shared libraries" 2161301ea0f4Smrg else 2162213fdd94Smrg echo "disable shared libraries" 2163301ea0f4Smrg fi 216497ee6427Smrg if test yes = "$build_old_libs"; then 2165213fdd94Smrg echo "enable static libraries" 2166301ea0f4Smrg else 2167213fdd94Smrg echo "disable static libraries" 2168301ea0f4Smrg fi 2169301ea0f4Smrg 2170213fdd94Smrg exit $? 2171213fdd94Smrg} 2172301ea0f4Smrg 217397ee6427Smrg 217497ee6427Smrg# func_enable_tag TAGNAME 217597ee6427Smrg# ----------------------- 2176213fdd94Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177213fdd94Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178213fdd94Smrg# variable here. 2179213fdd94Smrgfunc_enable_tag () 2180213fdd94Smrg{ 218197ee6427Smrg # Global variable: 218297ee6427Smrg tagname=$1 2183301ea0f4Smrg 218497ee6427Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218597ee6427Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218697ee6427Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187ef6fb4a5Smrg 218897ee6427Smrg # Validate tagname. 218997ee6427Smrg case $tagname in 219097ee6427Smrg *[!-_A-Za-z0-9,/]*) 219197ee6427Smrg func_fatal_error "invalid tag name: $tagname" 219297ee6427Smrg ;; 219397ee6427Smrg esac 2194ef6fb4a5Smrg 219597ee6427Smrg # Don't test for the "default" C tag, as we know it's 219697ee6427Smrg # there but not specially marked. 219797ee6427Smrg case $tagname in 219897ee6427Smrg CC) ;; 2199213fdd94Smrg *) 220097ee6427Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220197ee6427Smrg taglist="$taglist $tagname" 220297ee6427Smrg 220397ee6427Smrg # Evaluate the configuration. Be careful to quote the path 220497ee6427Smrg # and the sed script, to avoid splitting on whitespace, but 220597ee6427Smrg # also don't use non-portable quotes within backquotes within 220697ee6427Smrg # quotes we have to do it in 2 steps: 220797ee6427Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220897ee6427Smrg eval "$extractedcf" 220997ee6427Smrg else 221097ee6427Smrg func_error "ignoring unknown tag $tagname" 221197ee6427Smrg fi 221297ee6427Smrg ;; 221397ee6427Smrg esac 2214213fdd94Smrg} 2215ef6fb4a5Smrg 221697ee6427Smrg 2217213fdd94Smrg# func_check_version_match 221897ee6427Smrg# ------------------------ 2219213fdd94Smrg# Ensure that we are using m4 macros, and libtool script from the same 2220213fdd94Smrg# release of libtool. 2221213fdd94Smrgfunc_check_version_match () 2222213fdd94Smrg{ 222397ee6427Smrg if test "$package_revision" != "$macro_revision"; then 222497ee6427Smrg if test "$VERSION" != "$macro_version"; then 222597ee6427Smrg if test -z "$macro_version"; then 222697ee6427Smrg cat >&2 <<_LT_EOF 2227213fdd94Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228213fdd94Smrg$progname: definition of this LT_INIT comes from an older release. 2229213fdd94Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230213fdd94Smrg$progname: and run autoconf again. 2231213fdd94Smrg_LT_EOF 223297ee6427Smrg else 223397ee6427Smrg cat >&2 <<_LT_EOF 2234213fdd94Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235213fdd94Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236213fdd94Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237213fdd94Smrg$progname: and run autoconf again. 2238213fdd94Smrg_LT_EOF 223997ee6427Smrg fi 224097ee6427Smrg else 224197ee6427Smrg cat >&2 <<_LT_EOF 2242213fdd94Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243213fdd94Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244213fdd94Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245213fdd94Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2246213fdd94Smrg_LT_EOF 224797ee6427Smrg fi 2248ef6fb4a5Smrg 224997ee6427Smrg exit $EXIT_MISMATCH 225097ee6427Smrg fi 2251213fdd94Smrg} 2252301ea0f4Smrg 22530cc67336Smrg 225497ee6427Smrg# libtool_options_prep [ARG]... 225597ee6427Smrg# ----------------------------- 225697ee6427Smrg# Preparation for options parsed by libtool. 225797ee6427Smrglibtool_options_prep () 225897ee6427Smrg{ 225997ee6427Smrg $debug_mode 22600cc67336Smrg 226197ee6427Smrg # Option defaults: 226297ee6427Smrg opt_config=false 226397ee6427Smrg opt_dlopen= 226497ee6427Smrg opt_dry_run=false 226597ee6427Smrg opt_help=false 226697ee6427Smrg opt_mode= 226797ee6427Smrg opt_preserve_dup_deps=false 226897ee6427Smrg opt_quiet=false 22690cc67336Smrg 227097ee6427Smrg nonopt= 227197ee6427Smrg preserve_args= 22720cc67336Smrg 227397ee6427Smrg # Shorthand for --mode=foo, only valid as the first argument 227497ee6427Smrg case $1 in 227597ee6427Smrg clean|clea|cle|cl) 227697ee6427Smrg shift; set dummy --mode clean ${1+"$@"}; shift 227797ee6427Smrg ;; 227897ee6427Smrg compile|compil|compi|comp|com|co|c) 227997ee6427Smrg shift; set dummy --mode compile ${1+"$@"}; shift 228097ee6427Smrg ;; 228197ee6427Smrg execute|execut|execu|exec|exe|ex|e) 228297ee6427Smrg shift; set dummy --mode execute ${1+"$@"}; shift 228397ee6427Smrg ;; 228497ee6427Smrg finish|finis|fini|fin|fi|f) 228597ee6427Smrg shift; set dummy --mode finish ${1+"$@"}; shift 228697ee6427Smrg ;; 228797ee6427Smrg install|instal|insta|inst|ins|in|i) 228897ee6427Smrg shift; set dummy --mode install ${1+"$@"}; shift 228997ee6427Smrg ;; 229097ee6427Smrg link|lin|li|l) 229197ee6427Smrg shift; set dummy --mode link ${1+"$@"}; shift 229297ee6427Smrg ;; 229397ee6427Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229497ee6427Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229597ee6427Smrg ;; 229697ee6427Smrg esac 229797ee6427Smrg 229897ee6427Smrg # Pass back the list of options. 229997ee6427Smrg func_quote_for_eval ${1+"$@"} 230097ee6427Smrg libtool_options_prep_result=$func_quote_for_eval_result 230197ee6427Smrg} 230297ee6427Smrgfunc_add_hook func_options_prep libtool_options_prep 23030cc67336Smrg 2304213fdd94Smrg 230597ee6427Smrg# libtool_parse_options [ARG]... 230697ee6427Smrg# --------------------------------- 230797ee6427Smrg# Provide handling for libtool specific options. 230897ee6427Smrglibtool_parse_options () 2309213fdd94Smrg{ 231097ee6427Smrg $debug_cmd 2311301ea0f4Smrg 231297ee6427Smrg # Perform our own loop to consume as many options as possible in 231397ee6427Smrg # each iteration. 231497ee6427Smrg while test $# -gt 0; do 231597ee6427Smrg _G_opt=$1 231697ee6427Smrg shift 231797ee6427Smrg case $_G_opt in 231897ee6427Smrg --dry-run|--dryrun|-n) 231997ee6427Smrg opt_dry_run=: 232097ee6427Smrg ;; 232197ee6427Smrg 232297ee6427Smrg --config) func_config ;; 232397ee6427Smrg 232497ee6427Smrg --dlopen|-dlopen) 232597ee6427Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 232697ee6427Smrg}$1" 232797ee6427Smrg shift 232897ee6427Smrg ;; 232997ee6427Smrg 233097ee6427Smrg --preserve-dup-deps) 233197ee6427Smrg opt_preserve_dup_deps=: ;; 233297ee6427Smrg 233397ee6427Smrg --features) func_features ;; 233497ee6427Smrg 233597ee6427Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233697ee6427Smrg 233797ee6427Smrg --help) opt_help=: ;; 233897ee6427Smrg 233997ee6427Smrg --help-all) opt_help=': help-all' ;; 234097ee6427Smrg 234197ee6427Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234297ee6427Smrg opt_mode=$1 234397ee6427Smrg case $1 in 234497ee6427Smrg # Valid mode arguments: 234597ee6427Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234697ee6427Smrg 234797ee6427Smrg # Catch anything else as an error 234897ee6427Smrg *) func_error "invalid argument for $_G_opt" 234997ee6427Smrg exit_cmd=exit 235097ee6427Smrg break 235197ee6427Smrg ;; 235297ee6427Smrg esac 235397ee6427Smrg shift 235497ee6427Smrg ;; 235597ee6427Smrg 235697ee6427Smrg --no-silent|--no-quiet) 235797ee6427Smrg opt_quiet=false 235897ee6427Smrg func_append preserve_args " $_G_opt" 235997ee6427Smrg ;; 236097ee6427Smrg 236197ee6427Smrg --no-warnings|--no-warning|--no-warn) 236297ee6427Smrg opt_warning=false 236397ee6427Smrg func_append preserve_args " $_G_opt" 236497ee6427Smrg ;; 236597ee6427Smrg 236697ee6427Smrg --no-verbose) 236797ee6427Smrg opt_verbose=false 236897ee6427Smrg func_append preserve_args " $_G_opt" 236997ee6427Smrg ;; 237097ee6427Smrg 237197ee6427Smrg --silent|--quiet) 237297ee6427Smrg opt_quiet=: 237397ee6427Smrg opt_verbose=false 237497ee6427Smrg func_append preserve_args " $_G_opt" 237597ee6427Smrg ;; 237697ee6427Smrg 237797ee6427Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237897ee6427Smrg opt_tag=$1 237997ee6427Smrg func_append preserve_args " $_G_opt $1" 238097ee6427Smrg func_enable_tag "$1" 238197ee6427Smrg shift 238297ee6427Smrg ;; 238397ee6427Smrg 238497ee6427Smrg --verbose|-v) opt_quiet=false 238597ee6427Smrg opt_verbose=: 238697ee6427Smrg func_append preserve_args " $_G_opt" 238797ee6427Smrg ;; 238897ee6427Smrg 238997ee6427Smrg # An option not handled by this hook function: 239097ee6427Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239197ee6427Smrg esac 239297ee6427Smrg done 2393213fdd94Smrg 2394301ea0f4Smrg 239597ee6427Smrg # save modified positional parameters for caller 239697ee6427Smrg func_quote_for_eval ${1+"$@"} 239797ee6427Smrg libtool_parse_options_result=$func_quote_for_eval_result 239897ee6427Smrg} 239997ee6427Smrgfunc_add_hook func_parse_options libtool_parse_options 2400301ea0f4Smrg 2401301ea0f4Smrg 2402301ea0f4Smrg 240397ee6427Smrg# libtool_validate_options [ARG]... 240497ee6427Smrg# --------------------------------- 240597ee6427Smrg# Perform any sanity checks on option settings and/or unconsumed 240697ee6427Smrg# arguments. 240797ee6427Smrglibtool_validate_options () 240897ee6427Smrg{ 240997ee6427Smrg # save first non-option argument 241097ee6427Smrg if test 0 -lt $#; then 241197ee6427Smrg nonopt=$1 241297ee6427Smrg shift 2413213fdd94Smrg fi 24140cc67336Smrg 241597ee6427Smrg # preserve --debug 241697ee6427Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 24170cc67336Smrg 241897ee6427Smrg case $host in 241997ee6427Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242097ee6427Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242197ee6427Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242297ee6427Smrg # don't eliminate duplications in $postdeps and $predeps 242397ee6427Smrg opt_duplicate_compiler_generated_deps=: 242497ee6427Smrg ;; 242597ee6427Smrg *) 242697ee6427Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242797ee6427Smrg ;; 242897ee6427Smrg esac 24290cc67336Smrg 243097ee6427Smrg $opt_help || { 243197ee6427Smrg # Sanity checks first: 243297ee6427Smrg func_check_version_match 243397ee6427Smrg 243497ee6427Smrg test yes != "$build_libtool_libs" \ 243597ee6427Smrg && test yes != "$build_old_libs" \ 243697ee6427Smrg && func_fatal_configuration "not configured to build any kind of library" 243797ee6427Smrg 243897ee6427Smrg # Darwin sucks 243997ee6427Smrg eval std_shrext=\"$shrext_cmds\" 244097ee6427Smrg 244197ee6427Smrg # Only execute mode is allowed to have -dlopen flags. 244297ee6427Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244397ee6427Smrg func_error "unrecognized option '-dlopen'" 244497ee6427Smrg $ECHO "$help" 1>&2 244597ee6427Smrg exit $EXIT_FAILURE 244697ee6427Smrg fi 2447ef6fb4a5Smrg 244897ee6427Smrg # Change the help message to a mode-specific one. 244997ee6427Smrg generic_help=$help 245097ee6427Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 245197ee6427Smrg } 2452301ea0f4Smrg 245397ee6427Smrg # Pass back the unparsed argument list 245497ee6427Smrg func_quote_for_eval ${1+"$@"} 245597ee6427Smrg libtool_validate_options_result=$func_quote_for_eval_result 2456213fdd94Smrg} 245797ee6427Smrgfunc_add_hook func_validate_options libtool_validate_options 2458301ea0f4Smrg 2459301ea0f4Smrg 246097ee6427Smrg# Process options as early as possible so that --help and --version 246197ee6427Smrg# can return quickly. 246297ee6427Smrgfunc_options ${1+"$@"} 246397ee6427Smrgeval set dummy "$func_options_result"; shift 246497ee6427Smrg 2465ef6fb4a5Smrg 2466ef6fb4a5Smrg 2467213fdd94Smrg## ----------- ## 2468213fdd94Smrg## Main. ## 2469213fdd94Smrg## ----------- ## 2470301ea0f4Smrg 247197ee6427Smrgmagic='%%%MAGIC variable%%%' 247297ee6427Smrgmagic_exe='%%%MAGIC EXE variable%%%' 247397ee6427Smrg 247497ee6427Smrg# Global variables. 247597ee6427Smrgextracted_archives= 247697ee6427Smrgextracted_serial=0 247797ee6427Smrg 247897ee6427Smrg# If this variable is set in any of the actions, the command in it 247997ee6427Smrg# will be execed at the end. This prevents here-documents from being 248097ee6427Smrg# left over by shells. 248197ee6427Smrgexec_cmd= 248297ee6427Smrg 248397ee6427Smrg 248497ee6427Smrg# A function that is used when there is no print builtin or printf. 248597ee6427Smrgfunc_fallback_echo () 248697ee6427Smrg{ 248797ee6427Smrg eval 'cat <<_LTECHO_EOF 248897ee6427Smrg$1 248997ee6427Smrg_LTECHO_EOF' 249097ee6427Smrg} 249197ee6427Smrg 249297ee6427Smrg# func_generated_by_libtool 249397ee6427Smrg# True iff stdin has been generated by Libtool. This function is only 249497ee6427Smrg# a basic sanity check; it will hardly flush out determined imposters. 249597ee6427Smrgfunc_generated_by_libtool_p () 249697ee6427Smrg{ 249797ee6427Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249897ee6427Smrg} 249997ee6427Smrg 2500213fdd94Smrg# func_lalib_p file 250197ee6427Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502213fdd94Smrg# This function is only a basic sanity check; it will hardly flush out 2503213fdd94Smrg# determined imposters. 2504213fdd94Smrgfunc_lalib_p () 2505213fdd94Smrg{ 2506213fdd94Smrg test -f "$1" && 250797ee6427Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508213fdd94Smrg} 2509301ea0f4Smrg 2510213fdd94Smrg# func_lalib_unsafe_p file 251197ee6427Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512213fdd94Smrg# This function implements the same check as func_lalib_p without 2513213fdd94Smrg# resorting to external programs. To this end, it redirects stdin and 2514213fdd94Smrg# closes it afterwards, without saving the original file descriptor. 2515213fdd94Smrg# As a safety measure, use it only where a negative result would be 251697ee6427Smrg# fatal anyway. Works if 'file' does not exist. 2517213fdd94Smrgfunc_lalib_unsafe_p () 2518213fdd94Smrg{ 2519213fdd94Smrg lalib_p=no 2520213fdd94Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521213fdd94Smrg for lalib_p_l in 1 2 3 4 2522213fdd94Smrg do 2523213fdd94Smrg read lalib_p_line 252497ee6427Smrg case $lalib_p_line in 2525213fdd94Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526213fdd94Smrg esac 2527213fdd94Smrg done 2528213fdd94Smrg exec 0<&5 5<&- 2529213fdd94Smrg fi 253097ee6427Smrg test yes = "$lalib_p" 2531213fdd94Smrg} 2532301ea0f4Smrg 2533213fdd94Smrg# func_ltwrapper_script_p file 2534213fdd94Smrg# True iff FILE is a libtool wrapper script 2535213fdd94Smrg# This function is only a basic sanity check; it will hardly flush out 2536213fdd94Smrg# determined imposters. 2537213fdd94Smrgfunc_ltwrapper_script_p () 2538213fdd94Smrg{ 253997ee6427Smrg test -f "$1" && 254097ee6427Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541213fdd94Smrg} 2542ef6fb4a5Smrg 2543213fdd94Smrg# func_ltwrapper_executable_p file 2544213fdd94Smrg# True iff FILE is a libtool wrapper executable 2545213fdd94Smrg# This function is only a basic sanity check; it will hardly flush out 2546213fdd94Smrg# determined imposters. 2547213fdd94Smrgfunc_ltwrapper_executable_p () 2548213fdd94Smrg{ 2549213fdd94Smrg func_ltwrapper_exec_suffix= 2550213fdd94Smrg case $1 in 2551213fdd94Smrg *.exe) ;; 2552213fdd94Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553301ea0f4Smrg esac 2554213fdd94Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555213fdd94Smrg} 2556301ea0f4Smrg 2557213fdd94Smrg# func_ltwrapper_scriptname file 2558213fdd94Smrg# Assumes file is an ltwrapper_executable 2559213fdd94Smrg# uses $file to determine the appropriate filename for a 2560213fdd94Smrg# temporary ltwrapper_script. 2561213fdd94Smrgfunc_ltwrapper_scriptname () 2562213fdd94Smrg{ 2563213fdd94Smrg func_dirname_and_basename "$1" "" "." 2564213fdd94Smrg func_stripname '' '.exe' "$func_basename_result" 256597ee6427Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566213fdd94Smrg} 2567301ea0f4Smrg 2568213fdd94Smrg# func_ltwrapper_p file 2569213fdd94Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2570213fdd94Smrg# This function is only a basic sanity check; it will hardly flush out 2571213fdd94Smrg# determined imposters. 2572213fdd94Smrgfunc_ltwrapper_p () 2573213fdd94Smrg{ 2574213fdd94Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575213fdd94Smrg} 2576301ea0f4Smrg 2577301ea0f4Smrg 2578213fdd94Smrg# func_execute_cmds commands fail_cmd 2579213fdd94Smrg# Execute tilde-delimited COMMANDS. 2580213fdd94Smrg# If FAIL_CMD is given, eval that upon failure. 2581213fdd94Smrg# FAIL_CMD may read-access the current command in variable CMD! 2582213fdd94Smrgfunc_execute_cmds () 2583213fdd94Smrg{ 258497ee6427Smrg $debug_cmd 258597ee6427Smrg 2586213fdd94Smrg save_ifs=$IFS; IFS='~' 2587213fdd94Smrg for cmd in $1; do 258897ee6427Smrg IFS=$sp$nl 2589213fdd94Smrg eval cmd=\"$cmd\" 259097ee6427Smrg IFS=$save_ifs 2591213fdd94Smrg func_show_eval "$cmd" "${2-:}" 2592301ea0f4Smrg done 2593213fdd94Smrg IFS=$save_ifs 2594213fdd94Smrg} 2595301ea0f4Smrg 2596301ea0f4Smrg 2597213fdd94Smrg# func_source file 2598213fdd94Smrg# Source FILE, adding directory component if necessary. 2599213fdd94Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600213fdd94Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601213fdd94Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260297ee6427Smrg# 'FILE.' does not work on cygwin managed mounts. 2603213fdd94Smrgfunc_source () 2604213fdd94Smrg{ 260597ee6427Smrg $debug_cmd 260697ee6427Smrg 2607213fdd94Smrg case $1 in 2608213fdd94Smrg */* | *\\*) . "$1" ;; 2609213fdd94Smrg *) . "./$1" ;; 2610213fdd94Smrg esac 2611213fdd94Smrg} 2612301ea0f4Smrg 2613301ea0f4Smrg 2614213fdd94Smrg# func_resolve_sysroot PATH 2615213fdd94Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2616213fdd94Smrg# func_resolve_sysroot_result 2617213fdd94Smrgfunc_resolve_sysroot () 2618213fdd94Smrg{ 2619213fdd94Smrg func_resolve_sysroot_result=$1 2620213fdd94Smrg case $func_resolve_sysroot_result in 2621213fdd94Smrg =*) 2622213fdd94Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2623213fdd94Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624213fdd94Smrg ;; 2625213fdd94Smrg esac 2626213fdd94Smrg} 2627ef6fb4a5Smrg 2628213fdd94Smrg# func_replace_sysroot PATH 2629213fdd94Smrg# If PATH begins with the sysroot, replace it with = and 2630213fdd94Smrg# store the result into func_replace_sysroot_result. 2631213fdd94Smrgfunc_replace_sysroot () 2632213fdd94Smrg{ 263397ee6427Smrg case $lt_sysroot:$1 in 2634213fdd94Smrg ?*:"$lt_sysroot"*) 2635213fdd94Smrg func_stripname "$lt_sysroot" '' "$1" 263697ee6427Smrg func_replace_sysroot_result='='$func_stripname_result 2637213fdd94Smrg ;; 2638213fdd94Smrg *) 2639213fdd94Smrg # Including no sysroot. 2640213fdd94Smrg func_replace_sysroot_result=$1 2641213fdd94Smrg ;; 2642213fdd94Smrg esac 2643213fdd94Smrg} 2644301ea0f4Smrg 2645213fdd94Smrg# func_infer_tag arg 2646213fdd94Smrg# Infer tagged configuration to use if any are available and 2647213fdd94Smrg# if one wasn't chosen via the "--tag" command line option. 2648213fdd94Smrg# Only attempt this if the compiler in the base compile 2649213fdd94Smrg# command doesn't match the default compiler. 2650213fdd94Smrg# arg is usually of the form 'gcc ...' 2651213fdd94Smrgfunc_infer_tag () 2652213fdd94Smrg{ 265397ee6427Smrg $debug_cmd 265497ee6427Smrg 2655213fdd94Smrg if test -n "$available_tags" && test -z "$tagname"; then 2656213fdd94Smrg CC_quoted= 2657213fdd94Smrg for arg in $CC; do 2658213fdd94Smrg func_append_quoted CC_quoted "$arg" 2659213fdd94Smrg done 2660213fdd94Smrg CC_expanded=`func_echo_all $CC` 2661213fdd94Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662213fdd94Smrg case $@ in 2663213fdd94Smrg # Blanks in the command may have been stripped by the calling shell, 2664213fdd94Smrg # but not from the CC environment variable when configure was run. 2665213fdd94Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666213fdd94Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667213fdd94Smrg # Blanks at the start of $base_compile will cause this to fail 2668213fdd94Smrg # if we don't check for them as well. 2669213fdd94Smrg *) 2670213fdd94Smrg for z in $available_tags; do 2671213fdd94Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672213fdd94Smrg # Evaluate the configuration. 267397ee6427Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674213fdd94Smrg CC_quoted= 2675213fdd94Smrg for arg in $CC; do 2676213fdd94Smrg # Double-quote args containing other shell metacharacters. 2677213fdd94Smrg func_append_quoted CC_quoted "$arg" 2678213fdd94Smrg done 2679213fdd94Smrg CC_expanded=`func_echo_all $CC` 2680213fdd94Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681213fdd94Smrg case "$@ " in 2682213fdd94Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683213fdd94Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684213fdd94Smrg # The compiler in the base compile command matches 2685213fdd94Smrg # the one in the tagged configuration. 2686213fdd94Smrg # Assume this is the tagged configuration we want. 2687213fdd94Smrg tagname=$z 2688213fdd94Smrg break 2689213fdd94Smrg ;; 2690213fdd94Smrg esac 2691213fdd94Smrg fi 2692213fdd94Smrg done 2693213fdd94Smrg # If $tagname still isn't set, then no tagged configuration 2694213fdd94Smrg # was found and let the user know that the "--tag" command 2695213fdd94Smrg # line option must be used. 2696213fdd94Smrg if test -z "$tagname"; then 2697213fdd94Smrg func_echo "unable to infer tagged configuration" 269897ee6427Smrg func_fatal_error "specify a tag with '--tag'" 2699213fdd94Smrg# else 2700213fdd94Smrg# func_verbose "using $tagname tagged configuration" 2701213fdd94Smrg fi 2702213fdd94Smrg ;; 2703213fdd94Smrg esac 2704301ea0f4Smrg fi 2705213fdd94Smrg} 2706301ea0f4Smrg 2707301ea0f4Smrg 2708301ea0f4Smrg 2709213fdd94Smrg# func_write_libtool_object output_name pic_name nonpic_name 2710213fdd94Smrg# Create a libtool object file (analogous to a ".la" file), 2711213fdd94Smrg# but don't create it if we're doing a dry run. 2712213fdd94Smrgfunc_write_libtool_object () 2713213fdd94Smrg{ 271497ee6427Smrg write_libobj=$1 271597ee6427Smrg if test yes = "$build_libtool_libs"; then 271697ee6427Smrg write_lobj=\'$2\' 2717213fdd94Smrg else 2718213fdd94Smrg write_lobj=none 2719301ea0f4Smrg fi 2720301ea0f4Smrg 272197ee6427Smrg if test yes = "$build_old_libs"; then 272297ee6427Smrg write_oldobj=\'$3\' 2723213fdd94Smrg else 2724213fdd94Smrg write_oldobj=none 2725301ea0f4Smrg fi 2726ef6fb4a5Smrg 2727213fdd94Smrg $opt_dry_run || { 2728213fdd94Smrg cat >${write_libobj}T <<EOF 2729213fdd94Smrg# $write_libobj - a libtool object file 273097ee6427Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731ef6fb4a5Smrg# 2732ef6fb4a5Smrg# Please DO NOT delete this file! 2733ef6fb4a5Smrg# It is necessary for linking the library. 2734ef6fb4a5Smrg 2735ef6fb4a5Smrg# Name of the PIC object. 2736213fdd94Smrgpic_object=$write_lobj 2737301ea0f4Smrg 2738213fdd94Smrg# Name of the non-PIC object 2739213fdd94Smrgnon_pic_object=$write_oldobj 2740301ea0f4Smrg 2741213fdd94SmrgEOF 274297ee6427Smrg $MV "${write_libobj}T" "$write_libobj" 2743213fdd94Smrg } 2744213fdd94Smrg} 2745301ea0f4Smrg 2746301ea0f4Smrg 2747213fdd94Smrg################################################## 2748213fdd94Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749213fdd94Smrg################################################## 2750301ea0f4Smrg 2751213fdd94Smrg# func_convert_core_file_wine_to_w32 ARG 2752213fdd94Smrg# Helper function used by file name conversion functions when $build is *nix, 2753213fdd94Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754213fdd94Smrg# correctly configured wine environment available, with the winepath program 2755213fdd94Smrg# in $build's $PATH. 2756213fdd94Smrg# 2757213fdd94Smrg# ARG is the $build file name to be converted to w32 format. 2758213fdd94Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759213fdd94Smrg# be empty on error (or when ARG is empty) 2760213fdd94Smrgfunc_convert_core_file_wine_to_w32 () 2761213fdd94Smrg{ 276297ee6427Smrg $debug_cmd 276397ee6427Smrg 276497ee6427Smrg func_convert_core_file_wine_to_w32_result=$1 2765213fdd94Smrg if test -n "$1"; then 2766213fdd94Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2767213fdd94Smrg # are forced to check the contents of stdout. On the other hand, if the 2768213fdd94Smrg # command is not found, the shell will set an exit code of 127 and print 2769213fdd94Smrg # *an error message* to stdout. So we must check for both error code of 2770213fdd94Smrg # zero AND non-empty stdout, which explains the odd construction: 2771213fdd94Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277297ee6427Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773213fdd94Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277497ee6427Smrg $SED -e "$sed_naive_backslashify"` 2775213fdd94Smrg else 2776213fdd94Smrg func_convert_core_file_wine_to_w32_result= 2777213fdd94Smrg fi 2778213fdd94Smrg fi 2779213fdd94Smrg} 2780213fdd94Smrg# end: func_convert_core_file_wine_to_w32 2781ef6fb4a5Smrg 2782213fdd94Smrg 2783213fdd94Smrg# func_convert_core_path_wine_to_w32 ARG 2784213fdd94Smrg# Helper function used by path conversion functions when $build is *nix, and 2785213fdd94Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786213fdd94Smrg# configured wine environment available, with the winepath program in $build's 2787213fdd94Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788213fdd94Smrg# 2789213fdd94Smrg# ARG is path to be converted from $build format to win32. 2790213fdd94Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2791213fdd94Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792213fdd94Smrg# are convertible, then the result may be empty. 2793213fdd94Smrgfunc_convert_core_path_wine_to_w32 () 2794213fdd94Smrg{ 279597ee6427Smrg $debug_cmd 279697ee6427Smrg 2797213fdd94Smrg # unfortunately, winepath doesn't convert paths, only file names 279897ee6427Smrg func_convert_core_path_wine_to_w32_result= 2799213fdd94Smrg if test -n "$1"; then 2800213fdd94Smrg oldIFS=$IFS 2801213fdd94Smrg IFS=: 2802213fdd94Smrg for func_convert_core_path_wine_to_w32_f in $1; do 2803213fdd94Smrg IFS=$oldIFS 2804213fdd94Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280597ee6427Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806213fdd94Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280797ee6427Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808213fdd94Smrg else 2809213fdd94Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810213fdd94Smrg fi 2811ef6fb4a5Smrg fi 2812213fdd94Smrg done 2813213fdd94Smrg IFS=$oldIFS 2814213fdd94Smrg fi 2815213fdd94Smrg} 2816213fdd94Smrg# end: func_convert_core_path_wine_to_w32 2817213fdd94Smrg 2818213fdd94Smrg 2819213fdd94Smrg# func_cygpath ARGS... 2820213fdd94Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821213fdd94Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822213fdd94Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823213fdd94Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824213fdd94Smrg# file name or path is assumed to be in w32 format, as previously converted 2825213fdd94Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826213fdd94Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 2827213fdd94Smrg# Cygwin format). Returns an empty string on error. 2828213fdd94Smrg# 2829213fdd94Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 2830213fdd94Smrg# be converted. 2831213fdd94Smrg# 2832213fdd94Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833213fdd94Smrg# environment variable; do not put it in $PATH. 2834213fdd94Smrgfunc_cygpath () 2835213fdd94Smrg{ 283697ee6427Smrg $debug_cmd 283797ee6427Smrg 2838213fdd94Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839213fdd94Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840213fdd94Smrg if test "$?" -ne 0; then 2841213fdd94Smrg # on failure, ensure result is empty 2842213fdd94Smrg func_cygpath_result= 2843213fdd94Smrg fi 2844213fdd94Smrg else 2845213fdd94Smrg func_cygpath_result= 284697ee6427Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847213fdd94Smrg fi 2848213fdd94Smrg} 2849213fdd94Smrg#end: func_cygpath 2850301ea0f4Smrg 2851301ea0f4Smrg 2852213fdd94Smrg# func_convert_core_msys_to_w32 ARG 2853213fdd94Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 2854213fdd94Smrg# result in func_convert_core_msys_to_w32_result. 2855213fdd94Smrgfunc_convert_core_msys_to_w32 () 2856213fdd94Smrg{ 285797ee6427Smrg $debug_cmd 285897ee6427Smrg 2859213fdd94Smrg # awkward: cmd appends spaces to result 2860213fdd94Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286197ee6427Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862213fdd94Smrg} 2863213fdd94Smrg#end: func_convert_core_msys_to_w32 2864301ea0f4Smrg 2865301ea0f4Smrg 2866213fdd94Smrg# func_convert_file_check ARG1 ARG2 2867213fdd94Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 2868213fdd94Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869213fdd94Smrg# func_to_host_file_result to ARG1). 2870213fdd94Smrgfunc_convert_file_check () 2871213fdd94Smrg{ 287297ee6427Smrg $debug_cmd 287397ee6427Smrg 287497ee6427Smrg if test -z "$2" && test -n "$1"; then 2875213fdd94Smrg func_error "Could not determine host file name corresponding to" 287697ee6427Smrg func_error " '$1'" 2877213fdd94Smrg func_error "Continuing, but uninstalled executables may not work." 2878213fdd94Smrg # Fallback: 287997ee6427Smrg func_to_host_file_result=$1 2880213fdd94Smrg fi 2881213fdd94Smrg} 2882213fdd94Smrg# end func_convert_file_check 2883301ea0f4Smrg 2884301ea0f4Smrg 2885213fdd94Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886213fdd94Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2887213fdd94Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888213fdd94Smrg# func_to_host_file_result to a simplistic fallback value (see below). 2889213fdd94Smrgfunc_convert_path_check () 2890213fdd94Smrg{ 289197ee6427Smrg $debug_cmd 289297ee6427Smrg 2893213fdd94Smrg if test -z "$4" && test -n "$3"; then 2894213fdd94Smrg func_error "Could not determine the host path corresponding to" 289597ee6427Smrg func_error " '$3'" 2896213fdd94Smrg func_error "Continuing, but uninstalled executables may not work." 2897213fdd94Smrg # Fallback. This is a deliberately simplistic "conversion" and 2898213fdd94Smrg # should not be "improved". See libtool.info. 2899213fdd94Smrg if test "x$1" != "x$2"; then 2900213fdd94Smrg lt_replace_pathsep_chars="s|$1|$2|g" 2901213fdd94Smrg func_to_host_path_result=`echo "$3" | 2902213fdd94Smrg $SED -e "$lt_replace_pathsep_chars"` 2903213fdd94Smrg else 290497ee6427Smrg func_to_host_path_result=$3 2905213fdd94Smrg fi 2906213fdd94Smrg fi 2907213fdd94Smrg} 2908213fdd94Smrg# end func_convert_path_check 2909ef6fb4a5Smrg 2910ef6fb4a5Smrg 2911213fdd94Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912213fdd94Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913213fdd94Smrg# and appending REPL if ORIG matches BACKPAT. 2914213fdd94Smrgfunc_convert_path_front_back_pathsep () 2915213fdd94Smrg{ 291697ee6427Smrg $debug_cmd 291797ee6427Smrg 2918213fdd94Smrg case $4 in 291997ee6427Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920213fdd94Smrg ;; 2921213fdd94Smrg esac 2922213fdd94Smrg case $4 in 2923213fdd94Smrg $2 ) func_append func_to_host_path_result "$3" 2924213fdd94Smrg ;; 2925213fdd94Smrg esac 2926213fdd94Smrg} 2927213fdd94Smrg# end func_convert_path_front_back_pathsep 2928ef6fb4a5Smrg 2929301ea0f4Smrg 2930213fdd94Smrg################################################## 2931213fdd94Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932213fdd94Smrg################################################## 293397ee6427Smrg# invoked via '$to_host_file_cmd ARG' 2934213fdd94Smrg# 2935213fdd94Smrg# In each case, ARG is the path to be converted from $build to $host format. 2936213fdd94Smrg# Result will be available in $func_to_host_file_result. 2937301ea0f4Smrg 2938301ea0f4Smrg 2939213fdd94Smrg# func_to_host_file ARG 2940213fdd94Smrg# Converts the file name ARG from $build format to $host format. Return result 2941213fdd94Smrg# in func_to_host_file_result. 2942213fdd94Smrgfunc_to_host_file () 2943213fdd94Smrg{ 294497ee6427Smrg $debug_cmd 294597ee6427Smrg 2946213fdd94Smrg $to_host_file_cmd "$1" 2947213fdd94Smrg} 2948213fdd94Smrg# end func_to_host_file 2949301ea0f4Smrg 2950301ea0f4Smrg 2951213fdd94Smrg# func_to_tool_file ARG LAZY 2952213fdd94Smrg# converts the file name ARG from $build format to toolchain format. Return 2953213fdd94Smrg# result in func_to_tool_file_result. If the conversion in use is listed 2954213fdd94Smrg# in (the comma separated) LAZY, no conversion takes place. 2955213fdd94Smrgfunc_to_tool_file () 2956213fdd94Smrg{ 295797ee6427Smrg $debug_cmd 295897ee6427Smrg 2959213fdd94Smrg case ,$2, in 2960213fdd94Smrg *,"$to_tool_file_cmd",*) 2961213fdd94Smrg func_to_tool_file_result=$1 2962213fdd94Smrg ;; 2963213fdd94Smrg *) 2964213fdd94Smrg $to_tool_file_cmd "$1" 2965213fdd94Smrg func_to_tool_file_result=$func_to_host_file_result 2966213fdd94Smrg ;; 2967213fdd94Smrg esac 2968213fdd94Smrg} 2969213fdd94Smrg# end func_to_tool_file 2970301ea0f4Smrg 2971301ea0f4Smrg 2972213fdd94Smrg# func_convert_file_noop ARG 2973213fdd94Smrg# Copy ARG to func_to_host_file_result. 2974213fdd94Smrgfunc_convert_file_noop () 2975213fdd94Smrg{ 297697ee6427Smrg func_to_host_file_result=$1 2977213fdd94Smrg} 2978213fdd94Smrg# end func_convert_file_noop 2979ef6fb4a5Smrg 2980ef6fb4a5Smrg 2981213fdd94Smrg# func_convert_file_msys_to_w32 ARG 2982213fdd94Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983213fdd94Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 2984213fdd94Smrg# func_to_host_file_result. 2985213fdd94Smrgfunc_convert_file_msys_to_w32 () 2986213fdd94Smrg{ 298797ee6427Smrg $debug_cmd 298897ee6427Smrg 298997ee6427Smrg func_to_host_file_result=$1 2990213fdd94Smrg if test -n "$1"; then 2991213fdd94Smrg func_convert_core_msys_to_w32 "$1" 299297ee6427Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993213fdd94Smrg fi 2994213fdd94Smrg func_convert_file_check "$1" "$func_to_host_file_result" 2995213fdd94Smrg} 2996213fdd94Smrg# end func_convert_file_msys_to_w32 2997ef6fb4a5Smrg 2998301ea0f4Smrg 2999213fdd94Smrg# func_convert_file_cygwin_to_w32 ARG 3000213fdd94Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3001213fdd94Smrg# func_to_host_file_result. 3002213fdd94Smrgfunc_convert_file_cygwin_to_w32 () 3003213fdd94Smrg{ 300497ee6427Smrg $debug_cmd 300597ee6427Smrg 300697ee6427Smrg func_to_host_file_result=$1 3007213fdd94Smrg if test -n "$1"; then 3008213fdd94Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009213fdd94Smrg # LT_CYGPATH in this case. 3010213fdd94Smrg func_to_host_file_result=`cygpath -m "$1"` 3011213fdd94Smrg fi 3012213fdd94Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3013213fdd94Smrg} 3014213fdd94Smrg# end func_convert_file_cygwin_to_w32 3015301ea0f4Smrg 3016301ea0f4Smrg 3017213fdd94Smrg# func_convert_file_nix_to_w32 ARG 3018213fdd94Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019213fdd94Smrg# and a working winepath. Returns result in func_to_host_file_result. 3020213fdd94Smrgfunc_convert_file_nix_to_w32 () 3021213fdd94Smrg{ 302297ee6427Smrg $debug_cmd 302397ee6427Smrg 302497ee6427Smrg func_to_host_file_result=$1 3025213fdd94Smrg if test -n "$1"; then 3026213fdd94Smrg func_convert_core_file_wine_to_w32 "$1" 302797ee6427Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028213fdd94Smrg fi 3029213fdd94Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3030213fdd94Smrg} 3031213fdd94Smrg# end func_convert_file_nix_to_w32 3032301ea0f4Smrg 3033301ea0f4Smrg 3034213fdd94Smrg# func_convert_file_msys_to_cygwin ARG 3035213fdd94Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036213fdd94Smrg# Returns result in func_to_host_file_result. 3037213fdd94Smrgfunc_convert_file_msys_to_cygwin () 3038213fdd94Smrg{ 303997ee6427Smrg $debug_cmd 304097ee6427Smrg 304197ee6427Smrg func_to_host_file_result=$1 3042213fdd94Smrg if test -n "$1"; then 3043213fdd94Smrg func_convert_core_msys_to_w32 "$1" 3044213fdd94Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304597ee6427Smrg func_to_host_file_result=$func_cygpath_result 3046213fdd94Smrg fi 3047213fdd94Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3048213fdd94Smrg} 3049213fdd94Smrg# end func_convert_file_msys_to_cygwin 3050301ea0f4Smrg 3051301ea0f4Smrg 3052213fdd94Smrg# func_convert_file_nix_to_cygwin ARG 3053213fdd94Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054213fdd94Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055213fdd94Smrg# in func_to_host_file_result. 3056213fdd94Smrgfunc_convert_file_nix_to_cygwin () 3057213fdd94Smrg{ 305897ee6427Smrg $debug_cmd 305997ee6427Smrg 306097ee6427Smrg func_to_host_file_result=$1 3061213fdd94Smrg if test -n "$1"; then 3062213fdd94Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063213fdd94Smrg func_convert_core_file_wine_to_w32 "$1" 3064213fdd94Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306597ee6427Smrg func_to_host_file_result=$func_cygpath_result 3066213fdd94Smrg fi 3067213fdd94Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3068213fdd94Smrg} 3069213fdd94Smrg# end func_convert_file_nix_to_cygwin 3070301ea0f4Smrg 3071301ea0f4Smrg 3072213fdd94Smrg############################################# 3073213fdd94Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3074213fdd94Smrg############################################# 307597ee6427Smrg# invoked via '$to_host_path_cmd ARG' 3076213fdd94Smrg# 3077213fdd94Smrg# In each case, ARG is the path to be converted from $build to $host format. 3078213fdd94Smrg# The result will be available in $func_to_host_path_result. 3079213fdd94Smrg# 3080213fdd94Smrg# Path separators are also converted from $build format to $host format. If 3081213fdd94Smrg# ARG begins or ends with a path separator character, it is preserved (but 3082213fdd94Smrg# converted to $host format) on output. 3083213fdd94Smrg# 3084213fdd94Smrg# All path conversion functions are named using the following convention: 3085213fdd94Smrg# file name conversion function : func_convert_file_X_to_Y () 3086213fdd94Smrg# path conversion function : func_convert_path_X_to_Y () 3087213fdd94Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3088213fdd94Smrg# same. If conversion functions are added for new $build/$host combinations, 3089213fdd94Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090213fdd94Smrg# will break. 3091213fdd94Smrg 3092213fdd94Smrg 3093213fdd94Smrg# func_init_to_host_path_cmd 3094213fdd94Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095213fdd94Smrg# appropriate value, based on the value of $to_host_file_cmd. 3096213fdd94Smrgto_host_path_cmd= 3097213fdd94Smrgfunc_init_to_host_path_cmd () 3098213fdd94Smrg{ 309997ee6427Smrg $debug_cmd 310097ee6427Smrg 3101213fdd94Smrg if test -z "$to_host_path_cmd"; then 3102213fdd94Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310397ee6427Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 3104213fdd94Smrg fi 3105213fdd94Smrg} 3106301ea0f4Smrg 3107301ea0f4Smrg 3108213fdd94Smrg# func_to_host_path ARG 3109213fdd94Smrg# Converts the path ARG from $build format to $host format. Return result 3110213fdd94Smrg# in func_to_host_path_result. 3111213fdd94Smrgfunc_to_host_path () 3112213fdd94Smrg{ 311397ee6427Smrg $debug_cmd 311497ee6427Smrg 3115213fdd94Smrg func_init_to_host_path_cmd 3116213fdd94Smrg $to_host_path_cmd "$1" 3117213fdd94Smrg} 3118213fdd94Smrg# end func_to_host_path 3119301ea0f4Smrg 3120301ea0f4Smrg 3121213fdd94Smrg# func_convert_path_noop ARG 3122213fdd94Smrg# Copy ARG to func_to_host_path_result. 3123213fdd94Smrgfunc_convert_path_noop () 3124213fdd94Smrg{ 312597ee6427Smrg func_to_host_path_result=$1 3126213fdd94Smrg} 3127213fdd94Smrg# end func_convert_path_noop 3128301ea0f4Smrg 3129301ea0f4Smrg 3130213fdd94Smrg# func_convert_path_msys_to_w32 ARG 3131213fdd94Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132213fdd94Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3133213fdd94Smrg# func_to_host_path_result. 3134213fdd94Smrgfunc_convert_path_msys_to_w32 () 3135213fdd94Smrg{ 313697ee6427Smrg $debug_cmd 313797ee6427Smrg 313897ee6427Smrg func_to_host_path_result=$1 3139213fdd94Smrg if test -n "$1"; then 3140213fdd94Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3141213fdd94Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142213fdd94Smrg # and winepath ignores them completely. 3143213fdd94Smrg func_stripname : : "$1" 3144213fdd94Smrg func_to_host_path_tmp1=$func_stripname_result 3145213fdd94Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314697ee6427Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147213fdd94Smrg func_convert_path_check : ";" \ 3148213fdd94Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149213fdd94Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150213fdd94Smrg fi 3151213fdd94Smrg} 3152213fdd94Smrg# end func_convert_path_msys_to_w32 3153301ea0f4Smrg 3154301ea0f4Smrg 3155213fdd94Smrg# func_convert_path_cygwin_to_w32 ARG 3156213fdd94Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3157213fdd94Smrg# func_to_host_file_result. 3158213fdd94Smrgfunc_convert_path_cygwin_to_w32 () 3159213fdd94Smrg{ 316097ee6427Smrg $debug_cmd 316197ee6427Smrg 316297ee6427Smrg func_to_host_path_result=$1 3163213fdd94Smrg if test -n "$1"; then 3164213fdd94Smrg # See func_convert_path_msys_to_w32: 3165213fdd94Smrg func_stripname : : "$1" 3166213fdd94Smrg func_to_host_path_tmp1=$func_stripname_result 3167213fdd94Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168213fdd94Smrg func_convert_path_check : ";" \ 3169213fdd94Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170213fdd94Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171213fdd94Smrg fi 3172213fdd94Smrg} 3173213fdd94Smrg# end func_convert_path_cygwin_to_w32 3174301ea0f4Smrg 3175301ea0f4Smrg 3176213fdd94Smrg# func_convert_path_nix_to_w32 ARG 3177213fdd94Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178213fdd94Smrg# a working winepath. Returns result in func_to_host_file_result. 3179213fdd94Smrgfunc_convert_path_nix_to_w32 () 3180213fdd94Smrg{ 318197ee6427Smrg $debug_cmd 318297ee6427Smrg 318397ee6427Smrg func_to_host_path_result=$1 3184213fdd94Smrg if test -n "$1"; then 3185213fdd94Smrg # See func_convert_path_msys_to_w32: 3186213fdd94Smrg func_stripname : : "$1" 3187213fdd94Smrg func_to_host_path_tmp1=$func_stripname_result 3188213fdd94Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318997ee6427Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190213fdd94Smrg func_convert_path_check : ";" \ 3191213fdd94Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192213fdd94Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193213fdd94Smrg fi 3194213fdd94Smrg} 3195213fdd94Smrg# end func_convert_path_nix_to_w32 3196301ea0f4Smrg 3197301ea0f4Smrg 3198213fdd94Smrg# func_convert_path_msys_to_cygwin ARG 3199213fdd94Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200213fdd94Smrg# Returns result in func_to_host_file_result. 3201213fdd94Smrgfunc_convert_path_msys_to_cygwin () 3202213fdd94Smrg{ 320397ee6427Smrg $debug_cmd 320497ee6427Smrg 320597ee6427Smrg func_to_host_path_result=$1 3206213fdd94Smrg if test -n "$1"; then 3207213fdd94Smrg # See func_convert_path_msys_to_w32: 3208213fdd94Smrg func_stripname : : "$1" 3209213fdd94Smrg func_to_host_path_tmp1=$func_stripname_result 3210213fdd94Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211213fdd94Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321297ee6427Smrg func_to_host_path_result=$func_cygpath_result 3213213fdd94Smrg func_convert_path_check : : \ 3214213fdd94Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215213fdd94Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216213fdd94Smrg fi 3217213fdd94Smrg} 3218213fdd94Smrg# end func_convert_path_msys_to_cygwin 3219301ea0f4Smrg 3220301ea0f4Smrg 3221213fdd94Smrg# func_convert_path_nix_to_cygwin ARG 3222213fdd94Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223213fdd94Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224213fdd94Smrg# func_to_host_file_result. 3225213fdd94Smrgfunc_convert_path_nix_to_cygwin () 3226213fdd94Smrg{ 322797ee6427Smrg $debug_cmd 322897ee6427Smrg 322997ee6427Smrg func_to_host_path_result=$1 3230213fdd94Smrg if test -n "$1"; then 3231213fdd94Smrg # Remove leading and trailing path separator characters from 3232213fdd94Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3233213fdd94Smrg # into '.;' and ';.', and winepath ignores them completely. 3234213fdd94Smrg func_stripname : : "$1" 3235213fdd94Smrg func_to_host_path_tmp1=$func_stripname_result 3236213fdd94Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237213fdd94Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323897ee6427Smrg func_to_host_path_result=$func_cygpath_result 3239213fdd94Smrg func_convert_path_check : : \ 3240213fdd94Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241213fdd94Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242213fdd94Smrg fi 3243213fdd94Smrg} 3244213fdd94Smrg# end func_convert_path_nix_to_cygwin 3245301ea0f4Smrg 3246301ea0f4Smrg 324797ee6427Smrg# func_dll_def_p FILE 324897ee6427Smrg# True iff FILE is a Windows DLL '.def' file. 324997ee6427Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325097ee6427Smrgfunc_dll_def_p () 325197ee6427Smrg{ 325297ee6427Smrg $debug_cmd 325397ee6427Smrg 325497ee6427Smrg func_dll_def_p_tmp=`$SED -n \ 325597ee6427Smrg -e 's/^[ ]*//' \ 325697ee6427Smrg -e '/^\(;.*\)*$/d' \ 325797ee6427Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325897ee6427Smrg -e q \ 325997ee6427Smrg "$1"` 326097ee6427Smrg test DEF = "$func_dll_def_p_tmp" 326197ee6427Smrg} 326297ee6427Smrg 326397ee6427Smrg 3264213fdd94Smrg# func_mode_compile arg... 3265213fdd94Smrgfunc_mode_compile () 3266213fdd94Smrg{ 326797ee6427Smrg $debug_cmd 326897ee6427Smrg 3269213fdd94Smrg # Get the compilation command and the source file. 3270213fdd94Smrg base_compile= 327197ee6427Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272213fdd94Smrg suppress_opt=yes 3273213fdd94Smrg suppress_output= 3274213fdd94Smrg arg_mode=normal 3275213fdd94Smrg libobj= 3276213fdd94Smrg later= 3277213fdd94Smrg pie_flag= 3278213fdd94Smrg 3279213fdd94Smrg for arg 3280213fdd94Smrg do 3281213fdd94Smrg case $arg_mode in 3282213fdd94Smrg arg ) 3283213fdd94Smrg # do not "continue". Instead, add this to base_compile 328497ee6427Smrg lastarg=$arg 3285213fdd94Smrg arg_mode=normal 3286213fdd94Smrg ;; 3287213fdd94Smrg 3288213fdd94Smrg target ) 328997ee6427Smrg libobj=$arg 3290213fdd94Smrg arg_mode=normal 3291213fdd94Smrg continue 3292213fdd94Smrg ;; 3293213fdd94Smrg 3294213fdd94Smrg normal ) 3295213fdd94Smrg # Accept any command-line options. 3296213fdd94Smrg case $arg in 3297213fdd94Smrg -o) 3298213fdd94Smrg test -n "$libobj" && \ 329997ee6427Smrg func_fatal_error "you cannot specify '-o' more than once" 3300213fdd94Smrg arg_mode=target 3301ef6fb4a5Smrg continue 3302ef6fb4a5Smrg ;; 3303213fdd94Smrg 3304213fdd94Smrg -pie | -fpie | -fPIE) 3305213fdd94Smrg func_append pie_flag " $arg" 3306ef6fb4a5Smrg continue 3307ef6fb4a5Smrg ;; 3308213fdd94Smrg 3309213fdd94Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3310213fdd94Smrg func_append later " $arg" 3311ef6fb4a5Smrg continue 3312ef6fb4a5Smrg ;; 3313213fdd94Smrg 3314213fdd94Smrg -no-suppress) 3315213fdd94Smrg suppress_opt=no 3316ef6fb4a5Smrg continue 3317ef6fb4a5Smrg ;; 3318301ea0f4Smrg 3319213fdd94Smrg -Xcompiler) 3320213fdd94Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321213fdd94Smrg continue # The current "srcfile" will either be retained or 3322213fdd94Smrg ;; # replaced later. I would guess that would be a bug. 3323301ea0f4Smrg 3324213fdd94Smrg -Wc,*) 3325213fdd94Smrg func_stripname '-Wc,' '' "$arg" 3326213fdd94Smrg args=$func_stripname_result 3327213fdd94Smrg lastarg= 332897ee6427Smrg save_ifs=$IFS; IFS=, 3329213fdd94Smrg for arg in $args; do 333097ee6427Smrg IFS=$save_ifs 3331213fdd94Smrg func_append_quoted lastarg "$arg" 3332213fdd94Smrg done 333397ee6427Smrg IFS=$save_ifs 3334213fdd94Smrg func_stripname ' ' '' "$lastarg" 3335213fdd94Smrg lastarg=$func_stripname_result 3336301ea0f4Smrg 3337213fdd94Smrg # Add the arguments to base_compile. 3338213fdd94Smrg func_append base_compile " $lastarg" 3339213fdd94Smrg continue 3340213fdd94Smrg ;; 3341301ea0f4Smrg 3342213fdd94Smrg *) 3343213fdd94Smrg # Accept the current argument as the source file. 3344213fdd94Smrg # The previous "srcfile" becomes the current argument. 3345213fdd94Smrg # 334697ee6427Smrg lastarg=$srcfile 334797ee6427Smrg srcfile=$arg 3348213fdd94Smrg ;; 3349213fdd94Smrg esac # case $arg 3350ef6fb4a5Smrg ;; 3351213fdd94Smrg esac # case $arg_mode 3352301ea0f4Smrg 3353213fdd94Smrg # Aesthetically quote the previous argument. 3354213fdd94Smrg func_append_quoted base_compile "$lastarg" 3355213fdd94Smrg done # for arg 3356301ea0f4Smrg 3357213fdd94Smrg case $arg_mode in 3358213fdd94Smrg arg) 3359213fdd94Smrg func_fatal_error "you must specify an argument for -Xcompile" 3360213fdd94Smrg ;; 3361213fdd94Smrg target) 336297ee6427Smrg func_fatal_error "you must specify a target with '-o'" 3363213fdd94Smrg ;; 3364213fdd94Smrg *) 3365213fdd94Smrg # Get the name of the library object. 3366213fdd94Smrg test -z "$libobj" && { 3367213fdd94Smrg func_basename "$srcfile" 336897ee6427Smrg libobj=$func_basename_result 3369213fdd94Smrg } 3370213fdd94Smrg ;; 3371213fdd94Smrg esac 3372301ea0f4Smrg 3373213fdd94Smrg # Recognize several different file suffixes. 3374213fdd94Smrg # If the user specifies -o file.o, it is replaced with file.lo 3375213fdd94Smrg case $libobj in 3376213fdd94Smrg *.[cCFSifmso] | \ 3377213fdd94Smrg *.ada | *.adb | *.ads | *.asm | \ 3378213fdd94Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379213fdd94Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380213fdd94Smrg func_xform "$libobj" 3381213fdd94Smrg libobj=$func_xform_result 3382213fdd94Smrg ;; 3383213fdd94Smrg esac 3384301ea0f4Smrg 3385213fdd94Smrg case $libobj in 3386213fdd94Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387213fdd94Smrg *) 338897ee6427Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389213fdd94Smrg ;; 3390213fdd94Smrg esac 3391301ea0f4Smrg 3392213fdd94Smrg func_infer_tag $base_compile 3393301ea0f4Smrg 3394213fdd94Smrg for arg in $later; do 3395213fdd94Smrg case $arg in 3396213fdd94Smrg -shared) 339797ee6427Smrg test yes = "$build_libtool_libs" \ 339897ee6427Smrg || func_fatal_configuration "cannot build a shared library" 3399213fdd94Smrg build_old_libs=no 3400ef6fb4a5Smrg continue 3401ef6fb4a5Smrg ;; 3402301ea0f4Smrg 3403213fdd94Smrg -static) 3404213fdd94Smrg build_libtool_libs=no 3405213fdd94Smrg build_old_libs=yes 3406ef6fb4a5Smrg continue 3407ef6fb4a5Smrg ;; 3408301ea0f4Smrg 3409213fdd94Smrg -prefer-pic) 3410213fdd94Smrg pic_mode=yes 3411ef6fb4a5Smrg continue 3412ef6fb4a5Smrg ;; 3413301ea0f4Smrg 3414213fdd94Smrg -prefer-non-pic) 3415213fdd94Smrg pic_mode=no 3416ef6fb4a5Smrg continue 3417301ea0f4Smrg ;; 3418213fdd94Smrg esac 3419213fdd94Smrg done 3420301ea0f4Smrg 3421213fdd94Smrg func_quote_for_eval "$libobj" 3422213fdd94Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423213fdd94Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342497ee6427Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425213fdd94Smrg func_dirname_and_basename "$obj" "/" "" 342697ee6427Smrg objname=$func_basename_result 342797ee6427Smrg xdir=$func_dirname_result 342897ee6427Smrg lobj=$xdir$objdir/$objname 3429301ea0f4Smrg 3430213fdd94Smrg test -z "$base_compile" && \ 3431213fdd94Smrg func_fatal_help "you must specify a compilation command" 3432301ea0f4Smrg 3433213fdd94Smrg # Delete any leftover library objects. 343497ee6427Smrg if test yes = "$build_old_libs"; then 3435213fdd94Smrg removelist="$obj $lobj $libobj ${libobj}T" 3436213fdd94Smrg else 3437213fdd94Smrg removelist="$lobj $libobj ${libobj}T" 3438213fdd94Smrg fi 3439301ea0f4Smrg 3440213fdd94Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441213fdd94Smrg case $host_os in 3442213fdd94Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443213fdd94Smrg pic_mode=default 3444213fdd94Smrg ;; 3445213fdd94Smrg esac 344697ee6427Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447213fdd94Smrg # non-PIC code in shared libraries is not supported 3448213fdd94Smrg pic_mode=default 3449213fdd94Smrg fi 3450301ea0f4Smrg 3451213fdd94Smrg # Calculate the filename of the output object if compiler does 3452213fdd94Smrg # not support -o with -c 345397ee6427Smrg if test no = "$compiler_c_o"; then 345497ee6427Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345597ee6427Smrg lockfile=$output_obj.lock 3456213fdd94Smrg else 3457213fdd94Smrg output_obj= 3458213fdd94Smrg need_locks=no 3459213fdd94Smrg lockfile= 3460213fdd94Smrg fi 3461301ea0f4Smrg 3462213fdd94Smrg # Lock this critical section if it is needed 3463213fdd94Smrg # We use this script file to make the link, it avoids creating a new file 346497ee6427Smrg if test yes = "$need_locks"; then 3465213fdd94Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466213fdd94Smrg func_echo "Waiting for $lockfile to be removed" 3467213fdd94Smrg sleep 2 3468213fdd94Smrg done 346997ee6427Smrg elif test warn = "$need_locks"; then 3470213fdd94Smrg if test -f "$lockfile"; then 3471213fdd94Smrg $ECHO "\ 3472213fdd94Smrg*** ERROR, $lockfile exists and contains: 3473213fdd94Smrg`cat $lockfile 2>/dev/null` 3474301ea0f4Smrg 3475213fdd94SmrgThis indicates that another process is trying to use the same 3476213fdd94Smrgtemporary object file, and libtool could not work around it because 347797ee6427Smrgyour compiler does not support '-c' and '-o' together. If you 3478213fdd94Smrgrepeat this compilation, it may succeed, by chance, but you had better 3479213fdd94Smrgavoid parallel builds (make -j) in this platform, or get a better 3480213fdd94Smrgcompiler." 3481301ea0f4Smrg 3482213fdd94Smrg $opt_dry_run || $RM $removelist 3483213fdd94Smrg exit $EXIT_FAILURE 3484213fdd94Smrg fi 3485213fdd94Smrg func_append removelist " $output_obj" 3486213fdd94Smrg $ECHO "$srcfile" > "$lockfile" 3487213fdd94Smrg fi 3488301ea0f4Smrg 3489213fdd94Smrg $opt_dry_run || $RM $removelist 3490213fdd94Smrg func_append removelist " $lockfile" 3491213fdd94Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492301ea0f4Smrg 3493213fdd94Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494213fdd94Smrg srcfile=$func_to_tool_file_result 3495213fdd94Smrg func_quote_for_eval "$srcfile" 3496213fdd94Smrg qsrcfile=$func_quote_for_eval_result 3497301ea0f4Smrg 3498213fdd94Smrg # Only build a PIC object if we are building libtool libraries. 349997ee6427Smrg if test yes = "$build_libtool_libs"; then 3500213fdd94Smrg # Without this assignment, base_compile gets emptied. 3501213fdd94Smrg fbsd_hideous_sh_bug=$base_compile 3502301ea0f4Smrg 350397ee6427Smrg if test no != "$pic_mode"; then 3504213fdd94Smrg command="$base_compile $qsrcfile $pic_flag" 3505213fdd94Smrg else 3506213fdd94Smrg # Don't build PIC code 3507213fdd94Smrg command="$base_compile $qsrcfile" 3508213fdd94Smrg fi 3509301ea0f4Smrg 3510213fdd94Smrg func_mkdir_p "$xdir$objdir" 3511301ea0f4Smrg 3512213fdd94Smrg if test -z "$output_obj"; then 3513213fdd94Smrg # Place PIC objects in $objdir 3514213fdd94Smrg func_append command " -o $lobj" 3515213fdd94Smrg fi 35160cc67336Smrg 3517213fdd94Smrg func_show_eval_locale "$command" \ 3518213fdd94Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519301ea0f4Smrg 352097ee6427Smrg if test warn = "$need_locks" && 3521213fdd94Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522213fdd94Smrg $ECHO "\ 3523213fdd94Smrg*** ERROR, $lockfile contains: 3524213fdd94Smrg`cat $lockfile 2>/dev/null` 3525ef6fb4a5Smrg 3526213fdd94Smrgbut it should contain: 3527213fdd94Smrg$srcfile 3528ef6fb4a5Smrg 3529213fdd94SmrgThis indicates that another process is trying to use the same 3530213fdd94Smrgtemporary object file, and libtool could not work around it because 353197ee6427Smrgyour compiler does not support '-c' and '-o' together. If you 3532213fdd94Smrgrepeat this compilation, it may succeed, by chance, but you had better 3533213fdd94Smrgavoid parallel builds (make -j) in this platform, or get a better 3534213fdd94Smrgcompiler." 3535301ea0f4Smrg 3536213fdd94Smrg $opt_dry_run || $RM $removelist 3537213fdd94Smrg exit $EXIT_FAILURE 3538213fdd94Smrg fi 3539301ea0f4Smrg 3540213fdd94Smrg # Just move the object if needed, then go on to compile the next one 3541213fdd94Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542213fdd94Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543213fdd94Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544213fdd94Smrg fi 3545301ea0f4Smrg 3546213fdd94Smrg # Allow error messages only from the first compilation. 354797ee6427Smrg if test yes = "$suppress_opt"; then 3548213fdd94Smrg suppress_output=' >/dev/null 2>&1' 3549213fdd94Smrg fi 3550213fdd94Smrg fi 3551301ea0f4Smrg 3552213fdd94Smrg # Only build a position-dependent object if we build old libraries. 355397ee6427Smrg if test yes = "$build_old_libs"; then 355497ee6427Smrg if test yes != "$pic_mode"; then 3555213fdd94Smrg # Don't build PIC code 3556213fdd94Smrg command="$base_compile $qsrcfile$pie_flag" 3557213fdd94Smrg else 3558213fdd94Smrg command="$base_compile $qsrcfile $pic_flag" 3559213fdd94Smrg fi 356097ee6427Smrg if test yes = "$compiler_c_o"; then 3561213fdd94Smrg func_append command " -o $obj" 3562213fdd94Smrg fi 3563301ea0f4Smrg 3564213fdd94Smrg # Suppress compiler output if we already did a PIC compilation. 3565213fdd94Smrg func_append command "$suppress_output" 3566213fdd94Smrg func_show_eval_locale "$command" \ 3567213fdd94Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 35680cc67336Smrg 356997ee6427Smrg if test warn = "$need_locks" && 3570213fdd94Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571213fdd94Smrg $ECHO "\ 3572213fdd94Smrg*** ERROR, $lockfile contains: 3573213fdd94Smrg`cat $lockfile 2>/dev/null` 3574301ea0f4Smrg 3575213fdd94Smrgbut it should contain: 3576213fdd94Smrg$srcfile 35770cc67336Smrg 3578213fdd94SmrgThis indicates that another process is trying to use the same 3579213fdd94Smrgtemporary object file, and libtool could not work around it because 358097ee6427Smrgyour compiler does not support '-c' and '-o' together. If you 3581213fdd94Smrgrepeat this compilation, it may succeed, by chance, but you had better 3582213fdd94Smrgavoid parallel builds (make -j) in this platform, or get a better 3583213fdd94Smrgcompiler." 35840cc67336Smrg 3585213fdd94Smrg $opt_dry_run || $RM $removelist 3586213fdd94Smrg exit $EXIT_FAILURE 3587213fdd94Smrg fi 35880cc67336Smrg 3589213fdd94Smrg # Just move the object if needed 3590213fdd94Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591213fdd94Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592213fdd94Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593213fdd94Smrg fi 3594213fdd94Smrg fi 35950cc67336Smrg 3596213fdd94Smrg $opt_dry_run || { 3597213fdd94Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 35980cc67336Smrg 3599213fdd94Smrg # Unlock the critical section if it was locked 360097ee6427Smrg if test no != "$need_locks"; then 3601213fdd94Smrg removelist=$lockfile 3602213fdd94Smrg $RM "$lockfile" 3603213fdd94Smrg fi 3604213fdd94Smrg } 36050cc67336Smrg 3606213fdd94Smrg exit $EXIT_SUCCESS 3607213fdd94Smrg} 36080cc67336Smrg 3609213fdd94Smrg$opt_help || { 361097ee6427Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611213fdd94Smrg} 36120cc67336Smrg 3613213fdd94Smrgfunc_mode_help () 3614213fdd94Smrg{ 3615213fdd94Smrg # We need to display help for each of the modes. 3616213fdd94Smrg case $opt_mode in 3617213fdd94Smrg "") 3618213fdd94Smrg # Generic help is extracted from the usage comments 3619213fdd94Smrg # at the start of this file. 3620213fdd94Smrg func_help 3621213fdd94Smrg ;; 36220cc67336Smrg 3623213fdd94Smrg clean) 3624213fdd94Smrg $ECHO \ 3625213fdd94Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 36260cc67336Smrg 3627213fdd94SmrgRemove files from the build directory. 3628ef6fb4a5Smrg 3629213fdd94SmrgRM is the name of the program to use to delete files associated with each FILE 363097ee6427Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631213fdd94Smrgto RM. 3632301ea0f4Smrg 3633213fdd94SmrgIf FILE is a libtool library, object or program, all the files associated 3634213fdd94Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635213fdd94Smrg ;; 3636301ea0f4Smrg 3637213fdd94Smrg compile) 3638213fdd94Smrg $ECHO \ 3639213fdd94Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640301ea0f4Smrg 3641213fdd94SmrgCompile a source file into a libtool library object. 3642301ea0f4Smrg 3643213fdd94SmrgThis mode accepts the following additional options: 3644301ea0f4Smrg 3645213fdd94Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646213fdd94Smrg -no-suppress do not suppress compiler output for multiple passes 3647213fdd94Smrg -prefer-pic try to build PIC objects only 3648213fdd94Smrg -prefer-non-pic try to build non-PIC objects only 364997ee6427Smrg -shared do not build a '.o' file suitable for static linking 365097ee6427Smrg -static only build a '.o' file suitable for static linking 3651213fdd94Smrg -Wc,FLAG pass FLAG directly to the compiler 36520cc67336Smrg 365397ee6427SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654213fdd94Smrgfrom the given SOURCEFILE. 3655301ea0f4Smrg 3656213fdd94SmrgThe output file name is determined by removing the directory component from 365797ee6427SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365897ee6427Smrglibrary object suffix, '.lo'." 3659213fdd94Smrg ;; 36600cc67336Smrg 3661213fdd94Smrg execute) 3662213fdd94Smrg $ECHO \ 3663213fdd94Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664301ea0f4Smrg 3665213fdd94SmrgAutomatically set library path, then run a program. 3666301ea0f4Smrg 3667213fdd94SmrgThis mode accepts the following additional options: 3668301ea0f4Smrg 3669213fdd94Smrg -dlopen FILE add the directory containing FILE to the library path 36700cc67336Smrg 367197ee6427SmrgThis mode sets the library path environment variable according to '-dlopen' 3672213fdd94Smrgflags. 3673301ea0f4Smrg 3674213fdd94SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675213fdd94Smrginto their corresponding uninstalled binary, and any of their required library 3676213fdd94Smrgdirectories are added to the library path. 3677301ea0f4Smrg 3678213fdd94SmrgThen, COMMAND is executed, with ARGS as arguments." 3679213fdd94Smrg ;; 3680213fdd94Smrg 3681213fdd94Smrg finish) 3682213fdd94Smrg $ECHO \ 3683213fdd94Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684213fdd94Smrg 3685213fdd94SmrgComplete the installation of libtool libraries. 3686213fdd94Smrg 3687213fdd94SmrgEach LIBDIR is a directory that contains libtool libraries. 3688213fdd94Smrg 3689213fdd94SmrgThe commands that this mode executes may require superuser privileges. Use 369097ee6427Smrgthe '--dry-run' option if you just want to see what would be executed." 3691213fdd94Smrg ;; 3692213fdd94Smrg 3693213fdd94Smrg install) 3694213fdd94Smrg $ECHO \ 3695213fdd94Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696213fdd94Smrg 3697213fdd94SmrgInstall executables or libraries. 3698213fdd94Smrg 3699213fdd94SmrgINSTALL-COMMAND is the installation command. The first component should be 370097ee6427Smrgeither the 'install' or 'cp' program. 3701213fdd94Smrg 3702213fdd94SmrgThe following components of INSTALL-COMMAND are treated specially: 3703213fdd94Smrg 3704213fdd94Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705213fdd94Smrg 3706213fdd94SmrgThe rest of the components are interpreted as arguments to that command (only 3707213fdd94SmrgBSD-compatible install options are recognized)." 3708213fdd94Smrg ;; 3709213fdd94Smrg 3710213fdd94Smrg link) 3711213fdd94Smrg $ECHO \ 3712213fdd94Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713213fdd94Smrg 3714213fdd94SmrgLink object files or libraries together to form another library, or to 3715213fdd94Smrgcreate an executable program. 3716213fdd94Smrg 3717213fdd94SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718213fdd94Smrga program from several object files. 3719213fdd94Smrg 3720213fdd94SmrgThe following components of LINK-COMMAND are treated specially: 3721213fdd94Smrg 3722213fdd94Smrg -all-static do not do any dynamic linking at all 3723213fdd94Smrg -avoid-version do not add a version suffix if possible 3724213fdd94Smrg -bindir BINDIR specify path to binaries directory (for systems where 3725213fdd94Smrg libraries must be found in the PATH setting at runtime) 372697ee6427Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727213fdd94Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728213fdd94Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729213fdd94Smrg -export-symbols SYMFILE 3730213fdd94Smrg try to export only the symbols listed in SYMFILE 3731213fdd94Smrg -export-symbols-regex REGEX 3732213fdd94Smrg try to export only the symbols matching REGEX 3733213fdd94Smrg -LLIBDIR search LIBDIR for required installed libraries 3734213fdd94Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735213fdd94Smrg -module build a library that can dlopened 3736213fdd94Smrg -no-fast-install disable the fast-install mode 3737213fdd94Smrg -no-install link a not-installable executable 3738213fdd94Smrg -no-undefined declare that a library does not refer to external symbols 3739213fdd94Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374097ee6427Smrg -objectlist FILE use a list of object files found in FILE to specify objects 374197ee6427Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742213fdd94Smrg -precious-files-regex REGEX 3743213fdd94Smrg don't remove output files matching REGEX 3744213fdd94Smrg -release RELEASE specify package release information 3745213fdd94Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746213fdd94Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747213fdd94Smrg -shared only do dynamic linking of libtool libraries 3748213fdd94Smrg -shrext SUFFIX override the standard shared library file extension 3749213fdd94Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3750213fdd94Smrg -static-libtool-libs 3751213fdd94Smrg do not do any dynamic linking of libtool libraries 3752213fdd94Smrg -version-info CURRENT[:REVISION[:AGE]] 3753213fdd94Smrg specify library version info [each variable defaults to 0] 3754213fdd94Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 3755213fdd94Smrg -Wc,FLAG 3756213fdd94Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757213fdd94Smrg -Wl,FLAG 3758213fdd94Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759213fdd94Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760213fdd94Smrg 376197ee6427SmrgAll other options (arguments beginning with '-') are ignored. 3762213fdd94Smrg 376397ee6427SmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764213fdd94Smrgtreated as uninstalled libtool libraries, other files are standard or library 3765213fdd94Smrgobject files. 3766213fdd94Smrg 376797ee6427SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376897ee6427Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769213fdd94Smrgrequired, except when creating a convenience library. 3770213fdd94Smrg 377197ee6427SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377297ee6427Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773213fdd94Smrg 377497ee6427SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775213fdd94Smrgis created, otherwise an executable program is created." 3776213fdd94Smrg ;; 3777213fdd94Smrg 3778213fdd94Smrg uninstall) 3779213fdd94Smrg $ECHO \ 3780213fdd94Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781213fdd94Smrg 3782213fdd94SmrgRemove libraries from an installation directory. 3783213fdd94Smrg 3784213fdd94SmrgRM is the name of the program to use to delete files associated with each FILE 378597ee6427Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786213fdd94Smrgto RM. 3787213fdd94Smrg 3788213fdd94SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789213fdd94SmrgOtherwise, only FILE itself is deleted using RM." 3790213fdd94Smrg ;; 3791213fdd94Smrg 3792213fdd94Smrg *) 379397ee6427Smrg func_fatal_help "invalid operation mode '$opt_mode'" 3794213fdd94Smrg ;; 3795ef6fb4a5Smrg esac 3796301ea0f4Smrg 3797213fdd94Smrg echo 379897ee6427Smrg $ECHO "Try '$progname --help' for more information about other modes." 3799213fdd94Smrg} 38000cc67336Smrg 3801213fdd94Smrg# Now that we've collected a possible --mode arg, show help if necessary 3802213fdd94Smrgif $opt_help; then 380397ee6427Smrg if test : = "$opt_help"; then 3804213fdd94Smrg func_mode_help 3805213fdd94Smrg else 3806213fdd94Smrg { 3807213fdd94Smrg func_help noexit 3808213fdd94Smrg for opt_mode in compile link execute install finish uninstall clean; do 3809213fdd94Smrg func_mode_help 3810213fdd94Smrg done 381197ee6427Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812213fdd94Smrg { 3813213fdd94Smrg func_help noexit 3814213fdd94Smrg for opt_mode in compile link execute install finish uninstall clean; do 3815213fdd94Smrg echo 3816213fdd94Smrg func_mode_help 3817213fdd94Smrg done 3818213fdd94Smrg } | 381997ee6427Smrg $SED '1d 3820213fdd94Smrg /^When reporting/,/^Report/{ 3821213fdd94Smrg H 3822213fdd94Smrg d 3823213fdd94Smrg } 3824213fdd94Smrg $x 3825213fdd94Smrg /information about other modes/d 3826213fdd94Smrg /more detailed .*MODE/d 3827213fdd94Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828213fdd94Smrg fi 3829213fdd94Smrg exit $? 3830213fdd94Smrgfi 38310cc67336Smrg 38320cc67336Smrg 3833213fdd94Smrg# func_mode_execute arg... 3834213fdd94Smrgfunc_mode_execute () 3835213fdd94Smrg{ 383697ee6427Smrg $debug_cmd 383797ee6427Smrg 3838213fdd94Smrg # The first argument is the command name. 383997ee6427Smrg cmd=$nonopt 3840213fdd94Smrg test -z "$cmd" && \ 3841213fdd94Smrg func_fatal_help "you must specify a COMMAND" 3842213fdd94Smrg 3843213fdd94Smrg # Handle -dlopen flags immediately. 3844213fdd94Smrg for file in $opt_dlopen; do 3845213fdd94Smrg test -f "$file" \ 384697ee6427Smrg || func_fatal_help "'$file' is not a file" 3847213fdd94Smrg 3848213fdd94Smrg dir= 3849213fdd94Smrg case $file in 3850213fdd94Smrg *.la) 3851213fdd94Smrg func_resolve_sysroot "$file" 3852213fdd94Smrg file=$func_resolve_sysroot_result 3853213fdd94Smrg 3854213fdd94Smrg # Check to see that this really is a libtool archive. 3855213fdd94Smrg func_lalib_unsafe_p "$file" \ 385697ee6427Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857213fdd94Smrg 3858213fdd94Smrg # Read the libtool library. 3859213fdd94Smrg dlname= 3860213fdd94Smrg library_names= 3861213fdd94Smrg func_source "$file" 3862213fdd94Smrg 3863213fdd94Smrg # Skip this library if it cannot be dlopened. 3864213fdd94Smrg if test -z "$dlname"; then 3865213fdd94Smrg # Warn if it was a shared library. 3866213fdd94Smrg test -n "$library_names" && \ 386797ee6427Smrg func_warning "'$file' was not linked with '-export-dynamic'" 3868213fdd94Smrg continue 3869213fdd94Smrg fi 3870213fdd94Smrg 3871213fdd94Smrg func_dirname "$file" "" "." 387297ee6427Smrg dir=$func_dirname_result 3873213fdd94Smrg 3874213fdd94Smrg if test -f "$dir/$objdir/$dlname"; then 3875213fdd94Smrg func_append dir "/$objdir" 3876213fdd94Smrg else 3877213fdd94Smrg if test ! -f "$dir/$dlname"; then 387897ee6427Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879213fdd94Smrg fi 3880213fdd94Smrg fi 38810cc67336Smrg ;; 3882213fdd94Smrg 3883213fdd94Smrg *.lo) 3884213fdd94Smrg # Just add the directory containing the .lo file. 3885213fdd94Smrg func_dirname "$file" "" "." 388697ee6427Smrg dir=$func_dirname_result 3887ef6fb4a5Smrg ;; 3888213fdd94Smrg 3889213fdd94Smrg *) 389097ee6427Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891213fdd94Smrg continue 38920cc67336Smrg ;; 3893213fdd94Smrg esac 3894213fdd94Smrg 3895213fdd94Smrg # Get the absolute pathname. 3896213fdd94Smrg absdir=`cd "$dir" && pwd` 389797ee6427Smrg test -n "$absdir" && dir=$absdir 3898213fdd94Smrg 3899213fdd94Smrg # Now add the directory to shlibpath_var. 3900213fdd94Smrg if eval "test -z \"\$$shlibpath_var\""; then 3901213fdd94Smrg eval "$shlibpath_var=\"\$dir\"" 3902213fdd94Smrg else 3903213fdd94Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904ef6fb4a5Smrg fi 3905213fdd94Smrg done 3906213fdd94Smrg 3907213fdd94Smrg # This variable tells wrapper scripts just to set shlibpath_var 3908213fdd94Smrg # rather than running their programs. 390997ee6427Smrg libtool_execute_magic=$magic 3910213fdd94Smrg 3911213fdd94Smrg # Check if any of the arguments is a wrapper script. 3912213fdd94Smrg args= 3913213fdd94Smrg for file 3914213fdd94Smrg do 3915213fdd94Smrg case $file in 3916213fdd94Smrg -* | *.la | *.lo ) ;; 3917213fdd94Smrg *) 3918213fdd94Smrg # Do a test to see if this is really a libtool program. 3919213fdd94Smrg if func_ltwrapper_script_p "$file"; then 3920213fdd94Smrg func_source "$file" 3921213fdd94Smrg # Transform arg to wrapped name. 392297ee6427Smrg file=$progdir/$program 3923213fdd94Smrg elif func_ltwrapper_executable_p "$file"; then 3924213fdd94Smrg func_ltwrapper_scriptname "$file" 3925213fdd94Smrg func_source "$func_ltwrapper_scriptname_result" 3926213fdd94Smrg # Transform arg to wrapped name. 392797ee6427Smrg file=$progdir/$program 3928213fdd94Smrg fi 3929213fdd94Smrg ;; 3930213fdd94Smrg esac 3931213fdd94Smrg # Quote arguments (to preserve shell metacharacters). 3932213fdd94Smrg func_append_quoted args "$file" 3933213fdd94Smrg done 3934213fdd94Smrg 393597ee6427Smrg if $opt_dry_run; then 393697ee6427Smrg # Display what would be done. 393797ee6427Smrg if test -n "$shlibpath_var"; then 393897ee6427Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393997ee6427Smrg echo "export $shlibpath_var" 394097ee6427Smrg fi 394197ee6427Smrg $ECHO "$cmd$args" 394297ee6427Smrg exit $EXIT_SUCCESS 394397ee6427Smrg else 3944213fdd94Smrg if test -n "$shlibpath_var"; then 3945213fdd94Smrg # Export the shlibpath_var. 3946213fdd94Smrg eval "export $shlibpath_var" 3947ef6fb4a5Smrg fi 3948213fdd94Smrg 3949213fdd94Smrg # Restore saved environment variables 3950213fdd94Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951213fdd94Smrg do 3952213fdd94Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953213fdd94Smrg $lt_var=\$save_$lt_var; export $lt_var 3954213fdd94Smrg else 3955213fdd94Smrg $lt_unset $lt_var 3956213fdd94Smrg fi" 3957213fdd94Smrg done 3958213fdd94Smrg 3959213fdd94Smrg # Now prepare to actually exec the command. 396097ee6427Smrg exec_cmd=\$cmd$args 3961213fdd94Smrg fi 3962213fdd94Smrg} 3963301ea0f4Smrg 396497ee6427Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965301ea0f4Smrg 3966301ea0f4Smrg 3967213fdd94Smrg# func_mode_finish arg... 3968213fdd94Smrgfunc_mode_finish () 3969213fdd94Smrg{ 397097ee6427Smrg $debug_cmd 397197ee6427Smrg 3972213fdd94Smrg libs= 3973213fdd94Smrg libdirs= 3974213fdd94Smrg admincmds= 3975301ea0f4Smrg 3976213fdd94Smrg for opt in "$nonopt" ${1+"$@"} 3977213fdd94Smrg do 3978213fdd94Smrg if test -d "$opt"; then 3979213fdd94Smrg func_append libdirs " $opt" 3980301ea0f4Smrg 3981213fdd94Smrg elif test -f "$opt"; then 3982213fdd94Smrg if func_lalib_unsafe_p "$opt"; then 3983213fdd94Smrg func_append libs " $opt" 3984213fdd94Smrg else 398597ee6427Smrg func_warning "'$opt' is not a valid libtool archive" 3986ef6fb4a5Smrg fi 3987301ea0f4Smrg 3988213fdd94Smrg else 398997ee6427Smrg func_fatal_error "invalid argument '$opt'" 3990213fdd94Smrg fi 3991213fdd94Smrg done 3992301ea0f4Smrg 3993213fdd94Smrg if test -n "$libs"; then 3994213fdd94Smrg if test -n "$lt_sysroot"; then 3995213fdd94Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996213fdd94Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997213fdd94Smrg else 3998213fdd94Smrg sysroot_cmd= 3999213fdd94Smrg fi 4000301ea0f4Smrg 4001213fdd94Smrg # Remove sysroot references 4002213fdd94Smrg if $opt_dry_run; then 4003213fdd94Smrg for lib in $libs; do 400497ee6427Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005213fdd94Smrg done 4006213fdd94Smrg else 4007213fdd94Smrg tmpdir=`func_mktempdir` 4008213fdd94Smrg for lib in $libs; do 400997ee6427Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010213fdd94Smrg > $tmpdir/tmp-la 4011213fdd94Smrg mv -f $tmpdir/tmp-la $lib 4012ef6fb4a5Smrg done 4013213fdd94Smrg ${RM}r "$tmpdir" 4014213fdd94Smrg fi 4015213fdd94Smrg fi 4016213fdd94Smrg 4017213fdd94Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018213fdd94Smrg for libdir in $libdirs; do 4019213fdd94Smrg if test -n "$finish_cmds"; then 4020213fdd94Smrg # Do each command in the finish commands. 4021213fdd94Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022213fdd94Smrg'"$cmd"'"' 4023213fdd94Smrg fi 4024213fdd94Smrg if test -n "$finish_eval"; then 4025213fdd94Smrg # Do the single finish_eval. 4026213fdd94Smrg eval cmds=\"$finish_eval\" 4027213fdd94Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028213fdd94Smrg $cmds" 4029301ea0f4Smrg fi 4030213fdd94Smrg done 4031213fdd94Smrg fi 4032301ea0f4Smrg 4033213fdd94Smrg # Exit here if they wanted silent mode. 403497ee6427Smrg $opt_quiet && exit $EXIT_SUCCESS 4035301ea0f4Smrg 4036213fdd94Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037213fdd94Smrg echo "----------------------------------------------------------------------" 4038213fdd94Smrg echo "Libraries have been installed in:" 4039213fdd94Smrg for libdir in $libdirs; do 4040213fdd94Smrg $ECHO " $libdir" 4041213fdd94Smrg done 4042213fdd94Smrg echo 4043213fdd94Smrg echo "If you ever happen to want to link against installed libraries" 4044213fdd94Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404597ee6427Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046213fdd94Smrg echo "flag during linking and do at least one of the following:" 4047213fdd94Smrg if test -n "$shlibpath_var"; then 404897ee6427Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049213fdd94Smrg echo " during execution" 4050213fdd94Smrg fi 4051213fdd94Smrg if test -n "$runpath_var"; then 405297ee6427Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4053213fdd94Smrg echo " during linking" 4054213fdd94Smrg fi 4055213fdd94Smrg if test -n "$hardcode_libdir_flag_spec"; then 4056213fdd94Smrg libdir=LIBDIR 4057213fdd94Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4058213fdd94Smrg 405997ee6427Smrg $ECHO " - use the '$flag' linker flag" 4060213fdd94Smrg fi 4061213fdd94Smrg if test -n "$admincmds"; then 4062213fdd94Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4063213fdd94Smrg fi 4064213fdd94Smrg if test -f /etc/ld.so.conf; then 406597ee6427Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066213fdd94Smrg fi 4067213fdd94Smrg echo 4068213fdd94Smrg 4069213fdd94Smrg echo "See any operating system documentation about shared libraries for" 4070213fdd94Smrg case $host in 4071213fdd94Smrg solaris2.[6789]|solaris2.1[0-9]) 4072213fdd94Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073213fdd94Smrg echo "pages." 4074213fdd94Smrg ;; 4075ef6fb4a5Smrg *) 4076213fdd94Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077ef6fb4a5Smrg ;; 4078213fdd94Smrg esac 4079213fdd94Smrg echo "----------------------------------------------------------------------" 4080213fdd94Smrg fi 4081213fdd94Smrg exit $EXIT_SUCCESS 4082213fdd94Smrg} 4083301ea0f4Smrg 408497ee6427Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085301ea0f4Smrg 4086301ea0f4Smrg 4087213fdd94Smrg# func_mode_install arg... 4088213fdd94Smrgfunc_mode_install () 4089213fdd94Smrg{ 409097ee6427Smrg $debug_cmd 409197ee6427Smrg 4092213fdd94Smrg # There may be an optional sh(1) argument at the beginning of 4093213fdd94Smrg # install_prog (especially on Windows NT). 409497ee6427Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095213fdd94Smrg # Allow the use of GNU shtool's install command. 409697ee6427Smrg case $nonopt in *shtool*) :;; *) false;; esac 409797ee6427Smrg then 4098213fdd94Smrg # Aesthetically quote it. 4099213fdd94Smrg func_quote_for_eval "$nonopt" 4100213fdd94Smrg install_prog="$func_quote_for_eval_result " 4101213fdd94Smrg arg=$1 4102213fdd94Smrg shift 4103213fdd94Smrg else 4104213fdd94Smrg install_prog= 4105213fdd94Smrg arg=$nonopt 4106213fdd94Smrg fi 4107213fdd94Smrg 4108213fdd94Smrg # The real first argument should be the name of the installation program. 4109213fdd94Smrg # Aesthetically quote it. 4110213fdd94Smrg func_quote_for_eval "$arg" 4111213fdd94Smrg func_append install_prog "$func_quote_for_eval_result" 4112213fdd94Smrg install_shared_prog=$install_prog 4113213fdd94Smrg case " $install_prog " in 4114213fdd94Smrg *[\\\ /]cp\ *) install_cp=: ;; 4115213fdd94Smrg *) install_cp=false ;; 4116213fdd94Smrg esac 4117213fdd94Smrg 4118213fdd94Smrg # We need to accept at least all the BSD install flags. 4119213fdd94Smrg dest= 4120213fdd94Smrg files= 4121213fdd94Smrg opts= 4122213fdd94Smrg prev= 4123213fdd94Smrg install_type= 412497ee6427Smrg isdir=false 4125213fdd94Smrg stripme= 4126213fdd94Smrg no_mode=: 4127213fdd94Smrg for arg 4128213fdd94Smrg do 4129213fdd94Smrg arg2= 4130213fdd94Smrg if test -n "$dest"; then 4131213fdd94Smrg func_append files " $dest" 4132213fdd94Smrg dest=$arg 4133213fdd94Smrg continue 4134213fdd94Smrg fi 4135213fdd94Smrg 4136213fdd94Smrg case $arg in 413797ee6427Smrg -d) isdir=: ;; 4138213fdd94Smrg -f) 4139213fdd94Smrg if $install_cp; then :; else 4140213fdd94Smrg prev=$arg 4141213fdd94Smrg fi 4142213fdd94Smrg ;; 4143213fdd94Smrg -g | -m | -o) 4144213fdd94Smrg prev=$arg 4145213fdd94Smrg ;; 4146213fdd94Smrg -s) 4147213fdd94Smrg stripme=" -s" 4148213fdd94Smrg continue 4149213fdd94Smrg ;; 4150213fdd94Smrg -*) 4151213fdd94Smrg ;; 4152213fdd94Smrg *) 4153213fdd94Smrg # If the previous option needed an argument, then skip it. 4154213fdd94Smrg if test -n "$prev"; then 415597ee6427Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156213fdd94Smrg arg2=$install_override_mode 4157213fdd94Smrg no_mode=false 4158ef6fb4a5Smrg fi 4159213fdd94Smrg prev= 4160213fdd94Smrg else 4161213fdd94Smrg dest=$arg 4162ef6fb4a5Smrg continue 4163ef6fb4a5Smrg fi 4164213fdd94Smrg ;; 4165213fdd94Smrg esac 4166301ea0f4Smrg 4167213fdd94Smrg # Aesthetically quote the argument. 4168213fdd94Smrg func_quote_for_eval "$arg" 4169213fdd94Smrg func_append install_prog " $func_quote_for_eval_result" 4170213fdd94Smrg if test -n "$arg2"; then 4171213fdd94Smrg func_quote_for_eval "$arg2" 4172213fdd94Smrg fi 4173213fdd94Smrg func_append install_shared_prog " $func_quote_for_eval_result" 4174213fdd94Smrg done 4175301ea0f4Smrg 4176213fdd94Smrg test -z "$install_prog" && \ 4177213fdd94Smrg func_fatal_help "you must specify an install program" 4178301ea0f4Smrg 4179213fdd94Smrg test -n "$prev" && \ 418097ee6427Smrg func_fatal_help "the '$prev' option requires an argument" 4181301ea0f4Smrg 4182213fdd94Smrg if test -n "$install_override_mode" && $no_mode; then 4183213fdd94Smrg if $install_cp; then :; else 4184213fdd94Smrg func_quote_for_eval "$install_override_mode" 4185213fdd94Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4186213fdd94Smrg fi 4187213fdd94Smrg fi 4188301ea0f4Smrg 4189213fdd94Smrg if test -z "$files"; then 4190213fdd94Smrg if test -z "$dest"; then 4191213fdd94Smrg func_fatal_help "no file or destination specified" 4192213fdd94Smrg else 4193213fdd94Smrg func_fatal_help "you must specify a destination" 4194213fdd94Smrg fi 4195213fdd94Smrg fi 4196301ea0f4Smrg 4197213fdd94Smrg # Strip any trailing slash from the destination. 4198213fdd94Smrg func_stripname '' '/' "$dest" 4199213fdd94Smrg dest=$func_stripname_result 4200301ea0f4Smrg 4201213fdd94Smrg # Check to see that the destination is a directory. 420297ee6427Smrg test -d "$dest" && isdir=: 420397ee6427Smrg if $isdir; then 420497ee6427Smrg destdir=$dest 4205213fdd94Smrg destname= 4206213fdd94Smrg else 4207213fdd94Smrg func_dirname_and_basename "$dest" "" "." 420897ee6427Smrg destdir=$func_dirname_result 420997ee6427Smrg destname=$func_basename_result 4210301ea0f4Smrg 4211213fdd94Smrg # Not a directory, so check to see that there is only one file specified. 4212213fdd94Smrg set dummy $files; shift 4213213fdd94Smrg test "$#" -gt 1 && \ 421497ee6427Smrg func_fatal_help "'$dest' is not a directory" 4215213fdd94Smrg fi 4216213fdd94Smrg case $destdir in 4217213fdd94Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218213fdd94Smrg *) 4219213fdd94Smrg for file in $files; do 4220213fdd94Smrg case $file in 4221213fdd94Smrg *.lo) ;; 4222213fdd94Smrg *) 422397ee6427Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4224213fdd94Smrg ;; 4225213fdd94Smrg esac 4226213fdd94Smrg done 4227213fdd94Smrg ;; 4228213fdd94Smrg esac 4229301ea0f4Smrg 4230213fdd94Smrg # This variable tells wrapper scripts just to set variables rather 4231213fdd94Smrg # than running their programs. 423297ee6427Smrg libtool_install_magic=$magic 4233301ea0f4Smrg 4234213fdd94Smrg staticlibs= 4235213fdd94Smrg future_libdirs= 4236213fdd94Smrg current_libdirs= 4237213fdd94Smrg for file in $files; do 4238301ea0f4Smrg 4239213fdd94Smrg # Do each installation. 4240213fdd94Smrg case $file in 4241213fdd94Smrg *.$libext) 4242213fdd94Smrg # Do the static libraries later. 4243213fdd94Smrg func_append staticlibs " $file" 4244213fdd94Smrg ;; 4245301ea0f4Smrg 4246213fdd94Smrg *.la) 4247213fdd94Smrg func_resolve_sysroot "$file" 4248213fdd94Smrg file=$func_resolve_sysroot_result 4249301ea0f4Smrg 4250213fdd94Smrg # Check to see that this really is a libtool archive. 4251213fdd94Smrg func_lalib_unsafe_p "$file" \ 425297ee6427Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4253301ea0f4Smrg 4254213fdd94Smrg library_names= 4255213fdd94Smrg old_library= 4256213fdd94Smrg relink_command= 4257213fdd94Smrg func_source "$file" 4258301ea0f4Smrg 4259213fdd94Smrg # Add the libdir to current_libdirs if it is the destination. 4260213fdd94Smrg if test "X$destdir" = "X$libdir"; then 4261213fdd94Smrg case "$current_libdirs " in 4262213fdd94Smrg *" $libdir "*) ;; 4263213fdd94Smrg *) func_append current_libdirs " $libdir" ;; 4264213fdd94Smrg esac 4265213fdd94Smrg else 4266213fdd94Smrg # Note the libdir as a future libdir. 4267213fdd94Smrg case "$future_libdirs " in 4268213fdd94Smrg *" $libdir "*) ;; 4269213fdd94Smrg *) func_append future_libdirs " $libdir" ;; 4270213fdd94Smrg esac 4271213fdd94Smrg fi 4272301ea0f4Smrg 4273213fdd94Smrg func_dirname "$file" "/" "" 427497ee6427Smrg dir=$func_dirname_result 4275213fdd94Smrg func_append dir "$objdir" 4276301ea0f4Smrg 4277213fdd94Smrg if test -n "$relink_command"; then 4278213fdd94Smrg # Determine the prefix the user has applied to our future dir. 4279213fdd94Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280301ea0f4Smrg 4281213fdd94Smrg # Don't allow the user to place us outside of our expected 4282213fdd94Smrg # location b/c this prevents finding dependent libraries that 4283213fdd94Smrg # are installed to the same prefix. 4284213fdd94Smrg # At present, this check doesn't affect windows .dll's that 4285213fdd94Smrg # are installed into $libdir/../bin (currently, that works fine) 4286213fdd94Smrg # but it's something to keep an eye on. 4287213fdd94Smrg test "$inst_prefix_dir" = "$destdir" && \ 428897ee6427Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289213fdd94Smrg 4290213fdd94Smrg if test -n "$inst_prefix_dir"; then 4291213fdd94Smrg # Stick the inst_prefix_dir data into the link command. 4292213fdd94Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293ef6fb4a5Smrg else 4294213fdd94Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295ef6fb4a5Smrg fi 4296301ea0f4Smrg 429797ee6427Smrg func_warning "relinking '$file'" 4298213fdd94Smrg func_show_eval "$relink_command" \ 429997ee6427Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300213fdd94Smrg fi 4301213fdd94Smrg 4302213fdd94Smrg # See the names of the shared library. 4303213fdd94Smrg set dummy $library_names; shift 4304213fdd94Smrg if test -n "$1"; then 430597ee6427Smrg realname=$1 4306213fdd94Smrg shift 4307213fdd94Smrg 430897ee6427Smrg srcname=$realname 430997ee6427Smrg test -n "$relink_command" && srcname=${realname}T 4310213fdd94Smrg 4311213fdd94Smrg # Install the shared library and build the symlinks. 4312213fdd94Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313213fdd94Smrg 'exit $?' 431497ee6427Smrg tstripme=$stripme 4315213fdd94Smrg case $host_os in 4316213fdd94Smrg cygwin* | mingw* | pw32* | cegcc*) 4317213fdd94Smrg case $realname in 4318213fdd94Smrg *.dll.a) 431997ee6427Smrg tstripme= 432097ee6427Smrg ;; 432197ee6427Smrg esac 432297ee6427Smrg ;; 432397ee6427Smrg os2*) 432497ee6427Smrg case $realname in 432597ee6427Smrg *_dll.a) 432697ee6427Smrg tstripme= 4327213fdd94Smrg ;; 4328213fdd94Smrg esac 4329213fdd94Smrg ;; 4330213fdd94Smrg esac 4331213fdd94Smrg if test -n "$tstripme" && test -n "$striplib"; then 4332213fdd94Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333ef6fb4a5Smrg fi 4334301ea0f4Smrg 4335213fdd94Smrg if test "$#" -gt 0; then 4336213fdd94Smrg # Delete the old symlinks, and create new ones. 433797ee6427Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338213fdd94Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339213fdd94Smrg # so we also need to try rm && ln -s. 4340213fdd94Smrg for linkname 4341213fdd94Smrg do 4342213fdd94Smrg test "$linkname" != "$realname" \ 4343213fdd94Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344ef6fb4a5Smrg done 4345ef6fb4a5Smrg fi 4346301ea0f4Smrg 4347213fdd94Smrg # Do each command in the postinstall commands. 434897ee6427Smrg lib=$destdir/$realname 4349213fdd94Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350213fdd94Smrg fi 43510cc67336Smrg 4352213fdd94Smrg # Install the pseudo-library for information purposes. 4353213fdd94Smrg func_basename "$file" 435497ee6427Smrg name=$func_basename_result 435597ee6427Smrg instname=$dir/${name}i 4356213fdd94Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357ef6fb4a5Smrg 4358213fdd94Smrg # Maybe install the static library, too. 4359213fdd94Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360213fdd94Smrg ;; 4361213fdd94Smrg 4362213fdd94Smrg *.lo) 4363213fdd94Smrg # Install (i.e. copy) a libtool object. 4364213fdd94Smrg 4365213fdd94Smrg # Figure out destination file name, if it wasn't already specified. 4366213fdd94Smrg if test -n "$destname"; then 436797ee6427Smrg destfile=$destdir/$destname 4368ef6fb4a5Smrg else 4369213fdd94Smrg func_basename "$file" 437097ee6427Smrg destfile=$func_basename_result 437197ee6427Smrg destfile=$destdir/$destfile 4372ef6fb4a5Smrg fi 4373213fdd94Smrg 4374213fdd94Smrg # Deduce the name of the destination old-style object file. 4375213fdd94Smrg case $destfile in 4376213fdd94Smrg *.lo) 4377213fdd94Smrg func_lo2o "$destfile" 4378213fdd94Smrg staticdest=$func_lo2o_result 4379213fdd94Smrg ;; 4380213fdd94Smrg *.$objext) 438197ee6427Smrg staticdest=$destfile 4382213fdd94Smrg destfile= 4383213fdd94Smrg ;; 4384213fdd94Smrg *) 438597ee6427Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 43860cc67336Smrg ;; 43870cc67336Smrg esac 43880cc67336Smrg 4389213fdd94Smrg # Install the libtool object if requested. 4390213fdd94Smrg test -n "$destfile" && \ 4391213fdd94Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 43920cc67336Smrg 4393213fdd94Smrg # Install the old object if enabled. 439497ee6427Smrg if test yes = "$build_old_libs"; then 4395213fdd94Smrg # Deduce the name of the old-style object file. 4396213fdd94Smrg func_lo2o "$file" 4397213fdd94Smrg staticobj=$func_lo2o_result 4398213fdd94Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399213fdd94Smrg fi 4400213fdd94Smrg exit $EXIT_SUCCESS 4401213fdd94Smrg ;; 4402301ea0f4Smrg 4403213fdd94Smrg *) 4404213fdd94Smrg # Figure out destination file name, if it wasn't already specified. 4405213fdd94Smrg if test -n "$destname"; then 440697ee6427Smrg destfile=$destdir/$destname 4407213fdd94Smrg else 4408213fdd94Smrg func_basename "$file" 440997ee6427Smrg destfile=$func_basename_result 441097ee6427Smrg destfile=$destdir/$destfile 4411213fdd94Smrg fi 4412301ea0f4Smrg 4413213fdd94Smrg # If the file is missing, and there is a .exe on the end, strip it 4414213fdd94Smrg # because it is most likely a libtool script we actually want to 4415213fdd94Smrg # install 441697ee6427Smrg stripped_ext= 4417213fdd94Smrg case $file in 4418213fdd94Smrg *.exe) 4419213fdd94Smrg if test ! -f "$file"; then 4420213fdd94Smrg func_stripname '' '.exe' "$file" 4421213fdd94Smrg file=$func_stripname_result 442297ee6427Smrg stripped_ext=.exe 4423213fdd94Smrg fi 4424213fdd94Smrg ;; 4425213fdd94Smrg esac 4426301ea0f4Smrg 4427213fdd94Smrg # Do a test to see if this is really a libtool program. 4428213fdd94Smrg case $host in 4429213fdd94Smrg *cygwin* | *mingw*) 4430213fdd94Smrg if func_ltwrapper_executable_p "$file"; then 4431213fdd94Smrg func_ltwrapper_scriptname "$file" 4432213fdd94Smrg wrapper=$func_ltwrapper_scriptname_result 4433213fdd94Smrg else 4434213fdd94Smrg func_stripname '' '.exe' "$file" 4435213fdd94Smrg wrapper=$func_stripname_result 4436213fdd94Smrg fi 4437213fdd94Smrg ;; 4438213fdd94Smrg *) 4439213fdd94Smrg wrapper=$file 4440213fdd94Smrg ;; 4441213fdd94Smrg esac 4442213fdd94Smrg if func_ltwrapper_script_p "$wrapper"; then 4443213fdd94Smrg notinst_deplibs= 4444213fdd94Smrg relink_command= 4445301ea0f4Smrg 4446213fdd94Smrg func_source "$wrapper" 4447301ea0f4Smrg 4448213fdd94Smrg # Check the variables that should have been set. 4449213fdd94Smrg test -z "$generated_by_libtool_version" && \ 445097ee6427Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451301ea0f4Smrg 445297ee6427Smrg finalize=: 4453213fdd94Smrg for lib in $notinst_deplibs; do 4454213fdd94Smrg # Check to see that each library is installed. 4455213fdd94Smrg libdir= 4456213fdd94Smrg if test -f "$lib"; then 4457213fdd94Smrg func_source "$lib" 4458213fdd94Smrg fi 445997ee6427Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460213fdd94Smrg if test -n "$libdir" && test ! -f "$libfile"; then 446197ee6427Smrg func_warning "'$lib' has not been installed in '$libdir'" 446297ee6427Smrg finalize=false 4463213fdd94Smrg fi 4464213fdd94Smrg done 4465301ea0f4Smrg 4466213fdd94Smrg relink_command= 4467213fdd94Smrg func_source "$wrapper" 4468213fdd94Smrg 4469213fdd94Smrg outputname= 447097ee6427Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4471213fdd94Smrg $opt_dry_run || { 447297ee6427Smrg if $finalize; then 4473213fdd94Smrg tmpdir=`func_mktempdir` 4474213fdd94Smrg func_basename "$file$stripped_ext" 447597ee6427Smrg file=$func_basename_result 447697ee6427Smrg outputname=$tmpdir/$file 4477213fdd94Smrg # Replace the output file specification. 4478213fdd94Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479213fdd94Smrg 448097ee6427Smrg $opt_quiet || { 4481213fdd94Smrg func_quote_for_expand "$relink_command" 4482213fdd94Smrg eval "func_echo $func_quote_for_expand_result" 4483213fdd94Smrg } 4484213fdd94Smrg if eval "$relink_command"; then : 4485213fdd94Smrg else 448697ee6427Smrg func_error "error: relink '$file' with the above command before installing it" 4487213fdd94Smrg $opt_dry_run || ${RM}r "$tmpdir" 4488213fdd94Smrg continue 4489213fdd94Smrg fi 449097ee6427Smrg file=$outputname 4491213fdd94Smrg else 449297ee6427Smrg func_warning "cannot relink '$file'" 4493213fdd94Smrg fi 4494213fdd94Smrg } 4495213fdd94Smrg else 4496213fdd94Smrg # Install the binary that we compiled earlier. 4497213fdd94Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498213fdd94Smrg fi 4499ef6fb4a5Smrg fi 4500213fdd94Smrg 4501213fdd94Smrg # remove .exe since cygwin /usr/bin/install will append another 4502213fdd94Smrg # one anyway 4503213fdd94Smrg case $install_prog,$host in 4504213fdd94Smrg */usr/bin/install*,*cygwin*) 4505213fdd94Smrg case $file:$destfile in 4506213fdd94Smrg *.exe:*.exe) 4507213fdd94Smrg # this is ok 4508213fdd94Smrg ;; 4509213fdd94Smrg *.exe:*) 4510213fdd94Smrg destfile=$destfile.exe 4511213fdd94Smrg ;; 4512213fdd94Smrg *:*.exe) 4513213fdd94Smrg func_stripname '' '.exe' "$destfile" 4514213fdd94Smrg destfile=$func_stripname_result 4515213fdd94Smrg ;; 4516213fdd94Smrg esac 4517213fdd94Smrg ;; 4518213fdd94Smrg esac 4519213fdd94Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520213fdd94Smrg $opt_dry_run || if test -n "$outputname"; then 4521213fdd94Smrg ${RM}r "$tmpdir" 4522ef6fb4a5Smrg fi 4523ef6fb4a5Smrg ;; 4524ef6fb4a5Smrg esac 4525213fdd94Smrg done 45260cc67336Smrg 4527213fdd94Smrg for file in $staticlibs; do 4528213fdd94Smrg func_basename "$file" 452997ee6427Smrg name=$func_basename_result 45300cc67336Smrg 4531213fdd94Smrg # Set up the ranlib parameters. 453297ee6427Smrg oldlib=$destdir/$name 4533213fdd94Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534213fdd94Smrg tool_oldlib=$func_to_tool_file_result 45350cc67336Smrg 4536213fdd94Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537213fdd94Smrg 4538213fdd94Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4539213fdd94Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540ef6fb4a5Smrg fi 45410cc67336Smrg 4542213fdd94Smrg # Do each command in the postinstall commands. 4543213fdd94Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544213fdd94Smrg done 45450cc67336Smrg 4546213fdd94Smrg test -n "$future_libdirs" && \ 454797ee6427Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 45480cc67336Smrg 4549213fdd94Smrg if test -n "$current_libdirs"; then 4550213fdd94Smrg # Maybe just do a dry run. 4551213fdd94Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455297ee6427Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553213fdd94Smrg else 4554213fdd94Smrg exit $EXIT_SUCCESS 4555213fdd94Smrg fi 4556213fdd94Smrg} 45570cc67336Smrg 455897ee6427Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 45590cc67336Smrg 45600cc67336Smrg 4561213fdd94Smrg# func_generate_dlsyms outputname originator pic_p 4562213fdd94Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563213fdd94Smrg# a dlpreopen symbol table. 4564213fdd94Smrgfunc_generate_dlsyms () 4565213fdd94Smrg{ 456697ee6427Smrg $debug_cmd 456797ee6427Smrg 456897ee6427Smrg my_outputname=$1 456997ee6427Smrg my_originator=$2 457097ee6427Smrg my_pic_p=${3-false} 457197ee6427Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572213fdd94Smrg my_dlsyms= 4573213fdd94Smrg 457497ee6427Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575213fdd94Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457697ee6427Smrg my_dlsyms=${my_outputname}S.c 4577213fdd94Smrg else 4578213fdd94Smrg func_error "not configured to extract global symbols from dlpreopened files" 4579213fdd94Smrg fi 4580213fdd94Smrg fi 45810cc67336Smrg 4582213fdd94Smrg if test -n "$my_dlsyms"; then 4583213fdd94Smrg case $my_dlsyms in 4584213fdd94Smrg "") ;; 4585213fdd94Smrg *.c) 4586213fdd94Smrg # Discover the nlist of each of the dlfiles. 458797ee6427Smrg nlist=$output_objdir/$my_outputname.nm 45880cc67336Smrg 4589213fdd94Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 45900cc67336Smrg 4591213fdd94Smrg # Parse the name list into a source file. 4592213fdd94Smrg func_verbose "creating $output_objdir/$my_dlsyms" 45930cc67336Smrg 4594213fdd94Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459597ee6427Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459697ee6427Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 45970cc67336Smrg 4598213fdd94Smrg#ifdef __cplusplus 4599213fdd94Smrgextern \"C\" { 4600213fdd94Smrg#endif 46010cc67336Smrg 460297ee6427Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603213fdd94Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604213fdd94Smrg#endif 46050cc67336Smrg 4606213fdd94Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460797ee6427Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460897ee6427Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609213fdd94Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610213fdd94Smrg# define LT_DLSYM_CONST 461197ee6427Smrg#elif defined __osf__ 4612213fdd94Smrg/* This system does not cope well with relocations in const data. */ 4613213fdd94Smrg# define LT_DLSYM_CONST 4614213fdd94Smrg#else 4615213fdd94Smrg# define LT_DLSYM_CONST const 4616213fdd94Smrg#endif 46170cc67336Smrg 461897ee6427Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461997ee6427Smrg 4620213fdd94Smrg/* External symbol declarations for the compiler. */\ 4621213fdd94Smrg" 46220cc67336Smrg 462397ee6427Smrg if test yes = "$dlself"; then 462497ee6427Smrg func_verbose "generating symbol list for '$output'" 46250cc67336Smrg 4626213fdd94Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627301ea0f4Smrg 4628213fdd94Smrg # Add our own program objects to the symbol list. 4629213fdd94Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630213fdd94Smrg for progfile in $progfiles; do 4631213fdd94Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463297ee6427Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633213fdd94Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634ef6fb4a5Smrg done 4635301ea0f4Smrg 4636213fdd94Smrg if test -n "$exclude_expsyms"; then 4637213fdd94Smrg $opt_dry_run || { 4638213fdd94Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639213fdd94Smrg eval '$MV "$nlist"T "$nlist"' 4640213fdd94Smrg } 4641213fdd94Smrg fi 4642301ea0f4Smrg 4643213fdd94Smrg if test -n "$export_symbols_regex"; then 4644213fdd94Smrg $opt_dry_run || { 4645213fdd94Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646213fdd94Smrg eval '$MV "$nlist"T "$nlist"' 4647213fdd94Smrg } 4648213fdd94Smrg fi 4649301ea0f4Smrg 4650213fdd94Smrg # Prepare the list of exported symbols 4651213fdd94Smrg if test -z "$export_symbols"; then 465297ee6427Smrg export_symbols=$output_objdir/$outputname.exp 4653213fdd94Smrg $opt_dry_run || { 4654213fdd94Smrg $RM $export_symbols 465597ee6427Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656213fdd94Smrg case $host in 4657213fdd94Smrg *cygwin* | *mingw* | *cegcc* ) 4658213fdd94Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659213fdd94Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660213fdd94Smrg ;; 4661213fdd94Smrg esac 4662213fdd94Smrg } 4663213fdd94Smrg else 4664213fdd94Smrg $opt_dry_run || { 466597ee6427Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666213fdd94Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667213fdd94Smrg eval '$MV "$nlist"T "$nlist"' 4668213fdd94Smrg case $host in 4669213fdd94Smrg *cygwin* | *mingw* | *cegcc* ) 4670213fdd94Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671213fdd94Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672213fdd94Smrg ;; 4673213fdd94Smrg esac 4674213fdd94Smrg } 4675213fdd94Smrg fi 4676213fdd94Smrg fi 4677301ea0f4Smrg 4678213fdd94Smrg for dlprefile in $dlprefiles; do 467997ee6427Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4680213fdd94Smrg func_basename "$dlprefile" 468197ee6427Smrg name=$func_basename_result 4682213fdd94Smrg case $host in 4683213fdd94Smrg *cygwin* | *mingw* | *cegcc* ) 4684213fdd94Smrg # if an import library, we need to obtain dlname 4685213fdd94Smrg if func_win32_import_lib_p "$dlprefile"; then 4686213fdd94Smrg func_tr_sh "$dlprefile" 4687213fdd94Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468897ee6427Smrg dlprefile_dlbasename= 4689213fdd94Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690213fdd94Smrg # Use subshell, to avoid clobbering current variable values 4691213fdd94Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469297ee6427Smrg if test -n "$dlprefile_dlname"; then 4693213fdd94Smrg func_basename "$dlprefile_dlname" 469497ee6427Smrg dlprefile_dlbasename=$func_basename_result 4695213fdd94Smrg else 4696213fdd94Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4697213fdd94Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4698213fdd94Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4699213fdd94Smrg fi 4700213fdd94Smrg fi 4701213fdd94Smrg $opt_dry_run || { 470297ee6427Smrg if test -n "$dlprefile_dlbasename"; then 4703213fdd94Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704213fdd94Smrg else 4705213fdd94Smrg func_warning "Could not compute DLL name from $name" 4706213fdd94Smrg eval '$ECHO ": $name " >> "$nlist"' 4707213fdd94Smrg fi 4708213fdd94Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709213fdd94Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710213fdd94Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711213fdd94Smrg } 4712213fdd94Smrg else # not an import lib 4713213fdd94Smrg $opt_dry_run || { 4714213fdd94Smrg eval '$ECHO ": $name " >> "$nlist"' 4715213fdd94Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716213fdd94Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717213fdd94Smrg } 4718213fdd94Smrg fi 4719213fdd94Smrg ;; 4720213fdd94Smrg *) 4721213fdd94Smrg $opt_dry_run || { 4722213fdd94Smrg eval '$ECHO ": $name " >> "$nlist"' 4723213fdd94Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724213fdd94Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725213fdd94Smrg } 4726213fdd94Smrg ;; 4727213fdd94Smrg esac 4728213fdd94Smrg done 4729301ea0f4Smrg 4730213fdd94Smrg $opt_dry_run || { 4731213fdd94Smrg # Make sure we have at least an empty file. 4732213fdd94Smrg test -f "$nlist" || : > "$nlist" 4733301ea0f4Smrg 4734213fdd94Smrg if test -n "$exclude_expsyms"; then 4735213fdd94Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736213fdd94Smrg $MV "$nlist"T "$nlist" 4737213fdd94Smrg fi 4738301ea0f4Smrg 4739213fdd94Smrg # Try sorting and uniquifying the output. 4740213fdd94Smrg if $GREP -v "^: " < "$nlist" | 4741213fdd94Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742213fdd94Smrg sort -k 3 4743213fdd94Smrg else 4744213fdd94Smrg sort +2 4745213fdd94Smrg fi | 4746213fdd94Smrg uniq > "$nlist"S; then 4747213fdd94Smrg : 4748213fdd94Smrg else 4749213fdd94Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750213fdd94Smrg fi 4751301ea0f4Smrg 4752213fdd94Smrg if test -f "$nlist"S; then 4753213fdd94Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754213fdd94Smrg else 4755213fdd94Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756213fdd94Smrg fi 4757301ea0f4Smrg 475897ee6427Smrg func_show_eval '$RM "${nlist}I"' 475997ee6427Smrg if test -n "$global_symbol_to_import"; then 476097ee6427Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476197ee6427Smrg fi 476297ee6427Smrg 4763213fdd94Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4764213fdd94Smrg 4765213fdd94Smrg/* The mapping between symbol names and symbols. */ 4766213fdd94Smrgtypedef struct { 4767213fdd94Smrg const char *name; 4768213fdd94Smrg void *address; 4769213fdd94Smrg} lt_dlsymlist; 4770213fdd94Smrgextern LT_DLSYM_CONST lt_dlsymlist 477197ee6427Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477297ee6427Smrg" 477397ee6427Smrg 477497ee6427Smrg if test -s "$nlist"I; then 477597ee6427Smrg echo >> "$output_objdir/$my_dlsyms" "\ 477697ee6427Smrgstatic void lt_syminit(void) 477797ee6427Smrg{ 477897ee6427Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477997ee6427Smrg for (; symbol->name; ++symbol) 478097ee6427Smrg {" 478197ee6427Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478297ee6427Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478397ee6427Smrg } 478497ee6427Smrg}" 478597ee6427Smrg fi 478697ee6427Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4787213fdd94SmrgLT_DLSYM_CONST lt_dlsymlist 4788213fdd94Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 478997ee6427Smrg{ {\"$my_originator\", (void *) 0}," 479097ee6427Smrg 479197ee6427Smrg if test -s "$nlist"I; then 479297ee6427Smrg echo >> "$output_objdir/$my_dlsyms" "\ 479397ee6427Smrg {\"@INIT@\", (void *) <_syminit}," 479497ee6427Smrg fi 4795213fdd94Smrg 4796213fdd94Smrg case $need_lib_prefix in 4797213fdd94Smrg no) 4798213fdd94Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 47990cc67336Smrg ;; 4800ef6fb4a5Smrg *) 4801213fdd94Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802ef6fb4a5Smrg ;; 4803ef6fb4a5Smrg esac 4804213fdd94Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4805213fdd94Smrg {0, (void *) 0} 4806213fdd94Smrg}; 4807301ea0f4Smrg 4808213fdd94Smrg/* This works around a problem in FreeBSD linker */ 4809213fdd94Smrg#ifdef FREEBSD_WORKAROUND 4810213fdd94Smrgstatic const void *lt_preloaded_setup() { 4811213fdd94Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812213fdd94Smrg} 4813213fdd94Smrg#endif 4814301ea0f4Smrg 4815213fdd94Smrg#ifdef __cplusplus 4816213fdd94Smrg} 4817213fdd94Smrg#endif\ 4818213fdd94Smrg" 4819213fdd94Smrg } # !$opt_dry_run 4820301ea0f4Smrg 4821213fdd94Smrg pic_flag_for_symtable= 4822213fdd94Smrg case "$compile_command " in 4823213fdd94Smrg *" -static "*) ;; 4824213fdd94Smrg *) 4825213fdd94Smrg case $host in 4826213fdd94Smrg # compiling the symbol table file with pic_flag works around 4827213fdd94Smrg # a FreeBSD bug that causes programs to crash when -lm is 4828213fdd94Smrg # linked before any other PIC object. But we must not use 4829213fdd94Smrg # pic_flag when linking with -static. The problem exists in 4830213fdd94Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831213fdd94Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832213fdd94Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833213fdd94Smrg *-*-hpux*) 4834213fdd94Smrg pic_flag_for_symtable=" $pic_flag" ;; 4835213fdd94Smrg *) 483697ee6427Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837213fdd94Smrg ;; 4838213fdd94Smrg esac 4839213fdd94Smrg ;; 4840213fdd94Smrg esac 4841213fdd94Smrg symtab_cflags= 4842213fdd94Smrg for arg in $LTCFLAGS; do 4843213fdd94Smrg case $arg in 4844213fdd94Smrg -pie | -fpie | -fPIE) ;; 4845213fdd94Smrg *) func_append symtab_cflags " $arg" ;; 4846ef6fb4a5Smrg esac 4847ef6fb4a5Smrg done 4848301ea0f4Smrg 4849213fdd94Smrg # Now compile the dynamic symbol file. 4850213fdd94Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851301ea0f4Smrg 4852213fdd94Smrg # Clean up the generated files. 485397ee6427Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854301ea0f4Smrg 4855213fdd94Smrg # Transform the symbol file into the correct name. 485697ee6427Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857213fdd94Smrg case $host in 4858213fdd94Smrg *cygwin* | *mingw* | *cegcc* ) 4859213fdd94Smrg if test -f "$output_objdir/$my_outputname.def"; then 4860213fdd94Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861213fdd94Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862213fdd94Smrg else 4863213fdd94Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864213fdd94Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865213fdd94Smrg fi 4866213fdd94Smrg ;; 4867213fdd94Smrg *) 4868213fdd94Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869213fdd94Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870213fdd94Smrg ;; 4871213fdd94Smrg esac 4872213fdd94Smrg ;; 4873213fdd94Smrg *) 487497ee6427Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875213fdd94Smrg ;; 4876213fdd94Smrg esac 4877213fdd94Smrg else 4878213fdd94Smrg # We keep going just in case the user didn't refer to 4879213fdd94Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880213fdd94Smrg # really was required. 4881301ea0f4Smrg 4882213fdd94Smrg # Nullify the symbol file. 4883213fdd94Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884213fdd94Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885213fdd94Smrg fi 4886213fdd94Smrg} 4887301ea0f4Smrg 488897ee6427Smrg# func_cygming_gnu_implib_p ARG 488997ee6427Smrg# This predicate returns with zero status (TRUE) if 489097ee6427Smrg# ARG is a GNU/binutils-style import library. Returns 489197ee6427Smrg# with nonzero status (FALSE) otherwise. 489297ee6427Smrgfunc_cygming_gnu_implib_p () 489397ee6427Smrg{ 489497ee6427Smrg $debug_cmd 489597ee6427Smrg 489697ee6427Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489797ee6427Smrg 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)$'` 489897ee6427Smrg test -n "$func_cygming_gnu_implib_tmp" 489997ee6427Smrg} 490097ee6427Smrg 490197ee6427Smrg# func_cygming_ms_implib_p ARG 490297ee6427Smrg# This predicate returns with zero status (TRUE) if 490397ee6427Smrg# ARG is an MS-style import library. Returns 490497ee6427Smrg# with nonzero status (FALSE) otherwise. 490597ee6427Smrgfunc_cygming_ms_implib_p () 490697ee6427Smrg{ 490797ee6427Smrg $debug_cmd 490897ee6427Smrg 490997ee6427Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491097ee6427Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491197ee6427Smrg test -n "$func_cygming_ms_implib_tmp" 491297ee6427Smrg} 491397ee6427Smrg 4914213fdd94Smrg# func_win32_libid arg 4915213fdd94Smrg# return the library type of file 'arg' 4916213fdd94Smrg# 4917213fdd94Smrg# Need a lot of goo to handle *both* DLLs and import libs 4918213fdd94Smrg# Has to be a shell function in order to 'eat' the argument 4919213fdd94Smrg# that is supplied when $file_magic_command is called. 4920213fdd94Smrg# Despite the name, also deal with 64 bit binaries. 4921213fdd94Smrgfunc_win32_libid () 4922213fdd94Smrg{ 492397ee6427Smrg $debug_cmd 492497ee6427Smrg 492597ee6427Smrg win32_libid_type=unknown 4926213fdd94Smrg win32_fileres=`file -L $1 2>/dev/null` 4927213fdd94Smrg case $win32_fileres in 4928213fdd94Smrg *ar\ archive\ import\ library*) # definitely import 4929213fdd94Smrg win32_libid_type="x86 archive import" 4930213fdd94Smrg ;; 4931213fdd94Smrg *ar\ archive*) # could be an import, or static 4932213fdd94Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933213fdd94Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934213fdd94Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493597ee6427Smrg case $nm_interface in 493697ee6427Smrg "MS dumpbin") 493797ee6427Smrg if func_cygming_ms_implib_p "$1" || 493897ee6427Smrg func_cygming_gnu_implib_p "$1" 493997ee6427Smrg then 494097ee6427Smrg win32_nmres=import 494197ee6427Smrg else 494297ee6427Smrg win32_nmres= 494397ee6427Smrg fi 494497ee6427Smrg ;; 494597ee6427Smrg *) 494697ee6427Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494797ee6427Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494897ee6427Smrg $SED -n -e ' 4949213fdd94Smrg 1,100{ 4950213fdd94Smrg / I /{ 495197ee6427Smrg s|.*|import| 4952213fdd94Smrg p 4953213fdd94Smrg q 4954213fdd94Smrg } 4955213fdd94Smrg }'` 495697ee6427Smrg ;; 495797ee6427Smrg esac 4958213fdd94Smrg case $win32_nmres in 4959213fdd94Smrg import*) win32_libid_type="x86 archive import";; 4960213fdd94Smrg *) win32_libid_type="x86 archive static";; 4961213fdd94Smrg esac 4962213fdd94Smrg fi 4963213fdd94Smrg ;; 4964213fdd94Smrg *DLL*) 4965213fdd94Smrg win32_libid_type="x86 DLL" 4966213fdd94Smrg ;; 4967213fdd94Smrg *executable*) # but shell scripts are "executable" too... 4968213fdd94Smrg case $win32_fileres in 4969213fdd94Smrg *MS\ Windows\ PE\ Intel*) 4970213fdd94Smrg win32_libid_type="x86 DLL" 4971213fdd94Smrg ;; 4972213fdd94Smrg esac 4973213fdd94Smrg ;; 4974213fdd94Smrg esac 4975213fdd94Smrg $ECHO "$win32_libid_type" 4976213fdd94Smrg} 4977213fdd94Smrg 4978213fdd94Smrg# func_cygming_dll_for_implib ARG 4979213fdd94Smrg# 4980213fdd94Smrg# Platform-specific function to extract the 4981213fdd94Smrg# name of the DLL associated with the specified 4982213fdd94Smrg# import library ARG. 4983213fdd94Smrg# Invoked by eval'ing the libtool variable 4984213fdd94Smrg# $sharedlib_from_linklib_cmd 4985213fdd94Smrg# Result is available in the variable 4986213fdd94Smrg# $sharedlib_from_linklib_result 4987213fdd94Smrgfunc_cygming_dll_for_implib () 4988213fdd94Smrg{ 498997ee6427Smrg $debug_cmd 499097ee6427Smrg 4991213fdd94Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992213fdd94Smrg} 4993213fdd94Smrg 4994213fdd94Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995213fdd94Smrg# 4996213fdd94Smrg# The is the core of a fallback implementation of a 4997213fdd94Smrg# platform-specific function to extract the name of the 4998213fdd94Smrg# DLL associated with the specified import library LIBNAME. 4999213fdd94Smrg# 5000213fdd94Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5001213fdd94Smrg# on the platform and compiler that created the implib. 5002213fdd94Smrg# 5003213fdd94Smrg# Echos the name of the DLL associated with the 5004213fdd94Smrg# specified import library. 5005213fdd94Smrgfunc_cygming_dll_for_implib_fallback_core () 5006213fdd94Smrg{ 500797ee6427Smrg $debug_cmd 500897ee6427Smrg 5009213fdd94Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010213fdd94Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011213fdd94Smrg $SED '/^Contents of section '"$match_literal"':/{ 5012213fdd94Smrg # Place marker at beginning of archive member dllname section 5013213fdd94Smrg s/.*/====MARK====/ 5014213fdd94Smrg p 5015213fdd94Smrg d 5016213fdd94Smrg } 5017213fdd94Smrg # These lines can sometimes be longer than 43 characters, but 5018213fdd94Smrg # are always uninteresting 5019213fdd94Smrg /:[ ]*file format pe[i]\{,1\}-/d 5020213fdd94Smrg /^In archive [^:]*:/d 5021213fdd94Smrg # Ensure marker is printed 5022213fdd94Smrg /^====MARK====/p 5023213fdd94Smrg # Remove all lines with less than 43 characters 5024213fdd94Smrg /^.\{43\}/!d 5025213fdd94Smrg # From remaining lines, remove first 43 characters 5026213fdd94Smrg s/^.\{43\}//' | 5027213fdd94Smrg $SED -n ' 5028213fdd94Smrg # Join marker and all lines until next marker into a single line 5029213fdd94Smrg /^====MARK====/ b para 5030213fdd94Smrg H 5031213fdd94Smrg $ b para 5032213fdd94Smrg b 5033213fdd94Smrg :para 5034213fdd94Smrg x 5035213fdd94Smrg s/\n//g 5036213fdd94Smrg # Remove the marker 5037213fdd94Smrg s/^====MARK====// 5038213fdd94Smrg # Remove trailing dots and whitespace 5039213fdd94Smrg s/[\. \t]*$// 5040213fdd94Smrg # Print 5041213fdd94Smrg /./p' | 5042213fdd94Smrg # we now have a list, one entry per line, of the stringified 5043213fdd94Smrg # contents of the appropriate section of all members of the 504497ee6427Smrg # archive that possess that section. Heuristic: eliminate 504597ee6427Smrg # all those that have a first or second character that is 5046213fdd94Smrg # a '.' (that is, objdump's representation of an unprintable 5047213fdd94Smrg # character.) This should work for all archives with less than 5048213fdd94Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5049213fdd94Smrg # begins with a literal '.' or a single character followed by 5050213fdd94Smrg # a '.'. 5051213fdd94Smrg # 5052213fdd94Smrg # Of those that remain, print the first one. 5053213fdd94Smrg $SED -e '/^\./d;/^.\./d;q' 5054213fdd94Smrg} 5055213fdd94Smrg 5056213fdd94Smrg# func_cygming_dll_for_implib_fallback ARG 5057213fdd94Smrg# Platform-specific function to extract the 5058213fdd94Smrg# name of the DLL associated with the specified 5059213fdd94Smrg# import library ARG. 5060213fdd94Smrg# 5061213fdd94Smrg# This fallback implementation is for use when $DLLTOOL 5062213fdd94Smrg# does not support the --identify-strict option. 5063213fdd94Smrg# Invoked by eval'ing the libtool variable 5064213fdd94Smrg# $sharedlib_from_linklib_cmd 5065213fdd94Smrg# Result is available in the variable 5066213fdd94Smrg# $sharedlib_from_linklib_result 5067213fdd94Smrgfunc_cygming_dll_for_implib_fallback () 5068213fdd94Smrg{ 506997ee6427Smrg $debug_cmd 507097ee6427Smrg 507197ee6427Smrg if func_cygming_gnu_implib_p "$1"; then 5072213fdd94Smrg # binutils import library 5073213fdd94Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507497ee6427Smrg elif func_cygming_ms_implib_p "$1"; then 5075213fdd94Smrg # ms-generated import library 5076213fdd94Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077213fdd94Smrg else 5078213fdd94Smrg # unknown 507997ee6427Smrg sharedlib_from_linklib_result= 5080213fdd94Smrg fi 5081213fdd94Smrg} 5082213fdd94Smrg 5083213fdd94Smrg 5084213fdd94Smrg# func_extract_an_archive dir oldlib 5085213fdd94Smrgfunc_extract_an_archive () 5086213fdd94Smrg{ 508797ee6427Smrg $debug_cmd 508897ee6427Smrg 508997ee6427Smrg f_ex_an_ar_dir=$1; shift 509097ee6427Smrg f_ex_an_ar_oldlib=$1 509197ee6427Smrg if test yes = "$lock_old_archive_extraction"; then 5092213fdd94Smrg lockfile=$f_ex_an_ar_oldlib.lock 5093213fdd94Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094213fdd94Smrg func_echo "Waiting for $lockfile to be removed" 5095213fdd94Smrg sleep 2 5096ef6fb4a5Smrg done 5097213fdd94Smrg fi 5098213fdd94Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099213fdd94Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510097ee6427Smrg if test yes = "$lock_old_archive_extraction"; then 5101213fdd94Smrg $opt_dry_run || rm -f "$lockfile" 5102213fdd94Smrg fi 5103213fdd94Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104213fdd94Smrg : 5105213fdd94Smrg else 5106213fdd94Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107213fdd94Smrg fi 5108213fdd94Smrg} 5109301ea0f4Smrg 5110213fdd94Smrg 5111213fdd94Smrg# func_extract_archives gentop oldlib ... 5112213fdd94Smrgfunc_extract_archives () 5113213fdd94Smrg{ 511497ee6427Smrg $debug_cmd 511597ee6427Smrg 511697ee6427Smrg my_gentop=$1; shift 5117213fdd94Smrg my_oldlibs=${1+"$@"} 511897ee6427Smrg my_oldobjs= 511997ee6427Smrg my_xlib= 512097ee6427Smrg my_xabs= 512197ee6427Smrg my_xdir= 5122213fdd94Smrg 5123213fdd94Smrg for my_xlib in $my_oldlibs; do 5124213fdd94Smrg # Extract the objects. 5125213fdd94Smrg case $my_xlib in 512697ee6427Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127213fdd94Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128213fdd94Smrg esac 5129213fdd94Smrg func_basename "$my_xlib" 513097ee6427Smrg my_xlib=$func_basename_result 5131213fdd94Smrg my_xlib_u=$my_xlib 5132213fdd94Smrg while :; do 5133213fdd94Smrg case " $extracted_archives " in 5134213fdd94Smrg *" $my_xlib_u "*) 5135213fdd94Smrg func_arith $extracted_serial + 1 5136213fdd94Smrg extracted_serial=$func_arith_result 5137213fdd94Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138213fdd94Smrg *) break ;; 5139ef6fb4a5Smrg esac 5140ef6fb4a5Smrg done 5141213fdd94Smrg extracted_archives="$extracted_archives $my_xlib_u" 514297ee6427Smrg my_xdir=$my_gentop/$my_xlib_u 5143301ea0f4Smrg 5144213fdd94Smrg func_mkdir_p "$my_xdir" 5145301ea0f4Smrg 5146213fdd94Smrg case $host in 5147213fdd94Smrg *-darwin*) 5148213fdd94Smrg func_verbose "Extracting $my_xabs" 5149213fdd94Smrg # Do not bother doing anything if just a dry run 5150213fdd94Smrg $opt_dry_run || { 5151213fdd94Smrg darwin_orig_dir=`pwd` 5152213fdd94Smrg cd $my_xdir || exit $? 5153213fdd94Smrg darwin_archive=$my_xabs 5154213fdd94Smrg darwin_curdir=`pwd` 515597ee6427Smrg func_basename "$darwin_archive" 515697ee6427Smrg darwin_base_archive=$func_basename_result 5157213fdd94Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158213fdd94Smrg if test -n "$darwin_arches"; then 5159213fdd94Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160213fdd94Smrg darwin_arch= 5161213fdd94Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516297ee6427Smrg for darwin_arch in $darwin_arches; do 516397ee6427Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516497ee6427Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516597ee6427Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516697ee6427Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167213fdd94Smrg cd "$darwin_curdir" 516897ee6427Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169213fdd94Smrg done # $darwin_arches 5170213fdd94Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517197ee6427Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172213fdd94Smrg darwin_file= 5173213fdd94Smrg darwin_files= 5174213fdd94Smrg for darwin_file in $darwin_filelist; do 5175213fdd94Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176213fdd94Smrg $LIPO -create -output "$darwin_file" $darwin_files 5177213fdd94Smrg done # $darwin_filelist 5178213fdd94Smrg $RM -rf unfat-$$ 5179213fdd94Smrg cd "$darwin_orig_dir" 5180ef6fb4a5Smrg else 5181213fdd94Smrg cd $darwin_orig_dir 5182213fdd94Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183213fdd94Smrg fi # $darwin_arches 5184213fdd94Smrg } # !$opt_dry_run 5185213fdd94Smrg ;; 5186213fdd94Smrg *) 5187213fdd94Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188213fdd94Smrg ;; 5189213fdd94Smrg esac 5190213fdd94Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191213fdd94Smrg done 5192301ea0f4Smrg 519397ee6427Smrg func_extract_archives_result=$my_oldobjs 5194213fdd94Smrg} 5195301ea0f4Smrg 5196301ea0f4Smrg 5197213fdd94Smrg# func_emit_wrapper [arg=no] 5198213fdd94Smrg# 5199213fdd94Smrg# Emit a libtool wrapper script on stdout. 5200213fdd94Smrg# Don't directly open a file because we may want to 5201213fdd94Smrg# incorporate the script contents within a cygwin/mingw 5202213fdd94Smrg# wrapper executable. Must ONLY be called from within 5203213fdd94Smrg# func_mode_link because it depends on a number of variables 5204213fdd94Smrg# set therein. 5205213fdd94Smrg# 5206213fdd94Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207213fdd94Smrg# variable will take. If 'yes', then the emitted script 520897ee6427Smrg# will assume that the directory where it is stored is 5209213fdd94Smrg# the $objdir directory. This is a cygwin/mingw-specific 5210213fdd94Smrg# behavior. 5211213fdd94Smrgfunc_emit_wrapper () 5212213fdd94Smrg{ 5213213fdd94Smrg func_emit_wrapper_arg1=${1-no} 5214301ea0f4Smrg 5215213fdd94Smrg $ECHO "\ 5216213fdd94Smrg#! $SHELL 5217301ea0f4Smrg 5218213fdd94Smrg# $output - temporary wrapper script for $objdir/$outputname 521997ee6427Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220213fdd94Smrg# 5221213fdd94Smrg# The $output program cannot be directly executed until all the libtool 5222213fdd94Smrg# libraries that it depends on are installed. 5223213fdd94Smrg# 5224213fdd94Smrg# This wrapper script should never be moved out of the build directory. 5225213fdd94Smrg# If it is, it will not operate correctly. 5226301ea0f4Smrg 5227213fdd94Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5228213fdd94Smrg# metacharacters that are still active within double-quoted strings. 5229213fdd94Smrgsed_quote_subst='$sed_quote_subst' 5230301ea0f4Smrg 5231213fdd94Smrg# Be Bourne compatible 5232213fdd94Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233213fdd94Smrg emulate sh 5234213fdd94Smrg NULLCMD=: 5235213fdd94Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236213fdd94Smrg # is contrary to our usage. Disable this feature. 5237213fdd94Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238213fdd94Smrg setopt NO_GLOB_SUBST 5239213fdd94Smrgelse 5240213fdd94Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241213fdd94Smrgfi 5242213fdd94SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243213fdd94SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244301ea0f4Smrg 5245213fdd94Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246213fdd94Smrg# if CDPATH is set. 5247213fdd94Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248301ea0f4Smrg 5249213fdd94Smrgrelink_command=\"$relink_command\" 5250301ea0f4Smrg 5251213fdd94Smrg# This environment variable determines our operation mode. 5252213fdd94Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253213fdd94Smrg # install mode needs the following variables: 5254213fdd94Smrg generated_by_libtool_version='$macro_version' 5255213fdd94Smrg notinst_deplibs='$notinst_deplibs' 5256213fdd94Smrgelse 5257213fdd94Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258213fdd94Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259213fdd94Smrg file=\"\$0\"" 5260301ea0f4Smrg 5261213fdd94Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262213fdd94Smrg $ECHO "\ 5263301ea0f4Smrg 5264213fdd94Smrg# A function that is used when there is no print builtin or printf. 5265213fdd94Smrgfunc_fallback_echo () 5266213fdd94Smrg{ 5267213fdd94Smrg eval 'cat <<_LTECHO_EOF 5268213fdd94Smrg\$1 5269213fdd94Smrg_LTECHO_EOF' 5270213fdd94Smrg} 5271213fdd94Smrg ECHO=\"$qECHO\" 5272213fdd94Smrg fi 5273301ea0f4Smrg 5274213fdd94Smrg# Very basic option parsing. These options are (a) specific to 5275213fdd94Smrg# the libtool wrapper, (b) are identical between the wrapper 527697ee6427Smrg# /script/ and the wrapper /executable/ that is used only on 5277213fdd94Smrg# windows platforms, and (c) all begin with the string "--lt-" 527897ee6427Smrg# (application programs are unlikely to have options that match 5279213fdd94Smrg# this pattern). 5280213fdd94Smrg# 5281213fdd94Smrg# There are only two supported options: --lt-debug and 5282213fdd94Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5283213fdd94Smrg# 5284213fdd94Smrg# The first argument to this parsing function should be the 5285213fdd94Smrg# script's $0 value, followed by "$@". 5286213fdd94Smrglt_option_debug= 5287213fdd94Smrgfunc_parse_lt_options () 5288213fdd94Smrg{ 5289213fdd94Smrg lt_script_arg0=\$0 5290213fdd94Smrg shift 5291213fdd94Smrg for lt_opt 5292213fdd94Smrg do 5293213fdd94Smrg case \"\$lt_opt\" in 5294213fdd94Smrg --lt-debug) lt_option_debug=1 ;; 5295213fdd94Smrg --lt-dump-script) 5296213fdd94Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297213fdd94Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298213fdd94Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299213fdd94Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5300213fdd94Smrg exit 0 5301213fdd94Smrg ;; 5302213fdd94Smrg --lt-*) 5303213fdd94Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304213fdd94Smrg exit 1 5305213fdd94Smrg ;; 5306213fdd94Smrg esac 5307213fdd94Smrg done 5308301ea0f4Smrg 5309213fdd94Smrg # Print the debug banner immediately: 5310213fdd94Smrg if test -n \"\$lt_option_debug\"; then 531197ee6427Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312213fdd94Smrg fi 5313213fdd94Smrg} 5314301ea0f4Smrg 5315213fdd94Smrg# Used when --lt-debug. Prints its arguments to stdout 5316213fdd94Smrg# (redirection is the responsibility of the caller) 5317213fdd94Smrgfunc_lt_dump_args () 5318213fdd94Smrg{ 5319213fdd94Smrg lt_dump_args_N=1; 5320213fdd94Smrg for lt_arg 5321213fdd94Smrg do 532297ee6427Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323213fdd94Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324213fdd94Smrg done 5325213fdd94Smrg} 5326301ea0f4Smrg 5327213fdd94Smrg# Core function for launching the target application 5328213fdd94Smrgfunc_exec_program_core () 5329213fdd94Smrg{ 5330213fdd94Smrg" 5331213fdd94Smrg case $host in 5332213fdd94Smrg # Backslashes separate directories on plain windows 5333213fdd94Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5334213fdd94Smrg $ECHO "\ 5335213fdd94Smrg if test -n \"\$lt_option_debug\"; then 533697ee6427Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337213fdd94Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5338213fdd94Smrg fi 5339213fdd94Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340213fdd94Smrg" 5341213fdd94Smrg ;; 5342301ea0f4Smrg 5343213fdd94Smrg *) 5344213fdd94Smrg $ECHO "\ 5345213fdd94Smrg if test -n \"\$lt_option_debug\"; then 534697ee6427Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347213fdd94Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5348213fdd94Smrg fi 5349213fdd94Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350213fdd94Smrg" 5351213fdd94Smrg ;; 5352213fdd94Smrg esac 5353213fdd94Smrg $ECHO "\ 5354213fdd94Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355213fdd94Smrg exit 1 5356213fdd94Smrg} 5357301ea0f4Smrg 5358213fdd94Smrg# A function to encapsulate launching the target application 5359213fdd94Smrg# Strips options in the --lt-* namespace from \$@ and 5360213fdd94Smrg# launches target application with the remaining arguments. 5361213fdd94Smrgfunc_exec_program () 5362213fdd94Smrg{ 5363213fdd94Smrg case \" \$* \" in 5364213fdd94Smrg *\\ --lt-*) 5365213fdd94Smrg for lt_wr_arg 5366213fdd94Smrg do 5367213fdd94Smrg case \$lt_wr_arg in 5368213fdd94Smrg --lt-*) ;; 5369213fdd94Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370213fdd94Smrg esac 5371213fdd94Smrg shift 5372213fdd94Smrg done ;; 5373213fdd94Smrg esac 5374213fdd94Smrg func_exec_program_core \${1+\"\$@\"} 5375213fdd94Smrg} 5376301ea0f4Smrg 5377213fdd94Smrg # Parse options 5378213fdd94Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379301ea0f4Smrg 5380213fdd94Smrg # Find the directory that this script lives in. 5381213fdd94Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382213fdd94Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383301ea0f4Smrg 5384213fdd94Smrg # Follow symbolic links until we get to the real thisdir. 5385213fdd94Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386213fdd94Smrg while test -n \"\$file\"; do 5387213fdd94Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388301ea0f4Smrg 5389213fdd94Smrg # If there was a directory component, then change thisdir. 5390213fdd94Smrg if test \"x\$destdir\" != \"x\$file\"; then 5391213fdd94Smrg case \"\$destdir\" in 5392213fdd94Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393213fdd94Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394213fdd94Smrg esac 5395213fdd94Smrg fi 5396301ea0f4Smrg 5397213fdd94Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398213fdd94Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399213fdd94Smrg done 5400301ea0f4Smrg 5401213fdd94Smrg # Usually 'no', except on cygwin/mingw when embedded into 5402213fdd94Smrg # the cwrapper. 5403213fdd94Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404213fdd94Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405213fdd94Smrg # special case for '.' 5406213fdd94Smrg if test \"\$thisdir\" = \".\"; then 5407213fdd94Smrg thisdir=\`pwd\` 5408213fdd94Smrg fi 5409213fdd94Smrg # remove .libs from thisdir 5410213fdd94Smrg case \"\$thisdir\" in 5411213fdd94Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412213fdd94Smrg $objdir ) thisdir=. ;; 5413213fdd94Smrg esac 5414213fdd94Smrg fi 5415301ea0f4Smrg 5416213fdd94Smrg # Try to get the absolute directory name. 5417213fdd94Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5418213fdd94Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419213fdd94Smrg" 5420301ea0f4Smrg 542197ee6427Smrg if test yes = "$fast_install"; then 5422213fdd94Smrg $ECHO "\ 5423213fdd94Smrg program=lt-'$outputname'$exeext 5424213fdd94Smrg progdir=\"\$thisdir/$objdir\" 5425301ea0f4Smrg 5426213fdd94Smrg if test ! -f \"\$progdir/\$program\" || 542797ee6427Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428213fdd94Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429301ea0f4Smrg 5430213fdd94Smrg file=\"\$\$-\$program\" 5431301ea0f4Smrg 5432213fdd94Smrg if test ! -d \"\$progdir\"; then 5433213fdd94Smrg $MKDIR \"\$progdir\" 5434213fdd94Smrg else 5435213fdd94Smrg $RM \"\$progdir/\$file\" 5436213fdd94Smrg fi" 5437301ea0f4Smrg 5438213fdd94Smrg $ECHO "\ 5439301ea0f4Smrg 5440213fdd94Smrg # relink executable if necessary 5441213fdd94Smrg if test -n \"\$relink_command\"; then 5442213fdd94Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443213fdd94Smrg else 544497ee6427Smrg \$ECHO \"\$relink_command_output\" >&2 5445213fdd94Smrg $RM \"\$progdir/\$file\" 5446213fdd94Smrg exit 1 5447213fdd94Smrg fi 5448213fdd94Smrg fi 5449ef6fb4a5Smrg 5450213fdd94Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451213fdd94Smrg { $RM \"\$progdir/\$program\"; 5452213fdd94Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453213fdd94Smrg $RM \"\$progdir/\$file\" 5454213fdd94Smrg fi" 5455213fdd94Smrg else 5456213fdd94Smrg $ECHO "\ 5457213fdd94Smrg program='$outputname' 5458213fdd94Smrg progdir=\"\$thisdir/$objdir\" 5459213fdd94Smrg" 5460213fdd94Smrg fi 5461ef6fb4a5Smrg 5462213fdd94Smrg $ECHO "\ 5463ef6fb4a5Smrg 5464213fdd94Smrg if test -f \"\$progdir/\$program\"; then" 5465213fdd94Smrg 5466213fdd94Smrg # fixup the dll searchpath if we need to. 5467213fdd94Smrg # 5468213fdd94Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5469213fdd94Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5470213fdd94Smrg # libraries must come first. 5471213fdd94Smrg if test -n "$dllsearchpath"; then 5472213fdd94Smrg $ECHO "\ 5473213fdd94Smrg # Add the dll search path components to the executable PATH 5474213fdd94Smrg PATH=$dllsearchpath:\$PATH 5475213fdd94Smrg" 5476ef6fb4a5Smrg fi 5477ef6fb4a5Smrg 5478213fdd94Smrg # Export our shlibpath_var if we have one. 547997ee6427Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480213fdd94Smrg $ECHO "\ 5481213fdd94Smrg # Add our own library path to $shlibpath_var 5482213fdd94Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483ef6fb4a5Smrg 5484213fdd94Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485213fdd94Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5486213fdd94Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487213fdd94Smrg 5488213fdd94Smrg export $shlibpath_var 5489213fdd94Smrg" 5490ef6fb4a5Smrg fi 5491301ea0f4Smrg 5492213fdd94Smrg $ECHO "\ 5493213fdd94Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494213fdd94Smrg # Run the actual program with our arguments. 5495213fdd94Smrg func_exec_program \${1+\"\$@\"} 5496213fdd94Smrg fi 5497213fdd94Smrg else 5498213fdd94Smrg # The program doesn't exist. 549997ee6427Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500213fdd94Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501213fdd94Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502213fdd94Smrg exit 1 5503213fdd94Smrg fi 5504213fdd94Smrgfi\ 5505213fdd94Smrg" 5506213fdd94Smrg} 5507301ea0f4Smrg 5508301ea0f4Smrg 5509213fdd94Smrg# func_emit_cwrapperexe_src 5510213fdd94Smrg# emit the source code for a wrapper executable on stdout 5511213fdd94Smrg# Must ONLY be called from within func_mode_link because 5512213fdd94Smrg# it depends on a number of variable set therein. 5513213fdd94Smrgfunc_emit_cwrapperexe_src () 5514213fdd94Smrg{ 5515213fdd94Smrg cat <<EOF 5516ef6fb4a5Smrg 5517213fdd94Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551897ee6427Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519ef6fb4a5Smrg 5520213fdd94Smrg The $output program cannot be directly executed until all the libtool 5521213fdd94Smrg libraries that it depends on are installed. 5522ef6fb4a5Smrg 5523213fdd94Smrg This wrapper executable should never be moved out of the build directory. 5524213fdd94Smrg If it is, it will not operate correctly. 5525213fdd94Smrg*/ 5526213fdd94SmrgEOF 5527213fdd94Smrg cat <<"EOF" 5528213fdd94Smrg#ifdef _MSC_VER 5529213fdd94Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5530213fdd94Smrg#endif 5531213fdd94Smrg#include <stdio.h> 5532213fdd94Smrg#include <stdlib.h> 5533213fdd94Smrg#ifdef _MSC_VER 5534213fdd94Smrg# include <direct.h> 5535213fdd94Smrg# include <process.h> 5536213fdd94Smrg# include <io.h> 5537213fdd94Smrg#else 5538213fdd94Smrg# include <unistd.h> 5539213fdd94Smrg# include <stdint.h> 5540213fdd94Smrg# ifdef __CYGWIN__ 5541213fdd94Smrg# include <io.h> 5542213fdd94Smrg# endif 5543213fdd94Smrg#endif 5544213fdd94Smrg#include <malloc.h> 5545213fdd94Smrg#include <stdarg.h> 5546213fdd94Smrg#include <assert.h> 5547213fdd94Smrg#include <string.h> 5548213fdd94Smrg#include <ctype.h> 5549213fdd94Smrg#include <errno.h> 5550213fdd94Smrg#include <fcntl.h> 5551213fdd94Smrg#include <sys/stat.h> 5552ef6fb4a5Smrg 555397ee6427Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555497ee6427Smrg 5555213fdd94Smrg/* declarations of non-ANSI functions */ 555697ee6427Smrg#if defined __MINGW32__ 5557213fdd94Smrg# ifdef __STRICT_ANSI__ 5558213fdd94Smrgint _putenv (const char *); 5559213fdd94Smrg# endif 556097ee6427Smrg#elif defined __CYGWIN__ 5561213fdd94Smrg# ifdef __STRICT_ANSI__ 5562213fdd94Smrgchar *realpath (const char *, char *); 5563213fdd94Smrgint putenv (char *); 5564213fdd94Smrgint setenv (const char *, const char *, int); 5565213fdd94Smrg# endif 556697ee6427Smrg/* #elif defined other_platform || defined ... */ 5567213fdd94Smrg#endif 5568301ea0f4Smrg 5569213fdd94Smrg/* portability defines, excluding path handling macros */ 557097ee6427Smrg#if defined _MSC_VER 5571213fdd94Smrg# define setmode _setmode 5572213fdd94Smrg# define stat _stat 5573213fdd94Smrg# define chmod _chmod 5574213fdd94Smrg# define getcwd _getcwd 5575213fdd94Smrg# define putenv _putenv 5576213fdd94Smrg# define S_IXUSR _S_IEXEC 557797ee6427Smrg#elif defined __MINGW32__ 5578213fdd94Smrg# define setmode _setmode 5579213fdd94Smrg# define stat _stat 5580213fdd94Smrg# define chmod _chmod 5581213fdd94Smrg# define getcwd _getcwd 5582213fdd94Smrg# define putenv _putenv 558397ee6427Smrg#elif defined __CYGWIN__ 5584213fdd94Smrg# define HAVE_SETENV 5585213fdd94Smrg# define FOPEN_WB "wb" 558697ee6427Smrg/* #elif defined other platforms ... */ 5587213fdd94Smrg#endif 5588301ea0f4Smrg 558997ee6427Smrg#if defined PATH_MAX 5590213fdd94Smrg# define LT_PATHMAX PATH_MAX 559197ee6427Smrg#elif defined MAXPATHLEN 5592213fdd94Smrg# define LT_PATHMAX MAXPATHLEN 5593213fdd94Smrg#else 5594213fdd94Smrg# define LT_PATHMAX 1024 5595213fdd94Smrg#endif 5596301ea0f4Smrg 5597213fdd94Smrg#ifndef S_IXOTH 5598213fdd94Smrg# define S_IXOTH 0 5599213fdd94Smrg#endif 5600213fdd94Smrg#ifndef S_IXGRP 5601213fdd94Smrg# define S_IXGRP 0 5602213fdd94Smrg#endif 5603301ea0f4Smrg 5604213fdd94Smrg/* path handling portability macros */ 5605213fdd94Smrg#ifndef DIR_SEPARATOR 5606213fdd94Smrg# define DIR_SEPARATOR '/' 5607213fdd94Smrg# define PATH_SEPARATOR ':' 5608213fdd94Smrg#endif 5609301ea0f4Smrg 561097ee6427Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561197ee6427Smrg defined __OS2__ 5612213fdd94Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613213fdd94Smrg# define FOPEN_WB "wb" 5614213fdd94Smrg# ifndef DIR_SEPARATOR_2 5615213fdd94Smrg# define DIR_SEPARATOR_2 '\\' 5616213fdd94Smrg# endif 5617213fdd94Smrg# ifndef PATH_SEPARATOR_2 5618213fdd94Smrg# define PATH_SEPARATOR_2 ';' 5619213fdd94Smrg# endif 5620213fdd94Smrg#endif 5621301ea0f4Smrg 5622213fdd94Smrg#ifndef DIR_SEPARATOR_2 5623213fdd94Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624213fdd94Smrg#else /* DIR_SEPARATOR_2 */ 5625213fdd94Smrg# define IS_DIR_SEPARATOR(ch) \ 5626213fdd94Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627213fdd94Smrg#endif /* DIR_SEPARATOR_2 */ 5628301ea0f4Smrg 5629213fdd94Smrg#ifndef PATH_SEPARATOR_2 5630213fdd94Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631213fdd94Smrg#else /* PATH_SEPARATOR_2 */ 5632213fdd94Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633213fdd94Smrg#endif /* PATH_SEPARATOR_2 */ 5634301ea0f4Smrg 5635213fdd94Smrg#ifndef FOPEN_WB 5636213fdd94Smrg# define FOPEN_WB "w" 5637213fdd94Smrg#endif 5638213fdd94Smrg#ifndef _O_BINARY 5639213fdd94Smrg# define _O_BINARY 0 5640213fdd94Smrg#endif 5641301ea0f4Smrg 5642213fdd94Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643213fdd94Smrg#define XFREE(stale) do { \ 564497ee6427Smrg if (stale) { free (stale); stale = 0; } \ 5645213fdd94Smrg} while (0) 5646301ea0f4Smrg 564797ee6427Smrg#if defined LT_DEBUGWRAPPER 5648213fdd94Smrgstatic int lt_debug = 1; 5649213fdd94Smrg#else 5650213fdd94Smrgstatic int lt_debug = 0; 5651213fdd94Smrg#endif 5652301ea0f4Smrg 5653213fdd94Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654213fdd94Smrg 5655213fdd94Smrgvoid *xmalloc (size_t num); 5656213fdd94Smrgchar *xstrdup (const char *string); 5657213fdd94Smrgconst char *base_name (const char *name); 5658213fdd94Smrgchar *find_executable (const char *wrapper); 5659213fdd94Smrgchar *chase_symlinks (const char *pathspec); 5660213fdd94Smrgint make_executable (const char *path); 5661213fdd94Smrgint check_executable (const char *path); 5662213fdd94Smrgchar *strendzap (char *str, const char *pat); 5663213fdd94Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664213fdd94Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5665213fdd94Smrgstatic const char *nonnull (const char *s); 5666213fdd94Smrgstatic const char *nonempty (const char *s); 5667213fdd94Smrgvoid lt_setenv (const char *name, const char *value); 5668213fdd94Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669213fdd94Smrgvoid lt_update_exe_path (const char *name, const char *value); 5670213fdd94Smrgvoid lt_update_lib_path (const char *name, const char *value); 5671213fdd94Smrgchar **prepare_spawn (char **argv); 5672213fdd94Smrgvoid lt_dump_script (FILE *f); 5673213fdd94SmrgEOF 5674301ea0f4Smrg 5675213fdd94Smrg cat <<EOF 567697ee6427Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567797ee6427Smrg# define externally_visible volatile 567897ee6427Smrg#else 567997ee6427Smrg# define externally_visible __attribute__((externally_visible)) volatile 568097ee6427Smrg#endif 568197ee6427Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682213fdd94Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683213fdd94SmrgEOF 5684301ea0f4Smrg 568597ee6427Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686213fdd94Smrg func_to_host_path "$temp_rpath" 5687213fdd94Smrg cat <<EOF 5688213fdd94Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689213fdd94SmrgEOF 5690213fdd94Smrg else 5691213fdd94Smrg cat <<"EOF" 5692213fdd94Smrgconst char * LIB_PATH_VALUE = ""; 5693213fdd94SmrgEOF 5694213fdd94Smrg fi 5695301ea0f4Smrg 5696213fdd94Smrg if test -n "$dllsearchpath"; then 5697213fdd94Smrg func_to_host_path "$dllsearchpath:" 5698213fdd94Smrg cat <<EOF 5699213fdd94Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5700213fdd94Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701213fdd94SmrgEOF 5702213fdd94Smrg else 5703213fdd94Smrg cat <<"EOF" 5704213fdd94Smrgconst char * EXE_PATH_VARNAME = ""; 5705213fdd94Smrgconst char * EXE_PATH_VALUE = ""; 5706213fdd94SmrgEOF 5707213fdd94Smrg fi 5708301ea0f4Smrg 570997ee6427Smrg if test yes = "$fast_install"; then 5710213fdd94Smrg cat <<EOF 5711213fdd94Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712213fdd94SmrgEOF 5713213fdd94Smrg else 5714213fdd94Smrg cat <<EOF 5715213fdd94Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716213fdd94SmrgEOF 5717213fdd94Smrg fi 5718301ea0f4Smrg 5719301ea0f4Smrg 5720213fdd94Smrg cat <<"EOF" 5721301ea0f4Smrg 5722213fdd94Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723301ea0f4Smrg 5724213fdd94Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725213fdd94Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726213fdd94Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727301ea0f4Smrg 5728213fdd94Smrgint 5729213fdd94Smrgmain (int argc, char *argv[]) 5730213fdd94Smrg{ 5731213fdd94Smrg char **newargz; 5732213fdd94Smrg int newargc; 5733213fdd94Smrg char *tmp_pathspec; 5734213fdd94Smrg char *actual_cwrapper_path; 5735213fdd94Smrg char *actual_cwrapper_name; 5736213fdd94Smrg char *target_name; 5737213fdd94Smrg char *lt_argv_zero; 573897ee6427Smrg int rval = 127; 5739213fdd94Smrg 5740213fdd94Smrg int i; 5741301ea0f4Smrg 5742213fdd94Smrg program_name = (char *) xstrdup (base_name (argv[0])); 574397ee6427Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744301ea0f4Smrg 5745213fdd94Smrg /* very simple arg parsing; don't want to rely on getopt 5746213fdd94Smrg * also, copy all non cwrapper options to newargz, except 5747213fdd94Smrg * argz[0], which is handled differently 5748213fdd94Smrg */ 5749213fdd94Smrg newargc=0; 5750213fdd94Smrg for (i = 1; i < argc; i++) 5751213fdd94Smrg { 575297ee6427Smrg if (STREQ (argv[i], dumpscript_opt)) 5753213fdd94Smrg { 5754213fdd94SmrgEOF 575597ee6427Smrg case $host in 5756213fdd94Smrg *mingw* | *cygwin* ) 5757213fdd94Smrg # make stdout use "unix" line endings 5758213fdd94Smrg echo " setmode(1,_O_BINARY);" 5759213fdd94Smrg ;; 5760213fdd94Smrg esac 5761301ea0f4Smrg 5762213fdd94Smrg cat <<"EOF" 5763213fdd94Smrg lt_dump_script (stdout); 5764213fdd94Smrg return 0; 5765213fdd94Smrg } 576697ee6427Smrg if (STREQ (argv[i], debug_opt)) 5767213fdd94Smrg { 5768213fdd94Smrg lt_debug = 1; 5769213fdd94Smrg continue; 5770213fdd94Smrg } 577197ee6427Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5772213fdd94Smrg { 5773213fdd94Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774213fdd94Smrg namespace, but it is not one of the ones we know about and 5775213fdd94Smrg have already dealt with, above (inluding dump-script), then 5776213fdd94Smrg report an error. Otherwise, targets might begin to believe 5777213fdd94Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778213fdd94Smrg namespace. The first time any user complains about this, we'll 5779213fdd94Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780213fdd94Smrg or a configure.ac-settable value. 5781213fdd94Smrg */ 5782213fdd94Smrg lt_fatal (__FILE__, __LINE__, 5783213fdd94Smrg "unrecognized %s option: '%s'", 5784213fdd94Smrg ltwrapper_option_prefix, argv[i]); 5785213fdd94Smrg } 5786213fdd94Smrg /* otherwise ... */ 5787213fdd94Smrg newargz[++newargc] = xstrdup (argv[i]); 5788213fdd94Smrg } 5789213fdd94Smrg newargz[++newargc] = NULL; 5790301ea0f4Smrg 5791213fdd94SmrgEOF 5792213fdd94Smrg cat <<EOF 5793213fdd94Smrg /* The GNU banner must be the first non-error debug message */ 579497ee6427Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795213fdd94SmrgEOF 5796213fdd94Smrg cat <<"EOF" 5797213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799213fdd94Smrg 5800213fdd94Smrg tmp_pathspec = find_executable (argv[0]); 5801213fdd94Smrg if (tmp_pathspec == NULL) 5802213fdd94Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 5804213fdd94Smrg "(main) found exe (before symlink chase) at: %s\n", 5805213fdd94Smrg tmp_pathspec); 5806213fdd94Smrg 5807213fdd94Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 5809213fdd94Smrg "(main) found exe (after symlink chase) at: %s\n", 5810213fdd94Smrg actual_cwrapper_path); 5811213fdd94Smrg XFREE (tmp_pathspec); 5812213fdd94Smrg 5813213fdd94Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814213fdd94Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815213fdd94Smrg 5816213fdd94Smrg /* wrapper name transforms */ 5817213fdd94Smrg strendzap (actual_cwrapper_name, ".exe"); 5818213fdd94Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819213fdd94Smrg XFREE (actual_cwrapper_name); 5820213fdd94Smrg actual_cwrapper_name = tmp_pathspec; 5821213fdd94Smrg tmp_pathspec = 0; 5822213fdd94Smrg 5823213fdd94Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824213fdd94Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825213fdd94Smrg strendzap (target_name, ".exe"); 5826213fdd94Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827213fdd94Smrg XFREE (target_name); 5828213fdd94Smrg target_name = tmp_pathspec; 5829213fdd94Smrg tmp_pathspec = 0; 5830213fdd94Smrg 5831213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 5832213fdd94Smrg "(main) libtool target name: %s\n", 5833213fdd94Smrg target_name); 5834213fdd94SmrgEOF 5835213fdd94Smrg 5836213fdd94Smrg cat <<EOF 5837213fdd94Smrg newargz[0] = 5838213fdd94Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839213fdd94Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840213fdd94Smrg strcpy (newargz[0], actual_cwrapper_path); 5841213fdd94Smrg strcat (newargz[0], "$objdir"); 5842213fdd94Smrg strcat (newargz[0], "/"); 5843213fdd94SmrgEOF 5844213fdd94Smrg 5845213fdd94Smrg cat <<"EOF" 5846213fdd94Smrg /* stop here, and copy so we don't have to do this twice */ 5847213fdd94Smrg tmp_pathspec = xstrdup (newargz[0]); 5848213fdd94Smrg 5849213fdd94Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850213fdd94Smrg strcat (newargz[0], actual_cwrapper_name); 5851213fdd94Smrg 5852213fdd94Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853213fdd94Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854213fdd94Smrg XFREE (tmp_pathspec); 5855213fdd94Smrg tmp_pathspec = NULL; 5856213fdd94SmrgEOF 5857213fdd94Smrg 5858213fdd94Smrg case $host_os in 5859213fdd94Smrg mingw*) 5860213fdd94Smrg cat <<"EOF" 5861213fdd94Smrg { 5862213fdd94Smrg char* p; 5863213fdd94Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864213fdd94Smrg { 5865213fdd94Smrg *p = '/'; 5866213fdd94Smrg } 5867213fdd94Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868213fdd94Smrg { 5869213fdd94Smrg *p = '/'; 5870213fdd94Smrg } 5871213fdd94Smrg } 5872213fdd94SmrgEOF 5873213fdd94Smrg ;; 5874213fdd94Smrg esac 5875213fdd94Smrg 5876213fdd94Smrg cat <<"EOF" 5877213fdd94Smrg XFREE (target_name); 5878213fdd94Smrg XFREE (actual_cwrapper_path); 5879213fdd94Smrg XFREE (actual_cwrapper_name); 5880213fdd94Smrg 5881213fdd94Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882213fdd94Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883213fdd94Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884213fdd94Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885213fdd94Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5886213fdd94Smrg libraries must come first. */ 5887213fdd94Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888213fdd94Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889213fdd94Smrg 5890213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891213fdd94Smrg nonnull (lt_argv_zero)); 5892213fdd94Smrg for (i = 0; i < newargc; i++) 5893213fdd94Smrg { 5894213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895213fdd94Smrg i, nonnull (newargz[i])); 5896213fdd94Smrg } 5897213fdd94Smrg 5898213fdd94SmrgEOF 5899213fdd94Smrg 5900213fdd94Smrg case $host_os in 5901213fdd94Smrg mingw*) 5902213fdd94Smrg cat <<"EOF" 5903213fdd94Smrg /* execv doesn't actually work on mingw as expected on unix */ 5904213fdd94Smrg newargz = prepare_spawn (newargz); 590597ee6427Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906213fdd94Smrg if (rval == -1) 5907213fdd94Smrg { 5908213fdd94Smrg /* failed to start process */ 5909213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 5910213fdd94Smrg "(main) failed to launch target \"%s\": %s\n", 5911213fdd94Smrg lt_argv_zero, nonnull (strerror (errno))); 5912213fdd94Smrg return 127; 5913213fdd94Smrg } 5914213fdd94Smrg return rval; 5915213fdd94SmrgEOF 5916ef6fb4a5Smrg ;; 5917ef6fb4a5Smrg *) 5918213fdd94Smrg cat <<"EOF" 5919213fdd94Smrg execv (lt_argv_zero, newargz); 5920213fdd94Smrg return rval; /* =127, but avoids unused variable warning */ 5921213fdd94SmrgEOF 5922ef6fb4a5Smrg ;; 5923213fdd94Smrg esac 5924301ea0f4Smrg 5925213fdd94Smrg cat <<"EOF" 5926213fdd94Smrg} 5927301ea0f4Smrg 5928213fdd94Smrgvoid * 5929213fdd94Smrgxmalloc (size_t num) 5930213fdd94Smrg{ 5931213fdd94Smrg void *p = (void *) malloc (num); 5932213fdd94Smrg if (!p) 5933213fdd94Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934301ea0f4Smrg 5935213fdd94Smrg return p; 5936213fdd94Smrg} 5937301ea0f4Smrg 5938213fdd94Smrgchar * 5939213fdd94Smrgxstrdup (const char *string) 5940213fdd94Smrg{ 5941213fdd94Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942213fdd94Smrg string) : NULL; 5943213fdd94Smrg} 5944301ea0f4Smrg 5945213fdd94Smrgconst char * 5946213fdd94Smrgbase_name (const char *name) 5947213fdd94Smrg{ 5948213fdd94Smrg const char *base; 5949301ea0f4Smrg 595097ee6427Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951213fdd94Smrg /* Skip over the disk name in MSDOS pathnames. */ 5952213fdd94Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953213fdd94Smrg name += 2; 5954ef6fb4a5Smrg#endif 5955301ea0f4Smrg 5956213fdd94Smrg for (base = name; *name; name++) 5957213fdd94Smrg if (IS_DIR_SEPARATOR (*name)) 5958213fdd94Smrg base = name + 1; 5959213fdd94Smrg return base; 5960213fdd94Smrg} 5961301ea0f4Smrg 5962213fdd94Smrgint 5963213fdd94Smrgcheck_executable (const char *path) 5964213fdd94Smrg{ 5965213fdd94Smrg struct stat st; 5966301ea0f4Smrg 5967213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968213fdd94Smrg nonempty (path)); 5969213fdd94Smrg if ((!path) || (!*path)) 5970213fdd94Smrg return 0; 5971301ea0f4Smrg 5972213fdd94Smrg if ((stat (path, &st) >= 0) 5973213fdd94Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974213fdd94Smrg return 1; 5975213fdd94Smrg else 5976213fdd94Smrg return 0; 5977213fdd94Smrg} 5978301ea0f4Smrg 5979213fdd94Smrgint 5980213fdd94Smrgmake_executable (const char *path) 5981213fdd94Smrg{ 5982213fdd94Smrg int rval = 0; 5983213fdd94Smrg struct stat st; 5984301ea0f4Smrg 5985213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986213fdd94Smrg nonempty (path)); 5987213fdd94Smrg if ((!path) || (!*path)) 5988213fdd94Smrg return 0; 5989301ea0f4Smrg 5990213fdd94Smrg if (stat (path, &st) >= 0) 5991213fdd94Smrg { 5992213fdd94Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993213fdd94Smrg } 5994213fdd94Smrg return rval; 5995213fdd94Smrg} 5996301ea0f4Smrg 5997213fdd94Smrg/* Searches for the full path of the wrapper. Returns 5998213fdd94Smrg newly allocated full path name if found, NULL otherwise 5999213fdd94Smrg Does not chase symlinks, even on platforms that support them. 6000213fdd94Smrg*/ 6001213fdd94Smrgchar * 6002213fdd94Smrgfind_executable (const char *wrapper) 6003213fdd94Smrg{ 6004213fdd94Smrg int has_slash = 0; 6005213fdd94Smrg const char *p; 6006213fdd94Smrg const char *p_next; 6007213fdd94Smrg /* static buffer for getcwd */ 6008213fdd94Smrg char tmp[LT_PATHMAX + 1]; 600997ee6427Smrg size_t tmp_len; 6010213fdd94Smrg char *concat_name; 6011301ea0f4Smrg 6012213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013213fdd94Smrg nonempty (wrapper)); 6014301ea0f4Smrg 6015213fdd94Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016213fdd94Smrg return NULL; 6017301ea0f4Smrg 6018213fdd94Smrg /* Absolute path? */ 601997ee6427Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020213fdd94Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021213fdd94Smrg { 6022213fdd94Smrg concat_name = xstrdup (wrapper); 6023213fdd94Smrg if (check_executable (concat_name)) 6024213fdd94Smrg return concat_name; 6025213fdd94Smrg XFREE (concat_name); 6026213fdd94Smrg } 6027213fdd94Smrg else 6028213fdd94Smrg { 6029213fdd94Smrg#endif 6030213fdd94Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031213fdd94Smrg { 6032213fdd94Smrg concat_name = xstrdup (wrapper); 6033213fdd94Smrg if (check_executable (concat_name)) 6034213fdd94Smrg return concat_name; 6035213fdd94Smrg XFREE (concat_name); 6036213fdd94Smrg } 603797ee6427Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038213fdd94Smrg } 6039213fdd94Smrg#endif 6040301ea0f4Smrg 6041213fdd94Smrg for (p = wrapper; *p; p++) 6042213fdd94Smrg if (*p == '/') 6043213fdd94Smrg { 6044213fdd94Smrg has_slash = 1; 6045213fdd94Smrg break; 6046213fdd94Smrg } 6047213fdd94Smrg if (!has_slash) 6048213fdd94Smrg { 6049213fdd94Smrg /* no slashes; search PATH */ 6050213fdd94Smrg const char *path = getenv ("PATH"); 6051213fdd94Smrg if (path != NULL) 6052213fdd94Smrg { 6053213fdd94Smrg for (p = path; *p; p = p_next) 6054213fdd94Smrg { 6055213fdd94Smrg const char *q; 6056213fdd94Smrg size_t p_len; 6057213fdd94Smrg for (q = p; *q; q++) 6058213fdd94Smrg if (IS_PATH_SEPARATOR (*q)) 6059213fdd94Smrg break; 606097ee6427Smrg p_len = (size_t) (q - p); 6061213fdd94Smrg p_next = (*q == '\0' ? q : q + 1); 6062213fdd94Smrg if (p_len == 0) 6063213fdd94Smrg { 6064213fdd94Smrg /* empty path: current directory */ 6065213fdd94Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6066213fdd94Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067213fdd94Smrg nonnull (strerror (errno))); 6068213fdd94Smrg tmp_len = strlen (tmp); 6069213fdd94Smrg concat_name = 6070213fdd94Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071213fdd94Smrg memcpy (concat_name, tmp, tmp_len); 6072213fdd94Smrg concat_name[tmp_len] = '/'; 6073213fdd94Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6074213fdd94Smrg } 6075213fdd94Smrg else 6076213fdd94Smrg { 6077213fdd94Smrg concat_name = 6078213fdd94Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079213fdd94Smrg memcpy (concat_name, p, p_len); 6080213fdd94Smrg concat_name[p_len] = '/'; 6081213fdd94Smrg strcpy (concat_name + p_len + 1, wrapper); 6082213fdd94Smrg } 6083213fdd94Smrg if (check_executable (concat_name)) 6084213fdd94Smrg return concat_name; 6085213fdd94Smrg XFREE (concat_name); 6086213fdd94Smrg } 6087213fdd94Smrg } 6088213fdd94Smrg /* not found in PATH; assume curdir */ 6089213fdd94Smrg } 6090213fdd94Smrg /* Relative path | not found in path: prepend cwd */ 6091213fdd94Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6092213fdd94Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093213fdd94Smrg nonnull (strerror (errno))); 6094213fdd94Smrg tmp_len = strlen (tmp); 6095213fdd94Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096213fdd94Smrg memcpy (concat_name, tmp, tmp_len); 6097213fdd94Smrg concat_name[tmp_len] = '/'; 6098213fdd94Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099301ea0f4Smrg 6100213fdd94Smrg if (check_executable (concat_name)) 6101213fdd94Smrg return concat_name; 6102213fdd94Smrg XFREE (concat_name); 6103213fdd94Smrg return NULL; 6104213fdd94Smrg} 6105301ea0f4Smrg 6106213fdd94Smrgchar * 6107213fdd94Smrgchase_symlinks (const char *pathspec) 6108213fdd94Smrg{ 6109213fdd94Smrg#ifndef S_ISLNK 6110213fdd94Smrg return xstrdup (pathspec); 6111213fdd94Smrg#else 6112213fdd94Smrg char buf[LT_PATHMAX]; 6113213fdd94Smrg struct stat s; 6114213fdd94Smrg char *tmp_pathspec = xstrdup (pathspec); 6115213fdd94Smrg char *p; 6116213fdd94Smrg int has_symlinks = 0; 6117213fdd94Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6118213fdd94Smrg { 6119213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 6120213fdd94Smrg "checking path component for symlinks: %s\n", 6121213fdd94Smrg tmp_pathspec); 6122213fdd94Smrg if (lstat (tmp_pathspec, &s) == 0) 6123213fdd94Smrg { 6124213fdd94Smrg if (S_ISLNK (s.st_mode) != 0) 6125213fdd94Smrg { 6126213fdd94Smrg has_symlinks = 1; 6127213fdd94Smrg break; 6128213fdd94Smrg } 6129213fdd94Smrg 6130213fdd94Smrg /* search backwards for last DIR_SEPARATOR */ 6131213fdd94Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132213fdd94Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133213fdd94Smrg p--; 6134213fdd94Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135213fdd94Smrg { 6136213fdd94Smrg /* no more DIR_SEPARATORS left */ 6137213fdd94Smrg break; 6138213fdd94Smrg } 6139213fdd94Smrg *p = '\0'; 6140213fdd94Smrg } 6141213fdd94Smrg else 6142213fdd94Smrg { 6143213fdd94Smrg lt_fatal (__FILE__, __LINE__, 6144213fdd94Smrg "error accessing file \"%s\": %s", 6145213fdd94Smrg tmp_pathspec, nonnull (strerror (errno))); 6146213fdd94Smrg } 6147213fdd94Smrg } 6148213fdd94Smrg XFREE (tmp_pathspec); 6149301ea0f4Smrg 6150213fdd94Smrg if (!has_symlinks) 6151213fdd94Smrg { 6152213fdd94Smrg return xstrdup (pathspec); 6153213fdd94Smrg } 6154301ea0f4Smrg 6155213fdd94Smrg tmp_pathspec = realpath (pathspec, buf); 6156213fdd94Smrg if (tmp_pathspec == 0) 6157213fdd94Smrg { 6158213fdd94Smrg lt_fatal (__FILE__, __LINE__, 6159213fdd94Smrg "could not follow symlinks for %s", pathspec); 6160213fdd94Smrg } 6161213fdd94Smrg return xstrdup (tmp_pathspec); 6162ef6fb4a5Smrg#endif 6163213fdd94Smrg} 6164301ea0f4Smrg 6165213fdd94Smrgchar * 6166213fdd94Smrgstrendzap (char *str, const char *pat) 6167213fdd94Smrg{ 6168213fdd94Smrg size_t len, patlen; 6169301ea0f4Smrg 6170213fdd94Smrg assert (str != NULL); 6171213fdd94Smrg assert (pat != NULL); 6172301ea0f4Smrg 6173213fdd94Smrg len = strlen (str); 6174213fdd94Smrg patlen = strlen (pat); 6175301ea0f4Smrg 6176213fdd94Smrg if (patlen <= len) 6177213fdd94Smrg { 6178213fdd94Smrg str += len - patlen; 617997ee6427Smrg if (STREQ (str, pat)) 6180213fdd94Smrg *str = '\0'; 6181213fdd94Smrg } 6182213fdd94Smrg return str; 6183ef6fb4a5Smrg} 61840cc67336Smrg 6185213fdd94Smrgvoid 6186213fdd94Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6187213fdd94Smrg{ 6188213fdd94Smrg va_list args; 6189213fdd94Smrg if (lt_debug) 6190213fdd94Smrg { 6191213fdd94Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192213fdd94Smrg va_start (args, fmt); 6193213fdd94Smrg (void) vfprintf (stderr, fmt, args); 6194213fdd94Smrg va_end (args); 6195213fdd94Smrg } 6196213fdd94Smrg} 61970cc67336Smrg 6198213fdd94Smrgstatic void 6199213fdd94Smrglt_error_core (int exit_status, const char *file, 6200213fdd94Smrg int line, const char *mode, 6201213fdd94Smrg const char *message, va_list ap) 6202213fdd94Smrg{ 6203213fdd94Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204213fdd94Smrg vfprintf (stderr, message, ap); 6205213fdd94Smrg fprintf (stderr, ".\n"); 62060cc67336Smrg 6207213fdd94Smrg if (exit_status >= 0) 6208213fdd94Smrg exit (exit_status); 6209ef6fb4a5Smrg} 62100cc67336Smrg 6211213fdd94Smrgvoid 6212213fdd94Smrglt_fatal (const char *file, int line, const char *message, ...) 6213213fdd94Smrg{ 6214213fdd94Smrg va_list ap; 6215213fdd94Smrg va_start (ap, message); 6216213fdd94Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217213fdd94Smrg va_end (ap); 6218ef6fb4a5Smrg} 62190cc67336Smrg 6220213fdd94Smrgstatic const char * 6221213fdd94Smrgnonnull (const char *s) 6222213fdd94Smrg{ 6223213fdd94Smrg return s ? s : "(null)"; 6224213fdd94Smrg} 62250cc67336Smrg 6226213fdd94Smrgstatic const char * 6227213fdd94Smrgnonempty (const char *s) 6228213fdd94Smrg{ 6229213fdd94Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6230213fdd94Smrg} 62310cc67336Smrg 6232213fdd94Smrgvoid 6233213fdd94Smrglt_setenv (const char *name, const char *value) 6234213fdd94Smrg{ 6235213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 6236213fdd94Smrg "(lt_setenv) setting '%s' to '%s'\n", 6237213fdd94Smrg nonnull (name), nonnull (value)); 6238213fdd94Smrg { 6239213fdd94Smrg#ifdef HAVE_SETENV 6240213fdd94Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241213fdd94Smrg char *str = xstrdup (value); 6242213fdd94Smrg setenv (name, str, 1); 6243213fdd94Smrg#else 624497ee6427Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245213fdd94Smrg char *str = XMALLOC (char, len); 6246213fdd94Smrg sprintf (str, "%s=%s", name, value); 6247213fdd94Smrg if (putenv (str) != EXIT_SUCCESS) 6248213fdd94Smrg { 6249213fdd94Smrg XFREE (str); 6250213fdd94Smrg } 6251213fdd94Smrg#endif 6252213fdd94Smrg } 6253213fdd94Smrg} 62540cc67336Smrg 6255213fdd94Smrgchar * 6256213fdd94Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257213fdd94Smrg{ 6258213fdd94Smrg char *new_value; 6259213fdd94Smrg if (orig_value && *orig_value) 6260213fdd94Smrg { 626197ee6427Smrg size_t orig_value_len = strlen (orig_value); 626297ee6427Smrg size_t add_len = strlen (add); 6263213fdd94Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264213fdd94Smrg if (to_end) 6265213fdd94Smrg { 6266213fdd94Smrg strcpy (new_value, orig_value); 6267213fdd94Smrg strcpy (new_value + orig_value_len, add); 6268213fdd94Smrg } 6269ef6fb4a5Smrg else 6270213fdd94Smrg { 6271213fdd94Smrg strcpy (new_value, add); 6272213fdd94Smrg strcpy (new_value + add_len, orig_value); 6273213fdd94Smrg } 6274213fdd94Smrg } 6275213fdd94Smrg else 6276213fdd94Smrg { 6277213fdd94Smrg new_value = xstrdup (add); 6278213fdd94Smrg } 6279213fdd94Smrg return new_value; 6280213fdd94Smrg} 62810cc67336Smrg 6282213fdd94Smrgvoid 6283213fdd94Smrglt_update_exe_path (const char *name, const char *value) 6284213fdd94Smrg{ 6285213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 6286213fdd94Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287213fdd94Smrg nonnull (name), nonnull (value)); 62880cc67336Smrg 6289213fdd94Smrg if (name && *name && value && *value) 6290213fdd94Smrg { 6291213fdd94Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292213fdd94Smrg /* some systems can't cope with a ':'-terminated path #' */ 629397ee6427Smrg size_t len = strlen (new_value); 629497ee6427Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295213fdd94Smrg { 629697ee6427Smrg new_value[--len] = '\0'; 6297213fdd94Smrg } 6298213fdd94Smrg lt_setenv (name, new_value); 6299213fdd94Smrg XFREE (new_value); 6300213fdd94Smrg } 6301213fdd94Smrg} 63020cc67336Smrg 6303213fdd94Smrgvoid 6304213fdd94Smrglt_update_lib_path (const char *name, const char *value) 6305213fdd94Smrg{ 6306213fdd94Smrg lt_debugprintf (__FILE__, __LINE__, 6307213fdd94Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308213fdd94Smrg nonnull (name), nonnull (value)); 63090cc67336Smrg 6310213fdd94Smrg if (name && *name && value && *value) 6311213fdd94Smrg { 6312213fdd94Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313213fdd94Smrg lt_setenv (name, new_value); 6314213fdd94Smrg XFREE (new_value); 6315213fdd94Smrg } 6316213fdd94Smrg} 63170cc67336Smrg 6318ef6fb4a5SmrgEOF 6319213fdd94Smrg case $host_os in 6320213fdd94Smrg mingw*) 6321213fdd94Smrg cat <<"EOF" 6322213fdd94Smrg 6323213fdd94Smrg/* Prepares an argument vector before calling spawn(). 6324213fdd94Smrg Note that spawn() does not by itself call the command interpreter 6325213fdd94Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326213fdd94Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327213fdd94Smrg GetVersionEx(&v); 6328213fdd94Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329213fdd94Smrg }) ? "cmd.exe" : "command.com"). 6330213fdd94Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6331213fdd94Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332213fdd94Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333213fdd94Smrg special way: 6334213fdd94Smrg - Space and tab are interpreted as delimiters. They are not treated as 6335213fdd94Smrg delimiters if they are surrounded by double quotes: "...". 6336213fdd94Smrg - Unescaped double quotes are removed from the input. Their only effect is 6337213fdd94Smrg that within double quotes, space and tab are treated like normal 6338213fdd94Smrg characters. 6339213fdd94Smrg - Backslashes not followed by double quotes are not special. 6340213fdd94Smrg - But 2*n+1 backslashes followed by a double quote become 6341213fdd94Smrg n backslashes followed by a double quote (n >= 0): 6342213fdd94Smrg \" -> " 6343213fdd94Smrg \\\" -> \" 6344213fdd94Smrg \\\\\" -> \\" 6345213fdd94Smrg */ 6346213fdd94Smrg#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" 6347213fdd94Smrg#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" 6348213fdd94Smrgchar ** 6349213fdd94Smrgprepare_spawn (char **argv) 6350ef6fb4a5Smrg{ 6351213fdd94Smrg size_t argc; 6352213fdd94Smrg char **new_argv; 6353213fdd94Smrg size_t i; 63540cc67336Smrg 6355213fdd94Smrg /* Count number of arguments. */ 6356213fdd94Smrg for (argc = 0; argv[argc] != NULL; argc++) 6357213fdd94Smrg ; 63580cc67336Smrg 6359213fdd94Smrg /* Allocate new argument vector. */ 6360213fdd94Smrg new_argv = XMALLOC (char *, argc + 1); 63610cc67336Smrg 6362213fdd94Smrg /* Put quoted arguments into the new argument vector. */ 6363213fdd94Smrg for (i = 0; i < argc; i++) 6364213fdd94Smrg { 6365213fdd94Smrg const char *string = argv[i]; 6366213fdd94Smrg 6367213fdd94Smrg if (string[0] == '\0') 6368213fdd94Smrg new_argv[i] = xstrdup ("\"\""); 6369213fdd94Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370213fdd94Smrg { 6371213fdd94Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372213fdd94Smrg size_t length; 6373213fdd94Smrg unsigned int backslashes; 6374213fdd94Smrg const char *s; 6375213fdd94Smrg char *quoted_string; 6376213fdd94Smrg char *p; 6377213fdd94Smrg 6378213fdd94Smrg length = 0; 6379213fdd94Smrg backslashes = 0; 6380213fdd94Smrg if (quote_around) 6381213fdd94Smrg length++; 6382213fdd94Smrg for (s = string; *s != '\0'; s++) 6383213fdd94Smrg { 6384213fdd94Smrg char c = *s; 6385213fdd94Smrg if (c == '"') 6386213fdd94Smrg length += backslashes + 1; 6387213fdd94Smrg length++; 6388213fdd94Smrg if (c == '\\') 6389213fdd94Smrg backslashes++; 6390213fdd94Smrg else 6391213fdd94Smrg backslashes = 0; 6392213fdd94Smrg } 6393213fdd94Smrg if (quote_around) 6394213fdd94Smrg length += backslashes + 1; 6395213fdd94Smrg 6396213fdd94Smrg quoted_string = XMALLOC (char, length + 1); 6397213fdd94Smrg 6398213fdd94Smrg p = quoted_string; 6399213fdd94Smrg backslashes = 0; 6400213fdd94Smrg if (quote_around) 6401213fdd94Smrg *p++ = '"'; 6402213fdd94Smrg for (s = string; *s != '\0'; s++) 6403213fdd94Smrg { 6404213fdd94Smrg char c = *s; 6405213fdd94Smrg if (c == '"') 6406213fdd94Smrg { 6407213fdd94Smrg unsigned int j; 6408213fdd94Smrg for (j = backslashes + 1; j > 0; j--) 6409213fdd94Smrg *p++ = '\\'; 6410213fdd94Smrg } 6411213fdd94Smrg *p++ = c; 6412213fdd94Smrg if (c == '\\') 6413213fdd94Smrg backslashes++; 6414213fdd94Smrg else 6415213fdd94Smrg backslashes = 0; 6416213fdd94Smrg } 6417213fdd94Smrg if (quote_around) 6418213fdd94Smrg { 6419213fdd94Smrg unsigned int j; 6420213fdd94Smrg for (j = backslashes; j > 0; j--) 6421213fdd94Smrg *p++ = '\\'; 6422213fdd94Smrg *p++ = '"'; 6423213fdd94Smrg } 6424213fdd94Smrg *p = '\0'; 64250cc67336Smrg 6426213fdd94Smrg new_argv[i] = quoted_string; 6427213fdd94Smrg } 6428213fdd94Smrg else 6429213fdd94Smrg new_argv[i] = (char *) string; 6430213fdd94Smrg } 6431213fdd94Smrg new_argv[argc] = NULL; 64320cc67336Smrg 6433213fdd94Smrg return new_argv; 6434213fdd94Smrg} 6435ef6fb4a5SmrgEOF 6436213fdd94Smrg ;; 6437213fdd94Smrg esac 64380cc67336Smrg 6439213fdd94Smrg cat <<"EOF" 6440213fdd94Smrgvoid lt_dump_script (FILE* f) 6441213fdd94Smrg{ 6442ef6fb4a5SmrgEOF 6443213fdd94Smrg func_emit_wrapper yes | 6444213fdd94Smrg $SED -n -e ' 6445213fdd94Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6446213fdd94Smrg\2/ 6447213fdd94Smrgh 6448213fdd94Smrgs/\([\\"]\)/\\\1/g 6449213fdd94Smrgs/$/\\n/ 6450213fdd94Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451213fdd94Smrgg 6452213fdd94SmrgD' 6453213fdd94Smrg cat <<"EOF" 6454ef6fb4a5Smrg} 6455213fdd94SmrgEOF 6456ef6fb4a5Smrg} 6457213fdd94Smrg# end: func_emit_cwrapperexe_src 64580cc67336Smrg 6459213fdd94Smrg# func_win32_import_lib_p ARG 6460213fdd94Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6461213fdd94Smrgfunc_win32_import_lib_p () 6462ef6fb4a5Smrg{ 646397ee6427Smrg $debug_cmd 646497ee6427Smrg 6465213fdd94Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466213fdd94Smrg *import*) : ;; 6467213fdd94Smrg *) false ;; 6468213fdd94Smrg esac 6469ef6fb4a5Smrg} 64700cc67336Smrg 647197ee6427Smrg# func_suncc_cstd_abi 647297ee6427Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647397ee6427Smrg# Several compiler flags select an ABI that is incompatible with the 647497ee6427Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647597ee6427Smrgfunc_suncc_cstd_abi () 647697ee6427Smrg{ 647797ee6427Smrg $debug_cmd 647897ee6427Smrg 647997ee6427Smrg case " $compile_command " in 648097ee6427Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648197ee6427Smrg suncc_use_cstd_abi=no 648297ee6427Smrg ;; 648397ee6427Smrg *) 648497ee6427Smrg suncc_use_cstd_abi=yes 648597ee6427Smrg ;; 648697ee6427Smrg esac 648797ee6427Smrg} 648897ee6427Smrg 6489213fdd94Smrg# func_mode_link arg... 6490213fdd94Smrgfunc_mode_link () 6491ef6fb4a5Smrg{ 649297ee6427Smrg $debug_cmd 649397ee6427Smrg 6494213fdd94Smrg case $host in 6495213fdd94Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496213fdd94Smrg # It is impossible to link a dll without this setting, and 6497213fdd94Smrg # we shouldn't force the makefile maintainer to figure out 649897ee6427Smrg # what system we are compiling for in order to pass an extra 6499213fdd94Smrg # flag for every libtool invocation. 6500213fdd94Smrg # allow_undefined=no 65010cc67336Smrg 6502213fdd94Smrg # FIXME: Unfortunately, there are problems with the above when trying 650397ee6427Smrg # to make a dll that has undefined symbols, in which case not 6504213fdd94Smrg # even a static library is built. For now, we need to specify 6505213fdd94Smrg # -no-undefined on the libtool link line when we can be certain 6506213fdd94Smrg # that all symbols are satisfied, otherwise we get a static library. 6507213fdd94Smrg allow_undefined=yes 6508213fdd94Smrg ;; 6509213fdd94Smrg *) 6510213fdd94Smrg allow_undefined=yes 6511213fdd94Smrg ;; 6512213fdd94Smrg esac 6513213fdd94Smrg libtool_args=$nonopt 6514213fdd94Smrg base_compile="$nonopt $@" 6515213fdd94Smrg compile_command=$nonopt 6516213fdd94Smrg finalize_command=$nonopt 65170cc67336Smrg 6518213fdd94Smrg compile_rpath= 6519213fdd94Smrg finalize_rpath= 6520213fdd94Smrg compile_shlibpath= 6521213fdd94Smrg finalize_shlibpath= 6522213fdd94Smrg convenience= 6523213fdd94Smrg old_convenience= 6524213fdd94Smrg deplibs= 6525213fdd94Smrg old_deplibs= 6526213fdd94Smrg compiler_flags= 6527213fdd94Smrg linker_flags= 6528213fdd94Smrg dllsearchpath= 6529213fdd94Smrg lib_search_path=`pwd` 6530213fdd94Smrg inst_prefix_dir= 6531213fdd94Smrg new_inherited_linker_flags= 65320cc67336Smrg 6533213fdd94Smrg avoid_version=no 6534213fdd94Smrg bindir= 6535213fdd94Smrg dlfiles= 6536213fdd94Smrg dlprefiles= 6537213fdd94Smrg dlself=no 6538213fdd94Smrg export_dynamic=no 6539213fdd94Smrg export_symbols= 6540213fdd94Smrg export_symbols_regex= 6541213fdd94Smrg generated= 6542213fdd94Smrg libobjs= 6543213fdd94Smrg ltlibs= 6544213fdd94Smrg module=no 6545213fdd94Smrg no_install=no 6546213fdd94Smrg objs= 654797ee6427Smrg os2dllname= 6548213fdd94Smrg non_pic_objects= 6549213fdd94Smrg precious_files_regex= 6550213fdd94Smrg prefer_static_libs=no 655197ee6427Smrg preload=false 6552213fdd94Smrg prev= 6553213fdd94Smrg prevarg= 6554213fdd94Smrg release= 6555213fdd94Smrg rpath= 6556213fdd94Smrg xrpath= 6557213fdd94Smrg perm_rpath= 6558213fdd94Smrg temp_rpath= 6559213fdd94Smrg thread_safe=no 6560213fdd94Smrg vinfo= 6561213fdd94Smrg vinfo_number=no 6562213fdd94Smrg weak_libs= 656397ee6427Smrg single_module=$wl-single_module 6564213fdd94Smrg func_infer_tag $base_compile 65650cc67336Smrg 6566213fdd94Smrg # We need to know -static, to get the right output filenames. 6567213fdd94Smrg for arg 6568213fdd94Smrg do 6569213fdd94Smrg case $arg in 6570213fdd94Smrg -shared) 657197ee6427Smrg test yes != "$build_libtool_libs" \ 657297ee6427Smrg && func_fatal_configuration "cannot build a shared library" 6573213fdd94Smrg build_old_libs=no 6574213fdd94Smrg break 6575213fdd94Smrg ;; 6576213fdd94Smrg -all-static | -static | -static-libtool-libs) 6577213fdd94Smrg case $arg in 6578213fdd94Smrg -all-static) 657997ee6427Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580213fdd94Smrg func_warning "complete static linking is impossible in this configuration" 6581213fdd94Smrg fi 6582213fdd94Smrg if test -n "$link_static_flag"; then 6583213fdd94Smrg dlopen_self=$dlopen_self_static 6584213fdd94Smrg fi 6585213fdd94Smrg prefer_static_libs=yes 6586213fdd94Smrg ;; 6587213fdd94Smrg -static) 6588213fdd94Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589213fdd94Smrg dlopen_self=$dlopen_self_static 6590213fdd94Smrg fi 6591213fdd94Smrg prefer_static_libs=built 6592213fdd94Smrg ;; 6593213fdd94Smrg -static-libtool-libs) 6594213fdd94Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595213fdd94Smrg dlopen_self=$dlopen_self_static 6596213fdd94Smrg fi 6597213fdd94Smrg prefer_static_libs=yes 6598213fdd94Smrg ;; 6599213fdd94Smrg esac 6600213fdd94Smrg build_libtool_libs=no 6601213fdd94Smrg build_old_libs=yes 6602213fdd94Smrg break 6603213fdd94Smrg ;; 6604213fdd94Smrg esac 6605213fdd94Smrg done 66060cc67336Smrg 6607213fdd94Smrg # See if our shared archives depend on static archives. 6608213fdd94Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 66090cc67336Smrg 6610213fdd94Smrg # Go through the arguments, transforming them on the way. 6611213fdd94Smrg while test "$#" -gt 0; do 661297ee6427Smrg arg=$1 6613213fdd94Smrg shift 6614213fdd94Smrg func_quote_for_eval "$arg" 6615213fdd94Smrg qarg=$func_quote_for_eval_unquoted_result 6616213fdd94Smrg func_append libtool_args " $func_quote_for_eval_result" 6617301ea0f4Smrg 6618213fdd94Smrg # If the previous option needs an argument, assign it. 6619213fdd94Smrg if test -n "$prev"; then 6620213fdd94Smrg case $prev in 6621213fdd94Smrg output) 6622213fdd94Smrg func_append compile_command " @OUTPUT@" 6623213fdd94Smrg func_append finalize_command " @OUTPUT@" 6624213fdd94Smrg ;; 6625213fdd94Smrg esac 6626ef6fb4a5Smrg 6627213fdd94Smrg case $prev in 6628213fdd94Smrg bindir) 662997ee6427Smrg bindir=$arg 6630213fdd94Smrg prev= 6631213fdd94Smrg continue 6632213fdd94Smrg ;; 6633213fdd94Smrg dlfiles|dlprefiles) 663497ee6427Smrg $preload || { 6635213fdd94Smrg # Add the symbol object into the linking commands. 6636213fdd94Smrg func_append compile_command " @SYMFILE@" 6637213fdd94Smrg func_append finalize_command " @SYMFILE@" 663897ee6427Smrg preload=: 663997ee6427Smrg } 6640213fdd94Smrg case $arg in 6641213fdd94Smrg *.la | *.lo) ;; # We handle these cases below. 6642213fdd94Smrg force) 664397ee6427Smrg if test no = "$dlself"; then 6644213fdd94Smrg dlself=needless 6645213fdd94Smrg export_dynamic=yes 6646213fdd94Smrg fi 6647213fdd94Smrg prev= 6648213fdd94Smrg continue 6649213fdd94Smrg ;; 6650213fdd94Smrg self) 665197ee6427Smrg if test dlprefiles = "$prev"; then 6652213fdd94Smrg dlself=yes 665397ee6427Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654213fdd94Smrg dlself=yes 6655213fdd94Smrg else 6656213fdd94Smrg dlself=needless 6657213fdd94Smrg export_dynamic=yes 6658213fdd94Smrg fi 6659213fdd94Smrg prev= 6660213fdd94Smrg continue 6661213fdd94Smrg ;; 6662213fdd94Smrg *) 666397ee6427Smrg if test dlfiles = "$prev"; then 6664213fdd94Smrg func_append dlfiles " $arg" 6665213fdd94Smrg else 6666213fdd94Smrg func_append dlprefiles " $arg" 6667213fdd94Smrg fi 6668213fdd94Smrg prev= 6669213fdd94Smrg continue 6670213fdd94Smrg ;; 6671213fdd94Smrg esac 6672213fdd94Smrg ;; 6673213fdd94Smrg expsyms) 667497ee6427Smrg export_symbols=$arg 6675213fdd94Smrg test -f "$arg" \ 667697ee6427Smrg || func_fatal_error "symbol file '$arg' does not exist" 6677213fdd94Smrg prev= 6678213fdd94Smrg continue 6679213fdd94Smrg ;; 6680213fdd94Smrg expsyms_regex) 668197ee6427Smrg export_symbols_regex=$arg 6682213fdd94Smrg prev= 6683213fdd94Smrg continue 6684213fdd94Smrg ;; 6685213fdd94Smrg framework) 6686213fdd94Smrg case $host in 6687213fdd94Smrg *-*-darwin*) 6688213fdd94Smrg case "$deplibs " in 6689213fdd94Smrg *" $qarg.ltframework "*) ;; 6690213fdd94Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691213fdd94Smrg ;; 6692213fdd94Smrg esac 6693213fdd94Smrg ;; 6694213fdd94Smrg esac 6695213fdd94Smrg prev= 6696213fdd94Smrg continue 6697213fdd94Smrg ;; 6698213fdd94Smrg inst_prefix) 669997ee6427Smrg inst_prefix_dir=$arg 670097ee6427Smrg prev= 670197ee6427Smrg continue 670297ee6427Smrg ;; 670397ee6427Smrg mllvm) 670497ee6427Smrg # Clang does not use LLVM to link, so we can simply discard any 670597ee6427Smrg # '-mllvm $arg' options when doing the link step. 6706213fdd94Smrg prev= 6707213fdd94Smrg continue 6708213fdd94Smrg ;; 6709213fdd94Smrg objectlist) 6710213fdd94Smrg if test -f "$arg"; then 6711213fdd94Smrg save_arg=$arg 6712213fdd94Smrg moreargs= 6713213fdd94Smrg for fil in `cat "$save_arg"` 6714213fdd94Smrg do 6715213fdd94Smrg# func_append moreargs " $fil" 6716213fdd94Smrg arg=$fil 6717213fdd94Smrg # A libtool-controlled object. 6718ef6fb4a5Smrg 6719213fdd94Smrg # Check to see that this really is a libtool object. 6720213fdd94Smrg if func_lalib_unsafe_p "$arg"; then 6721213fdd94Smrg pic_object= 6722213fdd94Smrg non_pic_object= 6723ef6fb4a5Smrg 6724213fdd94Smrg # Read the .lo file 6725213fdd94Smrg func_source "$arg" 6726ef6fb4a5Smrg 6727213fdd94Smrg if test -z "$pic_object" || 6728213fdd94Smrg test -z "$non_pic_object" || 672997ee6427Smrg test none = "$pic_object" && 673097ee6427Smrg test none = "$non_pic_object"; then 673197ee6427Smrg func_fatal_error "cannot find name of object for '$arg'" 6732213fdd94Smrg fi 6733ef6fb4a5Smrg 6734213fdd94Smrg # Extract subdirectory from the argument. 6735213fdd94Smrg func_dirname "$arg" "/" "" 673697ee6427Smrg xdir=$func_dirname_result 6737ef6fb4a5Smrg 673897ee6427Smrg if test none != "$pic_object"; then 6739213fdd94Smrg # Prepend the subdirectory the object is found in. 674097ee6427Smrg pic_object=$xdir$pic_object 6741ef6fb4a5Smrg 674297ee6427Smrg if test dlfiles = "$prev"; then 674397ee6427Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744213fdd94Smrg func_append dlfiles " $pic_object" 6745213fdd94Smrg prev= 6746213fdd94Smrg continue 6747213fdd94Smrg else 6748213fdd94Smrg # If libtool objects are unsupported, then we need to preload. 6749213fdd94Smrg prev=dlprefiles 6750213fdd94Smrg fi 6751213fdd94Smrg fi 6752ef6fb4a5Smrg 6753213fdd94Smrg # CHECK ME: I think I busted this. -Ossama 675497ee6427Smrg if test dlprefiles = "$prev"; then 6755213fdd94Smrg # Preload the old-style object. 6756213fdd94Smrg func_append dlprefiles " $pic_object" 6757213fdd94Smrg prev= 6758213fdd94Smrg fi 6759ef6fb4a5Smrg 6760213fdd94Smrg # A PIC object. 6761213fdd94Smrg func_append libobjs " $pic_object" 676297ee6427Smrg arg=$pic_object 6763213fdd94Smrg fi 6764ef6fb4a5Smrg 6765213fdd94Smrg # Non-PIC object. 676697ee6427Smrg if test none != "$non_pic_object"; then 6767213fdd94Smrg # Prepend the subdirectory the object is found in. 676897ee6427Smrg non_pic_object=$xdir$non_pic_object 6769ef6fb4a5Smrg 6770213fdd94Smrg # A standard non-PIC object 6771213fdd94Smrg func_append non_pic_objects " $non_pic_object" 677297ee6427Smrg if test -z "$pic_object" || test none = "$pic_object"; then 677397ee6427Smrg arg=$non_pic_object 6774213fdd94Smrg fi 6775213fdd94Smrg else 6776213fdd94Smrg # If the PIC object exists, use it instead. 6777213fdd94Smrg # $xdir was prepended to $pic_object above. 677897ee6427Smrg non_pic_object=$pic_object 6779213fdd94Smrg func_append non_pic_objects " $non_pic_object" 6780213fdd94Smrg fi 6781213fdd94Smrg else 6782213fdd94Smrg # Only an error if not doing a dry-run. 6783213fdd94Smrg if $opt_dry_run; then 6784213fdd94Smrg # Extract subdirectory from the argument. 6785213fdd94Smrg func_dirname "$arg" "/" "" 678697ee6427Smrg xdir=$func_dirname_result 6787213fdd94Smrg 6788213fdd94Smrg func_lo2o "$arg" 6789213fdd94Smrg pic_object=$xdir$objdir/$func_lo2o_result 6790213fdd94Smrg non_pic_object=$xdir$func_lo2o_result 6791213fdd94Smrg func_append libobjs " $pic_object" 6792213fdd94Smrg func_append non_pic_objects " $non_pic_object" 6793213fdd94Smrg else 679497ee6427Smrg func_fatal_error "'$arg' is not a valid libtool object" 6795213fdd94Smrg fi 6796213fdd94Smrg fi 6797213fdd94Smrg done 6798213fdd94Smrg else 679997ee6427Smrg func_fatal_error "link input file '$arg' does not exist" 6800213fdd94Smrg fi 6801213fdd94Smrg arg=$save_arg 6802213fdd94Smrg prev= 6803213fdd94Smrg continue 6804213fdd94Smrg ;; 680597ee6427Smrg os2dllname) 680697ee6427Smrg os2dllname=$arg 680797ee6427Smrg prev= 680897ee6427Smrg continue 680997ee6427Smrg ;; 6810213fdd94Smrg precious_regex) 681197ee6427Smrg precious_files_regex=$arg 6812213fdd94Smrg prev= 6813213fdd94Smrg continue 6814213fdd94Smrg ;; 6815213fdd94Smrg release) 681697ee6427Smrg release=-$arg 6817213fdd94Smrg prev= 6818213fdd94Smrg continue 6819213fdd94Smrg ;; 6820213fdd94Smrg rpath | xrpath) 6821213fdd94Smrg # We need an absolute path. 6822213fdd94Smrg case $arg in 6823213fdd94Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824213fdd94Smrg *) 6825213fdd94Smrg func_fatal_error "only absolute run-paths are allowed" 6826213fdd94Smrg ;; 6827213fdd94Smrg esac 682897ee6427Smrg if test rpath = "$prev"; then 6829213fdd94Smrg case "$rpath " in 6830213fdd94Smrg *" $arg "*) ;; 6831213fdd94Smrg *) func_append rpath " $arg" ;; 6832213fdd94Smrg esac 6833213fdd94Smrg else 6834213fdd94Smrg case "$xrpath " in 6835213fdd94Smrg *" $arg "*) ;; 6836213fdd94Smrg *) func_append xrpath " $arg" ;; 6837213fdd94Smrg esac 6838213fdd94Smrg fi 6839213fdd94Smrg prev= 6840213fdd94Smrg continue 6841213fdd94Smrg ;; 6842213fdd94Smrg shrext) 684397ee6427Smrg shrext_cmds=$arg 6844213fdd94Smrg prev= 6845213fdd94Smrg continue 6846213fdd94Smrg ;; 6847213fdd94Smrg weak) 6848213fdd94Smrg func_append weak_libs " $arg" 6849213fdd94Smrg prev= 6850213fdd94Smrg continue 6851213fdd94Smrg ;; 6852213fdd94Smrg xcclinker) 6853213fdd94Smrg func_append linker_flags " $qarg" 6854213fdd94Smrg func_append compiler_flags " $qarg" 6855213fdd94Smrg prev= 6856213fdd94Smrg func_append compile_command " $qarg" 6857213fdd94Smrg func_append finalize_command " $qarg" 6858213fdd94Smrg continue 6859213fdd94Smrg ;; 6860213fdd94Smrg xcompiler) 6861213fdd94Smrg func_append compiler_flags " $qarg" 6862213fdd94Smrg prev= 6863213fdd94Smrg func_append compile_command " $qarg" 6864213fdd94Smrg func_append finalize_command " $qarg" 6865213fdd94Smrg continue 6866213fdd94Smrg ;; 6867213fdd94Smrg xlinker) 6868213fdd94Smrg func_append linker_flags " $qarg" 6869213fdd94Smrg func_append compiler_flags " $wl$qarg" 6870213fdd94Smrg prev= 6871213fdd94Smrg func_append compile_command " $wl$qarg" 6872213fdd94Smrg func_append finalize_command " $wl$qarg" 6873213fdd94Smrg continue 6874213fdd94Smrg ;; 6875213fdd94Smrg *) 6876213fdd94Smrg eval "$prev=\"\$arg\"" 6877213fdd94Smrg prev= 6878213fdd94Smrg continue 6879213fdd94Smrg ;; 6880213fdd94Smrg esac 6881213fdd94Smrg fi # test -n "$prev" 6882ef6fb4a5Smrg 688397ee6427Smrg prevarg=$arg 6884ef6fb4a5Smrg 6885213fdd94Smrg case $arg in 6886213fdd94Smrg -all-static) 6887213fdd94Smrg if test -n "$link_static_flag"; then 6888213fdd94Smrg # See comment for -static flag below, for more details. 6889213fdd94Smrg func_append compile_command " $link_static_flag" 6890213fdd94Smrg func_append finalize_command " $link_static_flag" 6891213fdd94Smrg fi 6892213fdd94Smrg continue 6893213fdd94Smrg ;; 6894ef6fb4a5Smrg 6895213fdd94Smrg -allow-undefined) 6896213fdd94Smrg # FIXME: remove this flag sometime in the future. 689797ee6427Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898213fdd94Smrg ;; 6899ef6fb4a5Smrg 6900213fdd94Smrg -avoid-version) 6901213fdd94Smrg avoid_version=yes 6902213fdd94Smrg continue 6903213fdd94Smrg ;; 6904ef6fb4a5Smrg 6905213fdd94Smrg -bindir) 6906213fdd94Smrg prev=bindir 6907213fdd94Smrg continue 6908213fdd94Smrg ;; 6909301ea0f4Smrg 6910213fdd94Smrg -dlopen) 6911213fdd94Smrg prev=dlfiles 6912213fdd94Smrg continue 6913213fdd94Smrg ;; 6914301ea0f4Smrg 6915213fdd94Smrg -dlpreopen) 6916213fdd94Smrg prev=dlprefiles 6917213fdd94Smrg continue 6918213fdd94Smrg ;; 6919301ea0f4Smrg 6920213fdd94Smrg -export-dynamic) 6921213fdd94Smrg export_dynamic=yes 6922213fdd94Smrg continue 6923213fdd94Smrg ;; 6924301ea0f4Smrg 6925213fdd94Smrg -export-symbols | -export-symbols-regex) 6926213fdd94Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927213fdd94Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928213fdd94Smrg fi 692997ee6427Smrg if test X-export-symbols = "X$arg"; then 6930213fdd94Smrg prev=expsyms 6931213fdd94Smrg else 6932213fdd94Smrg prev=expsyms_regex 6933213fdd94Smrg fi 6934213fdd94Smrg continue 6935213fdd94Smrg ;; 6936301ea0f4Smrg 6937213fdd94Smrg -framework) 6938213fdd94Smrg prev=framework 6939213fdd94Smrg continue 6940213fdd94Smrg ;; 6941301ea0f4Smrg 6942213fdd94Smrg -inst-prefix-dir) 6943213fdd94Smrg prev=inst_prefix 6944213fdd94Smrg continue 6945213fdd94Smrg ;; 6946301ea0f4Smrg 6947213fdd94Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948213fdd94Smrg # so, if we see these flags be careful not to treat them like -L 6949213fdd94Smrg -L[A-Z][A-Z]*:*) 6950213fdd94Smrg case $with_gcc/$host in 6951213fdd94Smrg no/*-*-irix* | /*-*-irix*) 6952213fdd94Smrg func_append compile_command " $arg" 6953213fdd94Smrg func_append finalize_command " $arg" 6954213fdd94Smrg ;; 6955213fdd94Smrg esac 6956213fdd94Smrg continue 6957213fdd94Smrg ;; 6958301ea0f4Smrg 6959213fdd94Smrg -L*) 6960213fdd94Smrg func_stripname "-L" '' "$arg" 6961213fdd94Smrg if test -z "$func_stripname_result"; then 6962213fdd94Smrg if test "$#" -gt 0; then 696397ee6427Smrg func_fatal_error "require no space between '-L' and '$1'" 6964213fdd94Smrg else 696597ee6427Smrg func_fatal_error "need path for '-L' option" 6966213fdd94Smrg fi 6967213fdd94Smrg fi 6968213fdd94Smrg func_resolve_sysroot "$func_stripname_result" 6969213fdd94Smrg dir=$func_resolve_sysroot_result 6970213fdd94Smrg # We need an absolute path. 6971213fdd94Smrg case $dir in 6972213fdd94Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973213fdd94Smrg *) 6974213fdd94Smrg absdir=`cd "$dir" && pwd` 6975213fdd94Smrg test -z "$absdir" && \ 697697ee6427Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697797ee6427Smrg dir=$absdir 6978213fdd94Smrg ;; 6979213fdd94Smrg esac 6980213fdd94Smrg case "$deplibs " in 6981213fdd94Smrg *" -L$dir "* | *" $arg "*) 6982213fdd94Smrg # Will only happen for absolute or sysroot arguments 6983213fdd94Smrg ;; 6984213fdd94Smrg *) 6985213fdd94Smrg # Preserve sysroot, but never include relative directories 6986213fdd94Smrg case $dir in 6987213fdd94Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988213fdd94Smrg *) func_append deplibs " -L$dir" ;; 6989213fdd94Smrg esac 6990213fdd94Smrg func_append lib_search_path " $dir" 6991213fdd94Smrg ;; 6992213fdd94Smrg esac 6993213fdd94Smrg case $host in 6994213fdd94Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995213fdd94Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996213fdd94Smrg case :$dllsearchpath: in 6997213fdd94Smrg *":$dir:"*) ;; 6998213fdd94Smrg ::) dllsearchpath=$dir;; 6999213fdd94Smrg *) func_append dllsearchpath ":$dir";; 7000213fdd94Smrg esac 7001213fdd94Smrg case :$dllsearchpath: in 7002213fdd94Smrg *":$testbindir:"*) ;; 7003213fdd94Smrg ::) dllsearchpath=$testbindir;; 7004213fdd94Smrg *) func_append dllsearchpath ":$testbindir";; 7005213fdd94Smrg esac 7006213fdd94Smrg ;; 7007213fdd94Smrg esac 7008213fdd94Smrg continue 7009213fdd94Smrg ;; 7010301ea0f4Smrg 7011213fdd94Smrg -l*) 701297ee6427Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013213fdd94Smrg case $host in 7014213fdd94Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015213fdd94Smrg # These systems don't actually have a C or math library (as such) 7016213fdd94Smrg continue 7017213fdd94Smrg ;; 7018213fdd94Smrg *-*-os2*) 7019213fdd94Smrg # These systems don't actually have a C library (as such) 702097ee6427Smrg test X-lc = "X$arg" && continue 7021213fdd94Smrg ;; 702297ee6427Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023213fdd94Smrg # Do not include libc due to us having libc/libc_r. 702497ee6427Smrg test X-lc = "X$arg" && continue 7025213fdd94Smrg ;; 7026213fdd94Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7027213fdd94Smrg # Rhapsody C and math libraries are in the System framework 7028213fdd94Smrg func_append deplibs " System.ltframework" 7029213fdd94Smrg continue 7030213fdd94Smrg ;; 7031213fdd94Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7032213fdd94Smrg # Causes problems with __ctype 703397ee6427Smrg test X-lc = "X$arg" && continue 7034213fdd94Smrg ;; 7035213fdd94Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036213fdd94Smrg # Compiler inserts libc in the correct place for threads to work 703797ee6427Smrg test X-lc = "X$arg" && continue 7038213fdd94Smrg ;; 7039213fdd94Smrg esac 704097ee6427Smrg elif test X-lc_r = "X$arg"; then 7041213fdd94Smrg case $host in 704297ee6427Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043213fdd94Smrg # Do not include libc_r directly, use -pthread flag. 7044213fdd94Smrg continue 7045213fdd94Smrg ;; 7046213fdd94Smrg esac 7047213fdd94Smrg fi 7048213fdd94Smrg func_append deplibs " $arg" 7049213fdd94Smrg continue 7050213fdd94Smrg ;; 7051213fdd94Smrg 705297ee6427Smrg -mllvm) 705397ee6427Smrg prev=mllvm 705497ee6427Smrg continue 705597ee6427Smrg ;; 705697ee6427Smrg 7057213fdd94Smrg -module) 7058213fdd94Smrg module=yes 7059213fdd94Smrg continue 7060213fdd94Smrg ;; 7061213fdd94Smrg 7062213fdd94Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063213fdd94Smrg # classes, name mangling, and exception handling. 7064213fdd94Smrg # Darwin uses the -arch flag to determine output architecture. 7065213fdd94Smrg -model|-arch|-isysroot|--sysroot) 7066213fdd94Smrg func_append compiler_flags " $arg" 7067213fdd94Smrg func_append compile_command " $arg" 7068213fdd94Smrg func_append finalize_command " $arg" 7069213fdd94Smrg prev=xcompiler 7070213fdd94Smrg continue 7071213fdd94Smrg ;; 7072213fdd94Smrg 7073213fdd94Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074213fdd94Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075213fdd94Smrg func_append compiler_flags " $arg" 7076213fdd94Smrg func_append compile_command " $arg" 7077213fdd94Smrg func_append finalize_command " $arg" 7078213fdd94Smrg case "$new_inherited_linker_flags " in 7079213fdd94Smrg *" $arg "*) ;; 7080213fdd94Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081213fdd94Smrg esac 7082213fdd94Smrg continue 7083213fdd94Smrg ;; 7084213fdd94Smrg 7085213fdd94Smrg -multi_module) 708697ee6427Smrg single_module=$wl-multi_module 7087213fdd94Smrg continue 7088213fdd94Smrg ;; 7089213fdd94Smrg 7090213fdd94Smrg -no-fast-install) 7091213fdd94Smrg fast_install=no 7092213fdd94Smrg continue 7093213fdd94Smrg ;; 7094213fdd94Smrg 7095213fdd94Smrg -no-install) 7096213fdd94Smrg case $host in 7097213fdd94Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098213fdd94Smrg # The PATH hackery in wrapper scripts is required on Windows 7099213fdd94Smrg # and Darwin in order for the loader to find any dlls it needs. 710097ee6427Smrg func_warning "'-no-install' is ignored for $host" 710197ee6427Smrg func_warning "assuming '-no-fast-install' instead" 7102213fdd94Smrg fast_install=no 7103213fdd94Smrg ;; 7104213fdd94Smrg *) no_install=yes ;; 7105213fdd94Smrg esac 7106213fdd94Smrg continue 7107213fdd94Smrg ;; 7108213fdd94Smrg 7109213fdd94Smrg -no-undefined) 7110213fdd94Smrg allow_undefined=no 7111213fdd94Smrg continue 7112213fdd94Smrg ;; 7113213fdd94Smrg 7114213fdd94Smrg -objectlist) 7115213fdd94Smrg prev=objectlist 7116213fdd94Smrg continue 7117213fdd94Smrg ;; 7118213fdd94Smrg 711997ee6427Smrg -os2dllname) 712097ee6427Smrg prev=os2dllname 712197ee6427Smrg continue 712297ee6427Smrg ;; 712397ee6427Smrg 7124213fdd94Smrg -o) prev=output ;; 7125213fdd94Smrg 7126213fdd94Smrg -precious-files-regex) 7127213fdd94Smrg prev=precious_regex 7128213fdd94Smrg continue 7129213fdd94Smrg ;; 7130213fdd94Smrg 7131213fdd94Smrg -release) 7132213fdd94Smrg prev=release 7133213fdd94Smrg continue 7134213fdd94Smrg ;; 7135213fdd94Smrg 7136213fdd94Smrg -rpath) 7137213fdd94Smrg prev=rpath 7138213fdd94Smrg continue 7139213fdd94Smrg ;; 7140213fdd94Smrg 7141213fdd94Smrg -R) 7142213fdd94Smrg prev=xrpath 7143213fdd94Smrg continue 7144213fdd94Smrg ;; 7145213fdd94Smrg 7146213fdd94Smrg -R*) 7147213fdd94Smrg func_stripname '-R' '' "$arg" 7148213fdd94Smrg dir=$func_stripname_result 7149213fdd94Smrg # We need an absolute path. 7150213fdd94Smrg case $dir in 7151213fdd94Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7152213fdd94Smrg =*) 7153213fdd94Smrg func_stripname '=' '' "$dir" 7154213fdd94Smrg dir=$lt_sysroot$func_stripname_result 7155213fdd94Smrg ;; 7156213fdd94Smrg *) 7157213fdd94Smrg func_fatal_error "only absolute run-paths are allowed" 7158213fdd94Smrg ;; 7159213fdd94Smrg esac 7160213fdd94Smrg case "$xrpath " in 7161213fdd94Smrg *" $dir "*) ;; 7162213fdd94Smrg *) func_append xrpath " $dir" ;; 7163213fdd94Smrg esac 7164213fdd94Smrg continue 7165213fdd94Smrg ;; 7166213fdd94Smrg 7167213fdd94Smrg -shared) 7168213fdd94Smrg # The effects of -shared are defined in a previous loop. 7169213fdd94Smrg continue 7170213fdd94Smrg ;; 7171213fdd94Smrg 7172213fdd94Smrg -shrext) 7173213fdd94Smrg prev=shrext 7174213fdd94Smrg continue 7175213fdd94Smrg ;; 7176213fdd94Smrg 7177213fdd94Smrg -static | -static-libtool-libs) 7178213fdd94Smrg # The effects of -static are defined in a previous loop. 7179213fdd94Smrg # We used to do the same as -all-static on platforms that 7180213fdd94Smrg # didn't have a PIC flag, but the assumption that the effects 7181213fdd94Smrg # would be equivalent was wrong. It would break on at least 7182213fdd94Smrg # Digital Unix and AIX. 7183213fdd94Smrg continue 7184213fdd94Smrg ;; 7185213fdd94Smrg 7186213fdd94Smrg -thread-safe) 7187213fdd94Smrg thread_safe=yes 7188213fdd94Smrg continue 7189213fdd94Smrg ;; 7190213fdd94Smrg 7191213fdd94Smrg -version-info) 7192213fdd94Smrg prev=vinfo 7193213fdd94Smrg continue 7194213fdd94Smrg ;; 7195213fdd94Smrg 7196213fdd94Smrg -version-number) 7197213fdd94Smrg prev=vinfo 7198213fdd94Smrg vinfo_number=yes 7199213fdd94Smrg continue 7200213fdd94Smrg ;; 7201213fdd94Smrg 7202213fdd94Smrg -weak) 7203213fdd94Smrg prev=weak 7204213fdd94Smrg continue 7205213fdd94Smrg ;; 7206213fdd94Smrg 7207213fdd94Smrg -Wc,*) 7208213fdd94Smrg func_stripname '-Wc,' '' "$arg" 7209213fdd94Smrg args=$func_stripname_result 7210213fdd94Smrg arg= 721197ee6427Smrg save_ifs=$IFS; IFS=, 7212213fdd94Smrg for flag in $args; do 721397ee6427Smrg IFS=$save_ifs 7214213fdd94Smrg func_quote_for_eval "$flag" 7215213fdd94Smrg func_append arg " $func_quote_for_eval_result" 7216213fdd94Smrg func_append compiler_flags " $func_quote_for_eval_result" 7217213fdd94Smrg done 721897ee6427Smrg IFS=$save_ifs 7219213fdd94Smrg func_stripname ' ' '' "$arg" 7220213fdd94Smrg arg=$func_stripname_result 7221213fdd94Smrg ;; 7222213fdd94Smrg 7223213fdd94Smrg -Wl,*) 7224213fdd94Smrg func_stripname '-Wl,' '' "$arg" 7225213fdd94Smrg args=$func_stripname_result 7226213fdd94Smrg arg= 722797ee6427Smrg save_ifs=$IFS; IFS=, 7228213fdd94Smrg for flag in $args; do 722997ee6427Smrg IFS=$save_ifs 7230213fdd94Smrg func_quote_for_eval "$flag" 7231213fdd94Smrg func_append arg " $wl$func_quote_for_eval_result" 7232213fdd94Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7233213fdd94Smrg func_append linker_flags " $func_quote_for_eval_result" 7234213fdd94Smrg done 723597ee6427Smrg IFS=$save_ifs 7236213fdd94Smrg func_stripname ' ' '' "$arg" 7237213fdd94Smrg arg=$func_stripname_result 7238213fdd94Smrg ;; 7239213fdd94Smrg 7240213fdd94Smrg -Xcompiler) 7241213fdd94Smrg prev=xcompiler 7242213fdd94Smrg continue 7243213fdd94Smrg ;; 7244213fdd94Smrg 7245213fdd94Smrg -Xlinker) 7246213fdd94Smrg prev=xlinker 7247213fdd94Smrg continue 7248213fdd94Smrg ;; 7249213fdd94Smrg 7250213fdd94Smrg -XCClinker) 7251213fdd94Smrg prev=xcclinker 7252213fdd94Smrg continue 7253213fdd94Smrg ;; 7254213fdd94Smrg 7255213fdd94Smrg # -msg_* for osf cc 7256213fdd94Smrg -msg_*) 7257213fdd94Smrg func_quote_for_eval "$arg" 725897ee6427Smrg arg=$func_quote_for_eval_result 7259213fdd94Smrg ;; 7260213fdd94Smrg 7261213fdd94Smrg # Flags to be passed through unchanged, with rationale: 7262213fdd94Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263213fdd94Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7264213fdd94Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265213fdd94Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7266213fdd94Smrg # -q* compiler args for the IBM compiler 7267213fdd94Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268213fdd94Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7269213fdd94Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727097ee6427Smrg # -fstack-protector* stack protector flags for GCC 7271213fdd94Smrg # @file GCC response files 7272213fdd94Smrg # -tp=* Portland pgcc target processor selection 7273213fdd94Smrg # --sysroot=* for sysroot support 727497ee6427Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275d94624a0Smrg # -specs=* GCC specs files 727697ee6427Smrg # -stdlib=* select c++ std lib with clang 7277d94624a0Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7278213fdd94Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7279213fdd94Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7280d94624a0Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7281d94624a0Smrg -specs=*|-fsanitize=*) 7282213fdd94Smrg func_quote_for_eval "$arg" 728397ee6427Smrg arg=$func_quote_for_eval_result 7284213fdd94Smrg func_append compile_command " $arg" 7285213fdd94Smrg func_append finalize_command " $arg" 7286213fdd94Smrg func_append compiler_flags " $arg" 7287213fdd94Smrg continue 7288213fdd94Smrg ;; 7289213fdd94Smrg 729097ee6427Smrg -Z*) 729197ee6427Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 729297ee6427Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 729397ee6427Smrg compiler_flags="$compiler_flags $arg" 729497ee6427Smrg func_append compile_command " $arg" 729597ee6427Smrg func_append finalize_command " $arg" 729697ee6427Smrg case $arg in 729797ee6427Smrg -Zlinker | -Zstack) 729897ee6427Smrg prev=xcompiler 729997ee6427Smrg ;; 730097ee6427Smrg esac 730197ee6427Smrg continue 730297ee6427Smrg else 730397ee6427Smrg # Otherwise treat like 'Some other compiler flag' below 730497ee6427Smrg func_quote_for_eval "$arg" 730597ee6427Smrg arg=$func_quote_for_eval_result 730697ee6427Smrg fi 730797ee6427Smrg ;; 730897ee6427Smrg 7309213fdd94Smrg # Some other compiler flag. 7310213fdd94Smrg -* | +*) 7311213fdd94Smrg func_quote_for_eval "$arg" 731297ee6427Smrg arg=$func_quote_for_eval_result 7313213fdd94Smrg ;; 7314213fdd94Smrg 7315213fdd94Smrg *.$objext) 7316213fdd94Smrg # A standard object. 7317213fdd94Smrg func_append objs " $arg" 7318213fdd94Smrg ;; 7319213fdd94Smrg 7320213fdd94Smrg *.lo) 7321213fdd94Smrg # A libtool-controlled object. 7322213fdd94Smrg 7323213fdd94Smrg # Check to see that this really is a libtool object. 7324213fdd94Smrg if func_lalib_unsafe_p "$arg"; then 7325213fdd94Smrg pic_object= 7326213fdd94Smrg non_pic_object= 7327213fdd94Smrg 7328213fdd94Smrg # Read the .lo file 7329213fdd94Smrg func_source "$arg" 7330213fdd94Smrg 7331213fdd94Smrg if test -z "$pic_object" || 7332213fdd94Smrg test -z "$non_pic_object" || 733397ee6427Smrg test none = "$pic_object" && 733497ee6427Smrg test none = "$non_pic_object"; then 733597ee6427Smrg func_fatal_error "cannot find name of object for '$arg'" 7336213fdd94Smrg fi 7337213fdd94Smrg 7338213fdd94Smrg # Extract subdirectory from the argument. 7339213fdd94Smrg func_dirname "$arg" "/" "" 734097ee6427Smrg xdir=$func_dirname_result 7341213fdd94Smrg 734297ee6427Smrg test none = "$pic_object" || { 7343213fdd94Smrg # Prepend the subdirectory the object is found in. 734497ee6427Smrg pic_object=$xdir$pic_object 7345213fdd94Smrg 734697ee6427Smrg if test dlfiles = "$prev"; then 734797ee6427Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7348213fdd94Smrg func_append dlfiles " $pic_object" 7349213fdd94Smrg prev= 7350213fdd94Smrg continue 7351213fdd94Smrg else 7352213fdd94Smrg # If libtool objects are unsupported, then we need to preload. 7353213fdd94Smrg prev=dlprefiles 7354213fdd94Smrg fi 7355213fdd94Smrg fi 7356213fdd94Smrg 7357213fdd94Smrg # CHECK ME: I think I busted this. -Ossama 735897ee6427Smrg if test dlprefiles = "$prev"; then 7359213fdd94Smrg # Preload the old-style object. 7360213fdd94Smrg func_append dlprefiles " $pic_object" 7361213fdd94Smrg prev= 7362213fdd94Smrg fi 7363213fdd94Smrg 7364213fdd94Smrg # A PIC object. 7365213fdd94Smrg func_append libobjs " $pic_object" 736697ee6427Smrg arg=$pic_object 736797ee6427Smrg } 7368213fdd94Smrg 7369213fdd94Smrg # Non-PIC object. 737097ee6427Smrg if test none != "$non_pic_object"; then 7371213fdd94Smrg # Prepend the subdirectory the object is found in. 737297ee6427Smrg non_pic_object=$xdir$non_pic_object 7373213fdd94Smrg 7374213fdd94Smrg # A standard non-PIC object 7375213fdd94Smrg func_append non_pic_objects " $non_pic_object" 737697ee6427Smrg if test -z "$pic_object" || test none = "$pic_object"; then 737797ee6427Smrg arg=$non_pic_object 7378213fdd94Smrg fi 7379213fdd94Smrg else 7380213fdd94Smrg # If the PIC object exists, use it instead. 7381213fdd94Smrg # $xdir was prepended to $pic_object above. 738297ee6427Smrg non_pic_object=$pic_object 7383213fdd94Smrg func_append non_pic_objects " $non_pic_object" 7384213fdd94Smrg fi 7385213fdd94Smrg else 7386213fdd94Smrg # Only an error if not doing a dry-run. 7387213fdd94Smrg if $opt_dry_run; then 7388213fdd94Smrg # Extract subdirectory from the argument. 7389213fdd94Smrg func_dirname "$arg" "/" "" 739097ee6427Smrg xdir=$func_dirname_result 7391213fdd94Smrg 7392213fdd94Smrg func_lo2o "$arg" 7393213fdd94Smrg pic_object=$xdir$objdir/$func_lo2o_result 7394213fdd94Smrg non_pic_object=$xdir$func_lo2o_result 7395213fdd94Smrg func_append libobjs " $pic_object" 7396213fdd94Smrg func_append non_pic_objects " $non_pic_object" 7397213fdd94Smrg else 739897ee6427Smrg func_fatal_error "'$arg' is not a valid libtool object" 7399213fdd94Smrg fi 7400213fdd94Smrg fi 7401213fdd94Smrg ;; 7402213fdd94Smrg 7403213fdd94Smrg *.$libext) 7404213fdd94Smrg # An archive. 7405213fdd94Smrg func_append deplibs " $arg" 7406213fdd94Smrg func_append old_deplibs " $arg" 7407213fdd94Smrg continue 7408213fdd94Smrg ;; 7409213fdd94Smrg 7410213fdd94Smrg *.la) 7411213fdd94Smrg # A libtool-controlled library. 7412213fdd94Smrg 7413213fdd94Smrg func_resolve_sysroot "$arg" 741497ee6427Smrg if test dlfiles = "$prev"; then 7415213fdd94Smrg # This library was specified with -dlopen. 7416213fdd94Smrg func_append dlfiles " $func_resolve_sysroot_result" 7417213fdd94Smrg prev= 741897ee6427Smrg elif test dlprefiles = "$prev"; then 7419213fdd94Smrg # The library was specified with -dlpreopen. 7420213fdd94Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7421213fdd94Smrg prev= 7422213fdd94Smrg else 7423213fdd94Smrg func_append deplibs " $func_resolve_sysroot_result" 7424213fdd94Smrg fi 7425213fdd94Smrg continue 7426213fdd94Smrg ;; 7427213fdd94Smrg 7428213fdd94Smrg # Some other compiler argument. 7429213fdd94Smrg *) 7430213fdd94Smrg # Unknown arguments in both finalize_command and compile_command need 7431213fdd94Smrg # to be aesthetically quoted because they are evaled later. 7432213fdd94Smrg func_quote_for_eval "$arg" 743397ee6427Smrg arg=$func_quote_for_eval_result 7434213fdd94Smrg ;; 7435213fdd94Smrg esac # arg 7436213fdd94Smrg 7437213fdd94Smrg # Now actually substitute the argument into the commands. 7438213fdd94Smrg if test -n "$arg"; then 7439213fdd94Smrg func_append compile_command " $arg" 7440213fdd94Smrg func_append finalize_command " $arg" 7441213fdd94Smrg fi 7442213fdd94Smrg done # argument parsing loop 7443213fdd94Smrg 7444213fdd94Smrg test -n "$prev" && \ 744597ee6427Smrg func_fatal_help "the '$prevarg' option requires an argument" 7446213fdd94Smrg 744797ee6427Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7448213fdd94Smrg eval arg=\"$export_dynamic_flag_spec\" 7449213fdd94Smrg func_append compile_command " $arg" 7450213fdd94Smrg func_append finalize_command " $arg" 7451213fdd94Smrg fi 7452213fdd94Smrg 7453213fdd94Smrg oldlibs= 7454213fdd94Smrg # calculate the name of the file, without its directory 7455213fdd94Smrg func_basename "$output" 745697ee6427Smrg outputname=$func_basename_result 745797ee6427Smrg libobjs_save=$libobjs 7458213fdd94Smrg 7459213fdd94Smrg if test -n "$shlibpath_var"; then 7460213fdd94Smrg # get the directories listed in $shlibpath_var 746197ee6427Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7462213fdd94Smrg else 7463213fdd94Smrg shlib_search_path= 7464213fdd94Smrg fi 7465213fdd94Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7466213fdd94Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7467213fdd94Smrg 746897ee6427Smrg # Definition is injected by LT_CONFIG during libtool generation. 746997ee6427Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 747097ee6427Smrg 7471213fdd94Smrg func_dirname "$output" "/" "" 747297ee6427Smrg output_objdir=$func_dirname_result$objdir 7473213fdd94Smrg func_to_tool_file "$output_objdir/" 7474213fdd94Smrg tool_output_objdir=$func_to_tool_file_result 7475213fdd94Smrg # Create the object directory. 7476213fdd94Smrg func_mkdir_p "$output_objdir" 7477213fdd94Smrg 7478213fdd94Smrg # Determine the type of output 7479213fdd94Smrg case $output in 7480213fdd94Smrg "") 7481213fdd94Smrg func_fatal_help "you must specify an output file" 7482213fdd94Smrg ;; 7483213fdd94Smrg *.$libext) linkmode=oldlib ;; 7484213fdd94Smrg *.lo | *.$objext) linkmode=obj ;; 7485213fdd94Smrg *.la) linkmode=lib ;; 7486213fdd94Smrg *) linkmode=prog ;; # Anything else should be a program. 7487213fdd94Smrg esac 7488213fdd94Smrg 7489213fdd94Smrg specialdeplibs= 7490213fdd94Smrg 7491213fdd94Smrg libs= 7492213fdd94Smrg # Find all interdependent deplibs by searching for libraries 7493213fdd94Smrg # that are linked more than once (e.g. -la -lb -la) 7494213fdd94Smrg for deplib in $deplibs; do 749597ee6427Smrg if $opt_preserve_dup_deps; then 7496213fdd94Smrg case "$libs " in 7497213fdd94Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7498213fdd94Smrg esac 7499213fdd94Smrg fi 7500213fdd94Smrg func_append libs " $deplib" 7501213fdd94Smrg done 7502213fdd94Smrg 750397ee6427Smrg if test lib = "$linkmode"; then 7504213fdd94Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7505213fdd94Smrg 7506213fdd94Smrg # Compute libraries that are listed more than once in $predeps 7507213fdd94Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7508213fdd94Smrg # not to be eliminated). 7509213fdd94Smrg pre_post_deps= 7510213fdd94Smrg if $opt_duplicate_compiler_generated_deps; then 7511213fdd94Smrg for pre_post_dep in $predeps $postdeps; do 7512213fdd94Smrg case "$pre_post_deps " in 7513213fdd94Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7514213fdd94Smrg esac 7515213fdd94Smrg func_append pre_post_deps " $pre_post_dep" 7516213fdd94Smrg done 7517213fdd94Smrg fi 7518213fdd94Smrg pre_post_deps= 7519213fdd94Smrg fi 7520213fdd94Smrg 7521213fdd94Smrg deplibs= 7522213fdd94Smrg newdependency_libs= 7523213fdd94Smrg newlib_search_path= 7524213fdd94Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7525213fdd94Smrg notinst_deplibs= # not-installed libtool libraries 7526213fdd94Smrg notinst_path= # paths that contain not-installed libtool libraries 7527213fdd94Smrg 7528213fdd94Smrg case $linkmode in 7529213fdd94Smrg lib) 7530213fdd94Smrg passes="conv dlpreopen link" 7531213fdd94Smrg for file in $dlfiles $dlprefiles; do 7532213fdd94Smrg case $file in 7533213fdd94Smrg *.la) ;; 7534213fdd94Smrg *) 753597ee6427Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7536213fdd94Smrg ;; 7537213fdd94Smrg esac 7538213fdd94Smrg done 7539213fdd94Smrg ;; 7540213fdd94Smrg prog) 7541213fdd94Smrg compile_deplibs= 7542213fdd94Smrg finalize_deplibs= 754397ee6427Smrg alldeplibs=false 7544213fdd94Smrg newdlfiles= 7545213fdd94Smrg newdlprefiles= 7546213fdd94Smrg passes="conv scan dlopen dlpreopen link" 7547213fdd94Smrg ;; 7548213fdd94Smrg *) passes="conv" 7549213fdd94Smrg ;; 7550213fdd94Smrg esac 7551213fdd94Smrg 7552213fdd94Smrg for pass in $passes; do 7553213fdd94Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7554213fdd94Smrg # so that -L comes before libs that need it for instance... 755597ee6427Smrg if test lib,link = "$linkmode,$pass"; then 7556213fdd94Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7557213fdd94Smrg ## order, and fix it there properly 7558213fdd94Smrg tmp_deplibs= 7559213fdd94Smrg for deplib in $deplibs; do 7560213fdd94Smrg tmp_deplibs="$deplib $tmp_deplibs" 7561213fdd94Smrg done 756297ee6427Smrg deplibs=$tmp_deplibs 7563213fdd94Smrg fi 7564213fdd94Smrg 756597ee6427Smrg if test lib,link = "$linkmode,$pass" || 756697ee6427Smrg test prog,scan = "$linkmode,$pass"; then 756797ee6427Smrg libs=$deplibs 7568213fdd94Smrg deplibs= 7569213fdd94Smrg fi 757097ee6427Smrg if test prog = "$linkmode"; then 7571213fdd94Smrg case $pass in 757297ee6427Smrg dlopen) libs=$dlfiles ;; 757397ee6427Smrg dlpreopen) libs=$dlprefiles ;; 7574d94624a0Smrg link) 7575d94624a0Smrg libs="$deplibs %DEPLIBS%" 7576d94624a0Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 7577d94624a0Smrg ;; 7578213fdd94Smrg esac 7579213fdd94Smrg fi 758097ee6427Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7581213fdd94Smrg # Collect and forward deplibs of preopened libtool libs 7582213fdd94Smrg for lib in $dlprefiles; do 7583213fdd94Smrg # Ignore non-libtool-libs 7584213fdd94Smrg dependency_libs= 7585213fdd94Smrg func_resolve_sysroot "$lib" 7586213fdd94Smrg case $lib in 7587213fdd94Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7588213fdd94Smrg esac 7589213fdd94Smrg 7590213fdd94Smrg # Collect preopened libtool deplibs, except any this library 7591213fdd94Smrg # has declared as weak libs 7592213fdd94Smrg for deplib in $dependency_libs; do 7593213fdd94Smrg func_basename "$deplib" 7594213fdd94Smrg deplib_base=$func_basename_result 7595213fdd94Smrg case " $weak_libs " in 7596213fdd94Smrg *" $deplib_base "*) ;; 7597213fdd94Smrg *) func_append deplibs " $deplib" ;; 7598213fdd94Smrg esac 7599213fdd94Smrg done 7600213fdd94Smrg done 760197ee6427Smrg libs=$dlprefiles 7602213fdd94Smrg fi 760397ee6427Smrg if test dlopen = "$pass"; then 7604213fdd94Smrg # Collect dlpreopened libraries 760597ee6427Smrg save_deplibs=$deplibs 7606213fdd94Smrg deplibs= 7607213fdd94Smrg fi 7608213fdd94Smrg 7609213fdd94Smrg for deplib in $libs; do 7610213fdd94Smrg lib= 761197ee6427Smrg found=false 7612213fdd94Smrg case $deplib in 7613213fdd94Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7614213fdd94Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 761597ee6427Smrg if test prog,link = "$linkmode,$pass"; then 7616213fdd94Smrg compile_deplibs="$deplib $compile_deplibs" 7617213fdd94Smrg finalize_deplibs="$deplib $finalize_deplibs" 7618213fdd94Smrg else 7619213fdd94Smrg func_append compiler_flags " $deplib" 762097ee6427Smrg if test lib = "$linkmode"; then 7621213fdd94Smrg case "$new_inherited_linker_flags " in 7622213fdd94Smrg *" $deplib "*) ;; 7623213fdd94Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7624213fdd94Smrg esac 7625213fdd94Smrg fi 7626213fdd94Smrg fi 7627213fdd94Smrg continue 7628213fdd94Smrg ;; 7629213fdd94Smrg -l*) 763097ee6427Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 763197ee6427Smrg func_warning "'-l' is ignored for archives/objects" 7632213fdd94Smrg continue 7633213fdd94Smrg fi 7634213fdd94Smrg func_stripname '-l' '' "$deplib" 7635213fdd94Smrg name=$func_stripname_result 763697ee6427Smrg if test lib = "$linkmode"; then 7637213fdd94Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7638213fdd94Smrg else 7639213fdd94Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7640213fdd94Smrg fi 7641213fdd94Smrg for searchdir in $searchdirs; do 7642213fdd94Smrg for search_ext in .la $std_shrext .so .a; do 7643213fdd94Smrg # Search the libtool library 764497ee6427Smrg lib=$searchdir/lib$name$search_ext 7645213fdd94Smrg if test -f "$lib"; then 764697ee6427Smrg if test .la = "$search_ext"; then 764797ee6427Smrg found=: 7648213fdd94Smrg else 764997ee6427Smrg found=false 7650213fdd94Smrg fi 7651213fdd94Smrg break 2 7652213fdd94Smrg fi 7653213fdd94Smrg done 7654213fdd94Smrg done 765597ee6427Smrg if $found; then 765697ee6427Smrg # deplib is a libtool library 7657213fdd94Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7658213fdd94Smrg # We need to do some special things here, and not later. 765997ee6427Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7660213fdd94Smrg case " $predeps $postdeps " in 7661213fdd94Smrg *" $deplib "*) 7662213fdd94Smrg if func_lalib_p "$lib"; then 7663213fdd94Smrg library_names= 7664213fdd94Smrg old_library= 7665213fdd94Smrg func_source "$lib" 7666213fdd94Smrg for l in $old_library $library_names; do 766797ee6427Smrg ll=$l 7668213fdd94Smrg done 766997ee6427Smrg if test "X$ll" = "X$old_library"; then # only static version available 767097ee6427Smrg found=false 7671213fdd94Smrg func_dirname "$lib" "" "." 767297ee6427Smrg ladir=$func_dirname_result 7673213fdd94Smrg lib=$ladir/$old_library 767497ee6427Smrg if test prog,link = "$linkmode,$pass"; then 7675213fdd94Smrg compile_deplibs="$deplib $compile_deplibs" 7676213fdd94Smrg finalize_deplibs="$deplib $finalize_deplibs" 7677213fdd94Smrg else 7678213fdd94Smrg deplibs="$deplib $deplibs" 767997ee6427Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7680213fdd94Smrg fi 7681213fdd94Smrg continue 7682213fdd94Smrg fi 7683213fdd94Smrg fi 7684213fdd94Smrg ;; 7685213fdd94Smrg *) ;; 7686213fdd94Smrg esac 7687213fdd94Smrg fi 768897ee6427Smrg else 768997ee6427Smrg # deplib doesn't seem to be a libtool library 769097ee6427Smrg if test prog,link = "$linkmode,$pass"; then 769197ee6427Smrg compile_deplibs="$deplib $compile_deplibs" 769297ee6427Smrg finalize_deplibs="$deplib $finalize_deplibs" 769397ee6427Smrg else 769497ee6427Smrg deplibs="$deplib $deplibs" 769597ee6427Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769697ee6427Smrg fi 769797ee6427Smrg continue 7698213fdd94Smrg fi 7699213fdd94Smrg ;; # -l 7700213fdd94Smrg *.ltframework) 770197ee6427Smrg if test prog,link = "$linkmode,$pass"; then 7702213fdd94Smrg compile_deplibs="$deplib $compile_deplibs" 7703213fdd94Smrg finalize_deplibs="$deplib $finalize_deplibs" 7704213fdd94Smrg else 7705213fdd94Smrg deplibs="$deplib $deplibs" 770697ee6427Smrg if test lib = "$linkmode"; then 7707213fdd94Smrg case "$new_inherited_linker_flags " in 7708213fdd94Smrg *" $deplib "*) ;; 7709213fdd94Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7710213fdd94Smrg esac 7711213fdd94Smrg fi 7712213fdd94Smrg fi 7713213fdd94Smrg continue 7714213fdd94Smrg ;; 7715213fdd94Smrg -L*) 7716213fdd94Smrg case $linkmode in 7717213fdd94Smrg lib) 7718213fdd94Smrg deplibs="$deplib $deplibs" 771997ee6427Smrg test conv = "$pass" && continue 7720213fdd94Smrg newdependency_libs="$deplib $newdependency_libs" 7721213fdd94Smrg func_stripname '-L' '' "$deplib" 7722213fdd94Smrg func_resolve_sysroot "$func_stripname_result" 7723213fdd94Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7724213fdd94Smrg ;; 7725213fdd94Smrg prog) 772697ee6427Smrg if test conv = "$pass"; then 7727213fdd94Smrg deplibs="$deplib $deplibs" 7728213fdd94Smrg continue 7729213fdd94Smrg fi 773097ee6427Smrg if test scan = "$pass"; then 7731213fdd94Smrg deplibs="$deplib $deplibs" 7732213fdd94Smrg else 7733213fdd94Smrg compile_deplibs="$deplib $compile_deplibs" 7734213fdd94Smrg finalize_deplibs="$deplib $finalize_deplibs" 7735213fdd94Smrg fi 7736213fdd94Smrg func_stripname '-L' '' "$deplib" 7737213fdd94Smrg func_resolve_sysroot "$func_stripname_result" 7738213fdd94Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7739213fdd94Smrg ;; 7740213fdd94Smrg *) 774197ee6427Smrg func_warning "'-L' is ignored for archives/objects" 7742213fdd94Smrg ;; 7743213fdd94Smrg esac # linkmode 7744213fdd94Smrg continue 7745213fdd94Smrg ;; # -L 7746213fdd94Smrg -R*) 774797ee6427Smrg if test link = "$pass"; then 7748213fdd94Smrg func_stripname '-R' '' "$deplib" 7749213fdd94Smrg func_resolve_sysroot "$func_stripname_result" 7750213fdd94Smrg dir=$func_resolve_sysroot_result 7751213fdd94Smrg # Make sure the xrpath contains only unique directories. 7752213fdd94Smrg case "$xrpath " in 7753213fdd94Smrg *" $dir "*) ;; 7754213fdd94Smrg *) func_append xrpath " $dir" ;; 7755213fdd94Smrg esac 7756213fdd94Smrg fi 7757213fdd94Smrg deplibs="$deplib $deplibs" 7758213fdd94Smrg continue 7759213fdd94Smrg ;; 7760213fdd94Smrg *.la) 7761213fdd94Smrg func_resolve_sysroot "$deplib" 7762213fdd94Smrg lib=$func_resolve_sysroot_result 7763213fdd94Smrg ;; 7764213fdd94Smrg *.$libext) 776597ee6427Smrg if test conv = "$pass"; then 7766213fdd94Smrg deplibs="$deplib $deplibs" 7767213fdd94Smrg continue 7768213fdd94Smrg fi 7769213fdd94Smrg case $linkmode in 7770213fdd94Smrg lib) 7771213fdd94Smrg # Linking convenience modules into shared libraries is allowed, 7772213fdd94Smrg # but linking other static libraries is non-portable. 7773213fdd94Smrg case " $dlpreconveniencelibs " in 7774213fdd94Smrg *" $deplib "*) ;; 7775213fdd94Smrg *) 777697ee6427Smrg valid_a_lib=false 7777213fdd94Smrg case $deplibs_check_method in 7778213fdd94Smrg match_pattern*) 7779213fdd94Smrg set dummy $deplibs_check_method; shift 7780213fdd94Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7781213fdd94Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7782213fdd94Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 778397ee6427Smrg valid_a_lib=: 7784213fdd94Smrg fi 7785213fdd94Smrg ;; 7786213fdd94Smrg pass_all) 778797ee6427Smrg valid_a_lib=: 7788213fdd94Smrg ;; 7789213fdd94Smrg esac 779097ee6427Smrg if $valid_a_lib; then 779197ee6427Smrg echo 779297ee6427Smrg $ECHO "*** Warning: Linking the shared library $output against the" 779397ee6427Smrg $ECHO "*** static library $deplib is not portable!" 779497ee6427Smrg deplibs="$deplib $deplibs" 779597ee6427Smrg else 7796213fdd94Smrg echo 7797213fdd94Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7798213fdd94Smrg echo "*** I have the capability to make that library automatically link in when" 7799213fdd94Smrg echo "*** you link to this library. But I can only do this if you have a" 7800213fdd94Smrg echo "*** shared version of the library, which you do not appear to have" 7801213fdd94Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 7802213fdd94Smrg echo "*** that it is just a static archive that I should not use here." 7803213fdd94Smrg fi 7804213fdd94Smrg ;; 7805213fdd94Smrg esac 7806213fdd94Smrg continue 7807213fdd94Smrg ;; 7808213fdd94Smrg prog) 780997ee6427Smrg if test link != "$pass"; then 7810213fdd94Smrg deplibs="$deplib $deplibs" 7811213fdd94Smrg else 7812213fdd94Smrg compile_deplibs="$deplib $compile_deplibs" 7813213fdd94Smrg finalize_deplibs="$deplib $finalize_deplibs" 7814213fdd94Smrg fi 7815213fdd94Smrg continue 7816213fdd94Smrg ;; 7817213fdd94Smrg esac # linkmode 7818213fdd94Smrg ;; # *.$libext 7819213fdd94Smrg *.lo | *.$objext) 782097ee6427Smrg if test conv = "$pass"; then 7821213fdd94Smrg deplibs="$deplib $deplibs" 782297ee6427Smrg elif test prog = "$linkmode"; then 782397ee6427Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7824213fdd94Smrg # If there is no dlopen support or we're linking statically, 7825213fdd94Smrg # we need to preload. 7826213fdd94Smrg func_append newdlprefiles " $deplib" 7827213fdd94Smrg compile_deplibs="$deplib $compile_deplibs" 7828213fdd94Smrg finalize_deplibs="$deplib $finalize_deplibs" 7829213fdd94Smrg else 7830213fdd94Smrg func_append newdlfiles " $deplib" 7831213fdd94Smrg fi 7832213fdd94Smrg fi 7833213fdd94Smrg continue 7834213fdd94Smrg ;; 7835213fdd94Smrg %DEPLIBS%) 783697ee6427Smrg alldeplibs=: 7837213fdd94Smrg continue 7838213fdd94Smrg ;; 7839213fdd94Smrg esac # case $deplib 7840213fdd94Smrg 784197ee6427Smrg $found || test -f "$lib" \ 784297ee6427Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7843213fdd94Smrg 7844213fdd94Smrg # Check to see that this really is a libtool archive. 7845213fdd94Smrg func_lalib_unsafe_p "$lib" \ 784697ee6427Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 7847213fdd94Smrg 7848213fdd94Smrg func_dirname "$lib" "" "." 784997ee6427Smrg ladir=$func_dirname_result 7850213fdd94Smrg 7851213fdd94Smrg dlname= 7852213fdd94Smrg dlopen= 7853213fdd94Smrg dlpreopen= 7854213fdd94Smrg libdir= 7855213fdd94Smrg library_names= 7856213fdd94Smrg old_library= 7857213fdd94Smrg inherited_linker_flags= 7858213fdd94Smrg # If the library was installed with an old release of libtool, 7859213fdd94Smrg # it will not redefine variables installed, or shouldnotlink 7860213fdd94Smrg installed=yes 7861213fdd94Smrg shouldnotlink=no 7862213fdd94Smrg avoidtemprpath= 7863213fdd94Smrg 7864213fdd94Smrg 7865213fdd94Smrg # Read the .la file 7866213fdd94Smrg func_source "$lib" 7867213fdd94Smrg 7868213fdd94Smrg # Convert "-framework foo" to "foo.ltframework" 7869213fdd94Smrg if test -n "$inherited_linker_flags"; then 7870213fdd94Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7871213fdd94Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7872213fdd94Smrg case " $new_inherited_linker_flags " in 7873213fdd94Smrg *" $tmp_inherited_linker_flag "*) ;; 7874213fdd94Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7875213fdd94Smrg esac 7876213fdd94Smrg done 7877213fdd94Smrg fi 7878213fdd94Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787997ee6427Smrg if test lib,link = "$linkmode,$pass" || 788097ee6427Smrg test prog,scan = "$linkmode,$pass" || 788197ee6427Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7882213fdd94Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7883213fdd94Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7884213fdd94Smrg fi 7885213fdd94Smrg 788697ee6427Smrg if test conv = "$pass"; then 7887213fdd94Smrg # Only check for convenience libraries 7888213fdd94Smrg deplibs="$lib $deplibs" 7889213fdd94Smrg if test -z "$libdir"; then 7890213fdd94Smrg if test -z "$old_library"; then 789197ee6427Smrg func_fatal_error "cannot find name of link library for '$lib'" 7892213fdd94Smrg fi 7893213fdd94Smrg # It is a libtool convenience library, so add in its objects. 7894213fdd94Smrg func_append convenience " $ladir/$objdir/$old_library" 7895213fdd94Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7896d94624a0Smrg tmp_libs= 7897d94624a0Smrg for deplib in $dependency_libs; do 7898d94624a0Smrg deplibs="$deplib $deplibs" 7899d94624a0Smrg if $opt_preserve_dup_deps; then 7900d94624a0Smrg case "$tmp_libs " in 7901d94624a0Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7902d94624a0Smrg esac 7903d94624a0Smrg fi 7904d94624a0Smrg func_append tmp_libs " $deplib" 7905d94624a0Smrg done 790697ee6427Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 790797ee6427Smrg func_fatal_error "'$lib' is not a convenience library" 7908213fdd94Smrg fi 7909213fdd94Smrg continue 7910213fdd94Smrg fi # $pass = conv 7911213fdd94Smrg 7912213fdd94Smrg 7913213fdd94Smrg # Get the name of the library we link against. 7914213fdd94Smrg linklib= 7915213fdd94Smrg if test -n "$old_library" && 791697ee6427Smrg { test yes = "$prefer_static_libs" || 791797ee6427Smrg test built,no = "$prefer_static_libs,$installed"; }; then 7918213fdd94Smrg linklib=$old_library 7919213fdd94Smrg else 7920213fdd94Smrg for l in $old_library $library_names; do 792197ee6427Smrg linklib=$l 7922213fdd94Smrg done 7923213fdd94Smrg fi 7924213fdd94Smrg if test -z "$linklib"; then 792597ee6427Smrg func_fatal_error "cannot find name of link library for '$lib'" 7926213fdd94Smrg fi 7927213fdd94Smrg 7928213fdd94Smrg # This library was specified with -dlopen. 792997ee6427Smrg if test dlopen = "$pass"; then 793097ee6427Smrg test -z "$libdir" \ 793197ee6427Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7932213fdd94Smrg if test -z "$dlname" || 793397ee6427Smrg test yes != "$dlopen_support" || 793497ee6427Smrg test no = "$build_libtool_libs" 793597ee6427Smrg then 7936213fdd94Smrg # If there is no dlname, no dlopen support or we're linking 7937213fdd94Smrg # statically, we need to preload. We also need to preload any 7938213fdd94Smrg # dependent libraries so libltdl's deplib preloader doesn't 7939213fdd94Smrg # bomb out in the load deplibs phase. 7940213fdd94Smrg func_append dlprefiles " $lib $dependency_libs" 7941213fdd94Smrg else 7942213fdd94Smrg func_append newdlfiles " $lib" 7943213fdd94Smrg fi 7944213fdd94Smrg continue 7945213fdd94Smrg fi # $pass = dlopen 7946213fdd94Smrg 7947213fdd94Smrg # We need an absolute path. 7948213fdd94Smrg case $ladir in 794997ee6427Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7950213fdd94Smrg *) 7951213fdd94Smrg abs_ladir=`cd "$ladir" && pwd` 7952213fdd94Smrg if test -z "$abs_ladir"; then 795397ee6427Smrg func_warning "cannot determine absolute directory name of '$ladir'" 7954213fdd94Smrg func_warning "passing it literally to the linker, although it might fail" 795597ee6427Smrg abs_ladir=$ladir 7956213fdd94Smrg fi 7957213fdd94Smrg ;; 7958213fdd94Smrg esac 7959213fdd94Smrg func_basename "$lib" 796097ee6427Smrg laname=$func_basename_result 7961213fdd94Smrg 7962213fdd94Smrg # Find the relevant object directory and library name. 796397ee6427Smrg if test yes = "$installed"; then 7964213fdd94Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 796597ee6427Smrg func_warning "library '$lib' was moved." 796697ee6427Smrg dir=$ladir 796797ee6427Smrg absdir=$abs_ladir 796897ee6427Smrg libdir=$abs_ladir 7969213fdd94Smrg else 797097ee6427Smrg dir=$lt_sysroot$libdir 797197ee6427Smrg absdir=$lt_sysroot$libdir 7972213fdd94Smrg fi 797397ee6427Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7974213fdd94Smrg else 7975213fdd94Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797697ee6427Smrg dir=$ladir 797797ee6427Smrg absdir=$abs_ladir 7978213fdd94Smrg # Remove this search path later 7979213fdd94Smrg func_append notinst_path " $abs_ladir" 7980213fdd94Smrg else 798197ee6427Smrg dir=$ladir/$objdir 798297ee6427Smrg absdir=$abs_ladir/$objdir 7983213fdd94Smrg # Remove this search path later 7984213fdd94Smrg func_append notinst_path " $abs_ladir" 7985213fdd94Smrg fi 7986213fdd94Smrg fi # $installed = yes 7987213fdd94Smrg func_stripname 'lib' '.la' "$laname" 7988213fdd94Smrg name=$func_stripname_result 7989213fdd94Smrg 7990213fdd94Smrg # This library was specified with -dlpreopen. 799197ee6427Smrg if test dlpreopen = "$pass"; then 799297ee6427Smrg if test -z "$libdir" && test prog = "$linkmode"; then 799397ee6427Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7994213fdd94Smrg fi 799597ee6427Smrg case $host in 7996213fdd94Smrg # special handling for platforms with PE-DLLs. 7997213fdd94Smrg *cygwin* | *mingw* | *cegcc* ) 7998213fdd94Smrg # Linker will automatically link against shared library if both 7999213fdd94Smrg # static and shared are present. Therefore, ensure we extract 8000213fdd94Smrg # symbols from the import library if a shared library is present 8001213fdd94Smrg # (otherwise, the dlopen module name will be incorrect). We do 8002213fdd94Smrg # this by putting the import library name into $newdlprefiles. 8003213fdd94Smrg # We recover the dlopen module name by 'saving' the la file 8004213fdd94Smrg # name in a special purpose variable, and (later) extracting the 8005213fdd94Smrg # dlname from the la file. 8006213fdd94Smrg if test -n "$dlname"; then 8007213fdd94Smrg func_tr_sh "$dir/$linklib" 8008213fdd94Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8009213fdd94Smrg func_append newdlprefiles " $dir/$linklib" 8010213fdd94Smrg else 8011213fdd94Smrg func_append newdlprefiles " $dir/$old_library" 8012213fdd94Smrg # Keep a list of preopened convenience libraries to check 8013213fdd94Smrg # that they are being used correctly in the link pass. 8014213fdd94Smrg test -z "$libdir" && \ 8015213fdd94Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8016213fdd94Smrg fi 8017213fdd94Smrg ;; 8018213fdd94Smrg * ) 8019213fdd94Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8020213fdd94Smrg # are required to link). 8021213fdd94Smrg if test -n "$old_library"; then 8022213fdd94Smrg func_append newdlprefiles " $dir/$old_library" 8023213fdd94Smrg # Keep a list of preopened convenience libraries to check 8024213fdd94Smrg # that they are being used correctly in the link pass. 8025213fdd94Smrg test -z "$libdir" && \ 8026213fdd94Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8027213fdd94Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8028213fdd94Smrg elif test -n "$dlname"; then 8029213fdd94Smrg func_append newdlprefiles " $dir/$dlname" 8030213fdd94Smrg else 8031213fdd94Smrg func_append newdlprefiles " $dir/$linklib" 8032213fdd94Smrg fi 8033213fdd94Smrg ;; 8034213fdd94Smrg esac 8035213fdd94Smrg fi # $pass = dlpreopen 8036213fdd94Smrg 8037213fdd94Smrg if test -z "$libdir"; then 8038213fdd94Smrg # Link the convenience library 803997ee6427Smrg if test lib = "$linkmode"; then 8040213fdd94Smrg deplibs="$dir/$old_library $deplibs" 804197ee6427Smrg elif test prog,link = "$linkmode,$pass"; then 8042213fdd94Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8043213fdd94Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8044213fdd94Smrg else 8045213fdd94Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8046213fdd94Smrg fi 8047213fdd94Smrg continue 8048213fdd94Smrg fi 8049213fdd94Smrg 8050213fdd94Smrg 805197ee6427Smrg if test prog = "$linkmode" && test link != "$pass"; then 8052213fdd94Smrg func_append newlib_search_path " $ladir" 8053213fdd94Smrg deplibs="$lib $deplibs" 8054213fdd94Smrg 805597ee6427Smrg linkalldeplibs=false 805697ee6427Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805797ee6427Smrg test no = "$build_libtool_libs"; then 805897ee6427Smrg linkalldeplibs=: 8059213fdd94Smrg fi 8060213fdd94Smrg 8061213fdd94Smrg tmp_libs= 8062213fdd94Smrg for deplib in $dependency_libs; do 8063213fdd94Smrg case $deplib in 8064213fdd94Smrg -L*) func_stripname '-L' '' "$deplib" 8065213fdd94Smrg func_resolve_sysroot "$func_stripname_result" 8066213fdd94Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8067213fdd94Smrg ;; 8068213fdd94Smrg esac 8069213fdd94Smrg # Need to link against all dependency_libs? 807097ee6427Smrg if $linkalldeplibs; then 8071213fdd94Smrg deplibs="$deplib $deplibs" 8072213fdd94Smrg else 8073213fdd94Smrg # Need to hardcode shared library paths 8074213fdd94Smrg # or/and link against static libraries 8075213fdd94Smrg newdependency_libs="$deplib $newdependency_libs" 8076213fdd94Smrg fi 807797ee6427Smrg if $opt_preserve_dup_deps; then 8078213fdd94Smrg case "$tmp_libs " in 8079213fdd94Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8080213fdd94Smrg esac 8081213fdd94Smrg fi 8082213fdd94Smrg func_append tmp_libs " $deplib" 8083213fdd94Smrg done # for deplib 8084213fdd94Smrg continue 8085213fdd94Smrg fi # $linkmode = prog... 8086213fdd94Smrg 808797ee6427Smrg if test prog,link = "$linkmode,$pass"; then 8088213fdd94Smrg if test -n "$library_names" && 808997ee6427Smrg { { test no = "$prefer_static_libs" || 809097ee6427Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8091213fdd94Smrg test -z "$old_library"; }; then 8092213fdd94Smrg # We need to hardcode the library path 809397ee6427Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8094213fdd94Smrg # Make sure the rpath contains only unique directories. 809597ee6427Smrg case $temp_rpath: in 8096213fdd94Smrg *"$absdir:"*) ;; 8097213fdd94Smrg *) func_append temp_rpath "$absdir:" ;; 8098213fdd94Smrg esac 8099213fdd94Smrg fi 8100213fdd94Smrg 8101213fdd94Smrg # Hardcode the library path. 8102213fdd94Smrg # Skip directories that are in the system default run-time 8103213fdd94Smrg # search path. 8104213fdd94Smrg case " $sys_lib_dlsearch_path " in 8105213fdd94Smrg *" $absdir "*) ;; 8106213fdd94Smrg *) 8107213fdd94Smrg case "$compile_rpath " in 8108213fdd94Smrg *" $absdir "*) ;; 8109213fdd94Smrg *) func_append compile_rpath " $absdir" ;; 8110213fdd94Smrg esac 8111213fdd94Smrg ;; 8112213fdd94Smrg esac 8113213fdd94Smrg case " $sys_lib_dlsearch_path " in 8114213fdd94Smrg *" $libdir "*) ;; 8115213fdd94Smrg *) 8116213fdd94Smrg case "$finalize_rpath " in 8117213fdd94Smrg *" $libdir "*) ;; 8118213fdd94Smrg *) func_append finalize_rpath " $libdir" ;; 8119213fdd94Smrg esac 8120213fdd94Smrg ;; 8121213fdd94Smrg esac 8122213fdd94Smrg fi # $linkmode,$pass = prog,link... 8123213fdd94Smrg 812497ee6427Smrg if $alldeplibs && 812597ee6427Smrg { test pass_all = "$deplibs_check_method" || 812697ee6427Smrg { test yes = "$build_libtool_libs" && 8127213fdd94Smrg test -n "$library_names"; }; }; then 8128213fdd94Smrg # We only need to search for static libraries 8129213fdd94Smrg continue 8130213fdd94Smrg fi 8131213fdd94Smrg fi 8132213fdd94Smrg 8133213fdd94Smrg link_static=no # Whether the deplib will be linked statically 8134213fdd94Smrg use_static_libs=$prefer_static_libs 813597ee6427Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8136213fdd94Smrg use_static_libs=no 8137213fdd94Smrg fi 8138213fdd94Smrg if test -n "$library_names" && 813997ee6427Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8140213fdd94Smrg case $host in 814197ee6427Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8142213fdd94Smrg # No point in relinking DLLs because paths are not encoded 8143213fdd94Smrg func_append notinst_deplibs " $lib" 8144213fdd94Smrg need_relink=no 8145213fdd94Smrg ;; 8146213fdd94Smrg *) 814797ee6427Smrg if test no = "$installed"; then 8148213fdd94Smrg func_append notinst_deplibs " $lib" 8149213fdd94Smrg need_relink=yes 8150213fdd94Smrg fi 8151213fdd94Smrg ;; 8152213fdd94Smrg esac 8153213fdd94Smrg # This is a shared library 8154213fdd94Smrg 8155213fdd94Smrg # Warn about portability, can't link against -module's on some 8156213fdd94Smrg # systems (darwin). Don't bleat about dlopened modules though! 815797ee6427Smrg dlopenmodule= 8158213fdd94Smrg for dlpremoduletest in $dlprefiles; do 8159213fdd94Smrg if test "X$dlpremoduletest" = "X$lib"; then 816097ee6427Smrg dlopenmodule=$dlpremoduletest 8161213fdd94Smrg break 8162213fdd94Smrg fi 8163213fdd94Smrg done 816497ee6427Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8165213fdd94Smrg echo 816697ee6427Smrg if test prog = "$linkmode"; then 8167213fdd94Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8168213fdd94Smrg else 8169213fdd94Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8170213fdd94Smrg fi 8171213fdd94Smrg $ECHO "*** $linklib is not portable!" 8172213fdd94Smrg fi 817397ee6427Smrg if test lib = "$linkmode" && 817497ee6427Smrg test yes = "$hardcode_into_libs"; then 8175213fdd94Smrg # Hardcode the library path. 8176213fdd94Smrg # Skip directories that are in the system default run-time 8177213fdd94Smrg # search path. 8178213fdd94Smrg case " $sys_lib_dlsearch_path " in 8179213fdd94Smrg *" $absdir "*) ;; 8180213fdd94Smrg *) 8181213fdd94Smrg case "$compile_rpath " in 8182213fdd94Smrg *" $absdir "*) ;; 8183213fdd94Smrg *) func_append compile_rpath " $absdir" ;; 8184213fdd94Smrg esac 8185213fdd94Smrg ;; 8186213fdd94Smrg esac 8187213fdd94Smrg case " $sys_lib_dlsearch_path " in 8188213fdd94Smrg *" $libdir "*) ;; 8189213fdd94Smrg *) 8190213fdd94Smrg case "$finalize_rpath " in 8191213fdd94Smrg *" $libdir "*) ;; 8192213fdd94Smrg *) func_append finalize_rpath " $libdir" ;; 8193213fdd94Smrg esac 8194213fdd94Smrg ;; 8195213fdd94Smrg esac 8196213fdd94Smrg fi 8197213fdd94Smrg 8198213fdd94Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8199213fdd94Smrg # figure out the soname 8200213fdd94Smrg set dummy $library_names 8201213fdd94Smrg shift 820297ee6427Smrg realname=$1 8203213fdd94Smrg shift 8204213fdd94Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8205213fdd94Smrg # use dlname if we got it. it's perfectly good, no? 8206213fdd94Smrg if test -n "$dlname"; then 820797ee6427Smrg soname=$dlname 8208213fdd94Smrg elif test -n "$soname_spec"; then 8209213fdd94Smrg # bleh windows 8210213fdd94Smrg case $host in 821197ee6427Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8212213fdd94Smrg func_arith $current - $age 8213213fdd94Smrg major=$func_arith_result 821497ee6427Smrg versuffix=-$major 8215213fdd94Smrg ;; 8216213fdd94Smrg esac 8217213fdd94Smrg eval soname=\"$soname_spec\" 8218213fdd94Smrg else 821997ee6427Smrg soname=$realname 8220213fdd94Smrg fi 8221213fdd94Smrg 8222213fdd94Smrg # Make a new name for the extract_expsyms_cmds to use 822397ee6427Smrg soroot=$soname 8224213fdd94Smrg func_basename "$soroot" 822597ee6427Smrg soname=$func_basename_result 8226213fdd94Smrg func_stripname 'lib' '.dll' "$soname" 8227213fdd94Smrg newlib=libimp-$func_stripname_result.a 8228213fdd94Smrg 8229213fdd94Smrg # If the library has no export list, then create one now 8230213fdd94Smrg if test -f "$output_objdir/$soname-def"; then : 8231213fdd94Smrg else 823297ee6427Smrg func_verbose "extracting exported symbol list from '$soname'" 8233213fdd94Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8234213fdd94Smrg fi 8235213fdd94Smrg 8236213fdd94Smrg # Create $newlib 8237213fdd94Smrg if test -f "$output_objdir/$newlib"; then :; else 823897ee6427Smrg func_verbose "generating import library for '$soname'" 8239213fdd94Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8240213fdd94Smrg fi 8241213fdd94Smrg # make sure the library variables are pointing to the new library 8242213fdd94Smrg dir=$output_objdir 8243213fdd94Smrg linklib=$newlib 8244213fdd94Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8245213fdd94Smrg 824697ee6427Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8247213fdd94Smrg add_shlibpath= 8248213fdd94Smrg add_dir= 8249213fdd94Smrg add= 8250213fdd94Smrg lib_linked=yes 8251213fdd94Smrg case $hardcode_action in 8252213fdd94Smrg immediate | unsupported) 825397ee6427Smrg if test no = "$hardcode_direct"; then 825497ee6427Smrg add=$dir/$linklib 8255213fdd94Smrg case $host in 825697ee6427Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825797ee6427Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8258213fdd94Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825997ee6427Smrg *-*-unixware7*) add_dir=-L$dir ;; 8260213fdd94Smrg *-*-darwin* ) 826197ee6427Smrg # if the lib is a (non-dlopened) module then we cannot 8262213fdd94Smrg # link against it, someone is ignoring the earlier warnings 8263213fdd94Smrg if /usr/bin/file -L $add 2> /dev/null | 826497ee6427Smrg $GREP ": [^:]* bundle" >/dev/null; then 8265213fdd94Smrg if test "X$dlopenmodule" != "X$lib"; then 8266213fdd94Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826797ee6427Smrg if test -z "$old_library"; then 8268213fdd94Smrg echo 8269213fdd94Smrg echo "*** And there doesn't seem to be a static archive available" 8270213fdd94Smrg echo "*** The link will probably fail, sorry" 8271213fdd94Smrg else 827297ee6427Smrg add=$dir/$old_library 8273213fdd94Smrg fi 8274213fdd94Smrg elif test -n "$old_library"; then 827597ee6427Smrg add=$dir/$old_library 8276213fdd94Smrg fi 8277213fdd94Smrg fi 8278213fdd94Smrg esac 827997ee6427Smrg elif test no = "$hardcode_minus_L"; then 8280213fdd94Smrg case $host in 828197ee6427Smrg *-*-sunos*) add_shlibpath=$dir ;; 8282213fdd94Smrg esac 828397ee6427Smrg add_dir=-L$dir 828497ee6427Smrg add=-l$name 828597ee6427Smrg elif test no = "$hardcode_shlibpath_var"; then 828697ee6427Smrg add_shlibpath=$dir 828797ee6427Smrg add=-l$name 8288213fdd94Smrg else 8289213fdd94Smrg lib_linked=no 8290213fdd94Smrg fi 8291213fdd94Smrg ;; 8292213fdd94Smrg relink) 829397ee6427Smrg if test yes = "$hardcode_direct" && 829497ee6427Smrg test no = "$hardcode_direct_absolute"; then 829597ee6427Smrg add=$dir/$linklib 829697ee6427Smrg elif test yes = "$hardcode_minus_L"; then 829797ee6427Smrg add_dir=-L$absdir 8298213fdd94Smrg # Try looking first in the location we're being installed to. 8299213fdd94Smrg if test -n "$inst_prefix_dir"; then 8300213fdd94Smrg case $libdir in 8301213fdd94Smrg [\\/]*) 8302213fdd94Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8303213fdd94Smrg ;; 8304213fdd94Smrg esac 8305213fdd94Smrg fi 830697ee6427Smrg add=-l$name 830797ee6427Smrg elif test yes = "$hardcode_shlibpath_var"; then 830897ee6427Smrg add_shlibpath=$dir 830997ee6427Smrg add=-l$name 8310213fdd94Smrg else 8311213fdd94Smrg lib_linked=no 8312213fdd94Smrg fi 8313213fdd94Smrg ;; 8314213fdd94Smrg *) lib_linked=no ;; 8315213fdd94Smrg esac 8316213fdd94Smrg 831797ee6427Smrg if test yes != "$lib_linked"; then 8318213fdd94Smrg func_fatal_configuration "unsupported hardcode properties" 8319213fdd94Smrg fi 8320213fdd94Smrg 8321213fdd94Smrg if test -n "$add_shlibpath"; then 8322213fdd94Smrg case :$compile_shlibpath: in 8323213fdd94Smrg *":$add_shlibpath:"*) ;; 8324213fdd94Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8325213fdd94Smrg esac 8326213fdd94Smrg fi 832797ee6427Smrg if test prog = "$linkmode"; then 8328213fdd94Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8329213fdd94Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8330213fdd94Smrg else 8331213fdd94Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8332213fdd94Smrg test -n "$add" && deplibs="$add $deplibs" 833397ee6427Smrg if test yes != "$hardcode_direct" && 833497ee6427Smrg test yes != "$hardcode_minus_L" && 833597ee6427Smrg test yes = "$hardcode_shlibpath_var"; then 8336213fdd94Smrg case :$finalize_shlibpath: in 8337213fdd94Smrg *":$libdir:"*) ;; 8338213fdd94Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8339213fdd94Smrg esac 8340213fdd94Smrg fi 8341213fdd94Smrg fi 8342213fdd94Smrg fi 8343213fdd94Smrg 834497ee6427Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8345213fdd94Smrg add_shlibpath= 8346213fdd94Smrg add_dir= 8347213fdd94Smrg add= 8348213fdd94Smrg # Finalize command for both is simple: just hardcode it. 834997ee6427Smrg if test yes = "$hardcode_direct" && 835097ee6427Smrg test no = "$hardcode_direct_absolute"; then 835197ee6427Smrg add=$libdir/$linklib 835297ee6427Smrg elif test yes = "$hardcode_minus_L"; then 835397ee6427Smrg add_dir=-L$libdir 835497ee6427Smrg add=-l$name 835597ee6427Smrg elif test yes = "$hardcode_shlibpath_var"; then 8356213fdd94Smrg case :$finalize_shlibpath: in 8357213fdd94Smrg *":$libdir:"*) ;; 8358213fdd94Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8359213fdd94Smrg esac 836097ee6427Smrg add=-l$name 836197ee6427Smrg elif test yes = "$hardcode_automatic"; then 8362213fdd94Smrg if test -n "$inst_prefix_dir" && 836397ee6427Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 836497ee6427Smrg add=$inst_prefix_dir$libdir/$linklib 8365213fdd94Smrg else 836697ee6427Smrg add=$libdir/$linklib 8367213fdd94Smrg fi 8368213fdd94Smrg else 8369213fdd94Smrg # We cannot seem to hardcode it, guess we'll fake it. 837097ee6427Smrg add_dir=-L$libdir 8371213fdd94Smrg # Try looking first in the location we're being installed to. 8372213fdd94Smrg if test -n "$inst_prefix_dir"; then 8373213fdd94Smrg case $libdir in 8374213fdd94Smrg [\\/]*) 8375213fdd94Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8376213fdd94Smrg ;; 8377213fdd94Smrg esac 8378213fdd94Smrg fi 837997ee6427Smrg add=-l$name 8380213fdd94Smrg fi 8381213fdd94Smrg 838297ee6427Smrg if test prog = "$linkmode"; then 8383213fdd94Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8384213fdd94Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8385213fdd94Smrg else 8386213fdd94Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8387213fdd94Smrg test -n "$add" && deplibs="$add $deplibs" 8388213fdd94Smrg fi 8389213fdd94Smrg fi 839097ee6427Smrg elif test prog = "$linkmode"; then 8391213fdd94Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8392213fdd94Smrg # is not unsupported. This is valid on all known static and 8393213fdd94Smrg # shared platforms. 839497ee6427Smrg if test unsupported != "$hardcode_direct"; then 839597ee6427Smrg test -n "$old_library" && linklib=$old_library 8396213fdd94Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8397213fdd94Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8398213fdd94Smrg else 8399213fdd94Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8400213fdd94Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8401213fdd94Smrg fi 840297ee6427Smrg elif test yes = "$build_libtool_libs"; then 8403213fdd94Smrg # Not a shared library 840497ee6427Smrg if test pass_all != "$deplibs_check_method"; then 8405213fdd94Smrg # We're trying link a shared library against a static one 8406213fdd94Smrg # but the system doesn't support it. 8407213fdd94Smrg 8408213fdd94Smrg # Just print a warning and add the library to dependency_libs so 8409213fdd94Smrg # that the program can be linked against the static library. 8410213fdd94Smrg echo 841197ee6427Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8412213fdd94Smrg echo "*** I have the capability to make that library automatically link in when" 8413213fdd94Smrg echo "*** you link to this library. But I can only do this if you have a" 8414213fdd94Smrg echo "*** shared version of the library, which you do not appear to have." 841597ee6427Smrg if test yes = "$module"; then 8416213fdd94Smrg echo "*** But as you try to build a module library, libtool will still create " 8417213fdd94Smrg echo "*** a static module, that should work as long as the dlopening application" 8418213fdd94Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8419213fdd94Smrg if test -z "$global_symbol_pipe"; then 8420213fdd94Smrg echo 8421213fdd94Smrg echo "*** However, this would only work if libtool was able to extract symbol" 842297ee6427Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8423213fdd94Smrg echo "*** not find such a program. So, this module is probably useless." 842497ee6427Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8425213fdd94Smrg fi 842697ee6427Smrg if test no = "$build_old_libs"; then 8427213fdd94Smrg build_libtool_libs=module 8428213fdd94Smrg build_old_libs=yes 8429213fdd94Smrg else 8430213fdd94Smrg build_libtool_libs=no 8431213fdd94Smrg fi 8432213fdd94Smrg fi 8433213fdd94Smrg else 8434213fdd94Smrg deplibs="$dir/$old_library $deplibs" 8435213fdd94Smrg link_static=yes 8436213fdd94Smrg fi 8437213fdd94Smrg fi # link shared/static library? 8438213fdd94Smrg 843997ee6427Smrg if test lib = "$linkmode"; then 8440213fdd94Smrg if test -n "$dependency_libs" && 844197ee6427Smrg { test yes != "$hardcode_into_libs" || 844297ee6427Smrg test yes = "$build_old_libs" || 844397ee6427Smrg test yes = "$link_static"; }; then 8444213fdd94Smrg # Extract -R from dependency_libs 8445213fdd94Smrg temp_deplibs= 8446213fdd94Smrg for libdir in $dependency_libs; do 8447213fdd94Smrg case $libdir in 8448213fdd94Smrg -R*) func_stripname '-R' '' "$libdir" 8449213fdd94Smrg temp_xrpath=$func_stripname_result 8450213fdd94Smrg case " $xrpath " in 8451213fdd94Smrg *" $temp_xrpath "*) ;; 8452213fdd94Smrg *) func_append xrpath " $temp_xrpath";; 8453213fdd94Smrg esac;; 8454213fdd94Smrg *) func_append temp_deplibs " $libdir";; 8455213fdd94Smrg esac 8456213fdd94Smrg done 845797ee6427Smrg dependency_libs=$temp_deplibs 8458213fdd94Smrg fi 8459213fdd94Smrg 8460213fdd94Smrg func_append newlib_search_path " $absdir" 8461213fdd94Smrg # Link against this library 846297ee6427Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8463213fdd94Smrg # ... and its dependency_libs 8464213fdd94Smrg tmp_libs= 8465213fdd94Smrg for deplib in $dependency_libs; do 8466213fdd94Smrg newdependency_libs="$deplib $newdependency_libs" 8467213fdd94Smrg case $deplib in 8468213fdd94Smrg -L*) func_stripname '-L' '' "$deplib" 8469213fdd94Smrg func_resolve_sysroot "$func_stripname_result";; 8470213fdd94Smrg *) func_resolve_sysroot "$deplib" ;; 8471213fdd94Smrg esac 847297ee6427Smrg if $opt_preserve_dup_deps; then 8473213fdd94Smrg case "$tmp_libs " in 8474213fdd94Smrg *" $func_resolve_sysroot_result "*) 8475213fdd94Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8476213fdd94Smrg esac 8477213fdd94Smrg fi 8478213fdd94Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8479213fdd94Smrg done 8480213fdd94Smrg 848197ee6427Smrg if test no != "$link_all_deplibs"; then 8482213fdd94Smrg # Add the search paths of all dependency libraries 8483213fdd94Smrg for deplib in $dependency_libs; do 8484213fdd94Smrg path= 8485213fdd94Smrg case $deplib in 848697ee6427Smrg -L*) path=$deplib ;; 8487213fdd94Smrg *.la) 8488213fdd94Smrg func_resolve_sysroot "$deplib" 8489213fdd94Smrg deplib=$func_resolve_sysroot_result 8490213fdd94Smrg func_dirname "$deplib" "" "." 8491213fdd94Smrg dir=$func_dirname_result 8492213fdd94Smrg # We need an absolute path. 8493213fdd94Smrg case $dir in 849497ee6427Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8495213fdd94Smrg *) 8496213fdd94Smrg absdir=`cd "$dir" && pwd` 8497213fdd94Smrg if test -z "$absdir"; then 849897ee6427Smrg func_warning "cannot determine absolute directory name of '$dir'" 849997ee6427Smrg absdir=$dir 8500213fdd94Smrg fi 8501213fdd94Smrg ;; 8502213fdd94Smrg esac 8503213fdd94Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8504213fdd94Smrg case $host in 8505213fdd94Smrg *-*-darwin*) 8506213fdd94Smrg depdepl= 850797ee6427Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850897ee6427Smrg if test -n "$deplibrary_names"; then 850997ee6427Smrg for tmp in $deplibrary_names; do 8510213fdd94Smrg depdepl=$tmp 8511213fdd94Smrg done 851297ee6427Smrg if test -f "$absdir/$objdir/$depdepl"; then 851397ee6427Smrg depdepl=$absdir/$objdir/$depdepl 851497ee6427Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8515213fdd94Smrg if test -z "$darwin_install_name"; then 851697ee6427Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8517213fdd94Smrg fi 851897ee6427Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851997ee6427Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8520213fdd94Smrg path= 8521213fdd94Smrg fi 8522213fdd94Smrg fi 8523213fdd94Smrg ;; 8524213fdd94Smrg *) 852597ee6427Smrg path=-L$absdir/$objdir 8526213fdd94Smrg ;; 8527213fdd94Smrg esac 8528213fdd94Smrg else 852997ee6427Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8530213fdd94Smrg test -z "$libdir" && \ 853197ee6427Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8532213fdd94Smrg test "$absdir" != "$libdir" && \ 853397ee6427Smrg func_warning "'$deplib' seems to be moved" 8534213fdd94Smrg 853597ee6427Smrg path=-L$absdir 8536213fdd94Smrg fi 8537213fdd94Smrg ;; 8538213fdd94Smrg esac 8539213fdd94Smrg case " $deplibs " in 8540213fdd94Smrg *" $path "*) ;; 8541213fdd94Smrg *) deplibs="$path $deplibs" ;; 8542213fdd94Smrg esac 8543213fdd94Smrg done 8544213fdd94Smrg fi # link_all_deplibs != no 8545213fdd94Smrg fi # linkmode = lib 8546213fdd94Smrg done # for deplib in $libs 854797ee6427Smrg if test link = "$pass"; then 854897ee6427Smrg if test prog = "$linkmode"; then 8549213fdd94Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8550213fdd94Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8551213fdd94Smrg else 8552213fdd94Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8553213fdd94Smrg fi 8554213fdd94Smrg fi 855597ee6427Smrg dependency_libs=$newdependency_libs 855697ee6427Smrg if test dlpreopen = "$pass"; then 8557213fdd94Smrg # Link the dlpreopened libraries before other libraries 8558213fdd94Smrg for deplib in $save_deplibs; do 8559213fdd94Smrg deplibs="$deplib $deplibs" 8560213fdd94Smrg done 8561213fdd94Smrg fi 856297ee6427Smrg if test dlopen != "$pass"; then 856397ee6427Smrg test conv = "$pass" || { 8564213fdd94Smrg # Make sure lib_search_path contains only unique directories. 8565213fdd94Smrg lib_search_path= 8566213fdd94Smrg for dir in $newlib_search_path; do 8567213fdd94Smrg case "$lib_search_path " in 8568213fdd94Smrg *" $dir "*) ;; 8569213fdd94Smrg *) func_append lib_search_path " $dir" ;; 8570213fdd94Smrg esac 8571213fdd94Smrg done 8572213fdd94Smrg newlib_search_path= 857397ee6427Smrg } 8574213fdd94Smrg 857597ee6427Smrg if test prog,link = "$linkmode,$pass"; then 8576213fdd94Smrg vars="compile_deplibs finalize_deplibs" 857797ee6427Smrg else 857897ee6427Smrg vars=deplibs 8579213fdd94Smrg fi 8580213fdd94Smrg for var in $vars dependency_libs; do 8581213fdd94Smrg # Add libraries to $var in reverse order 8582213fdd94Smrg eval tmp_libs=\"\$$var\" 8583213fdd94Smrg new_libs= 8584213fdd94Smrg for deplib in $tmp_libs; do 8585213fdd94Smrg # FIXME: Pedantically, this is the right thing to do, so 8586213fdd94Smrg # that some nasty dependency loop isn't accidentally 8587213fdd94Smrg # broken: 8588213fdd94Smrg #new_libs="$deplib $new_libs" 8589213fdd94Smrg # Pragmatically, this seems to cause very few problems in 8590213fdd94Smrg # practice: 8591213fdd94Smrg case $deplib in 8592213fdd94Smrg -L*) new_libs="$deplib $new_libs" ;; 8593213fdd94Smrg -R*) ;; 8594213fdd94Smrg *) 8595213fdd94Smrg # And here is the reason: when a library appears more 8596213fdd94Smrg # than once as an explicit dependence of a library, or 8597213fdd94Smrg # is implicitly linked in more than once by the 8598213fdd94Smrg # compiler, it is considered special, and multiple 8599213fdd94Smrg # occurrences thereof are not removed. Compare this 8600213fdd94Smrg # with having the same library being listed as a 8601213fdd94Smrg # dependency of multiple other libraries: in this case, 8602213fdd94Smrg # we know (pedantically, we assume) the library does not 8603213fdd94Smrg # need to be listed more than once, so we keep only the 8604213fdd94Smrg # last copy. This is not always right, but it is rare 8605213fdd94Smrg # enough that we require users that really mean to play 8606213fdd94Smrg # such unportable linking tricks to link the library 8607213fdd94Smrg # using -Wl,-lname, so that libtool does not consider it 8608213fdd94Smrg # for duplicate removal. 8609213fdd94Smrg case " $specialdeplibs " in 8610213fdd94Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8611213fdd94Smrg *) 8612213fdd94Smrg case " $new_libs " in 8613213fdd94Smrg *" $deplib "*) ;; 8614213fdd94Smrg *) new_libs="$deplib $new_libs" ;; 8615213fdd94Smrg esac 8616213fdd94Smrg ;; 8617213fdd94Smrg esac 8618213fdd94Smrg ;; 8619213fdd94Smrg esac 8620213fdd94Smrg done 8621213fdd94Smrg tmp_libs= 8622213fdd94Smrg for deplib in $new_libs; do 8623213fdd94Smrg case $deplib in 8624213fdd94Smrg -L*) 8625213fdd94Smrg case " $tmp_libs " in 8626213fdd94Smrg *" $deplib "*) ;; 8627213fdd94Smrg *) func_append tmp_libs " $deplib" ;; 8628213fdd94Smrg esac 8629213fdd94Smrg ;; 8630213fdd94Smrg *) func_append tmp_libs " $deplib" ;; 8631213fdd94Smrg esac 8632213fdd94Smrg done 8633213fdd94Smrg eval $var=\"$tmp_libs\" 8634213fdd94Smrg done # for var 8635213fdd94Smrg fi 863697ee6427Smrg 863797ee6427Smrg # Add Sun CC postdeps if required: 863897ee6427Smrg test CXX = "$tagname" && { 863997ee6427Smrg case $host_os in 864097ee6427Smrg linux*) 864197ee6427Smrg case `$CC -V 2>&1 | sed 5q` in 864297ee6427Smrg *Sun\ C*) # Sun C++ 5.9 864397ee6427Smrg func_suncc_cstd_abi 864497ee6427Smrg 864597ee6427Smrg if test no != "$suncc_use_cstd_abi"; then 864697ee6427Smrg func_append postdeps ' -library=Cstd -library=Crun' 864797ee6427Smrg fi 864897ee6427Smrg ;; 864997ee6427Smrg esac 865097ee6427Smrg ;; 865197ee6427Smrg 865297ee6427Smrg solaris*) 865397ee6427Smrg func_cc_basename "$CC" 865497ee6427Smrg case $func_cc_basename_result in 865597ee6427Smrg CC* | sunCC*) 865697ee6427Smrg func_suncc_cstd_abi 865797ee6427Smrg 865897ee6427Smrg if test no != "$suncc_use_cstd_abi"; then 865997ee6427Smrg func_append postdeps ' -library=Cstd -library=Crun' 866097ee6427Smrg fi 866197ee6427Smrg ;; 866297ee6427Smrg esac 866397ee6427Smrg ;; 866497ee6427Smrg esac 866597ee6427Smrg } 866697ee6427Smrg 8667213fdd94Smrg # Last step: remove runtime libs from dependency_libs 8668213fdd94Smrg # (they stay in deplibs) 8669213fdd94Smrg tmp_libs= 867097ee6427Smrg for i in $dependency_libs; do 8671213fdd94Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8672213fdd94Smrg *" $i "*) 867397ee6427Smrg i= 8674213fdd94Smrg ;; 8675213fdd94Smrg esac 867697ee6427Smrg if test -n "$i"; then 8677213fdd94Smrg func_append tmp_libs " $i" 8678213fdd94Smrg fi 8679213fdd94Smrg done 8680213fdd94Smrg dependency_libs=$tmp_libs 8681213fdd94Smrg done # for pass 868297ee6427Smrg if test prog = "$linkmode"; then 868397ee6427Smrg dlfiles=$newdlfiles 8684213fdd94Smrg fi 868597ee6427Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868697ee6427Smrg dlprefiles=$newdlprefiles 8687213fdd94Smrg fi 8688213fdd94Smrg 8689213fdd94Smrg case $linkmode in 8690213fdd94Smrg oldlib) 869197ee6427Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 869297ee6427Smrg func_warning "'-dlopen' is ignored for archives" 8693213fdd94Smrg fi 8694213fdd94Smrg 8695213fdd94Smrg case " $deplibs" in 8696213fdd94Smrg *\ -l* | *\ -L*) 869797ee6427Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8698213fdd94Smrg esac 8699213fdd94Smrg 8700213fdd94Smrg test -n "$rpath" && \ 870197ee6427Smrg func_warning "'-rpath' is ignored for archives" 8702213fdd94Smrg 8703213fdd94Smrg test -n "$xrpath" && \ 870497ee6427Smrg func_warning "'-R' is ignored for archives" 8705213fdd94Smrg 8706213fdd94Smrg test -n "$vinfo" && \ 870797ee6427Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8708213fdd94Smrg 8709213fdd94Smrg test -n "$release" && \ 871097ee6427Smrg func_warning "'-release' is ignored for archives" 8711213fdd94Smrg 8712213fdd94Smrg test -n "$export_symbols$export_symbols_regex" && \ 871397ee6427Smrg func_warning "'-export-symbols' is ignored for archives" 8714213fdd94Smrg 8715213fdd94Smrg # Now set the variables for building old libraries. 8716213fdd94Smrg build_libtool_libs=no 871797ee6427Smrg oldlibs=$output 8718213fdd94Smrg func_append objs "$old_deplibs" 8719213fdd94Smrg ;; 8720213fdd94Smrg 8721213fdd94Smrg lib) 872297ee6427Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 8723213fdd94Smrg case $outputname in 8724213fdd94Smrg lib*) 8725213fdd94Smrg func_stripname 'lib' '.la' "$outputname" 8726213fdd94Smrg name=$func_stripname_result 8727213fdd94Smrg eval shared_ext=\"$shrext_cmds\" 8728213fdd94Smrg eval libname=\"$libname_spec\" 8729213fdd94Smrg ;; 8730213fdd94Smrg *) 873197ee6427Smrg test no = "$module" \ 873297ee6427Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8733213fdd94Smrg 873497ee6427Smrg if test no != "$need_lib_prefix"; then 8735213fdd94Smrg # Add the "lib" prefix for modules if required 8736213fdd94Smrg func_stripname '' '.la' "$outputname" 8737213fdd94Smrg name=$func_stripname_result 8738213fdd94Smrg eval shared_ext=\"$shrext_cmds\" 8739213fdd94Smrg eval libname=\"$libname_spec\" 8740213fdd94Smrg else 8741213fdd94Smrg func_stripname '' '.la' "$outputname" 8742213fdd94Smrg libname=$func_stripname_result 8743213fdd94Smrg fi 8744213fdd94Smrg ;; 8745213fdd94Smrg esac 8746213fdd94Smrg 8747213fdd94Smrg if test -n "$objs"; then 874897ee6427Smrg if test pass_all != "$deplibs_check_method"; then 874997ee6427Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8750213fdd94Smrg else 8751213fdd94Smrg echo 8752213fdd94Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8753213fdd94Smrg $ECHO "*** objects $objs is not portable!" 8754213fdd94Smrg func_append libobjs " $objs" 8755213fdd94Smrg fi 8756213fdd94Smrg fi 8757213fdd94Smrg 875897ee6427Smrg test no = "$dlself" \ 875997ee6427Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8760213fdd94Smrg 8761213fdd94Smrg set dummy $rpath 8762213fdd94Smrg shift 876397ee6427Smrg test 1 -lt "$#" \ 876497ee6427Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8765213fdd94Smrg 876697ee6427Smrg install_libdir=$1 8767213fdd94Smrg 8768213fdd94Smrg oldlibs= 8769213fdd94Smrg if test -z "$rpath"; then 877097ee6427Smrg if test yes = "$build_libtool_libs"; then 8771213fdd94Smrg # Building a libtool convenience library. 877297ee6427Smrg # Some compilers have problems with a '.al' extension so 8773213fdd94Smrg # convenience libraries should have the same extension an 8774213fdd94Smrg # archive normally would. 8775213fdd94Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8776213fdd94Smrg build_libtool_libs=convenience 8777213fdd94Smrg build_old_libs=yes 8778213fdd94Smrg fi 8779213fdd94Smrg 8780213fdd94Smrg test -n "$vinfo" && \ 878197ee6427Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8782213fdd94Smrg 8783213fdd94Smrg test -n "$release" && \ 878497ee6427Smrg func_warning "'-release' is ignored for convenience libraries" 8785213fdd94Smrg else 8786213fdd94Smrg 8787213fdd94Smrg # Parse the version information argument. 878897ee6427Smrg save_ifs=$IFS; IFS=: 8789213fdd94Smrg set dummy $vinfo 0 0 0 8790213fdd94Smrg shift 879197ee6427Smrg IFS=$save_ifs 8792213fdd94Smrg 8793213fdd94Smrg test -n "$7" && \ 879497ee6427Smrg func_fatal_help "too many parameters to '-version-info'" 8795213fdd94Smrg 8796213fdd94Smrg # convert absolute version numbers to libtool ages 8797213fdd94Smrg # this retains compatibility with .la files and attempts 8798213fdd94Smrg # to make the code below a bit more comprehensible 8799213fdd94Smrg 8800213fdd94Smrg case $vinfo_number in 8801213fdd94Smrg yes) 880297ee6427Smrg number_major=$1 880397ee6427Smrg number_minor=$2 880497ee6427Smrg number_revision=$3 8805213fdd94Smrg # 8806213fdd94Smrg # There are really only two kinds -- those that 8807213fdd94Smrg # use the current revision as the major version 8808213fdd94Smrg # and those that subtract age and use age as 8809213fdd94Smrg # a minor version. But, then there is irix 881097ee6427Smrg # that has an extra 1 added just for fun 8811213fdd94Smrg # 8812213fdd94Smrg case $version_type in 8813213fdd94Smrg # correct linux to gnu/linux during the next big refactor 881497ee6427Smrg darwin|freebsd-elf|linux|osf|windows|none) 8815213fdd94Smrg func_arith $number_major + $number_minor 8816213fdd94Smrg current=$func_arith_result 881797ee6427Smrg age=$number_minor 881897ee6427Smrg revision=$number_revision 8819213fdd94Smrg ;; 882097ee6427Smrg freebsd-aout|qnx|sunos) 882197ee6427Smrg current=$number_major 882297ee6427Smrg revision=$number_minor 882397ee6427Smrg age=0 8824213fdd94Smrg ;; 8825213fdd94Smrg irix|nonstopux) 8826213fdd94Smrg func_arith $number_major + $number_minor 8827213fdd94Smrg current=$func_arith_result 882897ee6427Smrg age=$number_minor 882997ee6427Smrg revision=$number_minor 8830213fdd94Smrg lt_irix_increment=no 8831213fdd94Smrg ;; 8832d94624a0Smrg *) 8833d94624a0Smrg func_fatal_configuration "$modename: unknown library version type '$version_type'" 8834d94624a0Smrg ;; 8835213fdd94Smrg esac 8836213fdd94Smrg ;; 8837213fdd94Smrg no) 883897ee6427Smrg current=$1 883997ee6427Smrg revision=$2 884097ee6427Smrg age=$3 8841213fdd94Smrg ;; 8842213fdd94Smrg esac 8843213fdd94Smrg 8844213fdd94Smrg # Check that each of the things are valid numbers. 8845213fdd94Smrg case $current in 8846213fdd94Smrg 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]) ;; 8847213fdd94Smrg *) 884897ee6427Smrg func_error "CURRENT '$current' must be a nonnegative integer" 884997ee6427Smrg func_fatal_error "'$vinfo' is not valid version information" 8850213fdd94Smrg ;; 8851213fdd94Smrg esac 8852213fdd94Smrg 8853213fdd94Smrg case $revision in 8854213fdd94Smrg 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]) ;; 8855213fdd94Smrg *) 885697ee6427Smrg func_error "REVISION '$revision' must be a nonnegative integer" 885797ee6427Smrg func_fatal_error "'$vinfo' is not valid version information" 8858213fdd94Smrg ;; 8859213fdd94Smrg esac 8860213fdd94Smrg 8861213fdd94Smrg case $age in 8862213fdd94Smrg 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]) ;; 8863213fdd94Smrg *) 886497ee6427Smrg func_error "AGE '$age' must be a nonnegative integer" 886597ee6427Smrg func_fatal_error "'$vinfo' is not valid version information" 8866213fdd94Smrg ;; 8867213fdd94Smrg esac 8868213fdd94Smrg 8869213fdd94Smrg if test "$age" -gt "$current"; then 887097ee6427Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 887197ee6427Smrg func_fatal_error "'$vinfo' is not valid version information" 8872213fdd94Smrg fi 8873213fdd94Smrg 8874213fdd94Smrg # Calculate the version variables. 8875213fdd94Smrg major= 8876213fdd94Smrg versuffix= 8877213fdd94Smrg verstring= 8878213fdd94Smrg case $version_type in 8879213fdd94Smrg none) ;; 8880213fdd94Smrg 8881213fdd94Smrg darwin) 8882213fdd94Smrg # Like Linux, but with the current version available in 8883213fdd94Smrg # verstring for coding it into the library header 8884213fdd94Smrg func_arith $current - $age 8885213fdd94Smrg major=.$func_arith_result 888697ee6427Smrg versuffix=$major.$age.$revision 8887213fdd94Smrg # Darwin ld doesn't like 0 for these options... 8888213fdd94Smrg func_arith $current + 1 8889213fdd94Smrg minor_current=$func_arith_result 889097ee6427Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8891213fdd94Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889297ee6427Smrg # On Darwin other compilers 889397ee6427Smrg case $CC in 889497ee6427Smrg nagfor*) 889597ee6427Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 889697ee6427Smrg ;; 889797ee6427Smrg *) 889897ee6427Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889997ee6427Smrg ;; 890097ee6427Smrg esac 8901213fdd94Smrg ;; 8902213fdd94Smrg 8903213fdd94Smrg freebsd-aout) 890497ee6427Smrg major=.$current 890597ee6427Smrg versuffix=.$current.$revision 8906213fdd94Smrg ;; 8907213fdd94Smrg 8908213fdd94Smrg freebsd-elf) 890997ee6427Smrg func_arith $current - $age 891097ee6427Smrg major=.$func_arith_result 891197ee6427Smrg versuffix=$major.$age.$revision 8912213fdd94Smrg ;; 8913213fdd94Smrg 8914213fdd94Smrg irix | nonstopux) 891597ee6427Smrg if test no = "$lt_irix_increment"; then 8916213fdd94Smrg func_arith $current - $age 8917213fdd94Smrg else 8918213fdd94Smrg func_arith $current - $age + 1 8919213fdd94Smrg fi 8920213fdd94Smrg major=$func_arith_result 8921213fdd94Smrg 8922213fdd94Smrg case $version_type in 8923213fdd94Smrg nonstopux) verstring_prefix=nonstopux ;; 8924213fdd94Smrg *) verstring_prefix=sgi ;; 8925213fdd94Smrg esac 892697ee6427Smrg verstring=$verstring_prefix$major.$revision 8927213fdd94Smrg 8928213fdd94Smrg # Add in all the interfaces that we are compatible with. 8929213fdd94Smrg loop=$revision 893097ee6427Smrg while test 0 -ne "$loop"; do 8931213fdd94Smrg func_arith $revision - $loop 8932213fdd94Smrg iface=$func_arith_result 8933213fdd94Smrg func_arith $loop - 1 8934213fdd94Smrg loop=$func_arith_result 893597ee6427Smrg verstring=$verstring_prefix$major.$iface:$verstring 8936213fdd94Smrg done 8937213fdd94Smrg 893897ee6427Smrg # Before this point, $major must not contain '.'. 8939213fdd94Smrg major=.$major 894097ee6427Smrg versuffix=$major.$revision 8941213fdd94Smrg ;; 8942213fdd94Smrg 8943213fdd94Smrg linux) # correct to gnu/linux during the next big refactor 8944213fdd94Smrg func_arith $current - $age 8945213fdd94Smrg major=.$func_arith_result 894697ee6427Smrg versuffix=$major.$age.$revision 8947213fdd94Smrg ;; 8948213fdd94Smrg 8949213fdd94Smrg osf) 8950213fdd94Smrg func_arith $current - $age 8951213fdd94Smrg major=.$func_arith_result 895297ee6427Smrg versuffix=.$current.$age.$revision 895397ee6427Smrg verstring=$current.$age.$revision 8954213fdd94Smrg 8955213fdd94Smrg # Add in all the interfaces that we are compatible with. 8956213fdd94Smrg loop=$age 895797ee6427Smrg while test 0 -ne "$loop"; do 8958213fdd94Smrg func_arith $current - $loop 8959213fdd94Smrg iface=$func_arith_result 8960213fdd94Smrg func_arith $loop - 1 8961213fdd94Smrg loop=$func_arith_result 896297ee6427Smrg verstring=$verstring:$iface.0 8963213fdd94Smrg done 8964213fdd94Smrg 8965213fdd94Smrg # Make executables depend on our current version. 896697ee6427Smrg func_append verstring ":$current.0" 8967213fdd94Smrg ;; 8968213fdd94Smrg 8969213fdd94Smrg qnx) 897097ee6427Smrg major=.$current 897197ee6427Smrg versuffix=.$current 897297ee6427Smrg ;; 897397ee6427Smrg 897497ee6427Smrg sco) 897597ee6427Smrg major=.$current 897697ee6427Smrg versuffix=.$current 8977213fdd94Smrg ;; 8978213fdd94Smrg 8979213fdd94Smrg sunos) 898097ee6427Smrg major=.$current 898197ee6427Smrg versuffix=.$current.$revision 8982213fdd94Smrg ;; 8983213fdd94Smrg 8984213fdd94Smrg windows) 8985213fdd94Smrg # Use '-' rather than '.', since we only want one 898697ee6427Smrg # extension on DOS 8.3 file systems. 8987213fdd94Smrg func_arith $current - $age 8988213fdd94Smrg major=$func_arith_result 898997ee6427Smrg versuffix=-$major 8990213fdd94Smrg ;; 8991213fdd94Smrg 8992213fdd94Smrg *) 899397ee6427Smrg func_fatal_configuration "unknown library version type '$version_type'" 8994213fdd94Smrg ;; 8995213fdd94Smrg esac 8996213fdd94Smrg 8997213fdd94Smrg # Clear the version info if we defaulted, and they specified a release. 8998213fdd94Smrg if test -z "$vinfo" && test -n "$release"; then 8999213fdd94Smrg major= 9000213fdd94Smrg case $version_type in 9001213fdd94Smrg darwin) 9002213fdd94Smrg # we can't check for "0.0" in archive_cmds due to quoting 9003213fdd94Smrg # problems, so we reset it completely 9004213fdd94Smrg verstring= 9005213fdd94Smrg ;; 9006213fdd94Smrg *) 900797ee6427Smrg verstring=0.0 9008213fdd94Smrg ;; 9009213fdd94Smrg esac 901097ee6427Smrg if test no = "$need_version"; then 9011213fdd94Smrg versuffix= 9012213fdd94Smrg else 901397ee6427Smrg versuffix=.0.0 9014213fdd94Smrg fi 9015213fdd94Smrg fi 9016213fdd94Smrg 9017213fdd94Smrg # Remove version info from name if versioning should be avoided 901897ee6427Smrg if test yes,no = "$avoid_version,$need_version"; then 9019213fdd94Smrg major= 9020213fdd94Smrg versuffix= 902197ee6427Smrg verstring= 9022213fdd94Smrg fi 9023213fdd94Smrg 9024213fdd94Smrg # Check to see if the archive will have undefined symbols. 902597ee6427Smrg if test yes = "$allow_undefined"; then 902697ee6427Smrg if test unsupported = "$allow_undefined_flag"; then 902797ee6427Smrg if test yes = "$build_old_libs"; then 902897ee6427Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902997ee6427Smrg build_libtool_libs=no 903097ee6427Smrg else 903197ee6427Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 903297ee6427Smrg fi 9033213fdd94Smrg fi 9034213fdd94Smrg else 9035213fdd94Smrg # Don't allow undefined symbols. 903697ee6427Smrg allow_undefined_flag=$no_undefined_flag 9037213fdd94Smrg fi 9038213fdd94Smrg 9039213fdd94Smrg fi 9040213fdd94Smrg 904197ee6427Smrg func_generate_dlsyms "$libname" "$libname" : 9042213fdd94Smrg func_append libobjs " $symfileobj" 904397ee6427Smrg test " " = "$libobjs" && libobjs= 9044213fdd94Smrg 904597ee6427Smrg if test relink != "$opt_mode"; then 9046213fdd94Smrg # Remove our outputs, but don't remove object files since they 9047213fdd94Smrg # may have been created when compiling PIC objects. 9048213fdd94Smrg removelist= 9049213fdd94Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9050213fdd94Smrg for p in $tempremovelist; do 9051213fdd94Smrg case $p in 9052213fdd94Smrg *.$objext | *.gcno) 9053213fdd94Smrg ;; 905497ee6427Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 905597ee6427Smrg if test -n "$precious_files_regex"; then 9056213fdd94Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9057213fdd94Smrg then 9058213fdd94Smrg continue 9059213fdd94Smrg fi 9060213fdd94Smrg fi 9061213fdd94Smrg func_append removelist " $p" 9062213fdd94Smrg ;; 9063213fdd94Smrg *) ;; 9064213fdd94Smrg esac 9065213fdd94Smrg done 9066213fdd94Smrg test -n "$removelist" && \ 9067213fdd94Smrg func_show_eval "${RM}r \$removelist" 9068213fdd94Smrg fi 9069213fdd94Smrg 9070213fdd94Smrg # Now set the variables for building old libraries. 907197ee6427Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9072213fdd94Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9073213fdd94Smrg 9074213fdd94Smrg # Transform .lo files to .o files. 907597ee6427Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9076213fdd94Smrg fi 9077213fdd94Smrg 9078213fdd94Smrg # Eliminate all temporary directories. 9079213fdd94Smrg #for path in $notinst_path; do 9080213fdd94Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9081213fdd94Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9082213fdd94Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9083213fdd94Smrg #done 9084213fdd94Smrg 9085213fdd94Smrg if test -n "$xrpath"; then 9086213fdd94Smrg # If the user specified any rpath flags, then add them. 9087213fdd94Smrg temp_xrpath= 9088213fdd94Smrg for libdir in $xrpath; do 9089213fdd94Smrg func_replace_sysroot "$libdir" 9090213fdd94Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9091213fdd94Smrg case "$finalize_rpath " in 9092213fdd94Smrg *" $libdir "*) ;; 9093213fdd94Smrg *) func_append finalize_rpath " $libdir" ;; 9094213fdd94Smrg esac 9095213fdd94Smrg done 909697ee6427Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9097213fdd94Smrg dependency_libs="$temp_xrpath $dependency_libs" 9098213fdd94Smrg fi 9099213fdd94Smrg fi 9100213fdd94Smrg 9101213fdd94Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 910297ee6427Smrg old_dlfiles=$dlfiles 9103213fdd94Smrg dlfiles= 9104213fdd94Smrg for lib in $old_dlfiles; do 9105213fdd94Smrg case " $dlprefiles $dlfiles " in 9106213fdd94Smrg *" $lib "*) ;; 9107213fdd94Smrg *) func_append dlfiles " $lib" ;; 9108213fdd94Smrg esac 9109213fdd94Smrg done 9110213fdd94Smrg 9111213fdd94Smrg # Make sure dlprefiles contains only unique files 911297ee6427Smrg old_dlprefiles=$dlprefiles 9113213fdd94Smrg dlprefiles= 9114213fdd94Smrg for lib in $old_dlprefiles; do 9115213fdd94Smrg case "$dlprefiles " in 9116213fdd94Smrg *" $lib "*) ;; 9117213fdd94Smrg *) func_append dlprefiles " $lib" ;; 9118213fdd94Smrg esac 9119213fdd94Smrg done 9120213fdd94Smrg 912197ee6427Smrg if test yes = "$build_libtool_libs"; then 9122213fdd94Smrg if test -n "$rpath"; then 9123213fdd94Smrg case $host in 9124213fdd94Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9125213fdd94Smrg # these systems don't actually have a c library (as such)! 9126213fdd94Smrg ;; 9127213fdd94Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9128213fdd94Smrg # Rhapsody C library is in the System framework 9129213fdd94Smrg func_append deplibs " System.ltframework" 9130213fdd94Smrg ;; 9131213fdd94Smrg *-*-netbsd*) 9132213fdd94Smrg # Don't link with libc until the a.out ld.so is fixed. 9133213fdd94Smrg ;; 9134213fdd94Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9135213fdd94Smrg # Do not include libc due to us having libc/libc_r. 9136213fdd94Smrg ;; 9137213fdd94Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9138213fdd94Smrg # Causes problems with __ctype 9139213fdd94Smrg ;; 9140213fdd94Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9141213fdd94Smrg # Compiler inserts libc in the correct place for threads to work 9142213fdd94Smrg ;; 9143213fdd94Smrg *) 9144213fdd94Smrg # Add libc to deplibs on all other systems if necessary. 914597ee6427Smrg if test yes = "$build_libtool_need_lc"; then 9146213fdd94Smrg func_append deplibs " -lc" 9147213fdd94Smrg fi 9148213fdd94Smrg ;; 9149213fdd94Smrg esac 9150213fdd94Smrg fi 9151213fdd94Smrg 9152213fdd94Smrg # Transform deplibs into only deplibs that can be linked in shared. 9153213fdd94Smrg name_save=$name 9154213fdd94Smrg libname_save=$libname 9155213fdd94Smrg release_save=$release 9156213fdd94Smrg versuffix_save=$versuffix 9157213fdd94Smrg major_save=$major 9158213fdd94Smrg # I'm not sure if I'm treating the release correctly. I think 9159213fdd94Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9160213fdd94Smrg # add it in twice. Is that correct? 916197ee6427Smrg release= 916297ee6427Smrg versuffix= 916397ee6427Smrg major= 9164213fdd94Smrg newdeplibs= 9165213fdd94Smrg droppeddeps=no 9166213fdd94Smrg case $deplibs_check_method in 9167213fdd94Smrg pass_all) 9168213fdd94Smrg # Don't check for shared/static. Everything works. 9169213fdd94Smrg # This might be a little naive. We might want to check 9170213fdd94Smrg # whether the library exists or not. But this is on 9171213fdd94Smrg # osf3 & osf4 and I'm not really sure... Just 9172213fdd94Smrg # implementing what was already the behavior. 9173213fdd94Smrg newdeplibs=$deplibs 9174213fdd94Smrg ;; 9175213fdd94Smrg test_compile) 9176213fdd94Smrg # This code stresses the "libraries are programs" paradigm to its 9177213fdd94Smrg # limits. Maybe even breaks it. We compile a program, linking it 9178213fdd94Smrg # against the deplibs as a proxy for the library. Then we can check 9179213fdd94Smrg # whether they linked in statically or dynamically with ldd. 9180213fdd94Smrg $opt_dry_run || $RM conftest.c 9181213fdd94Smrg cat > conftest.c <<EOF 9182213fdd94Smrg int main() { return 0; } 9183213fdd94SmrgEOF 9184213fdd94Smrg $opt_dry_run || $RM conftest 9185213fdd94Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9186213fdd94Smrg ldd_output=`ldd conftest` 9187213fdd94Smrg for i in $deplibs; do 9188213fdd94Smrg case $i in 9189213fdd94Smrg -l*) 9190213fdd94Smrg func_stripname -l '' "$i" 9191213fdd94Smrg name=$func_stripname_result 919297ee6427Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9193213fdd94Smrg case " $predeps $postdeps " in 9194213fdd94Smrg *" $i "*) 9195213fdd94Smrg func_append newdeplibs " $i" 919697ee6427Smrg i= 9197213fdd94Smrg ;; 9198213fdd94Smrg esac 9199213fdd94Smrg fi 920097ee6427Smrg if test -n "$i"; then 9201213fdd94Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9202213fdd94Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9203213fdd94Smrg set dummy $deplib_matches; shift 9204213fdd94Smrg deplib_match=$1 920597ee6427Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9206213fdd94Smrg func_append newdeplibs " $i" 9207213fdd94Smrg else 9208213fdd94Smrg droppeddeps=yes 9209213fdd94Smrg echo 9210213fdd94Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9211213fdd94Smrg echo "*** I have the capability to make that library automatically link in when" 9212213fdd94Smrg echo "*** you link to this library. But I can only do this if you have a" 9213213fdd94Smrg echo "*** shared version of the library, which I believe you do not have" 9214213fdd94Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9215213fdd94Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9216213fdd94Smrg fi 9217213fdd94Smrg fi 9218213fdd94Smrg ;; 9219213fdd94Smrg *) 9220213fdd94Smrg func_append newdeplibs " $i" 9221213fdd94Smrg ;; 9222213fdd94Smrg esac 9223213fdd94Smrg done 9224213fdd94Smrg else 9225213fdd94Smrg # Error occurred in the first compile. Let's try to salvage 9226213fdd94Smrg # the situation: Compile a separate program for each library. 9227213fdd94Smrg for i in $deplibs; do 9228213fdd94Smrg case $i in 9229213fdd94Smrg -l*) 9230213fdd94Smrg func_stripname -l '' "$i" 9231213fdd94Smrg name=$func_stripname_result 9232213fdd94Smrg $opt_dry_run || $RM conftest 9233213fdd94Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9234213fdd94Smrg ldd_output=`ldd conftest` 923597ee6427Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9236213fdd94Smrg case " $predeps $postdeps " in 9237213fdd94Smrg *" $i "*) 9238213fdd94Smrg func_append newdeplibs " $i" 923997ee6427Smrg i= 9240213fdd94Smrg ;; 9241213fdd94Smrg esac 9242213fdd94Smrg fi 924397ee6427Smrg if test -n "$i"; then 9244213fdd94Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9245213fdd94Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9246213fdd94Smrg set dummy $deplib_matches; shift 9247213fdd94Smrg deplib_match=$1 924897ee6427Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9249213fdd94Smrg func_append newdeplibs " $i" 9250213fdd94Smrg else 9251213fdd94Smrg droppeddeps=yes 9252213fdd94Smrg echo 9253213fdd94Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9254213fdd94Smrg echo "*** I have the capability to make that library automatically link in when" 9255213fdd94Smrg echo "*** you link to this library. But I can only do this if you have a" 9256213fdd94Smrg echo "*** shared version of the library, which you do not appear to have" 9257213fdd94Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9258213fdd94Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9259213fdd94Smrg fi 9260213fdd94Smrg fi 9261213fdd94Smrg else 9262213fdd94Smrg droppeddeps=yes 9263213fdd94Smrg echo 9264213fdd94Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9265213fdd94Smrg echo "*** make it link in! You will probably need to install it or some" 9266213fdd94Smrg echo "*** library that it depends on before this library will be fully" 9267213fdd94Smrg echo "*** functional. Installing it before continuing would be even better." 9268213fdd94Smrg fi 9269213fdd94Smrg ;; 9270213fdd94Smrg *) 9271213fdd94Smrg func_append newdeplibs " $i" 9272213fdd94Smrg ;; 9273213fdd94Smrg esac 9274213fdd94Smrg done 9275213fdd94Smrg fi 9276213fdd94Smrg ;; 9277213fdd94Smrg file_magic*) 9278213fdd94Smrg set dummy $deplibs_check_method; shift 9279213fdd94Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9280213fdd94Smrg for a_deplib in $deplibs; do 9281213fdd94Smrg case $a_deplib in 9282213fdd94Smrg -l*) 9283213fdd94Smrg func_stripname -l '' "$a_deplib" 9284213fdd94Smrg name=$func_stripname_result 928597ee6427Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9286213fdd94Smrg case " $predeps $postdeps " in 9287213fdd94Smrg *" $a_deplib "*) 9288213fdd94Smrg func_append newdeplibs " $a_deplib" 928997ee6427Smrg a_deplib= 9290213fdd94Smrg ;; 9291213fdd94Smrg esac 9292213fdd94Smrg fi 929397ee6427Smrg if test -n "$a_deplib"; then 9294213fdd94Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9295213fdd94Smrg if test -n "$file_magic_glob"; then 9296213fdd94Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9297213fdd94Smrg else 9298213fdd94Smrg libnameglob=$libname 9299213fdd94Smrg fi 930097ee6427Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9301213fdd94Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 930297ee6427Smrg if test yes = "$want_nocaseglob"; then 9303213fdd94Smrg shopt -s nocaseglob 9304213fdd94Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9305213fdd94Smrg $nocaseglob 9306213fdd94Smrg else 9307213fdd94Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9308213fdd94Smrg fi 9309213fdd94Smrg for potent_lib in $potential_libs; do 9310213fdd94Smrg # Follow soft links. 9311213fdd94Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9312213fdd94Smrg $GREP " -> " >/dev/null; then 9313213fdd94Smrg continue 9314213fdd94Smrg fi 9315213fdd94Smrg # The statement above tries to avoid entering an 9316213fdd94Smrg # endless loop below, in case of cyclic links. 9317213fdd94Smrg # We might still enter an endless loop, since a link 9318213fdd94Smrg # loop can be closed while we follow links, 9319213fdd94Smrg # but so what? 932097ee6427Smrg potlib=$potent_lib 9321213fdd94Smrg while test -h "$potlib" 2>/dev/null; do 932297ee6427Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9323213fdd94Smrg case $potliblink in 932497ee6427Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 932597ee6427Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9326213fdd94Smrg esac 9327213fdd94Smrg done 9328213fdd94Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9329213fdd94Smrg $SED -e 10q | 9330213fdd94Smrg $EGREP "$file_magic_regex" > /dev/null; then 9331213fdd94Smrg func_append newdeplibs " $a_deplib" 933297ee6427Smrg a_deplib= 9333213fdd94Smrg break 2 9334213fdd94Smrg fi 9335213fdd94Smrg done 9336213fdd94Smrg done 9337213fdd94Smrg fi 933897ee6427Smrg if test -n "$a_deplib"; then 9339213fdd94Smrg droppeddeps=yes 9340213fdd94Smrg echo 9341213fdd94Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9342213fdd94Smrg echo "*** I have the capability to make that library automatically link in when" 9343213fdd94Smrg echo "*** you link to this library. But I can only do this if you have a" 9344213fdd94Smrg echo "*** shared version of the library, which you do not appear to have" 9345213fdd94Smrg echo "*** because I did check the linker path looking for a file starting" 934697ee6427Smrg if test -z "$potlib"; then 9347213fdd94Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9348213fdd94Smrg else 9349213fdd94Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9350213fdd94Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9351213fdd94Smrg fi 9352213fdd94Smrg fi 9353213fdd94Smrg ;; 9354213fdd94Smrg *) 9355213fdd94Smrg # Add a -L argument. 9356213fdd94Smrg func_append newdeplibs " $a_deplib" 9357213fdd94Smrg ;; 9358213fdd94Smrg esac 9359213fdd94Smrg done # Gone through all deplibs. 9360213fdd94Smrg ;; 9361213fdd94Smrg match_pattern*) 9362213fdd94Smrg set dummy $deplibs_check_method; shift 9363213fdd94Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9364213fdd94Smrg for a_deplib in $deplibs; do 9365213fdd94Smrg case $a_deplib in 9366213fdd94Smrg -l*) 9367213fdd94Smrg func_stripname -l '' "$a_deplib" 9368213fdd94Smrg name=$func_stripname_result 936997ee6427Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9370213fdd94Smrg case " $predeps $postdeps " in 9371213fdd94Smrg *" $a_deplib "*) 9372213fdd94Smrg func_append newdeplibs " $a_deplib" 937397ee6427Smrg a_deplib= 9374213fdd94Smrg ;; 9375213fdd94Smrg esac 9376213fdd94Smrg fi 937797ee6427Smrg if test -n "$a_deplib"; then 9378213fdd94Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9379213fdd94Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9380213fdd94Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9381213fdd94Smrg for potent_lib in $potential_libs; do 938297ee6427Smrg potlib=$potent_lib # see symlink-check above in file_magic test 9383213fdd94Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9384213fdd94Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9385213fdd94Smrg func_append newdeplibs " $a_deplib" 938697ee6427Smrg a_deplib= 9387213fdd94Smrg break 2 9388213fdd94Smrg fi 9389213fdd94Smrg done 9390213fdd94Smrg done 9391213fdd94Smrg fi 939297ee6427Smrg if test -n "$a_deplib"; then 9393213fdd94Smrg droppeddeps=yes 9394213fdd94Smrg echo 9395213fdd94Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9396213fdd94Smrg echo "*** I have the capability to make that library automatically link in when" 9397213fdd94Smrg echo "*** you link to this library. But I can only do this if you have a" 9398213fdd94Smrg echo "*** shared version of the library, which you do not appear to have" 9399213fdd94Smrg echo "*** because I did check the linker path looking for a file starting" 940097ee6427Smrg if test -z "$potlib"; then 9401213fdd94Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9402213fdd94Smrg else 9403213fdd94Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9404213fdd94Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9405213fdd94Smrg fi 9406213fdd94Smrg fi 9407213fdd94Smrg ;; 9408213fdd94Smrg *) 9409213fdd94Smrg # Add a -L argument. 9410213fdd94Smrg func_append newdeplibs " $a_deplib" 9411213fdd94Smrg ;; 9412213fdd94Smrg esac 9413213fdd94Smrg done # Gone through all deplibs. 9414213fdd94Smrg ;; 9415213fdd94Smrg none | unknown | *) 941697ee6427Smrg newdeplibs= 9417213fdd94Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 941897ee6427Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941997ee6427Smrg for i in $predeps $postdeps; do 9420213fdd94Smrg # can't use Xsed below, because $i might contain '/' 942197ee6427Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9422213fdd94Smrg done 9423213fdd94Smrg fi 9424213fdd94Smrg case $tmp_deplibs in 9425213fdd94Smrg *[!\ \ ]*) 9426213fdd94Smrg echo 942797ee6427Smrg if test none = "$deplibs_check_method"; then 9428213fdd94Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9429213fdd94Smrg else 9430213fdd94Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9431213fdd94Smrg fi 9432213fdd94Smrg echo "*** All declared inter-library dependencies are being dropped." 9433213fdd94Smrg droppeddeps=yes 9434213fdd94Smrg ;; 9435213fdd94Smrg esac 9436213fdd94Smrg ;; 9437213fdd94Smrg esac 9438213fdd94Smrg versuffix=$versuffix_save 9439213fdd94Smrg major=$major_save 9440213fdd94Smrg release=$release_save 9441213fdd94Smrg libname=$libname_save 9442213fdd94Smrg name=$name_save 9443301ea0f4Smrg 9444213fdd94Smrg case $host in 9445213fdd94Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9446213fdd94Smrg # On Rhapsody replace the C library with the System framework 9447213fdd94Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9448213fdd94Smrg ;; 9449213fdd94Smrg esac 9450301ea0f4Smrg 945197ee6427Smrg if test yes = "$droppeddeps"; then 945297ee6427Smrg if test yes = "$module"; then 9453213fdd94Smrg echo 9454213fdd94Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9455213fdd94Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9456213fdd94Smrg echo "*** a static module, that should work as long as the dlopening" 9457213fdd94Smrg echo "*** application is linked with the -dlopen flag." 9458213fdd94Smrg if test -z "$global_symbol_pipe"; then 9459213fdd94Smrg echo 9460213fdd94Smrg echo "*** However, this would only work if libtool was able to extract symbol" 946197ee6427Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9462213fdd94Smrg echo "*** not find such a program. So, this module is probably useless." 946397ee6427Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9464213fdd94Smrg fi 946597ee6427Smrg if test no = "$build_old_libs"; then 946697ee6427Smrg oldlibs=$output_objdir/$libname.$libext 9467213fdd94Smrg build_libtool_libs=module 9468213fdd94Smrg build_old_libs=yes 9469213fdd94Smrg else 9470213fdd94Smrg build_libtool_libs=no 9471213fdd94Smrg fi 9472213fdd94Smrg else 9473213fdd94Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9474213fdd94Smrg echo "*** automatically added whenever a program is linked with this library" 9475213fdd94Smrg echo "*** or is declared to -dlopen it." 9476301ea0f4Smrg 947797ee6427Smrg if test no = "$allow_undefined"; then 9478213fdd94Smrg echo 9479213fdd94Smrg echo "*** Since this library must not contain undefined symbols," 9480213fdd94Smrg echo "*** because either the platform does not support them or" 9481213fdd94Smrg echo "*** it was explicitly requested with -no-undefined," 9482213fdd94Smrg echo "*** libtool will only create a static version of it." 948397ee6427Smrg if test no = "$build_old_libs"; then 948497ee6427Smrg oldlibs=$output_objdir/$libname.$libext 9485213fdd94Smrg build_libtool_libs=module 9486213fdd94Smrg build_old_libs=yes 9487213fdd94Smrg else 9488213fdd94Smrg build_libtool_libs=no 9489213fdd94Smrg fi 9490213fdd94Smrg fi 9491213fdd94Smrg fi 94920cc67336Smrg fi 9493213fdd94Smrg # Done checking deplibs! 9494213fdd94Smrg deplibs=$newdeplibs 9495213fdd94Smrg fi 9496213fdd94Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9497213fdd94Smrg case $host in 9498213fdd94Smrg *-*-darwin*) 9499213fdd94Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9500213fdd94Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9501213fdd94Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9502213fdd94Smrg ;; 9503213fdd94Smrg esac 9504301ea0f4Smrg 9505213fdd94Smrg # move library search paths that coincide with paths to not yet 9506213fdd94Smrg # installed libraries to the beginning of the library search list 9507213fdd94Smrg new_libs= 9508213fdd94Smrg for path in $notinst_path; do 9509213fdd94Smrg case " $new_libs " in 9510213fdd94Smrg *" -L$path/$objdir "*) ;; 9511213fdd94Smrg *) 9512213fdd94Smrg case " $deplibs " in 9513213fdd94Smrg *" -L$path/$objdir "*) 9514213fdd94Smrg func_append new_libs " -L$path/$objdir" ;; 9515213fdd94Smrg esac 9516213fdd94Smrg ;; 9517213fdd94Smrg esac 9518213fdd94Smrg done 9519213fdd94Smrg for deplib in $deplibs; do 9520213fdd94Smrg case $deplib in 9521213fdd94Smrg -L*) 9522213fdd94Smrg case " $new_libs " in 9523213fdd94Smrg *" $deplib "*) ;; 9524213fdd94Smrg *) func_append new_libs " $deplib" ;; 9525213fdd94Smrg esac 9526213fdd94Smrg ;; 9527213fdd94Smrg *) func_append new_libs " $deplib" ;; 9528213fdd94Smrg esac 9529213fdd94Smrg done 953097ee6427Smrg deplibs=$new_libs 9531301ea0f4Smrg 9532213fdd94Smrg # All the library-specific variables (install_libdir is set above). 9533213fdd94Smrg library_names= 9534213fdd94Smrg old_library= 9535213fdd94Smrg dlname= 9536301ea0f4Smrg 9537213fdd94Smrg # Test again, we may have decided not to build it any more 953897ee6427Smrg if test yes = "$build_libtool_libs"; then 953997ee6427Smrg # Remove $wl instances when linking with ld. 9540213fdd94Smrg # FIXME: should test the right _cmds variable. 9541213fdd94Smrg case $archive_cmds in 9542213fdd94Smrg *\$LD\ *) wl= ;; 9543213fdd94Smrg esac 954497ee6427Smrg if test yes = "$hardcode_into_libs"; then 9545213fdd94Smrg # Hardcode the library paths 9546213fdd94Smrg hardcode_libdirs= 9547213fdd94Smrg dep_rpath= 954897ee6427Smrg rpath=$finalize_rpath 954997ee6427Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9550213fdd94Smrg for libdir in $rpath; do 9551213fdd94Smrg if test -n "$hardcode_libdir_flag_spec"; then 9552213fdd94Smrg if test -n "$hardcode_libdir_separator"; then 9553213fdd94Smrg func_replace_sysroot "$libdir" 9554213fdd94Smrg libdir=$func_replace_sysroot_result 9555213fdd94Smrg if test -z "$hardcode_libdirs"; then 955697ee6427Smrg hardcode_libdirs=$libdir 9557213fdd94Smrg else 9558213fdd94Smrg # Just accumulate the unique libdirs. 9559213fdd94Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9560213fdd94Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9561213fdd94Smrg ;; 9562213fdd94Smrg *) 9563213fdd94Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9564213fdd94Smrg ;; 9565213fdd94Smrg esac 9566213fdd94Smrg fi 9567213fdd94Smrg else 9568213fdd94Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9569213fdd94Smrg func_append dep_rpath " $flag" 9570213fdd94Smrg fi 9571213fdd94Smrg elif test -n "$runpath_var"; then 9572213fdd94Smrg case "$perm_rpath " in 9573213fdd94Smrg *" $libdir "*) ;; 9574213fdd94Smrg *) func_append perm_rpath " $libdir" ;; 9575213fdd94Smrg esac 9576213fdd94Smrg fi 9577213fdd94Smrg done 9578213fdd94Smrg # Substitute the hardcoded libdirs into the rpath. 9579213fdd94Smrg if test -n "$hardcode_libdir_separator" && 9580213fdd94Smrg test -n "$hardcode_libdirs"; then 958197ee6427Smrg libdir=$hardcode_libdirs 9582213fdd94Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9583213fdd94Smrg fi 9584213fdd94Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9585213fdd94Smrg # We should set the runpath_var. 9586213fdd94Smrg rpath= 9587213fdd94Smrg for dir in $perm_rpath; do 9588213fdd94Smrg func_append rpath "$dir:" 9589213fdd94Smrg done 9590213fdd94Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9591213fdd94Smrg fi 9592213fdd94Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9593ef6fb4a5Smrg fi 9594301ea0f4Smrg 959597ee6427Smrg shlibpath=$finalize_shlibpath 959697ee6427Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9597213fdd94Smrg if test -n "$shlibpath"; then 9598213fdd94Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9599ef6fb4a5Smrg fi 9600301ea0f4Smrg 9601213fdd94Smrg # Get the real and link names of the library. 9602213fdd94Smrg eval shared_ext=\"$shrext_cmds\" 9603213fdd94Smrg eval library_names=\"$library_names_spec\" 9604213fdd94Smrg set dummy $library_names 9605213fdd94Smrg shift 960697ee6427Smrg realname=$1 9607213fdd94Smrg shift 9608301ea0f4Smrg 9609213fdd94Smrg if test -n "$soname_spec"; then 9610213fdd94Smrg eval soname=\"$soname_spec\" 9611ef6fb4a5Smrg else 961297ee6427Smrg soname=$realname 9613213fdd94Smrg fi 9614213fdd94Smrg if test -z "$dlname"; then 9615213fdd94Smrg dlname=$soname 9616ef6fb4a5Smrg fi 9617301ea0f4Smrg 961897ee6427Smrg lib=$output_objdir/$realname 9619213fdd94Smrg linknames= 9620213fdd94Smrg for link 9621213fdd94Smrg do 9622213fdd94Smrg func_append linknames " $link" 9623213fdd94Smrg done 9624301ea0f4Smrg 9625213fdd94Smrg # Use standard objects if they are pic 9626213fdd94Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9627213fdd94Smrg test "X$libobjs" = "X " && libobjs= 96280cc67336Smrg 9629213fdd94Smrg delfiles= 9630213fdd94Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9631213fdd94Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 963297ee6427Smrg export_symbols=$output_objdir/$libname.uexp 9633213fdd94Smrg func_append delfiles " $export_symbols" 9634213fdd94Smrg fi 9635301ea0f4Smrg 9636213fdd94Smrg orig_export_symbols= 9637213fdd94Smrg case $host_os in 9638213fdd94Smrg cygwin* | mingw* | cegcc*) 9639213fdd94Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9640213fdd94Smrg # exporting using user supplied symfile 964197ee6427Smrg func_dll_def_p "$export_symbols" || { 9642213fdd94Smrg # and it's NOT already a .def file. Must figure out 9643213fdd94Smrg # which of the given symbols are data symbols and tag 9644213fdd94Smrg # them as such. So, trigger use of export_symbols_cmds. 9645213fdd94Smrg # export_symbols gets reassigned inside the "prepare 9646213fdd94Smrg # the list of exported symbols" if statement, so the 9647213fdd94Smrg # include_expsyms logic still works. 964897ee6427Smrg orig_export_symbols=$export_symbols 9649213fdd94Smrg export_symbols= 9650213fdd94Smrg always_export_symbols=yes 965197ee6427Smrg } 96520cc67336Smrg fi 9653213fdd94Smrg ;; 9654213fdd94Smrg esac 9655301ea0f4Smrg 9656213fdd94Smrg # Prepare the list of exported symbols 9657213fdd94Smrg if test -z "$export_symbols"; then 965897ee6427Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965997ee6427Smrg func_verbose "generating symbol list for '$libname.la'" 966097ee6427Smrg export_symbols=$output_objdir/$libname.exp 9661213fdd94Smrg $opt_dry_run || $RM $export_symbols 9662213fdd94Smrg cmds=$export_symbols_cmds 966397ee6427Smrg save_ifs=$IFS; IFS='~' 9664213fdd94Smrg for cmd1 in $cmds; do 966597ee6427Smrg IFS=$save_ifs 9666213fdd94Smrg # Take the normal branch if the nm_file_list_spec branch 9667213fdd94Smrg # doesn't work or if tool conversion is not needed. 9668213fdd94Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9669213fdd94Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9670213fdd94Smrg try_normal_branch=yes 9671213fdd94Smrg eval cmd=\"$cmd1\" 9672213fdd94Smrg func_len " $cmd" 9673213fdd94Smrg len=$func_len_result 9674213fdd94Smrg ;; 9675213fdd94Smrg *) 9676213fdd94Smrg try_normal_branch=no 9677213fdd94Smrg ;; 9678213fdd94Smrg esac 967997ee6427Smrg if test yes = "$try_normal_branch" \ 9680213fdd94Smrg && { test "$len" -lt "$max_cmd_len" \ 9681213fdd94Smrg || test "$max_cmd_len" -le -1; } 9682213fdd94Smrg then 9683213fdd94Smrg func_show_eval "$cmd" 'exit $?' 9684213fdd94Smrg skipped_export=false 9685213fdd94Smrg elif test -n "$nm_file_list_spec"; then 9686213fdd94Smrg func_basename "$output" 9687213fdd94Smrg output_la=$func_basename_result 9688213fdd94Smrg save_libobjs=$libobjs 9689213fdd94Smrg save_output=$output 969097ee6427Smrg output=$output_objdir/$output_la.nm 9691213fdd94Smrg func_to_tool_file "$output" 9692213fdd94Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9693213fdd94Smrg func_append delfiles " $output" 9694213fdd94Smrg func_verbose "creating $NM input file list: $output" 9695213fdd94Smrg for obj in $save_libobjs; do 9696213fdd94Smrg func_to_tool_file "$obj" 9697213fdd94Smrg $ECHO "$func_to_tool_file_result" 9698213fdd94Smrg done > "$output" 9699213fdd94Smrg eval cmd=\"$cmd1\" 9700213fdd94Smrg func_show_eval "$cmd" 'exit $?' 9701213fdd94Smrg output=$save_output 9702213fdd94Smrg libobjs=$save_libobjs 9703213fdd94Smrg skipped_export=false 9704213fdd94Smrg else 9705213fdd94Smrg # The command line is too long to execute in one step. 9706213fdd94Smrg func_verbose "using reloadable object file for export list..." 9707213fdd94Smrg skipped_export=: 9708213fdd94Smrg # Break out early, otherwise skipped_export may be 9709213fdd94Smrg # set to false by a later but shorter cmd. 9710213fdd94Smrg break 9711213fdd94Smrg fi 9712213fdd94Smrg done 971397ee6427Smrg IFS=$save_ifs 971497ee6427Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9715213fdd94Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9716213fdd94Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9717213fdd94Smrg fi 9718213fdd94Smrg fi 9719213fdd94Smrg fi 9720213fdd94Smrg 9721213fdd94Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 972297ee6427Smrg tmp_export_symbols=$export_symbols 972397ee6427Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9724213fdd94Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9725ef6fb4a5Smrg fi 9726301ea0f4Smrg 972797ee6427Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9728213fdd94Smrg # The given exports_symbols file has to be filtered, so filter it. 972997ee6427Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9730213fdd94Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 973197ee6427Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9732213fdd94Smrg # though. Also, the filter scales superlinearly with the number of 9733213fdd94Smrg # global variables. join(1) would be nice here, but unfortunately 9734213fdd94Smrg # isn't a blessed tool. 9735213fdd94Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9736213fdd94Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9737213fdd94Smrg export_symbols=$output_objdir/$libname.def 9738213fdd94Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9739213fdd94Smrg fi 97400cc67336Smrg 9741213fdd94Smrg tmp_deplibs= 9742213fdd94Smrg for test_deplib in $deplibs; do 9743213fdd94Smrg case " $convenience " in 9744213fdd94Smrg *" $test_deplib "*) ;; 9745213fdd94Smrg *) 9746213fdd94Smrg func_append tmp_deplibs " $test_deplib" 9747213fdd94Smrg ;; 9748213fdd94Smrg esac 9749213fdd94Smrg done 975097ee6427Smrg deplibs=$tmp_deplibs 9751ef6fb4a5Smrg 9752213fdd94Smrg if test -n "$convenience"; then 9753213fdd94Smrg if test -n "$whole_archive_flag_spec" && 975497ee6427Smrg test yes = "$compiler_needs_object" && 9755213fdd94Smrg test -z "$libobjs"; then 9756213fdd94Smrg # extract the archives, so we have objects to list. 9757213fdd94Smrg # TODO: could optimize this to just extract one archive. 9758213fdd94Smrg whole_archive_flag_spec= 9759213fdd94Smrg fi 9760213fdd94Smrg if test -n "$whole_archive_flag_spec"; then 9761213fdd94Smrg save_libobjs=$libobjs 9762213fdd94Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9763213fdd94Smrg test "X$libobjs" = "X " && libobjs= 9764301ea0f4Smrg else 976597ee6427Smrg gentop=$output_objdir/${outputname}x 9766213fdd94Smrg func_append generated " $gentop" 9767213fdd94Smrg 9768213fdd94Smrg func_extract_archives $gentop $convenience 9769213fdd94Smrg func_append libobjs " $func_extract_archives_result" 9770213fdd94Smrg test "X$libobjs" = "X " && libobjs= 9771301ea0f4Smrg fi 9772301ea0f4Smrg fi 97730cc67336Smrg 977497ee6427Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9775213fdd94Smrg eval flag=\"$thread_safe_flag_spec\" 9776213fdd94Smrg func_append linker_flags " $flag" 9777213fdd94Smrg fi 9778301ea0f4Smrg 9779213fdd94Smrg # Make a backup of the uninstalled library when relinking 978097ee6427Smrg if test relink = "$opt_mode"; then 9781213fdd94Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9782213fdd94Smrg fi 97830cc67336Smrg 9784213fdd94Smrg # Do each of the archive commands. 978597ee6427Smrg if test yes = "$module" && test -n "$module_cmds"; then 9786213fdd94Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9787213fdd94Smrg eval test_cmds=\"$module_expsym_cmds\" 9788213fdd94Smrg cmds=$module_expsym_cmds 9789213fdd94Smrg else 9790213fdd94Smrg eval test_cmds=\"$module_cmds\" 9791213fdd94Smrg cmds=$module_cmds 9792213fdd94Smrg fi 9793ef6fb4a5Smrg else 9794213fdd94Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9795213fdd94Smrg eval test_cmds=\"$archive_expsym_cmds\" 9796213fdd94Smrg cmds=$archive_expsym_cmds 9797213fdd94Smrg else 9798213fdd94Smrg eval test_cmds=\"$archive_cmds\" 9799213fdd94Smrg cmds=$archive_cmds 9800213fdd94Smrg fi 98010cc67336Smrg fi 98020cc67336Smrg 980397ee6427Smrg if test : != "$skipped_export" && 9804213fdd94Smrg func_len " $test_cmds" && 9805213fdd94Smrg len=$func_len_result && 9806213fdd94Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9807213fdd94Smrg : 9808213fdd94Smrg else 9809213fdd94Smrg # The command line is too long to link in one step, link piecewise 9810213fdd94Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9811213fdd94Smrg # script. 98120cc67336Smrg 9813213fdd94Smrg # Save the value of $output and $libobjs because we want to 9814213fdd94Smrg # use them later. If we have whole_archive_flag_spec, we 9815213fdd94Smrg # want to use save_libobjs as it was before 9816213fdd94Smrg # whole_archive_flag_spec was expanded, because we can't 9817213fdd94Smrg # assume the linker understands whole_archive_flag_spec. 9818213fdd94Smrg # This may have to be revisited, in case too many 9819213fdd94Smrg # convenience libraries get linked in and end up exceeding 9820213fdd94Smrg # the spec. 9821213fdd94Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9822213fdd94Smrg save_libobjs=$libobjs 9823213fdd94Smrg fi 9824213fdd94Smrg save_output=$output 9825213fdd94Smrg func_basename "$output" 9826213fdd94Smrg output_la=$func_basename_result 9827213fdd94Smrg 9828213fdd94Smrg # Clear the reloadable object creation command queue and 9829213fdd94Smrg # initialize k to one. 9830213fdd94Smrg test_cmds= 9831213fdd94Smrg concat_cmds= 9832213fdd94Smrg objlist= 9833213fdd94Smrg last_robj= 9834213fdd94Smrg k=1 9835213fdd94Smrg 983697ee6427Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 983797ee6427Smrg output=$output_objdir/$output_la.lnkscript 9838213fdd94Smrg func_verbose "creating GNU ld script: $output" 9839213fdd94Smrg echo 'INPUT (' > $output 9840213fdd94Smrg for obj in $save_libobjs 9841213fdd94Smrg do 9842213fdd94Smrg func_to_tool_file "$obj" 9843213fdd94Smrg $ECHO "$func_to_tool_file_result" >> $output 9844213fdd94Smrg done 9845213fdd94Smrg echo ')' >> $output 9846213fdd94Smrg func_append delfiles " $output" 9847213fdd94Smrg func_to_tool_file "$output" 9848213fdd94Smrg output=$func_to_tool_file_result 984997ee6427Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 985097ee6427Smrg output=$output_objdir/$output_la.lnk 9851213fdd94Smrg func_verbose "creating linker input file list: $output" 9852213fdd94Smrg : > $output 9853213fdd94Smrg set x $save_libobjs 9854213fdd94Smrg shift 9855213fdd94Smrg firstobj= 985697ee6427Smrg if test yes = "$compiler_needs_object"; then 9857213fdd94Smrg firstobj="$1 " 9858213fdd94Smrg shift 9859ef6fb4a5Smrg fi 9860213fdd94Smrg for obj 9861213fdd94Smrg do 9862213fdd94Smrg func_to_tool_file "$obj" 9863213fdd94Smrg $ECHO "$func_to_tool_file_result" >> $output 9864ef6fb4a5Smrg done 9865213fdd94Smrg func_append delfiles " $output" 9866213fdd94Smrg func_to_tool_file "$output" 9867213fdd94Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9868213fdd94Smrg else 9869213fdd94Smrg if test -n "$save_libobjs"; then 9870213fdd94Smrg func_verbose "creating reloadable object files..." 987197ee6427Smrg output=$output_objdir/$output_la-$k.$objext 9872213fdd94Smrg eval test_cmds=\"$reload_cmds\" 9873213fdd94Smrg func_len " $test_cmds" 9874213fdd94Smrg len0=$func_len_result 9875213fdd94Smrg len=$len0 9876213fdd94Smrg 9877213fdd94Smrg # Loop over the list of objects to be linked. 9878213fdd94Smrg for obj in $save_libobjs 9879213fdd94Smrg do 9880213fdd94Smrg func_len " $obj" 9881213fdd94Smrg func_arith $len + $func_len_result 9882213fdd94Smrg len=$func_arith_result 988397ee6427Smrg if test -z "$objlist" || 9884213fdd94Smrg test "$len" -lt "$max_cmd_len"; then 9885213fdd94Smrg func_append objlist " $obj" 9886213fdd94Smrg else 9887213fdd94Smrg # The command $test_cmds is almost too long, add a 9888213fdd94Smrg # command to the queue. 988997ee6427Smrg if test 1 -eq "$k"; then 9890213fdd94Smrg # The first file doesn't have a previous command to add. 9891213fdd94Smrg reload_objs=$objlist 9892213fdd94Smrg eval concat_cmds=\"$reload_cmds\" 9893213fdd94Smrg else 9894213fdd94Smrg # All subsequent reloadable object files will link in 9895213fdd94Smrg # the last one created. 9896213fdd94Smrg reload_objs="$objlist $last_robj" 9897213fdd94Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9898213fdd94Smrg fi 989997ee6427Smrg last_robj=$output_objdir/$output_la-$k.$objext 9900213fdd94Smrg func_arith $k + 1 9901213fdd94Smrg k=$func_arith_result 990297ee6427Smrg output=$output_objdir/$output_la-$k.$objext 9903213fdd94Smrg objlist=" $obj" 9904213fdd94Smrg func_len " $last_robj" 9905213fdd94Smrg func_arith $len0 + $func_len_result 9906213fdd94Smrg len=$func_arith_result 9907213fdd94Smrg fi 9908213fdd94Smrg done 9909213fdd94Smrg # Handle the remaining objects by creating one last 9910213fdd94Smrg # reloadable object file. All subsequent reloadable object 9911213fdd94Smrg # files will link in the last one created. 9912213fdd94Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9913213fdd94Smrg reload_objs="$objlist $last_robj" 991497ee6427Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9915213fdd94Smrg if test -n "$last_robj"; then 991697ee6427Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9917ef6fb4a5Smrg fi 9918213fdd94Smrg func_append delfiles " $output" 9919213fdd94Smrg 9920213fdd94Smrg else 9921213fdd94Smrg output= 9922213fdd94Smrg fi 9923213fdd94Smrg 992497ee6427Smrg ${skipped_export-false} && { 992597ee6427Smrg func_verbose "generating symbol list for '$libname.la'" 992697ee6427Smrg export_symbols=$output_objdir/$libname.exp 9927213fdd94Smrg $opt_dry_run || $RM $export_symbols 9928213fdd94Smrg libobjs=$output 9929213fdd94Smrg # Append the command to create the export file. 9930213fdd94Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9931213fdd94Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9932213fdd94Smrg if test -n "$last_robj"; then 9933213fdd94Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9934ef6fb4a5Smrg fi 993597ee6427Smrg } 9936213fdd94Smrg 9937213fdd94Smrg test -n "$save_libobjs" && 9938213fdd94Smrg func_verbose "creating a temporary reloadable object file: $output" 9939213fdd94Smrg 9940213fdd94Smrg # Loop through the commands generated above and execute them. 994197ee6427Smrg save_ifs=$IFS; IFS='~' 9942213fdd94Smrg for cmd in $concat_cmds; do 994397ee6427Smrg IFS=$save_ifs 994497ee6427Smrg $opt_quiet || { 9945213fdd94Smrg func_quote_for_expand "$cmd" 9946213fdd94Smrg eval "func_echo $func_quote_for_expand_result" 9947213fdd94Smrg } 9948213fdd94Smrg $opt_dry_run || eval "$cmd" || { 9949213fdd94Smrg lt_exit=$? 9950213fdd94Smrg 9951213fdd94Smrg # Restore the uninstalled library and exit 995297ee6427Smrg if test relink = "$opt_mode"; then 9953213fdd94Smrg ( cd "$output_objdir" && \ 9954213fdd94Smrg $RM "${realname}T" && \ 9955213fdd94Smrg $MV "${realname}U" "$realname" ) 9956213fdd94Smrg fi 9957213fdd94Smrg 9958213fdd94Smrg exit $lt_exit 9959213fdd94Smrg } 9960ef6fb4a5Smrg done 996197ee6427Smrg IFS=$save_ifs 9962213fdd94Smrg 9963213fdd94Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9964213fdd94Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9965213fdd94Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9966213fdd94Smrg fi 9967213fdd94Smrg fi 9968213fdd94Smrg 996997ee6427Smrg ${skipped_export-false} && { 9970213fdd94Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 997197ee6427Smrg tmp_export_symbols=$export_symbols 997297ee6427Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9973213fdd94Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9974213fdd94Smrg fi 9975213fdd94Smrg 9976213fdd94Smrg if test -n "$orig_export_symbols"; then 9977213fdd94Smrg # The given exports_symbols file has to be filtered, so filter it. 997897ee6427Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9979213fdd94Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 998097ee6427Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9981213fdd94Smrg # though. Also, the filter scales superlinearly with the number of 9982213fdd94Smrg # global variables. join(1) would be nice here, but unfortunately 9983213fdd94Smrg # isn't a blessed tool. 9984213fdd94Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9985213fdd94Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9986213fdd94Smrg export_symbols=$output_objdir/$libname.def 9987213fdd94Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9988213fdd94Smrg fi 998997ee6427Smrg } 9990213fdd94Smrg 9991213fdd94Smrg libobjs=$output 9992213fdd94Smrg # Restore the value of output. 9993213fdd94Smrg output=$save_output 9994213fdd94Smrg 9995213fdd94Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9996213fdd94Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9997213fdd94Smrg test "X$libobjs" = "X " && libobjs= 9998213fdd94Smrg fi 9999213fdd94Smrg # Expand the library linking commands again to reset the 10000213fdd94Smrg # value of $libobjs for piecewise linking. 10001213fdd94Smrg 10002213fdd94Smrg # Do each of the archive commands. 1000397ee6427Smrg if test yes = "$module" && test -n "$module_cmds"; then 10004213fdd94Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10005213fdd94Smrg cmds=$module_expsym_cmds 10006213fdd94Smrg else 10007213fdd94Smrg cmds=$module_cmds 10008213fdd94Smrg fi 10009ef6fb4a5Smrg else 10010213fdd94Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10011213fdd94Smrg cmds=$archive_expsym_cmds 10012213fdd94Smrg else 10013213fdd94Smrg cmds=$archive_cmds 10014213fdd94Smrg fi 10015ef6fb4a5Smrg fi 10016213fdd94Smrg fi 100170cc67336Smrg 10018213fdd94Smrg if test -n "$delfiles"; then 10019213fdd94Smrg # Append the command to remove temporary files to $cmds. 10020213fdd94Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10021213fdd94Smrg fi 10022301ea0f4Smrg 10023213fdd94Smrg # Add any objects from preloaded convenience libraries 10024213fdd94Smrg if test -n "$dlprefiles"; then 1002597ee6427Smrg gentop=$output_objdir/${outputname}x 10026213fdd94Smrg func_append generated " $gentop" 10027301ea0f4Smrg 10028213fdd94Smrg func_extract_archives $gentop $dlprefiles 10029213fdd94Smrg func_append libobjs " $func_extract_archives_result" 10030213fdd94Smrg test "X$libobjs" = "X " && libobjs= 10031213fdd94Smrg fi 10032301ea0f4Smrg 1003397ee6427Smrg save_ifs=$IFS; IFS='~' 10034213fdd94Smrg for cmd in $cmds; do 1003597ee6427Smrg IFS=$sp$nl 10036213fdd94Smrg eval cmd=\"$cmd\" 1003797ee6427Smrg IFS=$save_ifs 1003897ee6427Smrg $opt_quiet || { 10039213fdd94Smrg func_quote_for_expand "$cmd" 10040213fdd94Smrg eval "func_echo $func_quote_for_expand_result" 10041213fdd94Smrg } 10042213fdd94Smrg $opt_dry_run || eval "$cmd" || { 10043213fdd94Smrg lt_exit=$? 10044301ea0f4Smrg 10045213fdd94Smrg # Restore the uninstalled library and exit 1004697ee6427Smrg if test relink = "$opt_mode"; then 10047213fdd94Smrg ( cd "$output_objdir" && \ 10048213fdd94Smrg $RM "${realname}T" && \ 10049213fdd94Smrg $MV "${realname}U" "$realname" ) 10050213fdd94Smrg fi 10051301ea0f4Smrg 10052213fdd94Smrg exit $lt_exit 10053213fdd94Smrg } 10054213fdd94Smrg done 1005597ee6427Smrg IFS=$save_ifs 10056301ea0f4Smrg 10057213fdd94Smrg # Restore the uninstalled library and exit 1005897ee6427Smrg if test relink = "$opt_mode"; then 10059213fdd94Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10060301ea0f4Smrg 10061213fdd94Smrg if test -n "$convenience"; then 10062213fdd94Smrg if test -z "$whole_archive_flag_spec"; then 10063213fdd94Smrg func_show_eval '${RM}r "$gentop"' 10064213fdd94Smrg fi 10065213fdd94Smrg fi 10066301ea0f4Smrg 10067213fdd94Smrg exit $EXIT_SUCCESS 10068213fdd94Smrg fi 10069213fdd94Smrg 10070213fdd94Smrg # Create links to the real library. 10071213fdd94Smrg for linkname in $linknames; do 10072213fdd94Smrg if test "$realname" != "$linkname"; then 10073213fdd94Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10074ef6fb4a5Smrg fi 10075ef6fb4a5Smrg done 10076301ea0f4Smrg 10077213fdd94Smrg # If -module or -export-dynamic was specified, set the dlname. 1007897ee6427Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10079213fdd94Smrg # On all known operating systems, these are identical. 1008097ee6427Smrg dlname=$soname 10081213fdd94Smrg fi 10082213fdd94Smrg fi 100830cc67336Smrg ;; 10084301ea0f4Smrg 10085213fdd94Smrg obj) 1008697ee6427Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1008797ee6427Smrg func_warning "'-dlopen' is ignored for objects" 10088213fdd94Smrg fi 10089ef6fb4a5Smrg 10090213fdd94Smrg case " $deplibs" in 10091213fdd94Smrg *\ -l* | *\ -L*) 1009297ee6427Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10093301ea0f4Smrg esac 10094301ea0f4Smrg 10095213fdd94Smrg test -n "$rpath" && \ 1009697ee6427Smrg func_warning "'-rpath' is ignored for objects" 10097301ea0f4Smrg 10098213fdd94Smrg test -n "$xrpath" && \ 1009997ee6427Smrg func_warning "'-R' is ignored for objects" 10100301ea0f4Smrg 10101213fdd94Smrg test -n "$vinfo" && \ 1010297ee6427Smrg func_warning "'-version-info' is ignored for objects" 10103213fdd94Smrg 10104213fdd94Smrg test -n "$release" && \ 1010597ee6427Smrg func_warning "'-release' is ignored for objects" 10106213fdd94Smrg 10107213fdd94Smrg case $output in 10108213fdd94Smrg *.lo) 10109213fdd94Smrg test -n "$objs$old_deplibs" && \ 1011097ee6427Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10111213fdd94Smrg 10112213fdd94Smrg libobj=$output 10113213fdd94Smrg func_lo2o "$libobj" 10114213fdd94Smrg obj=$func_lo2o_result 10115ef6fb4a5Smrg ;; 10116ef6fb4a5Smrg *) 10117213fdd94Smrg libobj= 1011897ee6427Smrg obj=$output 10119301ea0f4Smrg ;; 10120301ea0f4Smrg esac 10121301ea0f4Smrg 10122213fdd94Smrg # Delete the old objects. 10123213fdd94Smrg $opt_dry_run || $RM $obj $libobj 10124301ea0f4Smrg 10125213fdd94Smrg # Objects from convenience libraries. This assumes 10126213fdd94Smrg # single-version convenience libraries. Whenever we create 10127213fdd94Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10128213fdd94Smrg # the extraction. 10129213fdd94Smrg reload_conv_objs= 10130213fdd94Smrg gentop= 1013197ee6427Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 1013297ee6427Smrg # whole_archive_flag_spec and hope we can get by with turning comma 1013397ee6427Smrg # into space. 1013497ee6427Smrg case $reload_cmds in 1013597ee6427Smrg *\$LD[\ \$]*) wl= ;; 1013697ee6427Smrg esac 10137213fdd94Smrg if test -n "$convenience"; then 10138213fdd94Smrg if test -n "$whole_archive_flag_spec"; then 10139213fdd94Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1014097ee6427Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1014197ee6427Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10142213fdd94Smrg else 1014397ee6427Smrg gentop=$output_objdir/${obj}x 10144213fdd94Smrg func_append generated " $gentop" 10145ef6fb4a5Smrg 10146213fdd94Smrg func_extract_archives $gentop $convenience 10147213fdd94Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10148213fdd94Smrg fi 10149ef6fb4a5Smrg fi 10150ef6fb4a5Smrg 10151213fdd94Smrg # If we're not building shared, we need to use non_pic_objs 1015297ee6427Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10153ef6fb4a5Smrg 10154213fdd94Smrg # Create the old-style object. 1015597ee6427Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10156ef6fb4a5Smrg 1015797ee6427Smrg output=$obj 10158213fdd94Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10159213fdd94Smrg 10160213fdd94Smrg # Exit if we aren't doing a library object file. 10161213fdd94Smrg if test -z "$libobj"; then 10162213fdd94Smrg if test -n "$gentop"; then 10163213fdd94Smrg func_show_eval '${RM}r "$gentop"' 10164213fdd94Smrg fi 10165213fdd94Smrg 10166213fdd94Smrg exit $EXIT_SUCCESS 10167ef6fb4a5Smrg fi 10168213fdd94Smrg 1016997ee6427Smrg test yes = "$build_libtool_libs" || { 10170213fdd94Smrg if test -n "$gentop"; then 10171213fdd94Smrg func_show_eval '${RM}r "$gentop"' 10172213fdd94Smrg fi 10173213fdd94Smrg 10174213fdd94Smrg # Create an invalid libtool object if no PIC, so that we don't 10175213fdd94Smrg # accidentally link it into a program. 10176213fdd94Smrg # $show "echo timestamp > $libobj" 10177213fdd94Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10178213fdd94Smrg exit $EXIT_SUCCESS 1017997ee6427Smrg } 10180213fdd94Smrg 1018197ee6427Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10182213fdd94Smrg # Only do commands if we really have different PIC objects. 10183213fdd94Smrg reload_objs="$libobjs $reload_conv_objs" 1018497ee6427Smrg output=$libobj 10185213fdd94Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10186213fdd94Smrg fi 10187213fdd94Smrg 10188213fdd94Smrg if test -n "$gentop"; then 10189213fdd94Smrg func_show_eval '${RM}r "$gentop"' 10190213fdd94Smrg fi 10191213fdd94Smrg 10192213fdd94Smrg exit $EXIT_SUCCESS 10193ef6fb4a5Smrg ;; 10194301ea0f4Smrg 10195213fdd94Smrg prog) 10196213fdd94Smrg case $host in 10197213fdd94Smrg *cygwin*) func_stripname '' '.exe' "$output" 10198213fdd94Smrg output=$func_stripname_result.exe;; 10199213fdd94Smrg esac 10200213fdd94Smrg test -n "$vinfo" && \ 1020197ee6427Smrg func_warning "'-version-info' is ignored for programs" 10202301ea0f4Smrg 10203213fdd94Smrg test -n "$release" && \ 1020497ee6427Smrg func_warning "'-release' is ignored for programs" 10205301ea0f4Smrg 1020697ee6427Smrg $preload \ 1020797ee6427Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1020897ee6427Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10209213fdd94Smrg 10210213fdd94Smrg case $host in 10211213fdd94Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10212213fdd94Smrg # On Rhapsody replace the C library is the System framework 10213213fdd94Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10214213fdd94Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10215ef6fb4a5Smrg ;; 10216213fdd94Smrg esac 10217ef6fb4a5Smrg 10218213fdd94Smrg case $host in 10219213fdd94Smrg *-*-darwin*) 10220213fdd94Smrg # Don't allow lazy linking, it breaks C++ global constructors 10221213fdd94Smrg # But is supposedly fixed on 10.4 or later (yay!). 1022297ee6427Smrg if test CXX = "$tagname"; then 10223213fdd94Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10224213fdd94Smrg 10.[0123]) 1022597ee6427Smrg func_append compile_command " $wl-bind_at_load" 1022697ee6427Smrg func_append finalize_command " $wl-bind_at_load" 10227213fdd94Smrg ;; 10228213fdd94Smrg esac 10229ef6fb4a5Smrg fi 10230213fdd94Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10231213fdd94Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10232213fdd94Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10233213fdd94Smrg ;; 10234213fdd94Smrg esac 10235ef6fb4a5Smrg 10236ef6fb4a5Smrg 10237213fdd94Smrg # move library search paths that coincide with paths to not yet 10238213fdd94Smrg # installed libraries to the beginning of the library search list 10239213fdd94Smrg new_libs= 10240213fdd94Smrg for path in $notinst_path; do 10241213fdd94Smrg case " $new_libs " in 10242213fdd94Smrg *" -L$path/$objdir "*) ;; 10243213fdd94Smrg *) 10244213fdd94Smrg case " $compile_deplibs " in 10245213fdd94Smrg *" -L$path/$objdir "*) 10246213fdd94Smrg func_append new_libs " -L$path/$objdir" ;; 102470cc67336Smrg esac 10248213fdd94Smrg ;; 10249213fdd94Smrg esac 10250213fdd94Smrg done 10251213fdd94Smrg for deplib in $compile_deplibs; do 10252213fdd94Smrg case $deplib in 10253213fdd94Smrg -L*) 10254213fdd94Smrg case " $new_libs " in 10255213fdd94Smrg *" $deplib "*) ;; 10256213fdd94Smrg *) func_append new_libs " $deplib" ;; 10257301ea0f4Smrg esac 10258213fdd94Smrg ;; 10259213fdd94Smrg *) func_append new_libs " $deplib" ;; 10260213fdd94Smrg esac 10261213fdd94Smrg done 1026297ee6427Smrg compile_deplibs=$new_libs 102630cc67336Smrg 10264ef6fb4a5Smrg 10265213fdd94Smrg func_append compile_command " $compile_deplibs" 10266213fdd94Smrg func_append finalize_command " $finalize_deplibs" 10267ef6fb4a5Smrg 10268213fdd94Smrg if test -n "$rpath$xrpath"; then 10269213fdd94Smrg # If the user specified any rpath flags, then add them. 10270213fdd94Smrg for libdir in $rpath $xrpath; do 10271213fdd94Smrg # This is the magic to use -rpath. 10272213fdd94Smrg case "$finalize_rpath " in 10273213fdd94Smrg *" $libdir "*) ;; 10274213fdd94Smrg *) func_append finalize_rpath " $libdir" ;; 10275213fdd94Smrg esac 10276213fdd94Smrg done 10277213fdd94Smrg fi 10278ef6fb4a5Smrg 10279213fdd94Smrg # Now hardcode the library paths 10280213fdd94Smrg rpath= 10281213fdd94Smrg hardcode_libdirs= 10282213fdd94Smrg for libdir in $compile_rpath $finalize_rpath; do 10283213fdd94Smrg if test -n "$hardcode_libdir_flag_spec"; then 10284213fdd94Smrg if test -n "$hardcode_libdir_separator"; then 10285213fdd94Smrg if test -z "$hardcode_libdirs"; then 1028697ee6427Smrg hardcode_libdirs=$libdir 10287213fdd94Smrg else 10288213fdd94Smrg # Just accumulate the unique libdirs. 10289213fdd94Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10290213fdd94Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10291213fdd94Smrg ;; 10292213fdd94Smrg *) 10293213fdd94Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10294213fdd94Smrg ;; 10295213fdd94Smrg esac 10296213fdd94Smrg fi 10297ef6fb4a5Smrg else 10298213fdd94Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10299213fdd94Smrg func_append rpath " $flag" 10300ef6fb4a5Smrg fi 10301213fdd94Smrg elif test -n "$runpath_var"; then 10302213fdd94Smrg case "$perm_rpath " in 10303213fdd94Smrg *" $libdir "*) ;; 10304213fdd94Smrg *) func_append perm_rpath " $libdir" ;; 10305213fdd94Smrg esac 10306213fdd94Smrg fi 10307213fdd94Smrg case $host in 10308213fdd94Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030997ee6427Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10310213fdd94Smrg case :$dllsearchpath: in 10311213fdd94Smrg *":$libdir:"*) ;; 10312213fdd94Smrg ::) dllsearchpath=$libdir;; 10313213fdd94Smrg *) func_append dllsearchpath ":$libdir";; 10314213fdd94Smrg esac 10315213fdd94Smrg case :$dllsearchpath: in 10316213fdd94Smrg *":$testbindir:"*) ;; 10317213fdd94Smrg ::) dllsearchpath=$testbindir;; 10318213fdd94Smrg *) func_append dllsearchpath ":$testbindir";; 10319213fdd94Smrg esac 10320213fdd94Smrg ;; 10321213fdd94Smrg esac 10322213fdd94Smrg done 10323213fdd94Smrg # Substitute the hardcoded libdirs into the rpath. 10324213fdd94Smrg if test -n "$hardcode_libdir_separator" && 10325213fdd94Smrg test -n "$hardcode_libdirs"; then 1032697ee6427Smrg libdir=$hardcode_libdirs 10327213fdd94Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10328213fdd94Smrg fi 1032997ee6427Smrg compile_rpath=$rpath 10330ef6fb4a5Smrg 10331213fdd94Smrg rpath= 10332213fdd94Smrg hardcode_libdirs= 10333213fdd94Smrg for libdir in $finalize_rpath; do 10334213fdd94Smrg if test -n "$hardcode_libdir_flag_spec"; then 10335213fdd94Smrg if test -n "$hardcode_libdir_separator"; then 10336213fdd94Smrg if test -z "$hardcode_libdirs"; then 1033797ee6427Smrg hardcode_libdirs=$libdir 10338213fdd94Smrg else 10339213fdd94Smrg # Just accumulate the unique libdirs. 10340213fdd94Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10341213fdd94Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10342213fdd94Smrg ;; 10343213fdd94Smrg *) 10344213fdd94Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10345213fdd94Smrg ;; 10346213fdd94Smrg esac 10347213fdd94Smrg fi 103480cc67336Smrg else 10349213fdd94Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10350213fdd94Smrg func_append rpath " $flag" 103510cc67336Smrg fi 10352213fdd94Smrg elif test -n "$runpath_var"; then 10353213fdd94Smrg case "$finalize_perm_rpath " in 10354213fdd94Smrg *" $libdir "*) ;; 10355213fdd94Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10356213fdd94Smrg esac 10357301ea0f4Smrg fi 10358213fdd94Smrg done 10359213fdd94Smrg # Substitute the hardcoded libdirs into the rpath. 10360213fdd94Smrg if test -n "$hardcode_libdir_separator" && 10361213fdd94Smrg test -n "$hardcode_libdirs"; then 1036297ee6427Smrg libdir=$hardcode_libdirs 10363213fdd94Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10364213fdd94Smrg fi 1036597ee6427Smrg finalize_rpath=$rpath 10366301ea0f4Smrg 1036797ee6427Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10368213fdd94Smrg # Transform all the library objects into standard objects. 10369213fdd94Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10370213fdd94Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10371213fdd94Smrg fi 10372301ea0f4Smrg 1037397ee6427Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10374301ea0f4Smrg 10375213fdd94Smrg # template prelinking step 10376213fdd94Smrg if test -n "$prelink_cmds"; then 10377213fdd94Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10378213fdd94Smrg fi 10379301ea0f4Smrg 1038097ee6427Smrg wrappers_required=: 10381213fdd94Smrg case $host in 10382213fdd94Smrg *cegcc* | *mingw32ce*) 10383213fdd94Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1038497ee6427Smrg wrappers_required=false 10385213fdd94Smrg ;; 10386213fdd94Smrg *cygwin* | *mingw* ) 1038797ee6427Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10388213fdd94Smrg ;; 10389213fdd94Smrg *) 1039097ee6427Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1039197ee6427Smrg wrappers_required=false 10392213fdd94Smrg fi 10393213fdd94Smrg ;; 10394213fdd94Smrg esac 1039597ee6427Smrg $wrappers_required || { 10396213fdd94Smrg # Replace the output file specification. 10397213fdd94Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1039897ee6427Smrg link_command=$compile_command$compile_rpath 10399301ea0f4Smrg 10400213fdd94Smrg # We have no uninstalled library dependencies, so finalize right now. 10401213fdd94Smrg exit_status=0 10402213fdd94Smrg func_show_eval "$link_command" 'exit_status=$?' 10403301ea0f4Smrg 10404213fdd94Smrg if test -n "$postlink_cmds"; then 10405213fdd94Smrg func_to_tool_file "$output" 10406213fdd94Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10407213fdd94Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 104080cc67336Smrg fi 10409301ea0f4Smrg 10410213fdd94Smrg # Delete the generated files. 1041197ee6427Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 1041297ee6427Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10413213fdd94Smrg fi 10414301ea0f4Smrg 10415213fdd94Smrg exit $exit_status 1041697ee6427Smrg } 10417301ea0f4Smrg 10418213fdd94Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10419213fdd94Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10420213fdd94Smrg fi 10421213fdd94Smrg if test -n "$finalize_shlibpath"; then 10422213fdd94Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10423213fdd94Smrg fi 10424ef6fb4a5Smrg 10425213fdd94Smrg compile_var= 10426213fdd94Smrg finalize_var= 10427213fdd94Smrg if test -n "$runpath_var"; then 10428213fdd94Smrg if test -n "$perm_rpath"; then 10429213fdd94Smrg # We should set the runpath_var. 10430213fdd94Smrg rpath= 10431213fdd94Smrg for dir in $perm_rpath; do 10432213fdd94Smrg func_append rpath "$dir:" 10433213fdd94Smrg done 10434213fdd94Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10435301ea0f4Smrg fi 10436213fdd94Smrg if test -n "$finalize_perm_rpath"; then 10437213fdd94Smrg # We should set the runpath_var. 10438213fdd94Smrg rpath= 10439213fdd94Smrg for dir in $finalize_perm_rpath; do 10440213fdd94Smrg func_append rpath "$dir:" 10441213fdd94Smrg done 10442213fdd94Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 104430cc67336Smrg fi 10444213fdd94Smrg fi 10445301ea0f4Smrg 1044697ee6427Smrg if test yes = "$no_install"; then 10447213fdd94Smrg # We don't need to create a wrapper script. 1044897ee6427Smrg link_command=$compile_var$compile_command$compile_rpath 10449213fdd94Smrg # Replace the output file specification. 10450213fdd94Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10451213fdd94Smrg # Delete the old output file. 10452213fdd94Smrg $opt_dry_run || $RM $output 10453213fdd94Smrg # Link the executable and exit 10454213fdd94Smrg func_show_eval "$link_command" 'exit $?' 10455301ea0f4Smrg 10456213fdd94Smrg if test -n "$postlink_cmds"; then 10457213fdd94Smrg func_to_tool_file "$output" 10458213fdd94Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10459213fdd94Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10460ef6fb4a5Smrg fi 10461213fdd94Smrg 10462ef6fb4a5Smrg exit $EXIT_SUCCESS 10463213fdd94Smrg fi 10464301ea0f4Smrg 1046597ee6427Smrg case $hardcode_action,$fast_install in 1046697ee6427Smrg relink,*) 1046797ee6427Smrg # Fast installation is not supported 1046897ee6427Smrg link_command=$compile_var$compile_command$compile_rpath 1046997ee6427Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10470213fdd94Smrg 1047197ee6427Smrg func_warning "this platform does not like uninstalled shared libraries" 1047297ee6427Smrg func_warning "'$output' will be relinked during installation" 1047397ee6427Smrg ;; 1047497ee6427Smrg *,yes) 1047597ee6427Smrg link_command=$finalize_var$compile_command$finalize_rpath 1047697ee6427Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1047797ee6427Smrg ;; 1047897ee6427Smrg *,no) 1047997ee6427Smrg link_command=$compile_var$compile_command$compile_rpath 1048097ee6427Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1048197ee6427Smrg ;; 1048297ee6427Smrg *,needless) 1048397ee6427Smrg link_command=$finalize_var$compile_command$finalize_rpath 1048497ee6427Smrg relink_command= 1048597ee6427Smrg ;; 1048697ee6427Smrg esac 10487301ea0f4Smrg 10488213fdd94Smrg # Replace the output file specification. 10489213fdd94Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10490301ea0f4Smrg 10491213fdd94Smrg # Delete the old output files. 10492213fdd94Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10493301ea0f4Smrg 10494213fdd94Smrg func_show_eval "$link_command" 'exit $?' 10495301ea0f4Smrg 10496213fdd94Smrg if test -n "$postlink_cmds"; then 10497213fdd94Smrg func_to_tool_file "$output_objdir/$outputname" 10498213fdd94Smrg 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'` 10499213fdd94Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10500213fdd94Smrg fi 10501ef6fb4a5Smrg 10502213fdd94Smrg # Now create the wrapper script. 10503213fdd94Smrg func_verbose "creating $output" 10504ef6fb4a5Smrg 10505213fdd94Smrg # Quote the relink command for shipping. 10506213fdd94Smrg if test -n "$relink_command"; then 10507213fdd94Smrg # Preserve any variables that may affect compiler behavior 10508213fdd94Smrg for var in $variables_saved_for_relink; do 10509213fdd94Smrg if eval test -z \"\${$var+set}\"; then 10510213fdd94Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10511213fdd94Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10512213fdd94Smrg relink_command="$var=; export $var; $relink_command" 105130cc67336Smrg else 10514213fdd94Smrg func_quote_for_eval "$var_value" 10515213fdd94Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 105160cc67336Smrg fi 10517213fdd94Smrg done 10518213fdd94Smrg relink_command="(cd `pwd`; $relink_command)" 10519213fdd94Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10520213fdd94Smrg fi 10521213fdd94Smrg 10522213fdd94Smrg # Only actually do things if not in dry run mode. 10523213fdd94Smrg $opt_dry_run || { 10524213fdd94Smrg # win32 will think the script is a binary if it has 10525213fdd94Smrg # a .exe suffix, so we strip it off here. 10526213fdd94Smrg case $output in 10527213fdd94Smrg *.exe) func_stripname '' '.exe' "$output" 10528213fdd94Smrg output=$func_stripname_result ;; 10529301ea0f4Smrg esac 10530213fdd94Smrg # test for cygwin because mv fails w/o .exe extensions 10531213fdd94Smrg case $host in 10532213fdd94Smrg *cygwin*) 10533213fdd94Smrg exeext=.exe 10534213fdd94Smrg func_stripname '' '.exe' "$outputname" 10535213fdd94Smrg outputname=$func_stripname_result ;; 10536213fdd94Smrg *) exeext= ;; 10537213fdd94Smrg esac 10538213fdd94Smrg case $host in 10539213fdd94Smrg *cygwin* | *mingw* ) 10540213fdd94Smrg func_dirname_and_basename "$output" "" "." 10541213fdd94Smrg output_name=$func_basename_result 10542213fdd94Smrg output_path=$func_dirname_result 1054397ee6427Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1054497ee6427Smrg cwrapper=$output_path/$output_name.exe 10545213fdd94Smrg $RM $cwrappersource $cwrapper 10546213fdd94Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10547213fdd94Smrg 10548213fdd94Smrg func_emit_cwrapperexe_src > $cwrappersource 10549213fdd94Smrg 10550213fdd94Smrg # The wrapper executable is built using the $host compiler, 10551213fdd94Smrg # because it contains $host paths and files. If cross- 10552213fdd94Smrg # compiling, it, like the target executable, must be 10553213fdd94Smrg # executed on the $host or under an emulation environment. 10554213fdd94Smrg $opt_dry_run || { 10555213fdd94Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10556213fdd94Smrg $STRIP $cwrapper 10557213fdd94Smrg } 10558301ea0f4Smrg 10559213fdd94Smrg # Now, create the wrapper script for func_source use: 10560213fdd94Smrg func_ltwrapper_scriptname $cwrapper 10561213fdd94Smrg $RM $func_ltwrapper_scriptname_result 10562213fdd94Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10563213fdd94Smrg $opt_dry_run || { 10564213fdd94Smrg # note: this script will not be executed, so do not chmod. 1056597ee6427Smrg if test "x$build" = "x$host"; then 10566213fdd94Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10567213fdd94Smrg else 10568213fdd94Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10569213fdd94Smrg fi 10570213fdd94Smrg } 10571213fdd94Smrg ;; 10572213fdd94Smrg * ) 10573213fdd94Smrg $RM $output 10574213fdd94Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10575301ea0f4Smrg 10576213fdd94Smrg func_emit_wrapper no > $output 10577213fdd94Smrg chmod +x $output 10578213fdd94Smrg ;; 10579213fdd94Smrg esac 10580213fdd94Smrg } 10581213fdd94Smrg exit $EXIT_SUCCESS 10582213fdd94Smrg ;; 10583213fdd94Smrg esac 10584301ea0f4Smrg 10585213fdd94Smrg # See if we need to build an old-fashioned archive. 10586213fdd94Smrg for oldlib in $oldlibs; do 10587301ea0f4Smrg 1058897ee6427Smrg case $build_libtool_libs in 1058997ee6427Smrg convenience) 1059097ee6427Smrg oldobjs="$libobjs_save $symfileobj" 1059197ee6427Smrg addlibs=$convenience 10592213fdd94Smrg build_libtool_libs=no 1059397ee6427Smrg ;; 1059497ee6427Smrg module) 1059597ee6427Smrg oldobjs=$libobjs_save 1059697ee6427Smrg addlibs=$old_convenience 1059797ee6427Smrg build_libtool_libs=no 1059897ee6427Smrg ;; 1059997ee6427Smrg *) 10600213fdd94Smrg oldobjs="$old_deplibs $non_pic_objects" 1060197ee6427Smrg $preload && test -f "$symfileobj" \ 1060297ee6427Smrg && func_append oldobjs " $symfileobj" 1060397ee6427Smrg addlibs=$old_convenience 1060497ee6427Smrg ;; 1060597ee6427Smrg esac 10606301ea0f4Smrg 10607213fdd94Smrg if test -n "$addlibs"; then 1060897ee6427Smrg gentop=$output_objdir/${outputname}x 10609213fdd94Smrg func_append generated " $gentop" 10610301ea0f4Smrg 10611213fdd94Smrg func_extract_archives $gentop $addlibs 10612213fdd94Smrg func_append oldobjs " $func_extract_archives_result" 10613213fdd94Smrg fi 10614301ea0f4Smrg 10615213fdd94Smrg # Do each command in the archive commands. 1061697ee6427Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10617213fdd94Smrg cmds=$old_archive_from_new_cmds 10618213fdd94Smrg else 10619301ea0f4Smrg 10620213fdd94Smrg # Add any objects from preloaded convenience libraries 10621213fdd94Smrg if test -n "$dlprefiles"; then 1062297ee6427Smrg gentop=$output_objdir/${outputname}x 10623213fdd94Smrg func_append generated " $gentop" 10624301ea0f4Smrg 10625213fdd94Smrg func_extract_archives $gentop $dlprefiles 10626213fdd94Smrg func_append oldobjs " $func_extract_archives_result" 10627213fdd94Smrg fi 10628301ea0f4Smrg 10629213fdd94Smrg # POSIX demands no paths to be encoded in archives. We have 10630213fdd94Smrg # to avoid creating archives with duplicate basenames if we 10631213fdd94Smrg # might have to extract them afterwards, e.g., when creating a 10632213fdd94Smrg # static archive out of a convenience library, or when linking 10633213fdd94Smrg # the entirety of a libtool archive into another (currently 10634213fdd94Smrg # not supported by libtool). 10635213fdd94Smrg if (for obj in $oldobjs 10636213fdd94Smrg do 10637213fdd94Smrg func_basename "$obj" 10638213fdd94Smrg $ECHO "$func_basename_result" 10639213fdd94Smrg done | sort | sort -uc >/dev/null 2>&1); then 10640213fdd94Smrg : 10641213fdd94Smrg else 10642213fdd94Smrg echo "copying selected object files to avoid basename conflicts..." 1064397ee6427Smrg gentop=$output_objdir/${outputname}x 10644213fdd94Smrg func_append generated " $gentop" 10645213fdd94Smrg func_mkdir_p "$gentop" 10646213fdd94Smrg save_oldobjs=$oldobjs 10647213fdd94Smrg oldobjs= 10648213fdd94Smrg counter=1 10649213fdd94Smrg for obj in $save_oldobjs 10650213fdd94Smrg do 10651213fdd94Smrg func_basename "$obj" 1065297ee6427Smrg objbase=$func_basename_result 10653213fdd94Smrg case " $oldobjs " in 10654213fdd94Smrg " ") oldobjs=$obj ;; 10655213fdd94Smrg *[\ /]"$objbase "*) 10656213fdd94Smrg while :; do 10657213fdd94Smrg # Make sure we don't pick an alternate name that also 10658213fdd94Smrg # overlaps. 10659213fdd94Smrg newobj=lt$counter-$objbase 10660213fdd94Smrg func_arith $counter + 1 10661213fdd94Smrg counter=$func_arith_result 10662213fdd94Smrg case " $oldobjs " in 10663213fdd94Smrg *[\ /]"$newobj "*) ;; 10664213fdd94Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10665213fdd94Smrg esac 10666213fdd94Smrg done 10667213fdd94Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10668213fdd94Smrg func_append oldobjs " $gentop/$newobj" 10669213fdd94Smrg ;; 10670213fdd94Smrg *) func_append oldobjs " $obj" ;; 10671213fdd94Smrg esac 10672301ea0f4Smrg done 106730cc67336Smrg fi 10674213fdd94Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10675213fdd94Smrg tool_oldlib=$func_to_tool_file_result 10676213fdd94Smrg eval cmds=\"$old_archive_cmds\" 10677ef6fb4a5Smrg 10678213fdd94Smrg func_len " $cmds" 10679213fdd94Smrg len=$func_len_result 10680213fdd94Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10681213fdd94Smrg cmds=$old_archive_cmds 10682213fdd94Smrg elif test -n "$archiver_list_spec"; then 10683213fdd94Smrg func_verbose "using command file archive linking..." 10684213fdd94Smrg for obj in $oldobjs 10685213fdd94Smrg do 10686213fdd94Smrg func_to_tool_file "$obj" 10687213fdd94Smrg $ECHO "$func_to_tool_file_result" 10688213fdd94Smrg done > $output_objdir/$libname.libcmd 10689213fdd94Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10690213fdd94Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10691213fdd94Smrg cmds=$old_archive_cmds 10692213fdd94Smrg else 10693213fdd94Smrg # the command line is too long to link in one step, link in parts 10694213fdd94Smrg func_verbose "using piecewise archive linking..." 10695213fdd94Smrg save_RANLIB=$RANLIB 10696213fdd94Smrg RANLIB=: 10697213fdd94Smrg objlist= 10698213fdd94Smrg concat_cmds= 10699213fdd94Smrg save_oldobjs=$oldobjs 10700213fdd94Smrg oldobjs= 10701213fdd94Smrg # Is there a better way of finding the last object in the list? 10702213fdd94Smrg for obj in $save_oldobjs 10703213fdd94Smrg do 10704213fdd94Smrg last_oldobj=$obj 10705213fdd94Smrg done 10706213fdd94Smrg eval test_cmds=\"$old_archive_cmds\" 10707213fdd94Smrg func_len " $test_cmds" 10708213fdd94Smrg len0=$func_len_result 10709213fdd94Smrg len=$len0 10710213fdd94Smrg for obj in $save_oldobjs 10711213fdd94Smrg do 10712213fdd94Smrg func_len " $obj" 10713213fdd94Smrg func_arith $len + $func_len_result 10714213fdd94Smrg len=$func_arith_result 10715213fdd94Smrg func_append objlist " $obj" 10716213fdd94Smrg if test "$len" -lt "$max_cmd_len"; then 10717213fdd94Smrg : 10718213fdd94Smrg else 10719213fdd94Smrg # the above command should be used before it gets too long 10720213fdd94Smrg oldobjs=$objlist 1072197ee6427Smrg if test "$obj" = "$last_oldobj"; then 10722213fdd94Smrg RANLIB=$save_RANLIB 10723213fdd94Smrg fi 10724213fdd94Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1072597ee6427Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10726213fdd94Smrg objlist= 10727213fdd94Smrg len=$len0 10728213fdd94Smrg fi 10729213fdd94Smrg done 10730213fdd94Smrg RANLIB=$save_RANLIB 10731213fdd94Smrg oldobjs=$objlist 1073297ee6427Smrg if test -z "$oldobjs"; then 10733213fdd94Smrg eval cmds=\"\$concat_cmds\" 10734213fdd94Smrg else 10735213fdd94Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10736213fdd94Smrg fi 10737213fdd94Smrg fi 10738213fdd94Smrg fi 10739213fdd94Smrg func_execute_cmds "$cmds" 'exit $?' 10740301ea0f4Smrg done 10741301ea0f4Smrg 10742213fdd94Smrg test -n "$generated" && \ 10743213fdd94Smrg func_show_eval "${RM}r$generated" 10744301ea0f4Smrg 10745213fdd94Smrg # Now create the libtool archive. 10746213fdd94Smrg case $output in 10747213fdd94Smrg *.la) 10748213fdd94Smrg old_library= 1074997ee6427Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 10750213fdd94Smrg func_verbose "creating $output" 107510cc67336Smrg 10752213fdd94Smrg # Preserve any variables that may affect compiler behavior 10753213fdd94Smrg for var in $variables_saved_for_relink; do 10754213fdd94Smrg if eval test -z \"\${$var+set}\"; then 10755213fdd94Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10756213fdd94Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10757213fdd94Smrg relink_command="$var=; export $var; $relink_command" 10758ef6fb4a5Smrg else 10759213fdd94Smrg func_quote_for_eval "$var_value" 10760213fdd94Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10761ef6fb4a5Smrg fi 10762213fdd94Smrg done 10763213fdd94Smrg # Quote the link command for shipping. 1076497ee6427Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10765213fdd94Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1076697ee6427Smrg if test yes = "$hardcode_automatic"; then 10767213fdd94Smrg relink_command= 10768213fdd94Smrg fi 10769301ea0f4Smrg 10770213fdd94Smrg # Only create the output if not a dry run. 10771213fdd94Smrg $opt_dry_run || { 10772213fdd94Smrg for installed in no yes; do 1077397ee6427Smrg if test yes = "$installed"; then 10774213fdd94Smrg if test -z "$install_libdir"; then 10775213fdd94Smrg break 10776213fdd94Smrg fi 1077797ee6427Smrg output=$output_objdir/${outputname}i 10778213fdd94Smrg # Replace all uninstalled libtool libraries with the installed ones 10779213fdd94Smrg newdependency_libs= 10780213fdd94Smrg for deplib in $dependency_libs; do 10781213fdd94Smrg case $deplib in 10782213fdd94Smrg *.la) 10783213fdd94Smrg func_basename "$deplib" 1078497ee6427Smrg name=$func_basename_result 10785213fdd94Smrg func_resolve_sysroot "$deplib" 1078697ee6427Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10787213fdd94Smrg test -z "$libdir" && \ 1078897ee6427Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 10789213fdd94Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10790213fdd94Smrg ;; 10791213fdd94Smrg -L*) 10792213fdd94Smrg func_stripname -L '' "$deplib" 10793213fdd94Smrg func_replace_sysroot "$func_stripname_result" 10794213fdd94Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10795213fdd94Smrg ;; 10796213fdd94Smrg -R*) 10797213fdd94Smrg func_stripname -R '' "$deplib" 10798213fdd94Smrg func_replace_sysroot "$func_stripname_result" 10799213fdd94Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10800213fdd94Smrg ;; 10801213fdd94Smrg *) func_append newdependency_libs " $deplib" ;; 10802213fdd94Smrg esac 10803213fdd94Smrg done 1080497ee6427Smrg dependency_libs=$newdependency_libs 10805213fdd94Smrg newdlfiles= 10806213fdd94Smrg 10807213fdd94Smrg for lib in $dlfiles; do 10808213fdd94Smrg case $lib in 10809213fdd94Smrg *.la) 10810213fdd94Smrg func_basename "$lib" 1081197ee6427Smrg name=$func_basename_result 1081297ee6427Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10813213fdd94Smrg test -z "$libdir" && \ 1081497ee6427Smrg func_fatal_error "'$lib' is not a valid libtool archive" 10815213fdd94Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10816213fdd94Smrg ;; 10817213fdd94Smrg *) func_append newdlfiles " $lib" ;; 10818213fdd94Smrg esac 10819213fdd94Smrg done 1082097ee6427Smrg dlfiles=$newdlfiles 10821213fdd94Smrg newdlprefiles= 10822213fdd94Smrg for lib in $dlprefiles; do 10823213fdd94Smrg case $lib in 10824213fdd94Smrg *.la) 10825213fdd94Smrg # Only pass preopened files to the pseudo-archive (for 10826213fdd94Smrg # eventual linking with the app. that links it) if we 10827213fdd94Smrg # didn't already link the preopened objects directly into 10828213fdd94Smrg # the library: 10829213fdd94Smrg func_basename "$lib" 1083097ee6427Smrg name=$func_basename_result 1083197ee6427Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10832213fdd94Smrg test -z "$libdir" && \ 1083397ee6427Smrg func_fatal_error "'$lib' is not a valid libtool archive" 10834213fdd94Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10835213fdd94Smrg ;; 10836213fdd94Smrg esac 10837213fdd94Smrg done 1083897ee6427Smrg dlprefiles=$newdlprefiles 10839213fdd94Smrg else 10840213fdd94Smrg newdlfiles= 10841213fdd94Smrg for lib in $dlfiles; do 10842213fdd94Smrg case $lib in 1084397ee6427Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844213fdd94Smrg *) abs=`pwd`"/$lib" ;; 10845213fdd94Smrg esac 10846213fdd94Smrg func_append newdlfiles " $abs" 10847213fdd94Smrg done 1084897ee6427Smrg dlfiles=$newdlfiles 10849213fdd94Smrg newdlprefiles= 10850213fdd94Smrg for lib in $dlprefiles; do 10851213fdd94Smrg case $lib in 1085297ee6427Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10853213fdd94Smrg *) abs=`pwd`"/$lib" ;; 10854213fdd94Smrg esac 10855213fdd94Smrg func_append newdlprefiles " $abs" 10856213fdd94Smrg done 1085797ee6427Smrg dlprefiles=$newdlprefiles 10858213fdd94Smrg fi 10859213fdd94Smrg $RM $output 10860213fdd94Smrg # place dlname in correct position for cygwin 10861213fdd94Smrg # In fact, it would be nice if we could use this code for all target 10862213fdd94Smrg # systems that can't hard-code library paths into their executables 10863213fdd94Smrg # and that have no shared library path variable independent of PATH, 10864213fdd94Smrg # but it turns out we can't easily determine that from inspecting 10865213fdd94Smrg # libtool variables, so we have to hard-code the OSs to which it 10866213fdd94Smrg # applies here; at the moment, that means platforms that use the PE 10867213fdd94Smrg # object format with DLL files. See the long comment at the top of 10868213fdd94Smrg # tests/bindir.at for full details. 10869213fdd94Smrg tdlname=$dlname 10870213fdd94Smrg case $host,$output,$installed,$module,$dlname in 10871213fdd94Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10872213fdd94Smrg # If a -bindir argument was supplied, place the dll there. 1087397ee6427Smrg if test -n "$bindir"; then 10874213fdd94Smrg func_relative_path "$install_libdir" "$bindir" 1087597ee6427Smrg tdlname=$func_relative_path_result/$dlname 10876213fdd94Smrg else 10877213fdd94Smrg # Otherwise fall back on heuristic. 10878213fdd94Smrg tdlname=../bin/$dlname 10879213fdd94Smrg fi 10880213fdd94Smrg ;; 10881213fdd94Smrg esac 10882213fdd94Smrg $ECHO > $output "\ 10883213fdd94Smrg# $outputname - a libtool library file 1088497ee6427Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10885213fdd94Smrg# 10886213fdd94Smrg# Please DO NOT delete this file! 10887213fdd94Smrg# It is necessary for linking the library. 10888301ea0f4Smrg 10889213fdd94Smrg# The name that we can dlopen(3). 10890213fdd94Smrgdlname='$tdlname' 10891301ea0f4Smrg 10892213fdd94Smrg# Names of this library. 10893213fdd94Smrglibrary_names='$library_names' 10894301ea0f4Smrg 10895213fdd94Smrg# The name of the static archive. 10896213fdd94Smrgold_library='$old_library' 10897301ea0f4Smrg 1089897ee6427Smrg# Linker flags that cannot go in dependency_libs. 10899213fdd94Smrginherited_linker_flags='$new_inherited_linker_flags' 10900301ea0f4Smrg 10901213fdd94Smrg# Libraries that this one depends upon. 10902213fdd94Smrgdependency_libs='$dependency_libs' 10903301ea0f4Smrg 10904213fdd94Smrg# Names of additional weak libraries provided by this library 10905213fdd94Smrgweak_library_names='$weak_libs' 10906301ea0f4Smrg 10907213fdd94Smrg# Version information for $libname. 10908213fdd94Smrgcurrent=$current 10909213fdd94Smrgage=$age 10910213fdd94Smrgrevision=$revision 10911301ea0f4Smrg 10912213fdd94Smrg# Is this an already installed library? 10913213fdd94Smrginstalled=$installed 10914301ea0f4Smrg 10915213fdd94Smrg# Should we warn about portability when linking against -modules? 10916213fdd94Smrgshouldnotlink=$module 10917301ea0f4Smrg 10918213fdd94Smrg# Files to dlopen/dlpreopen 10919213fdd94Smrgdlopen='$dlfiles' 10920213fdd94Smrgdlpreopen='$dlprefiles' 10921301ea0f4Smrg 10922213fdd94Smrg# Directory that this library needs to be installed in: 10923213fdd94Smrglibdir='$install_libdir'" 1092497ee6427Smrg if test no,yes = "$installed,$need_relink"; then 10925213fdd94Smrg $ECHO >> $output "\ 10926213fdd94Smrgrelink_command=\"$relink_command\"" 10927213fdd94Smrg fi 10928213fdd94Smrg done 10929213fdd94Smrg } 10930301ea0f4Smrg 10931213fdd94Smrg # Do a symbolic link so that the libtool archive can be found in 10932213fdd94Smrg # LD_LIBRARY_PATH before the program is installed. 10933213fdd94Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10934213fdd94Smrg ;; 10935213fdd94Smrg esac 10936213fdd94Smrg exit $EXIT_SUCCESS 10937213fdd94Smrg} 10938ef6fb4a5Smrg 1093997ee6427Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1094097ee6427Smrg func_mode_link ${1+"$@"} 1094197ee6427Smrgfi 10942301ea0f4Smrg 10943301ea0f4Smrg 10944213fdd94Smrg# func_mode_uninstall arg... 10945213fdd94Smrgfunc_mode_uninstall () 10946213fdd94Smrg{ 1094797ee6427Smrg $debug_cmd 1094897ee6427Smrg 1094997ee6427Smrg RM=$nonopt 10950301ea0f4Smrg files= 1095197ee6427Smrg rmforce=false 10952301ea0f4Smrg exit_status=0 10953301ea0f4Smrg 10954301ea0f4Smrg # This variable tells wrapper scripts just to set variables rather 10955301ea0f4Smrg # than running their programs. 1095697ee6427Smrg libtool_install_magic=$magic 10957301ea0f4Smrg 10958301ea0f4Smrg for arg 10959301ea0f4Smrg do 10960301ea0f4Smrg case $arg in 1096197ee6427Smrg -f) func_append RM " $arg"; rmforce=: ;; 10962213fdd94Smrg -*) func_append RM " $arg" ;; 10963213fdd94Smrg *) func_append files " $arg" ;; 10964301ea0f4Smrg esac 10965301ea0f4Smrg done 10966301ea0f4Smrg 10967213fdd94Smrg test -z "$RM" && \ 10968213fdd94Smrg func_fatal_help "you must specify an RM program" 10969301ea0f4Smrg 10970301ea0f4Smrg rmdirs= 10971301ea0f4Smrg 10972301ea0f4Smrg for file in $files; do 10973213fdd94Smrg func_dirname "$file" "" "." 1097497ee6427Smrg dir=$func_dirname_result 1097597ee6427Smrg if test . = "$dir"; then 1097697ee6427Smrg odir=$objdir 10977301ea0f4Smrg else 1097897ee6427Smrg odir=$dir/$objdir 10979301ea0f4Smrg fi 10980213fdd94Smrg func_basename "$file" 1098197ee6427Smrg name=$func_basename_result 1098297ee6427Smrg test uninstall = "$opt_mode" && odir=$dir 10983301ea0f4Smrg 10984213fdd94Smrg # Remember odir for removal later, being careful to avoid duplicates 1098597ee6427Smrg if test clean = "$opt_mode"; then 10986301ea0f4Smrg case " $rmdirs " in 10987213fdd94Smrg *" $odir "*) ;; 10988213fdd94Smrg *) func_append rmdirs " $odir" ;; 10989301ea0f4Smrg esac 10990301ea0f4Smrg fi 10991301ea0f4Smrg 10992301ea0f4Smrg # Don't error if the file doesn't exist and rm -f was used. 10993213fdd94Smrg if { test -L "$file"; } >/dev/null 2>&1 || 10994213fdd94Smrg { test -h "$file"; } >/dev/null 2>&1 || 10995213fdd94Smrg test -f "$file"; then 10996301ea0f4Smrg : 10997301ea0f4Smrg elif test -d "$file"; then 10998301ea0f4Smrg exit_status=1 10999301ea0f4Smrg continue 1100097ee6427Smrg elif $rmforce; then 11001301ea0f4Smrg continue 11002301ea0f4Smrg fi 11003301ea0f4Smrg 1100497ee6427Smrg rmfiles=$file 11005301ea0f4Smrg 11006301ea0f4Smrg case $name in 11007301ea0f4Smrg *.la) 11008301ea0f4Smrg # Possibly a libtool archive, so verify it. 11009213fdd94Smrg if func_lalib_p "$file"; then 11010213fdd94Smrg func_source $dir/$name 11011301ea0f4Smrg 11012301ea0f4Smrg # Delete the libtool libraries and symlinks. 11013301ea0f4Smrg for n in $library_names; do 11014213fdd94Smrg func_append rmfiles " $odir/$n" 11015301ea0f4Smrg done 11016213fdd94Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11017301ea0f4Smrg 1101897ee6427Smrg case $opt_mode in 11019301ea0f4Smrg clean) 11020213fdd94Smrg case " $library_names " in 11021301ea0f4Smrg *" $dlname "*) ;; 11022213fdd94Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11023301ea0f4Smrg esac 11024213fdd94Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11025301ea0f4Smrg ;; 11026301ea0f4Smrg uninstall) 11027301ea0f4Smrg if test -n "$library_names"; then 11028301ea0f4Smrg # Do each command in the postuninstall commands. 1102997ee6427Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11030301ea0f4Smrg fi 11031301ea0f4Smrg 11032301ea0f4Smrg if test -n "$old_library"; then 11033301ea0f4Smrg # Do each command in the old_postuninstall commands. 1103497ee6427Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11035301ea0f4Smrg fi 11036301ea0f4Smrg # FIXME: should reinstall the best remaining shared library. 11037301ea0f4Smrg ;; 11038301ea0f4Smrg esac 11039301ea0f4Smrg fi 11040301ea0f4Smrg ;; 11041301ea0f4Smrg 11042301ea0f4Smrg *.lo) 11043301ea0f4Smrg # Possibly a libtool object, so verify it. 11044213fdd94Smrg if func_lalib_p "$file"; then 11045301ea0f4Smrg 11046301ea0f4Smrg # Read the .lo file 11047213fdd94Smrg func_source $dir/$name 11048301ea0f4Smrg 11049301ea0f4Smrg # Add PIC object to the list of files to remove. 1105097ee6427Smrg if test -n "$pic_object" && test none != "$pic_object"; then 11051213fdd94Smrg func_append rmfiles " $dir/$pic_object" 11052301ea0f4Smrg fi 11053301ea0f4Smrg 11054301ea0f4Smrg # Add non-PIC object to the list of files to remove. 1105597ee6427Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11056213fdd94Smrg func_append rmfiles " $dir/$non_pic_object" 11057301ea0f4Smrg fi 11058301ea0f4Smrg fi 11059301ea0f4Smrg ;; 11060301ea0f4Smrg 11061301ea0f4Smrg *) 1106297ee6427Smrg if test clean = "$opt_mode"; then 11063301ea0f4Smrg noexename=$name 11064301ea0f4Smrg case $file in 11065301ea0f4Smrg *.exe) 11066213fdd94Smrg func_stripname '' '.exe' "$file" 11067213fdd94Smrg file=$func_stripname_result 11068213fdd94Smrg func_stripname '' '.exe' "$name" 11069213fdd94Smrg noexename=$func_stripname_result 11070301ea0f4Smrg # $file with .exe has already been added to rmfiles, 11071301ea0f4Smrg # add $file without .exe 11072213fdd94Smrg func_append rmfiles " $file" 11073301ea0f4Smrg ;; 11074301ea0f4Smrg esac 11075301ea0f4Smrg # Do a test to see if this is a libtool program. 11076213fdd94Smrg if func_ltwrapper_p "$file"; then 11077213fdd94Smrg if func_ltwrapper_executable_p "$file"; then 11078213fdd94Smrg func_ltwrapper_scriptname "$file" 11079213fdd94Smrg relink_command= 11080213fdd94Smrg func_source $func_ltwrapper_scriptname_result 11081213fdd94Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11082213fdd94Smrg else 11083213fdd94Smrg relink_command= 11084213fdd94Smrg func_source $dir/$noexename 11085213fdd94Smrg fi 11086301ea0f4Smrg 11087301ea0f4Smrg # note $name still contains .exe if it was in $file originally 11088301ea0f4Smrg # as does the version of $file that was added into $rmfiles 1108997ee6427Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1109097ee6427Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 11091213fdd94Smrg func_append rmfiles " $odir/lt-$name" 11092301ea0f4Smrg fi 1109397ee6427Smrg if test "X$noexename" != "X$name"; then 1109497ee6427Smrg func_append rmfiles " $odir/lt-$noexename.c" 11095301ea0f4Smrg fi 11096301ea0f4Smrg fi 11097301ea0f4Smrg fi 11098301ea0f4Smrg ;; 11099301ea0f4Smrg esac 11100213fdd94Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11101301ea0f4Smrg done 11102301ea0f4Smrg 1110397ee6427Smrg # Try to remove the $objdir's in the directories where we deleted files 11104301ea0f4Smrg for dir in $rmdirs; do 11105301ea0f4Smrg if test -d "$dir"; then 11106213fdd94Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11107301ea0f4Smrg fi 11108301ea0f4Smrg done 11109301ea0f4Smrg 11110301ea0f4Smrg exit $exit_status 11111213fdd94Smrg} 11112301ea0f4Smrg 1111397ee6427Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1111497ee6427Smrg func_mode_uninstall ${1+"$@"} 1111597ee6427Smrgfi 111160cc67336Smrg 11117213fdd94Smrgtest -z "$opt_mode" && { 1111897ee6427Smrg help=$generic_help 11119213fdd94Smrg func_fatal_help "you must specify a MODE" 11120213fdd94Smrg} 11121213fdd94Smrg 11122213fdd94Smrgtest -z "$exec_cmd" && \ 1112397ee6427Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11124301ea0f4Smrg 11125301ea0f4Smrgif test -n "$exec_cmd"; then 11126213fdd94Smrg eval exec "$exec_cmd" 11127301ea0f4Smrg exit $EXIT_FAILURE 11128301ea0f4Smrgfi 11129301ea0f4Smrg 11130213fdd94Smrgexit $exit_status 11131ef6fb4a5Smrg 11132301ea0f4Smrg 11133301ea0f4Smrg# The TAGs below are defined such that we never get into a situation 1113497ee6427Smrg# where we disable both kinds of libraries. Given conflicting 11135301ea0f4Smrg# choices, we go for a static library, that is the most portable, 11136301ea0f4Smrg# since we can't tell whether shared libraries were disabled because 11137301ea0f4Smrg# the user asked for that or because the platform doesn't support 11138301ea0f4Smrg# them. This is particularly important on AIX, because we don't 11139301ea0f4Smrg# support having both static and shared libraries enabled at the same 11140301ea0f4Smrg# time on that platform, so we default to a shared-only configuration. 11141301ea0f4Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11142301ea0f4Smrg# configuration. But we'll never go from static-only to shared-only. 11143301ea0f4Smrg 11144301ea0f4Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11145213fdd94Smrgbuild_libtool_libs=no 11146213fdd94Smrgbuild_old_libs=yes 11147301ea0f4Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11148301ea0f4Smrg 11149301ea0f4Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11150213fdd94Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11151301ea0f4Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11152301ea0f4Smrg 11153301ea0f4Smrg# Local Variables: 11154301ea0f4Smrg# mode:shell-script 11155301ea0f4Smrg# sh-indentation:2 11156301ea0f4Smrg# End: 11157