154cef2ddSmrg#! /usr/bin/env sh 254044362Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 354cef2ddSmrg## by inline-source v2019-02-19.15 44cd6a3aeSmrg 554cef2ddSmrg# libtool (GNU libtool) 2.4.7 654044362Smrg# Provide generalized library-building support services. 74cd6a3aeSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 84cd6a3aeSmrg 954cef2ddSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 104cd6a3aeSmrg# This is free software; see the source for copying conditions. There is NO 114cd6a3aeSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 124cd6a3aeSmrg 134cd6a3aeSmrg# GNU Libtool is free software; you can redistribute it and/or modify 148c9fbc29Smrg# it under the terms of the GNU General Public License as published by 158c9fbc29Smrg# the Free Software Foundation; either version 2 of the License, or 168c9fbc29Smrg# (at your option) any later version. 178c9fbc29Smrg# 184cd6a3aeSmrg# As a special exception to the GNU General Public License, 194cd6a3aeSmrg# if you distribute this file as part of a program or library that 204cd6a3aeSmrg# is built using GNU Libtool, you may include this file under the 214cd6a3aeSmrg# same distribution terms that you use for the rest of that program. 224cd6a3aeSmrg# 234cd6a3aeSmrg# GNU Libtool is distributed in the hope that it will be useful, but 248c9fbc29Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 258c9fbc29Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 268c9fbc29Smrg# General Public License for more details. 278c9fbc29Smrg# 288c9fbc29Smrg# You should have received a copy of the GNU General Public License 2954044362Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 308c9fbc29Smrg 318c9fbc29Smrg 324cd6a3aeSmrgPROGRAM=libtool 338c9fbc29SmrgPACKAGE=libtool 3454cef2ddSmrgVERSION=2.4.7 3554cef2ddSmrgpackage_revision=2.4.7 364e411241Smrg 3754044362Smrg 3854044362Smrg## ------ ## 3954044362Smrg## Usage. ## 4054044362Smrg## ------ ## 4154044362Smrg 4254044362Smrg# Run './libtool --help' for help with using this script from the 4354044362Smrg# command line. 4454044362Smrg 4554044362Smrg 4654044362Smrg## ------------------------------- ## 4754044362Smrg## User overridable command paths. ## 4854044362Smrg## ------------------------------- ## 4954044362Smrg 5054044362Smrg# After configure completes, it has a better idea of some of the 5154044362Smrg# shell tools we need than the defaults used by the functions shared 5254044362Smrg# with bootstrap, so set those here where they can still be over- 5354044362Smrg# ridden by the user, but otherwise take precedence. 5454044362Smrg 5554044362Smrg: ${AUTOCONF="autoconf"} 5654044362Smrg: ${AUTOMAKE="automake"} 5754044362Smrg 5854044362Smrg 5954044362Smrg## -------------------------- ## 6054044362Smrg## Source external libraries. ## 6154044362Smrg## -------------------------- ## 6254044362Smrg 6354044362Smrg# Much of our low-level functionality needs to be sourced from external 6454044362Smrg# libraries, which are installed to $pkgauxdir. 6554044362Smrg 6654044362Smrg# Set a version string for this script. 6754cef2ddSmrgscriptversion=2019-02-19.15; # UTC 6854044362Smrg 6954044362Smrg# General shell script boiler plate, and helper functions. 7054044362Smrg# Written by Gary V. Vaughan, 2004 7154044362Smrg 7254cef2ddSmrg# This is free software. There is NO warranty; not even for 7354cef2ddSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7454cef2ddSmrg# 7554cef2ddSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 7654cef2ddSmrg# 7754cef2ddSmrg# This file is dual licensed under the terms of the MIT license 7854cef2ddSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 7954cef2ddSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 8054cef2ddSmrg# these licenses when using or redistributing this software or any of 8154cef2ddSmrg# the files within it. See the URLs above, or the file `LICENSE` 8254cef2ddSmrg# included in the Bootstrap distribution for the full license texts. 8354044362Smrg 8454cef2ddSmrg# Please report bugs or propose patches to: 8554cef2ddSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 8654044362Smrg 8754044362Smrg 8854044362Smrg## ------ ## 8954044362Smrg## Usage. ## 9054044362Smrg## ------ ## 9154044362Smrg 9254044362Smrg# Evaluate this file near the top of your script to gain access to 9354044362Smrg# the functions and variables defined here: 9454044362Smrg# 9554044362Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 9654044362Smrg# 9754044362Smrg# If you need to override any of the default environment variable 9854044362Smrg# settings, do that before evaluating this file. 9954044362Smrg 10054044362Smrg 10154044362Smrg## -------------------- ## 10254044362Smrg## Shell normalisation. ## 10354044362Smrg## -------------------- ## 10454044362Smrg 10554044362Smrg# Some shells need a little help to be as Bourne compatible as possible. 10654044362Smrg# Before doing anything else, make sure all that help has been provided! 10754044362Smrg 10854044362SmrgDUALCASE=1; export DUALCASE # for MKS sh 10954044362Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1104e411241Smrg emulate sh 1114e411241Smrg NULLCMD=: 11254044362Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1134e411241Smrg # is contrary to our usage. Disable this feature. 1144e411241Smrg alias -g '${1+"$@"}'='"$@"' 1158c9fbc29Smrg setopt NO_GLOB_SUBST 1164e411241Smrgelse 11754044362Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1188c9fbc29Smrgfi 1198c9fbc29Smrg 12054044362Smrg# NLS nuisances: We save the old values in case they are required later. 12154044362Smrg_G_user_locale= 12254044362Smrg_G_safe_locale= 12354044362Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1244e411241Smrgdo 12554044362Smrg eval "if test set = \"\${$_G_var+set}\"; then 12654044362Smrg save_$_G_var=\$$_G_var 12754044362Smrg $_G_var=C 12854044362Smrg export $_G_var 12954044362Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13054044362Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1314e411241Smrg fi" 1324e411241Smrgdone 13354cef2ddSmrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 13454cef2ddSmrg# in case the environment reset is needed later and the $save_* variant is not 13554cef2ddSmrg# defined (see the code above). 13654cef2ddSmrgLC_ALL=C 13754cef2ddSmrgLANGUAGE=C 13854cef2ddSmrgexport LANGUAGE LC_ALL 1394e411241Smrg 14054044362Smrg# Make sure IFS has a sensible default 14154044362Smrgsp=' ' 14254044362Smrgnl=' 14354044362Smrg' 14454044362SmrgIFS="$sp $nl" 14554044362Smrg 14654044362Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 14754044362Smrgif test "${PATH_SEPARATOR+set}" != set; then 14854044362Smrg PATH_SEPARATOR=: 14954044362Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15054044362Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15154044362Smrg PATH_SEPARATOR=';' 15254044362Smrg } 15354044362Smrgfi 1544cd6a3aeSmrg 1554cd6a3aeSmrg 15654cef2ddSmrg# func_unset VAR 15754cef2ddSmrg# -------------- 15854cef2ddSmrg# Portably unset VAR. 15954cef2ddSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return 16054cef2ddSmrg# status if VAR is already unset, which might be problematic if the 16154cef2ddSmrg# statement is used at the end of a function (thus poisoning its return 16254cef2ddSmrg# value) or when 'set -e' is active (causing even a spurious abort of 16354cef2ddSmrg# the script in this case). 16454cef2ddSmrgfunc_unset () 16554cef2ddSmrg{ 16654cef2ddSmrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 16754cef2ddSmrg} 16854cef2ddSmrg 16954cef2ddSmrg 17054cef2ddSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 17154cef2ddSmrgfunc_unset CDPATH 17254cef2ddSmrg 17354cef2ddSmrg# Make sure ${,E,F}GREP behave sanely. 17454cef2ddSmrgfunc_unset GREP_OPTIONS 17554cef2ddSmrg 1764cd6a3aeSmrg 17754044362Smrg## ------------------------- ## 17854044362Smrg## Locate command utilities. ## 17954044362Smrg## ------------------------- ## 18054044362Smrg 18154044362Smrg 18254044362Smrg# func_executable_p FILE 18354044362Smrg# ---------------------- 18454044362Smrg# Check that FILE is an executable regular file. 18554044362Smrgfunc_executable_p () 18654044362Smrg{ 18754044362Smrg test -f "$1" && test -x "$1" 18854044362Smrg} 18954044362Smrg 19054044362Smrg 19154044362Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 19254044362Smrg# -------------------------------------------- 19354044362Smrg# Search for either a program that responds to --version with output 19454044362Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 19554044362Smrg# trying all the directories in PATH with each of the elements of 19654044362Smrg# PROGS_LIST. 19754044362Smrg# 19854044362Smrg# CHECK_FUNC should accept the path to a candidate program, and 19954044362Smrg# set $func_check_prog_result if it truncates its output less than 20054044362Smrg# $_G_path_prog_max characters. 20154044362Smrgfunc_path_progs () 20254044362Smrg{ 20354044362Smrg _G_progs_list=$1 20454044362Smrg _G_check_func=$2 20554044362Smrg _G_PATH=${3-"$PATH"} 20654044362Smrg 20754044362Smrg _G_path_prog_max=0 20854044362Smrg _G_path_prog_found=false 20954044362Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 21054044362Smrg for _G_dir in $_G_PATH; do 21154044362Smrg IFS=$_G_save_IFS 21254044362Smrg test -z "$_G_dir" && _G_dir=. 21354044362Smrg for _G_prog_name in $_G_progs_list; do 21454044362Smrg for _exeext in '' .EXE; do 21554044362Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 21654044362Smrg func_executable_p "$_G_path_prog" || continue 21754044362Smrg case `"$_G_path_prog" --version 2>&1` in 21854044362Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 21954044362Smrg *) $_G_check_func $_G_path_prog 22054044362Smrg func_path_progs_result=$func_check_prog_result 22154044362Smrg ;; 22254044362Smrg esac 22354044362Smrg $_G_path_prog_found && break 3 22454044362Smrg done 22554044362Smrg done 22654044362Smrg done 22754044362Smrg IFS=$_G_save_IFS 22854044362Smrg test -z "$func_path_progs_result" && { 22954044362Smrg echo "no acceptable sed could be found in \$PATH" >&2 23054044362Smrg exit 1 23154044362Smrg } 23254044362Smrg} 23354044362Smrg 23454044362Smrg 23554044362Smrg# We want to be able to use the functions in this file before configure 23654044362Smrg# has figured out where the best binaries are kept, which means we have 23754044362Smrg# to search for them ourselves - except when the results are already set 23854044362Smrg# where we skip the searches. 23954044362Smrg 24054044362Smrg# Unless the user overrides by setting SED, search the path for either GNU 24154044362Smrg# sed, or the sed that truncates its output the least. 24254044362Smrgtest -z "$SED" && { 24354044362Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 24454044362Smrg for _G_i in 1 2 3 4 5 6 7; do 24554044362Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 24654044362Smrg done 24754044362Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 24854044362Smrg _G_sed_script= 24954044362Smrg 25054044362Smrg func_check_prog_sed () 25154044362Smrg { 25254044362Smrg _G_path_prog=$1 25354044362Smrg 25454044362Smrg _G_count=0 25554044362Smrg printf 0123456789 >conftest.in 25654044362Smrg while : 25754044362Smrg do 25854044362Smrg cat conftest.in conftest.in >conftest.tmp 25954044362Smrg mv conftest.tmp conftest.in 26054044362Smrg cp conftest.in conftest.nl 26154044362Smrg echo '' >> conftest.nl 26254044362Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 26354044362Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 26454044362Smrg _G_count=`expr $_G_count + 1` 26554044362Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 26654044362Smrg # Best one so far, save it but keep looking for a better one 26754044362Smrg func_check_prog_result=$_G_path_prog 26854044362Smrg _G_path_prog_max=$_G_count 26954044362Smrg fi 27054044362Smrg # 10*(2^10) chars as input seems more than enough 27154044362Smrg test 10 -lt "$_G_count" && break 27254044362Smrg done 27354044362Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 27454044362Smrg } 27554044362Smrg 27654cef2ddSmrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 27754044362Smrg rm -f conftest.sed 27854044362Smrg SED=$func_path_progs_result 27954044362Smrg} 28054044362Smrg 28154044362Smrg 28254044362Smrg# Unless the user overrides by setting GREP, search the path for either GNU 28354044362Smrg# grep, or the grep that truncates its output the least. 28454044362Smrgtest -z "$GREP" && { 28554044362Smrg func_check_prog_grep () 28654044362Smrg { 28754044362Smrg _G_path_prog=$1 28854044362Smrg 28954044362Smrg _G_count=0 29054044362Smrg _G_path_prog_max=0 29154044362Smrg printf 0123456789 >conftest.in 29254044362Smrg while : 29354044362Smrg do 29454044362Smrg cat conftest.in conftest.in >conftest.tmp 29554044362Smrg mv conftest.tmp conftest.in 29654044362Smrg cp conftest.in conftest.nl 29754044362Smrg echo 'GREP' >> conftest.nl 29854044362Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 29954044362Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 30054044362Smrg _G_count=`expr $_G_count + 1` 30154044362Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 30254044362Smrg # Best one so far, save it but keep looking for a better one 30354044362Smrg func_check_prog_result=$_G_path_prog 30454044362Smrg _G_path_prog_max=$_G_count 30554044362Smrg fi 30654044362Smrg # 10*(2^10) chars as input seems more than enough 30754044362Smrg test 10 -lt "$_G_count" && break 30854044362Smrg done 30954044362Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 31054044362Smrg } 31154044362Smrg 31254cef2ddSmrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 31354044362Smrg GREP=$func_path_progs_result 31454044362Smrg} 31554044362Smrg 31654044362Smrg 31754044362Smrg## ------------------------------- ## 31854044362Smrg## User overridable command paths. ## 31954044362Smrg## ------------------------------- ## 32054044362Smrg 32154044362Smrg# All uppercase variable names are used for environment variables. These 32254044362Smrg# variables can be overridden by the user before calling a script that 32354044362Smrg# uses them if a suitable command of that name is not already available 32454044362Smrg# in the command search PATH. 3254cd6a3aeSmrg 3264cd6a3aeSmrg: ${CP="cp -f"} 32754044362Smrg: ${ECHO="printf %s\n"} 32854044362Smrg: ${EGREP="$GREP -E"} 32954044362Smrg: ${FGREP="$GREP -F"} 33054044362Smrg: ${LN_S="ln -s"} 3314cd6a3aeSmrg: ${MAKE="make"} 3324cd6a3aeSmrg: ${MKDIR="mkdir"} 3334cd6a3aeSmrg: ${MV="mv -f"} 3344cd6a3aeSmrg: ${RM="rm -f"} 3354cd6a3aeSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3368c9fbc29Smrg 3378c9fbc29Smrg 33854044362Smrg## -------------------- ## 33954044362Smrg## Useful sed snippets. ## 34054044362Smrg## -------------------- ## 3414cd6a3aeSmrg 34254044362Smrgsed_dirname='s|/[^/]*$||' 34354044362Smrgsed_basename='s|^.*/||' 3444cd6a3aeSmrg 34554044362Smrg# Sed substitution that helps us do robust quoting. It backslashifies 34654044362Smrg# metacharacters that are still active within double-quoted strings. 34754044362Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3484cd6a3aeSmrg 34954044362Smrg# Same as above, but do not quote variable references. 35054044362Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3514cd6a3aeSmrg 35254044362Smrg# Sed substitution that turns a string into a regex matching for the 35354044362Smrg# string literally. 35454044362Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3554cd6a3aeSmrg 35654044362Smrg# Sed substitution that converts a w32 file name or path 35754044362Smrg# that contains forward slashes, into one that contains 35854044362Smrg# (escaped) backslashes. A very naive implementation. 35954044362Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 36054044362Smrg 36154044362Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 36254044362Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 36354044362Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 36454044362Smrg# expansion. Since each input '\' is now two '\'s, look for any number 36554044362Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 36654044362Smrg_G_bs='\\' 36754044362Smrg_G_bs2='\\\\' 36854044362Smrg_G_bs4='\\\\\\\\' 36954044362Smrg_G_dollar='\$' 37054044362Smrgsed_double_backslash="\ 37154044362Smrg s/$_G_bs4/&\\ 37254044362Smrg/g 37354044362Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 37454044362Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 37554044362Smrg s/\n//g" 3764cd6a3aeSmrg 37754cef2ddSmrg# require_check_ifs_backslash 37854cef2ddSmrg# --------------------------- 37954cef2ddSmrg# Check if we can use backslash as IFS='\' separator, and set 38054cef2ddSmrg# $check_ifs_backshlash_broken to ':' or 'false'. 38154cef2ddSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 38254cef2ddSmrgfunc_require_check_ifs_backslash () 38354cef2ddSmrg{ 38454cef2ddSmrg _G_save_IFS=$IFS 38554cef2ddSmrg IFS='\' 38654cef2ddSmrg _G_check_ifs_backshlash='a\\b' 38754cef2ddSmrg for _G_i in $_G_check_ifs_backshlash 38854cef2ddSmrg do 38954cef2ddSmrg case $_G_i in 39054cef2ddSmrg a) 39154cef2ddSmrg check_ifs_backshlash_broken=false 39254cef2ddSmrg ;; 39354cef2ddSmrg '') 39454cef2ddSmrg break 39554cef2ddSmrg ;; 39654cef2ddSmrg *) 39754cef2ddSmrg check_ifs_backshlash_broken=: 39854cef2ddSmrg break 39954cef2ddSmrg ;; 40054cef2ddSmrg esac 40154cef2ddSmrg done 40254cef2ddSmrg IFS=$_G_save_IFS 40354cef2ddSmrg require_check_ifs_backslash=: 40454cef2ddSmrg} 40554cef2ddSmrg 4064cd6a3aeSmrg 40754044362Smrg## ----------------- ## 40854044362Smrg## Global variables. ## 40954044362Smrg## ----------------- ## 4104cd6a3aeSmrg 41154044362Smrg# Except for the global variables explicitly listed below, the following 41254044362Smrg# functions in the '^func_' namespace, and the '^require_' namespace 41354044362Smrg# variables initialised in the 'Resource management' section, sourcing 41454044362Smrg# this file will not pollute your global namespace with anything 41554044362Smrg# else. There's no portable way to scope variables in Bourne shell 41654044362Smrg# though, so actually running these functions will sometimes place 41754044362Smrg# results into a variable named after the function, and often use 41854044362Smrg# temporary variables in the '^_G_' namespace. If you are careful to 41954044362Smrg# avoid using those namespaces casually in your sourcing script, things 42054044362Smrg# should continue to work as you expect. And, of course, you can freely 42154044362Smrg# overwrite any of the functions or variables defined here before 42254044362Smrg# calling anything to customize them. 4234cd6a3aeSmrg 42454044362SmrgEXIT_SUCCESS=0 42554044362SmrgEXIT_FAILURE=1 42654044362SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 42754044362SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 4284cd6a3aeSmrg 42954044362Smrg# Allow overriding, eg assuming that you follow the convention of 43054044362Smrg# putting '$debug_cmd' at the start of all your functions, you can get 43154044362Smrg# bash to show function call trace with: 43254044362Smrg# 43354044362Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 43454044362Smrgdebug_cmd=${debug_cmd-":"} 43554044362Smrgexit_cmd=: 4364cd6a3aeSmrg 43754044362Smrg# By convention, finish your script with: 43854044362Smrg# 43954044362Smrg# exit $exit_status 44054044362Smrg# 44154044362Smrg# so that you can set exit_status to non-zero if you want to indicate 44254044362Smrg# something went wrong during execution without actually bailing out at 44354044362Smrg# the point of failure. 44454044362Smrgexit_status=$EXIT_SUCCESS 4454cd6a3aeSmrg 44654044362Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 44754044362Smrg# is ksh but when the shell is invoked as "sh" and the current value of 44854044362Smrg# the _XPG environment variable is not equal to 1 (one), the special 44954044362Smrg# positional parameter $0, within a function call, is the name of the 45054044362Smrg# function. 45154044362Smrgprogpath=$0 4524cd6a3aeSmrg 45354044362Smrg# The name of this program. 45454044362Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4554cd6a3aeSmrg 45654044362Smrg# Make sure we have an absolute progpath for reexecution: 4574cd6a3aeSmrgcase $progpath in 4584cd6a3aeSmrg [\\/]*|[A-Za-z]:\\*) ;; 4594cd6a3aeSmrg *[\\/]*) 46054044362Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4614cd6a3aeSmrg progdir=`cd "$progdir" && pwd` 46254044362Smrg progpath=$progdir/$progname 4634cd6a3aeSmrg ;; 4644cd6a3aeSmrg *) 46554044362Smrg _G_IFS=$IFS 46670728a38Smrg IFS=${PATH_SEPARATOR-:} 4674cd6a3aeSmrg for progdir in $PATH; do 46854044362Smrg IFS=$_G_IFS 4694cd6a3aeSmrg test -x "$progdir/$progname" && break 4704cd6a3aeSmrg done 47154044362Smrg IFS=$_G_IFS 4724cd6a3aeSmrg test -n "$progdir" || progdir=`pwd` 47354044362Smrg progpath=$progdir/$progname 4744cd6a3aeSmrg ;; 4754cd6a3aeSmrgesac 4764cd6a3aeSmrg 4774cd6a3aeSmrg 47854044362Smrg## ----------------- ## 47954044362Smrg## Standard options. ## 48054044362Smrg## ----------------- ## 4814cd6a3aeSmrg 48254044362Smrg# The following options affect the operation of the functions defined 48354044362Smrg# below, and should be set appropriately depending on run-time para- 48454044362Smrg# meters passed on the command line. 4854cd6a3aeSmrg 4864cd6a3aeSmrgopt_dry_run=false 4874cd6a3aeSmrgopt_quiet=false 4884cd6a3aeSmrgopt_verbose=false 4894cd6a3aeSmrg 49054044362Smrg# Categories 'all' and 'none' are always available. Append any others 49154044362Smrg# you will pass as the first argument to func_warning from your own 49254044362Smrg# code. 49354044362Smrgwarning_categories= 4944cd6a3aeSmrg 49554044362Smrg# By default, display warnings according to 'opt_warning_types'. Set 49654044362Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 49754044362Smrg# treat the next displayed warning as a fatal error. 49854044362Smrgwarning_func=func_warn_and_continue 4994cd6a3aeSmrg 50054044362Smrg# Set to 'all' to display all warnings, 'none' to suppress all 50154044362Smrg# warnings, or a space delimited list of some subset of 50254044362Smrg# 'warning_categories' to display only the listed warnings. 50354044362Smrgopt_warning_types=all 5044cd6a3aeSmrg 5054cd6a3aeSmrg 50654044362Smrg## -------------------- ## 50754044362Smrg## Resource management. ## 50854044362Smrg## -------------------- ## 5094cd6a3aeSmrg 51054044362Smrg# This section contains definitions for functions that each ensure a 51154044362Smrg# particular resource (a file, or a non-empty configuration variable for 51254044362Smrg# example) is available, and if appropriate to extract default values 51354044362Smrg# from pertinent package files. Call them using their associated 51454044362Smrg# 'require_*' variable to ensure that they are executed, at most, once. 51554044362Smrg# 51654044362Smrg# It's entirely deliberate that calling these functions can set 51754044362Smrg# variables that don't obey the namespace limitations obeyed by the rest 51854044362Smrg# of this file, in order that that they be as useful as possible to 51954044362Smrg# callers. 5204cd6a3aeSmrg 5214cd6a3aeSmrg 52254044362Smrg# require_term_colors 52354044362Smrg# ------------------- 52454044362Smrg# Allow display of bold text on terminals that support it. 52554044362Smrgrequire_term_colors=func_require_term_colors 52654044362Smrgfunc_require_term_colors () 5274cd6a3aeSmrg{ 52854044362Smrg $debug_cmd 52954044362Smrg 53054044362Smrg test -t 1 && { 53154044362Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 53254044362Smrg # precedence, because most terminfo databases neglect to describe 53354044362Smrg # whether color sequences are supported. 53454044362Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 53554044362Smrg 53654044362Smrg if test 1 = "$USE_ANSI_COLORS"; then 53754044362Smrg # Standard ANSI escape sequences 53854044362Smrg tc_reset='[0m' 53954044362Smrg tc_bold='[1m'; tc_standout='[7m' 54054044362Smrg tc_red='[31m'; tc_green='[32m' 54154044362Smrg tc_blue='[34m'; tc_cyan='[36m' 54254044362Smrg else 54354044362Smrg # Otherwise trust the terminfo database after all. 54454044362Smrg test -n "`tput sgr0 2>/dev/null`" && { 54554044362Smrg tc_reset=`tput sgr0` 54654044362Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 54754044362Smrg tc_standout=$tc_bold 54854044362Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 54954044362Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 55054044362Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 55154044362Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 55254044362Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 55354044362Smrg } 55454044362Smrg fi 55554044362Smrg } 5564cd6a3aeSmrg 55754044362Smrg require_term_colors=: 5584cd6a3aeSmrg} 5594cd6a3aeSmrg 5604cd6a3aeSmrg 56154044362Smrg## ----------------- ## 56254044362Smrg## Function library. ## 56354044362Smrg## ----------------- ## 56454044362Smrg 56554044362Smrg# This section contains a variety of useful functions to call in your 56654044362Smrg# scripts. Take note of the portable wrappers for features provided by 56754044362Smrg# some modern shells, which will fall back to slower equivalents on 56854044362Smrg# less featureful shells. 56954044362Smrg 57054044362Smrg 57154044362Smrg# func_append VAR VALUE 57254044362Smrg# --------------------- 57354044362Smrg# Append VALUE onto the existing contents of VAR. 57454044362Smrg 57554044362Smrg # We should try to minimise forks, especially on Windows where they are 57654044362Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 57754044362Smrg # being used: 57854044362Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 57954044362Smrg : ${_G_HAVE_ARITH_OP="yes"} 58054044362Smrg : ${_G_HAVE_XSI_OPS="yes"} 58154044362Smrg # The += operator was introduced in bash 3.1 58254044362Smrg case $BASH_VERSION in 58354044362Smrg [12].* | 3.0 | 3.0*) ;; 58454044362Smrg *) 58554044362Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 58654044362Smrg ;; 58754044362Smrg esac 58854044362Smrg fi 58954044362Smrg 59054044362Smrg # _G_HAVE_PLUSEQ_OP 59154044362Smrg # Can be empty, in which case the shell is probed, "yes" if += is 59254044362Smrg # useable or anything else if it does not work. 59354044362Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 59454044362Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 59554044362Smrg && _G_HAVE_PLUSEQ_OP=yes 59654044362Smrg 59754044362Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 59854044362Smrgthen 59954044362Smrg # This is an XSI compatible shell, allowing a faster implementation... 60054044362Smrg eval 'func_append () 60154044362Smrg { 60254044362Smrg $debug_cmd 60354044362Smrg 60454044362Smrg eval "$1+=\$2" 60554044362Smrg }' 60654044362Smrgelse 60754044362Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 60854044362Smrg func_append () 60954044362Smrg { 61054044362Smrg $debug_cmd 61154044362Smrg 61254044362Smrg eval "$1=\$$1\$2" 61354044362Smrg } 61454044362Smrgfi 61554044362Smrg 61654044362Smrg 61754044362Smrg# func_append_quoted VAR VALUE 61854044362Smrg# ---------------------------- 61954044362Smrg# Quote VALUE and append to the end of shell variable VAR, separated 62054044362Smrg# by a space. 62154044362Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 62254044362Smrg eval 'func_append_quoted () 62354044362Smrg { 62454044362Smrg $debug_cmd 62554044362Smrg 62654cef2ddSmrg func_quote_arg pretty "$2" 62754cef2ddSmrg eval "$1+=\\ \$func_quote_arg_result" 62854044362Smrg }' 62954044362Smrgelse 63054044362Smrg func_append_quoted () 63154044362Smrg { 63254044362Smrg $debug_cmd 63354044362Smrg 63454cef2ddSmrg func_quote_arg pretty "$2" 63554cef2ddSmrg eval "$1=\$$1\\ \$func_quote_arg_result" 63654044362Smrg } 63754044362Smrgfi 63854044362Smrg 63954044362Smrg 64054044362Smrg# func_append_uniq VAR VALUE 64154044362Smrg# -------------------------- 64254044362Smrg# Append unique VALUE onto the existing contents of VAR, assuming 64354044362Smrg# entries are delimited by the first character of VALUE. For example: 64454044362Smrg# 64554044362Smrg# func_append_uniq options " --another-option option-argument" 64654044362Smrg# 64754044362Smrg# will only append to $options if " --another-option option-argument " 64854044362Smrg# is not already present somewhere in $options already (note spaces at 64954044362Smrg# each end implied by leading space in second argument). 65054044362Smrgfunc_append_uniq () 65154044362Smrg{ 65254044362Smrg $debug_cmd 65354044362Smrg 65454044362Smrg eval _G_current_value='`$ECHO $'$1'`' 65554044362Smrg _G_delim=`expr "$2" : '\(.\)'` 65654044362Smrg 65754044362Smrg case $_G_delim$_G_current_value$_G_delim in 65854044362Smrg *"$2$_G_delim"*) ;; 65954044362Smrg *) func_append "$@" ;; 66054044362Smrg esac 66154044362Smrg} 66254044362Smrg 66354044362Smrg 66454044362Smrg# func_arith TERM... 66554044362Smrg# ------------------ 66654044362Smrg# Set func_arith_result to the result of evaluating TERMs. 66754044362Smrg test -z "$_G_HAVE_ARITH_OP" \ 66854044362Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 66954044362Smrg && _G_HAVE_ARITH_OP=yes 67054044362Smrg 67154044362Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 67254044362Smrg eval 'func_arith () 67354044362Smrg { 67454044362Smrg $debug_cmd 67554044362Smrg 67654044362Smrg func_arith_result=$(( $* )) 67754044362Smrg }' 67854044362Smrgelse 67954044362Smrg func_arith () 68054044362Smrg { 68154044362Smrg $debug_cmd 68254044362Smrg 68354044362Smrg func_arith_result=`expr "$@"` 68454044362Smrg } 68554044362Smrgfi 68654044362Smrg 68754044362Smrg 68854044362Smrg# func_basename FILE 68954044362Smrg# ------------------ 69054044362Smrg# Set func_basename_result to FILE with everything up to and including 69154044362Smrg# the last / stripped. 69254044362Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 69354044362Smrg # If this shell supports suffix pattern removal, then use it to avoid 69454044362Smrg # forking. Hide the definitions single quotes in case the shell chokes 69554044362Smrg # on unsupported syntax... 69654044362Smrg _b='func_basename_result=${1##*/}' 69754044362Smrg _d='case $1 in 69854044362Smrg */*) func_dirname_result=${1%/*}$2 ;; 69954044362Smrg * ) func_dirname_result=$3 ;; 70054044362Smrg esac' 70154044362Smrg 70254044362Smrgelse 70354044362Smrg # ...otherwise fall back to using sed. 70454044362Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 70554044362Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 70654044362Smrg if test "X$func_dirname_result" = "X$1"; then 70754044362Smrg func_dirname_result=$3 70854044362Smrg else 70954044362Smrg func_append func_dirname_result "$2" 71054044362Smrg fi' 71154044362Smrgfi 71254044362Smrg 71354044362Smrgeval 'func_basename () 71454044362Smrg{ 71554044362Smrg $debug_cmd 71654044362Smrg 71754044362Smrg '"$_b"' 71854044362Smrg}' 71954044362Smrg 72054044362Smrg 72154044362Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 72254044362Smrg# ------------------------------------------- 72354044362Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 72454044362Smrg# otherwise set result to NONDIR_REPLACEMENT. 72554044362Smrgeval 'func_dirname () 72654044362Smrg{ 72754044362Smrg $debug_cmd 72854044362Smrg 72954044362Smrg '"$_d"' 73054044362Smrg}' 73154044362Smrg 73254044362Smrg 73354044362Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 73454044362Smrg# -------------------------------------------------------- 73554044362Smrg# Perform func_basename and func_dirname in a single function 73654044362Smrg# call: 73754044362Smrg# dirname: Compute the dirname of FILE. If nonempty, 73854044362Smrg# add APPEND to the result, otherwise set result 73954044362Smrg# to NONDIR_REPLACEMENT. 74054044362Smrg# value returned in "$func_dirname_result" 74154044362Smrg# basename: Compute filename of FILE. 74254044362Smrg# value retuned in "$func_basename_result" 74354044362Smrg# For efficiency, we do not delegate to the functions above but instead 74454044362Smrg# duplicate the functionality here. 74554044362Smrgeval 'func_dirname_and_basename () 74654044362Smrg{ 74754044362Smrg $debug_cmd 74854044362Smrg 74954044362Smrg '"$_b"' 75054044362Smrg '"$_d"' 75154044362Smrg}' 75254044362Smrg 75354044362Smrg 75454044362Smrg# func_echo ARG... 75554044362Smrg# ---------------- 75654044362Smrg# Echo program name prefixed message. 75754044362Smrgfunc_echo () 75854044362Smrg{ 75954044362Smrg $debug_cmd 76054044362Smrg 76154044362Smrg _G_message=$* 76254044362Smrg 76354044362Smrg func_echo_IFS=$IFS 76454044362Smrg IFS=$nl 76554044362Smrg for _G_line in $_G_message; do 76654044362Smrg IFS=$func_echo_IFS 76754044362Smrg $ECHO "$progname: $_G_line" 76854044362Smrg done 76954044362Smrg IFS=$func_echo_IFS 77054044362Smrg} 77154044362Smrg 77254044362Smrg 77354044362Smrg# func_echo_all ARG... 77454044362Smrg# -------------------- 77554044362Smrg# Invoke $ECHO with all args, space-separated. 77654044362Smrgfunc_echo_all () 77754044362Smrg{ 77854044362Smrg $ECHO "$*" 77954044362Smrg} 78054044362Smrg 78154044362Smrg 78254044362Smrg# func_echo_infix_1 INFIX ARG... 78354044362Smrg# ------------------------------ 78454044362Smrg# Echo program name, followed by INFIX on the first line, with any 78554044362Smrg# additional lines not showing INFIX. 78654044362Smrgfunc_echo_infix_1 () 78754044362Smrg{ 78854044362Smrg $debug_cmd 78954044362Smrg 79054044362Smrg $require_term_colors 79154044362Smrg 79254044362Smrg _G_infix=$1; shift 79354044362Smrg _G_indent=$_G_infix 79454044362Smrg _G_prefix="$progname: $_G_infix: " 79554044362Smrg _G_message=$* 79654044362Smrg 79754044362Smrg # Strip color escape sequences before counting printable length 79854044362Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 79954044362Smrg do 80054044362Smrg test -n "$_G_tc" && { 80154044362Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 80254044362Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 80354044362Smrg } 80454044362Smrg done 80554044362Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 80654044362Smrg 80754044362Smrg func_echo_infix_1_IFS=$IFS 80854044362Smrg IFS=$nl 80954044362Smrg for _G_line in $_G_message; do 81054044362Smrg IFS=$func_echo_infix_1_IFS 81154044362Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 81254044362Smrg _G_prefix=$_G_indent 81354044362Smrg done 81454044362Smrg IFS=$func_echo_infix_1_IFS 81554044362Smrg} 81654044362Smrg 81754044362Smrg 81854044362Smrg# func_error ARG... 81954044362Smrg# ----------------- 82054044362Smrg# Echo program name prefixed message to standard error. 82154044362Smrgfunc_error () 82254044362Smrg{ 82354044362Smrg $debug_cmd 82454044362Smrg 82554044362Smrg $require_term_colors 82654044362Smrg 82754044362Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 82854044362Smrg} 82954044362Smrg 83054044362Smrg 83154044362Smrg# func_fatal_error ARG... 83254044362Smrg# ----------------------- 83354044362Smrg# Echo program name prefixed message to standard error, and exit. 83454044362Smrgfunc_fatal_error () 83554044362Smrg{ 83654044362Smrg $debug_cmd 83754044362Smrg 83854044362Smrg func_error "$*" 83954044362Smrg exit $EXIT_FAILURE 84054044362Smrg} 84154044362Smrg 84254044362Smrg 84354044362Smrg# func_grep EXPRESSION FILENAME 84454044362Smrg# ----------------------------- 8454cd6a3aeSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8464cd6a3aeSmrgfunc_grep () 8474cd6a3aeSmrg{ 84854044362Smrg $debug_cmd 84954044362Smrg 8504cd6a3aeSmrg $GREP "$1" "$2" >/dev/null 2>&1 8514cd6a3aeSmrg} 8524cd6a3aeSmrg 8534cd6a3aeSmrg 85454044362Smrg# func_len STRING 85554044362Smrg# --------------- 85654044362Smrg# Set func_len_result to the length of STRING. STRING may not 85754044362Smrg# start with a hyphen. 85854044362Smrg test -z "$_G_HAVE_XSI_OPS" \ 85954044362Smrg && (eval 'x=a/b/c; 86054044362Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 86154044362Smrg && _G_HAVE_XSI_OPS=yes 86254044362Smrg 86354044362Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 86454044362Smrg eval 'func_len () 86554044362Smrg { 86654044362Smrg $debug_cmd 86754044362Smrg 86854044362Smrg func_len_result=${#1} 86954044362Smrg }' 87054044362Smrgelse 87154044362Smrg func_len () 87254044362Smrg { 87354044362Smrg $debug_cmd 87454044362Smrg 87554044362Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 87654044362Smrg } 87754044362Smrgfi 87854044362Smrg 87954044362Smrg 88054044362Smrg# func_mkdir_p DIRECTORY-PATH 88154044362Smrg# --------------------------- 8824cd6a3aeSmrg# Make sure the entire path to DIRECTORY-PATH is available. 8834cd6a3aeSmrgfunc_mkdir_p () 8844cd6a3aeSmrg{ 88554044362Smrg $debug_cmd 8864cd6a3aeSmrg 88754044362Smrg _G_directory_path=$1 88854044362Smrg _G_dir_list= 8894cd6a3aeSmrg 89054044362Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89154044362Smrg 89254044362Smrg # Protect directory names starting with '-' 89354044362Smrg case $_G_directory_path in 89454044362Smrg -*) _G_directory_path=./$_G_directory_path ;; 8954cd6a3aeSmrg esac 8964cd6a3aeSmrg 8974cd6a3aeSmrg # While some portion of DIR does not yet exist... 89854044362Smrg while test ! -d "$_G_directory_path"; do 8994cd6a3aeSmrg # ...make a list in topmost first order. Use a colon delimited 9004cd6a3aeSmrg # list incase some portion of path contains whitespace. 90154044362Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 9024cd6a3aeSmrg 9034cd6a3aeSmrg # If the last portion added has no slash in it, the list is done 90454044362Smrg case $_G_directory_path in */*) ;; *) break ;; esac 9054cd6a3aeSmrg 9064cd6a3aeSmrg # ...otherwise throw away the child directory and loop 90754044362Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 9084cd6a3aeSmrg done 90954044362Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 9104cd6a3aeSmrg 91154044362Smrg func_mkdir_p_IFS=$IFS; IFS=: 91254044362Smrg for _G_dir in $_G_dir_list; do 91354044362Smrg IFS=$func_mkdir_p_IFS 91454044362Smrg # mkdir can fail with a 'File exist' error if two processes 9154cd6a3aeSmrg # try to create one of the directories concurrently. Don't 9164cd6a3aeSmrg # stop in that case! 91754044362Smrg $MKDIR "$_G_dir" 2>/dev/null || : 9184cd6a3aeSmrg done 91954044362Smrg IFS=$func_mkdir_p_IFS 9204cd6a3aeSmrg 9214cd6a3aeSmrg # Bail out if we (or some other process) failed to create a directory. 92254044362Smrg test -d "$_G_directory_path" || \ 92354044362Smrg func_fatal_error "Failed to create '$1'" 9244cd6a3aeSmrg fi 9254cd6a3aeSmrg} 9268c9fbc29Smrg 9278c9fbc29Smrg 92854044362Smrg# func_mktempdir [BASENAME] 92954044362Smrg# ------------------------- 9308c9fbc29Smrg# Make a temporary directory that won't clash with other running 9318c9fbc29Smrg# libtool processes, and avoids race conditions if possible. If 93254044362Smrg# given, BASENAME is the basename for that directory. 9338c9fbc29Smrgfunc_mktempdir () 9348c9fbc29Smrg{ 93554044362Smrg $debug_cmd 93654044362Smrg 93754044362Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9388c9fbc29Smrg 93954044362Smrg if test : = "$opt_dry_run"; then 9408c9fbc29Smrg # Return a directory name, but don't create it in dry-run mode 94154044362Smrg _G_tmpdir=$_G_template-$$ 9428c9fbc29Smrg else 9438c9fbc29Smrg 9448c9fbc29Smrg # If mktemp works, use that first and foremost 94554044362Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9468c9fbc29Smrg 94754044362Smrg if test ! -d "$_G_tmpdir"; then 9484cd6a3aeSmrg # Failing that, at least try and use $RANDOM to avoid a race 94954044362Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9508c9fbc29Smrg 95154044362Smrg func_mktempdir_umask=`umask` 9524cd6a3aeSmrg umask 0077 95354044362Smrg $MKDIR "$_G_tmpdir" 95454044362Smrg umask $func_mktempdir_umask 9558c9fbc29Smrg fi 9568c9fbc29Smrg 9578c9fbc29Smrg # If we're not in dry-run mode, bomb out on failure 95854044362Smrg test -d "$_G_tmpdir" || \ 95954044362Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 96054044362Smrg fi 96154044362Smrg 96254044362Smrg $ECHO "$_G_tmpdir" 96354044362Smrg} 96454044362Smrg 96554044362Smrg 96654044362Smrg# func_normal_abspath PATH 96754044362Smrg# ------------------------ 96854044362Smrg# Remove doubled-up and trailing slashes, "." path components, 96954044362Smrg# and cancel out any ".." path components in PATH after making 97054044362Smrg# it an absolute path. 97154044362Smrgfunc_normal_abspath () 97254044362Smrg{ 97354044362Smrg $debug_cmd 97454044362Smrg 97554044362Smrg # These SED scripts presuppose an absolute path with a trailing slash. 97654044362Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 97754044362Smrg _G_pathcdr='s|^/[^/]*||' 97854044362Smrg _G_removedotparts=':dotsl 97954044362Smrg s|/\./|/|g 98054044362Smrg t dotsl 98154044362Smrg s|/\.$|/|' 98254044362Smrg _G_collapseslashes='s|/\{1,\}|/|g' 98354044362Smrg _G_finalslash='s|/*$|/|' 98454044362Smrg 98554044362Smrg # Start from root dir and reassemble the path. 98654044362Smrg func_normal_abspath_result= 98754044362Smrg func_normal_abspath_tpath=$1 98854044362Smrg func_normal_abspath_altnamespace= 98954044362Smrg case $func_normal_abspath_tpath in 99054044362Smrg "") 99154044362Smrg # Empty path, that just means $cwd. 99254044362Smrg func_stripname '' '/' "`pwd`" 99354044362Smrg func_normal_abspath_result=$func_stripname_result 99454044362Smrg return 99554044362Smrg ;; 99654044362Smrg # The next three entries are used to spot a run of precisely 99754044362Smrg # two leading slashes without using negated character classes; 99854044362Smrg # we take advantage of case's first-match behaviour. 99954044362Smrg ///*) 100054044362Smrg # Unusual form of absolute path, do nothing. 100154044362Smrg ;; 100254044362Smrg //*) 100354044362Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 100454044362Smrg # and for example Cygwin uses it to access remote file shares 100554044362Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 100654044362Smrg func_normal_abspath_altnamespace=/ 100754044362Smrg ;; 100854044362Smrg /*) 100954044362Smrg # Absolute path, do nothing. 101054044362Smrg ;; 101154044362Smrg *) 101254044362Smrg # Relative path, prepend $cwd. 101354044362Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 101454044362Smrg ;; 101554044362Smrg esac 101654044362Smrg 101754044362Smrg # Cancel out all the simple stuff to save iterations. We also want 101854044362Smrg # the path to end with a slash for ease of parsing, so make sure 101954044362Smrg # there is one (and only one) here. 102054044362Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 102154044362Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 102254044362Smrg while :; do 102354044362Smrg # Processed it all yet? 102454044362Smrg if test / = "$func_normal_abspath_tpath"; then 102554044362Smrg # If we ascended to the root using ".." the result may be empty now. 102654044362Smrg if test -z "$func_normal_abspath_result"; then 102754044362Smrg func_normal_abspath_result=/ 102854044362Smrg fi 102954044362Smrg break 103054044362Smrg fi 103154044362Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103254044362Smrg -e "$_G_pathcar"` 103354044362Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103454044362Smrg -e "$_G_pathcdr"` 103554044362Smrg # Figure out what to do with it 103654044362Smrg case $func_normal_abspath_tcomponent in 103754044362Smrg "") 103854044362Smrg # Trailing empty path component, ignore it. 103954044362Smrg ;; 104054044362Smrg ..) 104154044362Smrg # Parent dir; strip last assembled component from result. 104254044362Smrg func_dirname "$func_normal_abspath_result" 104354044362Smrg func_normal_abspath_result=$func_dirname_result 104454044362Smrg ;; 104554044362Smrg *) 104654044362Smrg # Actual path component, append it. 104754044362Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 104854044362Smrg ;; 104954044362Smrg esac 105054044362Smrg done 105154044362Smrg # Restore leading double-slash if one was found on entry. 105254044362Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 105354044362Smrg} 105454044362Smrg 105554044362Smrg 105654044362Smrg# func_notquiet ARG... 105754044362Smrg# -------------------- 105854044362Smrg# Echo program name prefixed message only when not in quiet mode. 105954044362Smrgfunc_notquiet () 106054044362Smrg{ 106154044362Smrg $debug_cmd 106254044362Smrg 106354044362Smrg $opt_quiet || func_echo ${1+"$@"} 106454044362Smrg 106554044362Smrg # A bug in bash halts the script if the last line of a function 106654044362Smrg # fails when set -e is in force, so we need another command to 106754044362Smrg # work around that: 106854044362Smrg : 106954044362Smrg} 107054044362Smrg 107154044362Smrg 107254044362Smrg# func_relative_path SRCDIR DSTDIR 107354044362Smrg# -------------------------------- 107454044362Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 107554044362Smrgfunc_relative_path () 107654044362Smrg{ 107754044362Smrg $debug_cmd 107854044362Smrg 107954044362Smrg func_relative_path_result= 108054044362Smrg func_normal_abspath "$1" 108154044362Smrg func_relative_path_tlibdir=$func_normal_abspath_result 108254044362Smrg func_normal_abspath "$2" 108354044362Smrg func_relative_path_tbindir=$func_normal_abspath_result 108454044362Smrg 108554044362Smrg # Ascend the tree starting from libdir 108654044362Smrg while :; do 108754044362Smrg # check if we have found a prefix of bindir 108854044362Smrg case $func_relative_path_tbindir in 108954044362Smrg $func_relative_path_tlibdir) 109054044362Smrg # found an exact match 109154044362Smrg func_relative_path_tcancelled= 109254044362Smrg break 109354044362Smrg ;; 109454044362Smrg $func_relative_path_tlibdir*) 109554044362Smrg # found a matching prefix 109654044362Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 109754044362Smrg func_relative_path_tcancelled=$func_stripname_result 109854044362Smrg if test -z "$func_relative_path_result"; then 109954044362Smrg func_relative_path_result=. 110054044362Smrg fi 110154044362Smrg break 110254044362Smrg ;; 110354044362Smrg *) 110454044362Smrg func_dirname $func_relative_path_tlibdir 110554044362Smrg func_relative_path_tlibdir=$func_dirname_result 110654044362Smrg if test -z "$func_relative_path_tlibdir"; then 110754044362Smrg # Have to descend all the way to the root! 110854044362Smrg func_relative_path_result=../$func_relative_path_result 110954044362Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 111054044362Smrg break 111154044362Smrg fi 111254044362Smrg func_relative_path_result=../$func_relative_path_result 111354044362Smrg ;; 111454044362Smrg esac 111554044362Smrg done 111654044362Smrg 111754044362Smrg # Now calculate path; take care to avoid doubling-up slashes. 111854044362Smrg func_stripname '' '/' "$func_relative_path_result" 111954044362Smrg func_relative_path_result=$func_stripname_result 112054044362Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 112154044362Smrg if test -n "$func_stripname_result"; then 112254044362Smrg func_append func_relative_path_result "/$func_stripname_result" 112354044362Smrg fi 112454044362Smrg 112554044362Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 112654044362Smrg if test -n "$func_relative_path_result"; then 112754044362Smrg func_stripname './' '' "$func_relative_path_result" 112854044362Smrg func_relative_path_result=$func_stripname_result 11298c9fbc29Smrg fi 11308c9fbc29Smrg 113154044362Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 113254044362Smrg 113354044362Smrg : 113454044362Smrg} 113554044362Smrg 113654044362Smrg 113754cef2ddSmrg# func_quote_portable EVAL ARG 113854cef2ddSmrg# ---------------------------- 113954cef2ddSmrg# Internal function to portably implement func_quote_arg. Note that we still 114054cef2ddSmrg# keep attention to performance here so we as much as possible try to avoid 114154cef2ddSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 114254cef2ddSmrgfunc_quote_portable () 114354044362Smrg{ 114454044362Smrg $debug_cmd 114554044362Smrg 114654cef2ddSmrg $require_check_ifs_backslash 114754cef2ddSmrg 114854cef2ddSmrg func_quote_portable_result=$2 114954cef2ddSmrg 115054cef2ddSmrg # one-time-loop (easy break) 115154cef2ddSmrg while true 115254cef2ddSmrg do 115354cef2ddSmrg if $1; then 115454cef2ddSmrg func_quote_portable_result=`$ECHO "$2" | $SED \ 115554cef2ddSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 115654cef2ddSmrg break 115754044362Smrg fi 115854044362Smrg 115954cef2ddSmrg # Quote for eval. 116054cef2ddSmrg case $func_quote_portable_result in 116154cef2ddSmrg *[\\\`\"\$]*) 116254cef2ddSmrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 116354cef2ddSmrg # contains the shell wildcard characters. 116454cef2ddSmrg case $check_ifs_backshlash_broken$func_quote_portable_result in 116554cef2ddSmrg :*|*[\[\*\?]*) 116654cef2ddSmrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 116754cef2ddSmrg | $SED "$sed_quote_subst"` 116854cef2ddSmrg break 116954cef2ddSmrg ;; 117054cef2ddSmrg esac 117154cef2ddSmrg 117254cef2ddSmrg func_quote_portable_old_IFS=$IFS 117354cef2ddSmrg for _G_char in '\' '`' '"' '$' 117454cef2ddSmrg do 117554cef2ddSmrg # STATE($1) PREV($2) SEPARATOR($3) 117654cef2ddSmrg set start "" "" 117754cef2ddSmrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 117854cef2ddSmrg IFS=$_G_char 117954cef2ddSmrg for _G_part in $func_quote_portable_result 118054cef2ddSmrg do 118154cef2ddSmrg case $1 in 118254cef2ddSmrg quote) 118354cef2ddSmrg func_append func_quote_portable_result "$3$2" 118454cef2ddSmrg set quote "$_G_part" "\\$_G_char" 118554cef2ddSmrg ;; 118654cef2ddSmrg start) 118754cef2ddSmrg set first "" "" 118854cef2ddSmrg func_quote_portable_result= 118954cef2ddSmrg ;; 119054cef2ddSmrg first) 119154cef2ddSmrg set quote "$_G_part" "" 119254cef2ddSmrg ;; 119354cef2ddSmrg esac 119454cef2ddSmrg done 119554cef2ddSmrg done 119654cef2ddSmrg IFS=$func_quote_portable_old_IFS 119754044362Smrg ;; 119854cef2ddSmrg *) ;; 119954044362Smrg esac 120054cef2ddSmrg break 120154044362Smrg done 120254cef2ddSmrg 120354cef2ddSmrg func_quote_portable_unquoted_result=$func_quote_portable_result 120454cef2ddSmrg case $func_quote_portable_result in 120554cef2ddSmrg # double-quote args containing shell metacharacters to delay 120654cef2ddSmrg # word splitting, command substitution and variable expansion 120754cef2ddSmrg # for a subsequent eval. 120854cef2ddSmrg # many bourne shells cannot handle close brackets correctly 120954cef2ddSmrg # in scan sets, so we specify it separately. 121054cef2ddSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 121154cef2ddSmrg func_quote_portable_result=\"$func_quote_portable_result\" 121254cef2ddSmrg ;; 121354cef2ddSmrg esac 121454044362Smrg} 121554044362Smrg 121654044362Smrg 121754cef2ddSmrg# func_quotefast_eval ARG 121854cef2ddSmrg# ----------------------- 121954cef2ddSmrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 122054cef2ddSmrg# but optimized for speed. Result is stored in $func_quotefast_eval. 122154cef2ddSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 122254cef2ddSmrg printf -v _GL_test_printf_tilde %q '~' 122354cef2ddSmrg if test '\~' = "$_GL_test_printf_tilde"; then 122454cef2ddSmrg func_quotefast_eval () 122554cef2ddSmrg { 122654cef2ddSmrg printf -v func_quotefast_eval_result %q "$1" 122754cef2ddSmrg } 122854cef2ddSmrg else 122954cef2ddSmrg # Broken older Bash implementations. Make those faster too if possible. 123054cef2ddSmrg func_quotefast_eval () 123154cef2ddSmrg { 123254cef2ddSmrg case $1 in 123354cef2ddSmrg '~'*) 123454cef2ddSmrg func_quote_portable false "$1" 123554cef2ddSmrg func_quotefast_eval_result=$func_quote_portable_result 123654cef2ddSmrg ;; 123754cef2ddSmrg *) 123854cef2ddSmrg printf -v func_quotefast_eval_result %q "$1" 123954cef2ddSmrg ;; 124054cef2ddSmrg esac 124154cef2ddSmrg } 124254cef2ddSmrg fi 124354cef2ddSmrgelse 124454cef2ddSmrg func_quotefast_eval () 124554cef2ddSmrg { 124654cef2ddSmrg func_quote_portable false "$1" 124754cef2ddSmrg func_quotefast_eval_result=$func_quote_portable_result 124854cef2ddSmrg } 124954cef2ddSmrgfi 125054044362Smrg 125154cef2ddSmrg 125254cef2ddSmrg# func_quote_arg MODEs ARG 125354cef2ddSmrg# ------------------------ 125454cef2ddSmrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 125554cef2ddSmrg# specifiers listed below separated by ',' character. This function returns two 125654cef2ddSmrg# values: 125754cef2ddSmrg# i) func_quote_arg_result 125854cef2ddSmrg# double-quoted (when needed), suitable for a subsequent eval 125954cef2ddSmrg# ii) func_quote_arg_unquoted_result 126054cef2ddSmrg# has all characters that are still active within double 126154cef2ddSmrg# quotes backslashified. Available only if 'unquoted' is specified. 126254cef2ddSmrg# 126354cef2ddSmrg# Available modes: 126454cef2ddSmrg# ---------------- 126554cef2ddSmrg# 'eval' (default) 126654cef2ddSmrg# - escape shell special characters 126754cef2ddSmrg# 'expand' 126854cef2ddSmrg# - the same as 'eval'; but do not quote variable references 126954cef2ddSmrg# 'pretty' 127054cef2ddSmrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 127154cef2ddSmrg# be used later in func_quote to get output like: 'echo "a b"' instead 127254cef2ddSmrg# of 'echo a\ b'. This is slower than default on some shells. 127354cef2ddSmrg# 'unquoted' 127454cef2ddSmrg# - produce also $func_quote_arg_unquoted_result which does not contain 127554cef2ddSmrg# wrapping double-quotes. 127654cef2ddSmrg# 127754cef2ddSmrg# Examples for 'func_quote_arg pretty,unquoted string': 127854cef2ddSmrg# 127954cef2ddSmrg# string | *_result | *_unquoted_result 128054cef2ddSmrg# ------------+-----------------------+------------------- 128154cef2ddSmrg# " | \" | \" 128254cef2ddSmrg# a b | "a b" | a b 128354cef2ddSmrg# "a b" | "\"a b\"" | \"a b\" 128454cef2ddSmrg# * | "*" | * 128554cef2ddSmrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 128654cef2ddSmrg# 128754cef2ddSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 128854cef2ddSmrg# 128954cef2ddSmrg# string | *_result | *_unquoted_result 129054cef2ddSmrg# --------------+---------------------+-------------------- 129154cef2ddSmrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 129254cef2ddSmrgfunc_quote_arg () 129354cef2ddSmrg{ 129454cef2ddSmrg _G_quote_expand=false 129554cef2ddSmrg case ,$1, in 129654cef2ddSmrg *,expand,*) 129754cef2ddSmrg _G_quote_expand=: 129854cef2ddSmrg ;; 129954044362Smrg esac 130054044362Smrg 130154cef2ddSmrg case ,$1, in 130254cef2ddSmrg *,pretty,*|*,expand,*|*,unquoted,*) 130354cef2ddSmrg func_quote_portable $_G_quote_expand "$2" 130454cef2ddSmrg func_quote_arg_result=$func_quote_portable_result 130554cef2ddSmrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 130654cef2ddSmrg ;; 130754cef2ddSmrg *) 130854cef2ddSmrg # Faster quote-for-eval for some shells. 130954cef2ddSmrg func_quotefast_eval "$2" 131054cef2ddSmrg func_quote_arg_result=$func_quotefast_eval_result 131154044362Smrg ;; 131254044362Smrg esac 131354cef2ddSmrg} 131454cef2ddSmrg 131554044362Smrg 131654cef2ddSmrg# func_quote MODEs ARGs... 131754cef2ddSmrg# ------------------------ 131854cef2ddSmrg# Quote all ARGs to be evaled later and join them into single command. See 131954cef2ddSmrg# func_quote_arg's description for more info. 132054cef2ddSmrgfunc_quote () 132154cef2ddSmrg{ 132254cef2ddSmrg $debug_cmd 132354cef2ddSmrg _G_func_quote_mode=$1 ; shift 132454cef2ddSmrg func_quote_result= 132554cef2ddSmrg while test 0 -lt $#; do 132654cef2ddSmrg func_quote_arg "$_G_func_quote_mode" "$1" 132754cef2ddSmrg if test -n "$func_quote_result"; then 132854cef2ddSmrg func_append func_quote_result " $func_quote_arg_result" 132954cef2ddSmrg else 133054cef2ddSmrg func_append func_quote_result "$func_quote_arg_result" 133154cef2ddSmrg fi 133254cef2ddSmrg shift 133354cef2ddSmrg done 133454044362Smrg} 133554044362Smrg 133654044362Smrg 133754044362Smrg# func_stripname PREFIX SUFFIX NAME 133854044362Smrg# --------------------------------- 133954044362Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 134054044362Smrg# PREFIX and SUFFIX must not contain globbing or regex special 134154044362Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 134254044362Smrg# dot (in which case that matches only a dot). 134354044362Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 134454044362Smrg eval 'func_stripname () 134554044362Smrg { 134654044362Smrg $debug_cmd 134754044362Smrg 134854044362Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 134954044362Smrg # positional parameters, so assign one to ordinary variable first. 135054044362Smrg func_stripname_result=$3 135154044362Smrg func_stripname_result=${func_stripname_result#"$1"} 135254044362Smrg func_stripname_result=${func_stripname_result%"$2"} 135354044362Smrg }' 135454044362Smrgelse 135554044362Smrg func_stripname () 135654044362Smrg { 135754044362Smrg $debug_cmd 135854044362Smrg 135954044362Smrg case $2 in 136054044362Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 136154044362Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 136254044362Smrg esac 136354044362Smrg } 136454044362Smrgfi 136554044362Smrg 136654044362Smrg 136754044362Smrg# func_show_eval CMD [FAIL_EXP] 136854044362Smrg# ----------------------------- 136954044362Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 137054044362Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 137154044362Smrg# is given, then evaluate it. 137254044362Smrgfunc_show_eval () 137354044362Smrg{ 137454044362Smrg $debug_cmd 137554044362Smrg 137654044362Smrg _G_cmd=$1 137754044362Smrg _G_fail_exp=${2-':'} 137854044362Smrg 137954cef2ddSmrg func_quote_arg pretty,expand "$_G_cmd" 138054cef2ddSmrg eval "func_notquiet $func_quote_arg_result" 138154044362Smrg 138254044362Smrg $opt_dry_run || { 138354044362Smrg eval "$_G_cmd" 138454044362Smrg _G_status=$? 138554044362Smrg if test 0 -ne "$_G_status"; then 138654044362Smrg eval "(exit $_G_status); $_G_fail_exp" 138754044362Smrg fi 138854044362Smrg } 138954044362Smrg} 139054044362Smrg 139154044362Smrg 139254044362Smrg# func_show_eval_locale CMD [FAIL_EXP] 139354044362Smrg# ------------------------------------ 139454044362Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 139554044362Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 139654044362Smrg# is given, then evaluate it. Use the saved locale for evaluation. 139754044362Smrgfunc_show_eval_locale () 139854044362Smrg{ 139954044362Smrg $debug_cmd 140054044362Smrg 140154044362Smrg _G_cmd=$1 140254044362Smrg _G_fail_exp=${2-':'} 140354044362Smrg 140454044362Smrg $opt_quiet || { 140554cef2ddSmrg func_quote_arg expand,pretty "$_G_cmd" 140654cef2ddSmrg eval "func_echo $func_quote_arg_result" 140754044362Smrg } 140854044362Smrg 140954044362Smrg $opt_dry_run || { 141054044362Smrg eval "$_G_user_locale 141154044362Smrg $_G_cmd" 141254044362Smrg _G_status=$? 141354044362Smrg eval "$_G_safe_locale" 141454044362Smrg if test 0 -ne "$_G_status"; then 141554044362Smrg eval "(exit $_G_status); $_G_fail_exp" 141654044362Smrg fi 141754044362Smrg } 141854044362Smrg} 141954044362Smrg 142054044362Smrg 142154044362Smrg# func_tr_sh 142254044362Smrg# ---------- 142354044362Smrg# Turn $1 into a string suitable for a shell variable name. 142454044362Smrg# Result is stored in $func_tr_sh_result. All characters 142554044362Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 142654044362Smrg# if $1 begins with a digit, a '_' is prepended as well. 142754044362Smrgfunc_tr_sh () 142854044362Smrg{ 142954044362Smrg $debug_cmd 143054044362Smrg 143154044362Smrg case $1 in 143254044362Smrg [0-9]* | *[!a-zA-Z0-9_]*) 143354044362Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 143454044362Smrg ;; 143554044362Smrg * ) 143654044362Smrg func_tr_sh_result=$1 143754044362Smrg ;; 143854044362Smrg esac 143954044362Smrg} 144054044362Smrg 144154044362Smrg 144254044362Smrg# func_verbose ARG... 144354044362Smrg# ------------------- 144454044362Smrg# Echo program name prefixed message in verbose mode only. 144554044362Smrgfunc_verbose () 144654044362Smrg{ 144754044362Smrg $debug_cmd 144854044362Smrg 144954044362Smrg $opt_verbose && func_echo "$*" 145054044362Smrg 145154044362Smrg : 145254044362Smrg} 145354044362Smrg 145454044362Smrg 145554044362Smrg# func_warn_and_continue ARG... 145654044362Smrg# ----------------------------- 145754044362Smrg# Echo program name prefixed warning message to standard error. 145854044362Smrgfunc_warn_and_continue () 145954044362Smrg{ 146054044362Smrg $debug_cmd 146154044362Smrg 146254044362Smrg $require_term_colors 146354044362Smrg 146454044362Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 146554044362Smrg} 146654044362Smrg 146754044362Smrg 146854044362Smrg# func_warning CATEGORY ARG... 146954044362Smrg# ---------------------------- 147054044362Smrg# Echo program name prefixed warning message to standard error. Warning 147154044362Smrg# messages can be filtered according to CATEGORY, where this function 147254044362Smrg# elides messages where CATEGORY is not listed in the global variable 147354044362Smrg# 'opt_warning_types'. 147454044362Smrgfunc_warning () 147554044362Smrg{ 147654044362Smrg $debug_cmd 147754044362Smrg 147854044362Smrg # CATEGORY must be in the warning_categories list! 147954044362Smrg case " $warning_categories " in 148054044362Smrg *" $1 "*) ;; 148154044362Smrg *) func_internal_error "invalid warning category '$1'" ;; 148254044362Smrg esac 148354044362Smrg 148454044362Smrg _G_category=$1 148554044362Smrg shift 148654044362Smrg 148754044362Smrg case " $opt_warning_types " in 148854044362Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 148954044362Smrg esac 149054044362Smrg} 149154044362Smrg 149254044362Smrg 149354044362Smrg# func_sort_ver VER1 VER2 149454044362Smrg# ----------------------- 149554044362Smrg# 'sort -V' is not generally available. 149654044362Smrg# Note this deviates from the version comparison in automake 149754044362Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 149854044362Smrg# but this should suffice as we won't be specifying old 149954044362Smrg# version formats or redundant trailing .0 in bootstrap.conf. 150054044362Smrg# If we did want full compatibility then we should probably 150154044362Smrg# use m4_version_compare from autoconf. 150254044362Smrgfunc_sort_ver () 150354044362Smrg{ 150454044362Smrg $debug_cmd 150554044362Smrg 150654044362Smrg printf '%s\n%s\n' "$1" "$2" \ 150754044362Smrg | 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 150854044362Smrg} 150954044362Smrg 151054044362Smrg# func_lt_ver PREV CURR 151154044362Smrg# --------------------- 151254044362Smrg# Return true if PREV and CURR are in the correct order according to 151354044362Smrg# func_sort_ver, otherwise false. Use it like this: 151454044362Smrg# 151554044362Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 151654044362Smrgfunc_lt_ver () 151754044362Smrg{ 151854044362Smrg $debug_cmd 151954044362Smrg 152054044362Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 152154044362Smrg} 152254044362Smrg 152354044362Smrg 152454044362Smrg# Local variables: 152554044362Smrg# mode: shell-script 152654044362Smrg# sh-indentation: 2 152754044362Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 152854044362Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 152954044362Smrg# time-stamp-time-zone: "UTC" 153054044362Smrg# End: 153154044362Smrg#! /bin/sh 153254044362Smrg 153354044362Smrg# A portable, pluggable option parser for Bourne shell. 153454044362Smrg# Written by Gary V. Vaughan, 2010 153554044362Smrg 153654cef2ddSmrg# This is free software. There is NO warranty; not even for 153754cef2ddSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 153854cef2ddSmrg# 153954cef2ddSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 154054cef2ddSmrg# 154154cef2ddSmrg# This file is dual licensed under the terms of the MIT license 154254cef2ddSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 154354cef2ddSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 154454cef2ddSmrg# these licenses when using or redistributing this software or any of 154554cef2ddSmrg# the files within it. See the URLs above, or the file `LICENSE` 154654cef2ddSmrg# included in the Bootstrap distribution for the full license texts. 154754044362Smrg 154854cef2ddSmrg# Please report bugs or propose patches to: 154954cef2ddSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 155054044362Smrg 155154cef2ddSmrg# Set a version string for this script. 155254cef2ddSmrgscriptversion=2019-02-19.15; # UTC 155354044362Smrg 155454044362Smrg 155554044362Smrg## ------ ## 155654044362Smrg## Usage. ## 155754044362Smrg## ------ ## 155854044362Smrg 155954044362Smrg# This file is a library for parsing options in your shell scripts along 156054044362Smrg# with assorted other useful supporting features that you can make use 156154044362Smrg# of too. 156254044362Smrg# 156354044362Smrg# For the simplest scripts you might need only: 156454044362Smrg# 156554044362Smrg# #!/bin/sh 156654044362Smrg# . relative/path/to/funclib.sh 156754044362Smrg# . relative/path/to/options-parser 156854044362Smrg# scriptversion=1.0 156954044362Smrg# func_options ${1+"$@"} 157054044362Smrg# eval set dummy "$func_options_result"; shift 157154044362Smrg# ...rest of your script... 157254044362Smrg# 157354044362Smrg# In order for the '--version' option to work, you will need to have a 157454044362Smrg# suitably formatted comment like the one at the top of this file 157554cef2ddSmrg# starting with '# Written by ' and ending with '# Copyright'. 157654044362Smrg# 157754044362Smrg# For '-h' and '--help' to work, you will also need a one line 157854044362Smrg# description of your script's purpose in a comment directly above the 157954044362Smrg# '# Written by ' line, like the one at the top of this file. 158054044362Smrg# 158154044362Smrg# The default options also support '--debug', which will turn on shell 158254044362Smrg# execution tracing (see the comment above debug_cmd below for another 158354044362Smrg# use), and '--verbose' and the func_verbose function to allow your script 158454044362Smrg# to display verbose messages only when your user has specified 158554044362Smrg# '--verbose'. 158654044362Smrg# 158754cef2ddSmrg# After sourcing this file, you can plug in processing for additional 158854044362Smrg# options by amending the variables from the 'Configuration' section 158954044362Smrg# below, and following the instructions in the 'Option parsing' 159054044362Smrg# section further down. 159154044362Smrg 159254044362Smrg## -------------- ## 159354044362Smrg## Configuration. ## 159454044362Smrg## -------------- ## 159554044362Smrg 159654044362Smrg# You should override these variables in your script after sourcing this 159754044362Smrg# file so that they reflect the customisations you have added to the 159854044362Smrg# option parser. 159954044362Smrg 160054044362Smrg# The usage line for option parsing errors and the start of '-h' and 160154044362Smrg# '--help' output messages. You can embed shell variables for delayed 160254044362Smrg# expansion at the time the message is displayed, but you will need to 160354044362Smrg# quote other shell meta-characters carefully to prevent them being 160454044362Smrg# expanded when the contents are evaled. 160554044362Smrgusage='$progpath [OPTION]...' 160654044362Smrg 160754044362Smrg# Short help message in response to '-h' and '--help'. Add to this or 160854044362Smrg# override it after sourcing this library to reflect the full set of 160954044362Smrg# options your script accepts. 161054044362Smrgusage_message="\ 161154044362Smrg --debug enable verbose shell tracing 161254044362Smrg -W, --warnings=CATEGORY 161354044362Smrg report the warnings falling in CATEGORY [all] 161454044362Smrg -v, --verbose verbosely report processing 161554044362Smrg --version print version information and exit 161654044362Smrg -h, --help print short or long help message and exit 161754044362Smrg" 161854044362Smrg 161954044362Smrg# Additional text appended to 'usage_message' in response to '--help'. 162054044362Smrglong_help_message=" 162154044362SmrgWarning categories include: 162254044362Smrg 'all' show all warnings 162354044362Smrg 'none' turn off all the warnings 162454044362Smrg 'error' warnings are treated as fatal errors" 162554044362Smrg 162654044362Smrg# Help message printed before fatal option parsing errors. 162754044362Smrgfatal_help="Try '\$progname --help' for more information." 162854044362Smrg 162954044362Smrg 163054044362Smrg 163154044362Smrg## ------------------------- ## 163254044362Smrg## Hook function management. ## 163354044362Smrg## ------------------------- ## 163454044362Smrg 163554044362Smrg# This section contains functions for adding, removing, and running hooks 163654cef2ddSmrg# in the main code. A hook is just a list of function names that can be 163754cef2ddSmrg# run in order later on. 163854044362Smrg 163954044362Smrg# func_hookable FUNC_NAME 164054044362Smrg# ----------------------- 164154044362Smrg# Declare that FUNC_NAME will run hooks added with 164254044362Smrg# 'func_add_hook FUNC_NAME ...'. 164354044362Smrgfunc_hookable () 164454044362Smrg{ 164554044362Smrg $debug_cmd 164654044362Smrg 164754044362Smrg func_append hookable_fns " $1" 164854044362Smrg} 164954044362Smrg 165054044362Smrg 165154044362Smrg# func_add_hook FUNC_NAME HOOK_FUNC 165254044362Smrg# --------------------------------- 165354044362Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 165454044362Smrg# first have been declared "hookable" by a call to 'func_hookable'. 165554044362Smrgfunc_add_hook () 165654044362Smrg{ 165754044362Smrg $debug_cmd 165854044362Smrg 165954044362Smrg case " $hookable_fns " in 166054044362Smrg *" $1 "*) ;; 166154044362Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 166254044362Smrg esac 166354044362Smrg 166454044362Smrg eval func_append ${1}_hooks '" $2"' 166554044362Smrg} 166654044362Smrg 166754044362Smrg 166854044362Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 166954044362Smrg# ------------------------------------ 167054cef2ddSmrg# Remove HOOK_FUNC from the list of hook functions to be called by 167154cef2ddSmrg# FUNC_NAME. 167254044362Smrgfunc_remove_hook () 167354044362Smrg{ 167454044362Smrg $debug_cmd 167554044362Smrg 167654044362Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 167754044362Smrg} 167854044362Smrg 167954044362Smrg 168054cef2ddSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 168154cef2ddSmrg# --------------------------------------------- 168254cef2ddSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 168354cef2ddSmrg# *_result variable of FUNC_NAME_B. 168454cef2ddSmrgfunc_propagate_result () 168554cef2ddSmrg{ 168654cef2ddSmrg $debug_cmd 168754cef2ddSmrg 168854cef2ddSmrg func_propagate_result_result=: 168954cef2ddSmrg if eval "test \"\${${1}_result+set}\" = set" 169054cef2ddSmrg then 169154cef2ddSmrg eval "${2}_result=\$${1}_result" 169254cef2ddSmrg else 169354cef2ddSmrg func_propagate_result_result=false 169454cef2ddSmrg fi 169554cef2ddSmrg} 169654cef2ddSmrg 169754cef2ddSmrg 169854044362Smrg# func_run_hooks FUNC_NAME [ARG]... 169954044362Smrg# --------------------------------- 170054044362Smrg# Run all hook functions registered to FUNC_NAME. 170154cef2ddSmrg# It's assumed that the list of hook functions contains nothing more 170254044362Smrg# than a whitespace-delimited list of legal shell function names, and 170354044362Smrg# no effort is wasted trying to catch shell meta-characters or preserve 170454044362Smrg# whitespace. 170554044362Smrgfunc_run_hooks () 170654044362Smrg{ 170754044362Smrg $debug_cmd 170854044362Smrg 170954044362Smrg case " $hookable_fns " in 171054044362Smrg *" $1 "*) ;; 171154cef2ddSmrg *) func_fatal_error "'$1' does not support hook functions." ;; 171254044362Smrg esac 171354044362Smrg 171454044362Smrg eval _G_hook_fns=\$$1_hooks; shift 171554044362Smrg 171654044362Smrg for _G_hook in $_G_hook_fns; do 171754cef2ddSmrg func_unset "${_G_hook}_result" 171854cef2ddSmrg eval $_G_hook '${1+"$@"}' 171954cef2ddSmrg func_propagate_result $_G_hook func_run_hooks 172054cef2ddSmrg if $func_propagate_result_result; then 172154cef2ddSmrg eval set dummy "$func_run_hooks_result"; shift 172254cef2ddSmrg fi 172354044362Smrg done 172454044362Smrg} 172554044362Smrg 172654044362Smrg 172754044362Smrg 172854044362Smrg## --------------- ## 172954044362Smrg## Option parsing. ## 173054044362Smrg## --------------- ## 173154044362Smrg 173254044362Smrg# In order to add your own option parsing hooks, you must accept the 173354cef2ddSmrg# full positional parameter list from your hook function. You may remove 173454cef2ddSmrg# or edit any options that you action, and then pass back the remaining 173554cef2ddSmrg# unprocessed options in '<hooked_function_name>_result', escaped 173654cef2ddSmrg# suitably for 'eval'. 173754cef2ddSmrg# 173854cef2ddSmrg# The '<hooked_function_name>_result' variable is automatically unset 173954cef2ddSmrg# before your hook gets called; for best performance, only set the 174054cef2ddSmrg# *_result variable when necessary (i.e. don't call the 'func_quote' 174154cef2ddSmrg# function unnecessarily because it can be an expensive operation on some 174254cef2ddSmrg# machines). 174354cef2ddSmrg# 174454cef2ddSmrg# Like this: 174554044362Smrg# 174654044362Smrg# my_options_prep () 174754044362Smrg# { 174854044362Smrg# $debug_cmd 174954044362Smrg# 175054044362Smrg# # Extend the existing usage message. 175154044362Smrg# usage_message=$usage_message' 175254044362Smrg# -s, --silent don'\''t print informational messages 175354044362Smrg# ' 175454cef2ddSmrg# # No change in '$@' (ignored completely by this hook). Leave 175554cef2ddSmrg# # my_options_prep_result variable intact. 175654044362Smrg# } 175754044362Smrg# func_add_hook func_options_prep my_options_prep 175854044362Smrg# 175954044362Smrg# 176054044362Smrg# my_silent_option () 176154044362Smrg# { 176254044362Smrg# $debug_cmd 176354044362Smrg# 176454cef2ddSmrg# args_changed=false 176554cef2ddSmrg# 176654cef2ddSmrg# # Note that, for efficiency, we parse as many options as we can 176754044362Smrg# # recognise in a loop before passing the remainder back to the 176854044362Smrg# # caller on the first unrecognised argument we encounter. 176954044362Smrg# while test $# -gt 0; do 177054044362Smrg# opt=$1; shift 177154044362Smrg# case $opt in 177254cef2ddSmrg# --silent|-s) opt_silent=: 177354cef2ddSmrg# args_changed=: 177454cef2ddSmrg# ;; 177554044362Smrg# # Separate non-argument short options: 177654044362Smrg# -s*) func_split_short_opt "$_G_opt" 177754044362Smrg# set dummy "$func_split_short_opt_name" \ 177854044362Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 177954044362Smrg# shift 178054cef2ddSmrg# args_changed=: 178154044362Smrg# ;; 178254cef2ddSmrg# *) # Make sure the first unrecognised option "$_G_opt" 178354cef2ddSmrg# # is added back to "$@" in case we need it later, 178454cef2ddSmrg# # if $args_changed was set to 'true'. 178554cef2ddSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 178654044362Smrg# esac 178754044362Smrg# done 178854044362Smrg# 178954cef2ddSmrg# # Only call 'func_quote' here if we processed at least one argument. 179054cef2ddSmrg# if $args_changed; then 179154cef2ddSmrg# func_quote eval ${1+"$@"} 179254cef2ddSmrg# my_silent_option_result=$func_quote_result 179354cef2ddSmrg# fi 179454044362Smrg# } 179554044362Smrg# func_add_hook func_parse_options my_silent_option 179654044362Smrg# 179754044362Smrg# 179854044362Smrg# my_option_validation () 179954044362Smrg# { 180054044362Smrg# $debug_cmd 180154044362Smrg# 180254044362Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 180354044362Smrg# '--silent' and '--verbose' options are mutually exclusive." 180454044362Smrg# } 180554044362Smrg# func_add_hook func_validate_options my_option_validation 180654044362Smrg# 180754cef2ddSmrg# You'll also need to manually amend $usage_message to reflect the extra 180854044362Smrg# options you parse. It's preferable to append if you can, so that 180954044362Smrg# multiple option parsing hooks can be added safely. 181054044362Smrg 181154044362Smrg 181254cef2ddSmrg# func_options_finish [ARG]... 181354cef2ddSmrg# ---------------------------- 181454cef2ddSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 181554cef2ddSmrgfunc_options_finish () 181654cef2ddSmrg{ 181754cef2ddSmrg $debug_cmd 181854cef2ddSmrg 181954cef2ddSmrg func_run_hooks func_options ${1+"$@"} 182054cef2ddSmrg func_propagate_result func_run_hooks func_options_finish 182154cef2ddSmrg} 182254cef2ddSmrg 182354cef2ddSmrg 182454044362Smrg# func_options [ARG]... 182554044362Smrg# --------------------- 182654044362Smrg# All the functions called inside func_options are hookable. See the 182754044362Smrg# individual implementations for details. 182854044362Smrgfunc_hookable func_options 182954044362Smrgfunc_options () 183054044362Smrg{ 183154044362Smrg $debug_cmd 183254044362Smrg 183354cef2ddSmrg _G_options_quoted=false 183454044362Smrg 183554cef2ddSmrg for my_func in options_prep parse_options validate_options options_finish 183654cef2ddSmrg do 183754cef2ddSmrg func_unset func_${my_func}_result 183854cef2ddSmrg func_unset func_run_hooks_result 183954cef2ddSmrg eval func_$my_func '${1+"$@"}' 184054cef2ddSmrg func_propagate_result func_$my_func func_options 184154cef2ddSmrg if $func_propagate_result_result; then 184254cef2ddSmrg eval set dummy "$func_options_result"; shift 184354cef2ddSmrg _G_options_quoted=: 184454cef2ddSmrg fi 184554cef2ddSmrg done 184654044362Smrg 184754cef2ddSmrg $_G_options_quoted || { 184854cef2ddSmrg # As we (func_options) are top-level options-parser function and 184954cef2ddSmrg # nobody quoted "$@" for us yet, we need to do it explicitly for 185054cef2ddSmrg # caller. 185154cef2ddSmrg func_quote eval ${1+"$@"} 185254cef2ddSmrg func_options_result=$func_quote_result 185354cef2ddSmrg } 18548c9fbc29Smrg} 18558c9fbc29Smrg 18568c9fbc29Smrg 185754044362Smrg# func_options_prep [ARG]... 185854044362Smrg# -------------------------- 185954044362Smrg# All initialisations required before starting the option parse loop. 186054044362Smrg# Note that when calling hook functions, we pass through the list of 186154044362Smrg# positional parameters. If a hook function modifies that list, and 186254cef2ddSmrg# needs to propagate that back to rest of this script, then the complete 186354cef2ddSmrg# modified list must be put in 'func_run_hooks_result' before returning. 186454044362Smrgfunc_hookable func_options_prep 186554044362Smrgfunc_options_prep () 18668c9fbc29Smrg{ 186754044362Smrg $debug_cmd 18684cd6a3aeSmrg 186954044362Smrg # Option defaults: 187054044362Smrg opt_verbose=false 187154044362Smrg opt_warning_types= 187254044362Smrg 187354044362Smrg func_run_hooks func_options_prep ${1+"$@"} 187454cef2ddSmrg func_propagate_result func_run_hooks func_options_prep 18754cd6a3aeSmrg} 18764cd6a3aeSmrg 18774cd6a3aeSmrg 187854044362Smrg# func_parse_options [ARG]... 187954044362Smrg# --------------------------- 188054044362Smrg# The main option parsing loop. 188154044362Smrgfunc_hookable func_parse_options 188254044362Smrgfunc_parse_options () 18834cd6a3aeSmrg{ 188454044362Smrg $debug_cmd 18854cd6a3aeSmrg 188654cef2ddSmrg _G_parse_options_requote=false 188754044362Smrg # this just eases exit handling 188854044362Smrg while test $# -gt 0; do 188954044362Smrg # Defer to hook functions for initial option parsing, so they 189054044362Smrg # get priority in the event of reusing an option name. 189154044362Smrg func_run_hooks func_parse_options ${1+"$@"} 189254cef2ddSmrg func_propagate_result func_run_hooks func_parse_options 189354cef2ddSmrg if $func_propagate_result_result; then 189454cef2ddSmrg eval set dummy "$func_parse_options_result"; shift 189554cef2ddSmrg # Even though we may have changed "$@", we passed the "$@" array 189654cef2ddSmrg # down into the hook and it quoted it for us (because we are in 189754cef2ddSmrg # this if-branch). No need to quote it again. 189854cef2ddSmrg _G_parse_options_requote=false 189954cef2ddSmrg fi 19004cd6a3aeSmrg 190154044362Smrg # Break out of the loop if we already parsed every option. 190254044362Smrg test $# -gt 0 || break 19034cd6a3aeSmrg 190454cef2ddSmrg # We expect that one of the options parsed in this function matches 190554cef2ddSmrg # and thus we remove _G_opt from "$@" and need to re-quote. 190654cef2ddSmrg _G_match_parse_options=: 190754044362Smrg _G_opt=$1 190854044362Smrg shift 190954044362Smrg case $_G_opt in 191054044362Smrg --debug|-x) debug_cmd='set -x' 191154cef2ddSmrg func_echo "enabling shell trace mode" >&2 191254044362Smrg $debug_cmd 191354044362Smrg ;; 191454044362Smrg 191554044362Smrg --no-warnings|--no-warning|--no-warn) 191654044362Smrg set dummy --warnings none ${1+"$@"} 191754044362Smrg shift 191854044362Smrg ;; 19194cd6a3aeSmrg 192054044362Smrg --warnings|--warning|-W) 192154cef2ddSmrg if test $# = 0 && func_missing_arg $_G_opt; then 192254cef2ddSmrg _G_parse_options_requote=: 192354cef2ddSmrg break 192454cef2ddSmrg fi 192554044362Smrg case " $warning_categories $1" in 192654044362Smrg *" $1 "*) 192754044362Smrg # trailing space prevents matching last $1 above 192854044362Smrg func_append_uniq opt_warning_types " $1" 192954044362Smrg ;; 193054044362Smrg *all) 193154044362Smrg opt_warning_types=$warning_categories 193254044362Smrg ;; 193354044362Smrg *none) 193454044362Smrg opt_warning_types=none 193554044362Smrg warning_func=: 193654044362Smrg ;; 193754044362Smrg *error) 193854044362Smrg opt_warning_types=$warning_categories 193954044362Smrg warning_func=func_fatal_error 194054044362Smrg ;; 194154044362Smrg *) 194254044362Smrg func_fatal_error \ 194354044362Smrg "unsupported warning category: '$1'" 194454044362Smrg ;; 194554044362Smrg esac 194654044362Smrg shift 194754044362Smrg ;; 194854044362Smrg 194954044362Smrg --verbose|-v) opt_verbose=: ;; 195054044362Smrg --version) func_version ;; 195154044362Smrg -\?|-h) func_usage ;; 195254044362Smrg --help) func_help ;; 195354044362Smrg 195454044362Smrg # Separate optargs to long options (plugins may need this): 195554044362Smrg --*=*) func_split_equals "$_G_opt" 195654044362Smrg set dummy "$func_split_equals_lhs" \ 195754044362Smrg "$func_split_equals_rhs" ${1+"$@"} 195854044362Smrg shift 195954044362Smrg ;; 196054044362Smrg 196154044362Smrg # Separate optargs to short options: 196254044362Smrg -W*) 196354044362Smrg func_split_short_opt "$_G_opt" 196454044362Smrg set dummy "$func_split_short_opt_name" \ 196554044362Smrg "$func_split_short_opt_arg" ${1+"$@"} 196654044362Smrg shift 196754044362Smrg ;; 196854044362Smrg 196954044362Smrg # Separate non-argument short options: 197054044362Smrg -\?*|-h*|-v*|-x*) 197154044362Smrg func_split_short_opt "$_G_opt" 197254044362Smrg set dummy "$func_split_short_opt_name" \ 197354044362Smrg "-$func_split_short_opt_arg" ${1+"$@"} 197454044362Smrg shift 197554044362Smrg ;; 197654044362Smrg 197754cef2ddSmrg --) _G_parse_options_requote=: ; break ;; 197854044362Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 197954cef2ddSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 198054cef2ddSmrg _G_match_parse_options=false 198154cef2ddSmrg break 198254cef2ddSmrg ;; 198354044362Smrg esac 198454cef2ddSmrg 198554cef2ddSmrg if $_G_match_parse_options; then 198654cef2ddSmrg _G_parse_options_requote=: 198754cef2ddSmrg fi 198854044362Smrg done 198954044362Smrg 199054cef2ddSmrg if $_G_parse_options_requote; then 199154cef2ddSmrg # save modified positional parameters for caller 199254cef2ddSmrg func_quote eval ${1+"$@"} 199354cef2ddSmrg func_parse_options_result=$func_quote_result 199454cef2ddSmrg fi 19954cd6a3aeSmrg} 19964cd6a3aeSmrg 19974cd6a3aeSmrg 199854044362Smrg# func_validate_options [ARG]... 199954044362Smrg# ------------------------------ 200054044362Smrg# Perform any sanity checks on option settings and/or unconsumed 200154044362Smrg# arguments. 200254044362Smrgfunc_hookable func_validate_options 200354044362Smrgfunc_validate_options () 20044cd6a3aeSmrg{ 200554044362Smrg $debug_cmd 20064cd6a3aeSmrg 200754044362Smrg # Display all warnings if -W was not given. 200854044362Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20094cd6a3aeSmrg 201054044362Smrg func_run_hooks func_validate_options ${1+"$@"} 201154cef2ddSmrg func_propagate_result func_run_hooks func_validate_options 20124cd6a3aeSmrg 201354044362Smrg # Bail if the options were screwed! 201454044362Smrg $exit_cmd $EXIT_FAILURE 20158c9fbc29Smrg} 20168c9fbc29Smrg 20178c9fbc29Smrg 20184cd6a3aeSmrg 201954044362Smrg## ----------------- ## 202054044362Smrg## Helper functions. ## 202154044362Smrg## ----------------- ## 20228c9fbc29Smrg 202354044362Smrg# This section contains the helper functions used by the rest of the 202454044362Smrg# hookable option parser framework in ascii-betical order. 202554044362Smrg 202654044362Smrg 202754044362Smrg# func_fatal_help ARG... 202854044362Smrg# ---------------------- 202954044362Smrg# Echo program name prefixed message to standard error, followed by 203054044362Smrg# a help hint, and exit. 203154044362Smrgfunc_fatal_help () 20328c9fbc29Smrg{ 203354044362Smrg $debug_cmd 20344cd6a3aeSmrg 203554044362Smrg eval \$ECHO \""Usage: $usage"\" 203654044362Smrg eval \$ECHO \""$fatal_help"\" 203754044362Smrg func_error ${1+"$@"} 203854044362Smrg exit $EXIT_FAILURE 20398c9fbc29Smrg} 20408c9fbc29Smrg 204154044362Smrg 204254044362Smrg# func_help 204354044362Smrg# --------- 204454044362Smrg# Echo long help message to standard output and exit. 20454cd6a3aeSmrgfunc_help () 20468c9fbc29Smrg{ 204754044362Smrg $debug_cmd 204854044362Smrg 204954044362Smrg func_usage_message 205054044362Smrg $ECHO "$long_help_message" 205154044362Smrg exit 0 20524cd6a3aeSmrg} 20538c9fbc29Smrg 205454044362Smrg 205554044362Smrg# func_missing_arg ARGNAME 205654044362Smrg# ------------------------ 20574cd6a3aeSmrg# Echo program name prefixed message to standard error and set global 20584cd6a3aeSmrg# exit_cmd. 20594cd6a3aeSmrgfunc_missing_arg () 20604cd6a3aeSmrg{ 206154044362Smrg $debug_cmd 20628c9fbc29Smrg 206354044362Smrg func_error "Missing argument for '$1'." 20644cd6a3aeSmrg exit_cmd=exit 20658c9fbc29Smrg} 20668c9fbc29Smrg 20678c9fbc29Smrg 206854044362Smrg# func_split_equals STRING 206954044362Smrg# ------------------------ 207054cef2ddSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 207154cef2ddSmrg# after splitting STRING at the '=' sign. 207254044362Smrgtest -z "$_G_HAVE_XSI_OPS" \ 207354044362Smrg && (eval 'x=a/b/c; 207454044362Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 207554044362Smrg && _G_HAVE_XSI_OPS=yes 207654044362Smrg 207754044362Smrgif test yes = "$_G_HAVE_XSI_OPS" 207854044362Smrgthen 207954044362Smrg # This is an XSI compatible shell, allowing a faster implementation... 208054044362Smrg eval 'func_split_equals () 208154044362Smrg { 208254044362Smrg $debug_cmd 208354044362Smrg 208454044362Smrg func_split_equals_lhs=${1%%=*} 208554044362Smrg func_split_equals_rhs=${1#*=} 208654cef2ddSmrg if test "x$func_split_equals_lhs" = "x$1"; then 208754cef2ddSmrg func_split_equals_rhs= 208854cef2ddSmrg fi 208954044362Smrg }' 209054044362Smrgelse 209154044362Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 209254044362Smrg func_split_equals () 209354044362Smrg { 209454044362Smrg $debug_cmd 209554044362Smrg 209654044362Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 209754044362Smrg func_split_equals_rhs= 209854cef2ddSmrg test "x$func_split_equals_lhs=" = "x$1" \ 209954044362Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 210054044362Smrg } 210154044362Smrgfi #func_split_equals 210254044362Smrg 210354044362Smrg 210454044362Smrg# func_split_short_opt SHORTOPT 210554044362Smrg# ----------------------------- 21064cd6a3aeSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 21074cd6a3aeSmrg# variables after splitting SHORTOPT after the 2nd character. 210854044362Smrgif test yes = "$_G_HAVE_XSI_OPS" 210954044362Smrgthen 211054044362Smrg # This is an XSI compatible shell, allowing a faster implementation... 211154044362Smrg eval 'func_split_short_opt () 211254044362Smrg { 211354044362Smrg $debug_cmd 211454044362Smrg 211554044362Smrg func_split_short_opt_arg=${1#??} 211654044362Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 211754044362Smrg }' 211854044362Smrgelse 211954044362Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 212054044362Smrg func_split_short_opt () 212154044362Smrg { 212254044362Smrg $debug_cmd 212354044362Smrg 212454cef2ddSmrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 212554044362Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 212654044362Smrg } 212754044362Smrgfi #func_split_short_opt 212854044362Smrg 212954044362Smrg 213054044362Smrg# func_usage 213154044362Smrg# ---------- 213254044362Smrg# Echo short help message to standard output and exit. 213354044362Smrgfunc_usage () 21344cd6a3aeSmrg{ 213554044362Smrg $debug_cmd 21364cd6a3aeSmrg 213754044362Smrg func_usage_message 213854044362Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 213954044362Smrg exit 0 214054044362Smrg} 21418c9fbc29Smrg 21428c9fbc29Smrg 214354044362Smrg# func_usage_message 214454044362Smrg# ------------------ 214554044362Smrg# Echo short help message to standard output. 214654044362Smrgfunc_usage_message () 21474cd6a3aeSmrg{ 214854044362Smrg $debug_cmd 21498c9fbc29Smrg 215054044362Smrg eval \$ECHO \""Usage: $usage"\" 215154044362Smrg echo 215254044362Smrg $SED -n 's|^# || 215354044362Smrg /^Written by/{ 215454044362Smrg x;p;x 215554044362Smrg } 215654044362Smrg h 215754044362Smrg /^Written by/q' < "$progpath" 215854044362Smrg echo 215954044362Smrg eval \$ECHO \""$usage_message"\" 216054044362Smrg} 21618c9fbc29Smrg 21628c9fbc29Smrg 216354044362Smrg# func_version 216454044362Smrg# ------------ 216554044362Smrg# Echo version message to standard output and exit. 216654cef2ddSmrg# The version message is extracted from the calling file's header 216754cef2ddSmrg# comments, with leading '# ' stripped: 216854cef2ddSmrg# 1. First display the progname and version 216954cef2ddSmrg# 2. Followed by the header comment line matching /^# Written by / 217054cef2ddSmrg# 3. Then a blank line followed by the first following line matching 217154cef2ddSmrg# /^# Copyright / 217254cef2ddSmrg# 4. Immediately followed by any lines between the previous matches, 217354cef2ddSmrg# except lines preceding the intervening completely blank line. 217454cef2ddSmrg# For example, see the header comments of this file. 217554044362Smrgfunc_version () 217654044362Smrg{ 217754044362Smrg $debug_cmd 21788c9fbc29Smrg 217954044362Smrg printf '%s\n' "$progname $scriptversion" 218054044362Smrg $SED -n ' 218154cef2ddSmrg /^# Written by /!b 218254cef2ddSmrg s|^# ||; p; n 218354cef2ddSmrg 218454cef2ddSmrg :fwd2blnk 218554cef2ddSmrg /./ { 218654cef2ddSmrg n 218754cef2ddSmrg b fwd2blnk 218854044362Smrg } 218954cef2ddSmrg p; n 219054cef2ddSmrg 219154cef2ddSmrg :holdwrnt 219254cef2ddSmrg s|^# || 219354cef2ddSmrg s|^# *$|| 219454cef2ddSmrg /^Copyright /!{ 219554cef2ddSmrg /./H 219654cef2ddSmrg n 219754cef2ddSmrg b holdwrnt 219854044362Smrg } 219954cef2ddSmrg 220054cef2ddSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 220154cef2ddSmrg G 220254cef2ddSmrg s|\(\n\)\n*|\1|g 220354cef2ddSmrg p; q' < "$progpath" 22048c9fbc29Smrg 220554044362Smrg exit $? 220654044362Smrg} 22074e411241Smrg 22088c9fbc29Smrg 220954044362Smrg# Local variables: 221054044362Smrg# mode: shell-script 221154044362Smrg# sh-indentation: 2 221254044362Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 221354cef2ddSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 221454044362Smrg# time-stamp-time-zone: "UTC" 221554044362Smrg# End: 22164cd6a3aeSmrg 221754044362Smrg# Set a version string. 221854cef2ddSmrgscriptversion='(GNU libtool) 2.4.7' 22194cd6a3aeSmrg 22204cd6a3aeSmrg 222154044362Smrg# func_echo ARG... 222254044362Smrg# ---------------- 222354044362Smrg# Libtool also displays the current mode in messages, so override 222454044362Smrg# funclib.sh func_echo with this custom definition. 222554044362Smrgfunc_echo () 22264cd6a3aeSmrg{ 222754044362Smrg $debug_cmd 22284cd6a3aeSmrg 222954044362Smrg _G_message=$* 22304cd6a3aeSmrg 223154044362Smrg func_echo_IFS=$IFS 223254044362Smrg IFS=$nl 223354044362Smrg for _G_line in $_G_message; do 223454044362Smrg IFS=$func_echo_IFS 223554044362Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 223654044362Smrg done 223754044362Smrg IFS=$func_echo_IFS 223854044362Smrg} 22394cd6a3aeSmrg 224054044362Smrg 224154044362Smrg# func_warning ARG... 224254044362Smrg# ------------------- 224354044362Smrg# Libtool warnings are not categorized, so override funclib.sh 224454044362Smrg# func_warning with this simpler definition. 224554044362Smrgfunc_warning () 22464cd6a3aeSmrg{ 224754044362Smrg $debug_cmd 22484cd6a3aeSmrg 224954044362Smrg $warning_func ${1+"$@"} 225054044362Smrg} 22514cd6a3aeSmrg 22524cd6a3aeSmrg 225354044362Smrg## ---------------- ## 225454044362Smrg## Options parsing. ## 225554044362Smrg## ---------------- ## 225654044362Smrg 225754044362Smrg# Hook in the functions to make sure our own options are parsed during 225854044362Smrg# the option parsing loop. 225954044362Smrg 226054044362Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 226154044362Smrg 226254044362Smrg# Short help message in response to '-h'. 226354044362Smrgusage_message="Options: 226454044362Smrg --config show all configuration variables 226554044362Smrg --debug enable verbose shell tracing 226654044362Smrg -n, --dry-run display commands without modifying any files 226754044362Smrg --features display basic configuration information and exit 226854044362Smrg --mode=MODE use operation mode MODE 226954044362Smrg --no-warnings equivalent to '-Wnone' 227054044362Smrg --preserve-dup-deps don't remove duplicate dependency libraries 227154044362Smrg --quiet, --silent don't print informational messages 227254044362Smrg --tag=TAG use configuration variables from tag TAG 227354044362Smrg -v, --verbose print more informational messages than default 227454044362Smrg --version print version information 227554044362Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 227654044362Smrg -h, --help, --help-all print short, long, or detailed help message 227754044362Smrg" 22784cd6a3aeSmrg 227954044362Smrg# Additional text appended to 'usage_message' in response to '--help'. 228054044362Smrgfunc_help () 22814cd6a3aeSmrg{ 228254044362Smrg $debug_cmd 228354044362Smrg 228454044362Smrg func_usage_message 228554044362Smrg $ECHO "$long_help_message 228654044362Smrg 228754044362SmrgMODE must be one of the following: 228854044362Smrg 228954044362Smrg clean remove files from the build directory 229054044362Smrg compile compile a source file into a libtool object 229154044362Smrg execute automatically set library path, then run a program 229254044362Smrg finish complete the installation of libtool libraries 229354044362Smrg install install libraries or executables 229454044362Smrg link create a library or an executable 229554044362Smrg uninstall remove libraries from an installed directory 229654044362Smrg 229754044362SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 229854044362Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 229954044362SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 230054044362Smrg 230154044362SmrgWhen reporting a bug, please describe a test case to reproduce it and 230254044362Smrginclude the following information: 230354044362Smrg 230454044362Smrg host-triplet: $host 230554044362Smrg shell: $SHELL 230654044362Smrg compiler: $LTCC 230754044362Smrg compiler flags: $LTCFLAGS 230854044362Smrg linker: $LD (gnu? $with_gnu_ld) 230954cef2ddSmrg version: $progname (GNU libtool) 2.4.7 231054044362Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 231154044362Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 231254044362Smrg 231354044362SmrgReport bugs to <bug-libtool@gnu.org>. 231454cef2ddSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 231554044362SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 231654044362Smrg exit 0 231754044362Smrg} 23184cd6a3aeSmrg 23194cd6a3aeSmrg 232054044362Smrg# func_lo2o OBJECT-NAME 232154044362Smrg# --------------------- 232254044362Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 232354044362Smrg# object suffix. 232454044362Smrg 232554044362Smrglo2o=s/\\.lo\$/.$objext/ 232654044362Smrgo2lo=s/\\.$objext\$/.lo/ 232754044362Smrg 232854044362Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 232954044362Smrg eval 'func_lo2o () 233054044362Smrg { 233154044362Smrg case $1 in 233254044362Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 233354044362Smrg * ) func_lo2o_result=$1 ;; 233454044362Smrg esac 233554044362Smrg }' 233654044362Smrg 233754044362Smrg # func_xform LIBOBJ-OR-SOURCE 233854044362Smrg # --------------------------- 233954044362Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 234054044362Smrg # suffix to a '.lo' libtool-object suffix. 234154044362Smrg eval 'func_xform () 234254044362Smrg { 234354044362Smrg func_xform_result=${1%.*}.lo 234454044362Smrg }' 234554044362Smrgelse 234654044362Smrg # ...otherwise fall back to using sed. 234754044362Smrg func_lo2o () 234854044362Smrg { 234954044362Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 235054044362Smrg } 235154044362Smrg 235254044362Smrg func_xform () 235354044362Smrg { 235454044362Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 235554044362Smrg } 235654044362Smrgfi 23574cd6a3aeSmrg 23584cd6a3aeSmrg 235954044362Smrg# func_fatal_configuration ARG... 236054044362Smrg# ------------------------------- 23614cd6a3aeSmrg# Echo program name prefixed message to standard error, followed by 23624cd6a3aeSmrg# a configuration failure hint, and exit. 23634cd6a3aeSmrgfunc_fatal_configuration () 23644cd6a3aeSmrg{ 236554cef2ddSmrg func_fatal_error ${1+"$@"} \ 236654044362Smrg "See the $PACKAGE documentation for more information." \ 236754044362Smrg "Fatal configuration error." 23684cd6a3aeSmrg} 23694cd6a3aeSmrg 23704cd6a3aeSmrg 23714cd6a3aeSmrg# func_config 237254044362Smrg# ----------- 23734cd6a3aeSmrg# Display the configuration for all the tags in this script. 23744cd6a3aeSmrgfunc_config () 23754cd6a3aeSmrg{ 23764cd6a3aeSmrg re_begincf='^# ### BEGIN LIBTOOL' 23774cd6a3aeSmrg re_endcf='^# ### END LIBTOOL' 23784cd6a3aeSmrg 23794cd6a3aeSmrg # Default configuration. 23804cd6a3aeSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 23814cd6a3aeSmrg 23828c9fbc29Smrg # Now print the configurations for the tags. 23838c9fbc29Smrg for tagname in $taglist; do 23844cd6a3aeSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23858c9fbc29Smrg done 23868c9fbc29Smrg 23874cd6a3aeSmrg exit $? 23884cd6a3aeSmrg} 23898c9fbc29Smrg 239054044362Smrg 23914cd6a3aeSmrg# func_features 239254044362Smrg# ------------- 23934cd6a3aeSmrg# Display the features supported by this script. 23944cd6a3aeSmrgfunc_features () 23954cd6a3aeSmrg{ 23964cd6a3aeSmrg echo "host: $host" 239754044362Smrg if test yes = "$build_libtool_libs"; then 23984cd6a3aeSmrg echo "enable shared libraries" 23998c9fbc29Smrg else 24004cd6a3aeSmrg echo "disable shared libraries" 24018c9fbc29Smrg fi 240254044362Smrg if test yes = "$build_old_libs"; then 24034cd6a3aeSmrg echo "enable static libraries" 24048c9fbc29Smrg else 24054cd6a3aeSmrg echo "disable static libraries" 24068c9fbc29Smrg fi 24078c9fbc29Smrg 24084cd6a3aeSmrg exit $? 24094cd6a3aeSmrg} 24108c9fbc29Smrg 241154044362Smrg 241254044362Smrg# func_enable_tag TAGNAME 241354044362Smrg# ----------------------- 24144cd6a3aeSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 24154cd6a3aeSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 24164cd6a3aeSmrg# variable here. 24174cd6a3aeSmrgfunc_enable_tag () 24184cd6a3aeSmrg{ 241954044362Smrg # Global variable: 242054044362Smrg tagname=$1 24218c9fbc29Smrg 242254044362Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 242354044362Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 242454044362Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24258c9fbc29Smrg 242654044362Smrg # Validate tagname. 242754044362Smrg case $tagname in 242854044362Smrg *[!-_A-Za-z0-9,/]*) 242954044362Smrg func_fatal_error "invalid tag name: $tagname" 243054044362Smrg ;; 243154044362Smrg esac 24328c9fbc29Smrg 243354044362Smrg # Don't test for the "default" C tag, as we know it's 243454044362Smrg # there but not specially marked. 243554044362Smrg case $tagname in 243654044362Smrg CC) ;; 24374cd6a3aeSmrg *) 243854044362Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 243954044362Smrg taglist="$taglist $tagname" 244054044362Smrg 244154044362Smrg # Evaluate the configuration. Be careful to quote the path 244254044362Smrg # and the sed script, to avoid splitting on whitespace, but 244354044362Smrg # also don't use non-portable quotes within backquotes within 244454044362Smrg # quotes we have to do it in 2 steps: 244554044362Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 244654044362Smrg eval "$extractedcf" 244754044362Smrg else 244854044362Smrg func_error "ignoring unknown tag $tagname" 244954044362Smrg fi 245054044362Smrg ;; 245154044362Smrg esac 24524cd6a3aeSmrg} 24538c9fbc29Smrg 245454044362Smrg 24554cd6a3aeSmrg# func_check_version_match 245654044362Smrg# ------------------------ 24574cd6a3aeSmrg# Ensure that we are using m4 macros, and libtool script from the same 24584cd6a3aeSmrg# release of libtool. 24594cd6a3aeSmrgfunc_check_version_match () 24604cd6a3aeSmrg{ 246154044362Smrg if test "$package_revision" != "$macro_revision"; then 246254044362Smrg if test "$VERSION" != "$macro_version"; then 246354044362Smrg if test -z "$macro_version"; then 246454044362Smrg cat >&2 <<_LT_EOF 24654cd6a3aeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24664cd6a3aeSmrg$progname: definition of this LT_INIT comes from an older release. 24674cd6a3aeSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24684cd6a3aeSmrg$progname: and run autoconf again. 24694cd6a3aeSmrg_LT_EOF 247054044362Smrg else 247154044362Smrg cat >&2 <<_LT_EOF 24724cd6a3aeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24734cd6a3aeSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 24744cd6a3aeSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24754cd6a3aeSmrg$progname: and run autoconf again. 24764cd6a3aeSmrg_LT_EOF 247754044362Smrg fi 247854044362Smrg else 247954044362Smrg cat >&2 <<_LT_EOF 24804cd6a3aeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 24814cd6a3aeSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 24824cd6a3aeSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 24834cd6a3aeSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 24844cd6a3aeSmrg_LT_EOF 248554044362Smrg fi 24868c9fbc29Smrg 248754044362Smrg exit $EXIT_MISMATCH 248854044362Smrg fi 24894cd6a3aeSmrg} 24908c9fbc29Smrg 24918c9fbc29Smrg 249254044362Smrg# libtool_options_prep [ARG]... 249354044362Smrg# ----------------------------- 249454044362Smrg# Preparation for options parsed by libtool. 249554044362Smrglibtool_options_prep () 249654044362Smrg{ 249754044362Smrg $debug_mode 24988c9fbc29Smrg 249954044362Smrg # Option defaults: 250054044362Smrg opt_config=false 250154044362Smrg opt_dlopen= 250254044362Smrg opt_dry_run=false 250354044362Smrg opt_help=false 250454044362Smrg opt_mode= 250554044362Smrg opt_preserve_dup_deps=false 250654044362Smrg opt_quiet=false 25078c9fbc29Smrg 250854044362Smrg nonopt= 250954044362Smrg preserve_args= 25108c9fbc29Smrg 251154cef2ddSmrg _G_rc_lt_options_prep=: 251254cef2ddSmrg 251354044362Smrg # Shorthand for --mode=foo, only valid as the first argument 251454044362Smrg case $1 in 251554044362Smrg clean|clea|cle|cl) 251654044362Smrg shift; set dummy --mode clean ${1+"$@"}; shift 251754044362Smrg ;; 251854044362Smrg compile|compil|compi|comp|com|co|c) 251954044362Smrg shift; set dummy --mode compile ${1+"$@"}; shift 252054044362Smrg ;; 252154044362Smrg execute|execut|execu|exec|exe|ex|e) 252254044362Smrg shift; set dummy --mode execute ${1+"$@"}; shift 252354044362Smrg ;; 252454044362Smrg finish|finis|fini|fin|fi|f) 252554044362Smrg shift; set dummy --mode finish ${1+"$@"}; shift 252654044362Smrg ;; 252754044362Smrg install|instal|insta|inst|ins|in|i) 252854044362Smrg shift; set dummy --mode install ${1+"$@"}; shift 252954044362Smrg ;; 253054044362Smrg link|lin|li|l) 253154044362Smrg shift; set dummy --mode link ${1+"$@"}; shift 253254044362Smrg ;; 253354044362Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 253454044362Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 253554044362Smrg ;; 253654cef2ddSmrg *) 253754cef2ddSmrg _G_rc_lt_options_prep=false 253854cef2ddSmrg ;; 253954044362Smrg esac 254054044362Smrg 254154cef2ddSmrg if $_G_rc_lt_options_prep; then 254254cef2ddSmrg # Pass back the list of options. 254354cef2ddSmrg func_quote eval ${1+"$@"} 254454cef2ddSmrg libtool_options_prep_result=$func_quote_result 254554cef2ddSmrg fi 254654044362Smrg} 254754044362Smrgfunc_add_hook func_options_prep libtool_options_prep 25488c9fbc29Smrg 25494cd6a3aeSmrg 255054044362Smrg# libtool_parse_options [ARG]... 255154044362Smrg# --------------------------------- 255254044362Smrg# Provide handling for libtool specific options. 255354044362Smrglibtool_parse_options () 25544cd6a3aeSmrg{ 255554044362Smrg $debug_cmd 25568c9fbc29Smrg 255754cef2ddSmrg _G_rc_lt_parse_options=false 255854cef2ddSmrg 255954044362Smrg # Perform our own loop to consume as many options as possible in 256054044362Smrg # each iteration. 256154044362Smrg while test $# -gt 0; do 256254cef2ddSmrg _G_match_lt_parse_options=: 256354044362Smrg _G_opt=$1 256454044362Smrg shift 256554044362Smrg case $_G_opt in 256654044362Smrg --dry-run|--dryrun|-n) 256754044362Smrg opt_dry_run=: 256854044362Smrg ;; 256954044362Smrg 257054044362Smrg --config) func_config ;; 257154044362Smrg 257254044362Smrg --dlopen|-dlopen) 257354044362Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 257454044362Smrg}$1" 257554044362Smrg shift 257654044362Smrg ;; 257754044362Smrg 257854044362Smrg --preserve-dup-deps) 257954044362Smrg opt_preserve_dup_deps=: ;; 258054044362Smrg 258154044362Smrg --features) func_features ;; 258254044362Smrg 258354044362Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 258454044362Smrg 258554044362Smrg --help) opt_help=: ;; 258654044362Smrg 258754044362Smrg --help-all) opt_help=': help-all' ;; 258854044362Smrg 258954044362Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 259054044362Smrg opt_mode=$1 259154044362Smrg case $1 in 259254044362Smrg # Valid mode arguments: 259354044362Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 259454044362Smrg 259554044362Smrg # Catch anything else as an error 259654044362Smrg *) func_error "invalid argument for $_G_opt" 259754044362Smrg exit_cmd=exit 259854044362Smrg break 259954044362Smrg ;; 260054044362Smrg esac 260154044362Smrg shift 260254044362Smrg ;; 260354044362Smrg 260454044362Smrg --no-silent|--no-quiet) 260554044362Smrg opt_quiet=false 260654044362Smrg func_append preserve_args " $_G_opt" 260754044362Smrg ;; 260854044362Smrg 260954044362Smrg --no-warnings|--no-warning|--no-warn) 261054044362Smrg opt_warning=false 261154044362Smrg func_append preserve_args " $_G_opt" 261254044362Smrg ;; 261354044362Smrg 261454044362Smrg --no-verbose) 261554044362Smrg opt_verbose=false 261654044362Smrg func_append preserve_args " $_G_opt" 261754044362Smrg ;; 261854044362Smrg 261954044362Smrg --silent|--quiet) 262054044362Smrg opt_quiet=: 262154044362Smrg opt_verbose=false 262254044362Smrg func_append preserve_args " $_G_opt" 262354044362Smrg ;; 262454044362Smrg 262554044362Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 262654044362Smrg opt_tag=$1 262754044362Smrg func_append preserve_args " $_G_opt $1" 262854044362Smrg func_enable_tag "$1" 262954044362Smrg shift 263054044362Smrg ;; 263154044362Smrg 263254044362Smrg --verbose|-v) opt_quiet=false 263354044362Smrg opt_verbose=: 263454044362Smrg func_append preserve_args " $_G_opt" 263554044362Smrg ;; 263654044362Smrg 263754cef2ddSmrg # An option not handled by this hook function: 263854cef2ddSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 263954cef2ddSmrg _G_match_lt_parse_options=false 264054cef2ddSmrg break 264154cef2ddSmrg ;; 264254044362Smrg esac 264354cef2ddSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 264454044362Smrg done 26454cd6a3aeSmrg 264654cef2ddSmrg if $_G_rc_lt_parse_options; then 264754cef2ddSmrg # save modified positional parameters for caller 264854cef2ddSmrg func_quote eval ${1+"$@"} 264954cef2ddSmrg libtool_parse_options_result=$func_quote_result 265054cef2ddSmrg fi 265154044362Smrg} 265254044362Smrgfunc_add_hook func_parse_options libtool_parse_options 26538c9fbc29Smrg 26548c9fbc29Smrg 26558c9fbc29Smrg 265654044362Smrg# libtool_validate_options [ARG]... 265754044362Smrg# --------------------------------- 265854044362Smrg# Perform any sanity checks on option settings and/or unconsumed 265954044362Smrg# arguments. 266054044362Smrglibtool_validate_options () 266154044362Smrg{ 266254044362Smrg # save first non-option argument 266354044362Smrg if test 0 -lt $#; then 266454044362Smrg nonopt=$1 266554044362Smrg shift 26664cd6a3aeSmrg fi 26678c9fbc29Smrg 266854044362Smrg # preserve --debug 266954044362Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 26708c9fbc29Smrg 267154044362Smrg case $host in 267254044362Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 267354044362Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 267454044362Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 267554044362Smrg # don't eliminate duplications in $postdeps and $predeps 267654044362Smrg opt_duplicate_compiler_generated_deps=: 267754044362Smrg ;; 267854044362Smrg *) 267954044362Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 268054044362Smrg ;; 268154044362Smrg esac 26828c9fbc29Smrg 268354044362Smrg $opt_help || { 268454044362Smrg # Sanity checks first: 268554044362Smrg func_check_version_match 268654044362Smrg 268754044362Smrg test yes != "$build_libtool_libs" \ 268854044362Smrg && test yes != "$build_old_libs" \ 268954044362Smrg && func_fatal_configuration "not configured to build any kind of library" 269054044362Smrg 269154044362Smrg # Darwin sucks 269254044362Smrg eval std_shrext=\"$shrext_cmds\" 269354044362Smrg 269454044362Smrg # Only execute mode is allowed to have -dlopen flags. 269554044362Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 269654044362Smrg func_error "unrecognized option '-dlopen'" 269754044362Smrg $ECHO "$help" 1>&2 269854044362Smrg exit $EXIT_FAILURE 269954044362Smrg fi 27008c9fbc29Smrg 270154044362Smrg # Change the help message to a mode-specific one. 270254044362Smrg generic_help=$help 270354044362Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 270454044362Smrg } 27058c9fbc29Smrg 270654044362Smrg # Pass back the unparsed argument list 270754cef2ddSmrg func_quote eval ${1+"$@"} 270854cef2ddSmrg libtool_validate_options_result=$func_quote_result 27094cd6a3aeSmrg} 271054044362Smrgfunc_add_hook func_validate_options libtool_validate_options 27118c9fbc29Smrg 27128c9fbc29Smrg 271354044362Smrg# Process options as early as possible so that --help and --version 271454044362Smrg# can return quickly. 271554044362Smrgfunc_options ${1+"$@"} 271654044362Smrgeval set dummy "$func_options_result"; shift 271754044362Smrg 27188c9fbc29Smrg 27198c9fbc29Smrg 27204cd6a3aeSmrg## ----------- ## 27214cd6a3aeSmrg## Main. ## 27224cd6a3aeSmrg## ----------- ## 27238c9fbc29Smrg 272454044362Smrgmagic='%%%MAGIC variable%%%' 272554044362Smrgmagic_exe='%%%MAGIC EXE variable%%%' 272654044362Smrg 272754044362Smrg# Global variables. 272854044362Smrgextracted_archives= 272954044362Smrgextracted_serial=0 273054044362Smrg 273154044362Smrg# If this variable is set in any of the actions, the command in it 273254044362Smrg# will be execed at the end. This prevents here-documents from being 273354044362Smrg# left over by shells. 273454044362Smrgexec_cmd= 273554044362Smrg 273654044362Smrg 273754044362Smrg# A function that is used when there is no print builtin or printf. 273854044362Smrgfunc_fallback_echo () 273954044362Smrg{ 274054044362Smrg eval 'cat <<_LTECHO_EOF 274154044362Smrg$1 274254044362Smrg_LTECHO_EOF' 274354044362Smrg} 274454044362Smrg 274554044362Smrg# func_generated_by_libtool 274654044362Smrg# True iff stdin has been generated by Libtool. This function is only 274754044362Smrg# a basic sanity check; it will hardly flush out determined imposters. 274854044362Smrgfunc_generated_by_libtool_p () 274954044362Smrg{ 275054044362Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 275154044362Smrg} 275254044362Smrg 27534cd6a3aeSmrg# func_lalib_p file 275454044362Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27554cd6a3aeSmrg# This function is only a basic sanity check; it will hardly flush out 27564cd6a3aeSmrg# determined imposters. 27574cd6a3aeSmrgfunc_lalib_p () 27584cd6a3aeSmrg{ 27594cd6a3aeSmrg test -f "$1" && 276054044362Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 27614cd6a3aeSmrg} 27628c9fbc29Smrg 27634cd6a3aeSmrg# func_lalib_unsafe_p file 276454044362Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27654cd6a3aeSmrg# This function implements the same check as func_lalib_p without 27664cd6a3aeSmrg# resorting to external programs. To this end, it redirects stdin and 27674cd6a3aeSmrg# closes it afterwards, without saving the original file descriptor. 27684cd6a3aeSmrg# As a safety measure, use it only where a negative result would be 276954044362Smrg# fatal anyway. Works if 'file' does not exist. 27704cd6a3aeSmrgfunc_lalib_unsafe_p () 27714cd6a3aeSmrg{ 27724cd6a3aeSmrg lalib_p=no 27734cd6a3aeSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 27744cd6a3aeSmrg for lalib_p_l in 1 2 3 4 27754cd6a3aeSmrg do 27764cd6a3aeSmrg read lalib_p_line 277754044362Smrg case $lalib_p_line in 27784cd6a3aeSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 27794cd6a3aeSmrg esac 27804cd6a3aeSmrg done 27814cd6a3aeSmrg exec 0<&5 5<&- 27824cd6a3aeSmrg fi 278354044362Smrg test yes = "$lalib_p" 27844cd6a3aeSmrg} 27858c9fbc29Smrg 27864cd6a3aeSmrg# func_ltwrapper_script_p file 27874cd6a3aeSmrg# True iff FILE is a libtool wrapper script 27884cd6a3aeSmrg# This function is only a basic sanity check; it will hardly flush out 27894cd6a3aeSmrg# determined imposters. 27904cd6a3aeSmrgfunc_ltwrapper_script_p () 27914cd6a3aeSmrg{ 279254044362Smrg test -f "$1" && 279354044362Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 27944cd6a3aeSmrg} 27958c9fbc29Smrg 27964cd6a3aeSmrg# func_ltwrapper_executable_p file 27974cd6a3aeSmrg# True iff FILE is a libtool wrapper executable 27984cd6a3aeSmrg# This function is only a basic sanity check; it will hardly flush out 27994cd6a3aeSmrg# determined imposters. 28004cd6a3aeSmrgfunc_ltwrapper_executable_p () 28014cd6a3aeSmrg{ 28024cd6a3aeSmrg func_ltwrapper_exec_suffix= 28034cd6a3aeSmrg case $1 in 28044cd6a3aeSmrg *.exe) ;; 28054cd6a3aeSmrg *) func_ltwrapper_exec_suffix=.exe ;; 28068c9fbc29Smrg esac 28074cd6a3aeSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 28084cd6a3aeSmrg} 28098c9fbc29Smrg 28104cd6a3aeSmrg# func_ltwrapper_scriptname file 28114cd6a3aeSmrg# Assumes file is an ltwrapper_executable 28124cd6a3aeSmrg# uses $file to determine the appropriate filename for a 28134cd6a3aeSmrg# temporary ltwrapper_script. 28144cd6a3aeSmrgfunc_ltwrapper_scriptname () 28154cd6a3aeSmrg{ 28164cd6a3aeSmrg func_dirname_and_basename "$1" "" "." 28174cd6a3aeSmrg func_stripname '' '.exe' "$func_basename_result" 281854044362Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 28194cd6a3aeSmrg} 28208c9fbc29Smrg 28214cd6a3aeSmrg# func_ltwrapper_p file 28224cd6a3aeSmrg# True iff FILE is a libtool wrapper script or wrapper executable 28234cd6a3aeSmrg# This function is only a basic sanity check; it will hardly flush out 28244cd6a3aeSmrg# determined imposters. 28254cd6a3aeSmrgfunc_ltwrapper_p () 28264cd6a3aeSmrg{ 28274cd6a3aeSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 28284cd6a3aeSmrg} 28298c9fbc29Smrg 28308c9fbc29Smrg 28314cd6a3aeSmrg# func_execute_cmds commands fail_cmd 28324cd6a3aeSmrg# Execute tilde-delimited COMMANDS. 28334cd6a3aeSmrg# If FAIL_CMD is given, eval that upon failure. 28344cd6a3aeSmrg# FAIL_CMD may read-access the current command in variable CMD! 28354cd6a3aeSmrgfunc_execute_cmds () 28364cd6a3aeSmrg{ 283754044362Smrg $debug_cmd 283854044362Smrg 28394cd6a3aeSmrg save_ifs=$IFS; IFS='~' 28404cd6a3aeSmrg for cmd in $1; do 284154044362Smrg IFS=$sp$nl 28424cd6a3aeSmrg eval cmd=\"$cmd\" 284354044362Smrg IFS=$save_ifs 28444cd6a3aeSmrg func_show_eval "$cmd" "${2-:}" 28458c9fbc29Smrg done 28464cd6a3aeSmrg IFS=$save_ifs 28474cd6a3aeSmrg} 28488c9fbc29Smrg 28498c9fbc29Smrg 28504cd6a3aeSmrg# func_source file 28514cd6a3aeSmrg# Source FILE, adding directory component if necessary. 28524cd6a3aeSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 28534cd6a3aeSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 28544cd6a3aeSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 285554044362Smrg# 'FILE.' does not work on cygwin managed mounts. 28564cd6a3aeSmrgfunc_source () 28574cd6a3aeSmrg{ 285854044362Smrg $debug_cmd 285954044362Smrg 28604cd6a3aeSmrg case $1 in 28614cd6a3aeSmrg */* | *\\*) . "$1" ;; 28624cd6a3aeSmrg *) . "./$1" ;; 28634cd6a3aeSmrg esac 28644cd6a3aeSmrg} 28658c9fbc29Smrg 28668c9fbc29Smrg 28674cd6a3aeSmrg# func_resolve_sysroot PATH 28684cd6a3aeSmrg# Replace a leading = in PATH with a sysroot. Store the result into 28694cd6a3aeSmrg# func_resolve_sysroot_result 28704cd6a3aeSmrgfunc_resolve_sysroot () 28714cd6a3aeSmrg{ 28724cd6a3aeSmrg func_resolve_sysroot_result=$1 28734cd6a3aeSmrg case $func_resolve_sysroot_result in 28744cd6a3aeSmrg =*) 28754cd6a3aeSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 28764cd6a3aeSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 28774cd6a3aeSmrg ;; 28784cd6a3aeSmrg esac 28794cd6a3aeSmrg} 28808c9fbc29Smrg 28814cd6a3aeSmrg# func_replace_sysroot PATH 28824cd6a3aeSmrg# If PATH begins with the sysroot, replace it with = and 28834cd6a3aeSmrg# store the result into func_replace_sysroot_result. 28844cd6a3aeSmrgfunc_replace_sysroot () 28854cd6a3aeSmrg{ 288654044362Smrg case $lt_sysroot:$1 in 28874cd6a3aeSmrg ?*:"$lt_sysroot"*) 28884cd6a3aeSmrg func_stripname "$lt_sysroot" '' "$1" 288954044362Smrg func_replace_sysroot_result='='$func_stripname_result 28904cd6a3aeSmrg ;; 28914cd6a3aeSmrg *) 28924cd6a3aeSmrg # Including no sysroot. 28934cd6a3aeSmrg func_replace_sysroot_result=$1 28944cd6a3aeSmrg ;; 28954cd6a3aeSmrg esac 28964cd6a3aeSmrg} 28978c9fbc29Smrg 28984cd6a3aeSmrg# func_infer_tag arg 28994cd6a3aeSmrg# Infer tagged configuration to use if any are available and 29004cd6a3aeSmrg# if one wasn't chosen via the "--tag" command line option. 29014cd6a3aeSmrg# Only attempt this if the compiler in the base compile 29024cd6a3aeSmrg# command doesn't match the default compiler. 29034cd6a3aeSmrg# arg is usually of the form 'gcc ...' 29044cd6a3aeSmrgfunc_infer_tag () 29054cd6a3aeSmrg{ 290654044362Smrg $debug_cmd 290754044362Smrg 29084cd6a3aeSmrg if test -n "$available_tags" && test -z "$tagname"; then 29094cd6a3aeSmrg CC_quoted= 29104cd6a3aeSmrg for arg in $CC; do 29114cd6a3aeSmrg func_append_quoted CC_quoted "$arg" 29124cd6a3aeSmrg done 29134cd6a3aeSmrg CC_expanded=`func_echo_all $CC` 29144cd6a3aeSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29154cd6a3aeSmrg case $@ in 29164cd6a3aeSmrg # Blanks in the command may have been stripped by the calling shell, 29174cd6a3aeSmrg # but not from the CC environment variable when configure was run. 29184cd6a3aeSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29194cd6a3aeSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 29204cd6a3aeSmrg # Blanks at the start of $base_compile will cause this to fail 29214cd6a3aeSmrg # if we don't check for them as well. 29224cd6a3aeSmrg *) 29234cd6a3aeSmrg for z in $available_tags; do 29244cd6a3aeSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 29254cd6a3aeSmrg # Evaluate the configuration. 292654044362Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 29274cd6a3aeSmrg CC_quoted= 29284cd6a3aeSmrg for arg in $CC; do 29294cd6a3aeSmrg # Double-quote args containing other shell metacharacters. 29304cd6a3aeSmrg func_append_quoted CC_quoted "$arg" 29314cd6a3aeSmrg done 29324cd6a3aeSmrg CC_expanded=`func_echo_all $CC` 29334cd6a3aeSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29344cd6a3aeSmrg case "$@ " in 29354cd6a3aeSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29364cd6a3aeSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 29374cd6a3aeSmrg # The compiler in the base compile command matches 29384cd6a3aeSmrg # the one in the tagged configuration. 29394cd6a3aeSmrg # Assume this is the tagged configuration we want. 29404cd6a3aeSmrg tagname=$z 29414cd6a3aeSmrg break 29424cd6a3aeSmrg ;; 29434cd6a3aeSmrg esac 29444cd6a3aeSmrg fi 29454cd6a3aeSmrg done 29464cd6a3aeSmrg # If $tagname still isn't set, then no tagged configuration 29474cd6a3aeSmrg # was found and let the user know that the "--tag" command 29484cd6a3aeSmrg # line option must be used. 29494cd6a3aeSmrg if test -z "$tagname"; then 29504cd6a3aeSmrg func_echo "unable to infer tagged configuration" 295154044362Smrg func_fatal_error "specify a tag with '--tag'" 29524cd6a3aeSmrg# else 29534cd6a3aeSmrg# func_verbose "using $tagname tagged configuration" 29544cd6a3aeSmrg fi 29554cd6a3aeSmrg ;; 29564cd6a3aeSmrg esac 29578c9fbc29Smrg fi 29584cd6a3aeSmrg} 29598c9fbc29Smrg 29608c9fbc29Smrg 29618c9fbc29Smrg 29624cd6a3aeSmrg# func_write_libtool_object output_name pic_name nonpic_name 29634cd6a3aeSmrg# Create a libtool object file (analogous to a ".la" file), 29644cd6a3aeSmrg# but don't create it if we're doing a dry run. 29654cd6a3aeSmrgfunc_write_libtool_object () 29664cd6a3aeSmrg{ 296754044362Smrg write_libobj=$1 296854044362Smrg if test yes = "$build_libtool_libs"; then 296954044362Smrg write_lobj=\'$2\' 29704cd6a3aeSmrg else 29714cd6a3aeSmrg write_lobj=none 29728c9fbc29Smrg fi 29738c9fbc29Smrg 297454044362Smrg if test yes = "$build_old_libs"; then 297554044362Smrg write_oldobj=\'$3\' 29764cd6a3aeSmrg else 29774cd6a3aeSmrg write_oldobj=none 29788c9fbc29Smrg fi 29798c9fbc29Smrg 29804cd6a3aeSmrg $opt_dry_run || { 29814cd6a3aeSmrg cat >${write_libobj}T <<EOF 29824cd6a3aeSmrg# $write_libobj - a libtool object file 298354044362Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 29848c9fbc29Smrg# 29858c9fbc29Smrg# Please DO NOT delete this file! 29868c9fbc29Smrg# It is necessary for linking the library. 29878c9fbc29Smrg 29888c9fbc29Smrg# Name of the PIC object. 29894cd6a3aeSmrgpic_object=$write_lobj 29908c9fbc29Smrg 29914cd6a3aeSmrg# Name of the non-PIC object 29924cd6a3aeSmrgnon_pic_object=$write_oldobj 29938c9fbc29Smrg 29944cd6a3aeSmrgEOF 299554044362Smrg $MV "${write_libobj}T" "$write_libobj" 29964cd6a3aeSmrg } 29974cd6a3aeSmrg} 29988c9fbc29Smrg 29998c9fbc29Smrg 30004cd6a3aeSmrg################################################## 30014cd6a3aeSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 30024cd6a3aeSmrg################################################## 30038c9fbc29Smrg 30044cd6a3aeSmrg# func_convert_core_file_wine_to_w32 ARG 30054cd6a3aeSmrg# Helper function used by file name conversion functions when $build is *nix, 30064cd6a3aeSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 30074cd6a3aeSmrg# correctly configured wine environment available, with the winepath program 30084cd6a3aeSmrg# in $build's $PATH. 30094cd6a3aeSmrg# 30104cd6a3aeSmrg# ARG is the $build file name to be converted to w32 format. 30114cd6a3aeSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 30124cd6a3aeSmrg# be empty on error (or when ARG is empty) 30134cd6a3aeSmrgfunc_convert_core_file_wine_to_w32 () 30144cd6a3aeSmrg{ 301554044362Smrg $debug_cmd 301654044362Smrg 301754044362Smrg func_convert_core_file_wine_to_w32_result=$1 30184cd6a3aeSmrg if test -n "$1"; then 30194cd6a3aeSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 30204cd6a3aeSmrg # are forced to check the contents of stdout. On the other hand, if the 30214cd6a3aeSmrg # command is not found, the shell will set an exit code of 127 and print 30224cd6a3aeSmrg # *an error message* to stdout. So we must check for both error code of 30234cd6a3aeSmrg # zero AND non-empty stdout, which explains the odd construction: 30244cd6a3aeSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 302554044362Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 30264cd6a3aeSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 302754044362Smrg $SED -e "$sed_naive_backslashify"` 30284cd6a3aeSmrg else 30294cd6a3aeSmrg func_convert_core_file_wine_to_w32_result= 30304cd6a3aeSmrg fi 30314cd6a3aeSmrg fi 30324cd6a3aeSmrg} 30334cd6a3aeSmrg# end: func_convert_core_file_wine_to_w32 30348c9fbc29Smrg 30354cd6a3aeSmrg 30364cd6a3aeSmrg# func_convert_core_path_wine_to_w32 ARG 30374cd6a3aeSmrg# Helper function used by path conversion functions when $build is *nix, and 30384cd6a3aeSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 30394cd6a3aeSmrg# configured wine environment available, with the winepath program in $build's 30404cd6a3aeSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 30414cd6a3aeSmrg# 30424cd6a3aeSmrg# ARG is path to be converted from $build format to win32. 30434cd6a3aeSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 30444cd6a3aeSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 30454cd6a3aeSmrg# are convertible, then the result may be empty. 30464cd6a3aeSmrgfunc_convert_core_path_wine_to_w32 () 30474cd6a3aeSmrg{ 304854044362Smrg $debug_cmd 304954044362Smrg 30504cd6a3aeSmrg # unfortunately, winepath doesn't convert paths, only file names 305154044362Smrg func_convert_core_path_wine_to_w32_result= 30524cd6a3aeSmrg if test -n "$1"; then 30534cd6a3aeSmrg oldIFS=$IFS 30544cd6a3aeSmrg IFS=: 30554cd6a3aeSmrg for func_convert_core_path_wine_to_w32_f in $1; do 30564cd6a3aeSmrg IFS=$oldIFS 30574cd6a3aeSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 305854044362Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 30594cd6a3aeSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 306054044362Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 30614cd6a3aeSmrg else 30624cd6a3aeSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 30634cd6a3aeSmrg fi 30648c9fbc29Smrg fi 30654cd6a3aeSmrg done 30664cd6a3aeSmrg IFS=$oldIFS 30674cd6a3aeSmrg fi 30684cd6a3aeSmrg} 30694cd6a3aeSmrg# end: func_convert_core_path_wine_to_w32 30704cd6a3aeSmrg 30714cd6a3aeSmrg 30724cd6a3aeSmrg# func_cygpath ARGS... 30734cd6a3aeSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 30744cd6a3aeSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 30754cd6a3aeSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 30764cd6a3aeSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 30774cd6a3aeSmrg# file name or path is assumed to be in w32 format, as previously converted 30784cd6a3aeSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 30794cd6a3aeSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 30804cd6a3aeSmrg# Cygwin format). Returns an empty string on error. 30814cd6a3aeSmrg# 30824cd6a3aeSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 30834cd6a3aeSmrg# be converted. 30844cd6a3aeSmrg# 30854cd6a3aeSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 30864cd6a3aeSmrg# environment variable; do not put it in $PATH. 30874cd6a3aeSmrgfunc_cygpath () 30884cd6a3aeSmrg{ 308954044362Smrg $debug_cmd 309054044362Smrg 30914cd6a3aeSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 30924cd6a3aeSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 30934cd6a3aeSmrg if test "$?" -ne 0; then 30944cd6a3aeSmrg # on failure, ensure result is empty 30954cd6a3aeSmrg func_cygpath_result= 30964cd6a3aeSmrg fi 30974cd6a3aeSmrg else 30984cd6a3aeSmrg func_cygpath_result= 309954044362Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 31004cd6a3aeSmrg fi 31014cd6a3aeSmrg} 31024cd6a3aeSmrg#end: func_cygpath 31038c9fbc29Smrg 31048c9fbc29Smrg 31054cd6a3aeSmrg# func_convert_core_msys_to_w32 ARG 31064cd6a3aeSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 31074cd6a3aeSmrg# result in func_convert_core_msys_to_w32_result. 31084cd6a3aeSmrgfunc_convert_core_msys_to_w32 () 31094cd6a3aeSmrg{ 311054044362Smrg $debug_cmd 311154044362Smrg 31124cd6a3aeSmrg # awkward: cmd appends spaces to result 31134cd6a3aeSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 311454044362Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 31154cd6a3aeSmrg} 31164cd6a3aeSmrg#end: func_convert_core_msys_to_w32 31178c9fbc29Smrg 31188c9fbc29Smrg 31194cd6a3aeSmrg# func_convert_file_check ARG1 ARG2 31204cd6a3aeSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 31214cd6a3aeSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 31224cd6a3aeSmrg# func_to_host_file_result to ARG1). 31234cd6a3aeSmrgfunc_convert_file_check () 31244cd6a3aeSmrg{ 312554044362Smrg $debug_cmd 312654044362Smrg 312754044362Smrg if test -z "$2" && test -n "$1"; then 31284cd6a3aeSmrg func_error "Could not determine host file name corresponding to" 312954044362Smrg func_error " '$1'" 31304cd6a3aeSmrg func_error "Continuing, but uninstalled executables may not work." 31314cd6a3aeSmrg # Fallback: 313254044362Smrg func_to_host_file_result=$1 31334cd6a3aeSmrg fi 31344cd6a3aeSmrg} 31354cd6a3aeSmrg# end func_convert_file_check 31368c9fbc29Smrg 31378c9fbc29Smrg 31384cd6a3aeSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 31394cd6a3aeSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 31404cd6a3aeSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 31414cd6a3aeSmrg# func_to_host_file_result to a simplistic fallback value (see below). 31424cd6a3aeSmrgfunc_convert_path_check () 31434cd6a3aeSmrg{ 314454044362Smrg $debug_cmd 314554044362Smrg 31464cd6a3aeSmrg if test -z "$4" && test -n "$3"; then 31474cd6a3aeSmrg func_error "Could not determine the host path corresponding to" 314854044362Smrg func_error " '$3'" 31494cd6a3aeSmrg func_error "Continuing, but uninstalled executables may not work." 31504cd6a3aeSmrg # Fallback. This is a deliberately simplistic "conversion" and 31514cd6a3aeSmrg # should not be "improved". See libtool.info. 31524cd6a3aeSmrg if test "x$1" != "x$2"; then 31534cd6a3aeSmrg lt_replace_pathsep_chars="s|$1|$2|g" 31544cd6a3aeSmrg func_to_host_path_result=`echo "$3" | 31554cd6a3aeSmrg $SED -e "$lt_replace_pathsep_chars"` 31564cd6a3aeSmrg else 315754044362Smrg func_to_host_path_result=$3 31584cd6a3aeSmrg fi 31594cd6a3aeSmrg fi 31604cd6a3aeSmrg} 31614cd6a3aeSmrg# end func_convert_path_check 31628c9fbc29Smrg 31638c9fbc29Smrg 31644cd6a3aeSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 31654cd6a3aeSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 31664cd6a3aeSmrg# and appending REPL if ORIG matches BACKPAT. 31674cd6a3aeSmrgfunc_convert_path_front_back_pathsep () 31684cd6a3aeSmrg{ 316954044362Smrg $debug_cmd 317054044362Smrg 31714cd6a3aeSmrg case $4 in 317254044362Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 31734cd6a3aeSmrg ;; 31744cd6a3aeSmrg esac 31754cd6a3aeSmrg case $4 in 31764cd6a3aeSmrg $2 ) func_append func_to_host_path_result "$3" 31774cd6a3aeSmrg ;; 31784cd6a3aeSmrg esac 31794cd6a3aeSmrg} 31804cd6a3aeSmrg# end func_convert_path_front_back_pathsep 31818c9fbc29Smrg 31828c9fbc29Smrg 31834cd6a3aeSmrg################################################## 31844cd6a3aeSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 31854cd6a3aeSmrg################################################## 318654044362Smrg# invoked via '$to_host_file_cmd ARG' 31874cd6a3aeSmrg# 31884cd6a3aeSmrg# In each case, ARG is the path to be converted from $build to $host format. 31894cd6a3aeSmrg# Result will be available in $func_to_host_file_result. 31908c9fbc29Smrg 31918c9fbc29Smrg 31924cd6a3aeSmrg# func_to_host_file ARG 31934cd6a3aeSmrg# Converts the file name ARG from $build format to $host format. Return result 31944cd6a3aeSmrg# in func_to_host_file_result. 31954cd6a3aeSmrgfunc_to_host_file () 31964cd6a3aeSmrg{ 319754044362Smrg $debug_cmd 319854044362Smrg 31994cd6a3aeSmrg $to_host_file_cmd "$1" 32004cd6a3aeSmrg} 32014cd6a3aeSmrg# end func_to_host_file 32028c9fbc29Smrg 32038c9fbc29Smrg 32044cd6a3aeSmrg# func_to_tool_file ARG LAZY 32054cd6a3aeSmrg# converts the file name ARG from $build format to toolchain format. Return 32064cd6a3aeSmrg# result in func_to_tool_file_result. If the conversion in use is listed 32074cd6a3aeSmrg# in (the comma separated) LAZY, no conversion takes place. 32084cd6a3aeSmrgfunc_to_tool_file () 32094cd6a3aeSmrg{ 321054044362Smrg $debug_cmd 321154044362Smrg 32124cd6a3aeSmrg case ,$2, in 32134cd6a3aeSmrg *,"$to_tool_file_cmd",*) 32144cd6a3aeSmrg func_to_tool_file_result=$1 32154cd6a3aeSmrg ;; 32164cd6a3aeSmrg *) 32174cd6a3aeSmrg $to_tool_file_cmd "$1" 32184cd6a3aeSmrg func_to_tool_file_result=$func_to_host_file_result 32194cd6a3aeSmrg ;; 32204cd6a3aeSmrg esac 32214cd6a3aeSmrg} 32224cd6a3aeSmrg# end func_to_tool_file 32238c9fbc29Smrg 32248c9fbc29Smrg 32254cd6a3aeSmrg# func_convert_file_noop ARG 32264cd6a3aeSmrg# Copy ARG to func_to_host_file_result. 32274cd6a3aeSmrgfunc_convert_file_noop () 32284cd6a3aeSmrg{ 322954044362Smrg func_to_host_file_result=$1 32304cd6a3aeSmrg} 32314cd6a3aeSmrg# end func_convert_file_noop 32328c9fbc29Smrg 32338c9fbc29Smrg 32344cd6a3aeSmrg# func_convert_file_msys_to_w32 ARG 32354cd6a3aeSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 32364cd6a3aeSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 32374cd6a3aeSmrg# func_to_host_file_result. 32384cd6a3aeSmrgfunc_convert_file_msys_to_w32 () 32394cd6a3aeSmrg{ 324054044362Smrg $debug_cmd 324154044362Smrg 324254044362Smrg func_to_host_file_result=$1 32434cd6a3aeSmrg if test -n "$1"; then 32444cd6a3aeSmrg func_convert_core_msys_to_w32 "$1" 324554044362Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 32464cd6a3aeSmrg fi 32474cd6a3aeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32484cd6a3aeSmrg} 32494cd6a3aeSmrg# end func_convert_file_msys_to_w32 32508c9fbc29Smrg 32518c9fbc29Smrg 32524cd6a3aeSmrg# func_convert_file_cygwin_to_w32 ARG 32534cd6a3aeSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 32544cd6a3aeSmrg# func_to_host_file_result. 32554cd6a3aeSmrgfunc_convert_file_cygwin_to_w32 () 32564cd6a3aeSmrg{ 325754044362Smrg $debug_cmd 325854044362Smrg 325954044362Smrg func_to_host_file_result=$1 32604cd6a3aeSmrg if test -n "$1"; then 32614cd6a3aeSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 32624cd6a3aeSmrg # LT_CYGPATH in this case. 32634cd6a3aeSmrg func_to_host_file_result=`cygpath -m "$1"` 32644cd6a3aeSmrg fi 32654cd6a3aeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32664cd6a3aeSmrg} 32674cd6a3aeSmrg# end func_convert_file_cygwin_to_w32 32688c9fbc29Smrg 32698c9fbc29Smrg 32704cd6a3aeSmrg# func_convert_file_nix_to_w32 ARG 32714cd6a3aeSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 32724cd6a3aeSmrg# and a working winepath. Returns result in func_to_host_file_result. 32734cd6a3aeSmrgfunc_convert_file_nix_to_w32 () 32744cd6a3aeSmrg{ 327554044362Smrg $debug_cmd 327654044362Smrg 327754044362Smrg func_to_host_file_result=$1 32784cd6a3aeSmrg if test -n "$1"; then 32794cd6a3aeSmrg func_convert_core_file_wine_to_w32 "$1" 328054044362Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 32814cd6a3aeSmrg fi 32824cd6a3aeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32834cd6a3aeSmrg} 32844cd6a3aeSmrg# end func_convert_file_nix_to_w32 32858c9fbc29Smrg 32868c9fbc29Smrg 32874cd6a3aeSmrg# func_convert_file_msys_to_cygwin ARG 32884cd6a3aeSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32894cd6a3aeSmrg# Returns result in func_to_host_file_result. 32904cd6a3aeSmrgfunc_convert_file_msys_to_cygwin () 32914cd6a3aeSmrg{ 329254044362Smrg $debug_cmd 329354044362Smrg 329454044362Smrg func_to_host_file_result=$1 32954cd6a3aeSmrg if test -n "$1"; then 32964cd6a3aeSmrg func_convert_core_msys_to_w32 "$1" 32974cd6a3aeSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 329854044362Smrg func_to_host_file_result=$func_cygpath_result 32994cd6a3aeSmrg fi 33004cd6a3aeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33014cd6a3aeSmrg} 33024cd6a3aeSmrg# end func_convert_file_msys_to_cygwin 33038c9fbc29Smrg 33048c9fbc29Smrg 33054cd6a3aeSmrg# func_convert_file_nix_to_cygwin ARG 33064cd6a3aeSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 33074cd6a3aeSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 33084cd6a3aeSmrg# in func_to_host_file_result. 33094cd6a3aeSmrgfunc_convert_file_nix_to_cygwin () 33104cd6a3aeSmrg{ 331154044362Smrg $debug_cmd 331254044362Smrg 331354044362Smrg func_to_host_file_result=$1 33144cd6a3aeSmrg if test -n "$1"; then 33154cd6a3aeSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 33164cd6a3aeSmrg func_convert_core_file_wine_to_w32 "$1" 33174cd6a3aeSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 331854044362Smrg func_to_host_file_result=$func_cygpath_result 33194cd6a3aeSmrg fi 33204cd6a3aeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33214cd6a3aeSmrg} 33224cd6a3aeSmrg# end func_convert_file_nix_to_cygwin 33238c9fbc29Smrg 33248c9fbc29Smrg 33254cd6a3aeSmrg############################################# 33264cd6a3aeSmrg# $build to $host PATH CONVERSION FUNCTIONS # 33274cd6a3aeSmrg############################################# 332854044362Smrg# invoked via '$to_host_path_cmd ARG' 33294cd6a3aeSmrg# 33304cd6a3aeSmrg# In each case, ARG is the path to be converted from $build to $host format. 33314cd6a3aeSmrg# The result will be available in $func_to_host_path_result. 33324cd6a3aeSmrg# 33334cd6a3aeSmrg# Path separators are also converted from $build format to $host format. If 33344cd6a3aeSmrg# ARG begins or ends with a path separator character, it is preserved (but 33354cd6a3aeSmrg# converted to $host format) on output. 33364cd6a3aeSmrg# 33374cd6a3aeSmrg# All path conversion functions are named using the following convention: 33384cd6a3aeSmrg# file name conversion function : func_convert_file_X_to_Y () 33394cd6a3aeSmrg# path conversion function : func_convert_path_X_to_Y () 33404cd6a3aeSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 33414cd6a3aeSmrg# same. If conversion functions are added for new $build/$host combinations, 33424cd6a3aeSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 33434cd6a3aeSmrg# will break. 33444cd6a3aeSmrg 33454cd6a3aeSmrg 33464cd6a3aeSmrg# func_init_to_host_path_cmd 33474cd6a3aeSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 33484cd6a3aeSmrg# appropriate value, based on the value of $to_host_file_cmd. 33494cd6a3aeSmrgto_host_path_cmd= 33504cd6a3aeSmrgfunc_init_to_host_path_cmd () 33514cd6a3aeSmrg{ 335254044362Smrg $debug_cmd 335354044362Smrg 33544cd6a3aeSmrg if test -z "$to_host_path_cmd"; then 33554cd6a3aeSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 335654044362Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 33574cd6a3aeSmrg fi 33584cd6a3aeSmrg} 33598c9fbc29Smrg 33608c9fbc29Smrg 33614cd6a3aeSmrg# func_to_host_path ARG 33624cd6a3aeSmrg# Converts the path ARG from $build format to $host format. Return result 33634cd6a3aeSmrg# in func_to_host_path_result. 33644cd6a3aeSmrgfunc_to_host_path () 33654cd6a3aeSmrg{ 336654044362Smrg $debug_cmd 336754044362Smrg 33684cd6a3aeSmrg func_init_to_host_path_cmd 33694cd6a3aeSmrg $to_host_path_cmd "$1" 33704cd6a3aeSmrg} 33714cd6a3aeSmrg# end func_to_host_path 33728c9fbc29Smrg 33738c9fbc29Smrg 33744cd6a3aeSmrg# func_convert_path_noop ARG 33754cd6a3aeSmrg# Copy ARG to func_to_host_path_result. 33764cd6a3aeSmrgfunc_convert_path_noop () 33774cd6a3aeSmrg{ 337854044362Smrg func_to_host_path_result=$1 33794cd6a3aeSmrg} 33804cd6a3aeSmrg# end func_convert_path_noop 33818c9fbc29Smrg 33828c9fbc29Smrg 33834cd6a3aeSmrg# func_convert_path_msys_to_w32 ARG 33844cd6a3aeSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 33854cd6a3aeSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 33864cd6a3aeSmrg# func_to_host_path_result. 33874cd6a3aeSmrgfunc_convert_path_msys_to_w32 () 33884cd6a3aeSmrg{ 338954044362Smrg $debug_cmd 339054044362Smrg 339154044362Smrg func_to_host_path_result=$1 33924cd6a3aeSmrg if test -n "$1"; then 33934cd6a3aeSmrg # Remove leading and trailing path separator characters from ARG. MSYS 33944cd6a3aeSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 33954cd6a3aeSmrg # and winepath ignores them completely. 33964cd6a3aeSmrg func_stripname : : "$1" 33974cd6a3aeSmrg func_to_host_path_tmp1=$func_stripname_result 33984cd6a3aeSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 339954044362Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 34004cd6a3aeSmrg func_convert_path_check : ";" \ 34014cd6a3aeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34024cd6a3aeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34034cd6a3aeSmrg fi 34044cd6a3aeSmrg} 34054cd6a3aeSmrg# end func_convert_path_msys_to_w32 34068c9fbc29Smrg 34078c9fbc29Smrg 34084cd6a3aeSmrg# func_convert_path_cygwin_to_w32 ARG 34094cd6a3aeSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 34104cd6a3aeSmrg# func_to_host_file_result. 34114cd6a3aeSmrgfunc_convert_path_cygwin_to_w32 () 34124cd6a3aeSmrg{ 341354044362Smrg $debug_cmd 341454044362Smrg 341554044362Smrg func_to_host_path_result=$1 34164cd6a3aeSmrg if test -n "$1"; then 34174cd6a3aeSmrg # See func_convert_path_msys_to_w32: 34184cd6a3aeSmrg func_stripname : : "$1" 34194cd6a3aeSmrg func_to_host_path_tmp1=$func_stripname_result 34204cd6a3aeSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 34214cd6a3aeSmrg func_convert_path_check : ";" \ 34224cd6a3aeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34234cd6a3aeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34244cd6a3aeSmrg fi 34254cd6a3aeSmrg} 34264cd6a3aeSmrg# end func_convert_path_cygwin_to_w32 34278c9fbc29Smrg 34288c9fbc29Smrg 34294cd6a3aeSmrg# func_convert_path_nix_to_w32 ARG 34304cd6a3aeSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 34314cd6a3aeSmrg# a working winepath. Returns result in func_to_host_file_result. 34324cd6a3aeSmrgfunc_convert_path_nix_to_w32 () 34334cd6a3aeSmrg{ 343454044362Smrg $debug_cmd 343554044362Smrg 343654044362Smrg func_to_host_path_result=$1 34374cd6a3aeSmrg if test -n "$1"; then 34384cd6a3aeSmrg # See func_convert_path_msys_to_w32: 34394cd6a3aeSmrg func_stripname : : "$1" 34404cd6a3aeSmrg func_to_host_path_tmp1=$func_stripname_result 34414cd6a3aeSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 344254044362Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 34434cd6a3aeSmrg func_convert_path_check : ";" \ 34444cd6a3aeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34454cd6a3aeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34464cd6a3aeSmrg fi 34474cd6a3aeSmrg} 34484cd6a3aeSmrg# end func_convert_path_nix_to_w32 34498c9fbc29Smrg 34508c9fbc29Smrg 34514cd6a3aeSmrg# func_convert_path_msys_to_cygwin ARG 34524cd6a3aeSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 34534cd6a3aeSmrg# Returns result in func_to_host_file_result. 34544cd6a3aeSmrgfunc_convert_path_msys_to_cygwin () 34554cd6a3aeSmrg{ 345654044362Smrg $debug_cmd 345754044362Smrg 345854044362Smrg func_to_host_path_result=$1 34594cd6a3aeSmrg if test -n "$1"; then 34604cd6a3aeSmrg # See func_convert_path_msys_to_w32: 34614cd6a3aeSmrg func_stripname : : "$1" 34624cd6a3aeSmrg func_to_host_path_tmp1=$func_stripname_result 34634cd6a3aeSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 34644cd6a3aeSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 346554044362Smrg func_to_host_path_result=$func_cygpath_result 34664cd6a3aeSmrg func_convert_path_check : : \ 34674cd6a3aeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34684cd6a3aeSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34694cd6a3aeSmrg fi 34704cd6a3aeSmrg} 34714cd6a3aeSmrg# end func_convert_path_msys_to_cygwin 34728c9fbc29Smrg 34738c9fbc29Smrg 34744cd6a3aeSmrg# func_convert_path_nix_to_cygwin ARG 34754cd6a3aeSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 34764cd6a3aeSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 34774cd6a3aeSmrg# func_to_host_file_result. 34784cd6a3aeSmrgfunc_convert_path_nix_to_cygwin () 34794cd6a3aeSmrg{ 348054044362Smrg $debug_cmd 348154044362Smrg 348254044362Smrg func_to_host_path_result=$1 34834cd6a3aeSmrg if test -n "$1"; then 34844cd6a3aeSmrg # Remove leading and trailing path separator characters from 34854cd6a3aeSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 34864cd6a3aeSmrg # into '.;' and ';.', and winepath ignores them completely. 34874cd6a3aeSmrg func_stripname : : "$1" 34884cd6a3aeSmrg func_to_host_path_tmp1=$func_stripname_result 34894cd6a3aeSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34904cd6a3aeSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 349154044362Smrg func_to_host_path_result=$func_cygpath_result 34924cd6a3aeSmrg func_convert_path_check : : \ 34934cd6a3aeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34944cd6a3aeSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34954cd6a3aeSmrg fi 34964cd6a3aeSmrg} 34974cd6a3aeSmrg# end func_convert_path_nix_to_cygwin 34988c9fbc29Smrg 34998c9fbc29Smrg 350054044362Smrg# func_dll_def_p FILE 350154044362Smrg# True iff FILE is a Windows DLL '.def' file. 350254044362Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 350354044362Smrgfunc_dll_def_p () 350454044362Smrg{ 350554044362Smrg $debug_cmd 350654044362Smrg 350754044362Smrg func_dll_def_p_tmp=`$SED -n \ 350854044362Smrg -e 's/^[ ]*//' \ 350954044362Smrg -e '/^\(;.*\)*$/d' \ 351054044362Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 351154044362Smrg -e q \ 351254044362Smrg "$1"` 351354044362Smrg test DEF = "$func_dll_def_p_tmp" 351454044362Smrg} 351554044362Smrg 351654044362Smrg 35174cd6a3aeSmrg# func_mode_compile arg... 35184cd6a3aeSmrgfunc_mode_compile () 35194cd6a3aeSmrg{ 352054044362Smrg $debug_cmd 352154044362Smrg 35224cd6a3aeSmrg # Get the compilation command and the source file. 35234cd6a3aeSmrg base_compile= 352454044362Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 35254cd6a3aeSmrg suppress_opt=yes 35264cd6a3aeSmrg suppress_output= 35274cd6a3aeSmrg arg_mode=normal 35284cd6a3aeSmrg libobj= 35294cd6a3aeSmrg later= 35304cd6a3aeSmrg pie_flag= 35314cd6a3aeSmrg 35324cd6a3aeSmrg for arg 35334cd6a3aeSmrg do 35344cd6a3aeSmrg case $arg_mode in 35354cd6a3aeSmrg arg ) 35364cd6a3aeSmrg # do not "continue". Instead, add this to base_compile 353754044362Smrg lastarg=$arg 35384cd6a3aeSmrg arg_mode=normal 35394cd6a3aeSmrg ;; 35404cd6a3aeSmrg 35414cd6a3aeSmrg target ) 354254044362Smrg libobj=$arg 35434cd6a3aeSmrg arg_mode=normal 35444cd6a3aeSmrg continue 35454cd6a3aeSmrg ;; 35464cd6a3aeSmrg 35474cd6a3aeSmrg normal ) 35484cd6a3aeSmrg # Accept any command-line options. 35494cd6a3aeSmrg case $arg in 35504cd6a3aeSmrg -o) 35514cd6a3aeSmrg test -n "$libobj" && \ 355254044362Smrg func_fatal_error "you cannot specify '-o' more than once" 35534cd6a3aeSmrg arg_mode=target 35548c9fbc29Smrg continue 35558c9fbc29Smrg ;; 35564cd6a3aeSmrg 35574cd6a3aeSmrg -pie | -fpie | -fPIE) 35584cd6a3aeSmrg func_append pie_flag " $arg" 35598c9fbc29Smrg continue 35608c9fbc29Smrg ;; 35614cd6a3aeSmrg 35624cd6a3aeSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 35634cd6a3aeSmrg func_append later " $arg" 35648c9fbc29Smrg continue 35658c9fbc29Smrg ;; 35664cd6a3aeSmrg 35674cd6a3aeSmrg -no-suppress) 35684cd6a3aeSmrg suppress_opt=no 35698c9fbc29Smrg continue 35708c9fbc29Smrg ;; 35718c9fbc29Smrg 35724cd6a3aeSmrg -Xcompiler) 35734cd6a3aeSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 35744cd6a3aeSmrg continue # The current "srcfile" will either be retained or 35754cd6a3aeSmrg ;; # replaced later. I would guess that would be a bug. 35768c9fbc29Smrg 35774cd6a3aeSmrg -Wc,*) 35784cd6a3aeSmrg func_stripname '-Wc,' '' "$arg" 35794cd6a3aeSmrg args=$func_stripname_result 35804cd6a3aeSmrg lastarg= 358154044362Smrg save_ifs=$IFS; IFS=, 35824cd6a3aeSmrg for arg in $args; do 358354044362Smrg IFS=$save_ifs 35844cd6a3aeSmrg func_append_quoted lastarg "$arg" 35854cd6a3aeSmrg done 358654044362Smrg IFS=$save_ifs 35874cd6a3aeSmrg func_stripname ' ' '' "$lastarg" 35884cd6a3aeSmrg lastarg=$func_stripname_result 35898c9fbc29Smrg 35904cd6a3aeSmrg # Add the arguments to base_compile. 35914cd6a3aeSmrg func_append base_compile " $lastarg" 35924cd6a3aeSmrg continue 35934cd6a3aeSmrg ;; 35948c9fbc29Smrg 35954cd6a3aeSmrg *) 35964cd6a3aeSmrg # Accept the current argument as the source file. 35974cd6a3aeSmrg # The previous "srcfile" becomes the current argument. 35984cd6a3aeSmrg # 359954044362Smrg lastarg=$srcfile 360054044362Smrg srcfile=$arg 36014cd6a3aeSmrg ;; 36024cd6a3aeSmrg esac # case $arg 36038c9fbc29Smrg ;; 36044cd6a3aeSmrg esac # case $arg_mode 36058c9fbc29Smrg 36064cd6a3aeSmrg # Aesthetically quote the previous argument. 36074cd6a3aeSmrg func_append_quoted base_compile "$lastarg" 36084cd6a3aeSmrg done # for arg 36098c9fbc29Smrg 36104cd6a3aeSmrg case $arg_mode in 36114cd6a3aeSmrg arg) 36124cd6a3aeSmrg func_fatal_error "you must specify an argument for -Xcompile" 36134cd6a3aeSmrg ;; 36144cd6a3aeSmrg target) 361554044362Smrg func_fatal_error "you must specify a target with '-o'" 36164cd6a3aeSmrg ;; 36174cd6a3aeSmrg *) 36184cd6a3aeSmrg # Get the name of the library object. 36194cd6a3aeSmrg test -z "$libobj" && { 36204cd6a3aeSmrg func_basename "$srcfile" 362154044362Smrg libobj=$func_basename_result 36224cd6a3aeSmrg } 36234cd6a3aeSmrg ;; 36244cd6a3aeSmrg esac 36258c9fbc29Smrg 36264cd6a3aeSmrg # Recognize several different file suffixes. 36274cd6a3aeSmrg # If the user specifies -o file.o, it is replaced with file.lo 36284cd6a3aeSmrg case $libobj in 36294cd6a3aeSmrg *.[cCFSifmso] | \ 36304cd6a3aeSmrg *.ada | *.adb | *.ads | *.asm | \ 36314cd6a3aeSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 363270728a38Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 36334cd6a3aeSmrg func_xform "$libobj" 36344cd6a3aeSmrg libobj=$func_xform_result 36354cd6a3aeSmrg ;; 36364cd6a3aeSmrg esac 36378c9fbc29Smrg 36384cd6a3aeSmrg case $libobj in 36394cd6a3aeSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36404cd6a3aeSmrg *) 364154044362Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 36424cd6a3aeSmrg ;; 36434cd6a3aeSmrg esac 36448c9fbc29Smrg 36454cd6a3aeSmrg func_infer_tag $base_compile 36468c9fbc29Smrg 36474cd6a3aeSmrg for arg in $later; do 36484cd6a3aeSmrg case $arg in 36494cd6a3aeSmrg -shared) 365054044362Smrg test yes = "$build_libtool_libs" \ 365154044362Smrg || func_fatal_configuration "cannot build a shared library" 36524cd6a3aeSmrg build_old_libs=no 36538c9fbc29Smrg continue 36548c9fbc29Smrg ;; 36558c9fbc29Smrg 36564cd6a3aeSmrg -static) 36574cd6a3aeSmrg build_libtool_libs=no 36584cd6a3aeSmrg build_old_libs=yes 36598c9fbc29Smrg continue 36608c9fbc29Smrg ;; 36618c9fbc29Smrg 36624cd6a3aeSmrg -prefer-pic) 36634cd6a3aeSmrg pic_mode=yes 36648c9fbc29Smrg continue 36658c9fbc29Smrg ;; 36668c9fbc29Smrg 36674cd6a3aeSmrg -prefer-non-pic) 36684cd6a3aeSmrg pic_mode=no 36698c9fbc29Smrg continue 36708c9fbc29Smrg ;; 36714cd6a3aeSmrg esac 36724cd6a3aeSmrg done 36738c9fbc29Smrg 367454cef2ddSmrg func_quote_arg pretty "$libobj" 367554cef2ddSmrg test "X$libobj" != "X$func_quote_arg_result" \ 36764cd6a3aeSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 367754044362Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 36784cd6a3aeSmrg func_dirname_and_basename "$obj" "/" "" 367954044362Smrg objname=$func_basename_result 368054044362Smrg xdir=$func_dirname_result 368154044362Smrg lobj=$xdir$objdir/$objname 36828c9fbc29Smrg 36834cd6a3aeSmrg test -z "$base_compile" && \ 36844cd6a3aeSmrg func_fatal_help "you must specify a compilation command" 36858c9fbc29Smrg 36864cd6a3aeSmrg # Delete any leftover library objects. 368754044362Smrg if test yes = "$build_old_libs"; then 36884cd6a3aeSmrg removelist="$obj $lobj $libobj ${libobj}T" 36894cd6a3aeSmrg else 36904cd6a3aeSmrg removelist="$lobj $libobj ${libobj}T" 36914cd6a3aeSmrg fi 36924e411241Smrg 36934cd6a3aeSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 36944cd6a3aeSmrg case $host_os in 36954cd6a3aeSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36964cd6a3aeSmrg pic_mode=default 36974cd6a3aeSmrg ;; 36984cd6a3aeSmrg esac 369954044362Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 37004cd6a3aeSmrg # non-PIC code in shared libraries is not supported 37014cd6a3aeSmrg pic_mode=default 37024cd6a3aeSmrg fi 37038c9fbc29Smrg 37044cd6a3aeSmrg # Calculate the filename of the output object if compiler does 37054cd6a3aeSmrg # not support -o with -c 370654044362Smrg if test no = "$compiler_c_o"; then 370754044362Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 370854044362Smrg lockfile=$output_obj.lock 37094cd6a3aeSmrg else 37104cd6a3aeSmrg output_obj= 37114cd6a3aeSmrg need_locks=no 37124cd6a3aeSmrg lockfile= 37134cd6a3aeSmrg fi 37148c9fbc29Smrg 37154cd6a3aeSmrg # Lock this critical section if it is needed 37164cd6a3aeSmrg # We use this script file to make the link, it avoids creating a new file 371754044362Smrg if test yes = "$need_locks"; then 37184cd6a3aeSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37194cd6a3aeSmrg func_echo "Waiting for $lockfile to be removed" 37204cd6a3aeSmrg sleep 2 37214cd6a3aeSmrg done 372254044362Smrg elif test warn = "$need_locks"; then 37234cd6a3aeSmrg if test -f "$lockfile"; then 37244cd6a3aeSmrg $ECHO "\ 37254cd6a3aeSmrg*** ERROR, $lockfile exists and contains: 37264cd6a3aeSmrg`cat $lockfile 2>/dev/null` 37278c9fbc29Smrg 37284cd6a3aeSmrgThis indicates that another process is trying to use the same 37294cd6a3aeSmrgtemporary object file, and libtool could not work around it because 373054044362Smrgyour compiler does not support '-c' and '-o' together. If you 37314cd6a3aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 37324cd6a3aeSmrgavoid parallel builds (make -j) in this platform, or get a better 37334cd6a3aeSmrgcompiler." 37348c9fbc29Smrg 37354cd6a3aeSmrg $opt_dry_run || $RM $removelist 37364cd6a3aeSmrg exit $EXIT_FAILURE 37374cd6a3aeSmrg fi 37384cd6a3aeSmrg func_append removelist " $output_obj" 37394cd6a3aeSmrg $ECHO "$srcfile" > "$lockfile" 37404cd6a3aeSmrg fi 37418c9fbc29Smrg 37424cd6a3aeSmrg $opt_dry_run || $RM $removelist 37434cd6a3aeSmrg func_append removelist " $lockfile" 37444cd6a3aeSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37458c9fbc29Smrg 37464cd6a3aeSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 37474cd6a3aeSmrg srcfile=$func_to_tool_file_result 374854cef2ddSmrg func_quote_arg pretty "$srcfile" 374954cef2ddSmrg qsrcfile=$func_quote_arg_result 37508c9fbc29Smrg 37514cd6a3aeSmrg # Only build a PIC object if we are building libtool libraries. 375254044362Smrg if test yes = "$build_libtool_libs"; then 37534cd6a3aeSmrg # Without this assignment, base_compile gets emptied. 37544cd6a3aeSmrg fbsd_hideous_sh_bug=$base_compile 37558c9fbc29Smrg 375654044362Smrg if test no != "$pic_mode"; then 37574cd6a3aeSmrg command="$base_compile $qsrcfile $pic_flag" 37584cd6a3aeSmrg else 37594cd6a3aeSmrg # Don't build PIC code 37604cd6a3aeSmrg command="$base_compile $qsrcfile" 37614cd6a3aeSmrg fi 37628c9fbc29Smrg 37634cd6a3aeSmrg func_mkdir_p "$xdir$objdir" 37648c9fbc29Smrg 37654cd6a3aeSmrg if test -z "$output_obj"; then 37664cd6a3aeSmrg # Place PIC objects in $objdir 37674cd6a3aeSmrg func_append command " -o $lobj" 37684cd6a3aeSmrg fi 37698c9fbc29Smrg 37704cd6a3aeSmrg func_show_eval_locale "$command" \ 37714cd6a3aeSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37728c9fbc29Smrg 377354044362Smrg if test warn = "$need_locks" && 37744cd6a3aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 37754cd6a3aeSmrg $ECHO "\ 37764cd6a3aeSmrg*** ERROR, $lockfile contains: 37774cd6a3aeSmrg`cat $lockfile 2>/dev/null` 37788c9fbc29Smrg 37794cd6a3aeSmrgbut it should contain: 37804cd6a3aeSmrg$srcfile 37818c9fbc29Smrg 37824cd6a3aeSmrgThis indicates that another process is trying to use the same 37834cd6a3aeSmrgtemporary object file, and libtool could not work around it because 378454044362Smrgyour compiler does not support '-c' and '-o' together. If you 37854cd6a3aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 37864cd6a3aeSmrgavoid parallel builds (make -j) in this platform, or get a better 37874cd6a3aeSmrgcompiler." 37888c9fbc29Smrg 37894cd6a3aeSmrg $opt_dry_run || $RM $removelist 37904cd6a3aeSmrg exit $EXIT_FAILURE 37914cd6a3aeSmrg fi 37928c9fbc29Smrg 37934cd6a3aeSmrg # Just move the object if needed, then go on to compile the next one 37944cd6a3aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 37954cd6a3aeSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 37964cd6a3aeSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37974cd6a3aeSmrg fi 37988c9fbc29Smrg 37994cd6a3aeSmrg # Allow error messages only from the first compilation. 380054044362Smrg if test yes = "$suppress_opt"; then 38014cd6a3aeSmrg suppress_output=' >/dev/null 2>&1' 38024cd6a3aeSmrg fi 38034cd6a3aeSmrg fi 38048c9fbc29Smrg 38054cd6a3aeSmrg # Only build a position-dependent object if we build old libraries. 380654044362Smrg if test yes = "$build_old_libs"; then 380754044362Smrg if test yes != "$pic_mode"; then 38084cd6a3aeSmrg # Don't build PIC code 38094cd6a3aeSmrg command="$base_compile $qsrcfile$pie_flag" 38104cd6a3aeSmrg else 38114cd6a3aeSmrg command="$base_compile $qsrcfile $pic_flag" 38124cd6a3aeSmrg fi 381354044362Smrg if test yes = "$compiler_c_o"; then 38144cd6a3aeSmrg func_append command " -o $obj" 38154cd6a3aeSmrg fi 38168c9fbc29Smrg 38174cd6a3aeSmrg # Suppress compiler output if we already did a PIC compilation. 38184cd6a3aeSmrg func_append command "$suppress_output" 38194cd6a3aeSmrg func_show_eval_locale "$command" \ 38204cd6a3aeSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38218c9fbc29Smrg 382254044362Smrg if test warn = "$need_locks" && 38234cd6a3aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 38244cd6a3aeSmrg $ECHO "\ 38254cd6a3aeSmrg*** ERROR, $lockfile contains: 38264cd6a3aeSmrg`cat $lockfile 2>/dev/null` 38278c9fbc29Smrg 38284cd6a3aeSmrgbut it should contain: 38294cd6a3aeSmrg$srcfile 38308c9fbc29Smrg 38314cd6a3aeSmrgThis indicates that another process is trying to use the same 38324cd6a3aeSmrgtemporary object file, and libtool could not work around it because 383354044362Smrgyour compiler does not support '-c' and '-o' together. If you 38344cd6a3aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 38354cd6a3aeSmrgavoid parallel builds (make -j) in this platform, or get a better 38364cd6a3aeSmrgcompiler." 38378c9fbc29Smrg 38384cd6a3aeSmrg $opt_dry_run || $RM $removelist 38394cd6a3aeSmrg exit $EXIT_FAILURE 38404cd6a3aeSmrg fi 38418c9fbc29Smrg 38424cd6a3aeSmrg # Just move the object if needed 38434cd6a3aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 38444cd6a3aeSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 38454cd6a3aeSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38464cd6a3aeSmrg fi 38474cd6a3aeSmrg fi 38488c9fbc29Smrg 38494cd6a3aeSmrg $opt_dry_run || { 38504cd6a3aeSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38518c9fbc29Smrg 38524cd6a3aeSmrg # Unlock the critical section if it was locked 385354044362Smrg if test no != "$need_locks"; then 38544cd6a3aeSmrg removelist=$lockfile 38554cd6a3aeSmrg $RM "$lockfile" 38564cd6a3aeSmrg fi 38574cd6a3aeSmrg } 38588c9fbc29Smrg 38594cd6a3aeSmrg exit $EXIT_SUCCESS 38604cd6a3aeSmrg} 38618c9fbc29Smrg 38624cd6a3aeSmrg$opt_help || { 386354044362Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 38644cd6a3aeSmrg} 38658c9fbc29Smrg 38664cd6a3aeSmrgfunc_mode_help () 38674cd6a3aeSmrg{ 38684cd6a3aeSmrg # We need to display help for each of the modes. 38694cd6a3aeSmrg case $opt_mode in 38704cd6a3aeSmrg "") 38714cd6a3aeSmrg # Generic help is extracted from the usage comments 38724cd6a3aeSmrg # at the start of this file. 38734cd6a3aeSmrg func_help 38744cd6a3aeSmrg ;; 38758c9fbc29Smrg 38764cd6a3aeSmrg clean) 38774cd6a3aeSmrg $ECHO \ 38784cd6a3aeSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38798c9fbc29Smrg 38804cd6a3aeSmrgRemove files from the build directory. 38818c9fbc29Smrg 38824cd6a3aeSmrgRM is the name of the program to use to delete files associated with each FILE 388354044362Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 38844cd6a3aeSmrgto RM. 38858c9fbc29Smrg 38864cd6a3aeSmrgIf FILE is a libtool library, object or program, all the files associated 38874cd6a3aeSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 38884cd6a3aeSmrg ;; 38898c9fbc29Smrg 38904cd6a3aeSmrg compile) 38914cd6a3aeSmrg $ECHO \ 38924cd6a3aeSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38938c9fbc29Smrg 38944cd6a3aeSmrgCompile a source file into a libtool library object. 38958c9fbc29Smrg 38964cd6a3aeSmrgThis mode accepts the following additional options: 38978c9fbc29Smrg 38984cd6a3aeSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 38994cd6a3aeSmrg -no-suppress do not suppress compiler output for multiple passes 39004cd6a3aeSmrg -prefer-pic try to build PIC objects only 39014cd6a3aeSmrg -prefer-non-pic try to build non-PIC objects only 390254044362Smrg -shared do not build a '.o' file suitable for static linking 390354044362Smrg -static only build a '.o' file suitable for static linking 390454cef2ddSmrg -Wc,FLAG 390554cef2ddSmrg -Xcompiler FLAG pass FLAG directly to the compiler 39068c9fbc29Smrg 390754044362SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 39084cd6a3aeSmrgfrom the given SOURCEFILE. 39098c9fbc29Smrg 39104cd6a3aeSmrgThe output file name is determined by removing the directory component from 391154044362SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 391254044362Smrglibrary object suffix, '.lo'." 39134cd6a3aeSmrg ;; 39148c9fbc29Smrg 39154cd6a3aeSmrg execute) 39164cd6a3aeSmrg $ECHO \ 39174cd6a3aeSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39188c9fbc29Smrg 39194cd6a3aeSmrgAutomatically set library path, then run a program. 39208c9fbc29Smrg 39214cd6a3aeSmrgThis mode accepts the following additional options: 39228c9fbc29Smrg 39234cd6a3aeSmrg -dlopen FILE add the directory containing FILE to the library path 39248c9fbc29Smrg 392554044362SmrgThis mode sets the library path environment variable according to '-dlopen' 39264cd6a3aeSmrgflags. 39278c9fbc29Smrg 39284cd6a3aeSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 39294cd6a3aeSmrginto their corresponding uninstalled binary, and any of their required library 39304cd6a3aeSmrgdirectories are added to the library path. 39318c9fbc29Smrg 39324cd6a3aeSmrgThen, COMMAND is executed, with ARGS as arguments." 39334cd6a3aeSmrg ;; 39348c9fbc29Smrg 39354cd6a3aeSmrg finish) 39364cd6a3aeSmrg $ECHO \ 39374cd6a3aeSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39388c9fbc29Smrg 39394cd6a3aeSmrgComplete the installation of libtool libraries. 39404cd6a3aeSmrg 39414cd6a3aeSmrgEach LIBDIR is a directory that contains libtool libraries. 39424cd6a3aeSmrg 39434cd6a3aeSmrgThe commands that this mode executes may require superuser privileges. Use 394454044362Smrgthe '--dry-run' option if you just want to see what would be executed." 39454cd6a3aeSmrg ;; 39464cd6a3aeSmrg 39474cd6a3aeSmrg install) 39484cd6a3aeSmrg $ECHO \ 39494cd6a3aeSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39504cd6a3aeSmrg 39514cd6a3aeSmrgInstall executables or libraries. 39524cd6a3aeSmrg 39534cd6a3aeSmrgINSTALL-COMMAND is the installation command. The first component should be 395454044362Smrgeither the 'install' or 'cp' program. 39554cd6a3aeSmrg 39564cd6a3aeSmrgThe following components of INSTALL-COMMAND are treated specially: 39574cd6a3aeSmrg 39584cd6a3aeSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39594cd6a3aeSmrg 39604cd6a3aeSmrgThe rest of the components are interpreted as arguments to that command (only 39614cd6a3aeSmrgBSD-compatible install options are recognized)." 39624cd6a3aeSmrg ;; 39634cd6a3aeSmrg 39644cd6a3aeSmrg link) 39654cd6a3aeSmrg $ECHO \ 39664cd6a3aeSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39674cd6a3aeSmrg 39684cd6a3aeSmrgLink object files or libraries together to form another library, or to 39694cd6a3aeSmrgcreate an executable program. 39704cd6a3aeSmrg 39714cd6a3aeSmrgLINK-COMMAND is a command using the C compiler that you would use to create 39724cd6a3aeSmrga program from several object files. 39734cd6a3aeSmrg 39744cd6a3aeSmrgThe following components of LINK-COMMAND are treated specially: 39754cd6a3aeSmrg 39764cd6a3aeSmrg -all-static do not do any dynamic linking at all 39774cd6a3aeSmrg -avoid-version do not add a version suffix if possible 39784cd6a3aeSmrg -bindir BINDIR specify path to binaries directory (for systems where 39794cd6a3aeSmrg libraries must be found in the PATH setting at runtime) 398054044362Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 39814cd6a3aeSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 39824cd6a3aeSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 39834cd6a3aeSmrg -export-symbols SYMFILE 39844cd6a3aeSmrg try to export only the symbols listed in SYMFILE 39854cd6a3aeSmrg -export-symbols-regex REGEX 39864cd6a3aeSmrg try to export only the symbols matching REGEX 39874cd6a3aeSmrg -LLIBDIR search LIBDIR for required installed libraries 39884cd6a3aeSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 39894cd6a3aeSmrg -module build a library that can dlopened 39904cd6a3aeSmrg -no-fast-install disable the fast-install mode 39914cd6a3aeSmrg -no-install link a not-installable executable 39924cd6a3aeSmrg -no-undefined declare that a library does not refer to external symbols 39934cd6a3aeSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 399454044362Smrg -objectlist FILE use a list of object files found in FILE to specify objects 399554044362Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 39964cd6a3aeSmrg -precious-files-regex REGEX 39974cd6a3aeSmrg don't remove output files matching REGEX 39984cd6a3aeSmrg -release RELEASE specify package release information 39994cd6a3aeSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 40004cd6a3aeSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 40014cd6a3aeSmrg -shared only do dynamic linking of libtool libraries 40024cd6a3aeSmrg -shrext SUFFIX override the standard shared library file extension 40034cd6a3aeSmrg -static do not do any dynamic linking of uninstalled libtool libraries 40044cd6a3aeSmrg -static-libtool-libs 40054cd6a3aeSmrg do not do any dynamic linking of libtool libraries 40064cd6a3aeSmrg -version-info CURRENT[:REVISION[:AGE]] 40074cd6a3aeSmrg specify library version info [each variable defaults to 0] 40084cd6a3aeSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 40094cd6a3aeSmrg -Wc,FLAG 40104cd6a3aeSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 401154cef2ddSmrg -Wa,FLAG 401254cef2ddSmrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 40134cd6a3aeSmrg -Wl,FLAG 40144cd6a3aeSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 40154cd6a3aeSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40164cd6a3aeSmrg 401754044362SmrgAll other options (arguments beginning with '-') are ignored. 40184cd6a3aeSmrg 401954044362SmrgEvery other argument is treated as a filename. Files ending in '.la' are 40204cd6a3aeSmrgtreated as uninstalled libtool libraries, other files are standard or library 40214cd6a3aeSmrgobject files. 40224cd6a3aeSmrg 402354044362SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 402454044362Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 40254cd6a3aeSmrgrequired, except when creating a convenience library. 40264cd6a3aeSmrg 402754044362SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 402854044362Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 40294cd6a3aeSmrg 403054044362SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 40314cd6a3aeSmrgis created, otherwise an executable program is created." 40324cd6a3aeSmrg ;; 40334cd6a3aeSmrg 40344cd6a3aeSmrg uninstall) 40354cd6a3aeSmrg $ECHO \ 40364cd6a3aeSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40374cd6a3aeSmrg 40384cd6a3aeSmrgRemove libraries from an installation directory. 40394cd6a3aeSmrg 40404cd6a3aeSmrgRM is the name of the program to use to delete files associated with each FILE 404154044362Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 40424cd6a3aeSmrgto RM. 40434cd6a3aeSmrg 40444cd6a3aeSmrgIf FILE is a libtool library, all the files associated with it are deleted. 40454cd6a3aeSmrgOtherwise, only FILE itself is deleted using RM." 40464cd6a3aeSmrg ;; 40474cd6a3aeSmrg 40484cd6a3aeSmrg *) 404954044362Smrg func_fatal_help "invalid operation mode '$opt_mode'" 40504cd6a3aeSmrg ;; 40518c9fbc29Smrg esac 40528c9fbc29Smrg 40534cd6a3aeSmrg echo 405454044362Smrg $ECHO "Try '$progname --help' for more information about other modes." 40554cd6a3aeSmrg} 40568c9fbc29Smrg 40574cd6a3aeSmrg# Now that we've collected a possible --mode arg, show help if necessary 40584cd6a3aeSmrgif $opt_help; then 405954044362Smrg if test : = "$opt_help"; then 40604cd6a3aeSmrg func_mode_help 40614cd6a3aeSmrg else 40624cd6a3aeSmrg { 40634cd6a3aeSmrg func_help noexit 40644cd6a3aeSmrg for opt_mode in compile link execute install finish uninstall clean; do 40654cd6a3aeSmrg func_mode_help 40664cd6a3aeSmrg done 406754044362Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 40684cd6a3aeSmrg { 40694cd6a3aeSmrg func_help noexit 40704cd6a3aeSmrg for opt_mode in compile link execute install finish uninstall clean; do 40714cd6a3aeSmrg echo 40724cd6a3aeSmrg func_mode_help 40734cd6a3aeSmrg done 40744cd6a3aeSmrg } | 407554044362Smrg $SED '1d 40764cd6a3aeSmrg /^When reporting/,/^Report/{ 40774cd6a3aeSmrg H 40784cd6a3aeSmrg d 40794cd6a3aeSmrg } 40804cd6a3aeSmrg $x 40814cd6a3aeSmrg /information about other modes/d 40824cd6a3aeSmrg /more detailed .*MODE/d 40834cd6a3aeSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 40844cd6a3aeSmrg fi 40854cd6a3aeSmrg exit $? 40864cd6a3aeSmrgfi 40878c9fbc29Smrg 40888c9fbc29Smrg 40894cd6a3aeSmrg# func_mode_execute arg... 40904cd6a3aeSmrgfunc_mode_execute () 40914cd6a3aeSmrg{ 409254044362Smrg $debug_cmd 409354044362Smrg 40944cd6a3aeSmrg # The first argument is the command name. 409554044362Smrg cmd=$nonopt 40964cd6a3aeSmrg test -z "$cmd" && \ 40974cd6a3aeSmrg func_fatal_help "you must specify a COMMAND" 40984cd6a3aeSmrg 40994cd6a3aeSmrg # Handle -dlopen flags immediately. 41004cd6a3aeSmrg for file in $opt_dlopen; do 41014cd6a3aeSmrg test -f "$file" \ 410254044362Smrg || func_fatal_help "'$file' is not a file" 41034cd6a3aeSmrg 41044cd6a3aeSmrg dir= 41054cd6a3aeSmrg case $file in 41064cd6a3aeSmrg *.la) 41074cd6a3aeSmrg func_resolve_sysroot "$file" 41084cd6a3aeSmrg file=$func_resolve_sysroot_result 41094cd6a3aeSmrg 41104cd6a3aeSmrg # Check to see that this really is a libtool archive. 41114cd6a3aeSmrg func_lalib_unsafe_p "$file" \ 411254044362Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 41134cd6a3aeSmrg 41144cd6a3aeSmrg # Read the libtool library. 41154cd6a3aeSmrg dlname= 41164cd6a3aeSmrg library_names= 41174cd6a3aeSmrg func_source "$file" 41184cd6a3aeSmrg 41194cd6a3aeSmrg # Skip this library if it cannot be dlopened. 41204cd6a3aeSmrg if test -z "$dlname"; then 41214cd6a3aeSmrg # Warn if it was a shared library. 41224cd6a3aeSmrg test -n "$library_names" && \ 412354044362Smrg func_warning "'$file' was not linked with '-export-dynamic'" 41244cd6a3aeSmrg continue 41254cd6a3aeSmrg fi 41264cd6a3aeSmrg 41274cd6a3aeSmrg func_dirname "$file" "" "." 412854044362Smrg dir=$func_dirname_result 41294cd6a3aeSmrg 41304cd6a3aeSmrg if test -f "$dir/$objdir/$dlname"; then 41314cd6a3aeSmrg func_append dir "/$objdir" 41324cd6a3aeSmrg else 41334cd6a3aeSmrg if test ! -f "$dir/$dlname"; then 413454044362Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 41354cd6a3aeSmrg fi 41364cd6a3aeSmrg fi 41378c9fbc29Smrg ;; 41384cd6a3aeSmrg 41394cd6a3aeSmrg *.lo) 41404cd6a3aeSmrg # Just add the directory containing the .lo file. 41414cd6a3aeSmrg func_dirname "$file" "" "." 414254044362Smrg dir=$func_dirname_result 41438c9fbc29Smrg ;; 41444cd6a3aeSmrg 41454cd6a3aeSmrg *) 414654044362Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41474cd6a3aeSmrg continue 41488c9fbc29Smrg ;; 41494cd6a3aeSmrg esac 41504cd6a3aeSmrg 41514cd6a3aeSmrg # Get the absolute pathname. 41524cd6a3aeSmrg absdir=`cd "$dir" && pwd` 415354044362Smrg test -n "$absdir" && dir=$absdir 41544cd6a3aeSmrg 41554cd6a3aeSmrg # Now add the directory to shlibpath_var. 41564cd6a3aeSmrg if eval "test -z \"\$$shlibpath_var\""; then 41574cd6a3aeSmrg eval "$shlibpath_var=\"\$dir\"" 41584cd6a3aeSmrg else 41594cd6a3aeSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41608c9fbc29Smrg fi 41614cd6a3aeSmrg done 41624cd6a3aeSmrg 41634cd6a3aeSmrg # This variable tells wrapper scripts just to set shlibpath_var 41644cd6a3aeSmrg # rather than running their programs. 416554044362Smrg libtool_execute_magic=$magic 41664cd6a3aeSmrg 41674cd6a3aeSmrg # Check if any of the arguments is a wrapper script. 41684cd6a3aeSmrg args= 41694cd6a3aeSmrg for file 41704cd6a3aeSmrg do 41714cd6a3aeSmrg case $file in 41724cd6a3aeSmrg -* | *.la | *.lo ) ;; 41734cd6a3aeSmrg *) 41744cd6a3aeSmrg # Do a test to see if this is really a libtool program. 41754cd6a3aeSmrg if func_ltwrapper_script_p "$file"; then 41764cd6a3aeSmrg func_source "$file" 41774cd6a3aeSmrg # Transform arg to wrapped name. 417854044362Smrg file=$progdir/$program 41794cd6a3aeSmrg elif func_ltwrapper_executable_p "$file"; then 41804cd6a3aeSmrg func_ltwrapper_scriptname "$file" 41814cd6a3aeSmrg func_source "$func_ltwrapper_scriptname_result" 41824cd6a3aeSmrg # Transform arg to wrapped name. 418354044362Smrg file=$progdir/$program 41844cd6a3aeSmrg fi 41854cd6a3aeSmrg ;; 41864cd6a3aeSmrg esac 41874cd6a3aeSmrg # Quote arguments (to preserve shell metacharacters). 41884cd6a3aeSmrg func_append_quoted args "$file" 41894cd6a3aeSmrg done 41904cd6a3aeSmrg 419154044362Smrg if $opt_dry_run; then 419254044362Smrg # Display what would be done. 419354044362Smrg if test -n "$shlibpath_var"; then 419454044362Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 419554044362Smrg echo "export $shlibpath_var" 419654044362Smrg fi 419754044362Smrg $ECHO "$cmd$args" 419854044362Smrg exit $EXIT_SUCCESS 419954044362Smrg else 42004cd6a3aeSmrg if test -n "$shlibpath_var"; then 42014cd6a3aeSmrg # Export the shlibpath_var. 42024cd6a3aeSmrg eval "export $shlibpath_var" 42038c9fbc29Smrg fi 42044cd6a3aeSmrg 42054cd6a3aeSmrg # Restore saved environment variables 42064cd6a3aeSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 42074cd6a3aeSmrg do 42084cd6a3aeSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 42094cd6a3aeSmrg $lt_var=\$save_$lt_var; export $lt_var 42104cd6a3aeSmrg else 42114cd6a3aeSmrg $lt_unset $lt_var 42124cd6a3aeSmrg fi" 42134cd6a3aeSmrg done 42144cd6a3aeSmrg 42154cd6a3aeSmrg # Now prepare to actually exec the command. 421654044362Smrg exec_cmd=\$cmd$args 42174cd6a3aeSmrg fi 42184cd6a3aeSmrg} 42198c9fbc29Smrg 422054044362Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42218c9fbc29Smrg 42228c9fbc29Smrg 42234cd6a3aeSmrg# func_mode_finish arg... 42244cd6a3aeSmrgfunc_mode_finish () 42254cd6a3aeSmrg{ 422654044362Smrg $debug_cmd 422754044362Smrg 42284cd6a3aeSmrg libs= 42294cd6a3aeSmrg libdirs= 42304cd6a3aeSmrg admincmds= 42318c9fbc29Smrg 42324cd6a3aeSmrg for opt in "$nonopt" ${1+"$@"} 42334cd6a3aeSmrg do 42344cd6a3aeSmrg if test -d "$opt"; then 42354cd6a3aeSmrg func_append libdirs " $opt" 42368c9fbc29Smrg 42374cd6a3aeSmrg elif test -f "$opt"; then 42384cd6a3aeSmrg if func_lalib_unsafe_p "$opt"; then 42394cd6a3aeSmrg func_append libs " $opt" 42404cd6a3aeSmrg else 424154044362Smrg func_warning "'$opt' is not a valid libtool archive" 42428c9fbc29Smrg fi 42438c9fbc29Smrg 42444cd6a3aeSmrg else 424554044362Smrg func_fatal_error "invalid argument '$opt'" 42464cd6a3aeSmrg fi 42474cd6a3aeSmrg done 42488c9fbc29Smrg 42494cd6a3aeSmrg if test -n "$libs"; then 42504cd6a3aeSmrg if test -n "$lt_sysroot"; then 42514cd6a3aeSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 42524cd6a3aeSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 42534cd6a3aeSmrg else 42544cd6a3aeSmrg sysroot_cmd= 42554cd6a3aeSmrg fi 42568c9fbc29Smrg 42574cd6a3aeSmrg # Remove sysroot references 42584cd6a3aeSmrg if $opt_dry_run; then 42594cd6a3aeSmrg for lib in $libs; do 426054044362Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 42614cd6a3aeSmrg done 42624cd6a3aeSmrg else 42634cd6a3aeSmrg tmpdir=`func_mktempdir` 42644cd6a3aeSmrg for lib in $libs; do 426554044362Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 42664cd6a3aeSmrg > $tmpdir/tmp-la 42674cd6a3aeSmrg mv -f $tmpdir/tmp-la $lib 42688c9fbc29Smrg done 42694cd6a3aeSmrg ${RM}r "$tmpdir" 42704cd6a3aeSmrg fi 42714cd6a3aeSmrg fi 42724cd6a3aeSmrg 42734cd6a3aeSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42744cd6a3aeSmrg for libdir in $libdirs; do 42754cd6a3aeSmrg if test -n "$finish_cmds"; then 42764cd6a3aeSmrg # Do each command in the finish commands. 42774cd6a3aeSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 42784cd6a3aeSmrg'"$cmd"'"' 42798c9fbc29Smrg fi 42804cd6a3aeSmrg if test -n "$finish_eval"; then 42814cd6a3aeSmrg # Do the single finish_eval. 42824cd6a3aeSmrg eval cmds=\"$finish_eval\" 42834cd6a3aeSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 42844cd6a3aeSmrg $cmds" 42854cd6a3aeSmrg fi 42864cd6a3aeSmrg done 42874cd6a3aeSmrg fi 42888c9fbc29Smrg 42894cd6a3aeSmrg # Exit here if they wanted silent mode. 429054044362Smrg $opt_quiet && exit $EXIT_SUCCESS 42918c9fbc29Smrg 42924cd6a3aeSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42934cd6a3aeSmrg echo "----------------------------------------------------------------------" 42944cd6a3aeSmrg echo "Libraries have been installed in:" 42954cd6a3aeSmrg for libdir in $libdirs; do 42964cd6a3aeSmrg $ECHO " $libdir" 42974cd6a3aeSmrg done 42984cd6a3aeSmrg echo 42994cd6a3aeSmrg echo "If you ever happen to want to link against installed libraries" 43004cd6a3aeSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 430154044362Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 43024cd6a3aeSmrg echo "flag during linking and do at least one of the following:" 43034cd6a3aeSmrg if test -n "$shlibpath_var"; then 430454044362Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 43054cd6a3aeSmrg echo " during execution" 43064cd6a3aeSmrg fi 43074cd6a3aeSmrg if test -n "$runpath_var"; then 430854044362Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 43094cd6a3aeSmrg echo " during linking" 43104cd6a3aeSmrg fi 43114cd6a3aeSmrg if test -n "$hardcode_libdir_flag_spec"; then 43124cd6a3aeSmrg libdir=LIBDIR 43134cd6a3aeSmrg eval flag=\"$hardcode_libdir_flag_spec\" 43144cd6a3aeSmrg 431554044362Smrg $ECHO " - use the '$flag' linker flag" 43164cd6a3aeSmrg fi 43174cd6a3aeSmrg if test -n "$admincmds"; then 43184cd6a3aeSmrg $ECHO " - have your system administrator run these commands:$admincmds" 43194cd6a3aeSmrg fi 43204cd6a3aeSmrg if test -f /etc/ld.so.conf; then 432154044362Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 43224cd6a3aeSmrg fi 43234cd6a3aeSmrg echo 43244cd6a3aeSmrg 43254cd6a3aeSmrg echo "See any operating system documentation about shared libraries for" 43264cd6a3aeSmrg case $host in 43274cd6a3aeSmrg solaris2.[6789]|solaris2.1[0-9]) 43284cd6a3aeSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 43294cd6a3aeSmrg echo "pages." 43304cd6a3aeSmrg ;; 43318c9fbc29Smrg *) 43324cd6a3aeSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43338c9fbc29Smrg ;; 43344cd6a3aeSmrg esac 43354cd6a3aeSmrg echo "----------------------------------------------------------------------" 43364cd6a3aeSmrg fi 43374cd6a3aeSmrg exit $EXIT_SUCCESS 43384cd6a3aeSmrg} 43398c9fbc29Smrg 434054044362Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43418c9fbc29Smrg 43424cd6a3aeSmrg 43434cd6a3aeSmrg# func_mode_install arg... 43444cd6a3aeSmrgfunc_mode_install () 43454cd6a3aeSmrg{ 434654044362Smrg $debug_cmd 434754044362Smrg 43484cd6a3aeSmrg # There may be an optional sh(1) argument at the beginning of 43494cd6a3aeSmrg # install_prog (especially on Windows NT). 435054044362Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 43514cd6a3aeSmrg # Allow the use of GNU shtool's install command. 435254044362Smrg case $nonopt in *shtool*) :;; *) false;; esac 435354044362Smrg then 43544cd6a3aeSmrg # Aesthetically quote it. 435554cef2ddSmrg func_quote_arg pretty "$nonopt" 435654cef2ddSmrg install_prog="$func_quote_arg_result " 43574cd6a3aeSmrg arg=$1 43584cd6a3aeSmrg shift 43594cd6a3aeSmrg else 43604cd6a3aeSmrg install_prog= 43614cd6a3aeSmrg arg=$nonopt 43624cd6a3aeSmrg fi 43634cd6a3aeSmrg 43644cd6a3aeSmrg # The real first argument should be the name of the installation program. 43654cd6a3aeSmrg # Aesthetically quote it. 436654cef2ddSmrg func_quote_arg pretty "$arg" 436754cef2ddSmrg func_append install_prog "$func_quote_arg_result" 43684cd6a3aeSmrg install_shared_prog=$install_prog 43694cd6a3aeSmrg case " $install_prog " in 43704cd6a3aeSmrg *[\\\ /]cp\ *) install_cp=: ;; 43714cd6a3aeSmrg *) install_cp=false ;; 43724cd6a3aeSmrg esac 43734cd6a3aeSmrg 43744cd6a3aeSmrg # We need to accept at least all the BSD install flags. 43754cd6a3aeSmrg dest= 43764cd6a3aeSmrg files= 43774cd6a3aeSmrg opts= 43784cd6a3aeSmrg prev= 43794cd6a3aeSmrg install_type= 438054044362Smrg isdir=false 43814cd6a3aeSmrg stripme= 43824cd6a3aeSmrg no_mode=: 43834cd6a3aeSmrg for arg 43844cd6a3aeSmrg do 43854cd6a3aeSmrg arg2= 43864cd6a3aeSmrg if test -n "$dest"; then 43874cd6a3aeSmrg func_append files " $dest" 43884cd6a3aeSmrg dest=$arg 43894cd6a3aeSmrg continue 43904cd6a3aeSmrg fi 43914cd6a3aeSmrg 43924cd6a3aeSmrg case $arg in 439354044362Smrg -d) isdir=: ;; 43944cd6a3aeSmrg -f) 43954cd6a3aeSmrg if $install_cp; then :; else 43964cd6a3aeSmrg prev=$arg 43974cd6a3aeSmrg fi 43984cd6a3aeSmrg ;; 43994cd6a3aeSmrg -g | -m | -o) 44004cd6a3aeSmrg prev=$arg 44014cd6a3aeSmrg ;; 44024cd6a3aeSmrg -s) 44034cd6a3aeSmrg stripme=" -s" 44044cd6a3aeSmrg continue 44054cd6a3aeSmrg ;; 44064cd6a3aeSmrg -*) 44074cd6a3aeSmrg ;; 44084cd6a3aeSmrg *) 44094cd6a3aeSmrg # If the previous option needed an argument, then skip it. 44104cd6a3aeSmrg if test -n "$prev"; then 441154044362Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 44124cd6a3aeSmrg arg2=$install_override_mode 44134cd6a3aeSmrg no_mode=false 44148c9fbc29Smrg fi 44154cd6a3aeSmrg prev= 44164cd6a3aeSmrg else 44174cd6a3aeSmrg dest=$arg 44188c9fbc29Smrg continue 44198c9fbc29Smrg fi 44204cd6a3aeSmrg ;; 44214cd6a3aeSmrg esac 44228c9fbc29Smrg 44234cd6a3aeSmrg # Aesthetically quote the argument. 442454cef2ddSmrg func_quote_arg pretty "$arg" 442554cef2ddSmrg func_append install_prog " $func_quote_arg_result" 44264cd6a3aeSmrg if test -n "$arg2"; then 442754cef2ddSmrg func_quote_arg pretty "$arg2" 44284cd6a3aeSmrg fi 442954cef2ddSmrg func_append install_shared_prog " $func_quote_arg_result" 44304cd6a3aeSmrg done 44318c9fbc29Smrg 44324cd6a3aeSmrg test -z "$install_prog" && \ 44334cd6a3aeSmrg func_fatal_help "you must specify an install program" 44348c9fbc29Smrg 44354cd6a3aeSmrg test -n "$prev" && \ 443654044362Smrg func_fatal_help "the '$prev' option requires an argument" 44378c9fbc29Smrg 44384cd6a3aeSmrg if test -n "$install_override_mode" && $no_mode; then 44394cd6a3aeSmrg if $install_cp; then :; else 444054cef2ddSmrg func_quote_arg pretty "$install_override_mode" 444154cef2ddSmrg func_append install_shared_prog " -m $func_quote_arg_result" 44424cd6a3aeSmrg fi 44434cd6a3aeSmrg fi 44448c9fbc29Smrg 44454cd6a3aeSmrg if test -z "$files"; then 44464cd6a3aeSmrg if test -z "$dest"; then 44474cd6a3aeSmrg func_fatal_help "no file or destination specified" 44484cd6a3aeSmrg else 44494cd6a3aeSmrg func_fatal_help "you must specify a destination" 44504cd6a3aeSmrg fi 44514cd6a3aeSmrg fi 44528c9fbc29Smrg 44534cd6a3aeSmrg # Strip any trailing slash from the destination. 44544cd6a3aeSmrg func_stripname '' '/' "$dest" 44554cd6a3aeSmrg dest=$func_stripname_result 44568c9fbc29Smrg 44574cd6a3aeSmrg # Check to see that the destination is a directory. 445854044362Smrg test -d "$dest" && isdir=: 445954044362Smrg if $isdir; then 446054044362Smrg destdir=$dest 44614cd6a3aeSmrg destname= 44624cd6a3aeSmrg else 44634cd6a3aeSmrg func_dirname_and_basename "$dest" "" "." 446454044362Smrg destdir=$func_dirname_result 446554044362Smrg destname=$func_basename_result 44668c9fbc29Smrg 44674cd6a3aeSmrg # Not a directory, so check to see that there is only one file specified. 44684cd6a3aeSmrg set dummy $files; shift 44694cd6a3aeSmrg test "$#" -gt 1 && \ 447054044362Smrg func_fatal_help "'$dest' is not a directory" 44714cd6a3aeSmrg fi 44724cd6a3aeSmrg case $destdir in 44734cd6a3aeSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44744cd6a3aeSmrg *) 44754cd6a3aeSmrg for file in $files; do 44764cd6a3aeSmrg case $file in 44774cd6a3aeSmrg *.lo) ;; 44784cd6a3aeSmrg *) 447954044362Smrg func_fatal_help "'$destdir' must be an absolute directory name" 44804cd6a3aeSmrg ;; 44814cd6a3aeSmrg esac 44824cd6a3aeSmrg done 44834cd6a3aeSmrg ;; 44844cd6a3aeSmrg esac 44858c9fbc29Smrg 44864cd6a3aeSmrg # This variable tells wrapper scripts just to set variables rather 44874cd6a3aeSmrg # than running their programs. 448854044362Smrg libtool_install_magic=$magic 44898c9fbc29Smrg 44904cd6a3aeSmrg staticlibs= 44914cd6a3aeSmrg future_libdirs= 44924cd6a3aeSmrg current_libdirs= 44934cd6a3aeSmrg for file in $files; do 44948c9fbc29Smrg 44954cd6a3aeSmrg # Do each installation. 44964cd6a3aeSmrg case $file in 44974cd6a3aeSmrg *.$libext) 44984cd6a3aeSmrg # Do the static libraries later. 44994cd6a3aeSmrg func_append staticlibs " $file" 45004cd6a3aeSmrg ;; 45018c9fbc29Smrg 45024cd6a3aeSmrg *.la) 45034cd6a3aeSmrg func_resolve_sysroot "$file" 45044cd6a3aeSmrg file=$func_resolve_sysroot_result 45058c9fbc29Smrg 45064cd6a3aeSmrg # Check to see that this really is a libtool archive. 45074cd6a3aeSmrg func_lalib_unsafe_p "$file" \ 450854044362Smrg || func_fatal_help "'$file' is not a valid libtool archive" 45098c9fbc29Smrg 45104cd6a3aeSmrg library_names= 45114cd6a3aeSmrg old_library= 45124cd6a3aeSmrg relink_command= 45134cd6a3aeSmrg func_source "$file" 45148c9fbc29Smrg 45154cd6a3aeSmrg # Add the libdir to current_libdirs if it is the destination. 45164cd6a3aeSmrg if test "X$destdir" = "X$libdir"; then 45174cd6a3aeSmrg case "$current_libdirs " in 45184cd6a3aeSmrg *" $libdir "*) ;; 45194cd6a3aeSmrg *) func_append current_libdirs " $libdir" ;; 45204cd6a3aeSmrg esac 45214cd6a3aeSmrg else 45224cd6a3aeSmrg # Note the libdir as a future libdir. 45234cd6a3aeSmrg case "$future_libdirs " in 45244cd6a3aeSmrg *" $libdir "*) ;; 45254cd6a3aeSmrg *) func_append future_libdirs " $libdir" ;; 45264cd6a3aeSmrg esac 45274cd6a3aeSmrg fi 45288c9fbc29Smrg 45294cd6a3aeSmrg func_dirname "$file" "/" "" 453054044362Smrg dir=$func_dirname_result 45314cd6a3aeSmrg func_append dir "$objdir" 45328c9fbc29Smrg 45334cd6a3aeSmrg if test -n "$relink_command"; then 45344cd6a3aeSmrg # Determine the prefix the user has applied to our future dir. 45354cd6a3aeSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45368c9fbc29Smrg 45374cd6a3aeSmrg # Don't allow the user to place us outside of our expected 45384cd6a3aeSmrg # location b/c this prevents finding dependent libraries that 45394cd6a3aeSmrg # are installed to the same prefix. 45404cd6a3aeSmrg # At present, this check doesn't affect windows .dll's that 45414cd6a3aeSmrg # are installed into $libdir/../bin (currently, that works fine) 45424cd6a3aeSmrg # but it's something to keep an eye on. 45434cd6a3aeSmrg test "$inst_prefix_dir" = "$destdir" && \ 454454044362Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 45454cd6a3aeSmrg 45464cd6a3aeSmrg if test -n "$inst_prefix_dir"; then 45474cd6a3aeSmrg # Stick the inst_prefix_dir data into the link command. 45484cd6a3aeSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45498c9fbc29Smrg else 45504cd6a3aeSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45518c9fbc29Smrg fi 45528c9fbc29Smrg 455354044362Smrg func_warning "relinking '$file'" 45544cd6a3aeSmrg func_show_eval "$relink_command" \ 455554044362Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 45564cd6a3aeSmrg fi 45574cd6a3aeSmrg 45584cd6a3aeSmrg # See the names of the shared library. 45594cd6a3aeSmrg set dummy $library_names; shift 45604cd6a3aeSmrg if test -n "$1"; then 456154044362Smrg realname=$1 45624cd6a3aeSmrg shift 45634cd6a3aeSmrg 456454044362Smrg srcname=$realname 456554044362Smrg test -n "$relink_command" && srcname=${realname}T 45664cd6a3aeSmrg 45674cd6a3aeSmrg # Install the shared library and build the symlinks. 45684cd6a3aeSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 45694cd6a3aeSmrg 'exit $?' 457054044362Smrg tstripme=$stripme 45714cd6a3aeSmrg case $host_os in 45724cd6a3aeSmrg cygwin* | mingw* | pw32* | cegcc*) 45734cd6a3aeSmrg case $realname in 45744cd6a3aeSmrg *.dll.a) 457554044362Smrg tstripme= 457654044362Smrg ;; 457754044362Smrg esac 457854044362Smrg ;; 457954044362Smrg os2*) 458054044362Smrg case $realname in 458154044362Smrg *_dll.a) 458254044362Smrg tstripme= 45834cd6a3aeSmrg ;; 45844cd6a3aeSmrg esac 45854cd6a3aeSmrg ;; 45864cd6a3aeSmrg esac 45874cd6a3aeSmrg if test -n "$tstripme" && test -n "$striplib"; then 45884cd6a3aeSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45898c9fbc29Smrg fi 45908c9fbc29Smrg 45914cd6a3aeSmrg if test "$#" -gt 0; then 45924cd6a3aeSmrg # Delete the old symlinks, and create new ones. 459354044362Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 45944cd6a3aeSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 45954cd6a3aeSmrg # so we also need to try rm && ln -s. 45964cd6a3aeSmrg for linkname 45974cd6a3aeSmrg do 45984cd6a3aeSmrg test "$linkname" != "$realname" \ 45994cd6a3aeSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46008c9fbc29Smrg done 46018c9fbc29Smrg fi 46028c9fbc29Smrg 46034cd6a3aeSmrg # Do each command in the postinstall commands. 460454044362Smrg lib=$destdir/$realname 46054cd6a3aeSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 46064cd6a3aeSmrg fi 46078c9fbc29Smrg 46084cd6a3aeSmrg # Install the pseudo-library for information purposes. 46094cd6a3aeSmrg func_basename "$file" 461054044362Smrg name=$func_basename_result 461154044362Smrg instname=$dir/${name}i 46124cd6a3aeSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46138c9fbc29Smrg 46144cd6a3aeSmrg # Maybe install the static library, too. 46154cd6a3aeSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 46164cd6a3aeSmrg ;; 46174cd6a3aeSmrg 46184cd6a3aeSmrg *.lo) 46194cd6a3aeSmrg # Install (i.e. copy) a libtool object. 46204cd6a3aeSmrg 46214cd6a3aeSmrg # Figure out destination file name, if it wasn't already specified. 46224cd6a3aeSmrg if test -n "$destname"; then 462354044362Smrg destfile=$destdir/$destname 46248c9fbc29Smrg else 46254cd6a3aeSmrg func_basename "$file" 462654044362Smrg destfile=$func_basename_result 462754044362Smrg destfile=$destdir/$destfile 46288c9fbc29Smrg fi 46294cd6a3aeSmrg 46304cd6a3aeSmrg # Deduce the name of the destination old-style object file. 46314cd6a3aeSmrg case $destfile in 46324cd6a3aeSmrg *.lo) 46334cd6a3aeSmrg func_lo2o "$destfile" 46344cd6a3aeSmrg staticdest=$func_lo2o_result 46354cd6a3aeSmrg ;; 46364cd6a3aeSmrg *.$objext) 463754044362Smrg staticdest=$destfile 46384cd6a3aeSmrg destfile= 46394cd6a3aeSmrg ;; 46404cd6a3aeSmrg *) 464154044362Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46428c9fbc29Smrg ;; 46438c9fbc29Smrg esac 46448c9fbc29Smrg 46454cd6a3aeSmrg # Install the libtool object if requested. 46464cd6a3aeSmrg test -n "$destfile" && \ 46474cd6a3aeSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46488c9fbc29Smrg 46494cd6a3aeSmrg # Install the old object if enabled. 465054044362Smrg if test yes = "$build_old_libs"; then 46514cd6a3aeSmrg # Deduce the name of the old-style object file. 46524cd6a3aeSmrg func_lo2o "$file" 46534cd6a3aeSmrg staticobj=$func_lo2o_result 46544cd6a3aeSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 46554cd6a3aeSmrg fi 46564cd6a3aeSmrg exit $EXIT_SUCCESS 46574cd6a3aeSmrg ;; 46588c9fbc29Smrg 46594cd6a3aeSmrg *) 46604cd6a3aeSmrg # Figure out destination file name, if it wasn't already specified. 46614cd6a3aeSmrg if test -n "$destname"; then 466254044362Smrg destfile=$destdir/$destname 46634cd6a3aeSmrg else 46644cd6a3aeSmrg func_basename "$file" 466554044362Smrg destfile=$func_basename_result 466654044362Smrg destfile=$destdir/$destfile 46674cd6a3aeSmrg fi 46688c9fbc29Smrg 46694cd6a3aeSmrg # If the file is missing, and there is a .exe on the end, strip it 46704cd6a3aeSmrg # because it is most likely a libtool script we actually want to 46714cd6a3aeSmrg # install 467254044362Smrg stripped_ext= 46734cd6a3aeSmrg case $file in 46744cd6a3aeSmrg *.exe) 46754cd6a3aeSmrg if test ! -f "$file"; then 46764cd6a3aeSmrg func_stripname '' '.exe' "$file" 46774cd6a3aeSmrg file=$func_stripname_result 467854044362Smrg stripped_ext=.exe 46794cd6a3aeSmrg fi 46804cd6a3aeSmrg ;; 46814cd6a3aeSmrg esac 46828c9fbc29Smrg 46834cd6a3aeSmrg # Do a test to see if this is really a libtool program. 46844cd6a3aeSmrg case $host in 46854cd6a3aeSmrg *cygwin* | *mingw*) 46864cd6a3aeSmrg if func_ltwrapper_executable_p "$file"; then 46874cd6a3aeSmrg func_ltwrapper_scriptname "$file" 46884cd6a3aeSmrg wrapper=$func_ltwrapper_scriptname_result 46894cd6a3aeSmrg else 46904cd6a3aeSmrg func_stripname '' '.exe' "$file" 46914cd6a3aeSmrg wrapper=$func_stripname_result 46924cd6a3aeSmrg fi 46934cd6a3aeSmrg ;; 46944cd6a3aeSmrg *) 46954cd6a3aeSmrg wrapper=$file 46964cd6a3aeSmrg ;; 46974cd6a3aeSmrg esac 46984cd6a3aeSmrg if func_ltwrapper_script_p "$wrapper"; then 46994cd6a3aeSmrg notinst_deplibs= 47004cd6a3aeSmrg relink_command= 47018c9fbc29Smrg 47024cd6a3aeSmrg func_source "$wrapper" 47038c9fbc29Smrg 47044cd6a3aeSmrg # Check the variables that should have been set. 47054cd6a3aeSmrg test -z "$generated_by_libtool_version" && \ 470654044362Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47078c9fbc29Smrg 470854044362Smrg finalize=: 47094cd6a3aeSmrg for lib in $notinst_deplibs; do 47104cd6a3aeSmrg # Check to see that each library is installed. 47114cd6a3aeSmrg libdir= 47124cd6a3aeSmrg if test -f "$lib"; then 47134cd6a3aeSmrg func_source "$lib" 47144cd6a3aeSmrg fi 471554044362Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 47164cd6a3aeSmrg if test -n "$libdir" && test ! -f "$libfile"; then 471754044362Smrg func_warning "'$lib' has not been installed in '$libdir'" 471854044362Smrg finalize=false 47194cd6a3aeSmrg fi 47204cd6a3aeSmrg done 47218c9fbc29Smrg 47224cd6a3aeSmrg relink_command= 47234cd6a3aeSmrg func_source "$wrapper" 47244cd6a3aeSmrg 47254cd6a3aeSmrg outputname= 472654044362Smrg if test no = "$fast_install" && test -n "$relink_command"; then 47274cd6a3aeSmrg $opt_dry_run || { 472854044362Smrg if $finalize; then 47294cd6a3aeSmrg tmpdir=`func_mktempdir` 47304cd6a3aeSmrg func_basename "$file$stripped_ext" 473154044362Smrg file=$func_basename_result 473254044362Smrg outputname=$tmpdir/$file 47334cd6a3aeSmrg # Replace the output file specification. 47344cd6a3aeSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 47354cd6a3aeSmrg 473654044362Smrg $opt_quiet || { 473754cef2ddSmrg func_quote_arg expand,pretty "$relink_command" 473854cef2ddSmrg eval "func_echo $func_quote_arg_result" 47394cd6a3aeSmrg } 47404cd6a3aeSmrg if eval "$relink_command"; then : 47414cd6a3aeSmrg else 474254044362Smrg func_error "error: relink '$file' with the above command before installing it" 47434cd6a3aeSmrg $opt_dry_run || ${RM}r "$tmpdir" 47444cd6a3aeSmrg continue 47454cd6a3aeSmrg fi 474654044362Smrg file=$outputname 47474cd6a3aeSmrg else 474854044362Smrg func_warning "cannot relink '$file'" 47494cd6a3aeSmrg fi 47504cd6a3aeSmrg } 47514cd6a3aeSmrg else 47524cd6a3aeSmrg # Install the binary that we compiled earlier. 47534cd6a3aeSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47544cd6a3aeSmrg fi 47558c9fbc29Smrg fi 47564cd6a3aeSmrg 47574cd6a3aeSmrg # remove .exe since cygwin /usr/bin/install will append another 47584cd6a3aeSmrg # one anyway 47594cd6a3aeSmrg case $install_prog,$host in 47604cd6a3aeSmrg */usr/bin/install*,*cygwin*) 47614cd6a3aeSmrg case $file:$destfile in 47624cd6a3aeSmrg *.exe:*.exe) 47634cd6a3aeSmrg # this is ok 47644cd6a3aeSmrg ;; 47654cd6a3aeSmrg *.exe:*) 47664cd6a3aeSmrg destfile=$destfile.exe 47674cd6a3aeSmrg ;; 47684cd6a3aeSmrg *:*.exe) 47694cd6a3aeSmrg func_stripname '' '.exe' "$destfile" 47704cd6a3aeSmrg destfile=$func_stripname_result 47714cd6a3aeSmrg ;; 47724cd6a3aeSmrg esac 47734cd6a3aeSmrg ;; 47744cd6a3aeSmrg esac 47754cd6a3aeSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 47764cd6a3aeSmrg $opt_dry_run || if test -n "$outputname"; then 47774cd6a3aeSmrg ${RM}r "$tmpdir" 47788c9fbc29Smrg fi 47798c9fbc29Smrg ;; 47808c9fbc29Smrg esac 47814cd6a3aeSmrg done 47828c9fbc29Smrg 47834cd6a3aeSmrg for file in $staticlibs; do 47844cd6a3aeSmrg func_basename "$file" 478554044362Smrg name=$func_basename_result 47868c9fbc29Smrg 47874cd6a3aeSmrg # Set up the ranlib parameters. 478854044362Smrg oldlib=$destdir/$name 478970728a38Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 479070728a38Smrg tool_oldlib=$func_to_tool_file_result 47918c9fbc29Smrg 47924cd6a3aeSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47934cd6a3aeSmrg 47944cd6a3aeSmrg if test -n "$stripme" && test -n "$old_striplib"; then 479570728a38Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47968c9fbc29Smrg fi 47978c9fbc29Smrg 47984cd6a3aeSmrg # Do each command in the postinstall commands. 47994cd6a3aeSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 48004cd6a3aeSmrg done 48018c9fbc29Smrg 48024cd6a3aeSmrg test -n "$future_libdirs" && \ 480354044362Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 48048c9fbc29Smrg 48054cd6a3aeSmrg if test -n "$current_libdirs"; then 48064cd6a3aeSmrg # Maybe just do a dry run. 48074cd6a3aeSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 480854044362Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 48094cd6a3aeSmrg else 48104cd6a3aeSmrg exit $EXIT_SUCCESS 48114cd6a3aeSmrg fi 48124cd6a3aeSmrg} 48138c9fbc29Smrg 481454044362Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48158c9fbc29Smrg 48168c9fbc29Smrg 48174cd6a3aeSmrg# func_generate_dlsyms outputname originator pic_p 48184cd6a3aeSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 48194cd6a3aeSmrg# a dlpreopen symbol table. 48204cd6a3aeSmrgfunc_generate_dlsyms () 48214cd6a3aeSmrg{ 482254044362Smrg $debug_cmd 482354044362Smrg 482454044362Smrg my_outputname=$1 482554044362Smrg my_originator=$2 482654044362Smrg my_pic_p=${3-false} 482754044362Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 48284cd6a3aeSmrg my_dlsyms= 48294cd6a3aeSmrg 483054044362Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 48314cd6a3aeSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 483254044362Smrg my_dlsyms=${my_outputname}S.c 48334cd6a3aeSmrg else 48344cd6a3aeSmrg func_error "not configured to extract global symbols from dlpreopened files" 48354cd6a3aeSmrg fi 48364cd6a3aeSmrg fi 48378c9fbc29Smrg 48384cd6a3aeSmrg if test -n "$my_dlsyms"; then 48394cd6a3aeSmrg case $my_dlsyms in 48404cd6a3aeSmrg "") ;; 48414cd6a3aeSmrg *.c) 48424cd6a3aeSmrg # Discover the nlist of each of the dlfiles. 484354044362Smrg nlist=$output_objdir/$my_outputname.nm 48448c9fbc29Smrg 48454cd6a3aeSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48468c9fbc29Smrg 48474cd6a3aeSmrg # Parse the name list into a source file. 48484cd6a3aeSmrg func_verbose "creating $output_objdir/$my_dlsyms" 48498c9fbc29Smrg 48504cd6a3aeSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 485154044362Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 485254044362Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48538c9fbc29Smrg 48544cd6a3aeSmrg#ifdef __cplusplus 48554cd6a3aeSmrgextern \"C\" { 48564cd6a3aeSmrg#endif 48578c9fbc29Smrg 485854044362Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 48594cd6a3aeSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 48604cd6a3aeSmrg#endif 48618c9fbc29Smrg 48624cd6a3aeSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 486354044362Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 486454044362Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 48654cd6a3aeSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 48664cd6a3aeSmrg# define LT_DLSYM_CONST 486754044362Smrg#elif defined __osf__ 48684cd6a3aeSmrg/* This system does not cope well with relocations in const data. */ 48694cd6a3aeSmrg# define LT_DLSYM_CONST 48704cd6a3aeSmrg#else 48714cd6a3aeSmrg# define LT_DLSYM_CONST const 48724cd6a3aeSmrg#endif 48738c9fbc29Smrg 487454044362Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 487554044362Smrg 48764cd6a3aeSmrg/* External symbol declarations for the compiler. */\ 48774cd6a3aeSmrg" 48788c9fbc29Smrg 487954044362Smrg if test yes = "$dlself"; then 488054044362Smrg func_verbose "generating symbol list for '$output'" 48818c9fbc29Smrg 48824cd6a3aeSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48838c9fbc29Smrg 48844cd6a3aeSmrg # Add our own program objects to the symbol list. 48854cd6a3aeSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 48864cd6a3aeSmrg for progfile in $progfiles; do 48874cd6a3aeSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 488854044362Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 48894cd6a3aeSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48908c9fbc29Smrg done 48918c9fbc29Smrg 48924cd6a3aeSmrg if test -n "$exclude_expsyms"; then 48934cd6a3aeSmrg $opt_dry_run || { 48944cd6a3aeSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 48954cd6a3aeSmrg eval '$MV "$nlist"T "$nlist"' 48964cd6a3aeSmrg } 48974cd6a3aeSmrg fi 48988c9fbc29Smrg 48994cd6a3aeSmrg if test -n "$export_symbols_regex"; then 49004cd6a3aeSmrg $opt_dry_run || { 49014cd6a3aeSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 49024cd6a3aeSmrg eval '$MV "$nlist"T "$nlist"' 49034cd6a3aeSmrg } 49044cd6a3aeSmrg fi 49058c9fbc29Smrg 49064cd6a3aeSmrg # Prepare the list of exported symbols 49074cd6a3aeSmrg if test -z "$export_symbols"; then 490854044362Smrg export_symbols=$output_objdir/$outputname.exp 49094cd6a3aeSmrg $opt_dry_run || { 49104cd6a3aeSmrg $RM $export_symbols 491154044362Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 49124cd6a3aeSmrg case $host in 49134cd6a3aeSmrg *cygwin* | *mingw* | *cegcc* ) 49144cd6a3aeSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49154cd6a3aeSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 49164cd6a3aeSmrg ;; 49174cd6a3aeSmrg esac 49184cd6a3aeSmrg } 49194cd6a3aeSmrg else 49204cd6a3aeSmrg $opt_dry_run || { 492154044362Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 49224cd6a3aeSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 49234cd6a3aeSmrg eval '$MV "$nlist"T "$nlist"' 49244cd6a3aeSmrg case $host in 49254cd6a3aeSmrg *cygwin* | *mingw* | *cegcc* ) 49264cd6a3aeSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49274cd6a3aeSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 49284cd6a3aeSmrg ;; 49294cd6a3aeSmrg esac 49304cd6a3aeSmrg } 49314cd6a3aeSmrg fi 49324cd6a3aeSmrg fi 49338c9fbc29Smrg 49344cd6a3aeSmrg for dlprefile in $dlprefiles; do 493554044362Smrg func_verbose "extracting global C symbols from '$dlprefile'" 49364cd6a3aeSmrg func_basename "$dlprefile" 493754044362Smrg name=$func_basename_result 49384cd6a3aeSmrg case $host in 49394cd6a3aeSmrg *cygwin* | *mingw* | *cegcc* ) 49404cd6a3aeSmrg # if an import library, we need to obtain dlname 49414cd6a3aeSmrg if func_win32_import_lib_p "$dlprefile"; then 49424cd6a3aeSmrg func_tr_sh "$dlprefile" 49434cd6a3aeSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 494454044362Smrg dlprefile_dlbasename= 49454cd6a3aeSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 49464cd6a3aeSmrg # Use subshell, to avoid clobbering current variable values 49474cd6a3aeSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 494854044362Smrg if test -n "$dlprefile_dlname"; then 49494cd6a3aeSmrg func_basename "$dlprefile_dlname" 495054044362Smrg dlprefile_dlbasename=$func_basename_result 49514cd6a3aeSmrg else 49524cd6a3aeSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 49534cd6a3aeSmrg $sharedlib_from_linklib_cmd "$dlprefile" 49544cd6a3aeSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 49554cd6a3aeSmrg fi 49564cd6a3aeSmrg fi 49574cd6a3aeSmrg $opt_dry_run || { 495854044362Smrg if test -n "$dlprefile_dlbasename"; then 49594cd6a3aeSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 49604cd6a3aeSmrg else 49614cd6a3aeSmrg func_warning "Could not compute DLL name from $name" 49624cd6a3aeSmrg eval '$ECHO ": $name " >> "$nlist"' 49634cd6a3aeSmrg fi 49644cd6a3aeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49654cd6a3aeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 49664cd6a3aeSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 49674cd6a3aeSmrg } 49684cd6a3aeSmrg else # not an import lib 49694cd6a3aeSmrg $opt_dry_run || { 49704cd6a3aeSmrg eval '$ECHO ": $name " >> "$nlist"' 49714cd6a3aeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49724cd6a3aeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49734cd6a3aeSmrg } 49744cd6a3aeSmrg fi 49754cd6a3aeSmrg ;; 49764cd6a3aeSmrg *) 49774cd6a3aeSmrg $opt_dry_run || { 49784cd6a3aeSmrg eval '$ECHO ": $name " >> "$nlist"' 49794cd6a3aeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49804cd6a3aeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49814cd6a3aeSmrg } 49824cd6a3aeSmrg ;; 49834cd6a3aeSmrg esac 49844cd6a3aeSmrg done 49858c9fbc29Smrg 49864cd6a3aeSmrg $opt_dry_run || { 49874cd6a3aeSmrg # Make sure we have at least an empty file. 49884cd6a3aeSmrg test -f "$nlist" || : > "$nlist" 49898c9fbc29Smrg 49904cd6a3aeSmrg if test -n "$exclude_expsyms"; then 49914cd6a3aeSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 49924cd6a3aeSmrg $MV "$nlist"T "$nlist" 49934cd6a3aeSmrg fi 49948c9fbc29Smrg 49954cd6a3aeSmrg # Try sorting and uniquifying the output. 49964cd6a3aeSmrg if $GREP -v "^: " < "$nlist" | 49974cd6a3aeSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 49984cd6a3aeSmrg sort -k 3 49994cd6a3aeSmrg else 50004cd6a3aeSmrg sort +2 50014cd6a3aeSmrg fi | 50024cd6a3aeSmrg uniq > "$nlist"S; then 50034cd6a3aeSmrg : 50044cd6a3aeSmrg else 50054cd6a3aeSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 50064cd6a3aeSmrg fi 50078c9fbc29Smrg 50084cd6a3aeSmrg if test -f "$nlist"S; then 50094cd6a3aeSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50104cd6a3aeSmrg else 50114cd6a3aeSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50124cd6a3aeSmrg fi 50138c9fbc29Smrg 501454044362Smrg func_show_eval '$RM "${nlist}I"' 501554044362Smrg if test -n "$global_symbol_to_import"; then 501654044362Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 501754044362Smrg fi 501854044362Smrg 50194cd6a3aeSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50204cd6a3aeSmrg 50214cd6a3aeSmrg/* The mapping between symbol names and symbols. */ 50224cd6a3aeSmrgtypedef struct { 50234cd6a3aeSmrg const char *name; 50244cd6a3aeSmrg void *address; 50254cd6a3aeSmrg} lt_dlsymlist; 50264cd6a3aeSmrgextern LT_DLSYM_CONST lt_dlsymlist 502754044362Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 502854044362Smrg" 502954044362Smrg 503054044362Smrg if test -s "$nlist"I; then 503154044362Smrg echo >> "$output_objdir/$my_dlsyms" "\ 503254044362Smrgstatic void lt_syminit(void) 503354044362Smrg{ 503454044362Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 503554044362Smrg for (; symbol->name; ++symbol) 503654044362Smrg {" 503754044362Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 503854044362Smrg echo >> "$output_objdir/$my_dlsyms" "\ 503954044362Smrg } 504054044362Smrg}" 504154044362Smrg fi 504254044362Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50434cd6a3aeSmrgLT_DLSYM_CONST lt_dlsymlist 50444cd6a3aeSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 504554044362Smrg{ {\"$my_originator\", (void *) 0}," 504654044362Smrg 504754044362Smrg if test -s "$nlist"I; then 504854044362Smrg echo >> "$output_objdir/$my_dlsyms" "\ 504954044362Smrg {\"@INIT@\", (void *) <_syminit}," 505054044362Smrg fi 50514cd6a3aeSmrg 50524cd6a3aeSmrg case $need_lib_prefix in 50534cd6a3aeSmrg no) 50544cd6a3aeSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50558c9fbc29Smrg ;; 50568c9fbc29Smrg *) 50574cd6a3aeSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50588c9fbc29Smrg ;; 50598c9fbc29Smrg esac 50604cd6a3aeSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50614cd6a3aeSmrg {0, (void *) 0} 50624cd6a3aeSmrg}; 50638c9fbc29Smrg 50644cd6a3aeSmrg/* This works around a problem in FreeBSD linker */ 50654cd6a3aeSmrg#ifdef FREEBSD_WORKAROUND 50664cd6a3aeSmrgstatic const void *lt_preloaded_setup() { 50674cd6a3aeSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 50684cd6a3aeSmrg} 50694cd6a3aeSmrg#endif 50708c9fbc29Smrg 50714cd6a3aeSmrg#ifdef __cplusplus 50724cd6a3aeSmrg} 50734cd6a3aeSmrg#endif\ 50744cd6a3aeSmrg" 50754cd6a3aeSmrg } # !$opt_dry_run 50768c9fbc29Smrg 50774cd6a3aeSmrg pic_flag_for_symtable= 50784cd6a3aeSmrg case "$compile_command " in 50794cd6a3aeSmrg *" -static "*) ;; 50804cd6a3aeSmrg *) 50814cd6a3aeSmrg case $host in 50824cd6a3aeSmrg # compiling the symbol table file with pic_flag works around 50834cd6a3aeSmrg # a FreeBSD bug that causes programs to crash when -lm is 50844cd6a3aeSmrg # linked before any other PIC object. But we must not use 50854cd6a3aeSmrg # pic_flag when linking with -static. The problem exists in 50864cd6a3aeSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 508770728a38Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 50884cd6a3aeSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 50894cd6a3aeSmrg *-*-hpux*) 50904cd6a3aeSmrg pic_flag_for_symtable=" $pic_flag" ;; 50914cd6a3aeSmrg *) 509254044362Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 50934cd6a3aeSmrg ;; 50944cd6a3aeSmrg esac 50954cd6a3aeSmrg ;; 50964cd6a3aeSmrg esac 50974cd6a3aeSmrg symtab_cflags= 50984cd6a3aeSmrg for arg in $LTCFLAGS; do 50994cd6a3aeSmrg case $arg in 51004cd6a3aeSmrg -pie | -fpie | -fPIE) ;; 51014cd6a3aeSmrg *) func_append symtab_cflags " $arg" ;; 51028c9fbc29Smrg esac 51038c9fbc29Smrg done 51048c9fbc29Smrg 51054cd6a3aeSmrg # Now compile the dynamic symbol file. 51064cd6a3aeSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51078c9fbc29Smrg 51084cd6a3aeSmrg # Clean up the generated files. 510954044362Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51108c9fbc29Smrg 51114cd6a3aeSmrg # Transform the symbol file into the correct name. 511254044362Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 51134cd6a3aeSmrg case $host in 51144cd6a3aeSmrg *cygwin* | *mingw* | *cegcc* ) 51154cd6a3aeSmrg if test -f "$output_objdir/$my_outputname.def"; then 51164cd6a3aeSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51174cd6a3aeSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51184cd6a3aeSmrg else 51194cd6a3aeSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51204cd6a3aeSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51214cd6a3aeSmrg fi 51224cd6a3aeSmrg ;; 51234cd6a3aeSmrg *) 51244cd6a3aeSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51254cd6a3aeSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51264cd6a3aeSmrg ;; 51274cd6a3aeSmrg esac 51284cd6a3aeSmrg ;; 51294cd6a3aeSmrg *) 513054044362Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 51314cd6a3aeSmrg ;; 51324cd6a3aeSmrg esac 51334cd6a3aeSmrg else 51344cd6a3aeSmrg # We keep going just in case the user didn't refer to 51354cd6a3aeSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 51364cd6a3aeSmrg # really was required. 51378c9fbc29Smrg 51384cd6a3aeSmrg # Nullify the symbol file. 51394cd6a3aeSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 51404cd6a3aeSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51414cd6a3aeSmrg fi 51424cd6a3aeSmrg} 51438c9fbc29Smrg 514454044362Smrg# func_cygming_gnu_implib_p ARG 514554044362Smrg# This predicate returns with zero status (TRUE) if 514654044362Smrg# ARG is a GNU/binutils-style import library. Returns 514754044362Smrg# with nonzero status (FALSE) otherwise. 514854044362Smrgfunc_cygming_gnu_implib_p () 514954044362Smrg{ 515054044362Smrg $debug_cmd 515154044362Smrg 515254044362Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 515354044362Smrg 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)$'` 515454044362Smrg test -n "$func_cygming_gnu_implib_tmp" 515554044362Smrg} 515654044362Smrg 515754044362Smrg# func_cygming_ms_implib_p ARG 515854044362Smrg# This predicate returns with zero status (TRUE) if 515954044362Smrg# ARG is an MS-style import library. Returns 516054044362Smrg# with nonzero status (FALSE) otherwise. 516154044362Smrgfunc_cygming_ms_implib_p () 516254044362Smrg{ 516354044362Smrg $debug_cmd 516454044362Smrg 516554044362Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 516654044362Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 516754044362Smrg test -n "$func_cygming_ms_implib_tmp" 516854044362Smrg} 516954044362Smrg 51704cd6a3aeSmrg# func_win32_libid arg 51714cd6a3aeSmrg# return the library type of file 'arg' 51724cd6a3aeSmrg# 51734cd6a3aeSmrg# Need a lot of goo to handle *both* DLLs and import libs 51744cd6a3aeSmrg# Has to be a shell function in order to 'eat' the argument 51754cd6a3aeSmrg# that is supplied when $file_magic_command is called. 51764cd6a3aeSmrg# Despite the name, also deal with 64 bit binaries. 51774cd6a3aeSmrgfunc_win32_libid () 51784cd6a3aeSmrg{ 517954044362Smrg $debug_cmd 518054044362Smrg 518154044362Smrg win32_libid_type=unknown 51824cd6a3aeSmrg win32_fileres=`file -L $1 2>/dev/null` 51834cd6a3aeSmrg case $win32_fileres in 51844cd6a3aeSmrg *ar\ archive\ import\ library*) # definitely import 51854cd6a3aeSmrg win32_libid_type="x86 archive import" 51864cd6a3aeSmrg ;; 51874cd6a3aeSmrg *ar\ archive*) # could be an import, or static 51884cd6a3aeSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 51894cd6a3aeSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 51904cd6a3aeSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 519154044362Smrg case $nm_interface in 519254044362Smrg "MS dumpbin") 519354044362Smrg if func_cygming_ms_implib_p "$1" || 519454044362Smrg func_cygming_gnu_implib_p "$1" 519554044362Smrg then 519654044362Smrg win32_nmres=import 519754044362Smrg else 519854044362Smrg win32_nmres= 519954044362Smrg fi 520054044362Smrg ;; 520154044362Smrg *) 520254044362Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 520354044362Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 520454044362Smrg $SED -n -e ' 52054cd6a3aeSmrg 1,100{ 52064cd6a3aeSmrg / I /{ 520754044362Smrg s|.*|import| 52084cd6a3aeSmrg p 52094cd6a3aeSmrg q 52104cd6a3aeSmrg } 52114cd6a3aeSmrg }'` 521254044362Smrg ;; 521354044362Smrg esac 52144cd6a3aeSmrg case $win32_nmres in 52154cd6a3aeSmrg import*) win32_libid_type="x86 archive import";; 52164cd6a3aeSmrg *) win32_libid_type="x86 archive static";; 52174cd6a3aeSmrg esac 52184cd6a3aeSmrg fi 52194cd6a3aeSmrg ;; 52204cd6a3aeSmrg *DLL*) 52214cd6a3aeSmrg win32_libid_type="x86 DLL" 52224cd6a3aeSmrg ;; 52234cd6a3aeSmrg *executable*) # but shell scripts are "executable" too... 52244cd6a3aeSmrg case $win32_fileres in 52254cd6a3aeSmrg *MS\ Windows\ PE\ Intel*) 52264cd6a3aeSmrg win32_libid_type="x86 DLL" 52274cd6a3aeSmrg ;; 52284cd6a3aeSmrg esac 52294cd6a3aeSmrg ;; 52304cd6a3aeSmrg esac 52314cd6a3aeSmrg $ECHO "$win32_libid_type" 52324cd6a3aeSmrg} 52334cd6a3aeSmrg 52344cd6a3aeSmrg# func_cygming_dll_for_implib ARG 52354cd6a3aeSmrg# 52364cd6a3aeSmrg# Platform-specific function to extract the 52374cd6a3aeSmrg# name of the DLL associated with the specified 52384cd6a3aeSmrg# import library ARG. 52394cd6a3aeSmrg# Invoked by eval'ing the libtool variable 52404cd6a3aeSmrg# $sharedlib_from_linklib_cmd 52414cd6a3aeSmrg# Result is available in the variable 52424cd6a3aeSmrg# $sharedlib_from_linklib_result 52434cd6a3aeSmrgfunc_cygming_dll_for_implib () 52444cd6a3aeSmrg{ 524554044362Smrg $debug_cmd 524654044362Smrg 52474cd6a3aeSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 52484cd6a3aeSmrg} 52494cd6a3aeSmrg 52504cd6a3aeSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 52514cd6a3aeSmrg# 52524cd6a3aeSmrg# The is the core of a fallback implementation of a 52534cd6a3aeSmrg# platform-specific function to extract the name of the 52544cd6a3aeSmrg# DLL associated with the specified import library LIBNAME. 52554cd6a3aeSmrg# 52564cd6a3aeSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 52574cd6a3aeSmrg# on the platform and compiler that created the implib. 52584cd6a3aeSmrg# 52594cd6a3aeSmrg# Echos the name of the DLL associated with the 52604cd6a3aeSmrg# specified import library. 52614cd6a3aeSmrgfunc_cygming_dll_for_implib_fallback_core () 52624cd6a3aeSmrg{ 526354044362Smrg $debug_cmd 526454044362Smrg 52654cd6a3aeSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 52664cd6a3aeSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 52674cd6a3aeSmrg $SED '/^Contents of section '"$match_literal"':/{ 52684cd6a3aeSmrg # Place marker at beginning of archive member dllname section 52694cd6a3aeSmrg s/.*/====MARK====/ 52704cd6a3aeSmrg p 52714cd6a3aeSmrg d 52724cd6a3aeSmrg } 52734cd6a3aeSmrg # These lines can sometimes be longer than 43 characters, but 52744cd6a3aeSmrg # are always uninteresting 52754cd6a3aeSmrg /:[ ]*file format pe[i]\{,1\}-/d 52764cd6a3aeSmrg /^In archive [^:]*:/d 52774cd6a3aeSmrg # Ensure marker is printed 52784cd6a3aeSmrg /^====MARK====/p 52794cd6a3aeSmrg # Remove all lines with less than 43 characters 52804cd6a3aeSmrg /^.\{43\}/!d 52814cd6a3aeSmrg # From remaining lines, remove first 43 characters 52824cd6a3aeSmrg s/^.\{43\}//' | 52834cd6a3aeSmrg $SED -n ' 52844cd6a3aeSmrg # Join marker and all lines until next marker into a single line 52854cd6a3aeSmrg /^====MARK====/ b para 52864cd6a3aeSmrg H 52874cd6a3aeSmrg $ b para 52884cd6a3aeSmrg b 52894cd6a3aeSmrg :para 52904cd6a3aeSmrg x 52914cd6a3aeSmrg s/\n//g 52924cd6a3aeSmrg # Remove the marker 52934cd6a3aeSmrg s/^====MARK====// 52944cd6a3aeSmrg # Remove trailing dots and whitespace 52954cd6a3aeSmrg s/[\. \t]*$// 52964cd6a3aeSmrg # Print 52974cd6a3aeSmrg /./p' | 52984cd6a3aeSmrg # we now have a list, one entry per line, of the stringified 52994cd6a3aeSmrg # contents of the appropriate section of all members of the 530054044362Smrg # archive that possess that section. Heuristic: eliminate 530154044362Smrg # all those that have a first or second character that is 53024cd6a3aeSmrg # a '.' (that is, objdump's representation of an unprintable 53034cd6a3aeSmrg # character.) This should work for all archives with less than 53044cd6a3aeSmrg # 0x302f exports -- but will fail for DLLs whose name actually 53054cd6a3aeSmrg # begins with a literal '.' or a single character followed by 53064cd6a3aeSmrg # a '.'. 53074cd6a3aeSmrg # 53084cd6a3aeSmrg # Of those that remain, print the first one. 53094cd6a3aeSmrg $SED -e '/^\./d;/^.\./d;q' 53104cd6a3aeSmrg} 53114cd6a3aeSmrg 53124cd6a3aeSmrg# func_cygming_dll_for_implib_fallback ARG 53134cd6a3aeSmrg# Platform-specific function to extract the 53144cd6a3aeSmrg# name of the DLL associated with the specified 53154cd6a3aeSmrg# import library ARG. 53164cd6a3aeSmrg# 53174cd6a3aeSmrg# This fallback implementation is for use when $DLLTOOL 53184cd6a3aeSmrg# does not support the --identify-strict option. 53194cd6a3aeSmrg# Invoked by eval'ing the libtool variable 53204cd6a3aeSmrg# $sharedlib_from_linklib_cmd 53214cd6a3aeSmrg# Result is available in the variable 53224cd6a3aeSmrg# $sharedlib_from_linklib_result 53234cd6a3aeSmrgfunc_cygming_dll_for_implib_fallback () 53244cd6a3aeSmrg{ 532554044362Smrg $debug_cmd 532654044362Smrg 532754044362Smrg if func_cygming_gnu_implib_p "$1"; then 53284cd6a3aeSmrg # binutils import library 53294cd6a3aeSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 533054044362Smrg elif func_cygming_ms_implib_p "$1"; then 53314cd6a3aeSmrg # ms-generated import library 53324cd6a3aeSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 53334cd6a3aeSmrg else 53344cd6a3aeSmrg # unknown 533554044362Smrg sharedlib_from_linklib_result= 53364cd6a3aeSmrg fi 53374cd6a3aeSmrg} 53384cd6a3aeSmrg 53394cd6a3aeSmrg 53404cd6a3aeSmrg# func_extract_an_archive dir oldlib 53414cd6a3aeSmrgfunc_extract_an_archive () 53424cd6a3aeSmrg{ 534354044362Smrg $debug_cmd 534454044362Smrg 534554044362Smrg f_ex_an_ar_dir=$1; shift 534654044362Smrg f_ex_an_ar_oldlib=$1 534754044362Smrg if test yes = "$lock_old_archive_extraction"; then 53484cd6a3aeSmrg lockfile=$f_ex_an_ar_oldlib.lock 53494cd6a3aeSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 53504cd6a3aeSmrg func_echo "Waiting for $lockfile to be removed" 53514cd6a3aeSmrg sleep 2 53528c9fbc29Smrg done 53534cd6a3aeSmrg fi 53544cd6a3aeSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 53554cd6a3aeSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 535654044362Smrg if test yes = "$lock_old_archive_extraction"; then 53574cd6a3aeSmrg $opt_dry_run || rm -f "$lockfile" 53584cd6a3aeSmrg fi 53594cd6a3aeSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 53604cd6a3aeSmrg : 53614cd6a3aeSmrg else 53624cd6a3aeSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 53634cd6a3aeSmrg fi 53644cd6a3aeSmrg} 53658c9fbc29Smrg 53664cd6a3aeSmrg 53674cd6a3aeSmrg# func_extract_archives gentop oldlib ... 53684cd6a3aeSmrgfunc_extract_archives () 53694cd6a3aeSmrg{ 537054044362Smrg $debug_cmd 537154044362Smrg 537254044362Smrg my_gentop=$1; shift 53734cd6a3aeSmrg my_oldlibs=${1+"$@"} 537454044362Smrg my_oldobjs= 537554044362Smrg my_xlib= 537654044362Smrg my_xabs= 537754044362Smrg my_xdir= 53784cd6a3aeSmrg 53794cd6a3aeSmrg for my_xlib in $my_oldlibs; do 53804cd6a3aeSmrg # Extract the objects. 53814cd6a3aeSmrg case $my_xlib in 538254044362Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 53834cd6a3aeSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 53844cd6a3aeSmrg esac 53854cd6a3aeSmrg func_basename "$my_xlib" 538654044362Smrg my_xlib=$func_basename_result 53874cd6a3aeSmrg my_xlib_u=$my_xlib 53884cd6a3aeSmrg while :; do 53894cd6a3aeSmrg case " $extracted_archives " in 53904cd6a3aeSmrg *" $my_xlib_u "*) 53914cd6a3aeSmrg func_arith $extracted_serial + 1 53924cd6a3aeSmrg extracted_serial=$func_arith_result 53934cd6a3aeSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 53944cd6a3aeSmrg *) break ;; 53958c9fbc29Smrg esac 53968c9fbc29Smrg done 53974cd6a3aeSmrg extracted_archives="$extracted_archives $my_xlib_u" 539854044362Smrg my_xdir=$my_gentop/$my_xlib_u 53998c9fbc29Smrg 54004cd6a3aeSmrg func_mkdir_p "$my_xdir" 54018c9fbc29Smrg 54024cd6a3aeSmrg case $host in 54034cd6a3aeSmrg *-darwin*) 54044cd6a3aeSmrg func_verbose "Extracting $my_xabs" 54054cd6a3aeSmrg # Do not bother doing anything if just a dry run 54064cd6a3aeSmrg $opt_dry_run || { 54074cd6a3aeSmrg darwin_orig_dir=`pwd` 54084cd6a3aeSmrg cd $my_xdir || exit $? 54094cd6a3aeSmrg darwin_archive=$my_xabs 54104cd6a3aeSmrg darwin_curdir=`pwd` 541154044362Smrg func_basename "$darwin_archive" 541254044362Smrg darwin_base_archive=$func_basename_result 54134cd6a3aeSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 54144cd6a3aeSmrg if test -n "$darwin_arches"; then 54154cd6a3aeSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 54164cd6a3aeSmrg darwin_arch= 54174cd6a3aeSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 541854044362Smrg for darwin_arch in $darwin_arches; do 541954044362Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 542054044362Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 542154044362Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 542254044362Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 54234cd6a3aeSmrg cd "$darwin_curdir" 542454044362Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 54254cd6a3aeSmrg done # $darwin_arches 54264cd6a3aeSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 542754044362Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 54284cd6a3aeSmrg darwin_file= 54294cd6a3aeSmrg darwin_files= 54304cd6a3aeSmrg for darwin_file in $darwin_filelist; do 54314cd6a3aeSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 54324cd6a3aeSmrg $LIPO -create -output "$darwin_file" $darwin_files 54334cd6a3aeSmrg done # $darwin_filelist 54344cd6a3aeSmrg $RM -rf unfat-$$ 54354cd6a3aeSmrg cd "$darwin_orig_dir" 54368c9fbc29Smrg else 54374cd6a3aeSmrg cd $darwin_orig_dir 54384cd6a3aeSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 54394cd6a3aeSmrg fi # $darwin_arches 54404cd6a3aeSmrg } # !$opt_dry_run 54414cd6a3aeSmrg ;; 54424cd6a3aeSmrg *) 54434cd6a3aeSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 54444cd6a3aeSmrg ;; 54454cd6a3aeSmrg esac 54464cd6a3aeSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 54474cd6a3aeSmrg done 54488c9fbc29Smrg 544954044362Smrg func_extract_archives_result=$my_oldobjs 54504cd6a3aeSmrg} 54518c9fbc29Smrg 54528c9fbc29Smrg 54534cd6a3aeSmrg# func_emit_wrapper [arg=no] 54544cd6a3aeSmrg# 54554cd6a3aeSmrg# Emit a libtool wrapper script on stdout. 54564cd6a3aeSmrg# Don't directly open a file because we may want to 54574cd6a3aeSmrg# incorporate the script contents within a cygwin/mingw 54584cd6a3aeSmrg# wrapper executable. Must ONLY be called from within 54594cd6a3aeSmrg# func_mode_link because it depends on a number of variables 54604cd6a3aeSmrg# set therein. 54614cd6a3aeSmrg# 54624cd6a3aeSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 54634cd6a3aeSmrg# variable will take. If 'yes', then the emitted script 546454044362Smrg# will assume that the directory where it is stored is 54654cd6a3aeSmrg# the $objdir directory. This is a cygwin/mingw-specific 54664cd6a3aeSmrg# behavior. 54674cd6a3aeSmrgfunc_emit_wrapper () 54684cd6a3aeSmrg{ 54694cd6a3aeSmrg func_emit_wrapper_arg1=${1-no} 54708c9fbc29Smrg 54714cd6a3aeSmrg $ECHO "\ 54724cd6a3aeSmrg#! $SHELL 54738c9fbc29Smrg 54744cd6a3aeSmrg# $output - temporary wrapper script for $objdir/$outputname 547554044362Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 54764cd6a3aeSmrg# 54774cd6a3aeSmrg# The $output program cannot be directly executed until all the libtool 54784cd6a3aeSmrg# libraries that it depends on are installed. 54794cd6a3aeSmrg# 54804cd6a3aeSmrg# This wrapper script should never be moved out of the build directory. 54814cd6a3aeSmrg# If it is, it will not operate correctly. 54828c9fbc29Smrg 54834cd6a3aeSmrg# Sed substitution that helps us do robust quoting. It backslashifies 54844cd6a3aeSmrg# metacharacters that are still active within double-quoted strings. 54854cd6a3aeSmrgsed_quote_subst='$sed_quote_subst' 54868c9fbc29Smrg 54874cd6a3aeSmrg# Be Bourne compatible 54884cd6a3aeSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 54894cd6a3aeSmrg emulate sh 54904cd6a3aeSmrg NULLCMD=: 54914cd6a3aeSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 54924cd6a3aeSmrg # is contrary to our usage. Disable this feature. 54934cd6a3aeSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 54944cd6a3aeSmrg setopt NO_GLOB_SUBST 54954cd6a3aeSmrgelse 54964cd6a3aeSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 54974cd6a3aeSmrgfi 54984cd6a3aeSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 54994cd6a3aeSmrgDUALCASE=1; export DUALCASE # for MKS sh 55008c9fbc29Smrg 55014cd6a3aeSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 55024cd6a3aeSmrg# if CDPATH is set. 55034cd6a3aeSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55048c9fbc29Smrg 55054cd6a3aeSmrgrelink_command=\"$relink_command\" 55068c9fbc29Smrg 55074cd6a3aeSmrg# This environment variable determines our operation mode. 55084cd6a3aeSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 55094cd6a3aeSmrg # install mode needs the following variables: 55104cd6a3aeSmrg generated_by_libtool_version='$macro_version' 55114cd6a3aeSmrg notinst_deplibs='$notinst_deplibs' 55124cd6a3aeSmrgelse 55134cd6a3aeSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 55144cd6a3aeSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 55154cd6a3aeSmrg file=\"\$0\"" 55168c9fbc29Smrg 551754cef2ddSmrg func_quote_arg pretty "$ECHO" 551854cef2ddSmrg qECHO=$func_quote_arg_result 55194cd6a3aeSmrg $ECHO "\ 55208c9fbc29Smrg 55214cd6a3aeSmrg# A function that is used when there is no print builtin or printf. 55224cd6a3aeSmrgfunc_fallback_echo () 55234cd6a3aeSmrg{ 55244cd6a3aeSmrg eval 'cat <<_LTECHO_EOF 55254cd6a3aeSmrg\$1 55264cd6a3aeSmrg_LTECHO_EOF' 55274cd6a3aeSmrg} 552854cef2ddSmrg ECHO=$qECHO 55294cd6a3aeSmrg fi 55308c9fbc29Smrg 55314cd6a3aeSmrg# Very basic option parsing. These options are (a) specific to 55324cd6a3aeSmrg# the libtool wrapper, (b) are identical between the wrapper 553354044362Smrg# /script/ and the wrapper /executable/ that is used only on 55344cd6a3aeSmrg# windows platforms, and (c) all begin with the string "--lt-" 553554044362Smrg# (application programs are unlikely to have options that match 55364cd6a3aeSmrg# this pattern). 55374cd6a3aeSmrg# 55384cd6a3aeSmrg# There are only two supported options: --lt-debug and 55394cd6a3aeSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 55404cd6a3aeSmrg# 55414cd6a3aeSmrg# The first argument to this parsing function should be the 55424cd6a3aeSmrg# script's $0 value, followed by "$@". 55434cd6a3aeSmrglt_option_debug= 55444cd6a3aeSmrgfunc_parse_lt_options () 55454cd6a3aeSmrg{ 55464cd6a3aeSmrg lt_script_arg0=\$0 55474cd6a3aeSmrg shift 55484cd6a3aeSmrg for lt_opt 55494cd6a3aeSmrg do 55504cd6a3aeSmrg case \"\$lt_opt\" in 55514cd6a3aeSmrg --lt-debug) lt_option_debug=1 ;; 55524cd6a3aeSmrg --lt-dump-script) 55534cd6a3aeSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 55544cd6a3aeSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 55554cd6a3aeSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 55564cd6a3aeSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 55574cd6a3aeSmrg exit 0 55584cd6a3aeSmrg ;; 55594cd6a3aeSmrg --lt-*) 55604cd6a3aeSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 55614cd6a3aeSmrg exit 1 55624cd6a3aeSmrg ;; 55634cd6a3aeSmrg esac 55644cd6a3aeSmrg done 55658c9fbc29Smrg 55664cd6a3aeSmrg # Print the debug banner immediately: 55674cd6a3aeSmrg if test -n \"\$lt_option_debug\"; then 556854044362Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 55694cd6a3aeSmrg fi 55704cd6a3aeSmrg} 55718c9fbc29Smrg 55724cd6a3aeSmrg# Used when --lt-debug. Prints its arguments to stdout 55734cd6a3aeSmrg# (redirection is the responsibility of the caller) 55744cd6a3aeSmrgfunc_lt_dump_args () 55754cd6a3aeSmrg{ 55764cd6a3aeSmrg lt_dump_args_N=1; 55774cd6a3aeSmrg for lt_arg 55784cd6a3aeSmrg do 557954044362Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 55804cd6a3aeSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 55814cd6a3aeSmrg done 55824cd6a3aeSmrg} 55838c9fbc29Smrg 55844cd6a3aeSmrg# Core function for launching the target application 55854cd6a3aeSmrgfunc_exec_program_core () 55864cd6a3aeSmrg{ 55874cd6a3aeSmrg" 55884cd6a3aeSmrg case $host in 55894cd6a3aeSmrg # Backslashes separate directories on plain windows 55904cd6a3aeSmrg *-*-mingw | *-*-os2* | *-cegcc*) 55914cd6a3aeSmrg $ECHO "\ 55924cd6a3aeSmrg if test -n \"\$lt_option_debug\"; then 559354044362Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 55944cd6a3aeSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55954cd6a3aeSmrg fi 55964cd6a3aeSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 55974cd6a3aeSmrg" 55984cd6a3aeSmrg ;; 55998c9fbc29Smrg 56004cd6a3aeSmrg *) 56014cd6a3aeSmrg $ECHO "\ 56024cd6a3aeSmrg if test -n \"\$lt_option_debug\"; then 560354044362Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 56044cd6a3aeSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 56054cd6a3aeSmrg fi 56064cd6a3aeSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 56074cd6a3aeSmrg" 56084cd6a3aeSmrg ;; 56094cd6a3aeSmrg esac 56104cd6a3aeSmrg $ECHO "\ 56114cd6a3aeSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 56124cd6a3aeSmrg exit 1 56134cd6a3aeSmrg} 56148c9fbc29Smrg 56154cd6a3aeSmrg# A function to encapsulate launching the target application 56164cd6a3aeSmrg# Strips options in the --lt-* namespace from \$@ and 56174cd6a3aeSmrg# launches target application with the remaining arguments. 56184cd6a3aeSmrgfunc_exec_program () 56194cd6a3aeSmrg{ 562070728a38Smrg case \" \$* \" in 562170728a38Smrg *\\ --lt-*) 562270728a38Smrg for lt_wr_arg 562370728a38Smrg do 562470728a38Smrg case \$lt_wr_arg in 562570728a38Smrg --lt-*) ;; 562670728a38Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 562770728a38Smrg esac 562870728a38Smrg shift 562970728a38Smrg done ;; 563070728a38Smrg esac 56314cd6a3aeSmrg func_exec_program_core \${1+\"\$@\"} 56324cd6a3aeSmrg} 56338c9fbc29Smrg 56344cd6a3aeSmrg # Parse options 56354cd6a3aeSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56368c9fbc29Smrg 56374cd6a3aeSmrg # Find the directory that this script lives in. 56384cd6a3aeSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 56394cd6a3aeSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56408c9fbc29Smrg 56414cd6a3aeSmrg # Follow symbolic links until we get to the real thisdir. 56424cd6a3aeSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 56434cd6a3aeSmrg while test -n \"\$file\"; do 56444cd6a3aeSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56458c9fbc29Smrg 56464cd6a3aeSmrg # If there was a directory component, then change thisdir. 56474cd6a3aeSmrg if test \"x\$destdir\" != \"x\$file\"; then 56484cd6a3aeSmrg case \"\$destdir\" in 56494cd6a3aeSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 56504cd6a3aeSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 56514cd6a3aeSmrg esac 56524cd6a3aeSmrg fi 56538c9fbc29Smrg 56544cd6a3aeSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 56554cd6a3aeSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 56564cd6a3aeSmrg done 56578c9fbc29Smrg 56584cd6a3aeSmrg # Usually 'no', except on cygwin/mingw when embedded into 56594cd6a3aeSmrg # the cwrapper. 56604cd6a3aeSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 56614cd6a3aeSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 56624cd6a3aeSmrg # special case for '.' 56634cd6a3aeSmrg if test \"\$thisdir\" = \".\"; then 56644cd6a3aeSmrg thisdir=\`pwd\` 56654cd6a3aeSmrg fi 56664cd6a3aeSmrg # remove .libs from thisdir 56674cd6a3aeSmrg case \"\$thisdir\" in 56684cd6a3aeSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 56694cd6a3aeSmrg $objdir ) thisdir=. ;; 56704cd6a3aeSmrg esac 56714cd6a3aeSmrg fi 56728c9fbc29Smrg 56734cd6a3aeSmrg # Try to get the absolute directory name. 56744cd6a3aeSmrg absdir=\`cd \"\$thisdir\" && pwd\` 56754cd6a3aeSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 56764cd6a3aeSmrg" 56778c9fbc29Smrg 567854044362Smrg if test yes = "$fast_install"; then 56794cd6a3aeSmrg $ECHO "\ 56804cd6a3aeSmrg program=lt-'$outputname'$exeext 56814cd6a3aeSmrg progdir=\"\$thisdir/$objdir\" 56828c9fbc29Smrg 56834cd6a3aeSmrg if test ! -f \"\$progdir/\$program\" || 568454044362Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 56854cd6a3aeSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56868c9fbc29Smrg 56874cd6a3aeSmrg file=\"\$\$-\$program\" 56888c9fbc29Smrg 56894cd6a3aeSmrg if test ! -d \"\$progdir\"; then 56904cd6a3aeSmrg $MKDIR \"\$progdir\" 56914cd6a3aeSmrg else 56924cd6a3aeSmrg $RM \"\$progdir/\$file\" 56934cd6a3aeSmrg fi" 56948c9fbc29Smrg 56954cd6a3aeSmrg $ECHO "\ 56968c9fbc29Smrg 56974cd6a3aeSmrg # relink executable if necessary 56984cd6a3aeSmrg if test -n \"\$relink_command\"; then 56994cd6a3aeSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 57004cd6a3aeSmrg else 570154044362Smrg \$ECHO \"\$relink_command_output\" >&2 57024cd6a3aeSmrg $RM \"\$progdir/\$file\" 57034cd6a3aeSmrg exit 1 57044cd6a3aeSmrg fi 57054cd6a3aeSmrg fi 57068c9fbc29Smrg 57074cd6a3aeSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 57084cd6a3aeSmrg { $RM \"\$progdir/\$program\"; 57094cd6a3aeSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 57104cd6a3aeSmrg $RM \"\$progdir/\$file\" 57114cd6a3aeSmrg fi" 57124cd6a3aeSmrg else 57134cd6a3aeSmrg $ECHO "\ 57144cd6a3aeSmrg program='$outputname' 57154cd6a3aeSmrg progdir=\"\$thisdir/$objdir\" 57164cd6a3aeSmrg" 57178c9fbc29Smrg fi 57188c9fbc29Smrg 57194cd6a3aeSmrg $ECHO "\ 57208c9fbc29Smrg 57214cd6a3aeSmrg if test -f \"\$progdir/\$program\"; then" 57228c9fbc29Smrg 57234cd6a3aeSmrg # fixup the dll searchpath if we need to. 57244cd6a3aeSmrg # 57254cd6a3aeSmrg # Fix the DLL searchpath if we need to. Do this before prepending 57264cd6a3aeSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 57274cd6a3aeSmrg # libraries must come first. 57284cd6a3aeSmrg if test -n "$dllsearchpath"; then 57294cd6a3aeSmrg $ECHO "\ 57304cd6a3aeSmrg # Add the dll search path components to the executable PATH 57314cd6a3aeSmrg PATH=$dllsearchpath:\$PATH 57324cd6a3aeSmrg" 57334cd6a3aeSmrg fi 57348c9fbc29Smrg 57354cd6a3aeSmrg # Export our shlibpath_var if we have one. 573654044362Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 57374cd6a3aeSmrg $ECHO "\ 57384cd6a3aeSmrg # Add our own library path to $shlibpath_var 57394cd6a3aeSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57408c9fbc29Smrg 57414cd6a3aeSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 57424cd6a3aeSmrg # The second colon is a workaround for a bug in BeOS R4 sed 57434cd6a3aeSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57448c9fbc29Smrg 57454cd6a3aeSmrg export $shlibpath_var 57464cd6a3aeSmrg" 57474cd6a3aeSmrg fi 57488c9fbc29Smrg 57494cd6a3aeSmrg $ECHO "\ 57504cd6a3aeSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 57514cd6a3aeSmrg # Run the actual program with our arguments. 57524cd6a3aeSmrg func_exec_program \${1+\"\$@\"} 57534cd6a3aeSmrg fi 57544cd6a3aeSmrg else 57554cd6a3aeSmrg # The program doesn't exist. 575654044362Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 57574cd6a3aeSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 57584cd6a3aeSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 57594cd6a3aeSmrg exit 1 57604cd6a3aeSmrg fi 57614cd6a3aeSmrgfi\ 57624cd6a3aeSmrg" 57634cd6a3aeSmrg} 57648c9fbc29Smrg 57658c9fbc29Smrg 57664cd6a3aeSmrg# func_emit_cwrapperexe_src 57674cd6a3aeSmrg# emit the source code for a wrapper executable on stdout 57684cd6a3aeSmrg# Must ONLY be called from within func_mode_link because 57694cd6a3aeSmrg# it depends on a number of variable set therein. 57704cd6a3aeSmrgfunc_emit_cwrapperexe_src () 57714cd6a3aeSmrg{ 57724cd6a3aeSmrg cat <<EOF 57738c9fbc29Smrg 57744cd6a3aeSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 577554044362Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57768c9fbc29Smrg 57774cd6a3aeSmrg The $output program cannot be directly executed until all the libtool 57784cd6a3aeSmrg libraries that it depends on are installed. 57798c9fbc29Smrg 57804cd6a3aeSmrg This wrapper executable should never be moved out of the build directory. 57814cd6a3aeSmrg If it is, it will not operate correctly. 57824cd6a3aeSmrg*/ 57834cd6a3aeSmrgEOF 57844cd6a3aeSmrg cat <<"EOF" 57854cd6a3aeSmrg#ifdef _MSC_VER 57864cd6a3aeSmrg# define _CRT_SECURE_NO_DEPRECATE 1 57874cd6a3aeSmrg#endif 57884cd6a3aeSmrg#include <stdio.h> 57894cd6a3aeSmrg#include <stdlib.h> 57904cd6a3aeSmrg#ifdef _MSC_VER 57914cd6a3aeSmrg# include <direct.h> 57924cd6a3aeSmrg# include <process.h> 57934cd6a3aeSmrg# include <io.h> 57944cd6a3aeSmrg#else 57954cd6a3aeSmrg# include <unistd.h> 57964cd6a3aeSmrg# include <stdint.h> 57974cd6a3aeSmrg# ifdef __CYGWIN__ 57984cd6a3aeSmrg# include <io.h> 57994cd6a3aeSmrg# endif 58004cd6a3aeSmrg#endif 58014cd6a3aeSmrg#include <malloc.h> 58024cd6a3aeSmrg#include <stdarg.h> 58034cd6a3aeSmrg#include <assert.h> 58044cd6a3aeSmrg#include <string.h> 58054cd6a3aeSmrg#include <ctype.h> 58064cd6a3aeSmrg#include <errno.h> 58074cd6a3aeSmrg#include <fcntl.h> 58084cd6a3aeSmrg#include <sys/stat.h> 58098c9fbc29Smrg 581054044362Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 581154044362Smrg 58124cd6a3aeSmrg/* declarations of non-ANSI functions */ 581354044362Smrg#if defined __MINGW32__ 58144cd6a3aeSmrg# ifdef __STRICT_ANSI__ 58154cd6a3aeSmrgint _putenv (const char *); 58164cd6a3aeSmrg# endif 581754044362Smrg#elif defined __CYGWIN__ 58184cd6a3aeSmrg# ifdef __STRICT_ANSI__ 58194cd6a3aeSmrgchar *realpath (const char *, char *); 58204cd6a3aeSmrgint putenv (char *); 58214cd6a3aeSmrgint setenv (const char *, const char *, int); 58224cd6a3aeSmrg# endif 582354044362Smrg/* #elif defined other_platform || defined ... */ 58244cd6a3aeSmrg#endif 58258c9fbc29Smrg 58264cd6a3aeSmrg/* portability defines, excluding path handling macros */ 582754044362Smrg#if defined _MSC_VER 58284cd6a3aeSmrg# define setmode _setmode 58294cd6a3aeSmrg# define stat _stat 58304cd6a3aeSmrg# define chmod _chmod 58314cd6a3aeSmrg# define getcwd _getcwd 58324cd6a3aeSmrg# define putenv _putenv 58334cd6a3aeSmrg# define S_IXUSR _S_IEXEC 583454044362Smrg#elif defined __MINGW32__ 58354cd6a3aeSmrg# define setmode _setmode 58364cd6a3aeSmrg# define stat _stat 58374cd6a3aeSmrg# define chmod _chmod 58384cd6a3aeSmrg# define getcwd _getcwd 58394cd6a3aeSmrg# define putenv _putenv 584054044362Smrg#elif defined __CYGWIN__ 58414cd6a3aeSmrg# define HAVE_SETENV 58424cd6a3aeSmrg# define FOPEN_WB "wb" 584354044362Smrg/* #elif defined other platforms ... */ 58444cd6a3aeSmrg#endif 58458c9fbc29Smrg 584654044362Smrg#if defined PATH_MAX 58474cd6a3aeSmrg# define LT_PATHMAX PATH_MAX 584854044362Smrg#elif defined MAXPATHLEN 58494cd6a3aeSmrg# define LT_PATHMAX MAXPATHLEN 58504cd6a3aeSmrg#else 58514cd6a3aeSmrg# define LT_PATHMAX 1024 58524cd6a3aeSmrg#endif 58538c9fbc29Smrg 58544cd6a3aeSmrg#ifndef S_IXOTH 58554cd6a3aeSmrg# define S_IXOTH 0 58564cd6a3aeSmrg#endif 58574cd6a3aeSmrg#ifndef S_IXGRP 58584cd6a3aeSmrg# define S_IXGRP 0 58594cd6a3aeSmrg#endif 58608c9fbc29Smrg 58614cd6a3aeSmrg/* path handling portability macros */ 58624cd6a3aeSmrg#ifndef DIR_SEPARATOR 58634cd6a3aeSmrg# define DIR_SEPARATOR '/' 58644cd6a3aeSmrg# define PATH_SEPARATOR ':' 58654cd6a3aeSmrg#endif 58668c9fbc29Smrg 586754044362Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 586854044362Smrg defined __OS2__ 58694cd6a3aeSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 58704cd6a3aeSmrg# define FOPEN_WB "wb" 58714cd6a3aeSmrg# ifndef DIR_SEPARATOR_2 58724cd6a3aeSmrg# define DIR_SEPARATOR_2 '\\' 58734cd6a3aeSmrg# endif 58744cd6a3aeSmrg# ifndef PATH_SEPARATOR_2 58754cd6a3aeSmrg# define PATH_SEPARATOR_2 ';' 58764cd6a3aeSmrg# endif 58774cd6a3aeSmrg#endif 58788c9fbc29Smrg 58794cd6a3aeSmrg#ifndef DIR_SEPARATOR_2 58804cd6a3aeSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 58814cd6a3aeSmrg#else /* DIR_SEPARATOR_2 */ 58824cd6a3aeSmrg# define IS_DIR_SEPARATOR(ch) \ 58834cd6a3aeSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 58844cd6a3aeSmrg#endif /* DIR_SEPARATOR_2 */ 58858c9fbc29Smrg 58864cd6a3aeSmrg#ifndef PATH_SEPARATOR_2 58874cd6a3aeSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 58884cd6a3aeSmrg#else /* PATH_SEPARATOR_2 */ 58894cd6a3aeSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 58904cd6a3aeSmrg#endif /* PATH_SEPARATOR_2 */ 58918c9fbc29Smrg 58924cd6a3aeSmrg#ifndef FOPEN_WB 58934cd6a3aeSmrg# define FOPEN_WB "w" 58944cd6a3aeSmrg#endif 58954cd6a3aeSmrg#ifndef _O_BINARY 58964cd6a3aeSmrg# define _O_BINARY 0 58974cd6a3aeSmrg#endif 58988c9fbc29Smrg 58994cd6a3aeSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 59004cd6a3aeSmrg#define XFREE(stale) do { \ 590154044362Smrg if (stale) { free (stale); stale = 0; } \ 59024cd6a3aeSmrg} while (0) 59038c9fbc29Smrg 590454044362Smrg#if defined LT_DEBUGWRAPPER 59054cd6a3aeSmrgstatic int lt_debug = 1; 59064cd6a3aeSmrg#else 59074cd6a3aeSmrgstatic int lt_debug = 0; 59084cd6a3aeSmrg#endif 59098c9fbc29Smrg 59104cd6a3aeSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 59114cd6a3aeSmrg 59124cd6a3aeSmrgvoid *xmalloc (size_t num); 59134cd6a3aeSmrgchar *xstrdup (const char *string); 59144cd6a3aeSmrgconst char *base_name (const char *name); 59154cd6a3aeSmrgchar *find_executable (const char *wrapper); 59164cd6a3aeSmrgchar *chase_symlinks (const char *pathspec); 59174cd6a3aeSmrgint make_executable (const char *path); 59184cd6a3aeSmrgint check_executable (const char *path); 59194cd6a3aeSmrgchar *strendzap (char *str, const char *pat); 59204cd6a3aeSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 59214cd6a3aeSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 59224cd6a3aeSmrgstatic const char *nonnull (const char *s); 59234cd6a3aeSmrgstatic const char *nonempty (const char *s); 59244cd6a3aeSmrgvoid lt_setenv (const char *name, const char *value); 59254cd6a3aeSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 59264cd6a3aeSmrgvoid lt_update_exe_path (const char *name, const char *value); 59274cd6a3aeSmrgvoid lt_update_lib_path (const char *name, const char *value); 59284cd6a3aeSmrgchar **prepare_spawn (char **argv); 59294cd6a3aeSmrgvoid lt_dump_script (FILE *f); 59304cd6a3aeSmrgEOF 59318c9fbc29Smrg 59324cd6a3aeSmrg cat <<EOF 593354044362Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 593454044362Smrg# define externally_visible volatile 593554044362Smrg#else 593654044362Smrg# define externally_visible __attribute__((externally_visible)) volatile 593754044362Smrg#endif 593854044362Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 59394cd6a3aeSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 59404cd6a3aeSmrgEOF 59418c9fbc29Smrg 594254044362Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 59434cd6a3aeSmrg func_to_host_path "$temp_rpath" 59444cd6a3aeSmrg cat <<EOF 59454cd6a3aeSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59464cd6a3aeSmrgEOF 59474cd6a3aeSmrg else 59484cd6a3aeSmrg cat <<"EOF" 59494cd6a3aeSmrgconst char * LIB_PATH_VALUE = ""; 59504cd6a3aeSmrgEOF 59514cd6a3aeSmrg fi 59528c9fbc29Smrg 59534cd6a3aeSmrg if test -n "$dllsearchpath"; then 59544cd6a3aeSmrg func_to_host_path "$dllsearchpath:" 59554cd6a3aeSmrg cat <<EOF 59564cd6a3aeSmrgconst char * EXE_PATH_VARNAME = "PATH"; 59574cd6a3aeSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 59584cd6a3aeSmrgEOF 59594cd6a3aeSmrg else 59604cd6a3aeSmrg cat <<"EOF" 59614cd6a3aeSmrgconst char * EXE_PATH_VARNAME = ""; 59624cd6a3aeSmrgconst char * EXE_PATH_VALUE = ""; 59634cd6a3aeSmrgEOF 59644cd6a3aeSmrg fi 59658c9fbc29Smrg 596654044362Smrg if test yes = "$fast_install"; then 59674cd6a3aeSmrg cat <<EOF 59684cd6a3aeSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 59694cd6a3aeSmrgEOF 59704cd6a3aeSmrg else 59714cd6a3aeSmrg cat <<EOF 59724cd6a3aeSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 59734cd6a3aeSmrgEOF 59744cd6a3aeSmrg fi 59758c9fbc29Smrg 59768c9fbc29Smrg 59774cd6a3aeSmrg cat <<"EOF" 59788c9fbc29Smrg 59794cd6a3aeSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59808c9fbc29Smrg 59814cd6a3aeSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 59824cd6a3aeSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 59834cd6a3aeSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59844cd6a3aeSmrg 59854cd6a3aeSmrgint 59864cd6a3aeSmrgmain (int argc, char *argv[]) 59874cd6a3aeSmrg{ 59884cd6a3aeSmrg char **newargz; 59894cd6a3aeSmrg int newargc; 59904cd6a3aeSmrg char *tmp_pathspec; 59914cd6a3aeSmrg char *actual_cwrapper_path; 59924cd6a3aeSmrg char *actual_cwrapper_name; 59934cd6a3aeSmrg char *target_name; 59944cd6a3aeSmrg char *lt_argv_zero; 599554044362Smrg int rval = 127; 59964cd6a3aeSmrg 59974cd6a3aeSmrg int i; 59984cd6a3aeSmrg 59994cd6a3aeSmrg program_name = (char *) xstrdup (base_name (argv[0])); 600054044362Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 60014cd6a3aeSmrg 60024cd6a3aeSmrg /* very simple arg parsing; don't want to rely on getopt 60034cd6a3aeSmrg * also, copy all non cwrapper options to newargz, except 60044cd6a3aeSmrg * argz[0], which is handled differently 60054cd6a3aeSmrg */ 60064cd6a3aeSmrg newargc=0; 60074cd6a3aeSmrg for (i = 1; i < argc; i++) 60084cd6a3aeSmrg { 600954044362Smrg if (STREQ (argv[i], dumpscript_opt)) 60104cd6a3aeSmrg { 60114cd6a3aeSmrgEOF 601254044362Smrg case $host in 60134cd6a3aeSmrg *mingw* | *cygwin* ) 60144cd6a3aeSmrg # make stdout use "unix" line endings 60154cd6a3aeSmrg echo " setmode(1,_O_BINARY);" 60168c9fbc29Smrg ;; 60178c9fbc29Smrg esac 60188c9fbc29Smrg 60194cd6a3aeSmrg cat <<"EOF" 60204cd6a3aeSmrg lt_dump_script (stdout); 60214cd6a3aeSmrg return 0; 60224cd6a3aeSmrg } 602354044362Smrg if (STREQ (argv[i], debug_opt)) 60244cd6a3aeSmrg { 60254cd6a3aeSmrg lt_debug = 1; 60264cd6a3aeSmrg continue; 60274cd6a3aeSmrg } 602854044362Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 60294cd6a3aeSmrg { 60304cd6a3aeSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 60314cd6a3aeSmrg namespace, but it is not one of the ones we know about and 60324cd6a3aeSmrg have already dealt with, above (inluding dump-script), then 60334cd6a3aeSmrg report an error. Otherwise, targets might begin to believe 60344cd6a3aeSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 60354cd6a3aeSmrg namespace. The first time any user complains about this, we'll 60364cd6a3aeSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 60374cd6a3aeSmrg or a configure.ac-settable value. 60384cd6a3aeSmrg */ 60394cd6a3aeSmrg lt_fatal (__FILE__, __LINE__, 60404cd6a3aeSmrg "unrecognized %s option: '%s'", 60414cd6a3aeSmrg ltwrapper_option_prefix, argv[i]); 60424cd6a3aeSmrg } 60434cd6a3aeSmrg /* otherwise ... */ 60444cd6a3aeSmrg newargz[++newargc] = xstrdup (argv[i]); 60454cd6a3aeSmrg } 60464cd6a3aeSmrg newargz[++newargc] = NULL; 60478c9fbc29Smrg 60484cd6a3aeSmrgEOF 60494cd6a3aeSmrg cat <<EOF 60504cd6a3aeSmrg /* The GNU banner must be the first non-error debug message */ 605154044362Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 60524cd6a3aeSmrgEOF 60534cd6a3aeSmrg cat <<"EOF" 60544cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 60554cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 60564cd6a3aeSmrg 60574cd6a3aeSmrg tmp_pathspec = find_executable (argv[0]); 60584cd6a3aeSmrg if (tmp_pathspec == NULL) 60594cd6a3aeSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 60604cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 60614cd6a3aeSmrg "(main) found exe (before symlink chase) at: %s\n", 60624cd6a3aeSmrg tmp_pathspec); 60634cd6a3aeSmrg 60644cd6a3aeSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 60654cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 60664cd6a3aeSmrg "(main) found exe (after symlink chase) at: %s\n", 60674cd6a3aeSmrg actual_cwrapper_path); 60684cd6a3aeSmrg XFREE (tmp_pathspec); 60694cd6a3aeSmrg 60704cd6a3aeSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 60714cd6a3aeSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 60724cd6a3aeSmrg 60734cd6a3aeSmrg /* wrapper name transforms */ 60744cd6a3aeSmrg strendzap (actual_cwrapper_name, ".exe"); 60754cd6a3aeSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 60764cd6a3aeSmrg XFREE (actual_cwrapper_name); 60774cd6a3aeSmrg actual_cwrapper_name = tmp_pathspec; 60784cd6a3aeSmrg tmp_pathspec = 0; 60794cd6a3aeSmrg 60804cd6a3aeSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 60814cd6a3aeSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 60824cd6a3aeSmrg strendzap (target_name, ".exe"); 60834cd6a3aeSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 60844cd6a3aeSmrg XFREE (target_name); 60854cd6a3aeSmrg target_name = tmp_pathspec; 60864cd6a3aeSmrg tmp_pathspec = 0; 60874cd6a3aeSmrg 60884cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 60894cd6a3aeSmrg "(main) libtool target name: %s\n", 60904cd6a3aeSmrg target_name); 60914cd6a3aeSmrgEOF 60928c9fbc29Smrg 60934cd6a3aeSmrg cat <<EOF 60944cd6a3aeSmrg newargz[0] = 60954cd6a3aeSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 60964cd6a3aeSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 60974cd6a3aeSmrg strcpy (newargz[0], actual_cwrapper_path); 60984cd6a3aeSmrg strcat (newargz[0], "$objdir"); 60994cd6a3aeSmrg strcat (newargz[0], "/"); 61004cd6a3aeSmrgEOF 61018c9fbc29Smrg 61024cd6a3aeSmrg cat <<"EOF" 61034cd6a3aeSmrg /* stop here, and copy so we don't have to do this twice */ 61044cd6a3aeSmrg tmp_pathspec = xstrdup (newargz[0]); 61058c9fbc29Smrg 61064cd6a3aeSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 61074cd6a3aeSmrg strcat (newargz[0], actual_cwrapper_name); 61088c9fbc29Smrg 61094cd6a3aeSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 61104cd6a3aeSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 61114cd6a3aeSmrg XFREE (tmp_pathspec); 61124cd6a3aeSmrg tmp_pathspec = NULL; 61134cd6a3aeSmrgEOF 61148c9fbc29Smrg 61154cd6a3aeSmrg case $host_os in 61164cd6a3aeSmrg mingw*) 61174cd6a3aeSmrg cat <<"EOF" 61184cd6a3aeSmrg { 61194cd6a3aeSmrg char* p; 61204cd6a3aeSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 61214cd6a3aeSmrg { 61224cd6a3aeSmrg *p = '/'; 61234cd6a3aeSmrg } 61244cd6a3aeSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 61254cd6a3aeSmrg { 61264cd6a3aeSmrg *p = '/'; 61274cd6a3aeSmrg } 61284cd6a3aeSmrg } 61294cd6a3aeSmrgEOF 61304cd6a3aeSmrg ;; 61314cd6a3aeSmrg esac 61328c9fbc29Smrg 61334cd6a3aeSmrg cat <<"EOF" 61344cd6a3aeSmrg XFREE (target_name); 61354cd6a3aeSmrg XFREE (actual_cwrapper_path); 61364cd6a3aeSmrg XFREE (actual_cwrapper_name); 61374cd6a3aeSmrg 61384cd6a3aeSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 61394cd6a3aeSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 61404cd6a3aeSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 61414cd6a3aeSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 61424cd6a3aeSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 61434cd6a3aeSmrg libraries must come first. */ 61444cd6a3aeSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 61454cd6a3aeSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61464cd6a3aeSmrg 61474cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 61484cd6a3aeSmrg nonnull (lt_argv_zero)); 61494cd6a3aeSmrg for (i = 0; i < newargc; i++) 61504cd6a3aeSmrg { 61514cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 61524cd6a3aeSmrg i, nonnull (newargz[i])); 61534cd6a3aeSmrg } 61548c9fbc29Smrg 61554cd6a3aeSmrgEOF 61568c9fbc29Smrg 61574cd6a3aeSmrg case $host_os in 61584cd6a3aeSmrg mingw*) 61594cd6a3aeSmrg cat <<"EOF" 61604cd6a3aeSmrg /* execv doesn't actually work on mingw as expected on unix */ 61614cd6a3aeSmrg newargz = prepare_spawn (newargz); 616254044362Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 61634cd6a3aeSmrg if (rval == -1) 61644cd6a3aeSmrg { 61654cd6a3aeSmrg /* failed to start process */ 61664cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 61674cd6a3aeSmrg "(main) failed to launch target \"%s\": %s\n", 61684cd6a3aeSmrg lt_argv_zero, nonnull (strerror (errno))); 61694cd6a3aeSmrg return 127; 61704cd6a3aeSmrg } 61714cd6a3aeSmrg return rval; 61724cd6a3aeSmrgEOF 61734cd6a3aeSmrg ;; 61744cd6a3aeSmrg *) 61754cd6a3aeSmrg cat <<"EOF" 61764cd6a3aeSmrg execv (lt_argv_zero, newargz); 61774cd6a3aeSmrg return rval; /* =127, but avoids unused variable warning */ 61784cd6a3aeSmrgEOF 61794cd6a3aeSmrg ;; 61804cd6a3aeSmrg esac 61818c9fbc29Smrg 61824cd6a3aeSmrg cat <<"EOF" 61834cd6a3aeSmrg} 61848c9fbc29Smrg 61854cd6a3aeSmrgvoid * 61864cd6a3aeSmrgxmalloc (size_t num) 61874cd6a3aeSmrg{ 61884cd6a3aeSmrg void *p = (void *) malloc (num); 61894cd6a3aeSmrg if (!p) 61904cd6a3aeSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61918c9fbc29Smrg 61924cd6a3aeSmrg return p; 61934cd6a3aeSmrg} 61948c9fbc29Smrg 61954cd6a3aeSmrgchar * 61964cd6a3aeSmrgxstrdup (const char *string) 61974cd6a3aeSmrg{ 61984cd6a3aeSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 61994cd6a3aeSmrg string) : NULL; 62004cd6a3aeSmrg} 62018c9fbc29Smrg 62024cd6a3aeSmrgconst char * 62034cd6a3aeSmrgbase_name (const char *name) 62044cd6a3aeSmrg{ 62054cd6a3aeSmrg const char *base; 62068c9fbc29Smrg 620754044362Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62084cd6a3aeSmrg /* Skip over the disk name in MSDOS pathnames. */ 62094cd6a3aeSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 62104cd6a3aeSmrg name += 2; 62114cd6a3aeSmrg#endif 62128c9fbc29Smrg 62134cd6a3aeSmrg for (base = name; *name; name++) 62144cd6a3aeSmrg if (IS_DIR_SEPARATOR (*name)) 62154cd6a3aeSmrg base = name + 1; 62164cd6a3aeSmrg return base; 62174cd6a3aeSmrg} 62188c9fbc29Smrg 62194cd6a3aeSmrgint 62204cd6a3aeSmrgcheck_executable (const char *path) 62214cd6a3aeSmrg{ 62224cd6a3aeSmrg struct stat st; 62238c9fbc29Smrg 62244cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 62254cd6a3aeSmrg nonempty (path)); 62264cd6a3aeSmrg if ((!path) || (!*path)) 62274cd6a3aeSmrg return 0; 62288c9fbc29Smrg 62294cd6a3aeSmrg if ((stat (path, &st) >= 0) 62304cd6a3aeSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 62314cd6a3aeSmrg return 1; 62324cd6a3aeSmrg else 62334cd6a3aeSmrg return 0; 62344cd6a3aeSmrg} 62358c9fbc29Smrg 62364cd6a3aeSmrgint 62374cd6a3aeSmrgmake_executable (const char *path) 62384cd6a3aeSmrg{ 62394cd6a3aeSmrg int rval = 0; 62404cd6a3aeSmrg struct stat st; 62418c9fbc29Smrg 62424cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 62434cd6a3aeSmrg nonempty (path)); 62444cd6a3aeSmrg if ((!path) || (!*path)) 62454cd6a3aeSmrg return 0; 62468c9fbc29Smrg 62474cd6a3aeSmrg if (stat (path, &st) >= 0) 62484cd6a3aeSmrg { 62494cd6a3aeSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 62504cd6a3aeSmrg } 62514cd6a3aeSmrg return rval; 62524cd6a3aeSmrg} 62538c9fbc29Smrg 62544cd6a3aeSmrg/* Searches for the full path of the wrapper. Returns 62554cd6a3aeSmrg newly allocated full path name if found, NULL otherwise 62564cd6a3aeSmrg Does not chase symlinks, even on platforms that support them. 62574cd6a3aeSmrg*/ 62584cd6a3aeSmrgchar * 62594cd6a3aeSmrgfind_executable (const char *wrapper) 62604cd6a3aeSmrg{ 62614cd6a3aeSmrg int has_slash = 0; 62624cd6a3aeSmrg const char *p; 62634cd6a3aeSmrg const char *p_next; 62644cd6a3aeSmrg /* static buffer for getcwd */ 62654cd6a3aeSmrg char tmp[LT_PATHMAX + 1]; 626654044362Smrg size_t tmp_len; 62674cd6a3aeSmrg char *concat_name; 62688c9fbc29Smrg 62694cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 62704cd6a3aeSmrg nonempty (wrapper)); 62718c9fbc29Smrg 62724cd6a3aeSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 62734cd6a3aeSmrg return NULL; 62748c9fbc29Smrg 62754cd6a3aeSmrg /* Absolute path? */ 627654044362Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62774cd6a3aeSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 62784cd6a3aeSmrg { 62794cd6a3aeSmrg concat_name = xstrdup (wrapper); 62804cd6a3aeSmrg if (check_executable (concat_name)) 62814cd6a3aeSmrg return concat_name; 62824cd6a3aeSmrg XFREE (concat_name); 62834cd6a3aeSmrg } 62844cd6a3aeSmrg else 62854cd6a3aeSmrg { 62864cd6a3aeSmrg#endif 62874cd6a3aeSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 62884cd6a3aeSmrg { 62894cd6a3aeSmrg concat_name = xstrdup (wrapper); 62904cd6a3aeSmrg if (check_executable (concat_name)) 62914cd6a3aeSmrg return concat_name; 62924cd6a3aeSmrg XFREE (concat_name); 62934cd6a3aeSmrg } 629454044362Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62954cd6a3aeSmrg } 62964cd6a3aeSmrg#endif 62978c9fbc29Smrg 62984cd6a3aeSmrg for (p = wrapper; *p; p++) 62994cd6a3aeSmrg if (*p == '/') 63004cd6a3aeSmrg { 63014cd6a3aeSmrg has_slash = 1; 63024cd6a3aeSmrg break; 63034cd6a3aeSmrg } 63044cd6a3aeSmrg if (!has_slash) 63054cd6a3aeSmrg { 63064cd6a3aeSmrg /* no slashes; search PATH */ 63074cd6a3aeSmrg const char *path = getenv ("PATH"); 63084cd6a3aeSmrg if (path != NULL) 63094cd6a3aeSmrg { 63104cd6a3aeSmrg for (p = path; *p; p = p_next) 63114cd6a3aeSmrg { 63124cd6a3aeSmrg const char *q; 63134cd6a3aeSmrg size_t p_len; 63144cd6a3aeSmrg for (q = p; *q; q++) 63154cd6a3aeSmrg if (IS_PATH_SEPARATOR (*q)) 63164cd6a3aeSmrg break; 631754044362Smrg p_len = (size_t) (q - p); 63184cd6a3aeSmrg p_next = (*q == '\0' ? q : q + 1); 63194cd6a3aeSmrg if (p_len == 0) 63204cd6a3aeSmrg { 63214cd6a3aeSmrg /* empty path: current directory */ 63224cd6a3aeSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63234cd6a3aeSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63244cd6a3aeSmrg nonnull (strerror (errno))); 63254cd6a3aeSmrg tmp_len = strlen (tmp); 63264cd6a3aeSmrg concat_name = 63274cd6a3aeSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63284cd6a3aeSmrg memcpy (concat_name, tmp, tmp_len); 63294cd6a3aeSmrg concat_name[tmp_len] = '/'; 63304cd6a3aeSmrg strcpy (concat_name + tmp_len + 1, wrapper); 63314cd6a3aeSmrg } 63324cd6a3aeSmrg else 63334cd6a3aeSmrg { 63344cd6a3aeSmrg concat_name = 63354cd6a3aeSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 63364cd6a3aeSmrg memcpy (concat_name, p, p_len); 63374cd6a3aeSmrg concat_name[p_len] = '/'; 63384cd6a3aeSmrg strcpy (concat_name + p_len + 1, wrapper); 63394cd6a3aeSmrg } 63404cd6a3aeSmrg if (check_executable (concat_name)) 63414cd6a3aeSmrg return concat_name; 63424cd6a3aeSmrg XFREE (concat_name); 63434cd6a3aeSmrg } 63444cd6a3aeSmrg } 63454cd6a3aeSmrg /* not found in PATH; assume curdir */ 63464cd6a3aeSmrg } 63474cd6a3aeSmrg /* Relative path | not found in path: prepend cwd */ 63484cd6a3aeSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63494cd6a3aeSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63504cd6a3aeSmrg nonnull (strerror (errno))); 63514cd6a3aeSmrg tmp_len = strlen (tmp); 63524cd6a3aeSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63534cd6a3aeSmrg memcpy (concat_name, tmp, tmp_len); 63544cd6a3aeSmrg concat_name[tmp_len] = '/'; 63554cd6a3aeSmrg strcpy (concat_name + tmp_len + 1, wrapper); 63564cd6a3aeSmrg 63574cd6a3aeSmrg if (check_executable (concat_name)) 63584cd6a3aeSmrg return concat_name; 63594cd6a3aeSmrg XFREE (concat_name); 63604cd6a3aeSmrg return NULL; 63618c9fbc29Smrg} 63628c9fbc29Smrg 63634cd6a3aeSmrgchar * 63644cd6a3aeSmrgchase_symlinks (const char *pathspec) 63654cd6a3aeSmrg{ 63664cd6a3aeSmrg#ifndef S_ISLNK 63674cd6a3aeSmrg return xstrdup (pathspec); 63684cd6a3aeSmrg#else 63694cd6a3aeSmrg char buf[LT_PATHMAX]; 63704cd6a3aeSmrg struct stat s; 63714cd6a3aeSmrg char *tmp_pathspec = xstrdup (pathspec); 63724cd6a3aeSmrg char *p; 63734cd6a3aeSmrg int has_symlinks = 0; 63744cd6a3aeSmrg while (strlen (tmp_pathspec) && !has_symlinks) 63754cd6a3aeSmrg { 63764cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 63774cd6a3aeSmrg "checking path component for symlinks: %s\n", 63784cd6a3aeSmrg tmp_pathspec); 63794cd6a3aeSmrg if (lstat (tmp_pathspec, &s) == 0) 63804cd6a3aeSmrg { 63814cd6a3aeSmrg if (S_ISLNK (s.st_mode) != 0) 63824cd6a3aeSmrg { 63834cd6a3aeSmrg has_symlinks = 1; 63844cd6a3aeSmrg break; 63854cd6a3aeSmrg } 63868c9fbc29Smrg 63874cd6a3aeSmrg /* search backwards for last DIR_SEPARATOR */ 63884cd6a3aeSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 63894cd6a3aeSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63904cd6a3aeSmrg p--; 63914cd6a3aeSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63924cd6a3aeSmrg { 63934cd6a3aeSmrg /* no more DIR_SEPARATORS left */ 63944cd6a3aeSmrg break; 63954cd6a3aeSmrg } 63964cd6a3aeSmrg *p = '\0'; 63974cd6a3aeSmrg } 63984cd6a3aeSmrg else 63994cd6a3aeSmrg { 64004cd6a3aeSmrg lt_fatal (__FILE__, __LINE__, 64014cd6a3aeSmrg "error accessing file \"%s\": %s", 64024cd6a3aeSmrg tmp_pathspec, nonnull (strerror (errno))); 64034cd6a3aeSmrg } 64044cd6a3aeSmrg } 64054cd6a3aeSmrg XFREE (tmp_pathspec); 64068c9fbc29Smrg 64074cd6a3aeSmrg if (!has_symlinks) 64084cd6a3aeSmrg { 64094cd6a3aeSmrg return xstrdup (pathspec); 64104cd6a3aeSmrg } 64118c9fbc29Smrg 64124cd6a3aeSmrg tmp_pathspec = realpath (pathspec, buf); 64134cd6a3aeSmrg if (tmp_pathspec == 0) 64144cd6a3aeSmrg { 64154cd6a3aeSmrg lt_fatal (__FILE__, __LINE__, 64164cd6a3aeSmrg "could not follow symlinks for %s", pathspec); 64174cd6a3aeSmrg } 64184cd6a3aeSmrg return xstrdup (tmp_pathspec); 64194cd6a3aeSmrg#endif 64208c9fbc29Smrg} 64218c9fbc29Smrg 64224cd6a3aeSmrgchar * 64234cd6a3aeSmrgstrendzap (char *str, const char *pat) 64244cd6a3aeSmrg{ 64254cd6a3aeSmrg size_t len, patlen; 64268c9fbc29Smrg 64274cd6a3aeSmrg assert (str != NULL); 64284cd6a3aeSmrg assert (pat != NULL); 64298c9fbc29Smrg 64304cd6a3aeSmrg len = strlen (str); 64314cd6a3aeSmrg patlen = strlen (pat); 64328c9fbc29Smrg 64334cd6a3aeSmrg if (patlen <= len) 64344cd6a3aeSmrg { 64354cd6a3aeSmrg str += len - patlen; 643654044362Smrg if (STREQ (str, pat)) 64374cd6a3aeSmrg *str = '\0'; 64384cd6a3aeSmrg } 64394cd6a3aeSmrg return str; 64404cd6a3aeSmrg} 64418c9fbc29Smrg 64424cd6a3aeSmrgvoid 64434cd6a3aeSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 64444cd6a3aeSmrg{ 64454cd6a3aeSmrg va_list args; 64464cd6a3aeSmrg if (lt_debug) 64474cd6a3aeSmrg { 64484cd6a3aeSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 64494cd6a3aeSmrg va_start (args, fmt); 64504cd6a3aeSmrg (void) vfprintf (stderr, fmt, args); 64514cd6a3aeSmrg va_end (args); 64524cd6a3aeSmrg } 64534cd6a3aeSmrg} 64548c9fbc29Smrg 64554cd6a3aeSmrgstatic void 64564cd6a3aeSmrglt_error_core (int exit_status, const char *file, 64574cd6a3aeSmrg int line, const char *mode, 64584cd6a3aeSmrg const char *message, va_list ap) 64594cd6a3aeSmrg{ 64604cd6a3aeSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 64614cd6a3aeSmrg vfprintf (stderr, message, ap); 64624cd6a3aeSmrg fprintf (stderr, ".\n"); 64638c9fbc29Smrg 64644cd6a3aeSmrg if (exit_status >= 0) 64654cd6a3aeSmrg exit (exit_status); 64664cd6a3aeSmrg} 64678c9fbc29Smrg 64684cd6a3aeSmrgvoid 64694cd6a3aeSmrglt_fatal (const char *file, int line, const char *message, ...) 64704cd6a3aeSmrg{ 64714cd6a3aeSmrg va_list ap; 64724cd6a3aeSmrg va_start (ap, message); 64734cd6a3aeSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 64744cd6a3aeSmrg va_end (ap); 64754cd6a3aeSmrg} 64768c9fbc29Smrg 64774cd6a3aeSmrgstatic const char * 64784cd6a3aeSmrgnonnull (const char *s) 64794cd6a3aeSmrg{ 64804cd6a3aeSmrg return s ? s : "(null)"; 64814cd6a3aeSmrg} 64828c9fbc29Smrg 64834cd6a3aeSmrgstatic const char * 64844cd6a3aeSmrgnonempty (const char *s) 64854cd6a3aeSmrg{ 64864cd6a3aeSmrg return (s && !*s) ? "(empty)" : nonnull (s); 64874cd6a3aeSmrg} 64888c9fbc29Smrg 64894cd6a3aeSmrgvoid 64904cd6a3aeSmrglt_setenv (const char *name, const char *value) 64914cd6a3aeSmrg{ 64924cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 64934cd6a3aeSmrg "(lt_setenv) setting '%s' to '%s'\n", 64944cd6a3aeSmrg nonnull (name), nonnull (value)); 64954cd6a3aeSmrg { 64964cd6a3aeSmrg#ifdef HAVE_SETENV 64974cd6a3aeSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 64984cd6a3aeSmrg char *str = xstrdup (value); 64994cd6a3aeSmrg setenv (name, str, 1); 65008c9fbc29Smrg#else 650154044362Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 65024cd6a3aeSmrg char *str = XMALLOC (char, len); 65034cd6a3aeSmrg sprintf (str, "%s=%s", name, value); 65044cd6a3aeSmrg if (putenv (str) != EXIT_SUCCESS) 65054cd6a3aeSmrg { 65064cd6a3aeSmrg XFREE (str); 65074cd6a3aeSmrg } 65088c9fbc29Smrg#endif 65094cd6a3aeSmrg } 65104cd6a3aeSmrg} 65118c9fbc29Smrg 65124cd6a3aeSmrgchar * 65134cd6a3aeSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 65144cd6a3aeSmrg{ 65154cd6a3aeSmrg char *new_value; 65164cd6a3aeSmrg if (orig_value && *orig_value) 65174cd6a3aeSmrg { 651854044362Smrg size_t orig_value_len = strlen (orig_value); 651954044362Smrg size_t add_len = strlen (add); 65204cd6a3aeSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 65214cd6a3aeSmrg if (to_end) 65224cd6a3aeSmrg { 65234cd6a3aeSmrg strcpy (new_value, orig_value); 65244cd6a3aeSmrg strcpy (new_value + orig_value_len, add); 65254cd6a3aeSmrg } 65264cd6a3aeSmrg else 65274cd6a3aeSmrg { 65284cd6a3aeSmrg strcpy (new_value, add); 65294cd6a3aeSmrg strcpy (new_value + add_len, orig_value); 65304cd6a3aeSmrg } 65314cd6a3aeSmrg } 65324cd6a3aeSmrg else 65334cd6a3aeSmrg { 65344cd6a3aeSmrg new_value = xstrdup (add); 65354cd6a3aeSmrg } 65364cd6a3aeSmrg return new_value; 65374cd6a3aeSmrg} 65388c9fbc29Smrg 65394cd6a3aeSmrgvoid 65404cd6a3aeSmrglt_update_exe_path (const char *name, const char *value) 65414cd6a3aeSmrg{ 65424cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 65434cd6a3aeSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 65444cd6a3aeSmrg nonnull (name), nonnull (value)); 65458c9fbc29Smrg 65464cd6a3aeSmrg if (name && *name && value && *value) 65474cd6a3aeSmrg { 65484cd6a3aeSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 65494cd6a3aeSmrg /* some systems can't cope with a ':'-terminated path #' */ 655054044362Smrg size_t len = strlen (new_value); 655154044362Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 65524cd6a3aeSmrg { 655354044362Smrg new_value[--len] = '\0'; 65544cd6a3aeSmrg } 65554cd6a3aeSmrg lt_setenv (name, new_value); 65564cd6a3aeSmrg XFREE (new_value); 65574cd6a3aeSmrg } 65584cd6a3aeSmrg} 65598c9fbc29Smrg 65604cd6a3aeSmrgvoid 65614cd6a3aeSmrglt_update_lib_path (const char *name, const char *value) 65628c9fbc29Smrg{ 65634cd6a3aeSmrg lt_debugprintf (__FILE__, __LINE__, 65644cd6a3aeSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 65654cd6a3aeSmrg nonnull (name), nonnull (value)); 65668c9fbc29Smrg 65674cd6a3aeSmrg if (name && *name && value && *value) 65684cd6a3aeSmrg { 65694cd6a3aeSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 65704cd6a3aeSmrg lt_setenv (name, new_value); 65714cd6a3aeSmrg XFREE (new_value); 65724cd6a3aeSmrg } 65734cd6a3aeSmrg} 65748c9fbc29Smrg 65758c9fbc29SmrgEOF 65764cd6a3aeSmrg case $host_os in 65774cd6a3aeSmrg mingw*) 65784cd6a3aeSmrg cat <<"EOF" 65794cd6a3aeSmrg 65804cd6a3aeSmrg/* Prepares an argument vector before calling spawn(). 65814cd6a3aeSmrg Note that spawn() does not by itself call the command interpreter 65824cd6a3aeSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 65834cd6a3aeSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 65844cd6a3aeSmrg GetVersionEx(&v); 65854cd6a3aeSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 65864cd6a3aeSmrg }) ? "cmd.exe" : "command.com"). 65874cd6a3aeSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 65884cd6a3aeSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 65894cd6a3aeSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 65904cd6a3aeSmrg special way: 65914cd6a3aeSmrg - Space and tab are interpreted as delimiters. They are not treated as 65924cd6a3aeSmrg delimiters if they are surrounded by double quotes: "...". 65934cd6a3aeSmrg - Unescaped double quotes are removed from the input. Their only effect is 65944cd6a3aeSmrg that within double quotes, space and tab are treated like normal 65954cd6a3aeSmrg characters. 65964cd6a3aeSmrg - Backslashes not followed by double quotes are not special. 65974cd6a3aeSmrg - But 2*n+1 backslashes followed by a double quote become 65984cd6a3aeSmrg n backslashes followed by a double quote (n >= 0): 65994cd6a3aeSmrg \" -> " 66004cd6a3aeSmrg \\\" -> \" 66014cd6a3aeSmrg \\\\\" -> \\" 66024cd6a3aeSmrg */ 66034cd6a3aeSmrg#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" 66044cd6a3aeSmrg#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" 66054cd6a3aeSmrgchar ** 66064cd6a3aeSmrgprepare_spawn (char **argv) 66074cd6a3aeSmrg{ 66084cd6a3aeSmrg size_t argc; 66094cd6a3aeSmrg char **new_argv; 66104cd6a3aeSmrg size_t i; 66118c9fbc29Smrg 66124cd6a3aeSmrg /* Count number of arguments. */ 66134cd6a3aeSmrg for (argc = 0; argv[argc] != NULL; argc++) 66148c9fbc29Smrg ; 66158c9fbc29Smrg 66164cd6a3aeSmrg /* Allocate new argument vector. */ 66174cd6a3aeSmrg new_argv = XMALLOC (char *, argc + 1); 66188c9fbc29Smrg 66194cd6a3aeSmrg /* Put quoted arguments into the new argument vector. */ 66204cd6a3aeSmrg for (i = 0; i < argc; i++) 66214cd6a3aeSmrg { 66224cd6a3aeSmrg const char *string = argv[i]; 66234cd6a3aeSmrg 66244cd6a3aeSmrg if (string[0] == '\0') 66254cd6a3aeSmrg new_argv[i] = xstrdup ("\"\""); 66264cd6a3aeSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 66274cd6a3aeSmrg { 66284cd6a3aeSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 66294cd6a3aeSmrg size_t length; 66304cd6a3aeSmrg unsigned int backslashes; 66314cd6a3aeSmrg const char *s; 66324cd6a3aeSmrg char *quoted_string; 66334cd6a3aeSmrg char *p; 66344cd6a3aeSmrg 66354cd6a3aeSmrg length = 0; 66364cd6a3aeSmrg backslashes = 0; 66374cd6a3aeSmrg if (quote_around) 66384cd6a3aeSmrg length++; 66394cd6a3aeSmrg for (s = string; *s != '\0'; s++) 66404cd6a3aeSmrg { 66414cd6a3aeSmrg char c = *s; 66424cd6a3aeSmrg if (c == '"') 66434cd6a3aeSmrg length += backslashes + 1; 66444cd6a3aeSmrg length++; 66454cd6a3aeSmrg if (c == '\\') 66464cd6a3aeSmrg backslashes++; 66474cd6a3aeSmrg else 66484cd6a3aeSmrg backslashes = 0; 66494cd6a3aeSmrg } 66504cd6a3aeSmrg if (quote_around) 66514cd6a3aeSmrg length += backslashes + 1; 66524cd6a3aeSmrg 66534cd6a3aeSmrg quoted_string = XMALLOC (char, length + 1); 66544cd6a3aeSmrg 66554cd6a3aeSmrg p = quoted_string; 66564cd6a3aeSmrg backslashes = 0; 66574cd6a3aeSmrg if (quote_around) 66584cd6a3aeSmrg *p++ = '"'; 66594cd6a3aeSmrg for (s = string; *s != '\0'; s++) 66604cd6a3aeSmrg { 66614cd6a3aeSmrg char c = *s; 66624cd6a3aeSmrg if (c == '"') 66634cd6a3aeSmrg { 66644cd6a3aeSmrg unsigned int j; 66654cd6a3aeSmrg for (j = backslashes + 1; j > 0; j--) 66664cd6a3aeSmrg *p++ = '\\'; 66674cd6a3aeSmrg } 66684cd6a3aeSmrg *p++ = c; 66694cd6a3aeSmrg if (c == '\\') 66704cd6a3aeSmrg backslashes++; 66714cd6a3aeSmrg else 66724cd6a3aeSmrg backslashes = 0; 66734cd6a3aeSmrg } 66744cd6a3aeSmrg if (quote_around) 66754cd6a3aeSmrg { 66764cd6a3aeSmrg unsigned int j; 66774cd6a3aeSmrg for (j = backslashes; j > 0; j--) 66784cd6a3aeSmrg *p++ = '\\'; 66794cd6a3aeSmrg *p++ = '"'; 66804cd6a3aeSmrg } 66814cd6a3aeSmrg *p = '\0'; 66824cd6a3aeSmrg 66834cd6a3aeSmrg new_argv[i] = quoted_string; 66844cd6a3aeSmrg } 66854cd6a3aeSmrg else 66864cd6a3aeSmrg new_argv[i] = (char *) string; 66874cd6a3aeSmrg } 66884cd6a3aeSmrg new_argv[argc] = NULL; 66898c9fbc29Smrg 66904cd6a3aeSmrg return new_argv; 66918c9fbc29Smrg} 66924cd6a3aeSmrgEOF 66934cd6a3aeSmrg ;; 66944cd6a3aeSmrg esac 66958c9fbc29Smrg 66964cd6a3aeSmrg cat <<"EOF" 66974cd6a3aeSmrgvoid lt_dump_script (FILE* f) 66988c9fbc29Smrg{ 66994cd6a3aeSmrgEOF 67004cd6a3aeSmrg func_emit_wrapper yes | 670170728a38Smrg $SED -n -e ' 670270728a38Smrgs/^\(.\{79\}\)\(..*\)/\1\ 670370728a38Smrg\2/ 670470728a38Smrgh 670570728a38Smrgs/\([\\"]\)/\\\1/g 670670728a38Smrgs/$/\\n/ 670770728a38Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 670870728a38Smrgg 670970728a38SmrgD' 67104cd6a3aeSmrg cat <<"EOF" 67118c9fbc29Smrg} 67124cd6a3aeSmrgEOF 67138c9fbc29Smrg} 67144cd6a3aeSmrg# end: func_emit_cwrapperexe_src 67158c9fbc29Smrg 67164cd6a3aeSmrg# func_win32_import_lib_p ARG 67174cd6a3aeSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 67184cd6a3aeSmrgfunc_win32_import_lib_p () 67198c9fbc29Smrg{ 672054044362Smrg $debug_cmd 672154044362Smrg 67224cd6a3aeSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 67234cd6a3aeSmrg *import*) : ;; 67244cd6a3aeSmrg *) false ;; 67254cd6a3aeSmrg esac 67268c9fbc29Smrg} 67278c9fbc29Smrg 672854044362Smrg# func_suncc_cstd_abi 672954044362Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 673054044362Smrg# Several compiler flags select an ABI that is incompatible with the 673154044362Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 673254044362Smrgfunc_suncc_cstd_abi () 673354044362Smrg{ 673454044362Smrg $debug_cmd 673554044362Smrg 673654044362Smrg case " $compile_command " in 673754044362Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 673854044362Smrg suncc_use_cstd_abi=no 673954044362Smrg ;; 674054044362Smrg *) 674154044362Smrg suncc_use_cstd_abi=yes 674254044362Smrg ;; 674354044362Smrg esac 674454044362Smrg} 674554044362Smrg 67464cd6a3aeSmrg# func_mode_link arg... 67474cd6a3aeSmrgfunc_mode_link () 67488c9fbc29Smrg{ 674954044362Smrg $debug_cmd 675054044362Smrg 67514cd6a3aeSmrg case $host in 67524cd6a3aeSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 67534cd6a3aeSmrg # It is impossible to link a dll without this setting, and 67544cd6a3aeSmrg # we shouldn't force the makefile maintainer to figure out 675554044362Smrg # what system we are compiling for in order to pass an extra 67564cd6a3aeSmrg # flag for every libtool invocation. 67574cd6a3aeSmrg # allow_undefined=no 67588c9fbc29Smrg 67594cd6a3aeSmrg # FIXME: Unfortunately, there are problems with the above when trying 676054044362Smrg # to make a dll that has undefined symbols, in which case not 67614cd6a3aeSmrg # even a static library is built. For now, we need to specify 67624cd6a3aeSmrg # -no-undefined on the libtool link line when we can be certain 67634cd6a3aeSmrg # that all symbols are satisfied, otherwise we get a static library. 67644cd6a3aeSmrg allow_undefined=yes 67654cd6a3aeSmrg ;; 67664cd6a3aeSmrg *) 67674cd6a3aeSmrg allow_undefined=yes 67684cd6a3aeSmrg ;; 67694cd6a3aeSmrg esac 67704cd6a3aeSmrg libtool_args=$nonopt 67714cd6a3aeSmrg base_compile="$nonopt $@" 67724cd6a3aeSmrg compile_command=$nonopt 67734cd6a3aeSmrg finalize_command=$nonopt 67748c9fbc29Smrg 67754cd6a3aeSmrg compile_rpath= 67764cd6a3aeSmrg finalize_rpath= 67774cd6a3aeSmrg compile_shlibpath= 67784cd6a3aeSmrg finalize_shlibpath= 67794cd6a3aeSmrg convenience= 67804cd6a3aeSmrg old_convenience= 67814cd6a3aeSmrg deplibs= 67824cd6a3aeSmrg old_deplibs= 67834cd6a3aeSmrg compiler_flags= 67844cd6a3aeSmrg linker_flags= 67854cd6a3aeSmrg dllsearchpath= 67864cd6a3aeSmrg lib_search_path=`pwd` 67874cd6a3aeSmrg inst_prefix_dir= 67884cd6a3aeSmrg new_inherited_linker_flags= 67898c9fbc29Smrg 67904cd6a3aeSmrg avoid_version=no 67914cd6a3aeSmrg bindir= 67924cd6a3aeSmrg dlfiles= 67934cd6a3aeSmrg dlprefiles= 67944cd6a3aeSmrg dlself=no 67954cd6a3aeSmrg export_dynamic=no 67964cd6a3aeSmrg export_symbols= 67974cd6a3aeSmrg export_symbols_regex= 67984cd6a3aeSmrg generated= 67994cd6a3aeSmrg libobjs= 68004cd6a3aeSmrg ltlibs= 68014cd6a3aeSmrg module=no 68024cd6a3aeSmrg no_install=no 68034cd6a3aeSmrg objs= 680454044362Smrg os2dllname= 68054cd6a3aeSmrg non_pic_objects= 68064cd6a3aeSmrg precious_files_regex= 68074cd6a3aeSmrg prefer_static_libs=no 680854044362Smrg preload=false 68094cd6a3aeSmrg prev= 68104cd6a3aeSmrg prevarg= 68114cd6a3aeSmrg release= 68124cd6a3aeSmrg rpath= 68134cd6a3aeSmrg xrpath= 68144cd6a3aeSmrg perm_rpath= 68154cd6a3aeSmrg temp_rpath= 68164cd6a3aeSmrg thread_safe=no 68174cd6a3aeSmrg vinfo= 68184cd6a3aeSmrg vinfo_number=no 68194cd6a3aeSmrg weak_libs= 682054044362Smrg single_module=$wl-single_module 68214cd6a3aeSmrg func_infer_tag $base_compile 68228c9fbc29Smrg 68234cd6a3aeSmrg # We need to know -static, to get the right output filenames. 68244cd6a3aeSmrg for arg 68254cd6a3aeSmrg do 68264cd6a3aeSmrg case $arg in 68274cd6a3aeSmrg -shared) 682854044362Smrg test yes != "$build_libtool_libs" \ 682954044362Smrg && func_fatal_configuration "cannot build a shared library" 68304cd6a3aeSmrg build_old_libs=no 68314cd6a3aeSmrg break 68324cd6a3aeSmrg ;; 68334cd6a3aeSmrg -all-static | -static | -static-libtool-libs) 68344cd6a3aeSmrg case $arg in 68354cd6a3aeSmrg -all-static) 683654044362Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 68374cd6a3aeSmrg func_warning "complete static linking is impossible in this configuration" 68384cd6a3aeSmrg fi 68394cd6a3aeSmrg if test -n "$link_static_flag"; then 68404cd6a3aeSmrg dlopen_self=$dlopen_self_static 68414cd6a3aeSmrg fi 68424cd6a3aeSmrg prefer_static_libs=yes 68434cd6a3aeSmrg ;; 68444cd6a3aeSmrg -static) 68454cd6a3aeSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68464cd6a3aeSmrg dlopen_self=$dlopen_self_static 68474cd6a3aeSmrg fi 68484cd6a3aeSmrg prefer_static_libs=built 68494cd6a3aeSmrg ;; 68504cd6a3aeSmrg -static-libtool-libs) 68514cd6a3aeSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68524cd6a3aeSmrg dlopen_self=$dlopen_self_static 68534cd6a3aeSmrg fi 68544cd6a3aeSmrg prefer_static_libs=yes 68554cd6a3aeSmrg ;; 68564cd6a3aeSmrg esac 68574cd6a3aeSmrg build_libtool_libs=no 68584cd6a3aeSmrg build_old_libs=yes 68594cd6a3aeSmrg break 68604cd6a3aeSmrg ;; 68614cd6a3aeSmrg esac 68624cd6a3aeSmrg done 68638c9fbc29Smrg 68644cd6a3aeSmrg # See if our shared archives depend on static archives. 68654cd6a3aeSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68668c9fbc29Smrg 68674cd6a3aeSmrg # Go through the arguments, transforming them on the way. 68684cd6a3aeSmrg while test "$#" -gt 0; do 686954044362Smrg arg=$1 68704cd6a3aeSmrg shift 687154cef2ddSmrg func_quote_arg pretty,unquoted "$arg" 687254cef2ddSmrg qarg=$func_quote_arg_unquoted_result 687354cef2ddSmrg func_append libtool_args " $func_quote_arg_result" 68748c9fbc29Smrg 68754cd6a3aeSmrg # If the previous option needs an argument, assign it. 68764cd6a3aeSmrg if test -n "$prev"; then 68774cd6a3aeSmrg case $prev in 68784cd6a3aeSmrg output) 68794cd6a3aeSmrg func_append compile_command " @OUTPUT@" 68804cd6a3aeSmrg func_append finalize_command " @OUTPUT@" 68814cd6a3aeSmrg ;; 68824cd6a3aeSmrg esac 68838c9fbc29Smrg 68844cd6a3aeSmrg case $prev in 68854cd6a3aeSmrg bindir) 688654044362Smrg bindir=$arg 68874cd6a3aeSmrg prev= 68884cd6a3aeSmrg continue 68894cd6a3aeSmrg ;; 68904cd6a3aeSmrg dlfiles|dlprefiles) 689154044362Smrg $preload || { 68924cd6a3aeSmrg # Add the symbol object into the linking commands. 68934cd6a3aeSmrg func_append compile_command " @SYMFILE@" 68944cd6a3aeSmrg func_append finalize_command " @SYMFILE@" 689554044362Smrg preload=: 689654044362Smrg } 68974cd6a3aeSmrg case $arg in 68984cd6a3aeSmrg *.la | *.lo) ;; # We handle these cases below. 68994cd6a3aeSmrg force) 690054044362Smrg if test no = "$dlself"; then 69014cd6a3aeSmrg dlself=needless 69024cd6a3aeSmrg export_dynamic=yes 69034cd6a3aeSmrg fi 69044cd6a3aeSmrg prev= 69054cd6a3aeSmrg continue 69064cd6a3aeSmrg ;; 69074cd6a3aeSmrg self) 690854044362Smrg if test dlprefiles = "$prev"; then 69094cd6a3aeSmrg dlself=yes 691054044362Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 69114cd6a3aeSmrg dlself=yes 69124cd6a3aeSmrg else 69134cd6a3aeSmrg dlself=needless 69144cd6a3aeSmrg export_dynamic=yes 69154cd6a3aeSmrg fi 69164cd6a3aeSmrg prev= 69174cd6a3aeSmrg continue 69184cd6a3aeSmrg ;; 69194cd6a3aeSmrg *) 692054044362Smrg if test dlfiles = "$prev"; then 69214cd6a3aeSmrg func_append dlfiles " $arg" 69224cd6a3aeSmrg else 69234cd6a3aeSmrg func_append dlprefiles " $arg" 69244cd6a3aeSmrg fi 69254cd6a3aeSmrg prev= 69264cd6a3aeSmrg continue 69274cd6a3aeSmrg ;; 69284cd6a3aeSmrg esac 69294cd6a3aeSmrg ;; 69304cd6a3aeSmrg expsyms) 693154044362Smrg export_symbols=$arg 69324cd6a3aeSmrg test -f "$arg" \ 693354044362Smrg || func_fatal_error "symbol file '$arg' does not exist" 69344cd6a3aeSmrg prev= 69354cd6a3aeSmrg continue 69364cd6a3aeSmrg ;; 69374cd6a3aeSmrg expsyms_regex) 693854044362Smrg export_symbols_regex=$arg 69394cd6a3aeSmrg prev= 69404cd6a3aeSmrg continue 69414cd6a3aeSmrg ;; 69424cd6a3aeSmrg framework) 69434cd6a3aeSmrg case $host in 69444cd6a3aeSmrg *-*-darwin*) 69454cd6a3aeSmrg case "$deplibs " in 69464cd6a3aeSmrg *" $qarg.ltframework "*) ;; 69474cd6a3aeSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 69484cd6a3aeSmrg ;; 69494cd6a3aeSmrg esac 69504cd6a3aeSmrg ;; 69514cd6a3aeSmrg esac 69524cd6a3aeSmrg prev= 69534cd6a3aeSmrg continue 69544cd6a3aeSmrg ;; 69554cd6a3aeSmrg inst_prefix) 695654044362Smrg inst_prefix_dir=$arg 695754044362Smrg prev= 695854044362Smrg continue 695954044362Smrg ;; 696054044362Smrg mllvm) 696154044362Smrg # Clang does not use LLVM to link, so we can simply discard any 696254044362Smrg # '-mllvm $arg' options when doing the link step. 69634cd6a3aeSmrg prev= 69644cd6a3aeSmrg continue 69654cd6a3aeSmrg ;; 69664cd6a3aeSmrg objectlist) 69674cd6a3aeSmrg if test -f "$arg"; then 69684cd6a3aeSmrg save_arg=$arg 69694cd6a3aeSmrg moreargs= 69704cd6a3aeSmrg for fil in `cat "$save_arg"` 69714cd6a3aeSmrg do 69724cd6a3aeSmrg# func_append moreargs " $fil" 69734cd6a3aeSmrg arg=$fil 69744cd6a3aeSmrg # A libtool-controlled object. 69758c9fbc29Smrg 69764cd6a3aeSmrg # Check to see that this really is a libtool object. 69774cd6a3aeSmrg if func_lalib_unsafe_p "$arg"; then 69784cd6a3aeSmrg pic_object= 69794cd6a3aeSmrg non_pic_object= 69808c9fbc29Smrg 69814cd6a3aeSmrg # Read the .lo file 69824cd6a3aeSmrg func_source "$arg" 69838c9fbc29Smrg 69844cd6a3aeSmrg if test -z "$pic_object" || 69854cd6a3aeSmrg test -z "$non_pic_object" || 698654044362Smrg test none = "$pic_object" && 698754044362Smrg test none = "$non_pic_object"; then 698854044362Smrg func_fatal_error "cannot find name of object for '$arg'" 69894cd6a3aeSmrg fi 69908c9fbc29Smrg 69914cd6a3aeSmrg # Extract subdirectory from the argument. 69924cd6a3aeSmrg func_dirname "$arg" "/" "" 699354044362Smrg xdir=$func_dirname_result 69948c9fbc29Smrg 699554044362Smrg if test none != "$pic_object"; then 69964cd6a3aeSmrg # Prepend the subdirectory the object is found in. 699754044362Smrg pic_object=$xdir$pic_object 69988c9fbc29Smrg 699954044362Smrg if test dlfiles = "$prev"; then 700054044362Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 70014cd6a3aeSmrg func_append dlfiles " $pic_object" 70024cd6a3aeSmrg prev= 70034cd6a3aeSmrg continue 70044cd6a3aeSmrg else 70054cd6a3aeSmrg # If libtool objects are unsupported, then we need to preload. 70064cd6a3aeSmrg prev=dlprefiles 70074cd6a3aeSmrg fi 70084cd6a3aeSmrg fi 70098c9fbc29Smrg 70104cd6a3aeSmrg # CHECK ME: I think I busted this. -Ossama 701154044362Smrg if test dlprefiles = "$prev"; then 70124cd6a3aeSmrg # Preload the old-style object. 70134cd6a3aeSmrg func_append dlprefiles " $pic_object" 70144cd6a3aeSmrg prev= 70154cd6a3aeSmrg fi 70164e411241Smrg 70174cd6a3aeSmrg # A PIC object. 70184cd6a3aeSmrg func_append libobjs " $pic_object" 701954044362Smrg arg=$pic_object 70204cd6a3aeSmrg fi 70218c9fbc29Smrg 70224cd6a3aeSmrg # Non-PIC object. 702354044362Smrg if test none != "$non_pic_object"; then 70244cd6a3aeSmrg # Prepend the subdirectory the object is found in. 702554044362Smrg non_pic_object=$xdir$non_pic_object 70268c9fbc29Smrg 70274cd6a3aeSmrg # A standard non-PIC object 70284cd6a3aeSmrg func_append non_pic_objects " $non_pic_object" 702954044362Smrg if test -z "$pic_object" || test none = "$pic_object"; then 703054044362Smrg arg=$non_pic_object 70314cd6a3aeSmrg fi 70324cd6a3aeSmrg else 70334cd6a3aeSmrg # If the PIC object exists, use it instead. 70344cd6a3aeSmrg # $xdir was prepended to $pic_object above. 703554044362Smrg non_pic_object=$pic_object 70364cd6a3aeSmrg func_append non_pic_objects " $non_pic_object" 70374cd6a3aeSmrg fi 70384cd6a3aeSmrg else 70394cd6a3aeSmrg # Only an error if not doing a dry-run. 70404cd6a3aeSmrg if $opt_dry_run; then 70414cd6a3aeSmrg # Extract subdirectory from the argument. 70424cd6a3aeSmrg func_dirname "$arg" "/" "" 704354044362Smrg xdir=$func_dirname_result 70444cd6a3aeSmrg 70454cd6a3aeSmrg func_lo2o "$arg" 70464cd6a3aeSmrg pic_object=$xdir$objdir/$func_lo2o_result 70474cd6a3aeSmrg non_pic_object=$xdir$func_lo2o_result 70484cd6a3aeSmrg func_append libobjs " $pic_object" 70494cd6a3aeSmrg func_append non_pic_objects " $non_pic_object" 70504cd6a3aeSmrg else 705154044362Smrg func_fatal_error "'$arg' is not a valid libtool object" 70524cd6a3aeSmrg fi 70534cd6a3aeSmrg fi 70544cd6a3aeSmrg done 70554cd6a3aeSmrg else 705654044362Smrg func_fatal_error "link input file '$arg' does not exist" 70574cd6a3aeSmrg fi 70584cd6a3aeSmrg arg=$save_arg 70594cd6a3aeSmrg prev= 70604cd6a3aeSmrg continue 70614cd6a3aeSmrg ;; 706254044362Smrg os2dllname) 706354044362Smrg os2dllname=$arg 706454044362Smrg prev= 706554044362Smrg continue 706654044362Smrg ;; 70674cd6a3aeSmrg precious_regex) 706854044362Smrg precious_files_regex=$arg 70694cd6a3aeSmrg prev= 70704cd6a3aeSmrg continue 70714cd6a3aeSmrg ;; 70724cd6a3aeSmrg release) 707354044362Smrg release=-$arg 70744cd6a3aeSmrg prev= 70754cd6a3aeSmrg continue 70764cd6a3aeSmrg ;; 70774cd6a3aeSmrg rpath | xrpath) 70784cd6a3aeSmrg # We need an absolute path. 70794cd6a3aeSmrg case $arg in 70804cd6a3aeSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 70814cd6a3aeSmrg *) 70824cd6a3aeSmrg func_fatal_error "only absolute run-paths are allowed" 70834cd6a3aeSmrg ;; 70844cd6a3aeSmrg esac 708554044362Smrg if test rpath = "$prev"; then 70864cd6a3aeSmrg case "$rpath " in 70874cd6a3aeSmrg *" $arg "*) ;; 70884cd6a3aeSmrg *) func_append rpath " $arg" ;; 70894cd6a3aeSmrg esac 70904cd6a3aeSmrg else 70914cd6a3aeSmrg case "$xrpath " in 70924cd6a3aeSmrg *" $arg "*) ;; 70934cd6a3aeSmrg *) func_append xrpath " $arg" ;; 70944cd6a3aeSmrg esac 70954cd6a3aeSmrg fi 70964cd6a3aeSmrg prev= 70974cd6a3aeSmrg continue 70984cd6a3aeSmrg ;; 70994cd6a3aeSmrg shrext) 710054044362Smrg shrext_cmds=$arg 71014cd6a3aeSmrg prev= 71024cd6a3aeSmrg continue 71034cd6a3aeSmrg ;; 71044cd6a3aeSmrg weak) 71054cd6a3aeSmrg func_append weak_libs " $arg" 71064cd6a3aeSmrg prev= 71074cd6a3aeSmrg continue 71084cd6a3aeSmrg ;; 710954cef2ddSmrg xassembler) 711054cef2ddSmrg func_append compiler_flags " -Xassembler $qarg" 711154cef2ddSmrg prev= 711254cef2ddSmrg func_append compile_command " -Xassembler $qarg" 711354cef2ddSmrg func_append finalize_command " -Xassembler $qarg" 711454cef2ddSmrg continue 711554cef2ddSmrg ;; 71164cd6a3aeSmrg xcclinker) 71174cd6a3aeSmrg func_append linker_flags " $qarg" 71184cd6a3aeSmrg func_append compiler_flags " $qarg" 71194cd6a3aeSmrg prev= 71204cd6a3aeSmrg func_append compile_command " $qarg" 71214cd6a3aeSmrg func_append finalize_command " $qarg" 71224cd6a3aeSmrg continue 71234cd6a3aeSmrg ;; 71244cd6a3aeSmrg xcompiler) 71254cd6a3aeSmrg func_append compiler_flags " $qarg" 71264cd6a3aeSmrg prev= 71274cd6a3aeSmrg func_append compile_command " $qarg" 71284cd6a3aeSmrg func_append finalize_command " $qarg" 71294cd6a3aeSmrg continue 71304cd6a3aeSmrg ;; 71314cd6a3aeSmrg xlinker) 71324cd6a3aeSmrg func_append linker_flags " $qarg" 71334cd6a3aeSmrg func_append compiler_flags " $wl$qarg" 71344cd6a3aeSmrg prev= 71354cd6a3aeSmrg func_append compile_command " $wl$qarg" 71364cd6a3aeSmrg func_append finalize_command " $wl$qarg" 71374cd6a3aeSmrg continue 71384cd6a3aeSmrg ;; 71394cd6a3aeSmrg *) 71404cd6a3aeSmrg eval "$prev=\"\$arg\"" 71414cd6a3aeSmrg prev= 71424cd6a3aeSmrg continue 71434cd6a3aeSmrg ;; 71444cd6a3aeSmrg esac 71454cd6a3aeSmrg fi # test -n "$prev" 71468c9fbc29Smrg 714754044362Smrg prevarg=$arg 71488c9fbc29Smrg 71494cd6a3aeSmrg case $arg in 71504cd6a3aeSmrg -all-static) 71514cd6a3aeSmrg if test -n "$link_static_flag"; then 71524cd6a3aeSmrg # See comment for -static flag below, for more details. 71534cd6a3aeSmrg func_append compile_command " $link_static_flag" 71544cd6a3aeSmrg func_append finalize_command " $link_static_flag" 71554cd6a3aeSmrg fi 71564cd6a3aeSmrg continue 71574cd6a3aeSmrg ;; 71588c9fbc29Smrg 71594cd6a3aeSmrg -allow-undefined) 71604cd6a3aeSmrg # FIXME: remove this flag sometime in the future. 716154044362Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 71624cd6a3aeSmrg ;; 71638c9fbc29Smrg 71644cd6a3aeSmrg -avoid-version) 71654cd6a3aeSmrg avoid_version=yes 71664cd6a3aeSmrg continue 71674cd6a3aeSmrg ;; 71688c9fbc29Smrg 71694cd6a3aeSmrg -bindir) 71704cd6a3aeSmrg prev=bindir 71714cd6a3aeSmrg continue 71724cd6a3aeSmrg ;; 71734cd6a3aeSmrg 71744cd6a3aeSmrg -dlopen) 71754cd6a3aeSmrg prev=dlfiles 71764cd6a3aeSmrg continue 71774cd6a3aeSmrg ;; 71784cd6a3aeSmrg 71794cd6a3aeSmrg -dlpreopen) 71804cd6a3aeSmrg prev=dlprefiles 71814cd6a3aeSmrg continue 71824cd6a3aeSmrg ;; 71834cd6a3aeSmrg 71844cd6a3aeSmrg -export-dynamic) 71854cd6a3aeSmrg export_dynamic=yes 71864cd6a3aeSmrg continue 71874cd6a3aeSmrg ;; 71884cd6a3aeSmrg 71894cd6a3aeSmrg -export-symbols | -export-symbols-regex) 71904cd6a3aeSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 71914cd6a3aeSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 71924cd6a3aeSmrg fi 719354044362Smrg if test X-export-symbols = "X$arg"; then 71944cd6a3aeSmrg prev=expsyms 71954cd6a3aeSmrg else 71964cd6a3aeSmrg prev=expsyms_regex 71974cd6a3aeSmrg fi 71984cd6a3aeSmrg continue 71994cd6a3aeSmrg ;; 72004cd6a3aeSmrg 72014cd6a3aeSmrg -framework) 72024cd6a3aeSmrg prev=framework 72034cd6a3aeSmrg continue 72044cd6a3aeSmrg ;; 72054cd6a3aeSmrg 72064cd6a3aeSmrg -inst-prefix-dir) 72074cd6a3aeSmrg prev=inst_prefix 72084cd6a3aeSmrg continue 72094cd6a3aeSmrg ;; 72104cd6a3aeSmrg 72114cd6a3aeSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 72124cd6a3aeSmrg # so, if we see these flags be careful not to treat them like -L 72134cd6a3aeSmrg -L[A-Z][A-Z]*:*) 72144cd6a3aeSmrg case $with_gcc/$host in 72154cd6a3aeSmrg no/*-*-irix* | /*-*-irix*) 72164cd6a3aeSmrg func_append compile_command " $arg" 72174cd6a3aeSmrg func_append finalize_command " $arg" 72184cd6a3aeSmrg ;; 72194cd6a3aeSmrg esac 72204cd6a3aeSmrg continue 72214cd6a3aeSmrg ;; 72224cd6a3aeSmrg 72234cd6a3aeSmrg -L*) 72244cd6a3aeSmrg func_stripname "-L" '' "$arg" 72254cd6a3aeSmrg if test -z "$func_stripname_result"; then 72264cd6a3aeSmrg if test "$#" -gt 0; then 722754044362Smrg func_fatal_error "require no space between '-L' and '$1'" 72284cd6a3aeSmrg else 722954044362Smrg func_fatal_error "need path for '-L' option" 72304cd6a3aeSmrg fi 72314cd6a3aeSmrg fi 72324cd6a3aeSmrg func_resolve_sysroot "$func_stripname_result" 72334cd6a3aeSmrg dir=$func_resolve_sysroot_result 72344cd6a3aeSmrg # We need an absolute path. 72354cd6a3aeSmrg case $dir in 72364cd6a3aeSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 72374cd6a3aeSmrg *) 72384cd6a3aeSmrg absdir=`cd "$dir" && pwd` 72394cd6a3aeSmrg test -z "$absdir" && \ 724054044362Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 724154044362Smrg dir=$absdir 72424cd6a3aeSmrg ;; 72434cd6a3aeSmrg esac 72444cd6a3aeSmrg case "$deplibs " in 72454cd6a3aeSmrg *" -L$dir "* | *" $arg "*) 72464cd6a3aeSmrg # Will only happen for absolute or sysroot arguments 72474cd6a3aeSmrg ;; 72484cd6a3aeSmrg *) 72494cd6a3aeSmrg # Preserve sysroot, but never include relative directories 72504cd6a3aeSmrg case $dir in 72514cd6a3aeSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 72524cd6a3aeSmrg *) func_append deplibs " -L$dir" ;; 72534cd6a3aeSmrg esac 72544cd6a3aeSmrg func_append lib_search_path " $dir" 72554cd6a3aeSmrg ;; 72564cd6a3aeSmrg esac 72574cd6a3aeSmrg case $host in 72584cd6a3aeSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 72594cd6a3aeSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 72604cd6a3aeSmrg case :$dllsearchpath: in 72614cd6a3aeSmrg *":$dir:"*) ;; 72624cd6a3aeSmrg ::) dllsearchpath=$dir;; 72634cd6a3aeSmrg *) func_append dllsearchpath ":$dir";; 72644cd6a3aeSmrg esac 72654cd6a3aeSmrg case :$dllsearchpath: in 72664cd6a3aeSmrg *":$testbindir:"*) ;; 72674cd6a3aeSmrg ::) dllsearchpath=$testbindir;; 72684cd6a3aeSmrg *) func_append dllsearchpath ":$testbindir";; 72694cd6a3aeSmrg esac 72704cd6a3aeSmrg ;; 72714cd6a3aeSmrg esac 72724cd6a3aeSmrg continue 72734cd6a3aeSmrg ;; 72744cd6a3aeSmrg 72754cd6a3aeSmrg -l*) 727654044362Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 72774cd6a3aeSmrg case $host in 72784cd6a3aeSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 72794cd6a3aeSmrg # These systems don't actually have a C or math library (as such) 72804cd6a3aeSmrg continue 72814cd6a3aeSmrg ;; 72824cd6a3aeSmrg *-*-os2*) 72834cd6a3aeSmrg # These systems don't actually have a C library (as such) 728454044362Smrg test X-lc = "X$arg" && continue 72854cd6a3aeSmrg ;; 728654cef2ddSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 72874cd6a3aeSmrg # Do not include libc due to us having libc/libc_r. 728854044362Smrg test X-lc = "X$arg" && continue 72894cd6a3aeSmrg ;; 72904cd6a3aeSmrg *-*-rhapsody* | *-*-darwin1.[012]) 72914cd6a3aeSmrg # Rhapsody C and math libraries are in the System framework 72924cd6a3aeSmrg func_append deplibs " System.ltframework" 72934cd6a3aeSmrg continue 72944cd6a3aeSmrg ;; 72954cd6a3aeSmrg *-*-sco3.2v5* | *-*-sco5v6*) 72964cd6a3aeSmrg # Causes problems with __ctype 729754044362Smrg test X-lc = "X$arg" && continue 72984cd6a3aeSmrg ;; 72994cd6a3aeSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 73004cd6a3aeSmrg # Compiler inserts libc in the correct place for threads to work 730154044362Smrg test X-lc = "X$arg" && continue 73024cd6a3aeSmrg ;; 73034cd6a3aeSmrg esac 730454044362Smrg elif test X-lc_r = "X$arg"; then 73054cd6a3aeSmrg case $host in 730654cef2ddSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 73074cd6a3aeSmrg # Do not include libc_r directly, use -pthread flag. 73084cd6a3aeSmrg continue 73094cd6a3aeSmrg ;; 73104cd6a3aeSmrg esac 73114cd6a3aeSmrg fi 73124cd6a3aeSmrg func_append deplibs " $arg" 73134cd6a3aeSmrg continue 73144cd6a3aeSmrg ;; 73154cd6a3aeSmrg 731654044362Smrg -mllvm) 731754044362Smrg prev=mllvm 731854044362Smrg continue 731954044362Smrg ;; 732054044362Smrg 73214cd6a3aeSmrg -module) 73224cd6a3aeSmrg module=yes 73234cd6a3aeSmrg continue 73244cd6a3aeSmrg ;; 73254cd6a3aeSmrg 73264cd6a3aeSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 73274cd6a3aeSmrg # classes, name mangling, and exception handling. 73284cd6a3aeSmrg # Darwin uses the -arch flag to determine output architecture. 73294cd6a3aeSmrg -model|-arch|-isysroot|--sysroot) 73304cd6a3aeSmrg func_append compiler_flags " $arg" 73314cd6a3aeSmrg func_append compile_command " $arg" 73324cd6a3aeSmrg func_append finalize_command " $arg" 73334cd6a3aeSmrg prev=xcompiler 73344cd6a3aeSmrg continue 73354cd6a3aeSmrg ;; 733654cef2ddSmrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 733754cef2ddSmrg -pthread) 733854cef2ddSmrg case $host in 733954cef2ddSmrg *solaris2*) ;; 734054cef2ddSmrg *) 734154cef2ddSmrg case "$new_inherited_linker_flags " in 734254cef2ddSmrg *" $arg "*) ;; 734354cef2ddSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 734454cef2ddSmrg esac 734554cef2ddSmrg ;; 734654cef2ddSmrg esac 734754cef2ddSmrg continue 734854cef2ddSmrg ;; 734954cef2ddSmrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 735070728a38Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 73514cd6a3aeSmrg func_append compiler_flags " $arg" 73524cd6a3aeSmrg func_append compile_command " $arg" 73534cd6a3aeSmrg func_append finalize_command " $arg" 73544cd6a3aeSmrg case "$new_inherited_linker_flags " in 73554cd6a3aeSmrg *" $arg "*) ;; 73564cd6a3aeSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73574cd6a3aeSmrg esac 73589ab56c27Smrg 73599ab56c27Smrg # As we are forced to pass -nostdlib to g++ during linking, the option 73609ab56c27Smrg # -pthread{,s} is not in effect; add the -lpthread to $deplist 73619ab56c27Smrg # explicitly to link correctly. 73629ab56c27Smrg if test "$tagname" = CXX -a x"$with_gcc" = xyes; then 73639ab56c27Smrg case "$arg" in 73649ab56c27Smrg -pthread*) func_append deplibs " -lpthread" ;; 73659ab56c27Smrg esac 73669ab56c27Smrg fi 73679ab56c27Smrg 73684cd6a3aeSmrg continue 73694cd6a3aeSmrg ;; 73704cd6a3aeSmrg 73714cd6a3aeSmrg -multi_module) 737254044362Smrg single_module=$wl-multi_module 73734cd6a3aeSmrg continue 73744cd6a3aeSmrg ;; 73754cd6a3aeSmrg 73764cd6a3aeSmrg -no-fast-install) 73774cd6a3aeSmrg fast_install=no 73784cd6a3aeSmrg continue 73794cd6a3aeSmrg ;; 73804cd6a3aeSmrg 73814cd6a3aeSmrg -no-install) 73824cd6a3aeSmrg case $host in 73834cd6a3aeSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 73844cd6a3aeSmrg # The PATH hackery in wrapper scripts is required on Windows 73854cd6a3aeSmrg # and Darwin in order for the loader to find any dlls it needs. 738654044362Smrg func_warning "'-no-install' is ignored for $host" 738754044362Smrg func_warning "assuming '-no-fast-install' instead" 73884cd6a3aeSmrg fast_install=no 73894cd6a3aeSmrg ;; 73904cd6a3aeSmrg *) no_install=yes ;; 73914cd6a3aeSmrg esac 73924cd6a3aeSmrg continue 73934cd6a3aeSmrg ;; 73944cd6a3aeSmrg 73954cd6a3aeSmrg -no-undefined) 73964cd6a3aeSmrg allow_undefined=no 73974cd6a3aeSmrg continue 73984cd6a3aeSmrg ;; 73994cd6a3aeSmrg 74004cd6a3aeSmrg -objectlist) 74014cd6a3aeSmrg prev=objectlist 74024cd6a3aeSmrg continue 74034cd6a3aeSmrg ;; 74044cd6a3aeSmrg 740554044362Smrg -os2dllname) 740654044362Smrg prev=os2dllname 740754044362Smrg continue 740854044362Smrg ;; 740954044362Smrg 74104cd6a3aeSmrg -o) prev=output ;; 74114cd6a3aeSmrg 74124cd6a3aeSmrg -precious-files-regex) 74134cd6a3aeSmrg prev=precious_regex 74144cd6a3aeSmrg continue 74154cd6a3aeSmrg ;; 74164cd6a3aeSmrg 74174cd6a3aeSmrg -release) 74184cd6a3aeSmrg prev=release 74194cd6a3aeSmrg continue 74204cd6a3aeSmrg ;; 74214cd6a3aeSmrg 74224cd6a3aeSmrg -rpath) 74234cd6a3aeSmrg prev=rpath 74244cd6a3aeSmrg continue 74254cd6a3aeSmrg ;; 74264cd6a3aeSmrg 74274cd6a3aeSmrg -R) 74284cd6a3aeSmrg prev=xrpath 74294cd6a3aeSmrg continue 74304cd6a3aeSmrg ;; 74314cd6a3aeSmrg 74324cd6a3aeSmrg -R*) 74334cd6a3aeSmrg func_stripname '-R' '' "$arg" 74344cd6a3aeSmrg dir=$func_stripname_result 74354cd6a3aeSmrg # We need an absolute path. 74364cd6a3aeSmrg case $dir in 74374cd6a3aeSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 74384cd6a3aeSmrg =*) 74394cd6a3aeSmrg func_stripname '=' '' "$dir" 74404cd6a3aeSmrg dir=$lt_sysroot$func_stripname_result 74414cd6a3aeSmrg ;; 74424cd6a3aeSmrg *) 74434cd6a3aeSmrg func_fatal_error "only absolute run-paths are allowed" 74444cd6a3aeSmrg ;; 74454cd6a3aeSmrg esac 74464cd6a3aeSmrg case "$xrpath " in 74474cd6a3aeSmrg *" $dir "*) ;; 74484cd6a3aeSmrg *) func_append xrpath " $dir" ;; 74494cd6a3aeSmrg esac 74504cd6a3aeSmrg continue 74514cd6a3aeSmrg ;; 74524cd6a3aeSmrg 74534cd6a3aeSmrg -shared) 74544cd6a3aeSmrg # The effects of -shared are defined in a previous loop. 74554cd6a3aeSmrg continue 74564cd6a3aeSmrg ;; 74574cd6a3aeSmrg 74584cd6a3aeSmrg -shrext) 74594cd6a3aeSmrg prev=shrext 74604cd6a3aeSmrg continue 74614cd6a3aeSmrg ;; 74624cd6a3aeSmrg 74634cd6a3aeSmrg -static | -static-libtool-libs) 74644cd6a3aeSmrg # The effects of -static are defined in a previous loop. 74654cd6a3aeSmrg # We used to do the same as -all-static on platforms that 74664cd6a3aeSmrg # didn't have a PIC flag, but the assumption that the effects 74674cd6a3aeSmrg # would be equivalent was wrong. It would break on at least 74684cd6a3aeSmrg # Digital Unix and AIX. 74694cd6a3aeSmrg continue 74704cd6a3aeSmrg ;; 74714cd6a3aeSmrg 74724cd6a3aeSmrg -thread-safe) 74734cd6a3aeSmrg thread_safe=yes 74744cd6a3aeSmrg continue 74754cd6a3aeSmrg ;; 74764cd6a3aeSmrg 74774cd6a3aeSmrg -version-info) 74784cd6a3aeSmrg prev=vinfo 74794cd6a3aeSmrg continue 74804cd6a3aeSmrg ;; 74814cd6a3aeSmrg 74824cd6a3aeSmrg -version-number) 74834cd6a3aeSmrg prev=vinfo 74844cd6a3aeSmrg vinfo_number=yes 74854cd6a3aeSmrg continue 74864cd6a3aeSmrg ;; 74874cd6a3aeSmrg 74884cd6a3aeSmrg -weak) 74894cd6a3aeSmrg prev=weak 74904cd6a3aeSmrg continue 74914cd6a3aeSmrg ;; 74924cd6a3aeSmrg 74934cd6a3aeSmrg -Wc,*) 74944cd6a3aeSmrg func_stripname '-Wc,' '' "$arg" 74954cd6a3aeSmrg args=$func_stripname_result 74964cd6a3aeSmrg arg= 749754044362Smrg save_ifs=$IFS; IFS=, 74984cd6a3aeSmrg for flag in $args; do 749954044362Smrg IFS=$save_ifs 750054cef2ddSmrg func_quote_arg pretty "$flag" 750154cef2ddSmrg func_append arg " $func_quote_arg_result" 750254cef2ddSmrg func_append compiler_flags " $func_quote_arg_result" 75034cd6a3aeSmrg done 750454044362Smrg IFS=$save_ifs 75054cd6a3aeSmrg func_stripname ' ' '' "$arg" 75064cd6a3aeSmrg arg=$func_stripname_result 75074cd6a3aeSmrg ;; 75084cd6a3aeSmrg 75094cd6a3aeSmrg -Wl,*) 75104cd6a3aeSmrg func_stripname '-Wl,' '' "$arg" 75114cd6a3aeSmrg args=$func_stripname_result 75124cd6a3aeSmrg arg= 751354044362Smrg save_ifs=$IFS; IFS=, 75144cd6a3aeSmrg for flag in $args; do 751554044362Smrg IFS=$save_ifs 751654cef2ddSmrg func_quote_arg pretty "$flag" 751754cef2ddSmrg func_append arg " $wl$func_quote_arg_result" 751854cef2ddSmrg func_append compiler_flags " $wl$func_quote_arg_result" 751954cef2ddSmrg func_append linker_flags " $func_quote_arg_result" 75204cd6a3aeSmrg done 752154044362Smrg IFS=$save_ifs 75224cd6a3aeSmrg func_stripname ' ' '' "$arg" 75234cd6a3aeSmrg arg=$func_stripname_result 75244cd6a3aeSmrg ;; 75254cd6a3aeSmrg 752654cef2ddSmrg -Xassembler) 752754cef2ddSmrg prev=xassembler 752854cef2ddSmrg continue 752954cef2ddSmrg ;; 753054cef2ddSmrg 75314cd6a3aeSmrg -Xcompiler) 75324cd6a3aeSmrg prev=xcompiler 75334cd6a3aeSmrg continue 75344cd6a3aeSmrg ;; 75354cd6a3aeSmrg 75364cd6a3aeSmrg -Xlinker) 75374cd6a3aeSmrg prev=xlinker 75384cd6a3aeSmrg continue 75394cd6a3aeSmrg ;; 75404cd6a3aeSmrg 75414cd6a3aeSmrg -XCClinker) 75424cd6a3aeSmrg prev=xcclinker 75434cd6a3aeSmrg continue 75444cd6a3aeSmrg ;; 75454cd6a3aeSmrg 75464cd6a3aeSmrg # -msg_* for osf cc 75474cd6a3aeSmrg -msg_*) 754854cef2ddSmrg func_quote_arg pretty "$arg" 754954cef2ddSmrg arg=$func_quote_arg_result 75504cd6a3aeSmrg ;; 75514cd6a3aeSmrg 75524cd6a3aeSmrg # Flags to be passed through unchanged, with rationale: 75534cd6a3aeSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 75544cd6a3aeSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 75554cd6a3aeSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 75564cd6a3aeSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 75574cd6a3aeSmrg # -q* compiler args for the IBM compiler 75584cd6a3aeSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 75594cd6a3aeSmrg # -F/path path to uninstalled frameworks, gcc on darwin 75604cd6a3aeSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 756154044362Smrg # -fstack-protector* stack protector flags for GCC 75624cd6a3aeSmrg # @file GCC response files 75634cd6a3aeSmrg # -tp=* Portland pgcc target processor selection 75644cd6a3aeSmrg # --sysroot=* for sysroot support 756554044362Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 756654cef2ddSmrg # -specs=* GCC specs files 756754044362Smrg # -stdlib=* select c++ std lib with clang 756854cef2ddSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 756954cef2ddSmrg # -fuse-ld=* Linker select flags for GCC 757054cef2ddSmrg # -Wa,* Pass flags directly to the assembler 75714cd6a3aeSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 75724cd6a3aeSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 757354cef2ddSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 757454cef2ddSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 757554cef2ddSmrg func_quote_arg pretty "$arg" 757654cef2ddSmrg arg=$func_quote_arg_result 75774cd6a3aeSmrg func_append compile_command " $arg" 75784cd6a3aeSmrg func_append finalize_command " $arg" 75794cd6a3aeSmrg func_append compiler_flags " $arg" 75804cd6a3aeSmrg continue 75814cd6a3aeSmrg ;; 75824cd6a3aeSmrg 758354044362Smrg -Z*) 758454044362Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 758554044362Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 758654044362Smrg compiler_flags="$compiler_flags $arg" 758754044362Smrg func_append compile_command " $arg" 758854044362Smrg func_append finalize_command " $arg" 758954044362Smrg case $arg in 759054044362Smrg -Zlinker | -Zstack) 759154044362Smrg prev=xcompiler 759254044362Smrg ;; 759354044362Smrg esac 759454044362Smrg continue 759554044362Smrg else 759654044362Smrg # Otherwise treat like 'Some other compiler flag' below 759754cef2ddSmrg func_quote_arg pretty "$arg" 759854cef2ddSmrg arg=$func_quote_arg_result 759954044362Smrg fi 760054044362Smrg ;; 760154044362Smrg 76024cd6a3aeSmrg # Some other compiler flag. 76034cd6a3aeSmrg -* | +*) 760454cef2ddSmrg func_quote_arg pretty "$arg" 760554cef2ddSmrg arg=$func_quote_arg_result 76064cd6a3aeSmrg ;; 76074cd6a3aeSmrg 76084cd6a3aeSmrg *.$objext) 76094cd6a3aeSmrg # A standard object. 76104cd6a3aeSmrg func_append objs " $arg" 76114cd6a3aeSmrg ;; 76124cd6a3aeSmrg 76134cd6a3aeSmrg *.lo) 76144cd6a3aeSmrg # A libtool-controlled object. 76154cd6a3aeSmrg 76164cd6a3aeSmrg # Check to see that this really is a libtool object. 76174cd6a3aeSmrg if func_lalib_unsafe_p "$arg"; then 76184cd6a3aeSmrg pic_object= 76194cd6a3aeSmrg non_pic_object= 76204cd6a3aeSmrg 76214cd6a3aeSmrg # Read the .lo file 76224cd6a3aeSmrg func_source "$arg" 76234cd6a3aeSmrg 76244cd6a3aeSmrg if test -z "$pic_object" || 76254cd6a3aeSmrg test -z "$non_pic_object" || 762654044362Smrg test none = "$pic_object" && 762754044362Smrg test none = "$non_pic_object"; then 762854044362Smrg func_fatal_error "cannot find name of object for '$arg'" 76294cd6a3aeSmrg fi 76304cd6a3aeSmrg 76314cd6a3aeSmrg # Extract subdirectory from the argument. 76324cd6a3aeSmrg func_dirname "$arg" "/" "" 763354044362Smrg xdir=$func_dirname_result 76344cd6a3aeSmrg 763554044362Smrg test none = "$pic_object" || { 76364cd6a3aeSmrg # Prepend the subdirectory the object is found in. 763754044362Smrg pic_object=$xdir$pic_object 76384cd6a3aeSmrg 763954044362Smrg if test dlfiles = "$prev"; then 764054044362Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 76414cd6a3aeSmrg func_append dlfiles " $pic_object" 76424cd6a3aeSmrg prev= 76434cd6a3aeSmrg continue 76444cd6a3aeSmrg else 76454cd6a3aeSmrg # If libtool objects are unsupported, then we need to preload. 76464cd6a3aeSmrg prev=dlprefiles 76474cd6a3aeSmrg fi 76484cd6a3aeSmrg fi 76494cd6a3aeSmrg 76504cd6a3aeSmrg # CHECK ME: I think I busted this. -Ossama 765154044362Smrg if test dlprefiles = "$prev"; then 76524cd6a3aeSmrg # Preload the old-style object. 76534cd6a3aeSmrg func_append dlprefiles " $pic_object" 76544cd6a3aeSmrg prev= 76554cd6a3aeSmrg fi 76564cd6a3aeSmrg 76574cd6a3aeSmrg # A PIC object. 76584cd6a3aeSmrg func_append libobjs " $pic_object" 765954044362Smrg arg=$pic_object 766054044362Smrg } 76614cd6a3aeSmrg 76624cd6a3aeSmrg # Non-PIC object. 766354044362Smrg if test none != "$non_pic_object"; then 76644cd6a3aeSmrg # Prepend the subdirectory the object is found in. 766554044362Smrg non_pic_object=$xdir$non_pic_object 76664cd6a3aeSmrg 76674cd6a3aeSmrg # A standard non-PIC object 76684cd6a3aeSmrg func_append non_pic_objects " $non_pic_object" 766954044362Smrg if test -z "$pic_object" || test none = "$pic_object"; then 767054044362Smrg arg=$non_pic_object 76714cd6a3aeSmrg fi 76724cd6a3aeSmrg else 76734cd6a3aeSmrg # If the PIC object exists, use it instead. 76744cd6a3aeSmrg # $xdir was prepended to $pic_object above. 767554044362Smrg non_pic_object=$pic_object 76764cd6a3aeSmrg func_append non_pic_objects " $non_pic_object" 76774cd6a3aeSmrg fi 76784cd6a3aeSmrg else 76794cd6a3aeSmrg # Only an error if not doing a dry-run. 76804cd6a3aeSmrg if $opt_dry_run; then 76814cd6a3aeSmrg # Extract subdirectory from the argument. 76824cd6a3aeSmrg func_dirname "$arg" "/" "" 768354044362Smrg xdir=$func_dirname_result 76844cd6a3aeSmrg 76854cd6a3aeSmrg func_lo2o "$arg" 76864cd6a3aeSmrg pic_object=$xdir$objdir/$func_lo2o_result 76874cd6a3aeSmrg non_pic_object=$xdir$func_lo2o_result 76884cd6a3aeSmrg func_append libobjs " $pic_object" 76894cd6a3aeSmrg func_append non_pic_objects " $non_pic_object" 76904cd6a3aeSmrg else 769154044362Smrg func_fatal_error "'$arg' is not a valid libtool object" 76924cd6a3aeSmrg fi 76934cd6a3aeSmrg fi 76944cd6a3aeSmrg ;; 76954cd6a3aeSmrg 76964cd6a3aeSmrg *.$libext) 76974cd6a3aeSmrg # An archive. 76984cd6a3aeSmrg func_append deplibs " $arg" 76994cd6a3aeSmrg func_append old_deplibs " $arg" 77004cd6a3aeSmrg continue 77014cd6a3aeSmrg ;; 77024cd6a3aeSmrg 77034cd6a3aeSmrg *.la) 77044cd6a3aeSmrg # A libtool-controlled library. 77054cd6a3aeSmrg 77064cd6a3aeSmrg func_resolve_sysroot "$arg" 770754044362Smrg if test dlfiles = "$prev"; then 77084cd6a3aeSmrg # This library was specified with -dlopen. 77094cd6a3aeSmrg func_append dlfiles " $func_resolve_sysroot_result" 77104cd6a3aeSmrg prev= 771154044362Smrg elif test dlprefiles = "$prev"; then 77124cd6a3aeSmrg # The library was specified with -dlpreopen. 77134cd6a3aeSmrg func_append dlprefiles " $func_resolve_sysroot_result" 77144cd6a3aeSmrg prev= 77154cd6a3aeSmrg else 77164cd6a3aeSmrg func_append deplibs " $func_resolve_sysroot_result" 77174cd6a3aeSmrg fi 77184cd6a3aeSmrg continue 77194cd6a3aeSmrg ;; 77204cd6a3aeSmrg 77214cd6a3aeSmrg # Some other compiler argument. 77224cd6a3aeSmrg *) 77234cd6a3aeSmrg # Unknown arguments in both finalize_command and compile_command need 77244cd6a3aeSmrg # to be aesthetically quoted because they are evaled later. 772554cef2ddSmrg func_quote_arg pretty "$arg" 772654cef2ddSmrg arg=$func_quote_arg_result 77274cd6a3aeSmrg ;; 77284cd6a3aeSmrg esac # arg 77294cd6a3aeSmrg 77304cd6a3aeSmrg # Now actually substitute the argument into the commands. 77314cd6a3aeSmrg if test -n "$arg"; then 77324cd6a3aeSmrg func_append compile_command " $arg" 77334cd6a3aeSmrg func_append finalize_command " $arg" 77344cd6a3aeSmrg fi 77354cd6a3aeSmrg done # argument parsing loop 77364cd6a3aeSmrg 77374cd6a3aeSmrg test -n "$prev" && \ 773854044362Smrg func_fatal_help "the '$prevarg' option requires an argument" 77394cd6a3aeSmrg 774054044362Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 77414cd6a3aeSmrg eval arg=\"$export_dynamic_flag_spec\" 77424cd6a3aeSmrg func_append compile_command " $arg" 77434cd6a3aeSmrg func_append finalize_command " $arg" 77444cd6a3aeSmrg fi 77454cd6a3aeSmrg 77464cd6a3aeSmrg oldlibs= 77474cd6a3aeSmrg # calculate the name of the file, without its directory 77484cd6a3aeSmrg func_basename "$output" 774954044362Smrg outputname=$func_basename_result 775054044362Smrg libobjs_save=$libobjs 77514cd6a3aeSmrg 77524cd6a3aeSmrg if test -n "$shlibpath_var"; then 77534cd6a3aeSmrg # get the directories listed in $shlibpath_var 775454044362Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77554cd6a3aeSmrg else 77564cd6a3aeSmrg shlib_search_path= 77574cd6a3aeSmrg fi 77584cd6a3aeSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 77594cd6a3aeSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77604cd6a3aeSmrg 776154044362Smrg # Definition is injected by LT_CONFIG during libtool generation. 776254044362Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 776354044362Smrg 77644cd6a3aeSmrg func_dirname "$output" "/" "" 776554044362Smrg output_objdir=$func_dirname_result$objdir 77664cd6a3aeSmrg func_to_tool_file "$output_objdir/" 77674cd6a3aeSmrg tool_output_objdir=$func_to_tool_file_result 77684cd6a3aeSmrg # Create the object directory. 77694cd6a3aeSmrg func_mkdir_p "$output_objdir" 77704cd6a3aeSmrg 77714cd6a3aeSmrg # Determine the type of output 77724cd6a3aeSmrg case $output in 77734cd6a3aeSmrg "") 77744cd6a3aeSmrg func_fatal_help "you must specify an output file" 77754cd6a3aeSmrg ;; 77764cd6a3aeSmrg *.$libext) linkmode=oldlib ;; 77774cd6a3aeSmrg *.lo | *.$objext) linkmode=obj ;; 77784cd6a3aeSmrg *.la) linkmode=lib ;; 77794cd6a3aeSmrg *) linkmode=prog ;; # Anything else should be a program. 77804cd6a3aeSmrg esac 77814cd6a3aeSmrg 77824cd6a3aeSmrg specialdeplibs= 77834cd6a3aeSmrg 77844cd6a3aeSmrg libs= 77854cd6a3aeSmrg # Find all interdependent deplibs by searching for libraries 77864cd6a3aeSmrg # that are linked more than once (e.g. -la -lb -la) 77874cd6a3aeSmrg for deplib in $deplibs; do 778854044362Smrg if $opt_preserve_dup_deps; then 77894cd6a3aeSmrg case "$libs " in 77904cd6a3aeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 77914cd6a3aeSmrg esac 77924cd6a3aeSmrg fi 77934cd6a3aeSmrg func_append libs " $deplib" 77944cd6a3aeSmrg done 77954cd6a3aeSmrg 779654044362Smrg if test lib = "$linkmode"; then 77974cd6a3aeSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 77984cd6a3aeSmrg 77994cd6a3aeSmrg # Compute libraries that are listed more than once in $predeps 78004cd6a3aeSmrg # $postdeps and mark them as special (i.e., whose duplicates are 78014cd6a3aeSmrg # not to be eliminated). 78024cd6a3aeSmrg pre_post_deps= 78034cd6a3aeSmrg if $opt_duplicate_compiler_generated_deps; then 78044cd6a3aeSmrg for pre_post_dep in $predeps $postdeps; do 78054cd6a3aeSmrg case "$pre_post_deps " in 78064cd6a3aeSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 78074cd6a3aeSmrg esac 78084cd6a3aeSmrg func_append pre_post_deps " $pre_post_dep" 78094cd6a3aeSmrg done 78104cd6a3aeSmrg fi 78114cd6a3aeSmrg pre_post_deps= 78124cd6a3aeSmrg fi 78134cd6a3aeSmrg 78144cd6a3aeSmrg deplibs= 78154cd6a3aeSmrg newdependency_libs= 78164cd6a3aeSmrg newlib_search_path= 78174cd6a3aeSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 78184cd6a3aeSmrg notinst_deplibs= # not-installed libtool libraries 78194cd6a3aeSmrg notinst_path= # paths that contain not-installed libtool libraries 78204cd6a3aeSmrg 78214cd6a3aeSmrg case $linkmode in 78224cd6a3aeSmrg lib) 78234cd6a3aeSmrg passes="conv dlpreopen link" 78244cd6a3aeSmrg for file in $dlfiles $dlprefiles; do 78254cd6a3aeSmrg case $file in 78264cd6a3aeSmrg *.la) ;; 78274cd6a3aeSmrg *) 782854044362Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 78294cd6a3aeSmrg ;; 78304cd6a3aeSmrg esac 78314cd6a3aeSmrg done 78324cd6a3aeSmrg ;; 78334cd6a3aeSmrg prog) 78344cd6a3aeSmrg compile_deplibs= 78354cd6a3aeSmrg finalize_deplibs= 783654044362Smrg alldeplibs=false 78374cd6a3aeSmrg newdlfiles= 78384cd6a3aeSmrg newdlprefiles= 78394cd6a3aeSmrg passes="conv scan dlopen dlpreopen link" 78404cd6a3aeSmrg ;; 78414cd6a3aeSmrg *) passes="conv" 78424cd6a3aeSmrg ;; 78434cd6a3aeSmrg esac 78444cd6a3aeSmrg 78454cd6a3aeSmrg for pass in $passes; do 78464cd6a3aeSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 78474cd6a3aeSmrg # so that -L comes before libs that need it for instance... 784854044362Smrg if test lib,link = "$linkmode,$pass"; then 78494cd6a3aeSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 78504cd6a3aeSmrg ## order, and fix it there properly 78514cd6a3aeSmrg tmp_deplibs= 78524cd6a3aeSmrg for deplib in $deplibs; do 78534cd6a3aeSmrg tmp_deplibs="$deplib $tmp_deplibs" 78544cd6a3aeSmrg done 785554044362Smrg deplibs=$tmp_deplibs 78564cd6a3aeSmrg fi 78574cd6a3aeSmrg 785854044362Smrg if test lib,link = "$linkmode,$pass" || 785954044362Smrg test prog,scan = "$linkmode,$pass"; then 786054044362Smrg libs=$deplibs 78614cd6a3aeSmrg deplibs= 78624cd6a3aeSmrg fi 786354044362Smrg if test prog = "$linkmode"; then 78644cd6a3aeSmrg case $pass in 786554044362Smrg dlopen) libs=$dlfiles ;; 786654044362Smrg dlpreopen) libs=$dlprefiles ;; 78674cd6a3aeSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 78684cd6a3aeSmrg esac 78694cd6a3aeSmrg fi 787054044362Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 78714cd6a3aeSmrg # Collect and forward deplibs of preopened libtool libs 78724cd6a3aeSmrg for lib in $dlprefiles; do 78734cd6a3aeSmrg # Ignore non-libtool-libs 78744cd6a3aeSmrg dependency_libs= 78754cd6a3aeSmrg func_resolve_sysroot "$lib" 78764cd6a3aeSmrg case $lib in 78774cd6a3aeSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 78784cd6a3aeSmrg esac 78794cd6a3aeSmrg 78804cd6a3aeSmrg # Collect preopened libtool deplibs, except any this library 78814cd6a3aeSmrg # has declared as weak libs 78824cd6a3aeSmrg for deplib in $dependency_libs; do 78834cd6a3aeSmrg func_basename "$deplib" 78844cd6a3aeSmrg deplib_base=$func_basename_result 78854cd6a3aeSmrg case " $weak_libs " in 78864cd6a3aeSmrg *" $deplib_base "*) ;; 78874cd6a3aeSmrg *) func_append deplibs " $deplib" ;; 78884cd6a3aeSmrg esac 78894cd6a3aeSmrg done 78904cd6a3aeSmrg done 789154044362Smrg libs=$dlprefiles 78924cd6a3aeSmrg fi 789354044362Smrg if test dlopen = "$pass"; then 78944cd6a3aeSmrg # Collect dlpreopened libraries 789554044362Smrg save_deplibs=$deplibs 78964cd6a3aeSmrg deplibs= 78974cd6a3aeSmrg fi 78984cd6a3aeSmrg 78994cd6a3aeSmrg for deplib in $libs; do 79004cd6a3aeSmrg lib= 790154044362Smrg found=false 79024cd6a3aeSmrg case $deplib in 790370728a38Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 790470728a38Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 790554044362Smrg if test prog,link = "$linkmode,$pass"; then 79064cd6a3aeSmrg compile_deplibs="$deplib $compile_deplibs" 79074cd6a3aeSmrg finalize_deplibs="$deplib $finalize_deplibs" 79084cd6a3aeSmrg else 79094cd6a3aeSmrg func_append compiler_flags " $deplib" 791054044362Smrg if test lib = "$linkmode"; then 79114cd6a3aeSmrg case "$new_inherited_linker_flags " in 79124cd6a3aeSmrg *" $deplib "*) ;; 79134cd6a3aeSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79144cd6a3aeSmrg esac 79154cd6a3aeSmrg fi 79164cd6a3aeSmrg fi 79174cd6a3aeSmrg continue 79184cd6a3aeSmrg ;; 79194cd6a3aeSmrg -l*) 792054044362Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 792154044362Smrg func_warning "'-l' is ignored for archives/objects" 79224cd6a3aeSmrg continue 79234cd6a3aeSmrg fi 79244cd6a3aeSmrg func_stripname '-l' '' "$deplib" 79254cd6a3aeSmrg name=$func_stripname_result 792654044362Smrg if test lib = "$linkmode"; then 79274cd6a3aeSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 79284cd6a3aeSmrg else 79294cd6a3aeSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 79304cd6a3aeSmrg fi 79314cd6a3aeSmrg for searchdir in $searchdirs; do 79324cd6a3aeSmrg for search_ext in .la $std_shrext .so .a; do 79334cd6a3aeSmrg # Search the libtool library 793454044362Smrg lib=$searchdir/lib$name$search_ext 79354cd6a3aeSmrg if test -f "$lib"; then 793654044362Smrg if test .la = "$search_ext"; then 793754044362Smrg found=: 79384cd6a3aeSmrg else 793954044362Smrg found=false 79404cd6a3aeSmrg fi 79414cd6a3aeSmrg break 2 79424cd6a3aeSmrg fi 79434cd6a3aeSmrg done 79444cd6a3aeSmrg done 794554044362Smrg if $found; then 794654044362Smrg # deplib is a libtool library 79474cd6a3aeSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 79484cd6a3aeSmrg # We need to do some special things here, and not later. 794954044362Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 79504cd6a3aeSmrg case " $predeps $postdeps " in 79514cd6a3aeSmrg *" $deplib "*) 79524cd6a3aeSmrg if func_lalib_p "$lib"; then 79534cd6a3aeSmrg library_names= 79544cd6a3aeSmrg old_library= 79554cd6a3aeSmrg func_source "$lib" 79564cd6a3aeSmrg for l in $old_library $library_names; do 795754044362Smrg ll=$l 79584cd6a3aeSmrg done 795954044362Smrg if test "X$ll" = "X$old_library"; then # only static version available 796054044362Smrg found=false 79614cd6a3aeSmrg func_dirname "$lib" "" "." 796254044362Smrg ladir=$func_dirname_result 79634cd6a3aeSmrg lib=$ladir/$old_library 796454044362Smrg if test prog,link = "$linkmode,$pass"; then 79654cd6a3aeSmrg compile_deplibs="$deplib $compile_deplibs" 79664cd6a3aeSmrg finalize_deplibs="$deplib $finalize_deplibs" 79674cd6a3aeSmrg else 79684cd6a3aeSmrg deplibs="$deplib $deplibs" 796954044362Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79704cd6a3aeSmrg fi 79714cd6a3aeSmrg continue 79724cd6a3aeSmrg fi 79734cd6a3aeSmrg fi 79744cd6a3aeSmrg ;; 79754cd6a3aeSmrg *) ;; 79764cd6a3aeSmrg esac 79774cd6a3aeSmrg fi 797854044362Smrg else 797954044362Smrg # deplib doesn't seem to be a libtool library 798054044362Smrg if test prog,link = "$linkmode,$pass"; then 798154044362Smrg compile_deplibs="$deplib $compile_deplibs" 798254044362Smrg finalize_deplibs="$deplib $finalize_deplibs" 798354044362Smrg else 798454044362Smrg deplibs="$deplib $deplibs" 798554044362Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 798654044362Smrg fi 798754044362Smrg continue 79884cd6a3aeSmrg fi 79894cd6a3aeSmrg ;; # -l 79904cd6a3aeSmrg *.ltframework) 799154044362Smrg if test prog,link = "$linkmode,$pass"; then 79924cd6a3aeSmrg compile_deplibs="$deplib $compile_deplibs" 79934cd6a3aeSmrg finalize_deplibs="$deplib $finalize_deplibs" 79944cd6a3aeSmrg else 79954cd6a3aeSmrg deplibs="$deplib $deplibs" 799654044362Smrg if test lib = "$linkmode"; then 79974cd6a3aeSmrg case "$new_inherited_linker_flags " in 79984cd6a3aeSmrg *" $deplib "*) ;; 79994cd6a3aeSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 80004cd6a3aeSmrg esac 80014cd6a3aeSmrg fi 80024cd6a3aeSmrg fi 80034cd6a3aeSmrg continue 80044cd6a3aeSmrg ;; 80054cd6a3aeSmrg -L*) 80064cd6a3aeSmrg case $linkmode in 80074cd6a3aeSmrg lib) 80084cd6a3aeSmrg deplibs="$deplib $deplibs" 800954044362Smrg test conv = "$pass" && continue 80104cd6a3aeSmrg newdependency_libs="$deplib $newdependency_libs" 80114cd6a3aeSmrg func_stripname '-L' '' "$deplib" 80124cd6a3aeSmrg func_resolve_sysroot "$func_stripname_result" 80134cd6a3aeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80144cd6a3aeSmrg ;; 80154cd6a3aeSmrg prog) 801654044362Smrg if test conv = "$pass"; then 80174cd6a3aeSmrg deplibs="$deplib $deplibs" 80184cd6a3aeSmrg continue 80194cd6a3aeSmrg fi 802054044362Smrg if test scan = "$pass"; then 80214cd6a3aeSmrg deplibs="$deplib $deplibs" 80224cd6a3aeSmrg else 80234cd6a3aeSmrg compile_deplibs="$deplib $compile_deplibs" 80244cd6a3aeSmrg finalize_deplibs="$deplib $finalize_deplibs" 80254cd6a3aeSmrg fi 80264cd6a3aeSmrg func_stripname '-L' '' "$deplib" 80274cd6a3aeSmrg func_resolve_sysroot "$func_stripname_result" 80284cd6a3aeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80294cd6a3aeSmrg ;; 80304cd6a3aeSmrg *) 803154044362Smrg func_warning "'-L' is ignored for archives/objects" 80324cd6a3aeSmrg ;; 80334cd6a3aeSmrg esac # linkmode 80344cd6a3aeSmrg continue 80354cd6a3aeSmrg ;; # -L 80364cd6a3aeSmrg -R*) 803754044362Smrg if test link = "$pass"; then 80384cd6a3aeSmrg func_stripname '-R' '' "$deplib" 80394cd6a3aeSmrg func_resolve_sysroot "$func_stripname_result" 80404cd6a3aeSmrg dir=$func_resolve_sysroot_result 80414cd6a3aeSmrg # Make sure the xrpath contains only unique directories. 80424cd6a3aeSmrg case "$xrpath " in 80434cd6a3aeSmrg *" $dir "*) ;; 80444cd6a3aeSmrg *) func_append xrpath " $dir" ;; 80454cd6a3aeSmrg esac 80464cd6a3aeSmrg fi 80474cd6a3aeSmrg deplibs="$deplib $deplibs" 80484cd6a3aeSmrg continue 80494cd6a3aeSmrg ;; 80504cd6a3aeSmrg *.la) 80514cd6a3aeSmrg func_resolve_sysroot "$deplib" 80524cd6a3aeSmrg lib=$func_resolve_sysroot_result 80534cd6a3aeSmrg ;; 80544cd6a3aeSmrg *.$libext) 805554044362Smrg if test conv = "$pass"; then 80564cd6a3aeSmrg deplibs="$deplib $deplibs" 80574cd6a3aeSmrg continue 80584cd6a3aeSmrg fi 80594cd6a3aeSmrg case $linkmode in 80604cd6a3aeSmrg lib) 80614cd6a3aeSmrg # Linking convenience modules into shared libraries is allowed, 80624cd6a3aeSmrg # but linking other static libraries is non-portable. 80634cd6a3aeSmrg case " $dlpreconveniencelibs " in 80644cd6a3aeSmrg *" $deplib "*) ;; 80654cd6a3aeSmrg *) 806654044362Smrg valid_a_lib=false 80674cd6a3aeSmrg case $deplibs_check_method in 80684cd6a3aeSmrg match_pattern*) 80694cd6a3aeSmrg set dummy $deplibs_check_method; shift 80704cd6a3aeSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 80714cd6a3aeSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 80724cd6a3aeSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 807354044362Smrg valid_a_lib=: 80744cd6a3aeSmrg fi 80754cd6a3aeSmrg ;; 80764cd6a3aeSmrg pass_all) 807754044362Smrg valid_a_lib=: 80784cd6a3aeSmrg ;; 80794cd6a3aeSmrg esac 808054044362Smrg if $valid_a_lib; then 808154044362Smrg echo 808254044362Smrg $ECHO "*** Warning: Linking the shared library $output against the" 808354044362Smrg $ECHO "*** static library $deplib is not portable!" 808454044362Smrg deplibs="$deplib $deplibs" 808554044362Smrg else 80864cd6a3aeSmrg echo 80874cd6a3aeSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 80884cd6a3aeSmrg echo "*** I have the capability to make that library automatically link in when" 80894cd6a3aeSmrg echo "*** you link to this library. But I can only do this if you have a" 80904cd6a3aeSmrg echo "*** shared version of the library, which you do not appear to have" 80914cd6a3aeSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 80924cd6a3aeSmrg echo "*** that it is just a static archive that I should not use here." 80934cd6a3aeSmrg fi 80944cd6a3aeSmrg ;; 80954cd6a3aeSmrg esac 80964cd6a3aeSmrg continue 80974cd6a3aeSmrg ;; 80984cd6a3aeSmrg prog) 809954044362Smrg if test link != "$pass"; then 81004cd6a3aeSmrg deplibs="$deplib $deplibs" 81014cd6a3aeSmrg else 81024cd6a3aeSmrg compile_deplibs="$deplib $compile_deplibs" 81034cd6a3aeSmrg finalize_deplibs="$deplib $finalize_deplibs" 81044cd6a3aeSmrg fi 81054cd6a3aeSmrg continue 81064cd6a3aeSmrg ;; 81074cd6a3aeSmrg esac # linkmode 81084cd6a3aeSmrg ;; # *.$libext 81094cd6a3aeSmrg *.lo | *.$objext) 811054044362Smrg if test conv = "$pass"; then 81114cd6a3aeSmrg deplibs="$deplib $deplibs" 811254044362Smrg elif test prog = "$linkmode"; then 811354044362Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 81144cd6a3aeSmrg # If there is no dlopen support or we're linking statically, 81154cd6a3aeSmrg # we need to preload. 81164cd6a3aeSmrg func_append newdlprefiles " $deplib" 81174cd6a3aeSmrg compile_deplibs="$deplib $compile_deplibs" 81184cd6a3aeSmrg finalize_deplibs="$deplib $finalize_deplibs" 81194cd6a3aeSmrg else 81204cd6a3aeSmrg func_append newdlfiles " $deplib" 81214cd6a3aeSmrg fi 81224cd6a3aeSmrg fi 81234cd6a3aeSmrg continue 81244cd6a3aeSmrg ;; 81254cd6a3aeSmrg %DEPLIBS%) 812654044362Smrg alldeplibs=: 81274cd6a3aeSmrg continue 81284cd6a3aeSmrg ;; 81294cd6a3aeSmrg esac # case $deplib 81304cd6a3aeSmrg 813154044362Smrg $found || test -f "$lib" \ 813254044362Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 81334cd6a3aeSmrg 81344cd6a3aeSmrg # Check to see that this really is a libtool archive. 81354cd6a3aeSmrg func_lalib_unsafe_p "$lib" \ 813654044362Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 81374cd6a3aeSmrg 81384cd6a3aeSmrg func_dirname "$lib" "" "." 813954044362Smrg ladir=$func_dirname_result 81404cd6a3aeSmrg 81414cd6a3aeSmrg dlname= 81424cd6a3aeSmrg dlopen= 81434cd6a3aeSmrg dlpreopen= 81444cd6a3aeSmrg libdir= 81454cd6a3aeSmrg library_names= 81464cd6a3aeSmrg old_library= 81474cd6a3aeSmrg inherited_linker_flags= 81484cd6a3aeSmrg # If the library was installed with an old release of libtool, 81494cd6a3aeSmrg # it will not redefine variables installed, or shouldnotlink 81504cd6a3aeSmrg installed=yes 81514cd6a3aeSmrg shouldnotlink=no 81524cd6a3aeSmrg avoidtemprpath= 81534cd6a3aeSmrg 81544cd6a3aeSmrg 81554cd6a3aeSmrg # Read the .la file 81564cd6a3aeSmrg func_source "$lib" 81574cd6a3aeSmrg 81584cd6a3aeSmrg # Convert "-framework foo" to "foo.ltframework" 81594cd6a3aeSmrg if test -n "$inherited_linker_flags"; then 81604cd6a3aeSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 81614cd6a3aeSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 81624cd6a3aeSmrg case " $new_inherited_linker_flags " in 81634cd6a3aeSmrg *" $tmp_inherited_linker_flag "*) ;; 81644cd6a3aeSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 81654cd6a3aeSmrg esac 81664cd6a3aeSmrg done 81674cd6a3aeSmrg fi 81684cd6a3aeSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 816954044362Smrg if test lib,link = "$linkmode,$pass" || 817054044362Smrg test prog,scan = "$linkmode,$pass" || 817154044362Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 81724cd6a3aeSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 81734cd6a3aeSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 81744cd6a3aeSmrg fi 81754cd6a3aeSmrg 817654044362Smrg if test conv = "$pass"; then 81774cd6a3aeSmrg # Only check for convenience libraries 81784cd6a3aeSmrg deplibs="$lib $deplibs" 81794cd6a3aeSmrg if test -z "$libdir"; then 81804cd6a3aeSmrg if test -z "$old_library"; then 818154044362Smrg func_fatal_error "cannot find name of link library for '$lib'" 81824cd6a3aeSmrg fi 81834cd6a3aeSmrg # It is a libtool convenience library, so add in its objects. 81844cd6a3aeSmrg func_append convenience " $ladir/$objdir/$old_library" 81854cd6a3aeSmrg func_append old_convenience " $ladir/$objdir/$old_library" 818654044362Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 818754044362Smrg func_fatal_error "'$lib' is not a convenience library" 81884cd6a3aeSmrg fi 81894cd6a3aeSmrg tmp_libs= 81904cd6a3aeSmrg for deplib in $dependency_libs; do 81914cd6a3aeSmrg deplibs="$deplib $deplibs" 819254044362Smrg if $opt_preserve_dup_deps; then 81934cd6a3aeSmrg case "$tmp_libs " in 81944cd6a3aeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 81954cd6a3aeSmrg esac 81964cd6a3aeSmrg fi 81974cd6a3aeSmrg func_append tmp_libs " $deplib" 81984cd6a3aeSmrg done 81994cd6a3aeSmrg continue 82004cd6a3aeSmrg fi # $pass = conv 82014cd6a3aeSmrg 82024cd6a3aeSmrg 82034cd6a3aeSmrg # Get the name of the library we link against. 82044cd6a3aeSmrg linklib= 82054cd6a3aeSmrg if test -n "$old_library" && 820654044362Smrg { test yes = "$prefer_static_libs" || 820754044362Smrg test built,no = "$prefer_static_libs,$installed"; }; then 82084cd6a3aeSmrg linklib=$old_library 82094cd6a3aeSmrg else 82104cd6a3aeSmrg for l in $old_library $library_names; do 821154044362Smrg linklib=$l 82124cd6a3aeSmrg done 82134cd6a3aeSmrg fi 82144cd6a3aeSmrg if test -z "$linklib"; then 821554044362Smrg func_fatal_error "cannot find name of link library for '$lib'" 82164cd6a3aeSmrg fi 82174cd6a3aeSmrg 82184cd6a3aeSmrg # This library was specified with -dlopen. 821954044362Smrg if test dlopen = "$pass"; then 822054044362Smrg test -z "$libdir" \ 822154044362Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 82224cd6a3aeSmrg if test -z "$dlname" || 822354044362Smrg test yes != "$dlopen_support" || 822454044362Smrg test no = "$build_libtool_libs" 822554044362Smrg then 82264cd6a3aeSmrg # If there is no dlname, no dlopen support or we're linking 82274cd6a3aeSmrg # statically, we need to preload. We also need to preload any 82284cd6a3aeSmrg # dependent libraries so libltdl's deplib preloader doesn't 82294cd6a3aeSmrg # bomb out in the load deplibs phase. 82304cd6a3aeSmrg func_append dlprefiles " $lib $dependency_libs" 82314cd6a3aeSmrg else 82324cd6a3aeSmrg func_append newdlfiles " $lib" 82334cd6a3aeSmrg fi 82344cd6a3aeSmrg continue 82354cd6a3aeSmrg fi # $pass = dlopen 82364cd6a3aeSmrg 82374cd6a3aeSmrg # We need an absolute path. 82384cd6a3aeSmrg case $ladir in 823954044362Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 82404cd6a3aeSmrg *) 82414cd6a3aeSmrg abs_ladir=`cd "$ladir" && pwd` 82424cd6a3aeSmrg if test -z "$abs_ladir"; then 824354044362Smrg func_warning "cannot determine absolute directory name of '$ladir'" 82444cd6a3aeSmrg func_warning "passing it literally to the linker, although it might fail" 824554044362Smrg abs_ladir=$ladir 82464cd6a3aeSmrg fi 82474cd6a3aeSmrg ;; 82484cd6a3aeSmrg esac 82494cd6a3aeSmrg func_basename "$lib" 825054044362Smrg laname=$func_basename_result 82514cd6a3aeSmrg 82524cd6a3aeSmrg # Find the relevant object directory and library name. 825354044362Smrg if test yes = "$installed"; then 82544cd6a3aeSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 825554044362Smrg func_warning "library '$lib' was moved." 825654044362Smrg dir=$ladir 825754044362Smrg absdir=$abs_ladir 825854044362Smrg libdir=$abs_ladir 82594cd6a3aeSmrg else 826054044362Smrg dir=$lt_sysroot$libdir 826154044362Smrg absdir=$lt_sysroot$libdir 82624cd6a3aeSmrg fi 826354044362Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 82644cd6a3aeSmrg else 82654cd6a3aeSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 826654044362Smrg dir=$ladir 826754044362Smrg absdir=$abs_ladir 82684cd6a3aeSmrg # Remove this search path later 82694cd6a3aeSmrg func_append notinst_path " $abs_ladir" 82704cd6a3aeSmrg else 827154044362Smrg dir=$ladir/$objdir 827254044362Smrg absdir=$abs_ladir/$objdir 82734cd6a3aeSmrg # Remove this search path later 82744cd6a3aeSmrg func_append notinst_path " $abs_ladir" 82754cd6a3aeSmrg fi 82764cd6a3aeSmrg fi # $installed = yes 82774cd6a3aeSmrg func_stripname 'lib' '.la' "$laname" 82784cd6a3aeSmrg name=$func_stripname_result 82794cd6a3aeSmrg 82804cd6a3aeSmrg # This library was specified with -dlpreopen. 828154044362Smrg if test dlpreopen = "$pass"; then 828254044362Smrg if test -z "$libdir" && test prog = "$linkmode"; then 828354044362Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 82844cd6a3aeSmrg fi 828554044362Smrg case $host in 82864cd6a3aeSmrg # special handling for platforms with PE-DLLs. 82874cd6a3aeSmrg *cygwin* | *mingw* | *cegcc* ) 82884cd6a3aeSmrg # Linker will automatically link against shared library if both 82894cd6a3aeSmrg # static and shared are present. Therefore, ensure we extract 82904cd6a3aeSmrg # symbols from the import library if a shared library is present 82914cd6a3aeSmrg # (otherwise, the dlopen module name will be incorrect). We do 82924cd6a3aeSmrg # this by putting the import library name into $newdlprefiles. 82934cd6a3aeSmrg # We recover the dlopen module name by 'saving' the la file 82944cd6a3aeSmrg # name in a special purpose variable, and (later) extracting the 82954cd6a3aeSmrg # dlname from the la file. 82964cd6a3aeSmrg if test -n "$dlname"; then 82974cd6a3aeSmrg func_tr_sh "$dir/$linklib" 82984cd6a3aeSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 82994cd6a3aeSmrg func_append newdlprefiles " $dir/$linklib" 83004cd6a3aeSmrg else 83014cd6a3aeSmrg func_append newdlprefiles " $dir/$old_library" 83024cd6a3aeSmrg # Keep a list of preopened convenience libraries to check 83034cd6a3aeSmrg # that they are being used correctly in the link pass. 83044cd6a3aeSmrg test -z "$libdir" && \ 83054cd6a3aeSmrg func_append dlpreconveniencelibs " $dir/$old_library" 83064cd6a3aeSmrg fi 83074cd6a3aeSmrg ;; 83084cd6a3aeSmrg * ) 83094cd6a3aeSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 83104cd6a3aeSmrg # are required to link). 83114cd6a3aeSmrg if test -n "$old_library"; then 83124cd6a3aeSmrg func_append newdlprefiles " $dir/$old_library" 83134cd6a3aeSmrg # Keep a list of preopened convenience libraries to check 83144cd6a3aeSmrg # that they are being used correctly in the link pass. 83154cd6a3aeSmrg test -z "$libdir" && \ 83164cd6a3aeSmrg func_append dlpreconveniencelibs " $dir/$old_library" 83174cd6a3aeSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 83184cd6a3aeSmrg elif test -n "$dlname"; then 83194cd6a3aeSmrg func_append newdlprefiles " $dir/$dlname" 83204cd6a3aeSmrg else 83214cd6a3aeSmrg func_append newdlprefiles " $dir/$linklib" 83224cd6a3aeSmrg fi 83234cd6a3aeSmrg ;; 83244cd6a3aeSmrg esac 83254cd6a3aeSmrg fi # $pass = dlpreopen 83264cd6a3aeSmrg 83274cd6a3aeSmrg if test -z "$libdir"; then 83284cd6a3aeSmrg # Link the convenience library 832954044362Smrg if test lib = "$linkmode"; then 83304cd6a3aeSmrg deplibs="$dir/$old_library $deplibs" 833154044362Smrg elif test prog,link = "$linkmode,$pass"; then 83324cd6a3aeSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 83334cd6a3aeSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 83344cd6a3aeSmrg else 83354cd6a3aeSmrg deplibs="$lib $deplibs" # used for prog,scan pass 83364cd6a3aeSmrg fi 83374cd6a3aeSmrg continue 83384cd6a3aeSmrg fi 83394cd6a3aeSmrg 83404cd6a3aeSmrg 834154044362Smrg if test prog = "$linkmode" && test link != "$pass"; then 83424cd6a3aeSmrg func_append newlib_search_path " $ladir" 83434cd6a3aeSmrg deplibs="$lib $deplibs" 83444cd6a3aeSmrg 834554044362Smrg linkalldeplibs=false 834654044362Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 834754044362Smrg test no = "$build_libtool_libs"; then 834854044362Smrg linkalldeplibs=: 83494cd6a3aeSmrg fi 83504cd6a3aeSmrg 83514cd6a3aeSmrg tmp_libs= 83524cd6a3aeSmrg for deplib in $dependency_libs; do 83534cd6a3aeSmrg case $deplib in 83544cd6a3aeSmrg -L*) func_stripname '-L' '' "$deplib" 83554cd6a3aeSmrg func_resolve_sysroot "$func_stripname_result" 83564cd6a3aeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 83574cd6a3aeSmrg ;; 83584cd6a3aeSmrg esac 83594cd6a3aeSmrg # Need to link against all dependency_libs? 836054044362Smrg if $linkalldeplibs; then 83614cd6a3aeSmrg deplibs="$deplib $deplibs" 83624cd6a3aeSmrg else 83634cd6a3aeSmrg # Need to hardcode shared library paths 83644cd6a3aeSmrg # or/and link against static libraries 83654cd6a3aeSmrg newdependency_libs="$deplib $newdependency_libs" 83664cd6a3aeSmrg fi 836754044362Smrg if $opt_preserve_dup_deps; then 83684cd6a3aeSmrg case "$tmp_libs " in 83694cd6a3aeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 83704cd6a3aeSmrg esac 83714cd6a3aeSmrg fi 83724cd6a3aeSmrg func_append tmp_libs " $deplib" 83734cd6a3aeSmrg done # for deplib 83744cd6a3aeSmrg continue 83754cd6a3aeSmrg fi # $linkmode = prog... 83764cd6a3aeSmrg 837754044362Smrg if test prog,link = "$linkmode,$pass"; then 83784cd6a3aeSmrg if test -n "$library_names" && 837954044362Smrg { { test no = "$prefer_static_libs" || 838054044362Smrg test built,yes = "$prefer_static_libs,$installed"; } || 83814cd6a3aeSmrg test -z "$old_library"; }; then 83824cd6a3aeSmrg # We need to hardcode the library path 838354044362Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 83844cd6a3aeSmrg # Make sure the rpath contains only unique directories. 838554044362Smrg case $temp_rpath: in 83864cd6a3aeSmrg *"$absdir:"*) ;; 83874cd6a3aeSmrg *) func_append temp_rpath "$absdir:" ;; 83884cd6a3aeSmrg esac 83894cd6a3aeSmrg fi 83904cd6a3aeSmrg 83914cd6a3aeSmrg # Hardcode the library path. 83924cd6a3aeSmrg # Skip directories that are in the system default run-time 83934cd6a3aeSmrg # search path. 83944cd6a3aeSmrg case " $sys_lib_dlsearch_path " in 83954cd6a3aeSmrg *" $absdir "*) ;; 83964cd6a3aeSmrg *) 83974cd6a3aeSmrg case "$compile_rpath " in 83984cd6a3aeSmrg *" $absdir "*) ;; 83994cd6a3aeSmrg *) func_append compile_rpath " $absdir" ;; 84004cd6a3aeSmrg esac 84014cd6a3aeSmrg ;; 84024cd6a3aeSmrg esac 84034cd6a3aeSmrg case " $sys_lib_dlsearch_path " in 84044cd6a3aeSmrg *" $libdir "*) ;; 84054cd6a3aeSmrg *) 84064cd6a3aeSmrg case "$finalize_rpath " in 84074cd6a3aeSmrg *" $libdir "*) ;; 84084cd6a3aeSmrg *) func_append finalize_rpath " $libdir" ;; 84094cd6a3aeSmrg esac 84104cd6a3aeSmrg ;; 84114cd6a3aeSmrg esac 84124cd6a3aeSmrg fi # $linkmode,$pass = prog,link... 84134cd6a3aeSmrg 841454044362Smrg if $alldeplibs && 841554044362Smrg { test pass_all = "$deplibs_check_method" || 841654044362Smrg { test yes = "$build_libtool_libs" && 84174cd6a3aeSmrg test -n "$library_names"; }; }; then 84184cd6a3aeSmrg # We only need to search for static libraries 84194cd6a3aeSmrg continue 84204cd6a3aeSmrg fi 84214cd6a3aeSmrg fi 84224cd6a3aeSmrg 84234cd6a3aeSmrg link_static=no # Whether the deplib will be linked statically 84244cd6a3aeSmrg use_static_libs=$prefer_static_libs 842554044362Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 84264cd6a3aeSmrg use_static_libs=no 84274cd6a3aeSmrg fi 84284cd6a3aeSmrg if test -n "$library_names" && 842954044362Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 84304cd6a3aeSmrg case $host in 843154044362Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 84324cd6a3aeSmrg # No point in relinking DLLs because paths are not encoded 84334cd6a3aeSmrg func_append notinst_deplibs " $lib" 84344cd6a3aeSmrg need_relink=no 84354cd6a3aeSmrg ;; 84364cd6a3aeSmrg *) 843754044362Smrg if test no = "$installed"; then 84384cd6a3aeSmrg func_append notinst_deplibs " $lib" 84394cd6a3aeSmrg need_relink=yes 84404cd6a3aeSmrg fi 84414cd6a3aeSmrg ;; 84424cd6a3aeSmrg esac 84434cd6a3aeSmrg # This is a shared library 84444cd6a3aeSmrg 84454cd6a3aeSmrg # Warn about portability, can't link against -module's on some 84464cd6a3aeSmrg # systems (darwin). Don't bleat about dlopened modules though! 844754044362Smrg dlopenmodule= 84484cd6a3aeSmrg for dlpremoduletest in $dlprefiles; do 84494cd6a3aeSmrg if test "X$dlpremoduletest" = "X$lib"; then 845054044362Smrg dlopenmodule=$dlpremoduletest 84514cd6a3aeSmrg break 84524cd6a3aeSmrg fi 84534cd6a3aeSmrg done 845454044362Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 84554cd6a3aeSmrg echo 845654044362Smrg if test prog = "$linkmode"; then 84574cd6a3aeSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 84584cd6a3aeSmrg else 84594cd6a3aeSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 84604cd6a3aeSmrg fi 84614cd6a3aeSmrg $ECHO "*** $linklib is not portable!" 84624cd6a3aeSmrg fi 846354044362Smrg if test lib = "$linkmode" && 846454044362Smrg test yes = "$hardcode_into_libs"; then 84654cd6a3aeSmrg # Hardcode the library path. 84664cd6a3aeSmrg # Skip directories that are in the system default run-time 84674cd6a3aeSmrg # search path. 84684cd6a3aeSmrg case " $sys_lib_dlsearch_path " in 84694cd6a3aeSmrg *" $absdir "*) ;; 84704cd6a3aeSmrg *) 84714cd6a3aeSmrg case "$compile_rpath " in 84724cd6a3aeSmrg *" $absdir "*) ;; 84734cd6a3aeSmrg *) func_append compile_rpath " $absdir" ;; 84744cd6a3aeSmrg esac 84754cd6a3aeSmrg ;; 84764cd6a3aeSmrg esac 84774cd6a3aeSmrg case " $sys_lib_dlsearch_path " in 84784cd6a3aeSmrg *" $libdir "*) ;; 84794cd6a3aeSmrg *) 84804cd6a3aeSmrg case "$finalize_rpath " in 84814cd6a3aeSmrg *" $libdir "*) ;; 84824cd6a3aeSmrg *) func_append finalize_rpath " $libdir" ;; 84834cd6a3aeSmrg esac 84844cd6a3aeSmrg ;; 84854cd6a3aeSmrg esac 84864cd6a3aeSmrg fi 84874cd6a3aeSmrg 84884cd6a3aeSmrg if test -n "$old_archive_from_expsyms_cmds"; then 84894cd6a3aeSmrg # figure out the soname 84904cd6a3aeSmrg set dummy $library_names 84914cd6a3aeSmrg shift 849254044362Smrg realname=$1 84934cd6a3aeSmrg shift 84944cd6a3aeSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 84954cd6a3aeSmrg # use dlname if we got it. it's perfectly good, no? 84964cd6a3aeSmrg if test -n "$dlname"; then 849754044362Smrg soname=$dlname 84984cd6a3aeSmrg elif test -n "$soname_spec"; then 84994cd6a3aeSmrg # bleh windows 85004cd6a3aeSmrg case $host in 850154044362Smrg *cygwin* | mingw* | *cegcc* | *os2*) 85024cd6a3aeSmrg func_arith $current - $age 85034cd6a3aeSmrg major=$func_arith_result 850454044362Smrg versuffix=-$major 85054cd6a3aeSmrg ;; 85064cd6a3aeSmrg esac 85074cd6a3aeSmrg eval soname=\"$soname_spec\" 85084cd6a3aeSmrg else 850954044362Smrg soname=$realname 85104cd6a3aeSmrg fi 85114cd6a3aeSmrg 85124cd6a3aeSmrg # Make a new name for the extract_expsyms_cmds to use 851354044362Smrg soroot=$soname 85144cd6a3aeSmrg func_basename "$soroot" 851554044362Smrg soname=$func_basename_result 85164cd6a3aeSmrg func_stripname 'lib' '.dll' "$soname" 85174cd6a3aeSmrg newlib=libimp-$func_stripname_result.a 85184cd6a3aeSmrg 85194cd6a3aeSmrg # If the library has no export list, then create one now 85204cd6a3aeSmrg if test -f "$output_objdir/$soname-def"; then : 85214cd6a3aeSmrg else 852254044362Smrg func_verbose "extracting exported symbol list from '$soname'" 85234cd6a3aeSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 85244cd6a3aeSmrg fi 85254cd6a3aeSmrg 85264cd6a3aeSmrg # Create $newlib 85274cd6a3aeSmrg if test -f "$output_objdir/$newlib"; then :; else 852854044362Smrg func_verbose "generating import library for '$soname'" 85294cd6a3aeSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 85304cd6a3aeSmrg fi 85314cd6a3aeSmrg # make sure the library variables are pointing to the new library 85324cd6a3aeSmrg dir=$output_objdir 85334cd6a3aeSmrg linklib=$newlib 85344cd6a3aeSmrg fi # test -n "$old_archive_from_expsyms_cmds" 85354cd6a3aeSmrg 853654044362Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 85374cd6a3aeSmrg add_shlibpath= 85384cd6a3aeSmrg add_dir= 85394cd6a3aeSmrg add= 85404cd6a3aeSmrg lib_linked=yes 85414cd6a3aeSmrg case $hardcode_action in 85424cd6a3aeSmrg immediate | unsupported) 854354044362Smrg if test no = "$hardcode_direct"; then 854454044362Smrg add=$dir/$linklib 85454cd6a3aeSmrg case $host in 854654044362Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 854754044362Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 85484cd6a3aeSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 854954044362Smrg *-*-unixware7*) add_dir=-L$dir ;; 85504cd6a3aeSmrg *-*-darwin* ) 855154044362Smrg # if the lib is a (non-dlopened) module then we cannot 85524cd6a3aeSmrg # link against it, someone is ignoring the earlier warnings 85534cd6a3aeSmrg if /usr/bin/file -L $add 2> /dev/null | 855454044362Smrg $GREP ": [^:]* bundle" >/dev/null; then 85554cd6a3aeSmrg if test "X$dlopenmodule" != "X$lib"; then 85564cd6a3aeSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 855754044362Smrg if test -z "$old_library"; then 85584cd6a3aeSmrg echo 85594cd6a3aeSmrg echo "*** And there doesn't seem to be a static archive available" 85604cd6a3aeSmrg echo "*** The link will probably fail, sorry" 85614cd6a3aeSmrg else 856254044362Smrg add=$dir/$old_library 85634cd6a3aeSmrg fi 85644cd6a3aeSmrg elif test -n "$old_library"; then 856554044362Smrg add=$dir/$old_library 85664cd6a3aeSmrg fi 85674cd6a3aeSmrg fi 85684cd6a3aeSmrg esac 856954044362Smrg elif test no = "$hardcode_minus_L"; then 85704cd6a3aeSmrg case $host in 857154044362Smrg *-*-sunos*) add_shlibpath=$dir ;; 85724cd6a3aeSmrg esac 857354044362Smrg add_dir=-L$dir 857454044362Smrg add=-l$name 857554044362Smrg elif test no = "$hardcode_shlibpath_var"; then 857654044362Smrg add_shlibpath=$dir 857754044362Smrg add=-l$name 85784cd6a3aeSmrg else 85794cd6a3aeSmrg lib_linked=no 85804cd6a3aeSmrg fi 85814cd6a3aeSmrg ;; 85824cd6a3aeSmrg relink) 858354044362Smrg if test yes = "$hardcode_direct" && 858454044362Smrg test no = "$hardcode_direct_absolute"; then 858554044362Smrg add=$dir/$linklib 858654044362Smrg elif test yes = "$hardcode_minus_L"; then 858754044362Smrg add_dir=-L$absdir 85884cd6a3aeSmrg # Try looking first in the location we're being installed to. 85894cd6a3aeSmrg if test -n "$inst_prefix_dir"; then 85904cd6a3aeSmrg case $libdir in 85914cd6a3aeSmrg [\\/]*) 85924cd6a3aeSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 85934cd6a3aeSmrg ;; 85944cd6a3aeSmrg esac 85954cd6a3aeSmrg fi 859654044362Smrg add=-l$name 859754044362Smrg elif test yes = "$hardcode_shlibpath_var"; then 859854044362Smrg add_shlibpath=$dir 859954044362Smrg add=-l$name 86004cd6a3aeSmrg else 86014cd6a3aeSmrg lib_linked=no 86024cd6a3aeSmrg fi 86034cd6a3aeSmrg ;; 86044cd6a3aeSmrg *) lib_linked=no ;; 86054cd6a3aeSmrg esac 86064cd6a3aeSmrg 860754044362Smrg if test yes != "$lib_linked"; then 86084cd6a3aeSmrg func_fatal_configuration "unsupported hardcode properties" 86094cd6a3aeSmrg fi 86104cd6a3aeSmrg 86114cd6a3aeSmrg if test -n "$add_shlibpath"; then 86124cd6a3aeSmrg case :$compile_shlibpath: in 86134cd6a3aeSmrg *":$add_shlibpath:"*) ;; 86144cd6a3aeSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 86154cd6a3aeSmrg esac 86164cd6a3aeSmrg fi 861754044362Smrg if test prog = "$linkmode"; then 86184cd6a3aeSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 86194cd6a3aeSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 86204cd6a3aeSmrg else 86214cd6a3aeSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86224cd6a3aeSmrg test -n "$add" && deplibs="$add $deplibs" 862354044362Smrg if test yes != "$hardcode_direct" && 862454044362Smrg test yes != "$hardcode_minus_L" && 862554044362Smrg test yes = "$hardcode_shlibpath_var"; then 86264cd6a3aeSmrg case :$finalize_shlibpath: in 86274cd6a3aeSmrg *":$libdir:"*) ;; 86284cd6a3aeSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86294cd6a3aeSmrg esac 86304cd6a3aeSmrg fi 86314cd6a3aeSmrg fi 86324cd6a3aeSmrg fi 86334cd6a3aeSmrg 863454044362Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 86354cd6a3aeSmrg add_shlibpath= 86364cd6a3aeSmrg add_dir= 86374cd6a3aeSmrg add= 86384cd6a3aeSmrg # Finalize command for both is simple: just hardcode it. 863954044362Smrg if test yes = "$hardcode_direct" && 864054044362Smrg test no = "$hardcode_direct_absolute"; then 864154044362Smrg add=$libdir/$linklib 864254044362Smrg elif test yes = "$hardcode_minus_L"; then 864354044362Smrg add_dir=-L$libdir 864454044362Smrg add=-l$name 864554044362Smrg elif test yes = "$hardcode_shlibpath_var"; then 86464cd6a3aeSmrg case :$finalize_shlibpath: in 86474cd6a3aeSmrg *":$libdir:"*) ;; 86484cd6a3aeSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86494cd6a3aeSmrg esac 865054044362Smrg add=-l$name 865154044362Smrg elif test yes = "$hardcode_automatic"; then 86524cd6a3aeSmrg if test -n "$inst_prefix_dir" && 865354044362Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 865454044362Smrg add=$inst_prefix_dir$libdir/$linklib 86554cd6a3aeSmrg else 865654044362Smrg add=$libdir/$linklib 86574cd6a3aeSmrg fi 86584cd6a3aeSmrg else 86594cd6a3aeSmrg # We cannot seem to hardcode it, guess we'll fake it. 866054044362Smrg add_dir=-L$libdir 86614cd6a3aeSmrg # Try looking first in the location we're being installed to. 86624cd6a3aeSmrg if test -n "$inst_prefix_dir"; then 86634cd6a3aeSmrg case $libdir in 86644cd6a3aeSmrg [\\/]*) 86654cd6a3aeSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 86664cd6a3aeSmrg ;; 86674cd6a3aeSmrg esac 86684cd6a3aeSmrg fi 866954044362Smrg add=-l$name 86704cd6a3aeSmrg fi 86714cd6a3aeSmrg 867254044362Smrg if test prog = "$linkmode"; then 86734cd6a3aeSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 86744cd6a3aeSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 86754cd6a3aeSmrg else 86764cd6a3aeSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86774cd6a3aeSmrg test -n "$add" && deplibs="$add $deplibs" 86784cd6a3aeSmrg fi 86794cd6a3aeSmrg fi 868054044362Smrg elif test prog = "$linkmode"; then 86814cd6a3aeSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 86824cd6a3aeSmrg # is not unsupported. This is valid on all known static and 86834cd6a3aeSmrg # shared platforms. 868454044362Smrg if test unsupported != "$hardcode_direct"; then 868554044362Smrg test -n "$old_library" && linklib=$old_library 86864cd6a3aeSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 86874cd6a3aeSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 86884cd6a3aeSmrg else 86894cd6a3aeSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 86904cd6a3aeSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 86914cd6a3aeSmrg fi 869254044362Smrg elif test yes = "$build_libtool_libs"; then 86934cd6a3aeSmrg # Not a shared library 869454044362Smrg if test pass_all != "$deplibs_check_method"; then 86954cd6a3aeSmrg # We're trying link a shared library against a static one 86964cd6a3aeSmrg # but the system doesn't support it. 86974cd6a3aeSmrg 86984cd6a3aeSmrg # Just print a warning and add the library to dependency_libs so 86994cd6a3aeSmrg # that the program can be linked against the static library. 87004cd6a3aeSmrg echo 870154044362Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 87024cd6a3aeSmrg echo "*** I have the capability to make that library automatically link in when" 87034cd6a3aeSmrg echo "*** you link to this library. But I can only do this if you have a" 87044cd6a3aeSmrg echo "*** shared version of the library, which you do not appear to have." 870554044362Smrg if test yes = "$module"; then 87064cd6a3aeSmrg echo "*** But as you try to build a module library, libtool will still create " 87074cd6a3aeSmrg echo "*** a static module, that should work as long as the dlopening application" 87084cd6a3aeSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 87094cd6a3aeSmrg if test -z "$global_symbol_pipe"; then 87104cd6a3aeSmrg echo 87114cd6a3aeSmrg echo "*** However, this would only work if libtool was able to extract symbol" 871254044362Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 87134cd6a3aeSmrg echo "*** not find such a program. So, this module is probably useless." 871454044362Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 87154cd6a3aeSmrg fi 871654044362Smrg if test no = "$build_old_libs"; then 87174cd6a3aeSmrg build_libtool_libs=module 87184cd6a3aeSmrg build_old_libs=yes 87194cd6a3aeSmrg else 87204cd6a3aeSmrg build_libtool_libs=no 87214cd6a3aeSmrg fi 87224cd6a3aeSmrg fi 87234cd6a3aeSmrg else 87244cd6a3aeSmrg deplibs="$dir/$old_library $deplibs" 87254cd6a3aeSmrg link_static=yes 87264cd6a3aeSmrg fi 87274cd6a3aeSmrg fi # link shared/static library? 87284cd6a3aeSmrg 872954044362Smrg if test lib = "$linkmode"; then 87304cd6a3aeSmrg if test -n "$dependency_libs" && 873154044362Smrg { test yes != "$hardcode_into_libs" || 873254044362Smrg test yes = "$build_old_libs" || 873354044362Smrg test yes = "$link_static"; }; then 87344cd6a3aeSmrg # Extract -R from dependency_libs 87354cd6a3aeSmrg temp_deplibs= 87364cd6a3aeSmrg for libdir in $dependency_libs; do 87374cd6a3aeSmrg case $libdir in 87384cd6a3aeSmrg -R*) func_stripname '-R' '' "$libdir" 87394cd6a3aeSmrg temp_xrpath=$func_stripname_result 87404cd6a3aeSmrg case " $xrpath " in 87414cd6a3aeSmrg *" $temp_xrpath "*) ;; 87424cd6a3aeSmrg *) func_append xrpath " $temp_xrpath";; 87434cd6a3aeSmrg esac;; 87444cd6a3aeSmrg *) func_append temp_deplibs " $libdir";; 87454cd6a3aeSmrg esac 87464cd6a3aeSmrg done 874754044362Smrg dependency_libs=$temp_deplibs 87484cd6a3aeSmrg fi 87494cd6a3aeSmrg 87504cd6a3aeSmrg func_append newlib_search_path " $absdir" 87514cd6a3aeSmrg # Link against this library 875254044362Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 87534cd6a3aeSmrg # ... and its dependency_libs 87544cd6a3aeSmrg tmp_libs= 87554cd6a3aeSmrg for deplib in $dependency_libs; do 87564cd6a3aeSmrg newdependency_libs="$deplib $newdependency_libs" 87574cd6a3aeSmrg case $deplib in 87584cd6a3aeSmrg -L*) func_stripname '-L' '' "$deplib" 87594cd6a3aeSmrg func_resolve_sysroot "$func_stripname_result";; 87604cd6a3aeSmrg *) func_resolve_sysroot "$deplib" ;; 87614cd6a3aeSmrg esac 876254044362Smrg if $opt_preserve_dup_deps; then 87634cd6a3aeSmrg case "$tmp_libs " in 87644cd6a3aeSmrg *" $func_resolve_sysroot_result "*) 87654cd6a3aeSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 87664cd6a3aeSmrg esac 87674cd6a3aeSmrg fi 87684cd6a3aeSmrg func_append tmp_libs " $func_resolve_sysroot_result" 87694cd6a3aeSmrg done 87704cd6a3aeSmrg 877154044362Smrg if test no != "$link_all_deplibs"; then 87724cd6a3aeSmrg # Add the search paths of all dependency libraries 87734cd6a3aeSmrg for deplib in $dependency_libs; do 87744cd6a3aeSmrg path= 87754cd6a3aeSmrg case $deplib in 877654044362Smrg -L*) path=$deplib ;; 87774cd6a3aeSmrg *.la) 87784cd6a3aeSmrg func_resolve_sysroot "$deplib" 87794cd6a3aeSmrg deplib=$func_resolve_sysroot_result 87804cd6a3aeSmrg func_dirname "$deplib" "" "." 87814cd6a3aeSmrg dir=$func_dirname_result 87824cd6a3aeSmrg # We need an absolute path. 87834cd6a3aeSmrg case $dir in 878454044362Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 87854cd6a3aeSmrg *) 87864cd6a3aeSmrg absdir=`cd "$dir" && pwd` 87874cd6a3aeSmrg if test -z "$absdir"; then 878854044362Smrg func_warning "cannot determine absolute directory name of '$dir'" 878954044362Smrg absdir=$dir 87904cd6a3aeSmrg fi 87914cd6a3aeSmrg ;; 87924cd6a3aeSmrg esac 87934cd6a3aeSmrg if $GREP "^installed=no" $deplib > /dev/null; then 87944cd6a3aeSmrg case $host in 87954cd6a3aeSmrg *-*-darwin*) 87964cd6a3aeSmrg depdepl= 879754044362Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 879854044362Smrg if test -n "$deplibrary_names"; then 879954044362Smrg for tmp in $deplibrary_names; do 88004cd6a3aeSmrg depdepl=$tmp 88014cd6a3aeSmrg done 880254044362Smrg if test -f "$absdir/$objdir/$depdepl"; then 880354044362Smrg depdepl=$absdir/$objdir/$depdepl 880454044362Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 88054cd6a3aeSmrg if test -z "$darwin_install_name"; then 880654044362Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 88074cd6a3aeSmrg fi 880854044362Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 880954044362Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 88104cd6a3aeSmrg path= 88114cd6a3aeSmrg fi 88124cd6a3aeSmrg fi 88134cd6a3aeSmrg ;; 88144cd6a3aeSmrg *) 881554044362Smrg path=-L$absdir/$objdir 88164cd6a3aeSmrg ;; 88174cd6a3aeSmrg esac 88184cd6a3aeSmrg else 881954044362Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 88204cd6a3aeSmrg test -z "$libdir" && \ 882154044362Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 88224cd6a3aeSmrg test "$absdir" != "$libdir" && \ 882354044362Smrg func_warning "'$deplib' seems to be moved" 88244cd6a3aeSmrg 882554044362Smrg path=-L$absdir 88264cd6a3aeSmrg fi 88274cd6a3aeSmrg ;; 88284cd6a3aeSmrg esac 88294cd6a3aeSmrg case " $deplibs " in 88304cd6a3aeSmrg *" $path "*) ;; 88314cd6a3aeSmrg *) deplibs="$path $deplibs" ;; 88324cd6a3aeSmrg esac 88334cd6a3aeSmrg done 88344cd6a3aeSmrg fi # link_all_deplibs != no 88354cd6a3aeSmrg fi # linkmode = lib 88364cd6a3aeSmrg done # for deplib in $libs 883754044362Smrg if test link = "$pass"; then 883854044362Smrg if test prog = "$linkmode"; then 88394cd6a3aeSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 88404cd6a3aeSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 88414cd6a3aeSmrg else 88424cd6a3aeSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 88434cd6a3aeSmrg fi 88444cd6a3aeSmrg fi 884554044362Smrg dependency_libs=$newdependency_libs 884654044362Smrg if test dlpreopen = "$pass"; then 88474cd6a3aeSmrg # Link the dlpreopened libraries before other libraries 88484cd6a3aeSmrg for deplib in $save_deplibs; do 88494cd6a3aeSmrg deplibs="$deplib $deplibs" 88504cd6a3aeSmrg done 88514cd6a3aeSmrg fi 885254044362Smrg if test dlopen != "$pass"; then 885354044362Smrg test conv = "$pass" || { 88544cd6a3aeSmrg # Make sure lib_search_path contains only unique directories. 88554cd6a3aeSmrg lib_search_path= 88564cd6a3aeSmrg for dir in $newlib_search_path; do 88574cd6a3aeSmrg case "$lib_search_path " in 88584cd6a3aeSmrg *" $dir "*) ;; 88594cd6a3aeSmrg *) func_append lib_search_path " $dir" ;; 88604cd6a3aeSmrg esac 88614cd6a3aeSmrg done 88624cd6a3aeSmrg newlib_search_path= 886354044362Smrg } 88644cd6a3aeSmrg 886554044362Smrg if test prog,link = "$linkmode,$pass"; then 88664cd6a3aeSmrg vars="compile_deplibs finalize_deplibs" 886754044362Smrg else 886854044362Smrg vars=deplibs 88694cd6a3aeSmrg fi 88704cd6a3aeSmrg for var in $vars dependency_libs; do 88714cd6a3aeSmrg # Add libraries to $var in reverse order 88724cd6a3aeSmrg eval tmp_libs=\"\$$var\" 88734cd6a3aeSmrg new_libs= 88744cd6a3aeSmrg for deplib in $tmp_libs; do 88754cd6a3aeSmrg # FIXME: Pedantically, this is the right thing to do, so 88764cd6a3aeSmrg # that some nasty dependency loop isn't accidentally 88774cd6a3aeSmrg # broken: 88784cd6a3aeSmrg #new_libs="$deplib $new_libs" 88794cd6a3aeSmrg # Pragmatically, this seems to cause very few problems in 88804cd6a3aeSmrg # practice: 88814cd6a3aeSmrg case $deplib in 88824cd6a3aeSmrg -L*) new_libs="$deplib $new_libs" ;; 88834cd6a3aeSmrg -R*) ;; 88844cd6a3aeSmrg *) 88854cd6a3aeSmrg # And here is the reason: when a library appears more 88864cd6a3aeSmrg # than once as an explicit dependence of a library, or 88874cd6a3aeSmrg # is implicitly linked in more than once by the 88884cd6a3aeSmrg # compiler, it is considered special, and multiple 88894cd6a3aeSmrg # occurrences thereof are not removed. Compare this 88904cd6a3aeSmrg # with having the same library being listed as a 88914cd6a3aeSmrg # dependency of multiple other libraries: in this case, 88924cd6a3aeSmrg # we know (pedantically, we assume) the library does not 88934cd6a3aeSmrg # need to be listed more than once, so we keep only the 88944cd6a3aeSmrg # last copy. This is not always right, but it is rare 88954cd6a3aeSmrg # enough that we require users that really mean to play 88964cd6a3aeSmrg # such unportable linking tricks to link the library 88974cd6a3aeSmrg # using -Wl,-lname, so that libtool does not consider it 88984cd6a3aeSmrg # for duplicate removal. 88994cd6a3aeSmrg case " $specialdeplibs " in 89004cd6a3aeSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 89014cd6a3aeSmrg *) 89024cd6a3aeSmrg case " $new_libs " in 89034cd6a3aeSmrg *" $deplib "*) ;; 89044cd6a3aeSmrg *) new_libs="$deplib $new_libs" ;; 89054cd6a3aeSmrg esac 89064cd6a3aeSmrg ;; 89074cd6a3aeSmrg esac 89084cd6a3aeSmrg ;; 89094cd6a3aeSmrg esac 89104cd6a3aeSmrg done 89114cd6a3aeSmrg tmp_libs= 89124cd6a3aeSmrg for deplib in $new_libs; do 89134cd6a3aeSmrg case $deplib in 89144cd6a3aeSmrg -L*) 89154cd6a3aeSmrg case " $tmp_libs " in 89164cd6a3aeSmrg *" $deplib "*) ;; 89174cd6a3aeSmrg *) func_append tmp_libs " $deplib" ;; 89184cd6a3aeSmrg esac 89194cd6a3aeSmrg ;; 89204cd6a3aeSmrg *) func_append tmp_libs " $deplib" ;; 89214cd6a3aeSmrg esac 89224cd6a3aeSmrg done 89234cd6a3aeSmrg eval $var=\"$tmp_libs\" 89244cd6a3aeSmrg done # for var 89254cd6a3aeSmrg fi 892654044362Smrg 892754044362Smrg # Add Sun CC postdeps if required: 892854044362Smrg test CXX = "$tagname" && { 892954044362Smrg case $host_os in 893054044362Smrg linux*) 893154cef2ddSmrg case `$CC -V 2>&1 | $SED 5q` in 893254044362Smrg *Sun\ C*) # Sun C++ 5.9 893354044362Smrg func_suncc_cstd_abi 893454044362Smrg 893554044362Smrg if test no != "$suncc_use_cstd_abi"; then 893654044362Smrg func_append postdeps ' -library=Cstd -library=Crun' 893754044362Smrg fi 893854044362Smrg ;; 893954044362Smrg esac 894054044362Smrg ;; 894154044362Smrg 894254044362Smrg solaris*) 894354044362Smrg func_cc_basename "$CC" 894454044362Smrg case $func_cc_basename_result in 894554044362Smrg CC* | sunCC*) 894654044362Smrg func_suncc_cstd_abi 894754044362Smrg 894854044362Smrg if test no != "$suncc_use_cstd_abi"; then 894954044362Smrg func_append postdeps ' -library=Cstd -library=Crun' 895054044362Smrg fi 895154044362Smrg ;; 895254044362Smrg esac 895354044362Smrg ;; 895454044362Smrg esac 895554044362Smrg } 895654044362Smrg 89574cd6a3aeSmrg # Last step: remove runtime libs from dependency_libs 89584cd6a3aeSmrg # (they stay in deplibs) 89594cd6a3aeSmrg tmp_libs= 896054044362Smrg for i in $dependency_libs; do 89614cd6a3aeSmrg case " $predeps $postdeps $compiler_lib_search_path " in 89624cd6a3aeSmrg *" $i "*) 896354044362Smrg i= 89644cd6a3aeSmrg ;; 89654cd6a3aeSmrg esac 896654044362Smrg if test -n "$i"; then 89674cd6a3aeSmrg func_append tmp_libs " $i" 89684cd6a3aeSmrg fi 89694cd6a3aeSmrg done 89704cd6a3aeSmrg dependency_libs=$tmp_libs 89714cd6a3aeSmrg done # for pass 897254044362Smrg if test prog = "$linkmode"; then 897354044362Smrg dlfiles=$newdlfiles 89744cd6a3aeSmrg fi 897554044362Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 897654044362Smrg dlprefiles=$newdlprefiles 89774cd6a3aeSmrg fi 89784cd6a3aeSmrg 89794cd6a3aeSmrg case $linkmode in 89804cd6a3aeSmrg oldlib) 898154044362Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 898254044362Smrg func_warning "'-dlopen' is ignored for archives" 89834cd6a3aeSmrg fi 89844cd6a3aeSmrg 89854cd6a3aeSmrg case " $deplibs" in 89864cd6a3aeSmrg *\ -l* | *\ -L*) 898754044362Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 89884cd6a3aeSmrg esac 89894cd6a3aeSmrg 89904cd6a3aeSmrg test -n "$rpath" && \ 899154044362Smrg func_warning "'-rpath' is ignored for archives" 89924cd6a3aeSmrg 89934cd6a3aeSmrg test -n "$xrpath" && \ 899454044362Smrg func_warning "'-R' is ignored for archives" 89954cd6a3aeSmrg 89964cd6a3aeSmrg test -n "$vinfo" && \ 899754044362Smrg func_warning "'-version-info/-version-number' is ignored for archives" 89984cd6a3aeSmrg 89994cd6a3aeSmrg test -n "$release" && \ 900054044362Smrg func_warning "'-release' is ignored for archives" 90014cd6a3aeSmrg 90024cd6a3aeSmrg test -n "$export_symbols$export_symbols_regex" && \ 900354044362Smrg func_warning "'-export-symbols' is ignored for archives" 90044cd6a3aeSmrg 90054cd6a3aeSmrg # Now set the variables for building old libraries. 90064cd6a3aeSmrg build_libtool_libs=no 900754044362Smrg oldlibs=$output 90084cd6a3aeSmrg func_append objs "$old_deplibs" 90094cd6a3aeSmrg ;; 90104cd6a3aeSmrg 90114cd6a3aeSmrg lib) 901254044362Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 90134cd6a3aeSmrg case $outputname in 90144cd6a3aeSmrg lib*) 90154cd6a3aeSmrg func_stripname 'lib' '.la' "$outputname" 90164cd6a3aeSmrg name=$func_stripname_result 90174cd6a3aeSmrg eval shared_ext=\"$shrext_cmds\" 90184cd6a3aeSmrg eval libname=\"$libname_spec\" 90194cd6a3aeSmrg ;; 90204cd6a3aeSmrg *) 902154044362Smrg test no = "$module" \ 902254044362Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 90234cd6a3aeSmrg 902454044362Smrg if test no != "$need_lib_prefix"; then 90254cd6a3aeSmrg # Add the "lib" prefix for modules if required 90264cd6a3aeSmrg func_stripname '' '.la' "$outputname" 90274cd6a3aeSmrg name=$func_stripname_result 90284cd6a3aeSmrg eval shared_ext=\"$shrext_cmds\" 90294cd6a3aeSmrg eval libname=\"$libname_spec\" 90304cd6a3aeSmrg else 90314cd6a3aeSmrg func_stripname '' '.la' "$outputname" 90324cd6a3aeSmrg libname=$func_stripname_result 90334cd6a3aeSmrg fi 90344cd6a3aeSmrg ;; 90354cd6a3aeSmrg esac 90364cd6a3aeSmrg 90374cd6a3aeSmrg if test -n "$objs"; then 903854044362Smrg if test pass_all != "$deplibs_check_method"; then 903954044362Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 90404cd6a3aeSmrg else 90414cd6a3aeSmrg echo 90424cd6a3aeSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 90434cd6a3aeSmrg $ECHO "*** objects $objs is not portable!" 90444cd6a3aeSmrg func_append libobjs " $objs" 90454cd6a3aeSmrg fi 90464cd6a3aeSmrg fi 90474cd6a3aeSmrg 904854044362Smrg test no = "$dlself" \ 904954044362Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 90504cd6a3aeSmrg 90514cd6a3aeSmrg set dummy $rpath 90524cd6a3aeSmrg shift 905354044362Smrg test 1 -lt "$#" \ 905454044362Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 90554cd6a3aeSmrg 905654044362Smrg install_libdir=$1 90574cd6a3aeSmrg 90584cd6a3aeSmrg oldlibs= 90594cd6a3aeSmrg if test -z "$rpath"; then 906054044362Smrg if test yes = "$build_libtool_libs"; then 90614cd6a3aeSmrg # Building a libtool convenience library. 906254044362Smrg # Some compilers have problems with a '.al' extension so 90634cd6a3aeSmrg # convenience libraries should have the same extension an 90644cd6a3aeSmrg # archive normally would. 90654cd6a3aeSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 90664cd6a3aeSmrg build_libtool_libs=convenience 90674cd6a3aeSmrg build_old_libs=yes 90684cd6a3aeSmrg fi 90694cd6a3aeSmrg 90704cd6a3aeSmrg test -n "$vinfo" && \ 907154044362Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 90724cd6a3aeSmrg 90734cd6a3aeSmrg test -n "$release" && \ 907454044362Smrg func_warning "'-release' is ignored for convenience libraries" 90754cd6a3aeSmrg else 90764cd6a3aeSmrg 90774cd6a3aeSmrg # Parse the version information argument. 907854044362Smrg save_ifs=$IFS; IFS=: 90794cd6a3aeSmrg set dummy $vinfo 0 0 0 90804cd6a3aeSmrg shift 908154044362Smrg IFS=$save_ifs 90824cd6a3aeSmrg 90834cd6a3aeSmrg test -n "$7" && \ 908454044362Smrg func_fatal_help "too many parameters to '-version-info'" 90854cd6a3aeSmrg 90864cd6a3aeSmrg # convert absolute version numbers to libtool ages 90874cd6a3aeSmrg # this retains compatibility with .la files and attempts 90884cd6a3aeSmrg # to make the code below a bit more comprehensible 90894cd6a3aeSmrg 90904cd6a3aeSmrg case $vinfo_number in 90914cd6a3aeSmrg yes) 909254044362Smrg number_major=$1 909354044362Smrg number_minor=$2 909454044362Smrg number_revision=$3 90954cd6a3aeSmrg # 90964cd6a3aeSmrg # There are really only two kinds -- those that 90974cd6a3aeSmrg # use the current revision as the major version 90984cd6a3aeSmrg # and those that subtract age and use age as 90994cd6a3aeSmrg # a minor version. But, then there is irix 910054044362Smrg # that has an extra 1 added just for fun 91014cd6a3aeSmrg # 91024cd6a3aeSmrg case $version_type in 910370728a38Smrg # correct linux to gnu/linux during the next big refactor 910454cef2ddSmrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 91054cd6a3aeSmrg func_arith $number_major + $number_minor 91064cd6a3aeSmrg current=$func_arith_result 910754044362Smrg age=$number_minor 910854044362Smrg revision=$number_revision 91094cd6a3aeSmrg ;; 911054044362Smrg freebsd-aout|qnx|sunos) 911154044362Smrg current=$number_major 911254044362Smrg revision=$number_minor 911354044362Smrg age=0 91144cd6a3aeSmrg ;; 91154cd6a3aeSmrg irix|nonstopux) 91164cd6a3aeSmrg func_arith $number_major + $number_minor 91174cd6a3aeSmrg current=$func_arith_result 911854044362Smrg age=$number_minor 911954044362Smrg revision=$number_minor 91204cd6a3aeSmrg lt_irix_increment=no 91214cd6a3aeSmrg ;; 91224cd6a3aeSmrg esac 91234cd6a3aeSmrg ;; 91244cd6a3aeSmrg no) 912554044362Smrg current=$1 912654044362Smrg revision=$2 912754044362Smrg age=$3 91284cd6a3aeSmrg ;; 91294cd6a3aeSmrg esac 91304cd6a3aeSmrg 91314cd6a3aeSmrg # Check that each of the things are valid numbers. 91324cd6a3aeSmrg case $current in 91334cd6a3aeSmrg 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]) ;; 91344cd6a3aeSmrg *) 913554044362Smrg func_error "CURRENT '$current' must be a nonnegative integer" 913654044362Smrg func_fatal_error "'$vinfo' is not valid version information" 91374cd6a3aeSmrg ;; 91384cd6a3aeSmrg esac 91394cd6a3aeSmrg 91404cd6a3aeSmrg case $revision in 91414cd6a3aeSmrg 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]) ;; 91424cd6a3aeSmrg *) 914354044362Smrg func_error "REVISION '$revision' must be a nonnegative integer" 914454044362Smrg func_fatal_error "'$vinfo' is not valid version information" 91454cd6a3aeSmrg ;; 91464cd6a3aeSmrg esac 91474cd6a3aeSmrg 91484cd6a3aeSmrg case $age in 91494cd6a3aeSmrg 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]) ;; 91504cd6a3aeSmrg *) 915154044362Smrg func_error "AGE '$age' must be a nonnegative integer" 915254044362Smrg func_fatal_error "'$vinfo' is not valid version information" 91534cd6a3aeSmrg ;; 91544cd6a3aeSmrg esac 91554cd6a3aeSmrg 91564cd6a3aeSmrg if test "$age" -gt "$current"; then 915754044362Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 915854044362Smrg func_fatal_error "'$vinfo' is not valid version information" 91594cd6a3aeSmrg fi 91604cd6a3aeSmrg 91614cd6a3aeSmrg # Calculate the version variables. 91624cd6a3aeSmrg major= 91634cd6a3aeSmrg versuffix= 91644cd6a3aeSmrg verstring= 91654cd6a3aeSmrg case $version_type in 91664cd6a3aeSmrg none) ;; 91674cd6a3aeSmrg 91684cd6a3aeSmrg darwin) 91694cd6a3aeSmrg # Like Linux, but with the current version available in 91704cd6a3aeSmrg # verstring for coding it into the library header 91714cd6a3aeSmrg func_arith $current - $age 91724cd6a3aeSmrg major=.$func_arith_result 917354044362Smrg versuffix=$major.$age.$revision 91744cd6a3aeSmrg # Darwin ld doesn't like 0 for these options... 91754cd6a3aeSmrg func_arith $current + 1 91764cd6a3aeSmrg minor_current=$func_arith_result 917754044362Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91784cd6a3aeSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 917954044362Smrg # On Darwin other compilers 918054044362Smrg case $CC in 918154044362Smrg nagfor*) 918254044362Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 918354044362Smrg ;; 918454044362Smrg *) 918554044362Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 918654044362Smrg ;; 918754044362Smrg esac 91884cd6a3aeSmrg ;; 91894cd6a3aeSmrg 91904cd6a3aeSmrg freebsd-aout) 919154044362Smrg major=.$current 919254044362Smrg versuffix=.$current.$revision 91934cd6a3aeSmrg ;; 91944cd6a3aeSmrg 919554cef2ddSmrg freebsd-elf | midnightbsd-elf) 919654044362Smrg func_arith $current - $age 919754044362Smrg major=.$func_arith_result 919854044362Smrg versuffix=$major.$age.$revision 91994cd6a3aeSmrg ;; 92004cd6a3aeSmrg 92014cd6a3aeSmrg irix | nonstopux) 920254044362Smrg if test no = "$lt_irix_increment"; then 92034cd6a3aeSmrg func_arith $current - $age 92044cd6a3aeSmrg else 92054cd6a3aeSmrg func_arith $current - $age + 1 92064cd6a3aeSmrg fi 92074cd6a3aeSmrg major=$func_arith_result 92084cd6a3aeSmrg 92094cd6a3aeSmrg case $version_type in 92104cd6a3aeSmrg nonstopux) verstring_prefix=nonstopux ;; 92114cd6a3aeSmrg *) verstring_prefix=sgi ;; 92124cd6a3aeSmrg esac 921354044362Smrg verstring=$verstring_prefix$major.$revision 92144cd6a3aeSmrg 92154cd6a3aeSmrg # Add in all the interfaces that we are compatible with. 92164cd6a3aeSmrg loop=$revision 921754044362Smrg while test 0 -ne "$loop"; do 92184cd6a3aeSmrg func_arith $revision - $loop 92194cd6a3aeSmrg iface=$func_arith_result 92204cd6a3aeSmrg func_arith $loop - 1 92214cd6a3aeSmrg loop=$func_arith_result 922254044362Smrg verstring=$verstring_prefix$major.$iface:$verstring 92234cd6a3aeSmrg done 92244cd6a3aeSmrg 922554044362Smrg # Before this point, $major must not contain '.'. 92264cd6a3aeSmrg major=.$major 922754044362Smrg versuffix=$major.$revision 92284cd6a3aeSmrg ;; 92294cd6a3aeSmrg 923070728a38Smrg linux) # correct to gnu/linux during the next big refactor 92314cd6a3aeSmrg func_arith $current - $age 92324cd6a3aeSmrg major=.$func_arith_result 923354044362Smrg versuffix=$major.$age.$revision 92344cd6a3aeSmrg ;; 92354cd6a3aeSmrg 92364cd6a3aeSmrg osf) 92374cd6a3aeSmrg func_arith $current - $age 92384cd6a3aeSmrg major=.$func_arith_result 923954044362Smrg versuffix=.$current.$age.$revision 924054044362Smrg verstring=$current.$age.$revision 92414cd6a3aeSmrg 92424cd6a3aeSmrg # Add in all the interfaces that we are compatible with. 92434cd6a3aeSmrg loop=$age 924454044362Smrg while test 0 -ne "$loop"; do 92454cd6a3aeSmrg func_arith $current - $loop 92464cd6a3aeSmrg iface=$func_arith_result 92474cd6a3aeSmrg func_arith $loop - 1 92484cd6a3aeSmrg loop=$func_arith_result 924954044362Smrg verstring=$verstring:$iface.0 92504cd6a3aeSmrg done 92514cd6a3aeSmrg 92524cd6a3aeSmrg # Make executables depend on our current version. 925354044362Smrg func_append verstring ":$current.0" 92544cd6a3aeSmrg ;; 92554cd6a3aeSmrg 92564cd6a3aeSmrg qnx) 925754044362Smrg major=.$current 925854044362Smrg versuffix=.$current 925954044362Smrg ;; 926054044362Smrg 926154044362Smrg sco) 926254044362Smrg major=.$current 926354044362Smrg versuffix=.$current 92644cd6a3aeSmrg ;; 92654cd6a3aeSmrg 92664cd6a3aeSmrg sunos) 926754044362Smrg major=.$current 926854044362Smrg versuffix=.$current.$revision 92694cd6a3aeSmrg ;; 92704cd6a3aeSmrg 92714cd6a3aeSmrg windows) 92724cd6a3aeSmrg # Use '-' rather than '.', since we only want one 927354044362Smrg # extension on DOS 8.3 file systems. 92744cd6a3aeSmrg func_arith $current - $age 92754cd6a3aeSmrg major=$func_arith_result 927654044362Smrg versuffix=-$major 92774cd6a3aeSmrg ;; 92784cd6a3aeSmrg 92794cd6a3aeSmrg *) 928054044362Smrg func_fatal_configuration "unknown library version type '$version_type'" 92814cd6a3aeSmrg ;; 92824cd6a3aeSmrg esac 92834cd6a3aeSmrg 92844cd6a3aeSmrg # Clear the version info if we defaulted, and they specified a release. 92854cd6a3aeSmrg if test -z "$vinfo" && test -n "$release"; then 92864cd6a3aeSmrg major= 92874cd6a3aeSmrg case $version_type in 92884cd6a3aeSmrg darwin) 92894cd6a3aeSmrg # we can't check for "0.0" in archive_cmds due to quoting 92904cd6a3aeSmrg # problems, so we reset it completely 92914cd6a3aeSmrg verstring= 92924cd6a3aeSmrg ;; 92934cd6a3aeSmrg *) 929454044362Smrg verstring=0.0 92954cd6a3aeSmrg ;; 92964cd6a3aeSmrg esac 929754044362Smrg if test no = "$need_version"; then 92984cd6a3aeSmrg versuffix= 92994cd6a3aeSmrg else 930054044362Smrg versuffix=.0.0 93014cd6a3aeSmrg fi 93024cd6a3aeSmrg fi 93034cd6a3aeSmrg 93044cd6a3aeSmrg # Remove version info from name if versioning should be avoided 930554044362Smrg if test yes,no = "$avoid_version,$need_version"; then 93064cd6a3aeSmrg major= 93074cd6a3aeSmrg versuffix= 930854044362Smrg verstring= 93094cd6a3aeSmrg fi 93104cd6a3aeSmrg 93114cd6a3aeSmrg # Check to see if the archive will have undefined symbols. 931254044362Smrg if test yes = "$allow_undefined"; then 931354044362Smrg if test unsupported = "$allow_undefined_flag"; then 931454044362Smrg if test yes = "$build_old_libs"; then 931554044362Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 931654044362Smrg build_libtool_libs=no 931754044362Smrg else 931854044362Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 931954044362Smrg fi 93204cd6a3aeSmrg fi 93214cd6a3aeSmrg else 93224cd6a3aeSmrg # Don't allow undefined symbols. 932354044362Smrg allow_undefined_flag=$no_undefined_flag 93244cd6a3aeSmrg fi 93254cd6a3aeSmrg 93264cd6a3aeSmrg fi 93274cd6a3aeSmrg 932854044362Smrg func_generate_dlsyms "$libname" "$libname" : 93294cd6a3aeSmrg func_append libobjs " $symfileobj" 933054044362Smrg test " " = "$libobjs" && libobjs= 93314cd6a3aeSmrg 933254044362Smrg if test relink != "$opt_mode"; then 93334cd6a3aeSmrg # Remove our outputs, but don't remove object files since they 93344cd6a3aeSmrg # may have been created when compiling PIC objects. 93354cd6a3aeSmrg removelist= 93364cd6a3aeSmrg tempremovelist=`$ECHO "$output_objdir/*"` 93374cd6a3aeSmrg for p in $tempremovelist; do 93384cd6a3aeSmrg case $p in 93394cd6a3aeSmrg *.$objext | *.gcno) 93404cd6a3aeSmrg ;; 934154044362Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 934254044362Smrg if test -n "$precious_files_regex"; then 93434cd6a3aeSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 93444cd6a3aeSmrg then 93454cd6a3aeSmrg continue 93464cd6a3aeSmrg fi 93474cd6a3aeSmrg fi 93484cd6a3aeSmrg func_append removelist " $p" 93494cd6a3aeSmrg ;; 93504cd6a3aeSmrg *) ;; 93514cd6a3aeSmrg esac 93524cd6a3aeSmrg done 93534cd6a3aeSmrg test -n "$removelist" && \ 93544cd6a3aeSmrg func_show_eval "${RM}r \$removelist" 93554cd6a3aeSmrg fi 93564cd6a3aeSmrg 93574cd6a3aeSmrg # Now set the variables for building old libraries. 935854044362Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 93594cd6a3aeSmrg func_append oldlibs " $output_objdir/$libname.$libext" 93604cd6a3aeSmrg 93614cd6a3aeSmrg # Transform .lo files to .o files. 936254044362Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 93634cd6a3aeSmrg fi 93644cd6a3aeSmrg 93654cd6a3aeSmrg # Eliminate all temporary directories. 93664cd6a3aeSmrg #for path in $notinst_path; do 93674cd6a3aeSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 93684cd6a3aeSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 93694cd6a3aeSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 93704cd6a3aeSmrg #done 93714cd6a3aeSmrg 93724cd6a3aeSmrg if test -n "$xrpath"; then 93734cd6a3aeSmrg # If the user specified any rpath flags, then add them. 93744cd6a3aeSmrg temp_xrpath= 93754cd6a3aeSmrg for libdir in $xrpath; do 93764cd6a3aeSmrg func_replace_sysroot "$libdir" 93774cd6a3aeSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 93784cd6a3aeSmrg case "$finalize_rpath " in 93794cd6a3aeSmrg *" $libdir "*) ;; 93804cd6a3aeSmrg *) func_append finalize_rpath " $libdir" ;; 93814cd6a3aeSmrg esac 93824cd6a3aeSmrg done 938354044362Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 93844cd6a3aeSmrg dependency_libs="$temp_xrpath $dependency_libs" 93854cd6a3aeSmrg fi 93864cd6a3aeSmrg fi 93874cd6a3aeSmrg 93884cd6a3aeSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 938954044362Smrg old_dlfiles=$dlfiles 93904cd6a3aeSmrg dlfiles= 93914cd6a3aeSmrg for lib in $old_dlfiles; do 93924cd6a3aeSmrg case " $dlprefiles $dlfiles " in 93934cd6a3aeSmrg *" $lib "*) ;; 93944cd6a3aeSmrg *) func_append dlfiles " $lib" ;; 93954cd6a3aeSmrg esac 93964cd6a3aeSmrg done 93974cd6a3aeSmrg 93984cd6a3aeSmrg # Make sure dlprefiles contains only unique files 939954044362Smrg old_dlprefiles=$dlprefiles 94004cd6a3aeSmrg dlprefiles= 94014cd6a3aeSmrg for lib in $old_dlprefiles; do 94024cd6a3aeSmrg case "$dlprefiles " in 94034cd6a3aeSmrg *" $lib "*) ;; 94044cd6a3aeSmrg *) func_append dlprefiles " $lib" ;; 94054cd6a3aeSmrg esac 94064cd6a3aeSmrg done 94074cd6a3aeSmrg 940854044362Smrg if test yes = "$build_libtool_libs"; then 94094cd6a3aeSmrg if test -n "$rpath"; then 94104cd6a3aeSmrg case $host in 94114cd6a3aeSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 94124cd6a3aeSmrg # these systems don't actually have a c library (as such)! 94134cd6a3aeSmrg ;; 94144cd6a3aeSmrg *-*-rhapsody* | *-*-darwin1.[012]) 94154cd6a3aeSmrg # Rhapsody C library is in the System framework 94164cd6a3aeSmrg func_append deplibs " System.ltframework" 94174cd6a3aeSmrg ;; 94184cd6a3aeSmrg *-*-netbsd*) 94194cd6a3aeSmrg # Don't link with libc until the a.out ld.so is fixed. 94204cd6a3aeSmrg ;; 942154cef2ddSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 94224cd6a3aeSmrg # Do not include libc due to us having libc/libc_r. 94234cd6a3aeSmrg ;; 94244cd6a3aeSmrg *-*-sco3.2v5* | *-*-sco5v6*) 94254cd6a3aeSmrg # Causes problems with __ctype 94264cd6a3aeSmrg ;; 94274cd6a3aeSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 94284cd6a3aeSmrg # Compiler inserts libc in the correct place for threads to work 94294cd6a3aeSmrg ;; 94304cd6a3aeSmrg *) 94314cd6a3aeSmrg # Add libc to deplibs on all other systems if necessary. 943254044362Smrg if test yes = "$build_libtool_need_lc"; then 94334cd6a3aeSmrg func_append deplibs " -lc" 94344cd6a3aeSmrg fi 94354cd6a3aeSmrg ;; 94364cd6a3aeSmrg esac 94374cd6a3aeSmrg fi 94384cd6a3aeSmrg 94394cd6a3aeSmrg # Transform deplibs into only deplibs that can be linked in shared. 94404cd6a3aeSmrg name_save=$name 94414cd6a3aeSmrg libname_save=$libname 94424cd6a3aeSmrg release_save=$release 94434cd6a3aeSmrg versuffix_save=$versuffix 94444cd6a3aeSmrg major_save=$major 94454cd6a3aeSmrg # I'm not sure if I'm treating the release correctly. I think 94464cd6a3aeSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 94474cd6a3aeSmrg # add it in twice. Is that correct? 944854044362Smrg release= 944954044362Smrg versuffix= 945054044362Smrg major= 94514cd6a3aeSmrg newdeplibs= 94524cd6a3aeSmrg droppeddeps=no 94534cd6a3aeSmrg case $deplibs_check_method in 94544cd6a3aeSmrg pass_all) 94554cd6a3aeSmrg # Don't check for shared/static. Everything works. 94564cd6a3aeSmrg # This might be a little naive. We might want to check 94574cd6a3aeSmrg # whether the library exists or not. But this is on 94584cd6a3aeSmrg # osf3 & osf4 and I'm not really sure... Just 94594cd6a3aeSmrg # implementing what was already the behavior. 94604cd6a3aeSmrg newdeplibs=$deplibs 94614cd6a3aeSmrg ;; 94624cd6a3aeSmrg test_compile) 94634cd6a3aeSmrg # This code stresses the "libraries are programs" paradigm to its 94644cd6a3aeSmrg # limits. Maybe even breaks it. We compile a program, linking it 94654cd6a3aeSmrg # against the deplibs as a proxy for the library. Then we can check 94664cd6a3aeSmrg # whether they linked in statically or dynamically with ldd. 94674cd6a3aeSmrg $opt_dry_run || $RM conftest.c 94684cd6a3aeSmrg cat > conftest.c <<EOF 94694cd6a3aeSmrg int main() { return 0; } 94704cd6a3aeSmrgEOF 94714cd6a3aeSmrg $opt_dry_run || $RM conftest 94724cd6a3aeSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 94734cd6a3aeSmrg ldd_output=`ldd conftest` 94744cd6a3aeSmrg for i in $deplibs; do 94754cd6a3aeSmrg case $i in 94764cd6a3aeSmrg -l*) 94774cd6a3aeSmrg func_stripname -l '' "$i" 94784cd6a3aeSmrg name=$func_stripname_result 947954044362Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94804cd6a3aeSmrg case " $predeps $postdeps " in 94814cd6a3aeSmrg *" $i "*) 94824cd6a3aeSmrg func_append newdeplibs " $i" 948354044362Smrg i= 94844cd6a3aeSmrg ;; 94854cd6a3aeSmrg esac 94864cd6a3aeSmrg fi 948754044362Smrg if test -n "$i"; then 94884cd6a3aeSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 94894cd6a3aeSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 94904cd6a3aeSmrg set dummy $deplib_matches; shift 94914cd6a3aeSmrg deplib_match=$1 949254044362Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 94934cd6a3aeSmrg func_append newdeplibs " $i" 94944cd6a3aeSmrg else 94954cd6a3aeSmrg droppeddeps=yes 94964cd6a3aeSmrg echo 94974cd6a3aeSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 94984cd6a3aeSmrg echo "*** I have the capability to make that library automatically link in when" 94994cd6a3aeSmrg echo "*** you link to this library. But I can only do this if you have a" 95004cd6a3aeSmrg echo "*** shared version of the library, which I believe you do not have" 95014cd6a3aeSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 95024cd6a3aeSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 95034cd6a3aeSmrg fi 95044cd6a3aeSmrg fi 95054cd6a3aeSmrg ;; 95064cd6a3aeSmrg *) 95074cd6a3aeSmrg func_append newdeplibs " $i" 95084cd6a3aeSmrg ;; 95094cd6a3aeSmrg esac 95104cd6a3aeSmrg done 95114cd6a3aeSmrg else 95124cd6a3aeSmrg # Error occurred in the first compile. Let's try to salvage 95134cd6a3aeSmrg # the situation: Compile a separate program for each library. 95144cd6a3aeSmrg for i in $deplibs; do 95154cd6a3aeSmrg case $i in 95164cd6a3aeSmrg -l*) 95174cd6a3aeSmrg func_stripname -l '' "$i" 95184cd6a3aeSmrg name=$func_stripname_result 95194cd6a3aeSmrg $opt_dry_run || $RM conftest 95204cd6a3aeSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 95214cd6a3aeSmrg ldd_output=`ldd conftest` 952254044362Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95234cd6a3aeSmrg case " $predeps $postdeps " in 95244cd6a3aeSmrg *" $i "*) 95254cd6a3aeSmrg func_append newdeplibs " $i" 952654044362Smrg i= 95274cd6a3aeSmrg ;; 95284cd6a3aeSmrg esac 95294cd6a3aeSmrg fi 953054044362Smrg if test -n "$i"; then 95314cd6a3aeSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 95324cd6a3aeSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 95334cd6a3aeSmrg set dummy $deplib_matches; shift 95344cd6a3aeSmrg deplib_match=$1 953554044362Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 95364cd6a3aeSmrg func_append newdeplibs " $i" 95374cd6a3aeSmrg else 95384cd6a3aeSmrg droppeddeps=yes 95394cd6a3aeSmrg echo 95404cd6a3aeSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 95414cd6a3aeSmrg echo "*** I have the capability to make that library automatically link in when" 95424cd6a3aeSmrg echo "*** you link to this library. But I can only do this if you have a" 95434cd6a3aeSmrg echo "*** shared version of the library, which you do not appear to have" 95444cd6a3aeSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 95454cd6a3aeSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 95464cd6a3aeSmrg fi 95474cd6a3aeSmrg fi 95484cd6a3aeSmrg else 95494cd6a3aeSmrg droppeddeps=yes 95504cd6a3aeSmrg echo 95514cd6a3aeSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 95524cd6a3aeSmrg echo "*** make it link in! You will probably need to install it or some" 95534cd6a3aeSmrg echo "*** library that it depends on before this library will be fully" 95544cd6a3aeSmrg echo "*** functional. Installing it before continuing would be even better." 95554cd6a3aeSmrg fi 95564cd6a3aeSmrg ;; 95574cd6a3aeSmrg *) 95584cd6a3aeSmrg func_append newdeplibs " $i" 95594cd6a3aeSmrg ;; 95604cd6a3aeSmrg esac 95614cd6a3aeSmrg done 95624cd6a3aeSmrg fi 95634cd6a3aeSmrg ;; 95644cd6a3aeSmrg file_magic*) 95654cd6a3aeSmrg set dummy $deplibs_check_method; shift 95664cd6a3aeSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 95674cd6a3aeSmrg for a_deplib in $deplibs; do 95684cd6a3aeSmrg case $a_deplib in 95694cd6a3aeSmrg -l*) 95704cd6a3aeSmrg func_stripname -l '' "$a_deplib" 95714cd6a3aeSmrg name=$func_stripname_result 957254044362Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95734cd6a3aeSmrg case " $predeps $postdeps " in 95744cd6a3aeSmrg *" $a_deplib "*) 95754cd6a3aeSmrg func_append newdeplibs " $a_deplib" 957654044362Smrg a_deplib= 95774cd6a3aeSmrg ;; 95784cd6a3aeSmrg esac 95794cd6a3aeSmrg fi 958054044362Smrg if test -n "$a_deplib"; then 95814cd6a3aeSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 95824cd6a3aeSmrg if test -n "$file_magic_glob"; then 95834cd6a3aeSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 95844cd6a3aeSmrg else 95854cd6a3aeSmrg libnameglob=$libname 95864cd6a3aeSmrg fi 958754044362Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 95884cd6a3aeSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 958954044362Smrg if test yes = "$want_nocaseglob"; then 95904cd6a3aeSmrg shopt -s nocaseglob 95914cd6a3aeSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95924cd6a3aeSmrg $nocaseglob 95934cd6a3aeSmrg else 95944cd6a3aeSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95954cd6a3aeSmrg fi 95964cd6a3aeSmrg for potent_lib in $potential_libs; do 95974cd6a3aeSmrg # Follow soft links. 95984cd6a3aeSmrg if ls -lLd "$potent_lib" 2>/dev/null | 95994cd6a3aeSmrg $GREP " -> " >/dev/null; then 96004cd6a3aeSmrg continue 96014cd6a3aeSmrg fi 96024cd6a3aeSmrg # The statement above tries to avoid entering an 96034cd6a3aeSmrg # endless loop below, in case of cyclic links. 96044cd6a3aeSmrg # We might still enter an endless loop, since a link 96054cd6a3aeSmrg # loop can be closed while we follow links, 96064cd6a3aeSmrg # but so what? 960754044362Smrg potlib=$potent_lib 96084cd6a3aeSmrg while test -h "$potlib" 2>/dev/null; do 960954044362Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 96104cd6a3aeSmrg case $potliblink in 961154044362Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 961254044362Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 96134cd6a3aeSmrg esac 96144cd6a3aeSmrg done 96154cd6a3aeSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 96164cd6a3aeSmrg $SED -e 10q | 96174cd6a3aeSmrg $EGREP "$file_magic_regex" > /dev/null; then 96184cd6a3aeSmrg func_append newdeplibs " $a_deplib" 961954044362Smrg a_deplib= 96204cd6a3aeSmrg break 2 96214cd6a3aeSmrg fi 96224cd6a3aeSmrg done 96234cd6a3aeSmrg done 96244cd6a3aeSmrg fi 962554044362Smrg if test -n "$a_deplib"; then 96264cd6a3aeSmrg droppeddeps=yes 96274cd6a3aeSmrg echo 96284cd6a3aeSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96294cd6a3aeSmrg echo "*** I have the capability to make that library automatically link in when" 96304cd6a3aeSmrg echo "*** you link to this library. But I can only do this if you have a" 96314cd6a3aeSmrg echo "*** shared version of the library, which you do not appear to have" 96324cd6a3aeSmrg echo "*** because I did check the linker path looking for a file starting" 963354044362Smrg if test -z "$potlib"; then 96344cd6a3aeSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 96354cd6a3aeSmrg else 96364cd6a3aeSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96374cd6a3aeSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 96384cd6a3aeSmrg fi 96394cd6a3aeSmrg fi 96404cd6a3aeSmrg ;; 96414cd6a3aeSmrg *) 96424cd6a3aeSmrg # Add a -L argument. 96434cd6a3aeSmrg func_append newdeplibs " $a_deplib" 96444cd6a3aeSmrg ;; 96454cd6a3aeSmrg esac 96464cd6a3aeSmrg done # Gone through all deplibs. 96474cd6a3aeSmrg ;; 96484cd6a3aeSmrg match_pattern*) 96494cd6a3aeSmrg set dummy $deplibs_check_method; shift 96504cd6a3aeSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 96514cd6a3aeSmrg for a_deplib in $deplibs; do 96524cd6a3aeSmrg case $a_deplib in 96534cd6a3aeSmrg -l*) 96544cd6a3aeSmrg func_stripname -l '' "$a_deplib" 96554cd6a3aeSmrg name=$func_stripname_result 965654044362Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96574cd6a3aeSmrg case " $predeps $postdeps " in 96584cd6a3aeSmrg *" $a_deplib "*) 96594cd6a3aeSmrg func_append newdeplibs " $a_deplib" 966054044362Smrg a_deplib= 96614cd6a3aeSmrg ;; 96624cd6a3aeSmrg esac 96634cd6a3aeSmrg fi 966454044362Smrg if test -n "$a_deplib"; then 96654cd6a3aeSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 96664cd6a3aeSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 96674cd6a3aeSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 96684cd6a3aeSmrg for potent_lib in $potential_libs; do 966954044362Smrg potlib=$potent_lib # see symlink-check above in file_magic test 96704cd6a3aeSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 96714cd6a3aeSmrg $EGREP "$match_pattern_regex" > /dev/null; then 96724cd6a3aeSmrg func_append newdeplibs " $a_deplib" 967354044362Smrg a_deplib= 96744cd6a3aeSmrg break 2 96754cd6a3aeSmrg fi 96764cd6a3aeSmrg done 96774cd6a3aeSmrg done 96784cd6a3aeSmrg fi 967954044362Smrg if test -n "$a_deplib"; then 96804cd6a3aeSmrg droppeddeps=yes 96814cd6a3aeSmrg echo 96824cd6a3aeSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96834cd6a3aeSmrg echo "*** I have the capability to make that library automatically link in when" 96844cd6a3aeSmrg echo "*** you link to this library. But I can only do this if you have a" 96854cd6a3aeSmrg echo "*** shared version of the library, which you do not appear to have" 96864cd6a3aeSmrg echo "*** because I did check the linker path looking for a file starting" 968754044362Smrg if test -z "$potlib"; then 96884cd6a3aeSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 96894cd6a3aeSmrg else 96904cd6a3aeSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96914cd6a3aeSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 96924cd6a3aeSmrg fi 96934cd6a3aeSmrg fi 96944cd6a3aeSmrg ;; 96954cd6a3aeSmrg *) 96964cd6a3aeSmrg # Add a -L argument. 96974cd6a3aeSmrg func_append newdeplibs " $a_deplib" 96984cd6a3aeSmrg ;; 96994cd6a3aeSmrg esac 97004cd6a3aeSmrg done # Gone through all deplibs. 97014cd6a3aeSmrg ;; 97024cd6a3aeSmrg none | unknown | *) 970354044362Smrg newdeplibs= 97044cd6a3aeSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 970554044362Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 970654044362Smrg for i in $predeps $postdeps; do 97074cd6a3aeSmrg # can't use Xsed below, because $i might contain '/' 970854044362Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 97094cd6a3aeSmrg done 97104cd6a3aeSmrg fi 97114cd6a3aeSmrg case $tmp_deplibs in 97124cd6a3aeSmrg *[!\ \ ]*) 97134cd6a3aeSmrg echo 971454044362Smrg if test none = "$deplibs_check_method"; then 97154cd6a3aeSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 97164cd6a3aeSmrg else 97174cd6a3aeSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 97184cd6a3aeSmrg fi 97194cd6a3aeSmrg echo "*** All declared inter-library dependencies are being dropped." 97204cd6a3aeSmrg droppeddeps=yes 97214cd6a3aeSmrg ;; 97224cd6a3aeSmrg esac 97234cd6a3aeSmrg ;; 97244cd6a3aeSmrg esac 97254cd6a3aeSmrg versuffix=$versuffix_save 97264cd6a3aeSmrg major=$major_save 97274cd6a3aeSmrg release=$release_save 97284cd6a3aeSmrg libname=$libname_save 97294cd6a3aeSmrg name=$name_save 97304cd6a3aeSmrg 97314cd6a3aeSmrg case $host in 97324cd6a3aeSmrg *-*-rhapsody* | *-*-darwin1.[012]) 97334cd6a3aeSmrg # On Rhapsody replace the C library with the System framework 97344cd6a3aeSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 97354cd6a3aeSmrg ;; 97364cd6a3aeSmrg esac 97374cd6a3aeSmrg 973854044362Smrg if test yes = "$droppeddeps"; then 973954044362Smrg if test yes = "$module"; then 97404cd6a3aeSmrg echo 97414cd6a3aeSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 97424cd6a3aeSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 97434cd6a3aeSmrg echo "*** a static module, that should work as long as the dlopening" 97444cd6a3aeSmrg echo "*** application is linked with the -dlopen flag." 97454cd6a3aeSmrg if test -z "$global_symbol_pipe"; then 97464cd6a3aeSmrg echo 97474cd6a3aeSmrg echo "*** However, this would only work if libtool was able to extract symbol" 974854044362Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 97494cd6a3aeSmrg echo "*** not find such a program. So, this module is probably useless." 975054044362Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 97514cd6a3aeSmrg fi 975254044362Smrg if test no = "$build_old_libs"; then 975354044362Smrg oldlibs=$output_objdir/$libname.$libext 97544cd6a3aeSmrg build_libtool_libs=module 97554cd6a3aeSmrg build_old_libs=yes 97564cd6a3aeSmrg else 97574cd6a3aeSmrg build_libtool_libs=no 97584cd6a3aeSmrg fi 97594cd6a3aeSmrg else 97604cd6a3aeSmrg echo "*** The inter-library dependencies that have been dropped here will be" 97614cd6a3aeSmrg echo "*** automatically added whenever a program is linked with this library" 97624cd6a3aeSmrg echo "*** or is declared to -dlopen it." 97638c9fbc29Smrg 976454044362Smrg if test no = "$allow_undefined"; then 97654cd6a3aeSmrg echo 97664cd6a3aeSmrg echo "*** Since this library must not contain undefined symbols," 97674cd6a3aeSmrg echo "*** because either the platform does not support them or" 97684cd6a3aeSmrg echo "*** it was explicitly requested with -no-undefined," 97694cd6a3aeSmrg echo "*** libtool will only create a static version of it." 977054044362Smrg if test no = "$build_old_libs"; then 977154044362Smrg oldlibs=$output_objdir/$libname.$libext 97724cd6a3aeSmrg build_libtool_libs=module 97734cd6a3aeSmrg build_old_libs=yes 97744cd6a3aeSmrg else 97754cd6a3aeSmrg build_libtool_libs=no 97764cd6a3aeSmrg fi 97774cd6a3aeSmrg fi 97784cd6a3aeSmrg fi 97794cd6a3aeSmrg fi 97804cd6a3aeSmrg # Done checking deplibs! 97814cd6a3aeSmrg deplibs=$newdeplibs 97824cd6a3aeSmrg fi 97834cd6a3aeSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 97844cd6a3aeSmrg case $host in 97854cd6a3aeSmrg *-*-darwin*) 97864cd6a3aeSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97874cd6a3aeSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97884cd6a3aeSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97894cd6a3aeSmrg ;; 97904cd6a3aeSmrg esac 97918c9fbc29Smrg 97924cd6a3aeSmrg # move library search paths that coincide with paths to not yet 97934cd6a3aeSmrg # installed libraries to the beginning of the library search list 97944cd6a3aeSmrg new_libs= 97954cd6a3aeSmrg for path in $notinst_path; do 97964cd6a3aeSmrg case " $new_libs " in 97974cd6a3aeSmrg *" -L$path/$objdir "*) ;; 97984cd6a3aeSmrg *) 97994cd6a3aeSmrg case " $deplibs " in 98004cd6a3aeSmrg *" -L$path/$objdir "*) 98014cd6a3aeSmrg func_append new_libs " -L$path/$objdir" ;; 98024cd6a3aeSmrg esac 98034cd6a3aeSmrg ;; 98044cd6a3aeSmrg esac 98054cd6a3aeSmrg done 98064cd6a3aeSmrg for deplib in $deplibs; do 98074cd6a3aeSmrg case $deplib in 98084cd6a3aeSmrg -L*) 98094cd6a3aeSmrg case " $new_libs " in 98104cd6a3aeSmrg *" $deplib "*) ;; 98114cd6a3aeSmrg *) func_append new_libs " $deplib" ;; 98124cd6a3aeSmrg esac 98134cd6a3aeSmrg ;; 98144cd6a3aeSmrg *) func_append new_libs " $deplib" ;; 98154cd6a3aeSmrg esac 98164cd6a3aeSmrg done 981754044362Smrg deplibs=$new_libs 98188c9fbc29Smrg 98194cd6a3aeSmrg # All the library-specific variables (install_libdir is set above). 98204cd6a3aeSmrg library_names= 98214cd6a3aeSmrg old_library= 98224cd6a3aeSmrg dlname= 98238c9fbc29Smrg 98244cd6a3aeSmrg # Test again, we may have decided not to build it any more 982554044362Smrg if test yes = "$build_libtool_libs"; then 982654044362Smrg # Remove $wl instances when linking with ld. 982770728a38Smrg # FIXME: should test the right _cmds variable. 982870728a38Smrg case $archive_cmds in 982970728a38Smrg *\$LD\ *) wl= ;; 983070728a38Smrg esac 983154044362Smrg if test yes = "$hardcode_into_libs"; then 98324cd6a3aeSmrg # Hardcode the library paths 98334cd6a3aeSmrg hardcode_libdirs= 98344cd6a3aeSmrg dep_rpath= 983554044362Smrg rpath=$finalize_rpath 983654044362Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 98374cd6a3aeSmrg for libdir in $rpath; do 98384cd6a3aeSmrg if test -n "$hardcode_libdir_flag_spec"; then 98394cd6a3aeSmrg if test -n "$hardcode_libdir_separator"; then 98404cd6a3aeSmrg func_replace_sysroot "$libdir" 98414cd6a3aeSmrg libdir=$func_replace_sysroot_result 98424cd6a3aeSmrg if test -z "$hardcode_libdirs"; then 984354044362Smrg hardcode_libdirs=$libdir 98444cd6a3aeSmrg else 98454cd6a3aeSmrg # Just accumulate the unique libdirs. 98464cd6a3aeSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 98474cd6a3aeSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 98484cd6a3aeSmrg ;; 98494cd6a3aeSmrg *) 98504cd6a3aeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 98514cd6a3aeSmrg ;; 98524cd6a3aeSmrg esac 98534cd6a3aeSmrg fi 98544cd6a3aeSmrg else 98554cd6a3aeSmrg eval flag=\"$hardcode_libdir_flag_spec\" 98564cd6a3aeSmrg func_append dep_rpath " $flag" 98574cd6a3aeSmrg fi 98584cd6a3aeSmrg elif test -n "$runpath_var"; then 98594cd6a3aeSmrg case "$perm_rpath " in 98604cd6a3aeSmrg *" $libdir "*) ;; 986170728a38Smrg *) func_append perm_rpath " $libdir" ;; 98624cd6a3aeSmrg esac 98634cd6a3aeSmrg fi 98644cd6a3aeSmrg done 98654cd6a3aeSmrg # Substitute the hardcoded libdirs into the rpath. 98664cd6a3aeSmrg if test -n "$hardcode_libdir_separator" && 98674cd6a3aeSmrg test -n "$hardcode_libdirs"; then 986854044362Smrg libdir=$hardcode_libdirs 986970728a38Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 98704cd6a3aeSmrg fi 98714cd6a3aeSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 98724cd6a3aeSmrg # We should set the runpath_var. 98734cd6a3aeSmrg rpath= 98744cd6a3aeSmrg for dir in $perm_rpath; do 98754cd6a3aeSmrg func_append rpath "$dir:" 98764cd6a3aeSmrg done 98774cd6a3aeSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 98784cd6a3aeSmrg fi 98794cd6a3aeSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 98804cd6a3aeSmrg fi 98818c9fbc29Smrg 988254044362Smrg shlibpath=$finalize_shlibpath 988354044362Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 98844cd6a3aeSmrg if test -n "$shlibpath"; then 98854cd6a3aeSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 98864cd6a3aeSmrg fi 98878c9fbc29Smrg 98884cd6a3aeSmrg # Get the real and link names of the library. 98894cd6a3aeSmrg eval shared_ext=\"$shrext_cmds\" 98904cd6a3aeSmrg eval library_names=\"$library_names_spec\" 98914cd6a3aeSmrg set dummy $library_names 98924cd6a3aeSmrg shift 989354044362Smrg realname=$1 98944cd6a3aeSmrg shift 98958c9fbc29Smrg 98964cd6a3aeSmrg if test -n "$soname_spec"; then 98974cd6a3aeSmrg eval soname=\"$soname_spec\" 98988c9fbc29Smrg else 989954044362Smrg soname=$realname 99004cd6a3aeSmrg fi 99014cd6a3aeSmrg if test -z "$dlname"; then 99024cd6a3aeSmrg dlname=$soname 99038c9fbc29Smrg fi 99048c9fbc29Smrg 990554044362Smrg lib=$output_objdir/$realname 99064cd6a3aeSmrg linknames= 99074cd6a3aeSmrg for link 99084cd6a3aeSmrg do 99094cd6a3aeSmrg func_append linknames " $link" 99104cd6a3aeSmrg done 99118c9fbc29Smrg 99124cd6a3aeSmrg # Use standard objects if they are pic 99134cd6a3aeSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 99144cd6a3aeSmrg test "X$libobjs" = "X " && libobjs= 99158c9fbc29Smrg 99164cd6a3aeSmrg delfiles= 99174cd6a3aeSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99184cd6a3aeSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 991954044362Smrg export_symbols=$output_objdir/$libname.uexp 99204cd6a3aeSmrg func_append delfiles " $export_symbols" 99214cd6a3aeSmrg fi 99228c9fbc29Smrg 99234cd6a3aeSmrg orig_export_symbols= 99244cd6a3aeSmrg case $host_os in 99254cd6a3aeSmrg cygwin* | mingw* | cegcc*) 99264cd6a3aeSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 99274cd6a3aeSmrg # exporting using user supplied symfile 992854044362Smrg func_dll_def_p "$export_symbols" || { 99294cd6a3aeSmrg # and it's NOT already a .def file. Must figure out 99304cd6a3aeSmrg # which of the given symbols are data symbols and tag 99314cd6a3aeSmrg # them as such. So, trigger use of export_symbols_cmds. 99324cd6a3aeSmrg # export_symbols gets reassigned inside the "prepare 99334cd6a3aeSmrg # the list of exported symbols" if statement, so the 99344cd6a3aeSmrg # include_expsyms logic still works. 993554044362Smrg orig_export_symbols=$export_symbols 99364cd6a3aeSmrg export_symbols= 99374cd6a3aeSmrg always_export_symbols=yes 993854044362Smrg } 99394cd6a3aeSmrg fi 99404cd6a3aeSmrg ;; 99414cd6a3aeSmrg esac 99428c9fbc29Smrg 99434cd6a3aeSmrg # Prepare the list of exported symbols 99444cd6a3aeSmrg if test -z "$export_symbols"; then 994554044362Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 994654044362Smrg func_verbose "generating symbol list for '$libname.la'" 994754044362Smrg export_symbols=$output_objdir/$libname.exp 99484cd6a3aeSmrg $opt_dry_run || $RM $export_symbols 99494cd6a3aeSmrg cmds=$export_symbols_cmds 995054044362Smrg save_ifs=$IFS; IFS='~' 99514cd6a3aeSmrg for cmd1 in $cmds; do 995254044362Smrg IFS=$save_ifs 99534cd6a3aeSmrg # Take the normal branch if the nm_file_list_spec branch 99544cd6a3aeSmrg # doesn't work or if tool conversion is not needed. 99554cd6a3aeSmrg case $nm_file_list_spec~$to_tool_file_cmd in 99564cd6a3aeSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 99574cd6a3aeSmrg try_normal_branch=yes 99584cd6a3aeSmrg eval cmd=\"$cmd1\" 99594cd6a3aeSmrg func_len " $cmd" 99604cd6a3aeSmrg len=$func_len_result 99614cd6a3aeSmrg ;; 99624cd6a3aeSmrg *) 99634cd6a3aeSmrg try_normal_branch=no 99644cd6a3aeSmrg ;; 99654cd6a3aeSmrg esac 996654044362Smrg if test yes = "$try_normal_branch" \ 99674cd6a3aeSmrg && { test "$len" -lt "$max_cmd_len" \ 99684cd6a3aeSmrg || test "$max_cmd_len" -le -1; } 99694cd6a3aeSmrg then 99704cd6a3aeSmrg func_show_eval "$cmd" 'exit $?' 99714cd6a3aeSmrg skipped_export=false 99724cd6a3aeSmrg elif test -n "$nm_file_list_spec"; then 99734cd6a3aeSmrg func_basename "$output" 99744cd6a3aeSmrg output_la=$func_basename_result 99754cd6a3aeSmrg save_libobjs=$libobjs 99764cd6a3aeSmrg save_output=$output 997754044362Smrg output=$output_objdir/$output_la.nm 99784cd6a3aeSmrg func_to_tool_file "$output" 99794cd6a3aeSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 99804cd6a3aeSmrg func_append delfiles " $output" 99814cd6a3aeSmrg func_verbose "creating $NM input file list: $output" 99824cd6a3aeSmrg for obj in $save_libobjs; do 99834cd6a3aeSmrg func_to_tool_file "$obj" 99844cd6a3aeSmrg $ECHO "$func_to_tool_file_result" 99854cd6a3aeSmrg done > "$output" 99864cd6a3aeSmrg eval cmd=\"$cmd1\" 99874cd6a3aeSmrg func_show_eval "$cmd" 'exit $?' 99884cd6a3aeSmrg output=$save_output 99894cd6a3aeSmrg libobjs=$save_libobjs 99904cd6a3aeSmrg skipped_export=false 99914cd6a3aeSmrg else 99924cd6a3aeSmrg # The command line is too long to execute in one step. 99934cd6a3aeSmrg func_verbose "using reloadable object file for export list..." 99944cd6a3aeSmrg skipped_export=: 99954cd6a3aeSmrg # Break out early, otherwise skipped_export may be 99964cd6a3aeSmrg # set to false by a later but shorter cmd. 99974cd6a3aeSmrg break 99984cd6a3aeSmrg fi 99994cd6a3aeSmrg done 1000054044362Smrg IFS=$save_ifs 1000154044362Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 100024cd6a3aeSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 100034cd6a3aeSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 100044cd6a3aeSmrg fi 100054cd6a3aeSmrg fi 100068c9fbc29Smrg fi 100078c9fbc29Smrg 100084cd6a3aeSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 1000954044362Smrg tmp_export_symbols=$export_symbols 1001054044362Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 100114cd6a3aeSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 100128c9fbc29Smrg fi 100138c9fbc29Smrg 1001454044362Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 100154cd6a3aeSmrg # The given exports_symbols file has to be filtered, so filter it. 1001654044362Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 100174cd6a3aeSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1001854044362Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 100194cd6a3aeSmrg # though. Also, the filter scales superlinearly with the number of 100204cd6a3aeSmrg # global variables. join(1) would be nice here, but unfortunately 100214cd6a3aeSmrg # isn't a blessed tool. 100224cd6a3aeSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100234cd6a3aeSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 100244cd6a3aeSmrg export_symbols=$output_objdir/$libname.def 100254cd6a3aeSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100264cd6a3aeSmrg fi 100278c9fbc29Smrg 100284cd6a3aeSmrg tmp_deplibs= 100294cd6a3aeSmrg for test_deplib in $deplibs; do 100304cd6a3aeSmrg case " $convenience " in 100314cd6a3aeSmrg *" $test_deplib "*) ;; 100324cd6a3aeSmrg *) 100334cd6a3aeSmrg func_append tmp_deplibs " $test_deplib" 100344cd6a3aeSmrg ;; 100354cd6a3aeSmrg esac 100364cd6a3aeSmrg done 1003754044362Smrg deplibs=$tmp_deplibs 100388c9fbc29Smrg 100394cd6a3aeSmrg if test -n "$convenience"; then 100404cd6a3aeSmrg if test -n "$whole_archive_flag_spec" && 1004154044362Smrg test yes = "$compiler_needs_object" && 100424cd6a3aeSmrg test -z "$libobjs"; then 100434cd6a3aeSmrg # extract the archives, so we have objects to list. 100444cd6a3aeSmrg # TODO: could optimize this to just extract one archive. 100454cd6a3aeSmrg whole_archive_flag_spec= 100464cd6a3aeSmrg fi 100474cd6a3aeSmrg if test -n "$whole_archive_flag_spec"; then 100484cd6a3aeSmrg save_libobjs=$libobjs 100494cd6a3aeSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 100504cd6a3aeSmrg test "X$libobjs" = "X " && libobjs= 100514cd6a3aeSmrg else 1005254044362Smrg gentop=$output_objdir/${outputname}x 100534cd6a3aeSmrg func_append generated " $gentop" 100548c9fbc29Smrg 100554cd6a3aeSmrg func_extract_archives $gentop $convenience 100564cd6a3aeSmrg func_append libobjs " $func_extract_archives_result" 100574cd6a3aeSmrg test "X$libobjs" = "X " && libobjs= 100584cd6a3aeSmrg fi 100598c9fbc29Smrg fi 100608c9fbc29Smrg 1006154044362Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 100624cd6a3aeSmrg eval flag=\"$thread_safe_flag_spec\" 100634cd6a3aeSmrg func_append linker_flags " $flag" 100644cd6a3aeSmrg fi 100658c9fbc29Smrg 100664cd6a3aeSmrg # Make a backup of the uninstalled library when relinking 1006754044362Smrg if test relink = "$opt_mode"; then 100684cd6a3aeSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 100694cd6a3aeSmrg fi 100704cd6a3aeSmrg 100714cd6a3aeSmrg # Do each of the archive commands. 1007254044362Smrg if test yes = "$module" && test -n "$module_cmds"; then 100734cd6a3aeSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100744cd6a3aeSmrg eval test_cmds=\"$module_expsym_cmds\" 100754cd6a3aeSmrg cmds=$module_expsym_cmds 100764cd6a3aeSmrg else 100774cd6a3aeSmrg eval test_cmds=\"$module_cmds\" 100784cd6a3aeSmrg cmds=$module_cmds 100794cd6a3aeSmrg fi 100804cd6a3aeSmrg else 100814cd6a3aeSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100824cd6a3aeSmrg eval test_cmds=\"$archive_expsym_cmds\" 100834cd6a3aeSmrg cmds=$archive_expsym_cmds 100844cd6a3aeSmrg else 100854cd6a3aeSmrg eval test_cmds=\"$archive_cmds\" 100864cd6a3aeSmrg cmds=$archive_cmds 100874cd6a3aeSmrg fi 100884cd6a3aeSmrg fi 100898c9fbc29Smrg 1009054044362Smrg if test : != "$skipped_export" && 100914cd6a3aeSmrg func_len " $test_cmds" && 100924cd6a3aeSmrg len=$func_len_result && 100934cd6a3aeSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100948c9fbc29Smrg : 100958c9fbc29Smrg else 100964cd6a3aeSmrg # The command line is too long to link in one step, link piecewise 100974cd6a3aeSmrg # or, if using GNU ld and skipped_export is not :, use a linker 100984cd6a3aeSmrg # script. 100998c9fbc29Smrg 101004cd6a3aeSmrg # Save the value of $output and $libobjs because we want to 101014cd6a3aeSmrg # use them later. If we have whole_archive_flag_spec, we 101024cd6a3aeSmrg # want to use save_libobjs as it was before 101034cd6a3aeSmrg # whole_archive_flag_spec was expanded, because we can't 101044cd6a3aeSmrg # assume the linker understands whole_archive_flag_spec. 101054cd6a3aeSmrg # This may have to be revisited, in case too many 101064cd6a3aeSmrg # convenience libraries get linked in and end up exceeding 101074cd6a3aeSmrg # the spec. 101084cd6a3aeSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 101094cd6a3aeSmrg save_libobjs=$libobjs 101108c9fbc29Smrg fi 101114cd6a3aeSmrg save_output=$output 101124cd6a3aeSmrg func_basename "$output" 101134cd6a3aeSmrg output_la=$func_basename_result 101148c9fbc29Smrg 101154cd6a3aeSmrg # Clear the reloadable object creation command queue and 101164cd6a3aeSmrg # initialize k to one. 101174cd6a3aeSmrg test_cmds= 101188c9fbc29Smrg concat_cmds= 101194cd6a3aeSmrg objlist= 101204cd6a3aeSmrg last_robj= 101214cd6a3aeSmrg k=1 101228c9fbc29Smrg 1012354044362Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 1012454044362Smrg output=$output_objdir/$output_la.lnkscript 101254cd6a3aeSmrg func_verbose "creating GNU ld script: $output" 101264cd6a3aeSmrg echo 'INPUT (' > $output 101274cd6a3aeSmrg for obj in $save_libobjs 101284cd6a3aeSmrg do 101294cd6a3aeSmrg func_to_tool_file "$obj" 101304cd6a3aeSmrg $ECHO "$func_to_tool_file_result" >> $output 101314cd6a3aeSmrg done 101324cd6a3aeSmrg echo ')' >> $output 101334cd6a3aeSmrg func_append delfiles " $output" 101344cd6a3aeSmrg func_to_tool_file "$output" 101354cd6a3aeSmrg output=$func_to_tool_file_result 1013654044362Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 1013754044362Smrg output=$output_objdir/$output_la.lnk 101384cd6a3aeSmrg func_verbose "creating linker input file list: $output" 101394cd6a3aeSmrg : > $output 101404cd6a3aeSmrg set x $save_libobjs 101414cd6a3aeSmrg shift 101424cd6a3aeSmrg firstobj= 1014354044362Smrg if test yes = "$compiler_needs_object"; then 101444cd6a3aeSmrg firstobj="$1 " 101454cd6a3aeSmrg shift 101464cd6a3aeSmrg fi 101474cd6a3aeSmrg for obj 101484cd6a3aeSmrg do 101494cd6a3aeSmrg func_to_tool_file "$obj" 101504cd6a3aeSmrg $ECHO "$func_to_tool_file_result" >> $output 101514cd6a3aeSmrg done 101524cd6a3aeSmrg func_append delfiles " $output" 101534cd6a3aeSmrg func_to_tool_file "$output" 101544cd6a3aeSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 101554cd6a3aeSmrg else 101564cd6a3aeSmrg if test -n "$save_libobjs"; then 101574cd6a3aeSmrg func_verbose "creating reloadable object files..." 1015854044362Smrg output=$output_objdir/$output_la-$k.$objext 101594cd6a3aeSmrg eval test_cmds=\"$reload_cmds\" 101604cd6a3aeSmrg func_len " $test_cmds" 101614cd6a3aeSmrg len0=$func_len_result 101624cd6a3aeSmrg len=$len0 101634cd6a3aeSmrg 101644cd6a3aeSmrg # Loop over the list of objects to be linked. 101654cd6a3aeSmrg for obj in $save_libobjs 101664cd6a3aeSmrg do 101674cd6a3aeSmrg func_len " $obj" 101684cd6a3aeSmrg func_arith $len + $func_len_result 101694cd6a3aeSmrg len=$func_arith_result 1017054044362Smrg if test -z "$objlist" || 101714cd6a3aeSmrg test "$len" -lt "$max_cmd_len"; then 101724cd6a3aeSmrg func_append objlist " $obj" 101734cd6a3aeSmrg else 101744cd6a3aeSmrg # The command $test_cmds is almost too long, add a 101754cd6a3aeSmrg # command to the queue. 1017654044362Smrg if test 1 -eq "$k"; then 101774cd6a3aeSmrg # The first file doesn't have a previous command to add. 101784cd6a3aeSmrg reload_objs=$objlist 101794cd6a3aeSmrg eval concat_cmds=\"$reload_cmds\" 101804cd6a3aeSmrg else 101814cd6a3aeSmrg # All subsequent reloadable object files will link in 101824cd6a3aeSmrg # the last one created. 101834cd6a3aeSmrg reload_objs="$objlist $last_robj" 101844cd6a3aeSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 101854cd6a3aeSmrg fi 1018654044362Smrg last_robj=$output_objdir/$output_la-$k.$objext 101874cd6a3aeSmrg func_arith $k + 1 101884cd6a3aeSmrg k=$func_arith_result 1018954044362Smrg output=$output_objdir/$output_la-$k.$objext 101904cd6a3aeSmrg objlist=" $obj" 101914cd6a3aeSmrg func_len " $last_robj" 101924cd6a3aeSmrg func_arith $len0 + $func_len_result 101934cd6a3aeSmrg len=$func_arith_result 101944cd6a3aeSmrg fi 101954cd6a3aeSmrg done 101964cd6a3aeSmrg # Handle the remaining objects by creating one last 101974cd6a3aeSmrg # reloadable object file. All subsequent reloadable object 101984cd6a3aeSmrg # files will link in the last one created. 101994cd6a3aeSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102004cd6a3aeSmrg reload_objs="$objlist $last_robj" 1020154044362Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 102024cd6a3aeSmrg if test -n "$last_robj"; then 1020354044362Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102048c9fbc29Smrg fi 102054cd6a3aeSmrg func_append delfiles " $output" 102064cd6a3aeSmrg 102074cd6a3aeSmrg else 102084cd6a3aeSmrg output= 102094cd6a3aeSmrg fi 102104cd6a3aeSmrg 1021154044362Smrg ${skipped_export-false} && { 1021254044362Smrg func_verbose "generating symbol list for '$libname.la'" 1021354044362Smrg export_symbols=$output_objdir/$libname.exp 102144cd6a3aeSmrg $opt_dry_run || $RM $export_symbols 102154cd6a3aeSmrg libobjs=$output 102164cd6a3aeSmrg # Append the command to create the export file. 102178c9fbc29Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102184cd6a3aeSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 102194cd6a3aeSmrg if test -n "$last_robj"; then 102204cd6a3aeSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102214cd6a3aeSmrg fi 1022254044362Smrg } 102234cd6a3aeSmrg 102244cd6a3aeSmrg test -n "$save_libobjs" && 102254cd6a3aeSmrg func_verbose "creating a temporary reloadable object file: $output" 102264cd6a3aeSmrg 102274cd6a3aeSmrg # Loop through the commands generated above and execute them. 1022854044362Smrg save_ifs=$IFS; IFS='~' 102294cd6a3aeSmrg for cmd in $concat_cmds; do 1023054044362Smrg IFS=$save_ifs 1023154044362Smrg $opt_quiet || { 1023254cef2ddSmrg func_quote_arg expand,pretty "$cmd" 1023354cef2ddSmrg eval "func_echo $func_quote_arg_result" 102344cd6a3aeSmrg } 102354cd6a3aeSmrg $opt_dry_run || eval "$cmd" || { 102364cd6a3aeSmrg lt_exit=$? 102374cd6a3aeSmrg 102384cd6a3aeSmrg # Restore the uninstalled library and exit 1023954044362Smrg if test relink = "$opt_mode"; then 102404cd6a3aeSmrg ( cd "$output_objdir" && \ 102414cd6a3aeSmrg $RM "${realname}T" && \ 102424cd6a3aeSmrg $MV "${realname}U" "$realname" ) 102434cd6a3aeSmrg fi 102444cd6a3aeSmrg 102454cd6a3aeSmrg exit $lt_exit 102464cd6a3aeSmrg } 102474cd6a3aeSmrg done 1024854044362Smrg IFS=$save_ifs 102494cd6a3aeSmrg 102504cd6a3aeSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 102514cd6a3aeSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 102524cd6a3aeSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102538c9fbc29Smrg fi 102548c9fbc29Smrg fi 102558c9fbc29Smrg 1025654044362Smrg ${skipped_export-false} && { 102574cd6a3aeSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 1025854044362Smrg tmp_export_symbols=$export_symbols 1025954044362Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 102604cd6a3aeSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 102614cd6a3aeSmrg fi 102628c9fbc29Smrg 102634cd6a3aeSmrg if test -n "$orig_export_symbols"; then 102644cd6a3aeSmrg # The given exports_symbols file has to be filtered, so filter it. 1026554044362Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 102664cd6a3aeSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1026754044362Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 102684cd6a3aeSmrg # though. Also, the filter scales superlinearly with the number of 102694cd6a3aeSmrg # global variables. join(1) would be nice here, but unfortunately 102704cd6a3aeSmrg # isn't a blessed tool. 102714cd6a3aeSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 102724cd6a3aeSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 102734cd6a3aeSmrg export_symbols=$output_objdir/$libname.def 102744cd6a3aeSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 102754cd6a3aeSmrg fi 1027654044362Smrg } 102778c9fbc29Smrg 102784cd6a3aeSmrg libobjs=$output 102794cd6a3aeSmrg # Restore the value of output. 102804cd6a3aeSmrg output=$save_output 102818c9fbc29Smrg 102824cd6a3aeSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 102834cd6a3aeSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 102844cd6a3aeSmrg test "X$libobjs" = "X " && libobjs= 102854cd6a3aeSmrg fi 102864cd6a3aeSmrg # Expand the library linking commands again to reset the 102874cd6a3aeSmrg # value of $libobjs for piecewise linking. 102888c9fbc29Smrg 102894cd6a3aeSmrg # Do each of the archive commands. 1029054044362Smrg if test yes = "$module" && test -n "$module_cmds"; then 102914cd6a3aeSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 102924cd6a3aeSmrg cmds=$module_expsym_cmds 102934cd6a3aeSmrg else 102944cd6a3aeSmrg cmds=$module_cmds 102958c9fbc29Smrg fi 102968c9fbc29Smrg else 102974cd6a3aeSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 102984cd6a3aeSmrg cmds=$archive_expsym_cmds 102994cd6a3aeSmrg else 103004cd6a3aeSmrg cmds=$archive_cmds 103014cd6a3aeSmrg fi 103028c9fbc29Smrg fi 103034cd6a3aeSmrg fi 103048c9fbc29Smrg 103054cd6a3aeSmrg if test -n "$delfiles"; then 103064cd6a3aeSmrg # Append the command to remove temporary files to $cmds. 103074cd6a3aeSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 103084cd6a3aeSmrg fi 103098c9fbc29Smrg 103104cd6a3aeSmrg # Add any objects from preloaded convenience libraries 103114cd6a3aeSmrg if test -n "$dlprefiles"; then 1031254044362Smrg gentop=$output_objdir/${outputname}x 103134cd6a3aeSmrg func_append generated " $gentop" 103148c9fbc29Smrg 103154cd6a3aeSmrg func_extract_archives $gentop $dlprefiles 103164cd6a3aeSmrg func_append libobjs " $func_extract_archives_result" 103174cd6a3aeSmrg test "X$libobjs" = "X " && libobjs= 103184cd6a3aeSmrg fi 103198c9fbc29Smrg 1032054044362Smrg save_ifs=$IFS; IFS='~' 103214cd6a3aeSmrg for cmd in $cmds; do 1032254044362Smrg IFS=$sp$nl 103234cd6a3aeSmrg eval cmd=\"$cmd\" 1032454044362Smrg IFS=$save_ifs 1032554044362Smrg $opt_quiet || { 1032654cef2ddSmrg func_quote_arg expand,pretty "$cmd" 1032754cef2ddSmrg eval "func_echo $func_quote_arg_result" 103284cd6a3aeSmrg } 103294cd6a3aeSmrg $opt_dry_run || eval "$cmd" || { 103304cd6a3aeSmrg lt_exit=$? 103318c9fbc29Smrg 103324cd6a3aeSmrg # Restore the uninstalled library and exit 1033354044362Smrg if test relink = "$opt_mode"; then 103344cd6a3aeSmrg ( cd "$output_objdir" && \ 103354cd6a3aeSmrg $RM "${realname}T" && \ 103364cd6a3aeSmrg $MV "${realname}U" "$realname" ) 103374cd6a3aeSmrg fi 103388c9fbc29Smrg 103394cd6a3aeSmrg exit $lt_exit 103404cd6a3aeSmrg } 103414cd6a3aeSmrg done 1034254044362Smrg IFS=$save_ifs 103438c9fbc29Smrg 103444cd6a3aeSmrg # Restore the uninstalled library and exit 1034554044362Smrg if test relink = "$opt_mode"; then 103464cd6a3aeSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103478c9fbc29Smrg 103484cd6a3aeSmrg if test -n "$convenience"; then 103494cd6a3aeSmrg if test -z "$whole_archive_flag_spec"; then 103504cd6a3aeSmrg func_show_eval '${RM}r "$gentop"' 103514cd6a3aeSmrg fi 103524cd6a3aeSmrg fi 103538c9fbc29Smrg 103544cd6a3aeSmrg exit $EXIT_SUCCESS 103554cd6a3aeSmrg fi 103564cd6a3aeSmrg 103574cd6a3aeSmrg # Create links to the real library. 103584cd6a3aeSmrg for linkname in $linknames; do 103594cd6a3aeSmrg if test "$realname" != "$linkname"; then 103604cd6a3aeSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103618c9fbc29Smrg fi 103628c9fbc29Smrg done 103638c9fbc29Smrg 103644cd6a3aeSmrg # If -module or -export-dynamic was specified, set the dlname. 1036554044362Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 103664cd6a3aeSmrg # On all known operating systems, these are identical. 1036754044362Smrg dlname=$soname 103684cd6a3aeSmrg fi 103694cd6a3aeSmrg fi 103708c9fbc29Smrg ;; 103718c9fbc29Smrg 103724cd6a3aeSmrg obj) 1037354044362Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1037454044362Smrg func_warning "'-dlopen' is ignored for objects" 103754cd6a3aeSmrg fi 103768c9fbc29Smrg 103774cd6a3aeSmrg case " $deplibs" in 103784cd6a3aeSmrg *\ -l* | *\ -L*) 1037954044362Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 103808c9fbc29Smrg esac 103818c9fbc29Smrg 103824cd6a3aeSmrg test -n "$rpath" && \ 1038354044362Smrg func_warning "'-rpath' is ignored for objects" 103848c9fbc29Smrg 103854cd6a3aeSmrg test -n "$xrpath" && \ 1038654044362Smrg func_warning "'-R' is ignored for objects" 103878c9fbc29Smrg 103884cd6a3aeSmrg test -n "$vinfo" && \ 1038954044362Smrg func_warning "'-version-info' is ignored for objects" 103904cd6a3aeSmrg 103914cd6a3aeSmrg test -n "$release" && \ 1039254044362Smrg func_warning "'-release' is ignored for objects" 103934cd6a3aeSmrg 103944cd6a3aeSmrg case $output in 103954cd6a3aeSmrg *.lo) 103964cd6a3aeSmrg test -n "$objs$old_deplibs" && \ 1039754044362Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 103984cd6a3aeSmrg 103994cd6a3aeSmrg libobj=$output 104004cd6a3aeSmrg func_lo2o "$libobj" 104014cd6a3aeSmrg obj=$func_lo2o_result 104028c9fbc29Smrg ;; 104038c9fbc29Smrg *) 104044cd6a3aeSmrg libobj= 1040554044362Smrg obj=$output 104068c9fbc29Smrg ;; 104078c9fbc29Smrg esac 104088c9fbc29Smrg 104094cd6a3aeSmrg # Delete the old objects. 104104cd6a3aeSmrg $opt_dry_run || $RM $obj $libobj 104118c9fbc29Smrg 104124cd6a3aeSmrg # Objects from convenience libraries. This assumes 104134cd6a3aeSmrg # single-version convenience libraries. Whenever we create 104144cd6a3aeSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 104154cd6a3aeSmrg # the extraction. 104164cd6a3aeSmrg reload_conv_objs= 104174cd6a3aeSmrg gentop= 1041854044362Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 1041954044362Smrg # whole_archive_flag_spec and hope we can get by with turning comma 1042054044362Smrg # into space. 1042154044362Smrg case $reload_cmds in 1042254044362Smrg *\$LD[\ \$]*) wl= ;; 1042354044362Smrg esac 104244cd6a3aeSmrg if test -n "$convenience"; then 104254cd6a3aeSmrg if test -n "$whole_archive_flag_spec"; then 104264cd6a3aeSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1042754044362Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1042854044362Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 104294cd6a3aeSmrg else 1043054044362Smrg gentop=$output_objdir/${obj}x 104314cd6a3aeSmrg func_append generated " $gentop" 104328c9fbc29Smrg 104334cd6a3aeSmrg func_extract_archives $gentop $convenience 104344cd6a3aeSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 104354cd6a3aeSmrg fi 104368c9fbc29Smrg fi 104378c9fbc29Smrg 104384cd6a3aeSmrg # If we're not building shared, we need to use non_pic_objs 1043954044362Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104408c9fbc29Smrg 104414cd6a3aeSmrg # Create the old-style object. 1044254044362Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104438c9fbc29Smrg 1044454044362Smrg output=$obj 104454cd6a3aeSmrg func_execute_cmds "$reload_cmds" 'exit $?' 104464cd6a3aeSmrg 104474cd6a3aeSmrg # Exit if we aren't doing a library object file. 104484cd6a3aeSmrg if test -z "$libobj"; then 104494cd6a3aeSmrg if test -n "$gentop"; then 104504cd6a3aeSmrg func_show_eval '${RM}r "$gentop"' 104514cd6a3aeSmrg fi 104524cd6a3aeSmrg 104534cd6a3aeSmrg exit $EXIT_SUCCESS 104548c9fbc29Smrg fi 104554cd6a3aeSmrg 1045654044362Smrg test yes = "$build_libtool_libs" || { 104574cd6a3aeSmrg if test -n "$gentop"; then 104584cd6a3aeSmrg func_show_eval '${RM}r "$gentop"' 104594cd6a3aeSmrg fi 104604cd6a3aeSmrg 104614cd6a3aeSmrg # Create an invalid libtool object if no PIC, so that we don't 104624cd6a3aeSmrg # accidentally link it into a program. 104634cd6a3aeSmrg # $show "echo timestamp > $libobj" 104644cd6a3aeSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 104654cd6a3aeSmrg exit $EXIT_SUCCESS 1046654044362Smrg } 104674cd6a3aeSmrg 1046854044362Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 104694cd6a3aeSmrg # Only do commands if we really have different PIC objects. 104704cd6a3aeSmrg reload_objs="$libobjs $reload_conv_objs" 1047154044362Smrg output=$libobj 104724cd6a3aeSmrg func_execute_cmds "$reload_cmds" 'exit $?' 104734cd6a3aeSmrg fi 104744cd6a3aeSmrg 104754cd6a3aeSmrg if test -n "$gentop"; then 104764cd6a3aeSmrg func_show_eval '${RM}r "$gentop"' 104774cd6a3aeSmrg fi 104784cd6a3aeSmrg 104794cd6a3aeSmrg exit $EXIT_SUCCESS 104808c9fbc29Smrg ;; 104818c9fbc29Smrg 104824cd6a3aeSmrg prog) 104834cd6a3aeSmrg case $host in 104844cd6a3aeSmrg *cygwin*) func_stripname '' '.exe' "$output" 104854cd6a3aeSmrg output=$func_stripname_result.exe;; 104864cd6a3aeSmrg esac 104874cd6a3aeSmrg test -n "$vinfo" && \ 1048854044362Smrg func_warning "'-version-info' is ignored for programs" 104898c9fbc29Smrg 104904cd6a3aeSmrg test -n "$release" && \ 1049154044362Smrg func_warning "'-release' is ignored for programs" 104928c9fbc29Smrg 1049354044362Smrg $preload \ 1049454044362Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1049554044362Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 104964cd6a3aeSmrg 104974cd6a3aeSmrg case $host in 104984cd6a3aeSmrg *-*-rhapsody* | *-*-darwin1.[012]) 104994cd6a3aeSmrg # On Rhapsody replace the C library is the System framework 105004cd6a3aeSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 105014cd6a3aeSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 105028c9fbc29Smrg ;; 105034cd6a3aeSmrg esac 105048c9fbc29Smrg 105054cd6a3aeSmrg case $host in 105064cd6a3aeSmrg *-*-darwin*) 105074cd6a3aeSmrg # Don't allow lazy linking, it breaks C++ global constructors 105084cd6a3aeSmrg # But is supposedly fixed on 10.4 or later (yay!). 1050954044362Smrg if test CXX = "$tagname"; then 105104cd6a3aeSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 105114cd6a3aeSmrg 10.[0123]) 1051254044362Smrg func_append compile_command " $wl-bind_at_load" 1051354044362Smrg func_append finalize_command " $wl-bind_at_load" 105144cd6a3aeSmrg ;; 105154cd6a3aeSmrg esac 105168c9fbc29Smrg fi 105174cd6a3aeSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 105184cd6a3aeSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105194cd6a3aeSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105204cd6a3aeSmrg ;; 105214cd6a3aeSmrg esac 105228c9fbc29Smrg 105238c9fbc29Smrg 105244cd6a3aeSmrg # move library search paths that coincide with paths to not yet 105254cd6a3aeSmrg # installed libraries to the beginning of the library search list 105264cd6a3aeSmrg new_libs= 105274cd6a3aeSmrg for path in $notinst_path; do 105284cd6a3aeSmrg case " $new_libs " in 105294cd6a3aeSmrg *" -L$path/$objdir "*) ;; 105304cd6a3aeSmrg *) 105314cd6a3aeSmrg case " $compile_deplibs " in 105324cd6a3aeSmrg *" -L$path/$objdir "*) 105334cd6a3aeSmrg func_append new_libs " -L$path/$objdir" ;; 105348c9fbc29Smrg esac 105354cd6a3aeSmrg ;; 105364cd6a3aeSmrg esac 105374cd6a3aeSmrg done 105384cd6a3aeSmrg for deplib in $compile_deplibs; do 105394cd6a3aeSmrg case $deplib in 105404cd6a3aeSmrg -L*) 105414cd6a3aeSmrg case " $new_libs " in 105424cd6a3aeSmrg *" $deplib "*) ;; 105434cd6a3aeSmrg *) func_append new_libs " $deplib" ;; 105448c9fbc29Smrg esac 105454cd6a3aeSmrg ;; 105464cd6a3aeSmrg *) func_append new_libs " $deplib" ;; 105474cd6a3aeSmrg esac 105484cd6a3aeSmrg done 1054954044362Smrg compile_deplibs=$new_libs 105508c9fbc29Smrg 105518c9fbc29Smrg 105524cd6a3aeSmrg func_append compile_command " $compile_deplibs" 105534cd6a3aeSmrg func_append finalize_command " $finalize_deplibs" 105548c9fbc29Smrg 105554cd6a3aeSmrg if test -n "$rpath$xrpath"; then 105564cd6a3aeSmrg # If the user specified any rpath flags, then add them. 105574cd6a3aeSmrg for libdir in $rpath $xrpath; do 105584cd6a3aeSmrg # This is the magic to use -rpath. 105594cd6a3aeSmrg case "$finalize_rpath " in 105604cd6a3aeSmrg *" $libdir "*) ;; 105614cd6a3aeSmrg *) func_append finalize_rpath " $libdir" ;; 105624cd6a3aeSmrg esac 105634cd6a3aeSmrg done 105644cd6a3aeSmrg fi 105658c9fbc29Smrg 105664cd6a3aeSmrg # Now hardcode the library paths 105674cd6a3aeSmrg rpath= 105684cd6a3aeSmrg hardcode_libdirs= 105694cd6a3aeSmrg for libdir in $compile_rpath $finalize_rpath; do 105704cd6a3aeSmrg if test -n "$hardcode_libdir_flag_spec"; then 105714cd6a3aeSmrg if test -n "$hardcode_libdir_separator"; then 105724cd6a3aeSmrg if test -z "$hardcode_libdirs"; then 1057354044362Smrg hardcode_libdirs=$libdir 105744cd6a3aeSmrg else 105754cd6a3aeSmrg # Just accumulate the unique libdirs. 105764cd6a3aeSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 105774cd6a3aeSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 105784cd6a3aeSmrg ;; 105794cd6a3aeSmrg *) 105804cd6a3aeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 105814cd6a3aeSmrg ;; 105824cd6a3aeSmrg esac 105834cd6a3aeSmrg fi 105848c9fbc29Smrg else 105854cd6a3aeSmrg eval flag=\"$hardcode_libdir_flag_spec\" 105864cd6a3aeSmrg func_append rpath " $flag" 105878c9fbc29Smrg fi 105884cd6a3aeSmrg elif test -n "$runpath_var"; then 105894cd6a3aeSmrg case "$perm_rpath " in 105904cd6a3aeSmrg *" $libdir "*) ;; 105914cd6a3aeSmrg *) func_append perm_rpath " $libdir" ;; 105924cd6a3aeSmrg esac 105934cd6a3aeSmrg fi 105944cd6a3aeSmrg case $host in 105954cd6a3aeSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1059654044362Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 105974cd6a3aeSmrg case :$dllsearchpath: in 105984cd6a3aeSmrg *":$libdir:"*) ;; 105994cd6a3aeSmrg ::) dllsearchpath=$libdir;; 106004cd6a3aeSmrg *) func_append dllsearchpath ":$libdir";; 106014cd6a3aeSmrg esac 106024cd6a3aeSmrg case :$dllsearchpath: in 106034cd6a3aeSmrg *":$testbindir:"*) ;; 106044cd6a3aeSmrg ::) dllsearchpath=$testbindir;; 106054cd6a3aeSmrg *) func_append dllsearchpath ":$testbindir";; 106064cd6a3aeSmrg esac 106074cd6a3aeSmrg ;; 106084cd6a3aeSmrg esac 106094cd6a3aeSmrg done 106104cd6a3aeSmrg # Substitute the hardcoded libdirs into the rpath. 106114cd6a3aeSmrg if test -n "$hardcode_libdir_separator" && 106124cd6a3aeSmrg test -n "$hardcode_libdirs"; then 1061354044362Smrg libdir=$hardcode_libdirs 106144cd6a3aeSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 106154cd6a3aeSmrg fi 1061654044362Smrg compile_rpath=$rpath 106178c9fbc29Smrg 106184cd6a3aeSmrg rpath= 106194cd6a3aeSmrg hardcode_libdirs= 106204cd6a3aeSmrg for libdir in $finalize_rpath; do 106214cd6a3aeSmrg if test -n "$hardcode_libdir_flag_spec"; then 106224cd6a3aeSmrg if test -n "$hardcode_libdir_separator"; then 106234cd6a3aeSmrg if test -z "$hardcode_libdirs"; then 1062454044362Smrg hardcode_libdirs=$libdir 106254cd6a3aeSmrg else 106264cd6a3aeSmrg # Just accumulate the unique libdirs. 106274cd6a3aeSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 106284cd6a3aeSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 106294cd6a3aeSmrg ;; 106304cd6a3aeSmrg *) 106314cd6a3aeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 106324cd6a3aeSmrg ;; 106334cd6a3aeSmrg esac 106344cd6a3aeSmrg fi 106358c9fbc29Smrg else 106364cd6a3aeSmrg eval flag=\"$hardcode_libdir_flag_spec\" 106374cd6a3aeSmrg func_append rpath " $flag" 106388c9fbc29Smrg fi 106394cd6a3aeSmrg elif test -n "$runpath_var"; then 106404cd6a3aeSmrg case "$finalize_perm_rpath " in 106414cd6a3aeSmrg *" $libdir "*) ;; 106424cd6a3aeSmrg *) func_append finalize_perm_rpath " $libdir" ;; 106434cd6a3aeSmrg esac 106448c9fbc29Smrg fi 106454cd6a3aeSmrg done 106464cd6a3aeSmrg # Substitute the hardcoded libdirs into the rpath. 106474cd6a3aeSmrg if test -n "$hardcode_libdir_separator" && 106484cd6a3aeSmrg test -n "$hardcode_libdirs"; then 1064954044362Smrg libdir=$hardcode_libdirs 106504cd6a3aeSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 106514cd6a3aeSmrg fi 1065254044362Smrg finalize_rpath=$rpath 106538c9fbc29Smrg 1065454044362Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 106554cd6a3aeSmrg # Transform all the library objects into standard objects. 106564cd6a3aeSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106574cd6a3aeSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106584cd6a3aeSmrg fi 106598c9fbc29Smrg 1066054044362Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106618c9fbc29Smrg 106624cd6a3aeSmrg # template prelinking step 106634cd6a3aeSmrg if test -n "$prelink_cmds"; then 106644cd6a3aeSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 106654cd6a3aeSmrg fi 106668c9fbc29Smrg 1066754044362Smrg wrappers_required=: 106684cd6a3aeSmrg case $host in 106694cd6a3aeSmrg *cegcc* | *mingw32ce*) 106704cd6a3aeSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1067154044362Smrg wrappers_required=false 106724cd6a3aeSmrg ;; 106734cd6a3aeSmrg *cygwin* | *mingw* ) 1067454044362Smrg test yes = "$build_libtool_libs" || wrappers_required=false 106754cd6a3aeSmrg ;; 106764cd6a3aeSmrg *) 1067754044362Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1067854044362Smrg wrappers_required=false 106794cd6a3aeSmrg fi 106804cd6a3aeSmrg ;; 106814cd6a3aeSmrg esac 1068254044362Smrg $wrappers_required || { 106834cd6a3aeSmrg # Replace the output file specification. 106844cd6a3aeSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1068554044362Smrg link_command=$compile_command$compile_rpath 106868c9fbc29Smrg 106874cd6a3aeSmrg # We have no uninstalled library dependencies, so finalize right now. 106884cd6a3aeSmrg exit_status=0 106894cd6a3aeSmrg func_show_eval "$link_command" 'exit_status=$?' 106908c9fbc29Smrg 106914cd6a3aeSmrg if test -n "$postlink_cmds"; then 106924cd6a3aeSmrg func_to_tool_file "$output" 106934cd6a3aeSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 106944cd6a3aeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 106958c9fbc29Smrg fi 106968c9fbc29Smrg 106974cd6a3aeSmrg # Delete the generated files. 1069854044362Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 1069954044362Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 107004cd6a3aeSmrg fi 107018c9fbc29Smrg 107024cd6a3aeSmrg exit $exit_status 1070354044362Smrg } 107048c9fbc29Smrg 107054cd6a3aeSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 107064cd6a3aeSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 107074cd6a3aeSmrg fi 107084cd6a3aeSmrg if test -n "$finalize_shlibpath"; then 107094cd6a3aeSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 107104cd6a3aeSmrg fi 107118c9fbc29Smrg 107124cd6a3aeSmrg compile_var= 107134cd6a3aeSmrg finalize_var= 107144cd6a3aeSmrg if test -n "$runpath_var"; then 107154cd6a3aeSmrg if test -n "$perm_rpath"; then 107164cd6a3aeSmrg # We should set the runpath_var. 107174cd6a3aeSmrg rpath= 107184cd6a3aeSmrg for dir in $perm_rpath; do 107194cd6a3aeSmrg func_append rpath "$dir:" 107204cd6a3aeSmrg done 107214cd6a3aeSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107228c9fbc29Smrg fi 107234cd6a3aeSmrg if test -n "$finalize_perm_rpath"; then 107244cd6a3aeSmrg # We should set the runpath_var. 107254cd6a3aeSmrg rpath= 107264cd6a3aeSmrg for dir in $finalize_perm_rpath; do 107274cd6a3aeSmrg func_append rpath "$dir:" 107284cd6a3aeSmrg done 107294cd6a3aeSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107308c9fbc29Smrg fi 107314cd6a3aeSmrg fi 107328c9fbc29Smrg 1073354044362Smrg if test yes = "$no_install"; then 107344cd6a3aeSmrg # We don't need to create a wrapper script. 1073554044362Smrg link_command=$compile_var$compile_command$compile_rpath 107364cd6a3aeSmrg # Replace the output file specification. 107374cd6a3aeSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 107384cd6a3aeSmrg # Delete the old output file. 107394cd6a3aeSmrg $opt_dry_run || $RM $output 107404cd6a3aeSmrg # Link the executable and exit 107414cd6a3aeSmrg func_show_eval "$link_command" 'exit $?' 107428c9fbc29Smrg 107434cd6a3aeSmrg if test -n "$postlink_cmds"; then 107444cd6a3aeSmrg func_to_tool_file "$output" 107454cd6a3aeSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 107464cd6a3aeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107478c9fbc29Smrg fi 107484cd6a3aeSmrg 107498c9fbc29Smrg exit $EXIT_SUCCESS 107504cd6a3aeSmrg fi 107518c9fbc29Smrg 1075254044362Smrg case $hardcode_action,$fast_install in 1075354044362Smrg relink,*) 1075454044362Smrg # Fast installation is not supported 1075554044362Smrg link_command=$compile_var$compile_command$compile_rpath 1075654044362Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 107574cd6a3aeSmrg 1075854044362Smrg func_warning "this platform does not like uninstalled shared libraries" 1075954044362Smrg func_warning "'$output' will be relinked during installation" 1076054044362Smrg ;; 1076154044362Smrg *,yes) 1076254044362Smrg link_command=$finalize_var$compile_command$finalize_rpath 1076354044362Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1076454044362Smrg ;; 1076554044362Smrg *,no) 1076654044362Smrg link_command=$compile_var$compile_command$compile_rpath 1076754044362Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1076854044362Smrg ;; 1076954044362Smrg *,needless) 1077054044362Smrg link_command=$finalize_var$compile_command$finalize_rpath 1077154044362Smrg relink_command= 1077254044362Smrg ;; 1077354044362Smrg esac 107748c9fbc29Smrg 107754cd6a3aeSmrg # Replace the output file specification. 107764cd6a3aeSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107778c9fbc29Smrg 107784cd6a3aeSmrg # Delete the old output files. 107794cd6a3aeSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107808c9fbc29Smrg 107814cd6a3aeSmrg func_show_eval "$link_command" 'exit $?' 107828c9fbc29Smrg 107834cd6a3aeSmrg if test -n "$postlink_cmds"; then 107844cd6a3aeSmrg func_to_tool_file "$output_objdir/$outputname" 107854cd6a3aeSmrg 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'` 107864cd6a3aeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107874cd6a3aeSmrg fi 107888c9fbc29Smrg 107894cd6a3aeSmrg # Now create the wrapper script. 107904cd6a3aeSmrg func_verbose "creating $output" 107918c9fbc29Smrg 107924cd6a3aeSmrg # Quote the relink command for shipping. 107934cd6a3aeSmrg if test -n "$relink_command"; then 107944cd6a3aeSmrg # Preserve any variables that may affect compiler behavior 107954cd6a3aeSmrg for var in $variables_saved_for_relink; do 107964cd6a3aeSmrg if eval test -z \"\${$var+set}\"; then 107974cd6a3aeSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107984cd6a3aeSmrg elif eval var_value=\$$var; test -z "$var_value"; then 107994cd6a3aeSmrg relink_command="$var=; export $var; $relink_command" 108008c9fbc29Smrg else 1080154cef2ddSmrg func_quote_arg pretty "$var_value" 1080254cef2ddSmrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 108038c9fbc29Smrg fi 108044cd6a3aeSmrg done 1080554cef2ddSmrg func_quote eval cd "`pwd`" 1080654cef2ddSmrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 1080754cef2ddSmrg relink_command=$func_quote_arg_unquoted_result 108084cd6a3aeSmrg fi 108094cd6a3aeSmrg 108104cd6a3aeSmrg # Only actually do things if not in dry run mode. 108114cd6a3aeSmrg $opt_dry_run || { 108124cd6a3aeSmrg # win32 will think the script is a binary if it has 108134cd6a3aeSmrg # a .exe suffix, so we strip it off here. 108144cd6a3aeSmrg case $output in 108154cd6a3aeSmrg *.exe) func_stripname '' '.exe' "$output" 108164cd6a3aeSmrg output=$func_stripname_result ;; 108178c9fbc29Smrg esac 108184cd6a3aeSmrg # test for cygwin because mv fails w/o .exe extensions 108194cd6a3aeSmrg case $host in 108204cd6a3aeSmrg *cygwin*) 108214cd6a3aeSmrg exeext=.exe 108224cd6a3aeSmrg func_stripname '' '.exe' "$outputname" 108234cd6a3aeSmrg outputname=$func_stripname_result ;; 108244cd6a3aeSmrg *) exeext= ;; 108254cd6a3aeSmrg esac 108264cd6a3aeSmrg case $host in 108274cd6a3aeSmrg *cygwin* | *mingw* ) 108284cd6a3aeSmrg func_dirname_and_basename "$output" "" "." 108294cd6a3aeSmrg output_name=$func_basename_result 108304cd6a3aeSmrg output_path=$func_dirname_result 1083154044362Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1083254044362Smrg cwrapper=$output_path/$output_name.exe 108334cd6a3aeSmrg $RM $cwrappersource $cwrapper 108344cd6a3aeSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 108354cd6a3aeSmrg 108364cd6a3aeSmrg func_emit_cwrapperexe_src > $cwrappersource 108374cd6a3aeSmrg 108384cd6a3aeSmrg # The wrapper executable is built using the $host compiler, 108394cd6a3aeSmrg # because it contains $host paths and files. If cross- 108404cd6a3aeSmrg # compiling, it, like the target executable, must be 108414cd6a3aeSmrg # executed on the $host or under an emulation environment. 108424cd6a3aeSmrg $opt_dry_run || { 108434cd6a3aeSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 108444cd6a3aeSmrg $STRIP $cwrapper 108454cd6a3aeSmrg } 108468c9fbc29Smrg 108474cd6a3aeSmrg # Now, create the wrapper script for func_source use: 108484cd6a3aeSmrg func_ltwrapper_scriptname $cwrapper 108494cd6a3aeSmrg $RM $func_ltwrapper_scriptname_result 108504cd6a3aeSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 108514cd6a3aeSmrg $opt_dry_run || { 108524cd6a3aeSmrg # note: this script will not be executed, so do not chmod. 1085354044362Smrg if test "x$build" = "x$host"; then 108544cd6a3aeSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 108554cd6a3aeSmrg else 108564cd6a3aeSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 108574cd6a3aeSmrg fi 108584cd6a3aeSmrg } 108594cd6a3aeSmrg ;; 108604cd6a3aeSmrg * ) 108614cd6a3aeSmrg $RM $output 108624cd6a3aeSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108638c9fbc29Smrg 108644cd6a3aeSmrg func_emit_wrapper no > $output 108654cd6a3aeSmrg chmod +x $output 108664cd6a3aeSmrg ;; 108674cd6a3aeSmrg esac 108684cd6a3aeSmrg } 108694cd6a3aeSmrg exit $EXIT_SUCCESS 108704cd6a3aeSmrg ;; 108714cd6a3aeSmrg esac 108728c9fbc29Smrg 108734cd6a3aeSmrg # See if we need to build an old-fashioned archive. 108744cd6a3aeSmrg for oldlib in $oldlibs; do 108758c9fbc29Smrg 1087654044362Smrg case $build_libtool_libs in 1087754044362Smrg convenience) 1087854044362Smrg oldobjs="$libobjs_save $symfileobj" 1087954044362Smrg addlibs=$convenience 108804cd6a3aeSmrg build_libtool_libs=no 1088154044362Smrg ;; 1088254044362Smrg module) 1088354044362Smrg oldobjs=$libobjs_save 1088454044362Smrg addlibs=$old_convenience 1088554044362Smrg build_libtool_libs=no 1088654044362Smrg ;; 1088754044362Smrg *) 108884cd6a3aeSmrg oldobjs="$old_deplibs $non_pic_objects" 1088954044362Smrg $preload && test -f "$symfileobj" \ 1089054044362Smrg && func_append oldobjs " $symfileobj" 1089154044362Smrg addlibs=$old_convenience 1089254044362Smrg ;; 1089354044362Smrg esac 108948c9fbc29Smrg 108954cd6a3aeSmrg if test -n "$addlibs"; then 1089654044362Smrg gentop=$output_objdir/${outputname}x 108974cd6a3aeSmrg func_append generated " $gentop" 108988c9fbc29Smrg 108994cd6a3aeSmrg func_extract_archives $gentop $addlibs 109004cd6a3aeSmrg func_append oldobjs " $func_extract_archives_result" 109014cd6a3aeSmrg fi 109028c9fbc29Smrg 109034cd6a3aeSmrg # Do each command in the archive commands. 1090454044362Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 109054cd6a3aeSmrg cmds=$old_archive_from_new_cmds 109064cd6a3aeSmrg else 109078c9fbc29Smrg 109084cd6a3aeSmrg # Add any objects from preloaded convenience libraries 109094cd6a3aeSmrg if test -n "$dlprefiles"; then 1091054044362Smrg gentop=$output_objdir/${outputname}x 109114cd6a3aeSmrg func_append generated " $gentop" 109128c9fbc29Smrg 109134cd6a3aeSmrg func_extract_archives $gentop $dlprefiles 109144cd6a3aeSmrg func_append oldobjs " $func_extract_archives_result" 109154cd6a3aeSmrg fi 109168c9fbc29Smrg 109174cd6a3aeSmrg # POSIX demands no paths to be encoded in archives. We have 109184cd6a3aeSmrg # to avoid creating archives with duplicate basenames if we 109194cd6a3aeSmrg # might have to extract them afterwards, e.g., when creating a 109204cd6a3aeSmrg # static archive out of a convenience library, or when linking 109214cd6a3aeSmrg # the entirety of a libtool archive into another (currently 109224cd6a3aeSmrg # not supported by libtool). 109234cd6a3aeSmrg if (for obj in $oldobjs 109244cd6a3aeSmrg do 109254cd6a3aeSmrg func_basename "$obj" 109264cd6a3aeSmrg $ECHO "$func_basename_result" 109274cd6a3aeSmrg done | sort | sort -uc >/dev/null 2>&1); then 109284cd6a3aeSmrg : 109294cd6a3aeSmrg else 109304cd6a3aeSmrg echo "copying selected object files to avoid basename conflicts..." 1093154044362Smrg gentop=$output_objdir/${outputname}x 109324cd6a3aeSmrg func_append generated " $gentop" 109334cd6a3aeSmrg func_mkdir_p "$gentop" 109344cd6a3aeSmrg save_oldobjs=$oldobjs 109354cd6a3aeSmrg oldobjs= 109364cd6a3aeSmrg counter=1 109374cd6a3aeSmrg for obj in $save_oldobjs 109384cd6a3aeSmrg do 109394cd6a3aeSmrg func_basename "$obj" 1094054044362Smrg objbase=$func_basename_result 109414cd6a3aeSmrg case " $oldobjs " in 109424cd6a3aeSmrg " ") oldobjs=$obj ;; 109434cd6a3aeSmrg *[\ /]"$objbase "*) 109444cd6a3aeSmrg while :; do 109454cd6a3aeSmrg # Make sure we don't pick an alternate name that also 109464cd6a3aeSmrg # overlaps. 109474cd6a3aeSmrg newobj=lt$counter-$objbase 109484cd6a3aeSmrg func_arith $counter + 1 109494cd6a3aeSmrg counter=$func_arith_result 109504cd6a3aeSmrg case " $oldobjs " in 109514cd6a3aeSmrg *[\ /]"$newobj "*) ;; 109524cd6a3aeSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 109534cd6a3aeSmrg esac 109544cd6a3aeSmrg done 109554cd6a3aeSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 109564cd6a3aeSmrg func_append oldobjs " $gentop/$newobj" 109574cd6a3aeSmrg ;; 109584cd6a3aeSmrg *) func_append oldobjs " $obj" ;; 109594cd6a3aeSmrg esac 109608c9fbc29Smrg done 109618c9fbc29Smrg fi 1096270728a38Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1096370728a38Smrg tool_oldlib=$func_to_tool_file_result 109644cd6a3aeSmrg eval cmds=\"$old_archive_cmds\" 109658c9fbc29Smrg 109664cd6a3aeSmrg func_len " $cmds" 109674cd6a3aeSmrg len=$func_len_result 109684cd6a3aeSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 109694cd6a3aeSmrg cmds=$old_archive_cmds 109704cd6a3aeSmrg elif test -n "$archiver_list_spec"; then 109714cd6a3aeSmrg func_verbose "using command file archive linking..." 109724cd6a3aeSmrg for obj in $oldobjs 109734cd6a3aeSmrg do 109744cd6a3aeSmrg func_to_tool_file "$obj" 109754cd6a3aeSmrg $ECHO "$func_to_tool_file_result" 109764cd6a3aeSmrg done > $output_objdir/$libname.libcmd 109774cd6a3aeSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 109784cd6a3aeSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 109794cd6a3aeSmrg cmds=$old_archive_cmds 109804cd6a3aeSmrg else 109814cd6a3aeSmrg # the command line is too long to link in one step, link in parts 109824cd6a3aeSmrg func_verbose "using piecewise archive linking..." 109834cd6a3aeSmrg save_RANLIB=$RANLIB 109844cd6a3aeSmrg RANLIB=: 109854cd6a3aeSmrg objlist= 109864cd6a3aeSmrg concat_cmds= 109874cd6a3aeSmrg save_oldobjs=$oldobjs 109884cd6a3aeSmrg oldobjs= 109894cd6a3aeSmrg # Is there a better way of finding the last object in the list? 109904cd6a3aeSmrg for obj in $save_oldobjs 109914cd6a3aeSmrg do 109924cd6a3aeSmrg last_oldobj=$obj 109934cd6a3aeSmrg done 109944cd6a3aeSmrg eval test_cmds=\"$old_archive_cmds\" 109954cd6a3aeSmrg func_len " $test_cmds" 109964cd6a3aeSmrg len0=$func_len_result 109974cd6a3aeSmrg len=$len0 109984cd6a3aeSmrg for obj in $save_oldobjs 109994cd6a3aeSmrg do 110004cd6a3aeSmrg func_len " $obj" 110014cd6a3aeSmrg func_arith $len + $func_len_result 110024cd6a3aeSmrg len=$func_arith_result 110034cd6a3aeSmrg func_append objlist " $obj" 110044cd6a3aeSmrg if test "$len" -lt "$max_cmd_len"; then 110054cd6a3aeSmrg : 110064cd6a3aeSmrg else 110074cd6a3aeSmrg # the above command should be used before it gets too long 110084cd6a3aeSmrg oldobjs=$objlist 1100954044362Smrg if test "$obj" = "$last_oldobj"; then 110104cd6a3aeSmrg RANLIB=$save_RANLIB 110114cd6a3aeSmrg fi 110124cd6a3aeSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1101354044362Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 110144cd6a3aeSmrg objlist= 110154cd6a3aeSmrg len=$len0 110164cd6a3aeSmrg fi 110174cd6a3aeSmrg done 110184cd6a3aeSmrg RANLIB=$save_RANLIB 110194cd6a3aeSmrg oldobjs=$objlist 1102054044362Smrg if test -z "$oldobjs"; then 110214cd6a3aeSmrg eval cmds=\"\$concat_cmds\" 110224cd6a3aeSmrg else 110234cd6a3aeSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 110244cd6a3aeSmrg fi 110254cd6a3aeSmrg fi 110264cd6a3aeSmrg fi 110274cd6a3aeSmrg func_execute_cmds "$cmds" 'exit $?' 110288c9fbc29Smrg done 110298c9fbc29Smrg 110304cd6a3aeSmrg test -n "$generated" && \ 110314cd6a3aeSmrg func_show_eval "${RM}r$generated" 110328c9fbc29Smrg 110334cd6a3aeSmrg # Now create the libtool archive. 110344cd6a3aeSmrg case $output in 110354cd6a3aeSmrg *.la) 110364cd6a3aeSmrg old_library= 1103754044362Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 110384cd6a3aeSmrg func_verbose "creating $output" 110398c9fbc29Smrg 110404cd6a3aeSmrg # Preserve any variables that may affect compiler behavior 110414cd6a3aeSmrg for var in $variables_saved_for_relink; do 110424cd6a3aeSmrg if eval test -z \"\${$var+set}\"; then 110434cd6a3aeSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 110444cd6a3aeSmrg elif eval var_value=\$$var; test -z "$var_value"; then 110454cd6a3aeSmrg relink_command="$var=; export $var; $relink_command" 110468c9fbc29Smrg else 1104754cef2ddSmrg func_quote_arg pretty,unquoted "$var_value" 1104854cef2ddSmrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110498c9fbc29Smrg fi 110504cd6a3aeSmrg done 110514cd6a3aeSmrg # Quote the link command for shipping. 1105254cef2ddSmrg func_quote eval cd "`pwd`" 1105354cef2ddSmrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1105454cef2ddSmrg func_quote_arg pretty,unquoted "$relink_command" 1105554cef2ddSmrg relink_command=$func_quote_arg_unquoted_result 1105654044362Smrg if test yes = "$hardcode_automatic"; then 110574cd6a3aeSmrg relink_command= 110584cd6a3aeSmrg fi 110598c9fbc29Smrg 110604cd6a3aeSmrg # Only create the output if not a dry run. 110614cd6a3aeSmrg $opt_dry_run || { 110624cd6a3aeSmrg for installed in no yes; do 1106354044362Smrg if test yes = "$installed"; then 110644cd6a3aeSmrg if test -z "$install_libdir"; then 110654cd6a3aeSmrg break 110664cd6a3aeSmrg fi 1106754044362Smrg output=$output_objdir/${outputname}i 110684cd6a3aeSmrg # Replace all uninstalled libtool libraries with the installed ones 110694cd6a3aeSmrg newdependency_libs= 110704cd6a3aeSmrg for deplib in $dependency_libs; do 110714cd6a3aeSmrg case $deplib in 110724cd6a3aeSmrg *.la) 110734cd6a3aeSmrg func_basename "$deplib" 1107454044362Smrg name=$func_basename_result 1107570728a38Smrg func_resolve_sysroot "$deplib" 1107654044362Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 110774cd6a3aeSmrg test -z "$libdir" && \ 1107854044362Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 110794cd6a3aeSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 110804cd6a3aeSmrg ;; 110814cd6a3aeSmrg -L*) 110824cd6a3aeSmrg func_stripname -L '' "$deplib" 110834cd6a3aeSmrg func_replace_sysroot "$func_stripname_result" 110844cd6a3aeSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 110854cd6a3aeSmrg ;; 110864cd6a3aeSmrg -R*) 110874cd6a3aeSmrg func_stripname -R '' "$deplib" 110884cd6a3aeSmrg func_replace_sysroot "$func_stripname_result" 110894cd6a3aeSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 110904cd6a3aeSmrg ;; 110914cd6a3aeSmrg *) func_append newdependency_libs " $deplib" ;; 110924cd6a3aeSmrg esac 110934cd6a3aeSmrg done 1109454044362Smrg dependency_libs=$newdependency_libs 110954cd6a3aeSmrg newdlfiles= 110964cd6a3aeSmrg 110974cd6a3aeSmrg for lib in $dlfiles; do 110984cd6a3aeSmrg case $lib in 110994cd6a3aeSmrg *.la) 111004cd6a3aeSmrg func_basename "$lib" 1110154044362Smrg name=$func_basename_result 1110254044362Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111034cd6a3aeSmrg test -z "$libdir" && \ 1110454044362Smrg func_fatal_error "'$lib' is not a valid libtool archive" 111054cd6a3aeSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 111064cd6a3aeSmrg ;; 111074cd6a3aeSmrg *) func_append newdlfiles " $lib" ;; 111084cd6a3aeSmrg esac 111094cd6a3aeSmrg done 1111054044362Smrg dlfiles=$newdlfiles 111114cd6a3aeSmrg newdlprefiles= 111124cd6a3aeSmrg for lib in $dlprefiles; do 111134cd6a3aeSmrg case $lib in 111144cd6a3aeSmrg *.la) 111154cd6a3aeSmrg # Only pass preopened files to the pseudo-archive (for 111164cd6a3aeSmrg # eventual linking with the app. that links it) if we 111174cd6a3aeSmrg # didn't already link the preopened objects directly into 111184cd6a3aeSmrg # the library: 111194cd6a3aeSmrg func_basename "$lib" 1112054044362Smrg name=$func_basename_result 1112154044362Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111224cd6a3aeSmrg test -z "$libdir" && \ 1112354044362Smrg func_fatal_error "'$lib' is not a valid libtool archive" 111244cd6a3aeSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 111254cd6a3aeSmrg ;; 111264cd6a3aeSmrg esac 111274cd6a3aeSmrg done 1112854044362Smrg dlprefiles=$newdlprefiles 111294cd6a3aeSmrg else 111304cd6a3aeSmrg newdlfiles= 111314cd6a3aeSmrg for lib in $dlfiles; do 111324cd6a3aeSmrg case $lib in 1113354044362Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111344cd6a3aeSmrg *) abs=`pwd`"/$lib" ;; 111354cd6a3aeSmrg esac 111364cd6a3aeSmrg func_append newdlfiles " $abs" 111374cd6a3aeSmrg done 1113854044362Smrg dlfiles=$newdlfiles 111394cd6a3aeSmrg newdlprefiles= 111404cd6a3aeSmrg for lib in $dlprefiles; do 111414cd6a3aeSmrg case $lib in 1114254044362Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111434cd6a3aeSmrg *) abs=`pwd`"/$lib" ;; 111444cd6a3aeSmrg esac 111454cd6a3aeSmrg func_append newdlprefiles " $abs" 111464cd6a3aeSmrg done 1114754044362Smrg dlprefiles=$newdlprefiles 111484cd6a3aeSmrg fi 111494cd6a3aeSmrg $RM $output 111504cd6a3aeSmrg # place dlname in correct position for cygwin 111514cd6a3aeSmrg # In fact, it would be nice if we could use this code for all target 111524cd6a3aeSmrg # systems that can't hard-code library paths into their executables 111534cd6a3aeSmrg # and that have no shared library path variable independent of PATH, 111544cd6a3aeSmrg # but it turns out we can't easily determine that from inspecting 111554cd6a3aeSmrg # libtool variables, so we have to hard-code the OSs to which it 111564cd6a3aeSmrg # applies here; at the moment, that means platforms that use the PE 111574cd6a3aeSmrg # object format with DLL files. See the long comment at the top of 111584cd6a3aeSmrg # tests/bindir.at for full details. 111594cd6a3aeSmrg tdlname=$dlname 111604cd6a3aeSmrg case $host,$output,$installed,$module,$dlname in 111614cd6a3aeSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 111624cd6a3aeSmrg # If a -bindir argument was supplied, place the dll there. 1116354044362Smrg if test -n "$bindir"; then 111644cd6a3aeSmrg func_relative_path "$install_libdir" "$bindir" 1116554044362Smrg tdlname=$func_relative_path_result/$dlname 111664cd6a3aeSmrg else 111674cd6a3aeSmrg # Otherwise fall back on heuristic. 111684cd6a3aeSmrg tdlname=../bin/$dlname 111694cd6a3aeSmrg fi 111704cd6a3aeSmrg ;; 111714cd6a3aeSmrg esac 111724cd6a3aeSmrg $ECHO > $output "\ 111734cd6a3aeSmrg# $outputname - a libtool library file 1117454044362Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 111754cd6a3aeSmrg# 111764cd6a3aeSmrg# Please DO NOT delete this file! 111774cd6a3aeSmrg# It is necessary for linking the library. 111788c9fbc29Smrg 111794cd6a3aeSmrg# The name that we can dlopen(3). 111804cd6a3aeSmrgdlname='$tdlname' 111818c9fbc29Smrg 111824cd6a3aeSmrg# Names of this library. 111834cd6a3aeSmrglibrary_names='$library_names' 111848c9fbc29Smrg 111854cd6a3aeSmrg# The name of the static archive. 111864cd6a3aeSmrgold_library='$old_library' 111878c9fbc29Smrg 1118854044362Smrg# Linker flags that cannot go in dependency_libs. 111894cd6a3aeSmrginherited_linker_flags='$new_inherited_linker_flags' 111908c9fbc29Smrg 111914cd6a3aeSmrg# Libraries that this one depends upon. 111924cd6a3aeSmrgdependency_libs='$dependency_libs' 111938c9fbc29Smrg 111944cd6a3aeSmrg# Names of additional weak libraries provided by this library 111954cd6a3aeSmrgweak_library_names='$weak_libs' 111968c9fbc29Smrg 111974cd6a3aeSmrg# Version information for $libname. 111984cd6a3aeSmrgcurrent=$current 111994cd6a3aeSmrgage=$age 112004cd6a3aeSmrgrevision=$revision 112018c9fbc29Smrg 112024cd6a3aeSmrg# Is this an already installed library? 112034cd6a3aeSmrginstalled=$installed 112048c9fbc29Smrg 112054cd6a3aeSmrg# Should we warn about portability when linking against -modules? 112064cd6a3aeSmrgshouldnotlink=$module 112078c9fbc29Smrg 112084cd6a3aeSmrg# Files to dlopen/dlpreopen 112094cd6a3aeSmrgdlopen='$dlfiles' 112104cd6a3aeSmrgdlpreopen='$dlprefiles' 112118c9fbc29Smrg 112124cd6a3aeSmrg# Directory that this library needs to be installed in: 112134cd6a3aeSmrglibdir='$install_libdir'" 1121454044362Smrg if test no,yes = "$installed,$need_relink"; then 112154cd6a3aeSmrg $ECHO >> $output "\ 112164cd6a3aeSmrgrelink_command=\"$relink_command\"" 112174cd6a3aeSmrg fi 112184cd6a3aeSmrg done 112194cd6a3aeSmrg } 112208c9fbc29Smrg 112214cd6a3aeSmrg # Do a symbolic link so that the libtool archive can be found in 112224cd6a3aeSmrg # LD_LIBRARY_PATH before the program is installed. 112234cd6a3aeSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 112244cd6a3aeSmrg ;; 112254cd6a3aeSmrg esac 112264cd6a3aeSmrg exit $EXIT_SUCCESS 112274cd6a3aeSmrg} 112288c9fbc29Smrg 1122954044362Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1123054044362Smrg func_mode_link ${1+"$@"} 1123154044362Smrgfi 112328c9fbc29Smrg 112338c9fbc29Smrg 112344cd6a3aeSmrg# func_mode_uninstall arg... 112354cd6a3aeSmrgfunc_mode_uninstall () 112364cd6a3aeSmrg{ 1123754044362Smrg $debug_cmd 1123854044362Smrg 1123954044362Smrg RM=$nonopt 112408c9fbc29Smrg files= 1124154044362Smrg rmforce=false 112428c9fbc29Smrg exit_status=0 112438c9fbc29Smrg 112448c9fbc29Smrg # This variable tells wrapper scripts just to set variables rather 112458c9fbc29Smrg # than running their programs. 1124654044362Smrg libtool_install_magic=$magic 112478c9fbc29Smrg 112488c9fbc29Smrg for arg 112498c9fbc29Smrg do 112508c9fbc29Smrg case $arg in 1125154044362Smrg -f) func_append RM " $arg"; rmforce=: ;; 112524cd6a3aeSmrg -*) func_append RM " $arg" ;; 112534cd6a3aeSmrg *) func_append files " $arg" ;; 112548c9fbc29Smrg esac 112558c9fbc29Smrg done 112568c9fbc29Smrg 112574cd6a3aeSmrg test -z "$RM" && \ 112584cd6a3aeSmrg func_fatal_help "you must specify an RM program" 112598c9fbc29Smrg 112608c9fbc29Smrg rmdirs= 112618c9fbc29Smrg 112628c9fbc29Smrg for file in $files; do 112634cd6a3aeSmrg func_dirname "$file" "" "." 1126454044362Smrg dir=$func_dirname_result 1126554044362Smrg if test . = "$dir"; then 1126654044362Smrg odir=$objdir 112678c9fbc29Smrg else 1126854044362Smrg odir=$dir/$objdir 112698c9fbc29Smrg fi 112704cd6a3aeSmrg func_basename "$file" 1127154044362Smrg name=$func_basename_result 1127254044362Smrg test uninstall = "$opt_mode" && odir=$dir 112738c9fbc29Smrg 112744cd6a3aeSmrg # Remember odir for removal later, being careful to avoid duplicates 1127554044362Smrg if test clean = "$opt_mode"; then 112768c9fbc29Smrg case " $rmdirs " in 112774cd6a3aeSmrg *" $odir "*) ;; 112784cd6a3aeSmrg *) func_append rmdirs " $odir" ;; 112798c9fbc29Smrg esac 112808c9fbc29Smrg fi 112818c9fbc29Smrg 112828c9fbc29Smrg # Don't error if the file doesn't exist and rm -f was used. 112834cd6a3aeSmrg if { test -L "$file"; } >/dev/null 2>&1 || 112844cd6a3aeSmrg { test -h "$file"; } >/dev/null 2>&1 || 112854cd6a3aeSmrg test -f "$file"; then 112868c9fbc29Smrg : 112878c9fbc29Smrg elif test -d "$file"; then 112888c9fbc29Smrg exit_status=1 112898c9fbc29Smrg continue 1129054044362Smrg elif $rmforce; then 112918c9fbc29Smrg continue 112928c9fbc29Smrg fi 112938c9fbc29Smrg 1129454044362Smrg rmfiles=$file 112958c9fbc29Smrg 112968c9fbc29Smrg case $name in 112978c9fbc29Smrg *.la) 112988c9fbc29Smrg # Possibly a libtool archive, so verify it. 112994cd6a3aeSmrg if func_lalib_p "$file"; then 113004cd6a3aeSmrg func_source $dir/$name 113018c9fbc29Smrg 113028c9fbc29Smrg # Delete the libtool libraries and symlinks. 113038c9fbc29Smrg for n in $library_names; do 113044cd6a3aeSmrg func_append rmfiles " $odir/$n" 113058c9fbc29Smrg done 113064cd6a3aeSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 113078c9fbc29Smrg 1130854044362Smrg case $opt_mode in 113098c9fbc29Smrg clean) 113104cd6a3aeSmrg case " $library_names " in 113118c9fbc29Smrg *" $dlname "*) ;; 113124cd6a3aeSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113138c9fbc29Smrg esac 113144cd6a3aeSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113158c9fbc29Smrg ;; 113168c9fbc29Smrg uninstall) 113178c9fbc29Smrg if test -n "$library_names"; then 113188c9fbc29Smrg # Do each command in the postuninstall commands. 1131954044362Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113208c9fbc29Smrg fi 113218c9fbc29Smrg 113228c9fbc29Smrg if test -n "$old_library"; then 113238c9fbc29Smrg # Do each command in the old_postuninstall commands. 1132454044362Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113258c9fbc29Smrg fi 113268c9fbc29Smrg # FIXME: should reinstall the best remaining shared library. 113278c9fbc29Smrg ;; 113288c9fbc29Smrg esac 113298c9fbc29Smrg fi 113308c9fbc29Smrg ;; 113318c9fbc29Smrg 113328c9fbc29Smrg *.lo) 113338c9fbc29Smrg # Possibly a libtool object, so verify it. 113344cd6a3aeSmrg if func_lalib_p "$file"; then 113358c9fbc29Smrg 113368c9fbc29Smrg # Read the .lo file 113374cd6a3aeSmrg func_source $dir/$name 113388c9fbc29Smrg 113398c9fbc29Smrg # Add PIC object to the list of files to remove. 1134054044362Smrg if test -n "$pic_object" && test none != "$pic_object"; then 113414cd6a3aeSmrg func_append rmfiles " $dir/$pic_object" 113428c9fbc29Smrg fi 113438c9fbc29Smrg 113448c9fbc29Smrg # Add non-PIC object to the list of files to remove. 1134554044362Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 113464cd6a3aeSmrg func_append rmfiles " $dir/$non_pic_object" 113478c9fbc29Smrg fi 113488c9fbc29Smrg fi 113498c9fbc29Smrg ;; 113508c9fbc29Smrg 113518c9fbc29Smrg *) 1135254044362Smrg if test clean = "$opt_mode"; then 113538c9fbc29Smrg noexename=$name 113548c9fbc29Smrg case $file in 113558c9fbc29Smrg *.exe) 113564cd6a3aeSmrg func_stripname '' '.exe' "$file" 113574cd6a3aeSmrg file=$func_stripname_result 113584cd6a3aeSmrg func_stripname '' '.exe' "$name" 113594cd6a3aeSmrg noexename=$func_stripname_result 113608c9fbc29Smrg # $file with .exe has already been added to rmfiles, 113618c9fbc29Smrg # add $file without .exe 113624cd6a3aeSmrg func_append rmfiles " $file" 113638c9fbc29Smrg ;; 113648c9fbc29Smrg esac 113658c9fbc29Smrg # Do a test to see if this is a libtool program. 113664cd6a3aeSmrg if func_ltwrapper_p "$file"; then 113674cd6a3aeSmrg if func_ltwrapper_executable_p "$file"; then 113684cd6a3aeSmrg func_ltwrapper_scriptname "$file" 113694cd6a3aeSmrg relink_command= 113704cd6a3aeSmrg func_source $func_ltwrapper_scriptname_result 113714cd6a3aeSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 113724cd6a3aeSmrg else 113734cd6a3aeSmrg relink_command= 113744cd6a3aeSmrg func_source $dir/$noexename 113754cd6a3aeSmrg fi 113768c9fbc29Smrg 113778c9fbc29Smrg # note $name still contains .exe if it was in $file originally 113788c9fbc29Smrg # as does the version of $file that was added into $rmfiles 1137954044362Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1138054044362Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 113814cd6a3aeSmrg func_append rmfiles " $odir/lt-$name" 113828c9fbc29Smrg fi 1138354044362Smrg if test "X$noexename" != "X$name"; then 1138454044362Smrg func_append rmfiles " $odir/lt-$noexename.c" 113858c9fbc29Smrg fi 113868c9fbc29Smrg fi 113878c9fbc29Smrg fi 113888c9fbc29Smrg ;; 113898c9fbc29Smrg esac 113904cd6a3aeSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113918c9fbc29Smrg done 113928c9fbc29Smrg 1139354044362Smrg # Try to remove the $objdir's in the directories where we deleted files 113948c9fbc29Smrg for dir in $rmdirs; do 113958c9fbc29Smrg if test -d "$dir"; then 113964cd6a3aeSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113978c9fbc29Smrg fi 113988c9fbc29Smrg done 113998c9fbc29Smrg 114008c9fbc29Smrg exit $exit_status 114014cd6a3aeSmrg} 114028c9fbc29Smrg 1140354044362Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1140454044362Smrg func_mode_uninstall ${1+"$@"} 1140554044362Smrgfi 114068c9fbc29Smrg 114074cd6a3aeSmrgtest -z "$opt_mode" && { 1140854044362Smrg help=$generic_help 114094cd6a3aeSmrg func_fatal_help "you must specify a MODE" 114104cd6a3aeSmrg} 114114cd6a3aeSmrg 114124cd6a3aeSmrgtest -z "$exec_cmd" && \ 1141354044362Smrg func_fatal_help "invalid operation mode '$opt_mode'" 114148c9fbc29Smrg 114158c9fbc29Smrgif test -n "$exec_cmd"; then 114164cd6a3aeSmrg eval exec "$exec_cmd" 114178c9fbc29Smrg exit $EXIT_FAILURE 114188c9fbc29Smrgfi 114198c9fbc29Smrg 114204cd6a3aeSmrgexit $exit_status 114218c9fbc29Smrg 114228c9fbc29Smrg 114238c9fbc29Smrg# The TAGs below are defined such that we never get into a situation 1142454044362Smrg# where we disable both kinds of libraries. Given conflicting 114258c9fbc29Smrg# choices, we go for a static library, that is the most portable, 114268c9fbc29Smrg# since we can't tell whether shared libraries were disabled because 114278c9fbc29Smrg# the user asked for that or because the platform doesn't support 114288c9fbc29Smrg# them. This is particularly important on AIX, because we don't 114298c9fbc29Smrg# support having both static and shared libraries enabled at the same 114308c9fbc29Smrg# time on that platform, so we default to a shared-only configuration. 114318c9fbc29Smrg# If a disable-shared tag is given, we'll fallback to a static-only 114328c9fbc29Smrg# configuration. But we'll never go from static-only to shared-only. 114338c9fbc29Smrg 114348c9fbc29Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 114354cd6a3aeSmrgbuild_libtool_libs=no 114364cd6a3aeSmrgbuild_old_libs=yes 114378c9fbc29Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 114388c9fbc29Smrg 114398c9fbc29Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 114404cd6a3aeSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114418c9fbc29Smrg# ### END LIBTOOL TAG CONFIG: disable-static 114428c9fbc29Smrg 114438c9fbc29Smrg# Local Variables: 114448c9fbc29Smrg# mode:shell-script 114458c9fbc29Smrg# sh-indentation:2 114468c9fbc29Smrg# End: 11447