ltmain.sh revision 16ee1e9a
116ee1e9aSmrg#! /bin/sh 216ee1e9aSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 316ee1e9aSmrg## by inline-source v2014-01-03.01 4fda9279dSmrg 516ee1e9aSmrg# libtool (GNU libtool) 2.4.6 616ee1e9aSmrg# Provide generalized library-building support services. 7fda9279dSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8fda9279dSmrg 916ee1e9aSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10fda9279dSmrg# This is free software; see the source for copying conditions. There is NO 11fda9279dSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12fda9279dSmrg 13fda9279dSmrg# GNU Libtool is free software; you can redistribute it and/or modify 14fda9279dSmrg# it under the terms of the GNU General Public License as published by 15fda9279dSmrg# the Free Software Foundation; either version 2 of the License, or 16fda9279dSmrg# (at your option) any later version. 17fda9279dSmrg# 18fda9279dSmrg# As a special exception to the GNU General Public License, 19fda9279dSmrg# if you distribute this file as part of a program or library that 20fda9279dSmrg# is built using GNU Libtool, you may include this file under the 21fda9279dSmrg# same distribution terms that you use for the rest of that program. 22fda9279dSmrg# 23fda9279dSmrg# GNU Libtool is distributed in the hope that it will be useful, but 24fda9279dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25fda9279dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26fda9279dSmrg# General Public License for more details. 27fda9279dSmrg# 28fda9279dSmrg# You should have received a copy of the GNU General Public License 2916ee1e9aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30fda9279dSmrg 31fda9279dSmrg 32fda9279dSmrgPROGRAM=libtool 33fda9279dSmrgPACKAGE=libtool 3416ee1e9aSmrgVERSION=2.4.6 3516ee1e9aSmrgpackage_revision=2.4.6 36fda9279dSmrg 3716ee1e9aSmrg 3816ee1e9aSmrg## ------ ## 3916ee1e9aSmrg## Usage. ## 4016ee1e9aSmrg## ------ ## 4116ee1e9aSmrg 4216ee1e9aSmrg# Run './libtool --help' for help with using this script from the 4316ee1e9aSmrg# command line. 4416ee1e9aSmrg 4516ee1e9aSmrg 4616ee1e9aSmrg## ------------------------------- ## 4716ee1e9aSmrg## User overridable command paths. ## 4816ee1e9aSmrg## ------------------------------- ## 4916ee1e9aSmrg 5016ee1e9aSmrg# After configure completes, it has a better idea of some of the 5116ee1e9aSmrg# shell tools we need than the defaults used by the functions shared 5216ee1e9aSmrg# with bootstrap, so set those here where they can still be over- 5316ee1e9aSmrg# ridden by the user, but otherwise take precedence. 5416ee1e9aSmrg 5516ee1e9aSmrg: ${AUTOCONF="autoconf"} 5616ee1e9aSmrg: ${AUTOMAKE="automake"} 5716ee1e9aSmrg 5816ee1e9aSmrg 5916ee1e9aSmrg## -------------------------- ## 6016ee1e9aSmrg## Source external libraries. ## 6116ee1e9aSmrg## -------------------------- ## 6216ee1e9aSmrg 6316ee1e9aSmrg# Much of our low-level functionality needs to be sourced from external 6416ee1e9aSmrg# libraries, which are installed to $pkgauxdir. 6516ee1e9aSmrg 6616ee1e9aSmrg# Set a version string for this script. 6716ee1e9aSmrgscriptversion=2015-01-20.17; # UTC 6816ee1e9aSmrg 6916ee1e9aSmrg# General shell script boiler plate, and helper functions. 7016ee1e9aSmrg# Written by Gary V. Vaughan, 2004 7116ee1e9aSmrg 7216ee1e9aSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7316ee1e9aSmrg# This is free software; see the source for copying conditions. There is NO 7416ee1e9aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7516ee1e9aSmrg 7616ee1e9aSmrg# This program is free software; you can redistribute it and/or modify 7716ee1e9aSmrg# it under the terms of the GNU General Public License as published by 7816ee1e9aSmrg# the Free Software Foundation; either version 3 of the License, or 7916ee1e9aSmrg# (at your option) any later version. 8016ee1e9aSmrg 8116ee1e9aSmrg# As a special exception to the GNU General Public License, if you distribute 8216ee1e9aSmrg# this file as part of a program or library that is built using GNU Libtool, 8316ee1e9aSmrg# you may include this file under the same distribution terms that you use 8416ee1e9aSmrg# for the rest of that program. 8516ee1e9aSmrg 8616ee1e9aSmrg# This program is distributed in the hope that it will be useful, 8716ee1e9aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8816ee1e9aSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8916ee1e9aSmrg# General Public License for more details. 9016ee1e9aSmrg 9116ee1e9aSmrg# You should have received a copy of the GNU General Public License 9216ee1e9aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9316ee1e9aSmrg 9416ee1e9aSmrg# Please report bugs or propose patches to gary@gnu.org. 9516ee1e9aSmrg 9616ee1e9aSmrg 9716ee1e9aSmrg## ------ ## 9816ee1e9aSmrg## Usage. ## 9916ee1e9aSmrg## ------ ## 10016ee1e9aSmrg 10116ee1e9aSmrg# Evaluate this file near the top of your script to gain access to 10216ee1e9aSmrg# the functions and variables defined here: 10316ee1e9aSmrg# 10416ee1e9aSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10516ee1e9aSmrg# 10616ee1e9aSmrg# If you need to override any of the default environment variable 10716ee1e9aSmrg# settings, do that before evaluating this file. 10816ee1e9aSmrg 10916ee1e9aSmrg 11016ee1e9aSmrg## -------------------- ## 11116ee1e9aSmrg## Shell normalisation. ## 11216ee1e9aSmrg## -------------------- ## 11316ee1e9aSmrg 11416ee1e9aSmrg# Some shells need a little help to be as Bourne compatible as possible. 11516ee1e9aSmrg# Before doing anything else, make sure all that help has been provided! 11616ee1e9aSmrg 11716ee1e9aSmrgDUALCASE=1; export DUALCASE # for MKS sh 11816ee1e9aSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119fda9279dSmrg emulate sh 120fda9279dSmrg NULLCMD=: 12116ee1e9aSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122fda9279dSmrg # is contrary to our usage. Disable this feature. 123fda9279dSmrg alias -g '${1+"$@"}'='"$@"' 124fda9279dSmrg setopt NO_GLOB_SUBST 125fda9279dSmrgelse 12616ee1e9aSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127fda9279dSmrgfi 128fda9279dSmrg 12916ee1e9aSmrg# NLS nuisances: We save the old values in case they are required later. 13016ee1e9aSmrg_G_user_locale= 13116ee1e9aSmrg_G_safe_locale= 13216ee1e9aSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133fda9279dSmrgdo 13416ee1e9aSmrg eval "if test set = \"\${$_G_var+set}\"; then 13516ee1e9aSmrg save_$_G_var=\$$_G_var 13616ee1e9aSmrg $_G_var=C 13716ee1e9aSmrg export $_G_var 13816ee1e9aSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13916ee1e9aSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140fda9279dSmrg fi" 141fda9279dSmrgdone 142fda9279dSmrg 14316ee1e9aSmrg# CDPATH. 14416ee1e9aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145fda9279dSmrg 14616ee1e9aSmrg# Make sure IFS has a sensible default 14716ee1e9aSmrgsp=' ' 14816ee1e9aSmrgnl=' 14916ee1e9aSmrg' 15016ee1e9aSmrgIFS="$sp $nl" 15116ee1e9aSmrg 15216ee1e9aSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 15316ee1e9aSmrgif test "${PATH_SEPARATOR+set}" != set; then 15416ee1e9aSmrg PATH_SEPARATOR=: 15516ee1e9aSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15616ee1e9aSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15716ee1e9aSmrg PATH_SEPARATOR=';' 15816ee1e9aSmrg } 15916ee1e9aSmrgfi 160fda9279dSmrg 161fda9279dSmrg 162fda9279dSmrg 16316ee1e9aSmrg## ------------------------- ## 16416ee1e9aSmrg## Locate command utilities. ## 16516ee1e9aSmrg## ------------------------- ## 16616ee1e9aSmrg 16716ee1e9aSmrg 16816ee1e9aSmrg# func_executable_p FILE 16916ee1e9aSmrg# ---------------------- 17016ee1e9aSmrg# Check that FILE is an executable regular file. 17116ee1e9aSmrgfunc_executable_p () 17216ee1e9aSmrg{ 17316ee1e9aSmrg test -f "$1" && test -x "$1" 17416ee1e9aSmrg} 17516ee1e9aSmrg 17616ee1e9aSmrg 17716ee1e9aSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17816ee1e9aSmrg# -------------------------------------------- 17916ee1e9aSmrg# Search for either a program that responds to --version with output 18016ee1e9aSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18116ee1e9aSmrg# trying all the directories in PATH with each of the elements of 18216ee1e9aSmrg# PROGS_LIST. 18316ee1e9aSmrg# 18416ee1e9aSmrg# CHECK_FUNC should accept the path to a candidate program, and 18516ee1e9aSmrg# set $func_check_prog_result if it truncates its output less than 18616ee1e9aSmrg# $_G_path_prog_max characters. 18716ee1e9aSmrgfunc_path_progs () 18816ee1e9aSmrg{ 18916ee1e9aSmrg _G_progs_list=$1 19016ee1e9aSmrg _G_check_func=$2 19116ee1e9aSmrg _G_PATH=${3-"$PATH"} 19216ee1e9aSmrg 19316ee1e9aSmrg _G_path_prog_max=0 19416ee1e9aSmrg _G_path_prog_found=false 19516ee1e9aSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19616ee1e9aSmrg for _G_dir in $_G_PATH; do 19716ee1e9aSmrg IFS=$_G_save_IFS 19816ee1e9aSmrg test -z "$_G_dir" && _G_dir=. 19916ee1e9aSmrg for _G_prog_name in $_G_progs_list; do 20016ee1e9aSmrg for _exeext in '' .EXE; do 20116ee1e9aSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20216ee1e9aSmrg func_executable_p "$_G_path_prog" || continue 20316ee1e9aSmrg case `"$_G_path_prog" --version 2>&1` in 20416ee1e9aSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20516ee1e9aSmrg *) $_G_check_func $_G_path_prog 20616ee1e9aSmrg func_path_progs_result=$func_check_prog_result 20716ee1e9aSmrg ;; 20816ee1e9aSmrg esac 20916ee1e9aSmrg $_G_path_prog_found && break 3 21016ee1e9aSmrg done 21116ee1e9aSmrg done 21216ee1e9aSmrg done 21316ee1e9aSmrg IFS=$_G_save_IFS 21416ee1e9aSmrg test -z "$func_path_progs_result" && { 21516ee1e9aSmrg echo "no acceptable sed could be found in \$PATH" >&2 21616ee1e9aSmrg exit 1 21716ee1e9aSmrg } 21816ee1e9aSmrg} 21916ee1e9aSmrg 22016ee1e9aSmrg 22116ee1e9aSmrg# We want to be able to use the functions in this file before configure 22216ee1e9aSmrg# has figured out where the best binaries are kept, which means we have 22316ee1e9aSmrg# to search for them ourselves - except when the results are already set 22416ee1e9aSmrg# where we skip the searches. 22516ee1e9aSmrg 22616ee1e9aSmrg# Unless the user overrides by setting SED, search the path for either GNU 22716ee1e9aSmrg# sed, or the sed that truncates its output the least. 22816ee1e9aSmrgtest -z "$SED" && { 22916ee1e9aSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23016ee1e9aSmrg for _G_i in 1 2 3 4 5 6 7; do 23116ee1e9aSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23216ee1e9aSmrg done 23316ee1e9aSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23416ee1e9aSmrg _G_sed_script= 23516ee1e9aSmrg 23616ee1e9aSmrg func_check_prog_sed () 23716ee1e9aSmrg { 23816ee1e9aSmrg _G_path_prog=$1 23916ee1e9aSmrg 24016ee1e9aSmrg _G_count=0 24116ee1e9aSmrg printf 0123456789 >conftest.in 24216ee1e9aSmrg while : 24316ee1e9aSmrg do 24416ee1e9aSmrg cat conftest.in conftest.in >conftest.tmp 24516ee1e9aSmrg mv conftest.tmp conftest.in 24616ee1e9aSmrg cp conftest.in conftest.nl 24716ee1e9aSmrg echo '' >> conftest.nl 24816ee1e9aSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24916ee1e9aSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25016ee1e9aSmrg _G_count=`expr $_G_count + 1` 25116ee1e9aSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25216ee1e9aSmrg # Best one so far, save it but keep looking for a better one 25316ee1e9aSmrg func_check_prog_result=$_G_path_prog 25416ee1e9aSmrg _G_path_prog_max=$_G_count 25516ee1e9aSmrg fi 25616ee1e9aSmrg # 10*(2^10) chars as input seems more than enough 25716ee1e9aSmrg test 10 -lt "$_G_count" && break 25816ee1e9aSmrg done 25916ee1e9aSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26016ee1e9aSmrg } 26116ee1e9aSmrg 26216ee1e9aSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26316ee1e9aSmrg rm -f conftest.sed 26416ee1e9aSmrg SED=$func_path_progs_result 26516ee1e9aSmrg} 26616ee1e9aSmrg 26716ee1e9aSmrg 26816ee1e9aSmrg# Unless the user overrides by setting GREP, search the path for either GNU 26916ee1e9aSmrg# grep, or the grep that truncates its output the least. 27016ee1e9aSmrgtest -z "$GREP" && { 27116ee1e9aSmrg func_check_prog_grep () 27216ee1e9aSmrg { 27316ee1e9aSmrg _G_path_prog=$1 27416ee1e9aSmrg 27516ee1e9aSmrg _G_count=0 27616ee1e9aSmrg _G_path_prog_max=0 27716ee1e9aSmrg printf 0123456789 >conftest.in 27816ee1e9aSmrg while : 27916ee1e9aSmrg do 28016ee1e9aSmrg cat conftest.in conftest.in >conftest.tmp 28116ee1e9aSmrg mv conftest.tmp conftest.in 28216ee1e9aSmrg cp conftest.in conftest.nl 28316ee1e9aSmrg echo 'GREP' >> conftest.nl 28416ee1e9aSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28516ee1e9aSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28616ee1e9aSmrg _G_count=`expr $_G_count + 1` 28716ee1e9aSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28816ee1e9aSmrg # Best one so far, save it but keep looking for a better one 28916ee1e9aSmrg func_check_prog_result=$_G_path_prog 29016ee1e9aSmrg _G_path_prog_max=$_G_count 29116ee1e9aSmrg fi 29216ee1e9aSmrg # 10*(2^10) chars as input seems more than enough 29316ee1e9aSmrg test 10 -lt "$_G_count" && break 29416ee1e9aSmrg done 29516ee1e9aSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29616ee1e9aSmrg } 29716ee1e9aSmrg 29816ee1e9aSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29916ee1e9aSmrg GREP=$func_path_progs_result 30016ee1e9aSmrg} 30116ee1e9aSmrg 30216ee1e9aSmrg 30316ee1e9aSmrg## ------------------------------- ## 30416ee1e9aSmrg## User overridable command paths. ## 30516ee1e9aSmrg## ------------------------------- ## 30616ee1e9aSmrg 30716ee1e9aSmrg# All uppercase variable names are used for environment variables. These 30816ee1e9aSmrg# variables can be overridden by the user before calling a script that 30916ee1e9aSmrg# uses them if a suitable command of that name is not already available 31016ee1e9aSmrg# in the command search PATH. 311fda9279dSmrg 312fda9279dSmrg: ${CP="cp -f"} 31316ee1e9aSmrg: ${ECHO="printf %s\n"} 31416ee1e9aSmrg: ${EGREP="$GREP -E"} 31516ee1e9aSmrg: ${FGREP="$GREP -F"} 31616ee1e9aSmrg: ${LN_S="ln -s"} 317fda9279dSmrg: ${MAKE="make"} 318fda9279dSmrg: ${MKDIR="mkdir"} 319fda9279dSmrg: ${MV="mv -f"} 320fda9279dSmrg: ${RM="rm -f"} 321fda9279dSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322fda9279dSmrg 323fda9279dSmrg 32416ee1e9aSmrg## -------------------- ## 32516ee1e9aSmrg## Useful sed snippets. ## 32616ee1e9aSmrg## -------------------- ## 327fda9279dSmrg 32816ee1e9aSmrgsed_dirname='s|/[^/]*$||' 32916ee1e9aSmrgsed_basename='s|^.*/||' 330fda9279dSmrg 33116ee1e9aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 33216ee1e9aSmrg# metacharacters that are still active within double-quoted strings. 33316ee1e9aSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334fda9279dSmrg 33516ee1e9aSmrg# Same as above, but do not quote variable references. 33616ee1e9aSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337fda9279dSmrg 33816ee1e9aSmrg# Sed substitution that turns a string into a regex matching for the 33916ee1e9aSmrg# string literally. 34016ee1e9aSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341fda9279dSmrg 34216ee1e9aSmrg# Sed substitution that converts a w32 file name or path 34316ee1e9aSmrg# that contains forward slashes, into one that contains 34416ee1e9aSmrg# (escaped) backslashes. A very naive implementation. 34516ee1e9aSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34616ee1e9aSmrg 34716ee1e9aSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34816ee1e9aSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34916ee1e9aSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35016ee1e9aSmrg# expansion. Since each input '\' is now two '\'s, look for any number 35116ee1e9aSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35216ee1e9aSmrg_G_bs='\\' 35316ee1e9aSmrg_G_bs2='\\\\' 35416ee1e9aSmrg_G_bs4='\\\\\\\\' 35516ee1e9aSmrg_G_dollar='\$' 35616ee1e9aSmrgsed_double_backslash="\ 35716ee1e9aSmrg s/$_G_bs4/&\\ 35816ee1e9aSmrg/g 35916ee1e9aSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36016ee1e9aSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36116ee1e9aSmrg s/\n//g" 362fda9279dSmrg 363fda9279dSmrg 36416ee1e9aSmrg## ----------------- ## 36516ee1e9aSmrg## Global variables. ## 36616ee1e9aSmrg## ----------------- ## 367fda9279dSmrg 36816ee1e9aSmrg# Except for the global variables explicitly listed below, the following 36916ee1e9aSmrg# functions in the '^func_' namespace, and the '^require_' namespace 37016ee1e9aSmrg# variables initialised in the 'Resource management' section, sourcing 37116ee1e9aSmrg# this file will not pollute your global namespace with anything 37216ee1e9aSmrg# else. There's no portable way to scope variables in Bourne shell 37316ee1e9aSmrg# though, so actually running these functions will sometimes place 37416ee1e9aSmrg# results into a variable named after the function, and often use 37516ee1e9aSmrg# temporary variables in the '^_G_' namespace. If you are careful to 37616ee1e9aSmrg# avoid using those namespaces casually in your sourcing script, things 37716ee1e9aSmrg# should continue to work as you expect. And, of course, you can freely 37816ee1e9aSmrg# overwrite any of the functions or variables defined here before 37916ee1e9aSmrg# calling anything to customize them. 380fda9279dSmrg 38116ee1e9aSmrgEXIT_SUCCESS=0 38216ee1e9aSmrgEXIT_FAILURE=1 38316ee1e9aSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38416ee1e9aSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385fda9279dSmrg 38616ee1e9aSmrg# Allow overriding, eg assuming that you follow the convention of 38716ee1e9aSmrg# putting '$debug_cmd' at the start of all your functions, you can get 38816ee1e9aSmrg# bash to show function call trace with: 38916ee1e9aSmrg# 39016ee1e9aSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39116ee1e9aSmrgdebug_cmd=${debug_cmd-":"} 39216ee1e9aSmrgexit_cmd=: 393fda9279dSmrg 39416ee1e9aSmrg# By convention, finish your script with: 39516ee1e9aSmrg# 39616ee1e9aSmrg# exit $exit_status 39716ee1e9aSmrg# 39816ee1e9aSmrg# so that you can set exit_status to non-zero if you want to indicate 39916ee1e9aSmrg# something went wrong during execution without actually bailing out at 40016ee1e9aSmrg# the point of failure. 40116ee1e9aSmrgexit_status=$EXIT_SUCCESS 402fda9279dSmrg 40316ee1e9aSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40416ee1e9aSmrg# is ksh but when the shell is invoked as "sh" and the current value of 40516ee1e9aSmrg# the _XPG environment variable is not equal to 1 (one), the special 40616ee1e9aSmrg# positional parameter $0, within a function call, is the name of the 40716ee1e9aSmrg# function. 40816ee1e9aSmrgprogpath=$0 409fda9279dSmrg 41016ee1e9aSmrg# The name of this program. 41116ee1e9aSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412fda9279dSmrg 41316ee1e9aSmrg# Make sure we have an absolute progpath for reexecution: 414fda9279dSmrgcase $progpath in 415fda9279dSmrg [\\/]*|[A-Za-z]:\\*) ;; 416fda9279dSmrg *[\\/]*) 41716ee1e9aSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418fda9279dSmrg progdir=`cd "$progdir" && pwd` 41916ee1e9aSmrg progpath=$progdir/$progname 420fda9279dSmrg ;; 421fda9279dSmrg *) 42216ee1e9aSmrg _G_IFS=$IFS 423fda9279dSmrg IFS=${PATH_SEPARATOR-:} 424fda9279dSmrg for progdir in $PATH; do 42516ee1e9aSmrg IFS=$_G_IFS 426fda9279dSmrg test -x "$progdir/$progname" && break 427fda9279dSmrg done 42816ee1e9aSmrg IFS=$_G_IFS 429fda9279dSmrg test -n "$progdir" || progdir=`pwd` 43016ee1e9aSmrg progpath=$progdir/$progname 431fda9279dSmrg ;; 432fda9279dSmrgesac 433fda9279dSmrg 434fda9279dSmrg 43516ee1e9aSmrg## ----------------- ## 43616ee1e9aSmrg## Standard options. ## 43716ee1e9aSmrg## ----------------- ## 438fda9279dSmrg 43916ee1e9aSmrg# The following options affect the operation of the functions defined 44016ee1e9aSmrg# below, and should be set appropriately depending on run-time para- 44116ee1e9aSmrg# meters passed on the command line. 442fda9279dSmrg 443fda9279dSmrgopt_dry_run=false 444fda9279dSmrgopt_quiet=false 445fda9279dSmrgopt_verbose=false 446fda9279dSmrg 44716ee1e9aSmrg# Categories 'all' and 'none' are always available. Append any others 44816ee1e9aSmrg# you will pass as the first argument to func_warning from your own 44916ee1e9aSmrg# code. 45016ee1e9aSmrgwarning_categories= 451fda9279dSmrg 45216ee1e9aSmrg# By default, display warnings according to 'opt_warning_types'. Set 45316ee1e9aSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45416ee1e9aSmrg# treat the next displayed warning as a fatal error. 45516ee1e9aSmrgwarning_func=func_warn_and_continue 456fda9279dSmrg 45716ee1e9aSmrg# Set to 'all' to display all warnings, 'none' to suppress all 45816ee1e9aSmrg# warnings, or a space delimited list of some subset of 45916ee1e9aSmrg# 'warning_categories' to display only the listed warnings. 46016ee1e9aSmrgopt_warning_types=all 461fda9279dSmrg 462fda9279dSmrg 46316ee1e9aSmrg## -------------------- ## 46416ee1e9aSmrg## Resource management. ## 46516ee1e9aSmrg## -------------------- ## 466fda9279dSmrg 46716ee1e9aSmrg# This section contains definitions for functions that each ensure a 46816ee1e9aSmrg# particular resource (a file, or a non-empty configuration variable for 46916ee1e9aSmrg# example) is available, and if appropriate to extract default values 47016ee1e9aSmrg# from pertinent package files. Call them using their associated 47116ee1e9aSmrg# 'require_*' variable to ensure that they are executed, at most, once. 47216ee1e9aSmrg# 47316ee1e9aSmrg# It's entirely deliberate that calling these functions can set 47416ee1e9aSmrg# variables that don't obey the namespace limitations obeyed by the rest 47516ee1e9aSmrg# of this file, in order that that they be as useful as possible to 47616ee1e9aSmrg# callers. 477fda9279dSmrg 478fda9279dSmrg 47916ee1e9aSmrg# require_term_colors 48016ee1e9aSmrg# ------------------- 48116ee1e9aSmrg# Allow display of bold text on terminals that support it. 48216ee1e9aSmrgrequire_term_colors=func_require_term_colors 48316ee1e9aSmrgfunc_require_term_colors () 484fda9279dSmrg{ 48516ee1e9aSmrg $debug_cmd 48616ee1e9aSmrg 48716ee1e9aSmrg test -t 1 && { 48816ee1e9aSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 48916ee1e9aSmrg # precedence, because most terminfo databases neglect to describe 49016ee1e9aSmrg # whether color sequences are supported. 49116ee1e9aSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49216ee1e9aSmrg 49316ee1e9aSmrg if test 1 = "$USE_ANSI_COLORS"; then 49416ee1e9aSmrg # Standard ANSI escape sequences 49516ee1e9aSmrg tc_reset='[0m' 49616ee1e9aSmrg tc_bold='[1m'; tc_standout='[7m' 49716ee1e9aSmrg tc_red='[31m'; tc_green='[32m' 49816ee1e9aSmrg tc_blue='[34m'; tc_cyan='[36m' 49916ee1e9aSmrg else 50016ee1e9aSmrg # Otherwise trust the terminfo database after all. 50116ee1e9aSmrg test -n "`tput sgr0 2>/dev/null`" && { 50216ee1e9aSmrg tc_reset=`tput sgr0` 50316ee1e9aSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50416ee1e9aSmrg tc_standout=$tc_bold 50516ee1e9aSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50616ee1e9aSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50716ee1e9aSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50816ee1e9aSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50916ee1e9aSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51016ee1e9aSmrg } 51116ee1e9aSmrg fi 51216ee1e9aSmrg } 513fda9279dSmrg 51416ee1e9aSmrg require_term_colors=: 515fda9279dSmrg} 516fda9279dSmrg 517fda9279dSmrg 51816ee1e9aSmrg## ----------------- ## 51916ee1e9aSmrg## Function library. ## 52016ee1e9aSmrg## ----------------- ## 52116ee1e9aSmrg 52216ee1e9aSmrg# This section contains a variety of useful functions to call in your 52316ee1e9aSmrg# scripts. Take note of the portable wrappers for features provided by 52416ee1e9aSmrg# some modern shells, which will fall back to slower equivalents on 52516ee1e9aSmrg# less featureful shells. 52616ee1e9aSmrg 52716ee1e9aSmrg 52816ee1e9aSmrg# func_append VAR VALUE 52916ee1e9aSmrg# --------------------- 53016ee1e9aSmrg# Append VALUE onto the existing contents of VAR. 53116ee1e9aSmrg 53216ee1e9aSmrg # We should try to minimise forks, especially on Windows where they are 53316ee1e9aSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 53416ee1e9aSmrg # being used: 53516ee1e9aSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53616ee1e9aSmrg : ${_G_HAVE_ARITH_OP="yes"} 53716ee1e9aSmrg : ${_G_HAVE_XSI_OPS="yes"} 53816ee1e9aSmrg # The += operator was introduced in bash 3.1 53916ee1e9aSmrg case $BASH_VERSION in 54016ee1e9aSmrg [12].* | 3.0 | 3.0*) ;; 54116ee1e9aSmrg *) 54216ee1e9aSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54316ee1e9aSmrg ;; 54416ee1e9aSmrg esac 54516ee1e9aSmrg fi 54616ee1e9aSmrg 54716ee1e9aSmrg # _G_HAVE_PLUSEQ_OP 54816ee1e9aSmrg # Can be empty, in which case the shell is probed, "yes" if += is 54916ee1e9aSmrg # useable or anything else if it does not work. 55016ee1e9aSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55116ee1e9aSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55216ee1e9aSmrg && _G_HAVE_PLUSEQ_OP=yes 55316ee1e9aSmrg 55416ee1e9aSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55516ee1e9aSmrgthen 55616ee1e9aSmrg # This is an XSI compatible shell, allowing a faster implementation... 55716ee1e9aSmrg eval 'func_append () 55816ee1e9aSmrg { 55916ee1e9aSmrg $debug_cmd 56016ee1e9aSmrg 56116ee1e9aSmrg eval "$1+=\$2" 56216ee1e9aSmrg }' 56316ee1e9aSmrgelse 56416ee1e9aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 56516ee1e9aSmrg func_append () 56616ee1e9aSmrg { 56716ee1e9aSmrg $debug_cmd 56816ee1e9aSmrg 56916ee1e9aSmrg eval "$1=\$$1\$2" 57016ee1e9aSmrg } 57116ee1e9aSmrgfi 57216ee1e9aSmrg 57316ee1e9aSmrg 57416ee1e9aSmrg# func_append_quoted VAR VALUE 57516ee1e9aSmrg# ---------------------------- 57616ee1e9aSmrg# Quote VALUE and append to the end of shell variable VAR, separated 57716ee1e9aSmrg# by a space. 57816ee1e9aSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57916ee1e9aSmrg eval 'func_append_quoted () 58016ee1e9aSmrg { 58116ee1e9aSmrg $debug_cmd 58216ee1e9aSmrg 58316ee1e9aSmrg func_quote_for_eval "$2" 58416ee1e9aSmrg eval "$1+=\\ \$func_quote_for_eval_result" 58516ee1e9aSmrg }' 58616ee1e9aSmrgelse 58716ee1e9aSmrg func_append_quoted () 58816ee1e9aSmrg { 58916ee1e9aSmrg $debug_cmd 59016ee1e9aSmrg 59116ee1e9aSmrg func_quote_for_eval "$2" 59216ee1e9aSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59316ee1e9aSmrg } 59416ee1e9aSmrgfi 59516ee1e9aSmrg 59616ee1e9aSmrg 59716ee1e9aSmrg# func_append_uniq VAR VALUE 59816ee1e9aSmrg# -------------------------- 59916ee1e9aSmrg# Append unique VALUE onto the existing contents of VAR, assuming 60016ee1e9aSmrg# entries are delimited by the first character of VALUE. For example: 60116ee1e9aSmrg# 60216ee1e9aSmrg# func_append_uniq options " --another-option option-argument" 60316ee1e9aSmrg# 60416ee1e9aSmrg# will only append to $options if " --another-option option-argument " 60516ee1e9aSmrg# is not already present somewhere in $options already (note spaces at 60616ee1e9aSmrg# each end implied by leading space in second argument). 60716ee1e9aSmrgfunc_append_uniq () 60816ee1e9aSmrg{ 60916ee1e9aSmrg $debug_cmd 61016ee1e9aSmrg 61116ee1e9aSmrg eval _G_current_value='`$ECHO $'$1'`' 61216ee1e9aSmrg _G_delim=`expr "$2" : '\(.\)'` 61316ee1e9aSmrg 61416ee1e9aSmrg case $_G_delim$_G_current_value$_G_delim in 61516ee1e9aSmrg *"$2$_G_delim"*) ;; 61616ee1e9aSmrg *) func_append "$@" ;; 61716ee1e9aSmrg esac 61816ee1e9aSmrg} 61916ee1e9aSmrg 62016ee1e9aSmrg 62116ee1e9aSmrg# func_arith TERM... 62216ee1e9aSmrg# ------------------ 62316ee1e9aSmrg# Set func_arith_result to the result of evaluating TERMs. 62416ee1e9aSmrg test -z "$_G_HAVE_ARITH_OP" \ 62516ee1e9aSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62616ee1e9aSmrg && _G_HAVE_ARITH_OP=yes 62716ee1e9aSmrg 62816ee1e9aSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 62916ee1e9aSmrg eval 'func_arith () 63016ee1e9aSmrg { 63116ee1e9aSmrg $debug_cmd 63216ee1e9aSmrg 63316ee1e9aSmrg func_arith_result=$(( $* )) 63416ee1e9aSmrg }' 63516ee1e9aSmrgelse 63616ee1e9aSmrg func_arith () 63716ee1e9aSmrg { 63816ee1e9aSmrg $debug_cmd 63916ee1e9aSmrg 64016ee1e9aSmrg func_arith_result=`expr "$@"` 64116ee1e9aSmrg } 64216ee1e9aSmrgfi 64316ee1e9aSmrg 64416ee1e9aSmrg 64516ee1e9aSmrg# func_basename FILE 64616ee1e9aSmrg# ------------------ 64716ee1e9aSmrg# Set func_basename_result to FILE with everything up to and including 64816ee1e9aSmrg# the last / stripped. 64916ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 65016ee1e9aSmrg # If this shell supports suffix pattern removal, then use it to avoid 65116ee1e9aSmrg # forking. Hide the definitions single quotes in case the shell chokes 65216ee1e9aSmrg # on unsupported syntax... 65316ee1e9aSmrg _b='func_basename_result=${1##*/}' 65416ee1e9aSmrg _d='case $1 in 65516ee1e9aSmrg */*) func_dirname_result=${1%/*}$2 ;; 65616ee1e9aSmrg * ) func_dirname_result=$3 ;; 65716ee1e9aSmrg esac' 65816ee1e9aSmrg 65916ee1e9aSmrgelse 66016ee1e9aSmrg # ...otherwise fall back to using sed. 66116ee1e9aSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66216ee1e9aSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66316ee1e9aSmrg if test "X$func_dirname_result" = "X$1"; then 66416ee1e9aSmrg func_dirname_result=$3 66516ee1e9aSmrg else 66616ee1e9aSmrg func_append func_dirname_result "$2" 66716ee1e9aSmrg fi' 66816ee1e9aSmrgfi 66916ee1e9aSmrg 67016ee1e9aSmrgeval 'func_basename () 67116ee1e9aSmrg{ 67216ee1e9aSmrg $debug_cmd 67316ee1e9aSmrg 67416ee1e9aSmrg '"$_b"' 67516ee1e9aSmrg}' 67616ee1e9aSmrg 67716ee1e9aSmrg 67816ee1e9aSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67916ee1e9aSmrg# ------------------------------------------- 68016ee1e9aSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68116ee1e9aSmrg# otherwise set result to NONDIR_REPLACEMENT. 68216ee1e9aSmrgeval 'func_dirname () 68316ee1e9aSmrg{ 68416ee1e9aSmrg $debug_cmd 68516ee1e9aSmrg 68616ee1e9aSmrg '"$_d"' 68716ee1e9aSmrg}' 68816ee1e9aSmrg 68916ee1e9aSmrg 69016ee1e9aSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69116ee1e9aSmrg# -------------------------------------------------------- 69216ee1e9aSmrg# Perform func_basename and func_dirname in a single function 69316ee1e9aSmrg# call: 69416ee1e9aSmrg# dirname: Compute the dirname of FILE. If nonempty, 69516ee1e9aSmrg# add APPEND to the result, otherwise set result 69616ee1e9aSmrg# to NONDIR_REPLACEMENT. 69716ee1e9aSmrg# value returned in "$func_dirname_result" 69816ee1e9aSmrg# basename: Compute filename of FILE. 69916ee1e9aSmrg# value retuned in "$func_basename_result" 70016ee1e9aSmrg# For efficiency, we do not delegate to the functions above but instead 70116ee1e9aSmrg# duplicate the functionality here. 70216ee1e9aSmrgeval 'func_dirname_and_basename () 70316ee1e9aSmrg{ 70416ee1e9aSmrg $debug_cmd 70516ee1e9aSmrg 70616ee1e9aSmrg '"$_b"' 70716ee1e9aSmrg '"$_d"' 70816ee1e9aSmrg}' 70916ee1e9aSmrg 71016ee1e9aSmrg 71116ee1e9aSmrg# func_echo ARG... 71216ee1e9aSmrg# ---------------- 71316ee1e9aSmrg# Echo program name prefixed message. 71416ee1e9aSmrgfunc_echo () 71516ee1e9aSmrg{ 71616ee1e9aSmrg $debug_cmd 71716ee1e9aSmrg 71816ee1e9aSmrg _G_message=$* 71916ee1e9aSmrg 72016ee1e9aSmrg func_echo_IFS=$IFS 72116ee1e9aSmrg IFS=$nl 72216ee1e9aSmrg for _G_line in $_G_message; do 72316ee1e9aSmrg IFS=$func_echo_IFS 72416ee1e9aSmrg $ECHO "$progname: $_G_line" 72516ee1e9aSmrg done 72616ee1e9aSmrg IFS=$func_echo_IFS 72716ee1e9aSmrg} 72816ee1e9aSmrg 72916ee1e9aSmrg 73016ee1e9aSmrg# func_echo_all ARG... 73116ee1e9aSmrg# -------------------- 73216ee1e9aSmrg# Invoke $ECHO with all args, space-separated. 73316ee1e9aSmrgfunc_echo_all () 73416ee1e9aSmrg{ 73516ee1e9aSmrg $ECHO "$*" 73616ee1e9aSmrg} 73716ee1e9aSmrg 73816ee1e9aSmrg 73916ee1e9aSmrg# func_echo_infix_1 INFIX ARG... 74016ee1e9aSmrg# ------------------------------ 74116ee1e9aSmrg# Echo program name, followed by INFIX on the first line, with any 74216ee1e9aSmrg# additional lines not showing INFIX. 74316ee1e9aSmrgfunc_echo_infix_1 () 74416ee1e9aSmrg{ 74516ee1e9aSmrg $debug_cmd 74616ee1e9aSmrg 74716ee1e9aSmrg $require_term_colors 74816ee1e9aSmrg 74916ee1e9aSmrg _G_infix=$1; shift 75016ee1e9aSmrg _G_indent=$_G_infix 75116ee1e9aSmrg _G_prefix="$progname: $_G_infix: " 75216ee1e9aSmrg _G_message=$* 75316ee1e9aSmrg 75416ee1e9aSmrg # Strip color escape sequences before counting printable length 75516ee1e9aSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75616ee1e9aSmrg do 75716ee1e9aSmrg test -n "$_G_tc" && { 75816ee1e9aSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75916ee1e9aSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76016ee1e9aSmrg } 76116ee1e9aSmrg done 76216ee1e9aSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76316ee1e9aSmrg 76416ee1e9aSmrg func_echo_infix_1_IFS=$IFS 76516ee1e9aSmrg IFS=$nl 76616ee1e9aSmrg for _G_line in $_G_message; do 76716ee1e9aSmrg IFS=$func_echo_infix_1_IFS 76816ee1e9aSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76916ee1e9aSmrg _G_prefix=$_G_indent 77016ee1e9aSmrg done 77116ee1e9aSmrg IFS=$func_echo_infix_1_IFS 77216ee1e9aSmrg} 77316ee1e9aSmrg 77416ee1e9aSmrg 77516ee1e9aSmrg# func_error ARG... 77616ee1e9aSmrg# ----------------- 77716ee1e9aSmrg# Echo program name prefixed message to standard error. 77816ee1e9aSmrgfunc_error () 77916ee1e9aSmrg{ 78016ee1e9aSmrg $debug_cmd 78116ee1e9aSmrg 78216ee1e9aSmrg $require_term_colors 78316ee1e9aSmrg 78416ee1e9aSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78516ee1e9aSmrg} 78616ee1e9aSmrg 78716ee1e9aSmrg 78816ee1e9aSmrg# func_fatal_error ARG... 78916ee1e9aSmrg# ----------------------- 79016ee1e9aSmrg# Echo program name prefixed message to standard error, and exit. 79116ee1e9aSmrgfunc_fatal_error () 79216ee1e9aSmrg{ 79316ee1e9aSmrg $debug_cmd 79416ee1e9aSmrg 79516ee1e9aSmrg func_error "$*" 79616ee1e9aSmrg exit $EXIT_FAILURE 79716ee1e9aSmrg} 79816ee1e9aSmrg 79916ee1e9aSmrg 80016ee1e9aSmrg# func_grep EXPRESSION FILENAME 80116ee1e9aSmrg# ----------------------------- 802fda9279dSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803fda9279dSmrgfunc_grep () 804fda9279dSmrg{ 80516ee1e9aSmrg $debug_cmd 80616ee1e9aSmrg 807fda9279dSmrg $GREP "$1" "$2" >/dev/null 2>&1 808fda9279dSmrg} 809fda9279dSmrg 810fda9279dSmrg 81116ee1e9aSmrg# func_len STRING 81216ee1e9aSmrg# --------------- 81316ee1e9aSmrg# Set func_len_result to the length of STRING. STRING may not 81416ee1e9aSmrg# start with a hyphen. 81516ee1e9aSmrg test -z "$_G_HAVE_XSI_OPS" \ 81616ee1e9aSmrg && (eval 'x=a/b/c; 81716ee1e9aSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81816ee1e9aSmrg && _G_HAVE_XSI_OPS=yes 81916ee1e9aSmrg 82016ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 82116ee1e9aSmrg eval 'func_len () 82216ee1e9aSmrg { 82316ee1e9aSmrg $debug_cmd 82416ee1e9aSmrg 82516ee1e9aSmrg func_len_result=${#1} 82616ee1e9aSmrg }' 82716ee1e9aSmrgelse 82816ee1e9aSmrg func_len () 82916ee1e9aSmrg { 83016ee1e9aSmrg $debug_cmd 83116ee1e9aSmrg 83216ee1e9aSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83316ee1e9aSmrg } 83416ee1e9aSmrgfi 83516ee1e9aSmrg 83616ee1e9aSmrg 83716ee1e9aSmrg# func_mkdir_p DIRECTORY-PATH 83816ee1e9aSmrg# --------------------------- 839fda9279dSmrg# Make sure the entire path to DIRECTORY-PATH is available. 840fda9279dSmrgfunc_mkdir_p () 841fda9279dSmrg{ 84216ee1e9aSmrg $debug_cmd 84316ee1e9aSmrg 84416ee1e9aSmrg _G_directory_path=$1 84516ee1e9aSmrg _G_dir_list= 846fda9279dSmrg 84716ee1e9aSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848fda9279dSmrg 84916ee1e9aSmrg # Protect directory names starting with '-' 85016ee1e9aSmrg case $_G_directory_path in 85116ee1e9aSmrg -*) _G_directory_path=./$_G_directory_path ;; 852fda9279dSmrg esac 853fda9279dSmrg 854fda9279dSmrg # While some portion of DIR does not yet exist... 85516ee1e9aSmrg while test ! -d "$_G_directory_path"; do 856fda9279dSmrg # ...make a list in topmost first order. Use a colon delimited 857fda9279dSmrg # list incase some portion of path contains whitespace. 85816ee1e9aSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 859fda9279dSmrg 860fda9279dSmrg # If the last portion added has no slash in it, the list is done 86116ee1e9aSmrg case $_G_directory_path in */*) ;; *) break ;; esac 862fda9279dSmrg 863fda9279dSmrg # ...otherwise throw away the child directory and loop 86416ee1e9aSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865fda9279dSmrg done 86616ee1e9aSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867fda9279dSmrg 86816ee1e9aSmrg func_mkdir_p_IFS=$IFS; IFS=: 86916ee1e9aSmrg for _G_dir in $_G_dir_list; do 87016ee1e9aSmrg IFS=$func_mkdir_p_IFS 87116ee1e9aSmrg # mkdir can fail with a 'File exist' error if two processes 872fda9279dSmrg # try to create one of the directories concurrently. Don't 873fda9279dSmrg # stop in that case! 87416ee1e9aSmrg $MKDIR "$_G_dir" 2>/dev/null || : 875fda9279dSmrg done 87616ee1e9aSmrg IFS=$func_mkdir_p_IFS 877fda9279dSmrg 878fda9279dSmrg # Bail out if we (or some other process) failed to create a directory. 87916ee1e9aSmrg test -d "$_G_directory_path" || \ 88016ee1e9aSmrg func_fatal_error "Failed to create '$1'" 881fda9279dSmrg fi 882fda9279dSmrg} 883fda9279dSmrg 884fda9279dSmrg 88516ee1e9aSmrg# func_mktempdir [BASENAME] 88616ee1e9aSmrg# ------------------------- 887fda9279dSmrg# Make a temporary directory that won't clash with other running 888fda9279dSmrg# libtool processes, and avoids race conditions if possible. If 88916ee1e9aSmrg# given, BASENAME is the basename for that directory. 890fda9279dSmrgfunc_mktempdir () 891fda9279dSmrg{ 89216ee1e9aSmrg $debug_cmd 89316ee1e9aSmrg 89416ee1e9aSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895fda9279dSmrg 89616ee1e9aSmrg if test : = "$opt_dry_run"; then 897fda9279dSmrg # Return a directory name, but don't create it in dry-run mode 89816ee1e9aSmrg _G_tmpdir=$_G_template-$$ 899fda9279dSmrg else 900fda9279dSmrg 901fda9279dSmrg # If mktemp works, use that first and foremost 90216ee1e9aSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903fda9279dSmrg 90416ee1e9aSmrg if test ! -d "$_G_tmpdir"; then 905fda9279dSmrg # Failing that, at least try and use $RANDOM to avoid a race 90616ee1e9aSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907fda9279dSmrg 90816ee1e9aSmrg func_mktempdir_umask=`umask` 909fda9279dSmrg umask 0077 91016ee1e9aSmrg $MKDIR "$_G_tmpdir" 91116ee1e9aSmrg umask $func_mktempdir_umask 912fda9279dSmrg fi 913fda9279dSmrg 914fda9279dSmrg # If we're not in dry-run mode, bomb out on failure 91516ee1e9aSmrg test -d "$_G_tmpdir" || \ 91616ee1e9aSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917fda9279dSmrg fi 918fda9279dSmrg 91916ee1e9aSmrg $ECHO "$_G_tmpdir" 920fda9279dSmrg} 921fda9279dSmrg 922fda9279dSmrg 92316ee1e9aSmrg# func_normal_abspath PATH 92416ee1e9aSmrg# ------------------------ 92516ee1e9aSmrg# Remove doubled-up and trailing slashes, "." path components, 92616ee1e9aSmrg# and cancel out any ".." path components in PATH after making 92716ee1e9aSmrg# it an absolute path. 92816ee1e9aSmrgfunc_normal_abspath () 929fda9279dSmrg{ 93016ee1e9aSmrg $debug_cmd 931fda9279dSmrg 93216ee1e9aSmrg # These SED scripts presuppose an absolute path with a trailing slash. 93316ee1e9aSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93416ee1e9aSmrg _G_pathcdr='s|^/[^/]*||' 93516ee1e9aSmrg _G_removedotparts=':dotsl 93616ee1e9aSmrg s|/\./|/|g 93716ee1e9aSmrg t dotsl 93816ee1e9aSmrg s|/\.$|/|' 93916ee1e9aSmrg _G_collapseslashes='s|/\{1,\}|/|g' 94016ee1e9aSmrg _G_finalslash='s|/*$|/|' 94116ee1e9aSmrg 94216ee1e9aSmrg # Start from root dir and reassemble the path. 94316ee1e9aSmrg func_normal_abspath_result= 94416ee1e9aSmrg func_normal_abspath_tpath=$1 94516ee1e9aSmrg func_normal_abspath_altnamespace= 94616ee1e9aSmrg case $func_normal_abspath_tpath in 94716ee1e9aSmrg "") 94816ee1e9aSmrg # Empty path, that just means $cwd. 94916ee1e9aSmrg func_stripname '' '/' "`pwd`" 95016ee1e9aSmrg func_normal_abspath_result=$func_stripname_result 95116ee1e9aSmrg return 95216ee1e9aSmrg ;; 95316ee1e9aSmrg # The next three entries are used to spot a run of precisely 95416ee1e9aSmrg # two leading slashes without using negated character classes; 95516ee1e9aSmrg # we take advantage of case's first-match behaviour. 95616ee1e9aSmrg ///*) 95716ee1e9aSmrg # Unusual form of absolute path, do nothing. 95816ee1e9aSmrg ;; 95916ee1e9aSmrg //*) 96016ee1e9aSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96116ee1e9aSmrg # and for example Cygwin uses it to access remote file shares 96216ee1e9aSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 96316ee1e9aSmrg func_normal_abspath_altnamespace=/ 96416ee1e9aSmrg ;; 96516ee1e9aSmrg /*) 96616ee1e9aSmrg # Absolute path, do nothing. 967fda9279dSmrg ;; 968fda9279dSmrg *) 96916ee1e9aSmrg # Relative path, prepend $cwd. 97016ee1e9aSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97116ee1e9aSmrg ;; 972fda9279dSmrg esac 97316ee1e9aSmrg 97416ee1e9aSmrg # Cancel out all the simple stuff to save iterations. We also want 97516ee1e9aSmrg # the path to end with a slash for ease of parsing, so make sure 97616ee1e9aSmrg # there is one (and only one) here. 97716ee1e9aSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97816ee1e9aSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97916ee1e9aSmrg while :; do 98016ee1e9aSmrg # Processed it all yet? 98116ee1e9aSmrg if test / = "$func_normal_abspath_tpath"; then 98216ee1e9aSmrg # If we ascended to the root using ".." the result may be empty now. 98316ee1e9aSmrg if test -z "$func_normal_abspath_result"; then 98416ee1e9aSmrg func_normal_abspath_result=/ 98516ee1e9aSmrg fi 98616ee1e9aSmrg break 98716ee1e9aSmrg fi 98816ee1e9aSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98916ee1e9aSmrg -e "$_G_pathcar"` 99016ee1e9aSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99116ee1e9aSmrg -e "$_G_pathcdr"` 99216ee1e9aSmrg # Figure out what to do with it 99316ee1e9aSmrg case $func_normal_abspath_tcomponent in 99416ee1e9aSmrg "") 99516ee1e9aSmrg # Trailing empty path component, ignore it. 99616ee1e9aSmrg ;; 99716ee1e9aSmrg ..) 99816ee1e9aSmrg # Parent dir; strip last assembled component from result. 99916ee1e9aSmrg func_dirname "$func_normal_abspath_result" 100016ee1e9aSmrg func_normal_abspath_result=$func_dirname_result 100116ee1e9aSmrg ;; 100216ee1e9aSmrg *) 100316ee1e9aSmrg # Actual path component, append it. 100416ee1e9aSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100516ee1e9aSmrg ;; 100616ee1e9aSmrg esac 100716ee1e9aSmrg done 100816ee1e9aSmrg # Restore leading double-slash if one was found on entry. 100916ee1e9aSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101016ee1e9aSmrg} 101116ee1e9aSmrg 101216ee1e9aSmrg 101316ee1e9aSmrg# func_notquiet ARG... 101416ee1e9aSmrg# -------------------- 101516ee1e9aSmrg# Echo program name prefixed message only when not in quiet mode. 101616ee1e9aSmrgfunc_notquiet () 101716ee1e9aSmrg{ 101816ee1e9aSmrg $debug_cmd 101916ee1e9aSmrg 102016ee1e9aSmrg $opt_quiet || func_echo ${1+"$@"} 102116ee1e9aSmrg 102216ee1e9aSmrg # A bug in bash halts the script if the last line of a function 102316ee1e9aSmrg # fails when set -e is in force, so we need another command to 102416ee1e9aSmrg # work around that: 102516ee1e9aSmrg : 102616ee1e9aSmrg} 102716ee1e9aSmrg 102816ee1e9aSmrg 102916ee1e9aSmrg# func_relative_path SRCDIR DSTDIR 103016ee1e9aSmrg# -------------------------------- 103116ee1e9aSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103216ee1e9aSmrgfunc_relative_path () 103316ee1e9aSmrg{ 103416ee1e9aSmrg $debug_cmd 103516ee1e9aSmrg 103616ee1e9aSmrg func_relative_path_result= 103716ee1e9aSmrg func_normal_abspath "$1" 103816ee1e9aSmrg func_relative_path_tlibdir=$func_normal_abspath_result 103916ee1e9aSmrg func_normal_abspath "$2" 104016ee1e9aSmrg func_relative_path_tbindir=$func_normal_abspath_result 104116ee1e9aSmrg 104216ee1e9aSmrg # Ascend the tree starting from libdir 104316ee1e9aSmrg while :; do 104416ee1e9aSmrg # check if we have found a prefix of bindir 104516ee1e9aSmrg case $func_relative_path_tbindir in 104616ee1e9aSmrg $func_relative_path_tlibdir) 104716ee1e9aSmrg # found an exact match 104816ee1e9aSmrg func_relative_path_tcancelled= 104916ee1e9aSmrg break 105016ee1e9aSmrg ;; 105116ee1e9aSmrg $func_relative_path_tlibdir*) 105216ee1e9aSmrg # found a matching prefix 105316ee1e9aSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105416ee1e9aSmrg func_relative_path_tcancelled=$func_stripname_result 105516ee1e9aSmrg if test -z "$func_relative_path_result"; then 105616ee1e9aSmrg func_relative_path_result=. 105716ee1e9aSmrg fi 105816ee1e9aSmrg break 105916ee1e9aSmrg ;; 106016ee1e9aSmrg *) 106116ee1e9aSmrg func_dirname $func_relative_path_tlibdir 106216ee1e9aSmrg func_relative_path_tlibdir=$func_dirname_result 106316ee1e9aSmrg if test -z "$func_relative_path_tlibdir"; then 106416ee1e9aSmrg # Have to descend all the way to the root! 106516ee1e9aSmrg func_relative_path_result=../$func_relative_path_result 106616ee1e9aSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 106716ee1e9aSmrg break 106816ee1e9aSmrg fi 106916ee1e9aSmrg func_relative_path_result=../$func_relative_path_result 107016ee1e9aSmrg ;; 107116ee1e9aSmrg esac 107216ee1e9aSmrg done 107316ee1e9aSmrg 107416ee1e9aSmrg # Now calculate path; take care to avoid doubling-up slashes. 107516ee1e9aSmrg func_stripname '' '/' "$func_relative_path_result" 107616ee1e9aSmrg func_relative_path_result=$func_stripname_result 107716ee1e9aSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107816ee1e9aSmrg if test -n "$func_stripname_result"; then 107916ee1e9aSmrg func_append func_relative_path_result "/$func_stripname_result" 108016ee1e9aSmrg fi 108116ee1e9aSmrg 108216ee1e9aSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 108316ee1e9aSmrg if test -n "$func_relative_path_result"; then 108416ee1e9aSmrg func_stripname './' '' "$func_relative_path_result" 108516ee1e9aSmrg func_relative_path_result=$func_stripname_result 108616ee1e9aSmrg fi 108716ee1e9aSmrg 108816ee1e9aSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 108916ee1e9aSmrg 109016ee1e9aSmrg : 1091fda9279dSmrg} 1092fda9279dSmrg 1093fda9279dSmrg 109416ee1e9aSmrg# func_quote_for_eval ARG... 109516ee1e9aSmrg# -------------------------- 109616ee1e9aSmrg# Aesthetically quote ARGs to be evaled later. 109716ee1e9aSmrg# This function returns two values: 109816ee1e9aSmrg# i) func_quote_for_eval_result 109916ee1e9aSmrg# double-quoted, suitable for a subsequent eval 110016ee1e9aSmrg# ii) func_quote_for_eval_unquoted_result 110116ee1e9aSmrg# has all characters that are still active within double 110216ee1e9aSmrg# quotes backslashified. 110316ee1e9aSmrgfunc_quote_for_eval () 110416ee1e9aSmrg{ 110516ee1e9aSmrg $debug_cmd 110616ee1e9aSmrg 110716ee1e9aSmrg func_quote_for_eval_unquoted_result= 110816ee1e9aSmrg func_quote_for_eval_result= 110916ee1e9aSmrg while test 0 -lt $#; do 111016ee1e9aSmrg case $1 in 111116ee1e9aSmrg *[\\\`\"\$]*) 111216ee1e9aSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111316ee1e9aSmrg *) 111416ee1e9aSmrg _G_unquoted_arg=$1 ;; 111516ee1e9aSmrg esac 111616ee1e9aSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 111716ee1e9aSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111816ee1e9aSmrg else 111916ee1e9aSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112016ee1e9aSmrg fi 112116ee1e9aSmrg 112216ee1e9aSmrg case $_G_unquoted_arg in 112316ee1e9aSmrg # Double-quote args containing shell metacharacters to delay 112416ee1e9aSmrg # word splitting, command substitution and variable expansion 112516ee1e9aSmrg # for a subsequent eval. 112616ee1e9aSmrg # Many Bourne shells cannot handle close brackets correctly 112716ee1e9aSmrg # in scan sets, so we specify it separately. 112816ee1e9aSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112916ee1e9aSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 113016ee1e9aSmrg ;; 113116ee1e9aSmrg *) 113216ee1e9aSmrg _G_quoted_arg=$_G_unquoted_arg 113316ee1e9aSmrg ;; 113416ee1e9aSmrg esac 113516ee1e9aSmrg 113616ee1e9aSmrg if test -n "$func_quote_for_eval_result"; then 113716ee1e9aSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113816ee1e9aSmrg else 113916ee1e9aSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114016ee1e9aSmrg fi 114116ee1e9aSmrg shift 114216ee1e9aSmrg done 114316ee1e9aSmrg} 114416ee1e9aSmrg 114516ee1e9aSmrg 114616ee1e9aSmrg# func_quote_for_expand ARG 114716ee1e9aSmrg# ------------------------- 1148fda9279dSmrg# Aesthetically quote ARG to be evaled later; same as above, 1149fda9279dSmrg# but do not quote variable references. 1150fda9279dSmrgfunc_quote_for_expand () 1151fda9279dSmrg{ 115216ee1e9aSmrg $debug_cmd 115316ee1e9aSmrg 1154fda9279dSmrg case $1 in 1155fda9279dSmrg *[\\\`\"]*) 115616ee1e9aSmrg _G_arg=`$ECHO "$1" | $SED \ 115716ee1e9aSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158fda9279dSmrg *) 115916ee1e9aSmrg _G_arg=$1 ;; 1160fda9279dSmrg esac 1161fda9279dSmrg 116216ee1e9aSmrg case $_G_arg in 1163fda9279dSmrg # Double-quote args containing shell metacharacters to delay 1164fda9279dSmrg # word splitting and command substitution for a subsequent eval. 1165fda9279dSmrg # Many Bourne shells cannot handle close brackets correctly 1166fda9279dSmrg # in scan sets, so we specify it separately. 1167fda9279dSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116816ee1e9aSmrg _G_arg=\"$_G_arg\" 1169fda9279dSmrg ;; 1170fda9279dSmrg esac 1171fda9279dSmrg 117216ee1e9aSmrg func_quote_for_expand_result=$_G_arg 117316ee1e9aSmrg} 117416ee1e9aSmrg 117516ee1e9aSmrg 117616ee1e9aSmrg# func_stripname PREFIX SUFFIX NAME 117716ee1e9aSmrg# --------------------------------- 117816ee1e9aSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117916ee1e9aSmrg# PREFIX and SUFFIX must not contain globbing or regex special 118016ee1e9aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118116ee1e9aSmrg# dot (in which case that matches only a dot). 118216ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 118316ee1e9aSmrg eval 'func_stripname () 118416ee1e9aSmrg { 118516ee1e9aSmrg $debug_cmd 118616ee1e9aSmrg 118716ee1e9aSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118816ee1e9aSmrg # positional parameters, so assign one to ordinary variable first. 118916ee1e9aSmrg func_stripname_result=$3 119016ee1e9aSmrg func_stripname_result=${func_stripname_result#"$1"} 119116ee1e9aSmrg func_stripname_result=${func_stripname_result%"$2"} 119216ee1e9aSmrg }' 119316ee1e9aSmrgelse 119416ee1e9aSmrg func_stripname () 119516ee1e9aSmrg { 119616ee1e9aSmrg $debug_cmd 119716ee1e9aSmrg 119816ee1e9aSmrg case $2 in 119916ee1e9aSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120016ee1e9aSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120116ee1e9aSmrg esac 120216ee1e9aSmrg } 120316ee1e9aSmrgfi 120416ee1e9aSmrg 120516ee1e9aSmrg 120616ee1e9aSmrg# func_show_eval CMD [FAIL_EXP] 120716ee1e9aSmrg# ----------------------------- 120816ee1e9aSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120916ee1e9aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121016ee1e9aSmrg# is given, then evaluate it. 121116ee1e9aSmrgfunc_show_eval () 121216ee1e9aSmrg{ 121316ee1e9aSmrg $debug_cmd 121416ee1e9aSmrg 121516ee1e9aSmrg _G_cmd=$1 121616ee1e9aSmrg _G_fail_exp=${2-':'} 121716ee1e9aSmrg 121816ee1e9aSmrg func_quote_for_expand "$_G_cmd" 121916ee1e9aSmrg eval "func_notquiet $func_quote_for_expand_result" 122016ee1e9aSmrg 122116ee1e9aSmrg $opt_dry_run || { 122216ee1e9aSmrg eval "$_G_cmd" 122316ee1e9aSmrg _G_status=$? 122416ee1e9aSmrg if test 0 -ne "$_G_status"; then 122516ee1e9aSmrg eval "(exit $_G_status); $_G_fail_exp" 122616ee1e9aSmrg fi 122716ee1e9aSmrg } 122816ee1e9aSmrg} 122916ee1e9aSmrg 123016ee1e9aSmrg 123116ee1e9aSmrg# func_show_eval_locale CMD [FAIL_EXP] 123216ee1e9aSmrg# ------------------------------------ 123316ee1e9aSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123416ee1e9aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123516ee1e9aSmrg# is given, then evaluate it. Use the saved locale for evaluation. 123616ee1e9aSmrgfunc_show_eval_locale () 123716ee1e9aSmrg{ 123816ee1e9aSmrg $debug_cmd 123916ee1e9aSmrg 124016ee1e9aSmrg _G_cmd=$1 124116ee1e9aSmrg _G_fail_exp=${2-':'} 124216ee1e9aSmrg 124316ee1e9aSmrg $opt_quiet || { 124416ee1e9aSmrg func_quote_for_expand "$_G_cmd" 124516ee1e9aSmrg eval "func_echo $func_quote_for_expand_result" 124616ee1e9aSmrg } 124716ee1e9aSmrg 124816ee1e9aSmrg $opt_dry_run || { 124916ee1e9aSmrg eval "$_G_user_locale 125016ee1e9aSmrg $_G_cmd" 125116ee1e9aSmrg _G_status=$? 125216ee1e9aSmrg eval "$_G_safe_locale" 125316ee1e9aSmrg if test 0 -ne "$_G_status"; then 125416ee1e9aSmrg eval "(exit $_G_status); $_G_fail_exp" 125516ee1e9aSmrg fi 125616ee1e9aSmrg } 125716ee1e9aSmrg} 125816ee1e9aSmrg 125916ee1e9aSmrg 126016ee1e9aSmrg# func_tr_sh 126116ee1e9aSmrg# ---------- 126216ee1e9aSmrg# Turn $1 into a string suitable for a shell variable name. 126316ee1e9aSmrg# Result is stored in $func_tr_sh_result. All characters 126416ee1e9aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126516ee1e9aSmrg# if $1 begins with a digit, a '_' is prepended as well. 126616ee1e9aSmrgfunc_tr_sh () 126716ee1e9aSmrg{ 126816ee1e9aSmrg $debug_cmd 126916ee1e9aSmrg 127016ee1e9aSmrg case $1 in 127116ee1e9aSmrg [0-9]* | *[!a-zA-Z0-9_]*) 127216ee1e9aSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127316ee1e9aSmrg ;; 127416ee1e9aSmrg * ) 127516ee1e9aSmrg func_tr_sh_result=$1 127616ee1e9aSmrg ;; 127716ee1e9aSmrg esac 127816ee1e9aSmrg} 127916ee1e9aSmrg 128016ee1e9aSmrg 128116ee1e9aSmrg# func_verbose ARG... 128216ee1e9aSmrg# ------------------- 128316ee1e9aSmrg# Echo program name prefixed message in verbose mode only. 128416ee1e9aSmrgfunc_verbose () 128516ee1e9aSmrg{ 128616ee1e9aSmrg $debug_cmd 128716ee1e9aSmrg 128816ee1e9aSmrg $opt_verbose && func_echo "$*" 128916ee1e9aSmrg 129016ee1e9aSmrg : 129116ee1e9aSmrg} 129216ee1e9aSmrg 129316ee1e9aSmrg 129416ee1e9aSmrg# func_warn_and_continue ARG... 129516ee1e9aSmrg# ----------------------------- 129616ee1e9aSmrg# Echo program name prefixed warning message to standard error. 129716ee1e9aSmrgfunc_warn_and_continue () 129816ee1e9aSmrg{ 129916ee1e9aSmrg $debug_cmd 130016ee1e9aSmrg 130116ee1e9aSmrg $require_term_colors 130216ee1e9aSmrg 130316ee1e9aSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130416ee1e9aSmrg} 130516ee1e9aSmrg 130616ee1e9aSmrg 130716ee1e9aSmrg# func_warning CATEGORY ARG... 130816ee1e9aSmrg# ---------------------------- 130916ee1e9aSmrg# Echo program name prefixed warning message to standard error. Warning 131016ee1e9aSmrg# messages can be filtered according to CATEGORY, where this function 131116ee1e9aSmrg# elides messages where CATEGORY is not listed in the global variable 131216ee1e9aSmrg# 'opt_warning_types'. 131316ee1e9aSmrgfunc_warning () 131416ee1e9aSmrg{ 131516ee1e9aSmrg $debug_cmd 131616ee1e9aSmrg 131716ee1e9aSmrg # CATEGORY must be in the warning_categories list! 131816ee1e9aSmrg case " $warning_categories " in 131916ee1e9aSmrg *" $1 "*) ;; 132016ee1e9aSmrg *) func_internal_error "invalid warning category '$1'" ;; 132116ee1e9aSmrg esac 132216ee1e9aSmrg 132316ee1e9aSmrg _G_category=$1 132416ee1e9aSmrg shift 132516ee1e9aSmrg 132616ee1e9aSmrg case " $opt_warning_types " in 132716ee1e9aSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132816ee1e9aSmrg esac 1329fda9279dSmrg} 1330fda9279dSmrg 1331fda9279dSmrg 133216ee1e9aSmrg# func_sort_ver VER1 VER2 133316ee1e9aSmrg# ----------------------- 133416ee1e9aSmrg# 'sort -V' is not generally available. 133516ee1e9aSmrg# Note this deviates from the version comparison in automake 133616ee1e9aSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133716ee1e9aSmrg# but this should suffice as we won't be specifying old 133816ee1e9aSmrg# version formats or redundant trailing .0 in bootstrap.conf. 133916ee1e9aSmrg# If we did want full compatibility then we should probably 134016ee1e9aSmrg# use m4_version_compare from autoconf. 134116ee1e9aSmrgfunc_sort_ver () 134216ee1e9aSmrg{ 134316ee1e9aSmrg $debug_cmd 134416ee1e9aSmrg 134516ee1e9aSmrg printf '%s\n%s\n' "$1" "$2" \ 134616ee1e9aSmrg | 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 134716ee1e9aSmrg} 134816ee1e9aSmrg 134916ee1e9aSmrg# func_lt_ver PREV CURR 135016ee1e9aSmrg# --------------------- 135116ee1e9aSmrg# Return true if PREV and CURR are in the correct order according to 135216ee1e9aSmrg# func_sort_ver, otherwise false. Use it like this: 135316ee1e9aSmrg# 135416ee1e9aSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135516ee1e9aSmrgfunc_lt_ver () 135616ee1e9aSmrg{ 135716ee1e9aSmrg $debug_cmd 135816ee1e9aSmrg 135916ee1e9aSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136016ee1e9aSmrg} 136116ee1e9aSmrg 136216ee1e9aSmrg 136316ee1e9aSmrg# Local variables: 136416ee1e9aSmrg# mode: shell-script 136516ee1e9aSmrg# sh-indentation: 2 136616ee1e9aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 136716ee1e9aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136816ee1e9aSmrg# time-stamp-time-zone: "UTC" 136916ee1e9aSmrg# End: 137016ee1e9aSmrg#! /bin/sh 137116ee1e9aSmrg 137216ee1e9aSmrg# Set a version string for this script. 137316ee1e9aSmrgscriptversion=2014-01-07.03; # UTC 137416ee1e9aSmrg 137516ee1e9aSmrg# A portable, pluggable option parser for Bourne shell. 137616ee1e9aSmrg# Written by Gary V. Vaughan, 2010 137716ee1e9aSmrg 137816ee1e9aSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137916ee1e9aSmrg# This is free software; see the source for copying conditions. There is NO 138016ee1e9aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138116ee1e9aSmrg 138216ee1e9aSmrg# This program is free software: you can redistribute it and/or modify 138316ee1e9aSmrg# it under the terms of the GNU General Public License as published by 138416ee1e9aSmrg# the Free Software Foundation, either version 3 of the License, or 138516ee1e9aSmrg# (at your option) any later version. 138616ee1e9aSmrg 138716ee1e9aSmrg# This program is distributed in the hope that it will be useful, 138816ee1e9aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138916ee1e9aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139016ee1e9aSmrg# GNU General Public License for more details. 139116ee1e9aSmrg 139216ee1e9aSmrg# You should have received a copy of the GNU General Public License 139316ee1e9aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139416ee1e9aSmrg 139516ee1e9aSmrg# Please report bugs or propose patches to gary@gnu.org. 139616ee1e9aSmrg 139716ee1e9aSmrg 139816ee1e9aSmrg## ------ ## 139916ee1e9aSmrg## Usage. ## 140016ee1e9aSmrg## ------ ## 140116ee1e9aSmrg 140216ee1e9aSmrg# This file is a library for parsing options in your shell scripts along 140316ee1e9aSmrg# with assorted other useful supporting features that you can make use 140416ee1e9aSmrg# of too. 140516ee1e9aSmrg# 140616ee1e9aSmrg# For the simplest scripts you might need only: 140716ee1e9aSmrg# 140816ee1e9aSmrg# #!/bin/sh 140916ee1e9aSmrg# . relative/path/to/funclib.sh 141016ee1e9aSmrg# . relative/path/to/options-parser 141116ee1e9aSmrg# scriptversion=1.0 141216ee1e9aSmrg# func_options ${1+"$@"} 141316ee1e9aSmrg# eval set dummy "$func_options_result"; shift 141416ee1e9aSmrg# ...rest of your script... 141516ee1e9aSmrg# 141616ee1e9aSmrg# In order for the '--version' option to work, you will need to have a 141716ee1e9aSmrg# suitably formatted comment like the one at the top of this file 141816ee1e9aSmrg# starting with '# Written by ' and ending with '# warranty; '. 141916ee1e9aSmrg# 142016ee1e9aSmrg# For '-h' and '--help' to work, you will also need a one line 142116ee1e9aSmrg# description of your script's purpose in a comment directly above the 142216ee1e9aSmrg# '# Written by ' line, like the one at the top of this file. 142316ee1e9aSmrg# 142416ee1e9aSmrg# The default options also support '--debug', which will turn on shell 142516ee1e9aSmrg# execution tracing (see the comment above debug_cmd below for another 142616ee1e9aSmrg# use), and '--verbose' and the func_verbose function to allow your script 142716ee1e9aSmrg# to display verbose messages only when your user has specified 142816ee1e9aSmrg# '--verbose'. 142916ee1e9aSmrg# 143016ee1e9aSmrg# After sourcing this file, you can plug processing for additional 143116ee1e9aSmrg# options by amending the variables from the 'Configuration' section 143216ee1e9aSmrg# below, and following the instructions in the 'Option parsing' 143316ee1e9aSmrg# section further down. 143416ee1e9aSmrg 143516ee1e9aSmrg## -------------- ## 143616ee1e9aSmrg## Configuration. ## 143716ee1e9aSmrg## -------------- ## 143816ee1e9aSmrg 143916ee1e9aSmrg# You should override these variables in your script after sourcing this 144016ee1e9aSmrg# file so that they reflect the customisations you have added to the 144116ee1e9aSmrg# option parser. 144216ee1e9aSmrg 144316ee1e9aSmrg# The usage line for option parsing errors and the start of '-h' and 144416ee1e9aSmrg# '--help' output messages. You can embed shell variables for delayed 144516ee1e9aSmrg# expansion at the time the message is displayed, but you will need to 144616ee1e9aSmrg# quote other shell meta-characters carefully to prevent them being 144716ee1e9aSmrg# expanded when the contents are evaled. 144816ee1e9aSmrgusage='$progpath [OPTION]...' 144916ee1e9aSmrg 145016ee1e9aSmrg# Short help message in response to '-h' and '--help'. Add to this or 145116ee1e9aSmrg# override it after sourcing this library to reflect the full set of 145216ee1e9aSmrg# options your script accepts. 145316ee1e9aSmrgusage_message="\ 145416ee1e9aSmrg --debug enable verbose shell tracing 145516ee1e9aSmrg -W, --warnings=CATEGORY 145616ee1e9aSmrg report the warnings falling in CATEGORY [all] 145716ee1e9aSmrg -v, --verbose verbosely report processing 145816ee1e9aSmrg --version print version information and exit 145916ee1e9aSmrg -h, --help print short or long help message and exit 146016ee1e9aSmrg" 146116ee1e9aSmrg 146216ee1e9aSmrg# Additional text appended to 'usage_message' in response to '--help'. 146316ee1e9aSmrglong_help_message=" 146416ee1e9aSmrgWarning categories include: 146516ee1e9aSmrg 'all' show all warnings 146616ee1e9aSmrg 'none' turn off all the warnings 146716ee1e9aSmrg 'error' warnings are treated as fatal errors" 146816ee1e9aSmrg 146916ee1e9aSmrg# Help message printed before fatal option parsing errors. 147016ee1e9aSmrgfatal_help="Try '\$progname --help' for more information." 147116ee1e9aSmrg 147216ee1e9aSmrg 147316ee1e9aSmrg 147416ee1e9aSmrg## ------------------------- ## 147516ee1e9aSmrg## Hook function management. ## 147616ee1e9aSmrg## ------------------------- ## 147716ee1e9aSmrg 147816ee1e9aSmrg# This section contains functions for adding, removing, and running hooks 147916ee1e9aSmrg# to the main code. A hook is just a named list of of function, that can 148016ee1e9aSmrg# be run in order later on. 148116ee1e9aSmrg 148216ee1e9aSmrg# func_hookable FUNC_NAME 148316ee1e9aSmrg# ----------------------- 148416ee1e9aSmrg# Declare that FUNC_NAME will run hooks added with 148516ee1e9aSmrg# 'func_add_hook FUNC_NAME ...'. 148616ee1e9aSmrgfunc_hookable () 148716ee1e9aSmrg{ 148816ee1e9aSmrg $debug_cmd 148916ee1e9aSmrg 149016ee1e9aSmrg func_append hookable_fns " $1" 149116ee1e9aSmrg} 149216ee1e9aSmrg 149316ee1e9aSmrg 149416ee1e9aSmrg# func_add_hook FUNC_NAME HOOK_FUNC 149516ee1e9aSmrg# --------------------------------- 149616ee1e9aSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149716ee1e9aSmrg# first have been declared "hookable" by a call to 'func_hookable'. 149816ee1e9aSmrgfunc_add_hook () 149916ee1e9aSmrg{ 150016ee1e9aSmrg $debug_cmd 150116ee1e9aSmrg 150216ee1e9aSmrg case " $hookable_fns " in 150316ee1e9aSmrg *" $1 "*) ;; 150416ee1e9aSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150516ee1e9aSmrg esac 150616ee1e9aSmrg 150716ee1e9aSmrg eval func_append ${1}_hooks '" $2"' 150816ee1e9aSmrg} 150916ee1e9aSmrg 151016ee1e9aSmrg 151116ee1e9aSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 151216ee1e9aSmrg# ------------------------------------ 151316ee1e9aSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151416ee1e9aSmrgfunc_remove_hook () 151516ee1e9aSmrg{ 151616ee1e9aSmrg $debug_cmd 151716ee1e9aSmrg 151816ee1e9aSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151916ee1e9aSmrg} 152016ee1e9aSmrg 152116ee1e9aSmrg 152216ee1e9aSmrg# func_run_hooks FUNC_NAME [ARG]... 152316ee1e9aSmrg# --------------------------------- 152416ee1e9aSmrg# Run all hook functions registered to FUNC_NAME. 152516ee1e9aSmrg# It is assumed that the list of hook functions contains nothing more 152616ee1e9aSmrg# than a whitespace-delimited list of legal shell function names, and 152716ee1e9aSmrg# no effort is wasted trying to catch shell meta-characters or preserve 152816ee1e9aSmrg# whitespace. 152916ee1e9aSmrgfunc_run_hooks () 153016ee1e9aSmrg{ 153116ee1e9aSmrg $debug_cmd 153216ee1e9aSmrg 153316ee1e9aSmrg case " $hookable_fns " in 153416ee1e9aSmrg *" $1 "*) ;; 153516ee1e9aSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153616ee1e9aSmrg esac 153716ee1e9aSmrg 153816ee1e9aSmrg eval _G_hook_fns=\$$1_hooks; shift 153916ee1e9aSmrg 154016ee1e9aSmrg for _G_hook in $_G_hook_fns; do 154116ee1e9aSmrg eval $_G_hook '"$@"' 154216ee1e9aSmrg 154316ee1e9aSmrg # store returned options list back into positional 154416ee1e9aSmrg # parameters for next 'cmd' execution. 154516ee1e9aSmrg eval _G_hook_result=\$${_G_hook}_result 154616ee1e9aSmrg eval set dummy "$_G_hook_result"; shift 154716ee1e9aSmrg done 154816ee1e9aSmrg 154916ee1e9aSmrg func_quote_for_eval ${1+"$@"} 155016ee1e9aSmrg func_run_hooks_result=$func_quote_for_eval_result 155116ee1e9aSmrg} 155216ee1e9aSmrg 155316ee1e9aSmrg 155416ee1e9aSmrg 155516ee1e9aSmrg## --------------- ## 155616ee1e9aSmrg## Option parsing. ## 155716ee1e9aSmrg## --------------- ## 155816ee1e9aSmrg 155916ee1e9aSmrg# In order to add your own option parsing hooks, you must accept the 156016ee1e9aSmrg# full positional parameter list in your hook function, remove any 156116ee1e9aSmrg# options that you action, and then pass back the remaining unprocessed 156216ee1e9aSmrg# options in '<hooked_function_name>_result', escaped suitably for 156316ee1e9aSmrg# 'eval'. Like this: 156416ee1e9aSmrg# 156516ee1e9aSmrg# my_options_prep () 156616ee1e9aSmrg# { 156716ee1e9aSmrg# $debug_cmd 156816ee1e9aSmrg# 156916ee1e9aSmrg# # Extend the existing usage message. 157016ee1e9aSmrg# usage_message=$usage_message' 157116ee1e9aSmrg# -s, --silent don'\''t print informational messages 157216ee1e9aSmrg# ' 157316ee1e9aSmrg# 157416ee1e9aSmrg# func_quote_for_eval ${1+"$@"} 157516ee1e9aSmrg# my_options_prep_result=$func_quote_for_eval_result 157616ee1e9aSmrg# } 157716ee1e9aSmrg# func_add_hook func_options_prep my_options_prep 157816ee1e9aSmrg# 157916ee1e9aSmrg# 158016ee1e9aSmrg# my_silent_option () 158116ee1e9aSmrg# { 158216ee1e9aSmrg# $debug_cmd 158316ee1e9aSmrg# 158416ee1e9aSmrg# # Note that for efficiency, we parse as many options as we can 158516ee1e9aSmrg# # recognise in a loop before passing the remainder back to the 158616ee1e9aSmrg# # caller on the first unrecognised argument we encounter. 158716ee1e9aSmrg# while test $# -gt 0; do 158816ee1e9aSmrg# opt=$1; shift 158916ee1e9aSmrg# case $opt in 159016ee1e9aSmrg# --silent|-s) opt_silent=: ;; 159116ee1e9aSmrg# # Separate non-argument short options: 159216ee1e9aSmrg# -s*) func_split_short_opt "$_G_opt" 159316ee1e9aSmrg# set dummy "$func_split_short_opt_name" \ 159416ee1e9aSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 159516ee1e9aSmrg# shift 159616ee1e9aSmrg# ;; 159716ee1e9aSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159816ee1e9aSmrg# esac 159916ee1e9aSmrg# done 160016ee1e9aSmrg# 160116ee1e9aSmrg# func_quote_for_eval ${1+"$@"} 160216ee1e9aSmrg# my_silent_option_result=$func_quote_for_eval_result 160316ee1e9aSmrg# } 160416ee1e9aSmrg# func_add_hook func_parse_options my_silent_option 160516ee1e9aSmrg# 160616ee1e9aSmrg# 160716ee1e9aSmrg# my_option_validation () 160816ee1e9aSmrg# { 160916ee1e9aSmrg# $debug_cmd 161016ee1e9aSmrg# 161116ee1e9aSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161216ee1e9aSmrg# '--silent' and '--verbose' options are mutually exclusive." 161316ee1e9aSmrg# 161416ee1e9aSmrg# func_quote_for_eval ${1+"$@"} 161516ee1e9aSmrg# my_option_validation_result=$func_quote_for_eval_result 161616ee1e9aSmrg# } 161716ee1e9aSmrg# func_add_hook func_validate_options my_option_validation 161816ee1e9aSmrg# 161916ee1e9aSmrg# You'll alse need to manually amend $usage_message to reflect the extra 162016ee1e9aSmrg# options you parse. It's preferable to append if you can, so that 162116ee1e9aSmrg# multiple option parsing hooks can be added safely. 162216ee1e9aSmrg 162316ee1e9aSmrg 162416ee1e9aSmrg# func_options [ARG]... 162516ee1e9aSmrg# --------------------- 162616ee1e9aSmrg# All the functions called inside func_options are hookable. See the 162716ee1e9aSmrg# individual implementations for details. 162816ee1e9aSmrgfunc_hookable func_options 162916ee1e9aSmrgfunc_options () 1630fda9279dSmrg{ 163116ee1e9aSmrg $debug_cmd 1632fda9279dSmrg 163316ee1e9aSmrg func_options_prep ${1+"$@"} 163416ee1e9aSmrg eval func_parse_options \ 163516ee1e9aSmrg ${func_options_prep_result+"$func_options_prep_result"} 163616ee1e9aSmrg eval func_validate_options \ 163716ee1e9aSmrg ${func_parse_options_result+"$func_parse_options_result"} 1638fda9279dSmrg 163916ee1e9aSmrg eval func_run_hooks func_options \ 164016ee1e9aSmrg ${func_validate_options_result+"$func_validate_options_result"} 164116ee1e9aSmrg 164216ee1e9aSmrg # save modified positional parameters for caller 164316ee1e9aSmrg func_options_result=$func_run_hooks_result 1644fda9279dSmrg} 1645fda9279dSmrg 1646fda9279dSmrg 164716ee1e9aSmrg# func_options_prep [ARG]... 164816ee1e9aSmrg# -------------------------- 164916ee1e9aSmrg# All initialisations required before starting the option parse loop. 165016ee1e9aSmrg# Note that when calling hook functions, we pass through the list of 165116ee1e9aSmrg# positional parameters. If a hook function modifies that list, and 165216ee1e9aSmrg# needs to propogate that back to rest of this script, then the complete 165316ee1e9aSmrg# modified list must be put in 'func_run_hooks_result' before 165416ee1e9aSmrg# returning. 165516ee1e9aSmrgfunc_hookable func_options_prep 165616ee1e9aSmrgfunc_options_prep () 1657fda9279dSmrg{ 165816ee1e9aSmrg $debug_cmd 1659fda9279dSmrg 166016ee1e9aSmrg # Option defaults: 166116ee1e9aSmrg opt_verbose=false 166216ee1e9aSmrg opt_warning_types= 1663fda9279dSmrg 166416ee1e9aSmrg func_run_hooks func_options_prep ${1+"$@"} 166516ee1e9aSmrg 166616ee1e9aSmrg # save modified positional parameters for caller 166716ee1e9aSmrg func_options_prep_result=$func_run_hooks_result 1668fda9279dSmrg} 1669fda9279dSmrg 167016ee1e9aSmrg 167116ee1e9aSmrg# func_parse_options [ARG]... 167216ee1e9aSmrg# --------------------------- 167316ee1e9aSmrg# The main option parsing loop. 167416ee1e9aSmrgfunc_hookable func_parse_options 167516ee1e9aSmrgfunc_parse_options () 1676fda9279dSmrg{ 167716ee1e9aSmrg $debug_cmd 167816ee1e9aSmrg 167916ee1e9aSmrg func_parse_options_result= 168016ee1e9aSmrg 168116ee1e9aSmrg # this just eases exit handling 168216ee1e9aSmrg while test $# -gt 0; do 168316ee1e9aSmrg # Defer to hook functions for initial option parsing, so they 168416ee1e9aSmrg # get priority in the event of reusing an option name. 168516ee1e9aSmrg func_run_hooks func_parse_options ${1+"$@"} 168616ee1e9aSmrg 168716ee1e9aSmrg # Adjust func_parse_options positional parameters to match 168816ee1e9aSmrg eval set dummy "$func_run_hooks_result"; shift 168916ee1e9aSmrg 169016ee1e9aSmrg # Break out of the loop if we already parsed every option. 169116ee1e9aSmrg test $# -gt 0 || break 169216ee1e9aSmrg 169316ee1e9aSmrg _G_opt=$1 169416ee1e9aSmrg shift 169516ee1e9aSmrg case $_G_opt in 169616ee1e9aSmrg --debug|-x) debug_cmd='set -x' 169716ee1e9aSmrg func_echo "enabling shell trace mode" 169816ee1e9aSmrg $debug_cmd 169916ee1e9aSmrg ;; 170016ee1e9aSmrg 170116ee1e9aSmrg --no-warnings|--no-warning|--no-warn) 170216ee1e9aSmrg set dummy --warnings none ${1+"$@"} 170316ee1e9aSmrg shift 170416ee1e9aSmrg ;; 170516ee1e9aSmrg 170616ee1e9aSmrg --warnings|--warning|-W) 170716ee1e9aSmrg test $# = 0 && func_missing_arg $_G_opt && break 170816ee1e9aSmrg case " $warning_categories $1" in 170916ee1e9aSmrg *" $1 "*) 171016ee1e9aSmrg # trailing space prevents matching last $1 above 171116ee1e9aSmrg func_append_uniq opt_warning_types " $1" 171216ee1e9aSmrg ;; 171316ee1e9aSmrg *all) 171416ee1e9aSmrg opt_warning_types=$warning_categories 171516ee1e9aSmrg ;; 171616ee1e9aSmrg *none) 171716ee1e9aSmrg opt_warning_types=none 171816ee1e9aSmrg warning_func=: 171916ee1e9aSmrg ;; 172016ee1e9aSmrg *error) 172116ee1e9aSmrg opt_warning_types=$warning_categories 172216ee1e9aSmrg warning_func=func_fatal_error 172316ee1e9aSmrg ;; 172416ee1e9aSmrg *) 172516ee1e9aSmrg func_fatal_error \ 172616ee1e9aSmrg "unsupported warning category: '$1'" 172716ee1e9aSmrg ;; 172816ee1e9aSmrg esac 172916ee1e9aSmrg shift 173016ee1e9aSmrg ;; 173116ee1e9aSmrg 173216ee1e9aSmrg --verbose|-v) opt_verbose=: ;; 173316ee1e9aSmrg --version) func_version ;; 173416ee1e9aSmrg -\?|-h) func_usage ;; 173516ee1e9aSmrg --help) func_help ;; 173616ee1e9aSmrg 173716ee1e9aSmrg # Separate optargs to long options (plugins may need this): 173816ee1e9aSmrg --*=*) func_split_equals "$_G_opt" 173916ee1e9aSmrg set dummy "$func_split_equals_lhs" \ 174016ee1e9aSmrg "$func_split_equals_rhs" ${1+"$@"} 174116ee1e9aSmrg shift 174216ee1e9aSmrg ;; 174316ee1e9aSmrg 174416ee1e9aSmrg # Separate optargs to short options: 174516ee1e9aSmrg -W*) 174616ee1e9aSmrg func_split_short_opt "$_G_opt" 174716ee1e9aSmrg set dummy "$func_split_short_opt_name" \ 174816ee1e9aSmrg "$func_split_short_opt_arg" ${1+"$@"} 174916ee1e9aSmrg shift 175016ee1e9aSmrg ;; 175116ee1e9aSmrg 175216ee1e9aSmrg # Separate non-argument short options: 175316ee1e9aSmrg -\?*|-h*|-v*|-x*) 175416ee1e9aSmrg func_split_short_opt "$_G_opt" 175516ee1e9aSmrg set dummy "$func_split_short_opt_name" \ 175616ee1e9aSmrg "-$func_split_short_opt_arg" ${1+"$@"} 175716ee1e9aSmrg shift 175816ee1e9aSmrg ;; 175916ee1e9aSmrg 176016ee1e9aSmrg --) break ;; 176116ee1e9aSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176216ee1e9aSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176316ee1e9aSmrg esac 176416ee1e9aSmrg done 176516ee1e9aSmrg 176616ee1e9aSmrg # save modified positional parameters for caller 176716ee1e9aSmrg func_quote_for_eval ${1+"$@"} 176816ee1e9aSmrg func_parse_options_result=$func_quote_for_eval_result 1769fda9279dSmrg} 1770fda9279dSmrg 1771fda9279dSmrg 177216ee1e9aSmrg# func_validate_options [ARG]... 177316ee1e9aSmrg# ------------------------------ 177416ee1e9aSmrg# Perform any sanity checks on option settings and/or unconsumed 177516ee1e9aSmrg# arguments. 177616ee1e9aSmrgfunc_hookable func_validate_options 177716ee1e9aSmrgfunc_validate_options () 1778fda9279dSmrg{ 177916ee1e9aSmrg $debug_cmd 1780fda9279dSmrg 178116ee1e9aSmrg # Display all warnings if -W was not given. 178216ee1e9aSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 178316ee1e9aSmrg 178416ee1e9aSmrg func_run_hooks func_validate_options ${1+"$@"} 178516ee1e9aSmrg 178616ee1e9aSmrg # Bail if the options were screwed! 178716ee1e9aSmrg $exit_cmd $EXIT_FAILURE 178816ee1e9aSmrg 178916ee1e9aSmrg # save modified positional parameters for caller 179016ee1e9aSmrg func_validate_options_result=$func_run_hooks_result 1791fda9279dSmrg} 1792fda9279dSmrg 179316ee1e9aSmrg 179416ee1e9aSmrg 179516ee1e9aSmrg## ----------------- ## 179616ee1e9aSmrg## Helper functions. ## 179716ee1e9aSmrg## ----------------- ## 179816ee1e9aSmrg 179916ee1e9aSmrg# This section contains the helper functions used by the rest of the 180016ee1e9aSmrg# hookable option parser framework in ascii-betical order. 180116ee1e9aSmrg 180216ee1e9aSmrg 180316ee1e9aSmrg# func_fatal_help ARG... 180416ee1e9aSmrg# ---------------------- 180516ee1e9aSmrg# Echo program name prefixed message to standard error, followed by 180616ee1e9aSmrg# a help hint, and exit. 180716ee1e9aSmrgfunc_fatal_help () 1808fda9279dSmrg{ 180916ee1e9aSmrg $debug_cmd 1810fda9279dSmrg 181116ee1e9aSmrg eval \$ECHO \""Usage: $usage"\" 181216ee1e9aSmrg eval \$ECHO \""$fatal_help"\" 181316ee1e9aSmrg func_error ${1+"$@"} 181416ee1e9aSmrg exit $EXIT_FAILURE 1815fda9279dSmrg} 1816fda9279dSmrg 181716ee1e9aSmrg 181816ee1e9aSmrg# func_help 181916ee1e9aSmrg# --------- 182016ee1e9aSmrg# Echo long help message to standard output and exit. 1821fda9279dSmrgfunc_help () 1822fda9279dSmrg{ 182316ee1e9aSmrg $debug_cmd 182416ee1e9aSmrg 182516ee1e9aSmrg func_usage_message 182616ee1e9aSmrg $ECHO "$long_help_message" 182716ee1e9aSmrg exit 0 1828fda9279dSmrg} 1829fda9279dSmrg 183016ee1e9aSmrg 183116ee1e9aSmrg# func_missing_arg ARGNAME 183216ee1e9aSmrg# ------------------------ 1833fda9279dSmrg# Echo program name prefixed message to standard error and set global 1834fda9279dSmrg# exit_cmd. 1835fda9279dSmrgfunc_missing_arg () 1836fda9279dSmrg{ 183716ee1e9aSmrg $debug_cmd 1838fda9279dSmrg 183916ee1e9aSmrg func_error "Missing argument for '$1'." 1840fda9279dSmrg exit_cmd=exit 1841fda9279dSmrg} 1842fda9279dSmrg 1843fda9279dSmrg 184416ee1e9aSmrg# func_split_equals STRING 184516ee1e9aSmrg# ------------------------ 184616ee1e9aSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184716ee1e9aSmrg# splitting STRING at the '=' sign. 184816ee1e9aSmrgtest -z "$_G_HAVE_XSI_OPS" \ 184916ee1e9aSmrg && (eval 'x=a/b/c; 185016ee1e9aSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185116ee1e9aSmrg && _G_HAVE_XSI_OPS=yes 185216ee1e9aSmrg 185316ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS" 185416ee1e9aSmrgthen 185516ee1e9aSmrg # This is an XSI compatible shell, allowing a faster implementation... 185616ee1e9aSmrg eval 'func_split_equals () 185716ee1e9aSmrg { 185816ee1e9aSmrg $debug_cmd 185916ee1e9aSmrg 186016ee1e9aSmrg func_split_equals_lhs=${1%%=*} 186116ee1e9aSmrg func_split_equals_rhs=${1#*=} 186216ee1e9aSmrg test "x$func_split_equals_lhs" = "x$1" \ 186316ee1e9aSmrg && func_split_equals_rhs= 186416ee1e9aSmrg }' 186516ee1e9aSmrgelse 186616ee1e9aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 186716ee1e9aSmrg func_split_equals () 186816ee1e9aSmrg { 186916ee1e9aSmrg $debug_cmd 187016ee1e9aSmrg 187116ee1e9aSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187216ee1e9aSmrg func_split_equals_rhs= 187316ee1e9aSmrg test "x$func_split_equals_lhs" = "x$1" \ 187416ee1e9aSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187516ee1e9aSmrg } 187616ee1e9aSmrgfi #func_split_equals 187716ee1e9aSmrg 187816ee1e9aSmrg 187916ee1e9aSmrg# func_split_short_opt SHORTOPT 188016ee1e9aSmrg# ----------------------------- 1881fda9279dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882fda9279dSmrg# variables after splitting SHORTOPT after the 2nd character. 188316ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS" 188416ee1e9aSmrgthen 188516ee1e9aSmrg # This is an XSI compatible shell, allowing a faster implementation... 188616ee1e9aSmrg eval 'func_split_short_opt () 188716ee1e9aSmrg { 188816ee1e9aSmrg $debug_cmd 188916ee1e9aSmrg 189016ee1e9aSmrg func_split_short_opt_arg=${1#??} 189116ee1e9aSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189216ee1e9aSmrg }' 189316ee1e9aSmrgelse 189416ee1e9aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 189516ee1e9aSmrg func_split_short_opt () 189616ee1e9aSmrg { 189716ee1e9aSmrg $debug_cmd 189816ee1e9aSmrg 189916ee1e9aSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190016ee1e9aSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190116ee1e9aSmrg } 190216ee1e9aSmrgfi #func_split_short_opt 190316ee1e9aSmrg 190416ee1e9aSmrg 190516ee1e9aSmrg# func_usage 190616ee1e9aSmrg# ---------- 190716ee1e9aSmrg# Echo short help message to standard output and exit. 190816ee1e9aSmrgfunc_usage () 1909fda9279dSmrg{ 191016ee1e9aSmrg $debug_cmd 1911fda9279dSmrg 191216ee1e9aSmrg func_usage_message 191316ee1e9aSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191416ee1e9aSmrg exit 0 191516ee1e9aSmrg} 1916fda9279dSmrg 1917fda9279dSmrg 191816ee1e9aSmrg# func_usage_message 191916ee1e9aSmrg# ------------------ 192016ee1e9aSmrg# Echo short help message to standard output. 192116ee1e9aSmrgfunc_usage_message () 1922fda9279dSmrg{ 192316ee1e9aSmrg $debug_cmd 1924fda9279dSmrg 192516ee1e9aSmrg eval \$ECHO \""Usage: $usage"\" 192616ee1e9aSmrg echo 192716ee1e9aSmrg $SED -n 's|^# || 192816ee1e9aSmrg /^Written by/{ 192916ee1e9aSmrg x;p;x 193016ee1e9aSmrg } 193116ee1e9aSmrg h 193216ee1e9aSmrg /^Written by/q' < "$progpath" 193316ee1e9aSmrg echo 193416ee1e9aSmrg eval \$ECHO \""$usage_message"\" 193516ee1e9aSmrg} 1936fda9279dSmrg 1937fda9279dSmrg 193816ee1e9aSmrg# func_version 193916ee1e9aSmrg# ------------ 194016ee1e9aSmrg# Echo version message to standard output and exit. 194116ee1e9aSmrgfunc_version () 194216ee1e9aSmrg{ 194316ee1e9aSmrg $debug_cmd 1944fda9279dSmrg 194516ee1e9aSmrg printf '%s\n' "$progname $scriptversion" 194616ee1e9aSmrg $SED -n ' 194716ee1e9aSmrg /(C)/!b go 194816ee1e9aSmrg :more 194916ee1e9aSmrg /\./!{ 195016ee1e9aSmrg N 195116ee1e9aSmrg s|\n# | | 195216ee1e9aSmrg b more 195316ee1e9aSmrg } 195416ee1e9aSmrg :go 195516ee1e9aSmrg /^# Written by /,/# warranty; / { 195616ee1e9aSmrg s|^# || 195716ee1e9aSmrg s|^# *$|| 195816ee1e9aSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195916ee1e9aSmrg p 196016ee1e9aSmrg } 196116ee1e9aSmrg /^# Written by / { 196216ee1e9aSmrg s|^# || 196316ee1e9aSmrg p 196416ee1e9aSmrg } 196516ee1e9aSmrg /^warranty; /q' < "$progpath" 1966fda9279dSmrg 196716ee1e9aSmrg exit $? 196816ee1e9aSmrg} 1969fda9279dSmrg 1970fda9279dSmrg 197116ee1e9aSmrg# Local variables: 197216ee1e9aSmrg# mode: shell-script 197316ee1e9aSmrg# sh-indentation: 2 197416ee1e9aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 197516ee1e9aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197616ee1e9aSmrg# time-stamp-time-zone: "UTC" 197716ee1e9aSmrg# End: 1978fda9279dSmrg 197916ee1e9aSmrg# Set a version string. 198016ee1e9aSmrgscriptversion='(GNU libtool) 2.4.6' 1981fda9279dSmrg 1982fda9279dSmrg 198316ee1e9aSmrg# func_echo ARG... 198416ee1e9aSmrg# ---------------- 198516ee1e9aSmrg# Libtool also displays the current mode in messages, so override 198616ee1e9aSmrg# funclib.sh func_echo with this custom definition. 198716ee1e9aSmrgfunc_echo () 1988fda9279dSmrg{ 198916ee1e9aSmrg $debug_cmd 1990fda9279dSmrg 199116ee1e9aSmrg _G_message=$* 199216ee1e9aSmrg 199316ee1e9aSmrg func_echo_IFS=$IFS 199416ee1e9aSmrg IFS=$nl 199516ee1e9aSmrg for _G_line in $_G_message; do 199616ee1e9aSmrg IFS=$func_echo_IFS 199716ee1e9aSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199816ee1e9aSmrg done 199916ee1e9aSmrg IFS=$func_echo_IFS 200016ee1e9aSmrg} 2001fda9279dSmrg 2002fda9279dSmrg 200316ee1e9aSmrg# func_warning ARG... 200416ee1e9aSmrg# ------------------- 200516ee1e9aSmrg# Libtool warnings are not categorized, so override funclib.sh 200616ee1e9aSmrg# func_warning with this simpler definition. 200716ee1e9aSmrgfunc_warning () 2008fda9279dSmrg{ 200916ee1e9aSmrg $debug_cmd 201016ee1e9aSmrg 201116ee1e9aSmrg $warning_func ${1+"$@"} 201216ee1e9aSmrg} 201316ee1e9aSmrg 2014fda9279dSmrg 201516ee1e9aSmrg## ---------------- ## 201616ee1e9aSmrg## Options parsing. ## 201716ee1e9aSmrg## ---------------- ## 201816ee1e9aSmrg 201916ee1e9aSmrg# Hook in the functions to make sure our own options are parsed during 202016ee1e9aSmrg# the option parsing loop. 202116ee1e9aSmrg 202216ee1e9aSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 202316ee1e9aSmrg 202416ee1e9aSmrg# Short help message in response to '-h'. 202516ee1e9aSmrgusage_message="Options: 202616ee1e9aSmrg --config show all configuration variables 202716ee1e9aSmrg --debug enable verbose shell tracing 202816ee1e9aSmrg -n, --dry-run display commands without modifying any files 202916ee1e9aSmrg --features display basic configuration information and exit 203016ee1e9aSmrg --mode=MODE use operation mode MODE 203116ee1e9aSmrg --no-warnings equivalent to '-Wnone' 203216ee1e9aSmrg --preserve-dup-deps don't remove duplicate dependency libraries 203316ee1e9aSmrg --quiet, --silent don't print informational messages 203416ee1e9aSmrg --tag=TAG use configuration variables from tag TAG 203516ee1e9aSmrg -v, --verbose print more informational messages than default 203616ee1e9aSmrg --version print version information 203716ee1e9aSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203816ee1e9aSmrg -h, --help, --help-all print short, long, or detailed help message 203916ee1e9aSmrg" 2040fda9279dSmrg 204116ee1e9aSmrg# Additional text appended to 'usage_message' in response to '--help'. 204216ee1e9aSmrgfunc_help () 2043fda9279dSmrg{ 204416ee1e9aSmrg $debug_cmd 204516ee1e9aSmrg 204616ee1e9aSmrg func_usage_message 204716ee1e9aSmrg $ECHO "$long_help_message 204816ee1e9aSmrg 204916ee1e9aSmrgMODE must be one of the following: 205016ee1e9aSmrg 205116ee1e9aSmrg clean remove files from the build directory 205216ee1e9aSmrg compile compile a source file into a libtool object 205316ee1e9aSmrg execute automatically set library path, then run a program 205416ee1e9aSmrg finish complete the installation of libtool libraries 205516ee1e9aSmrg install install libraries or executables 205616ee1e9aSmrg link create a library or an executable 205716ee1e9aSmrg uninstall remove libraries from an installed directory 205816ee1e9aSmrg 205916ee1e9aSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206016ee1e9aSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206116ee1e9aSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206216ee1e9aSmrg 206316ee1e9aSmrgWhen reporting a bug, please describe a test case to reproduce it and 206416ee1e9aSmrginclude the following information: 206516ee1e9aSmrg 206616ee1e9aSmrg host-triplet: $host 206716ee1e9aSmrg shell: $SHELL 206816ee1e9aSmrg compiler: $LTCC 206916ee1e9aSmrg compiler flags: $LTCFLAGS 207016ee1e9aSmrg linker: $LD (gnu? $with_gnu_ld) 207116ee1e9aSmrg version: $progname (GNU libtool) 2.4.6 207216ee1e9aSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207316ee1e9aSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207416ee1e9aSmrg 207516ee1e9aSmrgReport bugs to <bug-libtool@gnu.org>. 207616ee1e9aSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 207716ee1e9aSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207816ee1e9aSmrg exit 0 207916ee1e9aSmrg} 2080fda9279dSmrg 2081fda9279dSmrg 208216ee1e9aSmrg# func_lo2o OBJECT-NAME 208316ee1e9aSmrg# --------------------- 208416ee1e9aSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208516ee1e9aSmrg# object suffix. 2086fda9279dSmrg 208716ee1e9aSmrglo2o=s/\\.lo\$/.$objext/ 208816ee1e9aSmrgo2lo=s/\\.$objext\$/.lo/ 2089fda9279dSmrg 209016ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 209116ee1e9aSmrg eval 'func_lo2o () 209216ee1e9aSmrg { 209316ee1e9aSmrg case $1 in 209416ee1e9aSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209516ee1e9aSmrg * ) func_lo2o_result=$1 ;; 209616ee1e9aSmrg esac 209716ee1e9aSmrg }' 209816ee1e9aSmrg 209916ee1e9aSmrg # func_xform LIBOBJ-OR-SOURCE 210016ee1e9aSmrg # --------------------------- 210116ee1e9aSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210216ee1e9aSmrg # suffix to a '.lo' libtool-object suffix. 210316ee1e9aSmrg eval 'func_xform () 210416ee1e9aSmrg { 210516ee1e9aSmrg func_xform_result=${1%.*}.lo 210616ee1e9aSmrg }' 210716ee1e9aSmrgelse 210816ee1e9aSmrg # ...otherwise fall back to using sed. 210916ee1e9aSmrg func_lo2o () 211016ee1e9aSmrg { 211116ee1e9aSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211216ee1e9aSmrg } 211316ee1e9aSmrg 211416ee1e9aSmrg func_xform () 211516ee1e9aSmrg { 211616ee1e9aSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211716ee1e9aSmrg } 211816ee1e9aSmrgfi 2119fda9279dSmrg 2120fda9279dSmrg 212116ee1e9aSmrg# func_fatal_configuration ARG... 212216ee1e9aSmrg# ------------------------------- 2123fda9279dSmrg# Echo program name prefixed message to standard error, followed by 2124fda9279dSmrg# a configuration failure hint, and exit. 2125fda9279dSmrgfunc_fatal_configuration () 2126fda9279dSmrg{ 212716ee1e9aSmrg func__fatal_error ${1+"$@"} \ 212816ee1e9aSmrg "See the $PACKAGE documentation for more information." \ 212916ee1e9aSmrg "Fatal configuration error." 2130fda9279dSmrg} 2131fda9279dSmrg 2132fda9279dSmrg 2133fda9279dSmrg# func_config 213416ee1e9aSmrg# ----------- 2135fda9279dSmrg# Display the configuration for all the tags in this script. 2136fda9279dSmrgfunc_config () 2137fda9279dSmrg{ 2138fda9279dSmrg re_begincf='^# ### BEGIN LIBTOOL' 2139fda9279dSmrg re_endcf='^# ### END LIBTOOL' 2140fda9279dSmrg 2141fda9279dSmrg # Default configuration. 2142fda9279dSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143fda9279dSmrg 2144fda9279dSmrg # Now print the configurations for the tags. 2145fda9279dSmrg for tagname in $taglist; do 2146fda9279dSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147fda9279dSmrg done 2148fda9279dSmrg 2149fda9279dSmrg exit $? 2150fda9279dSmrg} 2151fda9279dSmrg 215216ee1e9aSmrg 2153fda9279dSmrg# func_features 215416ee1e9aSmrg# ------------- 2155fda9279dSmrg# Display the features supported by this script. 2156fda9279dSmrgfunc_features () 2157fda9279dSmrg{ 2158fda9279dSmrg echo "host: $host" 215916ee1e9aSmrg if test yes = "$build_libtool_libs"; then 2160fda9279dSmrg echo "enable shared libraries" 2161fda9279dSmrg else 2162fda9279dSmrg echo "disable shared libraries" 2163fda9279dSmrg fi 216416ee1e9aSmrg if test yes = "$build_old_libs"; then 2165fda9279dSmrg echo "enable static libraries" 2166fda9279dSmrg else 2167fda9279dSmrg echo "disable static libraries" 2168fda9279dSmrg fi 2169fda9279dSmrg 2170fda9279dSmrg exit $? 2171fda9279dSmrg} 2172fda9279dSmrg 217316ee1e9aSmrg 217416ee1e9aSmrg# func_enable_tag TAGNAME 217516ee1e9aSmrg# ----------------------- 2176fda9279dSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177fda9279dSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178fda9279dSmrg# variable here. 2179fda9279dSmrgfunc_enable_tag () 2180fda9279dSmrg{ 218116ee1e9aSmrg # Global variable: 218216ee1e9aSmrg tagname=$1 2183fda9279dSmrg 218416ee1e9aSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218516ee1e9aSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218616ee1e9aSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187fda9279dSmrg 218816ee1e9aSmrg # Validate tagname. 218916ee1e9aSmrg case $tagname in 219016ee1e9aSmrg *[!-_A-Za-z0-9,/]*) 219116ee1e9aSmrg func_fatal_error "invalid tag name: $tagname" 219216ee1e9aSmrg ;; 219316ee1e9aSmrg esac 2194fda9279dSmrg 219516ee1e9aSmrg # Don't test for the "default" C tag, as we know it's 219616ee1e9aSmrg # there but not specially marked. 219716ee1e9aSmrg case $tagname in 219816ee1e9aSmrg CC) ;; 2199fda9279dSmrg *) 220016ee1e9aSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220116ee1e9aSmrg taglist="$taglist $tagname" 220216ee1e9aSmrg 220316ee1e9aSmrg # Evaluate the configuration. Be careful to quote the path 220416ee1e9aSmrg # and the sed script, to avoid splitting on whitespace, but 220516ee1e9aSmrg # also don't use non-portable quotes within backquotes within 220616ee1e9aSmrg # quotes we have to do it in 2 steps: 220716ee1e9aSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220816ee1e9aSmrg eval "$extractedcf" 220916ee1e9aSmrg else 221016ee1e9aSmrg func_error "ignoring unknown tag $tagname" 221116ee1e9aSmrg fi 221216ee1e9aSmrg ;; 221316ee1e9aSmrg esac 2214fda9279dSmrg} 2215fda9279dSmrg 221616ee1e9aSmrg 2217fda9279dSmrg# func_check_version_match 221816ee1e9aSmrg# ------------------------ 2219fda9279dSmrg# Ensure that we are using m4 macros, and libtool script from the same 2220fda9279dSmrg# release of libtool. 2221fda9279dSmrgfunc_check_version_match () 2222fda9279dSmrg{ 222316ee1e9aSmrg if test "$package_revision" != "$macro_revision"; then 222416ee1e9aSmrg if test "$VERSION" != "$macro_version"; then 222516ee1e9aSmrg if test -z "$macro_version"; then 222616ee1e9aSmrg cat >&2 <<_LT_EOF 2227fda9279dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228fda9279dSmrg$progname: definition of this LT_INIT comes from an older release. 2229fda9279dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230fda9279dSmrg$progname: and run autoconf again. 2231fda9279dSmrg_LT_EOF 223216ee1e9aSmrg else 223316ee1e9aSmrg cat >&2 <<_LT_EOF 2234fda9279dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235fda9279dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236fda9279dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237fda9279dSmrg$progname: and run autoconf again. 2238fda9279dSmrg_LT_EOF 223916ee1e9aSmrg fi 224016ee1e9aSmrg else 224116ee1e9aSmrg cat >&2 <<_LT_EOF 2242fda9279dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243fda9279dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244fda9279dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245fda9279dSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2246fda9279dSmrg_LT_EOF 224716ee1e9aSmrg fi 2248fda9279dSmrg 224916ee1e9aSmrg exit $EXIT_MISMATCH 225016ee1e9aSmrg fi 2251fda9279dSmrg} 2252fda9279dSmrg 2253fda9279dSmrg 225416ee1e9aSmrg# libtool_options_prep [ARG]... 225516ee1e9aSmrg# ----------------------------- 225616ee1e9aSmrg# Preparation for options parsed by libtool. 225716ee1e9aSmrglibtool_options_prep () 225816ee1e9aSmrg{ 225916ee1e9aSmrg $debug_mode 2260fda9279dSmrg 226116ee1e9aSmrg # Option defaults: 226216ee1e9aSmrg opt_config=false 226316ee1e9aSmrg opt_dlopen= 226416ee1e9aSmrg opt_dry_run=false 226516ee1e9aSmrg opt_help=false 226616ee1e9aSmrg opt_mode= 226716ee1e9aSmrg opt_preserve_dup_deps=false 226816ee1e9aSmrg opt_quiet=false 2269fda9279dSmrg 227016ee1e9aSmrg nonopt= 227116ee1e9aSmrg preserve_args= 2272fda9279dSmrg 227316ee1e9aSmrg # Shorthand for --mode=foo, only valid as the first argument 227416ee1e9aSmrg case $1 in 227516ee1e9aSmrg clean|clea|cle|cl) 227616ee1e9aSmrg shift; set dummy --mode clean ${1+"$@"}; shift 227716ee1e9aSmrg ;; 227816ee1e9aSmrg compile|compil|compi|comp|com|co|c) 227916ee1e9aSmrg shift; set dummy --mode compile ${1+"$@"}; shift 228016ee1e9aSmrg ;; 228116ee1e9aSmrg execute|execut|execu|exec|exe|ex|e) 228216ee1e9aSmrg shift; set dummy --mode execute ${1+"$@"}; shift 228316ee1e9aSmrg ;; 228416ee1e9aSmrg finish|finis|fini|fin|fi|f) 228516ee1e9aSmrg shift; set dummy --mode finish ${1+"$@"}; shift 228616ee1e9aSmrg ;; 228716ee1e9aSmrg install|instal|insta|inst|ins|in|i) 228816ee1e9aSmrg shift; set dummy --mode install ${1+"$@"}; shift 228916ee1e9aSmrg ;; 229016ee1e9aSmrg link|lin|li|l) 229116ee1e9aSmrg shift; set dummy --mode link ${1+"$@"}; shift 229216ee1e9aSmrg ;; 229316ee1e9aSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229416ee1e9aSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229516ee1e9aSmrg ;; 229616ee1e9aSmrg esac 229716ee1e9aSmrg 229816ee1e9aSmrg # Pass back the list of options. 229916ee1e9aSmrg func_quote_for_eval ${1+"$@"} 230016ee1e9aSmrg libtool_options_prep_result=$func_quote_for_eval_result 230116ee1e9aSmrg} 230216ee1e9aSmrgfunc_add_hook func_options_prep libtool_options_prep 2303fda9279dSmrg 2304fda9279dSmrg 230516ee1e9aSmrg# libtool_parse_options [ARG]... 230616ee1e9aSmrg# --------------------------------- 230716ee1e9aSmrg# Provide handling for libtool specific options. 230816ee1e9aSmrglibtool_parse_options () 2309fda9279dSmrg{ 231016ee1e9aSmrg $debug_cmd 2311fda9279dSmrg 231216ee1e9aSmrg # Perform our own loop to consume as many options as possible in 231316ee1e9aSmrg # each iteration. 231416ee1e9aSmrg while test $# -gt 0; do 231516ee1e9aSmrg _G_opt=$1 231616ee1e9aSmrg shift 231716ee1e9aSmrg case $_G_opt in 231816ee1e9aSmrg --dry-run|--dryrun|-n) 231916ee1e9aSmrg opt_dry_run=: 232016ee1e9aSmrg ;; 232116ee1e9aSmrg 232216ee1e9aSmrg --config) func_config ;; 232316ee1e9aSmrg 232416ee1e9aSmrg --dlopen|-dlopen) 232516ee1e9aSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 232616ee1e9aSmrg}$1" 232716ee1e9aSmrg shift 232816ee1e9aSmrg ;; 232916ee1e9aSmrg 233016ee1e9aSmrg --preserve-dup-deps) 233116ee1e9aSmrg opt_preserve_dup_deps=: ;; 233216ee1e9aSmrg 233316ee1e9aSmrg --features) func_features ;; 233416ee1e9aSmrg 233516ee1e9aSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233616ee1e9aSmrg 233716ee1e9aSmrg --help) opt_help=: ;; 233816ee1e9aSmrg 233916ee1e9aSmrg --help-all) opt_help=': help-all' ;; 234016ee1e9aSmrg 234116ee1e9aSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234216ee1e9aSmrg opt_mode=$1 234316ee1e9aSmrg case $1 in 234416ee1e9aSmrg # Valid mode arguments: 234516ee1e9aSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234616ee1e9aSmrg 234716ee1e9aSmrg # Catch anything else as an error 234816ee1e9aSmrg *) func_error "invalid argument for $_G_opt" 234916ee1e9aSmrg exit_cmd=exit 235016ee1e9aSmrg break 235116ee1e9aSmrg ;; 235216ee1e9aSmrg esac 235316ee1e9aSmrg shift 235416ee1e9aSmrg ;; 235516ee1e9aSmrg 235616ee1e9aSmrg --no-silent|--no-quiet) 235716ee1e9aSmrg opt_quiet=false 235816ee1e9aSmrg func_append preserve_args " $_G_opt" 235916ee1e9aSmrg ;; 236016ee1e9aSmrg 236116ee1e9aSmrg --no-warnings|--no-warning|--no-warn) 236216ee1e9aSmrg opt_warning=false 236316ee1e9aSmrg func_append preserve_args " $_G_opt" 236416ee1e9aSmrg ;; 236516ee1e9aSmrg 236616ee1e9aSmrg --no-verbose) 236716ee1e9aSmrg opt_verbose=false 236816ee1e9aSmrg func_append preserve_args " $_G_opt" 236916ee1e9aSmrg ;; 237016ee1e9aSmrg 237116ee1e9aSmrg --silent|--quiet) 237216ee1e9aSmrg opt_quiet=: 237316ee1e9aSmrg opt_verbose=false 237416ee1e9aSmrg func_append preserve_args " $_G_opt" 237516ee1e9aSmrg ;; 237616ee1e9aSmrg 237716ee1e9aSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237816ee1e9aSmrg opt_tag=$1 237916ee1e9aSmrg func_append preserve_args " $_G_opt $1" 238016ee1e9aSmrg func_enable_tag "$1" 238116ee1e9aSmrg shift 238216ee1e9aSmrg ;; 238316ee1e9aSmrg 238416ee1e9aSmrg --verbose|-v) opt_quiet=false 238516ee1e9aSmrg opt_verbose=: 238616ee1e9aSmrg func_append preserve_args " $_G_opt" 238716ee1e9aSmrg ;; 238816ee1e9aSmrg 238916ee1e9aSmrg # An option not handled by this hook function: 239016ee1e9aSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239116ee1e9aSmrg esac 239216ee1e9aSmrg done 2393fda9279dSmrg 2394fda9279dSmrg 239516ee1e9aSmrg # save modified positional parameters for caller 239616ee1e9aSmrg func_quote_for_eval ${1+"$@"} 239716ee1e9aSmrg libtool_parse_options_result=$func_quote_for_eval_result 239816ee1e9aSmrg} 239916ee1e9aSmrgfunc_add_hook func_parse_options libtool_parse_options 2400fda9279dSmrg 2401fda9279dSmrg 2402fda9279dSmrg 240316ee1e9aSmrg# libtool_validate_options [ARG]... 240416ee1e9aSmrg# --------------------------------- 240516ee1e9aSmrg# Perform any sanity checks on option settings and/or unconsumed 240616ee1e9aSmrg# arguments. 240716ee1e9aSmrglibtool_validate_options () 240816ee1e9aSmrg{ 240916ee1e9aSmrg # save first non-option argument 241016ee1e9aSmrg if test 0 -lt $#; then 241116ee1e9aSmrg nonopt=$1 241216ee1e9aSmrg shift 2413fda9279dSmrg fi 2414fda9279dSmrg 241516ee1e9aSmrg # preserve --debug 241616ee1e9aSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417fda9279dSmrg 241816ee1e9aSmrg case $host in 241916ee1e9aSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242016ee1e9aSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242116ee1e9aSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242216ee1e9aSmrg # don't eliminate duplications in $postdeps and $predeps 242316ee1e9aSmrg opt_duplicate_compiler_generated_deps=: 242416ee1e9aSmrg ;; 242516ee1e9aSmrg *) 242616ee1e9aSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242716ee1e9aSmrg ;; 242816ee1e9aSmrg esac 2429fda9279dSmrg 243016ee1e9aSmrg $opt_help || { 243116ee1e9aSmrg # Sanity checks first: 243216ee1e9aSmrg func_check_version_match 2433fda9279dSmrg 243416ee1e9aSmrg test yes != "$build_libtool_libs" \ 243516ee1e9aSmrg && test yes != "$build_old_libs" \ 243616ee1e9aSmrg && func_fatal_configuration "not configured to build any kind of library" 2437fda9279dSmrg 243816ee1e9aSmrg # Darwin sucks 243916ee1e9aSmrg eval std_shrext=\"$shrext_cmds\" 244016ee1e9aSmrg 244116ee1e9aSmrg # Only execute mode is allowed to have -dlopen flags. 244216ee1e9aSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244316ee1e9aSmrg func_error "unrecognized option '-dlopen'" 244416ee1e9aSmrg $ECHO "$help" 1>&2 244516ee1e9aSmrg exit $EXIT_FAILURE 244616ee1e9aSmrg fi 244716ee1e9aSmrg 244816ee1e9aSmrg # Change the help message to a mode-specific one. 244916ee1e9aSmrg generic_help=$help 245016ee1e9aSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 245116ee1e9aSmrg } 245216ee1e9aSmrg 245316ee1e9aSmrg # Pass back the unparsed argument list 245416ee1e9aSmrg func_quote_for_eval ${1+"$@"} 245516ee1e9aSmrg libtool_validate_options_result=$func_quote_for_eval_result 2456fda9279dSmrg} 245716ee1e9aSmrgfunc_add_hook func_validate_options libtool_validate_options 245816ee1e9aSmrg 2459fda9279dSmrg 246016ee1e9aSmrg# Process options as early as possible so that --help and --version 246116ee1e9aSmrg# can return quickly. 246216ee1e9aSmrgfunc_options ${1+"$@"} 246316ee1e9aSmrgeval set dummy "$func_options_result"; shift 2464fda9279dSmrg 2465fda9279dSmrg 2466fda9279dSmrg 2467fda9279dSmrg## ----------- ## 2468fda9279dSmrg## Main. ## 2469fda9279dSmrg## ----------- ## 2470fda9279dSmrg 247116ee1e9aSmrgmagic='%%%MAGIC variable%%%' 247216ee1e9aSmrgmagic_exe='%%%MAGIC EXE variable%%%' 247316ee1e9aSmrg 247416ee1e9aSmrg# Global variables. 247516ee1e9aSmrgextracted_archives= 247616ee1e9aSmrgextracted_serial=0 247716ee1e9aSmrg 247816ee1e9aSmrg# If this variable is set in any of the actions, the command in it 247916ee1e9aSmrg# will be execed at the end. This prevents here-documents from being 248016ee1e9aSmrg# left over by shells. 248116ee1e9aSmrgexec_cmd= 248216ee1e9aSmrg 248316ee1e9aSmrg 248416ee1e9aSmrg# A function that is used when there is no print builtin or printf. 248516ee1e9aSmrgfunc_fallback_echo () 248616ee1e9aSmrg{ 248716ee1e9aSmrg eval 'cat <<_LTECHO_EOF 248816ee1e9aSmrg$1 248916ee1e9aSmrg_LTECHO_EOF' 249016ee1e9aSmrg} 249116ee1e9aSmrg 249216ee1e9aSmrg# func_generated_by_libtool 249316ee1e9aSmrg# True iff stdin has been generated by Libtool. This function is only 249416ee1e9aSmrg# a basic sanity check; it will hardly flush out determined imposters. 249516ee1e9aSmrgfunc_generated_by_libtool_p () 249616ee1e9aSmrg{ 249716ee1e9aSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249816ee1e9aSmrg} 249916ee1e9aSmrg 2500fda9279dSmrg# func_lalib_p file 250116ee1e9aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2503fda9279dSmrg# determined imposters. 2504fda9279dSmrgfunc_lalib_p () 2505fda9279dSmrg{ 2506fda9279dSmrg test -f "$1" && 250716ee1e9aSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508fda9279dSmrg} 2509fda9279dSmrg 2510fda9279dSmrg# func_lalib_unsafe_p file 251116ee1e9aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512fda9279dSmrg# This function implements the same check as func_lalib_p without 2513fda9279dSmrg# resorting to external programs. To this end, it redirects stdin and 2514fda9279dSmrg# closes it afterwards, without saving the original file descriptor. 2515fda9279dSmrg# As a safety measure, use it only where a negative result would be 251616ee1e9aSmrg# fatal anyway. Works if 'file' does not exist. 2517fda9279dSmrgfunc_lalib_unsafe_p () 2518fda9279dSmrg{ 2519fda9279dSmrg lalib_p=no 2520fda9279dSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521fda9279dSmrg for lalib_p_l in 1 2 3 4 2522fda9279dSmrg do 2523fda9279dSmrg read lalib_p_line 252416ee1e9aSmrg case $lalib_p_line in 2525fda9279dSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526fda9279dSmrg esac 2527fda9279dSmrg done 2528fda9279dSmrg exec 0<&5 5<&- 2529fda9279dSmrg fi 253016ee1e9aSmrg test yes = "$lalib_p" 2531fda9279dSmrg} 2532fda9279dSmrg 2533fda9279dSmrg# func_ltwrapper_script_p file 2534fda9279dSmrg# True iff FILE is a libtool wrapper script 2535fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2536fda9279dSmrg# determined imposters. 2537fda9279dSmrgfunc_ltwrapper_script_p () 2538fda9279dSmrg{ 253916ee1e9aSmrg test -f "$1" && 254016ee1e9aSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541fda9279dSmrg} 2542fda9279dSmrg 2543fda9279dSmrg# func_ltwrapper_executable_p file 2544fda9279dSmrg# True iff FILE is a libtool wrapper executable 2545fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2546fda9279dSmrg# determined imposters. 2547fda9279dSmrgfunc_ltwrapper_executable_p () 2548fda9279dSmrg{ 2549fda9279dSmrg func_ltwrapper_exec_suffix= 2550fda9279dSmrg case $1 in 2551fda9279dSmrg *.exe) ;; 2552fda9279dSmrg *) func_ltwrapper_exec_suffix=.exe ;; 2553fda9279dSmrg esac 2554fda9279dSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555fda9279dSmrg} 2556fda9279dSmrg 2557fda9279dSmrg# func_ltwrapper_scriptname file 2558fda9279dSmrg# Assumes file is an ltwrapper_executable 2559fda9279dSmrg# uses $file to determine the appropriate filename for a 2560fda9279dSmrg# temporary ltwrapper_script. 2561fda9279dSmrgfunc_ltwrapper_scriptname () 2562fda9279dSmrg{ 2563fda9279dSmrg func_dirname_and_basename "$1" "" "." 2564fda9279dSmrg func_stripname '' '.exe' "$func_basename_result" 256516ee1e9aSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566fda9279dSmrg} 2567fda9279dSmrg 2568fda9279dSmrg# func_ltwrapper_p file 2569fda9279dSmrg# True iff FILE is a libtool wrapper script or wrapper executable 2570fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2571fda9279dSmrg# determined imposters. 2572fda9279dSmrgfunc_ltwrapper_p () 2573fda9279dSmrg{ 2574fda9279dSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575fda9279dSmrg} 2576fda9279dSmrg 2577fda9279dSmrg 2578fda9279dSmrg# func_execute_cmds commands fail_cmd 2579fda9279dSmrg# Execute tilde-delimited COMMANDS. 2580fda9279dSmrg# If FAIL_CMD is given, eval that upon failure. 2581fda9279dSmrg# FAIL_CMD may read-access the current command in variable CMD! 2582fda9279dSmrgfunc_execute_cmds () 2583fda9279dSmrg{ 258416ee1e9aSmrg $debug_cmd 258516ee1e9aSmrg 2586fda9279dSmrg save_ifs=$IFS; IFS='~' 2587fda9279dSmrg for cmd in $1; do 258816ee1e9aSmrg IFS=$sp$nl 2589fda9279dSmrg eval cmd=\"$cmd\" 259016ee1e9aSmrg IFS=$save_ifs 2591fda9279dSmrg func_show_eval "$cmd" "${2-:}" 2592fda9279dSmrg done 2593fda9279dSmrg IFS=$save_ifs 2594fda9279dSmrg} 2595fda9279dSmrg 2596fda9279dSmrg 2597fda9279dSmrg# func_source file 2598fda9279dSmrg# Source FILE, adding directory component if necessary. 2599fda9279dSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600fda9279dSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601fda9279dSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260216ee1e9aSmrg# 'FILE.' does not work on cygwin managed mounts. 2603fda9279dSmrgfunc_source () 2604fda9279dSmrg{ 260516ee1e9aSmrg $debug_cmd 260616ee1e9aSmrg 2607fda9279dSmrg case $1 in 2608fda9279dSmrg */* | *\\*) . "$1" ;; 2609fda9279dSmrg *) . "./$1" ;; 2610fda9279dSmrg esac 2611fda9279dSmrg} 2612fda9279dSmrg 2613fda9279dSmrg 2614fda9279dSmrg# func_resolve_sysroot PATH 2615fda9279dSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2616fda9279dSmrg# func_resolve_sysroot_result 2617fda9279dSmrgfunc_resolve_sysroot () 2618fda9279dSmrg{ 2619fda9279dSmrg func_resolve_sysroot_result=$1 2620fda9279dSmrg case $func_resolve_sysroot_result in 2621fda9279dSmrg =*) 2622fda9279dSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2623fda9279dSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624fda9279dSmrg ;; 2625fda9279dSmrg esac 2626fda9279dSmrg} 2627fda9279dSmrg 2628fda9279dSmrg# func_replace_sysroot PATH 2629fda9279dSmrg# If PATH begins with the sysroot, replace it with = and 2630fda9279dSmrg# store the result into func_replace_sysroot_result. 2631fda9279dSmrgfunc_replace_sysroot () 2632fda9279dSmrg{ 263316ee1e9aSmrg case $lt_sysroot:$1 in 2634fda9279dSmrg ?*:"$lt_sysroot"*) 2635fda9279dSmrg func_stripname "$lt_sysroot" '' "$1" 263616ee1e9aSmrg func_replace_sysroot_result='='$func_stripname_result 2637fda9279dSmrg ;; 2638fda9279dSmrg *) 2639fda9279dSmrg # Including no sysroot. 2640fda9279dSmrg func_replace_sysroot_result=$1 2641fda9279dSmrg ;; 2642fda9279dSmrg esac 2643fda9279dSmrg} 2644fda9279dSmrg 2645fda9279dSmrg# func_infer_tag arg 2646fda9279dSmrg# Infer tagged configuration to use if any are available and 2647fda9279dSmrg# if one wasn't chosen via the "--tag" command line option. 2648fda9279dSmrg# Only attempt this if the compiler in the base compile 2649fda9279dSmrg# command doesn't match the default compiler. 2650fda9279dSmrg# arg is usually of the form 'gcc ...' 2651fda9279dSmrgfunc_infer_tag () 2652fda9279dSmrg{ 265316ee1e9aSmrg $debug_cmd 265416ee1e9aSmrg 2655fda9279dSmrg if test -n "$available_tags" && test -z "$tagname"; then 2656fda9279dSmrg CC_quoted= 2657fda9279dSmrg for arg in $CC; do 2658fda9279dSmrg func_append_quoted CC_quoted "$arg" 2659fda9279dSmrg done 2660fda9279dSmrg CC_expanded=`func_echo_all $CC` 2661fda9279dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662fda9279dSmrg case $@ in 2663fda9279dSmrg # Blanks in the command may have been stripped by the calling shell, 2664fda9279dSmrg # but not from the CC environment variable when configure was run. 2665fda9279dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666fda9279dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667fda9279dSmrg # Blanks at the start of $base_compile will cause this to fail 2668fda9279dSmrg # if we don't check for them as well. 2669fda9279dSmrg *) 2670fda9279dSmrg for z in $available_tags; do 2671fda9279dSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672fda9279dSmrg # Evaluate the configuration. 267316ee1e9aSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674fda9279dSmrg CC_quoted= 2675fda9279dSmrg for arg in $CC; do 2676fda9279dSmrg # Double-quote args containing other shell metacharacters. 2677fda9279dSmrg func_append_quoted CC_quoted "$arg" 2678fda9279dSmrg done 2679fda9279dSmrg CC_expanded=`func_echo_all $CC` 2680fda9279dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681fda9279dSmrg case "$@ " in 2682fda9279dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683fda9279dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684fda9279dSmrg # The compiler in the base compile command matches 2685fda9279dSmrg # the one in the tagged configuration. 2686fda9279dSmrg # Assume this is the tagged configuration we want. 2687fda9279dSmrg tagname=$z 2688fda9279dSmrg break 2689fda9279dSmrg ;; 2690fda9279dSmrg esac 2691fda9279dSmrg fi 2692fda9279dSmrg done 2693fda9279dSmrg # If $tagname still isn't set, then no tagged configuration 2694fda9279dSmrg # was found and let the user know that the "--tag" command 2695fda9279dSmrg # line option must be used. 2696fda9279dSmrg if test -z "$tagname"; then 2697fda9279dSmrg func_echo "unable to infer tagged configuration" 269816ee1e9aSmrg func_fatal_error "specify a tag with '--tag'" 2699fda9279dSmrg# else 2700fda9279dSmrg# func_verbose "using $tagname tagged configuration" 2701fda9279dSmrg fi 2702fda9279dSmrg ;; 2703fda9279dSmrg esac 2704fda9279dSmrg fi 2705fda9279dSmrg} 2706fda9279dSmrg 2707fda9279dSmrg 2708fda9279dSmrg 2709fda9279dSmrg# func_write_libtool_object output_name pic_name nonpic_name 2710fda9279dSmrg# Create a libtool object file (analogous to a ".la" file), 2711fda9279dSmrg# but don't create it if we're doing a dry run. 2712fda9279dSmrgfunc_write_libtool_object () 2713fda9279dSmrg{ 271416ee1e9aSmrg write_libobj=$1 271516ee1e9aSmrg if test yes = "$build_libtool_libs"; then 271616ee1e9aSmrg write_lobj=\'$2\' 2717fda9279dSmrg else 2718fda9279dSmrg write_lobj=none 2719fda9279dSmrg fi 2720fda9279dSmrg 272116ee1e9aSmrg if test yes = "$build_old_libs"; then 272216ee1e9aSmrg write_oldobj=\'$3\' 2723fda9279dSmrg else 2724fda9279dSmrg write_oldobj=none 2725fda9279dSmrg fi 2726fda9279dSmrg 2727fda9279dSmrg $opt_dry_run || { 2728fda9279dSmrg cat >${write_libobj}T <<EOF 2729fda9279dSmrg# $write_libobj - a libtool object file 273016ee1e9aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731fda9279dSmrg# 2732fda9279dSmrg# Please DO NOT delete this file! 2733fda9279dSmrg# It is necessary for linking the library. 2734fda9279dSmrg 2735fda9279dSmrg# Name of the PIC object. 2736fda9279dSmrgpic_object=$write_lobj 2737fda9279dSmrg 2738fda9279dSmrg# Name of the non-PIC object 2739fda9279dSmrgnon_pic_object=$write_oldobj 2740fda9279dSmrg 2741fda9279dSmrgEOF 274216ee1e9aSmrg $MV "${write_libobj}T" "$write_libobj" 2743fda9279dSmrg } 2744fda9279dSmrg} 2745fda9279dSmrg 2746fda9279dSmrg 2747fda9279dSmrg################################################## 2748fda9279dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749fda9279dSmrg################################################## 2750fda9279dSmrg 2751fda9279dSmrg# func_convert_core_file_wine_to_w32 ARG 2752fda9279dSmrg# Helper function used by file name conversion functions when $build is *nix, 2753fda9279dSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754fda9279dSmrg# correctly configured wine environment available, with the winepath program 2755fda9279dSmrg# in $build's $PATH. 2756fda9279dSmrg# 2757fda9279dSmrg# ARG is the $build file name to be converted to w32 format. 2758fda9279dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759fda9279dSmrg# be empty on error (or when ARG is empty) 2760fda9279dSmrgfunc_convert_core_file_wine_to_w32 () 2761fda9279dSmrg{ 276216ee1e9aSmrg $debug_cmd 276316ee1e9aSmrg 276416ee1e9aSmrg func_convert_core_file_wine_to_w32_result=$1 2765fda9279dSmrg if test -n "$1"; then 2766fda9279dSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2767fda9279dSmrg # are forced to check the contents of stdout. On the other hand, if the 2768fda9279dSmrg # command is not found, the shell will set an exit code of 127 and print 2769fda9279dSmrg # *an error message* to stdout. So we must check for both error code of 2770fda9279dSmrg # zero AND non-empty stdout, which explains the odd construction: 2771fda9279dSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277216ee1e9aSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773fda9279dSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277416ee1e9aSmrg $SED -e "$sed_naive_backslashify"` 2775fda9279dSmrg else 2776fda9279dSmrg func_convert_core_file_wine_to_w32_result= 2777fda9279dSmrg fi 2778fda9279dSmrg fi 2779fda9279dSmrg} 2780fda9279dSmrg# end: func_convert_core_file_wine_to_w32 2781fda9279dSmrg 2782fda9279dSmrg 2783fda9279dSmrg# func_convert_core_path_wine_to_w32 ARG 2784fda9279dSmrg# Helper function used by path conversion functions when $build is *nix, and 2785fda9279dSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786fda9279dSmrg# configured wine environment available, with the winepath program in $build's 2787fda9279dSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788fda9279dSmrg# 2789fda9279dSmrg# ARG is path to be converted from $build format to win32. 2790fda9279dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2791fda9279dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792fda9279dSmrg# are convertible, then the result may be empty. 2793fda9279dSmrgfunc_convert_core_path_wine_to_w32 () 2794fda9279dSmrg{ 279516ee1e9aSmrg $debug_cmd 279616ee1e9aSmrg 2797fda9279dSmrg # unfortunately, winepath doesn't convert paths, only file names 279816ee1e9aSmrg func_convert_core_path_wine_to_w32_result= 2799fda9279dSmrg if test -n "$1"; then 2800fda9279dSmrg oldIFS=$IFS 2801fda9279dSmrg IFS=: 2802fda9279dSmrg for func_convert_core_path_wine_to_w32_f in $1; do 2803fda9279dSmrg IFS=$oldIFS 2804fda9279dSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280516ee1e9aSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806fda9279dSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280716ee1e9aSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808fda9279dSmrg else 2809fda9279dSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810fda9279dSmrg fi 2811fda9279dSmrg fi 2812fda9279dSmrg done 2813fda9279dSmrg IFS=$oldIFS 2814fda9279dSmrg fi 2815fda9279dSmrg} 2816fda9279dSmrg# end: func_convert_core_path_wine_to_w32 2817fda9279dSmrg 2818fda9279dSmrg 2819fda9279dSmrg# func_cygpath ARGS... 2820fda9279dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821fda9279dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822fda9279dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823fda9279dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824fda9279dSmrg# file name or path is assumed to be in w32 format, as previously converted 2825fda9279dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826fda9279dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 2827fda9279dSmrg# Cygwin format). Returns an empty string on error. 2828fda9279dSmrg# 2829fda9279dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 2830fda9279dSmrg# be converted. 2831fda9279dSmrg# 2832fda9279dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833fda9279dSmrg# environment variable; do not put it in $PATH. 2834fda9279dSmrgfunc_cygpath () 2835fda9279dSmrg{ 283616ee1e9aSmrg $debug_cmd 283716ee1e9aSmrg 2838fda9279dSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839fda9279dSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840fda9279dSmrg if test "$?" -ne 0; then 2841fda9279dSmrg # on failure, ensure result is empty 2842fda9279dSmrg func_cygpath_result= 2843fda9279dSmrg fi 2844fda9279dSmrg else 2845fda9279dSmrg func_cygpath_result= 284616ee1e9aSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847fda9279dSmrg fi 2848fda9279dSmrg} 2849fda9279dSmrg#end: func_cygpath 2850fda9279dSmrg 2851fda9279dSmrg 2852fda9279dSmrg# func_convert_core_msys_to_w32 ARG 2853fda9279dSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 2854fda9279dSmrg# result in func_convert_core_msys_to_w32_result. 2855fda9279dSmrgfunc_convert_core_msys_to_w32 () 2856fda9279dSmrg{ 285716ee1e9aSmrg $debug_cmd 285816ee1e9aSmrg 2859fda9279dSmrg # awkward: cmd appends spaces to result 2860fda9279dSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286116ee1e9aSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862fda9279dSmrg} 2863fda9279dSmrg#end: func_convert_core_msys_to_w32 2864fda9279dSmrg 2865fda9279dSmrg 2866fda9279dSmrg# func_convert_file_check ARG1 ARG2 2867fda9279dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 2868fda9279dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869fda9279dSmrg# func_to_host_file_result to ARG1). 2870fda9279dSmrgfunc_convert_file_check () 2871fda9279dSmrg{ 287216ee1e9aSmrg $debug_cmd 287316ee1e9aSmrg 287416ee1e9aSmrg if test -z "$2" && test -n "$1"; then 2875fda9279dSmrg func_error "Could not determine host file name corresponding to" 287616ee1e9aSmrg func_error " '$1'" 2877fda9279dSmrg func_error "Continuing, but uninstalled executables may not work." 2878fda9279dSmrg # Fallback: 287916ee1e9aSmrg func_to_host_file_result=$1 2880fda9279dSmrg fi 2881fda9279dSmrg} 2882fda9279dSmrg# end func_convert_file_check 2883fda9279dSmrg 2884fda9279dSmrg 2885fda9279dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886fda9279dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2887fda9279dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888fda9279dSmrg# func_to_host_file_result to a simplistic fallback value (see below). 2889fda9279dSmrgfunc_convert_path_check () 2890fda9279dSmrg{ 289116ee1e9aSmrg $debug_cmd 289216ee1e9aSmrg 2893fda9279dSmrg if test -z "$4" && test -n "$3"; then 2894fda9279dSmrg func_error "Could not determine the host path corresponding to" 289516ee1e9aSmrg func_error " '$3'" 2896fda9279dSmrg func_error "Continuing, but uninstalled executables may not work." 2897fda9279dSmrg # Fallback. This is a deliberately simplistic "conversion" and 2898fda9279dSmrg # should not be "improved". See libtool.info. 2899fda9279dSmrg if test "x$1" != "x$2"; then 2900fda9279dSmrg lt_replace_pathsep_chars="s|$1|$2|g" 2901fda9279dSmrg func_to_host_path_result=`echo "$3" | 2902fda9279dSmrg $SED -e "$lt_replace_pathsep_chars"` 2903fda9279dSmrg else 290416ee1e9aSmrg func_to_host_path_result=$3 2905fda9279dSmrg fi 2906fda9279dSmrg fi 2907fda9279dSmrg} 2908fda9279dSmrg# end func_convert_path_check 2909fda9279dSmrg 2910fda9279dSmrg 2911fda9279dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912fda9279dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913fda9279dSmrg# and appending REPL if ORIG matches BACKPAT. 2914fda9279dSmrgfunc_convert_path_front_back_pathsep () 2915fda9279dSmrg{ 291616ee1e9aSmrg $debug_cmd 291716ee1e9aSmrg 2918fda9279dSmrg case $4 in 291916ee1e9aSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920fda9279dSmrg ;; 2921fda9279dSmrg esac 2922fda9279dSmrg case $4 in 2923fda9279dSmrg $2 ) func_append func_to_host_path_result "$3" 2924fda9279dSmrg ;; 2925fda9279dSmrg esac 2926fda9279dSmrg} 2927fda9279dSmrg# end func_convert_path_front_back_pathsep 2928fda9279dSmrg 2929fda9279dSmrg 2930fda9279dSmrg################################################## 2931fda9279dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932fda9279dSmrg################################################## 293316ee1e9aSmrg# invoked via '$to_host_file_cmd ARG' 2934fda9279dSmrg# 2935fda9279dSmrg# In each case, ARG is the path to be converted from $build to $host format. 2936fda9279dSmrg# Result will be available in $func_to_host_file_result. 2937fda9279dSmrg 2938fda9279dSmrg 2939fda9279dSmrg# func_to_host_file ARG 2940fda9279dSmrg# Converts the file name ARG from $build format to $host format. Return result 2941fda9279dSmrg# in func_to_host_file_result. 2942fda9279dSmrgfunc_to_host_file () 2943fda9279dSmrg{ 294416ee1e9aSmrg $debug_cmd 294516ee1e9aSmrg 2946fda9279dSmrg $to_host_file_cmd "$1" 2947fda9279dSmrg} 2948fda9279dSmrg# end func_to_host_file 2949fda9279dSmrg 2950fda9279dSmrg 2951fda9279dSmrg# func_to_tool_file ARG LAZY 2952fda9279dSmrg# converts the file name ARG from $build format to toolchain format. Return 2953fda9279dSmrg# result in func_to_tool_file_result. If the conversion in use is listed 2954fda9279dSmrg# in (the comma separated) LAZY, no conversion takes place. 2955fda9279dSmrgfunc_to_tool_file () 2956fda9279dSmrg{ 295716ee1e9aSmrg $debug_cmd 295816ee1e9aSmrg 2959fda9279dSmrg case ,$2, in 2960fda9279dSmrg *,"$to_tool_file_cmd",*) 2961fda9279dSmrg func_to_tool_file_result=$1 2962fda9279dSmrg ;; 2963fda9279dSmrg *) 2964fda9279dSmrg $to_tool_file_cmd "$1" 2965fda9279dSmrg func_to_tool_file_result=$func_to_host_file_result 2966fda9279dSmrg ;; 2967fda9279dSmrg esac 2968fda9279dSmrg} 2969fda9279dSmrg# end func_to_tool_file 2970fda9279dSmrg 2971fda9279dSmrg 2972fda9279dSmrg# func_convert_file_noop ARG 2973fda9279dSmrg# Copy ARG to func_to_host_file_result. 2974fda9279dSmrgfunc_convert_file_noop () 2975fda9279dSmrg{ 297616ee1e9aSmrg func_to_host_file_result=$1 2977fda9279dSmrg} 2978fda9279dSmrg# end func_convert_file_noop 2979fda9279dSmrg 2980fda9279dSmrg 2981fda9279dSmrg# func_convert_file_msys_to_w32 ARG 2982fda9279dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983fda9279dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 2984fda9279dSmrg# func_to_host_file_result. 2985fda9279dSmrgfunc_convert_file_msys_to_w32 () 2986fda9279dSmrg{ 298716ee1e9aSmrg $debug_cmd 298816ee1e9aSmrg 298916ee1e9aSmrg func_to_host_file_result=$1 2990fda9279dSmrg if test -n "$1"; then 2991fda9279dSmrg func_convert_core_msys_to_w32 "$1" 299216ee1e9aSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993fda9279dSmrg fi 2994fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 2995fda9279dSmrg} 2996fda9279dSmrg# end func_convert_file_msys_to_w32 2997fda9279dSmrg 2998fda9279dSmrg 2999fda9279dSmrg# func_convert_file_cygwin_to_w32 ARG 3000fda9279dSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3001fda9279dSmrg# func_to_host_file_result. 3002fda9279dSmrgfunc_convert_file_cygwin_to_w32 () 3003fda9279dSmrg{ 300416ee1e9aSmrg $debug_cmd 300516ee1e9aSmrg 300616ee1e9aSmrg func_to_host_file_result=$1 3007fda9279dSmrg if test -n "$1"; then 3008fda9279dSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009fda9279dSmrg # LT_CYGPATH in this case. 3010fda9279dSmrg func_to_host_file_result=`cygpath -m "$1"` 3011fda9279dSmrg fi 3012fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3013fda9279dSmrg} 3014fda9279dSmrg# end func_convert_file_cygwin_to_w32 3015fda9279dSmrg 3016fda9279dSmrg 3017fda9279dSmrg# func_convert_file_nix_to_w32 ARG 3018fda9279dSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019fda9279dSmrg# and a working winepath. Returns result in func_to_host_file_result. 3020fda9279dSmrgfunc_convert_file_nix_to_w32 () 3021fda9279dSmrg{ 302216ee1e9aSmrg $debug_cmd 302316ee1e9aSmrg 302416ee1e9aSmrg func_to_host_file_result=$1 3025fda9279dSmrg if test -n "$1"; then 3026fda9279dSmrg func_convert_core_file_wine_to_w32 "$1" 302716ee1e9aSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028fda9279dSmrg fi 3029fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3030fda9279dSmrg} 3031fda9279dSmrg# end func_convert_file_nix_to_w32 3032fda9279dSmrg 3033fda9279dSmrg 3034fda9279dSmrg# func_convert_file_msys_to_cygwin ARG 3035fda9279dSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036fda9279dSmrg# Returns result in func_to_host_file_result. 3037fda9279dSmrgfunc_convert_file_msys_to_cygwin () 3038fda9279dSmrg{ 303916ee1e9aSmrg $debug_cmd 304016ee1e9aSmrg 304116ee1e9aSmrg func_to_host_file_result=$1 3042fda9279dSmrg if test -n "$1"; then 3043fda9279dSmrg func_convert_core_msys_to_w32 "$1" 3044fda9279dSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304516ee1e9aSmrg func_to_host_file_result=$func_cygpath_result 3046fda9279dSmrg fi 3047fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3048fda9279dSmrg} 3049fda9279dSmrg# end func_convert_file_msys_to_cygwin 3050fda9279dSmrg 3051fda9279dSmrg 3052fda9279dSmrg# func_convert_file_nix_to_cygwin ARG 3053fda9279dSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054fda9279dSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055fda9279dSmrg# in func_to_host_file_result. 3056fda9279dSmrgfunc_convert_file_nix_to_cygwin () 3057fda9279dSmrg{ 305816ee1e9aSmrg $debug_cmd 305916ee1e9aSmrg 306016ee1e9aSmrg func_to_host_file_result=$1 3061fda9279dSmrg if test -n "$1"; then 3062fda9279dSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063fda9279dSmrg func_convert_core_file_wine_to_w32 "$1" 3064fda9279dSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306516ee1e9aSmrg func_to_host_file_result=$func_cygpath_result 3066fda9279dSmrg fi 3067fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3068fda9279dSmrg} 3069fda9279dSmrg# end func_convert_file_nix_to_cygwin 3070fda9279dSmrg 3071fda9279dSmrg 3072fda9279dSmrg############################################# 3073fda9279dSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3074fda9279dSmrg############################################# 307516ee1e9aSmrg# invoked via '$to_host_path_cmd ARG' 3076fda9279dSmrg# 3077fda9279dSmrg# In each case, ARG is the path to be converted from $build to $host format. 3078fda9279dSmrg# The result will be available in $func_to_host_path_result. 3079fda9279dSmrg# 3080fda9279dSmrg# Path separators are also converted from $build format to $host format. If 3081fda9279dSmrg# ARG begins or ends with a path separator character, it is preserved (but 3082fda9279dSmrg# converted to $host format) on output. 3083fda9279dSmrg# 3084fda9279dSmrg# All path conversion functions are named using the following convention: 3085fda9279dSmrg# file name conversion function : func_convert_file_X_to_Y () 3086fda9279dSmrg# path conversion function : func_convert_path_X_to_Y () 3087fda9279dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3088fda9279dSmrg# same. If conversion functions are added for new $build/$host combinations, 3089fda9279dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090fda9279dSmrg# will break. 3091fda9279dSmrg 3092fda9279dSmrg 3093fda9279dSmrg# func_init_to_host_path_cmd 3094fda9279dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095fda9279dSmrg# appropriate value, based on the value of $to_host_file_cmd. 3096fda9279dSmrgto_host_path_cmd= 3097fda9279dSmrgfunc_init_to_host_path_cmd () 3098fda9279dSmrg{ 309916ee1e9aSmrg $debug_cmd 310016ee1e9aSmrg 3101fda9279dSmrg if test -z "$to_host_path_cmd"; then 3102fda9279dSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310316ee1e9aSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3104fda9279dSmrg fi 3105fda9279dSmrg} 3106fda9279dSmrg 3107fda9279dSmrg 3108fda9279dSmrg# func_to_host_path ARG 3109fda9279dSmrg# Converts the path ARG from $build format to $host format. Return result 3110fda9279dSmrg# in func_to_host_path_result. 3111fda9279dSmrgfunc_to_host_path () 3112fda9279dSmrg{ 311316ee1e9aSmrg $debug_cmd 311416ee1e9aSmrg 3115fda9279dSmrg func_init_to_host_path_cmd 3116fda9279dSmrg $to_host_path_cmd "$1" 3117fda9279dSmrg} 3118fda9279dSmrg# end func_to_host_path 3119fda9279dSmrg 3120fda9279dSmrg 3121fda9279dSmrg# func_convert_path_noop ARG 3122fda9279dSmrg# Copy ARG to func_to_host_path_result. 3123fda9279dSmrgfunc_convert_path_noop () 3124fda9279dSmrg{ 312516ee1e9aSmrg func_to_host_path_result=$1 3126fda9279dSmrg} 3127fda9279dSmrg# end func_convert_path_noop 3128fda9279dSmrg 3129fda9279dSmrg 3130fda9279dSmrg# func_convert_path_msys_to_w32 ARG 3131fda9279dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132fda9279dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3133fda9279dSmrg# func_to_host_path_result. 3134fda9279dSmrgfunc_convert_path_msys_to_w32 () 3135fda9279dSmrg{ 313616ee1e9aSmrg $debug_cmd 313716ee1e9aSmrg 313816ee1e9aSmrg func_to_host_path_result=$1 3139fda9279dSmrg if test -n "$1"; then 3140fda9279dSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3141fda9279dSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142fda9279dSmrg # and winepath ignores them completely. 3143fda9279dSmrg func_stripname : : "$1" 3144fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3145fda9279dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314616ee1e9aSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147fda9279dSmrg func_convert_path_check : ";" \ 3148fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150fda9279dSmrg fi 3151fda9279dSmrg} 3152fda9279dSmrg# end func_convert_path_msys_to_w32 3153fda9279dSmrg 3154fda9279dSmrg 3155fda9279dSmrg# func_convert_path_cygwin_to_w32 ARG 3156fda9279dSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3157fda9279dSmrg# func_to_host_file_result. 3158fda9279dSmrgfunc_convert_path_cygwin_to_w32 () 3159fda9279dSmrg{ 316016ee1e9aSmrg $debug_cmd 316116ee1e9aSmrg 316216ee1e9aSmrg func_to_host_path_result=$1 3163fda9279dSmrg if test -n "$1"; then 3164fda9279dSmrg # See func_convert_path_msys_to_w32: 3165fda9279dSmrg func_stripname : : "$1" 3166fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3167fda9279dSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168fda9279dSmrg func_convert_path_check : ";" \ 3169fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171fda9279dSmrg fi 3172fda9279dSmrg} 3173fda9279dSmrg# end func_convert_path_cygwin_to_w32 3174fda9279dSmrg 3175fda9279dSmrg 3176fda9279dSmrg# func_convert_path_nix_to_w32 ARG 3177fda9279dSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178fda9279dSmrg# a working winepath. Returns result in func_to_host_file_result. 3179fda9279dSmrgfunc_convert_path_nix_to_w32 () 3180fda9279dSmrg{ 318116ee1e9aSmrg $debug_cmd 318216ee1e9aSmrg 318316ee1e9aSmrg func_to_host_path_result=$1 3184fda9279dSmrg if test -n "$1"; then 3185fda9279dSmrg # See func_convert_path_msys_to_w32: 3186fda9279dSmrg func_stripname : : "$1" 3187fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3188fda9279dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318916ee1e9aSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190fda9279dSmrg func_convert_path_check : ";" \ 3191fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193fda9279dSmrg fi 3194fda9279dSmrg} 3195fda9279dSmrg# end func_convert_path_nix_to_w32 3196fda9279dSmrg 3197fda9279dSmrg 3198fda9279dSmrg# func_convert_path_msys_to_cygwin ARG 3199fda9279dSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200fda9279dSmrg# Returns result in func_to_host_file_result. 3201fda9279dSmrgfunc_convert_path_msys_to_cygwin () 3202fda9279dSmrg{ 320316ee1e9aSmrg $debug_cmd 320416ee1e9aSmrg 320516ee1e9aSmrg func_to_host_path_result=$1 3206fda9279dSmrg if test -n "$1"; then 3207fda9279dSmrg # See func_convert_path_msys_to_w32: 3208fda9279dSmrg func_stripname : : "$1" 3209fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3210fda9279dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211fda9279dSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321216ee1e9aSmrg func_to_host_path_result=$func_cygpath_result 3213fda9279dSmrg func_convert_path_check : : \ 3214fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216fda9279dSmrg fi 3217fda9279dSmrg} 3218fda9279dSmrg# end func_convert_path_msys_to_cygwin 3219fda9279dSmrg 3220fda9279dSmrg 3221fda9279dSmrg# func_convert_path_nix_to_cygwin ARG 3222fda9279dSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223fda9279dSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224fda9279dSmrg# func_to_host_file_result. 3225fda9279dSmrgfunc_convert_path_nix_to_cygwin () 3226fda9279dSmrg{ 322716ee1e9aSmrg $debug_cmd 322816ee1e9aSmrg 322916ee1e9aSmrg func_to_host_path_result=$1 3230fda9279dSmrg if test -n "$1"; then 3231fda9279dSmrg # Remove leading and trailing path separator characters from 3232fda9279dSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3233fda9279dSmrg # into '.;' and ';.', and winepath ignores them completely. 3234fda9279dSmrg func_stripname : : "$1" 3235fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3236fda9279dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237fda9279dSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323816ee1e9aSmrg func_to_host_path_result=$func_cygpath_result 3239fda9279dSmrg func_convert_path_check : : \ 3240fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242fda9279dSmrg fi 3243fda9279dSmrg} 3244fda9279dSmrg# end func_convert_path_nix_to_cygwin 3245fda9279dSmrg 3246fda9279dSmrg 324716ee1e9aSmrg# func_dll_def_p FILE 324816ee1e9aSmrg# True iff FILE is a Windows DLL '.def' file. 324916ee1e9aSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325016ee1e9aSmrgfunc_dll_def_p () 325116ee1e9aSmrg{ 325216ee1e9aSmrg $debug_cmd 325316ee1e9aSmrg 325416ee1e9aSmrg func_dll_def_p_tmp=`$SED -n \ 325516ee1e9aSmrg -e 's/^[ ]*//' \ 325616ee1e9aSmrg -e '/^\(;.*\)*$/d' \ 325716ee1e9aSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325816ee1e9aSmrg -e q \ 325916ee1e9aSmrg "$1"` 326016ee1e9aSmrg test DEF = "$func_dll_def_p_tmp" 326116ee1e9aSmrg} 326216ee1e9aSmrg 326316ee1e9aSmrg 3264fda9279dSmrg# func_mode_compile arg... 3265fda9279dSmrgfunc_mode_compile () 3266fda9279dSmrg{ 326716ee1e9aSmrg $debug_cmd 326816ee1e9aSmrg 3269fda9279dSmrg # Get the compilation command and the source file. 3270fda9279dSmrg base_compile= 327116ee1e9aSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272fda9279dSmrg suppress_opt=yes 3273fda9279dSmrg suppress_output= 3274fda9279dSmrg arg_mode=normal 3275fda9279dSmrg libobj= 3276fda9279dSmrg later= 3277fda9279dSmrg pie_flag= 3278fda9279dSmrg 3279fda9279dSmrg for arg 3280fda9279dSmrg do 3281fda9279dSmrg case $arg_mode in 3282fda9279dSmrg arg ) 3283fda9279dSmrg # do not "continue". Instead, add this to base_compile 328416ee1e9aSmrg lastarg=$arg 3285fda9279dSmrg arg_mode=normal 3286fda9279dSmrg ;; 3287fda9279dSmrg 3288fda9279dSmrg target ) 328916ee1e9aSmrg libobj=$arg 3290fda9279dSmrg arg_mode=normal 3291fda9279dSmrg continue 3292fda9279dSmrg ;; 3293fda9279dSmrg 3294fda9279dSmrg normal ) 3295fda9279dSmrg # Accept any command-line options. 3296fda9279dSmrg case $arg in 3297fda9279dSmrg -o) 3298fda9279dSmrg test -n "$libobj" && \ 329916ee1e9aSmrg func_fatal_error "you cannot specify '-o' more than once" 3300fda9279dSmrg arg_mode=target 3301fda9279dSmrg continue 3302fda9279dSmrg ;; 3303fda9279dSmrg 3304fda9279dSmrg -pie | -fpie | -fPIE) 3305fda9279dSmrg func_append pie_flag " $arg" 3306fda9279dSmrg continue 3307fda9279dSmrg ;; 3308fda9279dSmrg 3309fda9279dSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 3310fda9279dSmrg func_append later " $arg" 3311fda9279dSmrg continue 3312fda9279dSmrg ;; 3313fda9279dSmrg 3314fda9279dSmrg -no-suppress) 3315fda9279dSmrg suppress_opt=no 3316fda9279dSmrg continue 3317fda9279dSmrg ;; 3318fda9279dSmrg 3319fda9279dSmrg -Xcompiler) 3320fda9279dSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321fda9279dSmrg continue # The current "srcfile" will either be retained or 3322fda9279dSmrg ;; # replaced later. I would guess that would be a bug. 3323fda9279dSmrg 3324fda9279dSmrg -Wc,*) 3325fda9279dSmrg func_stripname '-Wc,' '' "$arg" 3326fda9279dSmrg args=$func_stripname_result 3327fda9279dSmrg lastarg= 332816ee1e9aSmrg save_ifs=$IFS; IFS=, 3329fda9279dSmrg for arg in $args; do 333016ee1e9aSmrg IFS=$save_ifs 3331fda9279dSmrg func_append_quoted lastarg "$arg" 3332fda9279dSmrg done 333316ee1e9aSmrg IFS=$save_ifs 3334fda9279dSmrg func_stripname ' ' '' "$lastarg" 3335fda9279dSmrg lastarg=$func_stripname_result 3336fda9279dSmrg 3337fda9279dSmrg # Add the arguments to base_compile. 3338fda9279dSmrg func_append base_compile " $lastarg" 3339fda9279dSmrg continue 3340fda9279dSmrg ;; 3341fda9279dSmrg 3342fda9279dSmrg *) 3343fda9279dSmrg # Accept the current argument as the source file. 3344fda9279dSmrg # The previous "srcfile" becomes the current argument. 3345fda9279dSmrg # 334616ee1e9aSmrg lastarg=$srcfile 334716ee1e9aSmrg srcfile=$arg 3348fda9279dSmrg ;; 3349fda9279dSmrg esac # case $arg 3350fda9279dSmrg ;; 3351fda9279dSmrg esac # case $arg_mode 3352fda9279dSmrg 3353fda9279dSmrg # Aesthetically quote the previous argument. 3354fda9279dSmrg func_append_quoted base_compile "$lastarg" 3355fda9279dSmrg done # for arg 3356fda9279dSmrg 3357fda9279dSmrg case $arg_mode in 3358fda9279dSmrg arg) 3359fda9279dSmrg func_fatal_error "you must specify an argument for -Xcompile" 3360fda9279dSmrg ;; 3361fda9279dSmrg target) 336216ee1e9aSmrg func_fatal_error "you must specify a target with '-o'" 3363fda9279dSmrg ;; 3364fda9279dSmrg *) 3365fda9279dSmrg # Get the name of the library object. 3366fda9279dSmrg test -z "$libobj" && { 3367fda9279dSmrg func_basename "$srcfile" 336816ee1e9aSmrg libobj=$func_basename_result 3369fda9279dSmrg } 3370fda9279dSmrg ;; 3371fda9279dSmrg esac 3372fda9279dSmrg 3373fda9279dSmrg # Recognize several different file suffixes. 3374fda9279dSmrg # If the user specifies -o file.o, it is replaced with file.lo 3375fda9279dSmrg case $libobj in 3376fda9279dSmrg *.[cCFSifmso] | \ 3377fda9279dSmrg *.ada | *.adb | *.ads | *.asm | \ 3378fda9279dSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379fda9279dSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380fda9279dSmrg func_xform "$libobj" 3381fda9279dSmrg libobj=$func_xform_result 3382fda9279dSmrg ;; 3383fda9279dSmrg esac 3384fda9279dSmrg 3385fda9279dSmrg case $libobj in 3386fda9279dSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387fda9279dSmrg *) 338816ee1e9aSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389fda9279dSmrg ;; 3390fda9279dSmrg esac 3391fda9279dSmrg 3392fda9279dSmrg func_infer_tag $base_compile 3393fda9279dSmrg 3394fda9279dSmrg for arg in $later; do 3395fda9279dSmrg case $arg in 3396fda9279dSmrg -shared) 339716ee1e9aSmrg test yes = "$build_libtool_libs" \ 339816ee1e9aSmrg || func_fatal_configuration "cannot build a shared library" 3399fda9279dSmrg build_old_libs=no 3400fda9279dSmrg continue 3401fda9279dSmrg ;; 3402fda9279dSmrg 3403fda9279dSmrg -static) 3404fda9279dSmrg build_libtool_libs=no 3405fda9279dSmrg build_old_libs=yes 3406fda9279dSmrg continue 3407fda9279dSmrg ;; 3408fda9279dSmrg 3409fda9279dSmrg -prefer-pic) 3410fda9279dSmrg pic_mode=yes 3411fda9279dSmrg continue 3412fda9279dSmrg ;; 3413fda9279dSmrg 3414fda9279dSmrg -prefer-non-pic) 3415fda9279dSmrg pic_mode=no 3416fda9279dSmrg continue 3417fda9279dSmrg ;; 3418fda9279dSmrg esac 3419fda9279dSmrg done 3420fda9279dSmrg 3421fda9279dSmrg func_quote_for_eval "$libobj" 3422fda9279dSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423fda9279dSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342416ee1e9aSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425fda9279dSmrg func_dirname_and_basename "$obj" "/" "" 342616ee1e9aSmrg objname=$func_basename_result 342716ee1e9aSmrg xdir=$func_dirname_result 342816ee1e9aSmrg lobj=$xdir$objdir/$objname 3429fda9279dSmrg 3430fda9279dSmrg test -z "$base_compile" && \ 3431fda9279dSmrg func_fatal_help "you must specify a compilation command" 3432fda9279dSmrg 3433fda9279dSmrg # Delete any leftover library objects. 343416ee1e9aSmrg if test yes = "$build_old_libs"; then 3435fda9279dSmrg removelist="$obj $lobj $libobj ${libobj}T" 3436fda9279dSmrg else 3437fda9279dSmrg removelist="$lobj $libobj ${libobj}T" 3438fda9279dSmrg fi 3439fda9279dSmrg 3440fda9279dSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441fda9279dSmrg case $host_os in 3442fda9279dSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443fda9279dSmrg pic_mode=default 3444fda9279dSmrg ;; 3445fda9279dSmrg esac 344616ee1e9aSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447fda9279dSmrg # non-PIC code in shared libraries is not supported 3448fda9279dSmrg pic_mode=default 3449fda9279dSmrg fi 3450fda9279dSmrg 3451fda9279dSmrg # Calculate the filename of the output object if compiler does 3452fda9279dSmrg # not support -o with -c 345316ee1e9aSmrg if test no = "$compiler_c_o"; then 345416ee1e9aSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345516ee1e9aSmrg lockfile=$output_obj.lock 3456fda9279dSmrg else 3457fda9279dSmrg output_obj= 3458fda9279dSmrg need_locks=no 3459fda9279dSmrg lockfile= 3460fda9279dSmrg fi 3461fda9279dSmrg 3462fda9279dSmrg # Lock this critical section if it is needed 3463fda9279dSmrg # We use this script file to make the link, it avoids creating a new file 346416ee1e9aSmrg if test yes = "$need_locks"; then 3465fda9279dSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466fda9279dSmrg func_echo "Waiting for $lockfile to be removed" 3467fda9279dSmrg sleep 2 3468fda9279dSmrg done 346916ee1e9aSmrg elif test warn = "$need_locks"; then 3470fda9279dSmrg if test -f "$lockfile"; then 3471fda9279dSmrg $ECHO "\ 3472fda9279dSmrg*** ERROR, $lockfile exists and contains: 3473fda9279dSmrg`cat $lockfile 2>/dev/null` 3474fda9279dSmrg 3475fda9279dSmrgThis indicates that another process is trying to use the same 3476fda9279dSmrgtemporary object file, and libtool could not work around it because 347716ee1e9aSmrgyour compiler does not support '-c' and '-o' together. If you 3478fda9279dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3479fda9279dSmrgavoid parallel builds (make -j) in this platform, or get a better 3480fda9279dSmrgcompiler." 3481fda9279dSmrg 3482fda9279dSmrg $opt_dry_run || $RM $removelist 3483fda9279dSmrg exit $EXIT_FAILURE 3484fda9279dSmrg fi 3485fda9279dSmrg func_append removelist " $output_obj" 3486fda9279dSmrg $ECHO "$srcfile" > "$lockfile" 3487fda9279dSmrg fi 3488fda9279dSmrg 3489fda9279dSmrg $opt_dry_run || $RM $removelist 3490fda9279dSmrg func_append removelist " $lockfile" 3491fda9279dSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492fda9279dSmrg 3493fda9279dSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494fda9279dSmrg srcfile=$func_to_tool_file_result 3495fda9279dSmrg func_quote_for_eval "$srcfile" 3496fda9279dSmrg qsrcfile=$func_quote_for_eval_result 3497fda9279dSmrg 3498fda9279dSmrg # Only build a PIC object if we are building libtool libraries. 349916ee1e9aSmrg if test yes = "$build_libtool_libs"; then 3500fda9279dSmrg # Without this assignment, base_compile gets emptied. 3501fda9279dSmrg fbsd_hideous_sh_bug=$base_compile 3502fda9279dSmrg 350316ee1e9aSmrg if test no != "$pic_mode"; then 3504fda9279dSmrg command="$base_compile $qsrcfile $pic_flag" 3505fda9279dSmrg else 3506fda9279dSmrg # Don't build PIC code 3507fda9279dSmrg command="$base_compile $qsrcfile" 3508fda9279dSmrg fi 3509fda9279dSmrg 3510fda9279dSmrg func_mkdir_p "$xdir$objdir" 3511fda9279dSmrg 3512fda9279dSmrg if test -z "$output_obj"; then 3513fda9279dSmrg # Place PIC objects in $objdir 3514fda9279dSmrg func_append command " -o $lobj" 3515fda9279dSmrg fi 3516fda9279dSmrg 3517fda9279dSmrg func_show_eval_locale "$command" \ 3518fda9279dSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519fda9279dSmrg 352016ee1e9aSmrg if test warn = "$need_locks" && 3521fda9279dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522fda9279dSmrg $ECHO "\ 3523fda9279dSmrg*** ERROR, $lockfile contains: 3524fda9279dSmrg`cat $lockfile 2>/dev/null` 3525fda9279dSmrg 3526fda9279dSmrgbut it should contain: 3527fda9279dSmrg$srcfile 3528fda9279dSmrg 3529fda9279dSmrgThis indicates that another process is trying to use the same 3530fda9279dSmrgtemporary object file, and libtool could not work around it because 353116ee1e9aSmrgyour compiler does not support '-c' and '-o' together. If you 3532fda9279dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3533fda9279dSmrgavoid parallel builds (make -j) in this platform, or get a better 3534fda9279dSmrgcompiler." 3535fda9279dSmrg 3536fda9279dSmrg $opt_dry_run || $RM $removelist 3537fda9279dSmrg exit $EXIT_FAILURE 3538fda9279dSmrg fi 3539fda9279dSmrg 3540fda9279dSmrg # Just move the object if needed, then go on to compile the next one 3541fda9279dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542fda9279dSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543fda9279dSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544fda9279dSmrg fi 3545fda9279dSmrg 3546fda9279dSmrg # Allow error messages only from the first compilation. 354716ee1e9aSmrg if test yes = "$suppress_opt"; then 3548fda9279dSmrg suppress_output=' >/dev/null 2>&1' 3549fda9279dSmrg fi 3550fda9279dSmrg fi 3551fda9279dSmrg 3552fda9279dSmrg # Only build a position-dependent object if we build old libraries. 355316ee1e9aSmrg if test yes = "$build_old_libs"; then 355416ee1e9aSmrg if test yes != "$pic_mode"; then 3555fda9279dSmrg # Don't build PIC code 3556fda9279dSmrg command="$base_compile $qsrcfile$pie_flag" 3557fda9279dSmrg else 3558fda9279dSmrg command="$base_compile $qsrcfile $pic_flag" 3559fda9279dSmrg fi 356016ee1e9aSmrg if test yes = "$compiler_c_o"; then 3561fda9279dSmrg func_append command " -o $obj" 3562fda9279dSmrg fi 3563fda9279dSmrg 3564fda9279dSmrg # Suppress compiler output if we already did a PIC compilation. 3565fda9279dSmrg func_append command "$suppress_output" 3566fda9279dSmrg func_show_eval_locale "$command" \ 3567fda9279dSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568fda9279dSmrg 356916ee1e9aSmrg if test warn = "$need_locks" && 3570fda9279dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571fda9279dSmrg $ECHO "\ 3572fda9279dSmrg*** ERROR, $lockfile contains: 3573fda9279dSmrg`cat $lockfile 2>/dev/null` 3574fda9279dSmrg 3575fda9279dSmrgbut it should contain: 3576fda9279dSmrg$srcfile 3577fda9279dSmrg 3578fda9279dSmrgThis indicates that another process is trying to use the same 3579fda9279dSmrgtemporary object file, and libtool could not work around it because 358016ee1e9aSmrgyour compiler does not support '-c' and '-o' together. If you 3581fda9279dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3582fda9279dSmrgavoid parallel builds (make -j) in this platform, or get a better 3583fda9279dSmrgcompiler." 3584fda9279dSmrg 3585fda9279dSmrg $opt_dry_run || $RM $removelist 3586fda9279dSmrg exit $EXIT_FAILURE 3587fda9279dSmrg fi 3588fda9279dSmrg 3589fda9279dSmrg # Just move the object if needed 3590fda9279dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591fda9279dSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592fda9279dSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593fda9279dSmrg fi 3594fda9279dSmrg fi 3595fda9279dSmrg 3596fda9279dSmrg $opt_dry_run || { 3597fda9279dSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598fda9279dSmrg 3599fda9279dSmrg # Unlock the critical section if it was locked 360016ee1e9aSmrg if test no != "$need_locks"; then 3601fda9279dSmrg removelist=$lockfile 3602fda9279dSmrg $RM "$lockfile" 3603fda9279dSmrg fi 3604fda9279dSmrg } 3605fda9279dSmrg 3606fda9279dSmrg exit $EXIT_SUCCESS 3607fda9279dSmrg} 3608fda9279dSmrg 3609fda9279dSmrg$opt_help || { 361016ee1e9aSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611fda9279dSmrg} 3612fda9279dSmrg 3613fda9279dSmrgfunc_mode_help () 3614fda9279dSmrg{ 3615fda9279dSmrg # We need to display help for each of the modes. 3616fda9279dSmrg case $opt_mode in 3617fda9279dSmrg "") 3618fda9279dSmrg # Generic help is extracted from the usage comments 3619fda9279dSmrg # at the start of this file. 3620fda9279dSmrg func_help 3621fda9279dSmrg ;; 3622fda9279dSmrg 3623fda9279dSmrg clean) 3624fda9279dSmrg $ECHO \ 3625fda9279dSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626fda9279dSmrg 3627fda9279dSmrgRemove files from the build directory. 3628fda9279dSmrg 3629fda9279dSmrgRM is the name of the program to use to delete files associated with each FILE 363016ee1e9aSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631fda9279dSmrgto RM. 3632fda9279dSmrg 3633fda9279dSmrgIf FILE is a libtool library, object or program, all the files associated 3634fda9279dSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635fda9279dSmrg ;; 3636fda9279dSmrg 3637fda9279dSmrg compile) 3638fda9279dSmrg $ECHO \ 3639fda9279dSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640fda9279dSmrg 3641fda9279dSmrgCompile a source file into a libtool library object. 3642fda9279dSmrg 3643fda9279dSmrgThis mode accepts the following additional options: 3644fda9279dSmrg 3645fda9279dSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646fda9279dSmrg -no-suppress do not suppress compiler output for multiple passes 3647fda9279dSmrg -prefer-pic try to build PIC objects only 3648fda9279dSmrg -prefer-non-pic try to build non-PIC objects only 364916ee1e9aSmrg -shared do not build a '.o' file suitable for static linking 365016ee1e9aSmrg -static only build a '.o' file suitable for static linking 3651fda9279dSmrg -Wc,FLAG pass FLAG directly to the compiler 3652fda9279dSmrg 365316ee1e9aSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654fda9279dSmrgfrom the given SOURCEFILE. 3655fda9279dSmrg 3656fda9279dSmrgThe output file name is determined by removing the directory component from 365716ee1e9aSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365816ee1e9aSmrglibrary object suffix, '.lo'." 3659fda9279dSmrg ;; 3660fda9279dSmrg 3661fda9279dSmrg execute) 3662fda9279dSmrg $ECHO \ 3663fda9279dSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664fda9279dSmrg 3665fda9279dSmrgAutomatically set library path, then run a program. 3666fda9279dSmrg 3667fda9279dSmrgThis mode accepts the following additional options: 3668fda9279dSmrg 3669fda9279dSmrg -dlopen FILE add the directory containing FILE to the library path 3670fda9279dSmrg 367116ee1e9aSmrgThis mode sets the library path environment variable according to '-dlopen' 3672fda9279dSmrgflags. 3673fda9279dSmrg 3674fda9279dSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675fda9279dSmrginto their corresponding uninstalled binary, and any of their required library 3676fda9279dSmrgdirectories are added to the library path. 3677fda9279dSmrg 3678fda9279dSmrgThen, COMMAND is executed, with ARGS as arguments." 3679fda9279dSmrg ;; 3680fda9279dSmrg 3681fda9279dSmrg finish) 3682fda9279dSmrg $ECHO \ 3683fda9279dSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684fda9279dSmrg 3685fda9279dSmrgComplete the installation of libtool libraries. 3686fda9279dSmrg 3687fda9279dSmrgEach LIBDIR is a directory that contains libtool libraries. 3688fda9279dSmrg 3689fda9279dSmrgThe commands that this mode executes may require superuser privileges. Use 369016ee1e9aSmrgthe '--dry-run' option if you just want to see what would be executed." 3691fda9279dSmrg ;; 3692fda9279dSmrg 3693fda9279dSmrg install) 3694fda9279dSmrg $ECHO \ 3695fda9279dSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696fda9279dSmrg 3697fda9279dSmrgInstall executables or libraries. 3698fda9279dSmrg 3699fda9279dSmrgINSTALL-COMMAND is the installation command. The first component should be 370016ee1e9aSmrgeither the 'install' or 'cp' program. 3701fda9279dSmrg 3702fda9279dSmrgThe following components of INSTALL-COMMAND are treated specially: 3703fda9279dSmrg 3704fda9279dSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705fda9279dSmrg 3706fda9279dSmrgThe rest of the components are interpreted as arguments to that command (only 3707fda9279dSmrgBSD-compatible install options are recognized)." 3708fda9279dSmrg ;; 3709fda9279dSmrg 3710fda9279dSmrg link) 3711fda9279dSmrg $ECHO \ 3712fda9279dSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713fda9279dSmrg 3714fda9279dSmrgLink object files or libraries together to form another library, or to 3715fda9279dSmrgcreate an executable program. 3716fda9279dSmrg 3717fda9279dSmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718fda9279dSmrga program from several object files. 3719fda9279dSmrg 3720fda9279dSmrgThe following components of LINK-COMMAND are treated specially: 3721fda9279dSmrg 3722fda9279dSmrg -all-static do not do any dynamic linking at all 3723fda9279dSmrg -avoid-version do not add a version suffix if possible 3724fda9279dSmrg -bindir BINDIR specify path to binaries directory (for systems where 3725fda9279dSmrg libraries must be found in the PATH setting at runtime) 372616ee1e9aSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727fda9279dSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728fda9279dSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729fda9279dSmrg -export-symbols SYMFILE 3730fda9279dSmrg try to export only the symbols listed in SYMFILE 3731fda9279dSmrg -export-symbols-regex REGEX 3732fda9279dSmrg try to export only the symbols matching REGEX 3733fda9279dSmrg -LLIBDIR search LIBDIR for required installed libraries 3734fda9279dSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735fda9279dSmrg -module build a library that can dlopened 3736fda9279dSmrg -no-fast-install disable the fast-install mode 3737fda9279dSmrg -no-install link a not-installable executable 3738fda9279dSmrg -no-undefined declare that a library does not refer to external symbols 3739fda9279dSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374016ee1e9aSmrg -objectlist FILE use a list of object files found in FILE to specify objects 374116ee1e9aSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742fda9279dSmrg -precious-files-regex REGEX 3743fda9279dSmrg don't remove output files matching REGEX 3744fda9279dSmrg -release RELEASE specify package release information 3745fda9279dSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746fda9279dSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747fda9279dSmrg -shared only do dynamic linking of libtool libraries 3748fda9279dSmrg -shrext SUFFIX override the standard shared library file extension 3749fda9279dSmrg -static do not do any dynamic linking of uninstalled libtool libraries 3750fda9279dSmrg -static-libtool-libs 3751fda9279dSmrg do not do any dynamic linking of libtool libraries 3752fda9279dSmrg -version-info CURRENT[:REVISION[:AGE]] 3753fda9279dSmrg specify library version info [each variable defaults to 0] 3754fda9279dSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 3755fda9279dSmrg -Wc,FLAG 3756fda9279dSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757fda9279dSmrg -Wl,FLAG 3758fda9279dSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759fda9279dSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760fda9279dSmrg 376116ee1e9aSmrgAll other options (arguments beginning with '-') are ignored. 3762fda9279dSmrg 376316ee1e9aSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764fda9279dSmrgtreated as uninstalled libtool libraries, other files are standard or library 3765fda9279dSmrgobject files. 3766fda9279dSmrg 376716ee1e9aSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376816ee1e9aSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769fda9279dSmrgrequired, except when creating a convenience library. 3770fda9279dSmrg 377116ee1e9aSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377216ee1e9aSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773fda9279dSmrg 377416ee1e9aSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775fda9279dSmrgis created, otherwise an executable program is created." 3776fda9279dSmrg ;; 3777fda9279dSmrg 3778fda9279dSmrg uninstall) 3779fda9279dSmrg $ECHO \ 3780fda9279dSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781fda9279dSmrg 3782fda9279dSmrgRemove libraries from an installation directory. 3783fda9279dSmrg 3784fda9279dSmrgRM is the name of the program to use to delete files associated with each FILE 378516ee1e9aSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786fda9279dSmrgto RM. 3787fda9279dSmrg 3788fda9279dSmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789fda9279dSmrgOtherwise, only FILE itself is deleted using RM." 3790fda9279dSmrg ;; 3791fda9279dSmrg 3792fda9279dSmrg *) 379316ee1e9aSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3794fda9279dSmrg ;; 3795fda9279dSmrg esac 3796fda9279dSmrg 3797fda9279dSmrg echo 379816ee1e9aSmrg $ECHO "Try '$progname --help' for more information about other modes." 3799fda9279dSmrg} 3800fda9279dSmrg 3801fda9279dSmrg# Now that we've collected a possible --mode arg, show help if necessary 3802fda9279dSmrgif $opt_help; then 380316ee1e9aSmrg if test : = "$opt_help"; then 3804fda9279dSmrg func_mode_help 3805fda9279dSmrg else 3806fda9279dSmrg { 3807fda9279dSmrg func_help noexit 3808fda9279dSmrg for opt_mode in compile link execute install finish uninstall clean; do 3809fda9279dSmrg func_mode_help 3810fda9279dSmrg done 381116ee1e9aSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812fda9279dSmrg { 3813fda9279dSmrg func_help noexit 3814fda9279dSmrg for opt_mode in compile link execute install finish uninstall clean; do 3815fda9279dSmrg echo 3816fda9279dSmrg func_mode_help 3817fda9279dSmrg done 3818fda9279dSmrg } | 381916ee1e9aSmrg $SED '1d 3820fda9279dSmrg /^When reporting/,/^Report/{ 3821fda9279dSmrg H 3822fda9279dSmrg d 3823fda9279dSmrg } 3824fda9279dSmrg $x 3825fda9279dSmrg /information about other modes/d 3826fda9279dSmrg /more detailed .*MODE/d 3827fda9279dSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828fda9279dSmrg fi 3829fda9279dSmrg exit $? 3830fda9279dSmrgfi 3831fda9279dSmrg 3832fda9279dSmrg 3833fda9279dSmrg# func_mode_execute arg... 3834fda9279dSmrgfunc_mode_execute () 3835fda9279dSmrg{ 383616ee1e9aSmrg $debug_cmd 383716ee1e9aSmrg 3838fda9279dSmrg # The first argument is the command name. 383916ee1e9aSmrg cmd=$nonopt 3840fda9279dSmrg test -z "$cmd" && \ 3841fda9279dSmrg func_fatal_help "you must specify a COMMAND" 3842fda9279dSmrg 3843fda9279dSmrg # Handle -dlopen flags immediately. 3844fda9279dSmrg for file in $opt_dlopen; do 3845fda9279dSmrg test -f "$file" \ 384616ee1e9aSmrg || func_fatal_help "'$file' is not a file" 3847fda9279dSmrg 3848fda9279dSmrg dir= 3849fda9279dSmrg case $file in 3850fda9279dSmrg *.la) 3851fda9279dSmrg func_resolve_sysroot "$file" 3852fda9279dSmrg file=$func_resolve_sysroot_result 3853fda9279dSmrg 3854fda9279dSmrg # Check to see that this really is a libtool archive. 3855fda9279dSmrg func_lalib_unsafe_p "$file" \ 385616ee1e9aSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857fda9279dSmrg 3858fda9279dSmrg # Read the libtool library. 3859fda9279dSmrg dlname= 3860fda9279dSmrg library_names= 3861fda9279dSmrg func_source "$file" 3862fda9279dSmrg 3863fda9279dSmrg # Skip this library if it cannot be dlopened. 3864fda9279dSmrg if test -z "$dlname"; then 3865fda9279dSmrg # Warn if it was a shared library. 3866fda9279dSmrg test -n "$library_names" && \ 386716ee1e9aSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3868fda9279dSmrg continue 3869fda9279dSmrg fi 3870fda9279dSmrg 3871fda9279dSmrg func_dirname "$file" "" "." 387216ee1e9aSmrg dir=$func_dirname_result 3873fda9279dSmrg 3874fda9279dSmrg if test -f "$dir/$objdir/$dlname"; then 3875fda9279dSmrg func_append dir "/$objdir" 3876fda9279dSmrg else 3877fda9279dSmrg if test ! -f "$dir/$dlname"; then 387816ee1e9aSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879fda9279dSmrg fi 3880fda9279dSmrg fi 3881fda9279dSmrg ;; 3882fda9279dSmrg 3883fda9279dSmrg *.lo) 3884fda9279dSmrg # Just add the directory containing the .lo file. 3885fda9279dSmrg func_dirname "$file" "" "." 388616ee1e9aSmrg dir=$func_dirname_result 3887fda9279dSmrg ;; 3888fda9279dSmrg 3889fda9279dSmrg *) 389016ee1e9aSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891fda9279dSmrg continue 3892fda9279dSmrg ;; 3893fda9279dSmrg esac 3894fda9279dSmrg 3895fda9279dSmrg # Get the absolute pathname. 3896fda9279dSmrg absdir=`cd "$dir" && pwd` 389716ee1e9aSmrg test -n "$absdir" && dir=$absdir 3898fda9279dSmrg 3899fda9279dSmrg # Now add the directory to shlibpath_var. 3900fda9279dSmrg if eval "test -z \"\$$shlibpath_var\""; then 3901fda9279dSmrg eval "$shlibpath_var=\"\$dir\"" 3902fda9279dSmrg else 3903fda9279dSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904fda9279dSmrg fi 3905fda9279dSmrg done 3906fda9279dSmrg 3907fda9279dSmrg # This variable tells wrapper scripts just to set shlibpath_var 3908fda9279dSmrg # rather than running their programs. 390916ee1e9aSmrg libtool_execute_magic=$magic 3910fda9279dSmrg 3911fda9279dSmrg # Check if any of the arguments is a wrapper script. 3912fda9279dSmrg args= 3913fda9279dSmrg for file 3914fda9279dSmrg do 3915fda9279dSmrg case $file in 3916fda9279dSmrg -* | *.la | *.lo ) ;; 3917fda9279dSmrg *) 3918fda9279dSmrg # Do a test to see if this is really a libtool program. 3919fda9279dSmrg if func_ltwrapper_script_p "$file"; then 3920fda9279dSmrg func_source "$file" 3921fda9279dSmrg # Transform arg to wrapped name. 392216ee1e9aSmrg file=$progdir/$program 3923fda9279dSmrg elif func_ltwrapper_executable_p "$file"; then 3924fda9279dSmrg func_ltwrapper_scriptname "$file" 3925fda9279dSmrg func_source "$func_ltwrapper_scriptname_result" 3926fda9279dSmrg # Transform arg to wrapped name. 392716ee1e9aSmrg file=$progdir/$program 3928fda9279dSmrg fi 3929fda9279dSmrg ;; 3930fda9279dSmrg esac 3931fda9279dSmrg # Quote arguments (to preserve shell metacharacters). 3932fda9279dSmrg func_append_quoted args "$file" 3933fda9279dSmrg done 3934fda9279dSmrg 393516ee1e9aSmrg if $opt_dry_run; then 393616ee1e9aSmrg # Display what would be done. 393716ee1e9aSmrg if test -n "$shlibpath_var"; then 393816ee1e9aSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393916ee1e9aSmrg echo "export $shlibpath_var" 394016ee1e9aSmrg fi 394116ee1e9aSmrg $ECHO "$cmd$args" 394216ee1e9aSmrg exit $EXIT_SUCCESS 394316ee1e9aSmrg else 3944fda9279dSmrg if test -n "$shlibpath_var"; then 3945fda9279dSmrg # Export the shlibpath_var. 3946fda9279dSmrg eval "export $shlibpath_var" 3947fda9279dSmrg fi 3948fda9279dSmrg 3949fda9279dSmrg # Restore saved environment variables 3950fda9279dSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951fda9279dSmrg do 3952fda9279dSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953fda9279dSmrg $lt_var=\$save_$lt_var; export $lt_var 3954fda9279dSmrg else 3955fda9279dSmrg $lt_unset $lt_var 3956fda9279dSmrg fi" 3957fda9279dSmrg done 3958fda9279dSmrg 3959fda9279dSmrg # Now prepare to actually exec the command. 396016ee1e9aSmrg exec_cmd=\$cmd$args 3961fda9279dSmrg fi 3962fda9279dSmrg} 3963fda9279dSmrg 396416ee1e9aSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965fda9279dSmrg 3966fda9279dSmrg 3967fda9279dSmrg# func_mode_finish arg... 3968fda9279dSmrgfunc_mode_finish () 3969fda9279dSmrg{ 397016ee1e9aSmrg $debug_cmd 397116ee1e9aSmrg 3972fda9279dSmrg libs= 3973fda9279dSmrg libdirs= 3974fda9279dSmrg admincmds= 3975fda9279dSmrg 3976fda9279dSmrg for opt in "$nonopt" ${1+"$@"} 3977fda9279dSmrg do 3978fda9279dSmrg if test -d "$opt"; then 3979fda9279dSmrg func_append libdirs " $opt" 3980fda9279dSmrg 3981fda9279dSmrg elif test -f "$opt"; then 3982fda9279dSmrg if func_lalib_unsafe_p "$opt"; then 3983fda9279dSmrg func_append libs " $opt" 3984fda9279dSmrg else 398516ee1e9aSmrg func_warning "'$opt' is not a valid libtool archive" 3986fda9279dSmrg fi 3987fda9279dSmrg 3988fda9279dSmrg else 398916ee1e9aSmrg func_fatal_error "invalid argument '$opt'" 3990fda9279dSmrg fi 3991fda9279dSmrg done 3992fda9279dSmrg 3993fda9279dSmrg if test -n "$libs"; then 3994fda9279dSmrg if test -n "$lt_sysroot"; then 3995fda9279dSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996fda9279dSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997fda9279dSmrg else 3998fda9279dSmrg sysroot_cmd= 3999fda9279dSmrg fi 4000fda9279dSmrg 4001fda9279dSmrg # Remove sysroot references 4002fda9279dSmrg if $opt_dry_run; then 4003fda9279dSmrg for lib in $libs; do 400416ee1e9aSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005fda9279dSmrg done 4006fda9279dSmrg else 4007fda9279dSmrg tmpdir=`func_mktempdir` 4008fda9279dSmrg for lib in $libs; do 400916ee1e9aSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010fda9279dSmrg > $tmpdir/tmp-la 4011fda9279dSmrg mv -f $tmpdir/tmp-la $lib 4012fda9279dSmrg done 4013fda9279dSmrg ${RM}r "$tmpdir" 4014fda9279dSmrg fi 4015fda9279dSmrg fi 4016fda9279dSmrg 4017fda9279dSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018fda9279dSmrg for libdir in $libdirs; do 4019fda9279dSmrg if test -n "$finish_cmds"; then 4020fda9279dSmrg # Do each command in the finish commands. 4021fda9279dSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022fda9279dSmrg'"$cmd"'"' 4023fda9279dSmrg fi 4024fda9279dSmrg if test -n "$finish_eval"; then 4025fda9279dSmrg # Do the single finish_eval. 4026fda9279dSmrg eval cmds=\"$finish_eval\" 4027fda9279dSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028fda9279dSmrg $cmds" 4029fda9279dSmrg fi 4030fda9279dSmrg done 4031fda9279dSmrg fi 4032fda9279dSmrg 4033fda9279dSmrg # Exit here if they wanted silent mode. 403416ee1e9aSmrg $opt_quiet && exit $EXIT_SUCCESS 4035fda9279dSmrg 4036fda9279dSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037fda9279dSmrg echo "----------------------------------------------------------------------" 4038fda9279dSmrg echo "Libraries have been installed in:" 4039fda9279dSmrg for libdir in $libdirs; do 4040fda9279dSmrg $ECHO " $libdir" 4041fda9279dSmrg done 4042fda9279dSmrg echo 4043fda9279dSmrg echo "If you ever happen to want to link against installed libraries" 4044fda9279dSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404516ee1e9aSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046fda9279dSmrg echo "flag during linking and do at least one of the following:" 4047fda9279dSmrg if test -n "$shlibpath_var"; then 404816ee1e9aSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049fda9279dSmrg echo " during execution" 4050fda9279dSmrg fi 4051fda9279dSmrg if test -n "$runpath_var"; then 405216ee1e9aSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4053fda9279dSmrg echo " during linking" 4054fda9279dSmrg fi 4055fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 4056fda9279dSmrg libdir=LIBDIR 4057fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4058fda9279dSmrg 405916ee1e9aSmrg $ECHO " - use the '$flag' linker flag" 4060fda9279dSmrg fi 4061fda9279dSmrg if test -n "$admincmds"; then 4062fda9279dSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4063fda9279dSmrg fi 4064fda9279dSmrg if test -f /etc/ld.so.conf; then 406516ee1e9aSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066fda9279dSmrg fi 4067fda9279dSmrg echo 4068fda9279dSmrg 4069fda9279dSmrg echo "See any operating system documentation about shared libraries for" 4070fda9279dSmrg case $host in 4071fda9279dSmrg solaris2.[6789]|solaris2.1[0-9]) 4072fda9279dSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073fda9279dSmrg echo "pages." 4074fda9279dSmrg ;; 4075fda9279dSmrg *) 4076fda9279dSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077fda9279dSmrg ;; 4078fda9279dSmrg esac 4079fda9279dSmrg echo "----------------------------------------------------------------------" 4080fda9279dSmrg fi 4081fda9279dSmrg exit $EXIT_SUCCESS 4082fda9279dSmrg} 4083fda9279dSmrg 408416ee1e9aSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085fda9279dSmrg 4086fda9279dSmrg 4087fda9279dSmrg# func_mode_install arg... 4088fda9279dSmrgfunc_mode_install () 4089fda9279dSmrg{ 409016ee1e9aSmrg $debug_cmd 409116ee1e9aSmrg 4092fda9279dSmrg # There may be an optional sh(1) argument at the beginning of 4093fda9279dSmrg # install_prog (especially on Windows NT). 409416ee1e9aSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095fda9279dSmrg # Allow the use of GNU shtool's install command. 409616ee1e9aSmrg case $nonopt in *shtool*) :;; *) false;; esac 409716ee1e9aSmrg then 4098fda9279dSmrg # Aesthetically quote it. 4099fda9279dSmrg func_quote_for_eval "$nonopt" 4100fda9279dSmrg install_prog="$func_quote_for_eval_result " 4101fda9279dSmrg arg=$1 4102fda9279dSmrg shift 4103fda9279dSmrg else 4104fda9279dSmrg install_prog= 4105fda9279dSmrg arg=$nonopt 4106fda9279dSmrg fi 4107fda9279dSmrg 4108fda9279dSmrg # The real first argument should be the name of the installation program. 4109fda9279dSmrg # Aesthetically quote it. 4110fda9279dSmrg func_quote_for_eval "$arg" 4111fda9279dSmrg func_append install_prog "$func_quote_for_eval_result" 4112fda9279dSmrg install_shared_prog=$install_prog 4113fda9279dSmrg case " $install_prog " in 4114fda9279dSmrg *[\\\ /]cp\ *) install_cp=: ;; 4115fda9279dSmrg *) install_cp=false ;; 4116fda9279dSmrg esac 4117fda9279dSmrg 4118fda9279dSmrg # We need to accept at least all the BSD install flags. 4119fda9279dSmrg dest= 4120fda9279dSmrg files= 4121fda9279dSmrg opts= 4122fda9279dSmrg prev= 4123fda9279dSmrg install_type= 412416ee1e9aSmrg isdir=false 4125fda9279dSmrg stripme= 4126fda9279dSmrg no_mode=: 4127fda9279dSmrg for arg 4128fda9279dSmrg do 4129fda9279dSmrg arg2= 4130fda9279dSmrg if test -n "$dest"; then 4131fda9279dSmrg func_append files " $dest" 4132fda9279dSmrg dest=$arg 4133fda9279dSmrg continue 4134fda9279dSmrg fi 4135fda9279dSmrg 4136fda9279dSmrg case $arg in 413716ee1e9aSmrg -d) isdir=: ;; 4138fda9279dSmrg -f) 4139fda9279dSmrg if $install_cp; then :; else 4140fda9279dSmrg prev=$arg 4141fda9279dSmrg fi 4142fda9279dSmrg ;; 4143fda9279dSmrg -g | -m | -o) 4144fda9279dSmrg prev=$arg 4145fda9279dSmrg ;; 4146fda9279dSmrg -s) 4147fda9279dSmrg stripme=" -s" 4148fda9279dSmrg continue 4149fda9279dSmrg ;; 4150fda9279dSmrg -*) 4151fda9279dSmrg ;; 4152fda9279dSmrg *) 4153fda9279dSmrg # If the previous option needed an argument, then skip it. 4154fda9279dSmrg if test -n "$prev"; then 415516ee1e9aSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156fda9279dSmrg arg2=$install_override_mode 4157fda9279dSmrg no_mode=false 4158fda9279dSmrg fi 4159fda9279dSmrg prev= 4160fda9279dSmrg else 4161fda9279dSmrg dest=$arg 4162fda9279dSmrg continue 4163fda9279dSmrg fi 4164fda9279dSmrg ;; 4165fda9279dSmrg esac 4166fda9279dSmrg 4167fda9279dSmrg # Aesthetically quote the argument. 4168fda9279dSmrg func_quote_for_eval "$arg" 4169fda9279dSmrg func_append install_prog " $func_quote_for_eval_result" 4170fda9279dSmrg if test -n "$arg2"; then 4171fda9279dSmrg func_quote_for_eval "$arg2" 4172fda9279dSmrg fi 4173fda9279dSmrg func_append install_shared_prog " $func_quote_for_eval_result" 4174fda9279dSmrg done 4175fda9279dSmrg 4176fda9279dSmrg test -z "$install_prog" && \ 4177fda9279dSmrg func_fatal_help "you must specify an install program" 4178fda9279dSmrg 4179fda9279dSmrg test -n "$prev" && \ 418016ee1e9aSmrg func_fatal_help "the '$prev' option requires an argument" 4181fda9279dSmrg 4182fda9279dSmrg if test -n "$install_override_mode" && $no_mode; then 4183fda9279dSmrg if $install_cp; then :; else 4184fda9279dSmrg func_quote_for_eval "$install_override_mode" 4185fda9279dSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4186fda9279dSmrg fi 4187fda9279dSmrg fi 4188fda9279dSmrg 4189fda9279dSmrg if test -z "$files"; then 4190fda9279dSmrg if test -z "$dest"; then 4191fda9279dSmrg func_fatal_help "no file or destination specified" 4192fda9279dSmrg else 4193fda9279dSmrg func_fatal_help "you must specify a destination" 4194fda9279dSmrg fi 4195fda9279dSmrg fi 4196fda9279dSmrg 4197fda9279dSmrg # Strip any trailing slash from the destination. 4198fda9279dSmrg func_stripname '' '/' "$dest" 4199fda9279dSmrg dest=$func_stripname_result 4200fda9279dSmrg 4201fda9279dSmrg # Check to see that the destination is a directory. 420216ee1e9aSmrg test -d "$dest" && isdir=: 420316ee1e9aSmrg if $isdir; then 420416ee1e9aSmrg destdir=$dest 4205fda9279dSmrg destname= 4206fda9279dSmrg else 4207fda9279dSmrg func_dirname_and_basename "$dest" "" "." 420816ee1e9aSmrg destdir=$func_dirname_result 420916ee1e9aSmrg destname=$func_basename_result 4210fda9279dSmrg 4211fda9279dSmrg # Not a directory, so check to see that there is only one file specified. 4212fda9279dSmrg set dummy $files; shift 4213fda9279dSmrg test "$#" -gt 1 && \ 421416ee1e9aSmrg func_fatal_help "'$dest' is not a directory" 4215fda9279dSmrg fi 4216fda9279dSmrg case $destdir in 4217fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218fda9279dSmrg *) 4219fda9279dSmrg for file in $files; do 4220fda9279dSmrg case $file in 4221fda9279dSmrg *.lo) ;; 4222fda9279dSmrg *) 422316ee1e9aSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4224fda9279dSmrg ;; 4225fda9279dSmrg esac 4226fda9279dSmrg done 4227fda9279dSmrg ;; 4228fda9279dSmrg esac 4229fda9279dSmrg 4230fda9279dSmrg # This variable tells wrapper scripts just to set variables rather 4231fda9279dSmrg # than running their programs. 423216ee1e9aSmrg libtool_install_magic=$magic 4233fda9279dSmrg 4234fda9279dSmrg staticlibs= 4235fda9279dSmrg future_libdirs= 4236fda9279dSmrg current_libdirs= 4237fda9279dSmrg for file in $files; do 4238fda9279dSmrg 4239fda9279dSmrg # Do each installation. 4240fda9279dSmrg case $file in 4241fda9279dSmrg *.$libext) 4242fda9279dSmrg # Do the static libraries later. 4243fda9279dSmrg func_append staticlibs " $file" 4244fda9279dSmrg ;; 4245fda9279dSmrg 4246fda9279dSmrg *.la) 4247fda9279dSmrg func_resolve_sysroot "$file" 4248fda9279dSmrg file=$func_resolve_sysroot_result 4249fda9279dSmrg 4250fda9279dSmrg # Check to see that this really is a libtool archive. 4251fda9279dSmrg func_lalib_unsafe_p "$file" \ 425216ee1e9aSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4253fda9279dSmrg 4254fda9279dSmrg library_names= 4255fda9279dSmrg old_library= 4256fda9279dSmrg relink_command= 4257fda9279dSmrg func_source "$file" 4258fda9279dSmrg 4259fda9279dSmrg # Add the libdir to current_libdirs if it is the destination. 4260fda9279dSmrg if test "X$destdir" = "X$libdir"; then 4261fda9279dSmrg case "$current_libdirs " in 4262fda9279dSmrg *" $libdir "*) ;; 4263fda9279dSmrg *) func_append current_libdirs " $libdir" ;; 4264fda9279dSmrg esac 4265fda9279dSmrg else 4266fda9279dSmrg # Note the libdir as a future libdir. 4267fda9279dSmrg case "$future_libdirs " in 4268fda9279dSmrg *" $libdir "*) ;; 4269fda9279dSmrg *) func_append future_libdirs " $libdir" ;; 4270fda9279dSmrg esac 4271fda9279dSmrg fi 4272fda9279dSmrg 4273fda9279dSmrg func_dirname "$file" "/" "" 427416ee1e9aSmrg dir=$func_dirname_result 4275fda9279dSmrg func_append dir "$objdir" 4276fda9279dSmrg 4277fda9279dSmrg if test -n "$relink_command"; then 4278fda9279dSmrg # Determine the prefix the user has applied to our future dir. 4279fda9279dSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280fda9279dSmrg 4281fda9279dSmrg # Don't allow the user to place us outside of our expected 4282fda9279dSmrg # location b/c this prevents finding dependent libraries that 4283fda9279dSmrg # are installed to the same prefix. 4284fda9279dSmrg # At present, this check doesn't affect windows .dll's that 4285fda9279dSmrg # are installed into $libdir/../bin (currently, that works fine) 4286fda9279dSmrg # but it's something to keep an eye on. 4287fda9279dSmrg test "$inst_prefix_dir" = "$destdir" && \ 428816ee1e9aSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289fda9279dSmrg 4290fda9279dSmrg if test -n "$inst_prefix_dir"; then 4291fda9279dSmrg # Stick the inst_prefix_dir data into the link command. 4292fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293fda9279dSmrg else 4294fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295fda9279dSmrg fi 4296fda9279dSmrg 429716ee1e9aSmrg func_warning "relinking '$file'" 4298fda9279dSmrg func_show_eval "$relink_command" \ 429916ee1e9aSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300fda9279dSmrg fi 4301fda9279dSmrg 4302fda9279dSmrg # See the names of the shared library. 4303fda9279dSmrg set dummy $library_names; shift 4304fda9279dSmrg if test -n "$1"; then 430516ee1e9aSmrg realname=$1 4306fda9279dSmrg shift 4307fda9279dSmrg 430816ee1e9aSmrg srcname=$realname 430916ee1e9aSmrg test -n "$relink_command" && srcname=${realname}T 4310fda9279dSmrg 4311fda9279dSmrg # Install the shared library and build the symlinks. 4312fda9279dSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313fda9279dSmrg 'exit $?' 431416ee1e9aSmrg tstripme=$stripme 4315fda9279dSmrg case $host_os in 4316fda9279dSmrg cygwin* | mingw* | pw32* | cegcc*) 4317fda9279dSmrg case $realname in 4318fda9279dSmrg *.dll.a) 431916ee1e9aSmrg tstripme= 432016ee1e9aSmrg ;; 432116ee1e9aSmrg esac 432216ee1e9aSmrg ;; 432316ee1e9aSmrg os2*) 432416ee1e9aSmrg case $realname in 432516ee1e9aSmrg *_dll.a) 432616ee1e9aSmrg tstripme= 4327fda9279dSmrg ;; 4328fda9279dSmrg esac 4329fda9279dSmrg ;; 4330fda9279dSmrg esac 4331fda9279dSmrg if test -n "$tstripme" && test -n "$striplib"; then 4332fda9279dSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333fda9279dSmrg fi 4334fda9279dSmrg 4335fda9279dSmrg if test "$#" -gt 0; then 4336fda9279dSmrg # Delete the old symlinks, and create new ones. 433716ee1e9aSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338fda9279dSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339fda9279dSmrg # so we also need to try rm && ln -s. 4340fda9279dSmrg for linkname 4341fda9279dSmrg do 4342fda9279dSmrg test "$linkname" != "$realname" \ 4343fda9279dSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344fda9279dSmrg done 4345fda9279dSmrg fi 4346fda9279dSmrg 4347fda9279dSmrg # Do each command in the postinstall commands. 434816ee1e9aSmrg lib=$destdir/$realname 4349fda9279dSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350fda9279dSmrg fi 4351fda9279dSmrg 4352fda9279dSmrg # Install the pseudo-library for information purposes. 4353fda9279dSmrg func_basename "$file" 435416ee1e9aSmrg name=$func_basename_result 435516ee1e9aSmrg instname=$dir/${name}i 4356fda9279dSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357fda9279dSmrg 4358fda9279dSmrg # Maybe install the static library, too. 4359fda9279dSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360fda9279dSmrg ;; 4361fda9279dSmrg 4362fda9279dSmrg *.lo) 4363fda9279dSmrg # Install (i.e. copy) a libtool object. 4364fda9279dSmrg 4365fda9279dSmrg # Figure out destination file name, if it wasn't already specified. 4366fda9279dSmrg if test -n "$destname"; then 436716ee1e9aSmrg destfile=$destdir/$destname 4368fda9279dSmrg else 4369fda9279dSmrg func_basename "$file" 437016ee1e9aSmrg destfile=$func_basename_result 437116ee1e9aSmrg destfile=$destdir/$destfile 4372fda9279dSmrg fi 4373fda9279dSmrg 4374fda9279dSmrg # Deduce the name of the destination old-style object file. 4375fda9279dSmrg case $destfile in 4376fda9279dSmrg *.lo) 4377fda9279dSmrg func_lo2o "$destfile" 4378fda9279dSmrg staticdest=$func_lo2o_result 4379fda9279dSmrg ;; 4380fda9279dSmrg *.$objext) 438116ee1e9aSmrg staticdest=$destfile 4382fda9279dSmrg destfile= 4383fda9279dSmrg ;; 4384fda9279dSmrg *) 438516ee1e9aSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386fda9279dSmrg ;; 4387fda9279dSmrg esac 4388fda9279dSmrg 4389fda9279dSmrg # Install the libtool object if requested. 4390fda9279dSmrg test -n "$destfile" && \ 4391fda9279dSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392fda9279dSmrg 4393fda9279dSmrg # Install the old object if enabled. 439416ee1e9aSmrg if test yes = "$build_old_libs"; then 4395fda9279dSmrg # Deduce the name of the old-style object file. 4396fda9279dSmrg func_lo2o "$file" 4397fda9279dSmrg staticobj=$func_lo2o_result 4398fda9279dSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399fda9279dSmrg fi 4400fda9279dSmrg exit $EXIT_SUCCESS 4401fda9279dSmrg ;; 4402fda9279dSmrg 4403fda9279dSmrg *) 4404fda9279dSmrg # Figure out destination file name, if it wasn't already specified. 4405fda9279dSmrg if test -n "$destname"; then 440616ee1e9aSmrg destfile=$destdir/$destname 4407fda9279dSmrg else 4408fda9279dSmrg func_basename "$file" 440916ee1e9aSmrg destfile=$func_basename_result 441016ee1e9aSmrg destfile=$destdir/$destfile 4411fda9279dSmrg fi 4412fda9279dSmrg 4413fda9279dSmrg # If the file is missing, and there is a .exe on the end, strip it 4414fda9279dSmrg # because it is most likely a libtool script we actually want to 4415fda9279dSmrg # install 441616ee1e9aSmrg stripped_ext= 4417fda9279dSmrg case $file in 4418fda9279dSmrg *.exe) 4419fda9279dSmrg if test ! -f "$file"; then 4420fda9279dSmrg func_stripname '' '.exe' "$file" 4421fda9279dSmrg file=$func_stripname_result 442216ee1e9aSmrg stripped_ext=.exe 4423fda9279dSmrg fi 4424fda9279dSmrg ;; 4425fda9279dSmrg esac 4426fda9279dSmrg 4427fda9279dSmrg # Do a test to see if this is really a libtool program. 4428fda9279dSmrg case $host in 4429fda9279dSmrg *cygwin* | *mingw*) 4430fda9279dSmrg if func_ltwrapper_executable_p "$file"; then 4431fda9279dSmrg func_ltwrapper_scriptname "$file" 4432fda9279dSmrg wrapper=$func_ltwrapper_scriptname_result 4433fda9279dSmrg else 4434fda9279dSmrg func_stripname '' '.exe' "$file" 4435fda9279dSmrg wrapper=$func_stripname_result 4436fda9279dSmrg fi 4437fda9279dSmrg ;; 4438fda9279dSmrg *) 4439fda9279dSmrg wrapper=$file 4440fda9279dSmrg ;; 4441fda9279dSmrg esac 4442fda9279dSmrg if func_ltwrapper_script_p "$wrapper"; then 4443fda9279dSmrg notinst_deplibs= 4444fda9279dSmrg relink_command= 4445fda9279dSmrg 4446fda9279dSmrg func_source "$wrapper" 4447fda9279dSmrg 4448fda9279dSmrg # Check the variables that should have been set. 4449fda9279dSmrg test -z "$generated_by_libtool_version" && \ 445016ee1e9aSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451fda9279dSmrg 445216ee1e9aSmrg finalize=: 4453fda9279dSmrg for lib in $notinst_deplibs; do 4454fda9279dSmrg # Check to see that each library is installed. 4455fda9279dSmrg libdir= 4456fda9279dSmrg if test -f "$lib"; then 4457fda9279dSmrg func_source "$lib" 4458fda9279dSmrg fi 445916ee1e9aSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460fda9279dSmrg if test -n "$libdir" && test ! -f "$libfile"; then 446116ee1e9aSmrg func_warning "'$lib' has not been installed in '$libdir'" 446216ee1e9aSmrg finalize=false 4463fda9279dSmrg fi 4464fda9279dSmrg done 4465fda9279dSmrg 4466fda9279dSmrg relink_command= 4467fda9279dSmrg func_source "$wrapper" 4468fda9279dSmrg 4469fda9279dSmrg outputname= 447016ee1e9aSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4471fda9279dSmrg $opt_dry_run || { 447216ee1e9aSmrg if $finalize; then 4473fda9279dSmrg tmpdir=`func_mktempdir` 4474fda9279dSmrg func_basename "$file$stripped_ext" 447516ee1e9aSmrg file=$func_basename_result 447616ee1e9aSmrg outputname=$tmpdir/$file 4477fda9279dSmrg # Replace the output file specification. 4478fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479fda9279dSmrg 448016ee1e9aSmrg $opt_quiet || { 4481fda9279dSmrg func_quote_for_expand "$relink_command" 4482fda9279dSmrg eval "func_echo $func_quote_for_expand_result" 4483fda9279dSmrg } 4484fda9279dSmrg if eval "$relink_command"; then : 4485fda9279dSmrg else 448616ee1e9aSmrg func_error "error: relink '$file' with the above command before installing it" 4487fda9279dSmrg $opt_dry_run || ${RM}r "$tmpdir" 4488fda9279dSmrg continue 4489fda9279dSmrg fi 449016ee1e9aSmrg file=$outputname 4491fda9279dSmrg else 449216ee1e9aSmrg func_warning "cannot relink '$file'" 4493fda9279dSmrg fi 4494fda9279dSmrg } 4495fda9279dSmrg else 4496fda9279dSmrg # Install the binary that we compiled earlier. 4497fda9279dSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498fda9279dSmrg fi 4499fda9279dSmrg fi 4500fda9279dSmrg 4501fda9279dSmrg # remove .exe since cygwin /usr/bin/install will append another 4502fda9279dSmrg # one anyway 4503fda9279dSmrg case $install_prog,$host in 4504fda9279dSmrg */usr/bin/install*,*cygwin*) 4505fda9279dSmrg case $file:$destfile in 4506fda9279dSmrg *.exe:*.exe) 4507fda9279dSmrg # this is ok 4508fda9279dSmrg ;; 4509fda9279dSmrg *.exe:*) 4510fda9279dSmrg destfile=$destfile.exe 4511fda9279dSmrg ;; 4512fda9279dSmrg *:*.exe) 4513fda9279dSmrg func_stripname '' '.exe' "$destfile" 4514fda9279dSmrg destfile=$func_stripname_result 4515fda9279dSmrg ;; 4516fda9279dSmrg esac 4517fda9279dSmrg ;; 4518fda9279dSmrg esac 4519fda9279dSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520fda9279dSmrg $opt_dry_run || if test -n "$outputname"; then 4521fda9279dSmrg ${RM}r "$tmpdir" 4522fda9279dSmrg fi 4523fda9279dSmrg ;; 4524fda9279dSmrg esac 4525fda9279dSmrg done 4526fda9279dSmrg 4527fda9279dSmrg for file in $staticlibs; do 4528fda9279dSmrg func_basename "$file" 452916ee1e9aSmrg name=$func_basename_result 4530fda9279dSmrg 4531fda9279dSmrg # Set up the ranlib parameters. 453216ee1e9aSmrg oldlib=$destdir/$name 4533fda9279dSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534fda9279dSmrg tool_oldlib=$func_to_tool_file_result 4535fda9279dSmrg 4536fda9279dSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537fda9279dSmrg 4538fda9279dSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4539fda9279dSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540fda9279dSmrg fi 4541fda9279dSmrg 4542fda9279dSmrg # Do each command in the postinstall commands. 4543fda9279dSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544fda9279dSmrg done 4545fda9279dSmrg 4546fda9279dSmrg test -n "$future_libdirs" && \ 454716ee1e9aSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548fda9279dSmrg 4549fda9279dSmrg if test -n "$current_libdirs"; then 4550fda9279dSmrg # Maybe just do a dry run. 4551fda9279dSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455216ee1e9aSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553fda9279dSmrg else 4554fda9279dSmrg exit $EXIT_SUCCESS 4555fda9279dSmrg fi 4556fda9279dSmrg} 4557fda9279dSmrg 455816ee1e9aSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559fda9279dSmrg 4560fda9279dSmrg 4561fda9279dSmrg# func_generate_dlsyms outputname originator pic_p 4562fda9279dSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563fda9279dSmrg# a dlpreopen symbol table. 4564fda9279dSmrgfunc_generate_dlsyms () 4565fda9279dSmrg{ 456616ee1e9aSmrg $debug_cmd 456716ee1e9aSmrg 456816ee1e9aSmrg my_outputname=$1 456916ee1e9aSmrg my_originator=$2 457016ee1e9aSmrg my_pic_p=${3-false} 457116ee1e9aSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572fda9279dSmrg my_dlsyms= 4573fda9279dSmrg 457416ee1e9aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575fda9279dSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457616ee1e9aSmrg my_dlsyms=${my_outputname}S.c 4577fda9279dSmrg else 4578fda9279dSmrg func_error "not configured to extract global symbols from dlpreopened files" 4579fda9279dSmrg fi 4580fda9279dSmrg fi 4581fda9279dSmrg 4582fda9279dSmrg if test -n "$my_dlsyms"; then 4583fda9279dSmrg case $my_dlsyms in 4584fda9279dSmrg "") ;; 4585fda9279dSmrg *.c) 4586fda9279dSmrg # Discover the nlist of each of the dlfiles. 458716ee1e9aSmrg nlist=$output_objdir/$my_outputname.nm 4588fda9279dSmrg 4589fda9279dSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590fda9279dSmrg 4591fda9279dSmrg # Parse the name list into a source file. 4592fda9279dSmrg func_verbose "creating $output_objdir/$my_dlsyms" 4593fda9279dSmrg 4594fda9279dSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459516ee1e9aSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459616ee1e9aSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597fda9279dSmrg 4598fda9279dSmrg#ifdef __cplusplus 4599fda9279dSmrgextern \"C\" { 4600fda9279dSmrg#endif 4601fda9279dSmrg 460216ee1e9aSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603fda9279dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604fda9279dSmrg#endif 4605fda9279dSmrg 4606fda9279dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460716ee1e9aSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460816ee1e9aSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609fda9279dSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610fda9279dSmrg# define LT_DLSYM_CONST 461116ee1e9aSmrg#elif defined __osf__ 4612fda9279dSmrg/* This system does not cope well with relocations in const data. */ 4613fda9279dSmrg# define LT_DLSYM_CONST 4614fda9279dSmrg#else 4615fda9279dSmrg# define LT_DLSYM_CONST const 4616fda9279dSmrg#endif 4617fda9279dSmrg 461816ee1e9aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461916ee1e9aSmrg 4620fda9279dSmrg/* External symbol declarations for the compiler. */\ 4621fda9279dSmrg" 4622fda9279dSmrg 462316ee1e9aSmrg if test yes = "$dlself"; then 462416ee1e9aSmrg func_verbose "generating symbol list for '$output'" 4625fda9279dSmrg 4626fda9279dSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627fda9279dSmrg 4628fda9279dSmrg # Add our own program objects to the symbol list. 4629fda9279dSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630fda9279dSmrg for progfile in $progfiles; do 4631fda9279dSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463216ee1e9aSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633fda9279dSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634fda9279dSmrg done 4635fda9279dSmrg 4636fda9279dSmrg if test -n "$exclude_expsyms"; then 4637fda9279dSmrg $opt_dry_run || { 4638fda9279dSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639fda9279dSmrg eval '$MV "$nlist"T "$nlist"' 4640fda9279dSmrg } 4641fda9279dSmrg fi 4642fda9279dSmrg 4643fda9279dSmrg if test -n "$export_symbols_regex"; then 4644fda9279dSmrg $opt_dry_run || { 4645fda9279dSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646fda9279dSmrg eval '$MV "$nlist"T "$nlist"' 4647fda9279dSmrg } 4648fda9279dSmrg fi 4649fda9279dSmrg 4650fda9279dSmrg # Prepare the list of exported symbols 4651fda9279dSmrg if test -z "$export_symbols"; then 465216ee1e9aSmrg export_symbols=$output_objdir/$outputname.exp 4653fda9279dSmrg $opt_dry_run || { 4654fda9279dSmrg $RM $export_symbols 465516ee1e9aSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656fda9279dSmrg case $host in 4657fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4658fda9279dSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659fda9279dSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660fda9279dSmrg ;; 4661fda9279dSmrg esac 4662fda9279dSmrg } 4663fda9279dSmrg else 4664fda9279dSmrg $opt_dry_run || { 466516ee1e9aSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666fda9279dSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667fda9279dSmrg eval '$MV "$nlist"T "$nlist"' 4668fda9279dSmrg case $host in 4669fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4670fda9279dSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671fda9279dSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672fda9279dSmrg ;; 4673fda9279dSmrg esac 4674fda9279dSmrg } 4675fda9279dSmrg fi 4676fda9279dSmrg fi 4677fda9279dSmrg 4678fda9279dSmrg for dlprefile in $dlprefiles; do 467916ee1e9aSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4680fda9279dSmrg func_basename "$dlprefile" 468116ee1e9aSmrg name=$func_basename_result 4682fda9279dSmrg case $host in 4683fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4684fda9279dSmrg # if an import library, we need to obtain dlname 4685fda9279dSmrg if func_win32_import_lib_p "$dlprefile"; then 4686fda9279dSmrg func_tr_sh "$dlprefile" 4687fda9279dSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468816ee1e9aSmrg dlprefile_dlbasename= 4689fda9279dSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690fda9279dSmrg # Use subshell, to avoid clobbering current variable values 4691fda9279dSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469216ee1e9aSmrg if test -n "$dlprefile_dlname"; then 4693fda9279dSmrg func_basename "$dlprefile_dlname" 469416ee1e9aSmrg dlprefile_dlbasename=$func_basename_result 4695fda9279dSmrg else 4696fda9279dSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4697fda9279dSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4698fda9279dSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4699fda9279dSmrg fi 4700fda9279dSmrg fi 4701fda9279dSmrg $opt_dry_run || { 470216ee1e9aSmrg if test -n "$dlprefile_dlbasename"; then 4703fda9279dSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704fda9279dSmrg else 4705fda9279dSmrg func_warning "Could not compute DLL name from $name" 4706fda9279dSmrg eval '$ECHO ": $name " >> "$nlist"' 4707fda9279dSmrg fi 4708fda9279dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709fda9279dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710fda9279dSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711fda9279dSmrg } 4712fda9279dSmrg else # not an import lib 4713fda9279dSmrg $opt_dry_run || { 4714fda9279dSmrg eval '$ECHO ": $name " >> "$nlist"' 4715fda9279dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716fda9279dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717fda9279dSmrg } 4718fda9279dSmrg fi 4719fda9279dSmrg ;; 4720fda9279dSmrg *) 4721fda9279dSmrg $opt_dry_run || { 4722fda9279dSmrg eval '$ECHO ": $name " >> "$nlist"' 4723fda9279dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724fda9279dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725fda9279dSmrg } 4726fda9279dSmrg ;; 4727fda9279dSmrg esac 4728fda9279dSmrg done 4729fda9279dSmrg 4730fda9279dSmrg $opt_dry_run || { 4731fda9279dSmrg # Make sure we have at least an empty file. 4732fda9279dSmrg test -f "$nlist" || : > "$nlist" 4733fda9279dSmrg 4734fda9279dSmrg if test -n "$exclude_expsyms"; then 4735fda9279dSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736fda9279dSmrg $MV "$nlist"T "$nlist" 4737fda9279dSmrg fi 4738fda9279dSmrg 4739fda9279dSmrg # Try sorting and uniquifying the output. 4740fda9279dSmrg if $GREP -v "^: " < "$nlist" | 4741fda9279dSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742fda9279dSmrg sort -k 3 4743fda9279dSmrg else 4744fda9279dSmrg sort +2 4745fda9279dSmrg fi | 4746fda9279dSmrg uniq > "$nlist"S; then 4747fda9279dSmrg : 4748fda9279dSmrg else 4749fda9279dSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750fda9279dSmrg fi 4751fda9279dSmrg 4752fda9279dSmrg if test -f "$nlist"S; then 4753fda9279dSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754fda9279dSmrg else 4755fda9279dSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756fda9279dSmrg fi 4757fda9279dSmrg 475816ee1e9aSmrg func_show_eval '$RM "${nlist}I"' 475916ee1e9aSmrg if test -n "$global_symbol_to_import"; then 476016ee1e9aSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476116ee1e9aSmrg fi 476216ee1e9aSmrg 4763fda9279dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4764fda9279dSmrg 4765fda9279dSmrg/* The mapping between symbol names and symbols. */ 4766fda9279dSmrgtypedef struct { 4767fda9279dSmrg const char *name; 4768fda9279dSmrg void *address; 4769fda9279dSmrg} lt_dlsymlist; 4770fda9279dSmrgextern LT_DLSYM_CONST lt_dlsymlist 477116ee1e9aSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477216ee1e9aSmrg" 477316ee1e9aSmrg 477416ee1e9aSmrg if test -s "$nlist"I; then 477516ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 477616ee1e9aSmrgstatic void lt_syminit(void) 477716ee1e9aSmrg{ 477816ee1e9aSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477916ee1e9aSmrg for (; symbol->name; ++symbol) 478016ee1e9aSmrg {" 478116ee1e9aSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478216ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 478316ee1e9aSmrg } 478416ee1e9aSmrg}" 478516ee1e9aSmrg fi 478616ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4787fda9279dSmrgLT_DLSYM_CONST lt_dlsymlist 4788fda9279dSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 478916ee1e9aSmrg{ {\"$my_originator\", (void *) 0}," 479016ee1e9aSmrg 479116ee1e9aSmrg if test -s "$nlist"I; then 479216ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 479316ee1e9aSmrg {\"@INIT@\", (void *) <_syminit}," 479416ee1e9aSmrg fi 4795fda9279dSmrg 4796fda9279dSmrg case $need_lib_prefix in 4797fda9279dSmrg no) 4798fda9279dSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799fda9279dSmrg ;; 4800fda9279dSmrg *) 4801fda9279dSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802fda9279dSmrg ;; 4803fda9279dSmrg esac 4804fda9279dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4805fda9279dSmrg {0, (void *) 0} 4806fda9279dSmrg}; 4807fda9279dSmrg 4808fda9279dSmrg/* This works around a problem in FreeBSD linker */ 4809fda9279dSmrg#ifdef FREEBSD_WORKAROUND 4810fda9279dSmrgstatic const void *lt_preloaded_setup() { 4811fda9279dSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812fda9279dSmrg} 4813fda9279dSmrg#endif 4814fda9279dSmrg 4815fda9279dSmrg#ifdef __cplusplus 4816fda9279dSmrg} 4817fda9279dSmrg#endif\ 4818fda9279dSmrg" 4819fda9279dSmrg } # !$opt_dry_run 4820fda9279dSmrg 4821fda9279dSmrg pic_flag_for_symtable= 4822fda9279dSmrg case "$compile_command " in 4823fda9279dSmrg *" -static "*) ;; 4824fda9279dSmrg *) 4825fda9279dSmrg case $host in 4826fda9279dSmrg # compiling the symbol table file with pic_flag works around 4827fda9279dSmrg # a FreeBSD bug that causes programs to crash when -lm is 4828fda9279dSmrg # linked before any other PIC object. But we must not use 4829fda9279dSmrg # pic_flag when linking with -static. The problem exists in 4830fda9279dSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831fda9279dSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832fda9279dSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833fda9279dSmrg *-*-hpux*) 4834fda9279dSmrg pic_flag_for_symtable=" $pic_flag" ;; 4835fda9279dSmrg *) 483616ee1e9aSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837fda9279dSmrg ;; 4838fda9279dSmrg esac 4839fda9279dSmrg ;; 4840fda9279dSmrg esac 4841fda9279dSmrg symtab_cflags= 4842fda9279dSmrg for arg in $LTCFLAGS; do 4843fda9279dSmrg case $arg in 4844fda9279dSmrg -pie | -fpie | -fPIE) ;; 4845fda9279dSmrg *) func_append symtab_cflags " $arg" ;; 4846fda9279dSmrg esac 4847fda9279dSmrg done 4848fda9279dSmrg 4849fda9279dSmrg # Now compile the dynamic symbol file. 4850fda9279dSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851fda9279dSmrg 4852fda9279dSmrg # Clean up the generated files. 485316ee1e9aSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854fda9279dSmrg 4855fda9279dSmrg # Transform the symbol file into the correct name. 485616ee1e9aSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857fda9279dSmrg case $host in 4858fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4859fda9279dSmrg if test -f "$output_objdir/$my_outputname.def"; then 4860fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862fda9279dSmrg else 4863fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865fda9279dSmrg fi 4866fda9279dSmrg ;; 4867fda9279dSmrg *) 4868fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870fda9279dSmrg ;; 4871fda9279dSmrg esac 4872fda9279dSmrg ;; 4873fda9279dSmrg *) 487416ee1e9aSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875fda9279dSmrg ;; 4876fda9279dSmrg esac 4877fda9279dSmrg else 4878fda9279dSmrg # We keep going just in case the user didn't refer to 4879fda9279dSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880fda9279dSmrg # really was required. 4881fda9279dSmrg 4882fda9279dSmrg # Nullify the symbol file. 4883fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885fda9279dSmrg fi 4886fda9279dSmrg} 4887fda9279dSmrg 488816ee1e9aSmrg# func_cygming_gnu_implib_p ARG 488916ee1e9aSmrg# This predicate returns with zero status (TRUE) if 489016ee1e9aSmrg# ARG is a GNU/binutils-style import library. Returns 489116ee1e9aSmrg# with nonzero status (FALSE) otherwise. 489216ee1e9aSmrgfunc_cygming_gnu_implib_p () 489316ee1e9aSmrg{ 489416ee1e9aSmrg $debug_cmd 489516ee1e9aSmrg 489616ee1e9aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489716ee1e9aSmrg 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)$'` 489816ee1e9aSmrg test -n "$func_cygming_gnu_implib_tmp" 489916ee1e9aSmrg} 490016ee1e9aSmrg 490116ee1e9aSmrg# func_cygming_ms_implib_p ARG 490216ee1e9aSmrg# This predicate returns with zero status (TRUE) if 490316ee1e9aSmrg# ARG is an MS-style import library. Returns 490416ee1e9aSmrg# with nonzero status (FALSE) otherwise. 490516ee1e9aSmrgfunc_cygming_ms_implib_p () 490616ee1e9aSmrg{ 490716ee1e9aSmrg $debug_cmd 490816ee1e9aSmrg 490916ee1e9aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491016ee1e9aSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491116ee1e9aSmrg test -n "$func_cygming_ms_implib_tmp" 491216ee1e9aSmrg} 491316ee1e9aSmrg 4914fda9279dSmrg# func_win32_libid arg 4915fda9279dSmrg# return the library type of file 'arg' 4916fda9279dSmrg# 4917fda9279dSmrg# Need a lot of goo to handle *both* DLLs and import libs 4918fda9279dSmrg# Has to be a shell function in order to 'eat' the argument 4919fda9279dSmrg# that is supplied when $file_magic_command is called. 4920fda9279dSmrg# Despite the name, also deal with 64 bit binaries. 4921fda9279dSmrgfunc_win32_libid () 4922fda9279dSmrg{ 492316ee1e9aSmrg $debug_cmd 492416ee1e9aSmrg 492516ee1e9aSmrg win32_libid_type=unknown 4926fda9279dSmrg win32_fileres=`file -L $1 2>/dev/null` 4927fda9279dSmrg case $win32_fileres in 4928fda9279dSmrg *ar\ archive\ import\ library*) # definitely import 4929fda9279dSmrg win32_libid_type="x86 archive import" 4930fda9279dSmrg ;; 4931fda9279dSmrg *ar\ archive*) # could be an import, or static 4932fda9279dSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933fda9279dSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934fda9279dSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493516ee1e9aSmrg case $nm_interface in 493616ee1e9aSmrg "MS dumpbin") 493716ee1e9aSmrg if func_cygming_ms_implib_p "$1" || 493816ee1e9aSmrg func_cygming_gnu_implib_p "$1" 493916ee1e9aSmrg then 494016ee1e9aSmrg win32_nmres=import 494116ee1e9aSmrg else 494216ee1e9aSmrg win32_nmres= 494316ee1e9aSmrg fi 494416ee1e9aSmrg ;; 494516ee1e9aSmrg *) 494616ee1e9aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494716ee1e9aSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494816ee1e9aSmrg $SED -n -e ' 4949fda9279dSmrg 1,100{ 4950fda9279dSmrg / I /{ 495116ee1e9aSmrg s|.*|import| 4952fda9279dSmrg p 4953fda9279dSmrg q 4954fda9279dSmrg } 4955fda9279dSmrg }'` 495616ee1e9aSmrg ;; 495716ee1e9aSmrg esac 4958fda9279dSmrg case $win32_nmres in 4959fda9279dSmrg import*) win32_libid_type="x86 archive import";; 4960fda9279dSmrg *) win32_libid_type="x86 archive static";; 4961fda9279dSmrg esac 4962fda9279dSmrg fi 4963fda9279dSmrg ;; 4964fda9279dSmrg *DLL*) 4965fda9279dSmrg win32_libid_type="x86 DLL" 4966fda9279dSmrg ;; 4967fda9279dSmrg *executable*) # but shell scripts are "executable" too... 4968fda9279dSmrg case $win32_fileres in 4969fda9279dSmrg *MS\ Windows\ PE\ Intel*) 4970fda9279dSmrg win32_libid_type="x86 DLL" 4971fda9279dSmrg ;; 4972fda9279dSmrg esac 4973fda9279dSmrg ;; 4974fda9279dSmrg esac 4975fda9279dSmrg $ECHO "$win32_libid_type" 4976fda9279dSmrg} 4977fda9279dSmrg 4978fda9279dSmrg# func_cygming_dll_for_implib ARG 4979fda9279dSmrg# 4980fda9279dSmrg# Platform-specific function to extract the 4981fda9279dSmrg# name of the DLL associated with the specified 4982fda9279dSmrg# import library ARG. 4983fda9279dSmrg# Invoked by eval'ing the libtool variable 4984fda9279dSmrg# $sharedlib_from_linklib_cmd 4985fda9279dSmrg# Result is available in the variable 4986fda9279dSmrg# $sharedlib_from_linklib_result 4987fda9279dSmrgfunc_cygming_dll_for_implib () 4988fda9279dSmrg{ 498916ee1e9aSmrg $debug_cmd 499016ee1e9aSmrg 4991fda9279dSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992fda9279dSmrg} 4993fda9279dSmrg 4994fda9279dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995fda9279dSmrg# 4996fda9279dSmrg# The is the core of a fallback implementation of a 4997fda9279dSmrg# platform-specific function to extract the name of the 4998fda9279dSmrg# DLL associated with the specified import library LIBNAME. 4999fda9279dSmrg# 5000fda9279dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5001fda9279dSmrg# on the platform and compiler that created the implib. 5002fda9279dSmrg# 5003fda9279dSmrg# Echos the name of the DLL associated with the 5004fda9279dSmrg# specified import library. 5005fda9279dSmrgfunc_cygming_dll_for_implib_fallback_core () 5006fda9279dSmrg{ 500716ee1e9aSmrg $debug_cmd 500816ee1e9aSmrg 5009fda9279dSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010fda9279dSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011fda9279dSmrg $SED '/^Contents of section '"$match_literal"':/{ 5012fda9279dSmrg # Place marker at beginning of archive member dllname section 5013fda9279dSmrg s/.*/====MARK====/ 5014fda9279dSmrg p 5015fda9279dSmrg d 5016fda9279dSmrg } 5017fda9279dSmrg # These lines can sometimes be longer than 43 characters, but 5018fda9279dSmrg # are always uninteresting 5019fda9279dSmrg /:[ ]*file format pe[i]\{,1\}-/d 5020fda9279dSmrg /^In archive [^:]*:/d 5021fda9279dSmrg # Ensure marker is printed 5022fda9279dSmrg /^====MARK====/p 5023fda9279dSmrg # Remove all lines with less than 43 characters 5024fda9279dSmrg /^.\{43\}/!d 5025fda9279dSmrg # From remaining lines, remove first 43 characters 5026fda9279dSmrg s/^.\{43\}//' | 5027fda9279dSmrg $SED -n ' 5028fda9279dSmrg # Join marker and all lines until next marker into a single line 5029fda9279dSmrg /^====MARK====/ b para 5030fda9279dSmrg H 5031fda9279dSmrg $ b para 5032fda9279dSmrg b 5033fda9279dSmrg :para 5034fda9279dSmrg x 5035fda9279dSmrg s/\n//g 5036fda9279dSmrg # Remove the marker 5037fda9279dSmrg s/^====MARK====// 5038fda9279dSmrg # Remove trailing dots and whitespace 5039fda9279dSmrg s/[\. \t]*$// 5040fda9279dSmrg # Print 5041fda9279dSmrg /./p' | 5042fda9279dSmrg # we now have a list, one entry per line, of the stringified 5043fda9279dSmrg # contents of the appropriate section of all members of the 504416ee1e9aSmrg # archive that possess that section. Heuristic: eliminate 504516ee1e9aSmrg # all those that have a first or second character that is 5046fda9279dSmrg # a '.' (that is, objdump's representation of an unprintable 5047fda9279dSmrg # character.) This should work for all archives with less than 5048fda9279dSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5049fda9279dSmrg # begins with a literal '.' or a single character followed by 5050fda9279dSmrg # a '.'. 5051fda9279dSmrg # 5052fda9279dSmrg # Of those that remain, print the first one. 5053fda9279dSmrg $SED -e '/^\./d;/^.\./d;q' 5054fda9279dSmrg} 5055fda9279dSmrg 5056fda9279dSmrg# func_cygming_dll_for_implib_fallback ARG 5057fda9279dSmrg# Platform-specific function to extract the 5058fda9279dSmrg# name of the DLL associated with the specified 5059fda9279dSmrg# import library ARG. 5060fda9279dSmrg# 5061fda9279dSmrg# This fallback implementation is for use when $DLLTOOL 5062fda9279dSmrg# does not support the --identify-strict option. 5063fda9279dSmrg# Invoked by eval'ing the libtool variable 5064fda9279dSmrg# $sharedlib_from_linklib_cmd 5065fda9279dSmrg# Result is available in the variable 5066fda9279dSmrg# $sharedlib_from_linklib_result 5067fda9279dSmrgfunc_cygming_dll_for_implib_fallback () 5068fda9279dSmrg{ 506916ee1e9aSmrg $debug_cmd 507016ee1e9aSmrg 507116ee1e9aSmrg if func_cygming_gnu_implib_p "$1"; then 5072fda9279dSmrg # binutils import library 5073fda9279dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507416ee1e9aSmrg elif func_cygming_ms_implib_p "$1"; then 5075fda9279dSmrg # ms-generated import library 5076fda9279dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077fda9279dSmrg else 5078fda9279dSmrg # unknown 507916ee1e9aSmrg sharedlib_from_linklib_result= 5080fda9279dSmrg fi 5081fda9279dSmrg} 5082fda9279dSmrg 5083fda9279dSmrg 5084fda9279dSmrg# func_extract_an_archive dir oldlib 5085fda9279dSmrgfunc_extract_an_archive () 5086fda9279dSmrg{ 508716ee1e9aSmrg $debug_cmd 508816ee1e9aSmrg 508916ee1e9aSmrg f_ex_an_ar_dir=$1; shift 509016ee1e9aSmrg f_ex_an_ar_oldlib=$1 509116ee1e9aSmrg if test yes = "$lock_old_archive_extraction"; then 5092fda9279dSmrg lockfile=$f_ex_an_ar_oldlib.lock 5093fda9279dSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094fda9279dSmrg func_echo "Waiting for $lockfile to be removed" 5095fda9279dSmrg sleep 2 5096fda9279dSmrg done 5097fda9279dSmrg fi 5098fda9279dSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099fda9279dSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510016ee1e9aSmrg if test yes = "$lock_old_archive_extraction"; then 5101fda9279dSmrg $opt_dry_run || rm -f "$lockfile" 5102fda9279dSmrg fi 5103fda9279dSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104fda9279dSmrg : 5105fda9279dSmrg else 5106fda9279dSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107fda9279dSmrg fi 5108fda9279dSmrg} 5109fda9279dSmrg 5110fda9279dSmrg 5111fda9279dSmrg# func_extract_archives gentop oldlib ... 5112fda9279dSmrgfunc_extract_archives () 5113fda9279dSmrg{ 511416ee1e9aSmrg $debug_cmd 511516ee1e9aSmrg 511616ee1e9aSmrg my_gentop=$1; shift 5117fda9279dSmrg my_oldlibs=${1+"$@"} 511816ee1e9aSmrg my_oldobjs= 511916ee1e9aSmrg my_xlib= 512016ee1e9aSmrg my_xabs= 512116ee1e9aSmrg my_xdir= 5122fda9279dSmrg 5123fda9279dSmrg for my_xlib in $my_oldlibs; do 5124fda9279dSmrg # Extract the objects. 5125fda9279dSmrg case $my_xlib in 512616ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127fda9279dSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128fda9279dSmrg esac 5129fda9279dSmrg func_basename "$my_xlib" 513016ee1e9aSmrg my_xlib=$func_basename_result 5131fda9279dSmrg my_xlib_u=$my_xlib 5132fda9279dSmrg while :; do 5133fda9279dSmrg case " $extracted_archives " in 5134fda9279dSmrg *" $my_xlib_u "*) 5135fda9279dSmrg func_arith $extracted_serial + 1 5136fda9279dSmrg extracted_serial=$func_arith_result 5137fda9279dSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138fda9279dSmrg *) break ;; 5139fda9279dSmrg esac 5140fda9279dSmrg done 5141fda9279dSmrg extracted_archives="$extracted_archives $my_xlib_u" 514216ee1e9aSmrg my_xdir=$my_gentop/$my_xlib_u 5143fda9279dSmrg 5144fda9279dSmrg func_mkdir_p "$my_xdir" 5145fda9279dSmrg 5146fda9279dSmrg case $host in 5147fda9279dSmrg *-darwin*) 5148fda9279dSmrg func_verbose "Extracting $my_xabs" 5149fda9279dSmrg # Do not bother doing anything if just a dry run 5150fda9279dSmrg $opt_dry_run || { 5151fda9279dSmrg darwin_orig_dir=`pwd` 5152fda9279dSmrg cd $my_xdir || exit $? 5153fda9279dSmrg darwin_archive=$my_xabs 5154fda9279dSmrg darwin_curdir=`pwd` 515516ee1e9aSmrg func_basename "$darwin_archive" 515616ee1e9aSmrg darwin_base_archive=$func_basename_result 5157fda9279dSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158fda9279dSmrg if test -n "$darwin_arches"; then 5159fda9279dSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160fda9279dSmrg darwin_arch= 5161fda9279dSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516216ee1e9aSmrg for darwin_arch in $darwin_arches; do 516316ee1e9aSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516416ee1e9aSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516516ee1e9aSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516616ee1e9aSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167fda9279dSmrg cd "$darwin_curdir" 516816ee1e9aSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169fda9279dSmrg done # $darwin_arches 5170fda9279dSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517116ee1e9aSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172fda9279dSmrg darwin_file= 5173fda9279dSmrg darwin_files= 5174fda9279dSmrg for darwin_file in $darwin_filelist; do 5175fda9279dSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176fda9279dSmrg $LIPO -create -output "$darwin_file" $darwin_files 5177fda9279dSmrg done # $darwin_filelist 5178fda9279dSmrg $RM -rf unfat-$$ 5179fda9279dSmrg cd "$darwin_orig_dir" 5180fda9279dSmrg else 5181fda9279dSmrg cd $darwin_orig_dir 5182fda9279dSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183fda9279dSmrg fi # $darwin_arches 5184fda9279dSmrg } # !$opt_dry_run 5185fda9279dSmrg ;; 5186fda9279dSmrg *) 5187fda9279dSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188fda9279dSmrg ;; 5189fda9279dSmrg esac 5190fda9279dSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191fda9279dSmrg done 5192fda9279dSmrg 519316ee1e9aSmrg func_extract_archives_result=$my_oldobjs 5194fda9279dSmrg} 5195fda9279dSmrg 5196fda9279dSmrg 5197fda9279dSmrg# func_emit_wrapper [arg=no] 5198fda9279dSmrg# 5199fda9279dSmrg# Emit a libtool wrapper script on stdout. 5200fda9279dSmrg# Don't directly open a file because we may want to 5201fda9279dSmrg# incorporate the script contents within a cygwin/mingw 5202fda9279dSmrg# wrapper executable. Must ONLY be called from within 5203fda9279dSmrg# func_mode_link because it depends on a number of variables 5204fda9279dSmrg# set therein. 5205fda9279dSmrg# 5206fda9279dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207fda9279dSmrg# variable will take. If 'yes', then the emitted script 520816ee1e9aSmrg# will assume that the directory where it is stored is 5209fda9279dSmrg# the $objdir directory. This is a cygwin/mingw-specific 5210fda9279dSmrg# behavior. 5211fda9279dSmrgfunc_emit_wrapper () 5212fda9279dSmrg{ 5213fda9279dSmrg func_emit_wrapper_arg1=${1-no} 5214fda9279dSmrg 5215fda9279dSmrg $ECHO "\ 5216fda9279dSmrg#! $SHELL 5217fda9279dSmrg 5218fda9279dSmrg# $output - temporary wrapper script for $objdir/$outputname 521916ee1e9aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220fda9279dSmrg# 5221fda9279dSmrg# The $output program cannot be directly executed until all the libtool 5222fda9279dSmrg# libraries that it depends on are installed. 5223fda9279dSmrg# 5224fda9279dSmrg# This wrapper script should never be moved out of the build directory. 5225fda9279dSmrg# If it is, it will not operate correctly. 5226fda9279dSmrg 5227fda9279dSmrg# Sed substitution that helps us do robust quoting. It backslashifies 5228fda9279dSmrg# metacharacters that are still active within double-quoted strings. 5229fda9279dSmrgsed_quote_subst='$sed_quote_subst' 5230fda9279dSmrg 5231fda9279dSmrg# Be Bourne compatible 5232fda9279dSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233fda9279dSmrg emulate sh 5234fda9279dSmrg NULLCMD=: 5235fda9279dSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236fda9279dSmrg # is contrary to our usage. Disable this feature. 5237fda9279dSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238fda9279dSmrg setopt NO_GLOB_SUBST 5239fda9279dSmrgelse 5240fda9279dSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241fda9279dSmrgfi 5242fda9279dSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243fda9279dSmrgDUALCASE=1; export DUALCASE # for MKS sh 5244fda9279dSmrg 5245fda9279dSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246fda9279dSmrg# if CDPATH is set. 5247fda9279dSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248fda9279dSmrg 5249fda9279dSmrgrelink_command=\"$relink_command\" 5250fda9279dSmrg 5251fda9279dSmrg# This environment variable determines our operation mode. 5252fda9279dSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253fda9279dSmrg # install mode needs the following variables: 5254fda9279dSmrg generated_by_libtool_version='$macro_version' 5255fda9279dSmrg notinst_deplibs='$notinst_deplibs' 5256fda9279dSmrgelse 5257fda9279dSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258fda9279dSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259fda9279dSmrg file=\"\$0\"" 5260fda9279dSmrg 5261fda9279dSmrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262fda9279dSmrg $ECHO "\ 5263fda9279dSmrg 5264fda9279dSmrg# A function that is used when there is no print builtin or printf. 5265fda9279dSmrgfunc_fallback_echo () 5266fda9279dSmrg{ 5267fda9279dSmrg eval 'cat <<_LTECHO_EOF 5268fda9279dSmrg\$1 5269fda9279dSmrg_LTECHO_EOF' 5270fda9279dSmrg} 5271fda9279dSmrg ECHO=\"$qECHO\" 5272fda9279dSmrg fi 5273fda9279dSmrg 5274fda9279dSmrg# Very basic option parsing. These options are (a) specific to 5275fda9279dSmrg# the libtool wrapper, (b) are identical between the wrapper 527616ee1e9aSmrg# /script/ and the wrapper /executable/ that is used only on 5277fda9279dSmrg# windows platforms, and (c) all begin with the string "--lt-" 527816ee1e9aSmrg# (application programs are unlikely to have options that match 5279fda9279dSmrg# this pattern). 5280fda9279dSmrg# 5281fda9279dSmrg# There are only two supported options: --lt-debug and 5282fda9279dSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 5283fda9279dSmrg# 5284fda9279dSmrg# The first argument to this parsing function should be the 5285fda9279dSmrg# script's $0 value, followed by "$@". 5286fda9279dSmrglt_option_debug= 5287fda9279dSmrgfunc_parse_lt_options () 5288fda9279dSmrg{ 5289fda9279dSmrg lt_script_arg0=\$0 5290fda9279dSmrg shift 5291fda9279dSmrg for lt_opt 5292fda9279dSmrg do 5293fda9279dSmrg case \"\$lt_opt\" in 5294fda9279dSmrg --lt-debug) lt_option_debug=1 ;; 5295fda9279dSmrg --lt-dump-script) 5296fda9279dSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297fda9279dSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298fda9279dSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299fda9279dSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 5300fda9279dSmrg exit 0 5301fda9279dSmrg ;; 5302fda9279dSmrg --lt-*) 5303fda9279dSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304fda9279dSmrg exit 1 5305fda9279dSmrg ;; 5306fda9279dSmrg esac 5307fda9279dSmrg done 5308fda9279dSmrg 5309fda9279dSmrg # Print the debug banner immediately: 5310fda9279dSmrg if test -n \"\$lt_option_debug\"; then 531116ee1e9aSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312fda9279dSmrg fi 5313fda9279dSmrg} 5314fda9279dSmrg 5315fda9279dSmrg# Used when --lt-debug. Prints its arguments to stdout 5316fda9279dSmrg# (redirection is the responsibility of the caller) 5317fda9279dSmrgfunc_lt_dump_args () 5318fda9279dSmrg{ 5319fda9279dSmrg lt_dump_args_N=1; 5320fda9279dSmrg for lt_arg 5321fda9279dSmrg do 532216ee1e9aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323fda9279dSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324fda9279dSmrg done 5325fda9279dSmrg} 5326fda9279dSmrg 5327fda9279dSmrg# Core function for launching the target application 5328fda9279dSmrgfunc_exec_program_core () 5329fda9279dSmrg{ 5330fda9279dSmrg" 5331fda9279dSmrg case $host in 5332fda9279dSmrg # Backslashes separate directories on plain windows 5333fda9279dSmrg *-*-mingw | *-*-os2* | *-cegcc*) 5334fda9279dSmrg $ECHO "\ 5335fda9279dSmrg if test -n \"\$lt_option_debug\"; then 533616ee1e9aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337fda9279dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5338fda9279dSmrg fi 5339fda9279dSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340fda9279dSmrg" 5341fda9279dSmrg ;; 5342fda9279dSmrg 5343fda9279dSmrg *) 5344fda9279dSmrg $ECHO "\ 5345fda9279dSmrg if test -n \"\$lt_option_debug\"; then 534616ee1e9aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347fda9279dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5348fda9279dSmrg fi 5349fda9279dSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350fda9279dSmrg" 5351fda9279dSmrg ;; 5352fda9279dSmrg esac 5353fda9279dSmrg $ECHO "\ 5354fda9279dSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355fda9279dSmrg exit 1 5356fda9279dSmrg} 5357fda9279dSmrg 5358fda9279dSmrg# A function to encapsulate launching the target application 5359fda9279dSmrg# Strips options in the --lt-* namespace from \$@ and 5360fda9279dSmrg# launches target application with the remaining arguments. 5361fda9279dSmrgfunc_exec_program () 5362fda9279dSmrg{ 5363fda9279dSmrg case \" \$* \" in 5364fda9279dSmrg *\\ --lt-*) 5365fda9279dSmrg for lt_wr_arg 5366fda9279dSmrg do 5367fda9279dSmrg case \$lt_wr_arg in 5368fda9279dSmrg --lt-*) ;; 5369fda9279dSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370fda9279dSmrg esac 5371fda9279dSmrg shift 5372fda9279dSmrg done ;; 5373fda9279dSmrg esac 5374fda9279dSmrg func_exec_program_core \${1+\"\$@\"} 5375fda9279dSmrg} 5376fda9279dSmrg 5377fda9279dSmrg # Parse options 5378fda9279dSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379fda9279dSmrg 5380fda9279dSmrg # Find the directory that this script lives in. 5381fda9279dSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382fda9279dSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383fda9279dSmrg 5384fda9279dSmrg # Follow symbolic links until we get to the real thisdir. 5385fda9279dSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386fda9279dSmrg while test -n \"\$file\"; do 5387fda9279dSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388fda9279dSmrg 5389fda9279dSmrg # If there was a directory component, then change thisdir. 5390fda9279dSmrg if test \"x\$destdir\" != \"x\$file\"; then 5391fda9279dSmrg case \"\$destdir\" in 5392fda9279dSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393fda9279dSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394fda9279dSmrg esac 5395fda9279dSmrg fi 5396fda9279dSmrg 5397fda9279dSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398fda9279dSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399fda9279dSmrg done 5400fda9279dSmrg 5401fda9279dSmrg # Usually 'no', except on cygwin/mingw when embedded into 5402fda9279dSmrg # the cwrapper. 5403fda9279dSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404fda9279dSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405fda9279dSmrg # special case for '.' 5406fda9279dSmrg if test \"\$thisdir\" = \".\"; then 5407fda9279dSmrg thisdir=\`pwd\` 5408fda9279dSmrg fi 5409fda9279dSmrg # remove .libs from thisdir 5410fda9279dSmrg case \"\$thisdir\" in 5411fda9279dSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412fda9279dSmrg $objdir ) thisdir=. ;; 5413fda9279dSmrg esac 5414fda9279dSmrg fi 5415fda9279dSmrg 5416fda9279dSmrg # Try to get the absolute directory name. 5417fda9279dSmrg absdir=\`cd \"\$thisdir\" && pwd\` 5418fda9279dSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419fda9279dSmrg" 5420fda9279dSmrg 542116ee1e9aSmrg if test yes = "$fast_install"; then 5422fda9279dSmrg $ECHO "\ 5423fda9279dSmrg program=lt-'$outputname'$exeext 5424fda9279dSmrg progdir=\"\$thisdir/$objdir\" 5425fda9279dSmrg 5426fda9279dSmrg if test ! -f \"\$progdir/\$program\" || 542716ee1e9aSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428fda9279dSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429fda9279dSmrg 5430fda9279dSmrg file=\"\$\$-\$program\" 5431fda9279dSmrg 5432fda9279dSmrg if test ! -d \"\$progdir\"; then 5433fda9279dSmrg $MKDIR \"\$progdir\" 5434fda9279dSmrg else 5435fda9279dSmrg $RM \"\$progdir/\$file\" 5436fda9279dSmrg fi" 5437fda9279dSmrg 5438fda9279dSmrg $ECHO "\ 5439fda9279dSmrg 5440fda9279dSmrg # relink executable if necessary 5441fda9279dSmrg if test -n \"\$relink_command\"; then 5442fda9279dSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443fda9279dSmrg else 544416ee1e9aSmrg \$ECHO \"\$relink_command_output\" >&2 5445fda9279dSmrg $RM \"\$progdir/\$file\" 5446fda9279dSmrg exit 1 5447fda9279dSmrg fi 5448fda9279dSmrg fi 5449fda9279dSmrg 5450fda9279dSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451fda9279dSmrg { $RM \"\$progdir/\$program\"; 5452fda9279dSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453fda9279dSmrg $RM \"\$progdir/\$file\" 5454fda9279dSmrg fi" 5455fda9279dSmrg else 5456fda9279dSmrg $ECHO "\ 5457fda9279dSmrg program='$outputname' 5458fda9279dSmrg progdir=\"\$thisdir/$objdir\" 5459fda9279dSmrg" 5460fda9279dSmrg fi 5461fda9279dSmrg 5462fda9279dSmrg $ECHO "\ 5463fda9279dSmrg 5464fda9279dSmrg if test -f \"\$progdir/\$program\"; then" 5465fda9279dSmrg 5466fda9279dSmrg # fixup the dll searchpath if we need to. 5467fda9279dSmrg # 5468fda9279dSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5469fda9279dSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5470fda9279dSmrg # libraries must come first. 5471fda9279dSmrg if test -n "$dllsearchpath"; then 5472fda9279dSmrg $ECHO "\ 5473fda9279dSmrg # Add the dll search path components to the executable PATH 5474fda9279dSmrg PATH=$dllsearchpath:\$PATH 5475fda9279dSmrg" 5476fda9279dSmrg fi 5477fda9279dSmrg 5478fda9279dSmrg # Export our shlibpath_var if we have one. 547916ee1e9aSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480fda9279dSmrg $ECHO "\ 5481fda9279dSmrg # Add our own library path to $shlibpath_var 5482fda9279dSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483fda9279dSmrg 5484fda9279dSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485fda9279dSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5486fda9279dSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487fda9279dSmrg 5488fda9279dSmrg export $shlibpath_var 5489fda9279dSmrg" 5490fda9279dSmrg fi 5491fda9279dSmrg 5492fda9279dSmrg $ECHO "\ 5493fda9279dSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494fda9279dSmrg # Run the actual program with our arguments. 5495fda9279dSmrg func_exec_program \${1+\"\$@\"} 5496fda9279dSmrg fi 5497fda9279dSmrg else 5498fda9279dSmrg # The program doesn't exist. 549916ee1e9aSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500fda9279dSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501fda9279dSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502fda9279dSmrg exit 1 5503fda9279dSmrg fi 5504fda9279dSmrgfi\ 5505fda9279dSmrg" 5506fda9279dSmrg} 5507fda9279dSmrg 5508fda9279dSmrg 5509fda9279dSmrg# func_emit_cwrapperexe_src 5510fda9279dSmrg# emit the source code for a wrapper executable on stdout 5511fda9279dSmrg# Must ONLY be called from within func_mode_link because 5512fda9279dSmrg# it depends on a number of variable set therein. 5513fda9279dSmrgfunc_emit_cwrapperexe_src () 5514fda9279dSmrg{ 5515fda9279dSmrg cat <<EOF 5516fda9279dSmrg 5517fda9279dSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551816ee1e9aSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519fda9279dSmrg 5520fda9279dSmrg The $output program cannot be directly executed until all the libtool 5521fda9279dSmrg libraries that it depends on are installed. 5522fda9279dSmrg 5523fda9279dSmrg This wrapper executable should never be moved out of the build directory. 5524fda9279dSmrg If it is, it will not operate correctly. 5525fda9279dSmrg*/ 5526fda9279dSmrgEOF 5527fda9279dSmrg cat <<"EOF" 5528fda9279dSmrg#ifdef _MSC_VER 5529fda9279dSmrg# define _CRT_SECURE_NO_DEPRECATE 1 5530fda9279dSmrg#endif 5531fda9279dSmrg#include <stdio.h> 5532fda9279dSmrg#include <stdlib.h> 5533fda9279dSmrg#ifdef _MSC_VER 5534fda9279dSmrg# include <direct.h> 5535fda9279dSmrg# include <process.h> 5536fda9279dSmrg# include <io.h> 5537fda9279dSmrg#else 5538fda9279dSmrg# include <unistd.h> 5539fda9279dSmrg# include <stdint.h> 5540fda9279dSmrg# ifdef __CYGWIN__ 5541fda9279dSmrg# include <io.h> 5542fda9279dSmrg# endif 5543fda9279dSmrg#endif 5544fda9279dSmrg#include <malloc.h> 5545fda9279dSmrg#include <stdarg.h> 5546fda9279dSmrg#include <assert.h> 5547fda9279dSmrg#include <string.h> 5548fda9279dSmrg#include <ctype.h> 5549fda9279dSmrg#include <errno.h> 5550fda9279dSmrg#include <fcntl.h> 5551fda9279dSmrg#include <sys/stat.h> 5552fda9279dSmrg 555316ee1e9aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555416ee1e9aSmrg 5555fda9279dSmrg/* declarations of non-ANSI functions */ 555616ee1e9aSmrg#if defined __MINGW32__ 5557fda9279dSmrg# ifdef __STRICT_ANSI__ 5558fda9279dSmrgint _putenv (const char *); 5559fda9279dSmrg# endif 556016ee1e9aSmrg#elif defined __CYGWIN__ 5561fda9279dSmrg# ifdef __STRICT_ANSI__ 5562fda9279dSmrgchar *realpath (const char *, char *); 5563fda9279dSmrgint putenv (char *); 5564fda9279dSmrgint setenv (const char *, const char *, int); 5565fda9279dSmrg# endif 556616ee1e9aSmrg/* #elif defined other_platform || defined ... */ 5567fda9279dSmrg#endif 5568fda9279dSmrg 5569fda9279dSmrg/* portability defines, excluding path handling macros */ 557016ee1e9aSmrg#if defined _MSC_VER 5571fda9279dSmrg# define setmode _setmode 5572fda9279dSmrg# define stat _stat 5573fda9279dSmrg# define chmod _chmod 5574fda9279dSmrg# define getcwd _getcwd 5575fda9279dSmrg# define putenv _putenv 5576fda9279dSmrg# define S_IXUSR _S_IEXEC 557716ee1e9aSmrg#elif defined __MINGW32__ 5578fda9279dSmrg# define setmode _setmode 5579fda9279dSmrg# define stat _stat 5580fda9279dSmrg# define chmod _chmod 5581fda9279dSmrg# define getcwd _getcwd 5582fda9279dSmrg# define putenv _putenv 558316ee1e9aSmrg#elif defined __CYGWIN__ 5584fda9279dSmrg# define HAVE_SETENV 5585fda9279dSmrg# define FOPEN_WB "wb" 558616ee1e9aSmrg/* #elif defined other platforms ... */ 5587fda9279dSmrg#endif 5588fda9279dSmrg 558916ee1e9aSmrg#if defined PATH_MAX 5590fda9279dSmrg# define LT_PATHMAX PATH_MAX 559116ee1e9aSmrg#elif defined MAXPATHLEN 5592fda9279dSmrg# define LT_PATHMAX MAXPATHLEN 5593fda9279dSmrg#else 5594fda9279dSmrg# define LT_PATHMAX 1024 5595fda9279dSmrg#endif 5596fda9279dSmrg 5597fda9279dSmrg#ifndef S_IXOTH 5598fda9279dSmrg# define S_IXOTH 0 5599fda9279dSmrg#endif 5600fda9279dSmrg#ifndef S_IXGRP 5601fda9279dSmrg# define S_IXGRP 0 5602fda9279dSmrg#endif 5603fda9279dSmrg 5604fda9279dSmrg/* path handling portability macros */ 5605fda9279dSmrg#ifndef DIR_SEPARATOR 5606fda9279dSmrg# define DIR_SEPARATOR '/' 5607fda9279dSmrg# define PATH_SEPARATOR ':' 5608fda9279dSmrg#endif 5609fda9279dSmrg 561016ee1e9aSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561116ee1e9aSmrg defined __OS2__ 5612fda9279dSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613fda9279dSmrg# define FOPEN_WB "wb" 5614fda9279dSmrg# ifndef DIR_SEPARATOR_2 5615fda9279dSmrg# define DIR_SEPARATOR_2 '\\' 5616fda9279dSmrg# endif 5617fda9279dSmrg# ifndef PATH_SEPARATOR_2 5618fda9279dSmrg# define PATH_SEPARATOR_2 ';' 5619fda9279dSmrg# endif 5620fda9279dSmrg#endif 5621fda9279dSmrg 5622fda9279dSmrg#ifndef DIR_SEPARATOR_2 5623fda9279dSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624fda9279dSmrg#else /* DIR_SEPARATOR_2 */ 5625fda9279dSmrg# define IS_DIR_SEPARATOR(ch) \ 5626fda9279dSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627fda9279dSmrg#endif /* DIR_SEPARATOR_2 */ 5628fda9279dSmrg 5629fda9279dSmrg#ifndef PATH_SEPARATOR_2 5630fda9279dSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631fda9279dSmrg#else /* PATH_SEPARATOR_2 */ 5632fda9279dSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633fda9279dSmrg#endif /* PATH_SEPARATOR_2 */ 5634fda9279dSmrg 5635fda9279dSmrg#ifndef FOPEN_WB 5636fda9279dSmrg# define FOPEN_WB "w" 5637fda9279dSmrg#endif 5638fda9279dSmrg#ifndef _O_BINARY 5639fda9279dSmrg# define _O_BINARY 0 5640fda9279dSmrg#endif 5641fda9279dSmrg 5642fda9279dSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643fda9279dSmrg#define XFREE(stale) do { \ 564416ee1e9aSmrg if (stale) { free (stale); stale = 0; } \ 5645fda9279dSmrg} while (0) 5646fda9279dSmrg 564716ee1e9aSmrg#if defined LT_DEBUGWRAPPER 5648fda9279dSmrgstatic int lt_debug = 1; 5649fda9279dSmrg#else 5650fda9279dSmrgstatic int lt_debug = 0; 5651fda9279dSmrg#endif 5652fda9279dSmrg 5653fda9279dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654fda9279dSmrg 5655fda9279dSmrgvoid *xmalloc (size_t num); 5656fda9279dSmrgchar *xstrdup (const char *string); 5657fda9279dSmrgconst char *base_name (const char *name); 5658fda9279dSmrgchar *find_executable (const char *wrapper); 5659fda9279dSmrgchar *chase_symlinks (const char *pathspec); 5660fda9279dSmrgint make_executable (const char *path); 5661fda9279dSmrgint check_executable (const char *path); 5662fda9279dSmrgchar *strendzap (char *str, const char *pat); 5663fda9279dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664fda9279dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5665fda9279dSmrgstatic const char *nonnull (const char *s); 5666fda9279dSmrgstatic const char *nonempty (const char *s); 5667fda9279dSmrgvoid lt_setenv (const char *name, const char *value); 5668fda9279dSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669fda9279dSmrgvoid lt_update_exe_path (const char *name, const char *value); 5670fda9279dSmrgvoid lt_update_lib_path (const char *name, const char *value); 5671fda9279dSmrgchar **prepare_spawn (char **argv); 5672fda9279dSmrgvoid lt_dump_script (FILE *f); 5673fda9279dSmrgEOF 5674fda9279dSmrg 5675fda9279dSmrg cat <<EOF 567616ee1e9aSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567716ee1e9aSmrg# define externally_visible volatile 567816ee1e9aSmrg#else 567916ee1e9aSmrg# define externally_visible __attribute__((externally_visible)) volatile 568016ee1e9aSmrg#endif 568116ee1e9aSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682fda9279dSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683fda9279dSmrgEOF 5684fda9279dSmrg 568516ee1e9aSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686fda9279dSmrg func_to_host_path "$temp_rpath" 5687fda9279dSmrg cat <<EOF 5688fda9279dSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689fda9279dSmrgEOF 5690fda9279dSmrg else 5691fda9279dSmrg cat <<"EOF" 5692fda9279dSmrgconst char * LIB_PATH_VALUE = ""; 5693fda9279dSmrgEOF 5694fda9279dSmrg fi 5695fda9279dSmrg 5696fda9279dSmrg if test -n "$dllsearchpath"; then 5697fda9279dSmrg func_to_host_path "$dllsearchpath:" 5698fda9279dSmrg cat <<EOF 5699fda9279dSmrgconst char * EXE_PATH_VARNAME = "PATH"; 5700fda9279dSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701fda9279dSmrgEOF 5702fda9279dSmrg else 5703fda9279dSmrg cat <<"EOF" 5704fda9279dSmrgconst char * EXE_PATH_VARNAME = ""; 5705fda9279dSmrgconst char * EXE_PATH_VALUE = ""; 5706fda9279dSmrgEOF 5707fda9279dSmrg fi 5708fda9279dSmrg 570916ee1e9aSmrg if test yes = "$fast_install"; then 5710fda9279dSmrg cat <<EOF 5711fda9279dSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712fda9279dSmrgEOF 5713fda9279dSmrg else 5714fda9279dSmrg cat <<EOF 5715fda9279dSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716fda9279dSmrgEOF 5717fda9279dSmrg fi 5718fda9279dSmrg 5719fda9279dSmrg 5720fda9279dSmrg cat <<"EOF" 5721fda9279dSmrg 5722fda9279dSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723fda9279dSmrg 5724fda9279dSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725fda9279dSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726fda9279dSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727fda9279dSmrg 5728fda9279dSmrgint 5729fda9279dSmrgmain (int argc, char *argv[]) 5730fda9279dSmrg{ 5731fda9279dSmrg char **newargz; 5732fda9279dSmrg int newargc; 5733fda9279dSmrg char *tmp_pathspec; 5734fda9279dSmrg char *actual_cwrapper_path; 5735fda9279dSmrg char *actual_cwrapper_name; 5736fda9279dSmrg char *target_name; 5737fda9279dSmrg char *lt_argv_zero; 573816ee1e9aSmrg int rval = 127; 5739fda9279dSmrg 5740fda9279dSmrg int i; 5741fda9279dSmrg 5742fda9279dSmrg program_name = (char *) xstrdup (base_name (argv[0])); 574316ee1e9aSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744fda9279dSmrg 5745fda9279dSmrg /* very simple arg parsing; don't want to rely on getopt 5746fda9279dSmrg * also, copy all non cwrapper options to newargz, except 5747fda9279dSmrg * argz[0], which is handled differently 5748fda9279dSmrg */ 5749fda9279dSmrg newargc=0; 5750fda9279dSmrg for (i = 1; i < argc; i++) 5751fda9279dSmrg { 575216ee1e9aSmrg if (STREQ (argv[i], dumpscript_opt)) 5753fda9279dSmrg { 5754fda9279dSmrgEOF 575516ee1e9aSmrg case $host in 5756fda9279dSmrg *mingw* | *cygwin* ) 5757fda9279dSmrg # make stdout use "unix" line endings 5758fda9279dSmrg echo " setmode(1,_O_BINARY);" 5759fda9279dSmrg ;; 5760fda9279dSmrg esac 5761fda9279dSmrg 5762fda9279dSmrg cat <<"EOF" 5763fda9279dSmrg lt_dump_script (stdout); 5764fda9279dSmrg return 0; 5765fda9279dSmrg } 576616ee1e9aSmrg if (STREQ (argv[i], debug_opt)) 5767fda9279dSmrg { 5768fda9279dSmrg lt_debug = 1; 5769fda9279dSmrg continue; 5770fda9279dSmrg } 577116ee1e9aSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5772fda9279dSmrg { 5773fda9279dSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774fda9279dSmrg namespace, but it is not one of the ones we know about and 5775fda9279dSmrg have already dealt with, above (inluding dump-script), then 5776fda9279dSmrg report an error. Otherwise, targets might begin to believe 5777fda9279dSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778fda9279dSmrg namespace. The first time any user complains about this, we'll 5779fda9279dSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780fda9279dSmrg or a configure.ac-settable value. 5781fda9279dSmrg */ 5782fda9279dSmrg lt_fatal (__FILE__, __LINE__, 5783fda9279dSmrg "unrecognized %s option: '%s'", 5784fda9279dSmrg ltwrapper_option_prefix, argv[i]); 5785fda9279dSmrg } 5786fda9279dSmrg /* otherwise ... */ 5787fda9279dSmrg newargz[++newargc] = xstrdup (argv[i]); 5788fda9279dSmrg } 5789fda9279dSmrg newargz[++newargc] = NULL; 5790fda9279dSmrg 5791fda9279dSmrgEOF 5792fda9279dSmrg cat <<EOF 5793fda9279dSmrg /* The GNU banner must be the first non-error debug message */ 579416ee1e9aSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795fda9279dSmrgEOF 5796fda9279dSmrg cat <<"EOF" 5797fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799fda9279dSmrg 5800fda9279dSmrg tmp_pathspec = find_executable (argv[0]); 5801fda9279dSmrg if (tmp_pathspec == NULL) 5802fda9279dSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5804fda9279dSmrg "(main) found exe (before symlink chase) at: %s\n", 5805fda9279dSmrg tmp_pathspec); 5806fda9279dSmrg 5807fda9279dSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5809fda9279dSmrg "(main) found exe (after symlink chase) at: %s\n", 5810fda9279dSmrg actual_cwrapper_path); 5811fda9279dSmrg XFREE (tmp_pathspec); 5812fda9279dSmrg 5813fda9279dSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814fda9279dSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815fda9279dSmrg 5816fda9279dSmrg /* wrapper name transforms */ 5817fda9279dSmrg strendzap (actual_cwrapper_name, ".exe"); 5818fda9279dSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819fda9279dSmrg XFREE (actual_cwrapper_name); 5820fda9279dSmrg actual_cwrapper_name = tmp_pathspec; 5821fda9279dSmrg tmp_pathspec = 0; 5822fda9279dSmrg 5823fda9279dSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824fda9279dSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825fda9279dSmrg strendzap (target_name, ".exe"); 5826fda9279dSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827fda9279dSmrg XFREE (target_name); 5828fda9279dSmrg target_name = tmp_pathspec; 5829fda9279dSmrg tmp_pathspec = 0; 5830fda9279dSmrg 5831fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5832fda9279dSmrg "(main) libtool target name: %s\n", 5833fda9279dSmrg target_name); 5834fda9279dSmrgEOF 5835fda9279dSmrg 5836fda9279dSmrg cat <<EOF 5837fda9279dSmrg newargz[0] = 5838fda9279dSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839fda9279dSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840fda9279dSmrg strcpy (newargz[0], actual_cwrapper_path); 5841fda9279dSmrg strcat (newargz[0], "$objdir"); 5842fda9279dSmrg strcat (newargz[0], "/"); 5843fda9279dSmrgEOF 5844fda9279dSmrg 5845fda9279dSmrg cat <<"EOF" 5846fda9279dSmrg /* stop here, and copy so we don't have to do this twice */ 5847fda9279dSmrg tmp_pathspec = xstrdup (newargz[0]); 5848fda9279dSmrg 5849fda9279dSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850fda9279dSmrg strcat (newargz[0], actual_cwrapper_name); 5851fda9279dSmrg 5852fda9279dSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853fda9279dSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854fda9279dSmrg XFREE (tmp_pathspec); 5855fda9279dSmrg tmp_pathspec = NULL; 5856fda9279dSmrgEOF 5857fda9279dSmrg 5858fda9279dSmrg case $host_os in 5859fda9279dSmrg mingw*) 5860fda9279dSmrg cat <<"EOF" 5861fda9279dSmrg { 5862fda9279dSmrg char* p; 5863fda9279dSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864fda9279dSmrg { 5865fda9279dSmrg *p = '/'; 5866fda9279dSmrg } 5867fda9279dSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868fda9279dSmrg { 5869fda9279dSmrg *p = '/'; 5870fda9279dSmrg } 5871fda9279dSmrg } 5872fda9279dSmrgEOF 5873fda9279dSmrg ;; 5874fda9279dSmrg esac 5875fda9279dSmrg 5876fda9279dSmrg cat <<"EOF" 5877fda9279dSmrg XFREE (target_name); 5878fda9279dSmrg XFREE (actual_cwrapper_path); 5879fda9279dSmrg XFREE (actual_cwrapper_name); 5880fda9279dSmrg 5881fda9279dSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882fda9279dSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883fda9279dSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884fda9279dSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885fda9279dSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5886fda9279dSmrg libraries must come first. */ 5887fda9279dSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888fda9279dSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889fda9279dSmrg 5890fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891fda9279dSmrg nonnull (lt_argv_zero)); 5892fda9279dSmrg for (i = 0; i < newargc; i++) 5893fda9279dSmrg { 5894fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895fda9279dSmrg i, nonnull (newargz[i])); 5896fda9279dSmrg } 5897fda9279dSmrg 5898fda9279dSmrgEOF 5899fda9279dSmrg 5900fda9279dSmrg case $host_os in 5901fda9279dSmrg mingw*) 5902fda9279dSmrg cat <<"EOF" 5903fda9279dSmrg /* execv doesn't actually work on mingw as expected on unix */ 5904fda9279dSmrg newargz = prepare_spawn (newargz); 590516ee1e9aSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906fda9279dSmrg if (rval == -1) 5907fda9279dSmrg { 5908fda9279dSmrg /* failed to start process */ 5909fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5910fda9279dSmrg "(main) failed to launch target \"%s\": %s\n", 5911fda9279dSmrg lt_argv_zero, nonnull (strerror (errno))); 5912fda9279dSmrg return 127; 5913fda9279dSmrg } 5914fda9279dSmrg return rval; 5915fda9279dSmrgEOF 5916fda9279dSmrg ;; 5917fda9279dSmrg *) 5918fda9279dSmrg cat <<"EOF" 5919fda9279dSmrg execv (lt_argv_zero, newargz); 5920fda9279dSmrg return rval; /* =127, but avoids unused variable warning */ 5921fda9279dSmrgEOF 5922fda9279dSmrg ;; 5923fda9279dSmrg esac 5924fda9279dSmrg 5925fda9279dSmrg cat <<"EOF" 5926fda9279dSmrg} 5927fda9279dSmrg 5928fda9279dSmrgvoid * 5929fda9279dSmrgxmalloc (size_t num) 5930fda9279dSmrg{ 5931fda9279dSmrg void *p = (void *) malloc (num); 5932fda9279dSmrg if (!p) 5933fda9279dSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934fda9279dSmrg 5935fda9279dSmrg return p; 5936fda9279dSmrg} 5937fda9279dSmrg 5938fda9279dSmrgchar * 5939fda9279dSmrgxstrdup (const char *string) 5940fda9279dSmrg{ 5941fda9279dSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942fda9279dSmrg string) : NULL; 5943fda9279dSmrg} 5944fda9279dSmrg 5945fda9279dSmrgconst char * 5946fda9279dSmrgbase_name (const char *name) 5947fda9279dSmrg{ 5948fda9279dSmrg const char *base; 5949fda9279dSmrg 595016ee1e9aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951fda9279dSmrg /* Skip over the disk name in MSDOS pathnames. */ 5952fda9279dSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953fda9279dSmrg name += 2; 5954fda9279dSmrg#endif 5955fda9279dSmrg 5956fda9279dSmrg for (base = name; *name; name++) 5957fda9279dSmrg if (IS_DIR_SEPARATOR (*name)) 5958fda9279dSmrg base = name + 1; 5959fda9279dSmrg return base; 5960fda9279dSmrg} 5961fda9279dSmrg 5962fda9279dSmrgint 5963fda9279dSmrgcheck_executable (const char *path) 5964fda9279dSmrg{ 5965fda9279dSmrg struct stat st; 5966fda9279dSmrg 5967fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968fda9279dSmrg nonempty (path)); 5969fda9279dSmrg if ((!path) || (!*path)) 5970fda9279dSmrg return 0; 5971fda9279dSmrg 5972fda9279dSmrg if ((stat (path, &st) >= 0) 5973fda9279dSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974fda9279dSmrg return 1; 5975fda9279dSmrg else 5976fda9279dSmrg return 0; 5977fda9279dSmrg} 5978fda9279dSmrg 5979fda9279dSmrgint 5980fda9279dSmrgmake_executable (const char *path) 5981fda9279dSmrg{ 5982fda9279dSmrg int rval = 0; 5983fda9279dSmrg struct stat st; 5984fda9279dSmrg 5985fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986fda9279dSmrg nonempty (path)); 5987fda9279dSmrg if ((!path) || (!*path)) 5988fda9279dSmrg return 0; 5989fda9279dSmrg 5990fda9279dSmrg if (stat (path, &st) >= 0) 5991fda9279dSmrg { 5992fda9279dSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993fda9279dSmrg } 5994fda9279dSmrg return rval; 5995fda9279dSmrg} 5996fda9279dSmrg 5997fda9279dSmrg/* Searches for the full path of the wrapper. Returns 5998fda9279dSmrg newly allocated full path name if found, NULL otherwise 5999fda9279dSmrg Does not chase symlinks, even on platforms that support them. 6000fda9279dSmrg*/ 6001fda9279dSmrgchar * 6002fda9279dSmrgfind_executable (const char *wrapper) 6003fda9279dSmrg{ 6004fda9279dSmrg int has_slash = 0; 6005fda9279dSmrg const char *p; 6006fda9279dSmrg const char *p_next; 6007fda9279dSmrg /* static buffer for getcwd */ 6008fda9279dSmrg char tmp[LT_PATHMAX + 1]; 600916ee1e9aSmrg size_t tmp_len; 6010fda9279dSmrg char *concat_name; 6011fda9279dSmrg 6012fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013fda9279dSmrg nonempty (wrapper)); 6014fda9279dSmrg 6015fda9279dSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016fda9279dSmrg return NULL; 6017fda9279dSmrg 6018fda9279dSmrg /* Absolute path? */ 601916ee1e9aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020fda9279dSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021fda9279dSmrg { 6022fda9279dSmrg concat_name = xstrdup (wrapper); 6023fda9279dSmrg if (check_executable (concat_name)) 6024fda9279dSmrg return concat_name; 6025fda9279dSmrg XFREE (concat_name); 6026fda9279dSmrg } 6027fda9279dSmrg else 6028fda9279dSmrg { 6029fda9279dSmrg#endif 6030fda9279dSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031fda9279dSmrg { 6032fda9279dSmrg concat_name = xstrdup (wrapper); 6033fda9279dSmrg if (check_executable (concat_name)) 6034fda9279dSmrg return concat_name; 6035fda9279dSmrg XFREE (concat_name); 6036fda9279dSmrg } 603716ee1e9aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038fda9279dSmrg } 6039fda9279dSmrg#endif 6040fda9279dSmrg 6041fda9279dSmrg for (p = wrapper; *p; p++) 6042fda9279dSmrg if (*p == '/') 6043fda9279dSmrg { 6044fda9279dSmrg has_slash = 1; 6045fda9279dSmrg break; 6046fda9279dSmrg } 6047fda9279dSmrg if (!has_slash) 6048fda9279dSmrg { 6049fda9279dSmrg /* no slashes; search PATH */ 6050fda9279dSmrg const char *path = getenv ("PATH"); 6051fda9279dSmrg if (path != NULL) 6052fda9279dSmrg { 6053fda9279dSmrg for (p = path; *p; p = p_next) 6054fda9279dSmrg { 6055fda9279dSmrg const char *q; 6056fda9279dSmrg size_t p_len; 6057fda9279dSmrg for (q = p; *q; q++) 6058fda9279dSmrg if (IS_PATH_SEPARATOR (*q)) 6059fda9279dSmrg break; 606016ee1e9aSmrg p_len = (size_t) (q - p); 6061fda9279dSmrg p_next = (*q == '\0' ? q : q + 1); 6062fda9279dSmrg if (p_len == 0) 6063fda9279dSmrg { 6064fda9279dSmrg /* empty path: current directory */ 6065fda9279dSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6066fda9279dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067fda9279dSmrg nonnull (strerror (errno))); 6068fda9279dSmrg tmp_len = strlen (tmp); 6069fda9279dSmrg concat_name = 6070fda9279dSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071fda9279dSmrg memcpy (concat_name, tmp, tmp_len); 6072fda9279dSmrg concat_name[tmp_len] = '/'; 6073fda9279dSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6074fda9279dSmrg } 6075fda9279dSmrg else 6076fda9279dSmrg { 6077fda9279dSmrg concat_name = 6078fda9279dSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079fda9279dSmrg memcpy (concat_name, p, p_len); 6080fda9279dSmrg concat_name[p_len] = '/'; 6081fda9279dSmrg strcpy (concat_name + p_len + 1, wrapper); 6082fda9279dSmrg } 6083fda9279dSmrg if (check_executable (concat_name)) 6084fda9279dSmrg return concat_name; 6085fda9279dSmrg XFREE (concat_name); 6086fda9279dSmrg } 6087fda9279dSmrg } 6088fda9279dSmrg /* not found in PATH; assume curdir */ 6089fda9279dSmrg } 6090fda9279dSmrg /* Relative path | not found in path: prepend cwd */ 6091fda9279dSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6092fda9279dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093fda9279dSmrg nonnull (strerror (errno))); 6094fda9279dSmrg tmp_len = strlen (tmp); 6095fda9279dSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096fda9279dSmrg memcpy (concat_name, tmp, tmp_len); 6097fda9279dSmrg concat_name[tmp_len] = '/'; 6098fda9279dSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6099fda9279dSmrg 6100fda9279dSmrg if (check_executable (concat_name)) 6101fda9279dSmrg return concat_name; 6102fda9279dSmrg XFREE (concat_name); 6103fda9279dSmrg return NULL; 6104fda9279dSmrg} 6105fda9279dSmrg 6106fda9279dSmrgchar * 6107fda9279dSmrgchase_symlinks (const char *pathspec) 6108fda9279dSmrg{ 6109fda9279dSmrg#ifndef S_ISLNK 6110fda9279dSmrg return xstrdup (pathspec); 6111fda9279dSmrg#else 6112fda9279dSmrg char buf[LT_PATHMAX]; 6113fda9279dSmrg struct stat s; 6114fda9279dSmrg char *tmp_pathspec = xstrdup (pathspec); 6115fda9279dSmrg char *p; 6116fda9279dSmrg int has_symlinks = 0; 6117fda9279dSmrg while (strlen (tmp_pathspec) && !has_symlinks) 6118fda9279dSmrg { 6119fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6120fda9279dSmrg "checking path component for symlinks: %s\n", 6121fda9279dSmrg tmp_pathspec); 6122fda9279dSmrg if (lstat (tmp_pathspec, &s) == 0) 6123fda9279dSmrg { 6124fda9279dSmrg if (S_ISLNK (s.st_mode) != 0) 6125fda9279dSmrg { 6126fda9279dSmrg has_symlinks = 1; 6127fda9279dSmrg break; 6128fda9279dSmrg } 6129fda9279dSmrg 6130fda9279dSmrg /* search backwards for last DIR_SEPARATOR */ 6131fda9279dSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132fda9279dSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133fda9279dSmrg p--; 6134fda9279dSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135fda9279dSmrg { 6136fda9279dSmrg /* no more DIR_SEPARATORS left */ 6137fda9279dSmrg break; 6138fda9279dSmrg } 6139fda9279dSmrg *p = '\0'; 6140fda9279dSmrg } 6141fda9279dSmrg else 6142fda9279dSmrg { 6143fda9279dSmrg lt_fatal (__FILE__, __LINE__, 6144fda9279dSmrg "error accessing file \"%s\": %s", 6145fda9279dSmrg tmp_pathspec, nonnull (strerror (errno))); 6146fda9279dSmrg } 6147fda9279dSmrg } 6148fda9279dSmrg XFREE (tmp_pathspec); 6149fda9279dSmrg 6150fda9279dSmrg if (!has_symlinks) 6151fda9279dSmrg { 6152fda9279dSmrg return xstrdup (pathspec); 6153fda9279dSmrg } 6154fda9279dSmrg 6155fda9279dSmrg tmp_pathspec = realpath (pathspec, buf); 6156fda9279dSmrg if (tmp_pathspec == 0) 6157fda9279dSmrg { 6158fda9279dSmrg lt_fatal (__FILE__, __LINE__, 6159fda9279dSmrg "could not follow symlinks for %s", pathspec); 6160fda9279dSmrg } 6161fda9279dSmrg return xstrdup (tmp_pathspec); 6162fda9279dSmrg#endif 6163fda9279dSmrg} 6164fda9279dSmrg 6165fda9279dSmrgchar * 6166fda9279dSmrgstrendzap (char *str, const char *pat) 6167fda9279dSmrg{ 6168fda9279dSmrg size_t len, patlen; 6169fda9279dSmrg 6170fda9279dSmrg assert (str != NULL); 6171fda9279dSmrg assert (pat != NULL); 6172fda9279dSmrg 6173fda9279dSmrg len = strlen (str); 6174fda9279dSmrg patlen = strlen (pat); 6175fda9279dSmrg 6176fda9279dSmrg if (patlen <= len) 6177fda9279dSmrg { 6178fda9279dSmrg str += len - patlen; 617916ee1e9aSmrg if (STREQ (str, pat)) 6180fda9279dSmrg *str = '\0'; 6181fda9279dSmrg } 6182fda9279dSmrg return str; 6183fda9279dSmrg} 6184fda9279dSmrg 6185fda9279dSmrgvoid 6186fda9279dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6187fda9279dSmrg{ 6188fda9279dSmrg va_list args; 6189fda9279dSmrg if (lt_debug) 6190fda9279dSmrg { 6191fda9279dSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192fda9279dSmrg va_start (args, fmt); 6193fda9279dSmrg (void) vfprintf (stderr, fmt, args); 6194fda9279dSmrg va_end (args); 6195fda9279dSmrg } 6196fda9279dSmrg} 6197fda9279dSmrg 6198fda9279dSmrgstatic void 6199fda9279dSmrglt_error_core (int exit_status, const char *file, 6200fda9279dSmrg int line, const char *mode, 6201fda9279dSmrg const char *message, va_list ap) 6202fda9279dSmrg{ 6203fda9279dSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204fda9279dSmrg vfprintf (stderr, message, ap); 6205fda9279dSmrg fprintf (stderr, ".\n"); 6206fda9279dSmrg 6207fda9279dSmrg if (exit_status >= 0) 6208fda9279dSmrg exit (exit_status); 6209fda9279dSmrg} 6210fda9279dSmrg 6211fda9279dSmrgvoid 6212fda9279dSmrglt_fatal (const char *file, int line, const char *message, ...) 6213fda9279dSmrg{ 6214fda9279dSmrg va_list ap; 6215fda9279dSmrg va_start (ap, message); 6216fda9279dSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217fda9279dSmrg va_end (ap); 6218fda9279dSmrg} 6219fda9279dSmrg 6220fda9279dSmrgstatic const char * 6221fda9279dSmrgnonnull (const char *s) 6222fda9279dSmrg{ 6223fda9279dSmrg return s ? s : "(null)"; 6224fda9279dSmrg} 6225fda9279dSmrg 6226fda9279dSmrgstatic const char * 6227fda9279dSmrgnonempty (const char *s) 6228fda9279dSmrg{ 6229fda9279dSmrg return (s && !*s) ? "(empty)" : nonnull (s); 6230fda9279dSmrg} 6231fda9279dSmrg 6232fda9279dSmrgvoid 6233fda9279dSmrglt_setenv (const char *name, const char *value) 6234fda9279dSmrg{ 6235fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6236fda9279dSmrg "(lt_setenv) setting '%s' to '%s'\n", 6237fda9279dSmrg nonnull (name), nonnull (value)); 6238fda9279dSmrg { 6239fda9279dSmrg#ifdef HAVE_SETENV 6240fda9279dSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241fda9279dSmrg char *str = xstrdup (value); 6242fda9279dSmrg setenv (name, str, 1); 6243fda9279dSmrg#else 624416ee1e9aSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245fda9279dSmrg char *str = XMALLOC (char, len); 6246fda9279dSmrg sprintf (str, "%s=%s", name, value); 6247fda9279dSmrg if (putenv (str) != EXIT_SUCCESS) 6248fda9279dSmrg { 6249fda9279dSmrg XFREE (str); 6250fda9279dSmrg } 6251fda9279dSmrg#endif 6252fda9279dSmrg } 6253fda9279dSmrg} 6254fda9279dSmrg 6255fda9279dSmrgchar * 6256fda9279dSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257fda9279dSmrg{ 6258fda9279dSmrg char *new_value; 6259fda9279dSmrg if (orig_value && *orig_value) 6260fda9279dSmrg { 626116ee1e9aSmrg size_t orig_value_len = strlen (orig_value); 626216ee1e9aSmrg size_t add_len = strlen (add); 6263fda9279dSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264fda9279dSmrg if (to_end) 6265fda9279dSmrg { 6266fda9279dSmrg strcpy (new_value, orig_value); 6267fda9279dSmrg strcpy (new_value + orig_value_len, add); 6268fda9279dSmrg } 6269fda9279dSmrg else 6270fda9279dSmrg { 6271fda9279dSmrg strcpy (new_value, add); 6272fda9279dSmrg strcpy (new_value + add_len, orig_value); 6273fda9279dSmrg } 6274fda9279dSmrg } 6275fda9279dSmrg else 6276fda9279dSmrg { 6277fda9279dSmrg new_value = xstrdup (add); 6278fda9279dSmrg } 6279fda9279dSmrg return new_value; 6280fda9279dSmrg} 6281fda9279dSmrg 6282fda9279dSmrgvoid 6283fda9279dSmrglt_update_exe_path (const char *name, const char *value) 6284fda9279dSmrg{ 6285fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6286fda9279dSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287fda9279dSmrg nonnull (name), nonnull (value)); 6288fda9279dSmrg 6289fda9279dSmrg if (name && *name && value && *value) 6290fda9279dSmrg { 6291fda9279dSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292fda9279dSmrg /* some systems can't cope with a ':'-terminated path #' */ 629316ee1e9aSmrg size_t len = strlen (new_value); 629416ee1e9aSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295fda9279dSmrg { 629616ee1e9aSmrg new_value[--len] = '\0'; 6297fda9279dSmrg } 6298fda9279dSmrg lt_setenv (name, new_value); 6299fda9279dSmrg XFREE (new_value); 6300fda9279dSmrg } 6301fda9279dSmrg} 6302fda9279dSmrg 6303fda9279dSmrgvoid 6304fda9279dSmrglt_update_lib_path (const char *name, const char *value) 6305fda9279dSmrg{ 6306fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6307fda9279dSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308fda9279dSmrg nonnull (name), nonnull (value)); 6309fda9279dSmrg 6310fda9279dSmrg if (name && *name && value && *value) 6311fda9279dSmrg { 6312fda9279dSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313fda9279dSmrg lt_setenv (name, new_value); 6314fda9279dSmrg XFREE (new_value); 6315fda9279dSmrg } 6316fda9279dSmrg} 6317fda9279dSmrg 6318fda9279dSmrgEOF 6319fda9279dSmrg case $host_os in 6320fda9279dSmrg mingw*) 6321fda9279dSmrg cat <<"EOF" 6322fda9279dSmrg 6323fda9279dSmrg/* Prepares an argument vector before calling spawn(). 6324fda9279dSmrg Note that spawn() does not by itself call the command interpreter 6325fda9279dSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326fda9279dSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327fda9279dSmrg GetVersionEx(&v); 6328fda9279dSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329fda9279dSmrg }) ? "cmd.exe" : "command.com"). 6330fda9279dSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 6331fda9279dSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332fda9279dSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333fda9279dSmrg special way: 6334fda9279dSmrg - Space and tab are interpreted as delimiters. They are not treated as 6335fda9279dSmrg delimiters if they are surrounded by double quotes: "...". 6336fda9279dSmrg - Unescaped double quotes are removed from the input. Their only effect is 6337fda9279dSmrg that within double quotes, space and tab are treated like normal 6338fda9279dSmrg characters. 6339fda9279dSmrg - Backslashes not followed by double quotes are not special. 6340fda9279dSmrg - But 2*n+1 backslashes followed by a double quote become 6341fda9279dSmrg n backslashes followed by a double quote (n >= 0): 6342fda9279dSmrg \" -> " 6343fda9279dSmrg \\\" -> \" 6344fda9279dSmrg \\\\\" -> \\" 6345fda9279dSmrg */ 6346fda9279dSmrg#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" 6347fda9279dSmrg#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" 6348fda9279dSmrgchar ** 6349fda9279dSmrgprepare_spawn (char **argv) 6350fda9279dSmrg{ 6351fda9279dSmrg size_t argc; 6352fda9279dSmrg char **new_argv; 6353fda9279dSmrg size_t i; 6354fda9279dSmrg 6355fda9279dSmrg /* Count number of arguments. */ 6356fda9279dSmrg for (argc = 0; argv[argc] != NULL; argc++) 6357fda9279dSmrg ; 6358fda9279dSmrg 6359fda9279dSmrg /* Allocate new argument vector. */ 6360fda9279dSmrg new_argv = XMALLOC (char *, argc + 1); 6361fda9279dSmrg 6362fda9279dSmrg /* Put quoted arguments into the new argument vector. */ 6363fda9279dSmrg for (i = 0; i < argc; i++) 6364fda9279dSmrg { 6365fda9279dSmrg const char *string = argv[i]; 6366fda9279dSmrg 6367fda9279dSmrg if (string[0] == '\0') 6368fda9279dSmrg new_argv[i] = xstrdup ("\"\""); 6369fda9279dSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370fda9279dSmrg { 6371fda9279dSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372fda9279dSmrg size_t length; 6373fda9279dSmrg unsigned int backslashes; 6374fda9279dSmrg const char *s; 6375fda9279dSmrg char *quoted_string; 6376fda9279dSmrg char *p; 6377fda9279dSmrg 6378fda9279dSmrg length = 0; 6379fda9279dSmrg backslashes = 0; 6380fda9279dSmrg if (quote_around) 6381fda9279dSmrg length++; 6382fda9279dSmrg for (s = string; *s != '\0'; s++) 6383fda9279dSmrg { 6384fda9279dSmrg char c = *s; 6385fda9279dSmrg if (c == '"') 6386fda9279dSmrg length += backslashes + 1; 6387fda9279dSmrg length++; 6388fda9279dSmrg if (c == '\\') 6389fda9279dSmrg backslashes++; 6390fda9279dSmrg else 6391fda9279dSmrg backslashes = 0; 6392fda9279dSmrg } 6393fda9279dSmrg if (quote_around) 6394fda9279dSmrg length += backslashes + 1; 6395fda9279dSmrg 6396fda9279dSmrg quoted_string = XMALLOC (char, length + 1); 6397fda9279dSmrg 6398fda9279dSmrg p = quoted_string; 6399fda9279dSmrg backslashes = 0; 6400fda9279dSmrg if (quote_around) 6401fda9279dSmrg *p++ = '"'; 6402fda9279dSmrg for (s = string; *s != '\0'; s++) 6403fda9279dSmrg { 6404fda9279dSmrg char c = *s; 6405fda9279dSmrg if (c == '"') 6406fda9279dSmrg { 6407fda9279dSmrg unsigned int j; 6408fda9279dSmrg for (j = backslashes + 1; j > 0; j--) 6409fda9279dSmrg *p++ = '\\'; 6410fda9279dSmrg } 6411fda9279dSmrg *p++ = c; 6412fda9279dSmrg if (c == '\\') 6413fda9279dSmrg backslashes++; 6414fda9279dSmrg else 6415fda9279dSmrg backslashes = 0; 6416fda9279dSmrg } 6417fda9279dSmrg if (quote_around) 6418fda9279dSmrg { 6419fda9279dSmrg unsigned int j; 6420fda9279dSmrg for (j = backslashes; j > 0; j--) 6421fda9279dSmrg *p++ = '\\'; 6422fda9279dSmrg *p++ = '"'; 6423fda9279dSmrg } 6424fda9279dSmrg *p = '\0'; 6425fda9279dSmrg 6426fda9279dSmrg new_argv[i] = quoted_string; 6427fda9279dSmrg } 6428fda9279dSmrg else 6429fda9279dSmrg new_argv[i] = (char *) string; 6430fda9279dSmrg } 6431fda9279dSmrg new_argv[argc] = NULL; 6432fda9279dSmrg 6433fda9279dSmrg return new_argv; 6434fda9279dSmrg} 6435fda9279dSmrgEOF 6436fda9279dSmrg ;; 6437fda9279dSmrg esac 6438fda9279dSmrg 6439fda9279dSmrg cat <<"EOF" 6440fda9279dSmrgvoid lt_dump_script (FILE* f) 6441fda9279dSmrg{ 6442fda9279dSmrgEOF 6443fda9279dSmrg func_emit_wrapper yes | 6444fda9279dSmrg $SED -n -e ' 6445fda9279dSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6446fda9279dSmrg\2/ 6447fda9279dSmrgh 6448fda9279dSmrgs/\([\\"]\)/\\\1/g 6449fda9279dSmrgs/$/\\n/ 6450fda9279dSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451fda9279dSmrgg 6452fda9279dSmrgD' 6453fda9279dSmrg cat <<"EOF" 6454fda9279dSmrg} 6455fda9279dSmrgEOF 6456fda9279dSmrg} 6457fda9279dSmrg# end: func_emit_cwrapperexe_src 6458fda9279dSmrg 6459fda9279dSmrg# func_win32_import_lib_p ARG 6460fda9279dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6461fda9279dSmrgfunc_win32_import_lib_p () 6462fda9279dSmrg{ 646316ee1e9aSmrg $debug_cmd 646416ee1e9aSmrg 6465fda9279dSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466fda9279dSmrg *import*) : ;; 6467fda9279dSmrg *) false ;; 6468fda9279dSmrg esac 6469fda9279dSmrg} 6470fda9279dSmrg 647116ee1e9aSmrg# func_suncc_cstd_abi 647216ee1e9aSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647316ee1e9aSmrg# Several compiler flags select an ABI that is incompatible with the 647416ee1e9aSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647516ee1e9aSmrgfunc_suncc_cstd_abi () 647616ee1e9aSmrg{ 647716ee1e9aSmrg $debug_cmd 647816ee1e9aSmrg 647916ee1e9aSmrg case " $compile_command " in 648016ee1e9aSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648116ee1e9aSmrg suncc_use_cstd_abi=no 648216ee1e9aSmrg ;; 648316ee1e9aSmrg *) 648416ee1e9aSmrg suncc_use_cstd_abi=yes 648516ee1e9aSmrg ;; 648616ee1e9aSmrg esac 648716ee1e9aSmrg} 648816ee1e9aSmrg 6489fda9279dSmrg# func_mode_link arg... 6490fda9279dSmrgfunc_mode_link () 6491fda9279dSmrg{ 649216ee1e9aSmrg $debug_cmd 649316ee1e9aSmrg 6494fda9279dSmrg case $host in 6495fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496fda9279dSmrg # It is impossible to link a dll without this setting, and 6497fda9279dSmrg # we shouldn't force the makefile maintainer to figure out 649816ee1e9aSmrg # what system we are compiling for in order to pass an extra 6499fda9279dSmrg # flag for every libtool invocation. 6500fda9279dSmrg # allow_undefined=no 6501fda9279dSmrg 6502fda9279dSmrg # FIXME: Unfortunately, there are problems with the above when trying 650316ee1e9aSmrg # to make a dll that has undefined symbols, in which case not 6504fda9279dSmrg # even a static library is built. For now, we need to specify 6505fda9279dSmrg # -no-undefined on the libtool link line when we can be certain 6506fda9279dSmrg # that all symbols are satisfied, otherwise we get a static library. 6507fda9279dSmrg allow_undefined=yes 6508fda9279dSmrg ;; 6509fda9279dSmrg *) 6510fda9279dSmrg allow_undefined=yes 6511fda9279dSmrg ;; 6512fda9279dSmrg esac 6513fda9279dSmrg libtool_args=$nonopt 6514fda9279dSmrg base_compile="$nonopt $@" 6515fda9279dSmrg compile_command=$nonopt 6516fda9279dSmrg finalize_command=$nonopt 6517fda9279dSmrg 6518fda9279dSmrg compile_rpath= 6519fda9279dSmrg finalize_rpath= 6520fda9279dSmrg compile_shlibpath= 6521fda9279dSmrg finalize_shlibpath= 6522fda9279dSmrg convenience= 6523fda9279dSmrg old_convenience= 6524fda9279dSmrg deplibs= 6525fda9279dSmrg old_deplibs= 6526fda9279dSmrg compiler_flags= 6527fda9279dSmrg linker_flags= 6528fda9279dSmrg dllsearchpath= 6529fda9279dSmrg lib_search_path=`pwd` 6530fda9279dSmrg inst_prefix_dir= 6531fda9279dSmrg new_inherited_linker_flags= 6532fda9279dSmrg 6533fda9279dSmrg avoid_version=no 6534fda9279dSmrg bindir= 6535fda9279dSmrg dlfiles= 6536fda9279dSmrg dlprefiles= 6537fda9279dSmrg dlself=no 6538fda9279dSmrg export_dynamic=no 6539fda9279dSmrg export_symbols= 6540fda9279dSmrg export_symbols_regex= 6541fda9279dSmrg generated= 6542fda9279dSmrg libobjs= 6543fda9279dSmrg ltlibs= 6544fda9279dSmrg module=no 6545fda9279dSmrg no_install=no 6546fda9279dSmrg objs= 654716ee1e9aSmrg os2dllname= 6548fda9279dSmrg non_pic_objects= 6549fda9279dSmrg precious_files_regex= 6550fda9279dSmrg prefer_static_libs=no 655116ee1e9aSmrg preload=false 6552fda9279dSmrg prev= 6553fda9279dSmrg prevarg= 6554fda9279dSmrg release= 6555fda9279dSmrg rpath= 6556fda9279dSmrg xrpath= 6557fda9279dSmrg perm_rpath= 6558fda9279dSmrg temp_rpath= 6559fda9279dSmrg thread_safe=no 6560fda9279dSmrg vinfo= 6561fda9279dSmrg vinfo_number=no 6562fda9279dSmrg weak_libs= 656316ee1e9aSmrg single_module=$wl-single_module 6564fda9279dSmrg func_infer_tag $base_compile 6565fda9279dSmrg 6566fda9279dSmrg # We need to know -static, to get the right output filenames. 6567fda9279dSmrg for arg 6568fda9279dSmrg do 6569fda9279dSmrg case $arg in 6570fda9279dSmrg -shared) 657116ee1e9aSmrg test yes != "$build_libtool_libs" \ 657216ee1e9aSmrg && func_fatal_configuration "cannot build a shared library" 6573fda9279dSmrg build_old_libs=no 6574fda9279dSmrg break 6575fda9279dSmrg ;; 6576fda9279dSmrg -all-static | -static | -static-libtool-libs) 6577fda9279dSmrg case $arg in 6578fda9279dSmrg -all-static) 657916ee1e9aSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580fda9279dSmrg func_warning "complete static linking is impossible in this configuration" 6581fda9279dSmrg fi 6582fda9279dSmrg if test -n "$link_static_flag"; then 6583fda9279dSmrg dlopen_self=$dlopen_self_static 6584fda9279dSmrg fi 6585fda9279dSmrg prefer_static_libs=yes 6586fda9279dSmrg ;; 6587fda9279dSmrg -static) 6588fda9279dSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589fda9279dSmrg dlopen_self=$dlopen_self_static 6590fda9279dSmrg fi 6591fda9279dSmrg prefer_static_libs=built 6592fda9279dSmrg ;; 6593fda9279dSmrg -static-libtool-libs) 6594fda9279dSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595fda9279dSmrg dlopen_self=$dlopen_self_static 6596fda9279dSmrg fi 6597fda9279dSmrg prefer_static_libs=yes 6598fda9279dSmrg ;; 6599fda9279dSmrg esac 6600fda9279dSmrg build_libtool_libs=no 6601fda9279dSmrg build_old_libs=yes 6602fda9279dSmrg break 6603fda9279dSmrg ;; 6604fda9279dSmrg esac 6605fda9279dSmrg done 6606fda9279dSmrg 6607fda9279dSmrg # See if our shared archives depend on static archives. 6608fda9279dSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609fda9279dSmrg 6610fda9279dSmrg # Go through the arguments, transforming them on the way. 6611fda9279dSmrg while test "$#" -gt 0; do 661216ee1e9aSmrg arg=$1 6613fda9279dSmrg shift 6614fda9279dSmrg func_quote_for_eval "$arg" 6615fda9279dSmrg qarg=$func_quote_for_eval_unquoted_result 6616fda9279dSmrg func_append libtool_args " $func_quote_for_eval_result" 6617fda9279dSmrg 6618fda9279dSmrg # If the previous option needs an argument, assign it. 6619fda9279dSmrg if test -n "$prev"; then 6620fda9279dSmrg case $prev in 6621fda9279dSmrg output) 6622fda9279dSmrg func_append compile_command " @OUTPUT@" 6623fda9279dSmrg func_append finalize_command " @OUTPUT@" 6624fda9279dSmrg ;; 6625fda9279dSmrg esac 6626fda9279dSmrg 6627fda9279dSmrg case $prev in 6628fda9279dSmrg bindir) 662916ee1e9aSmrg bindir=$arg 6630fda9279dSmrg prev= 6631fda9279dSmrg continue 6632fda9279dSmrg ;; 6633fda9279dSmrg dlfiles|dlprefiles) 663416ee1e9aSmrg $preload || { 6635fda9279dSmrg # Add the symbol object into the linking commands. 6636fda9279dSmrg func_append compile_command " @SYMFILE@" 6637fda9279dSmrg func_append finalize_command " @SYMFILE@" 663816ee1e9aSmrg preload=: 663916ee1e9aSmrg } 6640fda9279dSmrg case $arg in 6641fda9279dSmrg *.la | *.lo) ;; # We handle these cases below. 6642fda9279dSmrg force) 664316ee1e9aSmrg if test no = "$dlself"; then 6644fda9279dSmrg dlself=needless 6645fda9279dSmrg export_dynamic=yes 6646fda9279dSmrg fi 6647fda9279dSmrg prev= 6648fda9279dSmrg continue 6649fda9279dSmrg ;; 6650fda9279dSmrg self) 665116ee1e9aSmrg if test dlprefiles = "$prev"; then 6652fda9279dSmrg dlself=yes 665316ee1e9aSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654fda9279dSmrg dlself=yes 6655fda9279dSmrg else 6656fda9279dSmrg dlself=needless 6657fda9279dSmrg export_dynamic=yes 6658fda9279dSmrg fi 6659fda9279dSmrg prev= 6660fda9279dSmrg continue 6661fda9279dSmrg ;; 6662fda9279dSmrg *) 666316ee1e9aSmrg if test dlfiles = "$prev"; then 6664fda9279dSmrg func_append dlfiles " $arg" 6665fda9279dSmrg else 6666fda9279dSmrg func_append dlprefiles " $arg" 6667fda9279dSmrg fi 6668fda9279dSmrg prev= 6669fda9279dSmrg continue 6670fda9279dSmrg ;; 6671fda9279dSmrg esac 6672fda9279dSmrg ;; 6673fda9279dSmrg expsyms) 667416ee1e9aSmrg export_symbols=$arg 6675fda9279dSmrg test -f "$arg" \ 667616ee1e9aSmrg || func_fatal_error "symbol file '$arg' does not exist" 6677fda9279dSmrg prev= 6678fda9279dSmrg continue 6679fda9279dSmrg ;; 6680fda9279dSmrg expsyms_regex) 668116ee1e9aSmrg export_symbols_regex=$arg 6682fda9279dSmrg prev= 6683fda9279dSmrg continue 6684fda9279dSmrg ;; 6685fda9279dSmrg framework) 6686fda9279dSmrg case $host in 6687fda9279dSmrg *-*-darwin*) 6688fda9279dSmrg case "$deplibs " in 6689fda9279dSmrg *" $qarg.ltframework "*) ;; 6690fda9279dSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691fda9279dSmrg ;; 6692fda9279dSmrg esac 6693fda9279dSmrg ;; 6694fda9279dSmrg esac 6695fda9279dSmrg prev= 6696fda9279dSmrg continue 6697fda9279dSmrg ;; 6698fda9279dSmrg inst_prefix) 669916ee1e9aSmrg inst_prefix_dir=$arg 670016ee1e9aSmrg prev= 670116ee1e9aSmrg continue 670216ee1e9aSmrg ;; 670316ee1e9aSmrg mllvm) 670416ee1e9aSmrg # Clang does not use LLVM to link, so we can simply discard any 670516ee1e9aSmrg # '-mllvm $arg' options when doing the link step. 6706fda9279dSmrg prev= 6707fda9279dSmrg continue 6708fda9279dSmrg ;; 6709fda9279dSmrg objectlist) 6710fda9279dSmrg if test -f "$arg"; then 6711fda9279dSmrg save_arg=$arg 6712fda9279dSmrg moreargs= 6713fda9279dSmrg for fil in `cat "$save_arg"` 6714fda9279dSmrg do 6715fda9279dSmrg# func_append moreargs " $fil" 6716fda9279dSmrg arg=$fil 6717fda9279dSmrg # A libtool-controlled object. 6718fda9279dSmrg 6719fda9279dSmrg # Check to see that this really is a libtool object. 6720fda9279dSmrg if func_lalib_unsafe_p "$arg"; then 6721fda9279dSmrg pic_object= 6722fda9279dSmrg non_pic_object= 6723fda9279dSmrg 6724fda9279dSmrg # Read the .lo file 6725fda9279dSmrg func_source "$arg" 6726fda9279dSmrg 6727fda9279dSmrg if test -z "$pic_object" || 6728fda9279dSmrg test -z "$non_pic_object" || 672916ee1e9aSmrg test none = "$pic_object" && 673016ee1e9aSmrg test none = "$non_pic_object"; then 673116ee1e9aSmrg func_fatal_error "cannot find name of object for '$arg'" 6732fda9279dSmrg fi 6733fda9279dSmrg 6734fda9279dSmrg # Extract subdirectory from the argument. 6735fda9279dSmrg func_dirname "$arg" "/" "" 673616ee1e9aSmrg xdir=$func_dirname_result 6737fda9279dSmrg 673816ee1e9aSmrg if test none != "$pic_object"; then 6739fda9279dSmrg # Prepend the subdirectory the object is found in. 674016ee1e9aSmrg pic_object=$xdir$pic_object 6741fda9279dSmrg 674216ee1e9aSmrg if test dlfiles = "$prev"; then 674316ee1e9aSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744fda9279dSmrg func_append dlfiles " $pic_object" 6745fda9279dSmrg prev= 6746fda9279dSmrg continue 6747fda9279dSmrg else 6748fda9279dSmrg # If libtool objects are unsupported, then we need to preload. 6749fda9279dSmrg prev=dlprefiles 6750fda9279dSmrg fi 6751fda9279dSmrg fi 6752fda9279dSmrg 6753fda9279dSmrg # CHECK ME: I think I busted this. -Ossama 675416ee1e9aSmrg if test dlprefiles = "$prev"; then 6755fda9279dSmrg # Preload the old-style object. 6756fda9279dSmrg func_append dlprefiles " $pic_object" 6757fda9279dSmrg prev= 6758fda9279dSmrg fi 6759fda9279dSmrg 6760fda9279dSmrg # A PIC object. 6761fda9279dSmrg func_append libobjs " $pic_object" 676216ee1e9aSmrg arg=$pic_object 6763fda9279dSmrg fi 6764fda9279dSmrg 6765fda9279dSmrg # Non-PIC object. 676616ee1e9aSmrg if test none != "$non_pic_object"; then 6767fda9279dSmrg # Prepend the subdirectory the object is found in. 676816ee1e9aSmrg non_pic_object=$xdir$non_pic_object 6769fda9279dSmrg 6770fda9279dSmrg # A standard non-PIC object 6771fda9279dSmrg func_append non_pic_objects " $non_pic_object" 677216ee1e9aSmrg if test -z "$pic_object" || test none = "$pic_object"; then 677316ee1e9aSmrg arg=$non_pic_object 6774fda9279dSmrg fi 6775fda9279dSmrg else 6776fda9279dSmrg # If the PIC object exists, use it instead. 6777fda9279dSmrg # $xdir was prepended to $pic_object above. 677816ee1e9aSmrg non_pic_object=$pic_object 6779fda9279dSmrg func_append non_pic_objects " $non_pic_object" 6780fda9279dSmrg fi 6781fda9279dSmrg else 6782fda9279dSmrg # Only an error if not doing a dry-run. 6783fda9279dSmrg if $opt_dry_run; then 6784fda9279dSmrg # Extract subdirectory from the argument. 6785fda9279dSmrg func_dirname "$arg" "/" "" 678616ee1e9aSmrg xdir=$func_dirname_result 6787fda9279dSmrg 6788fda9279dSmrg func_lo2o "$arg" 6789fda9279dSmrg pic_object=$xdir$objdir/$func_lo2o_result 6790fda9279dSmrg non_pic_object=$xdir$func_lo2o_result 6791fda9279dSmrg func_append libobjs " $pic_object" 6792fda9279dSmrg func_append non_pic_objects " $non_pic_object" 6793fda9279dSmrg else 679416ee1e9aSmrg func_fatal_error "'$arg' is not a valid libtool object" 6795fda9279dSmrg fi 6796fda9279dSmrg fi 6797fda9279dSmrg done 6798fda9279dSmrg else 679916ee1e9aSmrg func_fatal_error "link input file '$arg' does not exist" 6800fda9279dSmrg fi 6801fda9279dSmrg arg=$save_arg 6802fda9279dSmrg prev= 6803fda9279dSmrg continue 6804fda9279dSmrg ;; 680516ee1e9aSmrg os2dllname) 680616ee1e9aSmrg os2dllname=$arg 680716ee1e9aSmrg prev= 680816ee1e9aSmrg continue 680916ee1e9aSmrg ;; 6810fda9279dSmrg precious_regex) 681116ee1e9aSmrg precious_files_regex=$arg 6812fda9279dSmrg prev= 6813fda9279dSmrg continue 6814fda9279dSmrg ;; 6815fda9279dSmrg release) 681616ee1e9aSmrg release=-$arg 6817fda9279dSmrg prev= 6818fda9279dSmrg continue 6819fda9279dSmrg ;; 6820fda9279dSmrg rpath | xrpath) 6821fda9279dSmrg # We need an absolute path. 6822fda9279dSmrg case $arg in 6823fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824fda9279dSmrg *) 6825fda9279dSmrg func_fatal_error "only absolute run-paths are allowed" 6826fda9279dSmrg ;; 6827fda9279dSmrg esac 682816ee1e9aSmrg if test rpath = "$prev"; then 6829fda9279dSmrg case "$rpath " in 6830fda9279dSmrg *" $arg "*) ;; 6831fda9279dSmrg *) func_append rpath " $arg" ;; 6832fda9279dSmrg esac 6833fda9279dSmrg else 6834fda9279dSmrg case "$xrpath " in 6835fda9279dSmrg *" $arg "*) ;; 6836fda9279dSmrg *) func_append xrpath " $arg" ;; 6837fda9279dSmrg esac 6838fda9279dSmrg fi 6839fda9279dSmrg prev= 6840fda9279dSmrg continue 6841fda9279dSmrg ;; 6842fda9279dSmrg shrext) 684316ee1e9aSmrg shrext_cmds=$arg 6844fda9279dSmrg prev= 6845fda9279dSmrg continue 6846fda9279dSmrg ;; 6847fda9279dSmrg weak) 6848fda9279dSmrg func_append weak_libs " $arg" 6849fda9279dSmrg prev= 6850fda9279dSmrg continue 6851fda9279dSmrg ;; 6852fda9279dSmrg xcclinker) 6853fda9279dSmrg func_append linker_flags " $qarg" 6854fda9279dSmrg func_append compiler_flags " $qarg" 6855fda9279dSmrg prev= 6856fda9279dSmrg func_append compile_command " $qarg" 6857fda9279dSmrg func_append finalize_command " $qarg" 6858fda9279dSmrg continue 6859fda9279dSmrg ;; 6860fda9279dSmrg xcompiler) 6861fda9279dSmrg func_append compiler_flags " $qarg" 6862fda9279dSmrg prev= 6863fda9279dSmrg func_append compile_command " $qarg" 6864fda9279dSmrg func_append finalize_command " $qarg" 6865fda9279dSmrg continue 6866fda9279dSmrg ;; 6867fda9279dSmrg xlinker) 6868fda9279dSmrg func_append linker_flags " $qarg" 6869fda9279dSmrg func_append compiler_flags " $wl$qarg" 6870fda9279dSmrg prev= 6871fda9279dSmrg func_append compile_command " $wl$qarg" 6872fda9279dSmrg func_append finalize_command " $wl$qarg" 6873fda9279dSmrg continue 6874fda9279dSmrg ;; 6875fda9279dSmrg *) 6876fda9279dSmrg eval "$prev=\"\$arg\"" 6877fda9279dSmrg prev= 6878fda9279dSmrg continue 6879fda9279dSmrg ;; 6880fda9279dSmrg esac 6881fda9279dSmrg fi # test -n "$prev" 6882fda9279dSmrg 688316ee1e9aSmrg prevarg=$arg 6884fda9279dSmrg 6885fda9279dSmrg case $arg in 6886fda9279dSmrg -all-static) 6887fda9279dSmrg if test -n "$link_static_flag"; then 6888fda9279dSmrg # See comment for -static flag below, for more details. 6889fda9279dSmrg func_append compile_command " $link_static_flag" 6890fda9279dSmrg func_append finalize_command " $link_static_flag" 6891fda9279dSmrg fi 6892fda9279dSmrg continue 6893fda9279dSmrg ;; 6894fda9279dSmrg 6895fda9279dSmrg -allow-undefined) 6896fda9279dSmrg # FIXME: remove this flag sometime in the future. 689716ee1e9aSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898fda9279dSmrg ;; 6899fda9279dSmrg 6900fda9279dSmrg -avoid-version) 6901fda9279dSmrg avoid_version=yes 6902fda9279dSmrg continue 6903fda9279dSmrg ;; 6904fda9279dSmrg 6905fda9279dSmrg -bindir) 6906fda9279dSmrg prev=bindir 6907fda9279dSmrg continue 6908fda9279dSmrg ;; 6909fda9279dSmrg 6910fda9279dSmrg -dlopen) 6911fda9279dSmrg prev=dlfiles 6912fda9279dSmrg continue 6913fda9279dSmrg ;; 6914fda9279dSmrg 6915fda9279dSmrg -dlpreopen) 6916fda9279dSmrg prev=dlprefiles 6917fda9279dSmrg continue 6918fda9279dSmrg ;; 6919fda9279dSmrg 6920fda9279dSmrg -export-dynamic) 6921fda9279dSmrg export_dynamic=yes 6922fda9279dSmrg continue 6923fda9279dSmrg ;; 6924fda9279dSmrg 6925fda9279dSmrg -export-symbols | -export-symbols-regex) 6926fda9279dSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927fda9279dSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928fda9279dSmrg fi 692916ee1e9aSmrg if test X-export-symbols = "X$arg"; then 6930fda9279dSmrg prev=expsyms 6931fda9279dSmrg else 6932fda9279dSmrg prev=expsyms_regex 6933fda9279dSmrg fi 6934fda9279dSmrg continue 6935fda9279dSmrg ;; 6936fda9279dSmrg 6937fda9279dSmrg -framework) 6938fda9279dSmrg prev=framework 6939fda9279dSmrg continue 6940fda9279dSmrg ;; 6941fda9279dSmrg 6942fda9279dSmrg -inst-prefix-dir) 6943fda9279dSmrg prev=inst_prefix 6944fda9279dSmrg continue 6945fda9279dSmrg ;; 6946fda9279dSmrg 6947fda9279dSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948fda9279dSmrg # so, if we see these flags be careful not to treat them like -L 6949fda9279dSmrg -L[A-Z][A-Z]*:*) 6950fda9279dSmrg case $with_gcc/$host in 6951fda9279dSmrg no/*-*-irix* | /*-*-irix*) 6952fda9279dSmrg func_append compile_command " $arg" 6953fda9279dSmrg func_append finalize_command " $arg" 6954fda9279dSmrg ;; 6955fda9279dSmrg esac 6956fda9279dSmrg continue 6957fda9279dSmrg ;; 6958fda9279dSmrg 6959fda9279dSmrg -L*) 6960fda9279dSmrg func_stripname "-L" '' "$arg" 6961fda9279dSmrg if test -z "$func_stripname_result"; then 6962fda9279dSmrg if test "$#" -gt 0; then 696316ee1e9aSmrg func_fatal_error "require no space between '-L' and '$1'" 6964fda9279dSmrg else 696516ee1e9aSmrg func_fatal_error "need path for '-L' option" 6966fda9279dSmrg fi 6967fda9279dSmrg fi 6968fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 6969fda9279dSmrg dir=$func_resolve_sysroot_result 6970fda9279dSmrg # We need an absolute path. 6971fda9279dSmrg case $dir in 6972fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973fda9279dSmrg *) 6974fda9279dSmrg absdir=`cd "$dir" && pwd` 6975fda9279dSmrg test -z "$absdir" && \ 697616ee1e9aSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697716ee1e9aSmrg dir=$absdir 6978fda9279dSmrg ;; 6979fda9279dSmrg esac 6980fda9279dSmrg case "$deplibs " in 6981fda9279dSmrg *" -L$dir "* | *" $arg "*) 6982fda9279dSmrg # Will only happen for absolute or sysroot arguments 6983fda9279dSmrg ;; 6984fda9279dSmrg *) 6985fda9279dSmrg # Preserve sysroot, but never include relative directories 6986fda9279dSmrg case $dir in 6987fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988fda9279dSmrg *) func_append deplibs " -L$dir" ;; 6989fda9279dSmrg esac 6990fda9279dSmrg func_append lib_search_path " $dir" 6991fda9279dSmrg ;; 6992fda9279dSmrg esac 6993fda9279dSmrg case $host in 6994fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995fda9279dSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996fda9279dSmrg case :$dllsearchpath: in 6997fda9279dSmrg *":$dir:"*) ;; 6998fda9279dSmrg ::) dllsearchpath=$dir;; 6999fda9279dSmrg *) func_append dllsearchpath ":$dir";; 7000fda9279dSmrg esac 7001fda9279dSmrg case :$dllsearchpath: in 7002fda9279dSmrg *":$testbindir:"*) ;; 7003fda9279dSmrg ::) dllsearchpath=$testbindir;; 7004fda9279dSmrg *) func_append dllsearchpath ":$testbindir";; 7005fda9279dSmrg esac 7006fda9279dSmrg ;; 7007fda9279dSmrg esac 7008fda9279dSmrg continue 7009fda9279dSmrg ;; 7010fda9279dSmrg 7011fda9279dSmrg -l*) 701216ee1e9aSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013fda9279dSmrg case $host in 7014fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015fda9279dSmrg # These systems don't actually have a C or math library (as such) 7016fda9279dSmrg continue 7017fda9279dSmrg ;; 7018fda9279dSmrg *-*-os2*) 7019fda9279dSmrg # These systems don't actually have a C library (as such) 702016ee1e9aSmrg test X-lc = "X$arg" && continue 7021fda9279dSmrg ;; 702216ee1e9aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023fda9279dSmrg # Do not include libc due to us having libc/libc_r. 702416ee1e9aSmrg test X-lc = "X$arg" && continue 7025fda9279dSmrg ;; 7026fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7027fda9279dSmrg # Rhapsody C and math libraries are in the System framework 7028fda9279dSmrg func_append deplibs " System.ltframework" 7029fda9279dSmrg continue 7030fda9279dSmrg ;; 7031fda9279dSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7032fda9279dSmrg # Causes problems with __ctype 703316ee1e9aSmrg test X-lc = "X$arg" && continue 7034fda9279dSmrg ;; 7035fda9279dSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036fda9279dSmrg # Compiler inserts libc in the correct place for threads to work 703716ee1e9aSmrg test X-lc = "X$arg" && continue 7038fda9279dSmrg ;; 7039fda9279dSmrg esac 704016ee1e9aSmrg elif test X-lc_r = "X$arg"; then 7041fda9279dSmrg case $host in 704216ee1e9aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043fda9279dSmrg # Do not include libc_r directly, use -pthread flag. 7044fda9279dSmrg continue 7045fda9279dSmrg ;; 7046fda9279dSmrg esac 7047fda9279dSmrg fi 7048fda9279dSmrg func_append deplibs " $arg" 7049fda9279dSmrg continue 7050fda9279dSmrg ;; 7051fda9279dSmrg 705216ee1e9aSmrg -mllvm) 705316ee1e9aSmrg prev=mllvm 705416ee1e9aSmrg continue 705516ee1e9aSmrg ;; 705616ee1e9aSmrg 7057fda9279dSmrg -module) 7058fda9279dSmrg module=yes 7059fda9279dSmrg continue 7060fda9279dSmrg ;; 7061fda9279dSmrg 7062fda9279dSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063fda9279dSmrg # classes, name mangling, and exception handling. 7064fda9279dSmrg # Darwin uses the -arch flag to determine output architecture. 7065fda9279dSmrg -model|-arch|-isysroot|--sysroot) 7066fda9279dSmrg func_append compiler_flags " $arg" 7067fda9279dSmrg func_append compile_command " $arg" 7068fda9279dSmrg func_append finalize_command " $arg" 7069fda9279dSmrg prev=xcompiler 7070fda9279dSmrg continue 7071fda9279dSmrg ;; 7072fda9279dSmrg 7073fda9279dSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074fda9279dSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075fda9279dSmrg func_append compiler_flags " $arg" 7076fda9279dSmrg func_append compile_command " $arg" 7077fda9279dSmrg func_append finalize_command " $arg" 7078fda9279dSmrg case "$new_inherited_linker_flags " in 7079fda9279dSmrg *" $arg "*) ;; 7080fda9279dSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081fda9279dSmrg esac 7082fda9279dSmrg continue 7083fda9279dSmrg ;; 7084fda9279dSmrg 7085fda9279dSmrg -multi_module) 708616ee1e9aSmrg single_module=$wl-multi_module 7087fda9279dSmrg continue 7088fda9279dSmrg ;; 7089fda9279dSmrg 7090fda9279dSmrg -no-fast-install) 7091fda9279dSmrg fast_install=no 7092fda9279dSmrg continue 7093fda9279dSmrg ;; 7094fda9279dSmrg 7095fda9279dSmrg -no-install) 7096fda9279dSmrg case $host in 7097fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098fda9279dSmrg # The PATH hackery in wrapper scripts is required on Windows 7099fda9279dSmrg # and Darwin in order for the loader to find any dlls it needs. 710016ee1e9aSmrg func_warning "'-no-install' is ignored for $host" 710116ee1e9aSmrg func_warning "assuming '-no-fast-install' instead" 7102fda9279dSmrg fast_install=no 7103fda9279dSmrg ;; 7104fda9279dSmrg *) no_install=yes ;; 7105fda9279dSmrg esac 7106fda9279dSmrg continue 7107fda9279dSmrg ;; 7108fda9279dSmrg 7109fda9279dSmrg -no-undefined) 7110fda9279dSmrg allow_undefined=no 7111fda9279dSmrg continue 7112fda9279dSmrg ;; 7113fda9279dSmrg 7114fda9279dSmrg -objectlist) 7115fda9279dSmrg prev=objectlist 7116fda9279dSmrg continue 7117fda9279dSmrg ;; 7118fda9279dSmrg 711916ee1e9aSmrg -os2dllname) 712016ee1e9aSmrg prev=os2dllname 712116ee1e9aSmrg continue 712216ee1e9aSmrg ;; 712316ee1e9aSmrg 7124fda9279dSmrg -o) prev=output ;; 7125fda9279dSmrg 7126fda9279dSmrg -precious-files-regex) 7127fda9279dSmrg prev=precious_regex 7128fda9279dSmrg continue 7129fda9279dSmrg ;; 7130fda9279dSmrg 7131fda9279dSmrg -release) 7132fda9279dSmrg prev=release 7133fda9279dSmrg continue 7134fda9279dSmrg ;; 7135fda9279dSmrg 7136fda9279dSmrg -rpath) 7137fda9279dSmrg prev=rpath 7138fda9279dSmrg continue 7139fda9279dSmrg ;; 7140fda9279dSmrg 7141fda9279dSmrg -R) 7142fda9279dSmrg prev=xrpath 7143fda9279dSmrg continue 7144fda9279dSmrg ;; 7145fda9279dSmrg 7146fda9279dSmrg -R*) 7147fda9279dSmrg func_stripname '-R' '' "$arg" 7148fda9279dSmrg dir=$func_stripname_result 7149fda9279dSmrg # We need an absolute path. 7150fda9279dSmrg case $dir in 7151fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7152fda9279dSmrg =*) 7153fda9279dSmrg func_stripname '=' '' "$dir" 7154fda9279dSmrg dir=$lt_sysroot$func_stripname_result 7155fda9279dSmrg ;; 7156fda9279dSmrg *) 7157fda9279dSmrg func_fatal_error "only absolute run-paths are allowed" 7158fda9279dSmrg ;; 7159fda9279dSmrg esac 7160fda9279dSmrg case "$xrpath " in 7161fda9279dSmrg *" $dir "*) ;; 7162fda9279dSmrg *) func_append xrpath " $dir" ;; 7163fda9279dSmrg esac 7164fda9279dSmrg continue 7165fda9279dSmrg ;; 7166fda9279dSmrg 7167fda9279dSmrg -shared) 7168fda9279dSmrg # The effects of -shared are defined in a previous loop. 7169fda9279dSmrg continue 7170fda9279dSmrg ;; 7171fda9279dSmrg 7172fda9279dSmrg -shrext) 7173fda9279dSmrg prev=shrext 7174fda9279dSmrg continue 7175fda9279dSmrg ;; 7176fda9279dSmrg 7177fda9279dSmrg -static | -static-libtool-libs) 7178fda9279dSmrg # The effects of -static are defined in a previous loop. 7179fda9279dSmrg # We used to do the same as -all-static on platforms that 7180fda9279dSmrg # didn't have a PIC flag, but the assumption that the effects 7181fda9279dSmrg # would be equivalent was wrong. It would break on at least 7182fda9279dSmrg # Digital Unix and AIX. 7183fda9279dSmrg continue 7184fda9279dSmrg ;; 7185fda9279dSmrg 7186fda9279dSmrg -thread-safe) 7187fda9279dSmrg thread_safe=yes 7188fda9279dSmrg continue 7189fda9279dSmrg ;; 7190fda9279dSmrg 7191fda9279dSmrg -version-info) 7192fda9279dSmrg prev=vinfo 7193fda9279dSmrg continue 7194fda9279dSmrg ;; 7195fda9279dSmrg 7196fda9279dSmrg -version-number) 7197fda9279dSmrg prev=vinfo 7198fda9279dSmrg vinfo_number=yes 7199fda9279dSmrg continue 7200fda9279dSmrg ;; 7201fda9279dSmrg 7202fda9279dSmrg -weak) 7203fda9279dSmrg prev=weak 7204fda9279dSmrg continue 7205fda9279dSmrg ;; 7206fda9279dSmrg 7207fda9279dSmrg -Wc,*) 7208fda9279dSmrg func_stripname '-Wc,' '' "$arg" 7209fda9279dSmrg args=$func_stripname_result 7210fda9279dSmrg arg= 721116ee1e9aSmrg save_ifs=$IFS; IFS=, 7212fda9279dSmrg for flag in $args; do 721316ee1e9aSmrg IFS=$save_ifs 7214fda9279dSmrg func_quote_for_eval "$flag" 7215fda9279dSmrg func_append arg " $func_quote_for_eval_result" 7216fda9279dSmrg func_append compiler_flags " $func_quote_for_eval_result" 7217fda9279dSmrg done 721816ee1e9aSmrg IFS=$save_ifs 7219fda9279dSmrg func_stripname ' ' '' "$arg" 7220fda9279dSmrg arg=$func_stripname_result 7221fda9279dSmrg ;; 7222fda9279dSmrg 7223fda9279dSmrg -Wl,*) 7224fda9279dSmrg func_stripname '-Wl,' '' "$arg" 7225fda9279dSmrg args=$func_stripname_result 7226fda9279dSmrg arg= 722716ee1e9aSmrg save_ifs=$IFS; IFS=, 7228fda9279dSmrg for flag in $args; do 722916ee1e9aSmrg IFS=$save_ifs 7230fda9279dSmrg func_quote_for_eval "$flag" 7231fda9279dSmrg func_append arg " $wl$func_quote_for_eval_result" 7232fda9279dSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7233fda9279dSmrg func_append linker_flags " $func_quote_for_eval_result" 7234fda9279dSmrg done 723516ee1e9aSmrg IFS=$save_ifs 7236fda9279dSmrg func_stripname ' ' '' "$arg" 7237fda9279dSmrg arg=$func_stripname_result 7238fda9279dSmrg ;; 7239fda9279dSmrg 7240fda9279dSmrg -Xcompiler) 7241fda9279dSmrg prev=xcompiler 7242fda9279dSmrg continue 7243fda9279dSmrg ;; 7244fda9279dSmrg 7245fda9279dSmrg -Xlinker) 7246fda9279dSmrg prev=xlinker 7247fda9279dSmrg continue 7248fda9279dSmrg ;; 7249fda9279dSmrg 7250fda9279dSmrg -XCClinker) 7251fda9279dSmrg prev=xcclinker 7252fda9279dSmrg continue 7253fda9279dSmrg ;; 7254fda9279dSmrg 7255fda9279dSmrg # -msg_* for osf cc 7256fda9279dSmrg -msg_*) 7257fda9279dSmrg func_quote_for_eval "$arg" 725816ee1e9aSmrg arg=$func_quote_for_eval_result 7259fda9279dSmrg ;; 7260fda9279dSmrg 7261fda9279dSmrg # Flags to be passed through unchanged, with rationale: 7262fda9279dSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263fda9279dSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 7264fda9279dSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265fda9279dSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7266fda9279dSmrg # -q* compiler args for the IBM compiler 7267fda9279dSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268fda9279dSmrg # -F/path path to uninstalled frameworks, gcc on darwin 7269fda9279dSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727016ee1e9aSmrg # -fstack-protector* stack protector flags for GCC 7271fda9279dSmrg # @file GCC response files 7272fda9279dSmrg # -tp=* Portland pgcc target processor selection 7273fda9279dSmrg # --sysroot=* for sysroot support 727416ee1e9aSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 727516ee1e9aSmrg # -stdlib=* select c++ std lib with clang 7276fda9279dSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277fda9279dSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 727816ee1e9aSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279fda9279dSmrg func_quote_for_eval "$arg" 728016ee1e9aSmrg arg=$func_quote_for_eval_result 7281fda9279dSmrg func_append compile_command " $arg" 7282fda9279dSmrg func_append finalize_command " $arg" 7283fda9279dSmrg func_append compiler_flags " $arg" 7284fda9279dSmrg continue 7285fda9279dSmrg ;; 7286fda9279dSmrg 728716ee1e9aSmrg -Z*) 728816ee1e9aSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 728916ee1e9aSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 729016ee1e9aSmrg compiler_flags="$compiler_flags $arg" 729116ee1e9aSmrg func_append compile_command " $arg" 729216ee1e9aSmrg func_append finalize_command " $arg" 729316ee1e9aSmrg case $arg in 729416ee1e9aSmrg -Zlinker | -Zstack) 729516ee1e9aSmrg prev=xcompiler 729616ee1e9aSmrg ;; 729716ee1e9aSmrg esac 729816ee1e9aSmrg continue 729916ee1e9aSmrg else 730016ee1e9aSmrg # Otherwise treat like 'Some other compiler flag' below 730116ee1e9aSmrg func_quote_for_eval "$arg" 730216ee1e9aSmrg arg=$func_quote_for_eval_result 730316ee1e9aSmrg fi 730416ee1e9aSmrg ;; 730516ee1e9aSmrg 7306fda9279dSmrg # Some other compiler flag. 7307fda9279dSmrg -* | +*) 7308fda9279dSmrg func_quote_for_eval "$arg" 730916ee1e9aSmrg arg=$func_quote_for_eval_result 7310fda9279dSmrg ;; 7311fda9279dSmrg 7312fda9279dSmrg *.$objext) 7313fda9279dSmrg # A standard object. 7314fda9279dSmrg func_append objs " $arg" 7315fda9279dSmrg ;; 7316fda9279dSmrg 7317fda9279dSmrg *.lo) 7318fda9279dSmrg # A libtool-controlled object. 7319fda9279dSmrg 7320fda9279dSmrg # Check to see that this really is a libtool object. 7321fda9279dSmrg if func_lalib_unsafe_p "$arg"; then 7322fda9279dSmrg pic_object= 7323fda9279dSmrg non_pic_object= 7324fda9279dSmrg 7325fda9279dSmrg # Read the .lo file 7326fda9279dSmrg func_source "$arg" 7327fda9279dSmrg 7328fda9279dSmrg if test -z "$pic_object" || 7329fda9279dSmrg test -z "$non_pic_object" || 733016ee1e9aSmrg test none = "$pic_object" && 733116ee1e9aSmrg test none = "$non_pic_object"; then 733216ee1e9aSmrg func_fatal_error "cannot find name of object for '$arg'" 7333fda9279dSmrg fi 7334fda9279dSmrg 7335fda9279dSmrg # Extract subdirectory from the argument. 7336fda9279dSmrg func_dirname "$arg" "/" "" 733716ee1e9aSmrg xdir=$func_dirname_result 7338fda9279dSmrg 733916ee1e9aSmrg test none = "$pic_object" || { 7340fda9279dSmrg # Prepend the subdirectory the object is found in. 734116ee1e9aSmrg pic_object=$xdir$pic_object 7342fda9279dSmrg 734316ee1e9aSmrg if test dlfiles = "$prev"; then 734416ee1e9aSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345fda9279dSmrg func_append dlfiles " $pic_object" 7346fda9279dSmrg prev= 7347fda9279dSmrg continue 7348fda9279dSmrg else 7349fda9279dSmrg # If libtool objects are unsupported, then we need to preload. 7350fda9279dSmrg prev=dlprefiles 7351fda9279dSmrg fi 7352fda9279dSmrg fi 7353fda9279dSmrg 7354fda9279dSmrg # CHECK ME: I think I busted this. -Ossama 735516ee1e9aSmrg if test dlprefiles = "$prev"; then 7356fda9279dSmrg # Preload the old-style object. 7357fda9279dSmrg func_append dlprefiles " $pic_object" 7358fda9279dSmrg prev= 7359fda9279dSmrg fi 7360fda9279dSmrg 7361fda9279dSmrg # A PIC object. 7362fda9279dSmrg func_append libobjs " $pic_object" 736316ee1e9aSmrg arg=$pic_object 736416ee1e9aSmrg } 7365fda9279dSmrg 7366fda9279dSmrg # Non-PIC object. 736716ee1e9aSmrg if test none != "$non_pic_object"; then 7368fda9279dSmrg # Prepend the subdirectory the object is found in. 736916ee1e9aSmrg non_pic_object=$xdir$non_pic_object 7370fda9279dSmrg 7371fda9279dSmrg # A standard non-PIC object 7372fda9279dSmrg func_append non_pic_objects " $non_pic_object" 737316ee1e9aSmrg if test -z "$pic_object" || test none = "$pic_object"; then 737416ee1e9aSmrg arg=$non_pic_object 7375fda9279dSmrg fi 7376fda9279dSmrg else 7377fda9279dSmrg # If the PIC object exists, use it instead. 7378fda9279dSmrg # $xdir was prepended to $pic_object above. 737916ee1e9aSmrg non_pic_object=$pic_object 7380fda9279dSmrg func_append non_pic_objects " $non_pic_object" 7381fda9279dSmrg fi 7382fda9279dSmrg else 7383fda9279dSmrg # Only an error if not doing a dry-run. 7384fda9279dSmrg if $opt_dry_run; then 7385fda9279dSmrg # Extract subdirectory from the argument. 7386fda9279dSmrg func_dirname "$arg" "/" "" 738716ee1e9aSmrg xdir=$func_dirname_result 7388fda9279dSmrg 7389fda9279dSmrg func_lo2o "$arg" 7390fda9279dSmrg pic_object=$xdir$objdir/$func_lo2o_result 7391fda9279dSmrg non_pic_object=$xdir$func_lo2o_result 7392fda9279dSmrg func_append libobjs " $pic_object" 7393fda9279dSmrg func_append non_pic_objects " $non_pic_object" 7394fda9279dSmrg else 739516ee1e9aSmrg func_fatal_error "'$arg' is not a valid libtool object" 7396fda9279dSmrg fi 7397fda9279dSmrg fi 7398fda9279dSmrg ;; 7399fda9279dSmrg 7400fda9279dSmrg *.$libext) 7401fda9279dSmrg # An archive. 7402fda9279dSmrg func_append deplibs " $arg" 7403fda9279dSmrg func_append old_deplibs " $arg" 7404fda9279dSmrg continue 7405fda9279dSmrg ;; 7406fda9279dSmrg 7407fda9279dSmrg *.la) 7408fda9279dSmrg # A libtool-controlled library. 7409fda9279dSmrg 7410fda9279dSmrg func_resolve_sysroot "$arg" 741116ee1e9aSmrg if test dlfiles = "$prev"; then 7412fda9279dSmrg # This library was specified with -dlopen. 7413fda9279dSmrg func_append dlfiles " $func_resolve_sysroot_result" 7414fda9279dSmrg prev= 741516ee1e9aSmrg elif test dlprefiles = "$prev"; then 7416fda9279dSmrg # The library was specified with -dlpreopen. 7417fda9279dSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7418fda9279dSmrg prev= 7419fda9279dSmrg else 7420fda9279dSmrg func_append deplibs " $func_resolve_sysroot_result" 7421fda9279dSmrg fi 7422fda9279dSmrg continue 7423fda9279dSmrg ;; 7424fda9279dSmrg 7425fda9279dSmrg # Some other compiler argument. 7426fda9279dSmrg *) 7427fda9279dSmrg # Unknown arguments in both finalize_command and compile_command need 7428fda9279dSmrg # to be aesthetically quoted because they are evaled later. 7429fda9279dSmrg func_quote_for_eval "$arg" 743016ee1e9aSmrg arg=$func_quote_for_eval_result 7431fda9279dSmrg ;; 7432fda9279dSmrg esac # arg 7433fda9279dSmrg 7434fda9279dSmrg # Now actually substitute the argument into the commands. 7435fda9279dSmrg if test -n "$arg"; then 7436fda9279dSmrg func_append compile_command " $arg" 7437fda9279dSmrg func_append finalize_command " $arg" 7438fda9279dSmrg fi 7439fda9279dSmrg done # argument parsing loop 7440fda9279dSmrg 7441fda9279dSmrg test -n "$prev" && \ 744216ee1e9aSmrg func_fatal_help "the '$prevarg' option requires an argument" 7443fda9279dSmrg 744416ee1e9aSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445fda9279dSmrg eval arg=\"$export_dynamic_flag_spec\" 7446fda9279dSmrg func_append compile_command " $arg" 7447fda9279dSmrg func_append finalize_command " $arg" 7448fda9279dSmrg fi 7449fda9279dSmrg 7450fda9279dSmrg oldlibs= 7451fda9279dSmrg # calculate the name of the file, without its directory 7452fda9279dSmrg func_basename "$output" 745316ee1e9aSmrg outputname=$func_basename_result 745416ee1e9aSmrg libobjs_save=$libobjs 7455fda9279dSmrg 7456fda9279dSmrg if test -n "$shlibpath_var"; then 7457fda9279dSmrg # get the directories listed in $shlibpath_var 745816ee1e9aSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459fda9279dSmrg else 7460fda9279dSmrg shlib_search_path= 7461fda9279dSmrg fi 7462fda9279dSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463fda9279dSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464fda9279dSmrg 746516ee1e9aSmrg # Definition is injected by LT_CONFIG during libtool generation. 746616ee1e9aSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 746716ee1e9aSmrg 7468fda9279dSmrg func_dirname "$output" "/" "" 746916ee1e9aSmrg output_objdir=$func_dirname_result$objdir 7470fda9279dSmrg func_to_tool_file "$output_objdir/" 7471fda9279dSmrg tool_output_objdir=$func_to_tool_file_result 7472fda9279dSmrg # Create the object directory. 7473fda9279dSmrg func_mkdir_p "$output_objdir" 7474fda9279dSmrg 7475fda9279dSmrg # Determine the type of output 7476fda9279dSmrg case $output in 7477fda9279dSmrg "") 7478fda9279dSmrg func_fatal_help "you must specify an output file" 7479fda9279dSmrg ;; 7480fda9279dSmrg *.$libext) linkmode=oldlib ;; 7481fda9279dSmrg *.lo | *.$objext) linkmode=obj ;; 7482fda9279dSmrg *.la) linkmode=lib ;; 7483fda9279dSmrg *) linkmode=prog ;; # Anything else should be a program. 7484fda9279dSmrg esac 7485fda9279dSmrg 7486fda9279dSmrg specialdeplibs= 7487fda9279dSmrg 7488fda9279dSmrg libs= 7489fda9279dSmrg # Find all interdependent deplibs by searching for libraries 7490fda9279dSmrg # that are linked more than once (e.g. -la -lb -la) 7491fda9279dSmrg for deplib in $deplibs; do 749216ee1e9aSmrg if $opt_preserve_dup_deps; then 7493fda9279dSmrg case "$libs " in 7494fda9279dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495fda9279dSmrg esac 7496fda9279dSmrg fi 7497fda9279dSmrg func_append libs " $deplib" 7498fda9279dSmrg done 7499fda9279dSmrg 750016ee1e9aSmrg if test lib = "$linkmode"; then 7501fda9279dSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502fda9279dSmrg 7503fda9279dSmrg # Compute libraries that are listed more than once in $predeps 7504fda9279dSmrg # $postdeps and mark them as special (i.e., whose duplicates are 7505fda9279dSmrg # not to be eliminated). 7506fda9279dSmrg pre_post_deps= 7507fda9279dSmrg if $opt_duplicate_compiler_generated_deps; then 7508fda9279dSmrg for pre_post_dep in $predeps $postdeps; do 7509fda9279dSmrg case "$pre_post_deps " in 7510fda9279dSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511fda9279dSmrg esac 7512fda9279dSmrg func_append pre_post_deps " $pre_post_dep" 7513fda9279dSmrg done 7514fda9279dSmrg fi 7515fda9279dSmrg pre_post_deps= 7516fda9279dSmrg fi 7517fda9279dSmrg 7518fda9279dSmrg deplibs= 7519fda9279dSmrg newdependency_libs= 7520fda9279dSmrg newlib_search_path= 7521fda9279dSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 7522fda9279dSmrg notinst_deplibs= # not-installed libtool libraries 7523fda9279dSmrg notinst_path= # paths that contain not-installed libtool libraries 7524fda9279dSmrg 7525fda9279dSmrg case $linkmode in 7526fda9279dSmrg lib) 7527fda9279dSmrg passes="conv dlpreopen link" 7528fda9279dSmrg for file in $dlfiles $dlprefiles; do 7529fda9279dSmrg case $file in 7530fda9279dSmrg *.la) ;; 7531fda9279dSmrg *) 753216ee1e9aSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533fda9279dSmrg ;; 7534fda9279dSmrg esac 7535fda9279dSmrg done 7536fda9279dSmrg ;; 7537fda9279dSmrg prog) 7538fda9279dSmrg compile_deplibs= 7539fda9279dSmrg finalize_deplibs= 754016ee1e9aSmrg alldeplibs=false 7541fda9279dSmrg newdlfiles= 7542fda9279dSmrg newdlprefiles= 7543fda9279dSmrg passes="conv scan dlopen dlpreopen link" 7544fda9279dSmrg ;; 7545fda9279dSmrg *) passes="conv" 7546fda9279dSmrg ;; 7547fda9279dSmrg esac 7548fda9279dSmrg 7549fda9279dSmrg for pass in $passes; do 7550fda9279dSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 7551fda9279dSmrg # so that -L comes before libs that need it for instance... 755216ee1e9aSmrg if test lib,link = "$linkmode,$pass"; then 7553fda9279dSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 7554fda9279dSmrg ## order, and fix it there properly 7555fda9279dSmrg tmp_deplibs= 7556fda9279dSmrg for deplib in $deplibs; do 7557fda9279dSmrg tmp_deplibs="$deplib $tmp_deplibs" 7558fda9279dSmrg done 755916ee1e9aSmrg deplibs=$tmp_deplibs 7560fda9279dSmrg fi 7561fda9279dSmrg 756216ee1e9aSmrg if test lib,link = "$linkmode,$pass" || 756316ee1e9aSmrg test prog,scan = "$linkmode,$pass"; then 756416ee1e9aSmrg libs=$deplibs 7565fda9279dSmrg deplibs= 7566fda9279dSmrg fi 756716ee1e9aSmrg if test prog = "$linkmode"; then 7568fda9279dSmrg case $pass in 756916ee1e9aSmrg dlopen) libs=$dlfiles ;; 757016ee1e9aSmrg dlpreopen) libs=$dlprefiles ;; 757116ee1e9aSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572fda9279dSmrg esac 7573fda9279dSmrg fi 757416ee1e9aSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7575fda9279dSmrg # Collect and forward deplibs of preopened libtool libs 7576fda9279dSmrg for lib in $dlprefiles; do 7577fda9279dSmrg # Ignore non-libtool-libs 7578fda9279dSmrg dependency_libs= 7579fda9279dSmrg func_resolve_sysroot "$lib" 7580fda9279dSmrg case $lib in 7581fda9279dSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7582fda9279dSmrg esac 7583fda9279dSmrg 7584fda9279dSmrg # Collect preopened libtool deplibs, except any this library 7585fda9279dSmrg # has declared as weak libs 7586fda9279dSmrg for deplib in $dependency_libs; do 7587fda9279dSmrg func_basename "$deplib" 7588fda9279dSmrg deplib_base=$func_basename_result 7589fda9279dSmrg case " $weak_libs " in 7590fda9279dSmrg *" $deplib_base "*) ;; 7591fda9279dSmrg *) func_append deplibs " $deplib" ;; 7592fda9279dSmrg esac 7593fda9279dSmrg done 7594fda9279dSmrg done 759516ee1e9aSmrg libs=$dlprefiles 7596fda9279dSmrg fi 759716ee1e9aSmrg if test dlopen = "$pass"; then 7598fda9279dSmrg # Collect dlpreopened libraries 759916ee1e9aSmrg save_deplibs=$deplibs 7600fda9279dSmrg deplibs= 7601fda9279dSmrg fi 7602fda9279dSmrg 7603fda9279dSmrg for deplib in $libs; do 7604fda9279dSmrg lib= 760516ee1e9aSmrg found=false 7606fda9279dSmrg case $deplib in 7607fda9279dSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608fda9279dSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 760916ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 7610fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7611fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7612fda9279dSmrg else 7613fda9279dSmrg func_append compiler_flags " $deplib" 761416ee1e9aSmrg if test lib = "$linkmode"; then 7615fda9279dSmrg case "$new_inherited_linker_flags " in 7616fda9279dSmrg *" $deplib "*) ;; 7617fda9279dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7618fda9279dSmrg esac 7619fda9279dSmrg fi 7620fda9279dSmrg fi 7621fda9279dSmrg continue 7622fda9279dSmrg ;; 7623fda9279dSmrg -l*) 762416ee1e9aSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 762516ee1e9aSmrg func_warning "'-l' is ignored for archives/objects" 7626fda9279dSmrg continue 7627fda9279dSmrg fi 7628fda9279dSmrg func_stripname '-l' '' "$deplib" 7629fda9279dSmrg name=$func_stripname_result 763016ee1e9aSmrg if test lib = "$linkmode"; then 7631fda9279dSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632fda9279dSmrg else 7633fda9279dSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634fda9279dSmrg fi 7635fda9279dSmrg for searchdir in $searchdirs; do 7636fda9279dSmrg for search_ext in .la $std_shrext .so .a; do 7637fda9279dSmrg # Search the libtool library 763816ee1e9aSmrg lib=$searchdir/lib$name$search_ext 7639fda9279dSmrg if test -f "$lib"; then 764016ee1e9aSmrg if test .la = "$search_ext"; then 764116ee1e9aSmrg found=: 7642fda9279dSmrg else 764316ee1e9aSmrg found=false 7644fda9279dSmrg fi 7645fda9279dSmrg break 2 7646fda9279dSmrg fi 7647fda9279dSmrg done 7648fda9279dSmrg done 764916ee1e9aSmrg if $found; then 765016ee1e9aSmrg # deplib is a libtool library 7651fda9279dSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652fda9279dSmrg # We need to do some special things here, and not later. 765316ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654fda9279dSmrg case " $predeps $postdeps " in 7655fda9279dSmrg *" $deplib "*) 7656fda9279dSmrg if func_lalib_p "$lib"; then 7657fda9279dSmrg library_names= 7658fda9279dSmrg old_library= 7659fda9279dSmrg func_source "$lib" 7660fda9279dSmrg for l in $old_library $library_names; do 766116ee1e9aSmrg ll=$l 7662fda9279dSmrg done 766316ee1e9aSmrg if test "X$ll" = "X$old_library"; then # only static version available 766416ee1e9aSmrg found=false 7665fda9279dSmrg func_dirname "$lib" "" "." 766616ee1e9aSmrg ladir=$func_dirname_result 7667fda9279dSmrg lib=$ladir/$old_library 766816ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 7669fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7670fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7671fda9279dSmrg else 7672fda9279dSmrg deplibs="$deplib $deplibs" 767316ee1e9aSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674fda9279dSmrg fi 7675fda9279dSmrg continue 7676fda9279dSmrg fi 7677fda9279dSmrg fi 7678fda9279dSmrg ;; 7679fda9279dSmrg *) ;; 7680fda9279dSmrg esac 7681fda9279dSmrg fi 768216ee1e9aSmrg else 768316ee1e9aSmrg # deplib doesn't seem to be a libtool library 768416ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 768516ee1e9aSmrg compile_deplibs="$deplib $compile_deplibs" 768616ee1e9aSmrg finalize_deplibs="$deplib $finalize_deplibs" 768716ee1e9aSmrg else 768816ee1e9aSmrg deplibs="$deplib $deplibs" 768916ee1e9aSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769016ee1e9aSmrg fi 769116ee1e9aSmrg continue 7692fda9279dSmrg fi 7693fda9279dSmrg ;; # -l 7694fda9279dSmrg *.ltframework) 769516ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 7696fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7697fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7698fda9279dSmrg else 7699fda9279dSmrg deplibs="$deplib $deplibs" 770016ee1e9aSmrg if test lib = "$linkmode"; then 7701fda9279dSmrg case "$new_inherited_linker_flags " in 7702fda9279dSmrg *" $deplib "*) ;; 7703fda9279dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7704fda9279dSmrg esac 7705fda9279dSmrg fi 7706fda9279dSmrg fi 7707fda9279dSmrg continue 7708fda9279dSmrg ;; 7709fda9279dSmrg -L*) 7710fda9279dSmrg case $linkmode in 7711fda9279dSmrg lib) 7712fda9279dSmrg deplibs="$deplib $deplibs" 771316ee1e9aSmrg test conv = "$pass" && continue 7714fda9279dSmrg newdependency_libs="$deplib $newdependency_libs" 7715fda9279dSmrg func_stripname '-L' '' "$deplib" 7716fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 7717fda9279dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7718fda9279dSmrg ;; 7719fda9279dSmrg prog) 772016ee1e9aSmrg if test conv = "$pass"; then 7721fda9279dSmrg deplibs="$deplib $deplibs" 7722fda9279dSmrg continue 7723fda9279dSmrg fi 772416ee1e9aSmrg if test scan = "$pass"; then 7725fda9279dSmrg deplibs="$deplib $deplibs" 7726fda9279dSmrg else 7727fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7728fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7729fda9279dSmrg fi 7730fda9279dSmrg func_stripname '-L' '' "$deplib" 7731fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 7732fda9279dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7733fda9279dSmrg ;; 7734fda9279dSmrg *) 773516ee1e9aSmrg func_warning "'-L' is ignored for archives/objects" 7736fda9279dSmrg ;; 7737fda9279dSmrg esac # linkmode 7738fda9279dSmrg continue 7739fda9279dSmrg ;; # -L 7740fda9279dSmrg -R*) 774116ee1e9aSmrg if test link = "$pass"; then 7742fda9279dSmrg func_stripname '-R' '' "$deplib" 7743fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 7744fda9279dSmrg dir=$func_resolve_sysroot_result 7745fda9279dSmrg # Make sure the xrpath contains only unique directories. 7746fda9279dSmrg case "$xrpath " in 7747fda9279dSmrg *" $dir "*) ;; 7748fda9279dSmrg *) func_append xrpath " $dir" ;; 7749fda9279dSmrg esac 7750fda9279dSmrg fi 7751fda9279dSmrg deplibs="$deplib $deplibs" 7752fda9279dSmrg continue 7753fda9279dSmrg ;; 7754fda9279dSmrg *.la) 7755fda9279dSmrg func_resolve_sysroot "$deplib" 7756fda9279dSmrg lib=$func_resolve_sysroot_result 7757fda9279dSmrg ;; 7758fda9279dSmrg *.$libext) 775916ee1e9aSmrg if test conv = "$pass"; then 7760fda9279dSmrg deplibs="$deplib $deplibs" 7761fda9279dSmrg continue 7762fda9279dSmrg fi 7763fda9279dSmrg case $linkmode in 7764fda9279dSmrg lib) 7765fda9279dSmrg # Linking convenience modules into shared libraries is allowed, 7766fda9279dSmrg # but linking other static libraries is non-portable. 7767fda9279dSmrg case " $dlpreconveniencelibs " in 7768fda9279dSmrg *" $deplib "*) ;; 7769fda9279dSmrg *) 777016ee1e9aSmrg valid_a_lib=false 7771fda9279dSmrg case $deplibs_check_method in 7772fda9279dSmrg match_pattern*) 7773fda9279dSmrg set dummy $deplibs_check_method; shift 7774fda9279dSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775fda9279dSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776fda9279dSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 777716ee1e9aSmrg valid_a_lib=: 7778fda9279dSmrg fi 7779fda9279dSmrg ;; 7780fda9279dSmrg pass_all) 778116ee1e9aSmrg valid_a_lib=: 7782fda9279dSmrg ;; 7783fda9279dSmrg esac 778416ee1e9aSmrg if $valid_a_lib; then 778516ee1e9aSmrg echo 778616ee1e9aSmrg $ECHO "*** Warning: Linking the shared library $output against the" 778716ee1e9aSmrg $ECHO "*** static library $deplib is not portable!" 778816ee1e9aSmrg deplibs="$deplib $deplibs" 778916ee1e9aSmrg else 7790fda9279dSmrg echo 7791fda9279dSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 7793fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 7794fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 7795fda9279dSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 7796fda9279dSmrg echo "*** that it is just a static archive that I should not use here." 7797fda9279dSmrg fi 7798fda9279dSmrg ;; 7799fda9279dSmrg esac 7800fda9279dSmrg continue 7801fda9279dSmrg ;; 7802fda9279dSmrg prog) 780316ee1e9aSmrg if test link != "$pass"; then 7804fda9279dSmrg deplibs="$deplib $deplibs" 7805fda9279dSmrg else 7806fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7807fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7808fda9279dSmrg fi 7809fda9279dSmrg continue 7810fda9279dSmrg ;; 7811fda9279dSmrg esac # linkmode 7812fda9279dSmrg ;; # *.$libext 7813fda9279dSmrg *.lo | *.$objext) 781416ee1e9aSmrg if test conv = "$pass"; then 7815fda9279dSmrg deplibs="$deplib $deplibs" 781616ee1e9aSmrg elif test prog = "$linkmode"; then 781716ee1e9aSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818fda9279dSmrg # If there is no dlopen support or we're linking statically, 7819fda9279dSmrg # we need to preload. 7820fda9279dSmrg func_append newdlprefiles " $deplib" 7821fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7822fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7823fda9279dSmrg else 7824fda9279dSmrg func_append newdlfiles " $deplib" 7825fda9279dSmrg fi 7826fda9279dSmrg fi 7827fda9279dSmrg continue 7828fda9279dSmrg ;; 7829fda9279dSmrg %DEPLIBS%) 783016ee1e9aSmrg alldeplibs=: 7831fda9279dSmrg continue 7832fda9279dSmrg ;; 7833fda9279dSmrg esac # case $deplib 7834fda9279dSmrg 783516ee1e9aSmrg $found || test -f "$lib" \ 783616ee1e9aSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837fda9279dSmrg 7838fda9279dSmrg # Check to see that this really is a libtool archive. 7839fda9279dSmrg func_lalib_unsafe_p "$lib" \ 784016ee1e9aSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7841fda9279dSmrg 7842fda9279dSmrg func_dirname "$lib" "" "." 784316ee1e9aSmrg ladir=$func_dirname_result 7844fda9279dSmrg 7845fda9279dSmrg dlname= 7846fda9279dSmrg dlopen= 7847fda9279dSmrg dlpreopen= 7848fda9279dSmrg libdir= 7849fda9279dSmrg library_names= 7850fda9279dSmrg old_library= 7851fda9279dSmrg inherited_linker_flags= 7852fda9279dSmrg # If the library was installed with an old release of libtool, 7853fda9279dSmrg # it will not redefine variables installed, or shouldnotlink 7854fda9279dSmrg installed=yes 7855fda9279dSmrg shouldnotlink=no 7856fda9279dSmrg avoidtemprpath= 7857fda9279dSmrg 7858fda9279dSmrg 7859fda9279dSmrg # Read the .la file 7860fda9279dSmrg func_source "$lib" 7861fda9279dSmrg 7862fda9279dSmrg # Convert "-framework foo" to "foo.ltframework" 7863fda9279dSmrg if test -n "$inherited_linker_flags"; then 7864fda9279dSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865fda9279dSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866fda9279dSmrg case " $new_inherited_linker_flags " in 7867fda9279dSmrg *" $tmp_inherited_linker_flag "*) ;; 7868fda9279dSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869fda9279dSmrg esac 7870fda9279dSmrg done 7871fda9279dSmrg fi 7872fda9279dSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787316ee1e9aSmrg if test lib,link = "$linkmode,$pass" || 787416ee1e9aSmrg test prog,scan = "$linkmode,$pass" || 787516ee1e9aSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876fda9279dSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7877fda9279dSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878fda9279dSmrg fi 7879fda9279dSmrg 788016ee1e9aSmrg if test conv = "$pass"; then 7881fda9279dSmrg # Only check for convenience libraries 7882fda9279dSmrg deplibs="$lib $deplibs" 7883fda9279dSmrg if test -z "$libdir"; then 7884fda9279dSmrg if test -z "$old_library"; then 788516ee1e9aSmrg func_fatal_error "cannot find name of link library for '$lib'" 7886fda9279dSmrg fi 7887fda9279dSmrg # It is a libtool convenience library, so add in its objects. 7888fda9279dSmrg func_append convenience " $ladir/$objdir/$old_library" 7889fda9279dSmrg func_append old_convenience " $ladir/$objdir/$old_library" 789016ee1e9aSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 789116ee1e9aSmrg func_fatal_error "'$lib' is not a convenience library" 7892fda9279dSmrg fi 789316ee1e9aSmrg tmp_libs= 789416ee1e9aSmrg for deplib in $dependency_libs; do 789516ee1e9aSmrg deplibs="$deplib $deplibs" 789616ee1e9aSmrg if $opt_preserve_dup_deps; then 789716ee1e9aSmrg case "$tmp_libs " in 789816ee1e9aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 789916ee1e9aSmrg esac 790016ee1e9aSmrg fi 790116ee1e9aSmrg func_append tmp_libs " $deplib" 790216ee1e9aSmrg done 7903fda9279dSmrg continue 7904fda9279dSmrg fi # $pass = conv 7905fda9279dSmrg 7906fda9279dSmrg 7907fda9279dSmrg # Get the name of the library we link against. 7908fda9279dSmrg linklib= 7909fda9279dSmrg if test -n "$old_library" && 791016ee1e9aSmrg { test yes = "$prefer_static_libs" || 791116ee1e9aSmrg test built,no = "$prefer_static_libs,$installed"; }; then 7912fda9279dSmrg linklib=$old_library 7913fda9279dSmrg else 7914fda9279dSmrg for l in $old_library $library_names; do 791516ee1e9aSmrg linklib=$l 7916fda9279dSmrg done 7917fda9279dSmrg fi 7918fda9279dSmrg if test -z "$linklib"; then 791916ee1e9aSmrg func_fatal_error "cannot find name of link library for '$lib'" 7920fda9279dSmrg fi 7921fda9279dSmrg 7922fda9279dSmrg # This library was specified with -dlopen. 792316ee1e9aSmrg if test dlopen = "$pass"; then 792416ee1e9aSmrg test -z "$libdir" \ 792516ee1e9aSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926fda9279dSmrg if test -z "$dlname" || 792716ee1e9aSmrg test yes != "$dlopen_support" || 792816ee1e9aSmrg test no = "$build_libtool_libs" 792916ee1e9aSmrg then 7930fda9279dSmrg # If there is no dlname, no dlopen support or we're linking 7931fda9279dSmrg # statically, we need to preload. We also need to preload any 7932fda9279dSmrg # dependent libraries so libltdl's deplib preloader doesn't 7933fda9279dSmrg # bomb out in the load deplibs phase. 7934fda9279dSmrg func_append dlprefiles " $lib $dependency_libs" 7935fda9279dSmrg else 7936fda9279dSmrg func_append newdlfiles " $lib" 7937fda9279dSmrg fi 7938fda9279dSmrg continue 7939fda9279dSmrg fi # $pass = dlopen 7940fda9279dSmrg 7941fda9279dSmrg # We need an absolute path. 7942fda9279dSmrg case $ladir in 794316ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944fda9279dSmrg *) 7945fda9279dSmrg abs_ladir=`cd "$ladir" && pwd` 7946fda9279dSmrg if test -z "$abs_ladir"; then 794716ee1e9aSmrg func_warning "cannot determine absolute directory name of '$ladir'" 7948fda9279dSmrg func_warning "passing it literally to the linker, although it might fail" 794916ee1e9aSmrg abs_ladir=$ladir 7950fda9279dSmrg fi 7951fda9279dSmrg ;; 7952fda9279dSmrg esac 7953fda9279dSmrg func_basename "$lib" 795416ee1e9aSmrg laname=$func_basename_result 7955fda9279dSmrg 7956fda9279dSmrg # Find the relevant object directory and library name. 795716ee1e9aSmrg if test yes = "$installed"; then 7958fda9279dSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 795916ee1e9aSmrg func_warning "library '$lib' was moved." 796016ee1e9aSmrg dir=$ladir 796116ee1e9aSmrg absdir=$abs_ladir 796216ee1e9aSmrg libdir=$abs_ladir 7963fda9279dSmrg else 796416ee1e9aSmrg dir=$lt_sysroot$libdir 796516ee1e9aSmrg absdir=$lt_sysroot$libdir 7966fda9279dSmrg fi 796716ee1e9aSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968fda9279dSmrg else 7969fda9279dSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797016ee1e9aSmrg dir=$ladir 797116ee1e9aSmrg absdir=$abs_ladir 7972fda9279dSmrg # Remove this search path later 7973fda9279dSmrg func_append notinst_path " $abs_ladir" 7974fda9279dSmrg else 797516ee1e9aSmrg dir=$ladir/$objdir 797616ee1e9aSmrg absdir=$abs_ladir/$objdir 7977fda9279dSmrg # Remove this search path later 7978fda9279dSmrg func_append notinst_path " $abs_ladir" 7979fda9279dSmrg fi 7980fda9279dSmrg fi # $installed = yes 7981fda9279dSmrg func_stripname 'lib' '.la' "$laname" 7982fda9279dSmrg name=$func_stripname_result 7983fda9279dSmrg 7984fda9279dSmrg # This library was specified with -dlpreopen. 798516ee1e9aSmrg if test dlpreopen = "$pass"; then 798616ee1e9aSmrg if test -z "$libdir" && test prog = "$linkmode"; then 798716ee1e9aSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988fda9279dSmrg fi 798916ee1e9aSmrg case $host in 7990fda9279dSmrg # special handling for platforms with PE-DLLs. 7991fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 7992fda9279dSmrg # Linker will automatically link against shared library if both 7993fda9279dSmrg # static and shared are present. Therefore, ensure we extract 7994fda9279dSmrg # symbols from the import library if a shared library is present 7995fda9279dSmrg # (otherwise, the dlopen module name will be incorrect). We do 7996fda9279dSmrg # this by putting the import library name into $newdlprefiles. 7997fda9279dSmrg # We recover the dlopen module name by 'saving' the la file 7998fda9279dSmrg # name in a special purpose variable, and (later) extracting the 7999fda9279dSmrg # dlname from the la file. 8000fda9279dSmrg if test -n "$dlname"; then 8001fda9279dSmrg func_tr_sh "$dir/$linklib" 8002fda9279dSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003fda9279dSmrg func_append newdlprefiles " $dir/$linklib" 8004fda9279dSmrg else 8005fda9279dSmrg func_append newdlprefiles " $dir/$old_library" 8006fda9279dSmrg # Keep a list of preopened convenience libraries to check 8007fda9279dSmrg # that they are being used correctly in the link pass. 8008fda9279dSmrg test -z "$libdir" && \ 8009fda9279dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8010fda9279dSmrg fi 8011fda9279dSmrg ;; 8012fda9279dSmrg * ) 8013fda9279dSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8014fda9279dSmrg # are required to link). 8015fda9279dSmrg if test -n "$old_library"; then 8016fda9279dSmrg func_append newdlprefiles " $dir/$old_library" 8017fda9279dSmrg # Keep a list of preopened convenience libraries to check 8018fda9279dSmrg # that they are being used correctly in the link pass. 8019fda9279dSmrg test -z "$libdir" && \ 8020fda9279dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8021fda9279dSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8022fda9279dSmrg elif test -n "$dlname"; then 8023fda9279dSmrg func_append newdlprefiles " $dir/$dlname" 8024fda9279dSmrg else 8025fda9279dSmrg func_append newdlprefiles " $dir/$linklib" 8026fda9279dSmrg fi 8027fda9279dSmrg ;; 8028fda9279dSmrg esac 8029fda9279dSmrg fi # $pass = dlpreopen 8030fda9279dSmrg 8031fda9279dSmrg if test -z "$libdir"; then 8032fda9279dSmrg # Link the convenience library 803316ee1e9aSmrg if test lib = "$linkmode"; then 8034fda9279dSmrg deplibs="$dir/$old_library $deplibs" 803516ee1e9aSmrg elif test prog,link = "$linkmode,$pass"; then 8036fda9279dSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 8037fda9279dSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038fda9279dSmrg else 8039fda9279dSmrg deplibs="$lib $deplibs" # used for prog,scan pass 8040fda9279dSmrg fi 8041fda9279dSmrg continue 8042fda9279dSmrg fi 8043fda9279dSmrg 8044fda9279dSmrg 804516ee1e9aSmrg if test prog = "$linkmode" && test link != "$pass"; then 8046fda9279dSmrg func_append newlib_search_path " $ladir" 8047fda9279dSmrg deplibs="$lib $deplibs" 8048fda9279dSmrg 804916ee1e9aSmrg linkalldeplibs=false 805016ee1e9aSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805116ee1e9aSmrg test no = "$build_libtool_libs"; then 805216ee1e9aSmrg linkalldeplibs=: 8053fda9279dSmrg fi 8054fda9279dSmrg 8055fda9279dSmrg tmp_libs= 8056fda9279dSmrg for deplib in $dependency_libs; do 8057fda9279dSmrg case $deplib in 8058fda9279dSmrg -L*) func_stripname '-L' '' "$deplib" 8059fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 8060fda9279dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8061fda9279dSmrg ;; 8062fda9279dSmrg esac 8063fda9279dSmrg # Need to link against all dependency_libs? 806416ee1e9aSmrg if $linkalldeplibs; then 8065fda9279dSmrg deplibs="$deplib $deplibs" 8066fda9279dSmrg else 8067fda9279dSmrg # Need to hardcode shared library paths 8068fda9279dSmrg # or/and link against static libraries 8069fda9279dSmrg newdependency_libs="$deplib $newdependency_libs" 8070fda9279dSmrg fi 807116ee1e9aSmrg if $opt_preserve_dup_deps; then 8072fda9279dSmrg case "$tmp_libs " in 8073fda9279dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074fda9279dSmrg esac 8075fda9279dSmrg fi 8076fda9279dSmrg func_append tmp_libs " $deplib" 8077fda9279dSmrg done # for deplib 8078fda9279dSmrg continue 8079fda9279dSmrg fi # $linkmode = prog... 8080fda9279dSmrg 808116ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 8082fda9279dSmrg if test -n "$library_names" && 808316ee1e9aSmrg { { test no = "$prefer_static_libs" || 808416ee1e9aSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8085fda9279dSmrg test -z "$old_library"; }; then 8086fda9279dSmrg # We need to hardcode the library path 808716ee1e9aSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088fda9279dSmrg # Make sure the rpath contains only unique directories. 808916ee1e9aSmrg case $temp_rpath: in 8090fda9279dSmrg *"$absdir:"*) ;; 8091fda9279dSmrg *) func_append temp_rpath "$absdir:" ;; 8092fda9279dSmrg esac 8093fda9279dSmrg fi 8094fda9279dSmrg 8095fda9279dSmrg # Hardcode the library path. 8096fda9279dSmrg # Skip directories that are in the system default run-time 8097fda9279dSmrg # search path. 8098fda9279dSmrg case " $sys_lib_dlsearch_path " in 8099fda9279dSmrg *" $absdir "*) ;; 8100fda9279dSmrg *) 8101fda9279dSmrg case "$compile_rpath " in 8102fda9279dSmrg *" $absdir "*) ;; 8103fda9279dSmrg *) func_append compile_rpath " $absdir" ;; 8104fda9279dSmrg esac 8105fda9279dSmrg ;; 8106fda9279dSmrg esac 8107fda9279dSmrg case " $sys_lib_dlsearch_path " in 8108fda9279dSmrg *" $libdir "*) ;; 8109fda9279dSmrg *) 8110fda9279dSmrg case "$finalize_rpath " in 8111fda9279dSmrg *" $libdir "*) ;; 8112fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 8113fda9279dSmrg esac 8114fda9279dSmrg ;; 8115fda9279dSmrg esac 8116fda9279dSmrg fi # $linkmode,$pass = prog,link... 8117fda9279dSmrg 811816ee1e9aSmrg if $alldeplibs && 811916ee1e9aSmrg { test pass_all = "$deplibs_check_method" || 812016ee1e9aSmrg { test yes = "$build_libtool_libs" && 8121fda9279dSmrg test -n "$library_names"; }; }; then 8122fda9279dSmrg # We only need to search for static libraries 8123fda9279dSmrg continue 8124fda9279dSmrg fi 8125fda9279dSmrg fi 8126fda9279dSmrg 8127fda9279dSmrg link_static=no # Whether the deplib will be linked statically 8128fda9279dSmrg use_static_libs=$prefer_static_libs 812916ee1e9aSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8130fda9279dSmrg use_static_libs=no 8131fda9279dSmrg fi 8132fda9279dSmrg if test -n "$library_names" && 813316ee1e9aSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134fda9279dSmrg case $host in 813516ee1e9aSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8136fda9279dSmrg # No point in relinking DLLs because paths are not encoded 8137fda9279dSmrg func_append notinst_deplibs " $lib" 8138fda9279dSmrg need_relink=no 8139fda9279dSmrg ;; 8140fda9279dSmrg *) 814116ee1e9aSmrg if test no = "$installed"; then 8142fda9279dSmrg func_append notinst_deplibs " $lib" 8143fda9279dSmrg need_relink=yes 8144fda9279dSmrg fi 8145fda9279dSmrg ;; 8146fda9279dSmrg esac 8147fda9279dSmrg # This is a shared library 8148fda9279dSmrg 8149fda9279dSmrg # Warn about portability, can't link against -module's on some 8150fda9279dSmrg # systems (darwin). Don't bleat about dlopened modules though! 815116ee1e9aSmrg dlopenmodule= 8152fda9279dSmrg for dlpremoduletest in $dlprefiles; do 8153fda9279dSmrg if test "X$dlpremoduletest" = "X$lib"; then 815416ee1e9aSmrg dlopenmodule=$dlpremoduletest 8155fda9279dSmrg break 8156fda9279dSmrg fi 8157fda9279dSmrg done 815816ee1e9aSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159fda9279dSmrg echo 816016ee1e9aSmrg if test prog = "$linkmode"; then 8161fda9279dSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162fda9279dSmrg else 8163fda9279dSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164fda9279dSmrg fi 8165fda9279dSmrg $ECHO "*** $linklib is not portable!" 8166fda9279dSmrg fi 816716ee1e9aSmrg if test lib = "$linkmode" && 816816ee1e9aSmrg test yes = "$hardcode_into_libs"; then 8169fda9279dSmrg # Hardcode the library path. 8170fda9279dSmrg # Skip directories that are in the system default run-time 8171fda9279dSmrg # search path. 8172fda9279dSmrg case " $sys_lib_dlsearch_path " in 8173fda9279dSmrg *" $absdir "*) ;; 8174fda9279dSmrg *) 8175fda9279dSmrg case "$compile_rpath " in 8176fda9279dSmrg *" $absdir "*) ;; 8177fda9279dSmrg *) func_append compile_rpath " $absdir" ;; 8178fda9279dSmrg esac 8179fda9279dSmrg ;; 8180fda9279dSmrg esac 8181fda9279dSmrg case " $sys_lib_dlsearch_path " in 8182fda9279dSmrg *" $libdir "*) ;; 8183fda9279dSmrg *) 8184fda9279dSmrg case "$finalize_rpath " in 8185fda9279dSmrg *" $libdir "*) ;; 8186fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 8187fda9279dSmrg esac 8188fda9279dSmrg ;; 8189fda9279dSmrg esac 8190fda9279dSmrg fi 8191fda9279dSmrg 8192fda9279dSmrg if test -n "$old_archive_from_expsyms_cmds"; then 8193fda9279dSmrg # figure out the soname 8194fda9279dSmrg set dummy $library_names 8195fda9279dSmrg shift 819616ee1e9aSmrg realname=$1 8197fda9279dSmrg shift 8198fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 8199fda9279dSmrg # use dlname if we got it. it's perfectly good, no? 8200fda9279dSmrg if test -n "$dlname"; then 820116ee1e9aSmrg soname=$dlname 8202fda9279dSmrg elif test -n "$soname_spec"; then 8203fda9279dSmrg # bleh windows 8204fda9279dSmrg case $host in 820516ee1e9aSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8206fda9279dSmrg func_arith $current - $age 8207fda9279dSmrg major=$func_arith_result 820816ee1e9aSmrg versuffix=-$major 8209fda9279dSmrg ;; 8210fda9279dSmrg esac 8211fda9279dSmrg eval soname=\"$soname_spec\" 8212fda9279dSmrg else 821316ee1e9aSmrg soname=$realname 8214fda9279dSmrg fi 8215fda9279dSmrg 8216fda9279dSmrg # Make a new name for the extract_expsyms_cmds to use 821716ee1e9aSmrg soroot=$soname 8218fda9279dSmrg func_basename "$soroot" 821916ee1e9aSmrg soname=$func_basename_result 8220fda9279dSmrg func_stripname 'lib' '.dll' "$soname" 8221fda9279dSmrg newlib=libimp-$func_stripname_result.a 8222fda9279dSmrg 8223fda9279dSmrg # If the library has no export list, then create one now 8224fda9279dSmrg if test -f "$output_objdir/$soname-def"; then : 8225fda9279dSmrg else 822616ee1e9aSmrg func_verbose "extracting exported symbol list from '$soname'" 8227fda9279dSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228fda9279dSmrg fi 8229fda9279dSmrg 8230fda9279dSmrg # Create $newlib 8231fda9279dSmrg if test -f "$output_objdir/$newlib"; then :; else 823216ee1e9aSmrg func_verbose "generating import library for '$soname'" 8233fda9279dSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234fda9279dSmrg fi 8235fda9279dSmrg # make sure the library variables are pointing to the new library 8236fda9279dSmrg dir=$output_objdir 8237fda9279dSmrg linklib=$newlib 8238fda9279dSmrg fi # test -n "$old_archive_from_expsyms_cmds" 8239fda9279dSmrg 824016ee1e9aSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241fda9279dSmrg add_shlibpath= 8242fda9279dSmrg add_dir= 8243fda9279dSmrg add= 8244fda9279dSmrg lib_linked=yes 8245fda9279dSmrg case $hardcode_action in 8246fda9279dSmrg immediate | unsupported) 824716ee1e9aSmrg if test no = "$hardcode_direct"; then 824816ee1e9aSmrg add=$dir/$linklib 8249fda9279dSmrg case $host in 825016ee1e9aSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825116ee1e9aSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252fda9279dSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825316ee1e9aSmrg *-*-unixware7*) add_dir=-L$dir ;; 8254fda9279dSmrg *-*-darwin* ) 825516ee1e9aSmrg # if the lib is a (non-dlopened) module then we cannot 8256fda9279dSmrg # link against it, someone is ignoring the earlier warnings 8257fda9279dSmrg if /usr/bin/file -L $add 2> /dev/null | 825816ee1e9aSmrg $GREP ": [^:]* bundle" >/dev/null; then 8259fda9279dSmrg if test "X$dlopenmodule" != "X$lib"; then 8260fda9279dSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826116ee1e9aSmrg if test -z "$old_library"; then 8262fda9279dSmrg echo 8263fda9279dSmrg echo "*** And there doesn't seem to be a static archive available" 8264fda9279dSmrg echo "*** The link will probably fail, sorry" 8265fda9279dSmrg else 826616ee1e9aSmrg add=$dir/$old_library 8267fda9279dSmrg fi 8268fda9279dSmrg elif test -n "$old_library"; then 826916ee1e9aSmrg add=$dir/$old_library 8270fda9279dSmrg fi 8271fda9279dSmrg fi 8272fda9279dSmrg esac 827316ee1e9aSmrg elif test no = "$hardcode_minus_L"; then 8274fda9279dSmrg case $host in 827516ee1e9aSmrg *-*-sunos*) add_shlibpath=$dir ;; 8276fda9279dSmrg esac 827716ee1e9aSmrg add_dir=-L$dir 827816ee1e9aSmrg add=-l$name 827916ee1e9aSmrg elif test no = "$hardcode_shlibpath_var"; then 828016ee1e9aSmrg add_shlibpath=$dir 828116ee1e9aSmrg add=-l$name 8282fda9279dSmrg else 8283fda9279dSmrg lib_linked=no 8284fda9279dSmrg fi 8285fda9279dSmrg ;; 8286fda9279dSmrg relink) 828716ee1e9aSmrg if test yes = "$hardcode_direct" && 828816ee1e9aSmrg test no = "$hardcode_direct_absolute"; then 828916ee1e9aSmrg add=$dir/$linklib 829016ee1e9aSmrg elif test yes = "$hardcode_minus_L"; then 829116ee1e9aSmrg add_dir=-L$absdir 8292fda9279dSmrg # Try looking first in the location we're being installed to. 8293fda9279dSmrg if test -n "$inst_prefix_dir"; then 8294fda9279dSmrg case $libdir in 8295fda9279dSmrg [\\/]*) 8296fda9279dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8297fda9279dSmrg ;; 8298fda9279dSmrg esac 8299fda9279dSmrg fi 830016ee1e9aSmrg add=-l$name 830116ee1e9aSmrg elif test yes = "$hardcode_shlibpath_var"; then 830216ee1e9aSmrg add_shlibpath=$dir 830316ee1e9aSmrg add=-l$name 8304fda9279dSmrg else 8305fda9279dSmrg lib_linked=no 8306fda9279dSmrg fi 8307fda9279dSmrg ;; 8308fda9279dSmrg *) lib_linked=no ;; 8309fda9279dSmrg esac 8310fda9279dSmrg 831116ee1e9aSmrg if test yes != "$lib_linked"; then 8312fda9279dSmrg func_fatal_configuration "unsupported hardcode properties" 8313fda9279dSmrg fi 8314fda9279dSmrg 8315fda9279dSmrg if test -n "$add_shlibpath"; then 8316fda9279dSmrg case :$compile_shlibpath: in 8317fda9279dSmrg *":$add_shlibpath:"*) ;; 8318fda9279dSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319fda9279dSmrg esac 8320fda9279dSmrg fi 832116ee1e9aSmrg if test prog = "$linkmode"; then 8322fda9279dSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323fda9279dSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324fda9279dSmrg else 8325fda9279dSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326fda9279dSmrg test -n "$add" && deplibs="$add $deplibs" 832716ee1e9aSmrg if test yes != "$hardcode_direct" && 832816ee1e9aSmrg test yes != "$hardcode_minus_L" && 832916ee1e9aSmrg test yes = "$hardcode_shlibpath_var"; then 8330fda9279dSmrg case :$finalize_shlibpath: in 8331fda9279dSmrg *":$libdir:"*) ;; 8332fda9279dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8333fda9279dSmrg esac 8334fda9279dSmrg fi 8335fda9279dSmrg fi 8336fda9279dSmrg fi 8337fda9279dSmrg 833816ee1e9aSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339fda9279dSmrg add_shlibpath= 8340fda9279dSmrg add_dir= 8341fda9279dSmrg add= 8342fda9279dSmrg # Finalize command for both is simple: just hardcode it. 834316ee1e9aSmrg if test yes = "$hardcode_direct" && 834416ee1e9aSmrg test no = "$hardcode_direct_absolute"; then 834516ee1e9aSmrg add=$libdir/$linklib 834616ee1e9aSmrg elif test yes = "$hardcode_minus_L"; then 834716ee1e9aSmrg add_dir=-L$libdir 834816ee1e9aSmrg add=-l$name 834916ee1e9aSmrg elif test yes = "$hardcode_shlibpath_var"; then 8350fda9279dSmrg case :$finalize_shlibpath: in 8351fda9279dSmrg *":$libdir:"*) ;; 8352fda9279dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8353fda9279dSmrg esac 835416ee1e9aSmrg add=-l$name 835516ee1e9aSmrg elif test yes = "$hardcode_automatic"; then 8356fda9279dSmrg if test -n "$inst_prefix_dir" && 835716ee1e9aSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 835816ee1e9aSmrg add=$inst_prefix_dir$libdir/$linklib 8359fda9279dSmrg else 836016ee1e9aSmrg add=$libdir/$linklib 8361fda9279dSmrg fi 8362fda9279dSmrg else 8363fda9279dSmrg # We cannot seem to hardcode it, guess we'll fake it. 836416ee1e9aSmrg add_dir=-L$libdir 8365fda9279dSmrg # Try looking first in the location we're being installed to. 8366fda9279dSmrg if test -n "$inst_prefix_dir"; then 8367fda9279dSmrg case $libdir in 8368fda9279dSmrg [\\/]*) 8369fda9279dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8370fda9279dSmrg ;; 8371fda9279dSmrg esac 8372fda9279dSmrg fi 837316ee1e9aSmrg add=-l$name 8374fda9279dSmrg fi 8375fda9279dSmrg 837616ee1e9aSmrg if test prog = "$linkmode"; then 8377fda9279dSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378fda9279dSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379fda9279dSmrg else 8380fda9279dSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381fda9279dSmrg test -n "$add" && deplibs="$add $deplibs" 8382fda9279dSmrg fi 8383fda9279dSmrg fi 838416ee1e9aSmrg elif test prog = "$linkmode"; then 8385fda9279dSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8386fda9279dSmrg # is not unsupported. This is valid on all known static and 8387fda9279dSmrg # shared platforms. 838816ee1e9aSmrg if test unsupported != "$hardcode_direct"; then 838916ee1e9aSmrg test -n "$old_library" && linklib=$old_library 8390fda9279dSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 8391fda9279dSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392fda9279dSmrg else 8393fda9279dSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8394fda9279dSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395fda9279dSmrg fi 839616ee1e9aSmrg elif test yes = "$build_libtool_libs"; then 8397fda9279dSmrg # Not a shared library 839816ee1e9aSmrg if test pass_all != "$deplibs_check_method"; then 8399fda9279dSmrg # We're trying link a shared library against a static one 8400fda9279dSmrg # but the system doesn't support it. 8401fda9279dSmrg 8402fda9279dSmrg # Just print a warning and add the library to dependency_libs so 8403fda9279dSmrg # that the program can be linked against the static library. 8404fda9279dSmrg echo 840516ee1e9aSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 8407fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 8408fda9279dSmrg echo "*** shared version of the library, which you do not appear to have." 840916ee1e9aSmrg if test yes = "$module"; then 8410fda9279dSmrg echo "*** But as you try to build a module library, libtool will still create " 8411fda9279dSmrg echo "*** a static module, that should work as long as the dlopening application" 8412fda9279dSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413fda9279dSmrg if test -z "$global_symbol_pipe"; then 8414fda9279dSmrg echo 8415fda9279dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 841616ee1e9aSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417fda9279dSmrg echo "*** not find such a program. So, this module is probably useless." 841816ee1e9aSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419fda9279dSmrg fi 842016ee1e9aSmrg if test no = "$build_old_libs"; then 8421fda9279dSmrg build_libtool_libs=module 8422fda9279dSmrg build_old_libs=yes 8423fda9279dSmrg else 8424fda9279dSmrg build_libtool_libs=no 8425fda9279dSmrg fi 8426fda9279dSmrg fi 8427fda9279dSmrg else 8428fda9279dSmrg deplibs="$dir/$old_library $deplibs" 8429fda9279dSmrg link_static=yes 8430fda9279dSmrg fi 8431fda9279dSmrg fi # link shared/static library? 8432fda9279dSmrg 843316ee1e9aSmrg if test lib = "$linkmode"; then 8434fda9279dSmrg if test -n "$dependency_libs" && 843516ee1e9aSmrg { test yes != "$hardcode_into_libs" || 843616ee1e9aSmrg test yes = "$build_old_libs" || 843716ee1e9aSmrg test yes = "$link_static"; }; then 8438fda9279dSmrg # Extract -R from dependency_libs 8439fda9279dSmrg temp_deplibs= 8440fda9279dSmrg for libdir in $dependency_libs; do 8441fda9279dSmrg case $libdir in 8442fda9279dSmrg -R*) func_stripname '-R' '' "$libdir" 8443fda9279dSmrg temp_xrpath=$func_stripname_result 8444fda9279dSmrg case " $xrpath " in 8445fda9279dSmrg *" $temp_xrpath "*) ;; 8446fda9279dSmrg *) func_append xrpath " $temp_xrpath";; 8447fda9279dSmrg esac;; 8448fda9279dSmrg *) func_append temp_deplibs " $libdir";; 8449fda9279dSmrg esac 8450fda9279dSmrg done 845116ee1e9aSmrg dependency_libs=$temp_deplibs 8452fda9279dSmrg fi 8453fda9279dSmrg 8454fda9279dSmrg func_append newlib_search_path " $absdir" 8455fda9279dSmrg # Link against this library 845616ee1e9aSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457fda9279dSmrg # ... and its dependency_libs 8458fda9279dSmrg tmp_libs= 8459fda9279dSmrg for deplib in $dependency_libs; do 8460fda9279dSmrg newdependency_libs="$deplib $newdependency_libs" 8461fda9279dSmrg case $deplib in 8462fda9279dSmrg -L*) func_stripname '-L' '' "$deplib" 8463fda9279dSmrg func_resolve_sysroot "$func_stripname_result";; 8464fda9279dSmrg *) func_resolve_sysroot "$deplib" ;; 8465fda9279dSmrg esac 846616ee1e9aSmrg if $opt_preserve_dup_deps; then 8467fda9279dSmrg case "$tmp_libs " in 8468fda9279dSmrg *" $func_resolve_sysroot_result "*) 8469fda9279dSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470fda9279dSmrg esac 8471fda9279dSmrg fi 8472fda9279dSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8473fda9279dSmrg done 8474fda9279dSmrg 847516ee1e9aSmrg if test no != "$link_all_deplibs"; then 8476fda9279dSmrg # Add the search paths of all dependency libraries 8477fda9279dSmrg for deplib in $dependency_libs; do 8478fda9279dSmrg path= 8479fda9279dSmrg case $deplib in 848016ee1e9aSmrg -L*) path=$deplib ;; 8481fda9279dSmrg *.la) 8482fda9279dSmrg func_resolve_sysroot "$deplib" 8483fda9279dSmrg deplib=$func_resolve_sysroot_result 8484fda9279dSmrg func_dirname "$deplib" "" "." 8485fda9279dSmrg dir=$func_dirname_result 8486fda9279dSmrg # We need an absolute path. 8487fda9279dSmrg case $dir in 848816ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489fda9279dSmrg *) 8490fda9279dSmrg absdir=`cd "$dir" && pwd` 8491fda9279dSmrg if test -z "$absdir"; then 849216ee1e9aSmrg func_warning "cannot determine absolute directory name of '$dir'" 849316ee1e9aSmrg absdir=$dir 8494fda9279dSmrg fi 8495fda9279dSmrg ;; 8496fda9279dSmrg esac 8497fda9279dSmrg if $GREP "^installed=no" $deplib > /dev/null; then 8498fda9279dSmrg case $host in 8499fda9279dSmrg *-*-darwin*) 8500fda9279dSmrg depdepl= 850116ee1e9aSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850216ee1e9aSmrg if test -n "$deplibrary_names"; then 850316ee1e9aSmrg for tmp in $deplibrary_names; do 8504fda9279dSmrg depdepl=$tmp 8505fda9279dSmrg done 850616ee1e9aSmrg if test -f "$absdir/$objdir/$depdepl"; then 850716ee1e9aSmrg depdepl=$absdir/$objdir/$depdepl 850816ee1e9aSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509fda9279dSmrg if test -z "$darwin_install_name"; then 851016ee1e9aSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511fda9279dSmrg fi 851216ee1e9aSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851316ee1e9aSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514fda9279dSmrg path= 8515fda9279dSmrg fi 8516fda9279dSmrg fi 8517fda9279dSmrg ;; 8518fda9279dSmrg *) 851916ee1e9aSmrg path=-L$absdir/$objdir 8520fda9279dSmrg ;; 8521fda9279dSmrg esac 8522fda9279dSmrg else 852316ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524fda9279dSmrg test -z "$libdir" && \ 852516ee1e9aSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8526fda9279dSmrg test "$absdir" != "$libdir" && \ 852716ee1e9aSmrg func_warning "'$deplib' seems to be moved" 8528fda9279dSmrg 852916ee1e9aSmrg path=-L$absdir 8530fda9279dSmrg fi 8531fda9279dSmrg ;; 8532fda9279dSmrg esac 8533fda9279dSmrg case " $deplibs " in 8534fda9279dSmrg *" $path "*) ;; 8535fda9279dSmrg *) deplibs="$path $deplibs" ;; 8536fda9279dSmrg esac 8537fda9279dSmrg done 8538fda9279dSmrg fi # link_all_deplibs != no 8539fda9279dSmrg fi # linkmode = lib 8540fda9279dSmrg done # for deplib in $libs 854116ee1e9aSmrg if test link = "$pass"; then 854216ee1e9aSmrg if test prog = "$linkmode"; then 8543fda9279dSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544fda9279dSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545fda9279dSmrg else 8546fda9279dSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547fda9279dSmrg fi 8548fda9279dSmrg fi 854916ee1e9aSmrg dependency_libs=$newdependency_libs 855016ee1e9aSmrg if test dlpreopen = "$pass"; then 8551fda9279dSmrg # Link the dlpreopened libraries before other libraries 8552fda9279dSmrg for deplib in $save_deplibs; do 8553fda9279dSmrg deplibs="$deplib $deplibs" 8554fda9279dSmrg done 8555fda9279dSmrg fi 855616ee1e9aSmrg if test dlopen != "$pass"; then 855716ee1e9aSmrg test conv = "$pass" || { 8558fda9279dSmrg # Make sure lib_search_path contains only unique directories. 8559fda9279dSmrg lib_search_path= 8560fda9279dSmrg for dir in $newlib_search_path; do 8561fda9279dSmrg case "$lib_search_path " in 8562fda9279dSmrg *" $dir "*) ;; 8563fda9279dSmrg *) func_append lib_search_path " $dir" ;; 8564fda9279dSmrg esac 8565fda9279dSmrg done 8566fda9279dSmrg newlib_search_path= 856716ee1e9aSmrg } 8568fda9279dSmrg 856916ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 8570fda9279dSmrg vars="compile_deplibs finalize_deplibs" 857116ee1e9aSmrg else 857216ee1e9aSmrg vars=deplibs 8573fda9279dSmrg fi 8574fda9279dSmrg for var in $vars dependency_libs; do 8575fda9279dSmrg # Add libraries to $var in reverse order 8576fda9279dSmrg eval tmp_libs=\"\$$var\" 8577fda9279dSmrg new_libs= 8578fda9279dSmrg for deplib in $tmp_libs; do 8579fda9279dSmrg # FIXME: Pedantically, this is the right thing to do, so 8580fda9279dSmrg # that some nasty dependency loop isn't accidentally 8581fda9279dSmrg # broken: 8582fda9279dSmrg #new_libs="$deplib $new_libs" 8583fda9279dSmrg # Pragmatically, this seems to cause very few problems in 8584fda9279dSmrg # practice: 8585fda9279dSmrg case $deplib in 8586fda9279dSmrg -L*) new_libs="$deplib $new_libs" ;; 8587fda9279dSmrg -R*) ;; 8588fda9279dSmrg *) 8589fda9279dSmrg # And here is the reason: when a library appears more 8590fda9279dSmrg # than once as an explicit dependence of a library, or 8591fda9279dSmrg # is implicitly linked in more than once by the 8592fda9279dSmrg # compiler, it is considered special, and multiple 8593fda9279dSmrg # occurrences thereof are not removed. Compare this 8594fda9279dSmrg # with having the same library being listed as a 8595fda9279dSmrg # dependency of multiple other libraries: in this case, 8596fda9279dSmrg # we know (pedantically, we assume) the library does not 8597fda9279dSmrg # need to be listed more than once, so we keep only the 8598fda9279dSmrg # last copy. This is not always right, but it is rare 8599fda9279dSmrg # enough that we require users that really mean to play 8600fda9279dSmrg # such unportable linking tricks to link the library 8601fda9279dSmrg # using -Wl,-lname, so that libtool does not consider it 8602fda9279dSmrg # for duplicate removal. 8603fda9279dSmrg case " $specialdeplibs " in 8604fda9279dSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605fda9279dSmrg *) 8606fda9279dSmrg case " $new_libs " in 8607fda9279dSmrg *" $deplib "*) ;; 8608fda9279dSmrg *) new_libs="$deplib $new_libs" ;; 8609fda9279dSmrg esac 8610fda9279dSmrg ;; 8611fda9279dSmrg esac 8612fda9279dSmrg ;; 8613fda9279dSmrg esac 8614fda9279dSmrg done 8615fda9279dSmrg tmp_libs= 8616fda9279dSmrg for deplib in $new_libs; do 8617fda9279dSmrg case $deplib in 8618fda9279dSmrg -L*) 8619fda9279dSmrg case " $tmp_libs " in 8620fda9279dSmrg *" $deplib "*) ;; 8621fda9279dSmrg *) func_append tmp_libs " $deplib" ;; 8622fda9279dSmrg esac 8623fda9279dSmrg ;; 8624fda9279dSmrg *) func_append tmp_libs " $deplib" ;; 8625fda9279dSmrg esac 8626fda9279dSmrg done 8627fda9279dSmrg eval $var=\"$tmp_libs\" 8628fda9279dSmrg done # for var 8629fda9279dSmrg fi 863016ee1e9aSmrg 863116ee1e9aSmrg # Add Sun CC postdeps if required: 863216ee1e9aSmrg test CXX = "$tagname" && { 863316ee1e9aSmrg case $host_os in 863416ee1e9aSmrg linux*) 863516ee1e9aSmrg case `$CC -V 2>&1 | sed 5q` in 863616ee1e9aSmrg *Sun\ C*) # Sun C++ 5.9 863716ee1e9aSmrg func_suncc_cstd_abi 863816ee1e9aSmrg 863916ee1e9aSmrg if test no != "$suncc_use_cstd_abi"; then 864016ee1e9aSmrg func_append postdeps ' -library=Cstd -library=Crun' 864116ee1e9aSmrg fi 864216ee1e9aSmrg ;; 864316ee1e9aSmrg esac 864416ee1e9aSmrg ;; 864516ee1e9aSmrg 864616ee1e9aSmrg solaris*) 864716ee1e9aSmrg func_cc_basename "$CC" 864816ee1e9aSmrg case $func_cc_basename_result in 864916ee1e9aSmrg CC* | sunCC*) 865016ee1e9aSmrg func_suncc_cstd_abi 865116ee1e9aSmrg 865216ee1e9aSmrg if test no != "$suncc_use_cstd_abi"; then 865316ee1e9aSmrg func_append postdeps ' -library=Cstd -library=Crun' 865416ee1e9aSmrg fi 865516ee1e9aSmrg ;; 865616ee1e9aSmrg esac 865716ee1e9aSmrg ;; 865816ee1e9aSmrg esac 865916ee1e9aSmrg } 866016ee1e9aSmrg 8661fda9279dSmrg # Last step: remove runtime libs from dependency_libs 8662fda9279dSmrg # (they stay in deplibs) 8663fda9279dSmrg tmp_libs= 866416ee1e9aSmrg for i in $dependency_libs; do 8665fda9279dSmrg case " $predeps $postdeps $compiler_lib_search_path " in 8666fda9279dSmrg *" $i "*) 866716ee1e9aSmrg i= 8668fda9279dSmrg ;; 8669fda9279dSmrg esac 867016ee1e9aSmrg if test -n "$i"; then 8671fda9279dSmrg func_append tmp_libs " $i" 8672fda9279dSmrg fi 8673fda9279dSmrg done 8674fda9279dSmrg dependency_libs=$tmp_libs 8675fda9279dSmrg done # for pass 867616ee1e9aSmrg if test prog = "$linkmode"; then 867716ee1e9aSmrg dlfiles=$newdlfiles 8678fda9279dSmrg fi 867916ee1e9aSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868016ee1e9aSmrg dlprefiles=$newdlprefiles 8681fda9279dSmrg fi 8682fda9279dSmrg 8683fda9279dSmrg case $linkmode in 8684fda9279dSmrg oldlib) 868516ee1e9aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 868616ee1e9aSmrg func_warning "'-dlopen' is ignored for archives" 8687fda9279dSmrg fi 8688fda9279dSmrg 8689fda9279dSmrg case " $deplibs" in 8690fda9279dSmrg *\ -l* | *\ -L*) 869116ee1e9aSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8692fda9279dSmrg esac 8693fda9279dSmrg 8694fda9279dSmrg test -n "$rpath" && \ 869516ee1e9aSmrg func_warning "'-rpath' is ignored for archives" 8696fda9279dSmrg 8697fda9279dSmrg test -n "$xrpath" && \ 869816ee1e9aSmrg func_warning "'-R' is ignored for archives" 8699fda9279dSmrg 8700fda9279dSmrg test -n "$vinfo" && \ 870116ee1e9aSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8702fda9279dSmrg 8703fda9279dSmrg test -n "$release" && \ 870416ee1e9aSmrg func_warning "'-release' is ignored for archives" 8705fda9279dSmrg 8706fda9279dSmrg test -n "$export_symbols$export_symbols_regex" && \ 870716ee1e9aSmrg func_warning "'-export-symbols' is ignored for archives" 8708fda9279dSmrg 8709fda9279dSmrg # Now set the variables for building old libraries. 8710fda9279dSmrg build_libtool_libs=no 871116ee1e9aSmrg oldlibs=$output 8712fda9279dSmrg func_append objs "$old_deplibs" 8713fda9279dSmrg ;; 8714fda9279dSmrg 8715fda9279dSmrg lib) 871616ee1e9aSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8717fda9279dSmrg case $outputname in 8718fda9279dSmrg lib*) 8719fda9279dSmrg func_stripname 'lib' '.la' "$outputname" 8720fda9279dSmrg name=$func_stripname_result 8721fda9279dSmrg eval shared_ext=\"$shrext_cmds\" 8722fda9279dSmrg eval libname=\"$libname_spec\" 8723fda9279dSmrg ;; 8724fda9279dSmrg *) 872516ee1e9aSmrg test no = "$module" \ 872616ee1e9aSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727fda9279dSmrg 872816ee1e9aSmrg if test no != "$need_lib_prefix"; then 8729fda9279dSmrg # Add the "lib" prefix for modules if required 8730fda9279dSmrg func_stripname '' '.la' "$outputname" 8731fda9279dSmrg name=$func_stripname_result 8732fda9279dSmrg eval shared_ext=\"$shrext_cmds\" 8733fda9279dSmrg eval libname=\"$libname_spec\" 8734fda9279dSmrg else 8735fda9279dSmrg func_stripname '' '.la' "$outputname" 8736fda9279dSmrg libname=$func_stripname_result 8737fda9279dSmrg fi 8738fda9279dSmrg ;; 8739fda9279dSmrg esac 8740fda9279dSmrg 8741fda9279dSmrg if test -n "$objs"; then 874216ee1e9aSmrg if test pass_all != "$deplibs_check_method"; then 874316ee1e9aSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744fda9279dSmrg else 8745fda9279dSmrg echo 8746fda9279dSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747fda9279dSmrg $ECHO "*** objects $objs is not portable!" 8748fda9279dSmrg func_append libobjs " $objs" 8749fda9279dSmrg fi 8750fda9279dSmrg fi 8751fda9279dSmrg 875216ee1e9aSmrg test no = "$dlself" \ 875316ee1e9aSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8754fda9279dSmrg 8755fda9279dSmrg set dummy $rpath 8756fda9279dSmrg shift 875716ee1e9aSmrg test 1 -lt "$#" \ 875816ee1e9aSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8759fda9279dSmrg 876016ee1e9aSmrg install_libdir=$1 8761fda9279dSmrg 8762fda9279dSmrg oldlibs= 8763fda9279dSmrg if test -z "$rpath"; then 876416ee1e9aSmrg if test yes = "$build_libtool_libs"; then 8765fda9279dSmrg # Building a libtool convenience library. 876616ee1e9aSmrg # Some compilers have problems with a '.al' extension so 8767fda9279dSmrg # convenience libraries should have the same extension an 8768fda9279dSmrg # archive normally would. 8769fda9279dSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770fda9279dSmrg build_libtool_libs=convenience 8771fda9279dSmrg build_old_libs=yes 8772fda9279dSmrg fi 8773fda9279dSmrg 8774fda9279dSmrg test -n "$vinfo" && \ 877516ee1e9aSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776fda9279dSmrg 8777fda9279dSmrg test -n "$release" && \ 877816ee1e9aSmrg func_warning "'-release' is ignored for convenience libraries" 8779fda9279dSmrg else 8780fda9279dSmrg 8781fda9279dSmrg # Parse the version information argument. 878216ee1e9aSmrg save_ifs=$IFS; IFS=: 8783fda9279dSmrg set dummy $vinfo 0 0 0 8784fda9279dSmrg shift 878516ee1e9aSmrg IFS=$save_ifs 8786fda9279dSmrg 8787fda9279dSmrg test -n "$7" && \ 878816ee1e9aSmrg func_fatal_help "too many parameters to '-version-info'" 8789fda9279dSmrg 8790fda9279dSmrg # convert absolute version numbers to libtool ages 8791fda9279dSmrg # this retains compatibility with .la files and attempts 8792fda9279dSmrg # to make the code below a bit more comprehensible 8793fda9279dSmrg 8794fda9279dSmrg case $vinfo_number in 8795fda9279dSmrg yes) 879616ee1e9aSmrg number_major=$1 879716ee1e9aSmrg number_minor=$2 879816ee1e9aSmrg number_revision=$3 8799fda9279dSmrg # 8800fda9279dSmrg # There are really only two kinds -- those that 8801fda9279dSmrg # use the current revision as the major version 8802fda9279dSmrg # and those that subtract age and use age as 8803fda9279dSmrg # a minor version. But, then there is irix 880416ee1e9aSmrg # that has an extra 1 added just for fun 8805fda9279dSmrg # 8806fda9279dSmrg case $version_type in 8807fda9279dSmrg # correct linux to gnu/linux during the next big refactor 880816ee1e9aSmrg darwin|freebsd-elf|linux|osf|windows|none) 8809fda9279dSmrg func_arith $number_major + $number_minor 8810fda9279dSmrg current=$func_arith_result 881116ee1e9aSmrg age=$number_minor 881216ee1e9aSmrg revision=$number_revision 8813fda9279dSmrg ;; 881416ee1e9aSmrg freebsd-aout|qnx|sunos) 881516ee1e9aSmrg current=$number_major 881616ee1e9aSmrg revision=$number_minor 881716ee1e9aSmrg age=0 8818fda9279dSmrg ;; 8819fda9279dSmrg irix|nonstopux) 8820fda9279dSmrg func_arith $number_major + $number_minor 8821fda9279dSmrg current=$func_arith_result 882216ee1e9aSmrg age=$number_minor 882316ee1e9aSmrg revision=$number_minor 8824fda9279dSmrg lt_irix_increment=no 8825fda9279dSmrg ;; 8826fda9279dSmrg esac 8827fda9279dSmrg ;; 8828fda9279dSmrg no) 882916ee1e9aSmrg current=$1 883016ee1e9aSmrg revision=$2 883116ee1e9aSmrg age=$3 8832fda9279dSmrg ;; 8833fda9279dSmrg esac 8834fda9279dSmrg 8835fda9279dSmrg # Check that each of the things are valid numbers. 8836fda9279dSmrg case $current in 8837fda9279dSmrg 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]) ;; 8838fda9279dSmrg *) 883916ee1e9aSmrg func_error "CURRENT '$current' must be a nonnegative integer" 884016ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8841fda9279dSmrg ;; 8842fda9279dSmrg esac 8843fda9279dSmrg 8844fda9279dSmrg case $revision in 8845fda9279dSmrg 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]) ;; 8846fda9279dSmrg *) 884716ee1e9aSmrg func_error "REVISION '$revision' must be a nonnegative integer" 884816ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8849fda9279dSmrg ;; 8850fda9279dSmrg esac 8851fda9279dSmrg 8852fda9279dSmrg case $age in 8853fda9279dSmrg 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]) ;; 8854fda9279dSmrg *) 885516ee1e9aSmrg func_error "AGE '$age' must be a nonnegative integer" 885616ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8857fda9279dSmrg ;; 8858fda9279dSmrg esac 8859fda9279dSmrg 8860fda9279dSmrg if test "$age" -gt "$current"; then 886116ee1e9aSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 886216ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8863fda9279dSmrg fi 8864fda9279dSmrg 8865fda9279dSmrg # Calculate the version variables. 8866fda9279dSmrg major= 8867fda9279dSmrg versuffix= 8868fda9279dSmrg verstring= 8869fda9279dSmrg case $version_type in 8870fda9279dSmrg none) ;; 8871fda9279dSmrg 8872fda9279dSmrg darwin) 8873fda9279dSmrg # Like Linux, but with the current version available in 8874fda9279dSmrg # verstring for coding it into the library header 8875fda9279dSmrg func_arith $current - $age 8876fda9279dSmrg major=.$func_arith_result 887716ee1e9aSmrg versuffix=$major.$age.$revision 8878fda9279dSmrg # Darwin ld doesn't like 0 for these options... 8879fda9279dSmrg func_arith $current + 1 8880fda9279dSmrg minor_current=$func_arith_result 888116ee1e9aSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882fda9279dSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 888316ee1e9aSmrg # On Darwin other compilers 888416ee1e9aSmrg case $CC in 888516ee1e9aSmrg nagfor*) 888616ee1e9aSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888716ee1e9aSmrg ;; 888816ee1e9aSmrg *) 888916ee1e9aSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889016ee1e9aSmrg ;; 889116ee1e9aSmrg esac 8892fda9279dSmrg ;; 8893fda9279dSmrg 8894fda9279dSmrg freebsd-aout) 889516ee1e9aSmrg major=.$current 889616ee1e9aSmrg versuffix=.$current.$revision 8897fda9279dSmrg ;; 8898fda9279dSmrg 8899fda9279dSmrg freebsd-elf) 890016ee1e9aSmrg func_arith $current - $age 890116ee1e9aSmrg major=.$func_arith_result 890216ee1e9aSmrg versuffix=$major.$age.$revision 8903fda9279dSmrg ;; 8904fda9279dSmrg 8905fda9279dSmrg irix | nonstopux) 890616ee1e9aSmrg if test no = "$lt_irix_increment"; then 8907fda9279dSmrg func_arith $current - $age 8908fda9279dSmrg else 8909fda9279dSmrg func_arith $current - $age + 1 8910fda9279dSmrg fi 8911fda9279dSmrg major=$func_arith_result 8912fda9279dSmrg 8913fda9279dSmrg case $version_type in 8914fda9279dSmrg nonstopux) verstring_prefix=nonstopux ;; 8915fda9279dSmrg *) verstring_prefix=sgi ;; 8916fda9279dSmrg esac 891716ee1e9aSmrg verstring=$verstring_prefix$major.$revision 8918fda9279dSmrg 8919fda9279dSmrg # Add in all the interfaces that we are compatible with. 8920fda9279dSmrg loop=$revision 892116ee1e9aSmrg while test 0 -ne "$loop"; do 8922fda9279dSmrg func_arith $revision - $loop 8923fda9279dSmrg iface=$func_arith_result 8924fda9279dSmrg func_arith $loop - 1 8925fda9279dSmrg loop=$func_arith_result 892616ee1e9aSmrg verstring=$verstring_prefix$major.$iface:$verstring 8927fda9279dSmrg done 8928fda9279dSmrg 892916ee1e9aSmrg # Before this point, $major must not contain '.'. 8930fda9279dSmrg major=.$major 893116ee1e9aSmrg versuffix=$major.$revision 8932fda9279dSmrg ;; 8933fda9279dSmrg 8934fda9279dSmrg linux) # correct to gnu/linux during the next big refactor 8935fda9279dSmrg func_arith $current - $age 8936fda9279dSmrg major=.$func_arith_result 893716ee1e9aSmrg versuffix=$major.$age.$revision 8938fda9279dSmrg ;; 8939fda9279dSmrg 8940fda9279dSmrg osf) 8941fda9279dSmrg func_arith $current - $age 8942fda9279dSmrg major=.$func_arith_result 894316ee1e9aSmrg versuffix=.$current.$age.$revision 894416ee1e9aSmrg verstring=$current.$age.$revision 8945fda9279dSmrg 8946fda9279dSmrg # Add in all the interfaces that we are compatible with. 8947fda9279dSmrg loop=$age 894816ee1e9aSmrg while test 0 -ne "$loop"; do 8949fda9279dSmrg func_arith $current - $loop 8950fda9279dSmrg iface=$func_arith_result 8951fda9279dSmrg func_arith $loop - 1 8952fda9279dSmrg loop=$func_arith_result 895316ee1e9aSmrg verstring=$verstring:$iface.0 8954fda9279dSmrg done 8955fda9279dSmrg 8956fda9279dSmrg # Make executables depend on our current version. 895716ee1e9aSmrg func_append verstring ":$current.0" 8958fda9279dSmrg ;; 8959fda9279dSmrg 8960fda9279dSmrg qnx) 896116ee1e9aSmrg major=.$current 896216ee1e9aSmrg versuffix=.$current 896316ee1e9aSmrg ;; 896416ee1e9aSmrg 896516ee1e9aSmrg sco) 896616ee1e9aSmrg major=.$current 896716ee1e9aSmrg versuffix=.$current 8968fda9279dSmrg ;; 8969fda9279dSmrg 8970fda9279dSmrg sunos) 897116ee1e9aSmrg major=.$current 897216ee1e9aSmrg versuffix=.$current.$revision 8973fda9279dSmrg ;; 8974fda9279dSmrg 8975fda9279dSmrg windows) 8976fda9279dSmrg # Use '-' rather than '.', since we only want one 897716ee1e9aSmrg # extension on DOS 8.3 file systems. 8978fda9279dSmrg func_arith $current - $age 8979fda9279dSmrg major=$func_arith_result 898016ee1e9aSmrg versuffix=-$major 8981fda9279dSmrg ;; 8982fda9279dSmrg 8983fda9279dSmrg *) 898416ee1e9aSmrg func_fatal_configuration "unknown library version type '$version_type'" 8985fda9279dSmrg ;; 8986fda9279dSmrg esac 8987fda9279dSmrg 8988fda9279dSmrg # Clear the version info if we defaulted, and they specified a release. 8989fda9279dSmrg if test -z "$vinfo" && test -n "$release"; then 8990fda9279dSmrg major= 8991fda9279dSmrg case $version_type in 8992fda9279dSmrg darwin) 8993fda9279dSmrg # we can't check for "0.0" in archive_cmds due to quoting 8994fda9279dSmrg # problems, so we reset it completely 8995fda9279dSmrg verstring= 8996fda9279dSmrg ;; 8997fda9279dSmrg *) 899816ee1e9aSmrg verstring=0.0 8999fda9279dSmrg ;; 9000fda9279dSmrg esac 900116ee1e9aSmrg if test no = "$need_version"; then 9002fda9279dSmrg versuffix= 9003fda9279dSmrg else 900416ee1e9aSmrg versuffix=.0.0 9005fda9279dSmrg fi 9006fda9279dSmrg fi 9007fda9279dSmrg 9008fda9279dSmrg # Remove version info from name if versioning should be avoided 900916ee1e9aSmrg if test yes,no = "$avoid_version,$need_version"; then 9010fda9279dSmrg major= 9011fda9279dSmrg versuffix= 901216ee1e9aSmrg verstring= 9013fda9279dSmrg fi 9014fda9279dSmrg 9015fda9279dSmrg # Check to see if the archive will have undefined symbols. 901616ee1e9aSmrg if test yes = "$allow_undefined"; then 901716ee1e9aSmrg if test unsupported = "$allow_undefined_flag"; then 901816ee1e9aSmrg if test yes = "$build_old_libs"; then 901916ee1e9aSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902016ee1e9aSmrg build_libtool_libs=no 902116ee1e9aSmrg else 902216ee1e9aSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 902316ee1e9aSmrg fi 9024fda9279dSmrg fi 9025fda9279dSmrg else 9026fda9279dSmrg # Don't allow undefined symbols. 902716ee1e9aSmrg allow_undefined_flag=$no_undefined_flag 9028fda9279dSmrg fi 9029fda9279dSmrg 9030fda9279dSmrg fi 9031fda9279dSmrg 903216ee1e9aSmrg func_generate_dlsyms "$libname" "$libname" : 9033fda9279dSmrg func_append libobjs " $symfileobj" 903416ee1e9aSmrg test " " = "$libobjs" && libobjs= 9035fda9279dSmrg 903616ee1e9aSmrg if test relink != "$opt_mode"; then 9037fda9279dSmrg # Remove our outputs, but don't remove object files since they 9038fda9279dSmrg # may have been created when compiling PIC objects. 9039fda9279dSmrg removelist= 9040fda9279dSmrg tempremovelist=`$ECHO "$output_objdir/*"` 9041fda9279dSmrg for p in $tempremovelist; do 9042fda9279dSmrg case $p in 9043fda9279dSmrg *.$objext | *.gcno) 9044fda9279dSmrg ;; 904516ee1e9aSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 904616ee1e9aSmrg if test -n "$precious_files_regex"; then 9047fda9279dSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048fda9279dSmrg then 9049fda9279dSmrg continue 9050fda9279dSmrg fi 9051fda9279dSmrg fi 9052fda9279dSmrg func_append removelist " $p" 9053fda9279dSmrg ;; 9054fda9279dSmrg *) ;; 9055fda9279dSmrg esac 9056fda9279dSmrg done 9057fda9279dSmrg test -n "$removelist" && \ 9058fda9279dSmrg func_show_eval "${RM}r \$removelist" 9059fda9279dSmrg fi 9060fda9279dSmrg 9061fda9279dSmrg # Now set the variables for building old libraries. 906216ee1e9aSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063fda9279dSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9064fda9279dSmrg 9065fda9279dSmrg # Transform .lo files to .o files. 906616ee1e9aSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067fda9279dSmrg fi 9068fda9279dSmrg 9069fda9279dSmrg # Eliminate all temporary directories. 9070fda9279dSmrg #for path in $notinst_path; do 9071fda9279dSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072fda9279dSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073fda9279dSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074fda9279dSmrg #done 9075fda9279dSmrg 9076fda9279dSmrg if test -n "$xrpath"; then 9077fda9279dSmrg # If the user specified any rpath flags, then add them. 9078fda9279dSmrg temp_xrpath= 9079fda9279dSmrg for libdir in $xrpath; do 9080fda9279dSmrg func_replace_sysroot "$libdir" 9081fda9279dSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9082fda9279dSmrg case "$finalize_rpath " in 9083fda9279dSmrg *" $libdir "*) ;; 9084fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 9085fda9279dSmrg esac 9086fda9279dSmrg done 908716ee1e9aSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088fda9279dSmrg dependency_libs="$temp_xrpath $dependency_libs" 9089fda9279dSmrg fi 9090fda9279dSmrg fi 9091fda9279dSmrg 9092fda9279dSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 909316ee1e9aSmrg old_dlfiles=$dlfiles 9094fda9279dSmrg dlfiles= 9095fda9279dSmrg for lib in $old_dlfiles; do 9096fda9279dSmrg case " $dlprefiles $dlfiles " in 9097fda9279dSmrg *" $lib "*) ;; 9098fda9279dSmrg *) func_append dlfiles " $lib" ;; 9099fda9279dSmrg esac 9100fda9279dSmrg done 9101fda9279dSmrg 9102fda9279dSmrg # Make sure dlprefiles contains only unique files 910316ee1e9aSmrg old_dlprefiles=$dlprefiles 9104fda9279dSmrg dlprefiles= 9105fda9279dSmrg for lib in $old_dlprefiles; do 9106fda9279dSmrg case "$dlprefiles " in 9107fda9279dSmrg *" $lib "*) ;; 9108fda9279dSmrg *) func_append dlprefiles " $lib" ;; 9109fda9279dSmrg esac 9110fda9279dSmrg done 9111fda9279dSmrg 911216ee1e9aSmrg if test yes = "$build_libtool_libs"; then 9113fda9279dSmrg if test -n "$rpath"; then 9114fda9279dSmrg case $host in 9115fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116fda9279dSmrg # these systems don't actually have a c library (as such)! 9117fda9279dSmrg ;; 9118fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9119fda9279dSmrg # Rhapsody C library is in the System framework 9120fda9279dSmrg func_append deplibs " System.ltframework" 9121fda9279dSmrg ;; 9122fda9279dSmrg *-*-netbsd*) 9123fda9279dSmrg # Don't link with libc until the a.out ld.so is fixed. 9124fda9279dSmrg ;; 9125fda9279dSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126fda9279dSmrg # Do not include libc due to us having libc/libc_r. 9127fda9279dSmrg ;; 9128fda9279dSmrg *-*-sco3.2v5* | *-*-sco5v6*) 9129fda9279dSmrg # Causes problems with __ctype 9130fda9279dSmrg ;; 9131fda9279dSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132fda9279dSmrg # Compiler inserts libc in the correct place for threads to work 9133fda9279dSmrg ;; 9134fda9279dSmrg *) 9135fda9279dSmrg # Add libc to deplibs on all other systems if necessary. 913616ee1e9aSmrg if test yes = "$build_libtool_need_lc"; then 9137fda9279dSmrg func_append deplibs " -lc" 9138fda9279dSmrg fi 9139fda9279dSmrg ;; 9140fda9279dSmrg esac 9141fda9279dSmrg fi 9142fda9279dSmrg 9143fda9279dSmrg # Transform deplibs into only deplibs that can be linked in shared. 9144fda9279dSmrg name_save=$name 9145fda9279dSmrg libname_save=$libname 9146fda9279dSmrg release_save=$release 9147fda9279dSmrg versuffix_save=$versuffix 9148fda9279dSmrg major_save=$major 9149fda9279dSmrg # I'm not sure if I'm treating the release correctly. I think 9150fda9279dSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 9151fda9279dSmrg # add it in twice. Is that correct? 915216ee1e9aSmrg release= 915316ee1e9aSmrg versuffix= 915416ee1e9aSmrg major= 9155fda9279dSmrg newdeplibs= 9156fda9279dSmrg droppeddeps=no 9157fda9279dSmrg case $deplibs_check_method in 9158fda9279dSmrg pass_all) 9159fda9279dSmrg # Don't check for shared/static. Everything works. 9160fda9279dSmrg # This might be a little naive. We might want to check 9161fda9279dSmrg # whether the library exists or not. But this is on 9162fda9279dSmrg # osf3 & osf4 and I'm not really sure... Just 9163fda9279dSmrg # implementing what was already the behavior. 9164fda9279dSmrg newdeplibs=$deplibs 9165fda9279dSmrg ;; 9166fda9279dSmrg test_compile) 9167fda9279dSmrg # This code stresses the "libraries are programs" paradigm to its 9168fda9279dSmrg # limits. Maybe even breaks it. We compile a program, linking it 9169fda9279dSmrg # against the deplibs as a proxy for the library. Then we can check 9170fda9279dSmrg # whether they linked in statically or dynamically with ldd. 9171fda9279dSmrg $opt_dry_run || $RM conftest.c 9172fda9279dSmrg cat > conftest.c <<EOF 9173fda9279dSmrg int main() { return 0; } 9174fda9279dSmrgEOF 9175fda9279dSmrg $opt_dry_run || $RM conftest 9176fda9279dSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177fda9279dSmrg ldd_output=`ldd conftest` 9178fda9279dSmrg for i in $deplibs; do 9179fda9279dSmrg case $i in 9180fda9279dSmrg -l*) 9181fda9279dSmrg func_stripname -l '' "$i" 9182fda9279dSmrg name=$func_stripname_result 918316ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184fda9279dSmrg case " $predeps $postdeps " in 9185fda9279dSmrg *" $i "*) 9186fda9279dSmrg func_append newdeplibs " $i" 918716ee1e9aSmrg i= 9188fda9279dSmrg ;; 9189fda9279dSmrg esac 9190fda9279dSmrg fi 919116ee1e9aSmrg if test -n "$i"; then 9192fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9193fda9279dSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194fda9279dSmrg set dummy $deplib_matches; shift 9195fda9279dSmrg deplib_match=$1 919616ee1e9aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197fda9279dSmrg func_append newdeplibs " $i" 9198fda9279dSmrg else 9199fda9279dSmrg droppeddeps=yes 9200fda9279dSmrg echo 9201fda9279dSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9203fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9204fda9279dSmrg echo "*** shared version of the library, which I believe you do not have" 9205fda9279dSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 9206fda9279dSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207fda9279dSmrg fi 9208fda9279dSmrg fi 9209fda9279dSmrg ;; 9210fda9279dSmrg *) 9211fda9279dSmrg func_append newdeplibs " $i" 9212fda9279dSmrg ;; 9213fda9279dSmrg esac 9214fda9279dSmrg done 9215fda9279dSmrg else 9216fda9279dSmrg # Error occurred in the first compile. Let's try to salvage 9217fda9279dSmrg # the situation: Compile a separate program for each library. 9218fda9279dSmrg for i in $deplibs; do 9219fda9279dSmrg case $i in 9220fda9279dSmrg -l*) 9221fda9279dSmrg func_stripname -l '' "$i" 9222fda9279dSmrg name=$func_stripname_result 9223fda9279dSmrg $opt_dry_run || $RM conftest 9224fda9279dSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225fda9279dSmrg ldd_output=`ldd conftest` 922616ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227fda9279dSmrg case " $predeps $postdeps " in 9228fda9279dSmrg *" $i "*) 9229fda9279dSmrg func_append newdeplibs " $i" 923016ee1e9aSmrg i= 9231fda9279dSmrg ;; 9232fda9279dSmrg esac 9233fda9279dSmrg fi 923416ee1e9aSmrg if test -n "$i"; then 9235fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9236fda9279dSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237fda9279dSmrg set dummy $deplib_matches; shift 9238fda9279dSmrg deplib_match=$1 923916ee1e9aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240fda9279dSmrg func_append newdeplibs " $i" 9241fda9279dSmrg else 9242fda9279dSmrg droppeddeps=yes 9243fda9279dSmrg echo 9244fda9279dSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9246fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9247fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 9248fda9279dSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 9249fda9279dSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250fda9279dSmrg fi 9251fda9279dSmrg fi 9252fda9279dSmrg else 9253fda9279dSmrg droppeddeps=yes 9254fda9279dSmrg echo 9255fda9279dSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256fda9279dSmrg echo "*** make it link in! You will probably need to install it or some" 9257fda9279dSmrg echo "*** library that it depends on before this library will be fully" 9258fda9279dSmrg echo "*** functional. Installing it before continuing would be even better." 9259fda9279dSmrg fi 9260fda9279dSmrg ;; 9261fda9279dSmrg *) 9262fda9279dSmrg func_append newdeplibs " $i" 9263fda9279dSmrg ;; 9264fda9279dSmrg esac 9265fda9279dSmrg done 9266fda9279dSmrg fi 9267fda9279dSmrg ;; 9268fda9279dSmrg file_magic*) 9269fda9279dSmrg set dummy $deplibs_check_method; shift 9270fda9279dSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271fda9279dSmrg for a_deplib in $deplibs; do 9272fda9279dSmrg case $a_deplib in 9273fda9279dSmrg -l*) 9274fda9279dSmrg func_stripname -l '' "$a_deplib" 9275fda9279dSmrg name=$func_stripname_result 927616ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277fda9279dSmrg case " $predeps $postdeps " in 9278fda9279dSmrg *" $a_deplib "*) 9279fda9279dSmrg func_append newdeplibs " $a_deplib" 928016ee1e9aSmrg a_deplib= 9281fda9279dSmrg ;; 9282fda9279dSmrg esac 9283fda9279dSmrg fi 928416ee1e9aSmrg if test -n "$a_deplib"; then 9285fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9286fda9279dSmrg if test -n "$file_magic_glob"; then 9287fda9279dSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288fda9279dSmrg else 9289fda9279dSmrg libnameglob=$libname 9290fda9279dSmrg fi 929116ee1e9aSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292fda9279dSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 929316ee1e9aSmrg if test yes = "$want_nocaseglob"; then 9294fda9279dSmrg shopt -s nocaseglob 9295fda9279dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296fda9279dSmrg $nocaseglob 9297fda9279dSmrg else 9298fda9279dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299fda9279dSmrg fi 9300fda9279dSmrg for potent_lib in $potential_libs; do 9301fda9279dSmrg # Follow soft links. 9302fda9279dSmrg if ls -lLd "$potent_lib" 2>/dev/null | 9303fda9279dSmrg $GREP " -> " >/dev/null; then 9304fda9279dSmrg continue 9305fda9279dSmrg fi 9306fda9279dSmrg # The statement above tries to avoid entering an 9307fda9279dSmrg # endless loop below, in case of cyclic links. 9308fda9279dSmrg # We might still enter an endless loop, since a link 9309fda9279dSmrg # loop can be closed while we follow links, 9310fda9279dSmrg # but so what? 931116ee1e9aSmrg potlib=$potent_lib 9312fda9279dSmrg while test -h "$potlib" 2>/dev/null; do 931316ee1e9aSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314fda9279dSmrg case $potliblink in 931516ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 931616ee1e9aSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317fda9279dSmrg esac 9318fda9279dSmrg done 9319fda9279dSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320fda9279dSmrg $SED -e 10q | 9321fda9279dSmrg $EGREP "$file_magic_regex" > /dev/null; then 9322fda9279dSmrg func_append newdeplibs " $a_deplib" 932316ee1e9aSmrg a_deplib= 9324fda9279dSmrg break 2 9325fda9279dSmrg fi 9326fda9279dSmrg done 9327fda9279dSmrg done 9328fda9279dSmrg fi 932916ee1e9aSmrg if test -n "$a_deplib"; then 9330fda9279dSmrg droppeddeps=yes 9331fda9279dSmrg echo 9332fda9279dSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9334fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9335fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 9336fda9279dSmrg echo "*** because I did check the linker path looking for a file starting" 933716ee1e9aSmrg if test -z "$potlib"; then 9338fda9279dSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339fda9279dSmrg else 9340fda9279dSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9341fda9279dSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 9342fda9279dSmrg fi 9343fda9279dSmrg fi 9344fda9279dSmrg ;; 9345fda9279dSmrg *) 9346fda9279dSmrg # Add a -L argument. 9347fda9279dSmrg func_append newdeplibs " $a_deplib" 9348fda9279dSmrg ;; 9349fda9279dSmrg esac 9350fda9279dSmrg done # Gone through all deplibs. 9351fda9279dSmrg ;; 9352fda9279dSmrg match_pattern*) 9353fda9279dSmrg set dummy $deplibs_check_method; shift 9354fda9279dSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355fda9279dSmrg for a_deplib in $deplibs; do 9356fda9279dSmrg case $a_deplib in 9357fda9279dSmrg -l*) 9358fda9279dSmrg func_stripname -l '' "$a_deplib" 9359fda9279dSmrg name=$func_stripname_result 936016ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361fda9279dSmrg case " $predeps $postdeps " in 9362fda9279dSmrg *" $a_deplib "*) 9363fda9279dSmrg func_append newdeplibs " $a_deplib" 936416ee1e9aSmrg a_deplib= 9365fda9279dSmrg ;; 9366fda9279dSmrg esac 9367fda9279dSmrg fi 936816ee1e9aSmrg if test -n "$a_deplib"; then 9369fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9370fda9279dSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371fda9279dSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372fda9279dSmrg for potent_lib in $potential_libs; do 937316ee1e9aSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9374fda9279dSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375fda9279dSmrg $EGREP "$match_pattern_regex" > /dev/null; then 9376fda9279dSmrg func_append newdeplibs " $a_deplib" 937716ee1e9aSmrg a_deplib= 9378fda9279dSmrg break 2 9379fda9279dSmrg fi 9380fda9279dSmrg done 9381fda9279dSmrg done 9382fda9279dSmrg fi 938316ee1e9aSmrg if test -n "$a_deplib"; then 9384fda9279dSmrg droppeddeps=yes 9385fda9279dSmrg echo 9386fda9279dSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9388fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9389fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 9390fda9279dSmrg echo "*** because I did check the linker path looking for a file starting" 939116ee1e9aSmrg if test -z "$potlib"; then 9392fda9279dSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393fda9279dSmrg else 9394fda9279dSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9395fda9279dSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396fda9279dSmrg fi 9397fda9279dSmrg fi 9398fda9279dSmrg ;; 9399fda9279dSmrg *) 9400fda9279dSmrg # Add a -L argument. 9401fda9279dSmrg func_append newdeplibs " $a_deplib" 9402fda9279dSmrg ;; 9403fda9279dSmrg esac 9404fda9279dSmrg done # Gone through all deplibs. 9405fda9279dSmrg ;; 9406fda9279dSmrg none | unknown | *) 940716ee1e9aSmrg newdeplibs= 9408fda9279dSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 940916ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941016ee1e9aSmrg for i in $predeps $postdeps; do 9411fda9279dSmrg # can't use Xsed below, because $i might contain '/' 941216ee1e9aSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413fda9279dSmrg done 9414fda9279dSmrg fi 9415fda9279dSmrg case $tmp_deplibs in 9416fda9279dSmrg *[!\ \ ]*) 9417fda9279dSmrg echo 941816ee1e9aSmrg if test none = "$deplibs_check_method"; then 9419fda9279dSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9420fda9279dSmrg else 9421fda9279dSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 9422fda9279dSmrg fi 9423fda9279dSmrg echo "*** All declared inter-library dependencies are being dropped." 9424fda9279dSmrg droppeddeps=yes 9425fda9279dSmrg ;; 9426fda9279dSmrg esac 9427fda9279dSmrg ;; 9428fda9279dSmrg esac 9429fda9279dSmrg versuffix=$versuffix_save 9430fda9279dSmrg major=$major_save 9431fda9279dSmrg release=$release_save 9432fda9279dSmrg libname=$libname_save 9433fda9279dSmrg name=$name_save 9434fda9279dSmrg 9435fda9279dSmrg case $host in 9436fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9437fda9279dSmrg # On Rhapsody replace the C library with the System framework 9438fda9279dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439fda9279dSmrg ;; 9440fda9279dSmrg esac 9441fda9279dSmrg 944216ee1e9aSmrg if test yes = "$droppeddeps"; then 944316ee1e9aSmrg if test yes = "$module"; then 9444fda9279dSmrg echo 9445fda9279dSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9446fda9279dSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447fda9279dSmrg echo "*** a static module, that should work as long as the dlopening" 9448fda9279dSmrg echo "*** application is linked with the -dlopen flag." 9449fda9279dSmrg if test -z "$global_symbol_pipe"; then 9450fda9279dSmrg echo 9451fda9279dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 945216ee1e9aSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453fda9279dSmrg echo "*** not find such a program. So, this module is probably useless." 945416ee1e9aSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455fda9279dSmrg fi 945616ee1e9aSmrg if test no = "$build_old_libs"; then 945716ee1e9aSmrg oldlibs=$output_objdir/$libname.$libext 9458fda9279dSmrg build_libtool_libs=module 9459fda9279dSmrg build_old_libs=yes 9460fda9279dSmrg else 9461fda9279dSmrg build_libtool_libs=no 9462fda9279dSmrg fi 9463fda9279dSmrg else 9464fda9279dSmrg echo "*** The inter-library dependencies that have been dropped here will be" 9465fda9279dSmrg echo "*** automatically added whenever a program is linked with this library" 9466fda9279dSmrg echo "*** or is declared to -dlopen it." 9467fda9279dSmrg 946816ee1e9aSmrg if test no = "$allow_undefined"; then 9469fda9279dSmrg echo 9470fda9279dSmrg echo "*** Since this library must not contain undefined symbols," 9471fda9279dSmrg echo "*** because either the platform does not support them or" 9472fda9279dSmrg echo "*** it was explicitly requested with -no-undefined," 9473fda9279dSmrg echo "*** libtool will only create a static version of it." 947416ee1e9aSmrg if test no = "$build_old_libs"; then 947516ee1e9aSmrg oldlibs=$output_objdir/$libname.$libext 9476fda9279dSmrg build_libtool_libs=module 9477fda9279dSmrg build_old_libs=yes 9478fda9279dSmrg else 9479fda9279dSmrg build_libtool_libs=no 9480fda9279dSmrg fi 9481fda9279dSmrg fi 9482fda9279dSmrg fi 9483fda9279dSmrg fi 9484fda9279dSmrg # Done checking deplibs! 9485fda9279dSmrg deplibs=$newdeplibs 9486fda9279dSmrg fi 9487fda9279dSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488fda9279dSmrg case $host in 9489fda9279dSmrg *-*-darwin*) 9490fda9279dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491fda9279dSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492fda9279dSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493fda9279dSmrg ;; 9494fda9279dSmrg esac 9495fda9279dSmrg 9496fda9279dSmrg # move library search paths that coincide with paths to not yet 9497fda9279dSmrg # installed libraries to the beginning of the library search list 9498fda9279dSmrg new_libs= 9499fda9279dSmrg for path in $notinst_path; do 9500fda9279dSmrg case " $new_libs " in 9501fda9279dSmrg *" -L$path/$objdir "*) ;; 9502fda9279dSmrg *) 9503fda9279dSmrg case " $deplibs " in 9504fda9279dSmrg *" -L$path/$objdir "*) 9505fda9279dSmrg func_append new_libs " -L$path/$objdir" ;; 9506fda9279dSmrg esac 9507fda9279dSmrg ;; 9508fda9279dSmrg esac 9509fda9279dSmrg done 9510fda9279dSmrg for deplib in $deplibs; do 9511fda9279dSmrg case $deplib in 9512fda9279dSmrg -L*) 9513fda9279dSmrg case " $new_libs " in 9514fda9279dSmrg *" $deplib "*) ;; 9515fda9279dSmrg *) func_append new_libs " $deplib" ;; 9516fda9279dSmrg esac 9517fda9279dSmrg ;; 9518fda9279dSmrg *) func_append new_libs " $deplib" ;; 9519fda9279dSmrg esac 9520fda9279dSmrg done 952116ee1e9aSmrg deplibs=$new_libs 9522fda9279dSmrg 9523fda9279dSmrg # All the library-specific variables (install_libdir is set above). 9524fda9279dSmrg library_names= 9525fda9279dSmrg old_library= 9526fda9279dSmrg dlname= 9527fda9279dSmrg 9528fda9279dSmrg # Test again, we may have decided not to build it any more 952916ee1e9aSmrg if test yes = "$build_libtool_libs"; then 953016ee1e9aSmrg # Remove $wl instances when linking with ld. 9531fda9279dSmrg # FIXME: should test the right _cmds variable. 9532fda9279dSmrg case $archive_cmds in 9533fda9279dSmrg *\$LD\ *) wl= ;; 9534fda9279dSmrg esac 953516ee1e9aSmrg if test yes = "$hardcode_into_libs"; then 9536fda9279dSmrg # Hardcode the library paths 9537fda9279dSmrg hardcode_libdirs= 9538fda9279dSmrg dep_rpath= 953916ee1e9aSmrg rpath=$finalize_rpath 954016ee1e9aSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541fda9279dSmrg for libdir in $rpath; do 9542fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 9543fda9279dSmrg if test -n "$hardcode_libdir_separator"; then 9544fda9279dSmrg func_replace_sysroot "$libdir" 9545fda9279dSmrg libdir=$func_replace_sysroot_result 9546fda9279dSmrg if test -z "$hardcode_libdirs"; then 954716ee1e9aSmrg hardcode_libdirs=$libdir 9548fda9279dSmrg else 9549fda9279dSmrg # Just accumulate the unique libdirs. 9550fda9279dSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551fda9279dSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552fda9279dSmrg ;; 9553fda9279dSmrg *) 9554fda9279dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555fda9279dSmrg ;; 9556fda9279dSmrg esac 9557fda9279dSmrg fi 9558fda9279dSmrg else 9559fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 9560fda9279dSmrg func_append dep_rpath " $flag" 9561fda9279dSmrg fi 9562fda9279dSmrg elif test -n "$runpath_var"; then 9563fda9279dSmrg case "$perm_rpath " in 9564fda9279dSmrg *" $libdir "*) ;; 9565fda9279dSmrg *) func_append perm_rpath " $libdir" ;; 9566fda9279dSmrg esac 9567fda9279dSmrg fi 9568fda9279dSmrg done 9569fda9279dSmrg # Substitute the hardcoded libdirs into the rpath. 9570fda9279dSmrg if test -n "$hardcode_libdir_separator" && 9571fda9279dSmrg test -n "$hardcode_libdirs"; then 957216ee1e9aSmrg libdir=$hardcode_libdirs 9573fda9279dSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574fda9279dSmrg fi 9575fda9279dSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576fda9279dSmrg # We should set the runpath_var. 9577fda9279dSmrg rpath= 9578fda9279dSmrg for dir in $perm_rpath; do 9579fda9279dSmrg func_append rpath "$dir:" 9580fda9279dSmrg done 9581fda9279dSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582fda9279dSmrg fi 9583fda9279dSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584fda9279dSmrg fi 9585fda9279dSmrg 958616ee1e9aSmrg shlibpath=$finalize_shlibpath 958716ee1e9aSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588fda9279dSmrg if test -n "$shlibpath"; then 9589fda9279dSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590fda9279dSmrg fi 9591fda9279dSmrg 9592fda9279dSmrg # Get the real and link names of the library. 9593fda9279dSmrg eval shared_ext=\"$shrext_cmds\" 9594fda9279dSmrg eval library_names=\"$library_names_spec\" 9595fda9279dSmrg set dummy $library_names 9596fda9279dSmrg shift 959716ee1e9aSmrg realname=$1 9598fda9279dSmrg shift 9599fda9279dSmrg 9600fda9279dSmrg if test -n "$soname_spec"; then 9601fda9279dSmrg eval soname=\"$soname_spec\" 9602fda9279dSmrg else 960316ee1e9aSmrg soname=$realname 9604fda9279dSmrg fi 9605fda9279dSmrg if test -z "$dlname"; then 9606fda9279dSmrg dlname=$soname 9607fda9279dSmrg fi 9608fda9279dSmrg 960916ee1e9aSmrg lib=$output_objdir/$realname 9610fda9279dSmrg linknames= 9611fda9279dSmrg for link 9612fda9279dSmrg do 9613fda9279dSmrg func_append linknames " $link" 9614fda9279dSmrg done 9615fda9279dSmrg 9616fda9279dSmrg # Use standard objects if they are pic 9617fda9279dSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618fda9279dSmrg test "X$libobjs" = "X " && libobjs= 9619fda9279dSmrg 9620fda9279dSmrg delfiles= 9621fda9279dSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622fda9279dSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 962316ee1e9aSmrg export_symbols=$output_objdir/$libname.uexp 9624fda9279dSmrg func_append delfiles " $export_symbols" 9625fda9279dSmrg fi 9626fda9279dSmrg 9627fda9279dSmrg orig_export_symbols= 9628fda9279dSmrg case $host_os in 9629fda9279dSmrg cygwin* | mingw* | cegcc*) 9630fda9279dSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631fda9279dSmrg # exporting using user supplied symfile 963216ee1e9aSmrg func_dll_def_p "$export_symbols" || { 9633fda9279dSmrg # and it's NOT already a .def file. Must figure out 9634fda9279dSmrg # which of the given symbols are data symbols and tag 9635fda9279dSmrg # them as such. So, trigger use of export_symbols_cmds. 9636fda9279dSmrg # export_symbols gets reassigned inside the "prepare 9637fda9279dSmrg # the list of exported symbols" if statement, so the 9638fda9279dSmrg # include_expsyms logic still works. 963916ee1e9aSmrg orig_export_symbols=$export_symbols 9640fda9279dSmrg export_symbols= 9641fda9279dSmrg always_export_symbols=yes 964216ee1e9aSmrg } 9643fda9279dSmrg fi 9644fda9279dSmrg ;; 9645fda9279dSmrg esac 9646fda9279dSmrg 9647fda9279dSmrg # Prepare the list of exported symbols 9648fda9279dSmrg if test -z "$export_symbols"; then 964916ee1e9aSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965016ee1e9aSmrg func_verbose "generating symbol list for '$libname.la'" 965116ee1e9aSmrg export_symbols=$output_objdir/$libname.exp 9652fda9279dSmrg $opt_dry_run || $RM $export_symbols 9653fda9279dSmrg cmds=$export_symbols_cmds 965416ee1e9aSmrg save_ifs=$IFS; IFS='~' 9655fda9279dSmrg for cmd1 in $cmds; do 965616ee1e9aSmrg IFS=$save_ifs 9657fda9279dSmrg # Take the normal branch if the nm_file_list_spec branch 9658fda9279dSmrg # doesn't work or if tool conversion is not needed. 9659fda9279dSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9660fda9279dSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661fda9279dSmrg try_normal_branch=yes 9662fda9279dSmrg eval cmd=\"$cmd1\" 9663fda9279dSmrg func_len " $cmd" 9664fda9279dSmrg len=$func_len_result 9665fda9279dSmrg ;; 9666fda9279dSmrg *) 9667fda9279dSmrg try_normal_branch=no 9668fda9279dSmrg ;; 9669fda9279dSmrg esac 967016ee1e9aSmrg if test yes = "$try_normal_branch" \ 9671fda9279dSmrg && { test "$len" -lt "$max_cmd_len" \ 9672fda9279dSmrg || test "$max_cmd_len" -le -1; } 9673fda9279dSmrg then 9674fda9279dSmrg func_show_eval "$cmd" 'exit $?' 9675fda9279dSmrg skipped_export=false 9676fda9279dSmrg elif test -n "$nm_file_list_spec"; then 9677fda9279dSmrg func_basename "$output" 9678fda9279dSmrg output_la=$func_basename_result 9679fda9279dSmrg save_libobjs=$libobjs 9680fda9279dSmrg save_output=$output 968116ee1e9aSmrg output=$output_objdir/$output_la.nm 9682fda9279dSmrg func_to_tool_file "$output" 9683fda9279dSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9684fda9279dSmrg func_append delfiles " $output" 9685fda9279dSmrg func_verbose "creating $NM input file list: $output" 9686fda9279dSmrg for obj in $save_libobjs; do 9687fda9279dSmrg func_to_tool_file "$obj" 9688fda9279dSmrg $ECHO "$func_to_tool_file_result" 9689fda9279dSmrg done > "$output" 9690fda9279dSmrg eval cmd=\"$cmd1\" 9691fda9279dSmrg func_show_eval "$cmd" 'exit $?' 9692fda9279dSmrg output=$save_output 9693fda9279dSmrg libobjs=$save_libobjs 9694fda9279dSmrg skipped_export=false 9695fda9279dSmrg else 9696fda9279dSmrg # The command line is too long to execute in one step. 9697fda9279dSmrg func_verbose "using reloadable object file for export list..." 9698fda9279dSmrg skipped_export=: 9699fda9279dSmrg # Break out early, otherwise skipped_export may be 9700fda9279dSmrg # set to false by a later but shorter cmd. 9701fda9279dSmrg break 9702fda9279dSmrg fi 9703fda9279dSmrg done 970416ee1e9aSmrg IFS=$save_ifs 970516ee1e9aSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706fda9279dSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707fda9279dSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708fda9279dSmrg fi 9709fda9279dSmrg fi 9710fda9279dSmrg fi 9711fda9279dSmrg 9712fda9279dSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 971316ee1e9aSmrg tmp_export_symbols=$export_symbols 971416ee1e9aSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715fda9279dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716fda9279dSmrg fi 9717fda9279dSmrg 971816ee1e9aSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719fda9279dSmrg # The given exports_symbols file has to be filtered, so filter it. 972016ee1e9aSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721fda9279dSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 972216ee1e9aSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9723fda9279dSmrg # though. Also, the filter scales superlinearly with the number of 9724fda9279dSmrg # global variables. join(1) would be nice here, but unfortunately 9725fda9279dSmrg # isn't a blessed tool. 9726fda9279dSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727fda9279dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728fda9279dSmrg export_symbols=$output_objdir/$libname.def 9729fda9279dSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730fda9279dSmrg fi 9731fda9279dSmrg 9732fda9279dSmrg tmp_deplibs= 9733fda9279dSmrg for test_deplib in $deplibs; do 9734fda9279dSmrg case " $convenience " in 9735fda9279dSmrg *" $test_deplib "*) ;; 9736fda9279dSmrg *) 9737fda9279dSmrg func_append tmp_deplibs " $test_deplib" 9738fda9279dSmrg ;; 9739fda9279dSmrg esac 9740fda9279dSmrg done 974116ee1e9aSmrg deplibs=$tmp_deplibs 9742fda9279dSmrg 9743fda9279dSmrg if test -n "$convenience"; then 9744fda9279dSmrg if test -n "$whole_archive_flag_spec" && 974516ee1e9aSmrg test yes = "$compiler_needs_object" && 9746fda9279dSmrg test -z "$libobjs"; then 9747fda9279dSmrg # extract the archives, so we have objects to list. 9748fda9279dSmrg # TODO: could optimize this to just extract one archive. 9749fda9279dSmrg whole_archive_flag_spec= 9750fda9279dSmrg fi 9751fda9279dSmrg if test -n "$whole_archive_flag_spec"; then 9752fda9279dSmrg save_libobjs=$libobjs 9753fda9279dSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754fda9279dSmrg test "X$libobjs" = "X " && libobjs= 9755fda9279dSmrg else 975616ee1e9aSmrg gentop=$output_objdir/${outputname}x 9757fda9279dSmrg func_append generated " $gentop" 9758fda9279dSmrg 9759fda9279dSmrg func_extract_archives $gentop $convenience 9760fda9279dSmrg func_append libobjs " $func_extract_archives_result" 9761fda9279dSmrg test "X$libobjs" = "X " && libobjs= 9762fda9279dSmrg fi 9763fda9279dSmrg fi 9764fda9279dSmrg 976516ee1e9aSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766fda9279dSmrg eval flag=\"$thread_safe_flag_spec\" 9767fda9279dSmrg func_append linker_flags " $flag" 9768fda9279dSmrg fi 9769fda9279dSmrg 9770fda9279dSmrg # Make a backup of the uninstalled library when relinking 977116ee1e9aSmrg if test relink = "$opt_mode"; then 9772fda9279dSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773fda9279dSmrg fi 9774fda9279dSmrg 9775fda9279dSmrg # Do each of the archive commands. 977616ee1e9aSmrg if test yes = "$module" && test -n "$module_cmds"; then 9777fda9279dSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778fda9279dSmrg eval test_cmds=\"$module_expsym_cmds\" 9779fda9279dSmrg cmds=$module_expsym_cmds 9780fda9279dSmrg else 9781fda9279dSmrg eval test_cmds=\"$module_cmds\" 9782fda9279dSmrg cmds=$module_cmds 9783fda9279dSmrg fi 9784fda9279dSmrg else 9785fda9279dSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786fda9279dSmrg eval test_cmds=\"$archive_expsym_cmds\" 9787fda9279dSmrg cmds=$archive_expsym_cmds 9788fda9279dSmrg else 9789fda9279dSmrg eval test_cmds=\"$archive_cmds\" 9790fda9279dSmrg cmds=$archive_cmds 9791fda9279dSmrg fi 9792fda9279dSmrg fi 9793fda9279dSmrg 979416ee1e9aSmrg if test : != "$skipped_export" && 9795fda9279dSmrg func_len " $test_cmds" && 9796fda9279dSmrg len=$func_len_result && 9797fda9279dSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798fda9279dSmrg : 9799fda9279dSmrg else 9800fda9279dSmrg # The command line is too long to link in one step, link piecewise 9801fda9279dSmrg # or, if using GNU ld and skipped_export is not :, use a linker 9802fda9279dSmrg # script. 9803fda9279dSmrg 9804fda9279dSmrg # Save the value of $output and $libobjs because we want to 9805fda9279dSmrg # use them later. If we have whole_archive_flag_spec, we 9806fda9279dSmrg # want to use save_libobjs as it was before 9807fda9279dSmrg # whole_archive_flag_spec was expanded, because we can't 9808fda9279dSmrg # assume the linker understands whole_archive_flag_spec. 9809fda9279dSmrg # This may have to be revisited, in case too many 9810fda9279dSmrg # convenience libraries get linked in and end up exceeding 9811fda9279dSmrg # the spec. 9812fda9279dSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813fda9279dSmrg save_libobjs=$libobjs 9814fda9279dSmrg fi 9815fda9279dSmrg save_output=$output 9816fda9279dSmrg func_basename "$output" 9817fda9279dSmrg output_la=$func_basename_result 9818fda9279dSmrg 9819fda9279dSmrg # Clear the reloadable object creation command queue and 9820fda9279dSmrg # initialize k to one. 9821fda9279dSmrg test_cmds= 9822fda9279dSmrg concat_cmds= 9823fda9279dSmrg objlist= 9824fda9279dSmrg last_robj= 9825fda9279dSmrg k=1 9826fda9279dSmrg 982716ee1e9aSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 982816ee1e9aSmrg output=$output_objdir/$output_la.lnkscript 9829fda9279dSmrg func_verbose "creating GNU ld script: $output" 9830fda9279dSmrg echo 'INPUT (' > $output 9831fda9279dSmrg for obj in $save_libobjs 9832fda9279dSmrg do 9833fda9279dSmrg func_to_tool_file "$obj" 9834fda9279dSmrg $ECHO "$func_to_tool_file_result" >> $output 9835fda9279dSmrg done 9836fda9279dSmrg echo ')' >> $output 9837fda9279dSmrg func_append delfiles " $output" 9838fda9279dSmrg func_to_tool_file "$output" 9839fda9279dSmrg output=$func_to_tool_file_result 984016ee1e9aSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 984116ee1e9aSmrg output=$output_objdir/$output_la.lnk 9842fda9279dSmrg func_verbose "creating linker input file list: $output" 9843fda9279dSmrg : > $output 9844fda9279dSmrg set x $save_libobjs 9845fda9279dSmrg shift 9846fda9279dSmrg firstobj= 984716ee1e9aSmrg if test yes = "$compiler_needs_object"; then 9848fda9279dSmrg firstobj="$1 " 9849fda9279dSmrg shift 9850fda9279dSmrg fi 9851fda9279dSmrg for obj 9852fda9279dSmrg do 9853fda9279dSmrg func_to_tool_file "$obj" 9854fda9279dSmrg $ECHO "$func_to_tool_file_result" >> $output 9855fda9279dSmrg done 9856fda9279dSmrg func_append delfiles " $output" 9857fda9279dSmrg func_to_tool_file "$output" 9858fda9279dSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859fda9279dSmrg else 9860fda9279dSmrg if test -n "$save_libobjs"; then 9861fda9279dSmrg func_verbose "creating reloadable object files..." 986216ee1e9aSmrg output=$output_objdir/$output_la-$k.$objext 9863fda9279dSmrg eval test_cmds=\"$reload_cmds\" 9864fda9279dSmrg func_len " $test_cmds" 9865fda9279dSmrg len0=$func_len_result 9866fda9279dSmrg len=$len0 9867fda9279dSmrg 9868fda9279dSmrg # Loop over the list of objects to be linked. 9869fda9279dSmrg for obj in $save_libobjs 9870fda9279dSmrg do 9871fda9279dSmrg func_len " $obj" 9872fda9279dSmrg func_arith $len + $func_len_result 9873fda9279dSmrg len=$func_arith_result 987416ee1e9aSmrg if test -z "$objlist" || 9875fda9279dSmrg test "$len" -lt "$max_cmd_len"; then 9876fda9279dSmrg func_append objlist " $obj" 9877fda9279dSmrg else 9878fda9279dSmrg # The command $test_cmds is almost too long, add a 9879fda9279dSmrg # command to the queue. 988016ee1e9aSmrg if test 1 -eq "$k"; then 9881fda9279dSmrg # The first file doesn't have a previous command to add. 9882fda9279dSmrg reload_objs=$objlist 9883fda9279dSmrg eval concat_cmds=\"$reload_cmds\" 9884fda9279dSmrg else 9885fda9279dSmrg # All subsequent reloadable object files will link in 9886fda9279dSmrg # the last one created. 9887fda9279dSmrg reload_objs="$objlist $last_robj" 9888fda9279dSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889fda9279dSmrg fi 989016ee1e9aSmrg last_robj=$output_objdir/$output_la-$k.$objext 9891fda9279dSmrg func_arith $k + 1 9892fda9279dSmrg k=$func_arith_result 989316ee1e9aSmrg output=$output_objdir/$output_la-$k.$objext 9894fda9279dSmrg objlist=" $obj" 9895fda9279dSmrg func_len " $last_robj" 9896fda9279dSmrg func_arith $len0 + $func_len_result 9897fda9279dSmrg len=$func_arith_result 9898fda9279dSmrg fi 9899fda9279dSmrg done 9900fda9279dSmrg # Handle the remaining objects by creating one last 9901fda9279dSmrg # reloadable object file. All subsequent reloadable object 9902fda9279dSmrg # files will link in the last one created. 9903fda9279dSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904fda9279dSmrg reload_objs="$objlist $last_robj" 990516ee1e9aSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906fda9279dSmrg if test -n "$last_robj"; then 990716ee1e9aSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908fda9279dSmrg fi 9909fda9279dSmrg func_append delfiles " $output" 9910fda9279dSmrg 9911fda9279dSmrg else 9912fda9279dSmrg output= 9913fda9279dSmrg fi 9914fda9279dSmrg 991516ee1e9aSmrg ${skipped_export-false} && { 991616ee1e9aSmrg func_verbose "generating symbol list for '$libname.la'" 991716ee1e9aSmrg export_symbols=$output_objdir/$libname.exp 9918fda9279dSmrg $opt_dry_run || $RM $export_symbols 9919fda9279dSmrg libobjs=$output 9920fda9279dSmrg # Append the command to create the export file. 9921fda9279dSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922fda9279dSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923fda9279dSmrg if test -n "$last_robj"; then 9924fda9279dSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925fda9279dSmrg fi 992616ee1e9aSmrg } 9927fda9279dSmrg 9928fda9279dSmrg test -n "$save_libobjs" && 9929fda9279dSmrg func_verbose "creating a temporary reloadable object file: $output" 9930fda9279dSmrg 9931fda9279dSmrg # Loop through the commands generated above and execute them. 993216ee1e9aSmrg save_ifs=$IFS; IFS='~' 9933fda9279dSmrg for cmd in $concat_cmds; do 993416ee1e9aSmrg IFS=$save_ifs 993516ee1e9aSmrg $opt_quiet || { 9936fda9279dSmrg func_quote_for_expand "$cmd" 9937fda9279dSmrg eval "func_echo $func_quote_for_expand_result" 9938fda9279dSmrg } 9939fda9279dSmrg $opt_dry_run || eval "$cmd" || { 9940fda9279dSmrg lt_exit=$? 9941fda9279dSmrg 9942fda9279dSmrg # Restore the uninstalled library and exit 994316ee1e9aSmrg if test relink = "$opt_mode"; then 9944fda9279dSmrg ( cd "$output_objdir" && \ 9945fda9279dSmrg $RM "${realname}T" && \ 9946fda9279dSmrg $MV "${realname}U" "$realname" ) 9947fda9279dSmrg fi 9948fda9279dSmrg 9949fda9279dSmrg exit $lt_exit 9950fda9279dSmrg } 9951fda9279dSmrg done 995216ee1e9aSmrg IFS=$save_ifs 9953fda9279dSmrg 9954fda9279dSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955fda9279dSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956fda9279dSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957fda9279dSmrg fi 9958fda9279dSmrg fi 9959fda9279dSmrg 996016ee1e9aSmrg ${skipped_export-false} && { 9961fda9279dSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 996216ee1e9aSmrg tmp_export_symbols=$export_symbols 996316ee1e9aSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964fda9279dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965fda9279dSmrg fi 9966fda9279dSmrg 9967fda9279dSmrg if test -n "$orig_export_symbols"; then 9968fda9279dSmrg # The given exports_symbols file has to be filtered, so filter it. 996916ee1e9aSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970fda9279dSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 997116ee1e9aSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9972fda9279dSmrg # though. Also, the filter scales superlinearly with the number of 9973fda9279dSmrg # global variables. join(1) would be nice here, but unfortunately 9974fda9279dSmrg # isn't a blessed tool. 9975fda9279dSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976fda9279dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977fda9279dSmrg export_symbols=$output_objdir/$libname.def 9978fda9279dSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979fda9279dSmrg fi 998016ee1e9aSmrg } 9981fda9279dSmrg 9982fda9279dSmrg libobjs=$output 9983fda9279dSmrg # Restore the value of output. 9984fda9279dSmrg output=$save_output 9985fda9279dSmrg 9986fda9279dSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987fda9279dSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988fda9279dSmrg test "X$libobjs" = "X " && libobjs= 9989fda9279dSmrg fi 9990fda9279dSmrg # Expand the library linking commands again to reset the 9991fda9279dSmrg # value of $libobjs for piecewise linking. 9992fda9279dSmrg 9993fda9279dSmrg # Do each of the archive commands. 999416ee1e9aSmrg if test yes = "$module" && test -n "$module_cmds"; then 9995fda9279dSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996fda9279dSmrg cmds=$module_expsym_cmds 9997fda9279dSmrg else 9998fda9279dSmrg cmds=$module_cmds 9999fda9279dSmrg fi 10000fda9279dSmrg else 10001fda9279dSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002fda9279dSmrg cmds=$archive_expsym_cmds 10003fda9279dSmrg else 10004fda9279dSmrg cmds=$archive_cmds 10005fda9279dSmrg fi 10006fda9279dSmrg fi 10007fda9279dSmrg fi 10008fda9279dSmrg 10009fda9279dSmrg if test -n "$delfiles"; then 10010fda9279dSmrg # Append the command to remove temporary files to $cmds. 10011fda9279dSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 10012fda9279dSmrg fi 10013fda9279dSmrg 10014fda9279dSmrg # Add any objects from preloaded convenience libraries 10015fda9279dSmrg if test -n "$dlprefiles"; then 1001616ee1e9aSmrg gentop=$output_objdir/${outputname}x 10017fda9279dSmrg func_append generated " $gentop" 10018fda9279dSmrg 10019fda9279dSmrg func_extract_archives $gentop $dlprefiles 10020fda9279dSmrg func_append libobjs " $func_extract_archives_result" 10021fda9279dSmrg test "X$libobjs" = "X " && libobjs= 10022fda9279dSmrg fi 10023fda9279dSmrg 1002416ee1e9aSmrg save_ifs=$IFS; IFS='~' 10025fda9279dSmrg for cmd in $cmds; do 1002616ee1e9aSmrg IFS=$sp$nl 10027fda9279dSmrg eval cmd=\"$cmd\" 1002816ee1e9aSmrg IFS=$save_ifs 1002916ee1e9aSmrg $opt_quiet || { 10030fda9279dSmrg func_quote_for_expand "$cmd" 10031fda9279dSmrg eval "func_echo $func_quote_for_expand_result" 10032fda9279dSmrg } 10033fda9279dSmrg $opt_dry_run || eval "$cmd" || { 10034fda9279dSmrg lt_exit=$? 10035fda9279dSmrg 10036fda9279dSmrg # Restore the uninstalled library and exit 1003716ee1e9aSmrg if test relink = "$opt_mode"; then 10038fda9279dSmrg ( cd "$output_objdir" && \ 10039fda9279dSmrg $RM "${realname}T" && \ 10040fda9279dSmrg $MV "${realname}U" "$realname" ) 10041fda9279dSmrg fi 10042fda9279dSmrg 10043fda9279dSmrg exit $lt_exit 10044fda9279dSmrg } 10045fda9279dSmrg done 1004616ee1e9aSmrg IFS=$save_ifs 10047fda9279dSmrg 10048fda9279dSmrg # Restore the uninstalled library and exit 1004916ee1e9aSmrg if test relink = "$opt_mode"; then 10050fda9279dSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051fda9279dSmrg 10052fda9279dSmrg if test -n "$convenience"; then 10053fda9279dSmrg if test -z "$whole_archive_flag_spec"; then 10054fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10055fda9279dSmrg fi 10056fda9279dSmrg fi 10057fda9279dSmrg 10058fda9279dSmrg exit $EXIT_SUCCESS 10059fda9279dSmrg fi 10060fda9279dSmrg 10061fda9279dSmrg # Create links to the real library. 10062fda9279dSmrg for linkname in $linknames; do 10063fda9279dSmrg if test "$realname" != "$linkname"; then 10064fda9279dSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065fda9279dSmrg fi 10066fda9279dSmrg done 10067fda9279dSmrg 10068fda9279dSmrg # If -module or -export-dynamic was specified, set the dlname. 1006916ee1e9aSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10070fda9279dSmrg # On all known operating systems, these are identical. 1007116ee1e9aSmrg dlname=$soname 10072fda9279dSmrg fi 10073fda9279dSmrg fi 10074fda9279dSmrg ;; 10075fda9279dSmrg 10076fda9279dSmrg obj) 1007716ee1e9aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1007816ee1e9aSmrg func_warning "'-dlopen' is ignored for objects" 10079fda9279dSmrg fi 10080fda9279dSmrg 10081fda9279dSmrg case " $deplibs" in 10082fda9279dSmrg *\ -l* | *\ -L*) 1008316ee1e9aSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084fda9279dSmrg esac 10085fda9279dSmrg 10086fda9279dSmrg test -n "$rpath" && \ 1008716ee1e9aSmrg func_warning "'-rpath' is ignored for objects" 10088fda9279dSmrg 10089fda9279dSmrg test -n "$xrpath" && \ 1009016ee1e9aSmrg func_warning "'-R' is ignored for objects" 10091fda9279dSmrg 10092fda9279dSmrg test -n "$vinfo" && \ 1009316ee1e9aSmrg func_warning "'-version-info' is ignored for objects" 10094fda9279dSmrg 10095fda9279dSmrg test -n "$release" && \ 1009616ee1e9aSmrg func_warning "'-release' is ignored for objects" 10097fda9279dSmrg 10098fda9279dSmrg case $output in 10099fda9279dSmrg *.lo) 10100fda9279dSmrg test -n "$objs$old_deplibs" && \ 1010116ee1e9aSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102fda9279dSmrg 10103fda9279dSmrg libobj=$output 10104fda9279dSmrg func_lo2o "$libobj" 10105fda9279dSmrg obj=$func_lo2o_result 10106fda9279dSmrg ;; 10107fda9279dSmrg *) 10108fda9279dSmrg libobj= 1010916ee1e9aSmrg obj=$output 10110fda9279dSmrg ;; 10111fda9279dSmrg esac 10112fda9279dSmrg 10113fda9279dSmrg # Delete the old objects. 10114fda9279dSmrg $opt_dry_run || $RM $obj $libobj 10115fda9279dSmrg 10116fda9279dSmrg # Objects from convenience libraries. This assumes 10117fda9279dSmrg # single-version convenience libraries. Whenever we create 10118fda9279dSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 10119fda9279dSmrg # the extraction. 10120fda9279dSmrg reload_conv_objs= 10121fda9279dSmrg gentop= 1012216ee1e9aSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 1012316ee1e9aSmrg # whole_archive_flag_spec and hope we can get by with turning comma 1012416ee1e9aSmrg # into space. 1012516ee1e9aSmrg case $reload_cmds in 1012616ee1e9aSmrg *\$LD[\ \$]*) wl= ;; 1012716ee1e9aSmrg esac 10128fda9279dSmrg if test -n "$convenience"; then 10129fda9279dSmrg if test -n "$whole_archive_flag_spec"; then 10130fda9279dSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1013116ee1e9aSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1013216ee1e9aSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133fda9279dSmrg else 1013416ee1e9aSmrg gentop=$output_objdir/${obj}x 10135fda9279dSmrg func_append generated " $gentop" 10136fda9279dSmrg 10137fda9279dSmrg func_extract_archives $gentop $convenience 10138fda9279dSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10139fda9279dSmrg fi 10140fda9279dSmrg fi 10141fda9279dSmrg 10142fda9279dSmrg # If we're not building shared, we need to use non_pic_objs 1014316ee1e9aSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144fda9279dSmrg 10145fda9279dSmrg # Create the old-style object. 1014616ee1e9aSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147fda9279dSmrg 1014816ee1e9aSmrg output=$obj 10149fda9279dSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10150fda9279dSmrg 10151fda9279dSmrg # Exit if we aren't doing a library object file. 10152fda9279dSmrg if test -z "$libobj"; then 10153fda9279dSmrg if test -n "$gentop"; then 10154fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10155fda9279dSmrg fi 10156fda9279dSmrg 10157fda9279dSmrg exit $EXIT_SUCCESS 10158fda9279dSmrg fi 10159fda9279dSmrg 1016016ee1e9aSmrg test yes = "$build_libtool_libs" || { 10161fda9279dSmrg if test -n "$gentop"; then 10162fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10163fda9279dSmrg fi 10164fda9279dSmrg 10165fda9279dSmrg # Create an invalid libtool object if no PIC, so that we don't 10166fda9279dSmrg # accidentally link it into a program. 10167fda9279dSmrg # $show "echo timestamp > $libobj" 10168fda9279dSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169fda9279dSmrg exit $EXIT_SUCCESS 1017016ee1e9aSmrg } 10171fda9279dSmrg 1017216ee1e9aSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10173fda9279dSmrg # Only do commands if we really have different PIC objects. 10174fda9279dSmrg reload_objs="$libobjs $reload_conv_objs" 1017516ee1e9aSmrg output=$libobj 10176fda9279dSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10177fda9279dSmrg fi 10178fda9279dSmrg 10179fda9279dSmrg if test -n "$gentop"; then 10180fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10181fda9279dSmrg fi 10182fda9279dSmrg 10183fda9279dSmrg exit $EXIT_SUCCESS 10184fda9279dSmrg ;; 10185fda9279dSmrg 10186fda9279dSmrg prog) 10187fda9279dSmrg case $host in 10188fda9279dSmrg *cygwin*) func_stripname '' '.exe' "$output" 10189fda9279dSmrg output=$func_stripname_result.exe;; 10190fda9279dSmrg esac 10191fda9279dSmrg test -n "$vinfo" && \ 1019216ee1e9aSmrg func_warning "'-version-info' is ignored for programs" 10193fda9279dSmrg 10194fda9279dSmrg test -n "$release" && \ 1019516ee1e9aSmrg func_warning "'-release' is ignored for programs" 10196fda9279dSmrg 1019716ee1e9aSmrg $preload \ 1019816ee1e9aSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1019916ee1e9aSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200fda9279dSmrg 10201fda9279dSmrg case $host in 10202fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 10203fda9279dSmrg # On Rhapsody replace the C library is the System framework 10204fda9279dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205fda9279dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206fda9279dSmrg ;; 10207fda9279dSmrg esac 10208fda9279dSmrg 10209fda9279dSmrg case $host in 10210fda9279dSmrg *-*-darwin*) 10211fda9279dSmrg # Don't allow lazy linking, it breaks C++ global constructors 10212fda9279dSmrg # But is supposedly fixed on 10.4 or later (yay!). 1021316ee1e9aSmrg if test CXX = "$tagname"; then 10214fda9279dSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215fda9279dSmrg 10.[0123]) 1021616ee1e9aSmrg func_append compile_command " $wl-bind_at_load" 1021716ee1e9aSmrg func_append finalize_command " $wl-bind_at_load" 10218fda9279dSmrg ;; 10219fda9279dSmrg esac 10220fda9279dSmrg fi 10221fda9279dSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222fda9279dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223fda9279dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224fda9279dSmrg ;; 10225fda9279dSmrg esac 10226fda9279dSmrg 10227fda9279dSmrg 10228fda9279dSmrg # move library search paths that coincide with paths to not yet 10229fda9279dSmrg # installed libraries to the beginning of the library search list 10230fda9279dSmrg new_libs= 10231fda9279dSmrg for path in $notinst_path; do 10232fda9279dSmrg case " $new_libs " in 10233fda9279dSmrg *" -L$path/$objdir "*) ;; 10234fda9279dSmrg *) 10235fda9279dSmrg case " $compile_deplibs " in 10236fda9279dSmrg *" -L$path/$objdir "*) 10237fda9279dSmrg func_append new_libs " -L$path/$objdir" ;; 10238fda9279dSmrg esac 10239fda9279dSmrg ;; 10240fda9279dSmrg esac 10241fda9279dSmrg done 10242fda9279dSmrg for deplib in $compile_deplibs; do 10243fda9279dSmrg case $deplib in 10244fda9279dSmrg -L*) 10245fda9279dSmrg case " $new_libs " in 10246fda9279dSmrg *" $deplib "*) ;; 10247fda9279dSmrg *) func_append new_libs " $deplib" ;; 10248fda9279dSmrg esac 10249fda9279dSmrg ;; 10250fda9279dSmrg *) func_append new_libs " $deplib" ;; 10251fda9279dSmrg esac 10252fda9279dSmrg done 1025316ee1e9aSmrg compile_deplibs=$new_libs 10254fda9279dSmrg 10255fda9279dSmrg 10256fda9279dSmrg func_append compile_command " $compile_deplibs" 10257fda9279dSmrg func_append finalize_command " $finalize_deplibs" 10258fda9279dSmrg 10259fda9279dSmrg if test -n "$rpath$xrpath"; then 10260fda9279dSmrg # If the user specified any rpath flags, then add them. 10261fda9279dSmrg for libdir in $rpath $xrpath; do 10262fda9279dSmrg # This is the magic to use -rpath. 10263fda9279dSmrg case "$finalize_rpath " in 10264fda9279dSmrg *" $libdir "*) ;; 10265fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 10266fda9279dSmrg esac 10267fda9279dSmrg done 10268fda9279dSmrg fi 10269fda9279dSmrg 10270fda9279dSmrg # Now hardcode the library paths 10271fda9279dSmrg rpath= 10272fda9279dSmrg hardcode_libdirs= 10273fda9279dSmrg for libdir in $compile_rpath $finalize_rpath; do 10274fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 10275fda9279dSmrg if test -n "$hardcode_libdir_separator"; then 10276fda9279dSmrg if test -z "$hardcode_libdirs"; then 1027716ee1e9aSmrg hardcode_libdirs=$libdir 10278fda9279dSmrg else 10279fda9279dSmrg # Just accumulate the unique libdirs. 10280fda9279dSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281fda9279dSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282fda9279dSmrg ;; 10283fda9279dSmrg *) 10284fda9279dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285fda9279dSmrg ;; 10286fda9279dSmrg esac 10287fda9279dSmrg fi 10288fda9279dSmrg else 10289fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10290fda9279dSmrg func_append rpath " $flag" 10291fda9279dSmrg fi 10292fda9279dSmrg elif test -n "$runpath_var"; then 10293fda9279dSmrg case "$perm_rpath " in 10294fda9279dSmrg *" $libdir "*) ;; 10295fda9279dSmrg *) func_append perm_rpath " $libdir" ;; 10296fda9279dSmrg esac 10297fda9279dSmrg fi 10298fda9279dSmrg case $host in 10299fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030016ee1e9aSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301fda9279dSmrg case :$dllsearchpath: in 10302fda9279dSmrg *":$libdir:"*) ;; 10303fda9279dSmrg ::) dllsearchpath=$libdir;; 10304fda9279dSmrg *) func_append dllsearchpath ":$libdir";; 10305fda9279dSmrg esac 10306fda9279dSmrg case :$dllsearchpath: in 10307fda9279dSmrg *":$testbindir:"*) ;; 10308fda9279dSmrg ::) dllsearchpath=$testbindir;; 10309fda9279dSmrg *) func_append dllsearchpath ":$testbindir";; 10310fda9279dSmrg esac 10311fda9279dSmrg ;; 10312fda9279dSmrg esac 10313fda9279dSmrg done 10314fda9279dSmrg # Substitute the hardcoded libdirs into the rpath. 10315fda9279dSmrg if test -n "$hardcode_libdir_separator" && 10316fda9279dSmrg test -n "$hardcode_libdirs"; then 1031716ee1e9aSmrg libdir=$hardcode_libdirs 10318fda9279dSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10319fda9279dSmrg fi 1032016ee1e9aSmrg compile_rpath=$rpath 10321fda9279dSmrg 10322fda9279dSmrg rpath= 10323fda9279dSmrg hardcode_libdirs= 10324fda9279dSmrg for libdir in $finalize_rpath; do 10325fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 10326fda9279dSmrg if test -n "$hardcode_libdir_separator"; then 10327fda9279dSmrg if test -z "$hardcode_libdirs"; then 1032816ee1e9aSmrg hardcode_libdirs=$libdir 10329fda9279dSmrg else 10330fda9279dSmrg # Just accumulate the unique libdirs. 10331fda9279dSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332fda9279dSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333fda9279dSmrg ;; 10334fda9279dSmrg *) 10335fda9279dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336fda9279dSmrg ;; 10337fda9279dSmrg esac 10338fda9279dSmrg fi 10339fda9279dSmrg else 10340fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10341fda9279dSmrg func_append rpath " $flag" 10342fda9279dSmrg fi 10343fda9279dSmrg elif test -n "$runpath_var"; then 10344fda9279dSmrg case "$finalize_perm_rpath " in 10345fda9279dSmrg *" $libdir "*) ;; 10346fda9279dSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10347fda9279dSmrg esac 10348fda9279dSmrg fi 10349fda9279dSmrg done 10350fda9279dSmrg # Substitute the hardcoded libdirs into the rpath. 10351fda9279dSmrg if test -n "$hardcode_libdir_separator" && 10352fda9279dSmrg test -n "$hardcode_libdirs"; then 1035316ee1e9aSmrg libdir=$hardcode_libdirs 10354fda9279dSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10355fda9279dSmrg fi 1035616ee1e9aSmrg finalize_rpath=$rpath 10357fda9279dSmrg 1035816ee1e9aSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359fda9279dSmrg # Transform all the library objects into standard objects. 10360fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362fda9279dSmrg fi 10363fda9279dSmrg 1036416ee1e9aSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365fda9279dSmrg 10366fda9279dSmrg # template prelinking step 10367fda9279dSmrg if test -n "$prelink_cmds"; then 10368fda9279dSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 10369fda9279dSmrg fi 10370fda9279dSmrg 1037116ee1e9aSmrg wrappers_required=: 10372fda9279dSmrg case $host in 10373fda9279dSmrg *cegcc* | *mingw32ce*) 10374fda9279dSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1037516ee1e9aSmrg wrappers_required=false 10376fda9279dSmrg ;; 10377fda9279dSmrg *cygwin* | *mingw* ) 1037816ee1e9aSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10379fda9279dSmrg ;; 10380fda9279dSmrg *) 1038116ee1e9aSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1038216ee1e9aSmrg wrappers_required=false 10383fda9279dSmrg fi 10384fda9279dSmrg ;; 10385fda9279dSmrg esac 1038616ee1e9aSmrg $wrappers_required || { 10387fda9279dSmrg # Replace the output file specification. 10388fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1038916ee1e9aSmrg link_command=$compile_command$compile_rpath 10390fda9279dSmrg 10391fda9279dSmrg # We have no uninstalled library dependencies, so finalize right now. 10392fda9279dSmrg exit_status=0 10393fda9279dSmrg func_show_eval "$link_command" 'exit_status=$?' 10394fda9279dSmrg 10395fda9279dSmrg if test -n "$postlink_cmds"; then 10396fda9279dSmrg func_to_tool_file "$output" 10397fda9279dSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398fda9279dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10399fda9279dSmrg fi 10400fda9279dSmrg 10401fda9279dSmrg # Delete the generated files. 1040216ee1e9aSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 1040316ee1e9aSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404fda9279dSmrg fi 10405fda9279dSmrg 10406fda9279dSmrg exit $exit_status 1040716ee1e9aSmrg } 10408fda9279dSmrg 10409fda9279dSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410fda9279dSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411fda9279dSmrg fi 10412fda9279dSmrg if test -n "$finalize_shlibpath"; then 10413fda9279dSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414fda9279dSmrg fi 10415fda9279dSmrg 10416fda9279dSmrg compile_var= 10417fda9279dSmrg finalize_var= 10418fda9279dSmrg if test -n "$runpath_var"; then 10419fda9279dSmrg if test -n "$perm_rpath"; then 10420fda9279dSmrg # We should set the runpath_var. 10421fda9279dSmrg rpath= 10422fda9279dSmrg for dir in $perm_rpath; do 10423fda9279dSmrg func_append rpath "$dir:" 10424fda9279dSmrg done 10425fda9279dSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426fda9279dSmrg fi 10427fda9279dSmrg if test -n "$finalize_perm_rpath"; then 10428fda9279dSmrg # We should set the runpath_var. 10429fda9279dSmrg rpath= 10430fda9279dSmrg for dir in $finalize_perm_rpath; do 10431fda9279dSmrg func_append rpath "$dir:" 10432fda9279dSmrg done 10433fda9279dSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434fda9279dSmrg fi 10435fda9279dSmrg fi 10436fda9279dSmrg 1043716ee1e9aSmrg if test yes = "$no_install"; then 10438fda9279dSmrg # We don't need to create a wrapper script. 1043916ee1e9aSmrg link_command=$compile_var$compile_command$compile_rpath 10440fda9279dSmrg # Replace the output file specification. 10441fda9279dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442fda9279dSmrg # Delete the old output file. 10443fda9279dSmrg $opt_dry_run || $RM $output 10444fda9279dSmrg # Link the executable and exit 10445fda9279dSmrg func_show_eval "$link_command" 'exit $?' 10446fda9279dSmrg 10447fda9279dSmrg if test -n "$postlink_cmds"; then 10448fda9279dSmrg func_to_tool_file "$output" 10449fda9279dSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450fda9279dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10451fda9279dSmrg fi 10452fda9279dSmrg 10453fda9279dSmrg exit $EXIT_SUCCESS 10454fda9279dSmrg fi 10455fda9279dSmrg 1045616ee1e9aSmrg case $hardcode_action,$fast_install in 1045716ee1e9aSmrg relink,*) 1045816ee1e9aSmrg # Fast installation is not supported 1045916ee1e9aSmrg link_command=$compile_var$compile_command$compile_rpath 1046016ee1e9aSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10461fda9279dSmrg 1046216ee1e9aSmrg func_warning "this platform does not like uninstalled shared libraries" 1046316ee1e9aSmrg func_warning "'$output' will be relinked during installation" 1046416ee1e9aSmrg ;; 1046516ee1e9aSmrg *,yes) 1046616ee1e9aSmrg link_command=$finalize_var$compile_command$finalize_rpath 1046716ee1e9aSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1046816ee1e9aSmrg ;; 1046916ee1e9aSmrg *,no) 1047016ee1e9aSmrg link_command=$compile_var$compile_command$compile_rpath 1047116ee1e9aSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1047216ee1e9aSmrg ;; 1047316ee1e9aSmrg *,needless) 1047416ee1e9aSmrg link_command=$finalize_var$compile_command$finalize_rpath 1047516ee1e9aSmrg relink_command= 1047616ee1e9aSmrg ;; 1047716ee1e9aSmrg esac 10478fda9279dSmrg 10479fda9279dSmrg # Replace the output file specification. 10480fda9279dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481fda9279dSmrg 10482fda9279dSmrg # Delete the old output files. 10483fda9279dSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484fda9279dSmrg 10485fda9279dSmrg func_show_eval "$link_command" 'exit $?' 10486fda9279dSmrg 10487fda9279dSmrg if test -n "$postlink_cmds"; then 10488fda9279dSmrg func_to_tool_file "$output_objdir/$outputname" 10489fda9279dSmrg 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'` 10490fda9279dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10491fda9279dSmrg fi 10492fda9279dSmrg 10493fda9279dSmrg # Now create the wrapper script. 10494fda9279dSmrg func_verbose "creating $output" 10495fda9279dSmrg 10496fda9279dSmrg # Quote the relink command for shipping. 10497fda9279dSmrg if test -n "$relink_command"; then 10498fda9279dSmrg # Preserve any variables that may affect compiler behavior 10499fda9279dSmrg for var in $variables_saved_for_relink; do 10500fda9279dSmrg if eval test -z \"\${$var+set}\"; then 10501fda9279dSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502fda9279dSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10503fda9279dSmrg relink_command="$var=; export $var; $relink_command" 10504fda9279dSmrg else 10505fda9279dSmrg func_quote_for_eval "$var_value" 10506fda9279dSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507fda9279dSmrg fi 10508fda9279dSmrg done 10509fda9279dSmrg relink_command="(cd `pwd`; $relink_command)" 10510fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511fda9279dSmrg fi 10512fda9279dSmrg 10513fda9279dSmrg # Only actually do things if not in dry run mode. 10514fda9279dSmrg $opt_dry_run || { 10515fda9279dSmrg # win32 will think the script is a binary if it has 10516fda9279dSmrg # a .exe suffix, so we strip it off here. 10517fda9279dSmrg case $output in 10518fda9279dSmrg *.exe) func_stripname '' '.exe' "$output" 10519fda9279dSmrg output=$func_stripname_result ;; 10520fda9279dSmrg esac 10521fda9279dSmrg # test for cygwin because mv fails w/o .exe extensions 10522fda9279dSmrg case $host in 10523fda9279dSmrg *cygwin*) 10524fda9279dSmrg exeext=.exe 10525fda9279dSmrg func_stripname '' '.exe' "$outputname" 10526fda9279dSmrg outputname=$func_stripname_result ;; 10527fda9279dSmrg *) exeext= ;; 10528fda9279dSmrg esac 10529fda9279dSmrg case $host in 10530fda9279dSmrg *cygwin* | *mingw* ) 10531fda9279dSmrg func_dirname_and_basename "$output" "" "." 10532fda9279dSmrg output_name=$func_basename_result 10533fda9279dSmrg output_path=$func_dirname_result 1053416ee1e9aSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1053516ee1e9aSmrg cwrapper=$output_path/$output_name.exe 10536fda9279dSmrg $RM $cwrappersource $cwrapper 10537fda9279dSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538fda9279dSmrg 10539fda9279dSmrg func_emit_cwrapperexe_src > $cwrappersource 10540fda9279dSmrg 10541fda9279dSmrg # The wrapper executable is built using the $host compiler, 10542fda9279dSmrg # because it contains $host paths and files. If cross- 10543fda9279dSmrg # compiling, it, like the target executable, must be 10544fda9279dSmrg # executed on the $host or under an emulation environment. 10545fda9279dSmrg $opt_dry_run || { 10546fda9279dSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547fda9279dSmrg $STRIP $cwrapper 10548fda9279dSmrg } 10549fda9279dSmrg 10550fda9279dSmrg # Now, create the wrapper script for func_source use: 10551fda9279dSmrg func_ltwrapper_scriptname $cwrapper 10552fda9279dSmrg $RM $func_ltwrapper_scriptname_result 10553fda9279dSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554fda9279dSmrg $opt_dry_run || { 10555fda9279dSmrg # note: this script will not be executed, so do not chmod. 1055616ee1e9aSmrg if test "x$build" = "x$host"; then 10557fda9279dSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558fda9279dSmrg else 10559fda9279dSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560fda9279dSmrg fi 10561fda9279dSmrg } 10562fda9279dSmrg ;; 10563fda9279dSmrg * ) 10564fda9279dSmrg $RM $output 10565fda9279dSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566fda9279dSmrg 10567fda9279dSmrg func_emit_wrapper no > $output 10568fda9279dSmrg chmod +x $output 10569fda9279dSmrg ;; 10570fda9279dSmrg esac 10571fda9279dSmrg } 10572fda9279dSmrg exit $EXIT_SUCCESS 10573fda9279dSmrg ;; 10574fda9279dSmrg esac 10575fda9279dSmrg 10576fda9279dSmrg # See if we need to build an old-fashioned archive. 10577fda9279dSmrg for oldlib in $oldlibs; do 10578fda9279dSmrg 1057916ee1e9aSmrg case $build_libtool_libs in 1058016ee1e9aSmrg convenience) 1058116ee1e9aSmrg oldobjs="$libobjs_save $symfileobj" 1058216ee1e9aSmrg addlibs=$convenience 10583fda9279dSmrg build_libtool_libs=no 1058416ee1e9aSmrg ;; 1058516ee1e9aSmrg module) 1058616ee1e9aSmrg oldobjs=$libobjs_save 1058716ee1e9aSmrg addlibs=$old_convenience 1058816ee1e9aSmrg build_libtool_libs=no 1058916ee1e9aSmrg ;; 1059016ee1e9aSmrg *) 10591fda9279dSmrg oldobjs="$old_deplibs $non_pic_objects" 1059216ee1e9aSmrg $preload && test -f "$symfileobj" \ 1059316ee1e9aSmrg && func_append oldobjs " $symfileobj" 1059416ee1e9aSmrg addlibs=$old_convenience 1059516ee1e9aSmrg ;; 1059616ee1e9aSmrg esac 10597fda9279dSmrg 10598fda9279dSmrg if test -n "$addlibs"; then 1059916ee1e9aSmrg gentop=$output_objdir/${outputname}x 10600fda9279dSmrg func_append generated " $gentop" 10601fda9279dSmrg 10602fda9279dSmrg func_extract_archives $gentop $addlibs 10603fda9279dSmrg func_append oldobjs " $func_extract_archives_result" 10604fda9279dSmrg fi 10605fda9279dSmrg 10606fda9279dSmrg # Do each command in the archive commands. 1060716ee1e9aSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608fda9279dSmrg cmds=$old_archive_from_new_cmds 10609fda9279dSmrg else 10610fda9279dSmrg 10611fda9279dSmrg # Add any objects from preloaded convenience libraries 10612fda9279dSmrg if test -n "$dlprefiles"; then 1061316ee1e9aSmrg gentop=$output_objdir/${outputname}x 10614fda9279dSmrg func_append generated " $gentop" 10615fda9279dSmrg 10616fda9279dSmrg func_extract_archives $gentop $dlprefiles 10617fda9279dSmrg func_append oldobjs " $func_extract_archives_result" 10618fda9279dSmrg fi 10619fda9279dSmrg 10620fda9279dSmrg # POSIX demands no paths to be encoded in archives. We have 10621fda9279dSmrg # to avoid creating archives with duplicate basenames if we 10622fda9279dSmrg # might have to extract them afterwards, e.g., when creating a 10623fda9279dSmrg # static archive out of a convenience library, or when linking 10624fda9279dSmrg # the entirety of a libtool archive into another (currently 10625fda9279dSmrg # not supported by libtool). 10626fda9279dSmrg if (for obj in $oldobjs 10627fda9279dSmrg do 10628fda9279dSmrg func_basename "$obj" 10629fda9279dSmrg $ECHO "$func_basename_result" 10630fda9279dSmrg done | sort | sort -uc >/dev/null 2>&1); then 10631fda9279dSmrg : 10632fda9279dSmrg else 10633fda9279dSmrg echo "copying selected object files to avoid basename conflicts..." 1063416ee1e9aSmrg gentop=$output_objdir/${outputname}x 10635fda9279dSmrg func_append generated " $gentop" 10636fda9279dSmrg func_mkdir_p "$gentop" 10637fda9279dSmrg save_oldobjs=$oldobjs 10638fda9279dSmrg oldobjs= 10639fda9279dSmrg counter=1 10640fda9279dSmrg for obj in $save_oldobjs 10641fda9279dSmrg do 10642fda9279dSmrg func_basename "$obj" 1064316ee1e9aSmrg objbase=$func_basename_result 10644fda9279dSmrg case " $oldobjs " in 10645fda9279dSmrg " ") oldobjs=$obj ;; 10646fda9279dSmrg *[\ /]"$objbase "*) 10647fda9279dSmrg while :; do 10648fda9279dSmrg # Make sure we don't pick an alternate name that also 10649fda9279dSmrg # overlaps. 10650fda9279dSmrg newobj=lt$counter-$objbase 10651fda9279dSmrg func_arith $counter + 1 10652fda9279dSmrg counter=$func_arith_result 10653fda9279dSmrg case " $oldobjs " in 10654fda9279dSmrg *[\ /]"$newobj "*) ;; 10655fda9279dSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656fda9279dSmrg esac 10657fda9279dSmrg done 10658fda9279dSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659fda9279dSmrg func_append oldobjs " $gentop/$newobj" 10660fda9279dSmrg ;; 10661fda9279dSmrg *) func_append oldobjs " $obj" ;; 10662fda9279dSmrg esac 10663fda9279dSmrg done 10664fda9279dSmrg fi 10665fda9279dSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666fda9279dSmrg tool_oldlib=$func_to_tool_file_result 10667fda9279dSmrg eval cmds=\"$old_archive_cmds\" 10668fda9279dSmrg 10669fda9279dSmrg func_len " $cmds" 10670fda9279dSmrg len=$func_len_result 10671fda9279dSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672fda9279dSmrg cmds=$old_archive_cmds 10673fda9279dSmrg elif test -n "$archiver_list_spec"; then 10674fda9279dSmrg func_verbose "using command file archive linking..." 10675fda9279dSmrg for obj in $oldobjs 10676fda9279dSmrg do 10677fda9279dSmrg func_to_tool_file "$obj" 10678fda9279dSmrg $ECHO "$func_to_tool_file_result" 10679fda9279dSmrg done > $output_objdir/$libname.libcmd 10680fda9279dSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10681fda9279dSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682fda9279dSmrg cmds=$old_archive_cmds 10683fda9279dSmrg else 10684fda9279dSmrg # the command line is too long to link in one step, link in parts 10685fda9279dSmrg func_verbose "using piecewise archive linking..." 10686fda9279dSmrg save_RANLIB=$RANLIB 10687fda9279dSmrg RANLIB=: 10688fda9279dSmrg objlist= 10689fda9279dSmrg concat_cmds= 10690fda9279dSmrg save_oldobjs=$oldobjs 10691fda9279dSmrg oldobjs= 10692fda9279dSmrg # Is there a better way of finding the last object in the list? 10693fda9279dSmrg for obj in $save_oldobjs 10694fda9279dSmrg do 10695fda9279dSmrg last_oldobj=$obj 10696fda9279dSmrg done 10697fda9279dSmrg eval test_cmds=\"$old_archive_cmds\" 10698fda9279dSmrg func_len " $test_cmds" 10699fda9279dSmrg len0=$func_len_result 10700fda9279dSmrg len=$len0 10701fda9279dSmrg for obj in $save_oldobjs 10702fda9279dSmrg do 10703fda9279dSmrg func_len " $obj" 10704fda9279dSmrg func_arith $len + $func_len_result 10705fda9279dSmrg len=$func_arith_result 10706fda9279dSmrg func_append objlist " $obj" 10707fda9279dSmrg if test "$len" -lt "$max_cmd_len"; then 10708fda9279dSmrg : 10709fda9279dSmrg else 10710fda9279dSmrg # the above command should be used before it gets too long 10711fda9279dSmrg oldobjs=$objlist 1071216ee1e9aSmrg if test "$obj" = "$last_oldobj"; then 10713fda9279dSmrg RANLIB=$save_RANLIB 10714fda9279dSmrg fi 10715fda9279dSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1071616ee1e9aSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717fda9279dSmrg objlist= 10718fda9279dSmrg len=$len0 10719fda9279dSmrg fi 10720fda9279dSmrg done 10721fda9279dSmrg RANLIB=$save_RANLIB 10722fda9279dSmrg oldobjs=$objlist 1072316ee1e9aSmrg if test -z "$oldobjs"; then 10724fda9279dSmrg eval cmds=\"\$concat_cmds\" 10725fda9279dSmrg else 10726fda9279dSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727fda9279dSmrg fi 10728fda9279dSmrg fi 10729fda9279dSmrg fi 10730fda9279dSmrg func_execute_cmds "$cmds" 'exit $?' 10731fda9279dSmrg done 10732fda9279dSmrg 10733fda9279dSmrg test -n "$generated" && \ 10734fda9279dSmrg func_show_eval "${RM}r$generated" 10735fda9279dSmrg 10736fda9279dSmrg # Now create the libtool archive. 10737fda9279dSmrg case $output in 10738fda9279dSmrg *.la) 10739fda9279dSmrg old_library= 1074016ee1e9aSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10741fda9279dSmrg func_verbose "creating $output" 10742fda9279dSmrg 10743fda9279dSmrg # Preserve any variables that may affect compiler behavior 10744fda9279dSmrg for var in $variables_saved_for_relink; do 10745fda9279dSmrg if eval test -z \"\${$var+set}\"; then 10746fda9279dSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747fda9279dSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10748fda9279dSmrg relink_command="$var=; export $var; $relink_command" 10749fda9279dSmrg else 10750fda9279dSmrg func_quote_for_eval "$var_value" 10751fda9279dSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752fda9279dSmrg fi 10753fda9279dSmrg done 10754fda9279dSmrg # Quote the link command for shipping. 1075516ee1e9aSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10756fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1075716ee1e9aSmrg if test yes = "$hardcode_automatic"; then 10758fda9279dSmrg relink_command= 10759fda9279dSmrg fi 10760fda9279dSmrg 10761fda9279dSmrg # Only create the output if not a dry run. 10762fda9279dSmrg $opt_dry_run || { 10763fda9279dSmrg for installed in no yes; do 1076416ee1e9aSmrg if test yes = "$installed"; then 10765fda9279dSmrg if test -z "$install_libdir"; then 10766fda9279dSmrg break 10767fda9279dSmrg fi 1076816ee1e9aSmrg output=$output_objdir/${outputname}i 10769fda9279dSmrg # Replace all uninstalled libtool libraries with the installed ones 10770fda9279dSmrg newdependency_libs= 10771fda9279dSmrg for deplib in $dependency_libs; do 10772fda9279dSmrg case $deplib in 10773fda9279dSmrg *.la) 10774fda9279dSmrg func_basename "$deplib" 1077516ee1e9aSmrg name=$func_basename_result 10776fda9279dSmrg func_resolve_sysroot "$deplib" 1077716ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778fda9279dSmrg test -z "$libdir" && \ 1077916ee1e9aSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 10780fda9279dSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781fda9279dSmrg ;; 10782fda9279dSmrg -L*) 10783fda9279dSmrg func_stripname -L '' "$deplib" 10784fda9279dSmrg func_replace_sysroot "$func_stripname_result" 10785fda9279dSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10786fda9279dSmrg ;; 10787fda9279dSmrg -R*) 10788fda9279dSmrg func_stripname -R '' "$deplib" 10789fda9279dSmrg func_replace_sysroot "$func_stripname_result" 10790fda9279dSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10791fda9279dSmrg ;; 10792fda9279dSmrg *) func_append newdependency_libs " $deplib" ;; 10793fda9279dSmrg esac 10794fda9279dSmrg done 1079516ee1e9aSmrg dependency_libs=$newdependency_libs 10796fda9279dSmrg newdlfiles= 10797fda9279dSmrg 10798fda9279dSmrg for lib in $dlfiles; do 10799fda9279dSmrg case $lib in 10800fda9279dSmrg *.la) 10801fda9279dSmrg func_basename "$lib" 1080216ee1e9aSmrg name=$func_basename_result 1080316ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804fda9279dSmrg test -z "$libdir" && \ 1080516ee1e9aSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10806fda9279dSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807fda9279dSmrg ;; 10808fda9279dSmrg *) func_append newdlfiles " $lib" ;; 10809fda9279dSmrg esac 10810fda9279dSmrg done 1081116ee1e9aSmrg dlfiles=$newdlfiles 10812fda9279dSmrg newdlprefiles= 10813fda9279dSmrg for lib in $dlprefiles; do 10814fda9279dSmrg case $lib in 10815fda9279dSmrg *.la) 10816fda9279dSmrg # Only pass preopened files to the pseudo-archive (for 10817fda9279dSmrg # eventual linking with the app. that links it) if we 10818fda9279dSmrg # didn't already link the preopened objects directly into 10819fda9279dSmrg # the library: 10820fda9279dSmrg func_basename "$lib" 1082116ee1e9aSmrg name=$func_basename_result 1082216ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823fda9279dSmrg test -z "$libdir" && \ 1082416ee1e9aSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10825fda9279dSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826fda9279dSmrg ;; 10827fda9279dSmrg esac 10828fda9279dSmrg done 1082916ee1e9aSmrg dlprefiles=$newdlprefiles 10830fda9279dSmrg else 10831fda9279dSmrg newdlfiles= 10832fda9279dSmrg for lib in $dlfiles; do 10833fda9279dSmrg case $lib in 1083416ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835fda9279dSmrg *) abs=`pwd`"/$lib" ;; 10836fda9279dSmrg esac 10837fda9279dSmrg func_append newdlfiles " $abs" 10838fda9279dSmrg done 1083916ee1e9aSmrg dlfiles=$newdlfiles 10840fda9279dSmrg newdlprefiles= 10841fda9279dSmrg for lib in $dlprefiles; do 10842fda9279dSmrg case $lib in 1084316ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844fda9279dSmrg *) abs=`pwd`"/$lib" ;; 10845fda9279dSmrg esac 10846fda9279dSmrg func_append newdlprefiles " $abs" 10847fda9279dSmrg done 1084816ee1e9aSmrg dlprefiles=$newdlprefiles 10849fda9279dSmrg fi 10850fda9279dSmrg $RM $output 10851fda9279dSmrg # place dlname in correct position for cygwin 10852fda9279dSmrg # In fact, it would be nice if we could use this code for all target 10853fda9279dSmrg # systems that can't hard-code library paths into their executables 10854fda9279dSmrg # and that have no shared library path variable independent of PATH, 10855fda9279dSmrg # but it turns out we can't easily determine that from inspecting 10856fda9279dSmrg # libtool variables, so we have to hard-code the OSs to which it 10857fda9279dSmrg # applies here; at the moment, that means platforms that use the PE 10858fda9279dSmrg # object format with DLL files. See the long comment at the top of 10859fda9279dSmrg # tests/bindir.at for full details. 10860fda9279dSmrg tdlname=$dlname 10861fda9279dSmrg case $host,$output,$installed,$module,$dlname in 10862fda9279dSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863fda9279dSmrg # If a -bindir argument was supplied, place the dll there. 1086416ee1e9aSmrg if test -n "$bindir"; then 10865fda9279dSmrg func_relative_path "$install_libdir" "$bindir" 1086616ee1e9aSmrg tdlname=$func_relative_path_result/$dlname 10867fda9279dSmrg else 10868fda9279dSmrg # Otherwise fall back on heuristic. 10869fda9279dSmrg tdlname=../bin/$dlname 10870fda9279dSmrg fi 10871fda9279dSmrg ;; 10872fda9279dSmrg esac 10873fda9279dSmrg $ECHO > $output "\ 10874fda9279dSmrg# $outputname - a libtool library file 1087516ee1e9aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876fda9279dSmrg# 10877fda9279dSmrg# Please DO NOT delete this file! 10878fda9279dSmrg# It is necessary for linking the library. 10879fda9279dSmrg 10880fda9279dSmrg# The name that we can dlopen(3). 10881fda9279dSmrgdlname='$tdlname' 10882fda9279dSmrg 10883fda9279dSmrg# Names of this library. 10884fda9279dSmrglibrary_names='$library_names' 10885fda9279dSmrg 10886fda9279dSmrg# The name of the static archive. 10887fda9279dSmrgold_library='$old_library' 10888fda9279dSmrg 1088916ee1e9aSmrg# Linker flags that cannot go in dependency_libs. 10890fda9279dSmrginherited_linker_flags='$new_inherited_linker_flags' 10891fda9279dSmrg 10892fda9279dSmrg# Libraries that this one depends upon. 10893fda9279dSmrgdependency_libs='$dependency_libs' 10894fda9279dSmrg 10895fda9279dSmrg# Names of additional weak libraries provided by this library 10896fda9279dSmrgweak_library_names='$weak_libs' 10897fda9279dSmrg 10898fda9279dSmrg# Version information for $libname. 10899fda9279dSmrgcurrent=$current 10900fda9279dSmrgage=$age 10901fda9279dSmrgrevision=$revision 10902fda9279dSmrg 10903fda9279dSmrg# Is this an already installed library? 10904fda9279dSmrginstalled=$installed 10905fda9279dSmrg 10906fda9279dSmrg# Should we warn about portability when linking against -modules? 10907fda9279dSmrgshouldnotlink=$module 10908fda9279dSmrg 10909fda9279dSmrg# Files to dlopen/dlpreopen 10910fda9279dSmrgdlopen='$dlfiles' 10911fda9279dSmrgdlpreopen='$dlprefiles' 10912fda9279dSmrg 10913fda9279dSmrg# Directory that this library needs to be installed in: 10914fda9279dSmrglibdir='$install_libdir'" 1091516ee1e9aSmrg if test no,yes = "$installed,$need_relink"; then 10916fda9279dSmrg $ECHO >> $output "\ 10917fda9279dSmrgrelink_command=\"$relink_command\"" 10918fda9279dSmrg fi 10919fda9279dSmrg done 10920fda9279dSmrg } 10921fda9279dSmrg 10922fda9279dSmrg # Do a symbolic link so that the libtool archive can be found in 10923fda9279dSmrg # LD_LIBRARY_PATH before the program is installed. 10924fda9279dSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925fda9279dSmrg ;; 10926fda9279dSmrg esac 10927fda9279dSmrg exit $EXIT_SUCCESS 10928fda9279dSmrg} 10929fda9279dSmrg 1093016ee1e9aSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1093116ee1e9aSmrg func_mode_link ${1+"$@"} 1093216ee1e9aSmrgfi 10933fda9279dSmrg 10934fda9279dSmrg 10935fda9279dSmrg# func_mode_uninstall arg... 10936fda9279dSmrgfunc_mode_uninstall () 10937fda9279dSmrg{ 1093816ee1e9aSmrg $debug_cmd 1093916ee1e9aSmrg 1094016ee1e9aSmrg RM=$nonopt 10941fda9279dSmrg files= 1094216ee1e9aSmrg rmforce=false 10943fda9279dSmrg exit_status=0 10944fda9279dSmrg 10945fda9279dSmrg # This variable tells wrapper scripts just to set variables rather 10946fda9279dSmrg # than running their programs. 1094716ee1e9aSmrg libtool_install_magic=$magic 10948fda9279dSmrg 10949fda9279dSmrg for arg 10950fda9279dSmrg do 10951fda9279dSmrg case $arg in 1095216ee1e9aSmrg -f) func_append RM " $arg"; rmforce=: ;; 10953fda9279dSmrg -*) func_append RM " $arg" ;; 10954fda9279dSmrg *) func_append files " $arg" ;; 10955fda9279dSmrg esac 10956fda9279dSmrg done 10957fda9279dSmrg 10958fda9279dSmrg test -z "$RM" && \ 10959fda9279dSmrg func_fatal_help "you must specify an RM program" 10960fda9279dSmrg 10961fda9279dSmrg rmdirs= 10962fda9279dSmrg 10963fda9279dSmrg for file in $files; do 10964fda9279dSmrg func_dirname "$file" "" "." 1096516ee1e9aSmrg dir=$func_dirname_result 1096616ee1e9aSmrg if test . = "$dir"; then 1096716ee1e9aSmrg odir=$objdir 10968fda9279dSmrg else 1096916ee1e9aSmrg odir=$dir/$objdir 10970fda9279dSmrg fi 10971fda9279dSmrg func_basename "$file" 1097216ee1e9aSmrg name=$func_basename_result 1097316ee1e9aSmrg test uninstall = "$opt_mode" && odir=$dir 10974fda9279dSmrg 10975fda9279dSmrg # Remember odir for removal later, being careful to avoid duplicates 1097616ee1e9aSmrg if test clean = "$opt_mode"; then 10977fda9279dSmrg case " $rmdirs " in 10978fda9279dSmrg *" $odir "*) ;; 10979fda9279dSmrg *) func_append rmdirs " $odir" ;; 10980fda9279dSmrg esac 10981fda9279dSmrg fi 10982fda9279dSmrg 10983fda9279dSmrg # Don't error if the file doesn't exist and rm -f was used. 10984fda9279dSmrg if { test -L "$file"; } >/dev/null 2>&1 || 10985fda9279dSmrg { test -h "$file"; } >/dev/null 2>&1 || 10986fda9279dSmrg test -f "$file"; then 10987fda9279dSmrg : 10988fda9279dSmrg elif test -d "$file"; then 10989fda9279dSmrg exit_status=1 10990fda9279dSmrg continue 1099116ee1e9aSmrg elif $rmforce; then 10992fda9279dSmrg continue 10993fda9279dSmrg fi 10994fda9279dSmrg 1099516ee1e9aSmrg rmfiles=$file 10996fda9279dSmrg 10997fda9279dSmrg case $name in 10998fda9279dSmrg *.la) 10999fda9279dSmrg # Possibly a libtool archive, so verify it. 11000fda9279dSmrg if func_lalib_p "$file"; then 11001fda9279dSmrg func_source $dir/$name 11002fda9279dSmrg 11003fda9279dSmrg # Delete the libtool libraries and symlinks. 11004fda9279dSmrg for n in $library_names; do 11005fda9279dSmrg func_append rmfiles " $odir/$n" 11006fda9279dSmrg done 11007fda9279dSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008fda9279dSmrg 1100916ee1e9aSmrg case $opt_mode in 11010fda9279dSmrg clean) 11011fda9279dSmrg case " $library_names " in 11012fda9279dSmrg *" $dlname "*) ;; 11013fda9279dSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014fda9279dSmrg esac 11015fda9279dSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016fda9279dSmrg ;; 11017fda9279dSmrg uninstall) 11018fda9279dSmrg if test -n "$library_names"; then 11019fda9279dSmrg # Do each command in the postuninstall commands. 1102016ee1e9aSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021fda9279dSmrg fi 11022fda9279dSmrg 11023fda9279dSmrg if test -n "$old_library"; then 11024fda9279dSmrg # Do each command in the old_postuninstall commands. 1102516ee1e9aSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026fda9279dSmrg fi 11027fda9279dSmrg # FIXME: should reinstall the best remaining shared library. 11028fda9279dSmrg ;; 11029fda9279dSmrg esac 11030fda9279dSmrg fi 11031fda9279dSmrg ;; 11032fda9279dSmrg 11033fda9279dSmrg *.lo) 11034fda9279dSmrg # Possibly a libtool object, so verify it. 11035fda9279dSmrg if func_lalib_p "$file"; then 11036fda9279dSmrg 11037fda9279dSmrg # Read the .lo file 11038fda9279dSmrg func_source $dir/$name 11039fda9279dSmrg 11040fda9279dSmrg # Add PIC object to the list of files to remove. 1104116ee1e9aSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11042fda9279dSmrg func_append rmfiles " $dir/$pic_object" 11043fda9279dSmrg fi 11044fda9279dSmrg 11045fda9279dSmrg # Add non-PIC object to the list of files to remove. 1104616ee1e9aSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047fda9279dSmrg func_append rmfiles " $dir/$non_pic_object" 11048fda9279dSmrg fi 11049fda9279dSmrg fi 11050fda9279dSmrg ;; 11051fda9279dSmrg 11052fda9279dSmrg *) 1105316ee1e9aSmrg if test clean = "$opt_mode"; then 11054fda9279dSmrg noexename=$name 11055fda9279dSmrg case $file in 11056fda9279dSmrg *.exe) 11057fda9279dSmrg func_stripname '' '.exe' "$file" 11058fda9279dSmrg file=$func_stripname_result 11059fda9279dSmrg func_stripname '' '.exe' "$name" 11060fda9279dSmrg noexename=$func_stripname_result 11061fda9279dSmrg # $file with .exe has already been added to rmfiles, 11062fda9279dSmrg # add $file without .exe 11063fda9279dSmrg func_append rmfiles " $file" 11064fda9279dSmrg ;; 11065fda9279dSmrg esac 11066fda9279dSmrg # Do a test to see if this is a libtool program. 11067fda9279dSmrg if func_ltwrapper_p "$file"; then 11068fda9279dSmrg if func_ltwrapper_executable_p "$file"; then 11069fda9279dSmrg func_ltwrapper_scriptname "$file" 11070fda9279dSmrg relink_command= 11071fda9279dSmrg func_source $func_ltwrapper_scriptname_result 11072fda9279dSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11073fda9279dSmrg else 11074fda9279dSmrg relink_command= 11075fda9279dSmrg func_source $dir/$noexename 11076fda9279dSmrg fi 11077fda9279dSmrg 11078fda9279dSmrg # note $name still contains .exe if it was in $file originally 11079fda9279dSmrg # as does the version of $file that was added into $rmfiles 1108016ee1e9aSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1108116ee1e9aSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11082fda9279dSmrg func_append rmfiles " $odir/lt-$name" 11083fda9279dSmrg fi 1108416ee1e9aSmrg if test "X$noexename" != "X$name"; then 1108516ee1e9aSmrg func_append rmfiles " $odir/lt-$noexename.c" 11086fda9279dSmrg fi 11087fda9279dSmrg fi 11088fda9279dSmrg fi 11089fda9279dSmrg ;; 11090fda9279dSmrg esac 11091fda9279dSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092fda9279dSmrg done 11093fda9279dSmrg 1109416ee1e9aSmrg # Try to remove the $objdir's in the directories where we deleted files 11095fda9279dSmrg for dir in $rmdirs; do 11096fda9279dSmrg if test -d "$dir"; then 11097fda9279dSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098fda9279dSmrg fi 11099fda9279dSmrg done 11100fda9279dSmrg 11101fda9279dSmrg exit $exit_status 11102fda9279dSmrg} 11103fda9279dSmrg 1110416ee1e9aSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1110516ee1e9aSmrg func_mode_uninstall ${1+"$@"} 1110616ee1e9aSmrgfi 11107fda9279dSmrg 11108fda9279dSmrgtest -z "$opt_mode" && { 1110916ee1e9aSmrg help=$generic_help 11110fda9279dSmrg func_fatal_help "you must specify a MODE" 11111fda9279dSmrg} 11112fda9279dSmrg 11113fda9279dSmrgtest -z "$exec_cmd" && \ 1111416ee1e9aSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11115fda9279dSmrg 11116fda9279dSmrgif test -n "$exec_cmd"; then 11117fda9279dSmrg eval exec "$exec_cmd" 11118fda9279dSmrg exit $EXIT_FAILURE 11119fda9279dSmrgfi 11120fda9279dSmrg 11121fda9279dSmrgexit $exit_status 11122fda9279dSmrg 11123fda9279dSmrg 11124fda9279dSmrg# The TAGs below are defined such that we never get into a situation 1112516ee1e9aSmrg# where we disable both kinds of libraries. Given conflicting 11126fda9279dSmrg# choices, we go for a static library, that is the most portable, 11127fda9279dSmrg# since we can't tell whether shared libraries were disabled because 11128fda9279dSmrg# the user asked for that or because the platform doesn't support 11129fda9279dSmrg# them. This is particularly important on AIX, because we don't 11130fda9279dSmrg# support having both static and shared libraries enabled at the same 11131fda9279dSmrg# time on that platform, so we default to a shared-only configuration. 11132fda9279dSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11133fda9279dSmrg# configuration. But we'll never go from static-only to shared-only. 11134fda9279dSmrg 11135fda9279dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136fda9279dSmrgbuild_libtool_libs=no 11137fda9279dSmrgbuild_old_libs=yes 11138fda9279dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139fda9279dSmrg 11140fda9279dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141fda9279dSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142fda9279dSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11143fda9279dSmrg 11144fda9279dSmrg# Local Variables: 11145fda9279dSmrg# mode:shell-script 11146fda9279dSmrg# sh-indentation:2 11147fda9279dSmrg# End: 11148