136e956c5Smrg#! /bin/sh 236e956c5Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 336e956c5Smrg## by inline-source v2014-01-03.01 45f5b92ffSmrg 536e956c5Smrg# libtool (GNU libtool) 2.4.6 636e956c5Smrg# Provide generalized library-building support services. 75f5b92ffSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 85f5b92ffSmrg 936e956c5Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 105f5b92ffSmrg# This is free software; see the source for copying conditions. There is NO 115f5b92ffSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 125f5b92ffSmrg 135f5b92ffSmrg# GNU Libtool is free software; you can redistribute it and/or modify 1417a48c7cSmrg# it under the terms of the GNU General Public License as published by 1517a48c7cSmrg# the Free Software Foundation; either version 2 of the License, or 1617a48c7cSmrg# (at your option) any later version. 1717a48c7cSmrg# 185f5b92ffSmrg# As a special exception to the GNU General Public License, 195f5b92ffSmrg# if you distribute this file as part of a program or library that 205f5b92ffSmrg# is built using GNU Libtool, you may include this file under the 215f5b92ffSmrg# same distribution terms that you use for the rest of that program. 225f5b92ffSmrg# 235f5b92ffSmrg# GNU Libtool is distributed in the hope that it will be useful, but 2417a48c7cSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2517a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2617a48c7cSmrg# General Public License for more details. 2717a48c7cSmrg# 2817a48c7cSmrg# You should have received a copy of the GNU General Public License 2936e956c5Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3017a48c7cSmrg 3117a48c7cSmrg 320dd80ee0SmrgPROGRAM=libtool 3317a48c7cSmrgPACKAGE=libtool 3436e956c5SmrgVERSION="2.4.6 Debian-2.4.6-0.1" 3536e956c5Smrgpackage_revision=2.4.6 3617a48c7cSmrg 3736e956c5Smrg 3836e956c5Smrg## ------ ## 3936e956c5Smrg## Usage. ## 4036e956c5Smrg## ------ ## 4136e956c5Smrg 4236e956c5Smrg# Run './libtool --help' for help with using this script from the 4336e956c5Smrg# command line. 4436e956c5Smrg 4536e956c5Smrg 4636e956c5Smrg## ------------------------------- ## 4736e956c5Smrg## User overridable command paths. ## 4836e956c5Smrg## ------------------------------- ## 4936e956c5Smrg 5036e956c5Smrg# After configure completes, it has a better idea of some of the 5136e956c5Smrg# shell tools we need than the defaults used by the functions shared 5236e956c5Smrg# with bootstrap, so set those here where they can still be over- 5336e956c5Smrg# ridden by the user, but otherwise take precedence. 5436e956c5Smrg 5536e956c5Smrg: ${AUTOCONF="autoconf"} 5636e956c5Smrg: ${AUTOMAKE="automake"} 5736e956c5Smrg 5836e956c5Smrg 5936e956c5Smrg## -------------------------- ## 6036e956c5Smrg## Source external libraries. ## 6136e956c5Smrg## -------------------------- ## 6236e956c5Smrg 6336e956c5Smrg# Much of our low-level functionality needs to be sourced from external 6436e956c5Smrg# libraries, which are installed to $pkgauxdir. 6536e956c5Smrg 6636e956c5Smrg# Set a version string for this script. 6736e956c5Smrgscriptversion=2015-01-20.17; # UTC 6836e956c5Smrg 6936e956c5Smrg# General shell script boiler plate, and helper functions. 7036e956c5Smrg# Written by Gary V. Vaughan, 2004 7136e956c5Smrg 7236e956c5Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7336e956c5Smrg# This is free software; see the source for copying conditions. There is NO 7436e956c5Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7536e956c5Smrg 7636e956c5Smrg# This program is free software; you can redistribute it and/or modify 7736e956c5Smrg# it under the terms of the GNU General Public License as published by 7836e956c5Smrg# the Free Software Foundation; either version 3 of the License, or 7936e956c5Smrg# (at your option) any later version. 8036e956c5Smrg 8136e956c5Smrg# As a special exception to the GNU General Public License, if you distribute 8236e956c5Smrg# this file as part of a program or library that is built using GNU Libtool, 8336e956c5Smrg# you may include this file under the same distribution terms that you use 8436e956c5Smrg# for the rest of that program. 8536e956c5Smrg 8636e956c5Smrg# This program is distributed in the hope that it will be useful, 8736e956c5Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8836e956c5Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8936e956c5Smrg# General Public License for more details. 9036e956c5Smrg 9136e956c5Smrg# You should have received a copy of the GNU General Public License 9236e956c5Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9336e956c5Smrg 9436e956c5Smrg# Please report bugs or propose patches to gary@gnu.org. 9536e956c5Smrg 9636e956c5Smrg 9736e956c5Smrg## ------ ## 9836e956c5Smrg## Usage. ## 9936e956c5Smrg## ------ ## 10036e956c5Smrg 10136e956c5Smrg# Evaluate this file near the top of your script to gain access to 10236e956c5Smrg# the functions and variables defined here: 10336e956c5Smrg# 10436e956c5Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10536e956c5Smrg# 10636e956c5Smrg# If you need to override any of the default environment variable 10736e956c5Smrg# settings, do that before evaluating this file. 10836e956c5Smrg 10936e956c5Smrg 11036e956c5Smrg## -------------------- ## 11136e956c5Smrg## Shell normalisation. ## 11236e956c5Smrg## -------------------- ## 11336e956c5Smrg 11436e956c5Smrg# Some shells need a little help to be as Bourne compatible as possible. 11536e956c5Smrg# Before doing anything else, make sure all that help has been provided! 11636e956c5Smrg 11736e956c5SmrgDUALCASE=1; export DUALCASE # for MKS sh 11836e956c5Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1198e0ed500Smrg emulate sh 1208e0ed500Smrg NULLCMD=: 12136e956c5Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1228e0ed500Smrg # is contrary to our usage. Disable this feature. 1238e0ed500Smrg alias -g '${1+"$@"}'='"$@"' 12417a48c7cSmrg setopt NO_GLOB_SUBST 1258e0ed500Smrgelse 12636e956c5Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 12717a48c7cSmrgfi 1280dd80ee0Smrg 12936e956c5Smrg# NLS nuisances: We save the old values in case they are required later. 13036e956c5Smrg_G_user_locale= 13136e956c5Smrg_G_safe_locale= 13236e956c5Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1338e0ed500Smrgdo 13436e956c5Smrg eval "if test set = \"\${$_G_var+set}\"; then 13536e956c5Smrg save_$_G_var=\$$_G_var 13636e956c5Smrg $_G_var=C 13736e956c5Smrg export $_G_var 13836e956c5Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13936e956c5Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140fbed5abfSmrg fi" 1418e0ed500Smrgdone 14217a48c7cSmrg 14336e956c5Smrg# CDPATH. 14436e956c5Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 1455f5b92ffSmrg 14636e956c5Smrg# Make sure IFS has a sensible default 14736e956c5Smrgsp=' ' 14836e956c5Smrgnl=' 14936e956c5Smrg' 15036e956c5SmrgIFS="$sp $nl" 15136e956c5Smrg 15236e956c5Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 15336e956c5Smrgif test "${PATH_SEPARATOR+set}" != set; then 15436e956c5Smrg PATH_SEPARATOR=: 15536e956c5Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15636e956c5Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15736e956c5Smrg PATH_SEPARATOR=';' 15836e956c5Smrg } 15936e956c5Smrgfi 1605f5b92ffSmrg 1615f5b92ffSmrg 1625f5b92ffSmrg 16336e956c5Smrg## ------------------------- ## 16436e956c5Smrg## Locate command utilities. ## 16536e956c5Smrg## ------------------------- ## 16636e956c5Smrg 16736e956c5Smrg 16836e956c5Smrg# func_executable_p FILE 16936e956c5Smrg# ---------------------- 17036e956c5Smrg# Check that FILE is an executable regular file. 17136e956c5Smrgfunc_executable_p () 17236e956c5Smrg{ 17336e956c5Smrg test -f "$1" && test -x "$1" 17436e956c5Smrg} 17536e956c5Smrg 17636e956c5Smrg 17736e956c5Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17836e956c5Smrg# -------------------------------------------- 17936e956c5Smrg# Search for either a program that responds to --version with output 18036e956c5Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18136e956c5Smrg# trying all the directories in PATH with each of the elements of 18236e956c5Smrg# PROGS_LIST. 18336e956c5Smrg# 18436e956c5Smrg# CHECK_FUNC should accept the path to a candidate program, and 18536e956c5Smrg# set $func_check_prog_result if it truncates its output less than 18636e956c5Smrg# $_G_path_prog_max characters. 18736e956c5Smrgfunc_path_progs () 18836e956c5Smrg{ 18936e956c5Smrg _G_progs_list=$1 19036e956c5Smrg _G_check_func=$2 19136e956c5Smrg _G_PATH=${3-"$PATH"} 19236e956c5Smrg 19336e956c5Smrg _G_path_prog_max=0 19436e956c5Smrg _G_path_prog_found=false 19536e956c5Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19636e956c5Smrg for _G_dir in $_G_PATH; do 19736e956c5Smrg IFS=$_G_save_IFS 19836e956c5Smrg test -z "$_G_dir" && _G_dir=. 19936e956c5Smrg for _G_prog_name in $_G_progs_list; do 20036e956c5Smrg for _exeext in '' .EXE; do 20136e956c5Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20236e956c5Smrg func_executable_p "$_G_path_prog" || continue 20336e956c5Smrg case `"$_G_path_prog" --version 2>&1` in 20436e956c5Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20536e956c5Smrg *) $_G_check_func $_G_path_prog 20636e956c5Smrg func_path_progs_result=$func_check_prog_result 20736e956c5Smrg ;; 20836e956c5Smrg esac 20936e956c5Smrg $_G_path_prog_found && break 3 21036e956c5Smrg done 21136e956c5Smrg done 21236e956c5Smrg done 21336e956c5Smrg IFS=$_G_save_IFS 21436e956c5Smrg test -z "$func_path_progs_result" && { 21536e956c5Smrg echo "no acceptable sed could be found in \$PATH" >&2 21636e956c5Smrg exit 1 21736e956c5Smrg } 21836e956c5Smrg} 21936e956c5Smrg 22036e956c5Smrg 22136e956c5Smrg# We want to be able to use the functions in this file before configure 22236e956c5Smrg# has figured out where the best binaries are kept, which means we have 22336e956c5Smrg# to search for them ourselves - except when the results are already set 22436e956c5Smrg# where we skip the searches. 22536e956c5Smrg 22636e956c5Smrg# Unless the user overrides by setting SED, search the path for either GNU 22736e956c5Smrg# sed, or the sed that truncates its output the least. 22836e956c5Smrgtest -z "$SED" && { 22936e956c5Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23036e956c5Smrg for _G_i in 1 2 3 4 5 6 7; do 23136e956c5Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23236e956c5Smrg done 23336e956c5Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23436e956c5Smrg _G_sed_script= 23536e956c5Smrg 23636e956c5Smrg func_check_prog_sed () 23736e956c5Smrg { 23836e956c5Smrg _G_path_prog=$1 23936e956c5Smrg 24036e956c5Smrg _G_count=0 24136e956c5Smrg printf 0123456789 >conftest.in 24236e956c5Smrg while : 24336e956c5Smrg do 24436e956c5Smrg cat conftest.in conftest.in >conftest.tmp 24536e956c5Smrg mv conftest.tmp conftest.in 24636e956c5Smrg cp conftest.in conftest.nl 24736e956c5Smrg echo '' >> conftest.nl 24836e956c5Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24936e956c5Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25036e956c5Smrg _G_count=`expr $_G_count + 1` 25136e956c5Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25236e956c5Smrg # Best one so far, save it but keep looking for a better one 25336e956c5Smrg func_check_prog_result=$_G_path_prog 25436e956c5Smrg _G_path_prog_max=$_G_count 25536e956c5Smrg fi 25636e956c5Smrg # 10*(2^10) chars as input seems more than enough 25736e956c5Smrg test 10 -lt "$_G_count" && break 25836e956c5Smrg done 25936e956c5Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26036e956c5Smrg } 26136e956c5Smrg 26236e956c5Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26336e956c5Smrg rm -f conftest.sed 26436e956c5Smrg SED=$func_path_progs_result 26536e956c5Smrg} 26636e956c5Smrg 26736e956c5Smrg 26836e956c5Smrg# Unless the user overrides by setting GREP, search the path for either GNU 26936e956c5Smrg# grep, or the grep that truncates its output the least. 27036e956c5Smrgtest -z "$GREP" && { 27136e956c5Smrg func_check_prog_grep () 27236e956c5Smrg { 27336e956c5Smrg _G_path_prog=$1 27436e956c5Smrg 27536e956c5Smrg _G_count=0 27636e956c5Smrg _G_path_prog_max=0 27736e956c5Smrg printf 0123456789 >conftest.in 27836e956c5Smrg while : 27936e956c5Smrg do 28036e956c5Smrg cat conftest.in conftest.in >conftest.tmp 28136e956c5Smrg mv conftest.tmp conftest.in 28236e956c5Smrg cp conftest.in conftest.nl 28336e956c5Smrg echo 'GREP' >> conftest.nl 28436e956c5Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28536e956c5Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28636e956c5Smrg _G_count=`expr $_G_count + 1` 28736e956c5Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28836e956c5Smrg # Best one so far, save it but keep looking for a better one 28936e956c5Smrg func_check_prog_result=$_G_path_prog 29036e956c5Smrg _G_path_prog_max=$_G_count 29136e956c5Smrg fi 29236e956c5Smrg # 10*(2^10) chars as input seems more than enough 29336e956c5Smrg test 10 -lt "$_G_count" && break 29436e956c5Smrg done 29536e956c5Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29636e956c5Smrg } 29736e956c5Smrg 29836e956c5Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29936e956c5Smrg GREP=$func_path_progs_result 30036e956c5Smrg} 30136e956c5Smrg 30236e956c5Smrg 30336e956c5Smrg## ------------------------------- ## 30436e956c5Smrg## User overridable command paths. ## 30536e956c5Smrg## ------------------------------- ## 30636e956c5Smrg 30736e956c5Smrg# All uppercase variable names are used for environment variables. These 30836e956c5Smrg# variables can be overridden by the user before calling a script that 30936e956c5Smrg# uses them if a suitable command of that name is not already available 31036e956c5Smrg# in the command search PATH. 3115f5b92ffSmrg 3125f5b92ffSmrg: ${CP="cp -f"} 31336e956c5Smrg: ${ECHO="printf %s\n"} 31436e956c5Smrg: ${EGREP="$GREP -E"} 31536e956c5Smrg: ${FGREP="$GREP -F"} 31636e956c5Smrg: ${LN_S="ln -s"} 3175f5b92ffSmrg: ${MAKE="make"} 3185f5b92ffSmrg: ${MKDIR="mkdir"} 3195f5b92ffSmrg: ${MV="mv -f"} 3205f5b92ffSmrg: ${RM="rm -f"} 3215f5b92ffSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 32217a48c7cSmrg 3235f5b92ffSmrg 32436e956c5Smrg## -------------------- ## 32536e956c5Smrg## Useful sed snippets. ## 32636e956c5Smrg## -------------------- ## 3270dd80ee0Smrg 32836e956c5Smrgsed_dirname='s|/[^/]*$||' 32936e956c5Smrgsed_basename='s|^.*/||' 3300dd80ee0Smrg 33136e956c5Smrg# Sed substitution that helps us do robust quoting. It backslashifies 33236e956c5Smrg# metacharacters that are still active within double-quoted strings. 33336e956c5Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3340dd80ee0Smrg 33536e956c5Smrg# Same as above, but do not quote variable references. 33636e956c5Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3370dd80ee0Smrg 33836e956c5Smrg# Sed substitution that turns a string into a regex matching for the 33936e956c5Smrg# string literally. 34036e956c5Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3410dd80ee0Smrg 34236e956c5Smrg# Sed substitution that converts a w32 file name or path 34336e956c5Smrg# that contains forward slashes, into one that contains 34436e956c5Smrg# (escaped) backslashes. A very naive implementation. 34536e956c5Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34636e956c5Smrg 34736e956c5Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34836e956c5Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34936e956c5Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35036e956c5Smrg# expansion. Since each input '\' is now two '\'s, look for any number 35136e956c5Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35236e956c5Smrg_G_bs='\\' 35336e956c5Smrg_G_bs2='\\\\' 35436e956c5Smrg_G_bs4='\\\\\\\\' 35536e956c5Smrg_G_dollar='\$' 35636e956c5Smrgsed_double_backslash="\ 35736e956c5Smrg s/$_G_bs4/&\\ 35836e956c5Smrg/g 35936e956c5Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36036e956c5Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36136e956c5Smrg s/\n//g" 3620dd80ee0Smrg 3630dd80ee0Smrg 36436e956c5Smrg## ----------------- ## 36536e956c5Smrg## Global variables. ## 36636e956c5Smrg## ----------------- ## 3670dd80ee0Smrg 36836e956c5Smrg# Except for the global variables explicitly listed below, the following 36936e956c5Smrg# functions in the '^func_' namespace, and the '^require_' namespace 37036e956c5Smrg# variables initialised in the 'Resource management' section, sourcing 37136e956c5Smrg# this file will not pollute your global namespace with anything 37236e956c5Smrg# else. There's no portable way to scope variables in Bourne shell 37336e956c5Smrg# though, so actually running these functions will sometimes place 37436e956c5Smrg# results into a variable named after the function, and often use 37536e956c5Smrg# temporary variables in the '^_G_' namespace. If you are careful to 37636e956c5Smrg# avoid using those namespaces casually in your sourcing script, things 37736e956c5Smrg# should continue to work as you expect. And, of course, you can freely 37836e956c5Smrg# overwrite any of the functions or variables defined here before 37936e956c5Smrg# calling anything to customize them. 3800dd80ee0Smrg 38136e956c5SmrgEXIT_SUCCESS=0 38236e956c5SmrgEXIT_FAILURE=1 38336e956c5SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38436e956c5SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38517a48c7cSmrg 38636e956c5Smrg# Allow overriding, eg assuming that you follow the convention of 38736e956c5Smrg# putting '$debug_cmd' at the start of all your functions, you can get 38836e956c5Smrg# bash to show function call trace with: 38936e956c5Smrg# 39036e956c5Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39136e956c5Smrgdebug_cmd=${debug_cmd-":"} 39236e956c5Smrgexit_cmd=: 3935f5b92ffSmrg 39436e956c5Smrg# By convention, finish your script with: 39536e956c5Smrg# 39636e956c5Smrg# exit $exit_status 39736e956c5Smrg# 39836e956c5Smrg# so that you can set exit_status to non-zero if you want to indicate 39936e956c5Smrg# something went wrong during execution without actually bailing out at 40036e956c5Smrg# the point of failure. 40136e956c5Smrgexit_status=$EXIT_SUCCESS 4020dd80ee0Smrg 40336e956c5Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40436e956c5Smrg# is ksh but when the shell is invoked as "sh" and the current value of 40536e956c5Smrg# the _XPG environment variable is not equal to 1 (one), the special 40636e956c5Smrg# positional parameter $0, within a function call, is the name of the 40736e956c5Smrg# function. 40836e956c5Smrgprogpath=$0 4095f5b92ffSmrg 41036e956c5Smrg# The name of this program. 41136e956c5Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4125f5b92ffSmrg 41336e956c5Smrg# Make sure we have an absolute progpath for reexecution: 4145f5b92ffSmrgcase $progpath in 4155f5b92ffSmrg [\\/]*|[A-Za-z]:\\*) ;; 4165f5b92ffSmrg *[\\/]*) 41736e956c5Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4185f5b92ffSmrg progdir=`cd "$progdir" && pwd` 41936e956c5Smrg progpath=$progdir/$progname 4205f5b92ffSmrg ;; 4215f5b92ffSmrg *) 42236e956c5Smrg _G_IFS=$IFS 4230dd80ee0Smrg IFS=${PATH_SEPARATOR-:} 4245f5b92ffSmrg for progdir in $PATH; do 42536e956c5Smrg IFS=$_G_IFS 4265f5b92ffSmrg test -x "$progdir/$progname" && break 4275f5b92ffSmrg done 42836e956c5Smrg IFS=$_G_IFS 4295f5b92ffSmrg test -n "$progdir" || progdir=`pwd` 43036e956c5Smrg progpath=$progdir/$progname 4315f5b92ffSmrg ;; 4325f5b92ffSmrgesac 4335f5b92ffSmrg 4345f5b92ffSmrg 43536e956c5Smrg## ----------------- ## 43636e956c5Smrg## Standard options. ## 43736e956c5Smrg## ----------------- ## 4380dd80ee0Smrg 43936e956c5Smrg# The following options affect the operation of the functions defined 44036e956c5Smrg# below, and should be set appropriately depending on run-time para- 44136e956c5Smrg# meters passed on the command line. 4425f5b92ffSmrg 4435f5b92ffSmrgopt_dry_run=false 4445f5b92ffSmrgopt_quiet=false 4455f5b92ffSmrgopt_verbose=false 4465f5b92ffSmrg 44736e956c5Smrg# Categories 'all' and 'none' are always available. Append any others 44836e956c5Smrg# you will pass as the first argument to func_warning from your own 44936e956c5Smrg# code. 45036e956c5Smrgwarning_categories= 4515f5b92ffSmrg 45236e956c5Smrg# By default, display warnings according to 'opt_warning_types'. Set 45336e956c5Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45436e956c5Smrg# treat the next displayed warning as a fatal error. 45536e956c5Smrgwarning_func=func_warn_and_continue 4565f5b92ffSmrg 45736e956c5Smrg# Set to 'all' to display all warnings, 'none' to suppress all 45836e956c5Smrg# warnings, or a space delimited list of some subset of 45936e956c5Smrg# 'warning_categories' to display only the listed warnings. 46036e956c5Smrgopt_warning_types=all 4615f5b92ffSmrg 4620dd80ee0Smrg 46336e956c5Smrg## -------------------- ## 46436e956c5Smrg## Resource management. ## 46536e956c5Smrg## -------------------- ## 4665f5b92ffSmrg 46736e956c5Smrg# This section contains definitions for functions that each ensure a 46836e956c5Smrg# particular resource (a file, or a non-empty configuration variable for 46936e956c5Smrg# example) is available, and if appropriate to extract default values 47036e956c5Smrg# from pertinent package files. Call them using their associated 47136e956c5Smrg# 'require_*' variable to ensure that they are executed, at most, once. 47236e956c5Smrg# 47336e956c5Smrg# It's entirely deliberate that calling these functions can set 47436e956c5Smrg# variables that don't obey the namespace limitations obeyed by the rest 47536e956c5Smrg# of this file, in order that that they be as useful as possible to 47636e956c5Smrg# callers. 4775f5b92ffSmrg 4785f5b92ffSmrg 47936e956c5Smrg# require_term_colors 48036e956c5Smrg# ------------------- 48136e956c5Smrg# Allow display of bold text on terminals that support it. 48236e956c5Smrgrequire_term_colors=func_require_term_colors 48336e956c5Smrgfunc_require_term_colors () 4845f5b92ffSmrg{ 48536e956c5Smrg $debug_cmd 48636e956c5Smrg 48736e956c5Smrg test -t 1 && { 48836e956c5Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 48936e956c5Smrg # precedence, because most terminfo databases neglect to describe 49036e956c5Smrg # whether color sequences are supported. 49136e956c5Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49236e956c5Smrg 49336e956c5Smrg if test 1 = "$USE_ANSI_COLORS"; then 49436e956c5Smrg # Standard ANSI escape sequences 49536e956c5Smrg tc_reset='[0m' 49636e956c5Smrg tc_bold='[1m'; tc_standout='[7m' 49736e956c5Smrg tc_red='[31m'; tc_green='[32m' 49836e956c5Smrg tc_blue='[34m'; tc_cyan='[36m' 49936e956c5Smrg else 50036e956c5Smrg # Otherwise trust the terminfo database after all. 50136e956c5Smrg test -n "`tput sgr0 2>/dev/null`" && { 50236e956c5Smrg tc_reset=`tput sgr0` 50336e956c5Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50436e956c5Smrg tc_standout=$tc_bold 50536e956c5Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50636e956c5Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50736e956c5Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50836e956c5Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50936e956c5Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51036e956c5Smrg } 51136e956c5Smrg fi 51236e956c5Smrg } 5135f5b92ffSmrg 51436e956c5Smrg require_term_colors=: 5155f5b92ffSmrg} 5165f5b92ffSmrg 5175f5b92ffSmrg 51836e956c5Smrg## ----------------- ## 51936e956c5Smrg## Function library. ## 52036e956c5Smrg## ----------------- ## 52136e956c5Smrg 52236e956c5Smrg# This section contains a variety of useful functions to call in your 52336e956c5Smrg# scripts. Take note of the portable wrappers for features provided by 52436e956c5Smrg# some modern shells, which will fall back to slower equivalents on 52536e956c5Smrg# less featureful shells. 52636e956c5Smrg 52736e956c5Smrg 52836e956c5Smrg# func_append VAR VALUE 52936e956c5Smrg# --------------------- 53036e956c5Smrg# Append VALUE onto the existing contents of VAR. 53136e956c5Smrg 53236e956c5Smrg # We should try to minimise forks, especially on Windows where they are 53336e956c5Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 53436e956c5Smrg # being used: 53536e956c5Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53636e956c5Smrg : ${_G_HAVE_ARITH_OP="yes"} 53736e956c5Smrg : ${_G_HAVE_XSI_OPS="yes"} 53836e956c5Smrg # The += operator was introduced in bash 3.1 53936e956c5Smrg case $BASH_VERSION in 54036e956c5Smrg [12].* | 3.0 | 3.0*) ;; 54136e956c5Smrg *) 54236e956c5Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54336e956c5Smrg ;; 54436e956c5Smrg esac 54536e956c5Smrg fi 54636e956c5Smrg 54736e956c5Smrg # _G_HAVE_PLUSEQ_OP 54836e956c5Smrg # Can be empty, in which case the shell is probed, "yes" if += is 54936e956c5Smrg # useable or anything else if it does not work. 55036e956c5Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55136e956c5Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55236e956c5Smrg && _G_HAVE_PLUSEQ_OP=yes 55336e956c5Smrg 55436e956c5Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55536e956c5Smrgthen 55636e956c5Smrg # This is an XSI compatible shell, allowing a faster implementation... 55736e956c5Smrg eval 'func_append () 55836e956c5Smrg { 55936e956c5Smrg $debug_cmd 56036e956c5Smrg 56136e956c5Smrg eval "$1+=\$2" 56236e956c5Smrg }' 56336e956c5Smrgelse 56436e956c5Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 56536e956c5Smrg func_append () 56636e956c5Smrg { 56736e956c5Smrg $debug_cmd 56836e956c5Smrg 56936e956c5Smrg eval "$1=\$$1\$2" 57036e956c5Smrg } 57136e956c5Smrgfi 57236e956c5Smrg 57336e956c5Smrg 57436e956c5Smrg# func_append_quoted VAR VALUE 57536e956c5Smrg# ---------------------------- 57636e956c5Smrg# Quote VALUE and append to the end of shell variable VAR, separated 57736e956c5Smrg# by a space. 57836e956c5Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57936e956c5Smrg eval 'func_append_quoted () 58036e956c5Smrg { 58136e956c5Smrg $debug_cmd 58236e956c5Smrg 58336e956c5Smrg func_quote_for_eval "$2" 58436e956c5Smrg eval "$1+=\\ \$func_quote_for_eval_result" 58536e956c5Smrg }' 58636e956c5Smrgelse 58736e956c5Smrg func_append_quoted () 58836e956c5Smrg { 58936e956c5Smrg $debug_cmd 59036e956c5Smrg 59136e956c5Smrg func_quote_for_eval "$2" 59236e956c5Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59336e956c5Smrg } 59436e956c5Smrgfi 59536e956c5Smrg 59636e956c5Smrg 59736e956c5Smrg# func_append_uniq VAR VALUE 59836e956c5Smrg# -------------------------- 59936e956c5Smrg# Append unique VALUE onto the existing contents of VAR, assuming 60036e956c5Smrg# entries are delimited by the first character of VALUE. For example: 60136e956c5Smrg# 60236e956c5Smrg# func_append_uniq options " --another-option option-argument" 60336e956c5Smrg# 60436e956c5Smrg# will only append to $options if " --another-option option-argument " 60536e956c5Smrg# is not already present somewhere in $options already (note spaces at 60636e956c5Smrg# each end implied by leading space in second argument). 60736e956c5Smrgfunc_append_uniq () 60836e956c5Smrg{ 60936e956c5Smrg $debug_cmd 61036e956c5Smrg 61136e956c5Smrg eval _G_current_value='`$ECHO $'$1'`' 61236e956c5Smrg _G_delim=`expr "$2" : '\(.\)'` 61336e956c5Smrg 61436e956c5Smrg case $_G_delim$_G_current_value$_G_delim in 61536e956c5Smrg *"$2$_G_delim"*) ;; 61636e956c5Smrg *) func_append "$@" ;; 61736e956c5Smrg esac 61836e956c5Smrg} 61936e956c5Smrg 62036e956c5Smrg 62136e956c5Smrg# func_arith TERM... 62236e956c5Smrg# ------------------ 62336e956c5Smrg# Set func_arith_result to the result of evaluating TERMs. 62436e956c5Smrg test -z "$_G_HAVE_ARITH_OP" \ 62536e956c5Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62636e956c5Smrg && _G_HAVE_ARITH_OP=yes 62736e956c5Smrg 62836e956c5Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 62936e956c5Smrg eval 'func_arith () 63036e956c5Smrg { 63136e956c5Smrg $debug_cmd 63236e956c5Smrg 63336e956c5Smrg func_arith_result=$(( $* )) 63436e956c5Smrg }' 63536e956c5Smrgelse 63636e956c5Smrg func_arith () 63736e956c5Smrg { 63836e956c5Smrg $debug_cmd 63936e956c5Smrg 64036e956c5Smrg func_arith_result=`expr "$@"` 64136e956c5Smrg } 64236e956c5Smrgfi 64336e956c5Smrg 64436e956c5Smrg 64536e956c5Smrg# func_basename FILE 64636e956c5Smrg# ------------------ 64736e956c5Smrg# Set func_basename_result to FILE with everything up to and including 64836e956c5Smrg# the last / stripped. 64936e956c5Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 65036e956c5Smrg # If this shell supports suffix pattern removal, then use it to avoid 65136e956c5Smrg # forking. Hide the definitions single quotes in case the shell chokes 65236e956c5Smrg # on unsupported syntax... 65336e956c5Smrg _b='func_basename_result=${1##*/}' 65436e956c5Smrg _d='case $1 in 65536e956c5Smrg */*) func_dirname_result=${1%/*}$2 ;; 65636e956c5Smrg * ) func_dirname_result=$3 ;; 65736e956c5Smrg esac' 65836e956c5Smrg 65936e956c5Smrgelse 66036e956c5Smrg # ...otherwise fall back to using sed. 66136e956c5Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66236e956c5Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66336e956c5Smrg if test "X$func_dirname_result" = "X$1"; then 66436e956c5Smrg func_dirname_result=$3 66536e956c5Smrg else 66636e956c5Smrg func_append func_dirname_result "$2" 66736e956c5Smrg fi' 66836e956c5Smrgfi 66936e956c5Smrg 67036e956c5Smrgeval 'func_basename () 67136e956c5Smrg{ 67236e956c5Smrg $debug_cmd 67336e956c5Smrg 67436e956c5Smrg '"$_b"' 67536e956c5Smrg}' 67636e956c5Smrg 67736e956c5Smrg 67836e956c5Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67936e956c5Smrg# ------------------------------------------- 68036e956c5Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68136e956c5Smrg# otherwise set result to NONDIR_REPLACEMENT. 68236e956c5Smrgeval 'func_dirname () 68336e956c5Smrg{ 68436e956c5Smrg $debug_cmd 68536e956c5Smrg 68636e956c5Smrg '"$_d"' 68736e956c5Smrg}' 68836e956c5Smrg 68936e956c5Smrg 69036e956c5Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69136e956c5Smrg# -------------------------------------------------------- 69236e956c5Smrg# Perform func_basename and func_dirname in a single function 69336e956c5Smrg# call: 69436e956c5Smrg# dirname: Compute the dirname of FILE. If nonempty, 69536e956c5Smrg# add APPEND to the result, otherwise set result 69636e956c5Smrg# to NONDIR_REPLACEMENT. 69736e956c5Smrg# value returned in "$func_dirname_result" 69836e956c5Smrg# basename: Compute filename of FILE. 69936e956c5Smrg# value retuned in "$func_basename_result" 70036e956c5Smrg# For efficiency, we do not delegate to the functions above but instead 70136e956c5Smrg# duplicate the functionality here. 70236e956c5Smrgeval 'func_dirname_and_basename () 70336e956c5Smrg{ 70436e956c5Smrg $debug_cmd 70536e956c5Smrg 70636e956c5Smrg '"$_b"' 70736e956c5Smrg '"$_d"' 70836e956c5Smrg}' 70936e956c5Smrg 71036e956c5Smrg 71136e956c5Smrg# func_echo ARG... 71236e956c5Smrg# ---------------- 71336e956c5Smrg# Echo program name prefixed message. 71436e956c5Smrgfunc_echo () 71536e956c5Smrg{ 71636e956c5Smrg $debug_cmd 71736e956c5Smrg 71836e956c5Smrg _G_message=$* 71936e956c5Smrg 72036e956c5Smrg func_echo_IFS=$IFS 72136e956c5Smrg IFS=$nl 72236e956c5Smrg for _G_line in $_G_message; do 72336e956c5Smrg IFS=$func_echo_IFS 72436e956c5Smrg $ECHO "$progname: $_G_line" 72536e956c5Smrg done 72636e956c5Smrg IFS=$func_echo_IFS 72736e956c5Smrg} 72836e956c5Smrg 72936e956c5Smrg 73036e956c5Smrg# func_echo_all ARG... 73136e956c5Smrg# -------------------- 73236e956c5Smrg# Invoke $ECHO with all args, space-separated. 73336e956c5Smrgfunc_echo_all () 73436e956c5Smrg{ 73536e956c5Smrg $ECHO "$*" 73636e956c5Smrg} 73736e956c5Smrg 73836e956c5Smrg 73936e956c5Smrg# func_echo_infix_1 INFIX ARG... 74036e956c5Smrg# ------------------------------ 74136e956c5Smrg# Echo program name, followed by INFIX on the first line, with any 74236e956c5Smrg# additional lines not showing INFIX. 74336e956c5Smrgfunc_echo_infix_1 () 74436e956c5Smrg{ 74536e956c5Smrg $debug_cmd 74636e956c5Smrg 74736e956c5Smrg $require_term_colors 74836e956c5Smrg 74936e956c5Smrg _G_infix=$1; shift 75036e956c5Smrg _G_indent=$_G_infix 75136e956c5Smrg _G_prefix="$progname: $_G_infix: " 75236e956c5Smrg _G_message=$* 75336e956c5Smrg 75436e956c5Smrg # Strip color escape sequences before counting printable length 75536e956c5Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75636e956c5Smrg do 75736e956c5Smrg test -n "$_G_tc" && { 75836e956c5Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75936e956c5Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76036e956c5Smrg } 76136e956c5Smrg done 76236e956c5Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76336e956c5Smrg 76436e956c5Smrg func_echo_infix_1_IFS=$IFS 76536e956c5Smrg IFS=$nl 76636e956c5Smrg for _G_line in $_G_message; do 76736e956c5Smrg IFS=$func_echo_infix_1_IFS 76836e956c5Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76936e956c5Smrg _G_prefix=$_G_indent 77036e956c5Smrg done 77136e956c5Smrg IFS=$func_echo_infix_1_IFS 77236e956c5Smrg} 77336e956c5Smrg 77436e956c5Smrg 77536e956c5Smrg# func_error ARG... 77636e956c5Smrg# ----------------- 77736e956c5Smrg# Echo program name prefixed message to standard error. 77836e956c5Smrgfunc_error () 77936e956c5Smrg{ 78036e956c5Smrg $debug_cmd 78136e956c5Smrg 78236e956c5Smrg $require_term_colors 78336e956c5Smrg 78436e956c5Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78536e956c5Smrg} 78636e956c5Smrg 78736e956c5Smrg 78836e956c5Smrg# func_fatal_error ARG... 78936e956c5Smrg# ----------------------- 79036e956c5Smrg# Echo program name prefixed message to standard error, and exit. 79136e956c5Smrgfunc_fatal_error () 79236e956c5Smrg{ 79336e956c5Smrg $debug_cmd 79436e956c5Smrg 79536e956c5Smrg func_error "$*" 79636e956c5Smrg exit $EXIT_FAILURE 79736e956c5Smrg} 79836e956c5Smrg 79936e956c5Smrg 80036e956c5Smrg# func_grep EXPRESSION FILENAME 80136e956c5Smrg# ----------------------------- 8025f5b92ffSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8035f5b92ffSmrgfunc_grep () 8045f5b92ffSmrg{ 80536e956c5Smrg $debug_cmd 80636e956c5Smrg 8075f5b92ffSmrg $GREP "$1" "$2" >/dev/null 2>&1 8085f5b92ffSmrg} 8095f5b92ffSmrg 8105f5b92ffSmrg 81136e956c5Smrg# func_len STRING 81236e956c5Smrg# --------------- 81336e956c5Smrg# Set func_len_result to the length of STRING. STRING may not 81436e956c5Smrg# start with a hyphen. 81536e956c5Smrg test -z "$_G_HAVE_XSI_OPS" \ 81636e956c5Smrg && (eval 'x=a/b/c; 81736e956c5Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81836e956c5Smrg && _G_HAVE_XSI_OPS=yes 81936e956c5Smrg 82036e956c5Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 82136e956c5Smrg eval 'func_len () 82236e956c5Smrg { 82336e956c5Smrg $debug_cmd 82436e956c5Smrg 82536e956c5Smrg func_len_result=${#1} 82636e956c5Smrg }' 82736e956c5Smrgelse 82836e956c5Smrg func_len () 82936e956c5Smrg { 83036e956c5Smrg $debug_cmd 83136e956c5Smrg 83236e956c5Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83336e956c5Smrg } 83436e956c5Smrgfi 83536e956c5Smrg 83636e956c5Smrg 83736e956c5Smrg# func_mkdir_p DIRECTORY-PATH 83836e956c5Smrg# --------------------------- 8395f5b92ffSmrg# Make sure the entire path to DIRECTORY-PATH is available. 8405f5b92ffSmrgfunc_mkdir_p () 8415f5b92ffSmrg{ 84236e956c5Smrg $debug_cmd 84336e956c5Smrg 84436e956c5Smrg _G_directory_path=$1 84536e956c5Smrg _G_dir_list= 8465f5b92ffSmrg 84736e956c5Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8485f5b92ffSmrg 84936e956c5Smrg # Protect directory names starting with '-' 85036e956c5Smrg case $_G_directory_path in 85136e956c5Smrg -*) _G_directory_path=./$_G_directory_path ;; 8525f5b92ffSmrg esac 8535f5b92ffSmrg 8545f5b92ffSmrg # While some portion of DIR does not yet exist... 85536e956c5Smrg while test ! -d "$_G_directory_path"; do 8565f5b92ffSmrg # ...make a list in topmost first order. Use a colon delimited 8575f5b92ffSmrg # list incase some portion of path contains whitespace. 85836e956c5Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 8595f5b92ffSmrg 8605f5b92ffSmrg # If the last portion added has no slash in it, the list is done 86136e956c5Smrg case $_G_directory_path in */*) ;; *) break ;; esac 8625f5b92ffSmrg 8635f5b92ffSmrg # ...otherwise throw away the child directory and loop 86436e956c5Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 8655f5b92ffSmrg done 86636e956c5Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 8675f5b92ffSmrg 86836e956c5Smrg func_mkdir_p_IFS=$IFS; IFS=: 86936e956c5Smrg for _G_dir in $_G_dir_list; do 87036e956c5Smrg IFS=$func_mkdir_p_IFS 87136e956c5Smrg # mkdir can fail with a 'File exist' error if two processes 8725f5b92ffSmrg # try to create one of the directories concurrently. Don't 8735f5b92ffSmrg # stop in that case! 87436e956c5Smrg $MKDIR "$_G_dir" 2>/dev/null || : 8755f5b92ffSmrg done 87636e956c5Smrg IFS=$func_mkdir_p_IFS 8775f5b92ffSmrg 8785f5b92ffSmrg # Bail out if we (or some other process) failed to create a directory. 87936e956c5Smrg test -d "$_G_directory_path" || \ 88036e956c5Smrg func_fatal_error "Failed to create '$1'" 8815f5b92ffSmrg fi 8825f5b92ffSmrg} 88317a48c7cSmrg 88417a48c7cSmrg 88536e956c5Smrg# func_mktempdir [BASENAME] 88636e956c5Smrg# ------------------------- 88717a48c7cSmrg# Make a temporary directory that won't clash with other running 88817a48c7cSmrg# libtool processes, and avoids race conditions if possible. If 88936e956c5Smrg# given, BASENAME is the basename for that directory. 89017a48c7cSmrgfunc_mktempdir () 89117a48c7cSmrg{ 89236e956c5Smrg $debug_cmd 89336e956c5Smrg 89436e956c5Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 89517a48c7cSmrg 89636e956c5Smrg if test : = "$opt_dry_run"; then 89717a48c7cSmrg # Return a directory name, but don't create it in dry-run mode 89836e956c5Smrg _G_tmpdir=$_G_template-$$ 89917a48c7cSmrg else 90017a48c7cSmrg 90117a48c7cSmrg # If mktemp works, use that first and foremost 90236e956c5Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 90317a48c7cSmrg 90436e956c5Smrg if test ! -d "$_G_tmpdir"; then 9055f5b92ffSmrg # Failing that, at least try and use $RANDOM to avoid a race 90636e956c5Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 90717a48c7cSmrg 90836e956c5Smrg func_mktempdir_umask=`umask` 9095f5b92ffSmrg umask 0077 91036e956c5Smrg $MKDIR "$_G_tmpdir" 91136e956c5Smrg umask $func_mktempdir_umask 91217a48c7cSmrg fi 91317a48c7cSmrg 91417a48c7cSmrg # If we're not in dry-run mode, bomb out on failure 91536e956c5Smrg test -d "$_G_tmpdir" || \ 91636e956c5Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91717a48c7cSmrg fi 91817a48c7cSmrg 91936e956c5Smrg $ECHO "$_G_tmpdir" 92017a48c7cSmrg} 92117a48c7cSmrg 92217a48c7cSmrg 92336e956c5Smrg# func_normal_abspath PATH 92436e956c5Smrg# ------------------------ 92536e956c5Smrg# Remove doubled-up and trailing slashes, "." path components, 92636e956c5Smrg# and cancel out any ".." path components in PATH after making 92736e956c5Smrg# it an absolute path. 92836e956c5Smrgfunc_normal_abspath () 92917a48c7cSmrg{ 93036e956c5Smrg $debug_cmd 9315f5b92ffSmrg 93236e956c5Smrg # These SED scripts presuppose an absolute path with a trailing slash. 93336e956c5Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93436e956c5Smrg _G_pathcdr='s|^/[^/]*||' 93536e956c5Smrg _G_removedotparts=':dotsl 93636e956c5Smrg s|/\./|/|g 93736e956c5Smrg t dotsl 93836e956c5Smrg s|/\.$|/|' 93936e956c5Smrg _G_collapseslashes='s|/\{1,\}|/|g' 94036e956c5Smrg _G_finalslash='s|/*$|/|' 94136e956c5Smrg 94236e956c5Smrg # Start from root dir and reassemble the path. 94336e956c5Smrg func_normal_abspath_result= 94436e956c5Smrg func_normal_abspath_tpath=$1 94536e956c5Smrg func_normal_abspath_altnamespace= 94636e956c5Smrg case $func_normal_abspath_tpath in 94736e956c5Smrg "") 94836e956c5Smrg # Empty path, that just means $cwd. 94936e956c5Smrg func_stripname '' '/' "`pwd`" 95036e956c5Smrg func_normal_abspath_result=$func_stripname_result 95136e956c5Smrg return 95236e956c5Smrg ;; 95336e956c5Smrg # The next three entries are used to spot a run of precisely 95436e956c5Smrg # two leading slashes without using negated character classes; 95536e956c5Smrg # we take advantage of case's first-match behaviour. 95636e956c5Smrg ///*) 95736e956c5Smrg # Unusual form of absolute path, do nothing. 95836e956c5Smrg ;; 95936e956c5Smrg //*) 96036e956c5Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96136e956c5Smrg # and for example Cygwin uses it to access remote file shares 96236e956c5Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 96336e956c5Smrg func_normal_abspath_altnamespace=/ 96436e956c5Smrg ;; 96536e956c5Smrg /*) 96636e956c5Smrg # Absolute path, do nothing. 9675f5b92ffSmrg ;; 9685f5b92ffSmrg *) 96936e956c5Smrg # Relative path, prepend $cwd. 97036e956c5Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97136e956c5Smrg ;; 97217a48c7cSmrg esac 97336e956c5Smrg 97436e956c5Smrg # Cancel out all the simple stuff to save iterations. We also want 97536e956c5Smrg # the path to end with a slash for ease of parsing, so make sure 97636e956c5Smrg # there is one (and only one) here. 97736e956c5Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97836e956c5Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97936e956c5Smrg while :; do 98036e956c5Smrg # Processed it all yet? 98136e956c5Smrg if test / = "$func_normal_abspath_tpath"; then 98236e956c5Smrg # If we ascended to the root using ".." the result may be empty now. 98336e956c5Smrg if test -z "$func_normal_abspath_result"; then 98436e956c5Smrg func_normal_abspath_result=/ 98536e956c5Smrg fi 98636e956c5Smrg break 98736e956c5Smrg fi 98836e956c5Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98936e956c5Smrg -e "$_G_pathcar"` 99036e956c5Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99136e956c5Smrg -e "$_G_pathcdr"` 99236e956c5Smrg # Figure out what to do with it 99336e956c5Smrg case $func_normal_abspath_tcomponent in 99436e956c5Smrg "") 99536e956c5Smrg # Trailing empty path component, ignore it. 99636e956c5Smrg ;; 99736e956c5Smrg ..) 99836e956c5Smrg # Parent dir; strip last assembled component from result. 99936e956c5Smrg func_dirname "$func_normal_abspath_result" 100036e956c5Smrg func_normal_abspath_result=$func_dirname_result 100136e956c5Smrg ;; 100236e956c5Smrg *) 100336e956c5Smrg # Actual path component, append it. 100436e956c5Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100536e956c5Smrg ;; 100636e956c5Smrg esac 100736e956c5Smrg done 100836e956c5Smrg # Restore leading double-slash if one was found on entry. 100936e956c5Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101036e956c5Smrg} 101136e956c5Smrg 101236e956c5Smrg 101336e956c5Smrg# func_notquiet ARG... 101436e956c5Smrg# -------------------- 101536e956c5Smrg# Echo program name prefixed message only when not in quiet mode. 101636e956c5Smrgfunc_notquiet () 101736e956c5Smrg{ 101836e956c5Smrg $debug_cmd 101936e956c5Smrg 102036e956c5Smrg $opt_quiet || func_echo ${1+"$@"} 102136e956c5Smrg 102236e956c5Smrg # A bug in bash halts the script if the last line of a function 102336e956c5Smrg # fails when set -e is in force, so we need another command to 102436e956c5Smrg # work around that: 102536e956c5Smrg : 102636e956c5Smrg} 102736e956c5Smrg 102836e956c5Smrg 102936e956c5Smrg# func_relative_path SRCDIR DSTDIR 103036e956c5Smrg# -------------------------------- 103136e956c5Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103236e956c5Smrgfunc_relative_path () 103336e956c5Smrg{ 103436e956c5Smrg $debug_cmd 103536e956c5Smrg 103636e956c5Smrg func_relative_path_result= 103736e956c5Smrg func_normal_abspath "$1" 103836e956c5Smrg func_relative_path_tlibdir=$func_normal_abspath_result 103936e956c5Smrg func_normal_abspath "$2" 104036e956c5Smrg func_relative_path_tbindir=$func_normal_abspath_result 104136e956c5Smrg 104236e956c5Smrg # Ascend the tree starting from libdir 104336e956c5Smrg while :; do 104436e956c5Smrg # check if we have found a prefix of bindir 104536e956c5Smrg case $func_relative_path_tbindir in 104636e956c5Smrg $func_relative_path_tlibdir) 104736e956c5Smrg # found an exact match 104836e956c5Smrg func_relative_path_tcancelled= 104936e956c5Smrg break 105036e956c5Smrg ;; 105136e956c5Smrg $func_relative_path_tlibdir*) 105236e956c5Smrg # found a matching prefix 105336e956c5Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105436e956c5Smrg func_relative_path_tcancelled=$func_stripname_result 105536e956c5Smrg if test -z "$func_relative_path_result"; then 105636e956c5Smrg func_relative_path_result=. 105736e956c5Smrg fi 105836e956c5Smrg break 105936e956c5Smrg ;; 106036e956c5Smrg *) 106136e956c5Smrg func_dirname $func_relative_path_tlibdir 106236e956c5Smrg func_relative_path_tlibdir=$func_dirname_result 106336e956c5Smrg if test -z "$func_relative_path_tlibdir"; then 106436e956c5Smrg # Have to descend all the way to the root! 106536e956c5Smrg func_relative_path_result=../$func_relative_path_result 106636e956c5Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 106736e956c5Smrg break 106836e956c5Smrg fi 106936e956c5Smrg func_relative_path_result=../$func_relative_path_result 107036e956c5Smrg ;; 107136e956c5Smrg esac 107236e956c5Smrg done 107336e956c5Smrg 107436e956c5Smrg # Now calculate path; take care to avoid doubling-up slashes. 107536e956c5Smrg func_stripname '' '/' "$func_relative_path_result" 107636e956c5Smrg func_relative_path_result=$func_stripname_result 107736e956c5Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107836e956c5Smrg if test -n "$func_stripname_result"; then 107936e956c5Smrg func_append func_relative_path_result "/$func_stripname_result" 108036e956c5Smrg fi 108136e956c5Smrg 108236e956c5Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 108336e956c5Smrg if test -n "$func_relative_path_result"; then 108436e956c5Smrg func_stripname './' '' "$func_relative_path_result" 108536e956c5Smrg func_relative_path_result=$func_stripname_result 108636e956c5Smrg fi 108736e956c5Smrg 108836e956c5Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 108936e956c5Smrg 109036e956c5Smrg : 109117a48c7cSmrg} 109217a48c7cSmrg 109317a48c7cSmrg 109436e956c5Smrg# func_quote_for_eval ARG... 109536e956c5Smrg# -------------------------- 109636e956c5Smrg# Aesthetically quote ARGs to be evaled later. 109736e956c5Smrg# This function returns two values: 109836e956c5Smrg# i) func_quote_for_eval_result 109936e956c5Smrg# double-quoted, suitable for a subsequent eval 110036e956c5Smrg# ii) func_quote_for_eval_unquoted_result 110136e956c5Smrg# has all characters that are still active within double 110236e956c5Smrg# quotes backslashified. 110336e956c5Smrgfunc_quote_for_eval () 110436e956c5Smrg{ 110536e956c5Smrg $debug_cmd 110636e956c5Smrg 110736e956c5Smrg func_quote_for_eval_unquoted_result= 110836e956c5Smrg func_quote_for_eval_result= 110936e956c5Smrg while test 0 -lt $#; do 111036e956c5Smrg case $1 in 111136e956c5Smrg *[\\\`\"\$]*) 111236e956c5Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111336e956c5Smrg *) 111436e956c5Smrg _G_unquoted_arg=$1 ;; 111536e956c5Smrg esac 111636e956c5Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 111736e956c5Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111836e956c5Smrg else 111936e956c5Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112036e956c5Smrg fi 112136e956c5Smrg 112236e956c5Smrg case $_G_unquoted_arg in 112336e956c5Smrg # Double-quote args containing shell metacharacters to delay 112436e956c5Smrg # word splitting, command substitution and variable expansion 112536e956c5Smrg # for a subsequent eval. 112636e956c5Smrg # Many Bourne shells cannot handle close brackets correctly 112736e956c5Smrg # in scan sets, so we specify it separately. 112836e956c5Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112936e956c5Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 113036e956c5Smrg ;; 113136e956c5Smrg *) 113236e956c5Smrg _G_quoted_arg=$_G_unquoted_arg 113336e956c5Smrg ;; 113436e956c5Smrg esac 113536e956c5Smrg 113636e956c5Smrg if test -n "$func_quote_for_eval_result"; then 113736e956c5Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113836e956c5Smrg else 113936e956c5Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114036e956c5Smrg fi 114136e956c5Smrg shift 114236e956c5Smrg done 114336e956c5Smrg} 114436e956c5Smrg 114536e956c5Smrg 114636e956c5Smrg# func_quote_for_expand ARG 114736e956c5Smrg# ------------------------- 11485f5b92ffSmrg# Aesthetically quote ARG to be evaled later; same as above, 11495f5b92ffSmrg# but do not quote variable references. 11505f5b92ffSmrgfunc_quote_for_expand () 115117a48c7cSmrg{ 115236e956c5Smrg $debug_cmd 115336e956c5Smrg 11545f5b92ffSmrg case $1 in 11555f5b92ffSmrg *[\\\`\"]*) 115636e956c5Smrg _G_arg=`$ECHO "$1" | $SED \ 115736e956c5Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115817a48c7cSmrg *) 115936e956c5Smrg _G_arg=$1 ;; 11605f5b92ffSmrg esac 11615f5b92ffSmrg 116236e956c5Smrg case $_G_arg in 11635f5b92ffSmrg # Double-quote args containing shell metacharacters to delay 11645f5b92ffSmrg # word splitting and command substitution for a subsequent eval. 11655f5b92ffSmrg # Many Bourne shells cannot handle close brackets correctly 11665f5b92ffSmrg # in scan sets, so we specify it separately. 11675f5b92ffSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116836e956c5Smrg _G_arg=\"$_G_arg\" 11695f5b92ffSmrg ;; 11705f5b92ffSmrg esac 11715f5b92ffSmrg 117236e956c5Smrg func_quote_for_expand_result=$_G_arg 117336e956c5Smrg} 117436e956c5Smrg 117536e956c5Smrg 117636e956c5Smrg# func_stripname PREFIX SUFFIX NAME 117736e956c5Smrg# --------------------------------- 117836e956c5Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117936e956c5Smrg# PREFIX and SUFFIX must not contain globbing or regex special 118036e956c5Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118136e956c5Smrg# dot (in which case that matches only a dot). 118236e956c5Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 118336e956c5Smrg eval 'func_stripname () 118436e956c5Smrg { 118536e956c5Smrg $debug_cmd 118636e956c5Smrg 118736e956c5Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118836e956c5Smrg # positional parameters, so assign one to ordinary variable first. 118936e956c5Smrg func_stripname_result=$3 119036e956c5Smrg func_stripname_result=${func_stripname_result#"$1"} 119136e956c5Smrg func_stripname_result=${func_stripname_result%"$2"} 119236e956c5Smrg }' 119336e956c5Smrgelse 119436e956c5Smrg func_stripname () 119536e956c5Smrg { 119636e956c5Smrg $debug_cmd 119736e956c5Smrg 119836e956c5Smrg case $2 in 119936e956c5Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120036e956c5Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120136e956c5Smrg esac 120236e956c5Smrg } 120336e956c5Smrgfi 120436e956c5Smrg 120536e956c5Smrg 120636e956c5Smrg# func_show_eval CMD [FAIL_EXP] 120736e956c5Smrg# ----------------------------- 120836e956c5Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120936e956c5Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121036e956c5Smrg# is given, then evaluate it. 121136e956c5Smrgfunc_show_eval () 121236e956c5Smrg{ 121336e956c5Smrg $debug_cmd 121436e956c5Smrg 121536e956c5Smrg _G_cmd=$1 121636e956c5Smrg _G_fail_exp=${2-':'} 121736e956c5Smrg 121836e956c5Smrg func_quote_for_expand "$_G_cmd" 121936e956c5Smrg eval "func_notquiet $func_quote_for_expand_result" 122036e956c5Smrg 122136e956c5Smrg $opt_dry_run || { 122236e956c5Smrg eval "$_G_cmd" 122336e956c5Smrg _G_status=$? 122436e956c5Smrg if test 0 -ne "$_G_status"; then 122536e956c5Smrg eval "(exit $_G_status); $_G_fail_exp" 122636e956c5Smrg fi 122736e956c5Smrg } 122836e956c5Smrg} 122936e956c5Smrg 123036e956c5Smrg 123136e956c5Smrg# func_show_eval_locale CMD [FAIL_EXP] 123236e956c5Smrg# ------------------------------------ 123336e956c5Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123436e956c5Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123536e956c5Smrg# is given, then evaluate it. Use the saved locale for evaluation. 123636e956c5Smrgfunc_show_eval_locale () 123736e956c5Smrg{ 123836e956c5Smrg $debug_cmd 123936e956c5Smrg 124036e956c5Smrg _G_cmd=$1 124136e956c5Smrg _G_fail_exp=${2-':'} 124236e956c5Smrg 124336e956c5Smrg $opt_quiet || { 124436e956c5Smrg func_quote_for_expand "$_G_cmd" 124536e956c5Smrg eval "func_echo $func_quote_for_expand_result" 124636e956c5Smrg } 124736e956c5Smrg 124836e956c5Smrg $opt_dry_run || { 124936e956c5Smrg eval "$_G_user_locale 125036e956c5Smrg $_G_cmd" 125136e956c5Smrg _G_status=$? 125236e956c5Smrg eval "$_G_safe_locale" 125336e956c5Smrg if test 0 -ne "$_G_status"; then 125436e956c5Smrg eval "(exit $_G_status); $_G_fail_exp" 125536e956c5Smrg fi 125636e956c5Smrg } 125736e956c5Smrg} 125836e956c5Smrg 125936e956c5Smrg 126036e956c5Smrg# func_tr_sh 126136e956c5Smrg# ---------- 126236e956c5Smrg# Turn $1 into a string suitable for a shell variable name. 126336e956c5Smrg# Result is stored in $func_tr_sh_result. All characters 126436e956c5Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126536e956c5Smrg# if $1 begins with a digit, a '_' is prepended as well. 126636e956c5Smrgfunc_tr_sh () 126736e956c5Smrg{ 126836e956c5Smrg $debug_cmd 126936e956c5Smrg 127036e956c5Smrg case $1 in 127136e956c5Smrg [0-9]* | *[!a-zA-Z0-9_]*) 127236e956c5Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127336e956c5Smrg ;; 127436e956c5Smrg * ) 127536e956c5Smrg func_tr_sh_result=$1 127636e956c5Smrg ;; 127736e956c5Smrg esac 127836e956c5Smrg} 127936e956c5Smrg 128036e956c5Smrg 128136e956c5Smrg# func_verbose ARG... 128236e956c5Smrg# ------------------- 128336e956c5Smrg# Echo program name prefixed message in verbose mode only. 128436e956c5Smrgfunc_verbose () 128536e956c5Smrg{ 128636e956c5Smrg $debug_cmd 128736e956c5Smrg 128836e956c5Smrg $opt_verbose && func_echo "$*" 128936e956c5Smrg 129036e956c5Smrg : 129136e956c5Smrg} 129236e956c5Smrg 129336e956c5Smrg 129436e956c5Smrg# func_warn_and_continue ARG... 129536e956c5Smrg# ----------------------------- 129636e956c5Smrg# Echo program name prefixed warning message to standard error. 129736e956c5Smrgfunc_warn_and_continue () 129836e956c5Smrg{ 129936e956c5Smrg $debug_cmd 130036e956c5Smrg 130136e956c5Smrg $require_term_colors 130236e956c5Smrg 130336e956c5Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130436e956c5Smrg} 130536e956c5Smrg 130636e956c5Smrg 130736e956c5Smrg# func_warning CATEGORY ARG... 130836e956c5Smrg# ---------------------------- 130936e956c5Smrg# Echo program name prefixed warning message to standard error. Warning 131036e956c5Smrg# messages can be filtered according to CATEGORY, where this function 131136e956c5Smrg# elides messages where CATEGORY is not listed in the global variable 131236e956c5Smrg# 'opt_warning_types'. 131336e956c5Smrgfunc_warning () 131436e956c5Smrg{ 131536e956c5Smrg $debug_cmd 131636e956c5Smrg 131736e956c5Smrg # CATEGORY must be in the warning_categories list! 131836e956c5Smrg case " $warning_categories " in 131936e956c5Smrg *" $1 "*) ;; 132036e956c5Smrg *) func_internal_error "invalid warning category '$1'" ;; 132136e956c5Smrg esac 132236e956c5Smrg 132336e956c5Smrg _G_category=$1 132436e956c5Smrg shift 132536e956c5Smrg 132636e956c5Smrg case " $opt_warning_types " in 132736e956c5Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132836e956c5Smrg esac 132917a48c7cSmrg} 133017a48c7cSmrg 133117a48c7cSmrg 133236e956c5Smrg# func_sort_ver VER1 VER2 133336e956c5Smrg# ----------------------- 133436e956c5Smrg# 'sort -V' is not generally available. 133536e956c5Smrg# Note this deviates from the version comparison in automake 133636e956c5Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133736e956c5Smrg# but this should suffice as we won't be specifying old 133836e956c5Smrg# version formats or redundant trailing .0 in bootstrap.conf. 133936e956c5Smrg# If we did want full compatibility then we should probably 134036e956c5Smrg# use m4_version_compare from autoconf. 134136e956c5Smrgfunc_sort_ver () 134236e956c5Smrg{ 134336e956c5Smrg $debug_cmd 134436e956c5Smrg 134536e956c5Smrg printf '%s\n%s\n' "$1" "$2" \ 134636e956c5Smrg | 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 134736e956c5Smrg} 134836e956c5Smrg 134936e956c5Smrg# func_lt_ver PREV CURR 135036e956c5Smrg# --------------------- 135136e956c5Smrg# Return true if PREV and CURR are in the correct order according to 135236e956c5Smrg# func_sort_ver, otherwise false. Use it like this: 135336e956c5Smrg# 135436e956c5Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135536e956c5Smrgfunc_lt_ver () 135636e956c5Smrg{ 135736e956c5Smrg $debug_cmd 135836e956c5Smrg 135936e956c5Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136036e956c5Smrg} 136136e956c5Smrg 136236e956c5Smrg 136336e956c5Smrg# Local variables: 136436e956c5Smrg# mode: shell-script 136536e956c5Smrg# sh-indentation: 2 136636e956c5Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 136736e956c5Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136836e956c5Smrg# time-stamp-time-zone: "UTC" 136936e956c5Smrg# End: 137036e956c5Smrg#! /bin/sh 137136e956c5Smrg 137236e956c5Smrg# Set a version string for this script. 137336e956c5Smrgscriptversion=2014-01-07.03; # UTC 137436e956c5Smrg 137536e956c5Smrg# A portable, pluggable option parser for Bourne shell. 137636e956c5Smrg# Written by Gary V. Vaughan, 2010 137736e956c5Smrg 137836e956c5Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137936e956c5Smrg# This is free software; see the source for copying conditions. There is NO 138036e956c5Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138136e956c5Smrg 138236e956c5Smrg# This program is free software: you can redistribute it and/or modify 138336e956c5Smrg# it under the terms of the GNU General Public License as published by 138436e956c5Smrg# the Free Software Foundation, either version 3 of the License, or 138536e956c5Smrg# (at your option) any later version. 138636e956c5Smrg 138736e956c5Smrg# This program is distributed in the hope that it will be useful, 138836e956c5Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138936e956c5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139036e956c5Smrg# GNU General Public License for more details. 139136e956c5Smrg 139236e956c5Smrg# You should have received a copy of the GNU General Public License 139336e956c5Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139436e956c5Smrg 139536e956c5Smrg# Please report bugs or propose patches to gary@gnu.org. 139636e956c5Smrg 139736e956c5Smrg 139836e956c5Smrg## ------ ## 139936e956c5Smrg## Usage. ## 140036e956c5Smrg## ------ ## 140136e956c5Smrg 140236e956c5Smrg# This file is a library for parsing options in your shell scripts along 140336e956c5Smrg# with assorted other useful supporting features that you can make use 140436e956c5Smrg# of too. 140536e956c5Smrg# 140636e956c5Smrg# For the simplest scripts you might need only: 140736e956c5Smrg# 140836e956c5Smrg# #!/bin/sh 140936e956c5Smrg# . relative/path/to/funclib.sh 141036e956c5Smrg# . relative/path/to/options-parser 141136e956c5Smrg# scriptversion=1.0 141236e956c5Smrg# func_options ${1+"$@"} 141336e956c5Smrg# eval set dummy "$func_options_result"; shift 141436e956c5Smrg# ...rest of your script... 141536e956c5Smrg# 141636e956c5Smrg# In order for the '--version' option to work, you will need to have a 141736e956c5Smrg# suitably formatted comment like the one at the top of this file 141836e956c5Smrg# starting with '# Written by ' and ending with '# warranty; '. 141936e956c5Smrg# 142036e956c5Smrg# For '-h' and '--help' to work, you will also need a one line 142136e956c5Smrg# description of your script's purpose in a comment directly above the 142236e956c5Smrg# '# Written by ' line, like the one at the top of this file. 142336e956c5Smrg# 142436e956c5Smrg# The default options also support '--debug', which will turn on shell 142536e956c5Smrg# execution tracing (see the comment above debug_cmd below for another 142636e956c5Smrg# use), and '--verbose' and the func_verbose function to allow your script 142736e956c5Smrg# to display verbose messages only when your user has specified 142836e956c5Smrg# '--verbose'. 142936e956c5Smrg# 143036e956c5Smrg# After sourcing this file, you can plug processing for additional 143136e956c5Smrg# options by amending the variables from the 'Configuration' section 143236e956c5Smrg# below, and following the instructions in the 'Option parsing' 143336e956c5Smrg# section further down. 143436e956c5Smrg 143536e956c5Smrg## -------------- ## 143636e956c5Smrg## Configuration. ## 143736e956c5Smrg## -------------- ## 143836e956c5Smrg 143936e956c5Smrg# You should override these variables in your script after sourcing this 144036e956c5Smrg# file so that they reflect the customisations you have added to the 144136e956c5Smrg# option parser. 144236e956c5Smrg 144336e956c5Smrg# The usage line for option parsing errors and the start of '-h' and 144436e956c5Smrg# '--help' output messages. You can embed shell variables for delayed 144536e956c5Smrg# expansion at the time the message is displayed, but you will need to 144636e956c5Smrg# quote other shell meta-characters carefully to prevent them being 144736e956c5Smrg# expanded when the contents are evaled. 144836e956c5Smrgusage='$progpath [OPTION]...' 144936e956c5Smrg 145036e956c5Smrg# Short help message in response to '-h' and '--help'. Add to this or 145136e956c5Smrg# override it after sourcing this library to reflect the full set of 145236e956c5Smrg# options your script accepts. 145336e956c5Smrgusage_message="\ 145436e956c5Smrg --debug enable verbose shell tracing 145536e956c5Smrg -W, --warnings=CATEGORY 145636e956c5Smrg report the warnings falling in CATEGORY [all] 145736e956c5Smrg -v, --verbose verbosely report processing 145836e956c5Smrg --version print version information and exit 145936e956c5Smrg -h, --help print short or long help message and exit 146036e956c5Smrg" 146136e956c5Smrg 146236e956c5Smrg# Additional text appended to 'usage_message' in response to '--help'. 146336e956c5Smrglong_help_message=" 146436e956c5SmrgWarning categories include: 146536e956c5Smrg 'all' show all warnings 146636e956c5Smrg 'none' turn off all the warnings 146736e956c5Smrg 'error' warnings are treated as fatal errors" 146836e956c5Smrg 146936e956c5Smrg# Help message printed before fatal option parsing errors. 147036e956c5Smrgfatal_help="Try '\$progname --help' for more information." 147136e956c5Smrg 147236e956c5Smrg 147336e956c5Smrg 147436e956c5Smrg## ------------------------- ## 147536e956c5Smrg## Hook function management. ## 147636e956c5Smrg## ------------------------- ## 147736e956c5Smrg 147836e956c5Smrg# This section contains functions for adding, removing, and running hooks 147936e956c5Smrg# to the main code. A hook is just a named list of of function, that can 148036e956c5Smrg# be run in order later on. 148136e956c5Smrg 148236e956c5Smrg# func_hookable FUNC_NAME 148336e956c5Smrg# ----------------------- 148436e956c5Smrg# Declare that FUNC_NAME will run hooks added with 148536e956c5Smrg# 'func_add_hook FUNC_NAME ...'. 148636e956c5Smrgfunc_hookable () 148736e956c5Smrg{ 148836e956c5Smrg $debug_cmd 148936e956c5Smrg 149036e956c5Smrg func_append hookable_fns " $1" 149136e956c5Smrg} 149236e956c5Smrg 149336e956c5Smrg 149436e956c5Smrg# func_add_hook FUNC_NAME HOOK_FUNC 149536e956c5Smrg# --------------------------------- 149636e956c5Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149736e956c5Smrg# first have been declared "hookable" by a call to 'func_hookable'. 149836e956c5Smrgfunc_add_hook () 149936e956c5Smrg{ 150036e956c5Smrg $debug_cmd 150136e956c5Smrg 150236e956c5Smrg case " $hookable_fns " in 150336e956c5Smrg *" $1 "*) ;; 150436e956c5Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150536e956c5Smrg esac 150636e956c5Smrg 150736e956c5Smrg eval func_append ${1}_hooks '" $2"' 150836e956c5Smrg} 150936e956c5Smrg 151036e956c5Smrg 151136e956c5Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 151236e956c5Smrg# ------------------------------------ 151336e956c5Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151436e956c5Smrgfunc_remove_hook () 151536e956c5Smrg{ 151636e956c5Smrg $debug_cmd 151736e956c5Smrg 151836e956c5Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151936e956c5Smrg} 152036e956c5Smrg 152136e956c5Smrg 152236e956c5Smrg# func_run_hooks FUNC_NAME [ARG]... 152336e956c5Smrg# --------------------------------- 152436e956c5Smrg# Run all hook functions registered to FUNC_NAME. 152536e956c5Smrg# It is assumed that the list of hook functions contains nothing more 152636e956c5Smrg# than a whitespace-delimited list of legal shell function names, and 152736e956c5Smrg# no effort is wasted trying to catch shell meta-characters or preserve 152836e956c5Smrg# whitespace. 152936e956c5Smrgfunc_run_hooks () 153036e956c5Smrg{ 153136e956c5Smrg $debug_cmd 153236e956c5Smrg 153336e956c5Smrg case " $hookable_fns " in 153436e956c5Smrg *" $1 "*) ;; 153536e956c5Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153636e956c5Smrg esac 153736e956c5Smrg 153836e956c5Smrg eval _G_hook_fns=\$$1_hooks; shift 153936e956c5Smrg 154036e956c5Smrg for _G_hook in $_G_hook_fns; do 154136e956c5Smrg eval $_G_hook '"$@"' 154236e956c5Smrg 154336e956c5Smrg # store returned options list back into positional 154436e956c5Smrg # parameters for next 'cmd' execution. 154536e956c5Smrg eval _G_hook_result=\$${_G_hook}_result 154636e956c5Smrg eval set dummy "$_G_hook_result"; shift 154736e956c5Smrg done 154836e956c5Smrg 154936e956c5Smrg func_quote_for_eval ${1+"$@"} 155036e956c5Smrg func_run_hooks_result=$func_quote_for_eval_result 155136e956c5Smrg} 155236e956c5Smrg 155336e956c5Smrg 155436e956c5Smrg 155536e956c5Smrg## --------------- ## 155636e956c5Smrg## Option parsing. ## 155736e956c5Smrg## --------------- ## 155836e956c5Smrg 155936e956c5Smrg# In order to add your own option parsing hooks, you must accept the 156036e956c5Smrg# full positional parameter list in your hook function, remove any 156136e956c5Smrg# options that you action, and then pass back the remaining unprocessed 156236e956c5Smrg# options in '<hooked_function_name>_result', escaped suitably for 156336e956c5Smrg# 'eval'. Like this: 156436e956c5Smrg# 156536e956c5Smrg# my_options_prep () 156636e956c5Smrg# { 156736e956c5Smrg# $debug_cmd 156836e956c5Smrg# 156936e956c5Smrg# # Extend the existing usage message. 157036e956c5Smrg# usage_message=$usage_message' 157136e956c5Smrg# -s, --silent don'\''t print informational messages 157236e956c5Smrg# ' 157336e956c5Smrg# 157436e956c5Smrg# func_quote_for_eval ${1+"$@"} 157536e956c5Smrg# my_options_prep_result=$func_quote_for_eval_result 157636e956c5Smrg# } 157736e956c5Smrg# func_add_hook func_options_prep my_options_prep 157836e956c5Smrg# 157936e956c5Smrg# 158036e956c5Smrg# my_silent_option () 158136e956c5Smrg# { 158236e956c5Smrg# $debug_cmd 158336e956c5Smrg# 158436e956c5Smrg# # Note that for efficiency, we parse as many options as we can 158536e956c5Smrg# # recognise in a loop before passing the remainder back to the 158636e956c5Smrg# # caller on the first unrecognised argument we encounter. 158736e956c5Smrg# while test $# -gt 0; do 158836e956c5Smrg# opt=$1; shift 158936e956c5Smrg# case $opt in 159036e956c5Smrg# --silent|-s) opt_silent=: ;; 159136e956c5Smrg# # Separate non-argument short options: 159236e956c5Smrg# -s*) func_split_short_opt "$_G_opt" 159336e956c5Smrg# set dummy "$func_split_short_opt_name" \ 159436e956c5Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 159536e956c5Smrg# shift 159636e956c5Smrg# ;; 159736e956c5Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159836e956c5Smrg# esac 159936e956c5Smrg# done 160036e956c5Smrg# 160136e956c5Smrg# func_quote_for_eval ${1+"$@"} 160236e956c5Smrg# my_silent_option_result=$func_quote_for_eval_result 160336e956c5Smrg# } 160436e956c5Smrg# func_add_hook func_parse_options my_silent_option 160536e956c5Smrg# 160636e956c5Smrg# 160736e956c5Smrg# my_option_validation () 160836e956c5Smrg# { 160936e956c5Smrg# $debug_cmd 161036e956c5Smrg# 161136e956c5Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161236e956c5Smrg# '--silent' and '--verbose' options are mutually exclusive." 161336e956c5Smrg# 161436e956c5Smrg# func_quote_for_eval ${1+"$@"} 161536e956c5Smrg# my_option_validation_result=$func_quote_for_eval_result 161636e956c5Smrg# } 161736e956c5Smrg# func_add_hook func_validate_options my_option_validation 161836e956c5Smrg# 161936e956c5Smrg# You'll alse need to manually amend $usage_message to reflect the extra 162036e956c5Smrg# options you parse. It's preferable to append if you can, so that 162136e956c5Smrg# multiple option parsing hooks can be added safely. 162236e956c5Smrg 162336e956c5Smrg 162436e956c5Smrg# func_options [ARG]... 162536e956c5Smrg# --------------------- 162636e956c5Smrg# All the functions called inside func_options are hookable. See the 162736e956c5Smrg# individual implementations for details. 162836e956c5Smrgfunc_hookable func_options 162936e956c5Smrgfunc_options () 163017a48c7cSmrg{ 163136e956c5Smrg $debug_cmd 163217a48c7cSmrg 163336e956c5Smrg func_options_prep ${1+"$@"} 163436e956c5Smrg eval func_parse_options \ 163536e956c5Smrg ${func_options_prep_result+"$func_options_prep_result"} 163636e956c5Smrg eval func_validate_options \ 163736e956c5Smrg ${func_parse_options_result+"$func_parse_options_result"} 16385f5b92ffSmrg 163936e956c5Smrg eval func_run_hooks func_options \ 164036e956c5Smrg ${func_validate_options_result+"$func_validate_options_result"} 164136e956c5Smrg 164236e956c5Smrg # save modified positional parameters for caller 164336e956c5Smrg func_options_result=$func_run_hooks_result 164417a48c7cSmrg} 164517a48c7cSmrg 16465f5b92ffSmrg 164736e956c5Smrg# func_options_prep [ARG]... 164836e956c5Smrg# -------------------------- 164936e956c5Smrg# All initialisations required before starting the option parse loop. 165036e956c5Smrg# Note that when calling hook functions, we pass through the list of 165136e956c5Smrg# positional parameters. If a hook function modifies that list, and 165236e956c5Smrg# needs to propogate that back to rest of this script, then the complete 165336e956c5Smrg# modified list must be put in 'func_run_hooks_result' before 165436e956c5Smrg# returning. 165536e956c5Smrgfunc_hookable func_options_prep 165636e956c5Smrgfunc_options_prep () 165717a48c7cSmrg{ 165836e956c5Smrg $debug_cmd 16595f5b92ffSmrg 166036e956c5Smrg # Option defaults: 166136e956c5Smrg opt_verbose=false 166236e956c5Smrg opt_warning_types= 16635f5b92ffSmrg 166436e956c5Smrg func_run_hooks func_options_prep ${1+"$@"} 166536e956c5Smrg 166636e956c5Smrg # save modified positional parameters for caller 166736e956c5Smrg func_options_prep_result=$func_run_hooks_result 16685f5b92ffSmrg} 166917a48c7cSmrg 167036e956c5Smrg 167136e956c5Smrg# func_parse_options [ARG]... 167236e956c5Smrg# --------------------------- 167336e956c5Smrg# The main option parsing loop. 167436e956c5Smrgfunc_hookable func_parse_options 167536e956c5Smrgfunc_parse_options () 16760dd80ee0Smrg{ 167736e956c5Smrg $debug_cmd 167836e956c5Smrg 167936e956c5Smrg func_parse_options_result= 168036e956c5Smrg 168136e956c5Smrg # this just eases exit handling 168236e956c5Smrg while test $# -gt 0; do 168336e956c5Smrg # Defer to hook functions for initial option parsing, so they 168436e956c5Smrg # get priority in the event of reusing an option name. 168536e956c5Smrg func_run_hooks func_parse_options ${1+"$@"} 168636e956c5Smrg 168736e956c5Smrg # Adjust func_parse_options positional parameters to match 168836e956c5Smrg eval set dummy "$func_run_hooks_result"; shift 168936e956c5Smrg 169036e956c5Smrg # Break out of the loop if we already parsed every option. 169136e956c5Smrg test $# -gt 0 || break 169236e956c5Smrg 169336e956c5Smrg _G_opt=$1 169436e956c5Smrg shift 169536e956c5Smrg case $_G_opt in 169636e956c5Smrg --debug|-x) debug_cmd='set -x' 169736e956c5Smrg func_echo "enabling shell trace mode" 169836e956c5Smrg $debug_cmd 169936e956c5Smrg ;; 170036e956c5Smrg 170136e956c5Smrg --no-warnings|--no-warning|--no-warn) 170236e956c5Smrg set dummy --warnings none ${1+"$@"} 170336e956c5Smrg shift 170436e956c5Smrg ;; 170536e956c5Smrg 170636e956c5Smrg --warnings|--warning|-W) 170736e956c5Smrg test $# = 0 && func_missing_arg $_G_opt && break 170836e956c5Smrg case " $warning_categories $1" in 170936e956c5Smrg *" $1 "*) 171036e956c5Smrg # trailing space prevents matching last $1 above 171136e956c5Smrg func_append_uniq opt_warning_types " $1" 171236e956c5Smrg ;; 171336e956c5Smrg *all) 171436e956c5Smrg opt_warning_types=$warning_categories 171536e956c5Smrg ;; 171636e956c5Smrg *none) 171736e956c5Smrg opt_warning_types=none 171836e956c5Smrg warning_func=: 171936e956c5Smrg ;; 172036e956c5Smrg *error) 172136e956c5Smrg opt_warning_types=$warning_categories 172236e956c5Smrg warning_func=func_fatal_error 172336e956c5Smrg ;; 172436e956c5Smrg *) 172536e956c5Smrg func_fatal_error \ 172636e956c5Smrg "unsupported warning category: '$1'" 172736e956c5Smrg ;; 172836e956c5Smrg esac 172936e956c5Smrg shift 173036e956c5Smrg ;; 173136e956c5Smrg 173236e956c5Smrg --verbose|-v) opt_verbose=: ;; 173336e956c5Smrg --version) func_version ;; 173436e956c5Smrg -\?|-h) func_usage ;; 173536e956c5Smrg --help) func_help ;; 173636e956c5Smrg 173736e956c5Smrg # Separate optargs to long options (plugins may need this): 173836e956c5Smrg --*=*) func_split_equals "$_G_opt" 173936e956c5Smrg set dummy "$func_split_equals_lhs" \ 174036e956c5Smrg "$func_split_equals_rhs" ${1+"$@"} 174136e956c5Smrg shift 174236e956c5Smrg ;; 174336e956c5Smrg 174436e956c5Smrg # Separate optargs to short options: 174536e956c5Smrg -W*) 174636e956c5Smrg func_split_short_opt "$_G_opt" 174736e956c5Smrg set dummy "$func_split_short_opt_name" \ 174836e956c5Smrg "$func_split_short_opt_arg" ${1+"$@"} 174936e956c5Smrg shift 175036e956c5Smrg ;; 175136e956c5Smrg 175236e956c5Smrg # Separate non-argument short options: 175336e956c5Smrg -\?*|-h*|-v*|-x*) 175436e956c5Smrg func_split_short_opt "$_G_opt" 175536e956c5Smrg set dummy "$func_split_short_opt_name" \ 175636e956c5Smrg "-$func_split_short_opt_arg" ${1+"$@"} 175736e956c5Smrg shift 175836e956c5Smrg ;; 175936e956c5Smrg 176036e956c5Smrg --) break ;; 176136e956c5Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176236e956c5Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176336e956c5Smrg esac 176436e956c5Smrg done 176536e956c5Smrg 176636e956c5Smrg # save modified positional parameters for caller 176736e956c5Smrg func_quote_for_eval ${1+"$@"} 176836e956c5Smrg func_parse_options_result=$func_quote_for_eval_result 17690dd80ee0Smrg} 17705f5b92ffSmrg 17715f5b92ffSmrg 177236e956c5Smrg# func_validate_options [ARG]... 177336e956c5Smrg# ------------------------------ 177436e956c5Smrg# Perform any sanity checks on option settings and/or unconsumed 177536e956c5Smrg# arguments. 177636e956c5Smrgfunc_hookable func_validate_options 177736e956c5Smrgfunc_validate_options () 17785f5b92ffSmrg{ 177936e956c5Smrg $debug_cmd 17800dd80ee0Smrg 178136e956c5Smrg # Display all warnings if -W was not given. 178236e956c5Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 178336e956c5Smrg 178436e956c5Smrg func_run_hooks func_validate_options ${1+"$@"} 178536e956c5Smrg 178636e956c5Smrg # Bail if the options were screwed! 178736e956c5Smrg $exit_cmd $EXIT_FAILURE 178836e956c5Smrg 178936e956c5Smrg # save modified positional parameters for caller 179036e956c5Smrg func_validate_options_result=$func_run_hooks_result 17915f5b92ffSmrg} 17925f5b92ffSmrg 179336e956c5Smrg 179436e956c5Smrg 179536e956c5Smrg## ----------------- ## 179636e956c5Smrg## Helper functions. ## 179736e956c5Smrg## ----------------- ## 179836e956c5Smrg 179936e956c5Smrg# This section contains the helper functions used by the rest of the 180036e956c5Smrg# hookable option parser framework in ascii-betical order. 180136e956c5Smrg 180236e956c5Smrg 180336e956c5Smrg# func_fatal_help ARG... 180436e956c5Smrg# ---------------------- 180536e956c5Smrg# Echo program name prefixed message to standard error, followed by 180636e956c5Smrg# a help hint, and exit. 180736e956c5Smrgfunc_fatal_help () 18085f5b92ffSmrg{ 180936e956c5Smrg $debug_cmd 18100dd80ee0Smrg 181136e956c5Smrg eval \$ECHO \""Usage: $usage"\" 181236e956c5Smrg eval \$ECHO \""$fatal_help"\" 181336e956c5Smrg func_error ${1+"$@"} 181436e956c5Smrg exit $EXIT_FAILURE 18155f5b92ffSmrg} 18165f5b92ffSmrg 181736e956c5Smrg 181836e956c5Smrg# func_help 181936e956c5Smrg# --------- 182036e956c5Smrg# Echo long help message to standard output and exit. 18215f5b92ffSmrgfunc_help () 18225f5b92ffSmrg{ 182336e956c5Smrg $debug_cmd 182436e956c5Smrg 182536e956c5Smrg func_usage_message 182636e956c5Smrg $ECHO "$long_help_message" 182736e956c5Smrg exit 0 18285f5b92ffSmrg} 18295f5b92ffSmrg 183036e956c5Smrg 183136e956c5Smrg# func_missing_arg ARGNAME 183236e956c5Smrg# ------------------------ 18335f5b92ffSmrg# Echo program name prefixed message to standard error and set global 18345f5b92ffSmrg# exit_cmd. 18355f5b92ffSmrgfunc_missing_arg () 18365f5b92ffSmrg{ 183736e956c5Smrg $debug_cmd 18380dd80ee0Smrg 183936e956c5Smrg func_error "Missing argument for '$1'." 18405f5b92ffSmrg exit_cmd=exit 184117a48c7cSmrg} 184217a48c7cSmrg 184317a48c7cSmrg 184436e956c5Smrg# func_split_equals STRING 184536e956c5Smrg# ------------------------ 184636e956c5Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184736e956c5Smrg# splitting STRING at the '=' sign. 184836e956c5Smrgtest -z "$_G_HAVE_XSI_OPS" \ 184936e956c5Smrg && (eval 'x=a/b/c; 185036e956c5Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185136e956c5Smrg && _G_HAVE_XSI_OPS=yes 185236e956c5Smrg 185336e956c5Smrgif test yes = "$_G_HAVE_XSI_OPS" 185436e956c5Smrgthen 185536e956c5Smrg # This is an XSI compatible shell, allowing a faster implementation... 185636e956c5Smrg eval 'func_split_equals () 185736e956c5Smrg { 185836e956c5Smrg $debug_cmd 185936e956c5Smrg 186036e956c5Smrg func_split_equals_lhs=${1%%=*} 186136e956c5Smrg func_split_equals_rhs=${1#*=} 186236e956c5Smrg test "x$func_split_equals_lhs" = "x$1" \ 186336e956c5Smrg && func_split_equals_rhs= 186436e956c5Smrg }' 186536e956c5Smrgelse 186636e956c5Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 186736e956c5Smrg func_split_equals () 186836e956c5Smrg { 186936e956c5Smrg $debug_cmd 187036e956c5Smrg 187136e956c5Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187236e956c5Smrg func_split_equals_rhs= 187336e956c5Smrg test "x$func_split_equals_lhs" = "x$1" \ 187436e956c5Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187536e956c5Smrg } 187636e956c5Smrgfi #func_split_equals 187736e956c5Smrg 187836e956c5Smrg 187936e956c5Smrg# func_split_short_opt SHORTOPT 188036e956c5Smrg# ----------------------------- 18810dd80ee0Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 18820dd80ee0Smrg# variables after splitting SHORTOPT after the 2nd character. 188336e956c5Smrgif test yes = "$_G_HAVE_XSI_OPS" 188436e956c5Smrgthen 188536e956c5Smrg # This is an XSI compatible shell, allowing a faster implementation... 188636e956c5Smrg eval 'func_split_short_opt () 188736e956c5Smrg { 188836e956c5Smrg $debug_cmd 188936e956c5Smrg 189036e956c5Smrg func_split_short_opt_arg=${1#??} 189136e956c5Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189236e956c5Smrg }' 189336e956c5Smrgelse 189436e956c5Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 189536e956c5Smrg func_split_short_opt () 189636e956c5Smrg { 189736e956c5Smrg $debug_cmd 189836e956c5Smrg 189936e956c5Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190036e956c5Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190136e956c5Smrg } 190236e956c5Smrgfi #func_split_short_opt 190336e956c5Smrg 190436e956c5Smrg 190536e956c5Smrg# func_usage 190636e956c5Smrg# ---------- 190736e956c5Smrg# Echo short help message to standard output and exit. 190836e956c5Smrgfunc_usage () 19090dd80ee0Smrg{ 191036e956c5Smrg $debug_cmd 191117a48c7cSmrg 191236e956c5Smrg func_usage_message 191336e956c5Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191436e956c5Smrg exit 0 191536e956c5Smrg} 19160dd80ee0Smrg 19170dd80ee0Smrg 191836e956c5Smrg# func_usage_message 191936e956c5Smrg# ------------------ 192036e956c5Smrg# Echo short help message to standard output. 192136e956c5Smrgfunc_usage_message () 19220dd80ee0Smrg{ 192336e956c5Smrg $debug_cmd 19240dd80ee0Smrg 192536e956c5Smrg eval \$ECHO \""Usage: $usage"\" 192636e956c5Smrg echo 192736e956c5Smrg $SED -n 's|^# || 192836e956c5Smrg /^Written by/{ 192936e956c5Smrg x;p;x 193036e956c5Smrg } 193136e956c5Smrg h 193236e956c5Smrg /^Written by/q' < "$progpath" 193336e956c5Smrg echo 193436e956c5Smrg eval \$ECHO \""$usage_message"\" 193536e956c5Smrg} 19360dd80ee0Smrg 19375f5b92ffSmrg 193836e956c5Smrg# func_version 193936e956c5Smrg# ------------ 194036e956c5Smrg# Echo version message to standard output and exit. 194136e956c5Smrgfunc_version () 194236e956c5Smrg{ 194336e956c5Smrg $debug_cmd 19445f5b92ffSmrg 194536e956c5Smrg printf '%s\n' "$progname $scriptversion" 194636e956c5Smrg $SED -n ' 194736e956c5Smrg /(C)/!b go 194836e956c5Smrg :more 194936e956c5Smrg /\./!{ 195036e956c5Smrg N 195136e956c5Smrg s|\n# | | 195236e956c5Smrg b more 195336e956c5Smrg } 195436e956c5Smrg :go 195536e956c5Smrg /^# Written by /,/# warranty; / { 195636e956c5Smrg s|^# || 195736e956c5Smrg s|^# *$|| 195836e956c5Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195936e956c5Smrg p 196036e956c5Smrg } 196136e956c5Smrg /^# Written by / { 196236e956c5Smrg s|^# || 196336e956c5Smrg p 196436e956c5Smrg } 196536e956c5Smrg /^warranty; /q' < "$progpath" 19665f5b92ffSmrg 196736e956c5Smrg exit $? 196836e956c5Smrg} 196917a48c7cSmrg 197017a48c7cSmrg 197136e956c5Smrg# Local variables: 197236e956c5Smrg# mode: shell-script 197336e956c5Smrg# sh-indentation: 2 197436e956c5Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 197536e956c5Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197636e956c5Smrg# time-stamp-time-zone: "UTC" 197736e956c5Smrg# End: 197817a48c7cSmrg 197936e956c5Smrg# Set a version string. 198036e956c5Smrgscriptversion='(GNU libtool) 2.4.6' 198117a48c7cSmrg 19825f5b92ffSmrg 198336e956c5Smrg# func_echo ARG... 198436e956c5Smrg# ---------------- 198536e956c5Smrg# Libtool also displays the current mode in messages, so override 198636e956c5Smrg# funclib.sh func_echo with this custom definition. 198736e956c5Smrgfunc_echo () 19880dd80ee0Smrg{ 198936e956c5Smrg $debug_cmd 19900dd80ee0Smrg 199136e956c5Smrg _G_message=$* 199236e956c5Smrg 199336e956c5Smrg func_echo_IFS=$IFS 199436e956c5Smrg IFS=$nl 199536e956c5Smrg for _G_line in $_G_message; do 199636e956c5Smrg IFS=$func_echo_IFS 199736e956c5Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199836e956c5Smrg done 199936e956c5Smrg IFS=$func_echo_IFS 200036e956c5Smrg} 20010dd80ee0Smrg 20020dd80ee0Smrg 200336e956c5Smrg# func_warning ARG... 200436e956c5Smrg# ------------------- 200536e956c5Smrg# Libtool warnings are not categorized, so override funclib.sh 200636e956c5Smrg# func_warning with this simpler definition. 200736e956c5Smrgfunc_warning () 20080dd80ee0Smrg{ 200936e956c5Smrg $debug_cmd 201036e956c5Smrg 201136e956c5Smrg $warning_func ${1+"$@"} 201236e956c5Smrg} 201336e956c5Smrg 20140dd80ee0Smrg 201536e956c5Smrg## ---------------- ## 201636e956c5Smrg## Options parsing. ## 201736e956c5Smrg## ---------------- ## 201836e956c5Smrg 201936e956c5Smrg# Hook in the functions to make sure our own options are parsed during 202036e956c5Smrg# the option parsing loop. 202136e956c5Smrg 202236e956c5Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 202336e956c5Smrg 202436e956c5Smrg# Short help message in response to '-h'. 202536e956c5Smrgusage_message="Options: 202636e956c5Smrg --config show all configuration variables 202736e956c5Smrg --debug enable verbose shell tracing 202836e956c5Smrg -n, --dry-run display commands without modifying any files 202936e956c5Smrg --features display basic configuration information and exit 203036e956c5Smrg --mode=MODE use operation mode MODE 203136e956c5Smrg --no-warnings equivalent to '-Wnone' 203236e956c5Smrg --preserve-dup-deps don't remove duplicate dependency libraries 203336e956c5Smrg --quiet, --silent don't print informational messages 203436e956c5Smrg --tag=TAG use configuration variables from tag TAG 203536e956c5Smrg -v, --verbose print more informational messages than default 203636e956c5Smrg --version print version information 203736e956c5Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203836e956c5Smrg -h, --help, --help-all print short, long, or detailed help message 203936e956c5Smrg" 20400dd80ee0Smrg 204136e956c5Smrg# Additional text appended to 'usage_message' in response to '--help'. 204236e956c5Smrgfunc_help () 20430dd80ee0Smrg{ 204436e956c5Smrg $debug_cmd 204536e956c5Smrg 204636e956c5Smrg func_usage_message 204736e956c5Smrg $ECHO "$long_help_message 204836e956c5Smrg 204936e956c5SmrgMODE must be one of the following: 205036e956c5Smrg 205136e956c5Smrg clean remove files from the build directory 205236e956c5Smrg compile compile a source file into a libtool object 205336e956c5Smrg execute automatically set library path, then run a program 205436e956c5Smrg finish complete the installation of libtool libraries 205536e956c5Smrg install install libraries or executables 205636e956c5Smrg link create a library or an executable 205736e956c5Smrg uninstall remove libraries from an installed directory 205836e956c5Smrg 205936e956c5SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206036e956c5Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206136e956c5SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206236e956c5Smrg 206336e956c5SmrgWhen reporting a bug, please describe a test case to reproduce it and 206436e956c5Smrginclude the following information: 206536e956c5Smrg 206636e956c5Smrg host-triplet: $host 206736e956c5Smrg shell: $SHELL 206836e956c5Smrg compiler: $LTCC 206936e956c5Smrg compiler flags: $LTCFLAGS 207036e956c5Smrg linker: $LD (gnu? $with_gnu_ld) 207136e956c5Smrg version: $progname (GNU libtool) 2.4.6 207236e956c5Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207336e956c5Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207436e956c5Smrg 207536e956c5SmrgReport bugs to <bug-libtool@gnu.org>. 207636e956c5SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 207736e956c5SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207836e956c5Smrg exit 0 207936e956c5Smrg} 20800dd80ee0Smrg 20810dd80ee0Smrg 208236e956c5Smrg# func_lo2o OBJECT-NAME 208336e956c5Smrg# --------------------- 208436e956c5Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208536e956c5Smrg# object suffix. 20860dd80ee0Smrg 208736e956c5Smrglo2o=s/\\.lo\$/.$objext/ 208836e956c5Smrgo2lo=s/\\.$objext\$/.lo/ 20890dd80ee0Smrg 209036e956c5Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 209136e956c5Smrg eval 'func_lo2o () 209236e956c5Smrg { 209336e956c5Smrg case $1 in 209436e956c5Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209536e956c5Smrg * ) func_lo2o_result=$1 ;; 209636e956c5Smrg esac 209736e956c5Smrg }' 209836e956c5Smrg 209936e956c5Smrg # func_xform LIBOBJ-OR-SOURCE 210036e956c5Smrg # --------------------------- 210136e956c5Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210236e956c5Smrg # suffix to a '.lo' libtool-object suffix. 210336e956c5Smrg eval 'func_xform () 210436e956c5Smrg { 210536e956c5Smrg func_xform_result=${1%.*}.lo 210636e956c5Smrg }' 210736e956c5Smrgelse 210836e956c5Smrg # ...otherwise fall back to using sed. 210936e956c5Smrg func_lo2o () 211036e956c5Smrg { 211136e956c5Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211236e956c5Smrg } 211336e956c5Smrg 211436e956c5Smrg func_xform () 211536e956c5Smrg { 211636e956c5Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211736e956c5Smrg } 211836e956c5Smrgfi 21190dd80ee0Smrg 21200dd80ee0Smrg 212136e956c5Smrg# func_fatal_configuration ARG... 212236e956c5Smrg# ------------------------------- 21235f5b92ffSmrg# Echo program name prefixed message to standard error, followed by 21245f5b92ffSmrg# a configuration failure hint, and exit. 21255f5b92ffSmrgfunc_fatal_configuration () 21265f5b92ffSmrg{ 212736e956c5Smrg func__fatal_error ${1+"$@"} \ 212836e956c5Smrg "See the $PACKAGE documentation for more information." \ 212936e956c5Smrg "Fatal configuration error." 21305f5b92ffSmrg} 213117a48c7cSmrg 2132fbed5abfSmrg 21335f5b92ffSmrg# func_config 213436e956c5Smrg# ----------- 21355f5b92ffSmrg# Display the configuration for all the tags in this script. 21365f5b92ffSmrgfunc_config () 21375f5b92ffSmrg{ 21385f5b92ffSmrg re_begincf='^# ### BEGIN LIBTOOL' 21395f5b92ffSmrg re_endcf='^# ### END LIBTOOL' 21405f5b92ffSmrg 21415f5b92ffSmrg # Default configuration. 21425f5b92ffSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 214317a48c7cSmrg 214417a48c7cSmrg # Now print the configurations for the tags. 214517a48c7cSmrg for tagname in $taglist; do 21465f5b92ffSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 214717a48c7cSmrg done 214817a48c7cSmrg 21495f5b92ffSmrg exit $? 21505f5b92ffSmrg} 215117a48c7cSmrg 215236e956c5Smrg 21535f5b92ffSmrg# func_features 215436e956c5Smrg# ------------- 21555f5b92ffSmrg# Display the features supported by this script. 21565f5b92ffSmrgfunc_features () 21575f5b92ffSmrg{ 21580dd80ee0Smrg echo "host: $host" 215936e956c5Smrg if test yes = "$build_libtool_libs"; then 21600dd80ee0Smrg echo "enable shared libraries" 216117a48c7cSmrg else 21620dd80ee0Smrg echo "disable shared libraries" 216317a48c7cSmrg fi 216436e956c5Smrg if test yes = "$build_old_libs"; then 21650dd80ee0Smrg echo "enable static libraries" 216617a48c7cSmrg else 21670dd80ee0Smrg echo "disable static libraries" 216817a48c7cSmrg fi 21695f5b92ffSmrg 217017a48c7cSmrg exit $? 21715f5b92ffSmrg} 217217a48c7cSmrg 217336e956c5Smrg 217436e956c5Smrg# func_enable_tag TAGNAME 217536e956c5Smrg# ----------------------- 21765f5b92ffSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 21775f5b92ffSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 21785f5b92ffSmrg# variable here. 21795f5b92ffSmrgfunc_enable_tag () 21805f5b92ffSmrg{ 218136e956c5Smrg # Global variable: 218236e956c5Smrg tagname=$1 218317a48c7cSmrg 218436e956c5Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218536e956c5Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218636e956c5Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 218717a48c7cSmrg 218836e956c5Smrg # Validate tagname. 218936e956c5Smrg case $tagname in 219036e956c5Smrg *[!-_A-Za-z0-9,/]*) 219136e956c5Smrg func_fatal_error "invalid tag name: $tagname" 219236e956c5Smrg ;; 219336e956c5Smrg esac 219417a48c7cSmrg 219536e956c5Smrg # Don't test for the "default" C tag, as we know it's 219636e956c5Smrg # there but not specially marked. 219736e956c5Smrg case $tagname in 219836e956c5Smrg CC) ;; 21995f5b92ffSmrg *) 220036e956c5Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220136e956c5Smrg taglist="$taglist $tagname" 220236e956c5Smrg 220336e956c5Smrg # Evaluate the configuration. Be careful to quote the path 220436e956c5Smrg # and the sed script, to avoid splitting on whitespace, but 220536e956c5Smrg # also don't use non-portable quotes within backquotes within 220636e956c5Smrg # quotes we have to do it in 2 steps: 220736e956c5Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220836e956c5Smrg eval "$extractedcf" 220936e956c5Smrg else 221036e956c5Smrg func_error "ignoring unknown tag $tagname" 221136e956c5Smrg fi 221236e956c5Smrg ;; 221336e956c5Smrg esac 22145f5b92ffSmrg} 22155f5b92ffSmrg 221636e956c5Smrg 22170dd80ee0Smrg# func_check_version_match 221836e956c5Smrg# ------------------------ 22190dd80ee0Smrg# Ensure that we are using m4 macros, and libtool script from the same 22200dd80ee0Smrg# release of libtool. 22210dd80ee0Smrgfunc_check_version_match () 22225f5b92ffSmrg{ 222336e956c5Smrg if test "$package_revision" != "$macro_revision"; then 222436e956c5Smrg if test "$VERSION" != "$macro_version"; then 222536e956c5Smrg if test -z "$macro_version"; then 222636e956c5Smrg cat >&2 <<_LT_EOF 22270dd80ee0Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22280dd80ee0Smrg$progname: definition of this LT_INIT comes from an older release. 22290dd80ee0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22300dd80ee0Smrg$progname: and run autoconf again. 22310dd80ee0Smrg_LT_EOF 223236e956c5Smrg else 223336e956c5Smrg cat >&2 <<_LT_EOF 22340dd80ee0Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22350dd80ee0Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 22360dd80ee0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22370dd80ee0Smrg$progname: and run autoconf again. 22380dd80ee0Smrg_LT_EOF 223936e956c5Smrg fi 224036e956c5Smrg else 224136e956c5Smrg cat >&2 <<_LT_EOF 22420dd80ee0Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 22430dd80ee0Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 22440dd80ee0Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 22450dd80ee0Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 22460dd80ee0Smrg_LT_EOF 224736e956c5Smrg fi 22480dd80ee0Smrg 224936e956c5Smrg exit $EXIT_MISMATCH 225036e956c5Smrg fi 22510dd80ee0Smrg} 22520dd80ee0Smrg 22530dd80ee0Smrg 225436e956c5Smrg# libtool_options_prep [ARG]... 225536e956c5Smrg# ----------------------------- 225636e956c5Smrg# Preparation for options parsed by libtool. 225736e956c5Smrglibtool_options_prep () 225836e956c5Smrg{ 225936e956c5Smrg $debug_mode 22600dd80ee0Smrg 226136e956c5Smrg # Option defaults: 226236e956c5Smrg opt_config=false 226336e956c5Smrg opt_dlopen= 226436e956c5Smrg opt_dry_run=false 226536e956c5Smrg opt_help=false 226636e956c5Smrg opt_mode= 226736e956c5Smrg opt_preserve_dup_deps=false 226836e956c5Smrg opt_quiet=false 22690dd80ee0Smrg 227036e956c5Smrg nonopt= 227136e956c5Smrg preserve_args= 22720dd80ee0Smrg 227336e956c5Smrg # Shorthand for --mode=foo, only valid as the first argument 227436e956c5Smrg case $1 in 227536e956c5Smrg clean|clea|cle|cl) 227636e956c5Smrg shift; set dummy --mode clean ${1+"$@"}; shift 227736e956c5Smrg ;; 227836e956c5Smrg compile|compil|compi|comp|com|co|c) 227936e956c5Smrg shift; set dummy --mode compile ${1+"$@"}; shift 228036e956c5Smrg ;; 228136e956c5Smrg execute|execut|execu|exec|exe|ex|e) 228236e956c5Smrg shift; set dummy --mode execute ${1+"$@"}; shift 228336e956c5Smrg ;; 228436e956c5Smrg finish|finis|fini|fin|fi|f) 228536e956c5Smrg shift; set dummy --mode finish ${1+"$@"}; shift 228636e956c5Smrg ;; 228736e956c5Smrg install|instal|insta|inst|ins|in|i) 228836e956c5Smrg shift; set dummy --mode install ${1+"$@"}; shift 228936e956c5Smrg ;; 229036e956c5Smrg link|lin|li|l) 229136e956c5Smrg shift; set dummy --mode link ${1+"$@"}; shift 229236e956c5Smrg ;; 229336e956c5Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229436e956c5Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229536e956c5Smrg ;; 229636e956c5Smrg esac 229736e956c5Smrg 229836e956c5Smrg # Pass back the list of options. 229936e956c5Smrg func_quote_for_eval ${1+"$@"} 230036e956c5Smrg libtool_options_prep_result=$func_quote_for_eval_result 230136e956c5Smrg} 230236e956c5Smrgfunc_add_hook func_options_prep libtool_options_prep 230317a48c7cSmrg 230417a48c7cSmrg 230536e956c5Smrg# libtool_parse_options [ARG]... 230636e956c5Smrg# --------------------------------- 230736e956c5Smrg# Provide handling for libtool specific options. 230836e956c5Smrglibtool_parse_options () 23090dd80ee0Smrg{ 231036e956c5Smrg $debug_cmd 23115f5b92ffSmrg 231236e956c5Smrg # Perform our own loop to consume as many options as possible in 231336e956c5Smrg # each iteration. 231436e956c5Smrg while test $# -gt 0; do 231536e956c5Smrg _G_opt=$1 231636e956c5Smrg shift 231736e956c5Smrg case $_G_opt in 231836e956c5Smrg --dry-run|--dryrun|-n) 231936e956c5Smrg opt_dry_run=: 232036e956c5Smrg ;; 232136e956c5Smrg 232236e956c5Smrg --config) func_config ;; 232336e956c5Smrg 232436e956c5Smrg --dlopen|-dlopen) 232536e956c5Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 232636e956c5Smrg}$1" 232736e956c5Smrg shift 232836e956c5Smrg ;; 232936e956c5Smrg 233036e956c5Smrg --preserve-dup-deps) 233136e956c5Smrg opt_preserve_dup_deps=: ;; 233236e956c5Smrg 233336e956c5Smrg --features) func_features ;; 233436e956c5Smrg 233536e956c5Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233636e956c5Smrg 233736e956c5Smrg --help) opt_help=: ;; 233836e956c5Smrg 233936e956c5Smrg --help-all) opt_help=': help-all' ;; 234036e956c5Smrg 234136e956c5Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234236e956c5Smrg opt_mode=$1 234336e956c5Smrg case $1 in 234436e956c5Smrg # Valid mode arguments: 234536e956c5Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234636e956c5Smrg 234736e956c5Smrg # Catch anything else as an error 234836e956c5Smrg *) func_error "invalid argument for $_G_opt" 234936e956c5Smrg exit_cmd=exit 235036e956c5Smrg break 235136e956c5Smrg ;; 235236e956c5Smrg esac 235336e956c5Smrg shift 235436e956c5Smrg ;; 235536e956c5Smrg 235636e956c5Smrg --no-silent|--no-quiet) 235736e956c5Smrg opt_quiet=false 235836e956c5Smrg func_append preserve_args " $_G_opt" 235936e956c5Smrg ;; 236036e956c5Smrg 236136e956c5Smrg --no-warnings|--no-warning|--no-warn) 236236e956c5Smrg opt_warning=false 236336e956c5Smrg func_append preserve_args " $_G_opt" 236436e956c5Smrg ;; 236536e956c5Smrg 236636e956c5Smrg --no-verbose) 236736e956c5Smrg opt_verbose=false 236836e956c5Smrg func_append preserve_args " $_G_opt" 236936e956c5Smrg ;; 237036e956c5Smrg 237136e956c5Smrg --silent|--quiet) 237236e956c5Smrg opt_quiet=: 237336e956c5Smrg opt_verbose=false 237436e956c5Smrg func_append preserve_args " $_G_opt" 237536e956c5Smrg ;; 237636e956c5Smrg 237736e956c5Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237836e956c5Smrg opt_tag=$1 237936e956c5Smrg func_append preserve_args " $_G_opt $1" 238036e956c5Smrg func_enable_tag "$1" 238136e956c5Smrg shift 238236e956c5Smrg ;; 238336e956c5Smrg 238436e956c5Smrg --verbose|-v) opt_quiet=false 238536e956c5Smrg opt_verbose=: 238636e956c5Smrg func_append preserve_args " $_G_opt" 238736e956c5Smrg ;; 238836e956c5Smrg 238936e956c5Smrg # An option not handled by this hook function: 239036e956c5Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239136e956c5Smrg esac 239236e956c5Smrg done 23930dd80ee0Smrg 23940dd80ee0Smrg 239536e956c5Smrg # save modified positional parameters for caller 239636e956c5Smrg func_quote_for_eval ${1+"$@"} 239736e956c5Smrg libtool_parse_options_result=$func_quote_for_eval_result 239836e956c5Smrg} 239936e956c5Smrgfunc_add_hook func_parse_options libtool_parse_options 24005f5b92ffSmrg 240117a48c7cSmrg 24025f5b92ffSmrg 240336e956c5Smrg# libtool_validate_options [ARG]... 240436e956c5Smrg# --------------------------------- 240536e956c5Smrg# Perform any sanity checks on option settings and/or unconsumed 240636e956c5Smrg# arguments. 240736e956c5Smrglibtool_validate_options () 240836e956c5Smrg{ 240936e956c5Smrg # save first non-option argument 241036e956c5Smrg if test 0 -lt $#; then 241136e956c5Smrg nonopt=$1 241236e956c5Smrg shift 24135f5b92ffSmrg fi 24145f5b92ffSmrg 241536e956c5Smrg # preserve --debug 241636e956c5Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 24175f5b92ffSmrg 241836e956c5Smrg case $host in 241936e956c5Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242036e956c5Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242136e956c5Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242236e956c5Smrg # don't eliminate duplications in $postdeps and $predeps 242336e956c5Smrg opt_duplicate_compiler_generated_deps=: 242436e956c5Smrg ;; 242536e956c5Smrg *) 242636e956c5Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242736e956c5Smrg ;; 242836e956c5Smrg esac 242917a48c7cSmrg 243036e956c5Smrg $opt_help || { 243136e956c5Smrg # Sanity checks first: 243236e956c5Smrg func_check_version_match 24335f5b92ffSmrg 243436e956c5Smrg test yes != "$build_libtool_libs" \ 243536e956c5Smrg && test yes != "$build_old_libs" \ 243636e956c5Smrg && func_fatal_configuration "not configured to build any kind of library" 24375f5b92ffSmrg 243836e956c5Smrg # Darwin sucks 243936e956c5Smrg eval std_shrext=\"$shrext_cmds\" 244036e956c5Smrg 244136e956c5Smrg # Only execute mode is allowed to have -dlopen flags. 244236e956c5Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244336e956c5Smrg func_error "unrecognized option '-dlopen'" 244436e956c5Smrg $ECHO "$help" 1>&2 244536e956c5Smrg exit $EXIT_FAILURE 244636e956c5Smrg fi 244736e956c5Smrg 244836e956c5Smrg # Change the help message to a mode-specific one. 244936e956c5Smrg generic_help=$help 245036e956c5Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 245136e956c5Smrg } 245236e956c5Smrg 245336e956c5Smrg # Pass back the unparsed argument list 245436e956c5Smrg func_quote_for_eval ${1+"$@"} 245536e956c5Smrg libtool_validate_options_result=$func_quote_for_eval_result 24560dd80ee0Smrg} 245736e956c5Smrgfunc_add_hook func_validate_options libtool_validate_options 245836e956c5Smrg 24595f5b92ffSmrg 246036e956c5Smrg# Process options as early as possible so that --help and --version 246136e956c5Smrg# can return quickly. 246236e956c5Smrgfunc_options ${1+"$@"} 246336e956c5Smrgeval set dummy "$func_options_result"; shift 24645f5b92ffSmrg 246517a48c7cSmrg 246617a48c7cSmrg 24670dd80ee0Smrg## ----------- ## 24680dd80ee0Smrg## Main. ## 24690dd80ee0Smrg## ----------- ## 247017a48c7cSmrg 247136e956c5Smrgmagic='%%%MAGIC variable%%%' 247236e956c5Smrgmagic_exe='%%%MAGIC EXE variable%%%' 247336e956c5Smrg 247436e956c5Smrg# Global variables. 247536e956c5Smrgextracted_archives= 247636e956c5Smrgextracted_serial=0 247736e956c5Smrg 247836e956c5Smrg# If this variable is set in any of the actions, the command in it 247936e956c5Smrg# will be execed at the end. This prevents here-documents from being 248036e956c5Smrg# left over by shells. 248136e956c5Smrgexec_cmd= 248236e956c5Smrg 248336e956c5Smrg 248436e956c5Smrg# A function that is used when there is no print builtin or printf. 248536e956c5Smrgfunc_fallback_echo () 248636e956c5Smrg{ 248736e956c5Smrg eval 'cat <<_LTECHO_EOF 248836e956c5Smrg$1 248936e956c5Smrg_LTECHO_EOF' 249036e956c5Smrg} 249136e956c5Smrg 249236e956c5Smrg# func_generated_by_libtool 249336e956c5Smrg# True iff stdin has been generated by Libtool. This function is only 249436e956c5Smrg# a basic sanity check; it will hardly flush out determined imposters. 249536e956c5Smrgfunc_generated_by_libtool_p () 249636e956c5Smrg{ 249736e956c5Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249836e956c5Smrg} 249936e956c5Smrg 25005f5b92ffSmrg# func_lalib_p file 250136e956c5Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25025f5b92ffSmrg# This function is only a basic sanity check; it will hardly flush out 25035f5b92ffSmrg# determined imposters. 25045f5b92ffSmrgfunc_lalib_p () 25055f5b92ffSmrg{ 25065f5b92ffSmrg test -f "$1" && 250736e956c5Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 25085f5b92ffSmrg} 250917a48c7cSmrg 25105f5b92ffSmrg# func_lalib_unsafe_p file 251136e956c5Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25125f5b92ffSmrg# This function implements the same check as func_lalib_p without 25135f5b92ffSmrg# resorting to external programs. To this end, it redirects stdin and 25145f5b92ffSmrg# closes it afterwards, without saving the original file descriptor. 25155f5b92ffSmrg# As a safety measure, use it only where a negative result would be 251636e956c5Smrg# fatal anyway. Works if 'file' does not exist. 25175f5b92ffSmrgfunc_lalib_unsafe_p () 25185f5b92ffSmrg{ 25195f5b92ffSmrg lalib_p=no 25205f5b92ffSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 25215f5b92ffSmrg for lalib_p_l in 1 2 3 4 25225f5b92ffSmrg do 25235f5b92ffSmrg read lalib_p_line 252436e956c5Smrg case $lalib_p_line in 25255f5b92ffSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 25265f5b92ffSmrg esac 25275f5b92ffSmrg done 25285f5b92ffSmrg exec 0<&5 5<&- 25295f5b92ffSmrg fi 253036e956c5Smrg test yes = "$lalib_p" 25315f5b92ffSmrg} 253217a48c7cSmrg 25335f5b92ffSmrg# func_ltwrapper_script_p file 25345f5b92ffSmrg# True iff FILE is a libtool wrapper script 25355f5b92ffSmrg# This function is only a basic sanity check; it will hardly flush out 25365f5b92ffSmrg# determined imposters. 25375f5b92ffSmrgfunc_ltwrapper_script_p () 25385f5b92ffSmrg{ 253936e956c5Smrg test -f "$1" && 254036e956c5Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 25415f5b92ffSmrg} 254217a48c7cSmrg 25435f5b92ffSmrg# func_ltwrapper_executable_p file 25445f5b92ffSmrg# True iff FILE is a libtool wrapper executable 25455f5b92ffSmrg# This function is only a basic sanity check; it will hardly flush out 25465f5b92ffSmrg# determined imposters. 25475f5b92ffSmrgfunc_ltwrapper_executable_p () 25485f5b92ffSmrg{ 25495f5b92ffSmrg func_ltwrapper_exec_suffix= 25505f5b92ffSmrg case $1 in 25515f5b92ffSmrg *.exe) ;; 25525f5b92ffSmrg *) func_ltwrapper_exec_suffix=.exe ;; 25535f5b92ffSmrg esac 25545f5b92ffSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 25555f5b92ffSmrg} 255617a48c7cSmrg 25575f5b92ffSmrg# func_ltwrapper_scriptname file 25585f5b92ffSmrg# Assumes file is an ltwrapper_executable 25595f5b92ffSmrg# uses $file to determine the appropriate filename for a 25605f5b92ffSmrg# temporary ltwrapper_script. 25615f5b92ffSmrgfunc_ltwrapper_scriptname () 25625f5b92ffSmrg{ 25630dd80ee0Smrg func_dirname_and_basename "$1" "" "." 25640dd80ee0Smrg func_stripname '' '.exe' "$func_basename_result" 256536e956c5Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 25665f5b92ffSmrg} 25675f5b92ffSmrg 25685f5b92ffSmrg# func_ltwrapper_p file 25695f5b92ffSmrg# True iff FILE is a libtool wrapper script or wrapper executable 25705f5b92ffSmrg# This function is only a basic sanity check; it will hardly flush out 25715f5b92ffSmrg# determined imposters. 25725f5b92ffSmrgfunc_ltwrapper_p () 25735f5b92ffSmrg{ 25745f5b92ffSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 25755f5b92ffSmrg} 25765f5b92ffSmrg 25775f5b92ffSmrg 25785f5b92ffSmrg# func_execute_cmds commands fail_cmd 25795f5b92ffSmrg# Execute tilde-delimited COMMANDS. 25805f5b92ffSmrg# If FAIL_CMD is given, eval that upon failure. 25815f5b92ffSmrg# FAIL_CMD may read-access the current command in variable CMD! 25825f5b92ffSmrgfunc_execute_cmds () 25835f5b92ffSmrg{ 258436e956c5Smrg $debug_cmd 258536e956c5Smrg 25865f5b92ffSmrg save_ifs=$IFS; IFS='~' 25875f5b92ffSmrg for cmd in $1; do 258836e956c5Smrg IFS=$sp$nl 25895f5b92ffSmrg eval cmd=\"$cmd\" 259036e956c5Smrg IFS=$save_ifs 25915f5b92ffSmrg func_show_eval "$cmd" "${2-:}" 25925f5b92ffSmrg done 25935f5b92ffSmrg IFS=$save_ifs 25945f5b92ffSmrg} 25955f5b92ffSmrg 25965f5b92ffSmrg 25975f5b92ffSmrg# func_source file 25985f5b92ffSmrg# Source FILE, adding directory component if necessary. 25995f5b92ffSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 26005f5b92ffSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 26015f5b92ffSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260236e956c5Smrg# 'FILE.' does not work on cygwin managed mounts. 26035f5b92ffSmrgfunc_source () 26045f5b92ffSmrg{ 260536e956c5Smrg $debug_cmd 260636e956c5Smrg 26075f5b92ffSmrg case $1 in 26085f5b92ffSmrg */* | *\\*) . "$1" ;; 26095f5b92ffSmrg *) . "./$1" ;; 26105f5b92ffSmrg esac 26115f5b92ffSmrg} 26125f5b92ffSmrg 26135f5b92ffSmrg 26140dd80ee0Smrg# func_resolve_sysroot PATH 26150dd80ee0Smrg# Replace a leading = in PATH with a sysroot. Store the result into 26160dd80ee0Smrg# func_resolve_sysroot_result 26170dd80ee0Smrgfunc_resolve_sysroot () 26180dd80ee0Smrg{ 26190dd80ee0Smrg func_resolve_sysroot_result=$1 26200dd80ee0Smrg case $func_resolve_sysroot_result in 26210dd80ee0Smrg =*) 26220dd80ee0Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 26230dd80ee0Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 26240dd80ee0Smrg ;; 26250dd80ee0Smrg esac 26260dd80ee0Smrg} 26270dd80ee0Smrg 26280dd80ee0Smrg# func_replace_sysroot PATH 26290dd80ee0Smrg# If PATH begins with the sysroot, replace it with = and 26300dd80ee0Smrg# store the result into func_replace_sysroot_result. 26310dd80ee0Smrgfunc_replace_sysroot () 26320dd80ee0Smrg{ 263336e956c5Smrg case $lt_sysroot:$1 in 26340dd80ee0Smrg ?*:"$lt_sysroot"*) 26350dd80ee0Smrg func_stripname "$lt_sysroot" '' "$1" 263636e956c5Smrg func_replace_sysroot_result='='$func_stripname_result 26370dd80ee0Smrg ;; 26380dd80ee0Smrg *) 26390dd80ee0Smrg # Including no sysroot. 26400dd80ee0Smrg func_replace_sysroot_result=$1 26410dd80ee0Smrg ;; 26420dd80ee0Smrg esac 26430dd80ee0Smrg} 26440dd80ee0Smrg 26455f5b92ffSmrg# func_infer_tag arg 26465f5b92ffSmrg# Infer tagged configuration to use if any are available and 26475f5b92ffSmrg# if one wasn't chosen via the "--tag" command line option. 26485f5b92ffSmrg# Only attempt this if the compiler in the base compile 26495f5b92ffSmrg# command doesn't match the default compiler. 26505f5b92ffSmrg# arg is usually of the form 'gcc ...' 26515f5b92ffSmrgfunc_infer_tag () 26525f5b92ffSmrg{ 265336e956c5Smrg $debug_cmd 265436e956c5Smrg 26555f5b92ffSmrg if test -n "$available_tags" && test -z "$tagname"; then 26565f5b92ffSmrg CC_quoted= 26575f5b92ffSmrg for arg in $CC; do 26580dd80ee0Smrg func_append_quoted CC_quoted "$arg" 26595f5b92ffSmrg done 26600dd80ee0Smrg CC_expanded=`func_echo_all $CC` 26610dd80ee0Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26625f5b92ffSmrg case $@ in 26635f5b92ffSmrg # Blanks in the command may have been stripped by the calling shell, 26645f5b92ffSmrg # but not from the CC environment variable when configure was run. 26650dd80ee0Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26660dd80ee0Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 26675f5b92ffSmrg # Blanks at the start of $base_compile will cause this to fail 26685f5b92ffSmrg # if we don't check for them as well. 26695f5b92ffSmrg *) 26705f5b92ffSmrg for z in $available_tags; do 26715f5b92ffSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 26725f5b92ffSmrg # Evaluate the configuration. 267336e956c5Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 26745f5b92ffSmrg CC_quoted= 26755f5b92ffSmrg for arg in $CC; do 26765f5b92ffSmrg # Double-quote args containing other shell metacharacters. 26770dd80ee0Smrg func_append_quoted CC_quoted "$arg" 26785f5b92ffSmrg done 26790dd80ee0Smrg CC_expanded=`func_echo_all $CC` 26800dd80ee0Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26815f5b92ffSmrg case "$@ " in 26820dd80ee0Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26830dd80ee0Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 26845f5b92ffSmrg # The compiler in the base compile command matches 26855f5b92ffSmrg # the one in the tagged configuration. 26865f5b92ffSmrg # Assume this is the tagged configuration we want. 26875f5b92ffSmrg tagname=$z 26885f5b92ffSmrg break 26895f5b92ffSmrg ;; 26905f5b92ffSmrg esac 26915f5b92ffSmrg fi 26925f5b92ffSmrg done 26935f5b92ffSmrg # If $tagname still isn't set, then no tagged configuration 26945f5b92ffSmrg # was found and let the user know that the "--tag" command 26955f5b92ffSmrg # line option must be used. 26965f5b92ffSmrg if test -z "$tagname"; then 26975f5b92ffSmrg func_echo "unable to infer tagged configuration" 269836e956c5Smrg func_fatal_error "specify a tag with '--tag'" 26995f5b92ffSmrg# else 27005f5b92ffSmrg# func_verbose "using $tagname tagged configuration" 27015f5b92ffSmrg fi 27025f5b92ffSmrg ;; 27035f5b92ffSmrg esac 27045f5b92ffSmrg fi 27055f5b92ffSmrg} 27065f5b92ffSmrg 27075f5b92ffSmrg 27085f5b92ffSmrg 27095f5b92ffSmrg# func_write_libtool_object output_name pic_name nonpic_name 27105f5b92ffSmrg# Create a libtool object file (analogous to a ".la" file), 27115f5b92ffSmrg# but don't create it if we're doing a dry run. 27125f5b92ffSmrgfunc_write_libtool_object () 27135f5b92ffSmrg{ 271436e956c5Smrg write_libobj=$1 271536e956c5Smrg if test yes = "$build_libtool_libs"; then 271636e956c5Smrg write_lobj=\'$2\' 27175f5b92ffSmrg else 27185f5b92ffSmrg write_lobj=none 27195f5b92ffSmrg fi 27205f5b92ffSmrg 272136e956c5Smrg if test yes = "$build_old_libs"; then 272236e956c5Smrg write_oldobj=\'$3\' 27235f5b92ffSmrg else 27245f5b92ffSmrg write_oldobj=none 27255f5b92ffSmrg fi 27265f5b92ffSmrg 27275f5b92ffSmrg $opt_dry_run || { 27285f5b92ffSmrg cat >${write_libobj}T <<EOF 27295f5b92ffSmrg# $write_libobj - a libtool object file 273036e956c5Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 27315f5b92ffSmrg# 27325f5b92ffSmrg# Please DO NOT delete this file! 27335f5b92ffSmrg# It is necessary for linking the library. 27345f5b92ffSmrg 27355f5b92ffSmrg# Name of the PIC object. 27365f5b92ffSmrgpic_object=$write_lobj 27375f5b92ffSmrg 27385f5b92ffSmrg# Name of the non-PIC object 27395f5b92ffSmrgnon_pic_object=$write_oldobj 27405f5b92ffSmrg 27415f5b92ffSmrgEOF 274236e956c5Smrg $MV "${write_libobj}T" "$write_libobj" 27435f5b92ffSmrg } 27445f5b92ffSmrg} 27455f5b92ffSmrg 27460dd80ee0Smrg 27470dd80ee0Smrg################################################## 27480dd80ee0Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 27490dd80ee0Smrg################################################## 27500dd80ee0Smrg 27510dd80ee0Smrg# func_convert_core_file_wine_to_w32 ARG 27520dd80ee0Smrg# Helper function used by file name conversion functions when $build is *nix, 27530dd80ee0Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 27540dd80ee0Smrg# correctly configured wine environment available, with the winepath program 27550dd80ee0Smrg# in $build's $PATH. 27560dd80ee0Smrg# 27570dd80ee0Smrg# ARG is the $build file name to be converted to w32 format. 27580dd80ee0Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 27590dd80ee0Smrg# be empty on error (or when ARG is empty) 27600dd80ee0Smrgfunc_convert_core_file_wine_to_w32 () 27610dd80ee0Smrg{ 276236e956c5Smrg $debug_cmd 276336e956c5Smrg 276436e956c5Smrg func_convert_core_file_wine_to_w32_result=$1 27650dd80ee0Smrg if test -n "$1"; then 27660dd80ee0Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 27670dd80ee0Smrg # are forced to check the contents of stdout. On the other hand, if the 27680dd80ee0Smrg # command is not found, the shell will set an exit code of 127 and print 27690dd80ee0Smrg # *an error message* to stdout. So we must check for both error code of 27700dd80ee0Smrg # zero AND non-empty stdout, which explains the odd construction: 27710dd80ee0Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277236e956c5Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 27730dd80ee0Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277436e956c5Smrg $SED -e "$sed_naive_backslashify"` 27750dd80ee0Smrg else 27760dd80ee0Smrg func_convert_core_file_wine_to_w32_result= 27770dd80ee0Smrg fi 27780dd80ee0Smrg fi 27790dd80ee0Smrg} 27800dd80ee0Smrg# end: func_convert_core_file_wine_to_w32 27810dd80ee0Smrg 27820dd80ee0Smrg 27830dd80ee0Smrg# func_convert_core_path_wine_to_w32 ARG 27840dd80ee0Smrg# Helper function used by path conversion functions when $build is *nix, and 27850dd80ee0Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 27860dd80ee0Smrg# configured wine environment available, with the winepath program in $build's 27870dd80ee0Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 27880dd80ee0Smrg# 27890dd80ee0Smrg# ARG is path to be converted from $build format to win32. 27900dd80ee0Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 27910dd80ee0Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 27920dd80ee0Smrg# are convertible, then the result may be empty. 27930dd80ee0Smrgfunc_convert_core_path_wine_to_w32 () 27940dd80ee0Smrg{ 279536e956c5Smrg $debug_cmd 279636e956c5Smrg 27970dd80ee0Smrg # unfortunately, winepath doesn't convert paths, only file names 279836e956c5Smrg func_convert_core_path_wine_to_w32_result= 27990dd80ee0Smrg if test -n "$1"; then 28000dd80ee0Smrg oldIFS=$IFS 28010dd80ee0Smrg IFS=: 28020dd80ee0Smrg for func_convert_core_path_wine_to_w32_f in $1; do 28030dd80ee0Smrg IFS=$oldIFS 28040dd80ee0Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280536e956c5Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 28060dd80ee0Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280736e956c5Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 28080dd80ee0Smrg else 28090dd80ee0Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 28100dd80ee0Smrg fi 28110dd80ee0Smrg fi 28120dd80ee0Smrg done 28130dd80ee0Smrg IFS=$oldIFS 28140dd80ee0Smrg fi 28150dd80ee0Smrg} 28160dd80ee0Smrg# end: func_convert_core_path_wine_to_w32 28170dd80ee0Smrg 28180dd80ee0Smrg 28190dd80ee0Smrg# func_cygpath ARGS... 28200dd80ee0Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 28210dd80ee0Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 28220dd80ee0Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 28230dd80ee0Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 28240dd80ee0Smrg# file name or path is assumed to be in w32 format, as previously converted 28250dd80ee0Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 28260dd80ee0Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 28270dd80ee0Smrg# Cygwin format). Returns an empty string on error. 28280dd80ee0Smrg# 28290dd80ee0Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 28300dd80ee0Smrg# be converted. 28310dd80ee0Smrg# 28320dd80ee0Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 28330dd80ee0Smrg# environment variable; do not put it in $PATH. 28340dd80ee0Smrgfunc_cygpath () 28350dd80ee0Smrg{ 283636e956c5Smrg $debug_cmd 283736e956c5Smrg 28380dd80ee0Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 28390dd80ee0Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 28400dd80ee0Smrg if test "$?" -ne 0; then 28410dd80ee0Smrg # on failure, ensure result is empty 28420dd80ee0Smrg func_cygpath_result= 28430dd80ee0Smrg fi 28440dd80ee0Smrg else 28450dd80ee0Smrg func_cygpath_result= 284636e956c5Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 28470dd80ee0Smrg fi 28480dd80ee0Smrg} 28490dd80ee0Smrg#end: func_cygpath 28500dd80ee0Smrg 28510dd80ee0Smrg 28520dd80ee0Smrg# func_convert_core_msys_to_w32 ARG 28530dd80ee0Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 28540dd80ee0Smrg# result in func_convert_core_msys_to_w32_result. 28550dd80ee0Smrgfunc_convert_core_msys_to_w32 () 28560dd80ee0Smrg{ 285736e956c5Smrg $debug_cmd 285836e956c5Smrg 28590dd80ee0Smrg # awkward: cmd appends spaces to result 28600dd80ee0Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286136e956c5Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 28620dd80ee0Smrg} 28630dd80ee0Smrg#end: func_convert_core_msys_to_w32 28640dd80ee0Smrg 28650dd80ee0Smrg 28660dd80ee0Smrg# func_convert_file_check ARG1 ARG2 28670dd80ee0Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 28680dd80ee0Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 28690dd80ee0Smrg# func_to_host_file_result to ARG1). 28700dd80ee0Smrgfunc_convert_file_check () 28710dd80ee0Smrg{ 287236e956c5Smrg $debug_cmd 287336e956c5Smrg 287436e956c5Smrg if test -z "$2" && test -n "$1"; then 28750dd80ee0Smrg func_error "Could not determine host file name corresponding to" 287636e956c5Smrg func_error " '$1'" 28770dd80ee0Smrg func_error "Continuing, but uninstalled executables may not work." 28780dd80ee0Smrg # Fallback: 287936e956c5Smrg func_to_host_file_result=$1 28800dd80ee0Smrg fi 28810dd80ee0Smrg} 28820dd80ee0Smrg# end func_convert_file_check 28830dd80ee0Smrg 28840dd80ee0Smrg 28850dd80ee0Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 28860dd80ee0Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 28870dd80ee0Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 28880dd80ee0Smrg# func_to_host_file_result to a simplistic fallback value (see below). 28890dd80ee0Smrgfunc_convert_path_check () 28900dd80ee0Smrg{ 289136e956c5Smrg $debug_cmd 289236e956c5Smrg 28930dd80ee0Smrg if test -z "$4" && test -n "$3"; then 28940dd80ee0Smrg func_error "Could not determine the host path corresponding to" 289536e956c5Smrg func_error " '$3'" 28960dd80ee0Smrg func_error "Continuing, but uninstalled executables may not work." 28970dd80ee0Smrg # Fallback. This is a deliberately simplistic "conversion" and 28980dd80ee0Smrg # should not be "improved". See libtool.info. 28990dd80ee0Smrg if test "x$1" != "x$2"; then 29000dd80ee0Smrg lt_replace_pathsep_chars="s|$1|$2|g" 29010dd80ee0Smrg func_to_host_path_result=`echo "$3" | 29020dd80ee0Smrg $SED -e "$lt_replace_pathsep_chars"` 29030dd80ee0Smrg else 290436e956c5Smrg func_to_host_path_result=$3 29050dd80ee0Smrg fi 29060dd80ee0Smrg fi 29070dd80ee0Smrg} 29080dd80ee0Smrg# end func_convert_path_check 29090dd80ee0Smrg 29100dd80ee0Smrg 29110dd80ee0Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 29120dd80ee0Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 29130dd80ee0Smrg# and appending REPL if ORIG matches BACKPAT. 29140dd80ee0Smrgfunc_convert_path_front_back_pathsep () 29150dd80ee0Smrg{ 291636e956c5Smrg $debug_cmd 291736e956c5Smrg 29180dd80ee0Smrg case $4 in 291936e956c5Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 29200dd80ee0Smrg ;; 29210dd80ee0Smrg esac 29220dd80ee0Smrg case $4 in 29230dd80ee0Smrg $2 ) func_append func_to_host_path_result "$3" 29240dd80ee0Smrg ;; 29250dd80ee0Smrg esac 29260dd80ee0Smrg} 29270dd80ee0Smrg# end func_convert_path_front_back_pathsep 29280dd80ee0Smrg 29290dd80ee0Smrg 29300dd80ee0Smrg################################################## 29310dd80ee0Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 29320dd80ee0Smrg################################################## 293336e956c5Smrg# invoked via '$to_host_file_cmd ARG' 29340dd80ee0Smrg# 29350dd80ee0Smrg# In each case, ARG is the path to be converted from $build to $host format. 29360dd80ee0Smrg# Result will be available in $func_to_host_file_result. 29370dd80ee0Smrg 29380dd80ee0Smrg 29390dd80ee0Smrg# func_to_host_file ARG 29400dd80ee0Smrg# Converts the file name ARG from $build format to $host format. Return result 29410dd80ee0Smrg# in func_to_host_file_result. 29420dd80ee0Smrgfunc_to_host_file () 29430dd80ee0Smrg{ 294436e956c5Smrg $debug_cmd 294536e956c5Smrg 29460dd80ee0Smrg $to_host_file_cmd "$1" 29470dd80ee0Smrg} 29480dd80ee0Smrg# end func_to_host_file 29490dd80ee0Smrg 29500dd80ee0Smrg 29510dd80ee0Smrg# func_to_tool_file ARG LAZY 29520dd80ee0Smrg# converts the file name ARG from $build format to toolchain format. Return 29530dd80ee0Smrg# result in func_to_tool_file_result. If the conversion in use is listed 29540dd80ee0Smrg# in (the comma separated) LAZY, no conversion takes place. 29550dd80ee0Smrgfunc_to_tool_file () 29560dd80ee0Smrg{ 295736e956c5Smrg $debug_cmd 295836e956c5Smrg 29590dd80ee0Smrg case ,$2, in 29600dd80ee0Smrg *,"$to_tool_file_cmd",*) 29610dd80ee0Smrg func_to_tool_file_result=$1 29620dd80ee0Smrg ;; 29630dd80ee0Smrg *) 29640dd80ee0Smrg $to_tool_file_cmd "$1" 29650dd80ee0Smrg func_to_tool_file_result=$func_to_host_file_result 29660dd80ee0Smrg ;; 29670dd80ee0Smrg esac 29680dd80ee0Smrg} 29690dd80ee0Smrg# end func_to_tool_file 29700dd80ee0Smrg 29710dd80ee0Smrg 29720dd80ee0Smrg# func_convert_file_noop ARG 29730dd80ee0Smrg# Copy ARG to func_to_host_file_result. 29740dd80ee0Smrgfunc_convert_file_noop () 29750dd80ee0Smrg{ 297636e956c5Smrg func_to_host_file_result=$1 29770dd80ee0Smrg} 29780dd80ee0Smrg# end func_convert_file_noop 29790dd80ee0Smrg 29800dd80ee0Smrg 29810dd80ee0Smrg# func_convert_file_msys_to_w32 ARG 29820dd80ee0Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 29830dd80ee0Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 29840dd80ee0Smrg# func_to_host_file_result. 29850dd80ee0Smrgfunc_convert_file_msys_to_w32 () 29860dd80ee0Smrg{ 298736e956c5Smrg $debug_cmd 298836e956c5Smrg 298936e956c5Smrg func_to_host_file_result=$1 29900dd80ee0Smrg if test -n "$1"; then 29910dd80ee0Smrg func_convert_core_msys_to_w32 "$1" 299236e956c5Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 29930dd80ee0Smrg fi 29940dd80ee0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 29950dd80ee0Smrg} 29960dd80ee0Smrg# end func_convert_file_msys_to_w32 29970dd80ee0Smrg 29980dd80ee0Smrg 29990dd80ee0Smrg# func_convert_file_cygwin_to_w32 ARG 30000dd80ee0Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 30010dd80ee0Smrg# func_to_host_file_result. 30020dd80ee0Smrgfunc_convert_file_cygwin_to_w32 () 30030dd80ee0Smrg{ 300436e956c5Smrg $debug_cmd 300536e956c5Smrg 300636e956c5Smrg func_to_host_file_result=$1 30070dd80ee0Smrg if test -n "$1"; then 30080dd80ee0Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 30090dd80ee0Smrg # LT_CYGPATH in this case. 30100dd80ee0Smrg func_to_host_file_result=`cygpath -m "$1"` 30110dd80ee0Smrg fi 30120dd80ee0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30130dd80ee0Smrg} 30140dd80ee0Smrg# end func_convert_file_cygwin_to_w32 30150dd80ee0Smrg 30160dd80ee0Smrg 30170dd80ee0Smrg# func_convert_file_nix_to_w32 ARG 30180dd80ee0Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 30190dd80ee0Smrg# and a working winepath. Returns result in func_to_host_file_result. 30200dd80ee0Smrgfunc_convert_file_nix_to_w32 () 30210dd80ee0Smrg{ 302236e956c5Smrg $debug_cmd 302336e956c5Smrg 302436e956c5Smrg func_to_host_file_result=$1 30250dd80ee0Smrg if test -n "$1"; then 30260dd80ee0Smrg func_convert_core_file_wine_to_w32 "$1" 302736e956c5Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 30280dd80ee0Smrg fi 30290dd80ee0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30300dd80ee0Smrg} 30310dd80ee0Smrg# end func_convert_file_nix_to_w32 30320dd80ee0Smrg 30330dd80ee0Smrg 30340dd80ee0Smrg# func_convert_file_msys_to_cygwin ARG 30350dd80ee0Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 30360dd80ee0Smrg# Returns result in func_to_host_file_result. 30370dd80ee0Smrgfunc_convert_file_msys_to_cygwin () 30380dd80ee0Smrg{ 303936e956c5Smrg $debug_cmd 304036e956c5Smrg 304136e956c5Smrg func_to_host_file_result=$1 30420dd80ee0Smrg if test -n "$1"; then 30430dd80ee0Smrg func_convert_core_msys_to_w32 "$1" 30440dd80ee0Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304536e956c5Smrg func_to_host_file_result=$func_cygpath_result 30460dd80ee0Smrg fi 30470dd80ee0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30480dd80ee0Smrg} 30490dd80ee0Smrg# end func_convert_file_msys_to_cygwin 30500dd80ee0Smrg 30510dd80ee0Smrg 30520dd80ee0Smrg# func_convert_file_nix_to_cygwin ARG 30530dd80ee0Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 30540dd80ee0Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 30550dd80ee0Smrg# in func_to_host_file_result. 30560dd80ee0Smrgfunc_convert_file_nix_to_cygwin () 30570dd80ee0Smrg{ 305836e956c5Smrg $debug_cmd 305936e956c5Smrg 306036e956c5Smrg func_to_host_file_result=$1 30610dd80ee0Smrg if test -n "$1"; then 30620dd80ee0Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 30630dd80ee0Smrg func_convert_core_file_wine_to_w32 "$1" 30640dd80ee0Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306536e956c5Smrg func_to_host_file_result=$func_cygpath_result 30660dd80ee0Smrg fi 30670dd80ee0Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30680dd80ee0Smrg} 30690dd80ee0Smrg# end func_convert_file_nix_to_cygwin 30700dd80ee0Smrg 30710dd80ee0Smrg 30720dd80ee0Smrg############################################# 30730dd80ee0Smrg# $build to $host PATH CONVERSION FUNCTIONS # 30740dd80ee0Smrg############################################# 307536e956c5Smrg# invoked via '$to_host_path_cmd ARG' 30760dd80ee0Smrg# 30770dd80ee0Smrg# In each case, ARG is the path to be converted from $build to $host format. 30780dd80ee0Smrg# The result will be available in $func_to_host_path_result. 30790dd80ee0Smrg# 30800dd80ee0Smrg# Path separators are also converted from $build format to $host format. If 30810dd80ee0Smrg# ARG begins or ends with a path separator character, it is preserved (but 30820dd80ee0Smrg# converted to $host format) on output. 30830dd80ee0Smrg# 30840dd80ee0Smrg# All path conversion functions are named using the following convention: 30850dd80ee0Smrg# file name conversion function : func_convert_file_X_to_Y () 30860dd80ee0Smrg# path conversion function : func_convert_path_X_to_Y () 30870dd80ee0Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 30880dd80ee0Smrg# same. If conversion functions are added for new $build/$host combinations, 30890dd80ee0Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 30900dd80ee0Smrg# will break. 30910dd80ee0Smrg 30920dd80ee0Smrg 30930dd80ee0Smrg# func_init_to_host_path_cmd 30940dd80ee0Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 30950dd80ee0Smrg# appropriate value, based on the value of $to_host_file_cmd. 30960dd80ee0Smrgto_host_path_cmd= 30970dd80ee0Smrgfunc_init_to_host_path_cmd () 30980dd80ee0Smrg{ 309936e956c5Smrg $debug_cmd 310036e956c5Smrg 31010dd80ee0Smrg if test -z "$to_host_path_cmd"; then 31020dd80ee0Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310336e956c5Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 31040dd80ee0Smrg fi 31050dd80ee0Smrg} 31060dd80ee0Smrg 31070dd80ee0Smrg 31080dd80ee0Smrg# func_to_host_path ARG 31090dd80ee0Smrg# Converts the path ARG from $build format to $host format. Return result 31100dd80ee0Smrg# in func_to_host_path_result. 31110dd80ee0Smrgfunc_to_host_path () 31120dd80ee0Smrg{ 311336e956c5Smrg $debug_cmd 311436e956c5Smrg 31150dd80ee0Smrg func_init_to_host_path_cmd 31160dd80ee0Smrg $to_host_path_cmd "$1" 31170dd80ee0Smrg} 31180dd80ee0Smrg# end func_to_host_path 31190dd80ee0Smrg 31200dd80ee0Smrg 31210dd80ee0Smrg# func_convert_path_noop ARG 31220dd80ee0Smrg# Copy ARG to func_to_host_path_result. 31230dd80ee0Smrgfunc_convert_path_noop () 31240dd80ee0Smrg{ 312536e956c5Smrg func_to_host_path_result=$1 31260dd80ee0Smrg} 31270dd80ee0Smrg# end func_convert_path_noop 31280dd80ee0Smrg 31290dd80ee0Smrg 31300dd80ee0Smrg# func_convert_path_msys_to_w32 ARG 31310dd80ee0Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 31320dd80ee0Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 31330dd80ee0Smrg# func_to_host_path_result. 31340dd80ee0Smrgfunc_convert_path_msys_to_w32 () 31350dd80ee0Smrg{ 313636e956c5Smrg $debug_cmd 313736e956c5Smrg 313836e956c5Smrg func_to_host_path_result=$1 31390dd80ee0Smrg if test -n "$1"; then 31400dd80ee0Smrg # Remove leading and trailing path separator characters from ARG. MSYS 31410dd80ee0Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 31420dd80ee0Smrg # and winepath ignores them completely. 31430dd80ee0Smrg func_stripname : : "$1" 31440dd80ee0Smrg func_to_host_path_tmp1=$func_stripname_result 31450dd80ee0Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314636e956c5Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 31470dd80ee0Smrg func_convert_path_check : ";" \ 31480dd80ee0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31490dd80ee0Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31500dd80ee0Smrg fi 31510dd80ee0Smrg} 31520dd80ee0Smrg# end func_convert_path_msys_to_w32 31530dd80ee0Smrg 31540dd80ee0Smrg 31550dd80ee0Smrg# func_convert_path_cygwin_to_w32 ARG 31560dd80ee0Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 31570dd80ee0Smrg# func_to_host_file_result. 31580dd80ee0Smrgfunc_convert_path_cygwin_to_w32 () 31590dd80ee0Smrg{ 316036e956c5Smrg $debug_cmd 316136e956c5Smrg 316236e956c5Smrg func_to_host_path_result=$1 31630dd80ee0Smrg if test -n "$1"; then 31640dd80ee0Smrg # See func_convert_path_msys_to_w32: 31650dd80ee0Smrg func_stripname : : "$1" 31660dd80ee0Smrg func_to_host_path_tmp1=$func_stripname_result 31670dd80ee0Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 31680dd80ee0Smrg func_convert_path_check : ";" \ 31690dd80ee0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31700dd80ee0Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31710dd80ee0Smrg fi 31720dd80ee0Smrg} 31730dd80ee0Smrg# end func_convert_path_cygwin_to_w32 31740dd80ee0Smrg 31750dd80ee0Smrg 31760dd80ee0Smrg# func_convert_path_nix_to_w32 ARG 31770dd80ee0Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 31780dd80ee0Smrg# a working winepath. Returns result in func_to_host_file_result. 31790dd80ee0Smrgfunc_convert_path_nix_to_w32 () 31800dd80ee0Smrg{ 318136e956c5Smrg $debug_cmd 318236e956c5Smrg 318336e956c5Smrg func_to_host_path_result=$1 31840dd80ee0Smrg if test -n "$1"; then 31850dd80ee0Smrg # See func_convert_path_msys_to_w32: 31860dd80ee0Smrg func_stripname : : "$1" 31870dd80ee0Smrg func_to_host_path_tmp1=$func_stripname_result 31880dd80ee0Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318936e956c5Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 31900dd80ee0Smrg func_convert_path_check : ";" \ 31910dd80ee0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31920dd80ee0Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31930dd80ee0Smrg fi 31940dd80ee0Smrg} 31950dd80ee0Smrg# end func_convert_path_nix_to_w32 31960dd80ee0Smrg 31970dd80ee0Smrg 31980dd80ee0Smrg# func_convert_path_msys_to_cygwin ARG 31990dd80ee0Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32000dd80ee0Smrg# Returns result in func_to_host_file_result. 32010dd80ee0Smrgfunc_convert_path_msys_to_cygwin () 32020dd80ee0Smrg{ 320336e956c5Smrg $debug_cmd 320436e956c5Smrg 320536e956c5Smrg func_to_host_path_result=$1 32060dd80ee0Smrg if test -n "$1"; then 32070dd80ee0Smrg # See func_convert_path_msys_to_w32: 32080dd80ee0Smrg func_stripname : : "$1" 32090dd80ee0Smrg func_to_host_path_tmp1=$func_stripname_result 32100dd80ee0Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 32110dd80ee0Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321236e956c5Smrg func_to_host_path_result=$func_cygpath_result 32130dd80ee0Smrg func_convert_path_check : : \ 32140dd80ee0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32150dd80ee0Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32160dd80ee0Smrg fi 32170dd80ee0Smrg} 32180dd80ee0Smrg# end func_convert_path_msys_to_cygwin 32190dd80ee0Smrg 32200dd80ee0Smrg 32210dd80ee0Smrg# func_convert_path_nix_to_cygwin ARG 32220dd80ee0Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 32230dd80ee0Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 32240dd80ee0Smrg# func_to_host_file_result. 32250dd80ee0Smrgfunc_convert_path_nix_to_cygwin () 32260dd80ee0Smrg{ 322736e956c5Smrg $debug_cmd 322836e956c5Smrg 322936e956c5Smrg func_to_host_path_result=$1 32300dd80ee0Smrg if test -n "$1"; then 32310dd80ee0Smrg # Remove leading and trailing path separator characters from 32320dd80ee0Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 32330dd80ee0Smrg # into '.;' and ';.', and winepath ignores them completely. 32340dd80ee0Smrg func_stripname : : "$1" 32350dd80ee0Smrg func_to_host_path_tmp1=$func_stripname_result 32360dd80ee0Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 32370dd80ee0Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323836e956c5Smrg func_to_host_path_result=$func_cygpath_result 32390dd80ee0Smrg func_convert_path_check : : \ 32400dd80ee0Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32410dd80ee0Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32420dd80ee0Smrg fi 32430dd80ee0Smrg} 32440dd80ee0Smrg# end func_convert_path_nix_to_cygwin 32450dd80ee0Smrg 32460dd80ee0Smrg 324736e956c5Smrg# func_dll_def_p FILE 324836e956c5Smrg# True iff FILE is a Windows DLL '.def' file. 324936e956c5Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325036e956c5Smrgfunc_dll_def_p () 325136e956c5Smrg{ 325236e956c5Smrg $debug_cmd 325336e956c5Smrg 325436e956c5Smrg func_dll_def_p_tmp=`$SED -n \ 325536e956c5Smrg -e 's/^[ ]*//' \ 325636e956c5Smrg -e '/^\(;.*\)*$/d' \ 325736e956c5Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325836e956c5Smrg -e q \ 325936e956c5Smrg "$1"` 326036e956c5Smrg test DEF = "$func_dll_def_p_tmp" 326136e956c5Smrg} 326236e956c5Smrg 326336e956c5Smrg 32645f5b92ffSmrg# func_mode_compile arg... 32655f5b92ffSmrgfunc_mode_compile () 32665f5b92ffSmrg{ 326736e956c5Smrg $debug_cmd 326836e956c5Smrg 32695f5b92ffSmrg # Get the compilation command and the source file. 32705f5b92ffSmrg base_compile= 327136e956c5Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 32725f5b92ffSmrg suppress_opt=yes 32735f5b92ffSmrg suppress_output= 32745f5b92ffSmrg arg_mode=normal 32755f5b92ffSmrg libobj= 32765f5b92ffSmrg later= 32775f5b92ffSmrg pie_flag= 32785f5b92ffSmrg 32795f5b92ffSmrg for arg 32805f5b92ffSmrg do 32815f5b92ffSmrg case $arg_mode in 32825f5b92ffSmrg arg ) 32835f5b92ffSmrg # do not "continue". Instead, add this to base_compile 328436e956c5Smrg lastarg=$arg 32855f5b92ffSmrg arg_mode=normal 32865f5b92ffSmrg ;; 32875f5b92ffSmrg 32885f5b92ffSmrg target ) 328936e956c5Smrg libobj=$arg 32905f5b92ffSmrg arg_mode=normal 32915f5b92ffSmrg continue 32925f5b92ffSmrg ;; 32935f5b92ffSmrg 32945f5b92ffSmrg normal ) 32955f5b92ffSmrg # Accept any command-line options. 32965f5b92ffSmrg case $arg in 32975f5b92ffSmrg -o) 32985f5b92ffSmrg test -n "$libobj" && \ 329936e956c5Smrg func_fatal_error "you cannot specify '-o' more than once" 33005f5b92ffSmrg arg_mode=target 33015f5b92ffSmrg continue 33025f5b92ffSmrg ;; 33035f5b92ffSmrg 33045f5b92ffSmrg -pie | -fpie | -fPIE) 33050dd80ee0Smrg func_append pie_flag " $arg" 33065f5b92ffSmrg continue 33075f5b92ffSmrg ;; 33085f5b92ffSmrg 33095f5b92ffSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 33100dd80ee0Smrg func_append later " $arg" 33115f5b92ffSmrg continue 33125f5b92ffSmrg ;; 33135f5b92ffSmrg 33145f5b92ffSmrg -no-suppress) 331517a48c7cSmrg suppress_opt=no 331617a48c7cSmrg continue 331717a48c7cSmrg ;; 331817a48c7cSmrg 331917a48c7cSmrg -Xcompiler) 332017a48c7cSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 332117a48c7cSmrg continue # The current "srcfile" will either be retained or 332217a48c7cSmrg ;; # replaced later. I would guess that would be a bug. 332317a48c7cSmrg 332417a48c7cSmrg -Wc,*) 33255f5b92ffSmrg func_stripname '-Wc,' '' "$arg" 33265f5b92ffSmrg args=$func_stripname_result 332717a48c7cSmrg lastarg= 332836e956c5Smrg save_ifs=$IFS; IFS=, 33295f5b92ffSmrg for arg in $args; do 333036e956c5Smrg IFS=$save_ifs 33310dd80ee0Smrg func_append_quoted lastarg "$arg" 333217a48c7cSmrg done 333336e956c5Smrg IFS=$save_ifs 33345f5b92ffSmrg func_stripname ' ' '' "$lastarg" 33355f5b92ffSmrg lastarg=$func_stripname_result 333617a48c7cSmrg 333717a48c7cSmrg # Add the arguments to base_compile. 33380dd80ee0Smrg func_append base_compile " $lastarg" 333917a48c7cSmrg continue 334017a48c7cSmrg ;; 334117a48c7cSmrg 33425f5b92ffSmrg *) 334317a48c7cSmrg # Accept the current argument as the source file. 334417a48c7cSmrg # The previous "srcfile" becomes the current argument. 334517a48c7cSmrg # 334636e956c5Smrg lastarg=$srcfile 334736e956c5Smrg srcfile=$arg 334817a48c7cSmrg ;; 334917a48c7cSmrg esac # case $arg 335017a48c7cSmrg ;; 335117a48c7cSmrg esac # case $arg_mode 335217a48c7cSmrg 335317a48c7cSmrg # Aesthetically quote the previous argument. 33540dd80ee0Smrg func_append_quoted base_compile "$lastarg" 335517a48c7cSmrg done # for arg 335617a48c7cSmrg 335717a48c7cSmrg case $arg_mode in 335817a48c7cSmrg arg) 33595f5b92ffSmrg func_fatal_error "you must specify an argument for -Xcompile" 336017a48c7cSmrg ;; 336117a48c7cSmrg target) 336236e956c5Smrg func_fatal_error "you must specify a target with '-o'" 336317a48c7cSmrg ;; 336417a48c7cSmrg *) 336517a48c7cSmrg # Get the name of the library object. 33665f5b92ffSmrg test -z "$libobj" && { 33675f5b92ffSmrg func_basename "$srcfile" 336836e956c5Smrg libobj=$func_basename_result 33695f5b92ffSmrg } 337017a48c7cSmrg ;; 337117a48c7cSmrg esac 337217a48c7cSmrg 337317a48c7cSmrg # Recognize several different file suffixes. 337417a48c7cSmrg # If the user specifies -o file.o, it is replaced with file.lo 337517a48c7cSmrg case $libobj in 33765f5b92ffSmrg *.[cCFSifmso] | \ 33775f5b92ffSmrg *.ada | *.adb | *.ads | *.asm | \ 33785f5b92ffSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 33790dd80ee0Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 33805f5b92ffSmrg func_xform "$libobj" 33815f5b92ffSmrg libobj=$func_xform_result 33825f5b92ffSmrg ;; 338317a48c7cSmrg esac 338417a48c7cSmrg 338517a48c7cSmrg case $libobj in 33865f5b92ffSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 338717a48c7cSmrg *) 338836e956c5Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 338917a48c7cSmrg ;; 339017a48c7cSmrg esac 339117a48c7cSmrg 339217a48c7cSmrg func_infer_tag $base_compile 339317a48c7cSmrg 339417a48c7cSmrg for arg in $later; do 339517a48c7cSmrg case $arg in 33965f5b92ffSmrg -shared) 339736e956c5Smrg test yes = "$build_libtool_libs" \ 339836e956c5Smrg || func_fatal_configuration "cannot build a shared library" 33995f5b92ffSmrg build_old_libs=no 34005f5b92ffSmrg continue 34015f5b92ffSmrg ;; 34025f5b92ffSmrg 340317a48c7cSmrg -static) 34045f5b92ffSmrg build_libtool_libs=no 340517a48c7cSmrg build_old_libs=yes 340617a48c7cSmrg continue 340717a48c7cSmrg ;; 340817a48c7cSmrg 340917a48c7cSmrg -prefer-pic) 341017a48c7cSmrg pic_mode=yes 341117a48c7cSmrg continue 341217a48c7cSmrg ;; 341317a48c7cSmrg 341417a48c7cSmrg -prefer-non-pic) 341517a48c7cSmrg pic_mode=no 341617a48c7cSmrg continue 341717a48c7cSmrg ;; 341817a48c7cSmrg esac 341917a48c7cSmrg done 342017a48c7cSmrg 34215f5b92ffSmrg func_quote_for_eval "$libobj" 34225f5b92ffSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 34235f5b92ffSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342436e956c5Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 34255f5b92ffSmrg func_dirname_and_basename "$obj" "/" "" 342636e956c5Smrg objname=$func_basename_result 342736e956c5Smrg xdir=$func_dirname_result 342836e956c5Smrg lobj=$xdir$objdir/$objname 342917a48c7cSmrg 34305f5b92ffSmrg test -z "$base_compile" && \ 34315f5b92ffSmrg func_fatal_help "you must specify a compilation command" 343217a48c7cSmrg 343317a48c7cSmrg # Delete any leftover library objects. 343436e956c5Smrg if test yes = "$build_old_libs"; then 343517a48c7cSmrg removelist="$obj $lobj $libobj ${libobj}T" 343617a48c7cSmrg else 343717a48c7cSmrg removelist="$lobj $libobj ${libobj}T" 343817a48c7cSmrg fi 343917a48c7cSmrg 344017a48c7cSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 344117a48c7cSmrg case $host_os in 34425f5b92ffSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 344317a48c7cSmrg pic_mode=default 344417a48c7cSmrg ;; 344517a48c7cSmrg esac 344636e956c5Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 344717a48c7cSmrg # non-PIC code in shared libraries is not supported 344817a48c7cSmrg pic_mode=default 344917a48c7cSmrg fi 345017a48c7cSmrg 345117a48c7cSmrg # Calculate the filename of the output object if compiler does 345217a48c7cSmrg # not support -o with -c 345336e956c5Smrg if test no = "$compiler_c_o"; then 345436e956c5Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345536e956c5Smrg lockfile=$output_obj.lock 345617a48c7cSmrg else 345717a48c7cSmrg output_obj= 345817a48c7cSmrg need_locks=no 345917a48c7cSmrg lockfile= 346017a48c7cSmrg fi 346117a48c7cSmrg 346217a48c7cSmrg # Lock this critical section if it is needed 346317a48c7cSmrg # We use this script file to make the link, it avoids creating a new file 346436e956c5Smrg if test yes = "$need_locks"; then 34655f5b92ffSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 34665f5b92ffSmrg func_echo "Waiting for $lockfile to be removed" 346717a48c7cSmrg sleep 2 346817a48c7cSmrg done 346936e956c5Smrg elif test warn = "$need_locks"; then 347017a48c7cSmrg if test -f "$lockfile"; then 34715f5b92ffSmrg $ECHO "\ 347217a48c7cSmrg*** ERROR, $lockfile exists and contains: 347317a48c7cSmrg`cat $lockfile 2>/dev/null` 347417a48c7cSmrg 347517a48c7cSmrgThis indicates that another process is trying to use the same 347617a48c7cSmrgtemporary object file, and libtool could not work around it because 347736e956c5Smrgyour compiler does not support '-c' and '-o' together. If you 347817a48c7cSmrgrepeat this compilation, it may succeed, by chance, but you had better 347917a48c7cSmrgavoid parallel builds (make -j) in this platform, or get a better 348017a48c7cSmrgcompiler." 348117a48c7cSmrg 34825f5b92ffSmrg $opt_dry_run || $RM $removelist 348317a48c7cSmrg exit $EXIT_FAILURE 348417a48c7cSmrg fi 34850dd80ee0Smrg func_append removelist " $output_obj" 34865f5b92ffSmrg $ECHO "$srcfile" > "$lockfile" 348717a48c7cSmrg fi 348817a48c7cSmrg 34895f5b92ffSmrg $opt_dry_run || $RM $removelist 34900dd80ee0Smrg func_append removelist " $lockfile" 34915f5b92ffSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 34925f5b92ffSmrg 34930dd80ee0Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 34940dd80ee0Smrg srcfile=$func_to_tool_file_result 34955f5b92ffSmrg func_quote_for_eval "$srcfile" 34965f5b92ffSmrg qsrcfile=$func_quote_for_eval_result 349717a48c7cSmrg 349817a48c7cSmrg # Only build a PIC object if we are building libtool libraries. 349936e956c5Smrg if test yes = "$build_libtool_libs"; then 350017a48c7cSmrg # Without this assignment, base_compile gets emptied. 350117a48c7cSmrg fbsd_hideous_sh_bug=$base_compile 350217a48c7cSmrg 350336e956c5Smrg if test no != "$pic_mode"; then 350417a48c7cSmrg command="$base_compile $qsrcfile $pic_flag" 350517a48c7cSmrg else 350617a48c7cSmrg # Don't build PIC code 350717a48c7cSmrg command="$base_compile $qsrcfile" 350817a48c7cSmrg fi 350917a48c7cSmrg 35105f5b92ffSmrg func_mkdir_p "$xdir$objdir" 351117a48c7cSmrg 351217a48c7cSmrg if test -z "$output_obj"; then 351317a48c7cSmrg # Place PIC objects in $objdir 35140dd80ee0Smrg func_append command " -o $lobj" 351517a48c7cSmrg fi 351617a48c7cSmrg 35175f5b92ffSmrg func_show_eval_locale "$command" \ 35185f5b92ffSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 351917a48c7cSmrg 352036e956c5Smrg if test warn = "$need_locks" && 352117a48c7cSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35225f5b92ffSmrg $ECHO "\ 352317a48c7cSmrg*** ERROR, $lockfile contains: 352417a48c7cSmrg`cat $lockfile 2>/dev/null` 352517a48c7cSmrg 352617a48c7cSmrgbut it should contain: 352717a48c7cSmrg$srcfile 352817a48c7cSmrg 352917a48c7cSmrgThis indicates that another process is trying to use the same 353017a48c7cSmrgtemporary object file, and libtool could not work around it because 353136e956c5Smrgyour compiler does not support '-c' and '-o' together. If you 353217a48c7cSmrgrepeat this compilation, it may succeed, by chance, but you had better 353317a48c7cSmrgavoid parallel builds (make -j) in this platform, or get a better 353417a48c7cSmrgcompiler." 353517a48c7cSmrg 35365f5b92ffSmrg $opt_dry_run || $RM $removelist 353717a48c7cSmrg exit $EXIT_FAILURE 353817a48c7cSmrg fi 353917a48c7cSmrg 354017a48c7cSmrg # Just move the object if needed, then go on to compile the next one 354117a48c7cSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 35425f5b92ffSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 35435f5b92ffSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 354417a48c7cSmrg fi 354517a48c7cSmrg 354617a48c7cSmrg # Allow error messages only from the first compilation. 354736e956c5Smrg if test yes = "$suppress_opt"; then 35485f5b92ffSmrg suppress_output=' >/dev/null 2>&1' 354917a48c7cSmrg fi 355017a48c7cSmrg fi 355117a48c7cSmrg 355217a48c7cSmrg # Only build a position-dependent object if we build old libraries. 355336e956c5Smrg if test yes = "$build_old_libs"; then 355436e956c5Smrg if test yes != "$pic_mode"; then 355517a48c7cSmrg # Don't build PIC code 35565f5b92ffSmrg command="$base_compile $qsrcfile$pie_flag" 355717a48c7cSmrg else 355817a48c7cSmrg command="$base_compile $qsrcfile $pic_flag" 355917a48c7cSmrg fi 356036e956c5Smrg if test yes = "$compiler_c_o"; then 35610dd80ee0Smrg func_append command " -o $obj" 356217a48c7cSmrg fi 356317a48c7cSmrg 356417a48c7cSmrg # Suppress compiler output if we already did a PIC compilation. 35650dd80ee0Smrg func_append command "$suppress_output" 35665f5b92ffSmrg func_show_eval_locale "$command" \ 35675f5b92ffSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 356817a48c7cSmrg 356936e956c5Smrg if test warn = "$need_locks" && 357017a48c7cSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35715f5b92ffSmrg $ECHO "\ 357217a48c7cSmrg*** ERROR, $lockfile contains: 357317a48c7cSmrg`cat $lockfile 2>/dev/null` 357417a48c7cSmrg 357517a48c7cSmrgbut it should contain: 357617a48c7cSmrg$srcfile 357717a48c7cSmrg 357817a48c7cSmrgThis indicates that another process is trying to use the same 357917a48c7cSmrgtemporary object file, and libtool could not work around it because 358036e956c5Smrgyour compiler does not support '-c' and '-o' together. If you 358117a48c7cSmrgrepeat this compilation, it may succeed, by chance, but you had better 358217a48c7cSmrgavoid parallel builds (make -j) in this platform, or get a better 358317a48c7cSmrgcompiler." 358417a48c7cSmrg 35855f5b92ffSmrg $opt_dry_run || $RM $removelist 358617a48c7cSmrg exit $EXIT_FAILURE 358717a48c7cSmrg fi 358817a48c7cSmrg 358917a48c7cSmrg # Just move the object if needed 359017a48c7cSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 35915f5b92ffSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 35925f5b92ffSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 359317a48c7cSmrg fi 359417a48c7cSmrg fi 359517a48c7cSmrg 35965f5b92ffSmrg $opt_dry_run || { 35975f5b92ffSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 359817a48c7cSmrg 35995f5b92ffSmrg # Unlock the critical section if it was locked 360036e956c5Smrg if test no != "$need_locks"; then 36015f5b92ffSmrg removelist=$lockfile 36025f5b92ffSmrg $RM "$lockfile" 36035f5b92ffSmrg fi 36045f5b92ffSmrg } 360517a48c7cSmrg 360617a48c7cSmrg exit $EXIT_SUCCESS 36075f5b92ffSmrg} 360817a48c7cSmrg 36095f5b92ffSmrg$opt_help || { 361036e956c5Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 36115f5b92ffSmrg} 361217a48c7cSmrg 36135f5b92ffSmrgfunc_mode_help () 36145f5b92ffSmrg{ 36155f5b92ffSmrg # We need to display help for each of the modes. 36160dd80ee0Smrg case $opt_mode in 36175f5b92ffSmrg "") 36185f5b92ffSmrg # Generic help is extracted from the usage comments 36195f5b92ffSmrg # at the start of this file. 36205f5b92ffSmrg func_help 36215f5b92ffSmrg ;; 362217a48c7cSmrg 36235f5b92ffSmrg clean) 36245f5b92ffSmrg $ECHO \ 36255f5b92ffSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 362617a48c7cSmrg 36275f5b92ffSmrgRemove files from the build directory. 362817a48c7cSmrg 36295f5b92ffSmrgRM is the name of the program to use to delete files associated with each FILE 363036e956c5Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 36315f5b92ffSmrgto RM. 363217a48c7cSmrg 36335f5b92ffSmrgIf FILE is a libtool library, object or program, all the files associated 36345f5b92ffSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 36355f5b92ffSmrg ;; 363617a48c7cSmrg 36375f5b92ffSmrg compile) 36385f5b92ffSmrg $ECHO \ 36395f5b92ffSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 364017a48c7cSmrg 36415f5b92ffSmrgCompile a source file into a libtool library object. 364217a48c7cSmrg 36435f5b92ffSmrgThis mode accepts the following additional options: 364417a48c7cSmrg 36455f5b92ffSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 36465f5b92ffSmrg -no-suppress do not suppress compiler output for multiple passes 36470dd80ee0Smrg -prefer-pic try to build PIC objects only 36480dd80ee0Smrg -prefer-non-pic try to build non-PIC objects only 364936e956c5Smrg -shared do not build a '.o' file suitable for static linking 365036e956c5Smrg -static only build a '.o' file suitable for static linking 36510dd80ee0Smrg -Wc,FLAG pass FLAG directly to the compiler 365217a48c7cSmrg 365336e956c5SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 36545f5b92ffSmrgfrom the given SOURCEFILE. 365517a48c7cSmrg 36565f5b92ffSmrgThe output file name is determined by removing the directory component from 365736e956c5SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365836e956c5Smrglibrary object suffix, '.lo'." 36595f5b92ffSmrg ;; 366017a48c7cSmrg 36615f5b92ffSmrg execute) 36625f5b92ffSmrg $ECHO \ 36635f5b92ffSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 366417a48c7cSmrg 36655f5b92ffSmrgAutomatically set library path, then run a program. 366617a48c7cSmrg 36675f5b92ffSmrgThis mode accepts the following additional options: 366817a48c7cSmrg 36695f5b92ffSmrg -dlopen FILE add the directory containing FILE to the library path 367017a48c7cSmrg 367136e956c5SmrgThis mode sets the library path environment variable according to '-dlopen' 36725f5b92ffSmrgflags. 367317a48c7cSmrg 36745f5b92ffSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 36755f5b92ffSmrginto their corresponding uninstalled binary, and any of their required library 36765f5b92ffSmrgdirectories are added to the library path. 367717a48c7cSmrg 36785f5b92ffSmrgThen, COMMAND is executed, with ARGS as arguments." 36795f5b92ffSmrg ;; 368017a48c7cSmrg 36815f5b92ffSmrg finish) 36825f5b92ffSmrg $ECHO \ 36835f5b92ffSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 368417a48c7cSmrg 36855f5b92ffSmrgComplete the installation of libtool libraries. 368617a48c7cSmrg 36875f5b92ffSmrgEach LIBDIR is a directory that contains libtool libraries. 368817a48c7cSmrg 36895f5b92ffSmrgThe commands that this mode executes may require superuser privileges. Use 369036e956c5Smrgthe '--dry-run' option if you just want to see what would be executed." 36915f5b92ffSmrg ;; 369217a48c7cSmrg 36935f5b92ffSmrg install) 36945f5b92ffSmrg $ECHO \ 36955f5b92ffSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 369617a48c7cSmrg 36975f5b92ffSmrgInstall executables or libraries. 369817a48c7cSmrg 36995f5b92ffSmrgINSTALL-COMMAND is the installation command. The first component should be 370036e956c5Smrgeither the 'install' or 'cp' program. 370117a48c7cSmrg 37025f5b92ffSmrgThe following components of INSTALL-COMMAND are treated specially: 370317a48c7cSmrg 37040dd80ee0Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 370517a48c7cSmrg 37065f5b92ffSmrgThe rest of the components are interpreted as arguments to that command (only 37075f5b92ffSmrgBSD-compatible install options are recognized)." 37085f5b92ffSmrg ;; 370917a48c7cSmrg 37105f5b92ffSmrg link) 37115f5b92ffSmrg $ECHO \ 37125f5b92ffSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 371317a48c7cSmrg 37145f5b92ffSmrgLink object files or libraries together to form another library, or to 37155f5b92ffSmrgcreate an executable program. 371617a48c7cSmrg 37175f5b92ffSmrgLINK-COMMAND is a command using the C compiler that you would use to create 37185f5b92ffSmrga program from several object files. 371917a48c7cSmrg 37205f5b92ffSmrgThe following components of LINK-COMMAND are treated specially: 372117a48c7cSmrg 37225f5b92ffSmrg -all-static do not do any dynamic linking at all 37235f5b92ffSmrg -avoid-version do not add a version suffix if possible 37240dd80ee0Smrg -bindir BINDIR specify path to binaries directory (for systems where 37250dd80ee0Smrg libraries must be found in the PATH setting at runtime) 372636e956c5Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 37275f5b92ffSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 37285f5b92ffSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 37295f5b92ffSmrg -export-symbols SYMFILE 37305f5b92ffSmrg try to export only the symbols listed in SYMFILE 37315f5b92ffSmrg -export-symbols-regex REGEX 37325f5b92ffSmrg try to export only the symbols matching REGEX 37335f5b92ffSmrg -LLIBDIR search LIBDIR for required installed libraries 37345f5b92ffSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 37355f5b92ffSmrg -module build a library that can dlopened 37365f5b92ffSmrg -no-fast-install disable the fast-install mode 37375f5b92ffSmrg -no-install link a not-installable executable 37385f5b92ffSmrg -no-undefined declare that a library does not refer to external symbols 37395f5b92ffSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374036e956c5Smrg -objectlist FILE use a list of object files found in FILE to specify objects 374136e956c5Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 37425f5b92ffSmrg -precious-files-regex REGEX 37435f5b92ffSmrg don't remove output files matching REGEX 37445f5b92ffSmrg -release RELEASE specify package release information 37455f5b92ffSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 37465f5b92ffSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 37475f5b92ffSmrg -shared only do dynamic linking of libtool libraries 37485f5b92ffSmrg -shrext SUFFIX override the standard shared library file extension 37495f5b92ffSmrg -static do not do any dynamic linking of uninstalled libtool libraries 37505f5b92ffSmrg -static-libtool-libs 37515f5b92ffSmrg do not do any dynamic linking of libtool libraries 37525f5b92ffSmrg -version-info CURRENT[:REVISION[:AGE]] 37535f5b92ffSmrg specify library version info [each variable defaults to 0] 37545f5b92ffSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 37550dd80ee0Smrg -Wc,FLAG 37560dd80ee0Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 37570dd80ee0Smrg -Wl,FLAG 37580dd80ee0Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 37590dd80ee0Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 376017a48c7cSmrg 376136e956c5SmrgAll other options (arguments beginning with '-') are ignored. 376217a48c7cSmrg 376336e956c5SmrgEvery other argument is treated as a filename. Files ending in '.la' are 37645f5b92ffSmrgtreated as uninstalled libtool libraries, other files are standard or library 37655f5b92ffSmrgobject files. 3766fbed5abfSmrg 376736e956c5SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376836e956c5Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 37695f5b92ffSmrgrequired, except when creating a convenience library. 377017a48c7cSmrg 377136e956c5SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377236e956c5Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 377317a48c7cSmrg 377436e956c5SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 37755f5b92ffSmrgis created, otherwise an executable program is created." 377617a48c7cSmrg ;; 377717a48c7cSmrg 37785f5b92ffSmrg uninstall) 37795f5b92ffSmrg $ECHO \ 37805f5b92ffSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 378117a48c7cSmrg 37825f5b92ffSmrgRemove libraries from an installation directory. 378317a48c7cSmrg 37845f5b92ffSmrgRM is the name of the program to use to delete files associated with each FILE 378536e956c5Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 37865f5b92ffSmrgto RM. 378717a48c7cSmrg 37885f5b92ffSmrgIf FILE is a libtool library, all the files associated with it are deleted. 37895f5b92ffSmrgOtherwise, only FILE itself is deleted using RM." 37905f5b92ffSmrg ;; 379117a48c7cSmrg 37925f5b92ffSmrg *) 379336e956c5Smrg func_fatal_help "invalid operation mode '$opt_mode'" 37945f5b92ffSmrg ;; 37955f5b92ffSmrg esac 379617a48c7cSmrg 37970dd80ee0Smrg echo 379836e956c5Smrg $ECHO "Try '$progname --help' for more information about other modes." 37995f5b92ffSmrg} 380017a48c7cSmrg 38010dd80ee0Smrg# Now that we've collected a possible --mode arg, show help if necessary 38020dd80ee0Smrgif $opt_help; then 380336e956c5Smrg if test : = "$opt_help"; then 38040dd80ee0Smrg func_mode_help 38050dd80ee0Smrg else 38060dd80ee0Smrg { 38070dd80ee0Smrg func_help noexit 38080dd80ee0Smrg for opt_mode in compile link execute install finish uninstall clean; do 38090dd80ee0Smrg func_mode_help 38100dd80ee0Smrg done 381136e956c5Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 38120dd80ee0Smrg { 38130dd80ee0Smrg func_help noexit 38140dd80ee0Smrg for opt_mode in compile link execute install finish uninstall clean; do 38150dd80ee0Smrg echo 38160dd80ee0Smrg func_mode_help 38170dd80ee0Smrg done 38180dd80ee0Smrg } | 381936e956c5Smrg $SED '1d 38200dd80ee0Smrg /^When reporting/,/^Report/{ 38210dd80ee0Smrg H 38220dd80ee0Smrg d 38230dd80ee0Smrg } 38240dd80ee0Smrg $x 38250dd80ee0Smrg /information about other modes/d 38260dd80ee0Smrg /more detailed .*MODE/d 38270dd80ee0Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 38280dd80ee0Smrg fi 38290dd80ee0Smrg exit $? 38300dd80ee0Smrgfi 383117a48c7cSmrg 383217a48c7cSmrg 38335f5b92ffSmrg# func_mode_execute arg... 38345f5b92ffSmrgfunc_mode_execute () 38355f5b92ffSmrg{ 383636e956c5Smrg $debug_cmd 383736e956c5Smrg 38385f5b92ffSmrg # The first argument is the command name. 383936e956c5Smrg cmd=$nonopt 38405f5b92ffSmrg test -z "$cmd" && \ 38415f5b92ffSmrg func_fatal_help "you must specify a COMMAND" 384217a48c7cSmrg 38435f5b92ffSmrg # Handle -dlopen flags immediately. 38440dd80ee0Smrg for file in $opt_dlopen; do 38455f5b92ffSmrg test -f "$file" \ 384636e956c5Smrg || func_fatal_help "'$file' is not a file" 384717a48c7cSmrg 38485f5b92ffSmrg dir= 38495f5b92ffSmrg case $file in 38505f5b92ffSmrg *.la) 38510dd80ee0Smrg func_resolve_sysroot "$file" 38520dd80ee0Smrg file=$func_resolve_sysroot_result 38530dd80ee0Smrg 38545f5b92ffSmrg # Check to see that this really is a libtool archive. 38555f5b92ffSmrg func_lalib_unsafe_p "$file" \ 385636e956c5Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 385717a48c7cSmrg 38585f5b92ffSmrg # Read the libtool library. 38595f5b92ffSmrg dlname= 38605f5b92ffSmrg library_names= 38615f5b92ffSmrg func_source "$file" 386217a48c7cSmrg 38635f5b92ffSmrg # Skip this library if it cannot be dlopened. 38645f5b92ffSmrg if test -z "$dlname"; then 38655f5b92ffSmrg # Warn if it was a shared library. 38665f5b92ffSmrg test -n "$library_names" && \ 386736e956c5Smrg func_warning "'$file' was not linked with '-export-dynamic'" 38685f5b92ffSmrg continue 38695f5b92ffSmrg fi 387017a48c7cSmrg 38715f5b92ffSmrg func_dirname "$file" "" "." 387236e956c5Smrg dir=$func_dirname_result 387317a48c7cSmrg 38745f5b92ffSmrg if test -f "$dir/$objdir/$dlname"; then 38750dd80ee0Smrg func_append dir "/$objdir" 38765f5b92ffSmrg else 38775f5b92ffSmrg if test ! -f "$dir/$dlname"; then 387836e956c5Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 38795f5b92ffSmrg fi 38805f5b92ffSmrg fi 388117a48c7cSmrg ;; 388217a48c7cSmrg 38835f5b92ffSmrg *.lo) 38845f5b92ffSmrg # Just add the directory containing the .lo file. 38855f5b92ffSmrg func_dirname "$file" "" "." 388636e956c5Smrg dir=$func_dirname_result 388717a48c7cSmrg ;; 388817a48c7cSmrg 38895f5b92ffSmrg *) 389036e956c5Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 389117a48c7cSmrg continue 389217a48c7cSmrg ;; 38935f5b92ffSmrg esac 389417a48c7cSmrg 38955f5b92ffSmrg # Get the absolute pathname. 38965f5b92ffSmrg absdir=`cd "$dir" && pwd` 389736e956c5Smrg test -n "$absdir" && dir=$absdir 389817a48c7cSmrg 38995f5b92ffSmrg # Now add the directory to shlibpath_var. 39005f5b92ffSmrg if eval "test -z \"\$$shlibpath_var\""; then 39015f5b92ffSmrg eval "$shlibpath_var=\"\$dir\"" 39025f5b92ffSmrg else 39035f5b92ffSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 39045f5b92ffSmrg fi 39055f5b92ffSmrg done 390617a48c7cSmrg 39075f5b92ffSmrg # This variable tells wrapper scripts just to set shlibpath_var 39085f5b92ffSmrg # rather than running their programs. 390936e956c5Smrg libtool_execute_magic=$magic 391017a48c7cSmrg 39115f5b92ffSmrg # Check if any of the arguments is a wrapper script. 39125f5b92ffSmrg args= 39135f5b92ffSmrg for file 39145f5b92ffSmrg do 39155f5b92ffSmrg case $file in 39160dd80ee0Smrg -* | *.la | *.lo ) ;; 39175f5b92ffSmrg *) 39185f5b92ffSmrg # Do a test to see if this is really a libtool program. 39195f5b92ffSmrg if func_ltwrapper_script_p "$file"; then 39205f5b92ffSmrg func_source "$file" 39215f5b92ffSmrg # Transform arg to wrapped name. 392236e956c5Smrg file=$progdir/$program 39235f5b92ffSmrg elif func_ltwrapper_executable_p "$file"; then 39245f5b92ffSmrg func_ltwrapper_scriptname "$file" 39255f5b92ffSmrg func_source "$func_ltwrapper_scriptname_result" 39265f5b92ffSmrg # Transform arg to wrapped name. 392736e956c5Smrg file=$progdir/$program 39285f5b92ffSmrg fi 39295f5b92ffSmrg ;; 39305f5b92ffSmrg esac 39315f5b92ffSmrg # Quote arguments (to preserve shell metacharacters). 39320dd80ee0Smrg func_append_quoted args "$file" 39335f5b92ffSmrg done 393417a48c7cSmrg 393536e956c5Smrg if $opt_dry_run; then 393636e956c5Smrg # Display what would be done. 393736e956c5Smrg if test -n "$shlibpath_var"; then 393836e956c5Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393936e956c5Smrg echo "export $shlibpath_var" 394036e956c5Smrg fi 394136e956c5Smrg $ECHO "$cmd$args" 394236e956c5Smrg exit $EXIT_SUCCESS 394336e956c5Smrg else 39445f5b92ffSmrg if test -n "$shlibpath_var"; then 39455f5b92ffSmrg # Export the shlibpath_var. 39465f5b92ffSmrg eval "export $shlibpath_var" 39475f5b92ffSmrg fi 394817a48c7cSmrg 39495f5b92ffSmrg # Restore saved environment variables 39505f5b92ffSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 39515f5b92ffSmrg do 39525f5b92ffSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 39535f5b92ffSmrg $lt_var=\$save_$lt_var; export $lt_var 395417a48c7cSmrg else 39555f5b92ffSmrg $lt_unset $lt_var 39565f5b92ffSmrg fi" 39575f5b92ffSmrg done 395817a48c7cSmrg 39595f5b92ffSmrg # Now prepare to actually exec the command. 396036e956c5Smrg exec_cmd=\$cmd$args 39615f5b92ffSmrg fi 39625f5b92ffSmrg} 396317a48c7cSmrg 396436e956c5Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 396517a48c7cSmrg 396617a48c7cSmrg 39675f5b92ffSmrg# func_mode_finish arg... 39685f5b92ffSmrgfunc_mode_finish () 39695f5b92ffSmrg{ 397036e956c5Smrg $debug_cmd 397136e956c5Smrg 39720dd80ee0Smrg libs= 39730dd80ee0Smrg libdirs= 39745f5b92ffSmrg admincmds= 397517a48c7cSmrg 39760dd80ee0Smrg for opt in "$nonopt" ${1+"$@"} 39770dd80ee0Smrg do 39780dd80ee0Smrg if test -d "$opt"; then 39790dd80ee0Smrg func_append libdirs " $opt" 39800dd80ee0Smrg 39810dd80ee0Smrg elif test -f "$opt"; then 39820dd80ee0Smrg if func_lalib_unsafe_p "$opt"; then 39830dd80ee0Smrg func_append libs " $opt" 39840dd80ee0Smrg else 398536e956c5Smrg func_warning "'$opt' is not a valid libtool archive" 39860dd80ee0Smrg fi 39870dd80ee0Smrg 39880dd80ee0Smrg else 398936e956c5Smrg func_fatal_error "invalid argument '$opt'" 39900dd80ee0Smrg fi 39910dd80ee0Smrg done 39920dd80ee0Smrg 39930dd80ee0Smrg if test -n "$libs"; then 39940dd80ee0Smrg if test -n "$lt_sysroot"; then 39950dd80ee0Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 39960dd80ee0Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 39970dd80ee0Smrg else 39980dd80ee0Smrg sysroot_cmd= 39990dd80ee0Smrg fi 40000dd80ee0Smrg 40010dd80ee0Smrg # Remove sysroot references 40020dd80ee0Smrg if $opt_dry_run; then 40030dd80ee0Smrg for lib in $libs; do 400436e956c5Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 40050dd80ee0Smrg done 40060dd80ee0Smrg else 40070dd80ee0Smrg tmpdir=`func_mktempdir` 40080dd80ee0Smrg for lib in $libs; do 400936e956c5Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 40100dd80ee0Smrg > $tmpdir/tmp-la 40110dd80ee0Smrg mv -f $tmpdir/tmp-la $lib 40120dd80ee0Smrg done 40130dd80ee0Smrg ${RM}r "$tmpdir" 40140dd80ee0Smrg fi 40150dd80ee0Smrg fi 401617a48c7cSmrg 40170dd80ee0Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40185f5b92ffSmrg for libdir in $libdirs; do 40195f5b92ffSmrg if test -n "$finish_cmds"; then 40205f5b92ffSmrg # Do each command in the finish commands. 40215f5b92ffSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 40225f5b92ffSmrg'"$cmd"'"' 402317a48c7cSmrg fi 40245f5b92ffSmrg if test -n "$finish_eval"; then 40255f5b92ffSmrg # Do the single finish_eval. 40265f5b92ffSmrg eval cmds=\"$finish_eval\" 40270dd80ee0Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 40285f5b92ffSmrg $cmds" 40295f5b92ffSmrg fi 40305f5b92ffSmrg done 40315f5b92ffSmrg fi 403217a48c7cSmrg 40335f5b92ffSmrg # Exit here if they wanted silent mode. 403436e956c5Smrg $opt_quiet && exit $EXIT_SUCCESS 403517a48c7cSmrg 40360dd80ee0Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40370dd80ee0Smrg echo "----------------------------------------------------------------------" 40380dd80ee0Smrg echo "Libraries have been installed in:" 40390dd80ee0Smrg for libdir in $libdirs; do 40400dd80ee0Smrg $ECHO " $libdir" 40410dd80ee0Smrg done 40420dd80ee0Smrg echo 40430dd80ee0Smrg echo "If you ever happen to want to link against installed libraries" 40440dd80ee0Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404536e956c5Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 40460dd80ee0Smrg echo "flag during linking and do at least one of the following:" 40470dd80ee0Smrg if test -n "$shlibpath_var"; then 404836e956c5Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 40490dd80ee0Smrg echo " during execution" 40500dd80ee0Smrg fi 40510dd80ee0Smrg if test -n "$runpath_var"; then 405236e956c5Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 40530dd80ee0Smrg echo " during linking" 40540dd80ee0Smrg fi 40550dd80ee0Smrg if test -n "$hardcode_libdir_flag_spec"; then 40560dd80ee0Smrg libdir=LIBDIR 40570dd80ee0Smrg eval flag=\"$hardcode_libdir_flag_spec\" 40585f5b92ffSmrg 405936e956c5Smrg $ECHO " - use the '$flag' linker flag" 40600dd80ee0Smrg fi 40610dd80ee0Smrg if test -n "$admincmds"; then 40620dd80ee0Smrg $ECHO " - have your system administrator run these commands:$admincmds" 40630dd80ee0Smrg fi 40640dd80ee0Smrg if test -f /etc/ld.so.conf; then 406536e956c5Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 40660dd80ee0Smrg fi 40670dd80ee0Smrg echo 40685f5b92ffSmrg 40690dd80ee0Smrg echo "See any operating system documentation about shared libraries for" 40700dd80ee0Smrg case $host in 40710dd80ee0Smrg solaris2.[6789]|solaris2.1[0-9]) 40720dd80ee0Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 40730dd80ee0Smrg echo "pages." 40740dd80ee0Smrg ;; 40750dd80ee0Smrg *) 40760dd80ee0Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 40770dd80ee0Smrg ;; 40780dd80ee0Smrg esac 40790dd80ee0Smrg echo "----------------------------------------------------------------------" 40800dd80ee0Smrg fi 40815f5b92ffSmrg exit $EXIT_SUCCESS 40825f5b92ffSmrg} 40835f5b92ffSmrg 408436e956c5Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 40855f5b92ffSmrg 40865f5b92ffSmrg 40875f5b92ffSmrg# func_mode_install arg... 40885f5b92ffSmrgfunc_mode_install () 40895f5b92ffSmrg{ 409036e956c5Smrg $debug_cmd 409136e956c5Smrg 40925f5b92ffSmrg # There may be an optional sh(1) argument at the beginning of 40935f5b92ffSmrg # install_prog (especially on Windows NT). 409436e956c5Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 40955f5b92ffSmrg # Allow the use of GNU shtool's install command. 409636e956c5Smrg case $nonopt in *shtool*) :;; *) false;; esac 409736e956c5Smrg then 40985f5b92ffSmrg # Aesthetically quote it. 40995f5b92ffSmrg func_quote_for_eval "$nonopt" 41005f5b92ffSmrg install_prog="$func_quote_for_eval_result " 41015f5b92ffSmrg arg=$1 41025f5b92ffSmrg shift 41035f5b92ffSmrg else 41045f5b92ffSmrg install_prog= 41055f5b92ffSmrg arg=$nonopt 41065f5b92ffSmrg fi 41075f5b92ffSmrg 41085f5b92ffSmrg # The real first argument should be the name of the installation program. 41095f5b92ffSmrg # Aesthetically quote it. 41105f5b92ffSmrg func_quote_for_eval "$arg" 41110dd80ee0Smrg func_append install_prog "$func_quote_for_eval_result" 41120dd80ee0Smrg install_shared_prog=$install_prog 41130dd80ee0Smrg case " $install_prog " in 41140dd80ee0Smrg *[\\\ /]cp\ *) install_cp=: ;; 41150dd80ee0Smrg *) install_cp=false ;; 41160dd80ee0Smrg esac 41175f5b92ffSmrg 41185f5b92ffSmrg # We need to accept at least all the BSD install flags. 41195f5b92ffSmrg dest= 41205f5b92ffSmrg files= 41215f5b92ffSmrg opts= 41225f5b92ffSmrg prev= 41235f5b92ffSmrg install_type= 412436e956c5Smrg isdir=false 41255f5b92ffSmrg stripme= 41260dd80ee0Smrg no_mode=: 41275f5b92ffSmrg for arg 41285f5b92ffSmrg do 41290dd80ee0Smrg arg2= 41305f5b92ffSmrg if test -n "$dest"; then 41310dd80ee0Smrg func_append files " $dest" 41325f5b92ffSmrg dest=$arg 41335f5b92ffSmrg continue 41345f5b92ffSmrg fi 41355f5b92ffSmrg 41365f5b92ffSmrg case $arg in 413736e956c5Smrg -d) isdir=: ;; 41385f5b92ffSmrg -f) 41390dd80ee0Smrg if $install_cp; then :; else 41400dd80ee0Smrg prev=$arg 41410dd80ee0Smrg fi 41425f5b92ffSmrg ;; 41435f5b92ffSmrg -g | -m | -o) 41445f5b92ffSmrg prev=$arg 41455f5b92ffSmrg ;; 41465f5b92ffSmrg -s) 41475f5b92ffSmrg stripme=" -s" 41485f5b92ffSmrg continue 41495f5b92ffSmrg ;; 41505f5b92ffSmrg -*) 41515f5b92ffSmrg ;; 41525f5b92ffSmrg *) 41535f5b92ffSmrg # If the previous option needed an argument, then skip it. 41545f5b92ffSmrg if test -n "$prev"; then 415536e956c5Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 41560dd80ee0Smrg arg2=$install_override_mode 41570dd80ee0Smrg no_mode=false 41580dd80ee0Smrg fi 415917a48c7cSmrg prev= 416017a48c7cSmrg else 41615f5b92ffSmrg dest=$arg 41625f5b92ffSmrg continue 416317a48c7cSmrg fi 416417a48c7cSmrg ;; 41655f5b92ffSmrg esac 416617a48c7cSmrg 41675f5b92ffSmrg # Aesthetically quote the argument. 41685f5b92ffSmrg func_quote_for_eval "$arg" 41690dd80ee0Smrg func_append install_prog " $func_quote_for_eval_result" 41700dd80ee0Smrg if test -n "$arg2"; then 41710dd80ee0Smrg func_quote_for_eval "$arg2" 41720dd80ee0Smrg fi 41730dd80ee0Smrg func_append install_shared_prog " $func_quote_for_eval_result" 41745f5b92ffSmrg done 417517a48c7cSmrg 41765f5b92ffSmrg test -z "$install_prog" && \ 41775f5b92ffSmrg func_fatal_help "you must specify an install program" 417817a48c7cSmrg 41795f5b92ffSmrg test -n "$prev" && \ 418036e956c5Smrg func_fatal_help "the '$prev' option requires an argument" 418117a48c7cSmrg 41820dd80ee0Smrg if test -n "$install_override_mode" && $no_mode; then 41830dd80ee0Smrg if $install_cp; then :; else 41840dd80ee0Smrg func_quote_for_eval "$install_override_mode" 41850dd80ee0Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 41860dd80ee0Smrg fi 41870dd80ee0Smrg fi 41880dd80ee0Smrg 41895f5b92ffSmrg if test -z "$files"; then 41905f5b92ffSmrg if test -z "$dest"; then 41915f5b92ffSmrg func_fatal_help "no file or destination specified" 41925f5b92ffSmrg else 41935f5b92ffSmrg func_fatal_help "you must specify a destination" 41945f5b92ffSmrg fi 419517a48c7cSmrg fi 419617a48c7cSmrg 41975f5b92ffSmrg # Strip any trailing slash from the destination. 41985f5b92ffSmrg func_stripname '' '/' "$dest" 41995f5b92ffSmrg dest=$func_stripname_result 420017a48c7cSmrg 42015f5b92ffSmrg # Check to see that the destination is a directory. 420236e956c5Smrg test -d "$dest" && isdir=: 420336e956c5Smrg if $isdir; then 420436e956c5Smrg destdir=$dest 42055f5b92ffSmrg destname= 420617a48c7cSmrg else 42075f5b92ffSmrg func_dirname_and_basename "$dest" "" "." 420836e956c5Smrg destdir=$func_dirname_result 420936e956c5Smrg destname=$func_basename_result 421017a48c7cSmrg 42115f5b92ffSmrg # Not a directory, so check to see that there is only one file specified. 42125f5b92ffSmrg set dummy $files; shift 42135f5b92ffSmrg test "$#" -gt 1 && \ 421436e956c5Smrg func_fatal_help "'$dest' is not a directory" 421517a48c7cSmrg fi 42165f5b92ffSmrg case $destdir in 42175f5b92ffSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 421817a48c7cSmrg *) 42195f5b92ffSmrg for file in $files; do 42205f5b92ffSmrg case $file in 42215f5b92ffSmrg *.lo) ;; 42225f5b92ffSmrg *) 422336e956c5Smrg func_fatal_help "'$destdir' must be an absolute directory name" 42245f5b92ffSmrg ;; 42255f5b92ffSmrg esac 42265f5b92ffSmrg done 422717a48c7cSmrg ;; 422817a48c7cSmrg esac 422917a48c7cSmrg 42305f5b92ffSmrg # This variable tells wrapper scripts just to set variables rather 42315f5b92ffSmrg # than running their programs. 423236e956c5Smrg libtool_install_magic=$magic 423317a48c7cSmrg 42345f5b92ffSmrg staticlibs= 42355f5b92ffSmrg future_libdirs= 42365f5b92ffSmrg current_libdirs= 42375f5b92ffSmrg for file in $files; do 423817a48c7cSmrg 42395f5b92ffSmrg # Do each installation. 42405f5b92ffSmrg case $file in 42415f5b92ffSmrg *.$libext) 42425f5b92ffSmrg # Do the static libraries later. 42430dd80ee0Smrg func_append staticlibs " $file" 42445f5b92ffSmrg ;; 42455f5b92ffSmrg 42465f5b92ffSmrg *.la) 42470dd80ee0Smrg func_resolve_sysroot "$file" 42480dd80ee0Smrg file=$func_resolve_sysroot_result 42490dd80ee0Smrg 42505f5b92ffSmrg # Check to see that this really is a libtool archive. 42515f5b92ffSmrg func_lalib_unsafe_p "$file" \ 425236e956c5Smrg || func_fatal_help "'$file' is not a valid libtool archive" 42535f5b92ffSmrg 42545f5b92ffSmrg library_names= 42555f5b92ffSmrg old_library= 42565f5b92ffSmrg relink_command= 42575f5b92ffSmrg func_source "$file" 42585f5b92ffSmrg 42595f5b92ffSmrg # Add the libdir to current_libdirs if it is the destination. 42605f5b92ffSmrg if test "X$destdir" = "X$libdir"; then 42615f5b92ffSmrg case "$current_libdirs " in 42625f5b92ffSmrg *" $libdir "*) ;; 42630dd80ee0Smrg *) func_append current_libdirs " $libdir" ;; 426417a48c7cSmrg esac 42655f5b92ffSmrg else 42665f5b92ffSmrg # Note the libdir as a future libdir. 42675f5b92ffSmrg case "$future_libdirs " in 42685f5b92ffSmrg *" $libdir "*) ;; 42690dd80ee0Smrg *) func_append future_libdirs " $libdir" ;; 42705f5b92ffSmrg esac 42715f5b92ffSmrg fi 427217a48c7cSmrg 42735f5b92ffSmrg func_dirname "$file" "/" "" 427436e956c5Smrg dir=$func_dirname_result 42750dd80ee0Smrg func_append dir "$objdir" 42765f5b92ffSmrg 42775f5b92ffSmrg if test -n "$relink_command"; then 42785f5b92ffSmrg # Determine the prefix the user has applied to our future dir. 42790dd80ee0Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 42805f5b92ffSmrg 42815f5b92ffSmrg # Don't allow the user to place us outside of our expected 42825f5b92ffSmrg # location b/c this prevents finding dependent libraries that 42835f5b92ffSmrg # are installed to the same prefix. 42845f5b92ffSmrg # At present, this check doesn't affect windows .dll's that 42855f5b92ffSmrg # are installed into $libdir/../bin (currently, that works fine) 42865f5b92ffSmrg # but it's something to keep an eye on. 42875f5b92ffSmrg test "$inst_prefix_dir" = "$destdir" && \ 428836e956c5Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 42895f5b92ffSmrg 42905f5b92ffSmrg if test -n "$inst_prefix_dir"; then 42915f5b92ffSmrg # Stick the inst_prefix_dir data into the link command. 42920dd80ee0Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 42935f5b92ffSmrg else 42940dd80ee0Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 42955f5b92ffSmrg fi 42965f5b92ffSmrg 429736e956c5Smrg func_warning "relinking '$file'" 42985f5b92ffSmrg func_show_eval "$relink_command" \ 429936e956c5Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 43005f5b92ffSmrg fi 43015f5b92ffSmrg 43025f5b92ffSmrg # See the names of the shared library. 43035f5b92ffSmrg set dummy $library_names; shift 43045f5b92ffSmrg if test -n "$1"; then 430536e956c5Smrg realname=$1 43065f5b92ffSmrg shift 43075f5b92ffSmrg 430836e956c5Smrg srcname=$realname 430936e956c5Smrg test -n "$relink_command" && srcname=${realname}T 43105f5b92ffSmrg 43115f5b92ffSmrg # Install the shared library and build the symlinks. 43120dd80ee0Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 43135f5b92ffSmrg 'exit $?' 431436e956c5Smrg tstripme=$stripme 43155f5b92ffSmrg case $host_os in 43165f5b92ffSmrg cygwin* | mingw* | pw32* | cegcc*) 43175f5b92ffSmrg case $realname in 43185f5b92ffSmrg *.dll.a) 431936e956c5Smrg tstripme= 432036e956c5Smrg ;; 432136e956c5Smrg esac 432236e956c5Smrg ;; 432336e956c5Smrg os2*) 432436e956c5Smrg case $realname in 432536e956c5Smrg *_dll.a) 432636e956c5Smrg tstripme= 43275f5b92ffSmrg ;; 43285f5b92ffSmrg esac 432917a48c7cSmrg ;; 433017a48c7cSmrg esac 43315f5b92ffSmrg if test -n "$tstripme" && test -n "$striplib"; then 43325f5b92ffSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 433317a48c7cSmrg fi 43345f5b92ffSmrg 43355f5b92ffSmrg if test "$#" -gt 0; then 43365f5b92ffSmrg # Delete the old symlinks, and create new ones. 433736e956c5Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 43385f5b92ffSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 43395f5b92ffSmrg # so we also need to try rm && ln -s. 43405f5b92ffSmrg for linkname 43415f5b92ffSmrg do 43425f5b92ffSmrg test "$linkname" != "$realname" \ 43435f5b92ffSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 434417a48c7cSmrg done 434517a48c7cSmrg fi 434617a48c7cSmrg 43475f5b92ffSmrg # Do each command in the postinstall commands. 434836e956c5Smrg lib=$destdir/$realname 43495f5b92ffSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 435017a48c7cSmrg fi 435117a48c7cSmrg 43525f5b92ffSmrg # Install the pseudo-library for information purposes. 43535f5b92ffSmrg func_basename "$file" 435436e956c5Smrg name=$func_basename_result 435536e956c5Smrg instname=$dir/${name}i 43565f5b92ffSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 435717a48c7cSmrg 43585f5b92ffSmrg # Maybe install the static library, too. 43590dd80ee0Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 43605f5b92ffSmrg ;; 436117a48c7cSmrg 43625f5b92ffSmrg *.lo) 43635f5b92ffSmrg # Install (i.e. copy) a libtool object. 436417a48c7cSmrg 43655f5b92ffSmrg # Figure out destination file name, if it wasn't already specified. 43665f5b92ffSmrg if test -n "$destname"; then 436736e956c5Smrg destfile=$destdir/$destname 43685f5b92ffSmrg else 43695f5b92ffSmrg func_basename "$file" 437036e956c5Smrg destfile=$func_basename_result 437136e956c5Smrg destfile=$destdir/$destfile 437217a48c7cSmrg fi 437317a48c7cSmrg 43745f5b92ffSmrg # Deduce the name of the destination old-style object file. 43755f5b92ffSmrg case $destfile in 43765f5b92ffSmrg *.lo) 43775f5b92ffSmrg func_lo2o "$destfile" 43785f5b92ffSmrg staticdest=$func_lo2o_result 43795f5b92ffSmrg ;; 43805f5b92ffSmrg *.$objext) 438136e956c5Smrg staticdest=$destfile 43825f5b92ffSmrg destfile= 43835f5b92ffSmrg ;; 43845f5b92ffSmrg *) 438536e956c5Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 43865f5b92ffSmrg ;; 43875f5b92ffSmrg esac 438817a48c7cSmrg 43895f5b92ffSmrg # Install the libtool object if requested. 43905f5b92ffSmrg test -n "$destfile" && \ 43915f5b92ffSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 439217a48c7cSmrg 43935f5b92ffSmrg # Install the old object if enabled. 439436e956c5Smrg if test yes = "$build_old_libs"; then 43955f5b92ffSmrg # Deduce the name of the old-style object file. 43965f5b92ffSmrg func_lo2o "$file" 43975f5b92ffSmrg staticobj=$func_lo2o_result 43985f5b92ffSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 439917a48c7cSmrg fi 44005f5b92ffSmrg exit $EXIT_SUCCESS 44015f5b92ffSmrg ;; 440217a48c7cSmrg 44035f5b92ffSmrg *) 44045f5b92ffSmrg # Figure out destination file name, if it wasn't already specified. 44055f5b92ffSmrg if test -n "$destname"; then 440636e956c5Smrg destfile=$destdir/$destname 44075f5b92ffSmrg else 44085f5b92ffSmrg func_basename "$file" 440936e956c5Smrg destfile=$func_basename_result 441036e956c5Smrg destfile=$destdir/$destfile 44115f5b92ffSmrg fi 441217a48c7cSmrg 44135f5b92ffSmrg # If the file is missing, and there is a .exe on the end, strip it 44145f5b92ffSmrg # because it is most likely a libtool script we actually want to 44155f5b92ffSmrg # install 441636e956c5Smrg stripped_ext= 44175f5b92ffSmrg case $file in 44185f5b92ffSmrg *.exe) 44195f5b92ffSmrg if test ! -f "$file"; then 44205f5b92ffSmrg func_stripname '' '.exe' "$file" 44215f5b92ffSmrg file=$func_stripname_result 442236e956c5Smrg stripped_ext=.exe 44235f5b92ffSmrg fi 44245f5b92ffSmrg ;; 44255f5b92ffSmrg esac 44265f5b92ffSmrg 44275f5b92ffSmrg # Do a test to see if this is really a libtool program. 44285f5b92ffSmrg case $host in 44295f5b92ffSmrg *cygwin* | *mingw*) 44305f5b92ffSmrg if func_ltwrapper_executable_p "$file"; then 44315f5b92ffSmrg func_ltwrapper_scriptname "$file" 44325f5b92ffSmrg wrapper=$func_ltwrapper_scriptname_result 44335f5b92ffSmrg else 44345f5b92ffSmrg func_stripname '' '.exe' "$file" 44355f5b92ffSmrg wrapper=$func_stripname_result 44365f5b92ffSmrg fi 44375f5b92ffSmrg ;; 443817a48c7cSmrg *) 44395f5b92ffSmrg wrapper=$file 44405f5b92ffSmrg ;; 44415f5b92ffSmrg esac 44425f5b92ffSmrg if func_ltwrapper_script_p "$wrapper"; then 44435f5b92ffSmrg notinst_deplibs= 44445f5b92ffSmrg relink_command= 44455f5b92ffSmrg 44465f5b92ffSmrg func_source "$wrapper" 44475f5b92ffSmrg 44485f5b92ffSmrg # Check the variables that should have been set. 44495f5b92ffSmrg test -z "$generated_by_libtool_version" && \ 445036e956c5Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 44515f5b92ffSmrg 445236e956c5Smrg finalize=: 44535f5b92ffSmrg for lib in $notinst_deplibs; do 44545f5b92ffSmrg # Check to see that each library is installed. 44555f5b92ffSmrg libdir= 44565f5b92ffSmrg if test -f "$lib"; then 44575f5b92ffSmrg func_source "$lib" 44585f5b92ffSmrg fi 445936e956c5Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 44605f5b92ffSmrg if test -n "$libdir" && test ! -f "$libfile"; then 446136e956c5Smrg func_warning "'$lib' has not been installed in '$libdir'" 446236e956c5Smrg finalize=false 44635f5b92ffSmrg fi 44645f5b92ffSmrg done 44655f5b92ffSmrg 44665f5b92ffSmrg relink_command= 44675f5b92ffSmrg func_source "$wrapper" 44685f5b92ffSmrg 44695f5b92ffSmrg outputname= 447036e956c5Smrg if test no = "$fast_install" && test -n "$relink_command"; then 44715f5b92ffSmrg $opt_dry_run || { 447236e956c5Smrg if $finalize; then 44735f5b92ffSmrg tmpdir=`func_mktempdir` 44745f5b92ffSmrg func_basename "$file$stripped_ext" 447536e956c5Smrg file=$func_basename_result 447636e956c5Smrg outputname=$tmpdir/$file 44775f5b92ffSmrg # Replace the output file specification. 44780dd80ee0Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 44795f5b92ffSmrg 448036e956c5Smrg $opt_quiet || { 44815f5b92ffSmrg func_quote_for_expand "$relink_command" 44825f5b92ffSmrg eval "func_echo $func_quote_for_expand_result" 44835f5b92ffSmrg } 44845f5b92ffSmrg if eval "$relink_command"; then : 44855f5b92ffSmrg else 448636e956c5Smrg func_error "error: relink '$file' with the above command before installing it" 44875f5b92ffSmrg $opt_dry_run || ${RM}r "$tmpdir" 44885f5b92ffSmrg continue 44895f5b92ffSmrg fi 449036e956c5Smrg file=$outputname 44915f5b92ffSmrg else 449236e956c5Smrg func_warning "cannot relink '$file'" 44935f5b92ffSmrg fi 44945f5b92ffSmrg } 44955f5b92ffSmrg else 44965f5b92ffSmrg # Install the binary that we compiled earlier. 44970dd80ee0Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 449817a48c7cSmrg fi 44995f5b92ffSmrg fi 45005f5b92ffSmrg 45015f5b92ffSmrg # remove .exe since cygwin /usr/bin/install will append another 45025f5b92ffSmrg # one anyway 45035f5b92ffSmrg case $install_prog,$host in 45045f5b92ffSmrg */usr/bin/install*,*cygwin*) 45055f5b92ffSmrg case $file:$destfile in 45065f5b92ffSmrg *.exe:*.exe) 45075f5b92ffSmrg # this is ok 45085f5b92ffSmrg ;; 45095f5b92ffSmrg *.exe:*) 45105f5b92ffSmrg destfile=$destfile.exe 45115f5b92ffSmrg ;; 45125f5b92ffSmrg *:*.exe) 45135f5b92ffSmrg func_stripname '' '.exe' "$destfile" 45145f5b92ffSmrg destfile=$func_stripname_result 45155f5b92ffSmrg ;; 45165f5b92ffSmrg esac 451717a48c7cSmrg ;; 451817a48c7cSmrg esac 45195f5b92ffSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 45205f5b92ffSmrg $opt_dry_run || if test -n "$outputname"; then 45215f5b92ffSmrg ${RM}r "$tmpdir" 45225f5b92ffSmrg fi 45235f5b92ffSmrg ;; 45245f5b92ffSmrg esac 45255f5b92ffSmrg done 452617a48c7cSmrg 45275f5b92ffSmrg for file in $staticlibs; do 45285f5b92ffSmrg func_basename "$file" 452936e956c5Smrg name=$func_basename_result 45305f5b92ffSmrg 45315f5b92ffSmrg # Set up the ranlib parameters. 453236e956c5Smrg oldlib=$destdir/$name 45330dd80ee0Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 45340dd80ee0Smrg tool_oldlib=$func_to_tool_file_result 45355f5b92ffSmrg 45365f5b92ffSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 45375f5b92ffSmrg 45385f5b92ffSmrg if test -n "$stripme" && test -n "$old_striplib"; then 45390dd80ee0Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 45405f5b92ffSmrg fi 45415f5b92ffSmrg 45425f5b92ffSmrg # Do each command in the postinstall commands. 45435f5b92ffSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 45445f5b92ffSmrg done 45455f5b92ffSmrg 45465f5b92ffSmrg test -n "$future_libdirs" && \ 454736e956c5Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 45485f5b92ffSmrg 45495f5b92ffSmrg if test -n "$current_libdirs"; then 45505f5b92ffSmrg # Maybe just do a dry run. 45515f5b92ffSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455236e956c5Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 45535f5b92ffSmrg else 45545f5b92ffSmrg exit $EXIT_SUCCESS 45555f5b92ffSmrg fi 45565f5b92ffSmrg} 45575f5b92ffSmrg 455836e956c5Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 45595f5b92ffSmrg 45605f5b92ffSmrg 45615f5b92ffSmrg# func_generate_dlsyms outputname originator pic_p 45625f5b92ffSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 45635f5b92ffSmrg# a dlpreopen symbol table. 45645f5b92ffSmrgfunc_generate_dlsyms () 45655f5b92ffSmrg{ 456636e956c5Smrg $debug_cmd 456736e956c5Smrg 456836e956c5Smrg my_outputname=$1 456936e956c5Smrg my_originator=$2 457036e956c5Smrg my_pic_p=${3-false} 457136e956c5Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 45725f5b92ffSmrg my_dlsyms= 45735f5b92ffSmrg 457436e956c5Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 45755f5b92ffSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457636e956c5Smrg my_dlsyms=${my_outputname}S.c 45775f5b92ffSmrg else 45785f5b92ffSmrg func_error "not configured to extract global symbols from dlpreopened files" 45795f5b92ffSmrg fi 45805f5b92ffSmrg fi 45815f5b92ffSmrg 45825f5b92ffSmrg if test -n "$my_dlsyms"; then 45835f5b92ffSmrg case $my_dlsyms in 45845f5b92ffSmrg "") ;; 45855f5b92ffSmrg *.c) 45865f5b92ffSmrg # Discover the nlist of each of the dlfiles. 458736e956c5Smrg nlist=$output_objdir/$my_outputname.nm 45885f5b92ffSmrg 45895f5b92ffSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 45905f5b92ffSmrg 45915f5b92ffSmrg # Parse the name list into a source file. 45925f5b92ffSmrg func_verbose "creating $output_objdir/$my_dlsyms" 45935f5b92ffSmrg 45945f5b92ffSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459536e956c5Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459636e956c5Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 45975f5b92ffSmrg 45985f5b92ffSmrg#ifdef __cplusplus 45995f5b92ffSmrgextern \"C\" { 46005f5b92ffSmrg#endif 46015f5b92ffSmrg 460236e956c5Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 46030dd80ee0Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 46040dd80ee0Smrg#endif 46050dd80ee0Smrg 46060dd80ee0Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460736e956c5Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460836e956c5Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 46090dd80ee0Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 46100dd80ee0Smrg# define LT_DLSYM_CONST 461136e956c5Smrg#elif defined __osf__ 46120dd80ee0Smrg/* This system does not cope well with relocations in const data. */ 46130dd80ee0Smrg# define LT_DLSYM_CONST 46140dd80ee0Smrg#else 46150dd80ee0Smrg# define LT_DLSYM_CONST const 46160dd80ee0Smrg#endif 46170dd80ee0Smrg 461836e956c5Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461936e956c5Smrg 46205f5b92ffSmrg/* External symbol declarations for the compiler. */\ 46215f5b92ffSmrg" 46225f5b92ffSmrg 462336e956c5Smrg if test yes = "$dlself"; then 462436e956c5Smrg func_verbose "generating symbol list for '$output'" 46255f5b92ffSmrg 46265f5b92ffSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 46275f5b92ffSmrg 46285f5b92ffSmrg # Add our own program objects to the symbol list. 46290dd80ee0Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 46305f5b92ffSmrg for progfile in $progfiles; do 46310dd80ee0Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463236e956c5Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 46330dd80ee0Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 46345f5b92ffSmrg done 46355f5b92ffSmrg 46365f5b92ffSmrg if test -n "$exclude_expsyms"; then 46375f5b92ffSmrg $opt_dry_run || { 46385f5b92ffSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 46395f5b92ffSmrg eval '$MV "$nlist"T "$nlist"' 46405f5b92ffSmrg } 464117a48c7cSmrg fi 46425f5b92ffSmrg 46435f5b92ffSmrg if test -n "$export_symbols_regex"; then 46445f5b92ffSmrg $opt_dry_run || { 46455f5b92ffSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 46465f5b92ffSmrg eval '$MV "$nlist"T "$nlist"' 46475f5b92ffSmrg } 46485f5b92ffSmrg fi 46495f5b92ffSmrg 46505f5b92ffSmrg # Prepare the list of exported symbols 46515f5b92ffSmrg if test -z "$export_symbols"; then 465236e956c5Smrg export_symbols=$output_objdir/$outputname.exp 46535f5b92ffSmrg $opt_dry_run || { 46545f5b92ffSmrg $RM $export_symbols 465536e956c5Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 46565f5b92ffSmrg case $host in 46575f5b92ffSmrg *cygwin* | *mingw* | *cegcc* ) 46585f5b92ffSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46595f5b92ffSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 46605f5b92ffSmrg ;; 46615f5b92ffSmrg esac 46625f5b92ffSmrg } 466317a48c7cSmrg else 46645f5b92ffSmrg $opt_dry_run || { 466536e956c5Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 46665f5b92ffSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 46675f5b92ffSmrg eval '$MV "$nlist"T "$nlist"' 46685f5b92ffSmrg case $host in 46690dd80ee0Smrg *cygwin* | *mingw* | *cegcc* ) 46705f5b92ffSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46715f5b92ffSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 46725f5b92ffSmrg ;; 46735f5b92ffSmrg esac 46745f5b92ffSmrg } 467517a48c7cSmrg fi 46765f5b92ffSmrg fi 467717a48c7cSmrg 46785f5b92ffSmrg for dlprefile in $dlprefiles; do 467936e956c5Smrg func_verbose "extracting global C symbols from '$dlprefile'" 46805f5b92ffSmrg func_basename "$dlprefile" 468136e956c5Smrg name=$func_basename_result 46820dd80ee0Smrg case $host in 46830dd80ee0Smrg *cygwin* | *mingw* | *cegcc* ) 46840dd80ee0Smrg # if an import library, we need to obtain dlname 46850dd80ee0Smrg if func_win32_import_lib_p "$dlprefile"; then 46860dd80ee0Smrg func_tr_sh "$dlprefile" 46870dd80ee0Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468836e956c5Smrg dlprefile_dlbasename= 46890dd80ee0Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 46900dd80ee0Smrg # Use subshell, to avoid clobbering current variable values 46910dd80ee0Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469236e956c5Smrg if test -n "$dlprefile_dlname"; then 46930dd80ee0Smrg func_basename "$dlprefile_dlname" 469436e956c5Smrg dlprefile_dlbasename=$func_basename_result 46950dd80ee0Smrg else 46960dd80ee0Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 46970dd80ee0Smrg $sharedlib_from_linklib_cmd "$dlprefile" 46980dd80ee0Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 46990dd80ee0Smrg fi 47000dd80ee0Smrg fi 47010dd80ee0Smrg $opt_dry_run || { 470236e956c5Smrg if test -n "$dlprefile_dlbasename"; then 47030dd80ee0Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 47040dd80ee0Smrg else 47050dd80ee0Smrg func_warning "Could not compute DLL name from $name" 47060dd80ee0Smrg eval '$ECHO ": $name " >> "$nlist"' 47070dd80ee0Smrg fi 47080dd80ee0Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47090dd80ee0Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 47100dd80ee0Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 47110dd80ee0Smrg } 47120dd80ee0Smrg else # not an import lib 47130dd80ee0Smrg $opt_dry_run || { 47140dd80ee0Smrg eval '$ECHO ": $name " >> "$nlist"' 47150dd80ee0Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47160dd80ee0Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47170dd80ee0Smrg } 47180dd80ee0Smrg fi 47190dd80ee0Smrg ;; 47200dd80ee0Smrg *) 47210dd80ee0Smrg $opt_dry_run || { 47220dd80ee0Smrg eval '$ECHO ": $name " >> "$nlist"' 47230dd80ee0Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47240dd80ee0Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47250dd80ee0Smrg } 47260dd80ee0Smrg ;; 47270dd80ee0Smrg esac 47285f5b92ffSmrg done 47295f5b92ffSmrg 47305f5b92ffSmrg $opt_dry_run || { 47315f5b92ffSmrg # Make sure we have at least an empty file. 47325f5b92ffSmrg test -f "$nlist" || : > "$nlist" 47335f5b92ffSmrg 47345f5b92ffSmrg if test -n "$exclude_expsyms"; then 47355f5b92ffSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 47365f5b92ffSmrg $MV "$nlist"T "$nlist" 473717a48c7cSmrg fi 47385f5b92ffSmrg 47395f5b92ffSmrg # Try sorting and uniquifying the output. 47405f5b92ffSmrg if $GREP -v "^: " < "$nlist" | 47415f5b92ffSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 47425f5b92ffSmrg sort -k 3 47435f5b92ffSmrg else 47445f5b92ffSmrg sort +2 47455f5b92ffSmrg fi | 47465f5b92ffSmrg uniq > "$nlist"S; then 47475f5b92ffSmrg : 474817a48c7cSmrg else 47495f5b92ffSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 475017a48c7cSmrg fi 475117a48c7cSmrg 47525f5b92ffSmrg if test -f "$nlist"S; then 47535f5b92ffSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 475417a48c7cSmrg else 47550dd80ee0Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 475617a48c7cSmrg fi 475717a48c7cSmrg 475836e956c5Smrg func_show_eval '$RM "${nlist}I"' 475936e956c5Smrg if test -n "$global_symbol_to_import"; then 476036e956c5Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476136e956c5Smrg fi 476236e956c5Smrg 47630dd80ee0Smrg echo >> "$output_objdir/$my_dlsyms" "\ 476417a48c7cSmrg 47655f5b92ffSmrg/* The mapping between symbol names and symbols. */ 47665f5b92ffSmrgtypedef struct { 47675f5b92ffSmrg const char *name; 47685f5b92ffSmrg void *address; 47695f5b92ffSmrg} lt_dlsymlist; 47700dd80ee0Smrgextern LT_DLSYM_CONST lt_dlsymlist 477136e956c5Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477236e956c5Smrg" 477336e956c5Smrg 477436e956c5Smrg if test -s "$nlist"I; then 477536e956c5Smrg echo >> "$output_objdir/$my_dlsyms" "\ 477636e956c5Smrgstatic void lt_syminit(void) 477736e956c5Smrg{ 477836e956c5Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477936e956c5Smrg for (; symbol->name; ++symbol) 478036e956c5Smrg {" 478136e956c5Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478236e956c5Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478336e956c5Smrg } 478436e956c5Smrg}" 478536e956c5Smrg fi 478636e956c5Smrg echo >> "$output_objdir/$my_dlsyms" "\ 47870dd80ee0SmrgLT_DLSYM_CONST lt_dlsymlist 47885f5b92ffSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 478936e956c5Smrg{ {\"$my_originator\", (void *) 0}," 479036e956c5Smrg 479136e956c5Smrg if test -s "$nlist"I; then 479236e956c5Smrg echo >> "$output_objdir/$my_dlsyms" "\ 479336e956c5Smrg {\"@INIT@\", (void *) <_syminit}," 479436e956c5Smrg fi 479517a48c7cSmrg 47965f5b92ffSmrg case $need_lib_prefix in 47975f5b92ffSmrg no) 47985f5b92ffSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 47995f5b92ffSmrg ;; 48005f5b92ffSmrg *) 48015f5b92ffSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 48025f5b92ffSmrg ;; 48035f5b92ffSmrg esac 48040dd80ee0Smrg echo >> "$output_objdir/$my_dlsyms" "\ 48055f5b92ffSmrg {0, (void *) 0} 48065f5b92ffSmrg}; 480717a48c7cSmrg 48085f5b92ffSmrg/* This works around a problem in FreeBSD linker */ 48095f5b92ffSmrg#ifdef FREEBSD_WORKAROUND 48105f5b92ffSmrgstatic const void *lt_preloaded_setup() { 48115f5b92ffSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 48125f5b92ffSmrg} 48135f5b92ffSmrg#endif 48145f5b92ffSmrg 48155f5b92ffSmrg#ifdef __cplusplus 48165f5b92ffSmrg} 48175f5b92ffSmrg#endif\ 48185f5b92ffSmrg" 48195f5b92ffSmrg } # !$opt_dry_run 48205f5b92ffSmrg 48215f5b92ffSmrg pic_flag_for_symtable= 48225f5b92ffSmrg case "$compile_command " in 48235f5b92ffSmrg *" -static "*) ;; 48245f5b92ffSmrg *) 48255f5b92ffSmrg case $host in 48265f5b92ffSmrg # compiling the symbol table file with pic_flag works around 48275f5b92ffSmrg # a FreeBSD bug that causes programs to crash when -lm is 48285f5b92ffSmrg # linked before any other PIC object. But we must not use 48295f5b92ffSmrg # pic_flag when linking with -static. The problem exists in 48305f5b92ffSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 48310dd80ee0Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 48325f5b92ffSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 48335f5b92ffSmrg *-*-hpux*) 48345f5b92ffSmrg pic_flag_for_symtable=" $pic_flag" ;; 48355f5b92ffSmrg *) 483636e956c5Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 48375f5b92ffSmrg ;; 48385f5b92ffSmrg esac 48395f5b92ffSmrg ;; 48405f5b92ffSmrg esac 48415f5b92ffSmrg symtab_cflags= 48425f5b92ffSmrg for arg in $LTCFLAGS; do 48435f5b92ffSmrg case $arg in 48445f5b92ffSmrg -pie | -fpie | -fPIE) ;; 48450dd80ee0Smrg *) func_append symtab_cflags " $arg" ;; 48465f5b92ffSmrg esac 48475f5b92ffSmrg done 484817a48c7cSmrg 48495f5b92ffSmrg # Now compile the dynamic symbol file. 48505f5b92ffSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 485117a48c7cSmrg 48525f5b92ffSmrg # Clean up the generated files. 485336e956c5Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 485417a48c7cSmrg 48555f5b92ffSmrg # Transform the symbol file into the correct name. 485636e956c5Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 48575f5b92ffSmrg case $host in 48585f5b92ffSmrg *cygwin* | *mingw* | *cegcc* ) 48595f5b92ffSmrg if test -f "$output_objdir/$my_outputname.def"; then 48600dd80ee0Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48610dd80ee0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48625f5b92ffSmrg else 48630dd80ee0Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48640dd80ee0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486517a48c7cSmrg fi 48665f5b92ffSmrg ;; 48675f5b92ffSmrg *) 48680dd80ee0Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48690dd80ee0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48705f5b92ffSmrg ;; 48715f5b92ffSmrg esac 48725f5b92ffSmrg ;; 48735f5b92ffSmrg *) 487436e956c5Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 48755f5b92ffSmrg ;; 48765f5b92ffSmrg esac 48775f5b92ffSmrg else 48785f5b92ffSmrg # We keep going just in case the user didn't refer to 48795f5b92ffSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 48805f5b92ffSmrg # really was required. 488117a48c7cSmrg 48825f5b92ffSmrg # Nullify the symbol file. 48830dd80ee0Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 48840dd80ee0Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 48855f5b92ffSmrg fi 48865f5b92ffSmrg} 488717a48c7cSmrg 488836e956c5Smrg# func_cygming_gnu_implib_p ARG 488936e956c5Smrg# This predicate returns with zero status (TRUE) if 489036e956c5Smrg# ARG is a GNU/binutils-style import library. Returns 489136e956c5Smrg# with nonzero status (FALSE) otherwise. 489236e956c5Smrgfunc_cygming_gnu_implib_p () 489336e956c5Smrg{ 489436e956c5Smrg $debug_cmd 489536e956c5Smrg 489636e956c5Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489736e956c5Smrg 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)$'` 489836e956c5Smrg test -n "$func_cygming_gnu_implib_tmp" 489936e956c5Smrg} 490036e956c5Smrg 490136e956c5Smrg# func_cygming_ms_implib_p ARG 490236e956c5Smrg# This predicate returns with zero status (TRUE) if 490336e956c5Smrg# ARG is an MS-style import library. Returns 490436e956c5Smrg# with nonzero status (FALSE) otherwise. 490536e956c5Smrgfunc_cygming_ms_implib_p () 490636e956c5Smrg{ 490736e956c5Smrg $debug_cmd 490836e956c5Smrg 490936e956c5Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491036e956c5Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491136e956c5Smrg test -n "$func_cygming_ms_implib_tmp" 491236e956c5Smrg} 491336e956c5Smrg 49145f5b92ffSmrg# func_win32_libid arg 49155f5b92ffSmrg# return the library type of file 'arg' 49165f5b92ffSmrg# 49175f5b92ffSmrg# Need a lot of goo to handle *both* DLLs and import libs 49185f5b92ffSmrg# Has to be a shell function in order to 'eat' the argument 49195f5b92ffSmrg# that is supplied when $file_magic_command is called. 49200dd80ee0Smrg# Despite the name, also deal with 64 bit binaries. 49215f5b92ffSmrgfunc_win32_libid () 49225f5b92ffSmrg{ 492336e956c5Smrg $debug_cmd 492436e956c5Smrg 492536e956c5Smrg win32_libid_type=unknown 49265f5b92ffSmrg win32_fileres=`file -L $1 2>/dev/null` 49275f5b92ffSmrg case $win32_fileres in 49285f5b92ffSmrg *ar\ archive\ import\ library*) # definitely import 49295f5b92ffSmrg win32_libid_type="x86 archive import" 49305f5b92ffSmrg ;; 49315f5b92ffSmrg *ar\ archive*) # could be an import, or static 49320dd80ee0Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 49335f5b92ffSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 49340dd80ee0Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493536e956c5Smrg case $nm_interface in 493636e956c5Smrg "MS dumpbin") 493736e956c5Smrg if func_cygming_ms_implib_p "$1" || 493836e956c5Smrg func_cygming_gnu_implib_p "$1" 493936e956c5Smrg then 494036e956c5Smrg win32_nmres=import 494136e956c5Smrg else 494236e956c5Smrg win32_nmres= 494336e956c5Smrg fi 494436e956c5Smrg ;; 494536e956c5Smrg *) 494636e956c5Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494736e956c5Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494836e956c5Smrg $SED -n -e ' 49495f5b92ffSmrg 1,100{ 49505f5b92ffSmrg / I /{ 495136e956c5Smrg s|.*|import| 49525f5b92ffSmrg p 49535f5b92ffSmrg q 49545f5b92ffSmrg } 49555f5b92ffSmrg }'` 495636e956c5Smrg ;; 495736e956c5Smrg esac 49585f5b92ffSmrg case $win32_nmres in 49595f5b92ffSmrg import*) win32_libid_type="x86 archive import";; 49605f5b92ffSmrg *) win32_libid_type="x86 archive static";; 49615f5b92ffSmrg esac 49625f5b92ffSmrg fi 49635f5b92ffSmrg ;; 49645f5b92ffSmrg *DLL*) 49655f5b92ffSmrg win32_libid_type="x86 DLL" 49665f5b92ffSmrg ;; 49675f5b92ffSmrg *executable*) # but shell scripts are "executable" too... 49685f5b92ffSmrg case $win32_fileres in 49695f5b92ffSmrg *MS\ Windows\ PE\ Intel*) 49705f5b92ffSmrg win32_libid_type="x86 DLL" 49715f5b92ffSmrg ;; 49725f5b92ffSmrg esac 49735f5b92ffSmrg ;; 49745f5b92ffSmrg esac 49755f5b92ffSmrg $ECHO "$win32_libid_type" 49765f5b92ffSmrg} 497717a48c7cSmrg 49780dd80ee0Smrg# func_cygming_dll_for_implib ARG 49790dd80ee0Smrg# 49800dd80ee0Smrg# Platform-specific function to extract the 49810dd80ee0Smrg# name of the DLL associated with the specified 49820dd80ee0Smrg# import library ARG. 49830dd80ee0Smrg# Invoked by eval'ing the libtool variable 49840dd80ee0Smrg# $sharedlib_from_linklib_cmd 49850dd80ee0Smrg# Result is available in the variable 49860dd80ee0Smrg# $sharedlib_from_linklib_result 49870dd80ee0Smrgfunc_cygming_dll_for_implib () 49880dd80ee0Smrg{ 498936e956c5Smrg $debug_cmd 499036e956c5Smrg 49910dd80ee0Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 49920dd80ee0Smrg} 49930dd80ee0Smrg 49940dd80ee0Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 49950dd80ee0Smrg# 49960dd80ee0Smrg# The is the core of a fallback implementation of a 49970dd80ee0Smrg# platform-specific function to extract the name of the 49980dd80ee0Smrg# DLL associated with the specified import library LIBNAME. 49990dd80ee0Smrg# 50000dd80ee0Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 50010dd80ee0Smrg# on the platform and compiler that created the implib. 50020dd80ee0Smrg# 50030dd80ee0Smrg# Echos the name of the DLL associated with the 50040dd80ee0Smrg# specified import library. 50050dd80ee0Smrgfunc_cygming_dll_for_implib_fallback_core () 50060dd80ee0Smrg{ 500736e956c5Smrg $debug_cmd 500836e956c5Smrg 50090dd80ee0Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 50100dd80ee0Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 50110dd80ee0Smrg $SED '/^Contents of section '"$match_literal"':/{ 50120dd80ee0Smrg # Place marker at beginning of archive member dllname section 50130dd80ee0Smrg s/.*/====MARK====/ 50140dd80ee0Smrg p 50150dd80ee0Smrg d 50160dd80ee0Smrg } 50170dd80ee0Smrg # These lines can sometimes be longer than 43 characters, but 50180dd80ee0Smrg # are always uninteresting 50190dd80ee0Smrg /:[ ]*file format pe[i]\{,1\}-/d 50200dd80ee0Smrg /^In archive [^:]*:/d 50210dd80ee0Smrg # Ensure marker is printed 50220dd80ee0Smrg /^====MARK====/p 50230dd80ee0Smrg # Remove all lines with less than 43 characters 50240dd80ee0Smrg /^.\{43\}/!d 50250dd80ee0Smrg # From remaining lines, remove first 43 characters 50260dd80ee0Smrg s/^.\{43\}//' | 50270dd80ee0Smrg $SED -n ' 50280dd80ee0Smrg # Join marker and all lines until next marker into a single line 50290dd80ee0Smrg /^====MARK====/ b para 50300dd80ee0Smrg H 50310dd80ee0Smrg $ b para 50320dd80ee0Smrg b 50330dd80ee0Smrg :para 50340dd80ee0Smrg x 50350dd80ee0Smrg s/\n//g 50360dd80ee0Smrg # Remove the marker 50370dd80ee0Smrg s/^====MARK====// 50380dd80ee0Smrg # Remove trailing dots and whitespace 50390dd80ee0Smrg s/[\. \t]*$// 50400dd80ee0Smrg # Print 50410dd80ee0Smrg /./p' | 50420dd80ee0Smrg # we now have a list, one entry per line, of the stringified 50430dd80ee0Smrg # contents of the appropriate section of all members of the 504436e956c5Smrg # archive that possess that section. Heuristic: eliminate 504536e956c5Smrg # all those that have a first or second character that is 50460dd80ee0Smrg # a '.' (that is, objdump's representation of an unprintable 50470dd80ee0Smrg # character.) This should work for all archives with less than 50480dd80ee0Smrg # 0x302f exports -- but will fail for DLLs whose name actually 50490dd80ee0Smrg # begins with a literal '.' or a single character followed by 50500dd80ee0Smrg # a '.'. 50510dd80ee0Smrg # 50520dd80ee0Smrg # Of those that remain, print the first one. 50530dd80ee0Smrg $SED -e '/^\./d;/^.\./d;q' 50540dd80ee0Smrg} 50550dd80ee0Smrg 50560dd80ee0Smrg# func_cygming_dll_for_implib_fallback ARG 50570dd80ee0Smrg# Platform-specific function to extract the 50580dd80ee0Smrg# name of the DLL associated with the specified 50590dd80ee0Smrg# import library ARG. 50600dd80ee0Smrg# 50610dd80ee0Smrg# This fallback implementation is for use when $DLLTOOL 50620dd80ee0Smrg# does not support the --identify-strict option. 50630dd80ee0Smrg# Invoked by eval'ing the libtool variable 50640dd80ee0Smrg# $sharedlib_from_linklib_cmd 50650dd80ee0Smrg# Result is available in the variable 50660dd80ee0Smrg# $sharedlib_from_linklib_result 50670dd80ee0Smrgfunc_cygming_dll_for_implib_fallback () 50680dd80ee0Smrg{ 506936e956c5Smrg $debug_cmd 507036e956c5Smrg 507136e956c5Smrg if func_cygming_gnu_implib_p "$1"; then 50720dd80ee0Smrg # binutils import library 50730dd80ee0Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507436e956c5Smrg elif func_cygming_ms_implib_p "$1"; then 50750dd80ee0Smrg # ms-generated import library 50760dd80ee0Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 50770dd80ee0Smrg else 50780dd80ee0Smrg # unknown 507936e956c5Smrg sharedlib_from_linklib_result= 50800dd80ee0Smrg fi 50810dd80ee0Smrg} 508217a48c7cSmrg 508317a48c7cSmrg 50845f5b92ffSmrg# func_extract_an_archive dir oldlib 50855f5b92ffSmrgfunc_extract_an_archive () 50865f5b92ffSmrg{ 508736e956c5Smrg $debug_cmd 508836e956c5Smrg 508936e956c5Smrg f_ex_an_ar_dir=$1; shift 509036e956c5Smrg f_ex_an_ar_oldlib=$1 509136e956c5Smrg if test yes = "$lock_old_archive_extraction"; then 50920dd80ee0Smrg lockfile=$f_ex_an_ar_oldlib.lock 50930dd80ee0Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 50940dd80ee0Smrg func_echo "Waiting for $lockfile to be removed" 50950dd80ee0Smrg sleep 2 50960dd80ee0Smrg done 50970dd80ee0Smrg fi 50980dd80ee0Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 50990dd80ee0Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510036e956c5Smrg if test yes = "$lock_old_archive_extraction"; then 51010dd80ee0Smrg $opt_dry_run || rm -f "$lockfile" 51020dd80ee0Smrg fi 51035f5b92ffSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 51045f5b92ffSmrg : 51055f5b92ffSmrg else 51065f5b92ffSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 51075f5b92ffSmrg fi 51085f5b92ffSmrg} 510917a48c7cSmrg 511017a48c7cSmrg 51115f5b92ffSmrg# func_extract_archives gentop oldlib ... 51125f5b92ffSmrgfunc_extract_archives () 51135f5b92ffSmrg{ 511436e956c5Smrg $debug_cmd 511536e956c5Smrg 511636e956c5Smrg my_gentop=$1; shift 51175f5b92ffSmrg my_oldlibs=${1+"$@"} 511836e956c5Smrg my_oldobjs= 511936e956c5Smrg my_xlib= 512036e956c5Smrg my_xabs= 512136e956c5Smrg my_xdir= 512217a48c7cSmrg 51235f5b92ffSmrg for my_xlib in $my_oldlibs; do 51245f5b92ffSmrg # Extract the objects. 51255f5b92ffSmrg case $my_xlib in 512636e956c5Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 51275f5b92ffSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 51285f5b92ffSmrg esac 51295f5b92ffSmrg func_basename "$my_xlib" 513036e956c5Smrg my_xlib=$func_basename_result 51315f5b92ffSmrg my_xlib_u=$my_xlib 51325f5b92ffSmrg while :; do 51335f5b92ffSmrg case " $extracted_archives " in 51345f5b92ffSmrg *" $my_xlib_u "*) 51355f5b92ffSmrg func_arith $extracted_serial + 1 51365f5b92ffSmrg extracted_serial=$func_arith_result 51375f5b92ffSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 51385f5b92ffSmrg *) break ;; 51395f5b92ffSmrg esac 51405f5b92ffSmrg done 51415f5b92ffSmrg extracted_archives="$extracted_archives $my_xlib_u" 514236e956c5Smrg my_xdir=$my_gentop/$my_xlib_u 514317a48c7cSmrg 51445f5b92ffSmrg func_mkdir_p "$my_xdir" 514517a48c7cSmrg 51465f5b92ffSmrg case $host in 51475f5b92ffSmrg *-darwin*) 51485f5b92ffSmrg func_verbose "Extracting $my_xabs" 51495f5b92ffSmrg # Do not bother doing anything if just a dry run 51505f5b92ffSmrg $opt_dry_run || { 51515f5b92ffSmrg darwin_orig_dir=`pwd` 51525f5b92ffSmrg cd $my_xdir || exit $? 51535f5b92ffSmrg darwin_archive=$my_xabs 51545f5b92ffSmrg darwin_curdir=`pwd` 515536e956c5Smrg func_basename "$darwin_archive" 515636e956c5Smrg darwin_base_archive=$func_basename_result 51575f5b92ffSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 51585f5b92ffSmrg if test -n "$darwin_arches"; then 51595f5b92ffSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 51605f5b92ffSmrg darwin_arch= 51615f5b92ffSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516236e956c5Smrg for darwin_arch in $darwin_arches; do 516336e956c5Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516436e956c5Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516536e956c5Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516636e956c5Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 51675f5b92ffSmrg cd "$darwin_curdir" 516836e956c5Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 51695f5b92ffSmrg done # $darwin_arches 51705f5b92ffSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517136e956c5Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 51725f5b92ffSmrg darwin_file= 51735f5b92ffSmrg darwin_files= 51745f5b92ffSmrg for darwin_file in $darwin_filelist; do 51750dd80ee0Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 51765f5b92ffSmrg $LIPO -create -output "$darwin_file" $darwin_files 51775f5b92ffSmrg done # $darwin_filelist 51785f5b92ffSmrg $RM -rf unfat-$$ 51795f5b92ffSmrg cd "$darwin_orig_dir" 518017a48c7cSmrg else 51815f5b92ffSmrg cd $darwin_orig_dir 51825f5b92ffSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51835f5b92ffSmrg fi # $darwin_arches 51845f5b92ffSmrg } # !$opt_dry_run 51855f5b92ffSmrg ;; 51865f5b92ffSmrg *) 51875f5b92ffSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51885f5b92ffSmrg ;; 51895f5b92ffSmrg esac 51900dd80ee0Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 51915f5b92ffSmrg done 519217a48c7cSmrg 519336e956c5Smrg func_extract_archives_result=$my_oldobjs 51945f5b92ffSmrg} 519517a48c7cSmrg 519617a48c7cSmrg 51970dd80ee0Smrg# func_emit_wrapper [arg=no] 51980dd80ee0Smrg# 51990dd80ee0Smrg# Emit a libtool wrapper script on stdout. 52000dd80ee0Smrg# Don't directly open a file because we may want to 52010dd80ee0Smrg# incorporate the script contents within a cygwin/mingw 52020dd80ee0Smrg# wrapper executable. Must ONLY be called from within 52030dd80ee0Smrg# func_mode_link because it depends on a number of variables 52040dd80ee0Smrg# set therein. 52055f5b92ffSmrg# 52060dd80ee0Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 52070dd80ee0Smrg# variable will take. If 'yes', then the emitted script 520836e956c5Smrg# will assume that the directory where it is stored is 52090dd80ee0Smrg# the $objdir directory. This is a cygwin/mingw-specific 52100dd80ee0Smrg# behavior. 52110dd80ee0Smrgfunc_emit_wrapper () 52125f5b92ffSmrg{ 52130dd80ee0Smrg func_emit_wrapper_arg1=${1-no} 521417a48c7cSmrg 52155f5b92ffSmrg $ECHO "\ 52165f5b92ffSmrg#! $SHELL 521717a48c7cSmrg 52185f5b92ffSmrg# $output - temporary wrapper script for $objdir/$outputname 521936e956c5Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 52205f5b92ffSmrg# 52215f5b92ffSmrg# The $output program cannot be directly executed until all the libtool 52225f5b92ffSmrg# libraries that it depends on are installed. 52235f5b92ffSmrg# 52245f5b92ffSmrg# This wrapper script should never be moved out of the build directory. 52255f5b92ffSmrg# If it is, it will not operate correctly. 522617a48c7cSmrg 52275f5b92ffSmrg# Sed substitution that helps us do robust quoting. It backslashifies 52285f5b92ffSmrg# metacharacters that are still active within double-quoted strings. 52295f5b92ffSmrgsed_quote_subst='$sed_quote_subst' 523017a48c7cSmrg 52315f5b92ffSmrg# Be Bourne compatible 52325f5b92ffSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 52335f5b92ffSmrg emulate sh 52345f5b92ffSmrg NULLCMD=: 52355f5b92ffSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 52365f5b92ffSmrg # is contrary to our usage. Disable this feature. 52375f5b92ffSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 52385f5b92ffSmrg setopt NO_GLOB_SUBST 52395f5b92ffSmrgelse 52405f5b92ffSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 52415f5b92ffSmrgfi 52425f5b92ffSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 52435f5b92ffSmrgDUALCASE=1; export DUALCASE # for MKS sh 524417a48c7cSmrg 52455f5b92ffSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 52465f5b92ffSmrg# if CDPATH is set. 52475f5b92ffSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 524817a48c7cSmrg 52495f5b92ffSmrgrelink_command=\"$relink_command\" 525017a48c7cSmrg 52515f5b92ffSmrg# This environment variable determines our operation mode. 52525f5b92ffSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 52535f5b92ffSmrg # install mode needs the following variables: 52545f5b92ffSmrg generated_by_libtool_version='$macro_version' 52555f5b92ffSmrg notinst_deplibs='$notinst_deplibs' 52565f5b92ffSmrgelse 52575f5b92ffSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 52585f5b92ffSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 52590dd80ee0Smrg file=\"\$0\"" 52600dd80ee0Smrg 52610dd80ee0Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 52620dd80ee0Smrg $ECHO "\ 52630dd80ee0Smrg 52640dd80ee0Smrg# A function that is used when there is no print builtin or printf. 52650dd80ee0Smrgfunc_fallback_echo () 52660dd80ee0Smrg{ 52670dd80ee0Smrg eval 'cat <<_LTECHO_EOF 52680dd80ee0Smrg\$1 52690dd80ee0Smrg_LTECHO_EOF' 52700dd80ee0Smrg} 52710dd80ee0Smrg ECHO=\"$qECHO\" 52720dd80ee0Smrg fi 52730dd80ee0Smrg 52740dd80ee0Smrg# Very basic option parsing. These options are (a) specific to 52750dd80ee0Smrg# the libtool wrapper, (b) are identical between the wrapper 527636e956c5Smrg# /script/ and the wrapper /executable/ that is used only on 52770dd80ee0Smrg# windows platforms, and (c) all begin with the string "--lt-" 527836e956c5Smrg# (application programs are unlikely to have options that match 52790dd80ee0Smrg# this pattern). 52800dd80ee0Smrg# 52810dd80ee0Smrg# There are only two supported options: --lt-debug and 52820dd80ee0Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 52830dd80ee0Smrg# 52840dd80ee0Smrg# The first argument to this parsing function should be the 52850dd80ee0Smrg# script's $0 value, followed by "$@". 52860dd80ee0Smrglt_option_debug= 52870dd80ee0Smrgfunc_parse_lt_options () 52880dd80ee0Smrg{ 52890dd80ee0Smrg lt_script_arg0=\$0 52900dd80ee0Smrg shift 52910dd80ee0Smrg for lt_opt 52920dd80ee0Smrg do 52930dd80ee0Smrg case \"\$lt_opt\" in 52940dd80ee0Smrg --lt-debug) lt_option_debug=1 ;; 52950dd80ee0Smrg --lt-dump-script) 52960dd80ee0Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 52970dd80ee0Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 52980dd80ee0Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 52990dd80ee0Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 53000dd80ee0Smrg exit 0 53010dd80ee0Smrg ;; 53020dd80ee0Smrg --lt-*) 53030dd80ee0Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 53040dd80ee0Smrg exit 1 53050dd80ee0Smrg ;; 53060dd80ee0Smrg esac 53070dd80ee0Smrg done 53080dd80ee0Smrg 53090dd80ee0Smrg # Print the debug banner immediately: 53100dd80ee0Smrg if test -n \"\$lt_option_debug\"; then 531136e956c5Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 53120dd80ee0Smrg fi 53130dd80ee0Smrg} 53140dd80ee0Smrg 53150dd80ee0Smrg# Used when --lt-debug. Prints its arguments to stdout 53160dd80ee0Smrg# (redirection is the responsibility of the caller) 53170dd80ee0Smrgfunc_lt_dump_args () 53180dd80ee0Smrg{ 53190dd80ee0Smrg lt_dump_args_N=1; 53200dd80ee0Smrg for lt_arg 53210dd80ee0Smrg do 532236e956c5Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 53230dd80ee0Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 53240dd80ee0Smrg done 53250dd80ee0Smrg} 53260dd80ee0Smrg 53270dd80ee0Smrg# Core function for launching the target application 53280dd80ee0Smrgfunc_exec_program_core () 53290dd80ee0Smrg{ 53305f5b92ffSmrg" 53310dd80ee0Smrg case $host in 53320dd80ee0Smrg # Backslashes separate directories on plain windows 53330dd80ee0Smrg *-*-mingw | *-*-os2* | *-cegcc*) 53340dd80ee0Smrg $ECHO "\ 53350dd80ee0Smrg if test -n \"\$lt_option_debug\"; then 533636e956c5Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 53370dd80ee0Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 53380dd80ee0Smrg fi 53390dd80ee0Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 53400dd80ee0Smrg" 53410dd80ee0Smrg ;; 53420dd80ee0Smrg 53430dd80ee0Smrg *) 53440dd80ee0Smrg $ECHO "\ 53450dd80ee0Smrg if test -n \"\$lt_option_debug\"; then 534636e956c5Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 53470dd80ee0Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 53480dd80ee0Smrg fi 53490dd80ee0Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 53500dd80ee0Smrg" 53510dd80ee0Smrg ;; 53520dd80ee0Smrg esac 53530dd80ee0Smrg $ECHO "\ 53540dd80ee0Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 53550dd80ee0Smrg exit 1 53560dd80ee0Smrg} 53570dd80ee0Smrg 53580dd80ee0Smrg# A function to encapsulate launching the target application 53590dd80ee0Smrg# Strips options in the --lt-* namespace from \$@ and 53600dd80ee0Smrg# launches target application with the remaining arguments. 53610dd80ee0Smrgfunc_exec_program () 53620dd80ee0Smrg{ 53630dd80ee0Smrg case \" \$* \" in 53640dd80ee0Smrg *\\ --lt-*) 53650dd80ee0Smrg for lt_wr_arg 53660dd80ee0Smrg do 53670dd80ee0Smrg case \$lt_wr_arg in 53680dd80ee0Smrg --lt-*) ;; 53690dd80ee0Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 53700dd80ee0Smrg esac 53710dd80ee0Smrg shift 53720dd80ee0Smrg done ;; 53730dd80ee0Smrg esac 53740dd80ee0Smrg func_exec_program_core \${1+\"\$@\"} 53750dd80ee0Smrg} 53760dd80ee0Smrg 53770dd80ee0Smrg # Parse options 53780dd80ee0Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 537917a48c7cSmrg 53805f5b92ffSmrg # Find the directory that this script lives in. 53810dd80ee0Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 53825f5b92ffSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 538317a48c7cSmrg 53845f5b92ffSmrg # Follow symbolic links until we get to the real thisdir. 53850dd80ee0Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 53865f5b92ffSmrg while test -n \"\$file\"; do 53870dd80ee0Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 538817a48c7cSmrg 53895f5b92ffSmrg # If there was a directory component, then change thisdir. 53905f5b92ffSmrg if test \"x\$destdir\" != \"x\$file\"; then 53915f5b92ffSmrg case \"\$destdir\" in 53925f5b92ffSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 53935f5b92ffSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 539417a48c7cSmrg esac 53955f5b92ffSmrg fi 539617a48c7cSmrg 53970dd80ee0Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 53980dd80ee0Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 53995f5b92ffSmrg done 540017a48c7cSmrg 54015f5b92ffSmrg # Usually 'no', except on cygwin/mingw when embedded into 54025f5b92ffSmrg # the cwrapper. 54030dd80ee0Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 54045f5b92ffSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 54055f5b92ffSmrg # special case for '.' 54065f5b92ffSmrg if test \"\$thisdir\" = \".\"; then 54075f5b92ffSmrg thisdir=\`pwd\` 54085f5b92ffSmrg fi 54095f5b92ffSmrg # remove .libs from thisdir 54105f5b92ffSmrg case \"\$thisdir\" in 54110dd80ee0Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 54125f5b92ffSmrg $objdir ) thisdir=. ;; 54135f5b92ffSmrg esac 54145f5b92ffSmrg fi 54155f5b92ffSmrg 54165f5b92ffSmrg # Try to get the absolute directory name. 54175f5b92ffSmrg absdir=\`cd \"\$thisdir\" && pwd\` 54185f5b92ffSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 54195f5b92ffSmrg" 54205f5b92ffSmrg 542136e956c5Smrg if test yes = "$fast_install"; then 54225f5b92ffSmrg $ECHO "\ 54235f5b92ffSmrg program=lt-'$outputname'$exeext 54245f5b92ffSmrg progdir=\"\$thisdir/$objdir\" 54255f5b92ffSmrg 54265f5b92ffSmrg if test ! -f \"\$progdir/\$program\" || 542736e956c5Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 54285f5b92ffSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 54295f5b92ffSmrg 54305f5b92ffSmrg file=\"\$\$-\$program\" 54315f5b92ffSmrg 54325f5b92ffSmrg if test ! -d \"\$progdir\"; then 54335f5b92ffSmrg $MKDIR \"\$progdir\" 54345f5b92ffSmrg else 54355f5b92ffSmrg $RM \"\$progdir/\$file\" 54365f5b92ffSmrg fi" 54375f5b92ffSmrg 54385f5b92ffSmrg $ECHO "\ 54395f5b92ffSmrg 54405f5b92ffSmrg # relink executable if necessary 54415f5b92ffSmrg if test -n \"\$relink_command\"; then 54425f5b92ffSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 54435f5b92ffSmrg else 544436e956c5Smrg \$ECHO \"\$relink_command_output\" >&2 54455f5b92ffSmrg $RM \"\$progdir/\$file\" 54465f5b92ffSmrg exit 1 544717a48c7cSmrg fi 54485f5b92ffSmrg fi 544917a48c7cSmrg 54505f5b92ffSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 54515f5b92ffSmrg { $RM \"\$progdir/\$program\"; 54525f5b92ffSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 54535f5b92ffSmrg $RM \"\$progdir/\$file\" 54545f5b92ffSmrg fi" 54555f5b92ffSmrg else 54565f5b92ffSmrg $ECHO "\ 54575f5b92ffSmrg program='$outputname' 54585f5b92ffSmrg progdir=\"\$thisdir/$objdir\" 54595f5b92ffSmrg" 546017a48c7cSmrg fi 546117a48c7cSmrg 54625f5b92ffSmrg $ECHO "\ 546317a48c7cSmrg 54645f5b92ffSmrg if test -f \"\$progdir/\$program\"; then" 546517a48c7cSmrg 54660dd80ee0Smrg # fixup the dll searchpath if we need to. 54670dd80ee0Smrg # 54680dd80ee0Smrg # Fix the DLL searchpath if we need to. Do this before prepending 54690dd80ee0Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 54700dd80ee0Smrg # libraries must come first. 54710dd80ee0Smrg if test -n "$dllsearchpath"; then 54720dd80ee0Smrg $ECHO "\ 54730dd80ee0Smrg # Add the dll search path components to the executable PATH 54740dd80ee0Smrg PATH=$dllsearchpath:\$PATH 54750dd80ee0Smrg" 54760dd80ee0Smrg fi 54770dd80ee0Smrg 54785f5b92ffSmrg # Export our shlibpath_var if we have one. 547936e956c5Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 54805f5b92ffSmrg $ECHO "\ 54815f5b92ffSmrg # Add our own library path to $shlibpath_var 54825f5b92ffSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 54835f5b92ffSmrg 54845f5b92ffSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 54855f5b92ffSmrg # The second colon is a workaround for a bug in BeOS R4 sed 54860dd80ee0Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 548717a48c7cSmrg 54885f5b92ffSmrg export $shlibpath_var 54895f5b92ffSmrg" 549017a48c7cSmrg fi 549117a48c7cSmrg 54925f5b92ffSmrg $ECHO "\ 54935f5b92ffSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 54945f5b92ffSmrg # Run the actual program with our arguments. 54950dd80ee0Smrg func_exec_program \${1+\"\$@\"} 54965f5b92ffSmrg fi 54975f5b92ffSmrg else 54985f5b92ffSmrg # The program doesn't exist. 549936e956c5Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 55005f5b92ffSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 55010dd80ee0Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 55025f5b92ffSmrg exit 1 55035f5b92ffSmrg fi 55045f5b92ffSmrgfi\ 55055f5b92ffSmrg" 55065f5b92ffSmrg} 550717a48c7cSmrg 550817a48c7cSmrg 55095f5b92ffSmrg# func_emit_cwrapperexe_src 55105f5b92ffSmrg# emit the source code for a wrapper executable on stdout 55115f5b92ffSmrg# Must ONLY be called from within func_mode_link because 55125f5b92ffSmrg# it depends on a number of variable set therein. 55135f5b92ffSmrgfunc_emit_cwrapperexe_src () 55145f5b92ffSmrg{ 55155f5b92ffSmrg cat <<EOF 551617a48c7cSmrg 55175f5b92ffSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551836e956c5Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 551917a48c7cSmrg 55205f5b92ffSmrg The $output program cannot be directly executed until all the libtool 55215f5b92ffSmrg libraries that it depends on are installed. 552217a48c7cSmrg 55235f5b92ffSmrg This wrapper executable should never be moved out of the build directory. 55245f5b92ffSmrg If it is, it will not operate correctly. 55255f5b92ffSmrg*/ 55265f5b92ffSmrgEOF 55275f5b92ffSmrg cat <<"EOF" 55280dd80ee0Smrg#ifdef _MSC_VER 55290dd80ee0Smrg# define _CRT_SECURE_NO_DEPRECATE 1 55300dd80ee0Smrg#endif 55315f5b92ffSmrg#include <stdio.h> 55325f5b92ffSmrg#include <stdlib.h> 55335f5b92ffSmrg#ifdef _MSC_VER 55345f5b92ffSmrg# include <direct.h> 55355f5b92ffSmrg# include <process.h> 55365f5b92ffSmrg# include <io.h> 55375f5b92ffSmrg#else 55385f5b92ffSmrg# include <unistd.h> 55395f5b92ffSmrg# include <stdint.h> 55405f5b92ffSmrg# ifdef __CYGWIN__ 55415f5b92ffSmrg# include <io.h> 55425f5b92ffSmrg# endif 55435f5b92ffSmrg#endif 55445f5b92ffSmrg#include <malloc.h> 55455f5b92ffSmrg#include <stdarg.h> 55465f5b92ffSmrg#include <assert.h> 55475f5b92ffSmrg#include <string.h> 55485f5b92ffSmrg#include <ctype.h> 55495f5b92ffSmrg#include <errno.h> 55505f5b92ffSmrg#include <fcntl.h> 55515f5b92ffSmrg#include <sys/stat.h> 555217a48c7cSmrg 555336e956c5Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555436e956c5Smrg 55550dd80ee0Smrg/* declarations of non-ANSI functions */ 555636e956c5Smrg#if defined __MINGW32__ 55570dd80ee0Smrg# ifdef __STRICT_ANSI__ 55580dd80ee0Smrgint _putenv (const char *); 55590dd80ee0Smrg# endif 556036e956c5Smrg#elif defined __CYGWIN__ 55610dd80ee0Smrg# ifdef __STRICT_ANSI__ 55620dd80ee0Smrgchar *realpath (const char *, char *); 55630dd80ee0Smrgint putenv (char *); 55640dd80ee0Smrgint setenv (const char *, const char *, int); 55650dd80ee0Smrg# endif 556636e956c5Smrg/* #elif defined other_platform || defined ... */ 55670dd80ee0Smrg#endif 55680dd80ee0Smrg 55690dd80ee0Smrg/* portability defines, excluding path handling macros */ 557036e956c5Smrg#if defined _MSC_VER 55710dd80ee0Smrg# define setmode _setmode 55720dd80ee0Smrg# define stat _stat 55730dd80ee0Smrg# define chmod _chmod 55740dd80ee0Smrg# define getcwd _getcwd 55750dd80ee0Smrg# define putenv _putenv 55760dd80ee0Smrg# define S_IXUSR _S_IEXEC 557736e956c5Smrg#elif defined __MINGW32__ 55780dd80ee0Smrg# define setmode _setmode 55790dd80ee0Smrg# define stat _stat 55800dd80ee0Smrg# define chmod _chmod 55810dd80ee0Smrg# define getcwd _getcwd 55820dd80ee0Smrg# define putenv _putenv 558336e956c5Smrg#elif defined __CYGWIN__ 55840dd80ee0Smrg# define HAVE_SETENV 55850dd80ee0Smrg# define FOPEN_WB "wb" 558636e956c5Smrg/* #elif defined other platforms ... */ 55870dd80ee0Smrg#endif 55880dd80ee0Smrg 558936e956c5Smrg#if defined PATH_MAX 55905f5b92ffSmrg# define LT_PATHMAX PATH_MAX 559136e956c5Smrg#elif defined MAXPATHLEN 55925f5b92ffSmrg# define LT_PATHMAX MAXPATHLEN 55935f5b92ffSmrg#else 55945f5b92ffSmrg# define LT_PATHMAX 1024 55955f5b92ffSmrg#endif 559617a48c7cSmrg 55975f5b92ffSmrg#ifndef S_IXOTH 55985f5b92ffSmrg# define S_IXOTH 0 55995f5b92ffSmrg#endif 56005f5b92ffSmrg#ifndef S_IXGRP 56015f5b92ffSmrg# define S_IXGRP 0 56025f5b92ffSmrg#endif 560317a48c7cSmrg 56040dd80ee0Smrg/* path handling portability macros */ 56055f5b92ffSmrg#ifndef DIR_SEPARATOR 56065f5b92ffSmrg# define DIR_SEPARATOR '/' 56075f5b92ffSmrg# define PATH_SEPARATOR ':' 56085f5b92ffSmrg#endif 560917a48c7cSmrg 561036e956c5Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561136e956c5Smrg defined __OS2__ 56125f5b92ffSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 56135f5b92ffSmrg# define FOPEN_WB "wb" 56145f5b92ffSmrg# ifndef DIR_SEPARATOR_2 56155f5b92ffSmrg# define DIR_SEPARATOR_2 '\\' 56165f5b92ffSmrg# endif 56175f5b92ffSmrg# ifndef PATH_SEPARATOR_2 56185f5b92ffSmrg# define PATH_SEPARATOR_2 ';' 56195f5b92ffSmrg# endif 56205f5b92ffSmrg#endif 562117a48c7cSmrg 56225f5b92ffSmrg#ifndef DIR_SEPARATOR_2 56235f5b92ffSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 56245f5b92ffSmrg#else /* DIR_SEPARATOR_2 */ 56255f5b92ffSmrg# define IS_DIR_SEPARATOR(ch) \ 56265f5b92ffSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 56275f5b92ffSmrg#endif /* DIR_SEPARATOR_2 */ 562817a48c7cSmrg 56295f5b92ffSmrg#ifndef PATH_SEPARATOR_2 56305f5b92ffSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 56315f5b92ffSmrg#else /* PATH_SEPARATOR_2 */ 56325f5b92ffSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 56335f5b92ffSmrg#endif /* PATH_SEPARATOR_2 */ 563417a48c7cSmrg 56355f5b92ffSmrg#ifndef FOPEN_WB 56365f5b92ffSmrg# define FOPEN_WB "w" 56375f5b92ffSmrg#endif 56385f5b92ffSmrg#ifndef _O_BINARY 56395f5b92ffSmrg# define _O_BINARY 0 56405f5b92ffSmrg#endif 564117a48c7cSmrg 56425f5b92ffSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 56435f5b92ffSmrg#define XFREE(stale) do { \ 564436e956c5Smrg if (stale) { free (stale); stale = 0; } \ 56455f5b92ffSmrg} while (0) 564617a48c7cSmrg 564736e956c5Smrg#if defined LT_DEBUGWRAPPER 56480dd80ee0Smrgstatic int lt_debug = 1; 56495f5b92ffSmrg#else 56500dd80ee0Smrgstatic int lt_debug = 0; 56515f5b92ffSmrg#endif 565217a48c7cSmrg 56530dd80ee0Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565417a48c7cSmrg 56555f5b92ffSmrgvoid *xmalloc (size_t num); 56565f5b92ffSmrgchar *xstrdup (const char *string); 56575f5b92ffSmrgconst char *base_name (const char *name); 56585f5b92ffSmrgchar *find_executable (const char *wrapper); 56595f5b92ffSmrgchar *chase_symlinks (const char *pathspec); 56605f5b92ffSmrgint make_executable (const char *path); 56615f5b92ffSmrgint check_executable (const char *path); 56625f5b92ffSmrgchar *strendzap (char *str, const char *pat); 56630dd80ee0Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 56640dd80ee0Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 56650dd80ee0Smrgstatic const char *nonnull (const char *s); 56660dd80ee0Smrgstatic const char *nonempty (const char *s); 56675f5b92ffSmrgvoid lt_setenv (const char *name, const char *value); 56685f5b92ffSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 56695f5b92ffSmrgvoid lt_update_exe_path (const char *name, const char *value); 56705f5b92ffSmrgvoid lt_update_lib_path (const char *name, const char *value); 56710dd80ee0Smrgchar **prepare_spawn (char **argv); 56720dd80ee0Smrgvoid lt_dump_script (FILE *f); 56735f5b92ffSmrgEOF 56745f5b92ffSmrg 56755f5b92ffSmrg cat <<EOF 567636e956c5Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567736e956c5Smrg# define externally_visible volatile 567836e956c5Smrg#else 567936e956c5Smrg# define externally_visible __attribute__((externally_visible)) volatile 568036e956c5Smrg#endif 568136e956c5Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 56825f5b92ffSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 56835f5b92ffSmrgEOF 568417a48c7cSmrg 568536e956c5Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 56860dd80ee0Smrg func_to_host_path "$temp_rpath" 56875f5b92ffSmrg cat <<EOF 56880dd80ee0Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 56895f5b92ffSmrgEOF 56905f5b92ffSmrg else 56915f5b92ffSmrg cat <<"EOF" 56925f5b92ffSmrgconst char * LIB_PATH_VALUE = ""; 56935f5b92ffSmrgEOF 569417a48c7cSmrg fi 569517a48c7cSmrg 56965f5b92ffSmrg if test -n "$dllsearchpath"; then 56970dd80ee0Smrg func_to_host_path "$dllsearchpath:" 56985f5b92ffSmrg cat <<EOF 56995f5b92ffSmrgconst char * EXE_PATH_VARNAME = "PATH"; 57000dd80ee0Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 570117a48c7cSmrgEOF 570217a48c7cSmrg else 57035f5b92ffSmrg cat <<"EOF" 57045f5b92ffSmrgconst char * EXE_PATH_VARNAME = ""; 57055f5b92ffSmrgconst char * EXE_PATH_VALUE = ""; 57065f5b92ffSmrgEOF 570717a48c7cSmrg fi 57085f5b92ffSmrg 570936e956c5Smrg if test yes = "$fast_install"; then 57105f5b92ffSmrg cat <<EOF 57115f5b92ffSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 57125f5b92ffSmrgEOF 571317a48c7cSmrg else 57145f5b92ffSmrg cat <<EOF 57155f5b92ffSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 57165f5b92ffSmrgEOF 571717a48c7cSmrg fi 571817a48c7cSmrg 571917a48c7cSmrg 57205f5b92ffSmrg cat <<"EOF" 572117a48c7cSmrg 57225f5b92ffSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 572317a48c7cSmrg 57245f5b92ffSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 57255f5b92ffSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 57260dd80ee0Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 572717a48c7cSmrg 57285f5b92ffSmrgint 57295f5b92ffSmrgmain (int argc, char *argv[]) 57305f5b92ffSmrg{ 57315f5b92ffSmrg char **newargz; 57325f5b92ffSmrg int newargc; 57335f5b92ffSmrg char *tmp_pathspec; 57345f5b92ffSmrg char *actual_cwrapper_path; 57355f5b92ffSmrg char *actual_cwrapper_name; 57365f5b92ffSmrg char *target_name; 57375f5b92ffSmrg char *lt_argv_zero; 573836e956c5Smrg int rval = 127; 573917a48c7cSmrg 57405f5b92ffSmrg int i; 574117a48c7cSmrg 57425f5b92ffSmrg program_name = (char *) xstrdup (base_name (argv[0])); 574336e956c5Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 574417a48c7cSmrg 57450dd80ee0Smrg /* very simple arg parsing; don't want to rely on getopt 57460dd80ee0Smrg * also, copy all non cwrapper options to newargz, except 57470dd80ee0Smrg * argz[0], which is handled differently 57480dd80ee0Smrg */ 57490dd80ee0Smrg newargc=0; 57505f5b92ffSmrg for (i = 1; i < argc; i++) 57515f5b92ffSmrg { 575236e956c5Smrg if (STREQ (argv[i], dumpscript_opt)) 57535f5b92ffSmrg { 57545f5b92ffSmrgEOF 575536e956c5Smrg case $host in 57565f5b92ffSmrg *mingw* | *cygwin* ) 57575f5b92ffSmrg # make stdout use "unix" line endings 57585f5b92ffSmrg echo " setmode(1,_O_BINARY);" 57595f5b92ffSmrg ;; 57605f5b92ffSmrg esac 576117a48c7cSmrg 57625f5b92ffSmrg cat <<"EOF" 57630dd80ee0Smrg lt_dump_script (stdout); 57645f5b92ffSmrg return 0; 57655f5b92ffSmrg } 576636e956c5Smrg if (STREQ (argv[i], debug_opt)) 57670dd80ee0Smrg { 57680dd80ee0Smrg lt_debug = 1; 57690dd80ee0Smrg continue; 57700dd80ee0Smrg } 577136e956c5Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 57720dd80ee0Smrg { 57730dd80ee0Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 57740dd80ee0Smrg namespace, but it is not one of the ones we know about and 57750dd80ee0Smrg have already dealt with, above (inluding dump-script), then 57760dd80ee0Smrg report an error. Otherwise, targets might begin to believe 57770dd80ee0Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 57780dd80ee0Smrg namespace. The first time any user complains about this, we'll 57790dd80ee0Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 57800dd80ee0Smrg or a configure.ac-settable value. 57810dd80ee0Smrg */ 57820dd80ee0Smrg lt_fatal (__FILE__, __LINE__, 57830dd80ee0Smrg "unrecognized %s option: '%s'", 57840dd80ee0Smrg ltwrapper_option_prefix, argv[i]); 57850dd80ee0Smrg } 57860dd80ee0Smrg /* otherwise ... */ 57870dd80ee0Smrg newargz[++newargc] = xstrdup (argv[i]); 57885f5b92ffSmrg } 57890dd80ee0Smrg newargz[++newargc] = NULL; 57900dd80ee0Smrg 57910dd80ee0SmrgEOF 57920dd80ee0Smrg cat <<EOF 57930dd80ee0Smrg /* The GNU banner must be the first non-error debug message */ 579436e956c5Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 57950dd80ee0SmrgEOF 57960dd80ee0Smrg cat <<"EOF" 57970dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 57980dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 579917a48c7cSmrg 58005f5b92ffSmrg tmp_pathspec = find_executable (argv[0]); 58015f5b92ffSmrg if (tmp_pathspec == NULL) 58020dd80ee0Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 58030dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 58040dd80ee0Smrg "(main) found exe (before symlink chase) at: %s\n", 58050dd80ee0Smrg tmp_pathspec); 58065f5b92ffSmrg 58075f5b92ffSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 58080dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 58090dd80ee0Smrg "(main) found exe (after symlink chase) at: %s\n", 58100dd80ee0Smrg actual_cwrapper_path); 58115f5b92ffSmrg XFREE (tmp_pathspec); 58125f5b92ffSmrg 58130dd80ee0Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 58145f5b92ffSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 58155f5b92ffSmrg 58165f5b92ffSmrg /* wrapper name transforms */ 58175f5b92ffSmrg strendzap (actual_cwrapper_name, ".exe"); 58185f5b92ffSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 58195f5b92ffSmrg XFREE (actual_cwrapper_name); 58205f5b92ffSmrg actual_cwrapper_name = tmp_pathspec; 58215f5b92ffSmrg tmp_pathspec = 0; 58225f5b92ffSmrg 58235f5b92ffSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 58245f5b92ffSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 58255f5b92ffSmrg strendzap (target_name, ".exe"); 58265f5b92ffSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 58275f5b92ffSmrg XFREE (target_name); 58285f5b92ffSmrg target_name = tmp_pathspec; 58295f5b92ffSmrg tmp_pathspec = 0; 58305f5b92ffSmrg 58310dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 58320dd80ee0Smrg "(main) libtool target name: %s\n", 58330dd80ee0Smrg target_name); 58345f5b92ffSmrgEOF 583517a48c7cSmrg 58365f5b92ffSmrg cat <<EOF 58375f5b92ffSmrg newargz[0] = 58385f5b92ffSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 58395f5b92ffSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 58405f5b92ffSmrg strcpy (newargz[0], actual_cwrapper_path); 58415f5b92ffSmrg strcat (newargz[0], "$objdir"); 58425f5b92ffSmrg strcat (newargz[0], "/"); 58435f5b92ffSmrgEOF 584417a48c7cSmrg 58455f5b92ffSmrg cat <<"EOF" 58465f5b92ffSmrg /* stop here, and copy so we don't have to do this twice */ 58475f5b92ffSmrg tmp_pathspec = xstrdup (newargz[0]); 584817a48c7cSmrg 58495f5b92ffSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 58505f5b92ffSmrg strcat (newargz[0], actual_cwrapper_name); 585117a48c7cSmrg 58525f5b92ffSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 58535f5b92ffSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 58545f5b92ffSmrg XFREE (tmp_pathspec); 58555f5b92ffSmrg tmp_pathspec = NULL; 58565f5b92ffSmrgEOF 585717a48c7cSmrg 58585f5b92ffSmrg case $host_os in 58595f5b92ffSmrg mingw*) 58605f5b92ffSmrg cat <<"EOF" 58615f5b92ffSmrg { 58625f5b92ffSmrg char* p; 58635f5b92ffSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 58645f5b92ffSmrg { 58655f5b92ffSmrg *p = '/'; 58665f5b92ffSmrg } 58675f5b92ffSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 58685f5b92ffSmrg { 58695f5b92ffSmrg *p = '/'; 58705f5b92ffSmrg } 58715f5b92ffSmrg } 58725f5b92ffSmrgEOF 58735f5b92ffSmrg ;; 58745f5b92ffSmrg esac 587517a48c7cSmrg 58765f5b92ffSmrg cat <<"EOF" 58775f5b92ffSmrg XFREE (target_name); 58785f5b92ffSmrg XFREE (actual_cwrapper_path); 58795f5b92ffSmrg XFREE (actual_cwrapper_name); 588017a48c7cSmrg 58815f5b92ffSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 58825f5b92ffSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 58830dd80ee0Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 58840dd80ee0Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 58850dd80ee0Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 58860dd80ee0Smrg libraries must come first. */ 58875f5b92ffSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 58880dd80ee0Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 588917a48c7cSmrg 58900dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 58910dd80ee0Smrg nonnull (lt_argv_zero)); 58925f5b92ffSmrg for (i = 0; i < newargc; i++) 58935f5b92ffSmrg { 58940dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 58950dd80ee0Smrg i, nonnull (newargz[i])); 58965f5b92ffSmrg } 589717a48c7cSmrg 58985f5b92ffSmrgEOF 589917a48c7cSmrg 59005f5b92ffSmrg case $host_os in 59015f5b92ffSmrg mingw*) 59025f5b92ffSmrg cat <<"EOF" 59035f5b92ffSmrg /* execv doesn't actually work on mingw as expected on unix */ 59040dd80ee0Smrg newargz = prepare_spawn (newargz); 590536e956c5Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 59065f5b92ffSmrg if (rval == -1) 59075f5b92ffSmrg { 59085f5b92ffSmrg /* failed to start process */ 59090dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 59100dd80ee0Smrg "(main) failed to launch target \"%s\": %s\n", 59110dd80ee0Smrg lt_argv_zero, nonnull (strerror (errno))); 59125f5b92ffSmrg return 127; 59135f5b92ffSmrg } 59145f5b92ffSmrg return rval; 59155f5b92ffSmrgEOF 59165f5b92ffSmrg ;; 59175f5b92ffSmrg *) 59185f5b92ffSmrg cat <<"EOF" 59195f5b92ffSmrg execv (lt_argv_zero, newargz); 59205f5b92ffSmrg return rval; /* =127, but avoids unused variable warning */ 59215f5b92ffSmrgEOF 59225f5b92ffSmrg ;; 59235f5b92ffSmrg esac 592417a48c7cSmrg 59255f5b92ffSmrg cat <<"EOF" 59265f5b92ffSmrg} 592717a48c7cSmrg 59285f5b92ffSmrgvoid * 59295f5b92ffSmrgxmalloc (size_t num) 59305f5b92ffSmrg{ 59315f5b92ffSmrg void *p = (void *) malloc (num); 59325f5b92ffSmrg if (!p) 59330dd80ee0Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 593417a48c7cSmrg 59355f5b92ffSmrg return p; 59365f5b92ffSmrg} 593717a48c7cSmrg 59385f5b92ffSmrgchar * 59395f5b92ffSmrgxstrdup (const char *string) 59405f5b92ffSmrg{ 59415f5b92ffSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 59425f5b92ffSmrg string) : NULL; 59435f5b92ffSmrg} 594417a48c7cSmrg 59455f5b92ffSmrgconst char * 59465f5b92ffSmrgbase_name (const char *name) 59475f5b92ffSmrg{ 59485f5b92ffSmrg const char *base; 594917a48c7cSmrg 595036e956c5Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 59515f5b92ffSmrg /* Skip over the disk name in MSDOS pathnames. */ 59525f5b92ffSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 59535f5b92ffSmrg name += 2; 59545f5b92ffSmrg#endif 595517a48c7cSmrg 59565f5b92ffSmrg for (base = name; *name; name++) 59575f5b92ffSmrg if (IS_DIR_SEPARATOR (*name)) 59585f5b92ffSmrg base = name + 1; 59595f5b92ffSmrg return base; 59605f5b92ffSmrg} 596117a48c7cSmrg 59625f5b92ffSmrgint 59635f5b92ffSmrgcheck_executable (const char *path) 59645f5b92ffSmrg{ 59655f5b92ffSmrg struct stat st; 596617a48c7cSmrg 59670dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 59680dd80ee0Smrg nonempty (path)); 59695f5b92ffSmrg if ((!path) || (!*path)) 59705f5b92ffSmrg return 0; 597117a48c7cSmrg 59725f5b92ffSmrg if ((stat (path, &st) >= 0) 59735f5b92ffSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 59745f5b92ffSmrg return 1; 59755f5b92ffSmrg else 59765f5b92ffSmrg return 0; 59775f5b92ffSmrg} 597817a48c7cSmrg 59795f5b92ffSmrgint 59805f5b92ffSmrgmake_executable (const char *path) 59815f5b92ffSmrg{ 59825f5b92ffSmrg int rval = 0; 59835f5b92ffSmrg struct stat st; 598417a48c7cSmrg 59850dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 59860dd80ee0Smrg nonempty (path)); 59875f5b92ffSmrg if ((!path) || (!*path)) 59885f5b92ffSmrg return 0; 598917a48c7cSmrg 59905f5b92ffSmrg if (stat (path, &st) >= 0) 59915f5b92ffSmrg { 59925f5b92ffSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 59935f5b92ffSmrg } 59945f5b92ffSmrg return rval; 59955f5b92ffSmrg} 599617a48c7cSmrg 59975f5b92ffSmrg/* Searches for the full path of the wrapper. Returns 59985f5b92ffSmrg newly allocated full path name if found, NULL otherwise 59995f5b92ffSmrg Does not chase symlinks, even on platforms that support them. 60005f5b92ffSmrg*/ 60015f5b92ffSmrgchar * 60025f5b92ffSmrgfind_executable (const char *wrapper) 60035f5b92ffSmrg{ 60045f5b92ffSmrg int has_slash = 0; 60055f5b92ffSmrg const char *p; 60065f5b92ffSmrg const char *p_next; 60075f5b92ffSmrg /* static buffer for getcwd */ 60085f5b92ffSmrg char tmp[LT_PATHMAX + 1]; 600936e956c5Smrg size_t tmp_len; 60105f5b92ffSmrg char *concat_name; 601117a48c7cSmrg 60120dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 60130dd80ee0Smrg nonempty (wrapper)); 601417a48c7cSmrg 60155f5b92ffSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 60165f5b92ffSmrg return NULL; 601717a48c7cSmrg 60185f5b92ffSmrg /* Absolute path? */ 601936e956c5Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60205f5b92ffSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 60215f5b92ffSmrg { 60225f5b92ffSmrg concat_name = xstrdup (wrapper); 60235f5b92ffSmrg if (check_executable (concat_name)) 60245f5b92ffSmrg return concat_name; 60255f5b92ffSmrg XFREE (concat_name); 60265f5b92ffSmrg } 60275f5b92ffSmrg else 60285f5b92ffSmrg { 60295f5b92ffSmrg#endif 60305f5b92ffSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 60315f5b92ffSmrg { 60325f5b92ffSmrg concat_name = xstrdup (wrapper); 60335f5b92ffSmrg if (check_executable (concat_name)) 60345f5b92ffSmrg return concat_name; 60355f5b92ffSmrg XFREE (concat_name); 60365f5b92ffSmrg } 603736e956c5Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60385f5b92ffSmrg } 60395f5b92ffSmrg#endif 604017a48c7cSmrg 60415f5b92ffSmrg for (p = wrapper; *p; p++) 60425f5b92ffSmrg if (*p == '/') 60435f5b92ffSmrg { 60445f5b92ffSmrg has_slash = 1; 60455f5b92ffSmrg break; 60465f5b92ffSmrg } 60475f5b92ffSmrg if (!has_slash) 60485f5b92ffSmrg { 60495f5b92ffSmrg /* no slashes; search PATH */ 60505f5b92ffSmrg const char *path = getenv ("PATH"); 60515f5b92ffSmrg if (path != NULL) 60525f5b92ffSmrg { 60535f5b92ffSmrg for (p = path; *p; p = p_next) 60545f5b92ffSmrg { 60555f5b92ffSmrg const char *q; 60565f5b92ffSmrg size_t p_len; 60575f5b92ffSmrg for (q = p; *q; q++) 60585f5b92ffSmrg if (IS_PATH_SEPARATOR (*q)) 60595f5b92ffSmrg break; 606036e956c5Smrg p_len = (size_t) (q - p); 60615f5b92ffSmrg p_next = (*q == '\0' ? q : q + 1); 60625f5b92ffSmrg if (p_len == 0) 60635f5b92ffSmrg { 60645f5b92ffSmrg /* empty path: current directory */ 60655f5b92ffSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60660dd80ee0Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60670dd80ee0Smrg nonnull (strerror (errno))); 60685f5b92ffSmrg tmp_len = strlen (tmp); 60695f5b92ffSmrg concat_name = 60705f5b92ffSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60715f5b92ffSmrg memcpy (concat_name, tmp, tmp_len); 60725f5b92ffSmrg concat_name[tmp_len] = '/'; 60735f5b92ffSmrg strcpy (concat_name + tmp_len + 1, wrapper); 60745f5b92ffSmrg } 60755f5b92ffSmrg else 60765f5b92ffSmrg { 60775f5b92ffSmrg concat_name = 60785f5b92ffSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 60795f5b92ffSmrg memcpy (concat_name, p, p_len); 60805f5b92ffSmrg concat_name[p_len] = '/'; 60815f5b92ffSmrg strcpy (concat_name + p_len + 1, wrapper); 60825f5b92ffSmrg } 60835f5b92ffSmrg if (check_executable (concat_name)) 60845f5b92ffSmrg return concat_name; 60855f5b92ffSmrg XFREE (concat_name); 60865f5b92ffSmrg } 60875f5b92ffSmrg } 60885f5b92ffSmrg /* not found in PATH; assume curdir */ 60895f5b92ffSmrg } 60905f5b92ffSmrg /* Relative path | not found in path: prepend cwd */ 60915f5b92ffSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60920dd80ee0Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60930dd80ee0Smrg nonnull (strerror (errno))); 60945f5b92ffSmrg tmp_len = strlen (tmp); 60955f5b92ffSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60965f5b92ffSmrg memcpy (concat_name, tmp, tmp_len); 60975f5b92ffSmrg concat_name[tmp_len] = '/'; 60985f5b92ffSmrg strcpy (concat_name + tmp_len + 1, wrapper); 609917a48c7cSmrg 61005f5b92ffSmrg if (check_executable (concat_name)) 61015f5b92ffSmrg return concat_name; 61025f5b92ffSmrg XFREE (concat_name); 61035f5b92ffSmrg return NULL; 61045f5b92ffSmrg} 610517a48c7cSmrg 61065f5b92ffSmrgchar * 61075f5b92ffSmrgchase_symlinks (const char *pathspec) 61085f5b92ffSmrg{ 61095f5b92ffSmrg#ifndef S_ISLNK 61105f5b92ffSmrg return xstrdup (pathspec); 61115f5b92ffSmrg#else 61125f5b92ffSmrg char buf[LT_PATHMAX]; 61135f5b92ffSmrg struct stat s; 61145f5b92ffSmrg char *tmp_pathspec = xstrdup (pathspec); 61155f5b92ffSmrg char *p; 61165f5b92ffSmrg int has_symlinks = 0; 61175f5b92ffSmrg while (strlen (tmp_pathspec) && !has_symlinks) 61185f5b92ffSmrg { 61190dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 61200dd80ee0Smrg "checking path component for symlinks: %s\n", 61210dd80ee0Smrg tmp_pathspec); 61225f5b92ffSmrg if (lstat (tmp_pathspec, &s) == 0) 61235f5b92ffSmrg { 61245f5b92ffSmrg if (S_ISLNK (s.st_mode) != 0) 61255f5b92ffSmrg { 61265f5b92ffSmrg has_symlinks = 1; 61275f5b92ffSmrg break; 61285f5b92ffSmrg } 612917a48c7cSmrg 61305f5b92ffSmrg /* search backwards for last DIR_SEPARATOR */ 61315f5b92ffSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 61325f5b92ffSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61335f5b92ffSmrg p--; 61345f5b92ffSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61355f5b92ffSmrg { 61365f5b92ffSmrg /* no more DIR_SEPARATORS left */ 61375f5b92ffSmrg break; 61385f5b92ffSmrg } 61395f5b92ffSmrg *p = '\0'; 61405f5b92ffSmrg } 61415f5b92ffSmrg else 61425f5b92ffSmrg { 61430dd80ee0Smrg lt_fatal (__FILE__, __LINE__, 61440dd80ee0Smrg "error accessing file \"%s\": %s", 61450dd80ee0Smrg tmp_pathspec, nonnull (strerror (errno))); 61465f5b92ffSmrg } 61475f5b92ffSmrg } 61485f5b92ffSmrg XFREE (tmp_pathspec); 614917a48c7cSmrg 61505f5b92ffSmrg if (!has_symlinks) 61515f5b92ffSmrg { 61525f5b92ffSmrg return xstrdup (pathspec); 61535f5b92ffSmrg } 615417a48c7cSmrg 61555f5b92ffSmrg tmp_pathspec = realpath (pathspec, buf); 61565f5b92ffSmrg if (tmp_pathspec == 0) 61575f5b92ffSmrg { 61580dd80ee0Smrg lt_fatal (__FILE__, __LINE__, 61590dd80ee0Smrg "could not follow symlinks for %s", pathspec); 61605f5b92ffSmrg } 61615f5b92ffSmrg return xstrdup (tmp_pathspec); 61625f5b92ffSmrg#endif 61635f5b92ffSmrg} 616417a48c7cSmrg 61655f5b92ffSmrgchar * 61665f5b92ffSmrgstrendzap (char *str, const char *pat) 61675f5b92ffSmrg{ 61685f5b92ffSmrg size_t len, patlen; 616917a48c7cSmrg 61705f5b92ffSmrg assert (str != NULL); 61715f5b92ffSmrg assert (pat != NULL); 617217a48c7cSmrg 61735f5b92ffSmrg len = strlen (str); 61745f5b92ffSmrg patlen = strlen (pat); 617517a48c7cSmrg 61765f5b92ffSmrg if (patlen <= len) 61775f5b92ffSmrg { 61785f5b92ffSmrg str += len - patlen; 617936e956c5Smrg if (STREQ (str, pat)) 61805f5b92ffSmrg *str = '\0'; 61815f5b92ffSmrg } 61825f5b92ffSmrg return str; 61835f5b92ffSmrg} 618417a48c7cSmrg 61850dd80ee0Smrgvoid 61860dd80ee0Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 61870dd80ee0Smrg{ 61880dd80ee0Smrg va_list args; 61890dd80ee0Smrg if (lt_debug) 61900dd80ee0Smrg { 61910dd80ee0Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 61920dd80ee0Smrg va_start (args, fmt); 61930dd80ee0Smrg (void) vfprintf (stderr, fmt, args); 61940dd80ee0Smrg va_end (args); 61950dd80ee0Smrg } 61960dd80ee0Smrg} 61970dd80ee0Smrg 61985f5b92ffSmrgstatic void 61990dd80ee0Smrglt_error_core (int exit_status, const char *file, 62000dd80ee0Smrg int line, const char *mode, 62015f5b92ffSmrg const char *message, va_list ap) 62025f5b92ffSmrg{ 62030dd80ee0Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 62045f5b92ffSmrg vfprintf (stderr, message, ap); 62055f5b92ffSmrg fprintf (stderr, ".\n"); 620617a48c7cSmrg 62075f5b92ffSmrg if (exit_status >= 0) 62085f5b92ffSmrg exit (exit_status); 62095f5b92ffSmrg} 621017a48c7cSmrg 62115f5b92ffSmrgvoid 62120dd80ee0Smrglt_fatal (const char *file, int line, const char *message, ...) 62135f5b92ffSmrg{ 62145f5b92ffSmrg va_list ap; 62155f5b92ffSmrg va_start (ap, message); 62160dd80ee0Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 62175f5b92ffSmrg va_end (ap); 62185f5b92ffSmrg} 621917a48c7cSmrg 62200dd80ee0Smrgstatic const char * 62210dd80ee0Smrgnonnull (const char *s) 62220dd80ee0Smrg{ 62230dd80ee0Smrg return s ? s : "(null)"; 62240dd80ee0Smrg} 62250dd80ee0Smrg 62260dd80ee0Smrgstatic const char * 62270dd80ee0Smrgnonempty (const char *s) 62280dd80ee0Smrg{ 62290dd80ee0Smrg return (s && !*s) ? "(empty)" : nonnull (s); 62300dd80ee0Smrg} 62310dd80ee0Smrg 62325f5b92ffSmrgvoid 62335f5b92ffSmrglt_setenv (const char *name, const char *value) 62345f5b92ffSmrg{ 62350dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 62360dd80ee0Smrg "(lt_setenv) setting '%s' to '%s'\n", 62370dd80ee0Smrg nonnull (name), nonnull (value)); 62385f5b92ffSmrg { 62395f5b92ffSmrg#ifdef HAVE_SETENV 62405f5b92ffSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 62415f5b92ffSmrg char *str = xstrdup (value); 62425f5b92ffSmrg setenv (name, str, 1); 62435f5b92ffSmrg#else 624436e956c5Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 62455f5b92ffSmrg char *str = XMALLOC (char, len); 62465f5b92ffSmrg sprintf (str, "%s=%s", name, value); 62475f5b92ffSmrg if (putenv (str) != EXIT_SUCCESS) 62485f5b92ffSmrg { 62495f5b92ffSmrg XFREE (str); 62505f5b92ffSmrg } 62515f5b92ffSmrg#endif 62525f5b92ffSmrg } 62535f5b92ffSmrg} 625417a48c7cSmrg 62555f5b92ffSmrgchar * 62565f5b92ffSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 62575f5b92ffSmrg{ 62585f5b92ffSmrg char *new_value; 62595f5b92ffSmrg if (orig_value && *orig_value) 62605f5b92ffSmrg { 626136e956c5Smrg size_t orig_value_len = strlen (orig_value); 626236e956c5Smrg size_t add_len = strlen (add); 62635f5b92ffSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 62645f5b92ffSmrg if (to_end) 62655f5b92ffSmrg { 62665f5b92ffSmrg strcpy (new_value, orig_value); 62675f5b92ffSmrg strcpy (new_value + orig_value_len, add); 62685f5b92ffSmrg } 62695f5b92ffSmrg else 62705f5b92ffSmrg { 62715f5b92ffSmrg strcpy (new_value, add); 62725f5b92ffSmrg strcpy (new_value + add_len, orig_value); 62735f5b92ffSmrg } 62745f5b92ffSmrg } 62755f5b92ffSmrg else 62765f5b92ffSmrg { 62775f5b92ffSmrg new_value = xstrdup (add); 62785f5b92ffSmrg } 62795f5b92ffSmrg return new_value; 62805f5b92ffSmrg} 628117a48c7cSmrg 62825f5b92ffSmrgvoid 62835f5b92ffSmrglt_update_exe_path (const char *name, const char *value) 62845f5b92ffSmrg{ 62850dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 62860dd80ee0Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 62870dd80ee0Smrg nonnull (name), nonnull (value)); 628817a48c7cSmrg 62895f5b92ffSmrg if (name && *name && value && *value) 62905f5b92ffSmrg { 62915f5b92ffSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 62925f5b92ffSmrg /* some systems can't cope with a ':'-terminated path #' */ 629336e956c5Smrg size_t len = strlen (new_value); 629436e956c5Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 62955f5b92ffSmrg { 629636e956c5Smrg new_value[--len] = '\0'; 62975f5b92ffSmrg } 62985f5b92ffSmrg lt_setenv (name, new_value); 62995f5b92ffSmrg XFREE (new_value); 63005f5b92ffSmrg } 63015f5b92ffSmrg} 630217a48c7cSmrg 63035f5b92ffSmrgvoid 63045f5b92ffSmrglt_update_lib_path (const char *name, const char *value) 63055f5b92ffSmrg{ 63060dd80ee0Smrg lt_debugprintf (__FILE__, __LINE__, 63070dd80ee0Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 63080dd80ee0Smrg nonnull (name), nonnull (value)); 630917a48c7cSmrg 63105f5b92ffSmrg if (name && *name && value && *value) 63115f5b92ffSmrg { 63125f5b92ffSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 63135f5b92ffSmrg lt_setenv (name, new_value); 63145f5b92ffSmrg XFREE (new_value); 63155f5b92ffSmrg } 63165f5b92ffSmrg} 631717a48c7cSmrg 63180dd80ee0SmrgEOF 63190dd80ee0Smrg case $host_os in 63200dd80ee0Smrg mingw*) 63210dd80ee0Smrg cat <<"EOF" 63220dd80ee0Smrg 63230dd80ee0Smrg/* Prepares an argument vector before calling spawn(). 63240dd80ee0Smrg Note that spawn() does not by itself call the command interpreter 63250dd80ee0Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 63260dd80ee0Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 63270dd80ee0Smrg GetVersionEx(&v); 63280dd80ee0Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 63290dd80ee0Smrg }) ? "cmd.exe" : "command.com"). 63300dd80ee0Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 63310dd80ee0Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 63320dd80ee0Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 63330dd80ee0Smrg special way: 63340dd80ee0Smrg - Space and tab are interpreted as delimiters. They are not treated as 63350dd80ee0Smrg delimiters if they are surrounded by double quotes: "...". 63360dd80ee0Smrg - Unescaped double quotes are removed from the input. Their only effect is 63370dd80ee0Smrg that within double quotes, space and tab are treated like normal 63380dd80ee0Smrg characters. 63390dd80ee0Smrg - Backslashes not followed by double quotes are not special. 63400dd80ee0Smrg - But 2*n+1 backslashes followed by a double quote become 63410dd80ee0Smrg n backslashes followed by a double quote (n >= 0): 63420dd80ee0Smrg \" -> " 63430dd80ee0Smrg \\\" -> \" 63440dd80ee0Smrg \\\\\" -> \\" 63450dd80ee0Smrg */ 63460dd80ee0Smrg#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" 63470dd80ee0Smrg#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" 63480dd80ee0Smrgchar ** 63490dd80ee0Smrgprepare_spawn (char **argv) 63500dd80ee0Smrg{ 63510dd80ee0Smrg size_t argc; 63520dd80ee0Smrg char **new_argv; 63530dd80ee0Smrg size_t i; 63540dd80ee0Smrg 63550dd80ee0Smrg /* Count number of arguments. */ 63560dd80ee0Smrg for (argc = 0; argv[argc] != NULL; argc++) 63570dd80ee0Smrg ; 63580dd80ee0Smrg 63590dd80ee0Smrg /* Allocate new argument vector. */ 63600dd80ee0Smrg new_argv = XMALLOC (char *, argc + 1); 63610dd80ee0Smrg 63620dd80ee0Smrg /* Put quoted arguments into the new argument vector. */ 63630dd80ee0Smrg for (i = 0; i < argc; i++) 63640dd80ee0Smrg { 63650dd80ee0Smrg const char *string = argv[i]; 63660dd80ee0Smrg 63670dd80ee0Smrg if (string[0] == '\0') 63680dd80ee0Smrg new_argv[i] = xstrdup ("\"\""); 63690dd80ee0Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 63700dd80ee0Smrg { 63710dd80ee0Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 63720dd80ee0Smrg size_t length; 63730dd80ee0Smrg unsigned int backslashes; 63740dd80ee0Smrg const char *s; 63750dd80ee0Smrg char *quoted_string; 63760dd80ee0Smrg char *p; 63770dd80ee0Smrg 63780dd80ee0Smrg length = 0; 63790dd80ee0Smrg backslashes = 0; 63800dd80ee0Smrg if (quote_around) 63810dd80ee0Smrg length++; 63820dd80ee0Smrg for (s = string; *s != '\0'; s++) 63830dd80ee0Smrg { 63840dd80ee0Smrg char c = *s; 63850dd80ee0Smrg if (c == '"') 63860dd80ee0Smrg length += backslashes + 1; 63870dd80ee0Smrg length++; 63880dd80ee0Smrg if (c == '\\') 63890dd80ee0Smrg backslashes++; 63900dd80ee0Smrg else 63910dd80ee0Smrg backslashes = 0; 63920dd80ee0Smrg } 63930dd80ee0Smrg if (quote_around) 63940dd80ee0Smrg length += backslashes + 1; 63950dd80ee0Smrg 63960dd80ee0Smrg quoted_string = XMALLOC (char, length + 1); 63970dd80ee0Smrg 63980dd80ee0Smrg p = quoted_string; 63990dd80ee0Smrg backslashes = 0; 64000dd80ee0Smrg if (quote_around) 64010dd80ee0Smrg *p++ = '"'; 64020dd80ee0Smrg for (s = string; *s != '\0'; s++) 64030dd80ee0Smrg { 64040dd80ee0Smrg char c = *s; 64050dd80ee0Smrg if (c == '"') 64060dd80ee0Smrg { 64070dd80ee0Smrg unsigned int j; 64080dd80ee0Smrg for (j = backslashes + 1; j > 0; j--) 64090dd80ee0Smrg *p++ = '\\'; 64100dd80ee0Smrg } 64110dd80ee0Smrg *p++ = c; 64120dd80ee0Smrg if (c == '\\') 64130dd80ee0Smrg backslashes++; 64140dd80ee0Smrg else 64150dd80ee0Smrg backslashes = 0; 64160dd80ee0Smrg } 64170dd80ee0Smrg if (quote_around) 64180dd80ee0Smrg { 64190dd80ee0Smrg unsigned int j; 64200dd80ee0Smrg for (j = backslashes; j > 0; j--) 64210dd80ee0Smrg *p++ = '\\'; 64220dd80ee0Smrg *p++ = '"'; 64230dd80ee0Smrg } 64240dd80ee0Smrg *p = '\0'; 64250dd80ee0Smrg 64260dd80ee0Smrg new_argv[i] = quoted_string; 64270dd80ee0Smrg } 64280dd80ee0Smrg else 64290dd80ee0Smrg new_argv[i] = (char *) string; 64300dd80ee0Smrg } 64310dd80ee0Smrg new_argv[argc] = NULL; 64320dd80ee0Smrg 64330dd80ee0Smrg return new_argv; 64340dd80ee0Smrg} 64350dd80ee0SmrgEOF 64360dd80ee0Smrg ;; 64370dd80ee0Smrg esac 643817a48c7cSmrg 64390dd80ee0Smrg cat <<"EOF" 64400dd80ee0Smrgvoid lt_dump_script (FILE* f) 64410dd80ee0Smrg{ 64420dd80ee0SmrgEOF 64430dd80ee0Smrg func_emit_wrapper yes | 64440dd80ee0Smrg $SED -n -e ' 64450dd80ee0Smrgs/^\(.\{79\}\)\(..*\)/\1\ 64460dd80ee0Smrg\2/ 64470dd80ee0Smrgh 64480dd80ee0Smrgs/\([\\"]\)/\\\1/g 64490dd80ee0Smrgs/$/\\n/ 64500dd80ee0Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 64510dd80ee0Smrgg 64520dd80ee0SmrgD' 64530dd80ee0Smrg cat <<"EOF" 64540dd80ee0Smrg} 64555f5b92ffSmrgEOF 64565f5b92ffSmrg} 64575f5b92ffSmrg# end: func_emit_cwrapperexe_src 645817a48c7cSmrg 64590dd80ee0Smrg# func_win32_import_lib_p ARG 64600dd80ee0Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 64610dd80ee0Smrgfunc_win32_import_lib_p () 64620dd80ee0Smrg{ 646336e956c5Smrg $debug_cmd 646436e956c5Smrg 64650dd80ee0Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 64660dd80ee0Smrg *import*) : ;; 64670dd80ee0Smrg *) false ;; 64680dd80ee0Smrg esac 64690dd80ee0Smrg} 64700dd80ee0Smrg 647136e956c5Smrg# func_suncc_cstd_abi 647236e956c5Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647336e956c5Smrg# Several compiler flags select an ABI that is incompatible with the 647436e956c5Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647536e956c5Smrgfunc_suncc_cstd_abi () 647636e956c5Smrg{ 647736e956c5Smrg $debug_cmd 647836e956c5Smrg 647936e956c5Smrg case " $compile_command " in 648036e956c5Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648136e956c5Smrg suncc_use_cstd_abi=no 648236e956c5Smrg ;; 648336e956c5Smrg *) 648436e956c5Smrg suncc_use_cstd_abi=yes 648536e956c5Smrg ;; 648636e956c5Smrg esac 648736e956c5Smrg} 648836e956c5Smrg 64895f5b92ffSmrg# func_mode_link arg... 64905f5b92ffSmrgfunc_mode_link () 64915f5b92ffSmrg{ 649236e956c5Smrg $debug_cmd 649336e956c5Smrg 64945f5b92ffSmrg case $host in 64955f5b92ffSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 64965f5b92ffSmrg # It is impossible to link a dll without this setting, and 64975f5b92ffSmrg # we shouldn't force the makefile maintainer to figure out 649836e956c5Smrg # what system we are compiling for in order to pass an extra 64995f5b92ffSmrg # flag for every libtool invocation. 65005f5b92ffSmrg # allow_undefined=no 650117a48c7cSmrg 65025f5b92ffSmrg # FIXME: Unfortunately, there are problems with the above when trying 650336e956c5Smrg # to make a dll that has undefined symbols, in which case not 65045f5b92ffSmrg # even a static library is built. For now, we need to specify 65055f5b92ffSmrg # -no-undefined on the libtool link line when we can be certain 65065f5b92ffSmrg # that all symbols are satisfied, otherwise we get a static library. 65075f5b92ffSmrg allow_undefined=yes 65085f5b92ffSmrg ;; 65095f5b92ffSmrg *) 65105f5b92ffSmrg allow_undefined=yes 65115f5b92ffSmrg ;; 65125f5b92ffSmrg esac 65135f5b92ffSmrg libtool_args=$nonopt 65145f5b92ffSmrg base_compile="$nonopt $@" 65155f5b92ffSmrg compile_command=$nonopt 65165f5b92ffSmrg finalize_command=$nonopt 651717a48c7cSmrg 65185f5b92ffSmrg compile_rpath= 65195f5b92ffSmrg finalize_rpath= 65205f5b92ffSmrg compile_shlibpath= 65215f5b92ffSmrg finalize_shlibpath= 65225f5b92ffSmrg convenience= 65235f5b92ffSmrg old_convenience= 65245f5b92ffSmrg deplibs= 65255f5b92ffSmrg old_deplibs= 65265f5b92ffSmrg compiler_flags= 65275f5b92ffSmrg linker_flags= 65285f5b92ffSmrg dllsearchpath= 65295f5b92ffSmrg lib_search_path=`pwd` 65305f5b92ffSmrg inst_prefix_dir= 65315f5b92ffSmrg new_inherited_linker_flags= 653217a48c7cSmrg 65335f5b92ffSmrg avoid_version=no 65340dd80ee0Smrg bindir= 65355f5b92ffSmrg dlfiles= 65365f5b92ffSmrg dlprefiles= 65375f5b92ffSmrg dlself=no 65385f5b92ffSmrg export_dynamic=no 65395f5b92ffSmrg export_symbols= 65405f5b92ffSmrg export_symbols_regex= 65415f5b92ffSmrg generated= 65425f5b92ffSmrg libobjs= 65435f5b92ffSmrg ltlibs= 65445f5b92ffSmrg module=no 65455f5b92ffSmrg no_install=no 65465f5b92ffSmrg objs= 654736e956c5Smrg os2dllname= 65485f5b92ffSmrg non_pic_objects= 65495f5b92ffSmrg precious_files_regex= 65505f5b92ffSmrg prefer_static_libs=no 655136e956c5Smrg preload=false 65525f5b92ffSmrg prev= 65535f5b92ffSmrg prevarg= 65545f5b92ffSmrg release= 65555f5b92ffSmrg rpath= 65565f5b92ffSmrg xrpath= 65575f5b92ffSmrg perm_rpath= 65585f5b92ffSmrg temp_rpath= 65595f5b92ffSmrg thread_safe=no 65605f5b92ffSmrg vinfo= 65615f5b92ffSmrg vinfo_number=no 65625f5b92ffSmrg weak_libs= 656336e956c5Smrg single_module=$wl-single_module 65645f5b92ffSmrg func_infer_tag $base_compile 65655f5b92ffSmrg 65665f5b92ffSmrg # We need to know -static, to get the right output filenames. 65675f5b92ffSmrg for arg 65685f5b92ffSmrg do 65695f5b92ffSmrg case $arg in 65705f5b92ffSmrg -shared) 657136e956c5Smrg test yes != "$build_libtool_libs" \ 657236e956c5Smrg && func_fatal_configuration "cannot build a shared library" 65735f5b92ffSmrg build_old_libs=no 65745f5b92ffSmrg break 65755f5b92ffSmrg ;; 65765f5b92ffSmrg -all-static | -static | -static-libtool-libs) 65775f5b92ffSmrg case $arg in 65785f5b92ffSmrg -all-static) 657936e956c5Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 65805f5b92ffSmrg func_warning "complete static linking is impossible in this configuration" 65815f5b92ffSmrg fi 65825f5b92ffSmrg if test -n "$link_static_flag"; then 65835f5b92ffSmrg dlopen_self=$dlopen_self_static 65845f5b92ffSmrg fi 65855f5b92ffSmrg prefer_static_libs=yes 65865f5b92ffSmrg ;; 65875f5b92ffSmrg -static) 65885f5b92ffSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65895f5b92ffSmrg dlopen_self=$dlopen_self_static 65905f5b92ffSmrg fi 65915f5b92ffSmrg prefer_static_libs=built 65925f5b92ffSmrg ;; 65935f5b92ffSmrg -static-libtool-libs) 65945f5b92ffSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65955f5b92ffSmrg dlopen_self=$dlopen_self_static 659617a48c7cSmrg fi 65975f5b92ffSmrg prefer_static_libs=yes 65985f5b92ffSmrg ;; 65995f5b92ffSmrg esac 66005f5b92ffSmrg build_libtool_libs=no 66015f5b92ffSmrg build_old_libs=yes 66025f5b92ffSmrg break 66035f5b92ffSmrg ;; 66045f5b92ffSmrg esac 66055f5b92ffSmrg done 660617a48c7cSmrg 66075f5b92ffSmrg # See if our shared archives depend on static archives. 66085f5b92ffSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 660917a48c7cSmrg 66105f5b92ffSmrg # Go through the arguments, transforming them on the way. 66115f5b92ffSmrg while test "$#" -gt 0; do 661236e956c5Smrg arg=$1 66135f5b92ffSmrg shift 66145f5b92ffSmrg func_quote_for_eval "$arg" 66155f5b92ffSmrg qarg=$func_quote_for_eval_unquoted_result 66165f5b92ffSmrg func_append libtool_args " $func_quote_for_eval_result" 661717a48c7cSmrg 66185f5b92ffSmrg # If the previous option needs an argument, assign it. 66195f5b92ffSmrg if test -n "$prev"; then 66205f5b92ffSmrg case $prev in 66215f5b92ffSmrg output) 66225f5b92ffSmrg func_append compile_command " @OUTPUT@" 66235f5b92ffSmrg func_append finalize_command " @OUTPUT@" 66245f5b92ffSmrg ;; 66255f5b92ffSmrg esac 662617a48c7cSmrg 66275f5b92ffSmrg case $prev in 66280dd80ee0Smrg bindir) 662936e956c5Smrg bindir=$arg 66300dd80ee0Smrg prev= 66310dd80ee0Smrg continue 66320dd80ee0Smrg ;; 66335f5b92ffSmrg dlfiles|dlprefiles) 663436e956c5Smrg $preload || { 66355f5b92ffSmrg # Add the symbol object into the linking commands. 66365f5b92ffSmrg func_append compile_command " @SYMFILE@" 66375f5b92ffSmrg func_append finalize_command " @SYMFILE@" 663836e956c5Smrg preload=: 663936e956c5Smrg } 66405f5b92ffSmrg case $arg in 66415f5b92ffSmrg *.la | *.lo) ;; # We handle these cases below. 66425f5b92ffSmrg force) 664336e956c5Smrg if test no = "$dlself"; then 66445f5b92ffSmrg dlself=needless 66455f5b92ffSmrg export_dynamic=yes 66465f5b92ffSmrg fi 66475f5b92ffSmrg prev= 66485f5b92ffSmrg continue 66495f5b92ffSmrg ;; 66505f5b92ffSmrg self) 665136e956c5Smrg if test dlprefiles = "$prev"; then 66525f5b92ffSmrg dlself=yes 665336e956c5Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 66545f5b92ffSmrg dlself=yes 665517a48c7cSmrg else 66565f5b92ffSmrg dlself=needless 66575f5b92ffSmrg export_dynamic=yes 665817a48c7cSmrg fi 66595f5b92ffSmrg prev= 66605f5b92ffSmrg continue 66615f5b92ffSmrg ;; 66625f5b92ffSmrg *) 666336e956c5Smrg if test dlfiles = "$prev"; then 66640dd80ee0Smrg func_append dlfiles " $arg" 666517a48c7cSmrg else 66660dd80ee0Smrg func_append dlprefiles " $arg" 666717a48c7cSmrg fi 66685f5b92ffSmrg prev= 66695f5b92ffSmrg continue 66705f5b92ffSmrg ;; 66715f5b92ffSmrg esac 66725f5b92ffSmrg ;; 66735f5b92ffSmrg expsyms) 667436e956c5Smrg export_symbols=$arg 66755f5b92ffSmrg test -f "$arg" \ 667636e956c5Smrg || func_fatal_error "symbol file '$arg' does not exist" 66775f5b92ffSmrg prev= 66785f5b92ffSmrg continue 66795f5b92ffSmrg ;; 66805f5b92ffSmrg expsyms_regex) 668136e956c5Smrg export_symbols_regex=$arg 66825f5b92ffSmrg prev= 66835f5b92ffSmrg continue 66845f5b92ffSmrg ;; 66855f5b92ffSmrg framework) 668617a48c7cSmrg case $host in 66875f5b92ffSmrg *-*-darwin*) 66885f5b92ffSmrg case "$deplibs " in 66895f5b92ffSmrg *" $qarg.ltframework "*) ;; 66900dd80ee0Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 66915f5b92ffSmrg ;; 66925f5b92ffSmrg esac 66935f5b92ffSmrg ;; 669417a48c7cSmrg esac 66955f5b92ffSmrg prev= 66965f5b92ffSmrg continue 669717a48c7cSmrg ;; 66985f5b92ffSmrg inst_prefix) 669936e956c5Smrg inst_prefix_dir=$arg 670036e956c5Smrg prev= 670136e956c5Smrg continue 670236e956c5Smrg ;; 670336e956c5Smrg mllvm) 670436e956c5Smrg # Clang does not use LLVM to link, so we can simply discard any 670536e956c5Smrg # '-mllvm $arg' options when doing the link step. 67065f5b92ffSmrg prev= 67075f5b92ffSmrg continue 670817a48c7cSmrg ;; 67095f5b92ffSmrg objectlist) 67105f5b92ffSmrg if test -f "$arg"; then 67115f5b92ffSmrg save_arg=$arg 67125f5b92ffSmrg moreargs= 67135f5b92ffSmrg for fil in `cat "$save_arg"` 67145f5b92ffSmrg do 67150dd80ee0Smrg# func_append moreargs " $fil" 67165f5b92ffSmrg arg=$fil 67175f5b92ffSmrg # A libtool-controlled object. 671817a48c7cSmrg 67195f5b92ffSmrg # Check to see that this really is a libtool object. 67205f5b92ffSmrg if func_lalib_unsafe_p "$arg"; then 67215f5b92ffSmrg pic_object= 67225f5b92ffSmrg non_pic_object= 672317a48c7cSmrg 67245f5b92ffSmrg # Read the .lo file 67255f5b92ffSmrg func_source "$arg" 672617a48c7cSmrg 67275f5b92ffSmrg if test -z "$pic_object" || 67285f5b92ffSmrg test -z "$non_pic_object" || 672936e956c5Smrg test none = "$pic_object" && 673036e956c5Smrg test none = "$non_pic_object"; then 673136e956c5Smrg func_fatal_error "cannot find name of object for '$arg'" 67325f5b92ffSmrg fi 673317a48c7cSmrg 67345f5b92ffSmrg # Extract subdirectory from the argument. 67355f5b92ffSmrg func_dirname "$arg" "/" "" 673636e956c5Smrg xdir=$func_dirname_result 673717a48c7cSmrg 673836e956c5Smrg if test none != "$pic_object"; then 67395f5b92ffSmrg # Prepend the subdirectory the object is found in. 674036e956c5Smrg pic_object=$xdir$pic_object 674117a48c7cSmrg 674236e956c5Smrg if test dlfiles = "$prev"; then 674336e956c5Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 67440dd80ee0Smrg func_append dlfiles " $pic_object" 67455f5b92ffSmrg prev= 67465f5b92ffSmrg continue 67475f5b92ffSmrg else 67485f5b92ffSmrg # If libtool objects are unsupported, then we need to preload. 67495f5b92ffSmrg prev=dlprefiles 67505f5b92ffSmrg fi 67515f5b92ffSmrg fi 675217a48c7cSmrg 67535f5b92ffSmrg # CHECK ME: I think I busted this. -Ossama 675436e956c5Smrg if test dlprefiles = "$prev"; then 67555f5b92ffSmrg # Preload the old-style object. 67560dd80ee0Smrg func_append dlprefiles " $pic_object" 67575f5b92ffSmrg prev= 67585f5b92ffSmrg fi 675917a48c7cSmrg 67605f5b92ffSmrg # A PIC object. 67615f5b92ffSmrg func_append libobjs " $pic_object" 676236e956c5Smrg arg=$pic_object 67635f5b92ffSmrg fi 676417a48c7cSmrg 67655f5b92ffSmrg # Non-PIC object. 676636e956c5Smrg if test none != "$non_pic_object"; then 67675f5b92ffSmrg # Prepend the subdirectory the object is found in. 676836e956c5Smrg non_pic_object=$xdir$non_pic_object 676917a48c7cSmrg 67705f5b92ffSmrg # A standard non-PIC object 67715f5b92ffSmrg func_append non_pic_objects " $non_pic_object" 677236e956c5Smrg if test -z "$pic_object" || test none = "$pic_object"; then 677336e956c5Smrg arg=$non_pic_object 67745f5b92ffSmrg fi 67755f5b92ffSmrg else 67765f5b92ffSmrg # If the PIC object exists, use it instead. 67775f5b92ffSmrg # $xdir was prepended to $pic_object above. 677836e956c5Smrg non_pic_object=$pic_object 67795f5b92ffSmrg func_append non_pic_objects " $non_pic_object" 67805f5b92ffSmrg fi 67815f5b92ffSmrg else 67825f5b92ffSmrg # Only an error if not doing a dry-run. 67835f5b92ffSmrg if $opt_dry_run; then 67845f5b92ffSmrg # Extract subdirectory from the argument. 67855f5b92ffSmrg func_dirname "$arg" "/" "" 678636e956c5Smrg xdir=$func_dirname_result 67875f5b92ffSmrg 67885f5b92ffSmrg func_lo2o "$arg" 67895f5b92ffSmrg pic_object=$xdir$objdir/$func_lo2o_result 67905f5b92ffSmrg non_pic_object=$xdir$func_lo2o_result 67915f5b92ffSmrg func_append libobjs " $pic_object" 67925f5b92ffSmrg func_append non_pic_objects " $non_pic_object" 67935f5b92ffSmrg else 679436e956c5Smrg func_fatal_error "'$arg' is not a valid libtool object" 67955f5b92ffSmrg fi 67965f5b92ffSmrg fi 67975f5b92ffSmrg done 679817a48c7cSmrg else 679936e956c5Smrg func_fatal_error "link input file '$arg' does not exist" 680017a48c7cSmrg fi 68015f5b92ffSmrg arg=$save_arg 68025f5b92ffSmrg prev= 68035f5b92ffSmrg continue 68045f5b92ffSmrg ;; 680536e956c5Smrg os2dllname) 680636e956c5Smrg os2dllname=$arg 680736e956c5Smrg prev= 680836e956c5Smrg continue 680936e956c5Smrg ;; 68105f5b92ffSmrg precious_regex) 681136e956c5Smrg precious_files_regex=$arg 68125f5b92ffSmrg prev= 68135f5b92ffSmrg continue 68145f5b92ffSmrg ;; 68155f5b92ffSmrg release) 681636e956c5Smrg release=-$arg 68175f5b92ffSmrg prev= 68185f5b92ffSmrg continue 68195f5b92ffSmrg ;; 68205f5b92ffSmrg rpath | xrpath) 68215f5b92ffSmrg # We need an absolute path. 68225f5b92ffSmrg case $arg in 68235f5b92ffSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 68245f5b92ffSmrg *) 68255f5b92ffSmrg func_fatal_error "only absolute run-paths are allowed" 68265f5b92ffSmrg ;; 68275f5b92ffSmrg esac 682836e956c5Smrg if test rpath = "$prev"; then 68295f5b92ffSmrg case "$rpath " in 68305f5b92ffSmrg *" $arg "*) ;; 68310dd80ee0Smrg *) func_append rpath " $arg" ;; 68325f5b92ffSmrg esac 683317a48c7cSmrg else 68345f5b92ffSmrg case "$xrpath " in 68355f5b92ffSmrg *" $arg "*) ;; 68360dd80ee0Smrg *) func_append xrpath " $arg" ;; 68375f5b92ffSmrg esac 683817a48c7cSmrg fi 68395f5b92ffSmrg prev= 68405f5b92ffSmrg continue 68415f5b92ffSmrg ;; 68425f5b92ffSmrg shrext) 684336e956c5Smrg shrext_cmds=$arg 68445f5b92ffSmrg prev= 68455f5b92ffSmrg continue 68465f5b92ffSmrg ;; 68475f5b92ffSmrg weak) 68480dd80ee0Smrg func_append weak_libs " $arg" 68495f5b92ffSmrg prev= 68505f5b92ffSmrg continue 68515f5b92ffSmrg ;; 68525f5b92ffSmrg xcclinker) 68530dd80ee0Smrg func_append linker_flags " $qarg" 68540dd80ee0Smrg func_append compiler_flags " $qarg" 68555f5b92ffSmrg prev= 68565f5b92ffSmrg func_append compile_command " $qarg" 68575f5b92ffSmrg func_append finalize_command " $qarg" 68585f5b92ffSmrg continue 68595f5b92ffSmrg ;; 68605f5b92ffSmrg xcompiler) 68610dd80ee0Smrg func_append compiler_flags " $qarg" 68625f5b92ffSmrg prev= 68635f5b92ffSmrg func_append compile_command " $qarg" 68645f5b92ffSmrg func_append finalize_command " $qarg" 68655f5b92ffSmrg continue 68665f5b92ffSmrg ;; 68675f5b92ffSmrg xlinker) 68680dd80ee0Smrg func_append linker_flags " $qarg" 68690dd80ee0Smrg func_append compiler_flags " $wl$qarg" 68705f5b92ffSmrg prev= 68715f5b92ffSmrg func_append compile_command " $wl$qarg" 68725f5b92ffSmrg func_append finalize_command " $wl$qarg" 68735f5b92ffSmrg continue 68745f5b92ffSmrg ;; 68755f5b92ffSmrg *) 68765f5b92ffSmrg eval "$prev=\"\$arg\"" 68775f5b92ffSmrg prev= 68785f5b92ffSmrg continue 68795f5b92ffSmrg ;; 688017a48c7cSmrg esac 68815f5b92ffSmrg fi # test -n "$prev" 688217a48c7cSmrg 688336e956c5Smrg prevarg=$arg 688417a48c7cSmrg 68855f5b92ffSmrg case $arg in 68865f5b92ffSmrg -all-static) 68875f5b92ffSmrg if test -n "$link_static_flag"; then 68885f5b92ffSmrg # See comment for -static flag below, for more details. 68895f5b92ffSmrg func_append compile_command " $link_static_flag" 68905f5b92ffSmrg func_append finalize_command " $link_static_flag" 68915f5b92ffSmrg fi 68925f5b92ffSmrg continue 68935f5b92ffSmrg ;; 689417a48c7cSmrg 68955f5b92ffSmrg -allow-undefined) 68965f5b92ffSmrg # FIXME: remove this flag sometime in the future. 689736e956c5Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 68985f5b92ffSmrg ;; 689917a48c7cSmrg 69005f5b92ffSmrg -avoid-version) 69015f5b92ffSmrg avoid_version=yes 69025f5b92ffSmrg continue 69035f5b92ffSmrg ;; 690417a48c7cSmrg 69050dd80ee0Smrg -bindir) 69060dd80ee0Smrg prev=bindir 69070dd80ee0Smrg continue 69080dd80ee0Smrg ;; 69090dd80ee0Smrg 69105f5b92ffSmrg -dlopen) 69115f5b92ffSmrg prev=dlfiles 69125f5b92ffSmrg continue 69135f5b92ffSmrg ;; 691417a48c7cSmrg 69155f5b92ffSmrg -dlpreopen) 69165f5b92ffSmrg prev=dlprefiles 69175f5b92ffSmrg continue 69185f5b92ffSmrg ;; 691917a48c7cSmrg 69205f5b92ffSmrg -export-dynamic) 69215f5b92ffSmrg export_dynamic=yes 69225f5b92ffSmrg continue 69235f5b92ffSmrg ;; 692417a48c7cSmrg 69255f5b92ffSmrg -export-symbols | -export-symbols-regex) 69265f5b92ffSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 69275f5b92ffSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 69285f5b92ffSmrg fi 692936e956c5Smrg if test X-export-symbols = "X$arg"; then 69305f5b92ffSmrg prev=expsyms 69315f5b92ffSmrg else 69325f5b92ffSmrg prev=expsyms_regex 69335f5b92ffSmrg fi 69345f5b92ffSmrg continue 69355f5b92ffSmrg ;; 693617a48c7cSmrg 69375f5b92ffSmrg -framework) 69385f5b92ffSmrg prev=framework 69395f5b92ffSmrg continue 69405f5b92ffSmrg ;; 694117a48c7cSmrg 69425f5b92ffSmrg -inst-prefix-dir) 69435f5b92ffSmrg prev=inst_prefix 69445f5b92ffSmrg continue 69455f5b92ffSmrg ;; 694617a48c7cSmrg 69475f5b92ffSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 69485f5b92ffSmrg # so, if we see these flags be careful not to treat them like -L 69495f5b92ffSmrg -L[A-Z][A-Z]*:*) 69505f5b92ffSmrg case $with_gcc/$host in 69515f5b92ffSmrg no/*-*-irix* | /*-*-irix*) 69525f5b92ffSmrg func_append compile_command " $arg" 69535f5b92ffSmrg func_append finalize_command " $arg" 69545f5b92ffSmrg ;; 69555f5b92ffSmrg esac 69565f5b92ffSmrg continue 69575f5b92ffSmrg ;; 695817a48c7cSmrg 69595f5b92ffSmrg -L*) 69600dd80ee0Smrg func_stripname "-L" '' "$arg" 69610dd80ee0Smrg if test -z "$func_stripname_result"; then 69625f5b92ffSmrg if test "$#" -gt 0; then 696336e956c5Smrg func_fatal_error "require no space between '-L' and '$1'" 69645f5b92ffSmrg else 696536e956c5Smrg func_fatal_error "need path for '-L' option" 69665f5b92ffSmrg fi 69675f5b92ffSmrg fi 69680dd80ee0Smrg func_resolve_sysroot "$func_stripname_result" 69690dd80ee0Smrg dir=$func_resolve_sysroot_result 69705f5b92ffSmrg # We need an absolute path. 69715f5b92ffSmrg case $dir in 69725f5b92ffSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 69735f5b92ffSmrg *) 69745f5b92ffSmrg absdir=`cd "$dir" && pwd` 69755f5b92ffSmrg test -z "$absdir" && \ 697636e956c5Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697736e956c5Smrg dir=$absdir 69785f5b92ffSmrg ;; 69795f5b92ffSmrg esac 69805f5b92ffSmrg case "$deplibs " in 69810dd80ee0Smrg *" -L$dir "* | *" $arg "*) 69820dd80ee0Smrg # Will only happen for absolute or sysroot arguments 69830dd80ee0Smrg ;; 69845f5b92ffSmrg *) 69850dd80ee0Smrg # Preserve sysroot, but never include relative directories 69860dd80ee0Smrg case $dir in 69870dd80ee0Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 69880dd80ee0Smrg *) func_append deplibs " -L$dir" ;; 69890dd80ee0Smrg esac 69900dd80ee0Smrg func_append lib_search_path " $dir" 69915f5b92ffSmrg ;; 69925f5b92ffSmrg esac 69935f5b92ffSmrg case $host in 69945f5b92ffSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 69950dd80ee0Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 69965f5b92ffSmrg case :$dllsearchpath: in 69975f5b92ffSmrg *":$dir:"*) ;; 69985f5b92ffSmrg ::) dllsearchpath=$dir;; 69990dd80ee0Smrg *) func_append dllsearchpath ":$dir";; 70005f5b92ffSmrg esac 70015f5b92ffSmrg case :$dllsearchpath: in 70025f5b92ffSmrg *":$testbindir:"*) ;; 70035f5b92ffSmrg ::) dllsearchpath=$testbindir;; 70040dd80ee0Smrg *) func_append dllsearchpath ":$testbindir";; 70055f5b92ffSmrg esac 70065f5b92ffSmrg ;; 70075f5b92ffSmrg esac 70085f5b92ffSmrg continue 70095f5b92ffSmrg ;; 701017a48c7cSmrg 70115f5b92ffSmrg -l*) 701236e956c5Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 70135f5b92ffSmrg case $host in 70140dd80ee0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 70155f5b92ffSmrg # These systems don't actually have a C or math library (as such) 70165f5b92ffSmrg continue 70175f5b92ffSmrg ;; 70185f5b92ffSmrg *-*-os2*) 70195f5b92ffSmrg # These systems don't actually have a C library (as such) 702036e956c5Smrg test X-lc = "X$arg" && continue 70215f5b92ffSmrg ;; 702236e956c5Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70235f5b92ffSmrg # Do not include libc due to us having libc/libc_r. 702436e956c5Smrg test X-lc = "X$arg" && continue 70255f5b92ffSmrg ;; 70265f5b92ffSmrg *-*-rhapsody* | *-*-darwin1.[012]) 70275f5b92ffSmrg # Rhapsody C and math libraries are in the System framework 70280dd80ee0Smrg func_append deplibs " System.ltframework" 70295f5b92ffSmrg continue 70305f5b92ffSmrg ;; 70315f5b92ffSmrg *-*-sco3.2v5* | *-*-sco5v6*) 70325f5b92ffSmrg # Causes problems with __ctype 703336e956c5Smrg test X-lc = "X$arg" && continue 70345f5b92ffSmrg ;; 70355f5b92ffSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 70365f5b92ffSmrg # Compiler inserts libc in the correct place for threads to work 703736e956c5Smrg test X-lc = "X$arg" && continue 70385f5b92ffSmrg ;; 70395f5b92ffSmrg esac 704036e956c5Smrg elif test X-lc_r = "X$arg"; then 70415f5b92ffSmrg case $host in 704236e956c5Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70435f5b92ffSmrg # Do not include libc_r directly, use -pthread flag. 70445f5b92ffSmrg continue 70455f5b92ffSmrg ;; 70465f5b92ffSmrg esac 70475f5b92ffSmrg fi 70480dd80ee0Smrg func_append deplibs " $arg" 70495f5b92ffSmrg continue 70505f5b92ffSmrg ;; 705117a48c7cSmrg 705236e956c5Smrg -mllvm) 705336e956c5Smrg prev=mllvm 705436e956c5Smrg continue 705536e956c5Smrg ;; 705636e956c5Smrg 70575f5b92ffSmrg -module) 70585f5b92ffSmrg module=yes 70595f5b92ffSmrg continue 70605f5b92ffSmrg ;; 706117a48c7cSmrg 70625f5b92ffSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 70635f5b92ffSmrg # classes, name mangling, and exception handling. 70645f5b92ffSmrg # Darwin uses the -arch flag to determine output architecture. 70650dd80ee0Smrg -model|-arch|-isysroot|--sysroot) 70660dd80ee0Smrg func_append compiler_flags " $arg" 70675f5b92ffSmrg func_append compile_command " $arg" 70685f5b92ffSmrg func_append finalize_command " $arg" 70695f5b92ffSmrg prev=xcompiler 70705f5b92ffSmrg continue 70715f5b92ffSmrg ;; 707217a48c7cSmrg 70730dd80ee0Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 70740dd80ee0Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 70750dd80ee0Smrg func_append compiler_flags " $arg" 70765f5b92ffSmrg func_append compile_command " $arg" 70775f5b92ffSmrg func_append finalize_command " $arg" 70785f5b92ffSmrg case "$new_inherited_linker_flags " in 70795f5b92ffSmrg *" $arg "*) ;; 70800dd80ee0Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 70815f5b92ffSmrg esac 70825f5b92ffSmrg continue 70835f5b92ffSmrg ;; 708417a48c7cSmrg 70855f5b92ffSmrg -multi_module) 708636e956c5Smrg single_module=$wl-multi_module 70875f5b92ffSmrg continue 70885f5b92ffSmrg ;; 708917a48c7cSmrg 70905f5b92ffSmrg -no-fast-install) 70915f5b92ffSmrg fast_install=no 70925f5b92ffSmrg continue 70935f5b92ffSmrg ;; 709417a48c7cSmrg 70955f5b92ffSmrg -no-install) 70965f5b92ffSmrg case $host in 70975f5b92ffSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 70985f5b92ffSmrg # The PATH hackery in wrapper scripts is required on Windows 70995f5b92ffSmrg # and Darwin in order for the loader to find any dlls it needs. 710036e956c5Smrg func_warning "'-no-install' is ignored for $host" 710136e956c5Smrg func_warning "assuming '-no-fast-install' instead" 71025f5b92ffSmrg fast_install=no 71035f5b92ffSmrg ;; 71045f5b92ffSmrg *) no_install=yes ;; 71055f5b92ffSmrg esac 71065f5b92ffSmrg continue 71075f5b92ffSmrg ;; 710817a48c7cSmrg 71095f5b92ffSmrg -no-undefined) 71105f5b92ffSmrg allow_undefined=no 71115f5b92ffSmrg continue 71125f5b92ffSmrg ;; 711317a48c7cSmrg 71145f5b92ffSmrg -objectlist) 71155f5b92ffSmrg prev=objectlist 71165f5b92ffSmrg continue 71175f5b92ffSmrg ;; 711817a48c7cSmrg 711936e956c5Smrg -os2dllname) 712036e956c5Smrg prev=os2dllname 712136e956c5Smrg continue 712236e956c5Smrg ;; 712336e956c5Smrg 71245f5b92ffSmrg -o) prev=output ;; 712517a48c7cSmrg 71265f5b92ffSmrg -precious-files-regex) 71275f5b92ffSmrg prev=precious_regex 71285f5b92ffSmrg continue 71295f5b92ffSmrg ;; 713017a48c7cSmrg 71315f5b92ffSmrg -release) 71325f5b92ffSmrg prev=release 71335f5b92ffSmrg continue 71345f5b92ffSmrg ;; 713517a48c7cSmrg 71365f5b92ffSmrg -rpath) 71375f5b92ffSmrg prev=rpath 71385f5b92ffSmrg continue 71395f5b92ffSmrg ;; 714017a48c7cSmrg 71415f5b92ffSmrg -R) 71425f5b92ffSmrg prev=xrpath 71435f5b92ffSmrg continue 71445f5b92ffSmrg ;; 714517a48c7cSmrg 71465f5b92ffSmrg -R*) 71475f5b92ffSmrg func_stripname '-R' '' "$arg" 71485f5b92ffSmrg dir=$func_stripname_result 71495f5b92ffSmrg # We need an absolute path. 71505f5b92ffSmrg case $dir in 71515f5b92ffSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 71520dd80ee0Smrg =*) 71530dd80ee0Smrg func_stripname '=' '' "$dir" 71540dd80ee0Smrg dir=$lt_sysroot$func_stripname_result 71550dd80ee0Smrg ;; 71565f5b92ffSmrg *) 71575f5b92ffSmrg func_fatal_error "only absolute run-paths are allowed" 71585f5b92ffSmrg ;; 71595f5b92ffSmrg esac 71605f5b92ffSmrg case "$xrpath " in 71615f5b92ffSmrg *" $dir "*) ;; 71620dd80ee0Smrg *) func_append xrpath " $dir" ;; 71635f5b92ffSmrg esac 71645f5b92ffSmrg continue 71655f5b92ffSmrg ;; 716617a48c7cSmrg 71675f5b92ffSmrg -shared) 71685f5b92ffSmrg # The effects of -shared are defined in a previous loop. 71695f5b92ffSmrg continue 71705f5b92ffSmrg ;; 717117a48c7cSmrg 71725f5b92ffSmrg -shrext) 71735f5b92ffSmrg prev=shrext 71745f5b92ffSmrg continue 71755f5b92ffSmrg ;; 717617a48c7cSmrg 71775f5b92ffSmrg -static | -static-libtool-libs) 71785f5b92ffSmrg # The effects of -static are defined in a previous loop. 71795f5b92ffSmrg # We used to do the same as -all-static on platforms that 71805f5b92ffSmrg # didn't have a PIC flag, but the assumption that the effects 71815f5b92ffSmrg # would be equivalent was wrong. It would break on at least 71825f5b92ffSmrg # Digital Unix and AIX. 71835f5b92ffSmrg continue 71845f5b92ffSmrg ;; 718517a48c7cSmrg 71865f5b92ffSmrg -thread-safe) 71875f5b92ffSmrg thread_safe=yes 71885f5b92ffSmrg continue 71895f5b92ffSmrg ;; 719017a48c7cSmrg 71915f5b92ffSmrg -version-info) 71925f5b92ffSmrg prev=vinfo 71935f5b92ffSmrg continue 71945f5b92ffSmrg ;; 719517a48c7cSmrg 71965f5b92ffSmrg -version-number) 71975f5b92ffSmrg prev=vinfo 71985f5b92ffSmrg vinfo_number=yes 71995f5b92ffSmrg continue 72005f5b92ffSmrg ;; 720117a48c7cSmrg 72025f5b92ffSmrg -weak) 72035f5b92ffSmrg prev=weak 72045f5b92ffSmrg continue 72055f5b92ffSmrg ;; 720617a48c7cSmrg 72075f5b92ffSmrg -Wc,*) 72085f5b92ffSmrg func_stripname '-Wc,' '' "$arg" 72095f5b92ffSmrg args=$func_stripname_result 72105f5b92ffSmrg arg= 721136e956c5Smrg save_ifs=$IFS; IFS=, 72125f5b92ffSmrg for flag in $args; do 721336e956c5Smrg IFS=$save_ifs 72145f5b92ffSmrg func_quote_for_eval "$flag" 72150dd80ee0Smrg func_append arg " $func_quote_for_eval_result" 72160dd80ee0Smrg func_append compiler_flags " $func_quote_for_eval_result" 72175f5b92ffSmrg done 721836e956c5Smrg IFS=$save_ifs 72195f5b92ffSmrg func_stripname ' ' '' "$arg" 72205f5b92ffSmrg arg=$func_stripname_result 72215f5b92ffSmrg ;; 722217a48c7cSmrg 72235f5b92ffSmrg -Wl,*) 72245f5b92ffSmrg func_stripname '-Wl,' '' "$arg" 72255f5b92ffSmrg args=$func_stripname_result 72265f5b92ffSmrg arg= 722736e956c5Smrg save_ifs=$IFS; IFS=, 72285f5b92ffSmrg for flag in $args; do 722936e956c5Smrg IFS=$save_ifs 72305f5b92ffSmrg func_quote_for_eval "$flag" 72310dd80ee0Smrg func_append arg " $wl$func_quote_for_eval_result" 72320dd80ee0Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 72330dd80ee0Smrg func_append linker_flags " $func_quote_for_eval_result" 72345f5b92ffSmrg done 723536e956c5Smrg IFS=$save_ifs 72365f5b92ffSmrg func_stripname ' ' '' "$arg" 72375f5b92ffSmrg arg=$func_stripname_result 72385f5b92ffSmrg ;; 723917a48c7cSmrg 72405f5b92ffSmrg -Xcompiler) 72415f5b92ffSmrg prev=xcompiler 72425f5b92ffSmrg continue 72435f5b92ffSmrg ;; 724417a48c7cSmrg 72455f5b92ffSmrg -Xlinker) 72465f5b92ffSmrg prev=xlinker 72475f5b92ffSmrg continue 72485f5b92ffSmrg ;; 724917a48c7cSmrg 72505f5b92ffSmrg -XCClinker) 72515f5b92ffSmrg prev=xcclinker 72525f5b92ffSmrg continue 72535f5b92ffSmrg ;; 725417a48c7cSmrg 72555f5b92ffSmrg # -msg_* for osf cc 72565f5b92ffSmrg -msg_*) 72575f5b92ffSmrg func_quote_for_eval "$arg" 725836e956c5Smrg arg=$func_quote_for_eval_result 72595f5b92ffSmrg ;; 726017a48c7cSmrg 72610dd80ee0Smrg # Flags to be passed through unchanged, with rationale: 72620dd80ee0Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 72630dd80ee0Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 72640dd80ee0Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 72650dd80ee0Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 72660dd80ee0Smrg # -q* compiler args for the IBM compiler 72670dd80ee0Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 72680dd80ee0Smrg # -F/path path to uninstalled frameworks, gcc on darwin 72690dd80ee0Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727036e956c5Smrg # -fstack-protector* stack protector flags for GCC 72710dd80ee0Smrg # @file GCC response files 72720dd80ee0Smrg # -tp=* Portland pgcc target processor selection 72730dd80ee0Smrg # --sysroot=* for sysroot support 727436e956c5Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 727536e956c5Smrg # -specs=* GCC specs files 727636e956c5Smrg # -stdlib=* select c++ std lib with clang 727736e956c5Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 72785f5b92ffSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 72790dd80ee0Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 728036e956c5Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 728136e956c5Smrg -specs=*|-fsanitize=*) 72825f5b92ffSmrg func_quote_for_eval "$arg" 728336e956c5Smrg arg=$func_quote_for_eval_result 72845f5b92ffSmrg func_append compile_command " $arg" 72855f5b92ffSmrg func_append finalize_command " $arg" 72860dd80ee0Smrg func_append compiler_flags " $arg" 72875f5b92ffSmrg continue 72885f5b92ffSmrg ;; 728917a48c7cSmrg 729036e956c5Smrg -Z*) 729136e956c5Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 729236e956c5Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 729336e956c5Smrg compiler_flags="$compiler_flags $arg" 729436e956c5Smrg func_append compile_command " $arg" 729536e956c5Smrg func_append finalize_command " $arg" 729636e956c5Smrg case $arg in 729736e956c5Smrg -Zlinker | -Zstack) 729836e956c5Smrg prev=xcompiler 729936e956c5Smrg ;; 730036e956c5Smrg esac 730136e956c5Smrg continue 730236e956c5Smrg else 730336e956c5Smrg # Otherwise treat like 'Some other compiler flag' below 730436e956c5Smrg func_quote_for_eval "$arg" 730536e956c5Smrg arg=$func_quote_for_eval_result 730636e956c5Smrg fi 730736e956c5Smrg ;; 730836e956c5Smrg 73095f5b92ffSmrg # Some other compiler flag. 73105f5b92ffSmrg -* | +*) 73115f5b92ffSmrg func_quote_for_eval "$arg" 731236e956c5Smrg arg=$func_quote_for_eval_result 73135f5b92ffSmrg ;; 731417a48c7cSmrg 73155f5b92ffSmrg *.$objext) 73165f5b92ffSmrg # A standard object. 73170dd80ee0Smrg func_append objs " $arg" 73185f5b92ffSmrg ;; 731917a48c7cSmrg 73205f5b92ffSmrg *.lo) 73215f5b92ffSmrg # A libtool-controlled object. 732217a48c7cSmrg 73235f5b92ffSmrg # Check to see that this really is a libtool object. 73245f5b92ffSmrg if func_lalib_unsafe_p "$arg"; then 73255f5b92ffSmrg pic_object= 73265f5b92ffSmrg non_pic_object= 732717a48c7cSmrg 73285f5b92ffSmrg # Read the .lo file 73295f5b92ffSmrg func_source "$arg" 733017a48c7cSmrg 73315f5b92ffSmrg if test -z "$pic_object" || 73325f5b92ffSmrg test -z "$non_pic_object" || 733336e956c5Smrg test none = "$pic_object" && 733436e956c5Smrg test none = "$non_pic_object"; then 733536e956c5Smrg func_fatal_error "cannot find name of object for '$arg'" 73365f5b92ffSmrg fi 733717a48c7cSmrg 73385f5b92ffSmrg # Extract subdirectory from the argument. 73395f5b92ffSmrg func_dirname "$arg" "/" "" 734036e956c5Smrg xdir=$func_dirname_result 73418e0ed500Smrg 734236e956c5Smrg test none = "$pic_object" || { 73435f5b92ffSmrg # Prepend the subdirectory the object is found in. 734436e956c5Smrg pic_object=$xdir$pic_object 734517a48c7cSmrg 734636e956c5Smrg if test dlfiles = "$prev"; then 734736e956c5Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 73480dd80ee0Smrg func_append dlfiles " $pic_object" 73495f5b92ffSmrg prev= 73505f5b92ffSmrg continue 73515f5b92ffSmrg else 73525f5b92ffSmrg # If libtool objects are unsupported, then we need to preload. 73535f5b92ffSmrg prev=dlprefiles 73545f5b92ffSmrg fi 73555f5b92ffSmrg fi 735617a48c7cSmrg 73575f5b92ffSmrg # CHECK ME: I think I busted this. -Ossama 735836e956c5Smrg if test dlprefiles = "$prev"; then 73595f5b92ffSmrg # Preload the old-style object. 73600dd80ee0Smrg func_append dlprefiles " $pic_object" 73615f5b92ffSmrg prev= 73625f5b92ffSmrg fi 736317a48c7cSmrg 73645f5b92ffSmrg # A PIC object. 73655f5b92ffSmrg func_append libobjs " $pic_object" 736636e956c5Smrg arg=$pic_object 736736e956c5Smrg } 736817a48c7cSmrg 73695f5b92ffSmrg # Non-PIC object. 737036e956c5Smrg if test none != "$non_pic_object"; then 73715f5b92ffSmrg # Prepend the subdirectory the object is found in. 737236e956c5Smrg non_pic_object=$xdir$non_pic_object 737317a48c7cSmrg 73745f5b92ffSmrg # A standard non-PIC object 73755f5b92ffSmrg func_append non_pic_objects " $non_pic_object" 737636e956c5Smrg if test -z "$pic_object" || test none = "$pic_object"; then 737736e956c5Smrg arg=$non_pic_object 73785f5b92ffSmrg fi 73795f5b92ffSmrg else 73805f5b92ffSmrg # If the PIC object exists, use it instead. 73815f5b92ffSmrg # $xdir was prepended to $pic_object above. 738236e956c5Smrg non_pic_object=$pic_object 73835f5b92ffSmrg func_append non_pic_objects " $non_pic_object" 73845f5b92ffSmrg fi 73855f5b92ffSmrg else 73865f5b92ffSmrg # Only an error if not doing a dry-run. 73875f5b92ffSmrg if $opt_dry_run; then 73885f5b92ffSmrg # Extract subdirectory from the argument. 73895f5b92ffSmrg func_dirname "$arg" "/" "" 739036e956c5Smrg xdir=$func_dirname_result 73915f5b92ffSmrg 73925f5b92ffSmrg func_lo2o "$arg" 73935f5b92ffSmrg pic_object=$xdir$objdir/$func_lo2o_result 73945f5b92ffSmrg non_pic_object=$xdir$func_lo2o_result 73955f5b92ffSmrg func_append libobjs " $pic_object" 73965f5b92ffSmrg func_append non_pic_objects " $non_pic_object" 73975f5b92ffSmrg else 739836e956c5Smrg func_fatal_error "'$arg' is not a valid libtool object" 73995f5b92ffSmrg fi 74005f5b92ffSmrg fi 74015f5b92ffSmrg ;; 740217a48c7cSmrg 74035f5b92ffSmrg *.$libext) 74045f5b92ffSmrg # An archive. 74050dd80ee0Smrg func_append deplibs " $arg" 74060dd80ee0Smrg func_append old_deplibs " $arg" 74075f5b92ffSmrg continue 74085f5b92ffSmrg ;; 74095f5b92ffSmrg 74105f5b92ffSmrg *.la) 74115f5b92ffSmrg # A libtool-controlled library. 74125f5b92ffSmrg 74130dd80ee0Smrg func_resolve_sysroot "$arg" 741436e956c5Smrg if test dlfiles = "$prev"; then 74155f5b92ffSmrg # This library was specified with -dlopen. 74160dd80ee0Smrg func_append dlfiles " $func_resolve_sysroot_result" 74175f5b92ffSmrg prev= 741836e956c5Smrg elif test dlprefiles = "$prev"; then 74195f5b92ffSmrg # The library was specified with -dlpreopen. 74200dd80ee0Smrg func_append dlprefiles " $func_resolve_sysroot_result" 74215f5b92ffSmrg prev= 74225f5b92ffSmrg else 74230dd80ee0Smrg func_append deplibs " $func_resolve_sysroot_result" 74245f5b92ffSmrg fi 74255f5b92ffSmrg continue 74265f5b92ffSmrg ;; 74275f5b92ffSmrg 74285f5b92ffSmrg # Some other compiler argument. 74295f5b92ffSmrg *) 74305f5b92ffSmrg # Unknown arguments in both finalize_command and compile_command need 74315f5b92ffSmrg # to be aesthetically quoted because they are evaled later. 74325f5b92ffSmrg func_quote_for_eval "$arg" 743336e956c5Smrg arg=$func_quote_for_eval_result 74345f5b92ffSmrg ;; 74355f5b92ffSmrg esac # arg 74365f5b92ffSmrg 74375f5b92ffSmrg # Now actually substitute the argument into the commands. 74385f5b92ffSmrg if test -n "$arg"; then 74395f5b92ffSmrg func_append compile_command " $arg" 74405f5b92ffSmrg func_append finalize_command " $arg" 74415f5b92ffSmrg fi 74425f5b92ffSmrg done # argument parsing loop 74435f5b92ffSmrg 74445f5b92ffSmrg test -n "$prev" && \ 744536e956c5Smrg func_fatal_help "the '$prevarg' option requires an argument" 74465f5b92ffSmrg 744736e956c5Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 74485f5b92ffSmrg eval arg=\"$export_dynamic_flag_spec\" 74495f5b92ffSmrg func_append compile_command " $arg" 74505f5b92ffSmrg func_append finalize_command " $arg" 74515f5b92ffSmrg fi 74525f5b92ffSmrg 74535f5b92ffSmrg oldlibs= 74545f5b92ffSmrg # calculate the name of the file, without its directory 74555f5b92ffSmrg func_basename "$output" 745636e956c5Smrg outputname=$func_basename_result 745736e956c5Smrg libobjs_save=$libobjs 74585f5b92ffSmrg 74595f5b92ffSmrg if test -n "$shlibpath_var"; then 74605f5b92ffSmrg # get the directories listed in $shlibpath_var 746136e956c5Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 74625f5b92ffSmrg else 74635f5b92ffSmrg shlib_search_path= 74645f5b92ffSmrg fi 74655f5b92ffSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 74665f5b92ffSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 74675f5b92ffSmrg 746836e956c5Smrg # Definition is injected by LT_CONFIG during libtool generation. 746936e956c5Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 747036e956c5Smrg 74715f5b92ffSmrg func_dirname "$output" "/" "" 747236e956c5Smrg output_objdir=$func_dirname_result$objdir 74730dd80ee0Smrg func_to_tool_file "$output_objdir/" 74740dd80ee0Smrg tool_output_objdir=$func_to_tool_file_result 74755f5b92ffSmrg # Create the object directory. 74765f5b92ffSmrg func_mkdir_p "$output_objdir" 74775f5b92ffSmrg 74785f5b92ffSmrg # Determine the type of output 74795f5b92ffSmrg case $output in 74805f5b92ffSmrg "") 74815f5b92ffSmrg func_fatal_help "you must specify an output file" 74825f5b92ffSmrg ;; 74835f5b92ffSmrg *.$libext) linkmode=oldlib ;; 74845f5b92ffSmrg *.lo | *.$objext) linkmode=obj ;; 74855f5b92ffSmrg *.la) linkmode=lib ;; 74865f5b92ffSmrg *) linkmode=prog ;; # Anything else should be a program. 74875f5b92ffSmrg esac 74885f5b92ffSmrg 74895f5b92ffSmrg specialdeplibs= 74905f5b92ffSmrg 74915f5b92ffSmrg libs= 74925f5b92ffSmrg # Find all interdependent deplibs by searching for libraries 74935f5b92ffSmrg # that are linked more than once (e.g. -la -lb -la) 74945f5b92ffSmrg for deplib in $deplibs; do 749536e956c5Smrg if $opt_preserve_dup_deps; then 74965f5b92ffSmrg case "$libs " in 74970dd80ee0Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 74985f5b92ffSmrg esac 74995f5b92ffSmrg fi 75000dd80ee0Smrg func_append libs " $deplib" 75015f5b92ffSmrg done 75025f5b92ffSmrg 750336e956c5Smrg if test lib = "$linkmode"; then 75045f5b92ffSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 75055f5b92ffSmrg 75065f5b92ffSmrg # Compute libraries that are listed more than once in $predeps 75075f5b92ffSmrg # $postdeps and mark them as special (i.e., whose duplicates are 75085f5b92ffSmrg # not to be eliminated). 75095f5b92ffSmrg pre_post_deps= 75105f5b92ffSmrg if $opt_duplicate_compiler_generated_deps; then 75115f5b92ffSmrg for pre_post_dep in $predeps $postdeps; do 75125f5b92ffSmrg case "$pre_post_deps " in 75130dd80ee0Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 75145f5b92ffSmrg esac 75150dd80ee0Smrg func_append pre_post_deps " $pre_post_dep" 75165f5b92ffSmrg done 75175f5b92ffSmrg fi 75185f5b92ffSmrg pre_post_deps= 75195f5b92ffSmrg fi 75205f5b92ffSmrg 75215f5b92ffSmrg deplibs= 75225f5b92ffSmrg newdependency_libs= 75235f5b92ffSmrg newlib_search_path= 75245f5b92ffSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 75255f5b92ffSmrg notinst_deplibs= # not-installed libtool libraries 75265f5b92ffSmrg notinst_path= # paths that contain not-installed libtool libraries 75275f5b92ffSmrg 75285f5b92ffSmrg case $linkmode in 75295f5b92ffSmrg lib) 75305f5b92ffSmrg passes="conv dlpreopen link" 75315f5b92ffSmrg for file in $dlfiles $dlprefiles; do 75325f5b92ffSmrg case $file in 75335f5b92ffSmrg *.la) ;; 75345f5b92ffSmrg *) 753536e956c5Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 75365f5b92ffSmrg ;; 75375f5b92ffSmrg esac 75385f5b92ffSmrg done 75395f5b92ffSmrg ;; 75405f5b92ffSmrg prog) 75415f5b92ffSmrg compile_deplibs= 75425f5b92ffSmrg finalize_deplibs= 754336e956c5Smrg alldeplibs=false 75445f5b92ffSmrg newdlfiles= 75455f5b92ffSmrg newdlprefiles= 75465f5b92ffSmrg passes="conv scan dlopen dlpreopen link" 75475f5b92ffSmrg ;; 75485f5b92ffSmrg *) passes="conv" 75495f5b92ffSmrg ;; 75505f5b92ffSmrg esac 75515f5b92ffSmrg 75525f5b92ffSmrg for pass in $passes; do 75535f5b92ffSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 75545f5b92ffSmrg # so that -L comes before libs that need it for instance... 755536e956c5Smrg if test lib,link = "$linkmode,$pass"; then 75565f5b92ffSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 75575f5b92ffSmrg ## order, and fix it there properly 75585f5b92ffSmrg tmp_deplibs= 75595f5b92ffSmrg for deplib in $deplibs; do 75605f5b92ffSmrg tmp_deplibs="$deplib $tmp_deplibs" 75615f5b92ffSmrg done 756236e956c5Smrg deplibs=$tmp_deplibs 75635f5b92ffSmrg fi 75645f5b92ffSmrg 756536e956c5Smrg if test lib,link = "$linkmode,$pass" || 756636e956c5Smrg test prog,scan = "$linkmode,$pass"; then 756736e956c5Smrg libs=$deplibs 75685f5b92ffSmrg deplibs= 75695f5b92ffSmrg fi 757036e956c5Smrg if test prog = "$linkmode"; then 75715f5b92ffSmrg case $pass in 757236e956c5Smrg dlopen) libs=$dlfiles ;; 757336e956c5Smrg dlpreopen) libs=$dlprefiles ;; 757436e956c5Smrg link) 757536e956c5Smrg libs="$deplibs %DEPLIBS%" 757636e956c5Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 757736e956c5Smrg ;; 75785f5b92ffSmrg esac 75795f5b92ffSmrg fi 758036e956c5Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 75815f5b92ffSmrg # Collect and forward deplibs of preopened libtool libs 75825f5b92ffSmrg for lib in $dlprefiles; do 75835f5b92ffSmrg # Ignore non-libtool-libs 75845f5b92ffSmrg dependency_libs= 75850dd80ee0Smrg func_resolve_sysroot "$lib" 75865f5b92ffSmrg case $lib in 75870dd80ee0Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 75885f5b92ffSmrg esac 75895f5b92ffSmrg 75905f5b92ffSmrg # Collect preopened libtool deplibs, except any this library 75915f5b92ffSmrg # has declared as weak libs 75925f5b92ffSmrg for deplib in $dependency_libs; do 75930dd80ee0Smrg func_basename "$deplib" 75940dd80ee0Smrg deplib_base=$func_basename_result 75955f5b92ffSmrg case " $weak_libs " in 75965f5b92ffSmrg *" $deplib_base "*) ;; 75970dd80ee0Smrg *) func_append deplibs " $deplib" ;; 75985f5b92ffSmrg esac 75995f5b92ffSmrg done 76005f5b92ffSmrg done 760136e956c5Smrg libs=$dlprefiles 76025f5b92ffSmrg fi 760336e956c5Smrg if test dlopen = "$pass"; then 76045f5b92ffSmrg # Collect dlpreopened libraries 760536e956c5Smrg save_deplibs=$deplibs 76065f5b92ffSmrg deplibs= 76075f5b92ffSmrg fi 76085f5b92ffSmrg 76095f5b92ffSmrg for deplib in $libs; do 76105f5b92ffSmrg lib= 761136e956c5Smrg found=false 76125f5b92ffSmrg case $deplib in 76130dd80ee0Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 76140dd80ee0Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 761536e956c5Smrg if test prog,link = "$linkmode,$pass"; then 76165f5b92ffSmrg compile_deplibs="$deplib $compile_deplibs" 76175f5b92ffSmrg finalize_deplibs="$deplib $finalize_deplibs" 76185f5b92ffSmrg else 76190dd80ee0Smrg func_append compiler_flags " $deplib" 762036e956c5Smrg if test lib = "$linkmode"; then 76215f5b92ffSmrg case "$new_inherited_linker_flags " in 76225f5b92ffSmrg *" $deplib "*) ;; 76230dd80ee0Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 76245f5b92ffSmrg esac 76255f5b92ffSmrg fi 76265f5b92ffSmrg fi 76275f5b92ffSmrg continue 76285f5b92ffSmrg ;; 76295f5b92ffSmrg -l*) 763036e956c5Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 763136e956c5Smrg func_warning "'-l' is ignored for archives/objects" 76325f5b92ffSmrg continue 76335f5b92ffSmrg fi 76345f5b92ffSmrg func_stripname '-l' '' "$deplib" 76355f5b92ffSmrg name=$func_stripname_result 763636e956c5Smrg if test lib = "$linkmode"; then 76375f5b92ffSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 76385f5b92ffSmrg else 76395f5b92ffSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 76405f5b92ffSmrg fi 76415f5b92ffSmrg for searchdir in $searchdirs; do 76425f5b92ffSmrg for search_ext in .la $std_shrext .so .a; do 76435f5b92ffSmrg # Search the libtool library 764436e956c5Smrg lib=$searchdir/lib$name$search_ext 76455f5b92ffSmrg if test -f "$lib"; then 764636e956c5Smrg if test .la = "$search_ext"; then 764736e956c5Smrg found=: 76485f5b92ffSmrg else 764936e956c5Smrg found=false 76505f5b92ffSmrg fi 76515f5b92ffSmrg break 2 76525f5b92ffSmrg fi 76535f5b92ffSmrg done 76545f5b92ffSmrg done 765536e956c5Smrg if $found; then 765636e956c5Smrg # deplib is a libtool library 76575f5b92ffSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 76585f5b92ffSmrg # We need to do some special things here, and not later. 765936e956c5Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 76605f5b92ffSmrg case " $predeps $postdeps " in 76615f5b92ffSmrg *" $deplib "*) 76625f5b92ffSmrg if func_lalib_p "$lib"; then 76635f5b92ffSmrg library_names= 76645f5b92ffSmrg old_library= 76655f5b92ffSmrg func_source "$lib" 76665f5b92ffSmrg for l in $old_library $library_names; do 766736e956c5Smrg ll=$l 76685f5b92ffSmrg done 766936e956c5Smrg if test "X$ll" = "X$old_library"; then # only static version available 767036e956c5Smrg found=false 76715f5b92ffSmrg func_dirname "$lib" "" "." 767236e956c5Smrg ladir=$func_dirname_result 76735f5b92ffSmrg lib=$ladir/$old_library 767436e956c5Smrg if test prog,link = "$linkmode,$pass"; then 76755f5b92ffSmrg compile_deplibs="$deplib $compile_deplibs" 76765f5b92ffSmrg finalize_deplibs="$deplib $finalize_deplibs" 76775f5b92ffSmrg else 76785f5b92ffSmrg deplibs="$deplib $deplibs" 767936e956c5Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76805f5b92ffSmrg fi 76815f5b92ffSmrg continue 76825f5b92ffSmrg fi 76835f5b92ffSmrg fi 76845f5b92ffSmrg ;; 76855f5b92ffSmrg *) ;; 76865f5b92ffSmrg esac 76875f5b92ffSmrg fi 768836e956c5Smrg else 768936e956c5Smrg # deplib doesn't seem to be a libtool library 769036e956c5Smrg if test prog,link = "$linkmode,$pass"; then 769136e956c5Smrg compile_deplibs="$deplib $compile_deplibs" 769236e956c5Smrg finalize_deplibs="$deplib $finalize_deplibs" 769336e956c5Smrg else 769436e956c5Smrg deplibs="$deplib $deplibs" 769536e956c5Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769636e956c5Smrg fi 769736e956c5Smrg continue 76985f5b92ffSmrg fi 76995f5b92ffSmrg ;; # -l 77005f5b92ffSmrg *.ltframework) 770136e956c5Smrg if test prog,link = "$linkmode,$pass"; then 77025f5b92ffSmrg compile_deplibs="$deplib $compile_deplibs" 77035f5b92ffSmrg finalize_deplibs="$deplib $finalize_deplibs" 77045f5b92ffSmrg else 77055f5b92ffSmrg deplibs="$deplib $deplibs" 770636e956c5Smrg if test lib = "$linkmode"; then 77075f5b92ffSmrg case "$new_inherited_linker_flags " in 77085f5b92ffSmrg *" $deplib "*) ;; 77090dd80ee0Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 77105f5b92ffSmrg esac 77115f5b92ffSmrg fi 77125f5b92ffSmrg fi 77135f5b92ffSmrg continue 77145f5b92ffSmrg ;; 77155f5b92ffSmrg -L*) 77165f5b92ffSmrg case $linkmode in 77175f5b92ffSmrg lib) 77185f5b92ffSmrg deplibs="$deplib $deplibs" 771936e956c5Smrg test conv = "$pass" && continue 77205f5b92ffSmrg newdependency_libs="$deplib $newdependency_libs" 77215f5b92ffSmrg func_stripname '-L' '' "$deplib" 77220dd80ee0Smrg func_resolve_sysroot "$func_stripname_result" 77230dd80ee0Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77245f5b92ffSmrg ;; 77255f5b92ffSmrg prog) 772636e956c5Smrg if test conv = "$pass"; then 77275f5b92ffSmrg deplibs="$deplib $deplibs" 77285f5b92ffSmrg continue 77295f5b92ffSmrg fi 773036e956c5Smrg if test scan = "$pass"; then 77315f5b92ffSmrg deplibs="$deplib $deplibs" 77325f5b92ffSmrg else 77335f5b92ffSmrg compile_deplibs="$deplib $compile_deplibs" 77345f5b92ffSmrg finalize_deplibs="$deplib $finalize_deplibs" 77355f5b92ffSmrg fi 77365f5b92ffSmrg func_stripname '-L' '' "$deplib" 77370dd80ee0Smrg func_resolve_sysroot "$func_stripname_result" 77380dd80ee0Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77395f5b92ffSmrg ;; 77405f5b92ffSmrg *) 774136e956c5Smrg func_warning "'-L' is ignored for archives/objects" 77425f5b92ffSmrg ;; 77435f5b92ffSmrg esac # linkmode 77445f5b92ffSmrg continue 77455f5b92ffSmrg ;; # -L 77465f5b92ffSmrg -R*) 774736e956c5Smrg if test link = "$pass"; then 77485f5b92ffSmrg func_stripname '-R' '' "$deplib" 77490dd80ee0Smrg func_resolve_sysroot "$func_stripname_result" 77500dd80ee0Smrg dir=$func_resolve_sysroot_result 77515f5b92ffSmrg # Make sure the xrpath contains only unique directories. 77525f5b92ffSmrg case "$xrpath " in 77535f5b92ffSmrg *" $dir "*) ;; 77540dd80ee0Smrg *) func_append xrpath " $dir" ;; 77555f5b92ffSmrg esac 77565f5b92ffSmrg fi 77575f5b92ffSmrg deplibs="$deplib $deplibs" 77585f5b92ffSmrg continue 77595f5b92ffSmrg ;; 77600dd80ee0Smrg *.la) 77610dd80ee0Smrg func_resolve_sysroot "$deplib" 77620dd80ee0Smrg lib=$func_resolve_sysroot_result 77630dd80ee0Smrg ;; 77645f5b92ffSmrg *.$libext) 776536e956c5Smrg if test conv = "$pass"; then 77665f5b92ffSmrg deplibs="$deplib $deplibs" 77675f5b92ffSmrg continue 77685f5b92ffSmrg fi 77695f5b92ffSmrg case $linkmode in 77705f5b92ffSmrg lib) 77715f5b92ffSmrg # Linking convenience modules into shared libraries is allowed, 77725f5b92ffSmrg # but linking other static libraries is non-portable. 77735f5b92ffSmrg case " $dlpreconveniencelibs " in 77745f5b92ffSmrg *" $deplib "*) ;; 77755f5b92ffSmrg *) 777636e956c5Smrg valid_a_lib=false 77775f5b92ffSmrg case $deplibs_check_method in 77785f5b92ffSmrg match_pattern*) 77795f5b92ffSmrg set dummy $deplibs_check_method; shift 77805f5b92ffSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77810dd80ee0Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 77825f5b92ffSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 778336e956c5Smrg valid_a_lib=: 77845f5b92ffSmrg fi 77855f5b92ffSmrg ;; 77865f5b92ffSmrg pass_all) 778736e956c5Smrg valid_a_lib=: 77885f5b92ffSmrg ;; 77895f5b92ffSmrg esac 779036e956c5Smrg if $valid_a_lib; then 779136e956c5Smrg echo 779236e956c5Smrg $ECHO "*** Warning: Linking the shared library $output against the" 779336e956c5Smrg $ECHO "*** static library $deplib is not portable!" 779436e956c5Smrg deplibs="$deplib $deplibs" 779536e956c5Smrg else 77960dd80ee0Smrg echo 77975f5b92ffSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 77980dd80ee0Smrg echo "*** I have the capability to make that library automatically link in when" 77990dd80ee0Smrg echo "*** you link to this library. But I can only do this if you have a" 78000dd80ee0Smrg echo "*** shared version of the library, which you do not appear to have" 78010dd80ee0Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 78020dd80ee0Smrg echo "*** that it is just a static archive that I should not use here." 78035f5b92ffSmrg fi 78045f5b92ffSmrg ;; 78055f5b92ffSmrg esac 78065f5b92ffSmrg continue 78075f5b92ffSmrg ;; 78085f5b92ffSmrg prog) 780936e956c5Smrg if test link != "$pass"; then 78105f5b92ffSmrg deplibs="$deplib $deplibs" 78115f5b92ffSmrg else 78125f5b92ffSmrg compile_deplibs="$deplib $compile_deplibs" 78135f5b92ffSmrg finalize_deplibs="$deplib $finalize_deplibs" 78145f5b92ffSmrg fi 78155f5b92ffSmrg continue 78165f5b92ffSmrg ;; 78175f5b92ffSmrg esac # linkmode 78185f5b92ffSmrg ;; # *.$libext 78195f5b92ffSmrg *.lo | *.$objext) 782036e956c5Smrg if test conv = "$pass"; then 78215f5b92ffSmrg deplibs="$deplib $deplibs" 782236e956c5Smrg elif test prog = "$linkmode"; then 782336e956c5Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 78245f5b92ffSmrg # If there is no dlopen support or we're linking statically, 78255f5b92ffSmrg # we need to preload. 78260dd80ee0Smrg func_append newdlprefiles " $deplib" 78275f5b92ffSmrg compile_deplibs="$deplib $compile_deplibs" 78285f5b92ffSmrg finalize_deplibs="$deplib $finalize_deplibs" 78295f5b92ffSmrg else 78300dd80ee0Smrg func_append newdlfiles " $deplib" 78315f5b92ffSmrg fi 78325f5b92ffSmrg fi 78335f5b92ffSmrg continue 78345f5b92ffSmrg ;; 78355f5b92ffSmrg %DEPLIBS%) 783636e956c5Smrg alldeplibs=: 78375f5b92ffSmrg continue 78385f5b92ffSmrg ;; 78395f5b92ffSmrg esac # case $deplib 78405f5b92ffSmrg 784136e956c5Smrg $found || test -f "$lib" \ 784236e956c5Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 78435f5b92ffSmrg 78445f5b92ffSmrg # Check to see that this really is a libtool archive. 78455f5b92ffSmrg func_lalib_unsafe_p "$lib" \ 784636e956c5Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 78475f5b92ffSmrg 78485f5b92ffSmrg func_dirname "$lib" "" "." 784936e956c5Smrg ladir=$func_dirname_result 78505f5b92ffSmrg 78515f5b92ffSmrg dlname= 78525f5b92ffSmrg dlopen= 78535f5b92ffSmrg dlpreopen= 78545f5b92ffSmrg libdir= 78555f5b92ffSmrg library_names= 78565f5b92ffSmrg old_library= 78575f5b92ffSmrg inherited_linker_flags= 78585f5b92ffSmrg # If the library was installed with an old release of libtool, 78595f5b92ffSmrg # it will not redefine variables installed, or shouldnotlink 78605f5b92ffSmrg installed=yes 78615f5b92ffSmrg shouldnotlink=no 78625f5b92ffSmrg avoidtemprpath= 78635f5b92ffSmrg 78645f5b92ffSmrg 78655f5b92ffSmrg # Read the .la file 78665f5b92ffSmrg func_source "$lib" 78675f5b92ffSmrg 78685f5b92ffSmrg # Convert "-framework foo" to "foo.ltframework" 78695f5b92ffSmrg if test -n "$inherited_linker_flags"; then 78700dd80ee0Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 78715f5b92ffSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 78725f5b92ffSmrg case " $new_inherited_linker_flags " in 78735f5b92ffSmrg *" $tmp_inherited_linker_flag "*) ;; 78740dd80ee0Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 78755f5b92ffSmrg esac 78765f5b92ffSmrg done 78775f5b92ffSmrg fi 78780dd80ee0Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787936e956c5Smrg if test lib,link = "$linkmode,$pass" || 788036e956c5Smrg test prog,scan = "$linkmode,$pass" || 788136e956c5Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 78820dd80ee0Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 78830dd80ee0Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 78845f5b92ffSmrg fi 78855f5b92ffSmrg 788636e956c5Smrg if test conv = "$pass"; then 78875f5b92ffSmrg # Only check for convenience libraries 78885f5b92ffSmrg deplibs="$lib $deplibs" 78895f5b92ffSmrg if test -z "$libdir"; then 78905f5b92ffSmrg if test -z "$old_library"; then 789136e956c5Smrg func_fatal_error "cannot find name of link library for '$lib'" 78925f5b92ffSmrg fi 78935f5b92ffSmrg # It is a libtool convenience library, so add in its objects. 78940dd80ee0Smrg func_append convenience " $ladir/$objdir/$old_library" 78950dd80ee0Smrg func_append old_convenience " $ladir/$objdir/$old_library" 789636e956c5Smrg tmp_libs= 789736e956c5Smrg for deplib in $dependency_libs; do 789836e956c5Smrg deplibs="$deplib $deplibs" 789936e956c5Smrg if $opt_preserve_dup_deps; then 790036e956c5Smrg case "$tmp_libs " in 790136e956c5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 790236e956c5Smrg esac 790336e956c5Smrg fi 790436e956c5Smrg func_append tmp_libs " $deplib" 790536e956c5Smrg done 790636e956c5Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 790736e956c5Smrg func_fatal_error "'$lib' is not a convenience library" 79085f5b92ffSmrg fi 79095f5b92ffSmrg continue 79105f5b92ffSmrg fi # $pass = conv 79115f5b92ffSmrg 79125f5b92ffSmrg 79135f5b92ffSmrg # Get the name of the library we link against. 79145f5b92ffSmrg linklib= 79150dd80ee0Smrg if test -n "$old_library" && 791636e956c5Smrg { test yes = "$prefer_static_libs" || 791736e956c5Smrg test built,no = "$prefer_static_libs,$installed"; }; then 79180dd80ee0Smrg linklib=$old_library 79190dd80ee0Smrg else 79200dd80ee0Smrg for l in $old_library $library_names; do 792136e956c5Smrg linklib=$l 79220dd80ee0Smrg done 79230dd80ee0Smrg fi 79245f5b92ffSmrg if test -z "$linklib"; then 792536e956c5Smrg func_fatal_error "cannot find name of link library for '$lib'" 79265f5b92ffSmrg fi 79275f5b92ffSmrg 79285f5b92ffSmrg # This library was specified with -dlopen. 792936e956c5Smrg if test dlopen = "$pass"; then 793036e956c5Smrg test -z "$libdir" \ 793136e956c5Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 79325f5b92ffSmrg if test -z "$dlname" || 793336e956c5Smrg test yes != "$dlopen_support" || 793436e956c5Smrg test no = "$build_libtool_libs" 793536e956c5Smrg then 79365f5b92ffSmrg # If there is no dlname, no dlopen support or we're linking 79375f5b92ffSmrg # statically, we need to preload. We also need to preload any 79385f5b92ffSmrg # dependent libraries so libltdl's deplib preloader doesn't 79395f5b92ffSmrg # bomb out in the load deplibs phase. 79400dd80ee0Smrg func_append dlprefiles " $lib $dependency_libs" 79415f5b92ffSmrg else 79420dd80ee0Smrg func_append newdlfiles " $lib" 79435f5b92ffSmrg fi 79445f5b92ffSmrg continue 79455f5b92ffSmrg fi # $pass = dlopen 79465f5b92ffSmrg 79475f5b92ffSmrg # We need an absolute path. 79485f5b92ffSmrg case $ladir in 794936e956c5Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 79505f5b92ffSmrg *) 79515f5b92ffSmrg abs_ladir=`cd "$ladir" && pwd` 79525f5b92ffSmrg if test -z "$abs_ladir"; then 795336e956c5Smrg func_warning "cannot determine absolute directory name of '$ladir'" 79545f5b92ffSmrg func_warning "passing it literally to the linker, although it might fail" 795536e956c5Smrg abs_ladir=$ladir 79565f5b92ffSmrg fi 79575f5b92ffSmrg ;; 79585f5b92ffSmrg esac 79595f5b92ffSmrg func_basename "$lib" 796036e956c5Smrg laname=$func_basename_result 79615f5b92ffSmrg 79625f5b92ffSmrg # Find the relevant object directory and library name. 796336e956c5Smrg if test yes = "$installed"; then 79640dd80ee0Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 796536e956c5Smrg func_warning "library '$lib' was moved." 796636e956c5Smrg dir=$ladir 796736e956c5Smrg absdir=$abs_ladir 796836e956c5Smrg libdir=$abs_ladir 79695f5b92ffSmrg else 797036e956c5Smrg dir=$lt_sysroot$libdir 797136e956c5Smrg absdir=$lt_sysroot$libdir 79725f5b92ffSmrg fi 797336e956c5Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 79745f5b92ffSmrg else 79755f5b92ffSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797636e956c5Smrg dir=$ladir 797736e956c5Smrg absdir=$abs_ladir 79785f5b92ffSmrg # Remove this search path later 79790dd80ee0Smrg func_append notinst_path " $abs_ladir" 79805f5b92ffSmrg else 798136e956c5Smrg dir=$ladir/$objdir 798236e956c5Smrg absdir=$abs_ladir/$objdir 79835f5b92ffSmrg # Remove this search path later 79840dd80ee0Smrg func_append notinst_path " $abs_ladir" 79855f5b92ffSmrg fi 79865f5b92ffSmrg fi # $installed = yes 79875f5b92ffSmrg func_stripname 'lib' '.la' "$laname" 79885f5b92ffSmrg name=$func_stripname_result 79895f5b92ffSmrg 79905f5b92ffSmrg # This library was specified with -dlpreopen. 799136e956c5Smrg if test dlpreopen = "$pass"; then 799236e956c5Smrg if test -z "$libdir" && test prog = "$linkmode"; then 799336e956c5Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 79945f5b92ffSmrg fi 799536e956c5Smrg case $host in 79960dd80ee0Smrg # special handling for platforms with PE-DLLs. 79970dd80ee0Smrg *cygwin* | *mingw* | *cegcc* ) 79980dd80ee0Smrg # Linker will automatically link against shared library if both 79990dd80ee0Smrg # static and shared are present. Therefore, ensure we extract 80000dd80ee0Smrg # symbols from the import library if a shared library is present 80010dd80ee0Smrg # (otherwise, the dlopen module name will be incorrect). We do 80020dd80ee0Smrg # this by putting the import library name into $newdlprefiles. 80030dd80ee0Smrg # We recover the dlopen module name by 'saving' the la file 80040dd80ee0Smrg # name in a special purpose variable, and (later) extracting the 80050dd80ee0Smrg # dlname from the la file. 80060dd80ee0Smrg if test -n "$dlname"; then 80070dd80ee0Smrg func_tr_sh "$dir/$linklib" 80080dd80ee0Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 80090dd80ee0Smrg func_append newdlprefiles " $dir/$linklib" 80100dd80ee0Smrg else 80110dd80ee0Smrg func_append newdlprefiles " $dir/$old_library" 80120dd80ee0Smrg # Keep a list of preopened convenience libraries to check 80130dd80ee0Smrg # that they are being used correctly in the link pass. 80140dd80ee0Smrg test -z "$libdir" && \ 80150dd80ee0Smrg func_append dlpreconveniencelibs " $dir/$old_library" 80160dd80ee0Smrg fi 80170dd80ee0Smrg ;; 80180dd80ee0Smrg * ) 80190dd80ee0Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 80200dd80ee0Smrg # are required to link). 80210dd80ee0Smrg if test -n "$old_library"; then 80220dd80ee0Smrg func_append newdlprefiles " $dir/$old_library" 80230dd80ee0Smrg # Keep a list of preopened convenience libraries to check 80240dd80ee0Smrg # that they are being used correctly in the link pass. 80250dd80ee0Smrg test -z "$libdir" && \ 80260dd80ee0Smrg func_append dlpreconveniencelibs " $dir/$old_library" 80270dd80ee0Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 80280dd80ee0Smrg elif test -n "$dlname"; then 80290dd80ee0Smrg func_append newdlprefiles " $dir/$dlname" 80300dd80ee0Smrg else 80310dd80ee0Smrg func_append newdlprefiles " $dir/$linklib" 80320dd80ee0Smrg fi 80330dd80ee0Smrg ;; 80340dd80ee0Smrg esac 80355f5b92ffSmrg fi # $pass = dlpreopen 80365f5b92ffSmrg 80375f5b92ffSmrg if test -z "$libdir"; then 80385f5b92ffSmrg # Link the convenience library 803936e956c5Smrg if test lib = "$linkmode"; then 80405f5b92ffSmrg deplibs="$dir/$old_library $deplibs" 804136e956c5Smrg elif test prog,link = "$linkmode,$pass"; then 80425f5b92ffSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 80435f5b92ffSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 80445f5b92ffSmrg else 80455f5b92ffSmrg deplibs="$lib $deplibs" # used for prog,scan pass 80465f5b92ffSmrg fi 80475f5b92ffSmrg continue 80485f5b92ffSmrg fi 80495f5b92ffSmrg 80505f5b92ffSmrg 805136e956c5Smrg if test prog = "$linkmode" && test link != "$pass"; then 80520dd80ee0Smrg func_append newlib_search_path " $ladir" 80535f5b92ffSmrg deplibs="$lib $deplibs" 80545f5b92ffSmrg 805536e956c5Smrg linkalldeplibs=false 805636e956c5Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805736e956c5Smrg test no = "$build_libtool_libs"; then 805836e956c5Smrg linkalldeplibs=: 80595f5b92ffSmrg fi 80605f5b92ffSmrg 80615f5b92ffSmrg tmp_libs= 80625f5b92ffSmrg for deplib in $dependency_libs; do 80635f5b92ffSmrg case $deplib in 80645f5b92ffSmrg -L*) func_stripname '-L' '' "$deplib" 80650dd80ee0Smrg func_resolve_sysroot "$func_stripname_result" 80660dd80ee0Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80675f5b92ffSmrg ;; 80685f5b92ffSmrg esac 80695f5b92ffSmrg # Need to link against all dependency_libs? 807036e956c5Smrg if $linkalldeplibs; then 80715f5b92ffSmrg deplibs="$deplib $deplibs" 80725f5b92ffSmrg else 80735f5b92ffSmrg # Need to hardcode shared library paths 80745f5b92ffSmrg # or/and link against static libraries 80755f5b92ffSmrg newdependency_libs="$deplib $newdependency_libs" 80765f5b92ffSmrg fi 807736e956c5Smrg if $opt_preserve_dup_deps; then 80785f5b92ffSmrg case "$tmp_libs " in 80790dd80ee0Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 80805f5b92ffSmrg esac 80815f5b92ffSmrg fi 80820dd80ee0Smrg func_append tmp_libs " $deplib" 80835f5b92ffSmrg done # for deplib 80845f5b92ffSmrg continue 80855f5b92ffSmrg fi # $linkmode = prog... 80865f5b92ffSmrg 808736e956c5Smrg if test prog,link = "$linkmode,$pass"; then 80885f5b92ffSmrg if test -n "$library_names" && 808936e956c5Smrg { { test no = "$prefer_static_libs" || 809036e956c5Smrg test built,yes = "$prefer_static_libs,$installed"; } || 80915f5b92ffSmrg test -z "$old_library"; }; then 80925f5b92ffSmrg # We need to hardcode the library path 809336e956c5Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 80945f5b92ffSmrg # Make sure the rpath contains only unique directories. 809536e956c5Smrg case $temp_rpath: in 80965f5b92ffSmrg *"$absdir:"*) ;; 80970dd80ee0Smrg *) func_append temp_rpath "$absdir:" ;; 80985f5b92ffSmrg esac 80995f5b92ffSmrg fi 81005f5b92ffSmrg 81015f5b92ffSmrg # Hardcode the library path. 81025f5b92ffSmrg # Skip directories that are in the system default run-time 81035f5b92ffSmrg # search path. 81045f5b92ffSmrg case " $sys_lib_dlsearch_path " in 81055f5b92ffSmrg *" $absdir "*) ;; 81065f5b92ffSmrg *) 81075f5b92ffSmrg case "$compile_rpath " in 81085f5b92ffSmrg *" $absdir "*) ;; 81090dd80ee0Smrg *) func_append compile_rpath " $absdir" ;; 81105f5b92ffSmrg esac 81115f5b92ffSmrg ;; 81125f5b92ffSmrg esac 81135f5b92ffSmrg case " $sys_lib_dlsearch_path " in 81145f5b92ffSmrg *" $libdir "*) ;; 81155f5b92ffSmrg *) 81165f5b92ffSmrg case "$finalize_rpath " in 81175f5b92ffSmrg *" $libdir "*) ;; 81180dd80ee0Smrg *) func_append finalize_rpath " $libdir" ;; 81195f5b92ffSmrg esac 81205f5b92ffSmrg ;; 81215f5b92ffSmrg esac 81225f5b92ffSmrg fi # $linkmode,$pass = prog,link... 81235f5b92ffSmrg 812436e956c5Smrg if $alldeplibs && 812536e956c5Smrg { test pass_all = "$deplibs_check_method" || 812636e956c5Smrg { test yes = "$build_libtool_libs" && 81275f5b92ffSmrg test -n "$library_names"; }; }; then 81285f5b92ffSmrg # We only need to search for static libraries 81295f5b92ffSmrg continue 81305f5b92ffSmrg fi 81315f5b92ffSmrg fi 81325f5b92ffSmrg 81335f5b92ffSmrg link_static=no # Whether the deplib will be linked statically 81345f5b92ffSmrg use_static_libs=$prefer_static_libs 813536e956c5Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 81365f5b92ffSmrg use_static_libs=no 81375f5b92ffSmrg fi 81385f5b92ffSmrg if test -n "$library_names" && 813936e956c5Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 81405f5b92ffSmrg case $host in 814136e956c5Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 81425f5b92ffSmrg # No point in relinking DLLs because paths are not encoded 81430dd80ee0Smrg func_append notinst_deplibs " $lib" 81445f5b92ffSmrg need_relink=no 81455f5b92ffSmrg ;; 81465f5b92ffSmrg *) 814736e956c5Smrg if test no = "$installed"; then 81480dd80ee0Smrg func_append notinst_deplibs " $lib" 81495f5b92ffSmrg need_relink=yes 81505f5b92ffSmrg fi 81515f5b92ffSmrg ;; 81525f5b92ffSmrg esac 81535f5b92ffSmrg # This is a shared library 81545f5b92ffSmrg 81555f5b92ffSmrg # Warn about portability, can't link against -module's on some 81565f5b92ffSmrg # systems (darwin). Don't bleat about dlopened modules though! 815736e956c5Smrg dlopenmodule= 81585f5b92ffSmrg for dlpremoduletest in $dlprefiles; do 81595f5b92ffSmrg if test "X$dlpremoduletest" = "X$lib"; then 816036e956c5Smrg dlopenmodule=$dlpremoduletest 81615f5b92ffSmrg break 81625f5b92ffSmrg fi 81635f5b92ffSmrg done 816436e956c5Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 81650dd80ee0Smrg echo 816636e956c5Smrg if test prog = "$linkmode"; then 81675f5b92ffSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 81685f5b92ffSmrg else 81695f5b92ffSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 81705f5b92ffSmrg fi 81715f5b92ffSmrg $ECHO "*** $linklib is not portable!" 81725f5b92ffSmrg fi 817336e956c5Smrg if test lib = "$linkmode" && 817436e956c5Smrg test yes = "$hardcode_into_libs"; then 81755f5b92ffSmrg # Hardcode the library path. 81765f5b92ffSmrg # Skip directories that are in the system default run-time 81775f5b92ffSmrg # search path. 81785f5b92ffSmrg case " $sys_lib_dlsearch_path " in 81795f5b92ffSmrg *" $absdir "*) ;; 81805f5b92ffSmrg *) 81815f5b92ffSmrg case "$compile_rpath " in 81825f5b92ffSmrg *" $absdir "*) ;; 81830dd80ee0Smrg *) func_append compile_rpath " $absdir" ;; 81845f5b92ffSmrg esac 81855f5b92ffSmrg ;; 81865f5b92ffSmrg esac 81875f5b92ffSmrg case " $sys_lib_dlsearch_path " in 81885f5b92ffSmrg *" $libdir "*) ;; 81895f5b92ffSmrg *) 81905f5b92ffSmrg case "$finalize_rpath " in 81915f5b92ffSmrg *" $libdir "*) ;; 81920dd80ee0Smrg *) func_append finalize_rpath " $libdir" ;; 81935f5b92ffSmrg esac 81945f5b92ffSmrg ;; 81955f5b92ffSmrg esac 81965f5b92ffSmrg fi 81975f5b92ffSmrg 81985f5b92ffSmrg if test -n "$old_archive_from_expsyms_cmds"; then 81995f5b92ffSmrg # figure out the soname 82005f5b92ffSmrg set dummy $library_names 82015f5b92ffSmrg shift 820236e956c5Smrg realname=$1 82035f5b92ffSmrg shift 82045f5b92ffSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 82055f5b92ffSmrg # use dlname if we got it. it's perfectly good, no? 82065f5b92ffSmrg if test -n "$dlname"; then 820736e956c5Smrg soname=$dlname 82085f5b92ffSmrg elif test -n "$soname_spec"; then 82095f5b92ffSmrg # bleh windows 82105f5b92ffSmrg case $host in 821136e956c5Smrg *cygwin* | mingw* | *cegcc* | *os2*) 82125f5b92ffSmrg func_arith $current - $age 82135f5b92ffSmrg major=$func_arith_result 821436e956c5Smrg versuffix=-$major 82155f5b92ffSmrg ;; 82165f5b92ffSmrg esac 82175f5b92ffSmrg eval soname=\"$soname_spec\" 82185f5b92ffSmrg else 821936e956c5Smrg soname=$realname 82205f5b92ffSmrg fi 82215f5b92ffSmrg 82225f5b92ffSmrg # Make a new name for the extract_expsyms_cmds to use 822336e956c5Smrg soroot=$soname 82245f5b92ffSmrg func_basename "$soroot" 822536e956c5Smrg soname=$func_basename_result 82265f5b92ffSmrg func_stripname 'lib' '.dll' "$soname" 82275f5b92ffSmrg newlib=libimp-$func_stripname_result.a 82285f5b92ffSmrg 82295f5b92ffSmrg # If the library has no export list, then create one now 82305f5b92ffSmrg if test -f "$output_objdir/$soname-def"; then : 82315f5b92ffSmrg else 823236e956c5Smrg func_verbose "extracting exported symbol list from '$soname'" 82335f5b92ffSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 82345f5b92ffSmrg fi 82355f5b92ffSmrg 82365f5b92ffSmrg # Create $newlib 82375f5b92ffSmrg if test -f "$output_objdir/$newlib"; then :; else 823836e956c5Smrg func_verbose "generating import library for '$soname'" 82395f5b92ffSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 82405f5b92ffSmrg fi 82415f5b92ffSmrg # make sure the library variables are pointing to the new library 82425f5b92ffSmrg dir=$output_objdir 82435f5b92ffSmrg linklib=$newlib 82445f5b92ffSmrg fi # test -n "$old_archive_from_expsyms_cmds" 82455f5b92ffSmrg 824636e956c5Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 82475f5b92ffSmrg add_shlibpath= 82485f5b92ffSmrg add_dir= 82495f5b92ffSmrg add= 82505f5b92ffSmrg lib_linked=yes 82515f5b92ffSmrg case $hardcode_action in 82525f5b92ffSmrg immediate | unsupported) 825336e956c5Smrg if test no = "$hardcode_direct"; then 825436e956c5Smrg add=$dir/$linklib 82555f5b92ffSmrg case $host in 825636e956c5Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825736e956c5Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 82585f5b92ffSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825936e956c5Smrg *-*-unixware7*) add_dir=-L$dir ;; 82605f5b92ffSmrg *-*-darwin* ) 826136e956c5Smrg # if the lib is a (non-dlopened) module then we cannot 82625f5b92ffSmrg # link against it, someone is ignoring the earlier warnings 82635f5b92ffSmrg if /usr/bin/file -L $add 2> /dev/null | 826436e956c5Smrg $GREP ": [^:]* bundle" >/dev/null; then 82655f5b92ffSmrg if test "X$dlopenmodule" != "X$lib"; then 82665f5b92ffSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826736e956c5Smrg if test -z "$old_library"; then 82680dd80ee0Smrg echo 82690dd80ee0Smrg echo "*** And there doesn't seem to be a static archive available" 82700dd80ee0Smrg echo "*** The link will probably fail, sorry" 82715f5b92ffSmrg else 827236e956c5Smrg add=$dir/$old_library 82735f5b92ffSmrg fi 82745f5b92ffSmrg elif test -n "$old_library"; then 827536e956c5Smrg add=$dir/$old_library 82765f5b92ffSmrg fi 82775f5b92ffSmrg fi 82785f5b92ffSmrg esac 827936e956c5Smrg elif test no = "$hardcode_minus_L"; then 82805f5b92ffSmrg case $host in 828136e956c5Smrg *-*-sunos*) add_shlibpath=$dir ;; 82825f5b92ffSmrg esac 828336e956c5Smrg add_dir=-L$dir 828436e956c5Smrg add=-l$name 828536e956c5Smrg elif test no = "$hardcode_shlibpath_var"; then 828636e956c5Smrg add_shlibpath=$dir 828736e956c5Smrg add=-l$name 82885f5b92ffSmrg else 82895f5b92ffSmrg lib_linked=no 82905f5b92ffSmrg fi 82915f5b92ffSmrg ;; 82925f5b92ffSmrg relink) 829336e956c5Smrg if test yes = "$hardcode_direct" && 829436e956c5Smrg test no = "$hardcode_direct_absolute"; then 829536e956c5Smrg add=$dir/$linklib 829636e956c5Smrg elif test yes = "$hardcode_minus_L"; then 829736e956c5Smrg add_dir=-L$absdir 82985f5b92ffSmrg # Try looking first in the location we're being installed to. 82995f5b92ffSmrg if test -n "$inst_prefix_dir"; then 83005f5b92ffSmrg case $libdir in 83015f5b92ffSmrg [\\/]*) 83020dd80ee0Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 83035f5b92ffSmrg ;; 83045f5b92ffSmrg esac 83055f5b92ffSmrg fi 830636e956c5Smrg add=-l$name 830736e956c5Smrg elif test yes = "$hardcode_shlibpath_var"; then 830836e956c5Smrg add_shlibpath=$dir 830936e956c5Smrg add=-l$name 83105f5b92ffSmrg else 83115f5b92ffSmrg lib_linked=no 83125f5b92ffSmrg fi 83135f5b92ffSmrg ;; 83145f5b92ffSmrg *) lib_linked=no ;; 83155f5b92ffSmrg esac 83165f5b92ffSmrg 831736e956c5Smrg if test yes != "$lib_linked"; then 83185f5b92ffSmrg func_fatal_configuration "unsupported hardcode properties" 83195f5b92ffSmrg fi 83205f5b92ffSmrg 83215f5b92ffSmrg if test -n "$add_shlibpath"; then 83225f5b92ffSmrg case :$compile_shlibpath: in 83235f5b92ffSmrg *":$add_shlibpath:"*) ;; 83240dd80ee0Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 83255f5b92ffSmrg esac 83265f5b92ffSmrg fi 832736e956c5Smrg if test prog = "$linkmode"; then 83285f5b92ffSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 83295f5b92ffSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 83305f5b92ffSmrg else 83315f5b92ffSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83325f5b92ffSmrg test -n "$add" && deplibs="$add $deplibs" 833336e956c5Smrg if test yes != "$hardcode_direct" && 833436e956c5Smrg test yes != "$hardcode_minus_L" && 833536e956c5Smrg test yes = "$hardcode_shlibpath_var"; then 83365f5b92ffSmrg case :$finalize_shlibpath: in 83375f5b92ffSmrg *":$libdir:"*) ;; 83380dd80ee0Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83395f5b92ffSmrg esac 83405f5b92ffSmrg fi 83415f5b92ffSmrg fi 83425f5b92ffSmrg fi 83435f5b92ffSmrg 834436e956c5Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 83455f5b92ffSmrg add_shlibpath= 83465f5b92ffSmrg add_dir= 83475f5b92ffSmrg add= 83485f5b92ffSmrg # Finalize command for both is simple: just hardcode it. 834936e956c5Smrg if test yes = "$hardcode_direct" && 835036e956c5Smrg test no = "$hardcode_direct_absolute"; then 835136e956c5Smrg add=$libdir/$linklib 835236e956c5Smrg elif test yes = "$hardcode_minus_L"; then 835336e956c5Smrg add_dir=-L$libdir 835436e956c5Smrg add=-l$name 835536e956c5Smrg elif test yes = "$hardcode_shlibpath_var"; then 83565f5b92ffSmrg case :$finalize_shlibpath: in 83575f5b92ffSmrg *":$libdir:"*) ;; 83580dd80ee0Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83595f5b92ffSmrg esac 836036e956c5Smrg add=-l$name 836136e956c5Smrg elif test yes = "$hardcode_automatic"; then 83625f5b92ffSmrg if test -n "$inst_prefix_dir" && 836336e956c5Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 836436e956c5Smrg add=$inst_prefix_dir$libdir/$linklib 83655f5b92ffSmrg else 836636e956c5Smrg add=$libdir/$linklib 83675f5b92ffSmrg fi 83685f5b92ffSmrg else 83695f5b92ffSmrg # We cannot seem to hardcode it, guess we'll fake it. 837036e956c5Smrg add_dir=-L$libdir 83715f5b92ffSmrg # Try looking first in the location we're being installed to. 83725f5b92ffSmrg if test -n "$inst_prefix_dir"; then 83735f5b92ffSmrg case $libdir in 83745f5b92ffSmrg [\\/]*) 83750dd80ee0Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 83765f5b92ffSmrg ;; 83775f5b92ffSmrg esac 83785f5b92ffSmrg fi 837936e956c5Smrg add=-l$name 83805f5b92ffSmrg fi 83815f5b92ffSmrg 838236e956c5Smrg if test prog = "$linkmode"; then 83835f5b92ffSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 83845f5b92ffSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 83855f5b92ffSmrg else 83865f5b92ffSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83875f5b92ffSmrg test -n "$add" && deplibs="$add $deplibs" 83885f5b92ffSmrg fi 83895f5b92ffSmrg fi 839036e956c5Smrg elif test prog = "$linkmode"; then 83915f5b92ffSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 83925f5b92ffSmrg # is not unsupported. This is valid on all known static and 83935f5b92ffSmrg # shared platforms. 839436e956c5Smrg if test unsupported != "$hardcode_direct"; then 839536e956c5Smrg test -n "$old_library" && linklib=$old_library 83965f5b92ffSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 83975f5b92ffSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 83985f5b92ffSmrg else 83995f5b92ffSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 84005f5b92ffSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 84015f5b92ffSmrg fi 840236e956c5Smrg elif test yes = "$build_libtool_libs"; then 84035f5b92ffSmrg # Not a shared library 840436e956c5Smrg if test pass_all != "$deplibs_check_method"; then 84055f5b92ffSmrg # We're trying link a shared library against a static one 84065f5b92ffSmrg # but the system doesn't support it. 84075f5b92ffSmrg 84085f5b92ffSmrg # Just print a warning and add the library to dependency_libs so 84095f5b92ffSmrg # that the program can be linked against the static library. 84100dd80ee0Smrg echo 841136e956c5Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 84120dd80ee0Smrg echo "*** I have the capability to make that library automatically link in when" 84130dd80ee0Smrg echo "*** you link to this library. But I can only do this if you have a" 84140dd80ee0Smrg echo "*** shared version of the library, which you do not appear to have." 841536e956c5Smrg if test yes = "$module"; then 84160dd80ee0Smrg echo "*** But as you try to build a module library, libtool will still create " 84170dd80ee0Smrg echo "*** a static module, that should work as long as the dlopening application" 84180dd80ee0Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 84195f5b92ffSmrg if test -z "$global_symbol_pipe"; then 84200dd80ee0Smrg echo 84210dd80ee0Smrg echo "*** However, this would only work if libtool was able to extract symbol" 842236e956c5Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 84230dd80ee0Smrg echo "*** not find such a program. So, this module is probably useless." 842436e956c5Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 84255f5b92ffSmrg fi 842636e956c5Smrg if test no = "$build_old_libs"; then 84275f5b92ffSmrg build_libtool_libs=module 84285f5b92ffSmrg build_old_libs=yes 84295f5b92ffSmrg else 84305f5b92ffSmrg build_libtool_libs=no 84315f5b92ffSmrg fi 84325f5b92ffSmrg fi 84335f5b92ffSmrg else 84345f5b92ffSmrg deplibs="$dir/$old_library $deplibs" 84355f5b92ffSmrg link_static=yes 84365f5b92ffSmrg fi 84375f5b92ffSmrg fi # link shared/static library? 84385f5b92ffSmrg 843936e956c5Smrg if test lib = "$linkmode"; then 84405f5b92ffSmrg if test -n "$dependency_libs" && 844136e956c5Smrg { test yes != "$hardcode_into_libs" || 844236e956c5Smrg test yes = "$build_old_libs" || 844336e956c5Smrg test yes = "$link_static"; }; then 84445f5b92ffSmrg # Extract -R from dependency_libs 84455f5b92ffSmrg temp_deplibs= 84465f5b92ffSmrg for libdir in $dependency_libs; do 84475f5b92ffSmrg case $libdir in 84485f5b92ffSmrg -R*) func_stripname '-R' '' "$libdir" 84495f5b92ffSmrg temp_xrpath=$func_stripname_result 84505f5b92ffSmrg case " $xrpath " in 84515f5b92ffSmrg *" $temp_xrpath "*) ;; 84520dd80ee0Smrg *) func_append xrpath " $temp_xrpath";; 84535f5b92ffSmrg esac;; 84540dd80ee0Smrg *) func_append temp_deplibs " $libdir";; 84555f5b92ffSmrg esac 84565f5b92ffSmrg done 845736e956c5Smrg dependency_libs=$temp_deplibs 84585f5b92ffSmrg fi 84595f5b92ffSmrg 84600dd80ee0Smrg func_append newlib_search_path " $absdir" 84615f5b92ffSmrg # Link against this library 846236e956c5Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 84635f5b92ffSmrg # ... and its dependency_libs 84645f5b92ffSmrg tmp_libs= 84655f5b92ffSmrg for deplib in $dependency_libs; do 84665f5b92ffSmrg newdependency_libs="$deplib $newdependency_libs" 84670dd80ee0Smrg case $deplib in 84680dd80ee0Smrg -L*) func_stripname '-L' '' "$deplib" 84690dd80ee0Smrg func_resolve_sysroot "$func_stripname_result";; 84700dd80ee0Smrg *) func_resolve_sysroot "$deplib" ;; 84710dd80ee0Smrg esac 847236e956c5Smrg if $opt_preserve_dup_deps; then 84735f5b92ffSmrg case "$tmp_libs " in 84740dd80ee0Smrg *" $func_resolve_sysroot_result "*) 84750dd80ee0Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 84765f5b92ffSmrg esac 84775f5b92ffSmrg fi 84780dd80ee0Smrg func_append tmp_libs " $func_resolve_sysroot_result" 84795f5b92ffSmrg done 84805f5b92ffSmrg 848136e956c5Smrg if test no != "$link_all_deplibs"; then 84825f5b92ffSmrg # Add the search paths of all dependency libraries 84835f5b92ffSmrg for deplib in $dependency_libs; do 84840dd80ee0Smrg path= 84855f5b92ffSmrg case $deplib in 848636e956c5Smrg -L*) path=$deplib ;; 84875f5b92ffSmrg *.la) 84880dd80ee0Smrg func_resolve_sysroot "$deplib" 84890dd80ee0Smrg deplib=$func_resolve_sysroot_result 84905f5b92ffSmrg func_dirname "$deplib" "" "." 84910dd80ee0Smrg dir=$func_dirname_result 84925f5b92ffSmrg # We need an absolute path. 84935f5b92ffSmrg case $dir in 849436e956c5Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 84955f5b92ffSmrg *) 84965f5b92ffSmrg absdir=`cd "$dir" && pwd` 84975f5b92ffSmrg if test -z "$absdir"; then 849836e956c5Smrg func_warning "cannot determine absolute directory name of '$dir'" 849936e956c5Smrg absdir=$dir 85005f5b92ffSmrg fi 85015f5b92ffSmrg ;; 85025f5b92ffSmrg esac 85035f5b92ffSmrg if $GREP "^installed=no" $deplib > /dev/null; then 85045f5b92ffSmrg case $host in 85055f5b92ffSmrg *-*-darwin*) 85065f5b92ffSmrg depdepl= 850736e956c5Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850836e956c5Smrg if test -n "$deplibrary_names"; then 850936e956c5Smrg for tmp in $deplibrary_names; do 85105f5b92ffSmrg depdepl=$tmp 85115f5b92ffSmrg done 851236e956c5Smrg if test -f "$absdir/$objdir/$depdepl"; then 851336e956c5Smrg depdepl=$absdir/$objdir/$depdepl 851436e956c5Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85155f5b92ffSmrg if test -z "$darwin_install_name"; then 851636e956c5Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85175f5b92ffSmrg fi 851836e956c5Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851936e956c5Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 85205f5b92ffSmrg path= 85215f5b92ffSmrg fi 85225f5b92ffSmrg fi 85235f5b92ffSmrg ;; 85245f5b92ffSmrg *) 852536e956c5Smrg path=-L$absdir/$objdir 85265f5b92ffSmrg ;; 85275f5b92ffSmrg esac 85285f5b92ffSmrg else 852936e956c5Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 85305f5b92ffSmrg test -z "$libdir" && \ 853136e956c5Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 85325f5b92ffSmrg test "$absdir" != "$libdir" && \ 853336e956c5Smrg func_warning "'$deplib' seems to be moved" 85345f5b92ffSmrg 853536e956c5Smrg path=-L$absdir 85365f5b92ffSmrg fi 85375f5b92ffSmrg ;; 85385f5b92ffSmrg esac 85395f5b92ffSmrg case " $deplibs " in 85405f5b92ffSmrg *" $path "*) ;; 85415f5b92ffSmrg *) deplibs="$path $deplibs" ;; 85425f5b92ffSmrg esac 85435f5b92ffSmrg done 85445f5b92ffSmrg fi # link_all_deplibs != no 85455f5b92ffSmrg fi # linkmode = lib 85465f5b92ffSmrg done # for deplib in $libs 854736e956c5Smrg if test link = "$pass"; then 854836e956c5Smrg if test prog = "$linkmode"; then 85495f5b92ffSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 85505f5b92ffSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 85515f5b92ffSmrg else 85520dd80ee0Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 85535f5b92ffSmrg fi 85545f5b92ffSmrg fi 855536e956c5Smrg dependency_libs=$newdependency_libs 855636e956c5Smrg if test dlpreopen = "$pass"; then 85575f5b92ffSmrg # Link the dlpreopened libraries before other libraries 85585f5b92ffSmrg for deplib in $save_deplibs; do 85595f5b92ffSmrg deplibs="$deplib $deplibs" 85605f5b92ffSmrg done 85615f5b92ffSmrg fi 856236e956c5Smrg if test dlopen != "$pass"; then 856336e956c5Smrg test conv = "$pass" || { 85645f5b92ffSmrg # Make sure lib_search_path contains only unique directories. 85655f5b92ffSmrg lib_search_path= 85665f5b92ffSmrg for dir in $newlib_search_path; do 85675f5b92ffSmrg case "$lib_search_path " in 85685f5b92ffSmrg *" $dir "*) ;; 85690dd80ee0Smrg *) func_append lib_search_path " $dir" ;; 85705f5b92ffSmrg esac 85715f5b92ffSmrg done 85725f5b92ffSmrg newlib_search_path= 857336e956c5Smrg } 85745f5b92ffSmrg 857536e956c5Smrg if test prog,link = "$linkmode,$pass"; then 85765f5b92ffSmrg vars="compile_deplibs finalize_deplibs" 857736e956c5Smrg else 857836e956c5Smrg vars=deplibs 85795f5b92ffSmrg fi 85805f5b92ffSmrg for var in $vars dependency_libs; do 85815f5b92ffSmrg # Add libraries to $var in reverse order 85825f5b92ffSmrg eval tmp_libs=\"\$$var\" 85835f5b92ffSmrg new_libs= 85845f5b92ffSmrg for deplib in $tmp_libs; do 85855f5b92ffSmrg # FIXME: Pedantically, this is the right thing to do, so 85865f5b92ffSmrg # that some nasty dependency loop isn't accidentally 85875f5b92ffSmrg # broken: 85885f5b92ffSmrg #new_libs="$deplib $new_libs" 85895f5b92ffSmrg # Pragmatically, this seems to cause very few problems in 85905f5b92ffSmrg # practice: 85915f5b92ffSmrg case $deplib in 85925f5b92ffSmrg -L*) new_libs="$deplib $new_libs" ;; 85935f5b92ffSmrg -R*) ;; 85945f5b92ffSmrg *) 85955f5b92ffSmrg # And here is the reason: when a library appears more 85965f5b92ffSmrg # than once as an explicit dependence of a library, or 85975f5b92ffSmrg # is implicitly linked in more than once by the 85985f5b92ffSmrg # compiler, it is considered special, and multiple 85995f5b92ffSmrg # occurrences thereof are not removed. Compare this 86005f5b92ffSmrg # with having the same library being listed as a 86015f5b92ffSmrg # dependency of multiple other libraries: in this case, 86025f5b92ffSmrg # we know (pedantically, we assume) the library does not 86035f5b92ffSmrg # need to be listed more than once, so we keep only the 86045f5b92ffSmrg # last copy. This is not always right, but it is rare 86055f5b92ffSmrg # enough that we require users that really mean to play 86065f5b92ffSmrg # such unportable linking tricks to link the library 86075f5b92ffSmrg # using -Wl,-lname, so that libtool does not consider it 86085f5b92ffSmrg # for duplicate removal. 86095f5b92ffSmrg case " $specialdeplibs " in 86105f5b92ffSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 86115f5b92ffSmrg *) 86125f5b92ffSmrg case " $new_libs " in 86135f5b92ffSmrg *" $deplib "*) ;; 86145f5b92ffSmrg *) new_libs="$deplib $new_libs" ;; 86155f5b92ffSmrg esac 86165f5b92ffSmrg ;; 86175f5b92ffSmrg esac 86185f5b92ffSmrg ;; 86195f5b92ffSmrg esac 86205f5b92ffSmrg done 86215f5b92ffSmrg tmp_libs= 86225f5b92ffSmrg for deplib in $new_libs; do 86235f5b92ffSmrg case $deplib in 86245f5b92ffSmrg -L*) 86255f5b92ffSmrg case " $tmp_libs " in 86265f5b92ffSmrg *" $deplib "*) ;; 86270dd80ee0Smrg *) func_append tmp_libs " $deplib" ;; 86285f5b92ffSmrg esac 86295f5b92ffSmrg ;; 86300dd80ee0Smrg *) func_append tmp_libs " $deplib" ;; 86315f5b92ffSmrg esac 86325f5b92ffSmrg done 86335f5b92ffSmrg eval $var=\"$tmp_libs\" 86345f5b92ffSmrg done # for var 86355f5b92ffSmrg fi 863636e956c5Smrg 863736e956c5Smrg # Add Sun CC postdeps if required: 863836e956c5Smrg test CXX = "$tagname" && { 863936e956c5Smrg case $host_os in 864036e956c5Smrg linux*) 864136e956c5Smrg case `$CC -V 2>&1 | sed 5q` in 864236e956c5Smrg *Sun\ C*) # Sun C++ 5.9 864336e956c5Smrg func_suncc_cstd_abi 864436e956c5Smrg 864536e956c5Smrg if test no != "$suncc_use_cstd_abi"; then 864636e956c5Smrg func_append postdeps ' -library=Cstd -library=Crun' 864736e956c5Smrg fi 864836e956c5Smrg ;; 864936e956c5Smrg esac 865036e956c5Smrg ;; 865136e956c5Smrg 865236e956c5Smrg solaris*) 865336e956c5Smrg func_cc_basename "$CC" 865436e956c5Smrg case $func_cc_basename_result in 865536e956c5Smrg CC* | sunCC*) 865636e956c5Smrg func_suncc_cstd_abi 865736e956c5Smrg 865836e956c5Smrg if test no != "$suncc_use_cstd_abi"; then 865936e956c5Smrg func_append postdeps ' -library=Cstd -library=Crun' 866036e956c5Smrg fi 866136e956c5Smrg ;; 866236e956c5Smrg esac 866336e956c5Smrg ;; 866436e956c5Smrg esac 866536e956c5Smrg } 866636e956c5Smrg 86675f5b92ffSmrg # Last step: remove runtime libs from dependency_libs 86685f5b92ffSmrg # (they stay in deplibs) 86695f5b92ffSmrg tmp_libs= 867036e956c5Smrg for i in $dependency_libs; do 86715f5b92ffSmrg case " $predeps $postdeps $compiler_lib_search_path " in 86725f5b92ffSmrg *" $i "*) 867336e956c5Smrg i= 86745f5b92ffSmrg ;; 86755f5b92ffSmrg esac 867636e956c5Smrg if test -n "$i"; then 86770dd80ee0Smrg func_append tmp_libs " $i" 86785f5b92ffSmrg fi 86795f5b92ffSmrg done 86805f5b92ffSmrg dependency_libs=$tmp_libs 86815f5b92ffSmrg done # for pass 868236e956c5Smrg if test prog = "$linkmode"; then 868336e956c5Smrg dlfiles=$newdlfiles 86845f5b92ffSmrg fi 868536e956c5Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868636e956c5Smrg dlprefiles=$newdlprefiles 86875f5b92ffSmrg fi 86885f5b92ffSmrg 86895f5b92ffSmrg case $linkmode in 86905f5b92ffSmrg oldlib) 869136e956c5Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 869236e956c5Smrg func_warning "'-dlopen' is ignored for archives" 86935f5b92ffSmrg fi 86945f5b92ffSmrg 86955f5b92ffSmrg case " $deplibs" in 86965f5b92ffSmrg *\ -l* | *\ -L*) 869736e956c5Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 86985f5b92ffSmrg esac 86995f5b92ffSmrg 87005f5b92ffSmrg test -n "$rpath" && \ 870136e956c5Smrg func_warning "'-rpath' is ignored for archives" 87025f5b92ffSmrg 87035f5b92ffSmrg test -n "$xrpath" && \ 870436e956c5Smrg func_warning "'-R' is ignored for archives" 87055f5b92ffSmrg 87065f5b92ffSmrg test -n "$vinfo" && \ 870736e956c5Smrg func_warning "'-version-info/-version-number' is ignored for archives" 87085f5b92ffSmrg 87095f5b92ffSmrg test -n "$release" && \ 871036e956c5Smrg func_warning "'-release' is ignored for archives" 87115f5b92ffSmrg 87125f5b92ffSmrg test -n "$export_symbols$export_symbols_regex" && \ 871336e956c5Smrg func_warning "'-export-symbols' is ignored for archives" 87145f5b92ffSmrg 87155f5b92ffSmrg # Now set the variables for building old libraries. 87165f5b92ffSmrg build_libtool_libs=no 871736e956c5Smrg oldlibs=$output 87180dd80ee0Smrg func_append objs "$old_deplibs" 87195f5b92ffSmrg ;; 87205f5b92ffSmrg 87215f5b92ffSmrg lib) 872236e956c5Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 87235f5b92ffSmrg case $outputname in 87245f5b92ffSmrg lib*) 87255f5b92ffSmrg func_stripname 'lib' '.la' "$outputname" 87265f5b92ffSmrg name=$func_stripname_result 87275f5b92ffSmrg eval shared_ext=\"$shrext_cmds\" 87285f5b92ffSmrg eval libname=\"$libname_spec\" 87295f5b92ffSmrg ;; 87305f5b92ffSmrg *) 873136e956c5Smrg test no = "$module" \ 873236e956c5Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 87335f5b92ffSmrg 873436e956c5Smrg if test no != "$need_lib_prefix"; then 87355f5b92ffSmrg # Add the "lib" prefix for modules if required 87365f5b92ffSmrg func_stripname '' '.la' "$outputname" 87375f5b92ffSmrg name=$func_stripname_result 87385f5b92ffSmrg eval shared_ext=\"$shrext_cmds\" 87395f5b92ffSmrg eval libname=\"$libname_spec\" 87405f5b92ffSmrg else 87415f5b92ffSmrg func_stripname '' '.la' "$outputname" 87425f5b92ffSmrg libname=$func_stripname_result 87435f5b92ffSmrg fi 87445f5b92ffSmrg ;; 87455f5b92ffSmrg esac 87465f5b92ffSmrg 87475f5b92ffSmrg if test -n "$objs"; then 874836e956c5Smrg if test pass_all != "$deplibs_check_method"; then 874936e956c5Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 87505f5b92ffSmrg else 87510dd80ee0Smrg echo 87525f5b92ffSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 87535f5b92ffSmrg $ECHO "*** objects $objs is not portable!" 87540dd80ee0Smrg func_append libobjs " $objs" 87555f5b92ffSmrg fi 87565f5b92ffSmrg fi 87575f5b92ffSmrg 875836e956c5Smrg test no = "$dlself" \ 875936e956c5Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 87605f5b92ffSmrg 87615f5b92ffSmrg set dummy $rpath 87625f5b92ffSmrg shift 876336e956c5Smrg test 1 -lt "$#" \ 876436e956c5Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 87655f5b92ffSmrg 876636e956c5Smrg install_libdir=$1 87675f5b92ffSmrg 87685f5b92ffSmrg oldlibs= 87695f5b92ffSmrg if test -z "$rpath"; then 877036e956c5Smrg if test yes = "$build_libtool_libs"; then 87715f5b92ffSmrg # Building a libtool convenience library. 877236e956c5Smrg # Some compilers have problems with a '.al' extension so 87735f5b92ffSmrg # convenience libraries should have the same extension an 87745f5b92ffSmrg # archive normally would. 87755f5b92ffSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 87765f5b92ffSmrg build_libtool_libs=convenience 87775f5b92ffSmrg build_old_libs=yes 87785f5b92ffSmrg fi 87795f5b92ffSmrg 87805f5b92ffSmrg test -n "$vinfo" && \ 878136e956c5Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 87825f5b92ffSmrg 87835f5b92ffSmrg test -n "$release" && \ 878436e956c5Smrg func_warning "'-release' is ignored for convenience libraries" 87855f5b92ffSmrg else 87865f5b92ffSmrg 87875f5b92ffSmrg # Parse the version information argument. 878836e956c5Smrg save_ifs=$IFS; IFS=: 87895f5b92ffSmrg set dummy $vinfo 0 0 0 87905f5b92ffSmrg shift 879136e956c5Smrg IFS=$save_ifs 87925f5b92ffSmrg 87935f5b92ffSmrg test -n "$7" && \ 879436e956c5Smrg func_fatal_help "too many parameters to '-version-info'" 87955f5b92ffSmrg 87965f5b92ffSmrg # convert absolute version numbers to libtool ages 87975f5b92ffSmrg # this retains compatibility with .la files and attempts 87985f5b92ffSmrg # to make the code below a bit more comprehensible 87995f5b92ffSmrg 88005f5b92ffSmrg case $vinfo_number in 88015f5b92ffSmrg yes) 880236e956c5Smrg number_major=$1 880336e956c5Smrg number_minor=$2 880436e956c5Smrg number_revision=$3 88055f5b92ffSmrg # 88065f5b92ffSmrg # There are really only two kinds -- those that 88075f5b92ffSmrg # use the current revision as the major version 88085f5b92ffSmrg # and those that subtract age and use age as 88095f5b92ffSmrg # a minor version. But, then there is irix 881036e956c5Smrg # that has an extra 1 added just for fun 88115f5b92ffSmrg # 88125f5b92ffSmrg case $version_type in 88130dd80ee0Smrg # correct linux to gnu/linux during the next big refactor 881436e956c5Smrg darwin|freebsd-elf|linux|osf|windows|none) 88155f5b92ffSmrg func_arith $number_major + $number_minor 88165f5b92ffSmrg current=$func_arith_result 881736e956c5Smrg age=$number_minor 881836e956c5Smrg revision=$number_revision 88195f5b92ffSmrg ;; 882036e956c5Smrg freebsd-aout|qnx|sunos) 882136e956c5Smrg current=$number_major 882236e956c5Smrg revision=$number_minor 882336e956c5Smrg age=0 88245f5b92ffSmrg ;; 88255f5b92ffSmrg irix|nonstopux) 88265f5b92ffSmrg func_arith $number_major + $number_minor 88275f5b92ffSmrg current=$func_arith_result 882836e956c5Smrg age=$number_minor 882936e956c5Smrg revision=$number_minor 88305f5b92ffSmrg lt_irix_increment=no 88315f5b92ffSmrg ;; 883236e956c5Smrg *) 883336e956c5Smrg func_fatal_configuration "$modename: unknown library version type '$version_type'" 883436e956c5Smrg ;; 88355f5b92ffSmrg esac 88365f5b92ffSmrg ;; 88375f5b92ffSmrg no) 883836e956c5Smrg current=$1 883936e956c5Smrg revision=$2 884036e956c5Smrg age=$3 88415f5b92ffSmrg ;; 88425f5b92ffSmrg esac 88435f5b92ffSmrg 88445f5b92ffSmrg # Check that each of the things are valid numbers. 88455f5b92ffSmrg case $current in 88465f5b92ffSmrg 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]) ;; 88475f5b92ffSmrg *) 884836e956c5Smrg func_error "CURRENT '$current' must be a nonnegative integer" 884936e956c5Smrg func_fatal_error "'$vinfo' is not valid version information" 88505f5b92ffSmrg ;; 88515f5b92ffSmrg esac 88525f5b92ffSmrg 88535f5b92ffSmrg case $revision in 88545f5b92ffSmrg 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]) ;; 88555f5b92ffSmrg *) 885636e956c5Smrg func_error "REVISION '$revision' must be a nonnegative integer" 885736e956c5Smrg func_fatal_error "'$vinfo' is not valid version information" 88585f5b92ffSmrg ;; 88595f5b92ffSmrg esac 88605f5b92ffSmrg 88615f5b92ffSmrg case $age in 88625f5b92ffSmrg 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]) ;; 88635f5b92ffSmrg *) 886436e956c5Smrg func_error "AGE '$age' must be a nonnegative integer" 886536e956c5Smrg func_fatal_error "'$vinfo' is not valid version information" 88665f5b92ffSmrg ;; 88675f5b92ffSmrg esac 88685f5b92ffSmrg 88695f5b92ffSmrg if test "$age" -gt "$current"; then 887036e956c5Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 887136e956c5Smrg func_fatal_error "'$vinfo' is not valid version information" 88725f5b92ffSmrg fi 88735f5b92ffSmrg 88745f5b92ffSmrg # Calculate the version variables. 88755f5b92ffSmrg major= 88765f5b92ffSmrg versuffix= 88775f5b92ffSmrg verstring= 88785f5b92ffSmrg case $version_type in 88795f5b92ffSmrg none) ;; 88805f5b92ffSmrg 88815f5b92ffSmrg darwin) 88825f5b92ffSmrg # Like Linux, but with the current version available in 88835f5b92ffSmrg # verstring for coding it into the library header 88845f5b92ffSmrg func_arith $current - $age 88855f5b92ffSmrg major=.$func_arith_result 888636e956c5Smrg versuffix=$major.$age.$revision 88875f5b92ffSmrg # Darwin ld doesn't like 0 for these options... 88885f5b92ffSmrg func_arith $current + 1 88895f5b92ffSmrg minor_current=$func_arith_result 889036e956c5Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88915f5b92ffSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889236e956c5Smrg # On Darwin other compilers 889336e956c5Smrg case $CC in 889436e956c5Smrg nagfor*) 889536e956c5Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 889636e956c5Smrg ;; 889736e956c5Smrg *) 889836e956c5Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889936e956c5Smrg ;; 890036e956c5Smrg esac 89015f5b92ffSmrg ;; 89025f5b92ffSmrg 89035f5b92ffSmrg freebsd-aout) 890436e956c5Smrg major=.$current 890536e956c5Smrg versuffix=.$current.$revision 89065f5b92ffSmrg ;; 89075f5b92ffSmrg 89085f5b92ffSmrg freebsd-elf) 890936e956c5Smrg func_arith $current - $age 891036e956c5Smrg major=.$func_arith_result 891136e956c5Smrg versuffix=$major.$age.$revision 89125f5b92ffSmrg ;; 89135f5b92ffSmrg 89145f5b92ffSmrg irix | nonstopux) 891536e956c5Smrg if test no = "$lt_irix_increment"; then 89165f5b92ffSmrg func_arith $current - $age 89175f5b92ffSmrg else 89185f5b92ffSmrg func_arith $current - $age + 1 89195f5b92ffSmrg fi 89205f5b92ffSmrg major=$func_arith_result 89215f5b92ffSmrg 89225f5b92ffSmrg case $version_type in 89235f5b92ffSmrg nonstopux) verstring_prefix=nonstopux ;; 89245f5b92ffSmrg *) verstring_prefix=sgi ;; 89255f5b92ffSmrg esac 892636e956c5Smrg verstring=$verstring_prefix$major.$revision 89275f5b92ffSmrg 89285f5b92ffSmrg # Add in all the interfaces that we are compatible with. 89295f5b92ffSmrg loop=$revision 893036e956c5Smrg while test 0 -ne "$loop"; do 89315f5b92ffSmrg func_arith $revision - $loop 89325f5b92ffSmrg iface=$func_arith_result 89335f5b92ffSmrg func_arith $loop - 1 89345f5b92ffSmrg loop=$func_arith_result 893536e956c5Smrg verstring=$verstring_prefix$major.$iface:$verstring 89365f5b92ffSmrg done 89375f5b92ffSmrg 893836e956c5Smrg # Before this point, $major must not contain '.'. 89395f5b92ffSmrg major=.$major 894036e956c5Smrg versuffix=$major.$revision 89415f5b92ffSmrg ;; 89425f5b92ffSmrg 89430dd80ee0Smrg linux) # correct to gnu/linux during the next big refactor 89445f5b92ffSmrg func_arith $current - $age 89455f5b92ffSmrg major=.$func_arith_result 894636e956c5Smrg versuffix=$major.$age.$revision 89475f5b92ffSmrg ;; 89485f5b92ffSmrg 89495f5b92ffSmrg osf) 89505f5b92ffSmrg func_arith $current - $age 89515f5b92ffSmrg major=.$func_arith_result 895236e956c5Smrg versuffix=.$current.$age.$revision 895336e956c5Smrg verstring=$current.$age.$revision 89545f5b92ffSmrg 89555f5b92ffSmrg # Add in all the interfaces that we are compatible with. 89565f5b92ffSmrg loop=$age 895736e956c5Smrg while test 0 -ne "$loop"; do 89585f5b92ffSmrg func_arith $current - $loop 89595f5b92ffSmrg iface=$func_arith_result 89605f5b92ffSmrg func_arith $loop - 1 89615f5b92ffSmrg loop=$func_arith_result 896236e956c5Smrg verstring=$verstring:$iface.0 89635f5b92ffSmrg done 89645f5b92ffSmrg 89655f5b92ffSmrg # Make executables depend on our current version. 896636e956c5Smrg func_append verstring ":$current.0" 89675f5b92ffSmrg ;; 89685f5b92ffSmrg 89695f5b92ffSmrg qnx) 897036e956c5Smrg major=.$current 897136e956c5Smrg versuffix=.$current 897236e956c5Smrg ;; 897336e956c5Smrg 897436e956c5Smrg sco) 897536e956c5Smrg major=.$current 897636e956c5Smrg versuffix=.$current 89775f5b92ffSmrg ;; 89785f5b92ffSmrg 89795f5b92ffSmrg sunos) 898036e956c5Smrg major=.$current 898136e956c5Smrg versuffix=.$current.$revision 89825f5b92ffSmrg ;; 89835f5b92ffSmrg 89845f5b92ffSmrg windows) 89855f5b92ffSmrg # Use '-' rather than '.', since we only want one 898636e956c5Smrg # extension on DOS 8.3 file systems. 89875f5b92ffSmrg func_arith $current - $age 89885f5b92ffSmrg major=$func_arith_result 898936e956c5Smrg versuffix=-$major 89905f5b92ffSmrg ;; 89915f5b92ffSmrg 89925f5b92ffSmrg *) 899336e956c5Smrg func_fatal_configuration "unknown library version type '$version_type'" 89945f5b92ffSmrg ;; 89955f5b92ffSmrg esac 89965f5b92ffSmrg 89975f5b92ffSmrg # Clear the version info if we defaulted, and they specified a release. 89985f5b92ffSmrg if test -z "$vinfo" && test -n "$release"; then 89995f5b92ffSmrg major= 90005f5b92ffSmrg case $version_type in 90015f5b92ffSmrg darwin) 90025f5b92ffSmrg # we can't check for "0.0" in archive_cmds due to quoting 90035f5b92ffSmrg # problems, so we reset it completely 90045f5b92ffSmrg verstring= 90055f5b92ffSmrg ;; 90065f5b92ffSmrg *) 900736e956c5Smrg verstring=0.0 90085f5b92ffSmrg ;; 90095f5b92ffSmrg esac 901036e956c5Smrg if test no = "$need_version"; then 90115f5b92ffSmrg versuffix= 90125f5b92ffSmrg else 901336e956c5Smrg versuffix=.0.0 90145f5b92ffSmrg fi 90155f5b92ffSmrg fi 90165f5b92ffSmrg 90175f5b92ffSmrg # Remove version info from name if versioning should be avoided 901836e956c5Smrg if test yes,no = "$avoid_version,$need_version"; then 90195f5b92ffSmrg major= 90205f5b92ffSmrg versuffix= 902136e956c5Smrg verstring= 90225f5b92ffSmrg fi 90235f5b92ffSmrg 90245f5b92ffSmrg # Check to see if the archive will have undefined symbols. 902536e956c5Smrg if test yes = "$allow_undefined"; then 902636e956c5Smrg if test unsupported = "$allow_undefined_flag"; then 902736e956c5Smrg if test yes = "$build_old_libs"; then 902836e956c5Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902936e956c5Smrg build_libtool_libs=no 903036e956c5Smrg else 903136e956c5Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 903236e956c5Smrg fi 90335f5b92ffSmrg fi 90345f5b92ffSmrg else 90355f5b92ffSmrg # Don't allow undefined symbols. 903636e956c5Smrg allow_undefined_flag=$no_undefined_flag 90375f5b92ffSmrg fi 90385f5b92ffSmrg 90395f5b92ffSmrg fi 90405f5b92ffSmrg 904136e956c5Smrg func_generate_dlsyms "$libname" "$libname" : 90420dd80ee0Smrg func_append libobjs " $symfileobj" 904336e956c5Smrg test " " = "$libobjs" && libobjs= 90445f5b92ffSmrg 904536e956c5Smrg if test relink != "$opt_mode"; then 90465f5b92ffSmrg # Remove our outputs, but don't remove object files since they 90475f5b92ffSmrg # may have been created when compiling PIC objects. 90485f5b92ffSmrg removelist= 90495f5b92ffSmrg tempremovelist=`$ECHO "$output_objdir/*"` 90505f5b92ffSmrg for p in $tempremovelist; do 90515f5b92ffSmrg case $p in 90525f5b92ffSmrg *.$objext | *.gcno) 90535f5b92ffSmrg ;; 905436e956c5Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 905536e956c5Smrg if test -n "$precious_files_regex"; then 90565f5b92ffSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 90575f5b92ffSmrg then 90585f5b92ffSmrg continue 90595f5b92ffSmrg fi 90605f5b92ffSmrg fi 90610dd80ee0Smrg func_append removelist " $p" 90625f5b92ffSmrg ;; 90635f5b92ffSmrg *) ;; 90645f5b92ffSmrg esac 90655f5b92ffSmrg done 90665f5b92ffSmrg test -n "$removelist" && \ 90675f5b92ffSmrg func_show_eval "${RM}r \$removelist" 90685f5b92ffSmrg fi 90695f5b92ffSmrg 90705f5b92ffSmrg # Now set the variables for building old libraries. 907136e956c5Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 90720dd80ee0Smrg func_append oldlibs " $output_objdir/$libname.$libext" 90735f5b92ffSmrg 90745f5b92ffSmrg # Transform .lo files to .o files. 907536e956c5Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 90765f5b92ffSmrg fi 90775f5b92ffSmrg 90785f5b92ffSmrg # Eliminate all temporary directories. 90795f5b92ffSmrg #for path in $notinst_path; do 90800dd80ee0Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 90810dd80ee0Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 90820dd80ee0Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 90835f5b92ffSmrg #done 90845f5b92ffSmrg 90855f5b92ffSmrg if test -n "$xrpath"; then 90865f5b92ffSmrg # If the user specified any rpath flags, then add them. 90875f5b92ffSmrg temp_xrpath= 90885f5b92ffSmrg for libdir in $xrpath; do 90890dd80ee0Smrg func_replace_sysroot "$libdir" 90900dd80ee0Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 90915f5b92ffSmrg case "$finalize_rpath " in 90925f5b92ffSmrg *" $libdir "*) ;; 90930dd80ee0Smrg *) func_append finalize_rpath " $libdir" ;; 90945f5b92ffSmrg esac 90955f5b92ffSmrg done 909636e956c5Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 90975f5b92ffSmrg dependency_libs="$temp_xrpath $dependency_libs" 90985f5b92ffSmrg fi 90995f5b92ffSmrg fi 91005f5b92ffSmrg 91015f5b92ffSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 910236e956c5Smrg old_dlfiles=$dlfiles 91035f5b92ffSmrg dlfiles= 91045f5b92ffSmrg for lib in $old_dlfiles; do 91055f5b92ffSmrg case " $dlprefiles $dlfiles " in 91065f5b92ffSmrg *" $lib "*) ;; 91070dd80ee0Smrg *) func_append dlfiles " $lib" ;; 91085f5b92ffSmrg esac 91095f5b92ffSmrg done 91105f5b92ffSmrg 91115f5b92ffSmrg # Make sure dlprefiles contains only unique files 911236e956c5Smrg old_dlprefiles=$dlprefiles 91135f5b92ffSmrg dlprefiles= 91145f5b92ffSmrg for lib in $old_dlprefiles; do 91155f5b92ffSmrg case "$dlprefiles " in 91165f5b92ffSmrg *" $lib "*) ;; 91170dd80ee0Smrg *) func_append dlprefiles " $lib" ;; 91185f5b92ffSmrg esac 91195f5b92ffSmrg done 91205f5b92ffSmrg 912136e956c5Smrg if test yes = "$build_libtool_libs"; then 91225f5b92ffSmrg if test -n "$rpath"; then 91235f5b92ffSmrg case $host in 91240dd80ee0Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 91255f5b92ffSmrg # these systems don't actually have a c library (as such)! 91265f5b92ffSmrg ;; 91275f5b92ffSmrg *-*-rhapsody* | *-*-darwin1.[012]) 91285f5b92ffSmrg # Rhapsody C library is in the System framework 91290dd80ee0Smrg func_append deplibs " System.ltframework" 91305f5b92ffSmrg ;; 91315f5b92ffSmrg *-*-netbsd*) 91325f5b92ffSmrg # Don't link with libc until the a.out ld.so is fixed. 91335f5b92ffSmrg ;; 91345f5b92ffSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 91355f5b92ffSmrg # Do not include libc due to us having libc/libc_r. 91365f5b92ffSmrg ;; 91375f5b92ffSmrg *-*-sco3.2v5* | *-*-sco5v6*) 91385f5b92ffSmrg # Causes problems with __ctype 91395f5b92ffSmrg ;; 91405f5b92ffSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 91415f5b92ffSmrg # Compiler inserts libc in the correct place for threads to work 91425f5b92ffSmrg ;; 91435f5b92ffSmrg *) 91445f5b92ffSmrg # Add libc to deplibs on all other systems if necessary. 914536e956c5Smrg if test yes = "$build_libtool_need_lc"; then 91460dd80ee0Smrg func_append deplibs " -lc" 91475f5b92ffSmrg fi 91485f5b92ffSmrg ;; 91495f5b92ffSmrg esac 91505f5b92ffSmrg fi 91515f5b92ffSmrg 91525f5b92ffSmrg # Transform deplibs into only deplibs that can be linked in shared. 91535f5b92ffSmrg name_save=$name 91545f5b92ffSmrg libname_save=$libname 91555f5b92ffSmrg release_save=$release 91565f5b92ffSmrg versuffix_save=$versuffix 91575f5b92ffSmrg major_save=$major 91585f5b92ffSmrg # I'm not sure if I'm treating the release correctly. I think 91595f5b92ffSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 91605f5b92ffSmrg # add it in twice. Is that correct? 916136e956c5Smrg release= 916236e956c5Smrg versuffix= 916336e956c5Smrg major= 91645f5b92ffSmrg newdeplibs= 91655f5b92ffSmrg droppeddeps=no 91665f5b92ffSmrg case $deplibs_check_method in 91675f5b92ffSmrg pass_all) 91685f5b92ffSmrg # Don't check for shared/static. Everything works. 91695f5b92ffSmrg # This might be a little naive. We might want to check 91705f5b92ffSmrg # whether the library exists or not. But this is on 91715f5b92ffSmrg # osf3 & osf4 and I'm not really sure... Just 91725f5b92ffSmrg # implementing what was already the behavior. 91735f5b92ffSmrg newdeplibs=$deplibs 91745f5b92ffSmrg ;; 91755f5b92ffSmrg test_compile) 91765f5b92ffSmrg # This code stresses the "libraries are programs" paradigm to its 91775f5b92ffSmrg # limits. Maybe even breaks it. We compile a program, linking it 91785f5b92ffSmrg # against the deplibs as a proxy for the library. Then we can check 91795f5b92ffSmrg # whether they linked in statically or dynamically with ldd. 91805f5b92ffSmrg $opt_dry_run || $RM conftest.c 91815f5b92ffSmrg cat > conftest.c <<EOF 91825f5b92ffSmrg int main() { return 0; } 91835f5b92ffSmrgEOF 91845f5b92ffSmrg $opt_dry_run || $RM conftest 91855f5b92ffSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 91865f5b92ffSmrg ldd_output=`ldd conftest` 91875f5b92ffSmrg for i in $deplibs; do 91885f5b92ffSmrg case $i in 91895f5b92ffSmrg -l*) 91905f5b92ffSmrg func_stripname -l '' "$i" 91915f5b92ffSmrg name=$func_stripname_result 919236e956c5Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 91935f5b92ffSmrg case " $predeps $postdeps " in 91945f5b92ffSmrg *" $i "*) 91950dd80ee0Smrg func_append newdeplibs " $i" 919636e956c5Smrg i= 91975f5b92ffSmrg ;; 91985f5b92ffSmrg esac 91995f5b92ffSmrg fi 920036e956c5Smrg if test -n "$i"; then 92015f5b92ffSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92025f5b92ffSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92035f5b92ffSmrg set dummy $deplib_matches; shift 92045f5b92ffSmrg deplib_match=$1 920536e956c5Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 92060dd80ee0Smrg func_append newdeplibs " $i" 92075f5b92ffSmrg else 92085f5b92ffSmrg droppeddeps=yes 92090dd80ee0Smrg echo 92105f5b92ffSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92110dd80ee0Smrg echo "*** I have the capability to make that library automatically link in when" 92120dd80ee0Smrg echo "*** you link to this library. But I can only do this if you have a" 92130dd80ee0Smrg echo "*** shared version of the library, which I believe you do not have" 92140dd80ee0Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 92150dd80ee0Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 92165f5b92ffSmrg fi 92175f5b92ffSmrg fi 92185f5b92ffSmrg ;; 92195f5b92ffSmrg *) 92200dd80ee0Smrg func_append newdeplibs " $i" 92215f5b92ffSmrg ;; 92225f5b92ffSmrg esac 92235f5b92ffSmrg done 92245f5b92ffSmrg else 92255f5b92ffSmrg # Error occurred in the first compile. Let's try to salvage 92265f5b92ffSmrg # the situation: Compile a separate program for each library. 92275f5b92ffSmrg for i in $deplibs; do 92285f5b92ffSmrg case $i in 92295f5b92ffSmrg -l*) 92305f5b92ffSmrg func_stripname -l '' "$i" 92315f5b92ffSmrg name=$func_stripname_result 92325f5b92ffSmrg $opt_dry_run || $RM conftest 92335f5b92ffSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 92345f5b92ffSmrg ldd_output=`ldd conftest` 923536e956c5Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92365f5b92ffSmrg case " $predeps $postdeps " in 92375f5b92ffSmrg *" $i "*) 92380dd80ee0Smrg func_append newdeplibs " $i" 923936e956c5Smrg i= 92405f5b92ffSmrg ;; 92415f5b92ffSmrg esac 92425f5b92ffSmrg fi 924336e956c5Smrg if test -n "$i"; then 92445f5b92ffSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92455f5b92ffSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92465f5b92ffSmrg set dummy $deplib_matches; shift 92475f5b92ffSmrg deplib_match=$1 924836e956c5Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 92490dd80ee0Smrg func_append newdeplibs " $i" 92505f5b92ffSmrg else 92515f5b92ffSmrg droppeddeps=yes 92520dd80ee0Smrg echo 92535f5b92ffSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92540dd80ee0Smrg echo "*** I have the capability to make that library automatically link in when" 92550dd80ee0Smrg echo "*** you link to this library. But I can only do this if you have a" 92560dd80ee0Smrg echo "*** shared version of the library, which you do not appear to have" 92570dd80ee0Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 92580dd80ee0Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 92595f5b92ffSmrg fi 92605f5b92ffSmrg fi 92615f5b92ffSmrg else 92625f5b92ffSmrg droppeddeps=yes 92630dd80ee0Smrg echo 92645f5b92ffSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 92650dd80ee0Smrg echo "*** make it link in! You will probably need to install it or some" 92660dd80ee0Smrg echo "*** library that it depends on before this library will be fully" 92670dd80ee0Smrg echo "*** functional. Installing it before continuing would be even better." 92685f5b92ffSmrg fi 92695f5b92ffSmrg ;; 92705f5b92ffSmrg *) 92710dd80ee0Smrg func_append newdeplibs " $i" 92725f5b92ffSmrg ;; 92735f5b92ffSmrg esac 92745f5b92ffSmrg done 92755f5b92ffSmrg fi 92765f5b92ffSmrg ;; 92775f5b92ffSmrg file_magic*) 92785f5b92ffSmrg set dummy $deplibs_check_method; shift 92795f5b92ffSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 92805f5b92ffSmrg for a_deplib in $deplibs; do 92815f5b92ffSmrg case $a_deplib in 92825f5b92ffSmrg -l*) 92835f5b92ffSmrg func_stripname -l '' "$a_deplib" 92845f5b92ffSmrg name=$func_stripname_result 928536e956c5Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92865f5b92ffSmrg case " $predeps $postdeps " in 92875f5b92ffSmrg *" $a_deplib "*) 92880dd80ee0Smrg func_append newdeplibs " $a_deplib" 928936e956c5Smrg a_deplib= 92905f5b92ffSmrg ;; 92915f5b92ffSmrg esac 92925f5b92ffSmrg fi 929336e956c5Smrg if test -n "$a_deplib"; then 92945f5b92ffSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92950dd80ee0Smrg if test -n "$file_magic_glob"; then 92960dd80ee0Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 92970dd80ee0Smrg else 92980dd80ee0Smrg libnameglob=$libname 92990dd80ee0Smrg fi 930036e956c5Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 93015f5b92ffSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 930236e956c5Smrg if test yes = "$want_nocaseglob"; then 93030dd80ee0Smrg shopt -s nocaseglob 93040dd80ee0Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 93050dd80ee0Smrg $nocaseglob 93060dd80ee0Smrg else 93070dd80ee0Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 93080dd80ee0Smrg fi 93095f5b92ffSmrg for potent_lib in $potential_libs; do 93105f5b92ffSmrg # Follow soft links. 93115f5b92ffSmrg if ls -lLd "$potent_lib" 2>/dev/null | 93125f5b92ffSmrg $GREP " -> " >/dev/null; then 93135f5b92ffSmrg continue 93145f5b92ffSmrg fi 93155f5b92ffSmrg # The statement above tries to avoid entering an 93165f5b92ffSmrg # endless loop below, in case of cyclic links. 93175f5b92ffSmrg # We might still enter an endless loop, since a link 93185f5b92ffSmrg # loop can be closed while we follow links, 93195f5b92ffSmrg # but so what? 932036e956c5Smrg potlib=$potent_lib 93215f5b92ffSmrg while test -h "$potlib" 2>/dev/null; do 932236e956c5Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 93235f5b92ffSmrg case $potliblink in 932436e956c5Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 932536e956c5Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 93265f5b92ffSmrg esac 93275f5b92ffSmrg done 93285f5b92ffSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 93295f5b92ffSmrg $SED -e 10q | 93305f5b92ffSmrg $EGREP "$file_magic_regex" > /dev/null; then 93310dd80ee0Smrg func_append newdeplibs " $a_deplib" 933236e956c5Smrg a_deplib= 93335f5b92ffSmrg break 2 93345f5b92ffSmrg fi 93355f5b92ffSmrg done 93365f5b92ffSmrg done 93375f5b92ffSmrg fi 933836e956c5Smrg if test -n "$a_deplib"; then 93395f5b92ffSmrg droppeddeps=yes 93400dd80ee0Smrg echo 93415f5b92ffSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93420dd80ee0Smrg echo "*** I have the capability to make that library automatically link in when" 93430dd80ee0Smrg echo "*** you link to this library. But I can only do this if you have a" 93440dd80ee0Smrg echo "*** shared version of the library, which you do not appear to have" 93450dd80ee0Smrg echo "*** because I did check the linker path looking for a file starting" 934636e956c5Smrg if test -z "$potlib"; then 93475f5b92ffSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 93485f5b92ffSmrg else 93495f5b92ffSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93505f5b92ffSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 93515f5b92ffSmrg fi 93525f5b92ffSmrg fi 93535f5b92ffSmrg ;; 93545f5b92ffSmrg *) 93555f5b92ffSmrg # Add a -L argument. 93560dd80ee0Smrg func_append newdeplibs " $a_deplib" 93575f5b92ffSmrg ;; 93585f5b92ffSmrg esac 93595f5b92ffSmrg done # Gone through all deplibs. 93605f5b92ffSmrg ;; 93615f5b92ffSmrg match_pattern*) 93625f5b92ffSmrg set dummy $deplibs_check_method; shift 93635f5b92ffSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 93645f5b92ffSmrg for a_deplib in $deplibs; do 93655f5b92ffSmrg case $a_deplib in 93665f5b92ffSmrg -l*) 93675f5b92ffSmrg func_stripname -l '' "$a_deplib" 93685f5b92ffSmrg name=$func_stripname_result 936936e956c5Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 93705f5b92ffSmrg case " $predeps $postdeps " in 93715f5b92ffSmrg *" $a_deplib "*) 93720dd80ee0Smrg func_append newdeplibs " $a_deplib" 937336e956c5Smrg a_deplib= 93745f5b92ffSmrg ;; 93755f5b92ffSmrg esac 93765f5b92ffSmrg fi 937736e956c5Smrg if test -n "$a_deplib"; then 93785f5b92ffSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 93795f5b92ffSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93805f5b92ffSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 93815f5b92ffSmrg for potent_lib in $potential_libs; do 938236e956c5Smrg potlib=$potent_lib # see symlink-check above in file_magic test 93830dd80ee0Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 93845f5b92ffSmrg $EGREP "$match_pattern_regex" > /dev/null; then 93850dd80ee0Smrg func_append newdeplibs " $a_deplib" 938636e956c5Smrg a_deplib= 93875f5b92ffSmrg break 2 93885f5b92ffSmrg fi 93895f5b92ffSmrg done 93905f5b92ffSmrg done 93915f5b92ffSmrg fi 939236e956c5Smrg if test -n "$a_deplib"; then 93935f5b92ffSmrg droppeddeps=yes 93940dd80ee0Smrg echo 93955f5b92ffSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93960dd80ee0Smrg echo "*** I have the capability to make that library automatically link in when" 93970dd80ee0Smrg echo "*** you link to this library. But I can only do this if you have a" 93980dd80ee0Smrg echo "*** shared version of the library, which you do not appear to have" 93990dd80ee0Smrg echo "*** because I did check the linker path looking for a file starting" 940036e956c5Smrg if test -z "$potlib"; then 94015f5b92ffSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 94025f5b92ffSmrg else 94035f5b92ffSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 94045f5b92ffSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 94055f5b92ffSmrg fi 94065f5b92ffSmrg fi 94075f5b92ffSmrg ;; 94085f5b92ffSmrg *) 94095f5b92ffSmrg # Add a -L argument. 94100dd80ee0Smrg func_append newdeplibs " $a_deplib" 94115f5b92ffSmrg ;; 94125f5b92ffSmrg esac 94135f5b92ffSmrg done # Gone through all deplibs. 94145f5b92ffSmrg ;; 94155f5b92ffSmrg none | unknown | *) 941636e956c5Smrg newdeplibs= 94170dd80ee0Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 941836e956c5Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941936e956c5Smrg for i in $predeps $postdeps; do 94205f5b92ffSmrg # can't use Xsed below, because $i might contain '/' 942136e956c5Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 94225f5b92ffSmrg done 94235f5b92ffSmrg fi 94240dd80ee0Smrg case $tmp_deplibs in 94250dd80ee0Smrg *[!\ \ ]*) 94260dd80ee0Smrg echo 942736e956c5Smrg if test none = "$deplibs_check_method"; then 94280dd80ee0Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 94295f5b92ffSmrg else 94300dd80ee0Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 94315f5b92ffSmrg fi 94320dd80ee0Smrg echo "*** All declared inter-library dependencies are being dropped." 94335f5b92ffSmrg droppeddeps=yes 94340dd80ee0Smrg ;; 94350dd80ee0Smrg esac 94365f5b92ffSmrg ;; 94375f5b92ffSmrg esac 94385f5b92ffSmrg versuffix=$versuffix_save 94395f5b92ffSmrg major=$major_save 94405f5b92ffSmrg release=$release_save 94415f5b92ffSmrg libname=$libname_save 94425f5b92ffSmrg name=$name_save 94435f5b92ffSmrg 94445f5b92ffSmrg case $host in 94455f5b92ffSmrg *-*-rhapsody* | *-*-darwin1.[012]) 94465f5b92ffSmrg # On Rhapsody replace the C library with the System framework 94470dd80ee0Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 94485f5b92ffSmrg ;; 94495f5b92ffSmrg esac 94505f5b92ffSmrg 945136e956c5Smrg if test yes = "$droppeddeps"; then 945236e956c5Smrg if test yes = "$module"; then 94530dd80ee0Smrg echo 94540dd80ee0Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 94555f5b92ffSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 94560dd80ee0Smrg echo "*** a static module, that should work as long as the dlopening" 94570dd80ee0Smrg echo "*** application is linked with the -dlopen flag." 94585f5b92ffSmrg if test -z "$global_symbol_pipe"; then 94590dd80ee0Smrg echo 94600dd80ee0Smrg echo "*** However, this would only work if libtool was able to extract symbol" 946136e956c5Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 94620dd80ee0Smrg echo "*** not find such a program. So, this module is probably useless." 946336e956c5Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 94645f5b92ffSmrg fi 946536e956c5Smrg if test no = "$build_old_libs"; then 946636e956c5Smrg oldlibs=$output_objdir/$libname.$libext 94675f5b92ffSmrg build_libtool_libs=module 94685f5b92ffSmrg build_old_libs=yes 94695f5b92ffSmrg else 94705f5b92ffSmrg build_libtool_libs=no 94715f5b92ffSmrg fi 94725f5b92ffSmrg else 94730dd80ee0Smrg echo "*** The inter-library dependencies that have been dropped here will be" 94740dd80ee0Smrg echo "*** automatically added whenever a program is linked with this library" 94750dd80ee0Smrg echo "*** or is declared to -dlopen it." 94765f5b92ffSmrg 947736e956c5Smrg if test no = "$allow_undefined"; then 94780dd80ee0Smrg echo 94790dd80ee0Smrg echo "*** Since this library must not contain undefined symbols," 94800dd80ee0Smrg echo "*** because either the platform does not support them or" 94810dd80ee0Smrg echo "*** it was explicitly requested with -no-undefined," 94820dd80ee0Smrg echo "*** libtool will only create a static version of it." 948336e956c5Smrg if test no = "$build_old_libs"; then 948436e956c5Smrg oldlibs=$output_objdir/$libname.$libext 94855f5b92ffSmrg build_libtool_libs=module 94865f5b92ffSmrg build_old_libs=yes 94875f5b92ffSmrg else 94885f5b92ffSmrg build_libtool_libs=no 94895f5b92ffSmrg fi 94905f5b92ffSmrg fi 94915f5b92ffSmrg fi 94925f5b92ffSmrg fi 94935f5b92ffSmrg # Done checking deplibs! 94945f5b92ffSmrg deplibs=$newdeplibs 94955f5b92ffSmrg fi 94965f5b92ffSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 94975f5b92ffSmrg case $host in 94985f5b92ffSmrg *-*-darwin*) 94990dd80ee0Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 95000dd80ee0Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 95010dd80ee0Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 95025f5b92ffSmrg ;; 95035f5b92ffSmrg esac 95045f5b92ffSmrg 95055f5b92ffSmrg # move library search paths that coincide with paths to not yet 95065f5b92ffSmrg # installed libraries to the beginning of the library search list 95075f5b92ffSmrg new_libs= 95085f5b92ffSmrg for path in $notinst_path; do 95095f5b92ffSmrg case " $new_libs " in 95105f5b92ffSmrg *" -L$path/$objdir "*) ;; 95115f5b92ffSmrg *) 95125f5b92ffSmrg case " $deplibs " in 95135f5b92ffSmrg *" -L$path/$objdir "*) 95140dd80ee0Smrg func_append new_libs " -L$path/$objdir" ;; 95155f5b92ffSmrg esac 95165f5b92ffSmrg ;; 95175f5b92ffSmrg esac 95185f5b92ffSmrg done 95195f5b92ffSmrg for deplib in $deplibs; do 95205f5b92ffSmrg case $deplib in 95215f5b92ffSmrg -L*) 95225f5b92ffSmrg case " $new_libs " in 95235f5b92ffSmrg *" $deplib "*) ;; 95240dd80ee0Smrg *) func_append new_libs " $deplib" ;; 95255f5b92ffSmrg esac 95265f5b92ffSmrg ;; 95270dd80ee0Smrg *) func_append new_libs " $deplib" ;; 95285f5b92ffSmrg esac 95295f5b92ffSmrg done 953036e956c5Smrg deplibs=$new_libs 95315f5b92ffSmrg 95325f5b92ffSmrg # All the library-specific variables (install_libdir is set above). 95335f5b92ffSmrg library_names= 95345f5b92ffSmrg old_library= 95355f5b92ffSmrg dlname= 95365f5b92ffSmrg 95375f5b92ffSmrg # Test again, we may have decided not to build it any more 953836e956c5Smrg if test yes = "$build_libtool_libs"; then 953936e956c5Smrg # Remove $wl instances when linking with ld. 95400dd80ee0Smrg # FIXME: should test the right _cmds variable. 95410dd80ee0Smrg case $archive_cmds in 95420dd80ee0Smrg *\$LD\ *) wl= ;; 95430dd80ee0Smrg esac 954436e956c5Smrg if test yes = "$hardcode_into_libs"; then 95455f5b92ffSmrg # Hardcode the library paths 95465f5b92ffSmrg hardcode_libdirs= 95475f5b92ffSmrg dep_rpath= 954836e956c5Smrg rpath=$finalize_rpath 954936e956c5Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 95505f5b92ffSmrg for libdir in $rpath; do 95515f5b92ffSmrg if test -n "$hardcode_libdir_flag_spec"; then 95525f5b92ffSmrg if test -n "$hardcode_libdir_separator"; then 95530dd80ee0Smrg func_replace_sysroot "$libdir" 95540dd80ee0Smrg libdir=$func_replace_sysroot_result 95555f5b92ffSmrg if test -z "$hardcode_libdirs"; then 955636e956c5Smrg hardcode_libdirs=$libdir 95575f5b92ffSmrg else 95585f5b92ffSmrg # Just accumulate the unique libdirs. 95595f5b92ffSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 95605f5b92ffSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 95615f5b92ffSmrg ;; 95625f5b92ffSmrg *) 95630dd80ee0Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 95645f5b92ffSmrg ;; 95655f5b92ffSmrg esac 95665f5b92ffSmrg fi 95675f5b92ffSmrg else 95685f5b92ffSmrg eval flag=\"$hardcode_libdir_flag_spec\" 95690dd80ee0Smrg func_append dep_rpath " $flag" 95705f5b92ffSmrg fi 95715f5b92ffSmrg elif test -n "$runpath_var"; then 95725f5b92ffSmrg case "$perm_rpath " in 95735f5b92ffSmrg *" $libdir "*) ;; 95740dd80ee0Smrg *) func_append perm_rpath " $libdir" ;; 95755f5b92ffSmrg esac 95765f5b92ffSmrg fi 95775f5b92ffSmrg done 95785f5b92ffSmrg # Substitute the hardcoded libdirs into the rpath. 95795f5b92ffSmrg if test -n "$hardcode_libdir_separator" && 95805f5b92ffSmrg test -n "$hardcode_libdirs"; then 958136e956c5Smrg libdir=$hardcode_libdirs 95820dd80ee0Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 95835f5b92ffSmrg fi 95845f5b92ffSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 95855f5b92ffSmrg # We should set the runpath_var. 95865f5b92ffSmrg rpath= 95875f5b92ffSmrg for dir in $perm_rpath; do 95880dd80ee0Smrg func_append rpath "$dir:" 95895f5b92ffSmrg done 95905f5b92ffSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 95915f5b92ffSmrg fi 95925f5b92ffSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 95935f5b92ffSmrg fi 959417a48c7cSmrg 959536e956c5Smrg shlibpath=$finalize_shlibpath 959636e956c5Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 95975f5b92ffSmrg if test -n "$shlibpath"; then 95985f5b92ffSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 95995f5b92ffSmrg fi 960017a48c7cSmrg 96015f5b92ffSmrg # Get the real and link names of the library. 96025f5b92ffSmrg eval shared_ext=\"$shrext_cmds\" 96035f5b92ffSmrg eval library_names=\"$library_names_spec\" 96045f5b92ffSmrg set dummy $library_names 96055f5b92ffSmrg shift 960636e956c5Smrg realname=$1 96075f5b92ffSmrg shift 960817a48c7cSmrg 96095f5b92ffSmrg if test -n "$soname_spec"; then 96105f5b92ffSmrg eval soname=\"$soname_spec\" 96115f5b92ffSmrg else 961236e956c5Smrg soname=$realname 96135f5b92ffSmrg fi 96145f5b92ffSmrg if test -z "$dlname"; then 96155f5b92ffSmrg dlname=$soname 96165f5b92ffSmrg fi 961717a48c7cSmrg 961836e956c5Smrg lib=$output_objdir/$realname 96195f5b92ffSmrg linknames= 96205f5b92ffSmrg for link 96215f5b92ffSmrg do 96220dd80ee0Smrg func_append linknames " $link" 96235f5b92ffSmrg done 962417a48c7cSmrg 96255f5b92ffSmrg # Use standard objects if they are pic 96260dd80ee0Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 96275f5b92ffSmrg test "X$libobjs" = "X " && libobjs= 962817a48c7cSmrg 96295f5b92ffSmrg delfiles= 96305f5b92ffSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 96315f5b92ffSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 963236e956c5Smrg export_symbols=$output_objdir/$libname.uexp 96330dd80ee0Smrg func_append delfiles " $export_symbols" 96345f5b92ffSmrg fi 963517a48c7cSmrg 96365f5b92ffSmrg orig_export_symbols= 96375f5b92ffSmrg case $host_os in 96385f5b92ffSmrg cygwin* | mingw* | cegcc*) 96395f5b92ffSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 96405f5b92ffSmrg # exporting using user supplied symfile 964136e956c5Smrg func_dll_def_p "$export_symbols" || { 96425f5b92ffSmrg # and it's NOT already a .def file. Must figure out 96435f5b92ffSmrg # which of the given symbols are data symbols and tag 96445f5b92ffSmrg # them as such. So, trigger use of export_symbols_cmds. 96455f5b92ffSmrg # export_symbols gets reassigned inside the "prepare 96465f5b92ffSmrg # the list of exported symbols" if statement, so the 96475f5b92ffSmrg # include_expsyms logic still works. 964836e956c5Smrg orig_export_symbols=$export_symbols 96495f5b92ffSmrg export_symbols= 96505f5b92ffSmrg always_export_symbols=yes 965136e956c5Smrg } 96525f5b92ffSmrg fi 96535f5b92ffSmrg ;; 96545f5b92ffSmrg esac 965517a48c7cSmrg 96565f5b92ffSmrg # Prepare the list of exported symbols 96575f5b92ffSmrg if test -z "$export_symbols"; then 965836e956c5Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965936e956c5Smrg func_verbose "generating symbol list for '$libname.la'" 966036e956c5Smrg export_symbols=$output_objdir/$libname.exp 96615f5b92ffSmrg $opt_dry_run || $RM $export_symbols 96625f5b92ffSmrg cmds=$export_symbols_cmds 966336e956c5Smrg save_ifs=$IFS; IFS='~' 96640dd80ee0Smrg for cmd1 in $cmds; do 966536e956c5Smrg IFS=$save_ifs 96660dd80ee0Smrg # Take the normal branch if the nm_file_list_spec branch 96670dd80ee0Smrg # doesn't work or if tool conversion is not needed. 96680dd80ee0Smrg case $nm_file_list_spec~$to_tool_file_cmd in 96690dd80ee0Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 96700dd80ee0Smrg try_normal_branch=yes 96710dd80ee0Smrg eval cmd=\"$cmd1\" 96720dd80ee0Smrg func_len " $cmd" 96730dd80ee0Smrg len=$func_len_result 96740dd80ee0Smrg ;; 96750dd80ee0Smrg *) 96760dd80ee0Smrg try_normal_branch=no 96770dd80ee0Smrg ;; 96780dd80ee0Smrg esac 967936e956c5Smrg if test yes = "$try_normal_branch" \ 96800dd80ee0Smrg && { test "$len" -lt "$max_cmd_len" \ 96810dd80ee0Smrg || test "$max_cmd_len" -le -1; } 96820dd80ee0Smrg then 96830dd80ee0Smrg func_show_eval "$cmd" 'exit $?' 96840dd80ee0Smrg skipped_export=false 96850dd80ee0Smrg elif test -n "$nm_file_list_spec"; then 96860dd80ee0Smrg func_basename "$output" 96870dd80ee0Smrg output_la=$func_basename_result 96880dd80ee0Smrg save_libobjs=$libobjs 96890dd80ee0Smrg save_output=$output 969036e956c5Smrg output=$output_objdir/$output_la.nm 96910dd80ee0Smrg func_to_tool_file "$output" 96920dd80ee0Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 96930dd80ee0Smrg func_append delfiles " $output" 96940dd80ee0Smrg func_verbose "creating $NM input file list: $output" 96950dd80ee0Smrg for obj in $save_libobjs; do 96960dd80ee0Smrg func_to_tool_file "$obj" 96970dd80ee0Smrg $ECHO "$func_to_tool_file_result" 96980dd80ee0Smrg done > "$output" 96990dd80ee0Smrg eval cmd=\"$cmd1\" 97005f5b92ffSmrg func_show_eval "$cmd" 'exit $?' 97010dd80ee0Smrg output=$save_output 97020dd80ee0Smrg libobjs=$save_libobjs 97035f5b92ffSmrg skipped_export=false 97045f5b92ffSmrg else 97055f5b92ffSmrg # The command line is too long to execute in one step. 97065f5b92ffSmrg func_verbose "using reloadable object file for export list..." 97075f5b92ffSmrg skipped_export=: 97085f5b92ffSmrg # Break out early, otherwise skipped_export may be 97095f5b92ffSmrg # set to false by a later but shorter cmd. 97105f5b92ffSmrg break 97115f5b92ffSmrg fi 97125f5b92ffSmrg done 971336e956c5Smrg IFS=$save_ifs 971436e956c5Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 97155f5b92ffSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 97165f5b92ffSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 97175f5b92ffSmrg fi 97185f5b92ffSmrg fi 971917a48c7cSmrg fi 972017a48c7cSmrg 97215f5b92ffSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 972236e956c5Smrg tmp_export_symbols=$export_symbols 972336e956c5Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 97240dd80ee0Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 97255f5b92ffSmrg fi 972617a48c7cSmrg 972736e956c5Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 97285f5b92ffSmrg # The given exports_symbols file has to be filtered, so filter it. 972936e956c5Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 97305f5b92ffSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 973136e956c5Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 97325f5b92ffSmrg # though. Also, the filter scales superlinearly with the number of 97335f5b92ffSmrg # global variables. join(1) would be nice here, but unfortunately 97345f5b92ffSmrg # isn't a blessed tool. 97355f5b92ffSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 97360dd80ee0Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 97375f5b92ffSmrg export_symbols=$output_objdir/$libname.def 97385f5b92ffSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 97395f5b92ffSmrg fi 974017a48c7cSmrg 97415f5b92ffSmrg tmp_deplibs= 97425f5b92ffSmrg for test_deplib in $deplibs; do 97435f5b92ffSmrg case " $convenience " in 97445f5b92ffSmrg *" $test_deplib "*) ;; 97455f5b92ffSmrg *) 97460dd80ee0Smrg func_append tmp_deplibs " $test_deplib" 97475f5b92ffSmrg ;; 97485f5b92ffSmrg esac 97495f5b92ffSmrg done 975036e956c5Smrg deplibs=$tmp_deplibs 975117a48c7cSmrg 97525f5b92ffSmrg if test -n "$convenience"; then 97535f5b92ffSmrg if test -n "$whole_archive_flag_spec" && 975436e956c5Smrg test yes = "$compiler_needs_object" && 97555f5b92ffSmrg test -z "$libobjs"; then 97565f5b92ffSmrg # extract the archives, so we have objects to list. 97575f5b92ffSmrg # TODO: could optimize this to just extract one archive. 97585f5b92ffSmrg whole_archive_flag_spec= 97595f5b92ffSmrg fi 97605f5b92ffSmrg if test -n "$whole_archive_flag_spec"; then 97615f5b92ffSmrg save_libobjs=$libobjs 97625f5b92ffSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 97635f5b92ffSmrg test "X$libobjs" = "X " && libobjs= 97645f5b92ffSmrg else 976536e956c5Smrg gentop=$output_objdir/${outputname}x 97660dd80ee0Smrg func_append generated " $gentop" 976717a48c7cSmrg 97685f5b92ffSmrg func_extract_archives $gentop $convenience 97690dd80ee0Smrg func_append libobjs " $func_extract_archives_result" 97705f5b92ffSmrg test "X$libobjs" = "X " && libobjs= 97715f5b92ffSmrg fi 977217a48c7cSmrg fi 977317a48c7cSmrg 977436e956c5Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 97755f5b92ffSmrg eval flag=\"$thread_safe_flag_spec\" 97760dd80ee0Smrg func_append linker_flags " $flag" 977717a48c7cSmrg fi 977817a48c7cSmrg 97795f5b92ffSmrg # Make a backup of the uninstalled library when relinking 978036e956c5Smrg if test relink = "$opt_mode"; then 97815f5b92ffSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 97825f5b92ffSmrg fi 978317a48c7cSmrg 97845f5b92ffSmrg # Do each of the archive commands. 978536e956c5Smrg if test yes = "$module" && test -n "$module_cmds"; then 97865f5b92ffSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 97875f5b92ffSmrg eval test_cmds=\"$module_expsym_cmds\" 97885f5b92ffSmrg cmds=$module_expsym_cmds 97895f5b92ffSmrg else 97905f5b92ffSmrg eval test_cmds=\"$module_cmds\" 97915f5b92ffSmrg cmds=$module_cmds 97925f5b92ffSmrg fi 979317a48c7cSmrg else 97945f5b92ffSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 97955f5b92ffSmrg eval test_cmds=\"$archive_expsym_cmds\" 97965f5b92ffSmrg cmds=$archive_expsym_cmds 97975f5b92ffSmrg else 97985f5b92ffSmrg eval test_cmds=\"$archive_cmds\" 97995f5b92ffSmrg cmds=$archive_cmds 98005f5b92ffSmrg fi 980117a48c7cSmrg fi 980217a48c7cSmrg 980336e956c5Smrg if test : != "$skipped_export" && 98045f5b92ffSmrg func_len " $test_cmds" && 98055f5b92ffSmrg len=$func_len_result && 98065f5b92ffSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 98075f5b92ffSmrg : 98085f5b92ffSmrg else 98095f5b92ffSmrg # The command line is too long to link in one step, link piecewise 98105f5b92ffSmrg # or, if using GNU ld and skipped_export is not :, use a linker 98115f5b92ffSmrg # script. 981217a48c7cSmrg 98135f5b92ffSmrg # Save the value of $output and $libobjs because we want to 98145f5b92ffSmrg # use them later. If we have whole_archive_flag_spec, we 98155f5b92ffSmrg # want to use save_libobjs as it was before 98165f5b92ffSmrg # whole_archive_flag_spec was expanded, because we can't 98175f5b92ffSmrg # assume the linker understands whole_archive_flag_spec. 98185f5b92ffSmrg # This may have to be revisited, in case too many 98195f5b92ffSmrg # convenience libraries get linked in and end up exceeding 98205f5b92ffSmrg # the spec. 98215f5b92ffSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 98225f5b92ffSmrg save_libobjs=$libobjs 98235f5b92ffSmrg fi 98245f5b92ffSmrg save_output=$output 98250dd80ee0Smrg func_basename "$output" 98260dd80ee0Smrg output_la=$func_basename_result 982717a48c7cSmrg 98285f5b92ffSmrg # Clear the reloadable object creation command queue and 98295f5b92ffSmrg # initialize k to one. 98305f5b92ffSmrg test_cmds= 98315f5b92ffSmrg concat_cmds= 98325f5b92ffSmrg objlist= 98335f5b92ffSmrg last_robj= 98345f5b92ffSmrg k=1 98355f5b92ffSmrg 983636e956c5Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 983736e956c5Smrg output=$output_objdir/$output_la.lnkscript 98385f5b92ffSmrg func_verbose "creating GNU ld script: $output" 98390dd80ee0Smrg echo 'INPUT (' > $output 98405f5b92ffSmrg for obj in $save_libobjs 984117a48c7cSmrg do 98420dd80ee0Smrg func_to_tool_file "$obj" 98430dd80ee0Smrg $ECHO "$func_to_tool_file_result" >> $output 98445f5b92ffSmrg done 98450dd80ee0Smrg echo ')' >> $output 98460dd80ee0Smrg func_append delfiles " $output" 98470dd80ee0Smrg func_to_tool_file "$output" 98480dd80ee0Smrg output=$func_to_tool_file_result 984936e956c5Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 985036e956c5Smrg output=$output_objdir/$output_la.lnk 98515f5b92ffSmrg func_verbose "creating linker input file list: $output" 98525f5b92ffSmrg : > $output 98535f5b92ffSmrg set x $save_libobjs 98545f5b92ffSmrg shift 98555f5b92ffSmrg firstobj= 985636e956c5Smrg if test yes = "$compiler_needs_object"; then 98575f5b92ffSmrg firstobj="$1 " 98585f5b92ffSmrg shift 98595f5b92ffSmrg fi 98605f5b92ffSmrg for obj 98615f5b92ffSmrg do 98620dd80ee0Smrg func_to_tool_file "$obj" 98630dd80ee0Smrg $ECHO "$func_to_tool_file_result" >> $output 98645f5b92ffSmrg done 98650dd80ee0Smrg func_append delfiles " $output" 98660dd80ee0Smrg func_to_tool_file "$output" 98670dd80ee0Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 98685f5b92ffSmrg else 98695f5b92ffSmrg if test -n "$save_libobjs"; then 98705f5b92ffSmrg func_verbose "creating reloadable object files..." 987136e956c5Smrg output=$output_objdir/$output_la-$k.$objext 98725f5b92ffSmrg eval test_cmds=\"$reload_cmds\" 98735f5b92ffSmrg func_len " $test_cmds" 98745f5b92ffSmrg len0=$func_len_result 98755f5b92ffSmrg len=$len0 98765f5b92ffSmrg 98775f5b92ffSmrg # Loop over the list of objects to be linked. 98785f5b92ffSmrg for obj in $save_libobjs 98795f5b92ffSmrg do 98805f5b92ffSmrg func_len " $obj" 98815f5b92ffSmrg func_arith $len + $func_len_result 98825f5b92ffSmrg len=$func_arith_result 988336e956c5Smrg if test -z "$objlist" || 98845f5b92ffSmrg test "$len" -lt "$max_cmd_len"; then 98855f5b92ffSmrg func_append objlist " $obj" 98865f5b92ffSmrg else 98875f5b92ffSmrg # The command $test_cmds is almost too long, add a 98885f5b92ffSmrg # command to the queue. 988936e956c5Smrg if test 1 -eq "$k"; then 98905f5b92ffSmrg # The first file doesn't have a previous command to add. 98910dd80ee0Smrg reload_objs=$objlist 98920dd80ee0Smrg eval concat_cmds=\"$reload_cmds\" 98935f5b92ffSmrg else 98945f5b92ffSmrg # All subsequent reloadable object files will link in 98955f5b92ffSmrg # the last one created. 98960dd80ee0Smrg reload_objs="$objlist $last_robj" 98970dd80ee0Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 98985f5b92ffSmrg fi 989936e956c5Smrg last_robj=$output_objdir/$output_la-$k.$objext 99005f5b92ffSmrg func_arith $k + 1 99015f5b92ffSmrg k=$func_arith_result 990236e956c5Smrg output=$output_objdir/$output_la-$k.$objext 99030dd80ee0Smrg objlist=" $obj" 99045f5b92ffSmrg func_len " $last_robj" 99055f5b92ffSmrg func_arith $len0 + $func_len_result 99065f5b92ffSmrg len=$func_arith_result 99075f5b92ffSmrg fi 99085f5b92ffSmrg done 99095f5b92ffSmrg # Handle the remaining objects by creating one last 99105f5b92ffSmrg # reloadable object file. All subsequent reloadable object 99115f5b92ffSmrg # files will link in the last one created. 99125f5b92ffSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99130dd80ee0Smrg reload_objs="$objlist $last_robj" 991436e956c5Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 99155f5b92ffSmrg if test -n "$last_robj"; then 991636e956c5Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99175f5b92ffSmrg fi 99180dd80ee0Smrg func_append delfiles " $output" 991917a48c7cSmrg 99205f5b92ffSmrg else 99215f5b92ffSmrg output= 99225f5b92ffSmrg fi 992317a48c7cSmrg 992436e956c5Smrg ${skipped_export-false} && { 992536e956c5Smrg func_verbose "generating symbol list for '$libname.la'" 992636e956c5Smrg export_symbols=$output_objdir/$libname.exp 99275f5b92ffSmrg $opt_dry_run || $RM $export_symbols 99285f5b92ffSmrg libobjs=$output 99295f5b92ffSmrg # Append the command to create the export file. 99305f5b92ffSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99315f5b92ffSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 99325f5b92ffSmrg if test -n "$last_robj"; then 99335f5b92ffSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99345f5b92ffSmrg fi 993536e956c5Smrg } 993617a48c7cSmrg 99375f5b92ffSmrg test -n "$save_libobjs" && 99385f5b92ffSmrg func_verbose "creating a temporary reloadable object file: $output" 993917a48c7cSmrg 99405f5b92ffSmrg # Loop through the commands generated above and execute them. 994136e956c5Smrg save_ifs=$IFS; IFS='~' 99425f5b92ffSmrg for cmd in $concat_cmds; do 994336e956c5Smrg IFS=$save_ifs 994436e956c5Smrg $opt_quiet || { 99455f5b92ffSmrg func_quote_for_expand "$cmd" 99465f5b92ffSmrg eval "func_echo $func_quote_for_expand_result" 99475f5b92ffSmrg } 99485f5b92ffSmrg $opt_dry_run || eval "$cmd" || { 99495f5b92ffSmrg lt_exit=$? 99505f5b92ffSmrg 99515f5b92ffSmrg # Restore the uninstalled library and exit 995236e956c5Smrg if test relink = "$opt_mode"; then 99535f5b92ffSmrg ( cd "$output_objdir" && \ 99545f5b92ffSmrg $RM "${realname}T" && \ 99555f5b92ffSmrg $MV "${realname}U" "$realname" ) 99565f5b92ffSmrg fi 995717a48c7cSmrg 99585f5b92ffSmrg exit $lt_exit 99595f5b92ffSmrg } 99605f5b92ffSmrg done 996136e956c5Smrg IFS=$save_ifs 996217a48c7cSmrg 99635f5b92ffSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 99645f5b92ffSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99655f5b92ffSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 996617a48c7cSmrg fi 996717a48c7cSmrg fi 996817a48c7cSmrg 996936e956c5Smrg ${skipped_export-false} && { 99705f5b92ffSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 997136e956c5Smrg tmp_export_symbols=$export_symbols 997236e956c5Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 99730dd80ee0Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 99745f5b92ffSmrg fi 997517a48c7cSmrg 99765f5b92ffSmrg if test -n "$orig_export_symbols"; then 99775f5b92ffSmrg # The given exports_symbols file has to be filtered, so filter it. 997836e956c5Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 99795f5b92ffSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 998036e956c5Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 99815f5b92ffSmrg # though. Also, the filter scales superlinearly with the number of 99825f5b92ffSmrg # global variables. join(1) would be nice here, but unfortunately 99835f5b92ffSmrg # isn't a blessed tool. 99845f5b92ffSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 99850dd80ee0Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 99865f5b92ffSmrg export_symbols=$output_objdir/$libname.def 99875f5b92ffSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 99885f5b92ffSmrg fi 998936e956c5Smrg } 999017a48c7cSmrg 99915f5b92ffSmrg libobjs=$output 99925f5b92ffSmrg # Restore the value of output. 99935f5b92ffSmrg output=$save_output 999417a48c7cSmrg 99955f5b92ffSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 99965f5b92ffSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 99975f5b92ffSmrg test "X$libobjs" = "X " && libobjs= 99985f5b92ffSmrg fi 99995f5b92ffSmrg # Expand the library linking commands again to reset the 100005f5b92ffSmrg # value of $libobjs for piecewise linking. 1000117a48c7cSmrg 100025f5b92ffSmrg # Do each of the archive commands. 1000336e956c5Smrg if test yes = "$module" && test -n "$module_cmds"; then 100045f5b92ffSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100055f5b92ffSmrg cmds=$module_expsym_cmds 100065f5b92ffSmrg else 100075f5b92ffSmrg cmds=$module_cmds 1000817a48c7cSmrg fi 1000917a48c7cSmrg else 100105f5b92ffSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100115f5b92ffSmrg cmds=$archive_expsym_cmds 100125f5b92ffSmrg else 100135f5b92ffSmrg cmds=$archive_cmds 100145f5b92ffSmrg fi 1001517a48c7cSmrg fi 100165f5b92ffSmrg fi 1001717a48c7cSmrg 100185f5b92ffSmrg if test -n "$delfiles"; then 100195f5b92ffSmrg # Append the command to remove temporary files to $cmds. 100205f5b92ffSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 100215f5b92ffSmrg fi 1002217a48c7cSmrg 100235f5b92ffSmrg # Add any objects from preloaded convenience libraries 100245f5b92ffSmrg if test -n "$dlprefiles"; then 1002536e956c5Smrg gentop=$output_objdir/${outputname}x 100260dd80ee0Smrg func_append generated " $gentop" 1002717a48c7cSmrg 100285f5b92ffSmrg func_extract_archives $gentop $dlprefiles 100290dd80ee0Smrg func_append libobjs " $func_extract_archives_result" 100305f5b92ffSmrg test "X$libobjs" = "X " && libobjs= 100315f5b92ffSmrg fi 1003217a48c7cSmrg 1003336e956c5Smrg save_ifs=$IFS; IFS='~' 100345f5b92ffSmrg for cmd in $cmds; do 1003536e956c5Smrg IFS=$sp$nl 100365f5b92ffSmrg eval cmd=\"$cmd\" 1003736e956c5Smrg IFS=$save_ifs 1003836e956c5Smrg $opt_quiet || { 100395f5b92ffSmrg func_quote_for_expand "$cmd" 100405f5b92ffSmrg eval "func_echo $func_quote_for_expand_result" 100415f5b92ffSmrg } 100425f5b92ffSmrg $opt_dry_run || eval "$cmd" || { 100435f5b92ffSmrg lt_exit=$? 1004417a48c7cSmrg 100455f5b92ffSmrg # Restore the uninstalled library and exit 1004636e956c5Smrg if test relink = "$opt_mode"; then 100475f5b92ffSmrg ( cd "$output_objdir" && \ 100485f5b92ffSmrg $RM "${realname}T" && \ 100495f5b92ffSmrg $MV "${realname}U" "$realname" ) 100505f5b92ffSmrg fi 1005117a48c7cSmrg 100525f5b92ffSmrg exit $lt_exit 100535f5b92ffSmrg } 100545f5b92ffSmrg done 1005536e956c5Smrg IFS=$save_ifs 1005617a48c7cSmrg 100575f5b92ffSmrg # Restore the uninstalled library and exit 1005836e956c5Smrg if test relink = "$opt_mode"; then 100595f5b92ffSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1006017a48c7cSmrg 100615f5b92ffSmrg if test -n "$convenience"; then 100625f5b92ffSmrg if test -z "$whole_archive_flag_spec"; then 100635f5b92ffSmrg func_show_eval '${RM}r "$gentop"' 100645f5b92ffSmrg fi 100655f5b92ffSmrg fi 1006617a48c7cSmrg 100675f5b92ffSmrg exit $EXIT_SUCCESS 100685f5b92ffSmrg fi 100695f5b92ffSmrg 100705f5b92ffSmrg # Create links to the real library. 100715f5b92ffSmrg for linkname in $linknames; do 100725f5b92ffSmrg if test "$realname" != "$linkname"; then 100735f5b92ffSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1007417a48c7cSmrg fi 1007517a48c7cSmrg done 1007617a48c7cSmrg 100775f5b92ffSmrg # If -module or -export-dynamic was specified, set the dlname. 1007836e956c5Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 100795f5b92ffSmrg # On all known operating systems, these are identical. 1008036e956c5Smrg dlname=$soname 100815f5b92ffSmrg fi 100825f5b92ffSmrg fi 1008317a48c7cSmrg ;; 1008417a48c7cSmrg 100855f5b92ffSmrg obj) 1008636e956c5Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1008736e956c5Smrg func_warning "'-dlopen' is ignored for objects" 100885f5b92ffSmrg fi 1008917a48c7cSmrg 100905f5b92ffSmrg case " $deplibs" in 100915f5b92ffSmrg *\ -l* | *\ -L*) 1009236e956c5Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 1009317a48c7cSmrg esac 1009417a48c7cSmrg 100955f5b92ffSmrg test -n "$rpath" && \ 1009636e956c5Smrg func_warning "'-rpath' is ignored for objects" 100975f5b92ffSmrg 100985f5b92ffSmrg test -n "$xrpath" && \ 1009936e956c5Smrg func_warning "'-R' is ignored for objects" 1010017a48c7cSmrg 101015f5b92ffSmrg test -n "$vinfo" && \ 1010236e956c5Smrg func_warning "'-version-info' is ignored for objects" 1010317a48c7cSmrg 101045f5b92ffSmrg test -n "$release" && \ 1010536e956c5Smrg func_warning "'-release' is ignored for objects" 101065f5b92ffSmrg 101075f5b92ffSmrg case $output in 101085f5b92ffSmrg *.lo) 101095f5b92ffSmrg test -n "$objs$old_deplibs" && \ 1011036e956c5Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 101115f5b92ffSmrg 101125f5b92ffSmrg libobj=$output 101135f5b92ffSmrg func_lo2o "$libobj" 101145f5b92ffSmrg obj=$func_lo2o_result 1011517a48c7cSmrg ;; 1011617a48c7cSmrg *) 101175f5b92ffSmrg libobj= 1011836e956c5Smrg obj=$output 1011917a48c7cSmrg ;; 1012017a48c7cSmrg esac 1012117a48c7cSmrg 101225f5b92ffSmrg # Delete the old objects. 101235f5b92ffSmrg $opt_dry_run || $RM $obj $libobj 1012417a48c7cSmrg 101255f5b92ffSmrg # Objects from convenience libraries. This assumes 101265f5b92ffSmrg # single-version convenience libraries. Whenever we create 101275f5b92ffSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 101285f5b92ffSmrg # the extraction. 101295f5b92ffSmrg reload_conv_objs= 101305f5b92ffSmrg gentop= 1013136e956c5Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 1013236e956c5Smrg # whole_archive_flag_spec and hope we can get by with turning comma 1013336e956c5Smrg # into space. 1013436e956c5Smrg case $reload_cmds in 1013536e956c5Smrg *\$LD[\ \$]*) wl= ;; 1013636e956c5Smrg esac 101375f5b92ffSmrg if test -n "$convenience"; then 101385f5b92ffSmrg if test -n "$whole_archive_flag_spec"; then 101395f5b92ffSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1014036e956c5Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1014136e956c5Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 101425f5b92ffSmrg else 1014336e956c5Smrg gentop=$output_objdir/${obj}x 101440dd80ee0Smrg func_append generated " $gentop" 1014517a48c7cSmrg 101465f5b92ffSmrg func_extract_archives $gentop $convenience 101475f5b92ffSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 101485f5b92ffSmrg fi 1014917a48c7cSmrg fi 1015017a48c7cSmrg 101510dd80ee0Smrg # If we're not building shared, we need to use non_pic_objs 1015236e956c5Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 101530dd80ee0Smrg 101545f5b92ffSmrg # Create the old-style object. 1015536e956c5Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 1015617a48c7cSmrg 1015736e956c5Smrg output=$obj 101585f5b92ffSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1015917a48c7cSmrg 101605f5b92ffSmrg # Exit if we aren't doing a library object file. 101615f5b92ffSmrg if test -z "$libobj"; then 101625f5b92ffSmrg if test -n "$gentop"; then 101635f5b92ffSmrg func_show_eval '${RM}r "$gentop"' 101645f5b92ffSmrg fi 101655f5b92ffSmrg 101665f5b92ffSmrg exit $EXIT_SUCCESS 1016717a48c7cSmrg fi 101685f5b92ffSmrg 1016936e956c5Smrg test yes = "$build_libtool_libs" || { 101705f5b92ffSmrg if test -n "$gentop"; then 101715f5b92ffSmrg func_show_eval '${RM}r "$gentop"' 101725f5b92ffSmrg fi 101735f5b92ffSmrg 101745f5b92ffSmrg # Create an invalid libtool object if no PIC, so that we don't 101755f5b92ffSmrg # accidentally link it into a program. 101765f5b92ffSmrg # $show "echo timestamp > $libobj" 101775f5b92ffSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 101785f5b92ffSmrg exit $EXIT_SUCCESS 1017936e956c5Smrg } 101805f5b92ffSmrg 1018136e956c5Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 101825f5b92ffSmrg # Only do commands if we really have different PIC objects. 101835f5b92ffSmrg reload_objs="$libobjs $reload_conv_objs" 1018436e956c5Smrg output=$libobj 101855f5b92ffSmrg func_execute_cmds "$reload_cmds" 'exit $?' 101865f5b92ffSmrg fi 101875f5b92ffSmrg 101885f5b92ffSmrg if test -n "$gentop"; then 101895f5b92ffSmrg func_show_eval '${RM}r "$gentop"' 101905f5b92ffSmrg fi 101915f5b92ffSmrg 101925f5b92ffSmrg exit $EXIT_SUCCESS 1019317a48c7cSmrg ;; 1019417a48c7cSmrg 101955f5b92ffSmrg prog) 101965f5b92ffSmrg case $host in 101975f5b92ffSmrg *cygwin*) func_stripname '' '.exe' "$output" 101985f5b92ffSmrg output=$func_stripname_result.exe;; 101995f5b92ffSmrg esac 102005f5b92ffSmrg test -n "$vinfo" && \ 1020136e956c5Smrg func_warning "'-version-info' is ignored for programs" 1020217a48c7cSmrg 102035f5b92ffSmrg test -n "$release" && \ 1020436e956c5Smrg func_warning "'-release' is ignored for programs" 1020517a48c7cSmrg 1020636e956c5Smrg $preload \ 1020736e956c5Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1020836e956c5Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 102095f5b92ffSmrg 102105f5b92ffSmrg case $host in 102115f5b92ffSmrg *-*-rhapsody* | *-*-darwin1.[012]) 102125f5b92ffSmrg # On Rhapsody replace the C library is the System framework 102130dd80ee0Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 102140dd80ee0Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 1021517a48c7cSmrg ;; 102165f5b92ffSmrg esac 1021717a48c7cSmrg 102185f5b92ffSmrg case $host in 102195f5b92ffSmrg *-*-darwin*) 102205f5b92ffSmrg # Don't allow lazy linking, it breaks C++ global constructors 102215f5b92ffSmrg # But is supposedly fixed on 10.4 or later (yay!). 1022236e956c5Smrg if test CXX = "$tagname"; then 102235f5b92ffSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 102245f5b92ffSmrg 10.[0123]) 1022536e956c5Smrg func_append compile_command " $wl-bind_at_load" 1022636e956c5Smrg func_append finalize_command " $wl-bind_at_load" 102275f5b92ffSmrg ;; 102285f5b92ffSmrg esac 1022917a48c7cSmrg fi 102305f5b92ffSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 102310dd80ee0Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102320dd80ee0Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102335f5b92ffSmrg ;; 102345f5b92ffSmrg esac 1023517a48c7cSmrg 1023617a48c7cSmrg 102375f5b92ffSmrg # move library search paths that coincide with paths to not yet 102385f5b92ffSmrg # installed libraries to the beginning of the library search list 102395f5b92ffSmrg new_libs= 102405f5b92ffSmrg for path in $notinst_path; do 102415f5b92ffSmrg case " $new_libs " in 102425f5b92ffSmrg *" -L$path/$objdir "*) ;; 102435f5b92ffSmrg *) 102445f5b92ffSmrg case " $compile_deplibs " in 102455f5b92ffSmrg *" -L$path/$objdir "*) 102460dd80ee0Smrg func_append new_libs " -L$path/$objdir" ;; 1024717a48c7cSmrg esac 102485f5b92ffSmrg ;; 102495f5b92ffSmrg esac 102505f5b92ffSmrg done 102515f5b92ffSmrg for deplib in $compile_deplibs; do 102525f5b92ffSmrg case $deplib in 102535f5b92ffSmrg -L*) 102545f5b92ffSmrg case " $new_libs " in 102555f5b92ffSmrg *" $deplib "*) ;; 102560dd80ee0Smrg *) func_append new_libs " $deplib" ;; 1025717a48c7cSmrg esac 102585f5b92ffSmrg ;; 102590dd80ee0Smrg *) func_append new_libs " $deplib" ;; 102605f5b92ffSmrg esac 102615f5b92ffSmrg done 1026236e956c5Smrg compile_deplibs=$new_libs 1026317a48c7cSmrg 1026417a48c7cSmrg 102650dd80ee0Smrg func_append compile_command " $compile_deplibs" 102660dd80ee0Smrg func_append finalize_command " $finalize_deplibs" 1026717a48c7cSmrg 102685f5b92ffSmrg if test -n "$rpath$xrpath"; then 102695f5b92ffSmrg # If the user specified any rpath flags, then add them. 102705f5b92ffSmrg for libdir in $rpath $xrpath; do 102715f5b92ffSmrg # This is the magic to use -rpath. 102725f5b92ffSmrg case "$finalize_rpath " in 102735f5b92ffSmrg *" $libdir "*) ;; 102740dd80ee0Smrg *) func_append finalize_rpath " $libdir" ;; 102755f5b92ffSmrg esac 102765f5b92ffSmrg done 102775f5b92ffSmrg fi 1027817a48c7cSmrg 102795f5b92ffSmrg # Now hardcode the library paths 102805f5b92ffSmrg rpath= 102815f5b92ffSmrg hardcode_libdirs= 102825f5b92ffSmrg for libdir in $compile_rpath $finalize_rpath; do 102835f5b92ffSmrg if test -n "$hardcode_libdir_flag_spec"; then 102845f5b92ffSmrg if test -n "$hardcode_libdir_separator"; then 102855f5b92ffSmrg if test -z "$hardcode_libdirs"; then 1028636e956c5Smrg hardcode_libdirs=$libdir 102875f5b92ffSmrg else 102885f5b92ffSmrg # Just accumulate the unique libdirs. 102895f5b92ffSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 102905f5b92ffSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 102915f5b92ffSmrg ;; 102925f5b92ffSmrg *) 102930dd80ee0Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 102945f5b92ffSmrg ;; 102955f5b92ffSmrg esac 102965f5b92ffSmrg fi 1029717a48c7cSmrg else 102985f5b92ffSmrg eval flag=\"$hardcode_libdir_flag_spec\" 102990dd80ee0Smrg func_append rpath " $flag" 1030017a48c7cSmrg fi 103015f5b92ffSmrg elif test -n "$runpath_var"; then 103025f5b92ffSmrg case "$perm_rpath " in 103035f5b92ffSmrg *" $libdir "*) ;; 103040dd80ee0Smrg *) func_append perm_rpath " $libdir" ;; 103055f5b92ffSmrg esac 103065f5b92ffSmrg fi 103075f5b92ffSmrg case $host in 103085f5b92ffSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030936e956c5Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 103105f5b92ffSmrg case :$dllsearchpath: in 103115f5b92ffSmrg *":$libdir:"*) ;; 103125f5b92ffSmrg ::) dllsearchpath=$libdir;; 103130dd80ee0Smrg *) func_append dllsearchpath ":$libdir";; 103145f5b92ffSmrg esac 103155f5b92ffSmrg case :$dllsearchpath: in 103165f5b92ffSmrg *":$testbindir:"*) ;; 103175f5b92ffSmrg ::) dllsearchpath=$testbindir;; 103180dd80ee0Smrg *) func_append dllsearchpath ":$testbindir";; 103195f5b92ffSmrg esac 103205f5b92ffSmrg ;; 103215f5b92ffSmrg esac 103225f5b92ffSmrg done 103235f5b92ffSmrg # Substitute the hardcoded libdirs into the rpath. 103245f5b92ffSmrg if test -n "$hardcode_libdir_separator" && 103255f5b92ffSmrg test -n "$hardcode_libdirs"; then 1032636e956c5Smrg libdir=$hardcode_libdirs 103275f5b92ffSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103285f5b92ffSmrg fi 1032936e956c5Smrg compile_rpath=$rpath 1033017a48c7cSmrg 103315f5b92ffSmrg rpath= 103325f5b92ffSmrg hardcode_libdirs= 103335f5b92ffSmrg for libdir in $finalize_rpath; do 103345f5b92ffSmrg if test -n "$hardcode_libdir_flag_spec"; then 103355f5b92ffSmrg if test -n "$hardcode_libdir_separator"; then 103365f5b92ffSmrg if test -z "$hardcode_libdirs"; then 1033736e956c5Smrg hardcode_libdirs=$libdir 103385f5b92ffSmrg else 103395f5b92ffSmrg # Just accumulate the unique libdirs. 103405f5b92ffSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 103415f5b92ffSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 103425f5b92ffSmrg ;; 103435f5b92ffSmrg *) 103440dd80ee0Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 103455f5b92ffSmrg ;; 103465f5b92ffSmrg esac 103475f5b92ffSmrg fi 1034817a48c7cSmrg else 103495f5b92ffSmrg eval flag=\"$hardcode_libdir_flag_spec\" 103500dd80ee0Smrg func_append rpath " $flag" 1035117a48c7cSmrg fi 103525f5b92ffSmrg elif test -n "$runpath_var"; then 103535f5b92ffSmrg case "$finalize_perm_rpath " in 103545f5b92ffSmrg *" $libdir "*) ;; 103550dd80ee0Smrg *) func_append finalize_perm_rpath " $libdir" ;; 103565f5b92ffSmrg esac 1035717a48c7cSmrg fi 103585f5b92ffSmrg done 103595f5b92ffSmrg # Substitute the hardcoded libdirs into the rpath. 103605f5b92ffSmrg if test -n "$hardcode_libdir_separator" && 103615f5b92ffSmrg test -n "$hardcode_libdirs"; then 1036236e956c5Smrg libdir=$hardcode_libdirs 103635f5b92ffSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103645f5b92ffSmrg fi 1036536e956c5Smrg finalize_rpath=$rpath 1036617a48c7cSmrg 1036736e956c5Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 103685f5b92ffSmrg # Transform all the library objects into standard objects. 103690dd80ee0Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103700dd80ee0Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103715f5b92ffSmrg fi 1037217a48c7cSmrg 1037336e956c5Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1037417a48c7cSmrg 103755f5b92ffSmrg # template prelinking step 103765f5b92ffSmrg if test -n "$prelink_cmds"; then 103775f5b92ffSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 103785f5b92ffSmrg fi 1037917a48c7cSmrg 1038036e956c5Smrg wrappers_required=: 103815f5b92ffSmrg case $host in 103820dd80ee0Smrg *cegcc* | *mingw32ce*) 103830dd80ee0Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1038436e956c5Smrg wrappers_required=false 103850dd80ee0Smrg ;; 103865f5b92ffSmrg *cygwin* | *mingw* ) 1038736e956c5Smrg test yes = "$build_libtool_libs" || wrappers_required=false 103885f5b92ffSmrg ;; 103895f5b92ffSmrg *) 1039036e956c5Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1039136e956c5Smrg wrappers_required=false 103925f5b92ffSmrg fi 103935f5b92ffSmrg ;; 103945f5b92ffSmrg esac 1039536e956c5Smrg $wrappers_required || { 103965f5b92ffSmrg # Replace the output file specification. 103970dd80ee0Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1039836e956c5Smrg link_command=$compile_command$compile_rpath 1039917a48c7cSmrg 104005f5b92ffSmrg # We have no uninstalled library dependencies, so finalize right now. 104015f5b92ffSmrg exit_status=0 104025f5b92ffSmrg func_show_eval "$link_command" 'exit_status=$?' 1040317a48c7cSmrg 104040dd80ee0Smrg if test -n "$postlink_cmds"; then 104050dd80ee0Smrg func_to_tool_file "$output" 104060dd80ee0Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 104070dd80ee0Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 104080dd80ee0Smrg fi 104090dd80ee0Smrg 104105f5b92ffSmrg # Delete the generated files. 1041136e956c5Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 1041236e956c5Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1041317a48c7cSmrg fi 1041417a48c7cSmrg 104155f5b92ffSmrg exit $exit_status 1041636e956c5Smrg } 1041717a48c7cSmrg 104185f5b92ffSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 104195f5b92ffSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 104205f5b92ffSmrg fi 104215f5b92ffSmrg if test -n "$finalize_shlibpath"; then 104225f5b92ffSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 104235f5b92ffSmrg fi 1042417a48c7cSmrg 104255f5b92ffSmrg compile_var= 104265f5b92ffSmrg finalize_var= 104275f5b92ffSmrg if test -n "$runpath_var"; then 104285f5b92ffSmrg if test -n "$perm_rpath"; then 104295f5b92ffSmrg # We should set the runpath_var. 104305f5b92ffSmrg rpath= 104315f5b92ffSmrg for dir in $perm_rpath; do 104320dd80ee0Smrg func_append rpath "$dir:" 104335f5b92ffSmrg done 104345f5b92ffSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1043517a48c7cSmrg fi 104365f5b92ffSmrg if test -n "$finalize_perm_rpath"; then 104375f5b92ffSmrg # We should set the runpath_var. 104385f5b92ffSmrg rpath= 104395f5b92ffSmrg for dir in $finalize_perm_rpath; do 104400dd80ee0Smrg func_append rpath "$dir:" 104415f5b92ffSmrg done 104425f5b92ffSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1044317a48c7cSmrg fi 104445f5b92ffSmrg fi 1044517a48c7cSmrg 1044636e956c5Smrg if test yes = "$no_install"; then 104475f5b92ffSmrg # We don't need to create a wrapper script. 1044836e956c5Smrg link_command=$compile_var$compile_command$compile_rpath 104495f5b92ffSmrg # Replace the output file specification. 104500dd80ee0Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104515f5b92ffSmrg # Delete the old output file. 104525f5b92ffSmrg $opt_dry_run || $RM $output 104535f5b92ffSmrg # Link the executable and exit 104545f5b92ffSmrg func_show_eval "$link_command" 'exit $?' 104550dd80ee0Smrg 104560dd80ee0Smrg if test -n "$postlink_cmds"; then 104570dd80ee0Smrg func_to_tool_file "$output" 104580dd80ee0Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 104590dd80ee0Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 104600dd80ee0Smrg fi 104610dd80ee0Smrg 1046217a48c7cSmrg exit $EXIT_SUCCESS 104635f5b92ffSmrg fi 1046417a48c7cSmrg 1046536e956c5Smrg case $hardcode_action,$fast_install in 1046636e956c5Smrg relink,*) 1046736e956c5Smrg # Fast installation is not supported 1046836e956c5Smrg link_command=$compile_var$compile_command$compile_rpath 1046936e956c5Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 104705f5b92ffSmrg 1047136e956c5Smrg func_warning "this platform does not like uninstalled shared libraries" 1047236e956c5Smrg func_warning "'$output' will be relinked during installation" 1047336e956c5Smrg ;; 1047436e956c5Smrg *,yes) 1047536e956c5Smrg link_command=$finalize_var$compile_command$finalize_rpath 1047636e956c5Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1047736e956c5Smrg ;; 1047836e956c5Smrg *,no) 1047936e956c5Smrg link_command=$compile_var$compile_command$compile_rpath 1048036e956c5Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1048136e956c5Smrg ;; 1048236e956c5Smrg *,needless) 1048336e956c5Smrg link_command=$finalize_var$compile_command$finalize_rpath 1048436e956c5Smrg relink_command= 1048536e956c5Smrg ;; 1048636e956c5Smrg esac 1048717a48c7cSmrg 104885f5b92ffSmrg # Replace the output file specification. 104890dd80ee0Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1049017a48c7cSmrg 104915f5b92ffSmrg # Delete the old output files. 104925f5b92ffSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1049317a48c7cSmrg 104945f5b92ffSmrg func_show_eval "$link_command" 'exit $?' 1049517a48c7cSmrg 104960dd80ee0Smrg if test -n "$postlink_cmds"; then 104970dd80ee0Smrg func_to_tool_file "$output_objdir/$outputname" 104980dd80ee0Smrg 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'` 104990dd80ee0Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 105000dd80ee0Smrg fi 105010dd80ee0Smrg 105025f5b92ffSmrg # Now create the wrapper script. 105035f5b92ffSmrg func_verbose "creating $output" 1050417a48c7cSmrg 105055f5b92ffSmrg # Quote the relink command for shipping. 105065f5b92ffSmrg if test -n "$relink_command"; then 105075f5b92ffSmrg # Preserve any variables that may affect compiler behavior 105085f5b92ffSmrg for var in $variables_saved_for_relink; do 105095f5b92ffSmrg if eval test -z \"\${$var+set}\"; then 105105f5b92ffSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 105115f5b92ffSmrg elif eval var_value=\$$var; test -z "$var_value"; then 105125f5b92ffSmrg relink_command="$var=; export $var; $relink_command" 1051317a48c7cSmrg else 105145f5b92ffSmrg func_quote_for_eval "$var_value" 105155f5b92ffSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1051617a48c7cSmrg fi 105175f5b92ffSmrg done 105185f5b92ffSmrg relink_command="(cd `pwd`; $relink_command)" 105190dd80ee0Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 105205f5b92ffSmrg fi 105215f5b92ffSmrg 105225f5b92ffSmrg # Only actually do things if not in dry run mode. 105235f5b92ffSmrg $opt_dry_run || { 105245f5b92ffSmrg # win32 will think the script is a binary if it has 105255f5b92ffSmrg # a .exe suffix, so we strip it off here. 105265f5b92ffSmrg case $output in 105275f5b92ffSmrg *.exe) func_stripname '' '.exe' "$output" 105285f5b92ffSmrg output=$func_stripname_result ;; 105295f5b92ffSmrg esac 105305f5b92ffSmrg # test for cygwin because mv fails w/o .exe extensions 105315f5b92ffSmrg case $host in 105325f5b92ffSmrg *cygwin*) 105335f5b92ffSmrg exeext=.exe 105345f5b92ffSmrg func_stripname '' '.exe' "$outputname" 105355f5b92ffSmrg outputname=$func_stripname_result ;; 105365f5b92ffSmrg *) exeext= ;; 1053717a48c7cSmrg esac 105385f5b92ffSmrg case $host in 105395f5b92ffSmrg *cygwin* | *mingw* ) 105405f5b92ffSmrg func_dirname_and_basename "$output" "" "." 105415f5b92ffSmrg output_name=$func_basename_result 105425f5b92ffSmrg output_path=$func_dirname_result 1054336e956c5Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1054436e956c5Smrg cwrapper=$output_path/$output_name.exe 105455f5b92ffSmrg $RM $cwrappersource $cwrapper 105465f5b92ffSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 105475f5b92ffSmrg 105485f5b92ffSmrg func_emit_cwrapperexe_src > $cwrappersource 105495f5b92ffSmrg 105505f5b92ffSmrg # The wrapper executable is built using the $host compiler, 105515f5b92ffSmrg # because it contains $host paths and files. If cross- 105525f5b92ffSmrg # compiling, it, like the target executable, must be 105535f5b92ffSmrg # executed on the $host or under an emulation environment. 105545f5b92ffSmrg $opt_dry_run || { 105555f5b92ffSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 105565f5b92ffSmrg $STRIP $cwrapper 105575f5b92ffSmrg } 1055817a48c7cSmrg 105595f5b92ffSmrg # Now, create the wrapper script for func_source use: 105605f5b92ffSmrg func_ltwrapper_scriptname $cwrapper 105615f5b92ffSmrg $RM $func_ltwrapper_scriptname_result 105625f5b92ffSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 105635f5b92ffSmrg $opt_dry_run || { 105645f5b92ffSmrg # note: this script will not be executed, so do not chmod. 1056536e956c5Smrg if test "x$build" = "x$host"; then 105665f5b92ffSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 105675f5b92ffSmrg else 105685f5b92ffSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 105695f5b92ffSmrg fi 105705f5b92ffSmrg } 105715f5b92ffSmrg ;; 105725f5b92ffSmrg * ) 105735f5b92ffSmrg $RM $output 105745f5b92ffSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1057517a48c7cSmrg 105765f5b92ffSmrg func_emit_wrapper no > $output 105775f5b92ffSmrg chmod +x $output 105785f5b92ffSmrg ;; 105795f5b92ffSmrg esac 105805f5b92ffSmrg } 105815f5b92ffSmrg exit $EXIT_SUCCESS 105825f5b92ffSmrg ;; 105835f5b92ffSmrg esac 1058417a48c7cSmrg 105855f5b92ffSmrg # See if we need to build an old-fashioned archive. 105865f5b92ffSmrg for oldlib in $oldlibs; do 1058717a48c7cSmrg 1058836e956c5Smrg case $build_libtool_libs in 1058936e956c5Smrg convenience) 1059036e956c5Smrg oldobjs="$libobjs_save $symfileobj" 1059136e956c5Smrg addlibs=$convenience 105925f5b92ffSmrg build_libtool_libs=no 1059336e956c5Smrg ;; 1059436e956c5Smrg module) 1059536e956c5Smrg oldobjs=$libobjs_save 1059636e956c5Smrg addlibs=$old_convenience 1059736e956c5Smrg build_libtool_libs=no 1059836e956c5Smrg ;; 1059936e956c5Smrg *) 106005f5b92ffSmrg oldobjs="$old_deplibs $non_pic_objects" 1060136e956c5Smrg $preload && test -f "$symfileobj" \ 1060236e956c5Smrg && func_append oldobjs " $symfileobj" 1060336e956c5Smrg addlibs=$old_convenience 1060436e956c5Smrg ;; 1060536e956c5Smrg esac 1060617a48c7cSmrg 106075f5b92ffSmrg if test -n "$addlibs"; then 1060836e956c5Smrg gentop=$output_objdir/${outputname}x 106090dd80ee0Smrg func_append generated " $gentop" 1061017a48c7cSmrg 106115f5b92ffSmrg func_extract_archives $gentop $addlibs 106120dd80ee0Smrg func_append oldobjs " $func_extract_archives_result" 106135f5b92ffSmrg fi 1061417a48c7cSmrg 106155f5b92ffSmrg # Do each command in the archive commands. 1061636e956c5Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 106175f5b92ffSmrg cmds=$old_archive_from_new_cmds 106185f5b92ffSmrg else 1061917a48c7cSmrg 106205f5b92ffSmrg # Add any objects from preloaded convenience libraries 106215f5b92ffSmrg if test -n "$dlprefiles"; then 1062236e956c5Smrg gentop=$output_objdir/${outputname}x 106230dd80ee0Smrg func_append generated " $gentop" 1062417a48c7cSmrg 106255f5b92ffSmrg func_extract_archives $gentop $dlprefiles 106260dd80ee0Smrg func_append oldobjs " $func_extract_archives_result" 106275f5b92ffSmrg fi 1062817a48c7cSmrg 106295f5b92ffSmrg # POSIX demands no paths to be encoded in archives. We have 106305f5b92ffSmrg # to avoid creating archives with duplicate basenames if we 106315f5b92ffSmrg # might have to extract them afterwards, e.g., when creating a 106325f5b92ffSmrg # static archive out of a convenience library, or when linking 106335f5b92ffSmrg # the entirety of a libtool archive into another (currently 106345f5b92ffSmrg # not supported by libtool). 106355f5b92ffSmrg if (for obj in $oldobjs 106365f5b92ffSmrg do 106375f5b92ffSmrg func_basename "$obj" 106385f5b92ffSmrg $ECHO "$func_basename_result" 106395f5b92ffSmrg done | sort | sort -uc >/dev/null 2>&1); then 106405f5b92ffSmrg : 106415f5b92ffSmrg else 106420dd80ee0Smrg echo "copying selected object files to avoid basename conflicts..." 1064336e956c5Smrg gentop=$output_objdir/${outputname}x 106440dd80ee0Smrg func_append generated " $gentop" 106455f5b92ffSmrg func_mkdir_p "$gentop" 106465f5b92ffSmrg save_oldobjs=$oldobjs 106475f5b92ffSmrg oldobjs= 106485f5b92ffSmrg counter=1 106495f5b92ffSmrg for obj in $save_oldobjs 106505f5b92ffSmrg do 106515f5b92ffSmrg func_basename "$obj" 1065236e956c5Smrg objbase=$func_basename_result 106535f5b92ffSmrg case " $oldobjs " in 106545f5b92ffSmrg " ") oldobjs=$obj ;; 106555f5b92ffSmrg *[\ /]"$objbase "*) 106565f5b92ffSmrg while :; do 106575f5b92ffSmrg # Make sure we don't pick an alternate name that also 106585f5b92ffSmrg # overlaps. 106595f5b92ffSmrg newobj=lt$counter-$objbase 106605f5b92ffSmrg func_arith $counter + 1 106615f5b92ffSmrg counter=$func_arith_result 106625f5b92ffSmrg case " $oldobjs " in 106635f5b92ffSmrg *[\ /]"$newobj "*) ;; 106645f5b92ffSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 106655f5b92ffSmrg esac 106665f5b92ffSmrg done 106675f5b92ffSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 106680dd80ee0Smrg func_append oldobjs " $gentop/$newobj" 106695f5b92ffSmrg ;; 106700dd80ee0Smrg *) func_append oldobjs " $obj" ;; 106715f5b92ffSmrg esac 1067217a48c7cSmrg done 1067317a48c7cSmrg fi 106740dd80ee0Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 106750dd80ee0Smrg tool_oldlib=$func_to_tool_file_result 106765f5b92ffSmrg eval cmds=\"$old_archive_cmds\" 1067717a48c7cSmrg 106785f5b92ffSmrg func_len " $cmds" 106795f5b92ffSmrg len=$func_len_result 106805f5b92ffSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 106815f5b92ffSmrg cmds=$old_archive_cmds 106820dd80ee0Smrg elif test -n "$archiver_list_spec"; then 106830dd80ee0Smrg func_verbose "using command file archive linking..." 106840dd80ee0Smrg for obj in $oldobjs 106850dd80ee0Smrg do 106860dd80ee0Smrg func_to_tool_file "$obj" 106870dd80ee0Smrg $ECHO "$func_to_tool_file_result" 106880dd80ee0Smrg done > $output_objdir/$libname.libcmd 106890dd80ee0Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 106900dd80ee0Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 106910dd80ee0Smrg cmds=$old_archive_cmds 106925f5b92ffSmrg else 106935f5b92ffSmrg # the command line is too long to link in one step, link in parts 106945f5b92ffSmrg func_verbose "using piecewise archive linking..." 106955f5b92ffSmrg save_RANLIB=$RANLIB 106965f5b92ffSmrg RANLIB=: 106975f5b92ffSmrg objlist= 106985f5b92ffSmrg concat_cmds= 106995f5b92ffSmrg save_oldobjs=$oldobjs 107005f5b92ffSmrg oldobjs= 107015f5b92ffSmrg # Is there a better way of finding the last object in the list? 107025f5b92ffSmrg for obj in $save_oldobjs 107035f5b92ffSmrg do 107045f5b92ffSmrg last_oldobj=$obj 107055f5b92ffSmrg done 107065f5b92ffSmrg eval test_cmds=\"$old_archive_cmds\" 107075f5b92ffSmrg func_len " $test_cmds" 107085f5b92ffSmrg len0=$func_len_result 107095f5b92ffSmrg len=$len0 107105f5b92ffSmrg for obj in $save_oldobjs 107115f5b92ffSmrg do 107125f5b92ffSmrg func_len " $obj" 107135f5b92ffSmrg func_arith $len + $func_len_result 107145f5b92ffSmrg len=$func_arith_result 107155f5b92ffSmrg func_append objlist " $obj" 107165f5b92ffSmrg if test "$len" -lt "$max_cmd_len"; then 107175f5b92ffSmrg : 107185f5b92ffSmrg else 107195f5b92ffSmrg # the above command should be used before it gets too long 107205f5b92ffSmrg oldobjs=$objlist 1072136e956c5Smrg if test "$obj" = "$last_oldobj"; then 107225f5b92ffSmrg RANLIB=$save_RANLIB 107235f5b92ffSmrg fi 107245f5b92ffSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1072536e956c5Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 107265f5b92ffSmrg objlist= 107275f5b92ffSmrg len=$len0 107285f5b92ffSmrg fi 107295f5b92ffSmrg done 107305f5b92ffSmrg RANLIB=$save_RANLIB 107315f5b92ffSmrg oldobjs=$objlist 1073236e956c5Smrg if test -z "$oldobjs"; then 107335f5b92ffSmrg eval cmds=\"\$concat_cmds\" 107345f5b92ffSmrg else 107355f5b92ffSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 107365f5b92ffSmrg fi 107375f5b92ffSmrg fi 107385f5b92ffSmrg fi 107395f5b92ffSmrg func_execute_cmds "$cmds" 'exit $?' 1074017a48c7cSmrg done 1074117a48c7cSmrg 107425f5b92ffSmrg test -n "$generated" && \ 107435f5b92ffSmrg func_show_eval "${RM}r$generated" 1074417a48c7cSmrg 107455f5b92ffSmrg # Now create the libtool archive. 107465f5b92ffSmrg case $output in 107475f5b92ffSmrg *.la) 107485f5b92ffSmrg old_library= 1074936e956c5Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 107505f5b92ffSmrg func_verbose "creating $output" 1075117a48c7cSmrg 107525f5b92ffSmrg # Preserve any variables that may affect compiler behavior 107535f5b92ffSmrg for var in $variables_saved_for_relink; do 107545f5b92ffSmrg if eval test -z \"\${$var+set}\"; then 107555f5b92ffSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107565f5b92ffSmrg elif eval var_value=\$$var; test -z "$var_value"; then 107575f5b92ffSmrg relink_command="$var=; export $var; $relink_command" 1075817a48c7cSmrg else 107595f5b92ffSmrg func_quote_for_eval "$var_value" 107605f5b92ffSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1076117a48c7cSmrg fi 107625f5b92ffSmrg done 107635f5b92ffSmrg # Quote the link command for shipping. 1076436e956c5Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 107650dd80ee0Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1076636e956c5Smrg if test yes = "$hardcode_automatic"; then 107675f5b92ffSmrg relink_command= 107685f5b92ffSmrg fi 1076917a48c7cSmrg 107705f5b92ffSmrg # Only create the output if not a dry run. 107715f5b92ffSmrg $opt_dry_run || { 107725f5b92ffSmrg for installed in no yes; do 1077336e956c5Smrg if test yes = "$installed"; then 107745f5b92ffSmrg if test -z "$install_libdir"; then 107755f5b92ffSmrg break 107765f5b92ffSmrg fi 1077736e956c5Smrg output=$output_objdir/${outputname}i 107785f5b92ffSmrg # Replace all uninstalled libtool libraries with the installed ones 107795f5b92ffSmrg newdependency_libs= 107805f5b92ffSmrg for deplib in $dependency_libs; do 107815f5b92ffSmrg case $deplib in 107825f5b92ffSmrg *.la) 107835f5b92ffSmrg func_basename "$deplib" 1078436e956c5Smrg name=$func_basename_result 107850dd80ee0Smrg func_resolve_sysroot "$deplib" 1078636e956c5Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 107875f5b92ffSmrg test -z "$libdir" && \ 1078836e956c5Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 107890dd80ee0Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 107900dd80ee0Smrg ;; 107910dd80ee0Smrg -L*) 107920dd80ee0Smrg func_stripname -L '' "$deplib" 107930dd80ee0Smrg func_replace_sysroot "$func_stripname_result" 107940dd80ee0Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 107955f5b92ffSmrg ;; 107960dd80ee0Smrg -R*) 107970dd80ee0Smrg func_stripname -R '' "$deplib" 107980dd80ee0Smrg func_replace_sysroot "$func_stripname_result" 107990dd80ee0Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 108000dd80ee0Smrg ;; 108010dd80ee0Smrg *) func_append newdependency_libs " $deplib" ;; 108025f5b92ffSmrg esac 108035f5b92ffSmrg done 1080436e956c5Smrg dependency_libs=$newdependency_libs 108055f5b92ffSmrg newdlfiles= 108065f5b92ffSmrg 108075f5b92ffSmrg for lib in $dlfiles; do 108085f5b92ffSmrg case $lib in 108095f5b92ffSmrg *.la) 108105f5b92ffSmrg func_basename "$lib" 1081136e956c5Smrg name=$func_basename_result 1081236e956c5Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108135f5b92ffSmrg test -z "$libdir" && \ 1081436e956c5Smrg func_fatal_error "'$lib' is not a valid libtool archive" 108150dd80ee0Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 108165f5b92ffSmrg ;; 108170dd80ee0Smrg *) func_append newdlfiles " $lib" ;; 108185f5b92ffSmrg esac 108195f5b92ffSmrg done 1082036e956c5Smrg dlfiles=$newdlfiles 108215f5b92ffSmrg newdlprefiles= 108225f5b92ffSmrg for lib in $dlprefiles; do 108235f5b92ffSmrg case $lib in 108245f5b92ffSmrg *.la) 108255f5b92ffSmrg # Only pass preopened files to the pseudo-archive (for 108265f5b92ffSmrg # eventual linking with the app. that links it) if we 108275f5b92ffSmrg # didn't already link the preopened objects directly into 108285f5b92ffSmrg # the library: 108295f5b92ffSmrg func_basename "$lib" 1083036e956c5Smrg name=$func_basename_result 1083136e956c5Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108325f5b92ffSmrg test -z "$libdir" && \ 1083336e956c5Smrg func_fatal_error "'$lib' is not a valid libtool archive" 108340dd80ee0Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 108355f5b92ffSmrg ;; 108365f5b92ffSmrg esac 108375f5b92ffSmrg done 1083836e956c5Smrg dlprefiles=$newdlprefiles 108395f5b92ffSmrg else 108405f5b92ffSmrg newdlfiles= 108415f5b92ffSmrg for lib in $dlfiles; do 108425f5b92ffSmrg case $lib in 1084336e956c5Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108445f5b92ffSmrg *) abs=`pwd`"/$lib" ;; 108455f5b92ffSmrg esac 108460dd80ee0Smrg func_append newdlfiles " $abs" 108475f5b92ffSmrg done 1084836e956c5Smrg dlfiles=$newdlfiles 108495f5b92ffSmrg newdlprefiles= 108505f5b92ffSmrg for lib in $dlprefiles; do 108515f5b92ffSmrg case $lib in 1085236e956c5Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108535f5b92ffSmrg *) abs=`pwd`"/$lib" ;; 108545f5b92ffSmrg esac 108550dd80ee0Smrg func_append newdlprefiles " $abs" 108565f5b92ffSmrg done 1085736e956c5Smrg dlprefiles=$newdlprefiles 108585f5b92ffSmrg fi 108595f5b92ffSmrg $RM $output 108605f5b92ffSmrg # place dlname in correct position for cygwin 108610dd80ee0Smrg # In fact, it would be nice if we could use this code for all target 108620dd80ee0Smrg # systems that can't hard-code library paths into their executables 108630dd80ee0Smrg # and that have no shared library path variable independent of PATH, 108640dd80ee0Smrg # but it turns out we can't easily determine that from inspecting 108650dd80ee0Smrg # libtool variables, so we have to hard-code the OSs to which it 108660dd80ee0Smrg # applies here; at the moment, that means platforms that use the PE 108670dd80ee0Smrg # object format with DLL files. See the long comment at the top of 108680dd80ee0Smrg # tests/bindir.at for full details. 108695f5b92ffSmrg tdlname=$dlname 108705f5b92ffSmrg case $host,$output,$installed,$module,$dlname in 108710dd80ee0Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 108720dd80ee0Smrg # If a -bindir argument was supplied, place the dll there. 1087336e956c5Smrg if test -n "$bindir"; then 108740dd80ee0Smrg func_relative_path "$install_libdir" "$bindir" 1087536e956c5Smrg tdlname=$func_relative_path_result/$dlname 108760dd80ee0Smrg else 108770dd80ee0Smrg # Otherwise fall back on heuristic. 108780dd80ee0Smrg tdlname=../bin/$dlname 108790dd80ee0Smrg fi 108800dd80ee0Smrg ;; 108815f5b92ffSmrg esac 108825f5b92ffSmrg $ECHO > $output "\ 108835f5b92ffSmrg# $outputname - a libtool library file 1088436e956c5Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 108855f5b92ffSmrg# 108865f5b92ffSmrg# Please DO NOT delete this file! 108875f5b92ffSmrg# It is necessary for linking the library. 1088817a48c7cSmrg 108895f5b92ffSmrg# The name that we can dlopen(3). 108905f5b92ffSmrgdlname='$tdlname' 1089117a48c7cSmrg 108925f5b92ffSmrg# Names of this library. 108935f5b92ffSmrglibrary_names='$library_names' 1089417a48c7cSmrg 108955f5b92ffSmrg# The name of the static archive. 108965f5b92ffSmrgold_library='$old_library' 1089717a48c7cSmrg 1089836e956c5Smrg# Linker flags that cannot go in dependency_libs. 108995f5b92ffSmrginherited_linker_flags='$new_inherited_linker_flags' 1090017a48c7cSmrg 109015f5b92ffSmrg# Libraries that this one depends upon. 109025f5b92ffSmrgdependency_libs='$dependency_libs' 1090317a48c7cSmrg 109045f5b92ffSmrg# Names of additional weak libraries provided by this library 109055f5b92ffSmrgweak_library_names='$weak_libs' 1090617a48c7cSmrg 109075f5b92ffSmrg# Version information for $libname. 109085f5b92ffSmrgcurrent=$current 109095f5b92ffSmrgage=$age 109105f5b92ffSmrgrevision=$revision 1091117a48c7cSmrg 109125f5b92ffSmrg# Is this an already installed library? 109135f5b92ffSmrginstalled=$installed 1091417a48c7cSmrg 109155f5b92ffSmrg# Should we warn about portability when linking against -modules? 109165f5b92ffSmrgshouldnotlink=$module 1091717a48c7cSmrg 109185f5b92ffSmrg# Files to dlopen/dlpreopen 109195f5b92ffSmrgdlopen='$dlfiles' 109205f5b92ffSmrgdlpreopen='$dlprefiles' 1092117a48c7cSmrg 109225f5b92ffSmrg# Directory that this library needs to be installed in: 109235f5b92ffSmrglibdir='$install_libdir'" 1092436e956c5Smrg if test no,yes = "$installed,$need_relink"; then 109255f5b92ffSmrg $ECHO >> $output "\ 109265f5b92ffSmrgrelink_command=\"$relink_command\"" 109275f5b92ffSmrg fi 109285f5b92ffSmrg done 109295f5b92ffSmrg } 1093017a48c7cSmrg 109315f5b92ffSmrg # Do a symbolic link so that the libtool archive can be found in 109325f5b92ffSmrg # LD_LIBRARY_PATH before the program is installed. 109335f5b92ffSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 109345f5b92ffSmrg ;; 109355f5b92ffSmrg esac 109365f5b92ffSmrg exit $EXIT_SUCCESS 109375f5b92ffSmrg} 1093817a48c7cSmrg 1093936e956c5Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1094036e956c5Smrg func_mode_link ${1+"$@"} 1094136e956c5Smrgfi 109428e0ed500Smrg 1094317a48c7cSmrg 109445f5b92ffSmrg# func_mode_uninstall arg... 109455f5b92ffSmrgfunc_mode_uninstall () 109465f5b92ffSmrg{ 1094736e956c5Smrg $debug_cmd 1094836e956c5Smrg 1094936e956c5Smrg RM=$nonopt 1095017a48c7cSmrg files= 1095136e956c5Smrg rmforce=false 1095217a48c7cSmrg exit_status=0 1095317a48c7cSmrg 1095417a48c7cSmrg # This variable tells wrapper scripts just to set variables rather 1095517a48c7cSmrg # than running their programs. 1095636e956c5Smrg libtool_install_magic=$magic 1095717a48c7cSmrg 1095817a48c7cSmrg for arg 1095917a48c7cSmrg do 1096017a48c7cSmrg case $arg in 1096136e956c5Smrg -f) func_append RM " $arg"; rmforce=: ;; 109620dd80ee0Smrg -*) func_append RM " $arg" ;; 109630dd80ee0Smrg *) func_append files " $arg" ;; 1096417a48c7cSmrg esac 1096517a48c7cSmrg done 1096617a48c7cSmrg 109675f5b92ffSmrg test -z "$RM" && \ 109685f5b92ffSmrg func_fatal_help "you must specify an RM program" 1096917a48c7cSmrg 1097017a48c7cSmrg rmdirs= 1097117a48c7cSmrg 1097217a48c7cSmrg for file in $files; do 109735f5b92ffSmrg func_dirname "$file" "" "." 1097436e956c5Smrg dir=$func_dirname_result 1097536e956c5Smrg if test . = "$dir"; then 1097636e956c5Smrg odir=$objdir 1097717a48c7cSmrg else 1097836e956c5Smrg odir=$dir/$objdir 1097917a48c7cSmrg fi 109805f5b92ffSmrg func_basename "$file" 1098136e956c5Smrg name=$func_basename_result 1098236e956c5Smrg test uninstall = "$opt_mode" && odir=$dir 1098317a48c7cSmrg 109840dd80ee0Smrg # Remember odir for removal later, being careful to avoid duplicates 1098536e956c5Smrg if test clean = "$opt_mode"; then 1098617a48c7cSmrg case " $rmdirs " in 109870dd80ee0Smrg *" $odir "*) ;; 109880dd80ee0Smrg *) func_append rmdirs " $odir" ;; 1098917a48c7cSmrg esac 1099017a48c7cSmrg fi 1099117a48c7cSmrg 1099217a48c7cSmrg # Don't error if the file doesn't exist and rm -f was used. 109935f5b92ffSmrg if { test -L "$file"; } >/dev/null 2>&1 || 109945f5b92ffSmrg { test -h "$file"; } >/dev/null 2>&1 || 109955f5b92ffSmrg test -f "$file"; then 1099617a48c7cSmrg : 1099717a48c7cSmrg elif test -d "$file"; then 1099817a48c7cSmrg exit_status=1 1099917a48c7cSmrg continue 1100036e956c5Smrg elif $rmforce; then 1100117a48c7cSmrg continue 1100217a48c7cSmrg fi 1100317a48c7cSmrg 1100436e956c5Smrg rmfiles=$file 1100517a48c7cSmrg 1100617a48c7cSmrg case $name in 1100717a48c7cSmrg *.la) 1100817a48c7cSmrg # Possibly a libtool archive, so verify it. 110095f5b92ffSmrg if func_lalib_p "$file"; then 110105f5b92ffSmrg func_source $dir/$name 1101117a48c7cSmrg 1101217a48c7cSmrg # Delete the libtool libraries and symlinks. 1101317a48c7cSmrg for n in $library_names; do 110140dd80ee0Smrg func_append rmfiles " $odir/$n" 1101517a48c7cSmrg done 110160dd80ee0Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1101717a48c7cSmrg 1101836e956c5Smrg case $opt_mode in 1101917a48c7cSmrg clean) 110200dd80ee0Smrg case " $library_names " in 1102117a48c7cSmrg *" $dlname "*) ;; 110220dd80ee0Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1102317a48c7cSmrg esac 110240dd80ee0Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1102517a48c7cSmrg ;; 1102617a48c7cSmrg uninstall) 1102717a48c7cSmrg if test -n "$library_names"; then 1102817a48c7cSmrg # Do each command in the postuninstall commands. 1102936e956c5Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1103017a48c7cSmrg fi 1103117a48c7cSmrg 1103217a48c7cSmrg if test -n "$old_library"; then 1103317a48c7cSmrg # Do each command in the old_postuninstall commands. 1103436e956c5Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1103517a48c7cSmrg fi 1103617a48c7cSmrg # FIXME: should reinstall the best remaining shared library. 1103717a48c7cSmrg ;; 1103817a48c7cSmrg esac 1103917a48c7cSmrg fi 1104017a48c7cSmrg ;; 1104117a48c7cSmrg 1104217a48c7cSmrg *.lo) 1104317a48c7cSmrg # Possibly a libtool object, so verify it. 110445f5b92ffSmrg if func_lalib_p "$file"; then 1104517a48c7cSmrg 1104617a48c7cSmrg # Read the .lo file 110475f5b92ffSmrg func_source $dir/$name 1104817a48c7cSmrg 1104917a48c7cSmrg # Add PIC object to the list of files to remove. 1105036e956c5Smrg if test -n "$pic_object" && test none != "$pic_object"; then 110510dd80ee0Smrg func_append rmfiles " $dir/$pic_object" 1105217a48c7cSmrg fi 1105317a48c7cSmrg 1105417a48c7cSmrg # Add non-PIC object to the list of files to remove. 1105536e956c5Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 110560dd80ee0Smrg func_append rmfiles " $dir/$non_pic_object" 1105717a48c7cSmrg fi 1105817a48c7cSmrg fi 1105917a48c7cSmrg ;; 1106017a48c7cSmrg 1106117a48c7cSmrg *) 1106236e956c5Smrg if test clean = "$opt_mode"; then 1106317a48c7cSmrg noexename=$name 1106417a48c7cSmrg case $file in 1106517a48c7cSmrg *.exe) 110665f5b92ffSmrg func_stripname '' '.exe' "$file" 110675f5b92ffSmrg file=$func_stripname_result 110685f5b92ffSmrg func_stripname '' '.exe' "$name" 110695f5b92ffSmrg noexename=$func_stripname_result 1107017a48c7cSmrg # $file with .exe has already been added to rmfiles, 1107117a48c7cSmrg # add $file without .exe 110720dd80ee0Smrg func_append rmfiles " $file" 1107317a48c7cSmrg ;; 1107417a48c7cSmrg esac 1107517a48c7cSmrg # Do a test to see if this is a libtool program. 110765f5b92ffSmrg if func_ltwrapper_p "$file"; then 110775f5b92ffSmrg if func_ltwrapper_executable_p "$file"; then 110785f5b92ffSmrg func_ltwrapper_scriptname "$file" 110795f5b92ffSmrg relink_command= 110805f5b92ffSmrg func_source $func_ltwrapper_scriptname_result 110810dd80ee0Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 110825f5b92ffSmrg else 110835f5b92ffSmrg relink_command= 110845f5b92ffSmrg func_source $dir/$noexename 110855f5b92ffSmrg fi 1108617a48c7cSmrg 1108717a48c7cSmrg # note $name still contains .exe if it was in $file originally 1108817a48c7cSmrg # as does the version of $file that was added into $rmfiles 1108936e956c5Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1109036e956c5Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 110910dd80ee0Smrg func_append rmfiles " $odir/lt-$name" 1109217a48c7cSmrg fi 1109336e956c5Smrg if test "X$noexename" != "X$name"; then 1109436e956c5Smrg func_append rmfiles " $odir/lt-$noexename.c" 1109517a48c7cSmrg fi 1109617a48c7cSmrg fi 1109717a48c7cSmrg fi 1109817a48c7cSmrg ;; 1109917a48c7cSmrg esac 111005f5b92ffSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1110117a48c7cSmrg done 1110217a48c7cSmrg 1110336e956c5Smrg # Try to remove the $objdir's in the directories where we deleted files 1110417a48c7cSmrg for dir in $rmdirs; do 1110517a48c7cSmrg if test -d "$dir"; then 111065f5b92ffSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1110717a48c7cSmrg fi 1110817a48c7cSmrg done 1110917a48c7cSmrg 1111017a48c7cSmrg exit $exit_status 111115f5b92ffSmrg} 1111217a48c7cSmrg 1111336e956c5Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1111436e956c5Smrg func_mode_uninstall ${1+"$@"} 1111536e956c5Smrgfi 1111617a48c7cSmrg 111170dd80ee0Smrgtest -z "$opt_mode" && { 1111836e956c5Smrg help=$generic_help 111195f5b92ffSmrg func_fatal_help "you must specify a MODE" 111205f5b92ffSmrg} 111215f5b92ffSmrg 111225f5b92ffSmrgtest -z "$exec_cmd" && \ 1112336e956c5Smrg func_fatal_help "invalid operation mode '$opt_mode'" 1112417a48c7cSmrg 1112517a48c7cSmrgif test -n "$exec_cmd"; then 111265f5b92ffSmrg eval exec "$exec_cmd" 1112717a48c7cSmrg exit $EXIT_FAILURE 1112817a48c7cSmrgfi 1112917a48c7cSmrg 111305f5b92ffSmrgexit $exit_status 1113117a48c7cSmrg 1113217a48c7cSmrg 1113317a48c7cSmrg# The TAGs below are defined such that we never get into a situation 1113436e956c5Smrg# where we disable both kinds of libraries. Given conflicting 1113517a48c7cSmrg# choices, we go for a static library, that is the most portable, 1113617a48c7cSmrg# since we can't tell whether shared libraries were disabled because 1113717a48c7cSmrg# the user asked for that or because the platform doesn't support 1113817a48c7cSmrg# them. This is particularly important on AIX, because we don't 1113917a48c7cSmrg# support having both static and shared libraries enabled at the same 1114017a48c7cSmrg# time on that platform, so we default to a shared-only configuration. 1114117a48c7cSmrg# If a disable-shared tag is given, we'll fallback to a static-only 1114217a48c7cSmrg# configuration. But we'll never go from static-only to shared-only. 1114317a48c7cSmrg 1114417a48c7cSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 111455f5b92ffSmrgbuild_libtool_libs=no 111465f5b92ffSmrgbuild_old_libs=yes 1114717a48c7cSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 1114817a48c7cSmrg 1114917a48c7cSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 111505f5b92ffSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1115117a48c7cSmrg# ### END LIBTOOL TAG CONFIG: disable-static 1115217a48c7cSmrg 1115317a48c7cSmrg# Local Variables: 1115417a48c7cSmrg# mode:shell-script 1115517a48c7cSmrg# sh-indentation:2 1115617a48c7cSmrg# End: 11157