ltmain.sh revision dd52494d
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 34cd34e0e1SmrgVERSION=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. 67dd52494dSmrgscriptversion=2015-10-04.22; # 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 1094dd52494dSmrg# func_quote ARG 1095dd52494dSmrg# -------------- 1096dd52494dSmrg# Aesthetically quote one ARG, store the result into $func_quote_result. Note 1097dd52494dSmrg# that we keep attention to performance here (so far O(N) complexity as long as 1098dd52494dSmrg# func_append is O(1)). 1099dd52494dSmrgfunc_quote () 1100dd52494dSmrg{ 1101dd52494dSmrg $debug_cmd 1102dd52494dSmrg 1103dd52494dSmrg func_quote_result=$1 1104dd52494dSmrg 1105dd52494dSmrg case $func_quote_result in 1106dd52494dSmrg *[\\\`\"\$]*) 1107dd52494dSmrg case $func_quote_result in 1108dd52494dSmrg *[\[\*\?]*) 1109dd52494dSmrg func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"` 1110dd52494dSmrg return 0 1111dd52494dSmrg ;; 1112dd52494dSmrg esac 1113dd52494dSmrg 1114dd52494dSmrg func_quote_old_IFS=$IFS 1115dd52494dSmrg for _G_char in '\' '`' '"' '$' 1116dd52494dSmrg do 1117dd52494dSmrg # STATE($1) PREV($2) SEPARATOR($3) 1118dd52494dSmrg set start "" "" 1119dd52494dSmrg func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy 1120dd52494dSmrg IFS=$_G_char 1121dd52494dSmrg for _G_part in $func_quote_result 1122dd52494dSmrg do 1123dd52494dSmrg case $1 in 1124dd52494dSmrg quote) 1125dd52494dSmrg func_append func_quote_result "$3$2" 1126dd52494dSmrg set quote "$_G_part" "\\$_G_char" 1127dd52494dSmrg ;; 1128dd52494dSmrg start) 1129dd52494dSmrg set first "" "" 1130dd52494dSmrg func_quote_result= 1131dd52494dSmrg ;; 1132dd52494dSmrg first) 1133dd52494dSmrg set quote "$_G_part" "" 1134dd52494dSmrg ;; 1135dd52494dSmrg esac 1136dd52494dSmrg done 1137dd52494dSmrg IFS=$func_quote_old_IFS 1138dd52494dSmrg done 1139dd52494dSmrg ;; 1140dd52494dSmrg *) ;; 1141dd52494dSmrg esac 1142dd52494dSmrg} 1143dd52494dSmrg 1144dd52494dSmrg 114516ee1e9aSmrg# func_quote_for_eval ARG... 114616ee1e9aSmrg# -------------------------- 114716ee1e9aSmrg# Aesthetically quote ARGs to be evaled later. 114816ee1e9aSmrg# This function returns two values: 114916ee1e9aSmrg# i) func_quote_for_eval_result 115016ee1e9aSmrg# double-quoted, suitable for a subsequent eval 115116ee1e9aSmrg# ii) func_quote_for_eval_unquoted_result 115216ee1e9aSmrg# has all characters that are still active within double 115316ee1e9aSmrg# quotes backslashified. 115416ee1e9aSmrgfunc_quote_for_eval () 115516ee1e9aSmrg{ 115616ee1e9aSmrg $debug_cmd 115716ee1e9aSmrg 115816ee1e9aSmrg func_quote_for_eval_unquoted_result= 115916ee1e9aSmrg func_quote_for_eval_result= 116016ee1e9aSmrg while test 0 -lt $#; do 1161dd52494dSmrg func_quote "$1" 1162dd52494dSmrg _G_unquoted_arg=$func_quote_result 116316ee1e9aSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 116416ee1e9aSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 116516ee1e9aSmrg else 116616ee1e9aSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 116716ee1e9aSmrg fi 116816ee1e9aSmrg 116916ee1e9aSmrg case $_G_unquoted_arg in 117016ee1e9aSmrg # Double-quote args containing shell metacharacters to delay 117116ee1e9aSmrg # word splitting, command substitution and variable expansion 117216ee1e9aSmrg # for a subsequent eval. 117316ee1e9aSmrg # Many Bourne shells cannot handle close brackets correctly 117416ee1e9aSmrg # in scan sets, so we specify it separately. 117516ee1e9aSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 117616ee1e9aSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 117716ee1e9aSmrg ;; 117816ee1e9aSmrg *) 117916ee1e9aSmrg _G_quoted_arg=$_G_unquoted_arg 118016ee1e9aSmrg ;; 118116ee1e9aSmrg esac 118216ee1e9aSmrg 118316ee1e9aSmrg if test -n "$func_quote_for_eval_result"; then 118416ee1e9aSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 118516ee1e9aSmrg else 118616ee1e9aSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 118716ee1e9aSmrg fi 118816ee1e9aSmrg shift 118916ee1e9aSmrg done 119016ee1e9aSmrg} 119116ee1e9aSmrg 119216ee1e9aSmrg 119316ee1e9aSmrg# func_quote_for_expand ARG 119416ee1e9aSmrg# ------------------------- 1195fda9279dSmrg# Aesthetically quote ARG to be evaled later; same as above, 1196fda9279dSmrg# but do not quote variable references. 1197fda9279dSmrgfunc_quote_for_expand () 1198fda9279dSmrg{ 119916ee1e9aSmrg $debug_cmd 120016ee1e9aSmrg 1201fda9279dSmrg case $1 in 1202fda9279dSmrg *[\\\`\"]*) 120316ee1e9aSmrg _G_arg=`$ECHO "$1" | $SED \ 120416ee1e9aSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1205fda9279dSmrg *) 120616ee1e9aSmrg _G_arg=$1 ;; 1207fda9279dSmrg esac 1208fda9279dSmrg 120916ee1e9aSmrg case $_G_arg in 1210fda9279dSmrg # Double-quote args containing shell metacharacters to delay 1211fda9279dSmrg # word splitting and command substitution for a subsequent eval. 1212fda9279dSmrg # Many Bourne shells cannot handle close brackets correctly 1213fda9279dSmrg # in scan sets, so we specify it separately. 1214fda9279dSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 121516ee1e9aSmrg _G_arg=\"$_G_arg\" 1216fda9279dSmrg ;; 1217fda9279dSmrg esac 1218fda9279dSmrg 121916ee1e9aSmrg func_quote_for_expand_result=$_G_arg 122016ee1e9aSmrg} 122116ee1e9aSmrg 122216ee1e9aSmrg 122316ee1e9aSmrg# func_stripname PREFIX SUFFIX NAME 122416ee1e9aSmrg# --------------------------------- 122516ee1e9aSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 122616ee1e9aSmrg# PREFIX and SUFFIX must not contain globbing or regex special 122716ee1e9aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 122816ee1e9aSmrg# dot (in which case that matches only a dot). 122916ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 123016ee1e9aSmrg eval 'func_stripname () 123116ee1e9aSmrg { 123216ee1e9aSmrg $debug_cmd 123316ee1e9aSmrg 123416ee1e9aSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 123516ee1e9aSmrg # positional parameters, so assign one to ordinary variable first. 123616ee1e9aSmrg func_stripname_result=$3 123716ee1e9aSmrg func_stripname_result=${func_stripname_result#"$1"} 123816ee1e9aSmrg func_stripname_result=${func_stripname_result%"$2"} 123916ee1e9aSmrg }' 124016ee1e9aSmrgelse 124116ee1e9aSmrg func_stripname () 124216ee1e9aSmrg { 124316ee1e9aSmrg $debug_cmd 124416ee1e9aSmrg 124516ee1e9aSmrg case $2 in 124616ee1e9aSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 124716ee1e9aSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 124816ee1e9aSmrg esac 124916ee1e9aSmrg } 125016ee1e9aSmrgfi 125116ee1e9aSmrg 125216ee1e9aSmrg 125316ee1e9aSmrg# func_show_eval CMD [FAIL_EXP] 125416ee1e9aSmrg# ----------------------------- 125516ee1e9aSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 125616ee1e9aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 125716ee1e9aSmrg# is given, then evaluate it. 125816ee1e9aSmrgfunc_show_eval () 125916ee1e9aSmrg{ 126016ee1e9aSmrg $debug_cmd 126116ee1e9aSmrg 126216ee1e9aSmrg _G_cmd=$1 126316ee1e9aSmrg _G_fail_exp=${2-':'} 126416ee1e9aSmrg 126516ee1e9aSmrg func_quote_for_expand "$_G_cmd" 126616ee1e9aSmrg eval "func_notquiet $func_quote_for_expand_result" 126716ee1e9aSmrg 126816ee1e9aSmrg $opt_dry_run || { 126916ee1e9aSmrg eval "$_G_cmd" 127016ee1e9aSmrg _G_status=$? 127116ee1e9aSmrg if test 0 -ne "$_G_status"; then 127216ee1e9aSmrg eval "(exit $_G_status); $_G_fail_exp" 127316ee1e9aSmrg fi 127416ee1e9aSmrg } 127516ee1e9aSmrg} 127616ee1e9aSmrg 127716ee1e9aSmrg 127816ee1e9aSmrg# func_show_eval_locale CMD [FAIL_EXP] 127916ee1e9aSmrg# ------------------------------------ 128016ee1e9aSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 128116ee1e9aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 128216ee1e9aSmrg# is given, then evaluate it. Use the saved locale for evaluation. 128316ee1e9aSmrgfunc_show_eval_locale () 128416ee1e9aSmrg{ 128516ee1e9aSmrg $debug_cmd 128616ee1e9aSmrg 128716ee1e9aSmrg _G_cmd=$1 128816ee1e9aSmrg _G_fail_exp=${2-':'} 128916ee1e9aSmrg 129016ee1e9aSmrg $opt_quiet || { 129116ee1e9aSmrg func_quote_for_expand "$_G_cmd" 129216ee1e9aSmrg eval "func_echo $func_quote_for_expand_result" 129316ee1e9aSmrg } 129416ee1e9aSmrg 129516ee1e9aSmrg $opt_dry_run || { 129616ee1e9aSmrg eval "$_G_user_locale 129716ee1e9aSmrg $_G_cmd" 129816ee1e9aSmrg _G_status=$? 129916ee1e9aSmrg eval "$_G_safe_locale" 130016ee1e9aSmrg if test 0 -ne "$_G_status"; then 130116ee1e9aSmrg eval "(exit $_G_status); $_G_fail_exp" 130216ee1e9aSmrg fi 130316ee1e9aSmrg } 130416ee1e9aSmrg} 130516ee1e9aSmrg 130616ee1e9aSmrg 130716ee1e9aSmrg# func_tr_sh 130816ee1e9aSmrg# ---------- 130916ee1e9aSmrg# Turn $1 into a string suitable for a shell variable name. 131016ee1e9aSmrg# Result is stored in $func_tr_sh_result. All characters 131116ee1e9aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 131216ee1e9aSmrg# if $1 begins with a digit, a '_' is prepended as well. 131316ee1e9aSmrgfunc_tr_sh () 131416ee1e9aSmrg{ 131516ee1e9aSmrg $debug_cmd 131616ee1e9aSmrg 131716ee1e9aSmrg case $1 in 131816ee1e9aSmrg [0-9]* | *[!a-zA-Z0-9_]*) 131916ee1e9aSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 132016ee1e9aSmrg ;; 132116ee1e9aSmrg * ) 132216ee1e9aSmrg func_tr_sh_result=$1 132316ee1e9aSmrg ;; 132416ee1e9aSmrg esac 132516ee1e9aSmrg} 132616ee1e9aSmrg 132716ee1e9aSmrg 132816ee1e9aSmrg# func_verbose ARG... 132916ee1e9aSmrg# ------------------- 133016ee1e9aSmrg# Echo program name prefixed message in verbose mode only. 133116ee1e9aSmrgfunc_verbose () 133216ee1e9aSmrg{ 133316ee1e9aSmrg $debug_cmd 133416ee1e9aSmrg 133516ee1e9aSmrg $opt_verbose && func_echo "$*" 133616ee1e9aSmrg 133716ee1e9aSmrg : 133816ee1e9aSmrg} 133916ee1e9aSmrg 134016ee1e9aSmrg 134116ee1e9aSmrg# func_warn_and_continue ARG... 134216ee1e9aSmrg# ----------------------------- 134316ee1e9aSmrg# Echo program name prefixed warning message to standard error. 134416ee1e9aSmrgfunc_warn_and_continue () 134516ee1e9aSmrg{ 134616ee1e9aSmrg $debug_cmd 134716ee1e9aSmrg 134816ee1e9aSmrg $require_term_colors 134916ee1e9aSmrg 135016ee1e9aSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 135116ee1e9aSmrg} 135216ee1e9aSmrg 135316ee1e9aSmrg 135416ee1e9aSmrg# func_warning CATEGORY ARG... 135516ee1e9aSmrg# ---------------------------- 135616ee1e9aSmrg# Echo program name prefixed warning message to standard error. Warning 135716ee1e9aSmrg# messages can be filtered according to CATEGORY, where this function 135816ee1e9aSmrg# elides messages where CATEGORY is not listed in the global variable 135916ee1e9aSmrg# 'opt_warning_types'. 136016ee1e9aSmrgfunc_warning () 136116ee1e9aSmrg{ 136216ee1e9aSmrg $debug_cmd 136316ee1e9aSmrg 136416ee1e9aSmrg # CATEGORY must be in the warning_categories list! 136516ee1e9aSmrg case " $warning_categories " in 136616ee1e9aSmrg *" $1 "*) ;; 136716ee1e9aSmrg *) func_internal_error "invalid warning category '$1'" ;; 136816ee1e9aSmrg esac 136916ee1e9aSmrg 137016ee1e9aSmrg _G_category=$1 137116ee1e9aSmrg shift 137216ee1e9aSmrg 137316ee1e9aSmrg case " $opt_warning_types " in 137416ee1e9aSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 137516ee1e9aSmrg esac 1376fda9279dSmrg} 1377fda9279dSmrg 1378fda9279dSmrg 137916ee1e9aSmrg# func_sort_ver VER1 VER2 138016ee1e9aSmrg# ----------------------- 138116ee1e9aSmrg# 'sort -V' is not generally available. 138216ee1e9aSmrg# Note this deviates from the version comparison in automake 138316ee1e9aSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 138416ee1e9aSmrg# but this should suffice as we won't be specifying old 138516ee1e9aSmrg# version formats or redundant trailing .0 in bootstrap.conf. 138616ee1e9aSmrg# If we did want full compatibility then we should probably 138716ee1e9aSmrg# use m4_version_compare from autoconf. 138816ee1e9aSmrgfunc_sort_ver () 138916ee1e9aSmrg{ 139016ee1e9aSmrg $debug_cmd 139116ee1e9aSmrg 139216ee1e9aSmrg printf '%s\n%s\n' "$1" "$2" \ 139316ee1e9aSmrg | 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 139416ee1e9aSmrg} 139516ee1e9aSmrg 139616ee1e9aSmrg# func_lt_ver PREV CURR 139716ee1e9aSmrg# --------------------- 139816ee1e9aSmrg# Return true if PREV and CURR are in the correct order according to 139916ee1e9aSmrg# func_sort_ver, otherwise false. Use it like this: 140016ee1e9aSmrg# 140116ee1e9aSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 140216ee1e9aSmrgfunc_lt_ver () 140316ee1e9aSmrg{ 140416ee1e9aSmrg $debug_cmd 140516ee1e9aSmrg 140616ee1e9aSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 140716ee1e9aSmrg} 140816ee1e9aSmrg 140916ee1e9aSmrg 141016ee1e9aSmrg# Local variables: 141116ee1e9aSmrg# mode: shell-script 141216ee1e9aSmrg# sh-indentation: 2 141316ee1e9aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 141416ee1e9aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 141516ee1e9aSmrg# time-stamp-time-zone: "UTC" 141616ee1e9aSmrg# End: 141716ee1e9aSmrg#! /bin/sh 141816ee1e9aSmrg 141916ee1e9aSmrg# Set a version string for this script. 142016ee1e9aSmrgscriptversion=2014-01-07.03; # UTC 142116ee1e9aSmrg 142216ee1e9aSmrg# A portable, pluggable option parser for Bourne shell. 142316ee1e9aSmrg# Written by Gary V. Vaughan, 2010 142416ee1e9aSmrg 142516ee1e9aSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 142616ee1e9aSmrg# This is free software; see the source for copying conditions. There is NO 142716ee1e9aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 142816ee1e9aSmrg 142916ee1e9aSmrg# This program is free software: you can redistribute it and/or modify 143016ee1e9aSmrg# it under the terms of the GNU General Public License as published by 143116ee1e9aSmrg# the Free Software Foundation, either version 3 of the License, or 143216ee1e9aSmrg# (at your option) any later version. 143316ee1e9aSmrg 143416ee1e9aSmrg# This program is distributed in the hope that it will be useful, 143516ee1e9aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 143616ee1e9aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 143716ee1e9aSmrg# GNU General Public License for more details. 143816ee1e9aSmrg 143916ee1e9aSmrg# You should have received a copy of the GNU General Public License 144016ee1e9aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 144116ee1e9aSmrg 144216ee1e9aSmrg# Please report bugs or propose patches to gary@gnu.org. 144316ee1e9aSmrg 144416ee1e9aSmrg 144516ee1e9aSmrg## ------ ## 144616ee1e9aSmrg## Usage. ## 144716ee1e9aSmrg## ------ ## 144816ee1e9aSmrg 144916ee1e9aSmrg# This file is a library for parsing options in your shell scripts along 145016ee1e9aSmrg# with assorted other useful supporting features that you can make use 145116ee1e9aSmrg# of too. 145216ee1e9aSmrg# 145316ee1e9aSmrg# For the simplest scripts you might need only: 145416ee1e9aSmrg# 145516ee1e9aSmrg# #!/bin/sh 145616ee1e9aSmrg# . relative/path/to/funclib.sh 145716ee1e9aSmrg# . relative/path/to/options-parser 145816ee1e9aSmrg# scriptversion=1.0 145916ee1e9aSmrg# func_options ${1+"$@"} 146016ee1e9aSmrg# eval set dummy "$func_options_result"; shift 146116ee1e9aSmrg# ...rest of your script... 146216ee1e9aSmrg# 146316ee1e9aSmrg# In order for the '--version' option to work, you will need to have a 146416ee1e9aSmrg# suitably formatted comment like the one at the top of this file 146516ee1e9aSmrg# starting with '# Written by ' and ending with '# warranty; '. 146616ee1e9aSmrg# 146716ee1e9aSmrg# For '-h' and '--help' to work, you will also need a one line 146816ee1e9aSmrg# description of your script's purpose in a comment directly above the 146916ee1e9aSmrg# '# Written by ' line, like the one at the top of this file. 147016ee1e9aSmrg# 147116ee1e9aSmrg# The default options also support '--debug', which will turn on shell 147216ee1e9aSmrg# execution tracing (see the comment above debug_cmd below for another 147316ee1e9aSmrg# use), and '--verbose' and the func_verbose function to allow your script 147416ee1e9aSmrg# to display verbose messages only when your user has specified 147516ee1e9aSmrg# '--verbose'. 147616ee1e9aSmrg# 147716ee1e9aSmrg# After sourcing this file, you can plug processing for additional 147816ee1e9aSmrg# options by amending the variables from the 'Configuration' section 147916ee1e9aSmrg# below, and following the instructions in the 'Option parsing' 148016ee1e9aSmrg# section further down. 148116ee1e9aSmrg 148216ee1e9aSmrg## -------------- ## 148316ee1e9aSmrg## Configuration. ## 148416ee1e9aSmrg## -------------- ## 148516ee1e9aSmrg 148616ee1e9aSmrg# You should override these variables in your script after sourcing this 148716ee1e9aSmrg# file so that they reflect the customisations you have added to the 148816ee1e9aSmrg# option parser. 148916ee1e9aSmrg 149016ee1e9aSmrg# The usage line for option parsing errors and the start of '-h' and 149116ee1e9aSmrg# '--help' output messages. You can embed shell variables for delayed 149216ee1e9aSmrg# expansion at the time the message is displayed, but you will need to 149316ee1e9aSmrg# quote other shell meta-characters carefully to prevent them being 149416ee1e9aSmrg# expanded when the contents are evaled. 149516ee1e9aSmrgusage='$progpath [OPTION]...' 149616ee1e9aSmrg 149716ee1e9aSmrg# Short help message in response to '-h' and '--help'. Add to this or 149816ee1e9aSmrg# override it after sourcing this library to reflect the full set of 149916ee1e9aSmrg# options your script accepts. 150016ee1e9aSmrgusage_message="\ 150116ee1e9aSmrg --debug enable verbose shell tracing 150216ee1e9aSmrg -W, --warnings=CATEGORY 150316ee1e9aSmrg report the warnings falling in CATEGORY [all] 150416ee1e9aSmrg -v, --verbose verbosely report processing 150516ee1e9aSmrg --version print version information and exit 150616ee1e9aSmrg -h, --help print short or long help message and exit 150716ee1e9aSmrg" 150816ee1e9aSmrg 150916ee1e9aSmrg# Additional text appended to 'usage_message' in response to '--help'. 151016ee1e9aSmrglong_help_message=" 151116ee1e9aSmrgWarning categories include: 151216ee1e9aSmrg 'all' show all warnings 151316ee1e9aSmrg 'none' turn off all the warnings 151416ee1e9aSmrg 'error' warnings are treated as fatal errors" 151516ee1e9aSmrg 151616ee1e9aSmrg# Help message printed before fatal option parsing errors. 151716ee1e9aSmrgfatal_help="Try '\$progname --help' for more information." 151816ee1e9aSmrg 151916ee1e9aSmrg 152016ee1e9aSmrg 152116ee1e9aSmrg## ------------------------- ## 152216ee1e9aSmrg## Hook function management. ## 152316ee1e9aSmrg## ------------------------- ## 152416ee1e9aSmrg 152516ee1e9aSmrg# This section contains functions for adding, removing, and running hooks 152616ee1e9aSmrg# to the main code. A hook is just a named list of of function, that can 152716ee1e9aSmrg# be run in order later on. 152816ee1e9aSmrg 152916ee1e9aSmrg# func_hookable FUNC_NAME 153016ee1e9aSmrg# ----------------------- 153116ee1e9aSmrg# Declare that FUNC_NAME will run hooks added with 153216ee1e9aSmrg# 'func_add_hook FUNC_NAME ...'. 153316ee1e9aSmrgfunc_hookable () 153416ee1e9aSmrg{ 153516ee1e9aSmrg $debug_cmd 153616ee1e9aSmrg 153716ee1e9aSmrg func_append hookable_fns " $1" 153816ee1e9aSmrg} 153916ee1e9aSmrg 154016ee1e9aSmrg 154116ee1e9aSmrg# func_add_hook FUNC_NAME HOOK_FUNC 154216ee1e9aSmrg# --------------------------------- 154316ee1e9aSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 154416ee1e9aSmrg# first have been declared "hookable" by a call to 'func_hookable'. 154516ee1e9aSmrgfunc_add_hook () 154616ee1e9aSmrg{ 154716ee1e9aSmrg $debug_cmd 154816ee1e9aSmrg 154916ee1e9aSmrg case " $hookable_fns " in 155016ee1e9aSmrg *" $1 "*) ;; 155116ee1e9aSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 155216ee1e9aSmrg esac 155316ee1e9aSmrg 155416ee1e9aSmrg eval func_append ${1}_hooks '" $2"' 155516ee1e9aSmrg} 155616ee1e9aSmrg 155716ee1e9aSmrg 155816ee1e9aSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 155916ee1e9aSmrg# ------------------------------------ 156016ee1e9aSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 156116ee1e9aSmrgfunc_remove_hook () 156216ee1e9aSmrg{ 156316ee1e9aSmrg $debug_cmd 156416ee1e9aSmrg 156516ee1e9aSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 156616ee1e9aSmrg} 156716ee1e9aSmrg 156816ee1e9aSmrg 156916ee1e9aSmrg# func_run_hooks FUNC_NAME [ARG]... 157016ee1e9aSmrg# --------------------------------- 157116ee1e9aSmrg# Run all hook functions registered to FUNC_NAME. 157216ee1e9aSmrg# It is assumed that the list of hook functions contains nothing more 157316ee1e9aSmrg# than a whitespace-delimited list of legal shell function names, and 157416ee1e9aSmrg# no effort is wasted trying to catch shell meta-characters or preserve 157516ee1e9aSmrg# whitespace. 157616ee1e9aSmrgfunc_run_hooks () 157716ee1e9aSmrg{ 157816ee1e9aSmrg $debug_cmd 157916ee1e9aSmrg 158016ee1e9aSmrg case " $hookable_fns " in 158116ee1e9aSmrg *" $1 "*) ;; 158216ee1e9aSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 158316ee1e9aSmrg esac 158416ee1e9aSmrg 158516ee1e9aSmrg eval _G_hook_fns=\$$1_hooks; shift 158616ee1e9aSmrg 158716ee1e9aSmrg for _G_hook in $_G_hook_fns; do 158816ee1e9aSmrg eval $_G_hook '"$@"' 158916ee1e9aSmrg 159016ee1e9aSmrg # store returned options list back into positional 159116ee1e9aSmrg # parameters for next 'cmd' execution. 159216ee1e9aSmrg eval _G_hook_result=\$${_G_hook}_result 159316ee1e9aSmrg eval set dummy "$_G_hook_result"; shift 159416ee1e9aSmrg done 159516ee1e9aSmrg 159616ee1e9aSmrg func_quote_for_eval ${1+"$@"} 159716ee1e9aSmrg func_run_hooks_result=$func_quote_for_eval_result 159816ee1e9aSmrg} 159916ee1e9aSmrg 160016ee1e9aSmrg 160116ee1e9aSmrg 160216ee1e9aSmrg## --------------- ## 160316ee1e9aSmrg## Option parsing. ## 160416ee1e9aSmrg## --------------- ## 160516ee1e9aSmrg 160616ee1e9aSmrg# In order to add your own option parsing hooks, you must accept the 160716ee1e9aSmrg# full positional parameter list in your hook function, remove any 160816ee1e9aSmrg# options that you action, and then pass back the remaining unprocessed 160916ee1e9aSmrg# options in '<hooked_function_name>_result', escaped suitably for 161016ee1e9aSmrg# 'eval'. Like this: 161116ee1e9aSmrg# 161216ee1e9aSmrg# my_options_prep () 161316ee1e9aSmrg# { 161416ee1e9aSmrg# $debug_cmd 161516ee1e9aSmrg# 161616ee1e9aSmrg# # Extend the existing usage message. 161716ee1e9aSmrg# usage_message=$usage_message' 161816ee1e9aSmrg# -s, --silent don'\''t print informational messages 161916ee1e9aSmrg# ' 162016ee1e9aSmrg# 162116ee1e9aSmrg# func_quote_for_eval ${1+"$@"} 162216ee1e9aSmrg# my_options_prep_result=$func_quote_for_eval_result 162316ee1e9aSmrg# } 162416ee1e9aSmrg# func_add_hook func_options_prep my_options_prep 162516ee1e9aSmrg# 162616ee1e9aSmrg# 162716ee1e9aSmrg# my_silent_option () 162816ee1e9aSmrg# { 162916ee1e9aSmrg# $debug_cmd 163016ee1e9aSmrg# 163116ee1e9aSmrg# # Note that for efficiency, we parse as many options as we can 163216ee1e9aSmrg# # recognise in a loop before passing the remainder back to the 163316ee1e9aSmrg# # caller on the first unrecognised argument we encounter. 163416ee1e9aSmrg# while test $# -gt 0; do 163516ee1e9aSmrg# opt=$1; shift 163616ee1e9aSmrg# case $opt in 163716ee1e9aSmrg# --silent|-s) opt_silent=: ;; 163816ee1e9aSmrg# # Separate non-argument short options: 163916ee1e9aSmrg# -s*) func_split_short_opt "$_G_opt" 164016ee1e9aSmrg# set dummy "$func_split_short_opt_name" \ 164116ee1e9aSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 164216ee1e9aSmrg# shift 164316ee1e9aSmrg# ;; 164416ee1e9aSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 164516ee1e9aSmrg# esac 164616ee1e9aSmrg# done 164716ee1e9aSmrg# 164816ee1e9aSmrg# func_quote_for_eval ${1+"$@"} 164916ee1e9aSmrg# my_silent_option_result=$func_quote_for_eval_result 165016ee1e9aSmrg# } 165116ee1e9aSmrg# func_add_hook func_parse_options my_silent_option 165216ee1e9aSmrg# 165316ee1e9aSmrg# 165416ee1e9aSmrg# my_option_validation () 165516ee1e9aSmrg# { 165616ee1e9aSmrg# $debug_cmd 165716ee1e9aSmrg# 165816ee1e9aSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 165916ee1e9aSmrg# '--silent' and '--verbose' options are mutually exclusive." 166016ee1e9aSmrg# 166116ee1e9aSmrg# func_quote_for_eval ${1+"$@"} 166216ee1e9aSmrg# my_option_validation_result=$func_quote_for_eval_result 166316ee1e9aSmrg# } 166416ee1e9aSmrg# func_add_hook func_validate_options my_option_validation 166516ee1e9aSmrg# 166616ee1e9aSmrg# You'll alse need to manually amend $usage_message to reflect the extra 166716ee1e9aSmrg# options you parse. It's preferable to append if you can, so that 166816ee1e9aSmrg# multiple option parsing hooks can be added safely. 166916ee1e9aSmrg 167016ee1e9aSmrg 167116ee1e9aSmrg# func_options [ARG]... 167216ee1e9aSmrg# --------------------- 167316ee1e9aSmrg# All the functions called inside func_options are hookable. See the 167416ee1e9aSmrg# individual implementations for details. 167516ee1e9aSmrgfunc_hookable func_options 167616ee1e9aSmrgfunc_options () 1677fda9279dSmrg{ 167816ee1e9aSmrg $debug_cmd 1679fda9279dSmrg 168016ee1e9aSmrg func_options_prep ${1+"$@"} 168116ee1e9aSmrg eval func_parse_options \ 168216ee1e9aSmrg ${func_options_prep_result+"$func_options_prep_result"} 168316ee1e9aSmrg eval func_validate_options \ 168416ee1e9aSmrg ${func_parse_options_result+"$func_parse_options_result"} 1685fda9279dSmrg 168616ee1e9aSmrg eval func_run_hooks func_options \ 168716ee1e9aSmrg ${func_validate_options_result+"$func_validate_options_result"} 168816ee1e9aSmrg 168916ee1e9aSmrg # save modified positional parameters for caller 169016ee1e9aSmrg func_options_result=$func_run_hooks_result 1691fda9279dSmrg} 1692fda9279dSmrg 1693fda9279dSmrg 169416ee1e9aSmrg# func_options_prep [ARG]... 169516ee1e9aSmrg# -------------------------- 169616ee1e9aSmrg# All initialisations required before starting the option parse loop. 169716ee1e9aSmrg# Note that when calling hook functions, we pass through the list of 169816ee1e9aSmrg# positional parameters. If a hook function modifies that list, and 169916ee1e9aSmrg# needs to propogate that back to rest of this script, then the complete 170016ee1e9aSmrg# modified list must be put in 'func_run_hooks_result' before 170116ee1e9aSmrg# returning. 170216ee1e9aSmrgfunc_hookable func_options_prep 170316ee1e9aSmrgfunc_options_prep () 1704fda9279dSmrg{ 170516ee1e9aSmrg $debug_cmd 1706fda9279dSmrg 170716ee1e9aSmrg # Option defaults: 170816ee1e9aSmrg opt_verbose=false 170916ee1e9aSmrg opt_warning_types= 1710fda9279dSmrg 171116ee1e9aSmrg func_run_hooks func_options_prep ${1+"$@"} 171216ee1e9aSmrg 171316ee1e9aSmrg # save modified positional parameters for caller 171416ee1e9aSmrg func_options_prep_result=$func_run_hooks_result 1715fda9279dSmrg} 1716fda9279dSmrg 171716ee1e9aSmrg 171816ee1e9aSmrg# func_parse_options [ARG]... 171916ee1e9aSmrg# --------------------------- 172016ee1e9aSmrg# The main option parsing loop. 172116ee1e9aSmrgfunc_hookable func_parse_options 172216ee1e9aSmrgfunc_parse_options () 1723fda9279dSmrg{ 172416ee1e9aSmrg $debug_cmd 172516ee1e9aSmrg 172616ee1e9aSmrg func_parse_options_result= 172716ee1e9aSmrg 172816ee1e9aSmrg # this just eases exit handling 172916ee1e9aSmrg while test $# -gt 0; do 173016ee1e9aSmrg # Defer to hook functions for initial option parsing, so they 173116ee1e9aSmrg # get priority in the event of reusing an option name. 173216ee1e9aSmrg func_run_hooks func_parse_options ${1+"$@"} 173316ee1e9aSmrg 173416ee1e9aSmrg # Adjust func_parse_options positional parameters to match 173516ee1e9aSmrg eval set dummy "$func_run_hooks_result"; shift 173616ee1e9aSmrg 173716ee1e9aSmrg # Break out of the loop if we already parsed every option. 173816ee1e9aSmrg test $# -gt 0 || break 173916ee1e9aSmrg 174016ee1e9aSmrg _G_opt=$1 174116ee1e9aSmrg shift 174216ee1e9aSmrg case $_G_opt in 174316ee1e9aSmrg --debug|-x) debug_cmd='set -x' 174416ee1e9aSmrg func_echo "enabling shell trace mode" 174516ee1e9aSmrg $debug_cmd 174616ee1e9aSmrg ;; 174716ee1e9aSmrg 174816ee1e9aSmrg --no-warnings|--no-warning|--no-warn) 174916ee1e9aSmrg set dummy --warnings none ${1+"$@"} 175016ee1e9aSmrg shift 175116ee1e9aSmrg ;; 175216ee1e9aSmrg 175316ee1e9aSmrg --warnings|--warning|-W) 175416ee1e9aSmrg test $# = 0 && func_missing_arg $_G_opt && break 175516ee1e9aSmrg case " $warning_categories $1" in 175616ee1e9aSmrg *" $1 "*) 175716ee1e9aSmrg # trailing space prevents matching last $1 above 175816ee1e9aSmrg func_append_uniq opt_warning_types " $1" 175916ee1e9aSmrg ;; 176016ee1e9aSmrg *all) 176116ee1e9aSmrg opt_warning_types=$warning_categories 176216ee1e9aSmrg ;; 176316ee1e9aSmrg *none) 176416ee1e9aSmrg opt_warning_types=none 176516ee1e9aSmrg warning_func=: 176616ee1e9aSmrg ;; 176716ee1e9aSmrg *error) 176816ee1e9aSmrg opt_warning_types=$warning_categories 176916ee1e9aSmrg warning_func=func_fatal_error 177016ee1e9aSmrg ;; 177116ee1e9aSmrg *) 177216ee1e9aSmrg func_fatal_error \ 177316ee1e9aSmrg "unsupported warning category: '$1'" 177416ee1e9aSmrg ;; 177516ee1e9aSmrg esac 177616ee1e9aSmrg shift 177716ee1e9aSmrg ;; 177816ee1e9aSmrg 177916ee1e9aSmrg --verbose|-v) opt_verbose=: ;; 178016ee1e9aSmrg --version) func_version ;; 178116ee1e9aSmrg -\?|-h) func_usage ;; 178216ee1e9aSmrg --help) func_help ;; 178316ee1e9aSmrg 178416ee1e9aSmrg # Separate optargs to long options (plugins may need this): 178516ee1e9aSmrg --*=*) func_split_equals "$_G_opt" 178616ee1e9aSmrg set dummy "$func_split_equals_lhs" \ 178716ee1e9aSmrg "$func_split_equals_rhs" ${1+"$@"} 178816ee1e9aSmrg shift 178916ee1e9aSmrg ;; 179016ee1e9aSmrg 179116ee1e9aSmrg # Separate optargs to short options: 179216ee1e9aSmrg -W*) 179316ee1e9aSmrg func_split_short_opt "$_G_opt" 179416ee1e9aSmrg set dummy "$func_split_short_opt_name" \ 179516ee1e9aSmrg "$func_split_short_opt_arg" ${1+"$@"} 179616ee1e9aSmrg shift 179716ee1e9aSmrg ;; 179816ee1e9aSmrg 179916ee1e9aSmrg # Separate non-argument short options: 180016ee1e9aSmrg -\?*|-h*|-v*|-x*) 180116ee1e9aSmrg func_split_short_opt "$_G_opt" 180216ee1e9aSmrg set dummy "$func_split_short_opt_name" \ 180316ee1e9aSmrg "-$func_split_short_opt_arg" ${1+"$@"} 180416ee1e9aSmrg shift 180516ee1e9aSmrg ;; 180616ee1e9aSmrg 180716ee1e9aSmrg --) break ;; 180816ee1e9aSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 180916ee1e9aSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 181016ee1e9aSmrg esac 181116ee1e9aSmrg done 181216ee1e9aSmrg 181316ee1e9aSmrg # save modified positional parameters for caller 181416ee1e9aSmrg func_quote_for_eval ${1+"$@"} 181516ee1e9aSmrg func_parse_options_result=$func_quote_for_eval_result 1816fda9279dSmrg} 1817fda9279dSmrg 1818fda9279dSmrg 181916ee1e9aSmrg# func_validate_options [ARG]... 182016ee1e9aSmrg# ------------------------------ 182116ee1e9aSmrg# Perform any sanity checks on option settings and/or unconsumed 182216ee1e9aSmrg# arguments. 182316ee1e9aSmrgfunc_hookable func_validate_options 182416ee1e9aSmrgfunc_validate_options () 1825fda9279dSmrg{ 182616ee1e9aSmrg $debug_cmd 1827fda9279dSmrg 182816ee1e9aSmrg # Display all warnings if -W was not given. 182916ee1e9aSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 183016ee1e9aSmrg 183116ee1e9aSmrg func_run_hooks func_validate_options ${1+"$@"} 183216ee1e9aSmrg 183316ee1e9aSmrg # Bail if the options were screwed! 183416ee1e9aSmrg $exit_cmd $EXIT_FAILURE 183516ee1e9aSmrg 183616ee1e9aSmrg # save modified positional parameters for caller 183716ee1e9aSmrg func_validate_options_result=$func_run_hooks_result 1838fda9279dSmrg} 1839fda9279dSmrg 184016ee1e9aSmrg 184116ee1e9aSmrg 184216ee1e9aSmrg## ----------------- ## 184316ee1e9aSmrg## Helper functions. ## 184416ee1e9aSmrg## ----------------- ## 184516ee1e9aSmrg 184616ee1e9aSmrg# This section contains the helper functions used by the rest of the 184716ee1e9aSmrg# hookable option parser framework in ascii-betical order. 184816ee1e9aSmrg 184916ee1e9aSmrg 185016ee1e9aSmrg# func_fatal_help ARG... 185116ee1e9aSmrg# ---------------------- 185216ee1e9aSmrg# Echo program name prefixed message to standard error, followed by 185316ee1e9aSmrg# a help hint, and exit. 185416ee1e9aSmrgfunc_fatal_help () 1855fda9279dSmrg{ 185616ee1e9aSmrg $debug_cmd 1857fda9279dSmrg 185816ee1e9aSmrg eval \$ECHO \""Usage: $usage"\" 185916ee1e9aSmrg eval \$ECHO \""$fatal_help"\" 186016ee1e9aSmrg func_error ${1+"$@"} 186116ee1e9aSmrg exit $EXIT_FAILURE 1862fda9279dSmrg} 1863fda9279dSmrg 186416ee1e9aSmrg 186516ee1e9aSmrg# func_help 186616ee1e9aSmrg# --------- 186716ee1e9aSmrg# Echo long help message to standard output and exit. 1868fda9279dSmrgfunc_help () 1869fda9279dSmrg{ 187016ee1e9aSmrg $debug_cmd 187116ee1e9aSmrg 187216ee1e9aSmrg func_usage_message 187316ee1e9aSmrg $ECHO "$long_help_message" 187416ee1e9aSmrg exit 0 1875fda9279dSmrg} 1876fda9279dSmrg 187716ee1e9aSmrg 187816ee1e9aSmrg# func_missing_arg ARGNAME 187916ee1e9aSmrg# ------------------------ 1880fda9279dSmrg# Echo program name prefixed message to standard error and set global 1881fda9279dSmrg# exit_cmd. 1882fda9279dSmrgfunc_missing_arg () 1883fda9279dSmrg{ 188416ee1e9aSmrg $debug_cmd 1885fda9279dSmrg 188616ee1e9aSmrg func_error "Missing argument for '$1'." 1887fda9279dSmrg exit_cmd=exit 1888fda9279dSmrg} 1889fda9279dSmrg 1890fda9279dSmrg 189116ee1e9aSmrg# func_split_equals STRING 189216ee1e9aSmrg# ------------------------ 189316ee1e9aSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 189416ee1e9aSmrg# splitting STRING at the '=' sign. 189516ee1e9aSmrgtest -z "$_G_HAVE_XSI_OPS" \ 189616ee1e9aSmrg && (eval 'x=a/b/c; 189716ee1e9aSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 189816ee1e9aSmrg && _G_HAVE_XSI_OPS=yes 189916ee1e9aSmrg 190016ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS" 190116ee1e9aSmrgthen 190216ee1e9aSmrg # This is an XSI compatible shell, allowing a faster implementation... 190316ee1e9aSmrg eval 'func_split_equals () 190416ee1e9aSmrg { 190516ee1e9aSmrg $debug_cmd 190616ee1e9aSmrg 190716ee1e9aSmrg func_split_equals_lhs=${1%%=*} 190816ee1e9aSmrg func_split_equals_rhs=${1#*=} 190916ee1e9aSmrg test "x$func_split_equals_lhs" = "x$1" \ 191016ee1e9aSmrg && func_split_equals_rhs= 191116ee1e9aSmrg }' 191216ee1e9aSmrgelse 191316ee1e9aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 191416ee1e9aSmrg func_split_equals () 191516ee1e9aSmrg { 191616ee1e9aSmrg $debug_cmd 191716ee1e9aSmrg 191816ee1e9aSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 191916ee1e9aSmrg func_split_equals_rhs= 192016ee1e9aSmrg test "x$func_split_equals_lhs" = "x$1" \ 192116ee1e9aSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 192216ee1e9aSmrg } 192316ee1e9aSmrgfi #func_split_equals 192416ee1e9aSmrg 192516ee1e9aSmrg 192616ee1e9aSmrg# func_split_short_opt SHORTOPT 192716ee1e9aSmrg# ----------------------------- 1928fda9279dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1929fda9279dSmrg# variables after splitting SHORTOPT after the 2nd character. 193016ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS" 193116ee1e9aSmrgthen 193216ee1e9aSmrg # This is an XSI compatible shell, allowing a faster implementation... 193316ee1e9aSmrg eval 'func_split_short_opt () 193416ee1e9aSmrg { 193516ee1e9aSmrg $debug_cmd 193616ee1e9aSmrg 193716ee1e9aSmrg func_split_short_opt_arg=${1#??} 193816ee1e9aSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 193916ee1e9aSmrg }' 194016ee1e9aSmrgelse 194116ee1e9aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 194216ee1e9aSmrg func_split_short_opt () 194316ee1e9aSmrg { 194416ee1e9aSmrg $debug_cmd 194516ee1e9aSmrg 194616ee1e9aSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 194716ee1e9aSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 194816ee1e9aSmrg } 194916ee1e9aSmrgfi #func_split_short_opt 195016ee1e9aSmrg 195116ee1e9aSmrg 195216ee1e9aSmrg# func_usage 195316ee1e9aSmrg# ---------- 195416ee1e9aSmrg# Echo short help message to standard output and exit. 195516ee1e9aSmrgfunc_usage () 1956fda9279dSmrg{ 195716ee1e9aSmrg $debug_cmd 1958fda9279dSmrg 195916ee1e9aSmrg func_usage_message 196016ee1e9aSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 196116ee1e9aSmrg exit 0 196216ee1e9aSmrg} 1963fda9279dSmrg 1964fda9279dSmrg 196516ee1e9aSmrg# func_usage_message 196616ee1e9aSmrg# ------------------ 196716ee1e9aSmrg# Echo short help message to standard output. 196816ee1e9aSmrgfunc_usage_message () 1969fda9279dSmrg{ 197016ee1e9aSmrg $debug_cmd 1971fda9279dSmrg 197216ee1e9aSmrg eval \$ECHO \""Usage: $usage"\" 197316ee1e9aSmrg echo 197416ee1e9aSmrg $SED -n 's|^# || 197516ee1e9aSmrg /^Written by/{ 197616ee1e9aSmrg x;p;x 197716ee1e9aSmrg } 197816ee1e9aSmrg h 197916ee1e9aSmrg /^Written by/q' < "$progpath" 198016ee1e9aSmrg echo 198116ee1e9aSmrg eval \$ECHO \""$usage_message"\" 198216ee1e9aSmrg} 1983fda9279dSmrg 1984fda9279dSmrg 198516ee1e9aSmrg# func_version 198616ee1e9aSmrg# ------------ 198716ee1e9aSmrg# Echo version message to standard output and exit. 198816ee1e9aSmrgfunc_version () 198916ee1e9aSmrg{ 199016ee1e9aSmrg $debug_cmd 1991fda9279dSmrg 199216ee1e9aSmrg printf '%s\n' "$progname $scriptversion" 199316ee1e9aSmrg $SED -n ' 199416ee1e9aSmrg /(C)/!b go 199516ee1e9aSmrg :more 199616ee1e9aSmrg /\./!{ 199716ee1e9aSmrg N 199816ee1e9aSmrg s|\n# | | 199916ee1e9aSmrg b more 200016ee1e9aSmrg } 200116ee1e9aSmrg :go 200216ee1e9aSmrg /^# Written by /,/# warranty; / { 200316ee1e9aSmrg s|^# || 200416ee1e9aSmrg s|^# *$|| 200516ee1e9aSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 200616ee1e9aSmrg p 200716ee1e9aSmrg } 200816ee1e9aSmrg /^# Written by / { 200916ee1e9aSmrg s|^# || 201016ee1e9aSmrg p 201116ee1e9aSmrg } 201216ee1e9aSmrg /^warranty; /q' < "$progpath" 2013fda9279dSmrg 201416ee1e9aSmrg exit $? 201516ee1e9aSmrg} 2016fda9279dSmrg 2017fda9279dSmrg 201816ee1e9aSmrg# Local variables: 201916ee1e9aSmrg# mode: shell-script 202016ee1e9aSmrg# sh-indentation: 2 202116ee1e9aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 202216ee1e9aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 202316ee1e9aSmrg# time-stamp-time-zone: "UTC" 202416ee1e9aSmrg# End: 2025fda9279dSmrg 202616ee1e9aSmrg# Set a version string. 202716ee1e9aSmrgscriptversion='(GNU libtool) 2.4.6' 2028fda9279dSmrg 2029fda9279dSmrg 203016ee1e9aSmrg# func_echo ARG... 203116ee1e9aSmrg# ---------------- 203216ee1e9aSmrg# Libtool also displays the current mode in messages, so override 203316ee1e9aSmrg# funclib.sh func_echo with this custom definition. 203416ee1e9aSmrgfunc_echo () 2035fda9279dSmrg{ 203616ee1e9aSmrg $debug_cmd 2037fda9279dSmrg 203816ee1e9aSmrg _G_message=$* 203916ee1e9aSmrg 204016ee1e9aSmrg func_echo_IFS=$IFS 204116ee1e9aSmrg IFS=$nl 204216ee1e9aSmrg for _G_line in $_G_message; do 204316ee1e9aSmrg IFS=$func_echo_IFS 204416ee1e9aSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 204516ee1e9aSmrg done 204616ee1e9aSmrg IFS=$func_echo_IFS 204716ee1e9aSmrg} 2048fda9279dSmrg 2049fda9279dSmrg 205016ee1e9aSmrg# func_warning ARG... 205116ee1e9aSmrg# ------------------- 205216ee1e9aSmrg# Libtool warnings are not categorized, so override funclib.sh 205316ee1e9aSmrg# func_warning with this simpler definition. 205416ee1e9aSmrgfunc_warning () 2055fda9279dSmrg{ 205616ee1e9aSmrg $debug_cmd 205716ee1e9aSmrg 205816ee1e9aSmrg $warning_func ${1+"$@"} 205916ee1e9aSmrg} 206016ee1e9aSmrg 2061fda9279dSmrg 206216ee1e9aSmrg## ---------------- ## 206316ee1e9aSmrg## Options parsing. ## 206416ee1e9aSmrg## ---------------- ## 206516ee1e9aSmrg 206616ee1e9aSmrg# Hook in the functions to make sure our own options are parsed during 206716ee1e9aSmrg# the option parsing loop. 206816ee1e9aSmrg 206916ee1e9aSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 207016ee1e9aSmrg 207116ee1e9aSmrg# Short help message in response to '-h'. 207216ee1e9aSmrgusage_message="Options: 207316ee1e9aSmrg --config show all configuration variables 207416ee1e9aSmrg --debug enable verbose shell tracing 207516ee1e9aSmrg -n, --dry-run display commands without modifying any files 207616ee1e9aSmrg --features display basic configuration information and exit 207716ee1e9aSmrg --mode=MODE use operation mode MODE 207816ee1e9aSmrg --no-warnings equivalent to '-Wnone' 207916ee1e9aSmrg --preserve-dup-deps don't remove duplicate dependency libraries 208016ee1e9aSmrg --quiet, --silent don't print informational messages 208116ee1e9aSmrg --tag=TAG use configuration variables from tag TAG 208216ee1e9aSmrg -v, --verbose print more informational messages than default 208316ee1e9aSmrg --version print version information 208416ee1e9aSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 208516ee1e9aSmrg -h, --help, --help-all print short, long, or detailed help message 208616ee1e9aSmrg" 2087fda9279dSmrg 208816ee1e9aSmrg# Additional text appended to 'usage_message' in response to '--help'. 208916ee1e9aSmrgfunc_help () 2090fda9279dSmrg{ 209116ee1e9aSmrg $debug_cmd 209216ee1e9aSmrg 209316ee1e9aSmrg func_usage_message 209416ee1e9aSmrg $ECHO "$long_help_message 209516ee1e9aSmrg 209616ee1e9aSmrgMODE must be one of the following: 209716ee1e9aSmrg 209816ee1e9aSmrg clean remove files from the build directory 209916ee1e9aSmrg compile compile a source file into a libtool object 210016ee1e9aSmrg execute automatically set library path, then run a program 210116ee1e9aSmrg finish complete the installation of libtool libraries 210216ee1e9aSmrg install install libraries or executables 210316ee1e9aSmrg link create a library or an executable 210416ee1e9aSmrg uninstall remove libraries from an installed directory 210516ee1e9aSmrg 210616ee1e9aSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 210716ee1e9aSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 210816ee1e9aSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 210916ee1e9aSmrg 211016ee1e9aSmrgWhen reporting a bug, please describe a test case to reproduce it and 211116ee1e9aSmrginclude the following information: 211216ee1e9aSmrg 211316ee1e9aSmrg host-triplet: $host 211416ee1e9aSmrg shell: $SHELL 211516ee1e9aSmrg compiler: $LTCC 211616ee1e9aSmrg compiler flags: $LTCFLAGS 211716ee1e9aSmrg linker: $LD (gnu? $with_gnu_ld) 211816ee1e9aSmrg version: $progname (GNU libtool) 2.4.6 211916ee1e9aSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 212016ee1e9aSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 212116ee1e9aSmrg 212216ee1e9aSmrgReport bugs to <bug-libtool@gnu.org>. 2123cd34e0e1SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 212416ee1e9aSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 212516ee1e9aSmrg exit 0 212616ee1e9aSmrg} 2127fda9279dSmrg 2128fda9279dSmrg 212916ee1e9aSmrg# func_lo2o OBJECT-NAME 213016ee1e9aSmrg# --------------------- 213116ee1e9aSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 213216ee1e9aSmrg# object suffix. 2133fda9279dSmrg 213416ee1e9aSmrglo2o=s/\\.lo\$/.$objext/ 213516ee1e9aSmrgo2lo=s/\\.$objext\$/.lo/ 2136fda9279dSmrg 213716ee1e9aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 213816ee1e9aSmrg eval 'func_lo2o () 213916ee1e9aSmrg { 214016ee1e9aSmrg case $1 in 214116ee1e9aSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 214216ee1e9aSmrg * ) func_lo2o_result=$1 ;; 214316ee1e9aSmrg esac 214416ee1e9aSmrg }' 214516ee1e9aSmrg 214616ee1e9aSmrg # func_xform LIBOBJ-OR-SOURCE 214716ee1e9aSmrg # --------------------------- 214816ee1e9aSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 214916ee1e9aSmrg # suffix to a '.lo' libtool-object suffix. 215016ee1e9aSmrg eval 'func_xform () 215116ee1e9aSmrg { 215216ee1e9aSmrg func_xform_result=${1%.*}.lo 215316ee1e9aSmrg }' 215416ee1e9aSmrgelse 215516ee1e9aSmrg # ...otherwise fall back to using sed. 215616ee1e9aSmrg func_lo2o () 215716ee1e9aSmrg { 215816ee1e9aSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 215916ee1e9aSmrg } 216016ee1e9aSmrg 216116ee1e9aSmrg func_xform () 216216ee1e9aSmrg { 216316ee1e9aSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 216416ee1e9aSmrg } 216516ee1e9aSmrgfi 2166fda9279dSmrg 2167fda9279dSmrg 216816ee1e9aSmrg# func_fatal_configuration ARG... 216916ee1e9aSmrg# ------------------------------- 2170fda9279dSmrg# Echo program name prefixed message to standard error, followed by 2171fda9279dSmrg# a configuration failure hint, and exit. 2172fda9279dSmrgfunc_fatal_configuration () 2173fda9279dSmrg{ 217416ee1e9aSmrg func__fatal_error ${1+"$@"} \ 217516ee1e9aSmrg "See the $PACKAGE documentation for more information." \ 217616ee1e9aSmrg "Fatal configuration error." 2177fda9279dSmrg} 2178fda9279dSmrg 2179fda9279dSmrg 2180fda9279dSmrg# func_config 218116ee1e9aSmrg# ----------- 2182fda9279dSmrg# Display the configuration for all the tags in this script. 2183fda9279dSmrgfunc_config () 2184fda9279dSmrg{ 2185fda9279dSmrg re_begincf='^# ### BEGIN LIBTOOL' 2186fda9279dSmrg re_endcf='^# ### END LIBTOOL' 2187fda9279dSmrg 2188fda9279dSmrg # Default configuration. 2189fda9279dSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2190fda9279dSmrg 2191fda9279dSmrg # Now print the configurations for the tags. 2192fda9279dSmrg for tagname in $taglist; do 2193fda9279dSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2194fda9279dSmrg done 2195fda9279dSmrg 2196fda9279dSmrg exit $? 2197fda9279dSmrg} 2198fda9279dSmrg 219916ee1e9aSmrg 2200fda9279dSmrg# func_features 220116ee1e9aSmrg# ------------- 2202fda9279dSmrg# Display the features supported by this script. 2203fda9279dSmrgfunc_features () 2204fda9279dSmrg{ 2205fda9279dSmrg echo "host: $host" 220616ee1e9aSmrg if test yes = "$build_libtool_libs"; then 2207fda9279dSmrg echo "enable shared libraries" 2208fda9279dSmrg else 2209fda9279dSmrg echo "disable shared libraries" 2210fda9279dSmrg fi 221116ee1e9aSmrg if test yes = "$build_old_libs"; then 2212fda9279dSmrg echo "enable static libraries" 2213fda9279dSmrg else 2214fda9279dSmrg echo "disable static libraries" 2215fda9279dSmrg fi 2216fda9279dSmrg 2217fda9279dSmrg exit $? 2218fda9279dSmrg} 2219fda9279dSmrg 222016ee1e9aSmrg 222116ee1e9aSmrg# func_enable_tag TAGNAME 222216ee1e9aSmrg# ----------------------- 2223fda9279dSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2224fda9279dSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2225fda9279dSmrg# variable here. 2226fda9279dSmrgfunc_enable_tag () 2227fda9279dSmrg{ 222816ee1e9aSmrg # Global variable: 222916ee1e9aSmrg tagname=$1 2230fda9279dSmrg 223116ee1e9aSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 223216ee1e9aSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 223316ee1e9aSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2234fda9279dSmrg 223516ee1e9aSmrg # Validate tagname. 223616ee1e9aSmrg case $tagname in 223716ee1e9aSmrg *[!-_A-Za-z0-9,/]*) 223816ee1e9aSmrg func_fatal_error "invalid tag name: $tagname" 223916ee1e9aSmrg ;; 224016ee1e9aSmrg esac 2241fda9279dSmrg 224216ee1e9aSmrg # Don't test for the "default" C tag, as we know it's 224316ee1e9aSmrg # there but not specially marked. 224416ee1e9aSmrg case $tagname in 224516ee1e9aSmrg CC) ;; 2246fda9279dSmrg *) 224716ee1e9aSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 224816ee1e9aSmrg taglist="$taglist $tagname" 224916ee1e9aSmrg 225016ee1e9aSmrg # Evaluate the configuration. Be careful to quote the path 225116ee1e9aSmrg # and the sed script, to avoid splitting on whitespace, but 225216ee1e9aSmrg # also don't use non-portable quotes within backquotes within 225316ee1e9aSmrg # quotes we have to do it in 2 steps: 225416ee1e9aSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 225516ee1e9aSmrg eval "$extractedcf" 225616ee1e9aSmrg else 225716ee1e9aSmrg func_error "ignoring unknown tag $tagname" 225816ee1e9aSmrg fi 225916ee1e9aSmrg ;; 226016ee1e9aSmrg esac 2261fda9279dSmrg} 2262fda9279dSmrg 226316ee1e9aSmrg 2264fda9279dSmrg# func_check_version_match 226516ee1e9aSmrg# ------------------------ 2266fda9279dSmrg# Ensure that we are using m4 macros, and libtool script from the same 2267fda9279dSmrg# release of libtool. 2268fda9279dSmrgfunc_check_version_match () 2269fda9279dSmrg{ 227016ee1e9aSmrg if test "$package_revision" != "$macro_revision"; then 227116ee1e9aSmrg if test "$VERSION" != "$macro_version"; then 227216ee1e9aSmrg if test -z "$macro_version"; then 227316ee1e9aSmrg cat >&2 <<_LT_EOF 2274fda9279dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2275fda9279dSmrg$progname: definition of this LT_INIT comes from an older release. 2276fda9279dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2277fda9279dSmrg$progname: and run autoconf again. 2278fda9279dSmrg_LT_EOF 227916ee1e9aSmrg else 228016ee1e9aSmrg cat >&2 <<_LT_EOF 2281fda9279dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2282fda9279dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2283fda9279dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2284fda9279dSmrg$progname: and run autoconf again. 2285fda9279dSmrg_LT_EOF 228616ee1e9aSmrg fi 228716ee1e9aSmrg else 228816ee1e9aSmrg cat >&2 <<_LT_EOF 2289fda9279dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2290fda9279dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2291fda9279dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2292fda9279dSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2293fda9279dSmrg_LT_EOF 229416ee1e9aSmrg fi 2295fda9279dSmrg 229616ee1e9aSmrg exit $EXIT_MISMATCH 229716ee1e9aSmrg fi 2298fda9279dSmrg} 2299fda9279dSmrg 2300fda9279dSmrg 230116ee1e9aSmrg# libtool_options_prep [ARG]... 230216ee1e9aSmrg# ----------------------------- 230316ee1e9aSmrg# Preparation for options parsed by libtool. 230416ee1e9aSmrglibtool_options_prep () 230516ee1e9aSmrg{ 230616ee1e9aSmrg $debug_mode 2307fda9279dSmrg 230816ee1e9aSmrg # Option defaults: 230916ee1e9aSmrg opt_config=false 231016ee1e9aSmrg opt_dlopen= 231116ee1e9aSmrg opt_dry_run=false 231216ee1e9aSmrg opt_help=false 231316ee1e9aSmrg opt_mode= 231416ee1e9aSmrg opt_preserve_dup_deps=false 231516ee1e9aSmrg opt_quiet=false 2316fda9279dSmrg 231716ee1e9aSmrg nonopt= 231816ee1e9aSmrg preserve_args= 2319fda9279dSmrg 232016ee1e9aSmrg # Shorthand for --mode=foo, only valid as the first argument 232116ee1e9aSmrg case $1 in 232216ee1e9aSmrg clean|clea|cle|cl) 232316ee1e9aSmrg shift; set dummy --mode clean ${1+"$@"}; shift 232416ee1e9aSmrg ;; 232516ee1e9aSmrg compile|compil|compi|comp|com|co|c) 232616ee1e9aSmrg shift; set dummy --mode compile ${1+"$@"}; shift 232716ee1e9aSmrg ;; 232816ee1e9aSmrg execute|execut|execu|exec|exe|ex|e) 232916ee1e9aSmrg shift; set dummy --mode execute ${1+"$@"}; shift 233016ee1e9aSmrg ;; 233116ee1e9aSmrg finish|finis|fini|fin|fi|f) 233216ee1e9aSmrg shift; set dummy --mode finish ${1+"$@"}; shift 233316ee1e9aSmrg ;; 233416ee1e9aSmrg install|instal|insta|inst|ins|in|i) 233516ee1e9aSmrg shift; set dummy --mode install ${1+"$@"}; shift 233616ee1e9aSmrg ;; 233716ee1e9aSmrg link|lin|li|l) 233816ee1e9aSmrg shift; set dummy --mode link ${1+"$@"}; shift 233916ee1e9aSmrg ;; 234016ee1e9aSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 234116ee1e9aSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 234216ee1e9aSmrg ;; 234316ee1e9aSmrg esac 234416ee1e9aSmrg 234516ee1e9aSmrg # Pass back the list of options. 234616ee1e9aSmrg func_quote_for_eval ${1+"$@"} 234716ee1e9aSmrg libtool_options_prep_result=$func_quote_for_eval_result 234816ee1e9aSmrg} 234916ee1e9aSmrgfunc_add_hook func_options_prep libtool_options_prep 2350fda9279dSmrg 2351fda9279dSmrg 235216ee1e9aSmrg# libtool_parse_options [ARG]... 235316ee1e9aSmrg# --------------------------------- 235416ee1e9aSmrg# Provide handling for libtool specific options. 235516ee1e9aSmrglibtool_parse_options () 2356fda9279dSmrg{ 235716ee1e9aSmrg $debug_cmd 2358fda9279dSmrg 235916ee1e9aSmrg # Perform our own loop to consume as many options as possible in 236016ee1e9aSmrg # each iteration. 236116ee1e9aSmrg while test $# -gt 0; do 236216ee1e9aSmrg _G_opt=$1 236316ee1e9aSmrg shift 236416ee1e9aSmrg case $_G_opt in 236516ee1e9aSmrg --dry-run|--dryrun|-n) 236616ee1e9aSmrg opt_dry_run=: 236716ee1e9aSmrg ;; 236816ee1e9aSmrg 236916ee1e9aSmrg --config) func_config ;; 237016ee1e9aSmrg 237116ee1e9aSmrg --dlopen|-dlopen) 237216ee1e9aSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 237316ee1e9aSmrg}$1" 237416ee1e9aSmrg shift 237516ee1e9aSmrg ;; 237616ee1e9aSmrg 237716ee1e9aSmrg --preserve-dup-deps) 237816ee1e9aSmrg opt_preserve_dup_deps=: ;; 237916ee1e9aSmrg 238016ee1e9aSmrg --features) func_features ;; 238116ee1e9aSmrg 238216ee1e9aSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 238316ee1e9aSmrg 238416ee1e9aSmrg --help) opt_help=: ;; 238516ee1e9aSmrg 238616ee1e9aSmrg --help-all) opt_help=': help-all' ;; 238716ee1e9aSmrg 238816ee1e9aSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 238916ee1e9aSmrg opt_mode=$1 239016ee1e9aSmrg case $1 in 239116ee1e9aSmrg # Valid mode arguments: 239216ee1e9aSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 239316ee1e9aSmrg 239416ee1e9aSmrg # Catch anything else as an error 239516ee1e9aSmrg *) func_error "invalid argument for $_G_opt" 239616ee1e9aSmrg exit_cmd=exit 239716ee1e9aSmrg break 239816ee1e9aSmrg ;; 239916ee1e9aSmrg esac 240016ee1e9aSmrg shift 240116ee1e9aSmrg ;; 240216ee1e9aSmrg 240316ee1e9aSmrg --no-silent|--no-quiet) 240416ee1e9aSmrg opt_quiet=false 240516ee1e9aSmrg func_append preserve_args " $_G_opt" 240616ee1e9aSmrg ;; 240716ee1e9aSmrg 240816ee1e9aSmrg --no-warnings|--no-warning|--no-warn) 240916ee1e9aSmrg opt_warning=false 241016ee1e9aSmrg func_append preserve_args " $_G_opt" 241116ee1e9aSmrg ;; 241216ee1e9aSmrg 241316ee1e9aSmrg --no-verbose) 241416ee1e9aSmrg opt_verbose=false 241516ee1e9aSmrg func_append preserve_args " $_G_opt" 241616ee1e9aSmrg ;; 241716ee1e9aSmrg 241816ee1e9aSmrg --silent|--quiet) 241916ee1e9aSmrg opt_quiet=: 242016ee1e9aSmrg opt_verbose=false 242116ee1e9aSmrg func_append preserve_args " $_G_opt" 242216ee1e9aSmrg ;; 242316ee1e9aSmrg 242416ee1e9aSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 242516ee1e9aSmrg opt_tag=$1 242616ee1e9aSmrg func_append preserve_args " $_G_opt $1" 242716ee1e9aSmrg func_enable_tag "$1" 242816ee1e9aSmrg shift 242916ee1e9aSmrg ;; 243016ee1e9aSmrg 243116ee1e9aSmrg --verbose|-v) opt_quiet=false 243216ee1e9aSmrg opt_verbose=: 243316ee1e9aSmrg func_append preserve_args " $_G_opt" 243416ee1e9aSmrg ;; 243516ee1e9aSmrg 243616ee1e9aSmrg # An option not handled by this hook function: 243716ee1e9aSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 243816ee1e9aSmrg esac 243916ee1e9aSmrg done 2440fda9279dSmrg 2441fda9279dSmrg 244216ee1e9aSmrg # save modified positional parameters for caller 244316ee1e9aSmrg func_quote_for_eval ${1+"$@"} 244416ee1e9aSmrg libtool_parse_options_result=$func_quote_for_eval_result 244516ee1e9aSmrg} 244616ee1e9aSmrgfunc_add_hook func_parse_options libtool_parse_options 2447fda9279dSmrg 2448fda9279dSmrg 2449fda9279dSmrg 245016ee1e9aSmrg# libtool_validate_options [ARG]... 245116ee1e9aSmrg# --------------------------------- 245216ee1e9aSmrg# Perform any sanity checks on option settings and/or unconsumed 245316ee1e9aSmrg# arguments. 245416ee1e9aSmrglibtool_validate_options () 245516ee1e9aSmrg{ 245616ee1e9aSmrg # save first non-option argument 245716ee1e9aSmrg if test 0 -lt $#; then 245816ee1e9aSmrg nonopt=$1 245916ee1e9aSmrg shift 2460fda9279dSmrg fi 2461fda9279dSmrg 246216ee1e9aSmrg # preserve --debug 246316ee1e9aSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2464fda9279dSmrg 246516ee1e9aSmrg case $host in 246616ee1e9aSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 246716ee1e9aSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 246816ee1e9aSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 246916ee1e9aSmrg # don't eliminate duplications in $postdeps and $predeps 247016ee1e9aSmrg opt_duplicate_compiler_generated_deps=: 247116ee1e9aSmrg ;; 247216ee1e9aSmrg *) 247316ee1e9aSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 247416ee1e9aSmrg ;; 247516ee1e9aSmrg esac 2476fda9279dSmrg 247716ee1e9aSmrg $opt_help || { 247816ee1e9aSmrg # Sanity checks first: 247916ee1e9aSmrg func_check_version_match 2480fda9279dSmrg 248116ee1e9aSmrg test yes != "$build_libtool_libs" \ 248216ee1e9aSmrg && test yes != "$build_old_libs" \ 248316ee1e9aSmrg && func_fatal_configuration "not configured to build any kind of library" 2484fda9279dSmrg 248516ee1e9aSmrg # Darwin sucks 248616ee1e9aSmrg eval std_shrext=\"$shrext_cmds\" 248716ee1e9aSmrg 248816ee1e9aSmrg # Only execute mode is allowed to have -dlopen flags. 248916ee1e9aSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 249016ee1e9aSmrg func_error "unrecognized option '-dlopen'" 249116ee1e9aSmrg $ECHO "$help" 1>&2 249216ee1e9aSmrg exit $EXIT_FAILURE 249316ee1e9aSmrg fi 249416ee1e9aSmrg 249516ee1e9aSmrg # Change the help message to a mode-specific one. 249616ee1e9aSmrg generic_help=$help 249716ee1e9aSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 249816ee1e9aSmrg } 249916ee1e9aSmrg 250016ee1e9aSmrg # Pass back the unparsed argument list 250116ee1e9aSmrg func_quote_for_eval ${1+"$@"} 250216ee1e9aSmrg libtool_validate_options_result=$func_quote_for_eval_result 2503fda9279dSmrg} 250416ee1e9aSmrgfunc_add_hook func_validate_options libtool_validate_options 250516ee1e9aSmrg 2506fda9279dSmrg 250716ee1e9aSmrg# Process options as early as possible so that --help and --version 250816ee1e9aSmrg# can return quickly. 250916ee1e9aSmrgfunc_options ${1+"$@"} 251016ee1e9aSmrgeval set dummy "$func_options_result"; shift 2511fda9279dSmrg 2512fda9279dSmrg 2513fda9279dSmrg 2514fda9279dSmrg## ----------- ## 2515fda9279dSmrg## Main. ## 2516fda9279dSmrg## ----------- ## 2517fda9279dSmrg 251816ee1e9aSmrgmagic='%%%MAGIC variable%%%' 251916ee1e9aSmrgmagic_exe='%%%MAGIC EXE variable%%%' 252016ee1e9aSmrg 252116ee1e9aSmrg# Global variables. 252216ee1e9aSmrgextracted_archives= 252316ee1e9aSmrgextracted_serial=0 252416ee1e9aSmrg 252516ee1e9aSmrg# If this variable is set in any of the actions, the command in it 252616ee1e9aSmrg# will be execed at the end. This prevents here-documents from being 252716ee1e9aSmrg# left over by shells. 252816ee1e9aSmrgexec_cmd= 252916ee1e9aSmrg 253016ee1e9aSmrg 253116ee1e9aSmrg# A function that is used when there is no print builtin or printf. 253216ee1e9aSmrgfunc_fallback_echo () 253316ee1e9aSmrg{ 253416ee1e9aSmrg eval 'cat <<_LTECHO_EOF 253516ee1e9aSmrg$1 253616ee1e9aSmrg_LTECHO_EOF' 253716ee1e9aSmrg} 253816ee1e9aSmrg 253916ee1e9aSmrg# func_generated_by_libtool 254016ee1e9aSmrg# True iff stdin has been generated by Libtool. This function is only 254116ee1e9aSmrg# a basic sanity check; it will hardly flush out determined imposters. 254216ee1e9aSmrgfunc_generated_by_libtool_p () 254316ee1e9aSmrg{ 254416ee1e9aSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 254516ee1e9aSmrg} 254616ee1e9aSmrg 2547fda9279dSmrg# func_lalib_p file 254816ee1e9aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2549fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2550fda9279dSmrg# determined imposters. 2551fda9279dSmrgfunc_lalib_p () 2552fda9279dSmrg{ 2553fda9279dSmrg test -f "$1" && 255416ee1e9aSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2555fda9279dSmrg} 2556fda9279dSmrg 2557fda9279dSmrg# func_lalib_unsafe_p file 255816ee1e9aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2559fda9279dSmrg# This function implements the same check as func_lalib_p without 2560fda9279dSmrg# resorting to external programs. To this end, it redirects stdin and 2561fda9279dSmrg# closes it afterwards, without saving the original file descriptor. 2562fda9279dSmrg# As a safety measure, use it only where a negative result would be 256316ee1e9aSmrg# fatal anyway. Works if 'file' does not exist. 2564fda9279dSmrgfunc_lalib_unsafe_p () 2565fda9279dSmrg{ 2566fda9279dSmrg lalib_p=no 2567fda9279dSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2568fda9279dSmrg for lalib_p_l in 1 2 3 4 2569fda9279dSmrg do 2570fda9279dSmrg read lalib_p_line 257116ee1e9aSmrg case $lalib_p_line in 2572fda9279dSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2573fda9279dSmrg esac 2574fda9279dSmrg done 2575fda9279dSmrg exec 0<&5 5<&- 2576fda9279dSmrg fi 257716ee1e9aSmrg test yes = "$lalib_p" 2578fda9279dSmrg} 2579fda9279dSmrg 2580fda9279dSmrg# func_ltwrapper_script_p file 2581fda9279dSmrg# True iff FILE is a libtool wrapper script 2582fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2583fda9279dSmrg# determined imposters. 2584fda9279dSmrgfunc_ltwrapper_script_p () 2585fda9279dSmrg{ 258616ee1e9aSmrg test -f "$1" && 258716ee1e9aSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2588fda9279dSmrg} 2589fda9279dSmrg 2590fda9279dSmrg# func_ltwrapper_executable_p file 2591fda9279dSmrg# True iff FILE is a libtool wrapper executable 2592fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2593fda9279dSmrg# determined imposters. 2594fda9279dSmrgfunc_ltwrapper_executable_p () 2595fda9279dSmrg{ 2596fda9279dSmrg func_ltwrapper_exec_suffix= 2597fda9279dSmrg case $1 in 2598fda9279dSmrg *.exe) ;; 2599fda9279dSmrg *) func_ltwrapper_exec_suffix=.exe ;; 2600fda9279dSmrg esac 2601fda9279dSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2602fda9279dSmrg} 2603fda9279dSmrg 2604fda9279dSmrg# func_ltwrapper_scriptname file 2605fda9279dSmrg# Assumes file is an ltwrapper_executable 2606fda9279dSmrg# uses $file to determine the appropriate filename for a 2607fda9279dSmrg# temporary ltwrapper_script. 2608fda9279dSmrgfunc_ltwrapper_scriptname () 2609fda9279dSmrg{ 2610fda9279dSmrg func_dirname_and_basename "$1" "" "." 2611fda9279dSmrg func_stripname '' '.exe' "$func_basename_result" 261216ee1e9aSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2613fda9279dSmrg} 2614fda9279dSmrg 2615fda9279dSmrg# func_ltwrapper_p file 2616fda9279dSmrg# True iff FILE is a libtool wrapper script or wrapper executable 2617fda9279dSmrg# This function is only a basic sanity check; it will hardly flush out 2618fda9279dSmrg# determined imposters. 2619fda9279dSmrgfunc_ltwrapper_p () 2620fda9279dSmrg{ 2621fda9279dSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2622fda9279dSmrg} 2623fda9279dSmrg 2624fda9279dSmrg 2625fda9279dSmrg# func_execute_cmds commands fail_cmd 2626fda9279dSmrg# Execute tilde-delimited COMMANDS. 2627fda9279dSmrg# If FAIL_CMD is given, eval that upon failure. 2628fda9279dSmrg# FAIL_CMD may read-access the current command in variable CMD! 2629fda9279dSmrgfunc_execute_cmds () 2630fda9279dSmrg{ 263116ee1e9aSmrg $debug_cmd 263216ee1e9aSmrg 2633fda9279dSmrg save_ifs=$IFS; IFS='~' 2634fda9279dSmrg for cmd in $1; do 263516ee1e9aSmrg IFS=$sp$nl 2636fda9279dSmrg eval cmd=\"$cmd\" 263716ee1e9aSmrg IFS=$save_ifs 2638fda9279dSmrg func_show_eval "$cmd" "${2-:}" 2639fda9279dSmrg done 2640fda9279dSmrg IFS=$save_ifs 2641fda9279dSmrg} 2642fda9279dSmrg 2643fda9279dSmrg 2644fda9279dSmrg# func_source file 2645fda9279dSmrg# Source FILE, adding directory component if necessary. 2646fda9279dSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 2647fda9279dSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2648fda9279dSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 264916ee1e9aSmrg# 'FILE.' does not work on cygwin managed mounts. 2650fda9279dSmrgfunc_source () 2651fda9279dSmrg{ 265216ee1e9aSmrg $debug_cmd 265316ee1e9aSmrg 2654fda9279dSmrg case $1 in 2655fda9279dSmrg */* | *\\*) . "$1" ;; 2656fda9279dSmrg *) . "./$1" ;; 2657fda9279dSmrg esac 2658fda9279dSmrg} 2659fda9279dSmrg 2660fda9279dSmrg 2661fda9279dSmrg# func_resolve_sysroot PATH 2662fda9279dSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2663fda9279dSmrg# func_resolve_sysroot_result 2664fda9279dSmrgfunc_resolve_sysroot () 2665fda9279dSmrg{ 2666fda9279dSmrg func_resolve_sysroot_result=$1 2667fda9279dSmrg case $func_resolve_sysroot_result in 2668fda9279dSmrg =*) 2669fda9279dSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2670fda9279dSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2671fda9279dSmrg ;; 2672fda9279dSmrg esac 2673fda9279dSmrg} 2674fda9279dSmrg 2675fda9279dSmrg# func_replace_sysroot PATH 2676fda9279dSmrg# If PATH begins with the sysroot, replace it with = and 2677fda9279dSmrg# store the result into func_replace_sysroot_result. 2678fda9279dSmrgfunc_replace_sysroot () 2679fda9279dSmrg{ 268016ee1e9aSmrg case $lt_sysroot:$1 in 2681fda9279dSmrg ?*:"$lt_sysroot"*) 2682fda9279dSmrg func_stripname "$lt_sysroot" '' "$1" 268316ee1e9aSmrg func_replace_sysroot_result='='$func_stripname_result 2684fda9279dSmrg ;; 2685fda9279dSmrg *) 2686fda9279dSmrg # Including no sysroot. 2687fda9279dSmrg func_replace_sysroot_result=$1 2688fda9279dSmrg ;; 2689fda9279dSmrg esac 2690fda9279dSmrg} 2691fda9279dSmrg 2692fda9279dSmrg# func_infer_tag arg 2693fda9279dSmrg# Infer tagged configuration to use if any are available and 2694fda9279dSmrg# if one wasn't chosen via the "--tag" command line option. 2695fda9279dSmrg# Only attempt this if the compiler in the base compile 2696fda9279dSmrg# command doesn't match the default compiler. 2697fda9279dSmrg# arg is usually of the form 'gcc ...' 2698fda9279dSmrgfunc_infer_tag () 2699fda9279dSmrg{ 270016ee1e9aSmrg $debug_cmd 270116ee1e9aSmrg 2702fda9279dSmrg if test -n "$available_tags" && test -z "$tagname"; then 2703fda9279dSmrg CC_quoted= 2704fda9279dSmrg for arg in $CC; do 2705fda9279dSmrg func_append_quoted CC_quoted "$arg" 2706fda9279dSmrg done 2707fda9279dSmrg CC_expanded=`func_echo_all $CC` 2708fda9279dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2709fda9279dSmrg case $@ in 2710fda9279dSmrg # Blanks in the command may have been stripped by the calling shell, 2711fda9279dSmrg # but not from the CC environment variable when configure was run. 2712fda9279dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2713fda9279dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2714fda9279dSmrg # Blanks at the start of $base_compile will cause this to fail 2715fda9279dSmrg # if we don't check for them as well. 2716fda9279dSmrg *) 2717fda9279dSmrg for z in $available_tags; do 2718fda9279dSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2719fda9279dSmrg # Evaluate the configuration. 272016ee1e9aSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2721fda9279dSmrg CC_quoted= 2722fda9279dSmrg for arg in $CC; do 2723fda9279dSmrg # Double-quote args containing other shell metacharacters. 2724fda9279dSmrg func_append_quoted CC_quoted "$arg" 2725fda9279dSmrg done 2726fda9279dSmrg CC_expanded=`func_echo_all $CC` 2727fda9279dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2728fda9279dSmrg case "$@ " in 2729fda9279dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2730fda9279dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2731fda9279dSmrg # The compiler in the base compile command matches 2732fda9279dSmrg # the one in the tagged configuration. 2733fda9279dSmrg # Assume this is the tagged configuration we want. 2734fda9279dSmrg tagname=$z 2735fda9279dSmrg break 2736fda9279dSmrg ;; 2737fda9279dSmrg esac 2738fda9279dSmrg fi 2739fda9279dSmrg done 2740fda9279dSmrg # If $tagname still isn't set, then no tagged configuration 2741fda9279dSmrg # was found and let the user know that the "--tag" command 2742fda9279dSmrg # line option must be used. 2743fda9279dSmrg if test -z "$tagname"; then 2744fda9279dSmrg func_echo "unable to infer tagged configuration" 274516ee1e9aSmrg func_fatal_error "specify a tag with '--tag'" 2746fda9279dSmrg# else 2747fda9279dSmrg# func_verbose "using $tagname tagged configuration" 2748fda9279dSmrg fi 2749fda9279dSmrg ;; 2750fda9279dSmrg esac 2751fda9279dSmrg fi 2752fda9279dSmrg} 2753fda9279dSmrg 2754fda9279dSmrg 2755fda9279dSmrg 2756fda9279dSmrg# func_write_libtool_object output_name pic_name nonpic_name 2757fda9279dSmrg# Create a libtool object file (analogous to a ".la" file), 2758fda9279dSmrg# but don't create it if we're doing a dry run. 2759fda9279dSmrgfunc_write_libtool_object () 2760fda9279dSmrg{ 276116ee1e9aSmrg write_libobj=$1 276216ee1e9aSmrg if test yes = "$build_libtool_libs"; then 276316ee1e9aSmrg write_lobj=\'$2\' 2764fda9279dSmrg else 2765fda9279dSmrg write_lobj=none 2766fda9279dSmrg fi 2767fda9279dSmrg 276816ee1e9aSmrg if test yes = "$build_old_libs"; then 276916ee1e9aSmrg write_oldobj=\'$3\' 2770fda9279dSmrg else 2771fda9279dSmrg write_oldobj=none 2772fda9279dSmrg fi 2773fda9279dSmrg 2774fda9279dSmrg $opt_dry_run || { 2775fda9279dSmrg cat >${write_libobj}T <<EOF 2776fda9279dSmrg# $write_libobj - a libtool object file 277716ee1e9aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2778fda9279dSmrg# 2779fda9279dSmrg# Please DO NOT delete this file! 2780fda9279dSmrg# It is necessary for linking the library. 2781fda9279dSmrg 2782fda9279dSmrg# Name of the PIC object. 2783fda9279dSmrgpic_object=$write_lobj 2784fda9279dSmrg 2785fda9279dSmrg# Name of the non-PIC object 2786fda9279dSmrgnon_pic_object=$write_oldobj 2787fda9279dSmrg 2788fda9279dSmrgEOF 278916ee1e9aSmrg $MV "${write_libobj}T" "$write_libobj" 2790fda9279dSmrg } 2791fda9279dSmrg} 2792fda9279dSmrg 2793fda9279dSmrg 2794fda9279dSmrg################################################## 2795fda9279dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2796fda9279dSmrg################################################## 2797fda9279dSmrg 2798fda9279dSmrg# func_convert_core_file_wine_to_w32 ARG 2799fda9279dSmrg# Helper function used by file name conversion functions when $build is *nix, 2800fda9279dSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2801fda9279dSmrg# correctly configured wine environment available, with the winepath program 2802fda9279dSmrg# in $build's $PATH. 2803fda9279dSmrg# 2804fda9279dSmrg# ARG is the $build file name to be converted to w32 format. 2805fda9279dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2806fda9279dSmrg# be empty on error (or when ARG is empty) 2807fda9279dSmrgfunc_convert_core_file_wine_to_w32 () 2808fda9279dSmrg{ 280916ee1e9aSmrg $debug_cmd 281016ee1e9aSmrg 281116ee1e9aSmrg func_convert_core_file_wine_to_w32_result=$1 2812fda9279dSmrg if test -n "$1"; then 2813fda9279dSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2814fda9279dSmrg # are forced to check the contents of stdout. On the other hand, if the 2815fda9279dSmrg # command is not found, the shell will set an exit code of 127 and print 2816fda9279dSmrg # *an error message* to stdout. So we must check for both error code of 2817fda9279dSmrg # zero AND non-empty stdout, which explains the odd construction: 2818fda9279dSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 281916ee1e9aSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2820fda9279dSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 282116ee1e9aSmrg $SED -e "$sed_naive_backslashify"` 2822fda9279dSmrg else 2823fda9279dSmrg func_convert_core_file_wine_to_w32_result= 2824fda9279dSmrg fi 2825fda9279dSmrg fi 2826fda9279dSmrg} 2827fda9279dSmrg# end: func_convert_core_file_wine_to_w32 2828fda9279dSmrg 2829fda9279dSmrg 2830fda9279dSmrg# func_convert_core_path_wine_to_w32 ARG 2831fda9279dSmrg# Helper function used by path conversion functions when $build is *nix, and 2832fda9279dSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2833fda9279dSmrg# configured wine environment available, with the winepath program in $build's 2834fda9279dSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2835fda9279dSmrg# 2836fda9279dSmrg# ARG is path to be converted from $build format to win32. 2837fda9279dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2838fda9279dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2839fda9279dSmrg# are convertible, then the result may be empty. 2840fda9279dSmrgfunc_convert_core_path_wine_to_w32 () 2841fda9279dSmrg{ 284216ee1e9aSmrg $debug_cmd 284316ee1e9aSmrg 2844fda9279dSmrg # unfortunately, winepath doesn't convert paths, only file names 284516ee1e9aSmrg func_convert_core_path_wine_to_w32_result= 2846fda9279dSmrg if test -n "$1"; then 2847fda9279dSmrg oldIFS=$IFS 2848fda9279dSmrg IFS=: 2849fda9279dSmrg for func_convert_core_path_wine_to_w32_f in $1; do 2850fda9279dSmrg IFS=$oldIFS 2851fda9279dSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 285216ee1e9aSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2853fda9279dSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 285416ee1e9aSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2855fda9279dSmrg else 2856fda9279dSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2857fda9279dSmrg fi 2858fda9279dSmrg fi 2859fda9279dSmrg done 2860fda9279dSmrg IFS=$oldIFS 2861fda9279dSmrg fi 2862fda9279dSmrg} 2863fda9279dSmrg# end: func_convert_core_path_wine_to_w32 2864fda9279dSmrg 2865fda9279dSmrg 2866fda9279dSmrg# func_cygpath ARGS... 2867fda9279dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2868fda9279dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2869fda9279dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2870fda9279dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2871fda9279dSmrg# file name or path is assumed to be in w32 format, as previously converted 2872fda9279dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2873fda9279dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 2874fda9279dSmrg# Cygwin format). Returns an empty string on error. 2875fda9279dSmrg# 2876fda9279dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 2877fda9279dSmrg# be converted. 2878fda9279dSmrg# 2879fda9279dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2880fda9279dSmrg# environment variable; do not put it in $PATH. 2881fda9279dSmrgfunc_cygpath () 2882fda9279dSmrg{ 288316ee1e9aSmrg $debug_cmd 288416ee1e9aSmrg 2885fda9279dSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2886fda9279dSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2887fda9279dSmrg if test "$?" -ne 0; then 2888fda9279dSmrg # on failure, ensure result is empty 2889fda9279dSmrg func_cygpath_result= 2890fda9279dSmrg fi 2891fda9279dSmrg else 2892fda9279dSmrg func_cygpath_result= 289316ee1e9aSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2894fda9279dSmrg fi 2895fda9279dSmrg} 2896fda9279dSmrg#end: func_cygpath 2897fda9279dSmrg 2898fda9279dSmrg 2899fda9279dSmrg# func_convert_core_msys_to_w32 ARG 2900fda9279dSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 2901fda9279dSmrg# result in func_convert_core_msys_to_w32_result. 2902fda9279dSmrgfunc_convert_core_msys_to_w32 () 2903fda9279dSmrg{ 290416ee1e9aSmrg $debug_cmd 290516ee1e9aSmrg 2906fda9279dSmrg # awkward: cmd appends spaces to result 2907fda9279dSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 290816ee1e9aSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2909fda9279dSmrg} 2910fda9279dSmrg#end: func_convert_core_msys_to_w32 2911fda9279dSmrg 2912fda9279dSmrg 2913fda9279dSmrg# func_convert_file_check ARG1 ARG2 2914fda9279dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 2915fda9279dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2916fda9279dSmrg# func_to_host_file_result to ARG1). 2917fda9279dSmrgfunc_convert_file_check () 2918fda9279dSmrg{ 291916ee1e9aSmrg $debug_cmd 292016ee1e9aSmrg 292116ee1e9aSmrg if test -z "$2" && test -n "$1"; then 2922fda9279dSmrg func_error "Could not determine host file name corresponding to" 292316ee1e9aSmrg func_error " '$1'" 2924fda9279dSmrg func_error "Continuing, but uninstalled executables may not work." 2925fda9279dSmrg # Fallback: 292616ee1e9aSmrg func_to_host_file_result=$1 2927fda9279dSmrg fi 2928fda9279dSmrg} 2929fda9279dSmrg# end func_convert_file_check 2930fda9279dSmrg 2931fda9279dSmrg 2932fda9279dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2933fda9279dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2934fda9279dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2935fda9279dSmrg# func_to_host_file_result to a simplistic fallback value (see below). 2936fda9279dSmrgfunc_convert_path_check () 2937fda9279dSmrg{ 293816ee1e9aSmrg $debug_cmd 293916ee1e9aSmrg 2940fda9279dSmrg if test -z "$4" && test -n "$3"; then 2941fda9279dSmrg func_error "Could not determine the host path corresponding to" 294216ee1e9aSmrg func_error " '$3'" 2943fda9279dSmrg func_error "Continuing, but uninstalled executables may not work." 2944fda9279dSmrg # Fallback. This is a deliberately simplistic "conversion" and 2945fda9279dSmrg # should not be "improved". See libtool.info. 2946fda9279dSmrg if test "x$1" != "x$2"; then 2947fda9279dSmrg lt_replace_pathsep_chars="s|$1|$2|g" 2948fda9279dSmrg func_to_host_path_result=`echo "$3" | 2949fda9279dSmrg $SED -e "$lt_replace_pathsep_chars"` 2950fda9279dSmrg else 295116ee1e9aSmrg func_to_host_path_result=$3 2952fda9279dSmrg fi 2953fda9279dSmrg fi 2954fda9279dSmrg} 2955fda9279dSmrg# end func_convert_path_check 2956fda9279dSmrg 2957fda9279dSmrg 2958fda9279dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2959fda9279dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2960fda9279dSmrg# and appending REPL if ORIG matches BACKPAT. 2961fda9279dSmrgfunc_convert_path_front_back_pathsep () 2962fda9279dSmrg{ 296316ee1e9aSmrg $debug_cmd 296416ee1e9aSmrg 2965fda9279dSmrg case $4 in 296616ee1e9aSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2967fda9279dSmrg ;; 2968fda9279dSmrg esac 2969fda9279dSmrg case $4 in 2970fda9279dSmrg $2 ) func_append func_to_host_path_result "$3" 2971fda9279dSmrg ;; 2972fda9279dSmrg esac 2973fda9279dSmrg} 2974fda9279dSmrg# end func_convert_path_front_back_pathsep 2975fda9279dSmrg 2976fda9279dSmrg 2977fda9279dSmrg################################################## 2978fda9279dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2979fda9279dSmrg################################################## 298016ee1e9aSmrg# invoked via '$to_host_file_cmd ARG' 2981fda9279dSmrg# 2982fda9279dSmrg# In each case, ARG is the path to be converted from $build to $host format. 2983fda9279dSmrg# Result will be available in $func_to_host_file_result. 2984fda9279dSmrg 2985fda9279dSmrg 2986fda9279dSmrg# func_to_host_file ARG 2987fda9279dSmrg# Converts the file name ARG from $build format to $host format. Return result 2988fda9279dSmrg# in func_to_host_file_result. 2989fda9279dSmrgfunc_to_host_file () 2990fda9279dSmrg{ 299116ee1e9aSmrg $debug_cmd 299216ee1e9aSmrg 2993fda9279dSmrg $to_host_file_cmd "$1" 2994fda9279dSmrg} 2995fda9279dSmrg# end func_to_host_file 2996fda9279dSmrg 2997fda9279dSmrg 2998fda9279dSmrg# func_to_tool_file ARG LAZY 2999fda9279dSmrg# converts the file name ARG from $build format to toolchain format. Return 3000fda9279dSmrg# result in func_to_tool_file_result. If the conversion in use is listed 3001fda9279dSmrg# in (the comma separated) LAZY, no conversion takes place. 3002fda9279dSmrgfunc_to_tool_file () 3003fda9279dSmrg{ 300416ee1e9aSmrg $debug_cmd 300516ee1e9aSmrg 3006fda9279dSmrg case ,$2, in 3007fda9279dSmrg *,"$to_tool_file_cmd",*) 3008fda9279dSmrg func_to_tool_file_result=$1 3009fda9279dSmrg ;; 3010fda9279dSmrg *) 3011fda9279dSmrg $to_tool_file_cmd "$1" 3012fda9279dSmrg func_to_tool_file_result=$func_to_host_file_result 3013fda9279dSmrg ;; 3014fda9279dSmrg esac 3015fda9279dSmrg} 3016fda9279dSmrg# end func_to_tool_file 3017fda9279dSmrg 3018fda9279dSmrg 3019fda9279dSmrg# func_convert_file_noop ARG 3020fda9279dSmrg# Copy ARG to func_to_host_file_result. 3021fda9279dSmrgfunc_convert_file_noop () 3022fda9279dSmrg{ 302316ee1e9aSmrg func_to_host_file_result=$1 3024fda9279dSmrg} 3025fda9279dSmrg# end func_convert_file_noop 3026fda9279dSmrg 3027fda9279dSmrg 3028fda9279dSmrg# func_convert_file_msys_to_w32 ARG 3029fda9279dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3030fda9279dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3031fda9279dSmrg# func_to_host_file_result. 3032fda9279dSmrgfunc_convert_file_msys_to_w32 () 3033fda9279dSmrg{ 303416ee1e9aSmrg $debug_cmd 303516ee1e9aSmrg 303616ee1e9aSmrg func_to_host_file_result=$1 3037fda9279dSmrg if test -n "$1"; then 3038fda9279dSmrg func_convert_core_msys_to_w32 "$1" 303916ee1e9aSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3040fda9279dSmrg fi 3041fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3042fda9279dSmrg} 3043fda9279dSmrg# end func_convert_file_msys_to_w32 3044fda9279dSmrg 3045fda9279dSmrg 3046fda9279dSmrg# func_convert_file_cygwin_to_w32 ARG 3047fda9279dSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3048fda9279dSmrg# func_to_host_file_result. 3049fda9279dSmrgfunc_convert_file_cygwin_to_w32 () 3050fda9279dSmrg{ 305116ee1e9aSmrg $debug_cmd 305216ee1e9aSmrg 305316ee1e9aSmrg func_to_host_file_result=$1 3054fda9279dSmrg if test -n "$1"; then 3055fda9279dSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3056fda9279dSmrg # LT_CYGPATH in this case. 3057fda9279dSmrg func_to_host_file_result=`cygpath -m "$1"` 3058fda9279dSmrg fi 3059fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3060fda9279dSmrg} 3061fda9279dSmrg# end func_convert_file_cygwin_to_w32 3062fda9279dSmrg 3063fda9279dSmrg 3064fda9279dSmrg# func_convert_file_nix_to_w32 ARG 3065fda9279dSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3066fda9279dSmrg# and a working winepath. Returns result in func_to_host_file_result. 3067fda9279dSmrgfunc_convert_file_nix_to_w32 () 3068fda9279dSmrg{ 306916ee1e9aSmrg $debug_cmd 307016ee1e9aSmrg 307116ee1e9aSmrg func_to_host_file_result=$1 3072fda9279dSmrg if test -n "$1"; then 3073fda9279dSmrg func_convert_core_file_wine_to_w32 "$1" 307416ee1e9aSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3075fda9279dSmrg fi 3076fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3077fda9279dSmrg} 3078fda9279dSmrg# end func_convert_file_nix_to_w32 3079fda9279dSmrg 3080fda9279dSmrg 3081fda9279dSmrg# func_convert_file_msys_to_cygwin ARG 3082fda9279dSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3083fda9279dSmrg# Returns result in func_to_host_file_result. 3084fda9279dSmrgfunc_convert_file_msys_to_cygwin () 3085fda9279dSmrg{ 308616ee1e9aSmrg $debug_cmd 308716ee1e9aSmrg 308816ee1e9aSmrg func_to_host_file_result=$1 3089fda9279dSmrg if test -n "$1"; then 3090fda9279dSmrg func_convert_core_msys_to_w32 "$1" 3091fda9279dSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 309216ee1e9aSmrg func_to_host_file_result=$func_cygpath_result 3093fda9279dSmrg fi 3094fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3095fda9279dSmrg} 3096fda9279dSmrg# end func_convert_file_msys_to_cygwin 3097fda9279dSmrg 3098fda9279dSmrg 3099fda9279dSmrg# func_convert_file_nix_to_cygwin ARG 3100fda9279dSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3101fda9279dSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3102fda9279dSmrg# in func_to_host_file_result. 3103fda9279dSmrgfunc_convert_file_nix_to_cygwin () 3104fda9279dSmrg{ 310516ee1e9aSmrg $debug_cmd 310616ee1e9aSmrg 310716ee1e9aSmrg func_to_host_file_result=$1 3108fda9279dSmrg if test -n "$1"; then 3109fda9279dSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3110fda9279dSmrg func_convert_core_file_wine_to_w32 "$1" 3111fda9279dSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 311216ee1e9aSmrg func_to_host_file_result=$func_cygpath_result 3113fda9279dSmrg fi 3114fda9279dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3115fda9279dSmrg} 3116fda9279dSmrg# end func_convert_file_nix_to_cygwin 3117fda9279dSmrg 3118fda9279dSmrg 3119fda9279dSmrg############################################# 3120fda9279dSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3121fda9279dSmrg############################################# 312216ee1e9aSmrg# invoked via '$to_host_path_cmd ARG' 3123fda9279dSmrg# 3124fda9279dSmrg# In each case, ARG is the path to be converted from $build to $host format. 3125fda9279dSmrg# The result will be available in $func_to_host_path_result. 3126fda9279dSmrg# 3127fda9279dSmrg# Path separators are also converted from $build format to $host format. If 3128fda9279dSmrg# ARG begins or ends with a path separator character, it is preserved (but 3129fda9279dSmrg# converted to $host format) on output. 3130fda9279dSmrg# 3131fda9279dSmrg# All path conversion functions are named using the following convention: 3132fda9279dSmrg# file name conversion function : func_convert_file_X_to_Y () 3133fda9279dSmrg# path conversion function : func_convert_path_X_to_Y () 3134fda9279dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3135fda9279dSmrg# same. If conversion functions are added for new $build/$host combinations, 3136fda9279dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3137fda9279dSmrg# will break. 3138fda9279dSmrg 3139fda9279dSmrg 3140fda9279dSmrg# func_init_to_host_path_cmd 3141fda9279dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3142fda9279dSmrg# appropriate value, based on the value of $to_host_file_cmd. 3143fda9279dSmrgto_host_path_cmd= 3144fda9279dSmrgfunc_init_to_host_path_cmd () 3145fda9279dSmrg{ 314616ee1e9aSmrg $debug_cmd 314716ee1e9aSmrg 3148fda9279dSmrg if test -z "$to_host_path_cmd"; then 3149fda9279dSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 315016ee1e9aSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3151fda9279dSmrg fi 3152fda9279dSmrg} 3153fda9279dSmrg 3154fda9279dSmrg 3155fda9279dSmrg# func_to_host_path ARG 3156fda9279dSmrg# Converts the path ARG from $build format to $host format. Return result 3157fda9279dSmrg# in func_to_host_path_result. 3158fda9279dSmrgfunc_to_host_path () 3159fda9279dSmrg{ 316016ee1e9aSmrg $debug_cmd 316116ee1e9aSmrg 3162fda9279dSmrg func_init_to_host_path_cmd 3163fda9279dSmrg $to_host_path_cmd "$1" 3164fda9279dSmrg} 3165fda9279dSmrg# end func_to_host_path 3166fda9279dSmrg 3167fda9279dSmrg 3168fda9279dSmrg# func_convert_path_noop ARG 3169fda9279dSmrg# Copy ARG to func_to_host_path_result. 3170fda9279dSmrgfunc_convert_path_noop () 3171fda9279dSmrg{ 317216ee1e9aSmrg func_to_host_path_result=$1 3173fda9279dSmrg} 3174fda9279dSmrg# end func_convert_path_noop 3175fda9279dSmrg 3176fda9279dSmrg 3177fda9279dSmrg# func_convert_path_msys_to_w32 ARG 3178fda9279dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3179fda9279dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3180fda9279dSmrg# func_to_host_path_result. 3181fda9279dSmrgfunc_convert_path_msys_to_w32 () 3182fda9279dSmrg{ 318316ee1e9aSmrg $debug_cmd 318416ee1e9aSmrg 318516ee1e9aSmrg func_to_host_path_result=$1 3186fda9279dSmrg if test -n "$1"; then 3187fda9279dSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3188fda9279dSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3189fda9279dSmrg # and winepath ignores them completely. 3190fda9279dSmrg func_stripname : : "$1" 3191fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3192fda9279dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 319316ee1e9aSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3194fda9279dSmrg func_convert_path_check : ";" \ 3195fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3196fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3197fda9279dSmrg fi 3198fda9279dSmrg} 3199fda9279dSmrg# end func_convert_path_msys_to_w32 3200fda9279dSmrg 3201fda9279dSmrg 3202fda9279dSmrg# func_convert_path_cygwin_to_w32 ARG 3203fda9279dSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3204fda9279dSmrg# func_to_host_file_result. 3205fda9279dSmrgfunc_convert_path_cygwin_to_w32 () 3206fda9279dSmrg{ 320716ee1e9aSmrg $debug_cmd 320816ee1e9aSmrg 320916ee1e9aSmrg func_to_host_path_result=$1 3210fda9279dSmrg if test -n "$1"; then 3211fda9279dSmrg # See func_convert_path_msys_to_w32: 3212fda9279dSmrg func_stripname : : "$1" 3213fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3214fda9279dSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3215fda9279dSmrg func_convert_path_check : ";" \ 3216fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3217fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3218fda9279dSmrg fi 3219fda9279dSmrg} 3220fda9279dSmrg# end func_convert_path_cygwin_to_w32 3221fda9279dSmrg 3222fda9279dSmrg 3223fda9279dSmrg# func_convert_path_nix_to_w32 ARG 3224fda9279dSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3225fda9279dSmrg# a working winepath. Returns result in func_to_host_file_result. 3226fda9279dSmrgfunc_convert_path_nix_to_w32 () 3227fda9279dSmrg{ 322816ee1e9aSmrg $debug_cmd 322916ee1e9aSmrg 323016ee1e9aSmrg func_to_host_path_result=$1 3231fda9279dSmrg if test -n "$1"; then 3232fda9279dSmrg # See func_convert_path_msys_to_w32: 3233fda9279dSmrg func_stripname : : "$1" 3234fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3235fda9279dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323616ee1e9aSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3237fda9279dSmrg func_convert_path_check : ";" \ 3238fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3239fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3240fda9279dSmrg fi 3241fda9279dSmrg} 3242fda9279dSmrg# end func_convert_path_nix_to_w32 3243fda9279dSmrg 3244fda9279dSmrg 3245fda9279dSmrg# func_convert_path_msys_to_cygwin ARG 3246fda9279dSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3247fda9279dSmrg# Returns result in func_to_host_file_result. 3248fda9279dSmrgfunc_convert_path_msys_to_cygwin () 3249fda9279dSmrg{ 325016ee1e9aSmrg $debug_cmd 325116ee1e9aSmrg 325216ee1e9aSmrg func_to_host_path_result=$1 3253fda9279dSmrg if test -n "$1"; then 3254fda9279dSmrg # See func_convert_path_msys_to_w32: 3255fda9279dSmrg func_stripname : : "$1" 3256fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3257fda9279dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3258fda9279dSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 325916ee1e9aSmrg func_to_host_path_result=$func_cygpath_result 3260fda9279dSmrg func_convert_path_check : : \ 3261fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3262fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3263fda9279dSmrg fi 3264fda9279dSmrg} 3265fda9279dSmrg# end func_convert_path_msys_to_cygwin 3266fda9279dSmrg 3267fda9279dSmrg 3268fda9279dSmrg# func_convert_path_nix_to_cygwin ARG 3269fda9279dSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3270fda9279dSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3271fda9279dSmrg# func_to_host_file_result. 3272fda9279dSmrgfunc_convert_path_nix_to_cygwin () 3273fda9279dSmrg{ 327416ee1e9aSmrg $debug_cmd 327516ee1e9aSmrg 327616ee1e9aSmrg func_to_host_path_result=$1 3277fda9279dSmrg if test -n "$1"; then 3278fda9279dSmrg # Remove leading and trailing path separator characters from 3279fda9279dSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3280fda9279dSmrg # into '.;' and ';.', and winepath ignores them completely. 3281fda9279dSmrg func_stripname : : "$1" 3282fda9279dSmrg func_to_host_path_tmp1=$func_stripname_result 3283fda9279dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3284fda9279dSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 328516ee1e9aSmrg func_to_host_path_result=$func_cygpath_result 3286fda9279dSmrg func_convert_path_check : : \ 3287fda9279dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3288fda9279dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3289fda9279dSmrg fi 3290fda9279dSmrg} 3291fda9279dSmrg# end func_convert_path_nix_to_cygwin 3292fda9279dSmrg 3293fda9279dSmrg 329416ee1e9aSmrg# func_dll_def_p FILE 329516ee1e9aSmrg# True iff FILE is a Windows DLL '.def' file. 329616ee1e9aSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 329716ee1e9aSmrgfunc_dll_def_p () 329816ee1e9aSmrg{ 329916ee1e9aSmrg $debug_cmd 330016ee1e9aSmrg 330116ee1e9aSmrg func_dll_def_p_tmp=`$SED -n \ 330216ee1e9aSmrg -e 's/^[ ]*//' \ 330316ee1e9aSmrg -e '/^\(;.*\)*$/d' \ 330416ee1e9aSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 330516ee1e9aSmrg -e q \ 330616ee1e9aSmrg "$1"` 330716ee1e9aSmrg test DEF = "$func_dll_def_p_tmp" 330816ee1e9aSmrg} 330916ee1e9aSmrg 331016ee1e9aSmrg 3311fda9279dSmrg# func_mode_compile arg... 3312fda9279dSmrgfunc_mode_compile () 3313fda9279dSmrg{ 331416ee1e9aSmrg $debug_cmd 331516ee1e9aSmrg 3316fda9279dSmrg # Get the compilation command and the source file. 3317fda9279dSmrg base_compile= 331816ee1e9aSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3319fda9279dSmrg suppress_opt=yes 3320fda9279dSmrg suppress_output= 3321fda9279dSmrg arg_mode=normal 3322fda9279dSmrg libobj= 3323fda9279dSmrg later= 3324fda9279dSmrg pie_flag= 3325fda9279dSmrg 3326fda9279dSmrg for arg 3327fda9279dSmrg do 3328fda9279dSmrg case $arg_mode in 3329fda9279dSmrg arg ) 3330fda9279dSmrg # do not "continue". Instead, add this to base_compile 333116ee1e9aSmrg lastarg=$arg 3332fda9279dSmrg arg_mode=normal 3333fda9279dSmrg ;; 3334fda9279dSmrg 3335fda9279dSmrg target ) 333616ee1e9aSmrg libobj=$arg 3337fda9279dSmrg arg_mode=normal 3338fda9279dSmrg continue 3339fda9279dSmrg ;; 3340fda9279dSmrg 3341fda9279dSmrg normal ) 3342fda9279dSmrg # Accept any command-line options. 3343fda9279dSmrg case $arg in 3344fda9279dSmrg -o) 3345fda9279dSmrg test -n "$libobj" && \ 334616ee1e9aSmrg func_fatal_error "you cannot specify '-o' more than once" 3347fda9279dSmrg arg_mode=target 3348fda9279dSmrg continue 3349fda9279dSmrg ;; 3350fda9279dSmrg 3351fda9279dSmrg -pie | -fpie | -fPIE) 3352fda9279dSmrg func_append pie_flag " $arg" 3353fda9279dSmrg continue 3354fda9279dSmrg ;; 3355fda9279dSmrg 3356fda9279dSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 3357fda9279dSmrg func_append later " $arg" 3358fda9279dSmrg continue 3359fda9279dSmrg ;; 3360fda9279dSmrg 3361fda9279dSmrg -no-suppress) 3362fda9279dSmrg suppress_opt=no 3363fda9279dSmrg continue 3364fda9279dSmrg ;; 3365fda9279dSmrg 3366fda9279dSmrg -Xcompiler) 3367fda9279dSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3368fda9279dSmrg continue # The current "srcfile" will either be retained or 3369fda9279dSmrg ;; # replaced later. I would guess that would be a bug. 3370fda9279dSmrg 3371fda9279dSmrg -Wc,*) 3372fda9279dSmrg func_stripname '-Wc,' '' "$arg" 3373fda9279dSmrg args=$func_stripname_result 3374fda9279dSmrg lastarg= 337516ee1e9aSmrg save_ifs=$IFS; IFS=, 3376fda9279dSmrg for arg in $args; do 337716ee1e9aSmrg IFS=$save_ifs 3378fda9279dSmrg func_append_quoted lastarg "$arg" 3379fda9279dSmrg done 338016ee1e9aSmrg IFS=$save_ifs 3381fda9279dSmrg func_stripname ' ' '' "$lastarg" 3382fda9279dSmrg lastarg=$func_stripname_result 3383fda9279dSmrg 3384fda9279dSmrg # Add the arguments to base_compile. 3385fda9279dSmrg func_append base_compile " $lastarg" 3386fda9279dSmrg continue 3387fda9279dSmrg ;; 3388fda9279dSmrg 3389fda9279dSmrg *) 3390fda9279dSmrg # Accept the current argument as the source file. 3391fda9279dSmrg # The previous "srcfile" becomes the current argument. 3392fda9279dSmrg # 339316ee1e9aSmrg lastarg=$srcfile 339416ee1e9aSmrg srcfile=$arg 3395fda9279dSmrg ;; 3396fda9279dSmrg esac # case $arg 3397fda9279dSmrg ;; 3398fda9279dSmrg esac # case $arg_mode 3399fda9279dSmrg 3400fda9279dSmrg # Aesthetically quote the previous argument. 3401fda9279dSmrg func_append_quoted base_compile "$lastarg" 3402fda9279dSmrg done # for arg 3403fda9279dSmrg 3404fda9279dSmrg case $arg_mode in 3405fda9279dSmrg arg) 3406fda9279dSmrg func_fatal_error "you must specify an argument for -Xcompile" 3407fda9279dSmrg ;; 3408fda9279dSmrg target) 340916ee1e9aSmrg func_fatal_error "you must specify a target with '-o'" 3410fda9279dSmrg ;; 3411fda9279dSmrg *) 3412fda9279dSmrg # Get the name of the library object. 3413fda9279dSmrg test -z "$libobj" && { 3414fda9279dSmrg func_basename "$srcfile" 341516ee1e9aSmrg libobj=$func_basename_result 3416fda9279dSmrg } 3417fda9279dSmrg ;; 3418fda9279dSmrg esac 3419fda9279dSmrg 3420fda9279dSmrg # Recognize several different file suffixes. 3421fda9279dSmrg # If the user specifies -o file.o, it is replaced with file.lo 3422fda9279dSmrg case $libobj in 3423fda9279dSmrg *.[cCFSifmso] | \ 3424fda9279dSmrg *.ada | *.adb | *.ads | *.asm | \ 3425fda9279dSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3426fda9279dSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3427fda9279dSmrg func_xform "$libobj" 3428fda9279dSmrg libobj=$func_xform_result 3429fda9279dSmrg ;; 3430fda9279dSmrg esac 3431fda9279dSmrg 3432fda9279dSmrg case $libobj in 3433fda9279dSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3434fda9279dSmrg *) 343516ee1e9aSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3436fda9279dSmrg ;; 3437fda9279dSmrg esac 3438fda9279dSmrg 3439fda9279dSmrg func_infer_tag $base_compile 3440fda9279dSmrg 3441fda9279dSmrg for arg in $later; do 3442fda9279dSmrg case $arg in 3443fda9279dSmrg -shared) 344416ee1e9aSmrg test yes = "$build_libtool_libs" \ 344516ee1e9aSmrg || func_fatal_configuration "cannot build a shared library" 3446fda9279dSmrg build_old_libs=no 3447fda9279dSmrg continue 3448fda9279dSmrg ;; 3449fda9279dSmrg 3450fda9279dSmrg -static) 3451fda9279dSmrg build_libtool_libs=no 3452fda9279dSmrg build_old_libs=yes 3453fda9279dSmrg continue 3454fda9279dSmrg ;; 3455fda9279dSmrg 3456fda9279dSmrg -prefer-pic) 3457fda9279dSmrg pic_mode=yes 3458fda9279dSmrg continue 3459fda9279dSmrg ;; 3460fda9279dSmrg 3461fda9279dSmrg -prefer-non-pic) 3462fda9279dSmrg pic_mode=no 3463fda9279dSmrg continue 3464fda9279dSmrg ;; 3465fda9279dSmrg esac 3466fda9279dSmrg done 3467fda9279dSmrg 3468fda9279dSmrg func_quote_for_eval "$libobj" 3469fda9279dSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3470fda9279dSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 347116ee1e9aSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3472fda9279dSmrg func_dirname_and_basename "$obj" "/" "" 347316ee1e9aSmrg objname=$func_basename_result 347416ee1e9aSmrg xdir=$func_dirname_result 347516ee1e9aSmrg lobj=$xdir$objdir/$objname 3476fda9279dSmrg 3477fda9279dSmrg test -z "$base_compile" && \ 3478fda9279dSmrg func_fatal_help "you must specify a compilation command" 3479fda9279dSmrg 3480fda9279dSmrg # Delete any leftover library objects. 348116ee1e9aSmrg if test yes = "$build_old_libs"; then 3482fda9279dSmrg removelist="$obj $lobj $libobj ${libobj}T" 3483fda9279dSmrg else 3484fda9279dSmrg removelist="$lobj $libobj ${libobj}T" 3485fda9279dSmrg fi 3486fda9279dSmrg 3487fda9279dSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3488fda9279dSmrg case $host_os in 3489fda9279dSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3490fda9279dSmrg pic_mode=default 3491fda9279dSmrg ;; 3492fda9279dSmrg esac 349316ee1e9aSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3494fda9279dSmrg # non-PIC code in shared libraries is not supported 3495fda9279dSmrg pic_mode=default 3496fda9279dSmrg fi 3497fda9279dSmrg 3498fda9279dSmrg # Calculate the filename of the output object if compiler does 3499fda9279dSmrg # not support -o with -c 350016ee1e9aSmrg if test no = "$compiler_c_o"; then 350116ee1e9aSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 350216ee1e9aSmrg lockfile=$output_obj.lock 3503fda9279dSmrg else 3504fda9279dSmrg output_obj= 3505fda9279dSmrg need_locks=no 3506fda9279dSmrg lockfile= 3507fda9279dSmrg fi 3508fda9279dSmrg 3509fda9279dSmrg # Lock this critical section if it is needed 3510fda9279dSmrg # We use this script file to make the link, it avoids creating a new file 351116ee1e9aSmrg if test yes = "$need_locks"; then 3512fda9279dSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3513fda9279dSmrg func_echo "Waiting for $lockfile to be removed" 3514fda9279dSmrg sleep 2 3515fda9279dSmrg done 351616ee1e9aSmrg elif test warn = "$need_locks"; then 3517fda9279dSmrg if test -f "$lockfile"; then 3518fda9279dSmrg $ECHO "\ 3519fda9279dSmrg*** ERROR, $lockfile exists and contains: 3520fda9279dSmrg`cat $lockfile 2>/dev/null` 3521fda9279dSmrg 3522fda9279dSmrgThis indicates that another process is trying to use the same 3523fda9279dSmrgtemporary object file, and libtool could not work around it because 352416ee1e9aSmrgyour compiler does not support '-c' and '-o' together. If you 3525fda9279dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3526fda9279dSmrgavoid parallel builds (make -j) in this platform, or get a better 3527fda9279dSmrgcompiler." 3528fda9279dSmrg 3529fda9279dSmrg $opt_dry_run || $RM $removelist 3530fda9279dSmrg exit $EXIT_FAILURE 3531fda9279dSmrg fi 3532fda9279dSmrg func_append removelist " $output_obj" 3533fda9279dSmrg $ECHO "$srcfile" > "$lockfile" 3534fda9279dSmrg fi 3535fda9279dSmrg 3536fda9279dSmrg $opt_dry_run || $RM $removelist 3537fda9279dSmrg func_append removelist " $lockfile" 3538fda9279dSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3539fda9279dSmrg 3540fda9279dSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3541fda9279dSmrg srcfile=$func_to_tool_file_result 3542fda9279dSmrg func_quote_for_eval "$srcfile" 3543fda9279dSmrg qsrcfile=$func_quote_for_eval_result 3544fda9279dSmrg 3545fda9279dSmrg # Only build a PIC object if we are building libtool libraries. 354616ee1e9aSmrg if test yes = "$build_libtool_libs"; then 3547fda9279dSmrg # Without this assignment, base_compile gets emptied. 3548fda9279dSmrg fbsd_hideous_sh_bug=$base_compile 3549fda9279dSmrg 355016ee1e9aSmrg if test no != "$pic_mode"; then 3551fda9279dSmrg command="$base_compile $qsrcfile $pic_flag" 3552fda9279dSmrg else 3553fda9279dSmrg # Don't build PIC code 3554fda9279dSmrg command="$base_compile $qsrcfile" 3555fda9279dSmrg fi 3556fda9279dSmrg 3557fda9279dSmrg func_mkdir_p "$xdir$objdir" 3558fda9279dSmrg 3559fda9279dSmrg if test -z "$output_obj"; then 3560fda9279dSmrg # Place PIC objects in $objdir 3561fda9279dSmrg func_append command " -o $lobj" 3562fda9279dSmrg fi 3563fda9279dSmrg 3564fda9279dSmrg func_show_eval_locale "$command" \ 3565fda9279dSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3566fda9279dSmrg 356716ee1e9aSmrg if test warn = "$need_locks" && 3568fda9279dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3569fda9279dSmrg $ECHO "\ 3570fda9279dSmrg*** ERROR, $lockfile contains: 3571fda9279dSmrg`cat $lockfile 2>/dev/null` 3572fda9279dSmrg 3573fda9279dSmrgbut it should contain: 3574fda9279dSmrg$srcfile 3575fda9279dSmrg 3576fda9279dSmrgThis indicates that another process is trying to use the same 3577fda9279dSmrgtemporary object file, and libtool could not work around it because 357816ee1e9aSmrgyour compiler does not support '-c' and '-o' together. If you 3579fda9279dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3580fda9279dSmrgavoid parallel builds (make -j) in this platform, or get a better 3581fda9279dSmrgcompiler." 3582fda9279dSmrg 3583fda9279dSmrg $opt_dry_run || $RM $removelist 3584fda9279dSmrg exit $EXIT_FAILURE 3585fda9279dSmrg fi 3586fda9279dSmrg 3587fda9279dSmrg # Just move the object if needed, then go on to compile the next one 3588fda9279dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3589fda9279dSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3590fda9279dSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3591fda9279dSmrg fi 3592fda9279dSmrg 3593fda9279dSmrg # Allow error messages only from the first compilation. 359416ee1e9aSmrg if test yes = "$suppress_opt"; then 3595fda9279dSmrg suppress_output=' >/dev/null 2>&1' 3596fda9279dSmrg fi 3597fda9279dSmrg fi 3598fda9279dSmrg 3599fda9279dSmrg # Only build a position-dependent object if we build old libraries. 360016ee1e9aSmrg if test yes = "$build_old_libs"; then 360116ee1e9aSmrg if test yes != "$pic_mode"; then 3602fda9279dSmrg # Don't build PIC code 3603fda9279dSmrg command="$base_compile $qsrcfile$pie_flag" 3604fda9279dSmrg else 3605fda9279dSmrg command="$base_compile $qsrcfile $pic_flag" 3606fda9279dSmrg fi 360716ee1e9aSmrg if test yes = "$compiler_c_o"; then 3608fda9279dSmrg func_append command " -o $obj" 3609fda9279dSmrg fi 3610fda9279dSmrg 3611fda9279dSmrg # Suppress compiler output if we already did a PIC compilation. 3612fda9279dSmrg func_append command "$suppress_output" 3613fda9279dSmrg func_show_eval_locale "$command" \ 3614fda9279dSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3615fda9279dSmrg 361616ee1e9aSmrg if test warn = "$need_locks" && 3617fda9279dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3618fda9279dSmrg $ECHO "\ 3619fda9279dSmrg*** ERROR, $lockfile contains: 3620fda9279dSmrg`cat $lockfile 2>/dev/null` 3621fda9279dSmrg 3622fda9279dSmrgbut it should contain: 3623fda9279dSmrg$srcfile 3624fda9279dSmrg 3625fda9279dSmrgThis indicates that another process is trying to use the same 3626fda9279dSmrgtemporary object file, and libtool could not work around it because 362716ee1e9aSmrgyour compiler does not support '-c' and '-o' together. If you 3628fda9279dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3629fda9279dSmrgavoid parallel builds (make -j) in this platform, or get a better 3630fda9279dSmrgcompiler." 3631fda9279dSmrg 3632fda9279dSmrg $opt_dry_run || $RM $removelist 3633fda9279dSmrg exit $EXIT_FAILURE 3634fda9279dSmrg fi 3635fda9279dSmrg 3636fda9279dSmrg # Just move the object if needed 3637fda9279dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3638fda9279dSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 3639fda9279dSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3640fda9279dSmrg fi 3641fda9279dSmrg fi 3642fda9279dSmrg 3643fda9279dSmrg $opt_dry_run || { 3644fda9279dSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3645fda9279dSmrg 3646fda9279dSmrg # Unlock the critical section if it was locked 364716ee1e9aSmrg if test no != "$need_locks"; then 3648fda9279dSmrg removelist=$lockfile 3649fda9279dSmrg $RM "$lockfile" 3650fda9279dSmrg fi 3651fda9279dSmrg } 3652fda9279dSmrg 3653fda9279dSmrg exit $EXIT_SUCCESS 3654fda9279dSmrg} 3655fda9279dSmrg 3656fda9279dSmrg$opt_help || { 365716ee1e9aSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3658fda9279dSmrg} 3659fda9279dSmrg 3660fda9279dSmrgfunc_mode_help () 3661fda9279dSmrg{ 3662fda9279dSmrg # We need to display help for each of the modes. 3663fda9279dSmrg case $opt_mode in 3664fda9279dSmrg "") 3665fda9279dSmrg # Generic help is extracted from the usage comments 3666fda9279dSmrg # at the start of this file. 3667fda9279dSmrg func_help 3668fda9279dSmrg ;; 3669fda9279dSmrg 3670fda9279dSmrg clean) 3671fda9279dSmrg $ECHO \ 3672fda9279dSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3673fda9279dSmrg 3674fda9279dSmrgRemove files from the build directory. 3675fda9279dSmrg 3676fda9279dSmrgRM is the name of the program to use to delete files associated with each FILE 367716ee1e9aSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3678fda9279dSmrgto RM. 3679fda9279dSmrg 3680fda9279dSmrgIf FILE is a libtool library, object or program, all the files associated 3681fda9279dSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3682fda9279dSmrg ;; 3683fda9279dSmrg 3684fda9279dSmrg compile) 3685fda9279dSmrg $ECHO \ 3686fda9279dSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3687fda9279dSmrg 3688fda9279dSmrgCompile a source file into a libtool library object. 3689fda9279dSmrg 3690fda9279dSmrgThis mode accepts the following additional options: 3691fda9279dSmrg 3692fda9279dSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3693fda9279dSmrg -no-suppress do not suppress compiler output for multiple passes 3694fda9279dSmrg -prefer-pic try to build PIC objects only 3695fda9279dSmrg -prefer-non-pic try to build non-PIC objects only 369616ee1e9aSmrg -shared do not build a '.o' file suitable for static linking 369716ee1e9aSmrg -static only build a '.o' file suitable for static linking 3698fda9279dSmrg -Wc,FLAG pass FLAG directly to the compiler 3699fda9279dSmrg 370016ee1e9aSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3701fda9279dSmrgfrom the given SOURCEFILE. 3702fda9279dSmrg 3703fda9279dSmrgThe output file name is determined by removing the directory component from 370416ee1e9aSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 370516ee1e9aSmrglibrary object suffix, '.lo'." 3706fda9279dSmrg ;; 3707fda9279dSmrg 3708fda9279dSmrg execute) 3709fda9279dSmrg $ECHO \ 3710fda9279dSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3711fda9279dSmrg 3712fda9279dSmrgAutomatically set library path, then run a program. 3713fda9279dSmrg 3714fda9279dSmrgThis mode accepts the following additional options: 3715fda9279dSmrg 3716fda9279dSmrg -dlopen FILE add the directory containing FILE to the library path 3717fda9279dSmrg 371816ee1e9aSmrgThis mode sets the library path environment variable according to '-dlopen' 3719fda9279dSmrgflags. 3720fda9279dSmrg 3721fda9279dSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3722fda9279dSmrginto their corresponding uninstalled binary, and any of their required library 3723fda9279dSmrgdirectories are added to the library path. 3724fda9279dSmrg 3725fda9279dSmrgThen, COMMAND is executed, with ARGS as arguments." 3726fda9279dSmrg ;; 3727fda9279dSmrg 3728fda9279dSmrg finish) 3729fda9279dSmrg $ECHO \ 3730fda9279dSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3731fda9279dSmrg 3732fda9279dSmrgComplete the installation of libtool libraries. 3733fda9279dSmrg 3734fda9279dSmrgEach LIBDIR is a directory that contains libtool libraries. 3735fda9279dSmrg 3736fda9279dSmrgThe commands that this mode executes may require superuser privileges. Use 373716ee1e9aSmrgthe '--dry-run' option if you just want to see what would be executed." 3738fda9279dSmrg ;; 3739fda9279dSmrg 3740fda9279dSmrg install) 3741fda9279dSmrg $ECHO \ 3742fda9279dSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3743fda9279dSmrg 3744fda9279dSmrgInstall executables or libraries. 3745fda9279dSmrg 3746fda9279dSmrgINSTALL-COMMAND is the installation command. The first component should be 374716ee1e9aSmrgeither the 'install' or 'cp' program. 3748fda9279dSmrg 3749fda9279dSmrgThe following components of INSTALL-COMMAND are treated specially: 3750fda9279dSmrg 3751fda9279dSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3752fda9279dSmrg 3753fda9279dSmrgThe rest of the components are interpreted as arguments to that command (only 3754fda9279dSmrgBSD-compatible install options are recognized)." 3755fda9279dSmrg ;; 3756fda9279dSmrg 3757fda9279dSmrg link) 3758fda9279dSmrg $ECHO \ 3759fda9279dSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3760fda9279dSmrg 3761fda9279dSmrgLink object files or libraries together to form another library, or to 3762fda9279dSmrgcreate an executable program. 3763fda9279dSmrg 3764fda9279dSmrgLINK-COMMAND is a command using the C compiler that you would use to create 3765fda9279dSmrga program from several object files. 3766fda9279dSmrg 3767fda9279dSmrgThe following components of LINK-COMMAND are treated specially: 3768fda9279dSmrg 3769fda9279dSmrg -all-static do not do any dynamic linking at all 3770fda9279dSmrg -avoid-version do not add a version suffix if possible 3771fda9279dSmrg -bindir BINDIR specify path to binaries directory (for systems where 3772fda9279dSmrg libraries must be found in the PATH setting at runtime) 377316ee1e9aSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3774fda9279dSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3775fda9279dSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3776fda9279dSmrg -export-symbols SYMFILE 3777fda9279dSmrg try to export only the symbols listed in SYMFILE 3778fda9279dSmrg -export-symbols-regex REGEX 3779fda9279dSmrg try to export only the symbols matching REGEX 3780fda9279dSmrg -LLIBDIR search LIBDIR for required installed libraries 3781fda9279dSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 3782fda9279dSmrg -module build a library that can dlopened 3783fda9279dSmrg -no-fast-install disable the fast-install mode 3784fda9279dSmrg -no-install link a not-installable executable 3785fda9279dSmrg -no-undefined declare that a library does not refer to external symbols 3786fda9279dSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 378716ee1e9aSmrg -objectlist FILE use a list of object files found in FILE to specify objects 378816ee1e9aSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3789fda9279dSmrg -precious-files-regex REGEX 3790fda9279dSmrg don't remove output files matching REGEX 3791fda9279dSmrg -release RELEASE specify package release information 3792fda9279dSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3793fda9279dSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3794fda9279dSmrg -shared only do dynamic linking of libtool libraries 3795fda9279dSmrg -shrext SUFFIX override the standard shared library file extension 3796fda9279dSmrg -static do not do any dynamic linking of uninstalled libtool libraries 3797fda9279dSmrg -static-libtool-libs 3798fda9279dSmrg do not do any dynamic linking of libtool libraries 3799fda9279dSmrg -version-info CURRENT[:REVISION[:AGE]] 3800fda9279dSmrg specify library version info [each variable defaults to 0] 3801fda9279dSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 3802fda9279dSmrg -Wc,FLAG 3803fda9279dSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3804fda9279dSmrg -Wl,FLAG 3805fda9279dSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3806fda9279dSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3807fda9279dSmrg 380816ee1e9aSmrgAll other options (arguments beginning with '-') are ignored. 3809fda9279dSmrg 381016ee1e9aSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3811fda9279dSmrgtreated as uninstalled libtool libraries, other files are standard or library 3812fda9279dSmrgobject files. 3813fda9279dSmrg 381416ee1e9aSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 381516ee1e9aSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3816fda9279dSmrgrequired, except when creating a convenience library. 3817fda9279dSmrg 381816ee1e9aSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 381916ee1e9aSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3820fda9279dSmrg 382116ee1e9aSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3822fda9279dSmrgis created, otherwise an executable program is created." 3823fda9279dSmrg ;; 3824fda9279dSmrg 3825fda9279dSmrg uninstall) 3826fda9279dSmrg $ECHO \ 3827fda9279dSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3828fda9279dSmrg 3829fda9279dSmrgRemove libraries from an installation directory. 3830fda9279dSmrg 3831fda9279dSmrgRM is the name of the program to use to delete files associated with each FILE 383216ee1e9aSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3833fda9279dSmrgto RM. 3834fda9279dSmrg 3835fda9279dSmrgIf FILE is a libtool library, all the files associated with it are deleted. 3836fda9279dSmrgOtherwise, only FILE itself is deleted using RM." 3837fda9279dSmrg ;; 3838fda9279dSmrg 3839fda9279dSmrg *) 384016ee1e9aSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3841fda9279dSmrg ;; 3842fda9279dSmrg esac 3843fda9279dSmrg 3844fda9279dSmrg echo 384516ee1e9aSmrg $ECHO "Try '$progname --help' for more information about other modes." 3846fda9279dSmrg} 3847fda9279dSmrg 3848fda9279dSmrg# Now that we've collected a possible --mode arg, show help if necessary 3849fda9279dSmrgif $opt_help; then 385016ee1e9aSmrg if test : = "$opt_help"; then 3851fda9279dSmrg func_mode_help 3852fda9279dSmrg else 3853fda9279dSmrg { 3854fda9279dSmrg func_help noexit 3855fda9279dSmrg for opt_mode in compile link execute install finish uninstall clean; do 3856fda9279dSmrg func_mode_help 3857fda9279dSmrg done 385816ee1e9aSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3859fda9279dSmrg { 3860fda9279dSmrg func_help noexit 3861fda9279dSmrg for opt_mode in compile link execute install finish uninstall clean; do 3862fda9279dSmrg echo 3863fda9279dSmrg func_mode_help 3864fda9279dSmrg done 3865fda9279dSmrg } | 386616ee1e9aSmrg $SED '1d 3867fda9279dSmrg /^When reporting/,/^Report/{ 3868fda9279dSmrg H 3869fda9279dSmrg d 3870fda9279dSmrg } 3871fda9279dSmrg $x 3872fda9279dSmrg /information about other modes/d 3873fda9279dSmrg /more detailed .*MODE/d 3874fda9279dSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3875fda9279dSmrg fi 3876fda9279dSmrg exit $? 3877fda9279dSmrgfi 3878fda9279dSmrg 3879fda9279dSmrg 3880fda9279dSmrg# func_mode_execute arg... 3881fda9279dSmrgfunc_mode_execute () 3882fda9279dSmrg{ 388316ee1e9aSmrg $debug_cmd 388416ee1e9aSmrg 3885fda9279dSmrg # The first argument is the command name. 388616ee1e9aSmrg cmd=$nonopt 3887fda9279dSmrg test -z "$cmd" && \ 3888fda9279dSmrg func_fatal_help "you must specify a COMMAND" 3889fda9279dSmrg 3890fda9279dSmrg # Handle -dlopen flags immediately. 3891fda9279dSmrg for file in $opt_dlopen; do 3892fda9279dSmrg test -f "$file" \ 389316ee1e9aSmrg || func_fatal_help "'$file' is not a file" 3894fda9279dSmrg 3895fda9279dSmrg dir= 3896fda9279dSmrg case $file in 3897fda9279dSmrg *.la) 3898fda9279dSmrg func_resolve_sysroot "$file" 3899fda9279dSmrg file=$func_resolve_sysroot_result 3900fda9279dSmrg 3901fda9279dSmrg # Check to see that this really is a libtool archive. 3902fda9279dSmrg func_lalib_unsafe_p "$file" \ 390316ee1e9aSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3904fda9279dSmrg 3905fda9279dSmrg # Read the libtool library. 3906fda9279dSmrg dlname= 3907fda9279dSmrg library_names= 3908fda9279dSmrg func_source "$file" 3909fda9279dSmrg 3910fda9279dSmrg # Skip this library if it cannot be dlopened. 3911fda9279dSmrg if test -z "$dlname"; then 3912fda9279dSmrg # Warn if it was a shared library. 3913fda9279dSmrg test -n "$library_names" && \ 391416ee1e9aSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3915fda9279dSmrg continue 3916fda9279dSmrg fi 3917fda9279dSmrg 3918fda9279dSmrg func_dirname "$file" "" "." 391916ee1e9aSmrg dir=$func_dirname_result 3920fda9279dSmrg 3921fda9279dSmrg if test -f "$dir/$objdir/$dlname"; then 3922fda9279dSmrg func_append dir "/$objdir" 3923fda9279dSmrg else 3924fda9279dSmrg if test ! -f "$dir/$dlname"; then 392516ee1e9aSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3926fda9279dSmrg fi 3927fda9279dSmrg fi 3928fda9279dSmrg ;; 3929fda9279dSmrg 3930fda9279dSmrg *.lo) 3931fda9279dSmrg # Just add the directory containing the .lo file. 3932fda9279dSmrg func_dirname "$file" "" "." 393316ee1e9aSmrg dir=$func_dirname_result 3934fda9279dSmrg ;; 3935fda9279dSmrg 3936fda9279dSmrg *) 393716ee1e9aSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3938fda9279dSmrg continue 3939fda9279dSmrg ;; 3940fda9279dSmrg esac 3941fda9279dSmrg 3942fda9279dSmrg # Get the absolute pathname. 3943fda9279dSmrg absdir=`cd "$dir" && pwd` 394416ee1e9aSmrg test -n "$absdir" && dir=$absdir 3945fda9279dSmrg 3946fda9279dSmrg # Now add the directory to shlibpath_var. 3947fda9279dSmrg if eval "test -z \"\$$shlibpath_var\""; then 3948fda9279dSmrg eval "$shlibpath_var=\"\$dir\"" 3949fda9279dSmrg else 3950fda9279dSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3951fda9279dSmrg fi 3952fda9279dSmrg done 3953fda9279dSmrg 3954fda9279dSmrg # This variable tells wrapper scripts just to set shlibpath_var 3955fda9279dSmrg # rather than running their programs. 395616ee1e9aSmrg libtool_execute_magic=$magic 3957fda9279dSmrg 3958fda9279dSmrg # Check if any of the arguments is a wrapper script. 3959fda9279dSmrg args= 3960fda9279dSmrg for file 3961fda9279dSmrg do 3962fda9279dSmrg case $file in 3963fda9279dSmrg -* | *.la | *.lo ) ;; 3964fda9279dSmrg *) 3965fda9279dSmrg # Do a test to see if this is really a libtool program. 3966fda9279dSmrg if func_ltwrapper_script_p "$file"; then 3967fda9279dSmrg func_source "$file" 3968fda9279dSmrg # Transform arg to wrapped name. 396916ee1e9aSmrg file=$progdir/$program 3970fda9279dSmrg elif func_ltwrapper_executable_p "$file"; then 3971fda9279dSmrg func_ltwrapper_scriptname "$file" 3972fda9279dSmrg func_source "$func_ltwrapper_scriptname_result" 3973fda9279dSmrg # Transform arg to wrapped name. 397416ee1e9aSmrg file=$progdir/$program 3975fda9279dSmrg fi 3976fda9279dSmrg ;; 3977fda9279dSmrg esac 3978fda9279dSmrg # Quote arguments (to preserve shell metacharacters). 3979fda9279dSmrg func_append_quoted args "$file" 3980fda9279dSmrg done 3981fda9279dSmrg 398216ee1e9aSmrg if $opt_dry_run; then 398316ee1e9aSmrg # Display what would be done. 398416ee1e9aSmrg if test -n "$shlibpath_var"; then 398516ee1e9aSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 398616ee1e9aSmrg echo "export $shlibpath_var" 398716ee1e9aSmrg fi 398816ee1e9aSmrg $ECHO "$cmd$args" 398916ee1e9aSmrg exit $EXIT_SUCCESS 399016ee1e9aSmrg else 3991fda9279dSmrg if test -n "$shlibpath_var"; then 3992fda9279dSmrg # Export the shlibpath_var. 3993fda9279dSmrg eval "export $shlibpath_var" 3994fda9279dSmrg fi 3995fda9279dSmrg 3996fda9279dSmrg # Restore saved environment variables 3997fda9279dSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3998fda9279dSmrg do 3999fda9279dSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 4000fda9279dSmrg $lt_var=\$save_$lt_var; export $lt_var 4001fda9279dSmrg else 4002fda9279dSmrg $lt_unset $lt_var 4003fda9279dSmrg fi" 4004fda9279dSmrg done 4005fda9279dSmrg 4006fda9279dSmrg # Now prepare to actually exec the command. 400716ee1e9aSmrg exec_cmd=\$cmd$args 4008fda9279dSmrg fi 4009fda9279dSmrg} 4010fda9279dSmrg 401116ee1e9aSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4012fda9279dSmrg 4013fda9279dSmrg 4014fda9279dSmrg# func_mode_finish arg... 4015fda9279dSmrgfunc_mode_finish () 4016fda9279dSmrg{ 401716ee1e9aSmrg $debug_cmd 401816ee1e9aSmrg 4019fda9279dSmrg libs= 4020fda9279dSmrg libdirs= 4021fda9279dSmrg admincmds= 4022fda9279dSmrg 4023fda9279dSmrg for opt in "$nonopt" ${1+"$@"} 4024fda9279dSmrg do 4025fda9279dSmrg if test -d "$opt"; then 4026fda9279dSmrg func_append libdirs " $opt" 4027fda9279dSmrg 4028fda9279dSmrg elif test -f "$opt"; then 4029fda9279dSmrg if func_lalib_unsafe_p "$opt"; then 4030fda9279dSmrg func_append libs " $opt" 4031fda9279dSmrg else 403216ee1e9aSmrg func_warning "'$opt' is not a valid libtool archive" 4033fda9279dSmrg fi 4034fda9279dSmrg 4035fda9279dSmrg else 403616ee1e9aSmrg func_fatal_error "invalid argument '$opt'" 4037fda9279dSmrg fi 4038fda9279dSmrg done 4039fda9279dSmrg 4040fda9279dSmrg if test -n "$libs"; then 4041fda9279dSmrg if test -n "$lt_sysroot"; then 4042fda9279dSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4043fda9279dSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4044fda9279dSmrg else 4045fda9279dSmrg sysroot_cmd= 4046fda9279dSmrg fi 4047fda9279dSmrg 4048fda9279dSmrg # Remove sysroot references 4049fda9279dSmrg if $opt_dry_run; then 4050fda9279dSmrg for lib in $libs; do 405116ee1e9aSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4052fda9279dSmrg done 4053fda9279dSmrg else 4054fda9279dSmrg tmpdir=`func_mktempdir` 4055fda9279dSmrg for lib in $libs; do 405616ee1e9aSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4057fda9279dSmrg > $tmpdir/tmp-la 4058fda9279dSmrg mv -f $tmpdir/tmp-la $lib 4059fda9279dSmrg done 4060fda9279dSmrg ${RM}r "$tmpdir" 4061fda9279dSmrg fi 4062fda9279dSmrg fi 4063fda9279dSmrg 4064fda9279dSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4065fda9279dSmrg for libdir in $libdirs; do 4066fda9279dSmrg if test -n "$finish_cmds"; then 4067fda9279dSmrg # Do each command in the finish commands. 4068fda9279dSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4069fda9279dSmrg'"$cmd"'"' 4070fda9279dSmrg fi 4071fda9279dSmrg if test -n "$finish_eval"; then 4072fda9279dSmrg # Do the single finish_eval. 4073fda9279dSmrg eval cmds=\"$finish_eval\" 4074fda9279dSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4075fda9279dSmrg $cmds" 4076fda9279dSmrg fi 4077fda9279dSmrg done 4078fda9279dSmrg fi 4079fda9279dSmrg 4080fda9279dSmrg # Exit here if they wanted silent mode. 408116ee1e9aSmrg $opt_quiet && exit $EXIT_SUCCESS 4082fda9279dSmrg 4083fda9279dSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4084fda9279dSmrg echo "----------------------------------------------------------------------" 4085fda9279dSmrg echo "Libraries have been installed in:" 4086fda9279dSmrg for libdir in $libdirs; do 4087fda9279dSmrg $ECHO " $libdir" 4088fda9279dSmrg done 4089fda9279dSmrg echo 4090fda9279dSmrg echo "If you ever happen to want to link against installed libraries" 4091fda9279dSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 409216ee1e9aSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4093fda9279dSmrg echo "flag during linking and do at least one of the following:" 4094fda9279dSmrg if test -n "$shlibpath_var"; then 409516ee1e9aSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4096fda9279dSmrg echo " during execution" 4097fda9279dSmrg fi 4098fda9279dSmrg if test -n "$runpath_var"; then 409916ee1e9aSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4100fda9279dSmrg echo " during linking" 4101fda9279dSmrg fi 4102fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 4103fda9279dSmrg libdir=LIBDIR 4104fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4105fda9279dSmrg 410616ee1e9aSmrg $ECHO " - use the '$flag' linker flag" 4107fda9279dSmrg fi 4108fda9279dSmrg if test -n "$admincmds"; then 4109fda9279dSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4110fda9279dSmrg fi 4111fda9279dSmrg if test -f /etc/ld.so.conf; then 411216ee1e9aSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4113fda9279dSmrg fi 4114fda9279dSmrg echo 4115fda9279dSmrg 4116fda9279dSmrg echo "See any operating system documentation about shared libraries for" 4117fda9279dSmrg case $host in 4118fda9279dSmrg solaris2.[6789]|solaris2.1[0-9]) 4119fda9279dSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4120fda9279dSmrg echo "pages." 4121fda9279dSmrg ;; 4122fda9279dSmrg *) 4123fda9279dSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4124fda9279dSmrg ;; 4125fda9279dSmrg esac 4126fda9279dSmrg echo "----------------------------------------------------------------------" 4127fda9279dSmrg fi 4128fda9279dSmrg exit $EXIT_SUCCESS 4129fda9279dSmrg} 4130fda9279dSmrg 413116ee1e9aSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4132fda9279dSmrg 4133fda9279dSmrg 4134fda9279dSmrg# func_mode_install arg... 4135fda9279dSmrgfunc_mode_install () 4136fda9279dSmrg{ 413716ee1e9aSmrg $debug_cmd 413816ee1e9aSmrg 4139fda9279dSmrg # There may be an optional sh(1) argument at the beginning of 4140fda9279dSmrg # install_prog (especially on Windows NT). 414116ee1e9aSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4142fda9279dSmrg # Allow the use of GNU shtool's install command. 414316ee1e9aSmrg case $nonopt in *shtool*) :;; *) false;; esac 414416ee1e9aSmrg then 4145fda9279dSmrg # Aesthetically quote it. 4146fda9279dSmrg func_quote_for_eval "$nonopt" 4147fda9279dSmrg install_prog="$func_quote_for_eval_result " 4148fda9279dSmrg arg=$1 4149fda9279dSmrg shift 4150fda9279dSmrg else 4151fda9279dSmrg install_prog= 4152fda9279dSmrg arg=$nonopt 4153fda9279dSmrg fi 4154fda9279dSmrg 4155fda9279dSmrg # The real first argument should be the name of the installation program. 4156fda9279dSmrg # Aesthetically quote it. 4157fda9279dSmrg func_quote_for_eval "$arg" 4158fda9279dSmrg func_append install_prog "$func_quote_for_eval_result" 4159fda9279dSmrg install_shared_prog=$install_prog 4160fda9279dSmrg case " $install_prog " in 4161fda9279dSmrg *[\\\ /]cp\ *) install_cp=: ;; 4162fda9279dSmrg *) install_cp=false ;; 4163fda9279dSmrg esac 4164fda9279dSmrg 4165fda9279dSmrg # We need to accept at least all the BSD install flags. 4166fda9279dSmrg dest= 4167fda9279dSmrg files= 4168fda9279dSmrg opts= 4169fda9279dSmrg prev= 4170fda9279dSmrg install_type= 417116ee1e9aSmrg isdir=false 4172fda9279dSmrg stripme= 4173fda9279dSmrg no_mode=: 4174fda9279dSmrg for arg 4175fda9279dSmrg do 4176fda9279dSmrg arg2= 4177fda9279dSmrg if test -n "$dest"; then 4178fda9279dSmrg func_append files " $dest" 4179fda9279dSmrg dest=$arg 4180fda9279dSmrg continue 4181fda9279dSmrg fi 4182fda9279dSmrg 4183fda9279dSmrg case $arg in 418416ee1e9aSmrg -d) isdir=: ;; 4185fda9279dSmrg -f) 4186fda9279dSmrg if $install_cp; then :; else 4187fda9279dSmrg prev=$arg 4188fda9279dSmrg fi 4189fda9279dSmrg ;; 4190fda9279dSmrg -g | -m | -o) 4191fda9279dSmrg prev=$arg 4192fda9279dSmrg ;; 4193fda9279dSmrg -s) 4194fda9279dSmrg stripme=" -s" 4195fda9279dSmrg continue 4196fda9279dSmrg ;; 4197fda9279dSmrg -*) 4198fda9279dSmrg ;; 4199fda9279dSmrg *) 4200fda9279dSmrg # If the previous option needed an argument, then skip it. 4201fda9279dSmrg if test -n "$prev"; then 420216ee1e9aSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4203fda9279dSmrg arg2=$install_override_mode 4204fda9279dSmrg no_mode=false 4205fda9279dSmrg fi 4206fda9279dSmrg prev= 4207fda9279dSmrg else 4208fda9279dSmrg dest=$arg 4209fda9279dSmrg continue 4210fda9279dSmrg fi 4211fda9279dSmrg ;; 4212fda9279dSmrg esac 4213fda9279dSmrg 4214fda9279dSmrg # Aesthetically quote the argument. 4215fda9279dSmrg func_quote_for_eval "$arg" 4216fda9279dSmrg func_append install_prog " $func_quote_for_eval_result" 4217fda9279dSmrg if test -n "$arg2"; then 4218fda9279dSmrg func_quote_for_eval "$arg2" 4219fda9279dSmrg fi 4220fda9279dSmrg func_append install_shared_prog " $func_quote_for_eval_result" 4221fda9279dSmrg done 4222fda9279dSmrg 4223fda9279dSmrg test -z "$install_prog" && \ 4224fda9279dSmrg func_fatal_help "you must specify an install program" 4225fda9279dSmrg 4226fda9279dSmrg test -n "$prev" && \ 422716ee1e9aSmrg func_fatal_help "the '$prev' option requires an argument" 4228fda9279dSmrg 4229fda9279dSmrg if test -n "$install_override_mode" && $no_mode; then 4230fda9279dSmrg if $install_cp; then :; else 4231fda9279dSmrg func_quote_for_eval "$install_override_mode" 4232fda9279dSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4233fda9279dSmrg fi 4234fda9279dSmrg fi 4235fda9279dSmrg 4236fda9279dSmrg if test -z "$files"; then 4237fda9279dSmrg if test -z "$dest"; then 4238fda9279dSmrg func_fatal_help "no file or destination specified" 4239fda9279dSmrg else 4240fda9279dSmrg func_fatal_help "you must specify a destination" 4241fda9279dSmrg fi 4242fda9279dSmrg fi 4243fda9279dSmrg 4244fda9279dSmrg # Strip any trailing slash from the destination. 4245fda9279dSmrg func_stripname '' '/' "$dest" 4246fda9279dSmrg dest=$func_stripname_result 4247fda9279dSmrg 4248fda9279dSmrg # Check to see that the destination is a directory. 424916ee1e9aSmrg test -d "$dest" && isdir=: 425016ee1e9aSmrg if $isdir; then 425116ee1e9aSmrg destdir=$dest 4252fda9279dSmrg destname= 4253fda9279dSmrg else 4254fda9279dSmrg func_dirname_and_basename "$dest" "" "." 425516ee1e9aSmrg destdir=$func_dirname_result 425616ee1e9aSmrg destname=$func_basename_result 4257fda9279dSmrg 4258fda9279dSmrg # Not a directory, so check to see that there is only one file specified. 4259fda9279dSmrg set dummy $files; shift 4260fda9279dSmrg test "$#" -gt 1 && \ 426116ee1e9aSmrg func_fatal_help "'$dest' is not a directory" 4262fda9279dSmrg fi 4263fda9279dSmrg case $destdir in 4264fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4265fda9279dSmrg *) 4266fda9279dSmrg for file in $files; do 4267fda9279dSmrg case $file in 4268fda9279dSmrg *.lo) ;; 4269fda9279dSmrg *) 427016ee1e9aSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4271fda9279dSmrg ;; 4272fda9279dSmrg esac 4273fda9279dSmrg done 4274fda9279dSmrg ;; 4275fda9279dSmrg esac 4276fda9279dSmrg 4277fda9279dSmrg # This variable tells wrapper scripts just to set variables rather 4278fda9279dSmrg # than running their programs. 427916ee1e9aSmrg libtool_install_magic=$magic 4280fda9279dSmrg 4281fda9279dSmrg staticlibs= 4282fda9279dSmrg future_libdirs= 4283fda9279dSmrg current_libdirs= 4284fda9279dSmrg for file in $files; do 4285fda9279dSmrg 4286fda9279dSmrg # Do each installation. 4287fda9279dSmrg case $file in 4288fda9279dSmrg *.$libext) 4289fda9279dSmrg # Do the static libraries later. 4290fda9279dSmrg func_append staticlibs " $file" 4291fda9279dSmrg ;; 4292fda9279dSmrg 4293fda9279dSmrg *.la) 4294fda9279dSmrg func_resolve_sysroot "$file" 4295fda9279dSmrg file=$func_resolve_sysroot_result 4296fda9279dSmrg 4297fda9279dSmrg # Check to see that this really is a libtool archive. 4298fda9279dSmrg func_lalib_unsafe_p "$file" \ 429916ee1e9aSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4300fda9279dSmrg 4301fda9279dSmrg library_names= 4302fda9279dSmrg old_library= 4303fda9279dSmrg relink_command= 4304fda9279dSmrg func_source "$file" 4305fda9279dSmrg 4306fda9279dSmrg # Add the libdir to current_libdirs if it is the destination. 4307fda9279dSmrg if test "X$destdir" = "X$libdir"; then 4308fda9279dSmrg case "$current_libdirs " in 4309fda9279dSmrg *" $libdir "*) ;; 4310fda9279dSmrg *) func_append current_libdirs " $libdir" ;; 4311fda9279dSmrg esac 4312fda9279dSmrg else 4313fda9279dSmrg # Note the libdir as a future libdir. 4314fda9279dSmrg case "$future_libdirs " in 4315fda9279dSmrg *" $libdir "*) ;; 4316fda9279dSmrg *) func_append future_libdirs " $libdir" ;; 4317fda9279dSmrg esac 4318fda9279dSmrg fi 4319fda9279dSmrg 4320fda9279dSmrg func_dirname "$file" "/" "" 432116ee1e9aSmrg dir=$func_dirname_result 4322fda9279dSmrg func_append dir "$objdir" 4323fda9279dSmrg 4324fda9279dSmrg if test -n "$relink_command"; then 4325fda9279dSmrg # Determine the prefix the user has applied to our future dir. 4326fda9279dSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4327fda9279dSmrg 4328fda9279dSmrg # Don't allow the user to place us outside of our expected 4329fda9279dSmrg # location b/c this prevents finding dependent libraries that 4330fda9279dSmrg # are installed to the same prefix. 4331fda9279dSmrg # At present, this check doesn't affect windows .dll's that 4332fda9279dSmrg # are installed into $libdir/../bin (currently, that works fine) 4333fda9279dSmrg # but it's something to keep an eye on. 4334fda9279dSmrg test "$inst_prefix_dir" = "$destdir" && \ 433516ee1e9aSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4336fda9279dSmrg 4337fda9279dSmrg if test -n "$inst_prefix_dir"; then 4338fda9279dSmrg # Stick the inst_prefix_dir data into the link command. 4339fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4340fda9279dSmrg else 4341fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4342fda9279dSmrg fi 4343fda9279dSmrg 434416ee1e9aSmrg func_warning "relinking '$file'" 4345fda9279dSmrg func_show_eval "$relink_command" \ 434616ee1e9aSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4347fda9279dSmrg fi 4348fda9279dSmrg 4349fda9279dSmrg # See the names of the shared library. 4350fda9279dSmrg set dummy $library_names; shift 4351fda9279dSmrg if test -n "$1"; then 435216ee1e9aSmrg realname=$1 4353fda9279dSmrg shift 4354fda9279dSmrg 435516ee1e9aSmrg srcname=$realname 435616ee1e9aSmrg test -n "$relink_command" && srcname=${realname}T 4357fda9279dSmrg 4358fda9279dSmrg # Install the shared library and build the symlinks. 4359fda9279dSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4360fda9279dSmrg 'exit $?' 436116ee1e9aSmrg tstripme=$stripme 4362fda9279dSmrg case $host_os in 4363fda9279dSmrg cygwin* | mingw* | pw32* | cegcc*) 4364fda9279dSmrg case $realname in 4365fda9279dSmrg *.dll.a) 436616ee1e9aSmrg tstripme= 436716ee1e9aSmrg ;; 436816ee1e9aSmrg esac 436916ee1e9aSmrg ;; 437016ee1e9aSmrg os2*) 437116ee1e9aSmrg case $realname in 437216ee1e9aSmrg *_dll.a) 437316ee1e9aSmrg tstripme= 4374fda9279dSmrg ;; 4375fda9279dSmrg esac 4376fda9279dSmrg ;; 4377fda9279dSmrg esac 4378fda9279dSmrg if test -n "$tstripme" && test -n "$striplib"; then 4379fda9279dSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4380fda9279dSmrg fi 4381fda9279dSmrg 4382fda9279dSmrg if test "$#" -gt 0; then 4383fda9279dSmrg # Delete the old symlinks, and create new ones. 438416ee1e9aSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4385fda9279dSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4386fda9279dSmrg # so we also need to try rm && ln -s. 4387fda9279dSmrg for linkname 4388fda9279dSmrg do 4389fda9279dSmrg test "$linkname" != "$realname" \ 4390fda9279dSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4391fda9279dSmrg done 4392fda9279dSmrg fi 4393fda9279dSmrg 4394fda9279dSmrg # Do each command in the postinstall commands. 439516ee1e9aSmrg lib=$destdir/$realname 4396fda9279dSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4397fda9279dSmrg fi 4398fda9279dSmrg 4399fda9279dSmrg # Install the pseudo-library for information purposes. 4400fda9279dSmrg func_basename "$file" 440116ee1e9aSmrg name=$func_basename_result 440216ee1e9aSmrg instname=$dir/${name}i 4403fda9279dSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4404fda9279dSmrg 4405fda9279dSmrg # Maybe install the static library, too. 4406fda9279dSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4407fda9279dSmrg ;; 4408fda9279dSmrg 4409fda9279dSmrg *.lo) 4410fda9279dSmrg # Install (i.e. copy) a libtool object. 4411fda9279dSmrg 4412fda9279dSmrg # Figure out destination file name, if it wasn't already specified. 4413fda9279dSmrg if test -n "$destname"; then 441416ee1e9aSmrg destfile=$destdir/$destname 4415fda9279dSmrg else 4416fda9279dSmrg func_basename "$file" 441716ee1e9aSmrg destfile=$func_basename_result 441816ee1e9aSmrg destfile=$destdir/$destfile 4419fda9279dSmrg fi 4420fda9279dSmrg 4421fda9279dSmrg # Deduce the name of the destination old-style object file. 4422fda9279dSmrg case $destfile in 4423fda9279dSmrg *.lo) 4424fda9279dSmrg func_lo2o "$destfile" 4425fda9279dSmrg staticdest=$func_lo2o_result 4426fda9279dSmrg ;; 4427fda9279dSmrg *.$objext) 442816ee1e9aSmrg staticdest=$destfile 4429fda9279dSmrg destfile= 4430fda9279dSmrg ;; 4431fda9279dSmrg *) 443216ee1e9aSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4433fda9279dSmrg ;; 4434fda9279dSmrg esac 4435fda9279dSmrg 4436fda9279dSmrg # Install the libtool object if requested. 4437fda9279dSmrg test -n "$destfile" && \ 4438fda9279dSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4439fda9279dSmrg 4440fda9279dSmrg # Install the old object if enabled. 444116ee1e9aSmrg if test yes = "$build_old_libs"; then 4442fda9279dSmrg # Deduce the name of the old-style object file. 4443fda9279dSmrg func_lo2o "$file" 4444fda9279dSmrg staticobj=$func_lo2o_result 4445fda9279dSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4446fda9279dSmrg fi 4447fda9279dSmrg exit $EXIT_SUCCESS 4448fda9279dSmrg ;; 4449fda9279dSmrg 4450fda9279dSmrg *) 4451fda9279dSmrg # Figure out destination file name, if it wasn't already specified. 4452fda9279dSmrg if test -n "$destname"; then 445316ee1e9aSmrg destfile=$destdir/$destname 4454fda9279dSmrg else 4455fda9279dSmrg func_basename "$file" 445616ee1e9aSmrg destfile=$func_basename_result 445716ee1e9aSmrg destfile=$destdir/$destfile 4458fda9279dSmrg fi 4459fda9279dSmrg 4460fda9279dSmrg # If the file is missing, and there is a .exe on the end, strip it 4461fda9279dSmrg # because it is most likely a libtool script we actually want to 4462fda9279dSmrg # install 446316ee1e9aSmrg stripped_ext= 4464fda9279dSmrg case $file in 4465fda9279dSmrg *.exe) 4466fda9279dSmrg if test ! -f "$file"; then 4467fda9279dSmrg func_stripname '' '.exe' "$file" 4468fda9279dSmrg file=$func_stripname_result 446916ee1e9aSmrg stripped_ext=.exe 4470fda9279dSmrg fi 4471fda9279dSmrg ;; 4472fda9279dSmrg esac 4473fda9279dSmrg 4474fda9279dSmrg # Do a test to see if this is really a libtool program. 4475fda9279dSmrg case $host in 4476fda9279dSmrg *cygwin* | *mingw*) 4477fda9279dSmrg if func_ltwrapper_executable_p "$file"; then 4478fda9279dSmrg func_ltwrapper_scriptname "$file" 4479fda9279dSmrg wrapper=$func_ltwrapper_scriptname_result 4480fda9279dSmrg else 4481fda9279dSmrg func_stripname '' '.exe' "$file" 4482fda9279dSmrg wrapper=$func_stripname_result 4483fda9279dSmrg fi 4484fda9279dSmrg ;; 4485fda9279dSmrg *) 4486fda9279dSmrg wrapper=$file 4487fda9279dSmrg ;; 4488fda9279dSmrg esac 4489fda9279dSmrg if func_ltwrapper_script_p "$wrapper"; then 4490fda9279dSmrg notinst_deplibs= 4491fda9279dSmrg relink_command= 4492fda9279dSmrg 4493fda9279dSmrg func_source "$wrapper" 4494fda9279dSmrg 4495fda9279dSmrg # Check the variables that should have been set. 4496fda9279dSmrg test -z "$generated_by_libtool_version" && \ 449716ee1e9aSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4498fda9279dSmrg 449916ee1e9aSmrg finalize=: 4500fda9279dSmrg for lib in $notinst_deplibs; do 4501fda9279dSmrg # Check to see that each library is installed. 4502fda9279dSmrg libdir= 4503fda9279dSmrg if test -f "$lib"; then 4504fda9279dSmrg func_source "$lib" 4505fda9279dSmrg fi 450616ee1e9aSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4507fda9279dSmrg if test -n "$libdir" && test ! -f "$libfile"; then 450816ee1e9aSmrg func_warning "'$lib' has not been installed in '$libdir'" 450916ee1e9aSmrg finalize=false 4510fda9279dSmrg fi 4511fda9279dSmrg done 4512fda9279dSmrg 4513fda9279dSmrg relink_command= 4514fda9279dSmrg func_source "$wrapper" 4515fda9279dSmrg 4516fda9279dSmrg outputname= 451716ee1e9aSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4518fda9279dSmrg $opt_dry_run || { 451916ee1e9aSmrg if $finalize; then 4520fda9279dSmrg tmpdir=`func_mktempdir` 4521fda9279dSmrg func_basename "$file$stripped_ext" 452216ee1e9aSmrg file=$func_basename_result 452316ee1e9aSmrg outputname=$tmpdir/$file 4524fda9279dSmrg # Replace the output file specification. 4525fda9279dSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4526fda9279dSmrg 452716ee1e9aSmrg $opt_quiet || { 4528fda9279dSmrg func_quote_for_expand "$relink_command" 4529fda9279dSmrg eval "func_echo $func_quote_for_expand_result" 4530fda9279dSmrg } 4531fda9279dSmrg if eval "$relink_command"; then : 4532fda9279dSmrg else 453316ee1e9aSmrg func_error "error: relink '$file' with the above command before installing it" 4534fda9279dSmrg $opt_dry_run || ${RM}r "$tmpdir" 4535fda9279dSmrg continue 4536fda9279dSmrg fi 453716ee1e9aSmrg file=$outputname 4538fda9279dSmrg else 453916ee1e9aSmrg func_warning "cannot relink '$file'" 4540fda9279dSmrg fi 4541fda9279dSmrg } 4542fda9279dSmrg else 4543fda9279dSmrg # Install the binary that we compiled earlier. 4544fda9279dSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4545fda9279dSmrg fi 4546fda9279dSmrg fi 4547fda9279dSmrg 4548fda9279dSmrg # remove .exe since cygwin /usr/bin/install will append another 4549fda9279dSmrg # one anyway 4550fda9279dSmrg case $install_prog,$host in 4551fda9279dSmrg */usr/bin/install*,*cygwin*) 4552fda9279dSmrg case $file:$destfile in 4553fda9279dSmrg *.exe:*.exe) 4554fda9279dSmrg # this is ok 4555fda9279dSmrg ;; 4556fda9279dSmrg *.exe:*) 4557fda9279dSmrg destfile=$destfile.exe 4558fda9279dSmrg ;; 4559fda9279dSmrg *:*.exe) 4560fda9279dSmrg func_stripname '' '.exe' "$destfile" 4561fda9279dSmrg destfile=$func_stripname_result 4562fda9279dSmrg ;; 4563fda9279dSmrg esac 4564fda9279dSmrg ;; 4565fda9279dSmrg esac 4566fda9279dSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4567fda9279dSmrg $opt_dry_run || if test -n "$outputname"; then 4568fda9279dSmrg ${RM}r "$tmpdir" 4569fda9279dSmrg fi 4570fda9279dSmrg ;; 4571fda9279dSmrg esac 4572fda9279dSmrg done 4573fda9279dSmrg 4574fda9279dSmrg for file in $staticlibs; do 4575fda9279dSmrg func_basename "$file" 457616ee1e9aSmrg name=$func_basename_result 4577fda9279dSmrg 4578fda9279dSmrg # Set up the ranlib parameters. 457916ee1e9aSmrg oldlib=$destdir/$name 4580fda9279dSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4581fda9279dSmrg tool_oldlib=$func_to_tool_file_result 4582fda9279dSmrg 4583fda9279dSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4584fda9279dSmrg 4585fda9279dSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4586fda9279dSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4587fda9279dSmrg fi 4588fda9279dSmrg 4589fda9279dSmrg # Do each command in the postinstall commands. 4590fda9279dSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4591fda9279dSmrg done 4592fda9279dSmrg 4593fda9279dSmrg test -n "$future_libdirs" && \ 459416ee1e9aSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4595fda9279dSmrg 4596fda9279dSmrg if test -n "$current_libdirs"; then 4597fda9279dSmrg # Maybe just do a dry run. 4598fda9279dSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 459916ee1e9aSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4600fda9279dSmrg else 4601fda9279dSmrg exit $EXIT_SUCCESS 4602fda9279dSmrg fi 4603fda9279dSmrg} 4604fda9279dSmrg 460516ee1e9aSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4606fda9279dSmrg 4607fda9279dSmrg 4608fda9279dSmrg# func_generate_dlsyms outputname originator pic_p 4609fda9279dSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4610fda9279dSmrg# a dlpreopen symbol table. 4611fda9279dSmrgfunc_generate_dlsyms () 4612fda9279dSmrg{ 461316ee1e9aSmrg $debug_cmd 461416ee1e9aSmrg 461516ee1e9aSmrg my_outputname=$1 461616ee1e9aSmrg my_originator=$2 461716ee1e9aSmrg my_pic_p=${3-false} 461816ee1e9aSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4619fda9279dSmrg my_dlsyms= 4620fda9279dSmrg 462116ee1e9aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4622fda9279dSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 462316ee1e9aSmrg my_dlsyms=${my_outputname}S.c 4624fda9279dSmrg else 4625fda9279dSmrg func_error "not configured to extract global symbols from dlpreopened files" 4626fda9279dSmrg fi 4627fda9279dSmrg fi 4628fda9279dSmrg 4629fda9279dSmrg if test -n "$my_dlsyms"; then 4630fda9279dSmrg case $my_dlsyms in 4631fda9279dSmrg "") ;; 4632fda9279dSmrg *.c) 4633fda9279dSmrg # Discover the nlist of each of the dlfiles. 463416ee1e9aSmrg nlist=$output_objdir/$my_outputname.nm 4635fda9279dSmrg 4636fda9279dSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4637fda9279dSmrg 4638fda9279dSmrg # Parse the name list into a source file. 4639fda9279dSmrg func_verbose "creating $output_objdir/$my_dlsyms" 4640fda9279dSmrg 4641fda9279dSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 464216ee1e9aSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 464316ee1e9aSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4644fda9279dSmrg 4645fda9279dSmrg#ifdef __cplusplus 4646fda9279dSmrgextern \"C\" { 4647fda9279dSmrg#endif 4648fda9279dSmrg 464916ee1e9aSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4650fda9279dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4651fda9279dSmrg#endif 4652fda9279dSmrg 4653fda9279dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 465416ee1e9aSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 465516ee1e9aSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4656fda9279dSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4657fda9279dSmrg# define LT_DLSYM_CONST 465816ee1e9aSmrg#elif defined __osf__ 4659fda9279dSmrg/* This system does not cope well with relocations in const data. */ 4660fda9279dSmrg# define LT_DLSYM_CONST 4661fda9279dSmrg#else 4662fda9279dSmrg# define LT_DLSYM_CONST const 4663fda9279dSmrg#endif 4664fda9279dSmrg 466516ee1e9aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 466616ee1e9aSmrg 4667fda9279dSmrg/* External symbol declarations for the compiler. */\ 4668fda9279dSmrg" 4669fda9279dSmrg 467016ee1e9aSmrg if test yes = "$dlself"; then 467116ee1e9aSmrg func_verbose "generating symbol list for '$output'" 4672fda9279dSmrg 4673fda9279dSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4674fda9279dSmrg 4675fda9279dSmrg # Add our own program objects to the symbol list. 4676fda9279dSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4677fda9279dSmrg for progfile in $progfiles; do 4678fda9279dSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 467916ee1e9aSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4680fda9279dSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4681fda9279dSmrg done 4682fda9279dSmrg 4683fda9279dSmrg if test -n "$exclude_expsyms"; then 4684fda9279dSmrg $opt_dry_run || { 4685fda9279dSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4686fda9279dSmrg eval '$MV "$nlist"T "$nlist"' 4687fda9279dSmrg } 4688fda9279dSmrg fi 4689fda9279dSmrg 4690fda9279dSmrg if test -n "$export_symbols_regex"; then 4691fda9279dSmrg $opt_dry_run || { 4692fda9279dSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4693fda9279dSmrg eval '$MV "$nlist"T "$nlist"' 4694fda9279dSmrg } 4695fda9279dSmrg fi 4696fda9279dSmrg 4697fda9279dSmrg # Prepare the list of exported symbols 4698fda9279dSmrg if test -z "$export_symbols"; then 469916ee1e9aSmrg export_symbols=$output_objdir/$outputname.exp 4700fda9279dSmrg $opt_dry_run || { 4701fda9279dSmrg $RM $export_symbols 470216ee1e9aSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4703fda9279dSmrg case $host in 4704fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4705fda9279dSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4706fda9279dSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4707fda9279dSmrg ;; 4708fda9279dSmrg esac 4709fda9279dSmrg } 4710fda9279dSmrg else 4711fda9279dSmrg $opt_dry_run || { 471216ee1e9aSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4713fda9279dSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4714fda9279dSmrg eval '$MV "$nlist"T "$nlist"' 4715fda9279dSmrg case $host in 4716fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4717fda9279dSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4718fda9279dSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4719fda9279dSmrg ;; 4720fda9279dSmrg esac 4721fda9279dSmrg } 4722fda9279dSmrg fi 4723fda9279dSmrg fi 4724fda9279dSmrg 4725fda9279dSmrg for dlprefile in $dlprefiles; do 472616ee1e9aSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4727fda9279dSmrg func_basename "$dlprefile" 472816ee1e9aSmrg name=$func_basename_result 4729fda9279dSmrg case $host in 4730fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4731fda9279dSmrg # if an import library, we need to obtain dlname 4732fda9279dSmrg if func_win32_import_lib_p "$dlprefile"; then 4733fda9279dSmrg func_tr_sh "$dlprefile" 4734fda9279dSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 473516ee1e9aSmrg dlprefile_dlbasename= 4736fda9279dSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4737fda9279dSmrg # Use subshell, to avoid clobbering current variable values 4738fda9279dSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 473916ee1e9aSmrg if test -n "$dlprefile_dlname"; then 4740fda9279dSmrg func_basename "$dlprefile_dlname" 474116ee1e9aSmrg dlprefile_dlbasename=$func_basename_result 4742fda9279dSmrg else 4743fda9279dSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4744fda9279dSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4745fda9279dSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4746fda9279dSmrg fi 4747fda9279dSmrg fi 4748fda9279dSmrg $opt_dry_run || { 474916ee1e9aSmrg if test -n "$dlprefile_dlbasename"; then 4750fda9279dSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4751fda9279dSmrg else 4752fda9279dSmrg func_warning "Could not compute DLL name from $name" 4753fda9279dSmrg eval '$ECHO ": $name " >> "$nlist"' 4754fda9279dSmrg fi 4755fda9279dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4756fda9279dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4757fda9279dSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4758fda9279dSmrg } 4759fda9279dSmrg else # not an import lib 4760fda9279dSmrg $opt_dry_run || { 4761fda9279dSmrg eval '$ECHO ": $name " >> "$nlist"' 4762fda9279dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4763fda9279dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4764fda9279dSmrg } 4765fda9279dSmrg fi 4766fda9279dSmrg ;; 4767fda9279dSmrg *) 4768fda9279dSmrg $opt_dry_run || { 4769fda9279dSmrg eval '$ECHO ": $name " >> "$nlist"' 4770fda9279dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4771fda9279dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4772fda9279dSmrg } 4773fda9279dSmrg ;; 4774fda9279dSmrg esac 4775fda9279dSmrg done 4776fda9279dSmrg 4777fda9279dSmrg $opt_dry_run || { 4778fda9279dSmrg # Make sure we have at least an empty file. 4779fda9279dSmrg test -f "$nlist" || : > "$nlist" 4780fda9279dSmrg 4781fda9279dSmrg if test -n "$exclude_expsyms"; then 4782fda9279dSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4783fda9279dSmrg $MV "$nlist"T "$nlist" 4784fda9279dSmrg fi 4785fda9279dSmrg 4786fda9279dSmrg # Try sorting and uniquifying the output. 4787fda9279dSmrg if $GREP -v "^: " < "$nlist" | 4788fda9279dSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4789fda9279dSmrg sort -k 3 4790fda9279dSmrg else 4791fda9279dSmrg sort +2 4792fda9279dSmrg fi | 4793fda9279dSmrg uniq > "$nlist"S; then 4794fda9279dSmrg : 4795fda9279dSmrg else 4796fda9279dSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 4797fda9279dSmrg fi 4798fda9279dSmrg 4799fda9279dSmrg if test -f "$nlist"S; then 4800fda9279dSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4801fda9279dSmrg else 4802fda9279dSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4803fda9279dSmrg fi 4804fda9279dSmrg 480516ee1e9aSmrg func_show_eval '$RM "${nlist}I"' 480616ee1e9aSmrg if test -n "$global_symbol_to_import"; then 480716ee1e9aSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 480816ee1e9aSmrg fi 480916ee1e9aSmrg 4810fda9279dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4811fda9279dSmrg 4812fda9279dSmrg/* The mapping between symbol names and symbols. */ 4813fda9279dSmrgtypedef struct { 4814fda9279dSmrg const char *name; 4815fda9279dSmrg void *address; 4816fda9279dSmrg} lt_dlsymlist; 4817fda9279dSmrgextern LT_DLSYM_CONST lt_dlsymlist 481816ee1e9aSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 481916ee1e9aSmrg" 482016ee1e9aSmrg 482116ee1e9aSmrg if test -s "$nlist"I; then 482216ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 482316ee1e9aSmrgstatic void lt_syminit(void) 482416ee1e9aSmrg{ 482516ee1e9aSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 482616ee1e9aSmrg for (; symbol->name; ++symbol) 482716ee1e9aSmrg {" 482816ee1e9aSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 482916ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 483016ee1e9aSmrg } 483116ee1e9aSmrg}" 483216ee1e9aSmrg fi 483316ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4834fda9279dSmrgLT_DLSYM_CONST lt_dlsymlist 4835fda9279dSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 483616ee1e9aSmrg{ {\"$my_originator\", (void *) 0}," 483716ee1e9aSmrg 483816ee1e9aSmrg if test -s "$nlist"I; then 483916ee1e9aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 484016ee1e9aSmrg {\"@INIT@\", (void *) <_syminit}," 484116ee1e9aSmrg fi 4842fda9279dSmrg 4843fda9279dSmrg case $need_lib_prefix in 4844fda9279dSmrg no) 4845fda9279dSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4846fda9279dSmrg ;; 4847fda9279dSmrg *) 4848fda9279dSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4849fda9279dSmrg ;; 4850fda9279dSmrg esac 4851fda9279dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4852fda9279dSmrg {0, (void *) 0} 4853fda9279dSmrg}; 4854fda9279dSmrg 4855fda9279dSmrg/* This works around a problem in FreeBSD linker */ 4856fda9279dSmrg#ifdef FREEBSD_WORKAROUND 4857fda9279dSmrgstatic const void *lt_preloaded_setup() { 4858fda9279dSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 4859fda9279dSmrg} 4860fda9279dSmrg#endif 4861fda9279dSmrg 4862fda9279dSmrg#ifdef __cplusplus 4863fda9279dSmrg} 4864fda9279dSmrg#endif\ 4865fda9279dSmrg" 4866fda9279dSmrg } # !$opt_dry_run 4867fda9279dSmrg 4868fda9279dSmrg pic_flag_for_symtable= 4869fda9279dSmrg case "$compile_command " in 4870fda9279dSmrg *" -static "*) ;; 4871fda9279dSmrg *) 4872fda9279dSmrg case $host in 4873fda9279dSmrg # compiling the symbol table file with pic_flag works around 4874fda9279dSmrg # a FreeBSD bug that causes programs to crash when -lm is 4875fda9279dSmrg # linked before any other PIC object. But we must not use 4876fda9279dSmrg # pic_flag when linking with -static. The problem exists in 4877fda9279dSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4878fda9279dSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4879fda9279dSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4880fda9279dSmrg *-*-hpux*) 4881fda9279dSmrg pic_flag_for_symtable=" $pic_flag" ;; 4882fda9279dSmrg *) 488316ee1e9aSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4884fda9279dSmrg ;; 4885fda9279dSmrg esac 4886fda9279dSmrg ;; 4887fda9279dSmrg esac 4888fda9279dSmrg symtab_cflags= 4889fda9279dSmrg for arg in $LTCFLAGS; do 4890fda9279dSmrg case $arg in 4891fda9279dSmrg -pie | -fpie | -fPIE) ;; 4892fda9279dSmrg *) func_append symtab_cflags " $arg" ;; 4893fda9279dSmrg esac 4894fda9279dSmrg done 4895fda9279dSmrg 4896fda9279dSmrg # Now compile the dynamic symbol file. 4897fda9279dSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4898fda9279dSmrg 4899fda9279dSmrg # Clean up the generated files. 490016ee1e9aSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4901fda9279dSmrg 4902fda9279dSmrg # Transform the symbol file into the correct name. 490316ee1e9aSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4904fda9279dSmrg case $host in 4905fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 4906fda9279dSmrg if test -f "$output_objdir/$my_outputname.def"; then 4907fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4908fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4909fda9279dSmrg else 4910fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4911fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4912fda9279dSmrg fi 4913fda9279dSmrg ;; 4914fda9279dSmrg *) 4915fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4916fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4917fda9279dSmrg ;; 4918fda9279dSmrg esac 4919fda9279dSmrg ;; 4920fda9279dSmrg *) 492116ee1e9aSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4922fda9279dSmrg ;; 4923fda9279dSmrg esac 4924fda9279dSmrg else 4925fda9279dSmrg # We keep going just in case the user didn't refer to 4926fda9279dSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4927fda9279dSmrg # really was required. 4928fda9279dSmrg 4929fda9279dSmrg # Nullify the symbol file. 4930fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4931fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4932fda9279dSmrg fi 4933fda9279dSmrg} 4934fda9279dSmrg 493516ee1e9aSmrg# func_cygming_gnu_implib_p ARG 493616ee1e9aSmrg# This predicate returns with zero status (TRUE) if 493716ee1e9aSmrg# ARG is a GNU/binutils-style import library. Returns 493816ee1e9aSmrg# with nonzero status (FALSE) otherwise. 493916ee1e9aSmrgfunc_cygming_gnu_implib_p () 494016ee1e9aSmrg{ 494116ee1e9aSmrg $debug_cmd 494216ee1e9aSmrg 494316ee1e9aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494416ee1e9aSmrg 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)$'` 494516ee1e9aSmrg test -n "$func_cygming_gnu_implib_tmp" 494616ee1e9aSmrg} 494716ee1e9aSmrg 494816ee1e9aSmrg# func_cygming_ms_implib_p ARG 494916ee1e9aSmrg# This predicate returns with zero status (TRUE) if 495016ee1e9aSmrg# ARG is an MS-style import library. Returns 495116ee1e9aSmrg# with nonzero status (FALSE) otherwise. 495216ee1e9aSmrgfunc_cygming_ms_implib_p () 495316ee1e9aSmrg{ 495416ee1e9aSmrg $debug_cmd 495516ee1e9aSmrg 495616ee1e9aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 495716ee1e9aSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 495816ee1e9aSmrg test -n "$func_cygming_ms_implib_tmp" 495916ee1e9aSmrg} 496016ee1e9aSmrg 4961fda9279dSmrg# func_win32_libid arg 4962fda9279dSmrg# return the library type of file 'arg' 4963fda9279dSmrg# 4964fda9279dSmrg# Need a lot of goo to handle *both* DLLs and import libs 4965fda9279dSmrg# Has to be a shell function in order to 'eat' the argument 4966fda9279dSmrg# that is supplied when $file_magic_command is called. 4967fda9279dSmrg# Despite the name, also deal with 64 bit binaries. 4968fda9279dSmrgfunc_win32_libid () 4969fda9279dSmrg{ 497016ee1e9aSmrg $debug_cmd 497116ee1e9aSmrg 497216ee1e9aSmrg win32_libid_type=unknown 4973fda9279dSmrg win32_fileres=`file -L $1 2>/dev/null` 4974fda9279dSmrg case $win32_fileres in 4975fda9279dSmrg *ar\ archive\ import\ library*) # definitely import 4976fda9279dSmrg win32_libid_type="x86 archive import" 4977fda9279dSmrg ;; 4978fda9279dSmrg *ar\ archive*) # could be an import, or static 4979fda9279dSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4980fda9279dSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4981fda9279dSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 498216ee1e9aSmrg case $nm_interface in 498316ee1e9aSmrg "MS dumpbin") 498416ee1e9aSmrg if func_cygming_ms_implib_p "$1" || 498516ee1e9aSmrg func_cygming_gnu_implib_p "$1" 498616ee1e9aSmrg then 498716ee1e9aSmrg win32_nmres=import 498816ee1e9aSmrg else 498916ee1e9aSmrg win32_nmres= 499016ee1e9aSmrg fi 499116ee1e9aSmrg ;; 499216ee1e9aSmrg *) 499316ee1e9aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 499416ee1e9aSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 499516ee1e9aSmrg $SED -n -e ' 4996fda9279dSmrg 1,100{ 4997fda9279dSmrg / I /{ 499816ee1e9aSmrg s|.*|import| 4999fda9279dSmrg p 5000fda9279dSmrg q 5001fda9279dSmrg } 5002fda9279dSmrg }'` 500316ee1e9aSmrg ;; 500416ee1e9aSmrg esac 5005fda9279dSmrg case $win32_nmres in 5006fda9279dSmrg import*) win32_libid_type="x86 archive import";; 5007fda9279dSmrg *) win32_libid_type="x86 archive static";; 5008fda9279dSmrg esac 5009fda9279dSmrg fi 5010fda9279dSmrg ;; 5011fda9279dSmrg *DLL*) 5012fda9279dSmrg win32_libid_type="x86 DLL" 5013fda9279dSmrg ;; 5014fda9279dSmrg *executable*) # but shell scripts are "executable" too... 5015fda9279dSmrg case $win32_fileres in 5016fda9279dSmrg *MS\ Windows\ PE\ Intel*) 5017fda9279dSmrg win32_libid_type="x86 DLL" 5018fda9279dSmrg ;; 5019fda9279dSmrg esac 5020fda9279dSmrg ;; 5021fda9279dSmrg esac 5022fda9279dSmrg $ECHO "$win32_libid_type" 5023fda9279dSmrg} 5024fda9279dSmrg 5025fda9279dSmrg# func_cygming_dll_for_implib ARG 5026fda9279dSmrg# 5027fda9279dSmrg# Platform-specific function to extract the 5028fda9279dSmrg# name of the DLL associated with the specified 5029fda9279dSmrg# import library ARG. 5030fda9279dSmrg# Invoked by eval'ing the libtool variable 5031fda9279dSmrg# $sharedlib_from_linklib_cmd 5032fda9279dSmrg# Result is available in the variable 5033fda9279dSmrg# $sharedlib_from_linklib_result 5034fda9279dSmrgfunc_cygming_dll_for_implib () 5035fda9279dSmrg{ 503616ee1e9aSmrg $debug_cmd 503716ee1e9aSmrg 5038fda9279dSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5039fda9279dSmrg} 5040fda9279dSmrg 5041fda9279dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5042fda9279dSmrg# 5043fda9279dSmrg# The is the core of a fallback implementation of a 5044fda9279dSmrg# platform-specific function to extract the name of the 5045fda9279dSmrg# DLL associated with the specified import library LIBNAME. 5046fda9279dSmrg# 5047fda9279dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5048fda9279dSmrg# on the platform and compiler that created the implib. 5049fda9279dSmrg# 5050fda9279dSmrg# Echos the name of the DLL associated with the 5051fda9279dSmrg# specified import library. 5052fda9279dSmrgfunc_cygming_dll_for_implib_fallback_core () 5053fda9279dSmrg{ 505416ee1e9aSmrg $debug_cmd 505516ee1e9aSmrg 5056fda9279dSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5057fda9279dSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5058fda9279dSmrg $SED '/^Contents of section '"$match_literal"':/{ 5059fda9279dSmrg # Place marker at beginning of archive member dllname section 5060fda9279dSmrg s/.*/====MARK====/ 5061fda9279dSmrg p 5062fda9279dSmrg d 5063fda9279dSmrg } 5064fda9279dSmrg # These lines can sometimes be longer than 43 characters, but 5065fda9279dSmrg # are always uninteresting 5066fda9279dSmrg /:[ ]*file format pe[i]\{,1\}-/d 5067fda9279dSmrg /^In archive [^:]*:/d 5068fda9279dSmrg # Ensure marker is printed 5069fda9279dSmrg /^====MARK====/p 5070fda9279dSmrg # Remove all lines with less than 43 characters 5071fda9279dSmrg /^.\{43\}/!d 5072fda9279dSmrg # From remaining lines, remove first 43 characters 5073fda9279dSmrg s/^.\{43\}//' | 5074fda9279dSmrg $SED -n ' 5075fda9279dSmrg # Join marker and all lines until next marker into a single line 5076fda9279dSmrg /^====MARK====/ b para 5077fda9279dSmrg H 5078fda9279dSmrg $ b para 5079fda9279dSmrg b 5080fda9279dSmrg :para 5081fda9279dSmrg x 5082fda9279dSmrg s/\n//g 5083fda9279dSmrg # Remove the marker 5084fda9279dSmrg s/^====MARK====// 5085fda9279dSmrg # Remove trailing dots and whitespace 5086fda9279dSmrg s/[\. \t]*$// 5087fda9279dSmrg # Print 5088fda9279dSmrg /./p' | 5089fda9279dSmrg # we now have a list, one entry per line, of the stringified 5090fda9279dSmrg # contents of the appropriate section of all members of the 509116ee1e9aSmrg # archive that possess that section. Heuristic: eliminate 509216ee1e9aSmrg # all those that have a first or second character that is 5093fda9279dSmrg # a '.' (that is, objdump's representation of an unprintable 5094fda9279dSmrg # character.) This should work for all archives with less than 5095fda9279dSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5096fda9279dSmrg # begins with a literal '.' or a single character followed by 5097fda9279dSmrg # a '.'. 5098fda9279dSmrg # 5099fda9279dSmrg # Of those that remain, print the first one. 5100fda9279dSmrg $SED -e '/^\./d;/^.\./d;q' 5101fda9279dSmrg} 5102fda9279dSmrg 5103fda9279dSmrg# func_cygming_dll_for_implib_fallback ARG 5104fda9279dSmrg# Platform-specific function to extract the 5105fda9279dSmrg# name of the DLL associated with the specified 5106fda9279dSmrg# import library ARG. 5107fda9279dSmrg# 5108fda9279dSmrg# This fallback implementation is for use when $DLLTOOL 5109fda9279dSmrg# does not support the --identify-strict option. 5110fda9279dSmrg# Invoked by eval'ing the libtool variable 5111fda9279dSmrg# $sharedlib_from_linklib_cmd 5112fda9279dSmrg# Result is available in the variable 5113fda9279dSmrg# $sharedlib_from_linklib_result 5114fda9279dSmrgfunc_cygming_dll_for_implib_fallback () 5115fda9279dSmrg{ 511616ee1e9aSmrg $debug_cmd 511716ee1e9aSmrg 511816ee1e9aSmrg if func_cygming_gnu_implib_p "$1"; then 5119fda9279dSmrg # binutils import library 5120fda9279dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 512116ee1e9aSmrg elif func_cygming_ms_implib_p "$1"; then 5122fda9279dSmrg # ms-generated import library 5123fda9279dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5124fda9279dSmrg else 5125fda9279dSmrg # unknown 512616ee1e9aSmrg sharedlib_from_linklib_result= 5127fda9279dSmrg fi 5128fda9279dSmrg} 5129fda9279dSmrg 5130fda9279dSmrg 5131fda9279dSmrg# func_extract_an_archive dir oldlib 5132fda9279dSmrgfunc_extract_an_archive () 5133fda9279dSmrg{ 513416ee1e9aSmrg $debug_cmd 513516ee1e9aSmrg 513616ee1e9aSmrg f_ex_an_ar_dir=$1; shift 513716ee1e9aSmrg f_ex_an_ar_oldlib=$1 513816ee1e9aSmrg if test yes = "$lock_old_archive_extraction"; then 5139fda9279dSmrg lockfile=$f_ex_an_ar_oldlib.lock 5140fda9279dSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5141fda9279dSmrg func_echo "Waiting for $lockfile to be removed" 5142fda9279dSmrg sleep 2 5143fda9279dSmrg done 5144fda9279dSmrg fi 5145fda9279dSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5146fda9279dSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 514716ee1e9aSmrg if test yes = "$lock_old_archive_extraction"; then 5148fda9279dSmrg $opt_dry_run || rm -f "$lockfile" 5149fda9279dSmrg fi 5150fda9279dSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5151fda9279dSmrg : 5152fda9279dSmrg else 5153fda9279dSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5154fda9279dSmrg fi 5155fda9279dSmrg} 5156fda9279dSmrg 5157fda9279dSmrg 5158fda9279dSmrg# func_extract_archives gentop oldlib ... 5159fda9279dSmrgfunc_extract_archives () 5160fda9279dSmrg{ 516116ee1e9aSmrg $debug_cmd 516216ee1e9aSmrg 516316ee1e9aSmrg my_gentop=$1; shift 5164fda9279dSmrg my_oldlibs=${1+"$@"} 516516ee1e9aSmrg my_oldobjs= 516616ee1e9aSmrg my_xlib= 516716ee1e9aSmrg my_xabs= 516816ee1e9aSmrg my_xdir= 5169fda9279dSmrg 5170fda9279dSmrg for my_xlib in $my_oldlibs; do 5171fda9279dSmrg # Extract the objects. 5172fda9279dSmrg case $my_xlib in 517316ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5174fda9279dSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 5175fda9279dSmrg esac 5176fda9279dSmrg func_basename "$my_xlib" 517716ee1e9aSmrg my_xlib=$func_basename_result 5178fda9279dSmrg my_xlib_u=$my_xlib 5179fda9279dSmrg while :; do 5180fda9279dSmrg case " $extracted_archives " in 5181fda9279dSmrg *" $my_xlib_u "*) 5182fda9279dSmrg func_arith $extracted_serial + 1 5183fda9279dSmrg extracted_serial=$func_arith_result 5184fda9279dSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5185fda9279dSmrg *) break ;; 5186fda9279dSmrg esac 5187fda9279dSmrg done 5188fda9279dSmrg extracted_archives="$extracted_archives $my_xlib_u" 518916ee1e9aSmrg my_xdir=$my_gentop/$my_xlib_u 5190fda9279dSmrg 5191fda9279dSmrg func_mkdir_p "$my_xdir" 5192fda9279dSmrg 5193fda9279dSmrg case $host in 5194fda9279dSmrg *-darwin*) 5195fda9279dSmrg func_verbose "Extracting $my_xabs" 5196fda9279dSmrg # Do not bother doing anything if just a dry run 5197fda9279dSmrg $opt_dry_run || { 5198fda9279dSmrg darwin_orig_dir=`pwd` 5199fda9279dSmrg cd $my_xdir || exit $? 5200fda9279dSmrg darwin_archive=$my_xabs 5201fda9279dSmrg darwin_curdir=`pwd` 520216ee1e9aSmrg func_basename "$darwin_archive" 520316ee1e9aSmrg darwin_base_archive=$func_basename_result 5204fda9279dSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5205fda9279dSmrg if test -n "$darwin_arches"; then 5206fda9279dSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5207fda9279dSmrg darwin_arch= 5208fda9279dSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 520916ee1e9aSmrg for darwin_arch in $darwin_arches; do 521016ee1e9aSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 521116ee1e9aSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 521216ee1e9aSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 521316ee1e9aSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5214fda9279dSmrg cd "$darwin_curdir" 521516ee1e9aSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5216fda9279dSmrg done # $darwin_arches 5217fda9279dSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 521816ee1e9aSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5219fda9279dSmrg darwin_file= 5220fda9279dSmrg darwin_files= 5221fda9279dSmrg for darwin_file in $darwin_filelist; do 5222fda9279dSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5223fda9279dSmrg $LIPO -create -output "$darwin_file" $darwin_files 5224fda9279dSmrg done # $darwin_filelist 5225fda9279dSmrg $RM -rf unfat-$$ 5226fda9279dSmrg cd "$darwin_orig_dir" 5227fda9279dSmrg else 5228fda9279dSmrg cd $darwin_orig_dir 5229fda9279dSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5230fda9279dSmrg fi # $darwin_arches 5231fda9279dSmrg } # !$opt_dry_run 5232fda9279dSmrg ;; 5233fda9279dSmrg *) 5234fda9279dSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5235fda9279dSmrg ;; 5236fda9279dSmrg esac 5237fda9279dSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5238fda9279dSmrg done 5239fda9279dSmrg 524016ee1e9aSmrg func_extract_archives_result=$my_oldobjs 5241fda9279dSmrg} 5242fda9279dSmrg 5243fda9279dSmrg 5244fda9279dSmrg# func_emit_wrapper [arg=no] 5245fda9279dSmrg# 5246fda9279dSmrg# Emit a libtool wrapper script on stdout. 5247fda9279dSmrg# Don't directly open a file because we may want to 5248fda9279dSmrg# incorporate the script contents within a cygwin/mingw 5249fda9279dSmrg# wrapper executable. Must ONLY be called from within 5250fda9279dSmrg# func_mode_link because it depends on a number of variables 5251fda9279dSmrg# set therein. 5252fda9279dSmrg# 5253fda9279dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5254fda9279dSmrg# variable will take. If 'yes', then the emitted script 525516ee1e9aSmrg# will assume that the directory where it is stored is 5256fda9279dSmrg# the $objdir directory. This is a cygwin/mingw-specific 5257fda9279dSmrg# behavior. 5258fda9279dSmrgfunc_emit_wrapper () 5259fda9279dSmrg{ 5260fda9279dSmrg func_emit_wrapper_arg1=${1-no} 5261fda9279dSmrg 5262fda9279dSmrg $ECHO "\ 5263fda9279dSmrg#! $SHELL 5264fda9279dSmrg 5265fda9279dSmrg# $output - temporary wrapper script for $objdir/$outputname 526616ee1e9aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5267fda9279dSmrg# 5268fda9279dSmrg# The $output program cannot be directly executed until all the libtool 5269fda9279dSmrg# libraries that it depends on are installed. 5270fda9279dSmrg# 5271fda9279dSmrg# This wrapper script should never be moved out of the build directory. 5272fda9279dSmrg# If it is, it will not operate correctly. 5273fda9279dSmrg 5274fda9279dSmrg# Sed substitution that helps us do robust quoting. It backslashifies 5275fda9279dSmrg# metacharacters that are still active within double-quoted strings. 5276fda9279dSmrgsed_quote_subst='$sed_quote_subst' 5277fda9279dSmrg 5278fda9279dSmrg# Be Bourne compatible 5279fda9279dSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5280fda9279dSmrg emulate sh 5281fda9279dSmrg NULLCMD=: 5282fda9279dSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5283fda9279dSmrg # is contrary to our usage. Disable this feature. 5284fda9279dSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5285fda9279dSmrg setopt NO_GLOB_SUBST 5286fda9279dSmrgelse 5287fda9279dSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5288fda9279dSmrgfi 5289fda9279dSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5290fda9279dSmrgDUALCASE=1; export DUALCASE # for MKS sh 5291fda9279dSmrg 5292fda9279dSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5293fda9279dSmrg# if CDPATH is set. 5294fda9279dSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5295fda9279dSmrg 5296fda9279dSmrgrelink_command=\"$relink_command\" 5297fda9279dSmrg 5298fda9279dSmrg# This environment variable determines our operation mode. 5299fda9279dSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5300fda9279dSmrg # install mode needs the following variables: 5301fda9279dSmrg generated_by_libtool_version='$macro_version' 5302fda9279dSmrg notinst_deplibs='$notinst_deplibs' 5303fda9279dSmrgelse 5304fda9279dSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5305fda9279dSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5306fda9279dSmrg file=\"\$0\"" 5307fda9279dSmrg 5308dd52494dSmrg func_quote "$ECHO" 5309dd52494dSmrg qECHO=$func_quote_result 5310fda9279dSmrg $ECHO "\ 5311fda9279dSmrg 5312fda9279dSmrg# A function that is used when there is no print builtin or printf. 5313fda9279dSmrgfunc_fallback_echo () 5314fda9279dSmrg{ 5315fda9279dSmrg eval 'cat <<_LTECHO_EOF 5316fda9279dSmrg\$1 5317fda9279dSmrg_LTECHO_EOF' 5318fda9279dSmrg} 5319fda9279dSmrg ECHO=\"$qECHO\" 5320fda9279dSmrg fi 5321fda9279dSmrg 5322fda9279dSmrg# Very basic option parsing. These options are (a) specific to 5323fda9279dSmrg# the libtool wrapper, (b) are identical between the wrapper 532416ee1e9aSmrg# /script/ and the wrapper /executable/ that is used only on 5325fda9279dSmrg# windows platforms, and (c) all begin with the string "--lt-" 532616ee1e9aSmrg# (application programs are unlikely to have options that match 5327fda9279dSmrg# this pattern). 5328fda9279dSmrg# 5329fda9279dSmrg# There are only two supported options: --lt-debug and 5330fda9279dSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 5331fda9279dSmrg# 5332fda9279dSmrg# The first argument to this parsing function should be the 5333fda9279dSmrg# script's $0 value, followed by "$@". 5334fda9279dSmrglt_option_debug= 5335fda9279dSmrgfunc_parse_lt_options () 5336fda9279dSmrg{ 5337fda9279dSmrg lt_script_arg0=\$0 5338fda9279dSmrg shift 5339fda9279dSmrg for lt_opt 5340fda9279dSmrg do 5341fda9279dSmrg case \"\$lt_opt\" in 5342fda9279dSmrg --lt-debug) lt_option_debug=1 ;; 5343fda9279dSmrg --lt-dump-script) 5344fda9279dSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5345fda9279dSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5346fda9279dSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5347fda9279dSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 5348fda9279dSmrg exit 0 5349fda9279dSmrg ;; 5350fda9279dSmrg --lt-*) 5351fda9279dSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5352fda9279dSmrg exit 1 5353fda9279dSmrg ;; 5354fda9279dSmrg esac 5355fda9279dSmrg done 5356fda9279dSmrg 5357fda9279dSmrg # Print the debug banner immediately: 5358fda9279dSmrg if test -n \"\$lt_option_debug\"; then 535916ee1e9aSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5360fda9279dSmrg fi 5361fda9279dSmrg} 5362fda9279dSmrg 5363fda9279dSmrg# Used when --lt-debug. Prints its arguments to stdout 5364fda9279dSmrg# (redirection is the responsibility of the caller) 5365fda9279dSmrgfunc_lt_dump_args () 5366fda9279dSmrg{ 5367fda9279dSmrg lt_dump_args_N=1; 5368fda9279dSmrg for lt_arg 5369fda9279dSmrg do 537016ee1e9aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5371fda9279dSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5372fda9279dSmrg done 5373fda9279dSmrg} 5374fda9279dSmrg 5375fda9279dSmrg# Core function for launching the target application 5376fda9279dSmrgfunc_exec_program_core () 5377fda9279dSmrg{ 5378fda9279dSmrg" 5379fda9279dSmrg case $host in 5380fda9279dSmrg # Backslashes separate directories on plain windows 5381fda9279dSmrg *-*-mingw | *-*-os2* | *-cegcc*) 5382fda9279dSmrg $ECHO "\ 5383fda9279dSmrg if test -n \"\$lt_option_debug\"; then 538416ee1e9aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5385fda9279dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5386fda9279dSmrg fi 5387fda9279dSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5388fda9279dSmrg" 5389fda9279dSmrg ;; 5390fda9279dSmrg 5391fda9279dSmrg *) 5392fda9279dSmrg $ECHO "\ 5393fda9279dSmrg if test -n \"\$lt_option_debug\"; then 539416ee1e9aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5395fda9279dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5396fda9279dSmrg fi 5397fda9279dSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5398fda9279dSmrg" 5399fda9279dSmrg ;; 5400fda9279dSmrg esac 5401fda9279dSmrg $ECHO "\ 5402fda9279dSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5403fda9279dSmrg exit 1 5404fda9279dSmrg} 5405fda9279dSmrg 5406fda9279dSmrg# A function to encapsulate launching the target application 5407fda9279dSmrg# Strips options in the --lt-* namespace from \$@ and 5408fda9279dSmrg# launches target application with the remaining arguments. 5409fda9279dSmrgfunc_exec_program () 5410fda9279dSmrg{ 5411fda9279dSmrg case \" \$* \" in 5412fda9279dSmrg *\\ --lt-*) 5413fda9279dSmrg for lt_wr_arg 5414fda9279dSmrg do 5415fda9279dSmrg case \$lt_wr_arg in 5416fda9279dSmrg --lt-*) ;; 5417fda9279dSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5418fda9279dSmrg esac 5419fda9279dSmrg shift 5420fda9279dSmrg done ;; 5421fda9279dSmrg esac 5422fda9279dSmrg func_exec_program_core \${1+\"\$@\"} 5423fda9279dSmrg} 5424fda9279dSmrg 5425fda9279dSmrg # Parse options 5426fda9279dSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5427fda9279dSmrg 5428fda9279dSmrg # Find the directory that this script lives in. 5429fda9279dSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5430fda9279dSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5431fda9279dSmrg 5432fda9279dSmrg # Follow symbolic links until we get to the real thisdir. 5433fda9279dSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5434fda9279dSmrg while test -n \"\$file\"; do 5435fda9279dSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5436fda9279dSmrg 5437fda9279dSmrg # If there was a directory component, then change thisdir. 5438fda9279dSmrg if test \"x\$destdir\" != \"x\$file\"; then 5439fda9279dSmrg case \"\$destdir\" in 5440fda9279dSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5441fda9279dSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5442fda9279dSmrg esac 5443fda9279dSmrg fi 5444fda9279dSmrg 5445fda9279dSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5446fda9279dSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5447fda9279dSmrg done 5448fda9279dSmrg 5449fda9279dSmrg # Usually 'no', except on cygwin/mingw when embedded into 5450fda9279dSmrg # the cwrapper. 5451fda9279dSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5452fda9279dSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5453fda9279dSmrg # special case for '.' 5454fda9279dSmrg if test \"\$thisdir\" = \".\"; then 5455fda9279dSmrg thisdir=\`pwd\` 5456fda9279dSmrg fi 5457fda9279dSmrg # remove .libs from thisdir 5458fda9279dSmrg case \"\$thisdir\" in 5459fda9279dSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5460fda9279dSmrg $objdir ) thisdir=. ;; 5461fda9279dSmrg esac 5462fda9279dSmrg fi 5463fda9279dSmrg 5464fda9279dSmrg # Try to get the absolute directory name. 5465fda9279dSmrg absdir=\`cd \"\$thisdir\" && pwd\` 5466fda9279dSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5467fda9279dSmrg" 5468fda9279dSmrg 546916ee1e9aSmrg if test yes = "$fast_install"; then 5470fda9279dSmrg $ECHO "\ 5471fda9279dSmrg program=lt-'$outputname'$exeext 5472fda9279dSmrg progdir=\"\$thisdir/$objdir\" 5473fda9279dSmrg 5474fda9279dSmrg if test ! -f \"\$progdir/\$program\" || 547516ee1e9aSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5476fda9279dSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5477fda9279dSmrg 5478fda9279dSmrg file=\"\$\$-\$program\" 5479fda9279dSmrg 5480fda9279dSmrg if test ! -d \"\$progdir\"; then 5481fda9279dSmrg $MKDIR \"\$progdir\" 5482fda9279dSmrg else 5483fda9279dSmrg $RM \"\$progdir/\$file\" 5484fda9279dSmrg fi" 5485fda9279dSmrg 5486fda9279dSmrg $ECHO "\ 5487fda9279dSmrg 5488fda9279dSmrg # relink executable if necessary 5489fda9279dSmrg if test -n \"\$relink_command\"; then 5490fda9279dSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5491fda9279dSmrg else 549216ee1e9aSmrg \$ECHO \"\$relink_command_output\" >&2 5493fda9279dSmrg $RM \"\$progdir/\$file\" 5494fda9279dSmrg exit 1 5495fda9279dSmrg fi 5496fda9279dSmrg fi 5497fda9279dSmrg 5498fda9279dSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5499fda9279dSmrg { $RM \"\$progdir/\$program\"; 5500fda9279dSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5501fda9279dSmrg $RM \"\$progdir/\$file\" 5502fda9279dSmrg fi" 5503fda9279dSmrg else 5504fda9279dSmrg $ECHO "\ 5505fda9279dSmrg program='$outputname' 5506fda9279dSmrg progdir=\"\$thisdir/$objdir\" 5507fda9279dSmrg" 5508fda9279dSmrg fi 5509fda9279dSmrg 5510fda9279dSmrg $ECHO "\ 5511fda9279dSmrg 5512fda9279dSmrg if test -f \"\$progdir/\$program\"; then" 5513fda9279dSmrg 5514fda9279dSmrg # fixup the dll searchpath if we need to. 5515fda9279dSmrg # 5516fda9279dSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5517fda9279dSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5518fda9279dSmrg # libraries must come first. 5519fda9279dSmrg if test -n "$dllsearchpath"; then 5520fda9279dSmrg $ECHO "\ 5521fda9279dSmrg # Add the dll search path components to the executable PATH 5522fda9279dSmrg PATH=$dllsearchpath:\$PATH 5523fda9279dSmrg" 5524fda9279dSmrg fi 5525fda9279dSmrg 5526fda9279dSmrg # Export our shlibpath_var if we have one. 552716ee1e9aSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5528fda9279dSmrg $ECHO "\ 5529fda9279dSmrg # Add our own library path to $shlibpath_var 5530fda9279dSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5531fda9279dSmrg 5532fda9279dSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 5533fda9279dSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5534fda9279dSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5535fda9279dSmrg 5536fda9279dSmrg export $shlibpath_var 5537fda9279dSmrg" 5538fda9279dSmrg fi 5539fda9279dSmrg 5540fda9279dSmrg $ECHO "\ 5541fda9279dSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5542fda9279dSmrg # Run the actual program with our arguments. 5543fda9279dSmrg func_exec_program \${1+\"\$@\"} 5544fda9279dSmrg fi 5545fda9279dSmrg else 5546fda9279dSmrg # The program doesn't exist. 554716ee1e9aSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5548fda9279dSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5549fda9279dSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5550fda9279dSmrg exit 1 5551fda9279dSmrg fi 5552fda9279dSmrgfi\ 5553fda9279dSmrg" 5554fda9279dSmrg} 5555fda9279dSmrg 5556fda9279dSmrg 5557fda9279dSmrg# func_emit_cwrapperexe_src 5558fda9279dSmrg# emit the source code for a wrapper executable on stdout 5559fda9279dSmrg# Must ONLY be called from within func_mode_link because 5560fda9279dSmrg# it depends on a number of variable set therein. 5561fda9279dSmrgfunc_emit_cwrapperexe_src () 5562fda9279dSmrg{ 5563fda9279dSmrg cat <<EOF 5564fda9279dSmrg 5565fda9279dSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 556616ee1e9aSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5567fda9279dSmrg 5568fda9279dSmrg The $output program cannot be directly executed until all the libtool 5569fda9279dSmrg libraries that it depends on are installed. 5570fda9279dSmrg 5571fda9279dSmrg This wrapper executable should never be moved out of the build directory. 5572fda9279dSmrg If it is, it will not operate correctly. 5573fda9279dSmrg*/ 5574fda9279dSmrgEOF 5575fda9279dSmrg cat <<"EOF" 5576fda9279dSmrg#ifdef _MSC_VER 5577fda9279dSmrg# define _CRT_SECURE_NO_DEPRECATE 1 5578fda9279dSmrg#endif 5579fda9279dSmrg#include <stdio.h> 5580fda9279dSmrg#include <stdlib.h> 5581fda9279dSmrg#ifdef _MSC_VER 5582fda9279dSmrg# include <direct.h> 5583fda9279dSmrg# include <process.h> 5584fda9279dSmrg# include <io.h> 5585fda9279dSmrg#else 5586fda9279dSmrg# include <unistd.h> 5587fda9279dSmrg# include <stdint.h> 5588fda9279dSmrg# ifdef __CYGWIN__ 5589fda9279dSmrg# include <io.h> 5590fda9279dSmrg# endif 5591fda9279dSmrg#endif 5592fda9279dSmrg#include <malloc.h> 5593fda9279dSmrg#include <stdarg.h> 5594fda9279dSmrg#include <assert.h> 5595fda9279dSmrg#include <string.h> 5596fda9279dSmrg#include <ctype.h> 5597fda9279dSmrg#include <errno.h> 5598fda9279dSmrg#include <fcntl.h> 5599fda9279dSmrg#include <sys/stat.h> 5600fda9279dSmrg 560116ee1e9aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 560216ee1e9aSmrg 5603fda9279dSmrg/* declarations of non-ANSI functions */ 560416ee1e9aSmrg#if defined __MINGW32__ 5605fda9279dSmrg# ifdef __STRICT_ANSI__ 5606fda9279dSmrgint _putenv (const char *); 5607fda9279dSmrg# endif 560816ee1e9aSmrg#elif defined __CYGWIN__ 5609fda9279dSmrg# ifdef __STRICT_ANSI__ 5610fda9279dSmrgchar *realpath (const char *, char *); 5611fda9279dSmrgint putenv (char *); 5612fda9279dSmrgint setenv (const char *, const char *, int); 5613fda9279dSmrg# endif 561416ee1e9aSmrg/* #elif defined other_platform || defined ... */ 5615fda9279dSmrg#endif 5616fda9279dSmrg 5617fda9279dSmrg/* portability defines, excluding path handling macros */ 561816ee1e9aSmrg#if defined _MSC_VER 5619fda9279dSmrg# define setmode _setmode 5620fda9279dSmrg# define stat _stat 5621fda9279dSmrg# define chmod _chmod 5622fda9279dSmrg# define getcwd _getcwd 5623fda9279dSmrg# define putenv _putenv 5624fda9279dSmrg# define S_IXUSR _S_IEXEC 562516ee1e9aSmrg#elif defined __MINGW32__ 5626fda9279dSmrg# define setmode _setmode 5627fda9279dSmrg# define stat _stat 5628fda9279dSmrg# define chmod _chmod 5629fda9279dSmrg# define getcwd _getcwd 5630fda9279dSmrg# define putenv _putenv 563116ee1e9aSmrg#elif defined __CYGWIN__ 5632fda9279dSmrg# define HAVE_SETENV 5633fda9279dSmrg# define FOPEN_WB "wb" 563416ee1e9aSmrg/* #elif defined other platforms ... */ 5635fda9279dSmrg#endif 5636fda9279dSmrg 563716ee1e9aSmrg#if defined PATH_MAX 5638fda9279dSmrg# define LT_PATHMAX PATH_MAX 563916ee1e9aSmrg#elif defined MAXPATHLEN 5640fda9279dSmrg# define LT_PATHMAX MAXPATHLEN 5641fda9279dSmrg#else 5642fda9279dSmrg# define LT_PATHMAX 1024 5643fda9279dSmrg#endif 5644fda9279dSmrg 5645fda9279dSmrg#ifndef S_IXOTH 5646fda9279dSmrg# define S_IXOTH 0 5647fda9279dSmrg#endif 5648fda9279dSmrg#ifndef S_IXGRP 5649fda9279dSmrg# define S_IXGRP 0 5650fda9279dSmrg#endif 5651fda9279dSmrg 5652fda9279dSmrg/* path handling portability macros */ 5653fda9279dSmrg#ifndef DIR_SEPARATOR 5654fda9279dSmrg# define DIR_SEPARATOR '/' 5655fda9279dSmrg# define PATH_SEPARATOR ':' 5656fda9279dSmrg#endif 5657fda9279dSmrg 565816ee1e9aSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 565916ee1e9aSmrg defined __OS2__ 5660fda9279dSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 5661fda9279dSmrg# define FOPEN_WB "wb" 5662fda9279dSmrg# ifndef DIR_SEPARATOR_2 5663fda9279dSmrg# define DIR_SEPARATOR_2 '\\' 5664fda9279dSmrg# endif 5665fda9279dSmrg# ifndef PATH_SEPARATOR_2 5666fda9279dSmrg# define PATH_SEPARATOR_2 ';' 5667fda9279dSmrg# endif 5668fda9279dSmrg#endif 5669fda9279dSmrg 5670fda9279dSmrg#ifndef DIR_SEPARATOR_2 5671fda9279dSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5672fda9279dSmrg#else /* DIR_SEPARATOR_2 */ 5673fda9279dSmrg# define IS_DIR_SEPARATOR(ch) \ 5674fda9279dSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5675fda9279dSmrg#endif /* DIR_SEPARATOR_2 */ 5676fda9279dSmrg 5677fda9279dSmrg#ifndef PATH_SEPARATOR_2 5678fda9279dSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5679fda9279dSmrg#else /* PATH_SEPARATOR_2 */ 5680fda9279dSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5681fda9279dSmrg#endif /* PATH_SEPARATOR_2 */ 5682fda9279dSmrg 5683fda9279dSmrg#ifndef FOPEN_WB 5684fda9279dSmrg# define FOPEN_WB "w" 5685fda9279dSmrg#endif 5686fda9279dSmrg#ifndef _O_BINARY 5687fda9279dSmrg# define _O_BINARY 0 5688fda9279dSmrg#endif 5689fda9279dSmrg 5690fda9279dSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5691fda9279dSmrg#define XFREE(stale) do { \ 569216ee1e9aSmrg if (stale) { free (stale); stale = 0; } \ 5693fda9279dSmrg} while (0) 5694fda9279dSmrg 569516ee1e9aSmrg#if defined LT_DEBUGWRAPPER 5696fda9279dSmrgstatic int lt_debug = 1; 5697fda9279dSmrg#else 5698fda9279dSmrgstatic int lt_debug = 0; 5699fda9279dSmrg#endif 5700fda9279dSmrg 5701fda9279dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5702fda9279dSmrg 5703fda9279dSmrgvoid *xmalloc (size_t num); 5704fda9279dSmrgchar *xstrdup (const char *string); 5705fda9279dSmrgconst char *base_name (const char *name); 5706fda9279dSmrgchar *find_executable (const char *wrapper); 5707fda9279dSmrgchar *chase_symlinks (const char *pathspec); 5708fda9279dSmrgint make_executable (const char *path); 5709fda9279dSmrgint check_executable (const char *path); 5710fda9279dSmrgchar *strendzap (char *str, const char *pat); 5711fda9279dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5712fda9279dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5713fda9279dSmrgstatic const char *nonnull (const char *s); 5714fda9279dSmrgstatic const char *nonempty (const char *s); 5715fda9279dSmrgvoid lt_setenv (const char *name, const char *value); 5716fda9279dSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5717fda9279dSmrgvoid lt_update_exe_path (const char *name, const char *value); 5718fda9279dSmrgvoid lt_update_lib_path (const char *name, const char *value); 5719fda9279dSmrgchar **prepare_spawn (char **argv); 5720fda9279dSmrgvoid lt_dump_script (FILE *f); 5721fda9279dSmrgEOF 5722fda9279dSmrg 5723fda9279dSmrg cat <<EOF 572416ee1e9aSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 572516ee1e9aSmrg# define externally_visible volatile 572616ee1e9aSmrg#else 572716ee1e9aSmrg# define externally_visible __attribute__((externally_visible)) volatile 572816ee1e9aSmrg#endif 572916ee1e9aSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5730fda9279dSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5731fda9279dSmrgEOF 5732fda9279dSmrg 573316ee1e9aSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5734fda9279dSmrg func_to_host_path "$temp_rpath" 5735fda9279dSmrg cat <<EOF 5736fda9279dSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5737fda9279dSmrgEOF 5738fda9279dSmrg else 5739fda9279dSmrg cat <<"EOF" 5740fda9279dSmrgconst char * LIB_PATH_VALUE = ""; 5741fda9279dSmrgEOF 5742fda9279dSmrg fi 5743fda9279dSmrg 5744fda9279dSmrg if test -n "$dllsearchpath"; then 5745fda9279dSmrg func_to_host_path "$dllsearchpath:" 5746fda9279dSmrg cat <<EOF 5747fda9279dSmrgconst char * EXE_PATH_VARNAME = "PATH"; 5748fda9279dSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5749fda9279dSmrgEOF 5750fda9279dSmrg else 5751fda9279dSmrg cat <<"EOF" 5752fda9279dSmrgconst char * EXE_PATH_VARNAME = ""; 5753fda9279dSmrgconst char * EXE_PATH_VALUE = ""; 5754fda9279dSmrgEOF 5755fda9279dSmrg fi 5756fda9279dSmrg 575716ee1e9aSmrg if test yes = "$fast_install"; then 5758fda9279dSmrg cat <<EOF 5759fda9279dSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5760fda9279dSmrgEOF 5761fda9279dSmrg else 5762fda9279dSmrg cat <<EOF 5763fda9279dSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5764fda9279dSmrgEOF 5765fda9279dSmrg fi 5766fda9279dSmrg 5767fda9279dSmrg 5768fda9279dSmrg cat <<"EOF" 5769fda9279dSmrg 5770fda9279dSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5771fda9279dSmrg 5772fda9279dSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5773fda9279dSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5774fda9279dSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5775fda9279dSmrg 5776fda9279dSmrgint 5777fda9279dSmrgmain (int argc, char *argv[]) 5778fda9279dSmrg{ 5779fda9279dSmrg char **newargz; 5780fda9279dSmrg int newargc; 5781fda9279dSmrg char *tmp_pathspec; 5782fda9279dSmrg char *actual_cwrapper_path; 5783fda9279dSmrg char *actual_cwrapper_name; 5784fda9279dSmrg char *target_name; 5785fda9279dSmrg char *lt_argv_zero; 578616ee1e9aSmrg int rval = 127; 5787fda9279dSmrg 5788fda9279dSmrg int i; 5789fda9279dSmrg 5790fda9279dSmrg program_name = (char *) xstrdup (base_name (argv[0])); 579116ee1e9aSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5792fda9279dSmrg 5793fda9279dSmrg /* very simple arg parsing; don't want to rely on getopt 5794fda9279dSmrg * also, copy all non cwrapper options to newargz, except 5795fda9279dSmrg * argz[0], which is handled differently 5796fda9279dSmrg */ 5797fda9279dSmrg newargc=0; 5798fda9279dSmrg for (i = 1; i < argc; i++) 5799fda9279dSmrg { 580016ee1e9aSmrg if (STREQ (argv[i], dumpscript_opt)) 5801fda9279dSmrg { 5802fda9279dSmrgEOF 580316ee1e9aSmrg case $host in 5804fda9279dSmrg *mingw* | *cygwin* ) 5805fda9279dSmrg # make stdout use "unix" line endings 5806fda9279dSmrg echo " setmode(1,_O_BINARY);" 5807fda9279dSmrg ;; 5808fda9279dSmrg esac 5809fda9279dSmrg 5810fda9279dSmrg cat <<"EOF" 5811fda9279dSmrg lt_dump_script (stdout); 5812fda9279dSmrg return 0; 5813fda9279dSmrg } 581416ee1e9aSmrg if (STREQ (argv[i], debug_opt)) 5815fda9279dSmrg { 5816fda9279dSmrg lt_debug = 1; 5817fda9279dSmrg continue; 5818fda9279dSmrg } 581916ee1e9aSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5820fda9279dSmrg { 5821fda9279dSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5822fda9279dSmrg namespace, but it is not one of the ones we know about and 5823fda9279dSmrg have already dealt with, above (inluding dump-script), then 5824fda9279dSmrg report an error. Otherwise, targets might begin to believe 5825fda9279dSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5826fda9279dSmrg namespace. The first time any user complains about this, we'll 5827fda9279dSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5828fda9279dSmrg or a configure.ac-settable value. 5829fda9279dSmrg */ 5830fda9279dSmrg lt_fatal (__FILE__, __LINE__, 5831fda9279dSmrg "unrecognized %s option: '%s'", 5832fda9279dSmrg ltwrapper_option_prefix, argv[i]); 5833fda9279dSmrg } 5834fda9279dSmrg /* otherwise ... */ 5835fda9279dSmrg newargz[++newargc] = xstrdup (argv[i]); 5836fda9279dSmrg } 5837fda9279dSmrg newargz[++newargc] = NULL; 5838fda9279dSmrg 5839fda9279dSmrgEOF 5840fda9279dSmrg cat <<EOF 5841fda9279dSmrg /* The GNU banner must be the first non-error debug message */ 584216ee1e9aSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5843fda9279dSmrgEOF 5844fda9279dSmrg cat <<"EOF" 5845fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5846fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5847fda9279dSmrg 5848fda9279dSmrg tmp_pathspec = find_executable (argv[0]); 5849fda9279dSmrg if (tmp_pathspec == NULL) 5850fda9279dSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5851fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5852fda9279dSmrg "(main) found exe (before symlink chase) at: %s\n", 5853fda9279dSmrg tmp_pathspec); 5854fda9279dSmrg 5855fda9279dSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5856fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5857fda9279dSmrg "(main) found exe (after symlink chase) at: %s\n", 5858fda9279dSmrg actual_cwrapper_path); 5859fda9279dSmrg XFREE (tmp_pathspec); 5860fda9279dSmrg 5861fda9279dSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5862fda9279dSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5863fda9279dSmrg 5864fda9279dSmrg /* wrapper name transforms */ 5865fda9279dSmrg strendzap (actual_cwrapper_name, ".exe"); 5866fda9279dSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5867fda9279dSmrg XFREE (actual_cwrapper_name); 5868fda9279dSmrg actual_cwrapper_name = tmp_pathspec; 5869fda9279dSmrg tmp_pathspec = 0; 5870fda9279dSmrg 5871fda9279dSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5872fda9279dSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5873fda9279dSmrg strendzap (target_name, ".exe"); 5874fda9279dSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5875fda9279dSmrg XFREE (target_name); 5876fda9279dSmrg target_name = tmp_pathspec; 5877fda9279dSmrg tmp_pathspec = 0; 5878fda9279dSmrg 5879fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5880fda9279dSmrg "(main) libtool target name: %s\n", 5881fda9279dSmrg target_name); 5882fda9279dSmrgEOF 5883fda9279dSmrg 5884fda9279dSmrg cat <<EOF 5885fda9279dSmrg newargz[0] = 5886fda9279dSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5887fda9279dSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5888fda9279dSmrg strcpy (newargz[0], actual_cwrapper_path); 5889fda9279dSmrg strcat (newargz[0], "$objdir"); 5890fda9279dSmrg strcat (newargz[0], "/"); 5891fda9279dSmrgEOF 5892fda9279dSmrg 5893fda9279dSmrg cat <<"EOF" 5894fda9279dSmrg /* stop here, and copy so we don't have to do this twice */ 5895fda9279dSmrg tmp_pathspec = xstrdup (newargz[0]); 5896fda9279dSmrg 5897fda9279dSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5898fda9279dSmrg strcat (newargz[0], actual_cwrapper_name); 5899fda9279dSmrg 5900fda9279dSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 5901fda9279dSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5902fda9279dSmrg XFREE (tmp_pathspec); 5903fda9279dSmrg tmp_pathspec = NULL; 5904fda9279dSmrgEOF 5905fda9279dSmrg 5906fda9279dSmrg case $host_os in 5907fda9279dSmrg mingw*) 5908fda9279dSmrg cat <<"EOF" 5909fda9279dSmrg { 5910fda9279dSmrg char* p; 5911fda9279dSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 5912fda9279dSmrg { 5913fda9279dSmrg *p = '/'; 5914fda9279dSmrg } 5915fda9279dSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5916fda9279dSmrg { 5917fda9279dSmrg *p = '/'; 5918fda9279dSmrg } 5919fda9279dSmrg } 5920fda9279dSmrgEOF 5921fda9279dSmrg ;; 5922fda9279dSmrg esac 5923fda9279dSmrg 5924fda9279dSmrg cat <<"EOF" 5925fda9279dSmrg XFREE (target_name); 5926fda9279dSmrg XFREE (actual_cwrapper_path); 5927fda9279dSmrg XFREE (actual_cwrapper_name); 5928fda9279dSmrg 5929fda9279dSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5930fda9279dSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5931fda9279dSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5932fda9279dSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5933fda9279dSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5934fda9279dSmrg libraries must come first. */ 5935fda9279dSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5936fda9279dSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5937fda9279dSmrg 5938fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5939fda9279dSmrg nonnull (lt_argv_zero)); 5940fda9279dSmrg for (i = 0; i < newargc; i++) 5941fda9279dSmrg { 5942fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5943fda9279dSmrg i, nonnull (newargz[i])); 5944fda9279dSmrg } 5945fda9279dSmrg 5946fda9279dSmrgEOF 5947fda9279dSmrg 5948fda9279dSmrg case $host_os in 5949fda9279dSmrg mingw*) 5950fda9279dSmrg cat <<"EOF" 5951fda9279dSmrg /* execv doesn't actually work on mingw as expected on unix */ 5952fda9279dSmrg newargz = prepare_spawn (newargz); 595316ee1e9aSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5954fda9279dSmrg if (rval == -1) 5955fda9279dSmrg { 5956fda9279dSmrg /* failed to start process */ 5957fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 5958fda9279dSmrg "(main) failed to launch target \"%s\": %s\n", 5959fda9279dSmrg lt_argv_zero, nonnull (strerror (errno))); 5960fda9279dSmrg return 127; 5961fda9279dSmrg } 5962fda9279dSmrg return rval; 5963fda9279dSmrgEOF 5964fda9279dSmrg ;; 5965fda9279dSmrg *) 5966fda9279dSmrg cat <<"EOF" 5967fda9279dSmrg execv (lt_argv_zero, newargz); 5968fda9279dSmrg return rval; /* =127, but avoids unused variable warning */ 5969fda9279dSmrgEOF 5970fda9279dSmrg ;; 5971fda9279dSmrg esac 5972fda9279dSmrg 5973fda9279dSmrg cat <<"EOF" 5974fda9279dSmrg} 5975fda9279dSmrg 5976fda9279dSmrgvoid * 5977fda9279dSmrgxmalloc (size_t num) 5978fda9279dSmrg{ 5979fda9279dSmrg void *p = (void *) malloc (num); 5980fda9279dSmrg if (!p) 5981fda9279dSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5982fda9279dSmrg 5983fda9279dSmrg return p; 5984fda9279dSmrg} 5985fda9279dSmrg 5986fda9279dSmrgchar * 5987fda9279dSmrgxstrdup (const char *string) 5988fda9279dSmrg{ 5989fda9279dSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5990fda9279dSmrg string) : NULL; 5991fda9279dSmrg} 5992fda9279dSmrg 5993fda9279dSmrgconst char * 5994fda9279dSmrgbase_name (const char *name) 5995fda9279dSmrg{ 5996fda9279dSmrg const char *base; 5997fda9279dSmrg 599816ee1e9aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5999fda9279dSmrg /* Skip over the disk name in MSDOS pathnames. */ 6000fda9279dSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6001fda9279dSmrg name += 2; 6002fda9279dSmrg#endif 6003fda9279dSmrg 6004fda9279dSmrg for (base = name; *name; name++) 6005fda9279dSmrg if (IS_DIR_SEPARATOR (*name)) 6006fda9279dSmrg base = name + 1; 6007fda9279dSmrg return base; 6008fda9279dSmrg} 6009fda9279dSmrg 6010fda9279dSmrgint 6011fda9279dSmrgcheck_executable (const char *path) 6012fda9279dSmrg{ 6013fda9279dSmrg struct stat st; 6014fda9279dSmrg 6015fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6016fda9279dSmrg nonempty (path)); 6017fda9279dSmrg if ((!path) || (!*path)) 6018fda9279dSmrg return 0; 6019fda9279dSmrg 6020fda9279dSmrg if ((stat (path, &st) >= 0) 6021fda9279dSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6022fda9279dSmrg return 1; 6023fda9279dSmrg else 6024fda9279dSmrg return 0; 6025fda9279dSmrg} 6026fda9279dSmrg 6027fda9279dSmrgint 6028fda9279dSmrgmake_executable (const char *path) 6029fda9279dSmrg{ 6030fda9279dSmrg int rval = 0; 6031fda9279dSmrg struct stat st; 6032fda9279dSmrg 6033fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6034fda9279dSmrg nonempty (path)); 6035fda9279dSmrg if ((!path) || (!*path)) 6036fda9279dSmrg return 0; 6037fda9279dSmrg 6038fda9279dSmrg if (stat (path, &st) >= 0) 6039fda9279dSmrg { 6040fda9279dSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6041fda9279dSmrg } 6042fda9279dSmrg return rval; 6043fda9279dSmrg} 6044fda9279dSmrg 6045fda9279dSmrg/* Searches for the full path of the wrapper. Returns 6046fda9279dSmrg newly allocated full path name if found, NULL otherwise 6047fda9279dSmrg Does not chase symlinks, even on platforms that support them. 6048fda9279dSmrg*/ 6049fda9279dSmrgchar * 6050fda9279dSmrgfind_executable (const char *wrapper) 6051fda9279dSmrg{ 6052fda9279dSmrg int has_slash = 0; 6053fda9279dSmrg const char *p; 6054fda9279dSmrg const char *p_next; 6055fda9279dSmrg /* static buffer for getcwd */ 6056fda9279dSmrg char tmp[LT_PATHMAX + 1]; 605716ee1e9aSmrg size_t tmp_len; 6058fda9279dSmrg char *concat_name; 6059fda9279dSmrg 6060fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6061fda9279dSmrg nonempty (wrapper)); 6062fda9279dSmrg 6063fda9279dSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 6064fda9279dSmrg return NULL; 6065fda9279dSmrg 6066fda9279dSmrg /* Absolute path? */ 606716ee1e9aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6068fda9279dSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6069fda9279dSmrg { 6070fda9279dSmrg concat_name = xstrdup (wrapper); 6071fda9279dSmrg if (check_executable (concat_name)) 6072fda9279dSmrg return concat_name; 6073fda9279dSmrg XFREE (concat_name); 6074fda9279dSmrg } 6075fda9279dSmrg else 6076fda9279dSmrg { 6077fda9279dSmrg#endif 6078fda9279dSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 6079fda9279dSmrg { 6080fda9279dSmrg concat_name = xstrdup (wrapper); 6081fda9279dSmrg if (check_executable (concat_name)) 6082fda9279dSmrg return concat_name; 6083fda9279dSmrg XFREE (concat_name); 6084fda9279dSmrg } 608516ee1e9aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6086fda9279dSmrg } 6087fda9279dSmrg#endif 6088fda9279dSmrg 6089fda9279dSmrg for (p = wrapper; *p; p++) 6090fda9279dSmrg if (*p == '/') 6091fda9279dSmrg { 6092fda9279dSmrg has_slash = 1; 6093fda9279dSmrg break; 6094fda9279dSmrg } 6095fda9279dSmrg if (!has_slash) 6096fda9279dSmrg { 6097fda9279dSmrg /* no slashes; search PATH */ 6098fda9279dSmrg const char *path = getenv ("PATH"); 6099fda9279dSmrg if (path != NULL) 6100fda9279dSmrg { 6101fda9279dSmrg for (p = path; *p; p = p_next) 6102fda9279dSmrg { 6103fda9279dSmrg const char *q; 6104fda9279dSmrg size_t p_len; 6105fda9279dSmrg for (q = p; *q; q++) 6106fda9279dSmrg if (IS_PATH_SEPARATOR (*q)) 6107fda9279dSmrg break; 610816ee1e9aSmrg p_len = (size_t) (q - p); 6109fda9279dSmrg p_next = (*q == '\0' ? q : q + 1); 6110fda9279dSmrg if (p_len == 0) 6111fda9279dSmrg { 6112fda9279dSmrg /* empty path: current directory */ 6113fda9279dSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6114fda9279dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6115fda9279dSmrg nonnull (strerror (errno))); 6116fda9279dSmrg tmp_len = strlen (tmp); 6117fda9279dSmrg concat_name = 6118fda9279dSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6119fda9279dSmrg memcpy (concat_name, tmp, tmp_len); 6120fda9279dSmrg concat_name[tmp_len] = '/'; 6121fda9279dSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6122fda9279dSmrg } 6123fda9279dSmrg else 6124fda9279dSmrg { 6125fda9279dSmrg concat_name = 6126fda9279dSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6127fda9279dSmrg memcpy (concat_name, p, p_len); 6128fda9279dSmrg concat_name[p_len] = '/'; 6129fda9279dSmrg strcpy (concat_name + p_len + 1, wrapper); 6130fda9279dSmrg } 6131fda9279dSmrg if (check_executable (concat_name)) 6132fda9279dSmrg return concat_name; 6133fda9279dSmrg XFREE (concat_name); 6134fda9279dSmrg } 6135fda9279dSmrg } 6136fda9279dSmrg /* not found in PATH; assume curdir */ 6137fda9279dSmrg } 6138fda9279dSmrg /* Relative path | not found in path: prepend cwd */ 6139fda9279dSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6140fda9279dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6141fda9279dSmrg nonnull (strerror (errno))); 6142fda9279dSmrg tmp_len = strlen (tmp); 6143fda9279dSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6144fda9279dSmrg memcpy (concat_name, tmp, tmp_len); 6145fda9279dSmrg concat_name[tmp_len] = '/'; 6146fda9279dSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6147fda9279dSmrg 6148fda9279dSmrg if (check_executable (concat_name)) 6149fda9279dSmrg return concat_name; 6150fda9279dSmrg XFREE (concat_name); 6151fda9279dSmrg return NULL; 6152fda9279dSmrg} 6153fda9279dSmrg 6154fda9279dSmrgchar * 6155fda9279dSmrgchase_symlinks (const char *pathspec) 6156fda9279dSmrg{ 6157fda9279dSmrg#ifndef S_ISLNK 6158fda9279dSmrg return xstrdup (pathspec); 6159fda9279dSmrg#else 6160fda9279dSmrg char buf[LT_PATHMAX]; 6161fda9279dSmrg struct stat s; 6162fda9279dSmrg char *tmp_pathspec = xstrdup (pathspec); 6163fda9279dSmrg char *p; 6164fda9279dSmrg int has_symlinks = 0; 6165fda9279dSmrg while (strlen (tmp_pathspec) && !has_symlinks) 6166fda9279dSmrg { 6167fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6168fda9279dSmrg "checking path component for symlinks: %s\n", 6169fda9279dSmrg tmp_pathspec); 6170fda9279dSmrg if (lstat (tmp_pathspec, &s) == 0) 6171fda9279dSmrg { 6172fda9279dSmrg if (S_ISLNK (s.st_mode) != 0) 6173fda9279dSmrg { 6174fda9279dSmrg has_symlinks = 1; 6175fda9279dSmrg break; 6176fda9279dSmrg } 6177fda9279dSmrg 6178fda9279dSmrg /* search backwards for last DIR_SEPARATOR */ 6179fda9279dSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6180fda9279dSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6181fda9279dSmrg p--; 6182fda9279dSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6183fda9279dSmrg { 6184fda9279dSmrg /* no more DIR_SEPARATORS left */ 6185fda9279dSmrg break; 6186fda9279dSmrg } 6187fda9279dSmrg *p = '\0'; 6188fda9279dSmrg } 6189fda9279dSmrg else 6190fda9279dSmrg { 6191fda9279dSmrg lt_fatal (__FILE__, __LINE__, 6192fda9279dSmrg "error accessing file \"%s\": %s", 6193fda9279dSmrg tmp_pathspec, nonnull (strerror (errno))); 6194fda9279dSmrg } 6195fda9279dSmrg } 6196fda9279dSmrg XFREE (tmp_pathspec); 6197fda9279dSmrg 6198fda9279dSmrg if (!has_symlinks) 6199fda9279dSmrg { 6200fda9279dSmrg return xstrdup (pathspec); 6201fda9279dSmrg } 6202fda9279dSmrg 6203fda9279dSmrg tmp_pathspec = realpath (pathspec, buf); 6204fda9279dSmrg if (tmp_pathspec == 0) 6205fda9279dSmrg { 6206fda9279dSmrg lt_fatal (__FILE__, __LINE__, 6207fda9279dSmrg "could not follow symlinks for %s", pathspec); 6208fda9279dSmrg } 6209fda9279dSmrg return xstrdup (tmp_pathspec); 6210fda9279dSmrg#endif 6211fda9279dSmrg} 6212fda9279dSmrg 6213fda9279dSmrgchar * 6214fda9279dSmrgstrendzap (char *str, const char *pat) 6215fda9279dSmrg{ 6216fda9279dSmrg size_t len, patlen; 6217fda9279dSmrg 6218fda9279dSmrg assert (str != NULL); 6219fda9279dSmrg assert (pat != NULL); 6220fda9279dSmrg 6221fda9279dSmrg len = strlen (str); 6222fda9279dSmrg patlen = strlen (pat); 6223fda9279dSmrg 6224fda9279dSmrg if (patlen <= len) 6225fda9279dSmrg { 6226fda9279dSmrg str += len - patlen; 622716ee1e9aSmrg if (STREQ (str, pat)) 6228fda9279dSmrg *str = '\0'; 6229fda9279dSmrg } 6230fda9279dSmrg return str; 6231fda9279dSmrg} 6232fda9279dSmrg 6233fda9279dSmrgvoid 6234fda9279dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6235fda9279dSmrg{ 6236fda9279dSmrg va_list args; 6237fda9279dSmrg if (lt_debug) 6238fda9279dSmrg { 6239fda9279dSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6240fda9279dSmrg va_start (args, fmt); 6241fda9279dSmrg (void) vfprintf (stderr, fmt, args); 6242fda9279dSmrg va_end (args); 6243fda9279dSmrg } 6244fda9279dSmrg} 6245fda9279dSmrg 6246fda9279dSmrgstatic void 6247fda9279dSmrglt_error_core (int exit_status, const char *file, 6248fda9279dSmrg int line, const char *mode, 6249fda9279dSmrg const char *message, va_list ap) 6250fda9279dSmrg{ 6251fda9279dSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6252fda9279dSmrg vfprintf (stderr, message, ap); 6253fda9279dSmrg fprintf (stderr, ".\n"); 6254fda9279dSmrg 6255fda9279dSmrg if (exit_status >= 0) 6256fda9279dSmrg exit (exit_status); 6257fda9279dSmrg} 6258fda9279dSmrg 6259fda9279dSmrgvoid 6260fda9279dSmrglt_fatal (const char *file, int line, const char *message, ...) 6261fda9279dSmrg{ 6262fda9279dSmrg va_list ap; 6263fda9279dSmrg va_start (ap, message); 6264fda9279dSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6265fda9279dSmrg va_end (ap); 6266fda9279dSmrg} 6267fda9279dSmrg 6268fda9279dSmrgstatic const char * 6269fda9279dSmrgnonnull (const char *s) 6270fda9279dSmrg{ 6271fda9279dSmrg return s ? s : "(null)"; 6272fda9279dSmrg} 6273fda9279dSmrg 6274fda9279dSmrgstatic const char * 6275fda9279dSmrgnonempty (const char *s) 6276fda9279dSmrg{ 6277fda9279dSmrg return (s && !*s) ? "(empty)" : nonnull (s); 6278fda9279dSmrg} 6279fda9279dSmrg 6280fda9279dSmrgvoid 6281fda9279dSmrglt_setenv (const char *name, const char *value) 6282fda9279dSmrg{ 6283fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6284fda9279dSmrg "(lt_setenv) setting '%s' to '%s'\n", 6285fda9279dSmrg nonnull (name), nonnull (value)); 6286fda9279dSmrg { 6287fda9279dSmrg#ifdef HAVE_SETENV 6288fda9279dSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 6289fda9279dSmrg char *str = xstrdup (value); 6290fda9279dSmrg setenv (name, str, 1); 6291fda9279dSmrg#else 629216ee1e9aSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6293fda9279dSmrg char *str = XMALLOC (char, len); 6294fda9279dSmrg sprintf (str, "%s=%s", name, value); 6295fda9279dSmrg if (putenv (str) != EXIT_SUCCESS) 6296fda9279dSmrg { 6297fda9279dSmrg XFREE (str); 6298fda9279dSmrg } 6299fda9279dSmrg#endif 6300fda9279dSmrg } 6301fda9279dSmrg} 6302fda9279dSmrg 6303fda9279dSmrgchar * 6304fda9279dSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 6305fda9279dSmrg{ 6306fda9279dSmrg char *new_value; 6307fda9279dSmrg if (orig_value && *orig_value) 6308fda9279dSmrg { 630916ee1e9aSmrg size_t orig_value_len = strlen (orig_value); 631016ee1e9aSmrg size_t add_len = strlen (add); 6311fda9279dSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6312fda9279dSmrg if (to_end) 6313fda9279dSmrg { 6314fda9279dSmrg strcpy (new_value, orig_value); 6315fda9279dSmrg strcpy (new_value + orig_value_len, add); 6316fda9279dSmrg } 6317fda9279dSmrg else 6318fda9279dSmrg { 6319fda9279dSmrg strcpy (new_value, add); 6320fda9279dSmrg strcpy (new_value + add_len, orig_value); 6321fda9279dSmrg } 6322fda9279dSmrg } 6323fda9279dSmrg else 6324fda9279dSmrg { 6325fda9279dSmrg new_value = xstrdup (add); 6326fda9279dSmrg } 6327fda9279dSmrg return new_value; 6328fda9279dSmrg} 6329fda9279dSmrg 6330fda9279dSmrgvoid 6331fda9279dSmrglt_update_exe_path (const char *name, const char *value) 6332fda9279dSmrg{ 6333fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6334fda9279dSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6335fda9279dSmrg nonnull (name), nonnull (value)); 6336fda9279dSmrg 6337fda9279dSmrg if (name && *name && value && *value) 6338fda9279dSmrg { 6339fda9279dSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6340fda9279dSmrg /* some systems can't cope with a ':'-terminated path #' */ 634116ee1e9aSmrg size_t len = strlen (new_value); 634216ee1e9aSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6343fda9279dSmrg { 634416ee1e9aSmrg new_value[--len] = '\0'; 6345fda9279dSmrg } 6346fda9279dSmrg lt_setenv (name, new_value); 6347fda9279dSmrg XFREE (new_value); 6348fda9279dSmrg } 6349fda9279dSmrg} 6350fda9279dSmrg 6351fda9279dSmrgvoid 6352fda9279dSmrglt_update_lib_path (const char *name, const char *value) 6353fda9279dSmrg{ 6354fda9279dSmrg lt_debugprintf (__FILE__, __LINE__, 6355fda9279dSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6356fda9279dSmrg nonnull (name), nonnull (value)); 6357fda9279dSmrg 6358fda9279dSmrg if (name && *name && value && *value) 6359fda9279dSmrg { 6360fda9279dSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6361fda9279dSmrg lt_setenv (name, new_value); 6362fda9279dSmrg XFREE (new_value); 6363fda9279dSmrg } 6364fda9279dSmrg} 6365fda9279dSmrg 6366fda9279dSmrgEOF 6367fda9279dSmrg case $host_os in 6368fda9279dSmrg mingw*) 6369fda9279dSmrg cat <<"EOF" 6370fda9279dSmrg 6371fda9279dSmrg/* Prepares an argument vector before calling spawn(). 6372fda9279dSmrg Note that spawn() does not by itself call the command interpreter 6373fda9279dSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6374fda9279dSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6375fda9279dSmrg GetVersionEx(&v); 6376fda9279dSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6377fda9279dSmrg }) ? "cmd.exe" : "command.com"). 6378fda9279dSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 6379fda9279dSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6380fda9279dSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6381fda9279dSmrg special way: 6382fda9279dSmrg - Space and tab are interpreted as delimiters. They are not treated as 6383fda9279dSmrg delimiters if they are surrounded by double quotes: "...". 6384fda9279dSmrg - Unescaped double quotes are removed from the input. Their only effect is 6385fda9279dSmrg that within double quotes, space and tab are treated like normal 6386fda9279dSmrg characters. 6387fda9279dSmrg - Backslashes not followed by double quotes are not special. 6388fda9279dSmrg - But 2*n+1 backslashes followed by a double quote become 6389fda9279dSmrg n backslashes followed by a double quote (n >= 0): 6390fda9279dSmrg \" -> " 6391fda9279dSmrg \\\" -> \" 6392fda9279dSmrg \\\\\" -> \\" 6393fda9279dSmrg */ 6394fda9279dSmrg#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" 6395fda9279dSmrg#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" 6396fda9279dSmrgchar ** 6397fda9279dSmrgprepare_spawn (char **argv) 6398fda9279dSmrg{ 6399fda9279dSmrg size_t argc; 6400fda9279dSmrg char **new_argv; 6401fda9279dSmrg size_t i; 6402fda9279dSmrg 6403fda9279dSmrg /* Count number of arguments. */ 6404fda9279dSmrg for (argc = 0; argv[argc] != NULL; argc++) 6405fda9279dSmrg ; 6406fda9279dSmrg 6407fda9279dSmrg /* Allocate new argument vector. */ 6408fda9279dSmrg new_argv = XMALLOC (char *, argc + 1); 6409fda9279dSmrg 6410fda9279dSmrg /* Put quoted arguments into the new argument vector. */ 6411fda9279dSmrg for (i = 0; i < argc; i++) 6412fda9279dSmrg { 6413fda9279dSmrg const char *string = argv[i]; 6414fda9279dSmrg 6415fda9279dSmrg if (string[0] == '\0') 6416fda9279dSmrg new_argv[i] = xstrdup ("\"\""); 6417fda9279dSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6418fda9279dSmrg { 6419fda9279dSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6420fda9279dSmrg size_t length; 6421fda9279dSmrg unsigned int backslashes; 6422fda9279dSmrg const char *s; 6423fda9279dSmrg char *quoted_string; 6424fda9279dSmrg char *p; 6425fda9279dSmrg 6426fda9279dSmrg length = 0; 6427fda9279dSmrg backslashes = 0; 6428fda9279dSmrg if (quote_around) 6429fda9279dSmrg length++; 6430fda9279dSmrg for (s = string; *s != '\0'; s++) 6431fda9279dSmrg { 6432fda9279dSmrg char c = *s; 6433fda9279dSmrg if (c == '"') 6434fda9279dSmrg length += backslashes + 1; 6435fda9279dSmrg length++; 6436fda9279dSmrg if (c == '\\') 6437fda9279dSmrg backslashes++; 6438fda9279dSmrg else 6439fda9279dSmrg backslashes = 0; 6440fda9279dSmrg } 6441fda9279dSmrg if (quote_around) 6442fda9279dSmrg length += backslashes + 1; 6443fda9279dSmrg 6444fda9279dSmrg quoted_string = XMALLOC (char, length + 1); 6445fda9279dSmrg 6446fda9279dSmrg p = quoted_string; 6447fda9279dSmrg backslashes = 0; 6448fda9279dSmrg if (quote_around) 6449fda9279dSmrg *p++ = '"'; 6450fda9279dSmrg for (s = string; *s != '\0'; s++) 6451fda9279dSmrg { 6452fda9279dSmrg char c = *s; 6453fda9279dSmrg if (c == '"') 6454fda9279dSmrg { 6455fda9279dSmrg unsigned int j; 6456fda9279dSmrg for (j = backslashes + 1; j > 0; j--) 6457fda9279dSmrg *p++ = '\\'; 6458fda9279dSmrg } 6459fda9279dSmrg *p++ = c; 6460fda9279dSmrg if (c == '\\') 6461fda9279dSmrg backslashes++; 6462fda9279dSmrg else 6463fda9279dSmrg backslashes = 0; 6464fda9279dSmrg } 6465fda9279dSmrg if (quote_around) 6466fda9279dSmrg { 6467fda9279dSmrg unsigned int j; 6468fda9279dSmrg for (j = backslashes; j > 0; j--) 6469fda9279dSmrg *p++ = '\\'; 6470fda9279dSmrg *p++ = '"'; 6471fda9279dSmrg } 6472fda9279dSmrg *p = '\0'; 6473fda9279dSmrg 6474fda9279dSmrg new_argv[i] = quoted_string; 6475fda9279dSmrg } 6476fda9279dSmrg else 6477fda9279dSmrg new_argv[i] = (char *) string; 6478fda9279dSmrg } 6479fda9279dSmrg new_argv[argc] = NULL; 6480fda9279dSmrg 6481fda9279dSmrg return new_argv; 6482fda9279dSmrg} 6483fda9279dSmrgEOF 6484fda9279dSmrg ;; 6485fda9279dSmrg esac 6486fda9279dSmrg 6487fda9279dSmrg cat <<"EOF" 6488fda9279dSmrgvoid lt_dump_script (FILE* f) 6489fda9279dSmrg{ 6490fda9279dSmrgEOF 6491fda9279dSmrg func_emit_wrapper yes | 6492fda9279dSmrg $SED -n -e ' 6493fda9279dSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6494fda9279dSmrg\2/ 6495fda9279dSmrgh 6496fda9279dSmrgs/\([\\"]\)/\\\1/g 6497fda9279dSmrgs/$/\\n/ 6498fda9279dSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6499fda9279dSmrgg 6500fda9279dSmrgD' 6501fda9279dSmrg cat <<"EOF" 6502fda9279dSmrg} 6503fda9279dSmrgEOF 6504fda9279dSmrg} 6505fda9279dSmrg# end: func_emit_cwrapperexe_src 6506fda9279dSmrg 6507fda9279dSmrg# func_win32_import_lib_p ARG 6508fda9279dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6509fda9279dSmrgfunc_win32_import_lib_p () 6510fda9279dSmrg{ 651116ee1e9aSmrg $debug_cmd 651216ee1e9aSmrg 6513fda9279dSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6514fda9279dSmrg *import*) : ;; 6515fda9279dSmrg *) false ;; 6516fda9279dSmrg esac 6517fda9279dSmrg} 6518fda9279dSmrg 651916ee1e9aSmrg# func_suncc_cstd_abi 652016ee1e9aSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 652116ee1e9aSmrg# Several compiler flags select an ABI that is incompatible with the 652216ee1e9aSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 652316ee1e9aSmrgfunc_suncc_cstd_abi () 652416ee1e9aSmrg{ 652516ee1e9aSmrg $debug_cmd 652616ee1e9aSmrg 652716ee1e9aSmrg case " $compile_command " in 652816ee1e9aSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 652916ee1e9aSmrg suncc_use_cstd_abi=no 653016ee1e9aSmrg ;; 653116ee1e9aSmrg *) 653216ee1e9aSmrg suncc_use_cstd_abi=yes 653316ee1e9aSmrg ;; 653416ee1e9aSmrg esac 653516ee1e9aSmrg} 653616ee1e9aSmrg 6537fda9279dSmrg# func_mode_link arg... 6538fda9279dSmrgfunc_mode_link () 6539fda9279dSmrg{ 654016ee1e9aSmrg $debug_cmd 654116ee1e9aSmrg 6542fda9279dSmrg case $host in 6543fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6544fda9279dSmrg # It is impossible to link a dll without this setting, and 6545fda9279dSmrg # we shouldn't force the makefile maintainer to figure out 654616ee1e9aSmrg # what system we are compiling for in order to pass an extra 6547fda9279dSmrg # flag for every libtool invocation. 6548fda9279dSmrg # allow_undefined=no 6549fda9279dSmrg 6550fda9279dSmrg # FIXME: Unfortunately, there are problems with the above when trying 655116ee1e9aSmrg # to make a dll that has undefined symbols, in which case not 6552fda9279dSmrg # even a static library is built. For now, we need to specify 6553fda9279dSmrg # -no-undefined on the libtool link line when we can be certain 6554fda9279dSmrg # that all symbols are satisfied, otherwise we get a static library. 6555fda9279dSmrg allow_undefined=yes 6556fda9279dSmrg ;; 6557fda9279dSmrg *) 6558fda9279dSmrg allow_undefined=yes 6559fda9279dSmrg ;; 6560fda9279dSmrg esac 6561fda9279dSmrg libtool_args=$nonopt 6562fda9279dSmrg base_compile="$nonopt $@" 6563fda9279dSmrg compile_command=$nonopt 6564fda9279dSmrg finalize_command=$nonopt 6565fda9279dSmrg 6566fda9279dSmrg compile_rpath= 6567fda9279dSmrg finalize_rpath= 6568fda9279dSmrg compile_shlibpath= 6569fda9279dSmrg finalize_shlibpath= 6570fda9279dSmrg convenience= 6571fda9279dSmrg old_convenience= 6572fda9279dSmrg deplibs= 6573fda9279dSmrg old_deplibs= 6574fda9279dSmrg compiler_flags= 6575fda9279dSmrg linker_flags= 6576fda9279dSmrg dllsearchpath= 6577fda9279dSmrg lib_search_path=`pwd` 6578fda9279dSmrg inst_prefix_dir= 6579fda9279dSmrg new_inherited_linker_flags= 6580fda9279dSmrg 6581fda9279dSmrg avoid_version=no 6582fda9279dSmrg bindir= 6583fda9279dSmrg dlfiles= 6584fda9279dSmrg dlprefiles= 6585fda9279dSmrg dlself=no 6586fda9279dSmrg export_dynamic=no 6587fda9279dSmrg export_symbols= 6588fda9279dSmrg export_symbols_regex= 6589fda9279dSmrg generated= 6590fda9279dSmrg libobjs= 6591fda9279dSmrg ltlibs= 6592fda9279dSmrg module=no 6593fda9279dSmrg no_install=no 6594fda9279dSmrg objs= 659516ee1e9aSmrg os2dllname= 6596fda9279dSmrg non_pic_objects= 6597fda9279dSmrg precious_files_regex= 6598fda9279dSmrg prefer_static_libs=no 659916ee1e9aSmrg preload=false 6600fda9279dSmrg prev= 6601fda9279dSmrg prevarg= 6602fda9279dSmrg release= 6603fda9279dSmrg rpath= 6604fda9279dSmrg xrpath= 6605fda9279dSmrg perm_rpath= 6606fda9279dSmrg temp_rpath= 6607fda9279dSmrg thread_safe=no 6608fda9279dSmrg vinfo= 6609fda9279dSmrg vinfo_number=no 6610fda9279dSmrg weak_libs= 661116ee1e9aSmrg single_module=$wl-single_module 6612fda9279dSmrg func_infer_tag $base_compile 6613fda9279dSmrg 6614fda9279dSmrg # We need to know -static, to get the right output filenames. 6615fda9279dSmrg for arg 6616fda9279dSmrg do 6617fda9279dSmrg case $arg in 6618fda9279dSmrg -shared) 661916ee1e9aSmrg test yes != "$build_libtool_libs" \ 662016ee1e9aSmrg && func_fatal_configuration "cannot build a shared library" 6621fda9279dSmrg build_old_libs=no 6622fda9279dSmrg break 6623fda9279dSmrg ;; 6624fda9279dSmrg -all-static | -static | -static-libtool-libs) 6625fda9279dSmrg case $arg in 6626fda9279dSmrg -all-static) 662716ee1e9aSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6628fda9279dSmrg func_warning "complete static linking is impossible in this configuration" 6629fda9279dSmrg fi 6630fda9279dSmrg if test -n "$link_static_flag"; then 6631fda9279dSmrg dlopen_self=$dlopen_self_static 6632fda9279dSmrg fi 6633fda9279dSmrg prefer_static_libs=yes 6634fda9279dSmrg ;; 6635fda9279dSmrg -static) 6636fda9279dSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6637fda9279dSmrg dlopen_self=$dlopen_self_static 6638fda9279dSmrg fi 6639fda9279dSmrg prefer_static_libs=built 6640fda9279dSmrg ;; 6641fda9279dSmrg -static-libtool-libs) 6642fda9279dSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6643fda9279dSmrg dlopen_self=$dlopen_self_static 6644fda9279dSmrg fi 6645fda9279dSmrg prefer_static_libs=yes 6646fda9279dSmrg ;; 6647fda9279dSmrg esac 6648fda9279dSmrg build_libtool_libs=no 6649fda9279dSmrg build_old_libs=yes 6650fda9279dSmrg break 6651fda9279dSmrg ;; 6652fda9279dSmrg esac 6653fda9279dSmrg done 6654fda9279dSmrg 6655fda9279dSmrg # See if our shared archives depend on static archives. 6656fda9279dSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6657fda9279dSmrg 6658fda9279dSmrg # Go through the arguments, transforming them on the way. 6659fda9279dSmrg while test "$#" -gt 0; do 666016ee1e9aSmrg arg=$1 6661fda9279dSmrg shift 6662fda9279dSmrg func_quote_for_eval "$arg" 6663fda9279dSmrg qarg=$func_quote_for_eval_unquoted_result 6664fda9279dSmrg func_append libtool_args " $func_quote_for_eval_result" 6665fda9279dSmrg 6666fda9279dSmrg # If the previous option needs an argument, assign it. 6667fda9279dSmrg if test -n "$prev"; then 6668fda9279dSmrg case $prev in 6669fda9279dSmrg output) 6670fda9279dSmrg func_append compile_command " @OUTPUT@" 6671fda9279dSmrg func_append finalize_command " @OUTPUT@" 6672fda9279dSmrg ;; 6673fda9279dSmrg esac 6674fda9279dSmrg 6675fda9279dSmrg case $prev in 6676fda9279dSmrg bindir) 667716ee1e9aSmrg bindir=$arg 6678fda9279dSmrg prev= 6679fda9279dSmrg continue 6680fda9279dSmrg ;; 6681fda9279dSmrg dlfiles|dlprefiles) 668216ee1e9aSmrg $preload || { 6683fda9279dSmrg # Add the symbol object into the linking commands. 6684fda9279dSmrg func_append compile_command " @SYMFILE@" 6685fda9279dSmrg func_append finalize_command " @SYMFILE@" 668616ee1e9aSmrg preload=: 668716ee1e9aSmrg } 6688fda9279dSmrg case $arg in 6689fda9279dSmrg *.la | *.lo) ;; # We handle these cases below. 6690fda9279dSmrg force) 669116ee1e9aSmrg if test no = "$dlself"; then 6692fda9279dSmrg dlself=needless 6693fda9279dSmrg export_dynamic=yes 6694fda9279dSmrg fi 6695fda9279dSmrg prev= 6696fda9279dSmrg continue 6697fda9279dSmrg ;; 6698fda9279dSmrg self) 669916ee1e9aSmrg if test dlprefiles = "$prev"; then 6700fda9279dSmrg dlself=yes 670116ee1e9aSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6702fda9279dSmrg dlself=yes 6703fda9279dSmrg else 6704fda9279dSmrg dlself=needless 6705fda9279dSmrg export_dynamic=yes 6706fda9279dSmrg fi 6707fda9279dSmrg prev= 6708fda9279dSmrg continue 6709fda9279dSmrg ;; 6710fda9279dSmrg *) 671116ee1e9aSmrg if test dlfiles = "$prev"; then 6712fda9279dSmrg func_append dlfiles " $arg" 6713fda9279dSmrg else 6714fda9279dSmrg func_append dlprefiles " $arg" 6715fda9279dSmrg fi 6716fda9279dSmrg prev= 6717fda9279dSmrg continue 6718fda9279dSmrg ;; 6719fda9279dSmrg esac 6720fda9279dSmrg ;; 6721fda9279dSmrg expsyms) 672216ee1e9aSmrg export_symbols=$arg 6723fda9279dSmrg test -f "$arg" \ 672416ee1e9aSmrg || func_fatal_error "symbol file '$arg' does not exist" 6725fda9279dSmrg prev= 6726fda9279dSmrg continue 6727fda9279dSmrg ;; 6728fda9279dSmrg expsyms_regex) 672916ee1e9aSmrg export_symbols_regex=$arg 6730fda9279dSmrg prev= 6731fda9279dSmrg continue 6732fda9279dSmrg ;; 6733fda9279dSmrg framework) 6734fda9279dSmrg case $host in 6735fda9279dSmrg *-*-darwin*) 6736fda9279dSmrg case "$deplibs " in 6737fda9279dSmrg *" $qarg.ltframework "*) ;; 6738fda9279dSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6739fda9279dSmrg ;; 6740fda9279dSmrg esac 6741fda9279dSmrg ;; 6742fda9279dSmrg esac 6743fda9279dSmrg prev= 6744fda9279dSmrg continue 6745fda9279dSmrg ;; 6746fda9279dSmrg inst_prefix) 674716ee1e9aSmrg inst_prefix_dir=$arg 674816ee1e9aSmrg prev= 674916ee1e9aSmrg continue 675016ee1e9aSmrg ;; 675116ee1e9aSmrg mllvm) 675216ee1e9aSmrg # Clang does not use LLVM to link, so we can simply discard any 675316ee1e9aSmrg # '-mllvm $arg' options when doing the link step. 6754fda9279dSmrg prev= 6755fda9279dSmrg continue 6756fda9279dSmrg ;; 6757fda9279dSmrg objectlist) 6758fda9279dSmrg if test -f "$arg"; then 6759fda9279dSmrg save_arg=$arg 6760fda9279dSmrg moreargs= 6761fda9279dSmrg for fil in `cat "$save_arg"` 6762fda9279dSmrg do 6763fda9279dSmrg# func_append moreargs " $fil" 6764fda9279dSmrg arg=$fil 6765fda9279dSmrg # A libtool-controlled object. 6766fda9279dSmrg 6767fda9279dSmrg # Check to see that this really is a libtool object. 6768fda9279dSmrg if func_lalib_unsafe_p "$arg"; then 6769fda9279dSmrg pic_object= 6770fda9279dSmrg non_pic_object= 6771fda9279dSmrg 6772fda9279dSmrg # Read the .lo file 6773fda9279dSmrg func_source "$arg" 6774fda9279dSmrg 6775fda9279dSmrg if test -z "$pic_object" || 6776fda9279dSmrg test -z "$non_pic_object" || 677716ee1e9aSmrg test none = "$pic_object" && 677816ee1e9aSmrg test none = "$non_pic_object"; then 677916ee1e9aSmrg func_fatal_error "cannot find name of object for '$arg'" 6780fda9279dSmrg fi 6781fda9279dSmrg 6782fda9279dSmrg # Extract subdirectory from the argument. 6783fda9279dSmrg func_dirname "$arg" "/" "" 678416ee1e9aSmrg xdir=$func_dirname_result 6785fda9279dSmrg 678616ee1e9aSmrg if test none != "$pic_object"; then 6787fda9279dSmrg # Prepend the subdirectory the object is found in. 678816ee1e9aSmrg pic_object=$xdir$pic_object 6789fda9279dSmrg 679016ee1e9aSmrg if test dlfiles = "$prev"; then 679116ee1e9aSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6792fda9279dSmrg func_append dlfiles " $pic_object" 6793fda9279dSmrg prev= 6794fda9279dSmrg continue 6795fda9279dSmrg else 6796fda9279dSmrg # If libtool objects are unsupported, then we need to preload. 6797fda9279dSmrg prev=dlprefiles 6798fda9279dSmrg fi 6799fda9279dSmrg fi 6800fda9279dSmrg 6801fda9279dSmrg # CHECK ME: I think I busted this. -Ossama 680216ee1e9aSmrg if test dlprefiles = "$prev"; then 6803fda9279dSmrg # Preload the old-style object. 6804fda9279dSmrg func_append dlprefiles " $pic_object" 6805fda9279dSmrg prev= 6806fda9279dSmrg fi 6807fda9279dSmrg 6808fda9279dSmrg # A PIC object. 6809fda9279dSmrg func_append libobjs " $pic_object" 681016ee1e9aSmrg arg=$pic_object 6811fda9279dSmrg fi 6812fda9279dSmrg 6813fda9279dSmrg # Non-PIC object. 681416ee1e9aSmrg if test none != "$non_pic_object"; then 6815fda9279dSmrg # Prepend the subdirectory the object is found in. 681616ee1e9aSmrg non_pic_object=$xdir$non_pic_object 6817fda9279dSmrg 6818fda9279dSmrg # A standard non-PIC object 6819fda9279dSmrg func_append non_pic_objects " $non_pic_object" 682016ee1e9aSmrg if test -z "$pic_object" || test none = "$pic_object"; then 682116ee1e9aSmrg arg=$non_pic_object 6822fda9279dSmrg fi 6823fda9279dSmrg else 6824fda9279dSmrg # If the PIC object exists, use it instead. 6825fda9279dSmrg # $xdir was prepended to $pic_object above. 682616ee1e9aSmrg non_pic_object=$pic_object 6827fda9279dSmrg func_append non_pic_objects " $non_pic_object" 6828fda9279dSmrg fi 6829fda9279dSmrg else 6830fda9279dSmrg # Only an error if not doing a dry-run. 6831fda9279dSmrg if $opt_dry_run; then 6832fda9279dSmrg # Extract subdirectory from the argument. 6833fda9279dSmrg func_dirname "$arg" "/" "" 683416ee1e9aSmrg xdir=$func_dirname_result 6835fda9279dSmrg 6836fda9279dSmrg func_lo2o "$arg" 6837fda9279dSmrg pic_object=$xdir$objdir/$func_lo2o_result 6838fda9279dSmrg non_pic_object=$xdir$func_lo2o_result 6839fda9279dSmrg func_append libobjs " $pic_object" 6840fda9279dSmrg func_append non_pic_objects " $non_pic_object" 6841fda9279dSmrg else 684216ee1e9aSmrg func_fatal_error "'$arg' is not a valid libtool object" 6843fda9279dSmrg fi 6844fda9279dSmrg fi 6845fda9279dSmrg done 6846fda9279dSmrg else 684716ee1e9aSmrg func_fatal_error "link input file '$arg' does not exist" 6848fda9279dSmrg fi 6849fda9279dSmrg arg=$save_arg 6850fda9279dSmrg prev= 6851fda9279dSmrg continue 6852fda9279dSmrg ;; 685316ee1e9aSmrg os2dllname) 685416ee1e9aSmrg os2dllname=$arg 685516ee1e9aSmrg prev= 685616ee1e9aSmrg continue 685716ee1e9aSmrg ;; 6858fda9279dSmrg precious_regex) 685916ee1e9aSmrg precious_files_regex=$arg 6860fda9279dSmrg prev= 6861fda9279dSmrg continue 6862fda9279dSmrg ;; 6863fda9279dSmrg release) 686416ee1e9aSmrg release=-$arg 6865fda9279dSmrg prev= 6866fda9279dSmrg continue 6867fda9279dSmrg ;; 6868fda9279dSmrg rpath | xrpath) 6869fda9279dSmrg # We need an absolute path. 6870fda9279dSmrg case $arg in 6871fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6872fda9279dSmrg *) 6873fda9279dSmrg func_fatal_error "only absolute run-paths are allowed" 6874fda9279dSmrg ;; 6875fda9279dSmrg esac 687616ee1e9aSmrg if test rpath = "$prev"; then 6877fda9279dSmrg case "$rpath " in 6878fda9279dSmrg *" $arg "*) ;; 6879fda9279dSmrg *) func_append rpath " $arg" ;; 6880fda9279dSmrg esac 6881fda9279dSmrg else 6882fda9279dSmrg case "$xrpath " in 6883fda9279dSmrg *" $arg "*) ;; 6884fda9279dSmrg *) func_append xrpath " $arg" ;; 6885fda9279dSmrg esac 6886fda9279dSmrg fi 6887fda9279dSmrg prev= 6888fda9279dSmrg continue 6889fda9279dSmrg ;; 6890fda9279dSmrg shrext) 689116ee1e9aSmrg shrext_cmds=$arg 6892fda9279dSmrg prev= 6893fda9279dSmrg continue 6894fda9279dSmrg ;; 6895fda9279dSmrg weak) 6896fda9279dSmrg func_append weak_libs " $arg" 6897fda9279dSmrg prev= 6898fda9279dSmrg continue 6899fda9279dSmrg ;; 6900fda9279dSmrg xcclinker) 6901fda9279dSmrg func_append linker_flags " $qarg" 6902fda9279dSmrg func_append compiler_flags " $qarg" 6903fda9279dSmrg prev= 6904fda9279dSmrg func_append compile_command " $qarg" 6905fda9279dSmrg func_append finalize_command " $qarg" 6906fda9279dSmrg continue 6907fda9279dSmrg ;; 6908fda9279dSmrg xcompiler) 6909fda9279dSmrg func_append compiler_flags " $qarg" 6910fda9279dSmrg prev= 6911fda9279dSmrg func_append compile_command " $qarg" 6912fda9279dSmrg func_append finalize_command " $qarg" 6913fda9279dSmrg continue 6914fda9279dSmrg ;; 6915fda9279dSmrg xlinker) 6916fda9279dSmrg func_append linker_flags " $qarg" 6917fda9279dSmrg func_append compiler_flags " $wl$qarg" 6918fda9279dSmrg prev= 6919fda9279dSmrg func_append compile_command " $wl$qarg" 6920fda9279dSmrg func_append finalize_command " $wl$qarg" 6921fda9279dSmrg continue 6922fda9279dSmrg ;; 6923fda9279dSmrg *) 6924fda9279dSmrg eval "$prev=\"\$arg\"" 6925fda9279dSmrg prev= 6926fda9279dSmrg continue 6927fda9279dSmrg ;; 6928fda9279dSmrg esac 6929fda9279dSmrg fi # test -n "$prev" 6930fda9279dSmrg 693116ee1e9aSmrg prevarg=$arg 6932fda9279dSmrg 6933fda9279dSmrg case $arg in 6934fda9279dSmrg -all-static) 6935fda9279dSmrg if test -n "$link_static_flag"; then 6936fda9279dSmrg # See comment for -static flag below, for more details. 6937fda9279dSmrg func_append compile_command " $link_static_flag" 6938fda9279dSmrg func_append finalize_command " $link_static_flag" 6939fda9279dSmrg fi 6940fda9279dSmrg continue 6941fda9279dSmrg ;; 6942fda9279dSmrg 6943fda9279dSmrg -allow-undefined) 6944fda9279dSmrg # FIXME: remove this flag sometime in the future. 694516ee1e9aSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6946fda9279dSmrg ;; 6947fda9279dSmrg 6948fda9279dSmrg -avoid-version) 6949fda9279dSmrg avoid_version=yes 6950fda9279dSmrg continue 6951fda9279dSmrg ;; 6952fda9279dSmrg 6953fda9279dSmrg -bindir) 6954fda9279dSmrg prev=bindir 6955fda9279dSmrg continue 6956fda9279dSmrg ;; 6957fda9279dSmrg 6958fda9279dSmrg -dlopen) 6959fda9279dSmrg prev=dlfiles 6960fda9279dSmrg continue 6961fda9279dSmrg ;; 6962fda9279dSmrg 6963fda9279dSmrg -dlpreopen) 6964fda9279dSmrg prev=dlprefiles 6965fda9279dSmrg continue 6966fda9279dSmrg ;; 6967fda9279dSmrg 6968fda9279dSmrg -export-dynamic) 6969fda9279dSmrg export_dynamic=yes 6970fda9279dSmrg continue 6971fda9279dSmrg ;; 6972fda9279dSmrg 6973fda9279dSmrg -export-symbols | -export-symbols-regex) 6974fda9279dSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6975fda9279dSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6976fda9279dSmrg fi 697716ee1e9aSmrg if test X-export-symbols = "X$arg"; then 6978fda9279dSmrg prev=expsyms 6979fda9279dSmrg else 6980fda9279dSmrg prev=expsyms_regex 6981fda9279dSmrg fi 6982fda9279dSmrg continue 6983fda9279dSmrg ;; 6984fda9279dSmrg 6985fda9279dSmrg -framework) 6986fda9279dSmrg prev=framework 6987fda9279dSmrg continue 6988fda9279dSmrg ;; 6989fda9279dSmrg 6990fda9279dSmrg -inst-prefix-dir) 6991fda9279dSmrg prev=inst_prefix 6992fda9279dSmrg continue 6993fda9279dSmrg ;; 6994fda9279dSmrg 6995fda9279dSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6996fda9279dSmrg # so, if we see these flags be careful not to treat them like -L 6997fda9279dSmrg -L[A-Z][A-Z]*:*) 6998fda9279dSmrg case $with_gcc/$host in 6999fda9279dSmrg no/*-*-irix* | /*-*-irix*) 7000fda9279dSmrg func_append compile_command " $arg" 7001fda9279dSmrg func_append finalize_command " $arg" 7002fda9279dSmrg ;; 7003fda9279dSmrg esac 7004fda9279dSmrg continue 7005fda9279dSmrg ;; 7006fda9279dSmrg 7007fda9279dSmrg -L*) 7008fda9279dSmrg func_stripname "-L" '' "$arg" 7009fda9279dSmrg if test -z "$func_stripname_result"; then 7010fda9279dSmrg if test "$#" -gt 0; then 701116ee1e9aSmrg func_fatal_error "require no space between '-L' and '$1'" 7012fda9279dSmrg else 701316ee1e9aSmrg func_fatal_error "need path for '-L' option" 7014fda9279dSmrg fi 7015fda9279dSmrg fi 7016fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 7017fda9279dSmrg dir=$func_resolve_sysroot_result 7018fda9279dSmrg # We need an absolute path. 7019fda9279dSmrg case $dir in 7020fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7021fda9279dSmrg *) 7022fda9279dSmrg absdir=`cd "$dir" && pwd` 7023fda9279dSmrg test -z "$absdir" && \ 702416ee1e9aSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 702516ee1e9aSmrg dir=$absdir 7026fda9279dSmrg ;; 7027fda9279dSmrg esac 7028fda9279dSmrg case "$deplibs " in 7029fda9279dSmrg *" -L$dir "* | *" $arg "*) 7030fda9279dSmrg # Will only happen for absolute or sysroot arguments 7031fda9279dSmrg ;; 7032fda9279dSmrg *) 7033fda9279dSmrg # Preserve sysroot, but never include relative directories 7034fda9279dSmrg case $dir in 7035fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7036fda9279dSmrg *) func_append deplibs " -L$dir" ;; 7037fda9279dSmrg esac 7038fda9279dSmrg func_append lib_search_path " $dir" 7039fda9279dSmrg ;; 7040fda9279dSmrg esac 7041fda9279dSmrg case $host in 7042fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7043fda9279dSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7044fda9279dSmrg case :$dllsearchpath: in 7045fda9279dSmrg *":$dir:"*) ;; 7046fda9279dSmrg ::) dllsearchpath=$dir;; 7047fda9279dSmrg *) func_append dllsearchpath ":$dir";; 7048fda9279dSmrg esac 7049fda9279dSmrg case :$dllsearchpath: in 7050fda9279dSmrg *":$testbindir:"*) ;; 7051fda9279dSmrg ::) dllsearchpath=$testbindir;; 7052fda9279dSmrg *) func_append dllsearchpath ":$testbindir";; 7053fda9279dSmrg esac 7054fda9279dSmrg ;; 7055fda9279dSmrg esac 7056fda9279dSmrg continue 7057fda9279dSmrg ;; 7058fda9279dSmrg 7059fda9279dSmrg -l*) 706016ee1e9aSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7061fda9279dSmrg case $host in 7062fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7063fda9279dSmrg # These systems don't actually have a C or math library (as such) 7064fda9279dSmrg continue 7065fda9279dSmrg ;; 7066fda9279dSmrg *-*-os2*) 7067fda9279dSmrg # These systems don't actually have a C library (as such) 706816ee1e9aSmrg test X-lc = "X$arg" && continue 7069fda9279dSmrg ;; 707016ee1e9aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7071fda9279dSmrg # Do not include libc due to us having libc/libc_r. 707216ee1e9aSmrg test X-lc = "X$arg" && continue 7073fda9279dSmrg ;; 7074fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7075fda9279dSmrg # Rhapsody C and math libraries are in the System framework 7076fda9279dSmrg func_append deplibs " System.ltframework" 7077fda9279dSmrg continue 7078fda9279dSmrg ;; 7079fda9279dSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7080fda9279dSmrg # Causes problems with __ctype 708116ee1e9aSmrg test X-lc = "X$arg" && continue 7082fda9279dSmrg ;; 7083fda9279dSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7084fda9279dSmrg # Compiler inserts libc in the correct place for threads to work 708516ee1e9aSmrg test X-lc = "X$arg" && continue 7086fda9279dSmrg ;; 7087fda9279dSmrg esac 708816ee1e9aSmrg elif test X-lc_r = "X$arg"; then 7089fda9279dSmrg case $host in 709016ee1e9aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7091fda9279dSmrg # Do not include libc_r directly, use -pthread flag. 7092fda9279dSmrg continue 7093fda9279dSmrg ;; 7094fda9279dSmrg esac 7095fda9279dSmrg fi 7096fda9279dSmrg func_append deplibs " $arg" 7097fda9279dSmrg continue 7098fda9279dSmrg ;; 7099fda9279dSmrg 710016ee1e9aSmrg -mllvm) 710116ee1e9aSmrg prev=mllvm 710216ee1e9aSmrg continue 710316ee1e9aSmrg ;; 710416ee1e9aSmrg 7105fda9279dSmrg -module) 7106fda9279dSmrg module=yes 7107fda9279dSmrg continue 7108fda9279dSmrg ;; 7109fda9279dSmrg 7110fda9279dSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7111fda9279dSmrg # classes, name mangling, and exception handling. 7112fda9279dSmrg # Darwin uses the -arch flag to determine output architecture. 7113fda9279dSmrg -model|-arch|-isysroot|--sysroot) 7114fda9279dSmrg func_append compiler_flags " $arg" 7115fda9279dSmrg func_append compile_command " $arg" 7116fda9279dSmrg func_append finalize_command " $arg" 7117fda9279dSmrg prev=xcompiler 7118fda9279dSmrg continue 7119fda9279dSmrg ;; 7120fda9279dSmrg 7121fda9279dSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7122fda9279dSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7123fda9279dSmrg func_append compiler_flags " $arg" 7124fda9279dSmrg func_append compile_command " $arg" 7125fda9279dSmrg func_append finalize_command " $arg" 7126fda9279dSmrg case "$new_inherited_linker_flags " in 7127fda9279dSmrg *" $arg "*) ;; 7128fda9279dSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7129fda9279dSmrg esac 7130fda9279dSmrg continue 7131fda9279dSmrg ;; 7132fda9279dSmrg 7133fda9279dSmrg -multi_module) 713416ee1e9aSmrg single_module=$wl-multi_module 7135fda9279dSmrg continue 7136fda9279dSmrg ;; 7137fda9279dSmrg 7138fda9279dSmrg -no-fast-install) 7139fda9279dSmrg fast_install=no 7140fda9279dSmrg continue 7141fda9279dSmrg ;; 7142fda9279dSmrg 7143fda9279dSmrg -no-install) 7144fda9279dSmrg case $host in 7145fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7146fda9279dSmrg # The PATH hackery in wrapper scripts is required on Windows 7147fda9279dSmrg # and Darwin in order for the loader to find any dlls it needs. 714816ee1e9aSmrg func_warning "'-no-install' is ignored for $host" 714916ee1e9aSmrg func_warning "assuming '-no-fast-install' instead" 7150fda9279dSmrg fast_install=no 7151fda9279dSmrg ;; 7152fda9279dSmrg *) no_install=yes ;; 7153fda9279dSmrg esac 7154fda9279dSmrg continue 7155fda9279dSmrg ;; 7156fda9279dSmrg 7157fda9279dSmrg -no-undefined) 7158fda9279dSmrg allow_undefined=no 7159fda9279dSmrg continue 7160fda9279dSmrg ;; 7161fda9279dSmrg 7162fda9279dSmrg -objectlist) 7163fda9279dSmrg prev=objectlist 7164fda9279dSmrg continue 7165fda9279dSmrg ;; 7166fda9279dSmrg 716716ee1e9aSmrg -os2dllname) 716816ee1e9aSmrg prev=os2dllname 716916ee1e9aSmrg continue 717016ee1e9aSmrg ;; 717116ee1e9aSmrg 7172fda9279dSmrg -o) prev=output ;; 7173fda9279dSmrg 7174fda9279dSmrg -precious-files-regex) 7175fda9279dSmrg prev=precious_regex 7176fda9279dSmrg continue 7177fda9279dSmrg ;; 7178fda9279dSmrg 7179fda9279dSmrg -release) 7180fda9279dSmrg prev=release 7181fda9279dSmrg continue 7182fda9279dSmrg ;; 7183fda9279dSmrg 7184fda9279dSmrg -rpath) 7185fda9279dSmrg prev=rpath 7186fda9279dSmrg continue 7187fda9279dSmrg ;; 7188fda9279dSmrg 7189fda9279dSmrg -R) 7190fda9279dSmrg prev=xrpath 7191fda9279dSmrg continue 7192fda9279dSmrg ;; 7193fda9279dSmrg 7194fda9279dSmrg -R*) 7195fda9279dSmrg func_stripname '-R' '' "$arg" 7196fda9279dSmrg dir=$func_stripname_result 7197fda9279dSmrg # We need an absolute path. 7198fda9279dSmrg case $dir in 7199fda9279dSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7200fda9279dSmrg =*) 7201fda9279dSmrg func_stripname '=' '' "$dir" 7202fda9279dSmrg dir=$lt_sysroot$func_stripname_result 7203fda9279dSmrg ;; 7204fda9279dSmrg *) 7205fda9279dSmrg func_fatal_error "only absolute run-paths are allowed" 7206fda9279dSmrg ;; 7207fda9279dSmrg esac 7208fda9279dSmrg case "$xrpath " in 7209fda9279dSmrg *" $dir "*) ;; 7210fda9279dSmrg *) func_append xrpath " $dir" ;; 7211fda9279dSmrg esac 7212fda9279dSmrg continue 7213fda9279dSmrg ;; 7214fda9279dSmrg 7215fda9279dSmrg -shared) 7216fda9279dSmrg # The effects of -shared are defined in a previous loop. 7217fda9279dSmrg continue 7218fda9279dSmrg ;; 7219fda9279dSmrg 7220fda9279dSmrg -shrext) 7221fda9279dSmrg prev=shrext 7222fda9279dSmrg continue 7223fda9279dSmrg ;; 7224fda9279dSmrg 7225fda9279dSmrg -static | -static-libtool-libs) 7226fda9279dSmrg # The effects of -static are defined in a previous loop. 7227fda9279dSmrg # We used to do the same as -all-static on platforms that 7228fda9279dSmrg # didn't have a PIC flag, but the assumption that the effects 7229fda9279dSmrg # would be equivalent was wrong. It would break on at least 7230fda9279dSmrg # Digital Unix and AIX. 7231fda9279dSmrg continue 7232fda9279dSmrg ;; 7233fda9279dSmrg 7234fda9279dSmrg -thread-safe) 7235fda9279dSmrg thread_safe=yes 7236fda9279dSmrg continue 7237fda9279dSmrg ;; 7238fda9279dSmrg 7239fda9279dSmrg -version-info) 7240fda9279dSmrg prev=vinfo 7241fda9279dSmrg continue 7242fda9279dSmrg ;; 7243fda9279dSmrg 7244fda9279dSmrg -version-number) 7245fda9279dSmrg prev=vinfo 7246fda9279dSmrg vinfo_number=yes 7247fda9279dSmrg continue 7248fda9279dSmrg ;; 7249fda9279dSmrg 7250fda9279dSmrg -weak) 7251fda9279dSmrg prev=weak 7252fda9279dSmrg continue 7253fda9279dSmrg ;; 7254fda9279dSmrg 7255fda9279dSmrg -Wc,*) 7256fda9279dSmrg func_stripname '-Wc,' '' "$arg" 7257fda9279dSmrg args=$func_stripname_result 7258fda9279dSmrg arg= 725916ee1e9aSmrg save_ifs=$IFS; IFS=, 7260fda9279dSmrg for flag in $args; do 726116ee1e9aSmrg IFS=$save_ifs 7262fda9279dSmrg func_quote_for_eval "$flag" 7263fda9279dSmrg func_append arg " $func_quote_for_eval_result" 7264fda9279dSmrg func_append compiler_flags " $func_quote_for_eval_result" 7265fda9279dSmrg done 726616ee1e9aSmrg IFS=$save_ifs 7267fda9279dSmrg func_stripname ' ' '' "$arg" 7268fda9279dSmrg arg=$func_stripname_result 7269fda9279dSmrg ;; 7270fda9279dSmrg 7271fda9279dSmrg -Wl,*) 7272fda9279dSmrg func_stripname '-Wl,' '' "$arg" 7273fda9279dSmrg args=$func_stripname_result 7274fda9279dSmrg arg= 727516ee1e9aSmrg save_ifs=$IFS; IFS=, 7276fda9279dSmrg for flag in $args; do 727716ee1e9aSmrg IFS=$save_ifs 7278fda9279dSmrg func_quote_for_eval "$flag" 7279fda9279dSmrg func_append arg " $wl$func_quote_for_eval_result" 7280fda9279dSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7281fda9279dSmrg func_append linker_flags " $func_quote_for_eval_result" 7282fda9279dSmrg done 728316ee1e9aSmrg IFS=$save_ifs 7284fda9279dSmrg func_stripname ' ' '' "$arg" 7285fda9279dSmrg arg=$func_stripname_result 7286fda9279dSmrg ;; 7287fda9279dSmrg 7288fda9279dSmrg -Xcompiler) 7289fda9279dSmrg prev=xcompiler 7290fda9279dSmrg continue 7291fda9279dSmrg ;; 7292fda9279dSmrg 7293fda9279dSmrg -Xlinker) 7294fda9279dSmrg prev=xlinker 7295fda9279dSmrg continue 7296fda9279dSmrg ;; 7297fda9279dSmrg 7298fda9279dSmrg -XCClinker) 7299fda9279dSmrg prev=xcclinker 7300fda9279dSmrg continue 7301fda9279dSmrg ;; 7302fda9279dSmrg 7303fda9279dSmrg # -msg_* for osf cc 7304fda9279dSmrg -msg_*) 7305fda9279dSmrg func_quote_for_eval "$arg" 730616ee1e9aSmrg arg=$func_quote_for_eval_result 7307fda9279dSmrg ;; 7308fda9279dSmrg 7309fda9279dSmrg # Flags to be passed through unchanged, with rationale: 7310fda9279dSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7311fda9279dSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 7312fda9279dSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7313fda9279dSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7314fda9279dSmrg # -q* compiler args for the IBM compiler 7315fda9279dSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7316fda9279dSmrg # -F/path path to uninstalled frameworks, gcc on darwin 7317fda9279dSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 731816ee1e9aSmrg # -fstack-protector* stack protector flags for GCC 7319fda9279dSmrg # @file GCC response files 7320fda9279dSmrg # -tp=* Portland pgcc target processor selection 7321fda9279dSmrg # --sysroot=* for sysroot support 732216ee1e9aSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7323dd52494dSmrg # -specs=* GCC specs files 732416ee1e9aSmrg # -stdlib=* select c++ std lib with clang 7325dd52494dSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 7326dd52494dSmrg # -fuse-ld=* Linker select flags for GCC 7327fda9279dSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7328fda9279dSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7329dd52494dSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7330dd52494dSmrg -specs=*|-fsanitize=*|-fuse-ld=*) 7331fda9279dSmrg func_quote_for_eval "$arg" 733216ee1e9aSmrg arg=$func_quote_for_eval_result 7333fda9279dSmrg func_append compile_command " $arg" 7334fda9279dSmrg func_append finalize_command " $arg" 7335fda9279dSmrg func_append compiler_flags " $arg" 7336fda9279dSmrg continue 7337fda9279dSmrg ;; 7338fda9279dSmrg 733916ee1e9aSmrg -Z*) 734016ee1e9aSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 734116ee1e9aSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 734216ee1e9aSmrg compiler_flags="$compiler_flags $arg" 734316ee1e9aSmrg func_append compile_command " $arg" 734416ee1e9aSmrg func_append finalize_command " $arg" 734516ee1e9aSmrg case $arg in 734616ee1e9aSmrg -Zlinker | -Zstack) 734716ee1e9aSmrg prev=xcompiler 734816ee1e9aSmrg ;; 734916ee1e9aSmrg esac 735016ee1e9aSmrg continue 735116ee1e9aSmrg else 735216ee1e9aSmrg # Otherwise treat like 'Some other compiler flag' below 735316ee1e9aSmrg func_quote_for_eval "$arg" 735416ee1e9aSmrg arg=$func_quote_for_eval_result 735516ee1e9aSmrg fi 735616ee1e9aSmrg ;; 735716ee1e9aSmrg 7358fda9279dSmrg # Some other compiler flag. 7359fda9279dSmrg -* | +*) 7360fda9279dSmrg func_quote_for_eval "$arg" 736116ee1e9aSmrg arg=$func_quote_for_eval_result 7362fda9279dSmrg ;; 7363fda9279dSmrg 7364fda9279dSmrg *.$objext) 7365fda9279dSmrg # A standard object. 7366fda9279dSmrg func_append objs " $arg" 7367fda9279dSmrg ;; 7368fda9279dSmrg 7369fda9279dSmrg *.lo) 7370fda9279dSmrg # A libtool-controlled object. 7371fda9279dSmrg 7372fda9279dSmrg # Check to see that this really is a libtool object. 7373fda9279dSmrg if func_lalib_unsafe_p "$arg"; then 7374fda9279dSmrg pic_object= 7375fda9279dSmrg non_pic_object= 7376fda9279dSmrg 7377fda9279dSmrg # Read the .lo file 7378fda9279dSmrg func_source "$arg" 7379fda9279dSmrg 7380fda9279dSmrg if test -z "$pic_object" || 7381fda9279dSmrg test -z "$non_pic_object" || 738216ee1e9aSmrg test none = "$pic_object" && 738316ee1e9aSmrg test none = "$non_pic_object"; then 738416ee1e9aSmrg func_fatal_error "cannot find name of object for '$arg'" 7385fda9279dSmrg fi 7386fda9279dSmrg 7387fda9279dSmrg # Extract subdirectory from the argument. 7388fda9279dSmrg func_dirname "$arg" "/" "" 738916ee1e9aSmrg xdir=$func_dirname_result 7390fda9279dSmrg 739116ee1e9aSmrg test none = "$pic_object" || { 7392fda9279dSmrg # Prepend the subdirectory the object is found in. 739316ee1e9aSmrg pic_object=$xdir$pic_object 7394fda9279dSmrg 739516ee1e9aSmrg if test dlfiles = "$prev"; then 739616ee1e9aSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7397fda9279dSmrg func_append dlfiles " $pic_object" 7398fda9279dSmrg prev= 7399fda9279dSmrg continue 7400fda9279dSmrg else 7401fda9279dSmrg # If libtool objects are unsupported, then we need to preload. 7402fda9279dSmrg prev=dlprefiles 7403fda9279dSmrg fi 7404fda9279dSmrg fi 7405fda9279dSmrg 7406fda9279dSmrg # CHECK ME: I think I busted this. -Ossama 740716ee1e9aSmrg if test dlprefiles = "$prev"; then 7408fda9279dSmrg # Preload the old-style object. 7409fda9279dSmrg func_append dlprefiles " $pic_object" 7410fda9279dSmrg prev= 7411fda9279dSmrg fi 7412fda9279dSmrg 7413fda9279dSmrg # A PIC object. 7414fda9279dSmrg func_append libobjs " $pic_object" 741516ee1e9aSmrg arg=$pic_object 741616ee1e9aSmrg } 7417fda9279dSmrg 7418fda9279dSmrg # Non-PIC object. 741916ee1e9aSmrg if test none != "$non_pic_object"; then 7420fda9279dSmrg # Prepend the subdirectory the object is found in. 742116ee1e9aSmrg non_pic_object=$xdir$non_pic_object 7422fda9279dSmrg 7423fda9279dSmrg # A standard non-PIC object 7424fda9279dSmrg func_append non_pic_objects " $non_pic_object" 742516ee1e9aSmrg if test -z "$pic_object" || test none = "$pic_object"; then 742616ee1e9aSmrg arg=$non_pic_object 7427fda9279dSmrg fi 7428fda9279dSmrg else 7429fda9279dSmrg # If the PIC object exists, use it instead. 7430fda9279dSmrg # $xdir was prepended to $pic_object above. 743116ee1e9aSmrg non_pic_object=$pic_object 7432fda9279dSmrg func_append non_pic_objects " $non_pic_object" 7433fda9279dSmrg fi 7434fda9279dSmrg else 7435fda9279dSmrg # Only an error if not doing a dry-run. 7436fda9279dSmrg if $opt_dry_run; then 7437fda9279dSmrg # Extract subdirectory from the argument. 7438fda9279dSmrg func_dirname "$arg" "/" "" 743916ee1e9aSmrg xdir=$func_dirname_result 7440fda9279dSmrg 7441fda9279dSmrg func_lo2o "$arg" 7442fda9279dSmrg pic_object=$xdir$objdir/$func_lo2o_result 7443fda9279dSmrg non_pic_object=$xdir$func_lo2o_result 7444fda9279dSmrg func_append libobjs " $pic_object" 7445fda9279dSmrg func_append non_pic_objects " $non_pic_object" 7446fda9279dSmrg else 744716ee1e9aSmrg func_fatal_error "'$arg' is not a valid libtool object" 7448fda9279dSmrg fi 7449fda9279dSmrg fi 7450fda9279dSmrg ;; 7451fda9279dSmrg 7452fda9279dSmrg *.$libext) 7453fda9279dSmrg # An archive. 7454fda9279dSmrg func_append deplibs " $arg" 7455fda9279dSmrg func_append old_deplibs " $arg" 7456fda9279dSmrg continue 7457fda9279dSmrg ;; 7458fda9279dSmrg 7459fda9279dSmrg *.la) 7460fda9279dSmrg # A libtool-controlled library. 7461fda9279dSmrg 7462fda9279dSmrg func_resolve_sysroot "$arg" 746316ee1e9aSmrg if test dlfiles = "$prev"; then 7464fda9279dSmrg # This library was specified with -dlopen. 7465fda9279dSmrg func_append dlfiles " $func_resolve_sysroot_result" 7466fda9279dSmrg prev= 746716ee1e9aSmrg elif test dlprefiles = "$prev"; then 7468fda9279dSmrg # The library was specified with -dlpreopen. 7469fda9279dSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7470fda9279dSmrg prev= 7471fda9279dSmrg else 7472fda9279dSmrg func_append deplibs " $func_resolve_sysroot_result" 7473fda9279dSmrg fi 7474fda9279dSmrg continue 7475fda9279dSmrg ;; 7476fda9279dSmrg 7477fda9279dSmrg # Some other compiler argument. 7478fda9279dSmrg *) 7479fda9279dSmrg # Unknown arguments in both finalize_command and compile_command need 7480fda9279dSmrg # to be aesthetically quoted because they are evaled later. 7481fda9279dSmrg func_quote_for_eval "$arg" 748216ee1e9aSmrg arg=$func_quote_for_eval_result 7483fda9279dSmrg ;; 7484fda9279dSmrg esac # arg 7485fda9279dSmrg 7486fda9279dSmrg # Now actually substitute the argument into the commands. 7487fda9279dSmrg if test -n "$arg"; then 7488fda9279dSmrg func_append compile_command " $arg" 7489fda9279dSmrg func_append finalize_command " $arg" 7490fda9279dSmrg fi 7491fda9279dSmrg done # argument parsing loop 7492fda9279dSmrg 7493fda9279dSmrg test -n "$prev" && \ 749416ee1e9aSmrg func_fatal_help "the '$prevarg' option requires an argument" 7495fda9279dSmrg 749616ee1e9aSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7497fda9279dSmrg eval arg=\"$export_dynamic_flag_spec\" 7498fda9279dSmrg func_append compile_command " $arg" 7499fda9279dSmrg func_append finalize_command " $arg" 7500fda9279dSmrg fi 7501fda9279dSmrg 7502fda9279dSmrg oldlibs= 7503fda9279dSmrg # calculate the name of the file, without its directory 7504fda9279dSmrg func_basename "$output" 750516ee1e9aSmrg outputname=$func_basename_result 750616ee1e9aSmrg libobjs_save=$libobjs 7507fda9279dSmrg 7508fda9279dSmrg if test -n "$shlibpath_var"; then 7509fda9279dSmrg # get the directories listed in $shlibpath_var 751016ee1e9aSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7511fda9279dSmrg else 7512fda9279dSmrg shlib_search_path= 7513fda9279dSmrg fi 7514fda9279dSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7515fda9279dSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7516fda9279dSmrg 751716ee1e9aSmrg # Definition is injected by LT_CONFIG during libtool generation. 751816ee1e9aSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 751916ee1e9aSmrg 7520fda9279dSmrg func_dirname "$output" "/" "" 752116ee1e9aSmrg output_objdir=$func_dirname_result$objdir 7522fda9279dSmrg func_to_tool_file "$output_objdir/" 7523fda9279dSmrg tool_output_objdir=$func_to_tool_file_result 7524fda9279dSmrg # Create the object directory. 7525fda9279dSmrg func_mkdir_p "$output_objdir" 7526fda9279dSmrg 7527fda9279dSmrg # Determine the type of output 7528fda9279dSmrg case $output in 7529fda9279dSmrg "") 7530fda9279dSmrg func_fatal_help "you must specify an output file" 7531fda9279dSmrg ;; 7532fda9279dSmrg *.$libext) linkmode=oldlib ;; 7533fda9279dSmrg *.lo | *.$objext) linkmode=obj ;; 7534fda9279dSmrg *.la) linkmode=lib ;; 7535fda9279dSmrg *) linkmode=prog ;; # Anything else should be a program. 7536fda9279dSmrg esac 7537fda9279dSmrg 7538fda9279dSmrg specialdeplibs= 7539fda9279dSmrg 7540fda9279dSmrg libs= 7541fda9279dSmrg # Find all interdependent deplibs by searching for libraries 7542fda9279dSmrg # that are linked more than once (e.g. -la -lb -la) 7543fda9279dSmrg for deplib in $deplibs; do 754416ee1e9aSmrg if $opt_preserve_dup_deps; then 7545fda9279dSmrg case "$libs " in 7546fda9279dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7547fda9279dSmrg esac 7548fda9279dSmrg fi 7549fda9279dSmrg func_append libs " $deplib" 7550fda9279dSmrg done 7551fda9279dSmrg 755216ee1e9aSmrg if test lib = "$linkmode"; then 7553fda9279dSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7554fda9279dSmrg 7555fda9279dSmrg # Compute libraries that are listed more than once in $predeps 7556fda9279dSmrg # $postdeps and mark them as special (i.e., whose duplicates are 7557fda9279dSmrg # not to be eliminated). 7558fda9279dSmrg pre_post_deps= 7559fda9279dSmrg if $opt_duplicate_compiler_generated_deps; then 7560fda9279dSmrg for pre_post_dep in $predeps $postdeps; do 7561fda9279dSmrg case "$pre_post_deps " in 7562fda9279dSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7563fda9279dSmrg esac 7564fda9279dSmrg func_append pre_post_deps " $pre_post_dep" 7565fda9279dSmrg done 7566fda9279dSmrg fi 7567fda9279dSmrg pre_post_deps= 7568fda9279dSmrg fi 7569fda9279dSmrg 7570fda9279dSmrg deplibs= 7571fda9279dSmrg newdependency_libs= 7572fda9279dSmrg newlib_search_path= 7573fda9279dSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 7574fda9279dSmrg notinst_deplibs= # not-installed libtool libraries 7575fda9279dSmrg notinst_path= # paths that contain not-installed libtool libraries 7576fda9279dSmrg 7577fda9279dSmrg case $linkmode in 7578fda9279dSmrg lib) 7579fda9279dSmrg passes="conv dlpreopen link" 7580fda9279dSmrg for file in $dlfiles $dlprefiles; do 7581fda9279dSmrg case $file in 7582fda9279dSmrg *.la) ;; 7583fda9279dSmrg *) 758416ee1e9aSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7585fda9279dSmrg ;; 7586fda9279dSmrg esac 7587fda9279dSmrg done 7588fda9279dSmrg ;; 7589fda9279dSmrg prog) 7590fda9279dSmrg compile_deplibs= 7591fda9279dSmrg finalize_deplibs= 759216ee1e9aSmrg alldeplibs=false 7593fda9279dSmrg newdlfiles= 7594fda9279dSmrg newdlprefiles= 7595fda9279dSmrg passes="conv scan dlopen dlpreopen link" 7596fda9279dSmrg ;; 7597fda9279dSmrg *) passes="conv" 7598fda9279dSmrg ;; 7599fda9279dSmrg esac 7600fda9279dSmrg 7601fda9279dSmrg for pass in $passes; do 7602fda9279dSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 7603fda9279dSmrg # so that -L comes before libs that need it for instance... 760416ee1e9aSmrg if test lib,link = "$linkmode,$pass"; then 7605fda9279dSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 7606fda9279dSmrg ## order, and fix it there properly 7607fda9279dSmrg tmp_deplibs= 7608fda9279dSmrg for deplib in $deplibs; do 7609fda9279dSmrg tmp_deplibs="$deplib $tmp_deplibs" 7610fda9279dSmrg done 761116ee1e9aSmrg deplibs=$tmp_deplibs 7612fda9279dSmrg fi 7613fda9279dSmrg 761416ee1e9aSmrg if test lib,link = "$linkmode,$pass" || 761516ee1e9aSmrg test prog,scan = "$linkmode,$pass"; then 761616ee1e9aSmrg libs=$deplibs 7617fda9279dSmrg deplibs= 7618fda9279dSmrg fi 761916ee1e9aSmrg if test prog = "$linkmode"; then 7620fda9279dSmrg case $pass in 762116ee1e9aSmrg dlopen) libs=$dlfiles ;; 762216ee1e9aSmrg dlpreopen) libs=$dlprefiles ;; 7623cd34e0e1Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7624fda9279dSmrg esac 7625fda9279dSmrg fi 762616ee1e9aSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7627fda9279dSmrg # Collect and forward deplibs of preopened libtool libs 7628fda9279dSmrg for lib in $dlprefiles; do 7629fda9279dSmrg # Ignore non-libtool-libs 7630fda9279dSmrg dependency_libs= 7631fda9279dSmrg func_resolve_sysroot "$lib" 7632fda9279dSmrg case $lib in 7633fda9279dSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7634fda9279dSmrg esac 7635fda9279dSmrg 7636fda9279dSmrg # Collect preopened libtool deplibs, except any this library 7637fda9279dSmrg # has declared as weak libs 7638fda9279dSmrg for deplib in $dependency_libs; do 7639fda9279dSmrg func_basename "$deplib" 7640fda9279dSmrg deplib_base=$func_basename_result 7641fda9279dSmrg case " $weak_libs " in 7642fda9279dSmrg *" $deplib_base "*) ;; 7643fda9279dSmrg *) func_append deplibs " $deplib" ;; 7644fda9279dSmrg esac 7645fda9279dSmrg done 7646fda9279dSmrg done 764716ee1e9aSmrg libs=$dlprefiles 7648fda9279dSmrg fi 764916ee1e9aSmrg if test dlopen = "$pass"; then 7650fda9279dSmrg # Collect dlpreopened libraries 765116ee1e9aSmrg save_deplibs=$deplibs 7652fda9279dSmrg deplibs= 7653fda9279dSmrg fi 7654fda9279dSmrg 7655fda9279dSmrg for deplib in $libs; do 7656fda9279dSmrg lib= 765716ee1e9aSmrg found=false 7658fda9279dSmrg case $deplib in 7659fda9279dSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7660fda9279dSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 766116ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 7662fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7663fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7664fda9279dSmrg else 7665fda9279dSmrg func_append compiler_flags " $deplib" 766616ee1e9aSmrg if test lib = "$linkmode"; then 7667fda9279dSmrg case "$new_inherited_linker_flags " in 7668fda9279dSmrg *" $deplib "*) ;; 7669fda9279dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7670fda9279dSmrg esac 7671fda9279dSmrg fi 7672fda9279dSmrg fi 7673fda9279dSmrg continue 7674fda9279dSmrg ;; 7675fda9279dSmrg -l*) 767616ee1e9aSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 767716ee1e9aSmrg func_warning "'-l' is ignored for archives/objects" 7678fda9279dSmrg continue 7679fda9279dSmrg fi 7680fda9279dSmrg func_stripname '-l' '' "$deplib" 7681fda9279dSmrg name=$func_stripname_result 768216ee1e9aSmrg if test lib = "$linkmode"; then 7683fda9279dSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7684fda9279dSmrg else 7685fda9279dSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7686fda9279dSmrg fi 7687fda9279dSmrg for searchdir in $searchdirs; do 7688fda9279dSmrg for search_ext in .la $std_shrext .so .a; do 7689fda9279dSmrg # Search the libtool library 769016ee1e9aSmrg lib=$searchdir/lib$name$search_ext 7691fda9279dSmrg if test -f "$lib"; then 769216ee1e9aSmrg if test .la = "$search_ext"; then 769316ee1e9aSmrg found=: 7694fda9279dSmrg else 769516ee1e9aSmrg found=false 7696fda9279dSmrg fi 7697fda9279dSmrg break 2 7698fda9279dSmrg fi 7699fda9279dSmrg done 7700fda9279dSmrg done 770116ee1e9aSmrg if $found; then 770216ee1e9aSmrg # deplib is a libtool library 7703fda9279dSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7704fda9279dSmrg # We need to do some special things here, and not later. 770516ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7706fda9279dSmrg case " $predeps $postdeps " in 7707fda9279dSmrg *" $deplib "*) 7708fda9279dSmrg if func_lalib_p "$lib"; then 7709fda9279dSmrg library_names= 7710fda9279dSmrg old_library= 7711fda9279dSmrg func_source "$lib" 7712fda9279dSmrg for l in $old_library $library_names; do 771316ee1e9aSmrg ll=$l 7714fda9279dSmrg done 771516ee1e9aSmrg if test "X$ll" = "X$old_library"; then # only static version available 771616ee1e9aSmrg found=false 7717fda9279dSmrg func_dirname "$lib" "" "." 771816ee1e9aSmrg ladir=$func_dirname_result 7719fda9279dSmrg lib=$ladir/$old_library 772016ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 7721fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7722fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7723fda9279dSmrg else 7724fda9279dSmrg deplibs="$deplib $deplibs" 772516ee1e9aSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7726fda9279dSmrg fi 7727fda9279dSmrg continue 7728fda9279dSmrg fi 7729fda9279dSmrg fi 7730fda9279dSmrg ;; 7731fda9279dSmrg *) ;; 7732fda9279dSmrg esac 7733fda9279dSmrg fi 773416ee1e9aSmrg else 773516ee1e9aSmrg # deplib doesn't seem to be a libtool library 773616ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 773716ee1e9aSmrg compile_deplibs="$deplib $compile_deplibs" 773816ee1e9aSmrg finalize_deplibs="$deplib $finalize_deplibs" 773916ee1e9aSmrg else 774016ee1e9aSmrg deplibs="$deplib $deplibs" 774116ee1e9aSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 774216ee1e9aSmrg fi 774316ee1e9aSmrg continue 7744fda9279dSmrg fi 7745fda9279dSmrg ;; # -l 7746fda9279dSmrg *.ltframework) 774716ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 7748fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7749fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7750fda9279dSmrg else 7751fda9279dSmrg deplibs="$deplib $deplibs" 775216ee1e9aSmrg if test lib = "$linkmode"; then 7753fda9279dSmrg case "$new_inherited_linker_flags " in 7754fda9279dSmrg *" $deplib "*) ;; 7755fda9279dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7756fda9279dSmrg esac 7757fda9279dSmrg fi 7758fda9279dSmrg fi 7759fda9279dSmrg continue 7760fda9279dSmrg ;; 7761fda9279dSmrg -L*) 7762fda9279dSmrg case $linkmode in 7763fda9279dSmrg lib) 7764fda9279dSmrg deplibs="$deplib $deplibs" 776516ee1e9aSmrg test conv = "$pass" && continue 7766fda9279dSmrg newdependency_libs="$deplib $newdependency_libs" 7767fda9279dSmrg func_stripname '-L' '' "$deplib" 7768fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 7769fda9279dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7770fda9279dSmrg ;; 7771fda9279dSmrg prog) 777216ee1e9aSmrg if test conv = "$pass"; then 7773fda9279dSmrg deplibs="$deplib $deplibs" 7774fda9279dSmrg continue 7775fda9279dSmrg fi 777616ee1e9aSmrg if test scan = "$pass"; then 7777fda9279dSmrg deplibs="$deplib $deplibs" 7778fda9279dSmrg else 7779fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7780fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7781fda9279dSmrg fi 7782fda9279dSmrg func_stripname '-L' '' "$deplib" 7783fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 7784fda9279dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7785fda9279dSmrg ;; 7786fda9279dSmrg *) 778716ee1e9aSmrg func_warning "'-L' is ignored for archives/objects" 7788fda9279dSmrg ;; 7789fda9279dSmrg esac # linkmode 7790fda9279dSmrg continue 7791fda9279dSmrg ;; # -L 7792fda9279dSmrg -R*) 779316ee1e9aSmrg if test link = "$pass"; then 7794fda9279dSmrg func_stripname '-R' '' "$deplib" 7795fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 7796fda9279dSmrg dir=$func_resolve_sysroot_result 7797fda9279dSmrg # Make sure the xrpath contains only unique directories. 7798fda9279dSmrg case "$xrpath " in 7799fda9279dSmrg *" $dir "*) ;; 7800fda9279dSmrg *) func_append xrpath " $dir" ;; 7801fda9279dSmrg esac 7802fda9279dSmrg fi 7803fda9279dSmrg deplibs="$deplib $deplibs" 7804fda9279dSmrg continue 7805fda9279dSmrg ;; 7806fda9279dSmrg *.la) 7807fda9279dSmrg func_resolve_sysroot "$deplib" 7808fda9279dSmrg lib=$func_resolve_sysroot_result 7809fda9279dSmrg ;; 7810fda9279dSmrg *.$libext) 781116ee1e9aSmrg if test conv = "$pass"; then 7812fda9279dSmrg deplibs="$deplib $deplibs" 7813fda9279dSmrg continue 7814fda9279dSmrg fi 7815fda9279dSmrg case $linkmode in 7816fda9279dSmrg lib) 7817fda9279dSmrg # Linking convenience modules into shared libraries is allowed, 7818fda9279dSmrg # but linking other static libraries is non-portable. 7819fda9279dSmrg case " $dlpreconveniencelibs " in 7820fda9279dSmrg *" $deplib "*) ;; 7821fda9279dSmrg *) 782216ee1e9aSmrg valid_a_lib=false 7823fda9279dSmrg case $deplibs_check_method in 7824fda9279dSmrg match_pattern*) 7825fda9279dSmrg set dummy $deplibs_check_method; shift 7826fda9279dSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7827fda9279dSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7828fda9279dSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 782916ee1e9aSmrg valid_a_lib=: 7830fda9279dSmrg fi 7831fda9279dSmrg ;; 7832fda9279dSmrg pass_all) 783316ee1e9aSmrg valid_a_lib=: 7834fda9279dSmrg ;; 7835fda9279dSmrg esac 783616ee1e9aSmrg if $valid_a_lib; then 783716ee1e9aSmrg echo 783816ee1e9aSmrg $ECHO "*** Warning: Linking the shared library $output against the" 783916ee1e9aSmrg $ECHO "*** static library $deplib is not portable!" 784016ee1e9aSmrg deplibs="$deplib $deplibs" 784116ee1e9aSmrg else 7842fda9279dSmrg echo 7843fda9279dSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7844fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 7845fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 7846fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 7847fda9279dSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 7848fda9279dSmrg echo "*** that it is just a static archive that I should not use here." 7849fda9279dSmrg fi 7850fda9279dSmrg ;; 7851fda9279dSmrg esac 7852fda9279dSmrg continue 7853fda9279dSmrg ;; 7854fda9279dSmrg prog) 785516ee1e9aSmrg if test link != "$pass"; then 7856fda9279dSmrg deplibs="$deplib $deplibs" 7857fda9279dSmrg else 7858fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7859fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7860fda9279dSmrg fi 7861fda9279dSmrg continue 7862fda9279dSmrg ;; 7863fda9279dSmrg esac # linkmode 7864fda9279dSmrg ;; # *.$libext 7865fda9279dSmrg *.lo | *.$objext) 786616ee1e9aSmrg if test conv = "$pass"; then 7867fda9279dSmrg deplibs="$deplib $deplibs" 786816ee1e9aSmrg elif test prog = "$linkmode"; then 786916ee1e9aSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7870fda9279dSmrg # If there is no dlopen support or we're linking statically, 7871fda9279dSmrg # we need to preload. 7872fda9279dSmrg func_append newdlprefiles " $deplib" 7873fda9279dSmrg compile_deplibs="$deplib $compile_deplibs" 7874fda9279dSmrg finalize_deplibs="$deplib $finalize_deplibs" 7875fda9279dSmrg else 7876fda9279dSmrg func_append newdlfiles " $deplib" 7877fda9279dSmrg fi 7878fda9279dSmrg fi 7879fda9279dSmrg continue 7880fda9279dSmrg ;; 7881fda9279dSmrg %DEPLIBS%) 788216ee1e9aSmrg alldeplibs=: 7883fda9279dSmrg continue 7884fda9279dSmrg ;; 7885fda9279dSmrg esac # case $deplib 7886fda9279dSmrg 788716ee1e9aSmrg $found || test -f "$lib" \ 788816ee1e9aSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7889fda9279dSmrg 7890fda9279dSmrg # Check to see that this really is a libtool archive. 7891fda9279dSmrg func_lalib_unsafe_p "$lib" \ 789216ee1e9aSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7893fda9279dSmrg 7894fda9279dSmrg func_dirname "$lib" "" "." 789516ee1e9aSmrg ladir=$func_dirname_result 7896fda9279dSmrg 7897fda9279dSmrg dlname= 7898fda9279dSmrg dlopen= 7899fda9279dSmrg dlpreopen= 7900fda9279dSmrg libdir= 7901fda9279dSmrg library_names= 7902fda9279dSmrg old_library= 7903fda9279dSmrg inherited_linker_flags= 7904fda9279dSmrg # If the library was installed with an old release of libtool, 7905fda9279dSmrg # it will not redefine variables installed, or shouldnotlink 7906fda9279dSmrg installed=yes 7907fda9279dSmrg shouldnotlink=no 7908fda9279dSmrg avoidtemprpath= 7909fda9279dSmrg 7910fda9279dSmrg 7911fda9279dSmrg # Read the .la file 7912fda9279dSmrg func_source "$lib" 7913fda9279dSmrg 7914fda9279dSmrg # Convert "-framework foo" to "foo.ltframework" 7915fda9279dSmrg if test -n "$inherited_linker_flags"; then 7916fda9279dSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7917fda9279dSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7918fda9279dSmrg case " $new_inherited_linker_flags " in 7919fda9279dSmrg *" $tmp_inherited_linker_flag "*) ;; 7920fda9279dSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7921fda9279dSmrg esac 7922fda9279dSmrg done 7923fda9279dSmrg fi 7924fda9279dSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 792516ee1e9aSmrg if test lib,link = "$linkmode,$pass" || 792616ee1e9aSmrg test prog,scan = "$linkmode,$pass" || 792716ee1e9aSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7928fda9279dSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7929fda9279dSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7930fda9279dSmrg fi 7931fda9279dSmrg 793216ee1e9aSmrg if test conv = "$pass"; then 7933fda9279dSmrg # Only check for convenience libraries 7934fda9279dSmrg deplibs="$lib $deplibs" 7935fda9279dSmrg if test -z "$libdir"; then 7936fda9279dSmrg if test -z "$old_library"; then 793716ee1e9aSmrg func_fatal_error "cannot find name of link library for '$lib'" 7938fda9279dSmrg fi 7939fda9279dSmrg # It is a libtool convenience library, so add in its objects. 7940fda9279dSmrg func_append convenience " $ladir/$objdir/$old_library" 7941fda9279dSmrg func_append old_convenience " $ladir/$objdir/$old_library" 794216ee1e9aSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 794316ee1e9aSmrg func_fatal_error "'$lib' is not a convenience library" 7944fda9279dSmrg fi 7945cd34e0e1Smrg tmp_libs= 7946cd34e0e1Smrg for deplib in $dependency_libs; do 7947cd34e0e1Smrg deplibs="$deplib $deplibs" 7948cd34e0e1Smrg if $opt_preserve_dup_deps; then 7949cd34e0e1Smrg case "$tmp_libs " in 7950cd34e0e1Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7951cd34e0e1Smrg esac 7952cd34e0e1Smrg fi 7953cd34e0e1Smrg func_append tmp_libs " $deplib" 7954cd34e0e1Smrg done 7955fda9279dSmrg continue 7956fda9279dSmrg fi # $pass = conv 7957fda9279dSmrg 7958fda9279dSmrg 7959fda9279dSmrg # Get the name of the library we link against. 7960fda9279dSmrg linklib= 7961fda9279dSmrg if test -n "$old_library" && 796216ee1e9aSmrg { test yes = "$prefer_static_libs" || 796316ee1e9aSmrg test built,no = "$prefer_static_libs,$installed"; }; then 7964fda9279dSmrg linklib=$old_library 7965fda9279dSmrg else 7966fda9279dSmrg for l in $old_library $library_names; do 796716ee1e9aSmrg linklib=$l 7968fda9279dSmrg done 7969fda9279dSmrg fi 7970fda9279dSmrg if test -z "$linklib"; then 797116ee1e9aSmrg func_fatal_error "cannot find name of link library for '$lib'" 7972fda9279dSmrg fi 7973fda9279dSmrg 7974fda9279dSmrg # This library was specified with -dlopen. 797516ee1e9aSmrg if test dlopen = "$pass"; then 797616ee1e9aSmrg test -z "$libdir" \ 797716ee1e9aSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7978fda9279dSmrg if test -z "$dlname" || 797916ee1e9aSmrg test yes != "$dlopen_support" || 798016ee1e9aSmrg test no = "$build_libtool_libs" 798116ee1e9aSmrg then 7982fda9279dSmrg # If there is no dlname, no dlopen support or we're linking 7983fda9279dSmrg # statically, we need to preload. We also need to preload any 7984fda9279dSmrg # dependent libraries so libltdl's deplib preloader doesn't 7985fda9279dSmrg # bomb out in the load deplibs phase. 7986fda9279dSmrg func_append dlprefiles " $lib $dependency_libs" 7987fda9279dSmrg else 7988fda9279dSmrg func_append newdlfiles " $lib" 7989fda9279dSmrg fi 7990fda9279dSmrg continue 7991fda9279dSmrg fi # $pass = dlopen 7992fda9279dSmrg 7993fda9279dSmrg # We need an absolute path. 7994fda9279dSmrg case $ladir in 799516ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7996fda9279dSmrg *) 7997fda9279dSmrg abs_ladir=`cd "$ladir" && pwd` 7998fda9279dSmrg if test -z "$abs_ladir"; then 799916ee1e9aSmrg func_warning "cannot determine absolute directory name of '$ladir'" 8000fda9279dSmrg func_warning "passing it literally to the linker, although it might fail" 800116ee1e9aSmrg abs_ladir=$ladir 8002fda9279dSmrg fi 8003fda9279dSmrg ;; 8004fda9279dSmrg esac 8005fda9279dSmrg func_basename "$lib" 800616ee1e9aSmrg laname=$func_basename_result 8007fda9279dSmrg 8008fda9279dSmrg # Find the relevant object directory and library name. 800916ee1e9aSmrg if test yes = "$installed"; then 8010fda9279dSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 801116ee1e9aSmrg func_warning "library '$lib' was moved." 801216ee1e9aSmrg dir=$ladir 801316ee1e9aSmrg absdir=$abs_ladir 801416ee1e9aSmrg libdir=$abs_ladir 8015fda9279dSmrg else 801616ee1e9aSmrg dir=$lt_sysroot$libdir 801716ee1e9aSmrg absdir=$lt_sysroot$libdir 8018fda9279dSmrg fi 801916ee1e9aSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8020fda9279dSmrg else 8021fda9279dSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 802216ee1e9aSmrg dir=$ladir 802316ee1e9aSmrg absdir=$abs_ladir 8024fda9279dSmrg # Remove this search path later 8025fda9279dSmrg func_append notinst_path " $abs_ladir" 8026fda9279dSmrg else 802716ee1e9aSmrg dir=$ladir/$objdir 802816ee1e9aSmrg absdir=$abs_ladir/$objdir 8029fda9279dSmrg # Remove this search path later 8030fda9279dSmrg func_append notinst_path " $abs_ladir" 8031fda9279dSmrg fi 8032fda9279dSmrg fi # $installed = yes 8033fda9279dSmrg func_stripname 'lib' '.la' "$laname" 8034fda9279dSmrg name=$func_stripname_result 8035fda9279dSmrg 8036fda9279dSmrg # This library was specified with -dlpreopen. 803716ee1e9aSmrg if test dlpreopen = "$pass"; then 803816ee1e9aSmrg if test -z "$libdir" && test prog = "$linkmode"; then 803916ee1e9aSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8040fda9279dSmrg fi 804116ee1e9aSmrg case $host in 8042fda9279dSmrg # special handling for platforms with PE-DLLs. 8043fda9279dSmrg *cygwin* | *mingw* | *cegcc* ) 8044fda9279dSmrg # Linker will automatically link against shared library if both 8045fda9279dSmrg # static and shared are present. Therefore, ensure we extract 8046fda9279dSmrg # symbols from the import library if a shared library is present 8047fda9279dSmrg # (otherwise, the dlopen module name will be incorrect). We do 8048fda9279dSmrg # this by putting the import library name into $newdlprefiles. 8049fda9279dSmrg # We recover the dlopen module name by 'saving' the la file 8050fda9279dSmrg # name in a special purpose variable, and (later) extracting the 8051fda9279dSmrg # dlname from the la file. 8052fda9279dSmrg if test -n "$dlname"; then 8053fda9279dSmrg func_tr_sh "$dir/$linklib" 8054fda9279dSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8055fda9279dSmrg func_append newdlprefiles " $dir/$linklib" 8056fda9279dSmrg else 8057fda9279dSmrg func_append newdlprefiles " $dir/$old_library" 8058fda9279dSmrg # Keep a list of preopened convenience libraries to check 8059fda9279dSmrg # that they are being used correctly in the link pass. 8060fda9279dSmrg test -z "$libdir" && \ 8061fda9279dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8062fda9279dSmrg fi 8063fda9279dSmrg ;; 8064fda9279dSmrg * ) 8065fda9279dSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8066fda9279dSmrg # are required to link). 8067fda9279dSmrg if test -n "$old_library"; then 8068fda9279dSmrg func_append newdlprefiles " $dir/$old_library" 8069fda9279dSmrg # Keep a list of preopened convenience libraries to check 8070fda9279dSmrg # that they are being used correctly in the link pass. 8071fda9279dSmrg test -z "$libdir" && \ 8072fda9279dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8073fda9279dSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8074fda9279dSmrg elif test -n "$dlname"; then 8075fda9279dSmrg func_append newdlprefiles " $dir/$dlname" 8076fda9279dSmrg else 8077fda9279dSmrg func_append newdlprefiles " $dir/$linklib" 8078fda9279dSmrg fi 8079fda9279dSmrg ;; 8080fda9279dSmrg esac 8081fda9279dSmrg fi # $pass = dlpreopen 8082fda9279dSmrg 8083fda9279dSmrg if test -z "$libdir"; then 8084fda9279dSmrg # Link the convenience library 808516ee1e9aSmrg if test lib = "$linkmode"; then 8086fda9279dSmrg deplibs="$dir/$old_library $deplibs" 808716ee1e9aSmrg elif test prog,link = "$linkmode,$pass"; then 8088fda9279dSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 8089fda9279dSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8090fda9279dSmrg else 8091fda9279dSmrg deplibs="$lib $deplibs" # used for prog,scan pass 8092fda9279dSmrg fi 8093fda9279dSmrg continue 8094fda9279dSmrg fi 8095fda9279dSmrg 8096fda9279dSmrg 809716ee1e9aSmrg if test prog = "$linkmode" && test link != "$pass"; then 8098fda9279dSmrg func_append newlib_search_path " $ladir" 8099fda9279dSmrg deplibs="$lib $deplibs" 8100fda9279dSmrg 810116ee1e9aSmrg linkalldeplibs=false 810216ee1e9aSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 810316ee1e9aSmrg test no = "$build_libtool_libs"; then 810416ee1e9aSmrg linkalldeplibs=: 8105fda9279dSmrg fi 8106fda9279dSmrg 8107fda9279dSmrg tmp_libs= 8108fda9279dSmrg for deplib in $dependency_libs; do 8109fda9279dSmrg case $deplib in 8110fda9279dSmrg -L*) func_stripname '-L' '' "$deplib" 8111fda9279dSmrg func_resolve_sysroot "$func_stripname_result" 8112fda9279dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8113fda9279dSmrg ;; 8114fda9279dSmrg esac 8115fda9279dSmrg # Need to link against all dependency_libs? 811616ee1e9aSmrg if $linkalldeplibs; then 8117fda9279dSmrg deplibs="$deplib $deplibs" 8118fda9279dSmrg else 8119fda9279dSmrg # Need to hardcode shared library paths 8120fda9279dSmrg # or/and link against static libraries 8121fda9279dSmrg newdependency_libs="$deplib $newdependency_libs" 8122fda9279dSmrg fi 812316ee1e9aSmrg if $opt_preserve_dup_deps; then 8124fda9279dSmrg case "$tmp_libs " in 8125fda9279dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8126fda9279dSmrg esac 8127fda9279dSmrg fi 8128fda9279dSmrg func_append tmp_libs " $deplib" 8129fda9279dSmrg done # for deplib 8130fda9279dSmrg continue 8131fda9279dSmrg fi # $linkmode = prog... 8132fda9279dSmrg 813316ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 8134fda9279dSmrg if test -n "$library_names" && 813516ee1e9aSmrg { { test no = "$prefer_static_libs" || 813616ee1e9aSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8137fda9279dSmrg test -z "$old_library"; }; then 8138fda9279dSmrg # We need to hardcode the library path 813916ee1e9aSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8140fda9279dSmrg # Make sure the rpath contains only unique directories. 814116ee1e9aSmrg case $temp_rpath: in 8142fda9279dSmrg *"$absdir:"*) ;; 8143fda9279dSmrg *) func_append temp_rpath "$absdir:" ;; 8144fda9279dSmrg esac 8145fda9279dSmrg fi 8146fda9279dSmrg 8147fda9279dSmrg # Hardcode the library path. 8148fda9279dSmrg # Skip directories that are in the system default run-time 8149fda9279dSmrg # search path. 8150fda9279dSmrg case " $sys_lib_dlsearch_path " in 8151fda9279dSmrg *" $absdir "*) ;; 8152fda9279dSmrg *) 8153fda9279dSmrg case "$compile_rpath " in 8154fda9279dSmrg *" $absdir "*) ;; 8155fda9279dSmrg *) func_append compile_rpath " $absdir" ;; 8156fda9279dSmrg esac 8157fda9279dSmrg ;; 8158fda9279dSmrg esac 8159fda9279dSmrg case " $sys_lib_dlsearch_path " in 8160fda9279dSmrg *" $libdir "*) ;; 8161fda9279dSmrg *) 8162fda9279dSmrg case "$finalize_rpath " in 8163fda9279dSmrg *" $libdir "*) ;; 8164fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 8165fda9279dSmrg esac 8166fda9279dSmrg ;; 8167fda9279dSmrg esac 8168fda9279dSmrg fi # $linkmode,$pass = prog,link... 8169fda9279dSmrg 817016ee1e9aSmrg if $alldeplibs && 817116ee1e9aSmrg { test pass_all = "$deplibs_check_method" || 817216ee1e9aSmrg { test yes = "$build_libtool_libs" && 8173fda9279dSmrg test -n "$library_names"; }; }; then 8174fda9279dSmrg # We only need to search for static libraries 8175fda9279dSmrg continue 8176fda9279dSmrg fi 8177fda9279dSmrg fi 8178fda9279dSmrg 8179fda9279dSmrg link_static=no # Whether the deplib will be linked statically 8180fda9279dSmrg use_static_libs=$prefer_static_libs 818116ee1e9aSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8182fda9279dSmrg use_static_libs=no 8183fda9279dSmrg fi 8184fda9279dSmrg if test -n "$library_names" && 818516ee1e9aSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8186fda9279dSmrg case $host in 818716ee1e9aSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8188fda9279dSmrg # No point in relinking DLLs because paths are not encoded 8189fda9279dSmrg func_append notinst_deplibs " $lib" 8190fda9279dSmrg need_relink=no 8191fda9279dSmrg ;; 8192fda9279dSmrg *) 819316ee1e9aSmrg if test no = "$installed"; then 8194fda9279dSmrg func_append notinst_deplibs " $lib" 8195fda9279dSmrg need_relink=yes 8196fda9279dSmrg fi 8197fda9279dSmrg ;; 8198fda9279dSmrg esac 8199fda9279dSmrg # This is a shared library 8200fda9279dSmrg 8201fda9279dSmrg # Warn about portability, can't link against -module's on some 8202fda9279dSmrg # systems (darwin). Don't bleat about dlopened modules though! 820316ee1e9aSmrg dlopenmodule= 8204fda9279dSmrg for dlpremoduletest in $dlprefiles; do 8205fda9279dSmrg if test "X$dlpremoduletest" = "X$lib"; then 820616ee1e9aSmrg dlopenmodule=$dlpremoduletest 8207fda9279dSmrg break 8208fda9279dSmrg fi 8209fda9279dSmrg done 821016ee1e9aSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8211fda9279dSmrg echo 821216ee1e9aSmrg if test prog = "$linkmode"; then 8213fda9279dSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8214fda9279dSmrg else 8215fda9279dSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8216fda9279dSmrg fi 8217fda9279dSmrg $ECHO "*** $linklib is not portable!" 8218fda9279dSmrg fi 821916ee1e9aSmrg if test lib = "$linkmode" && 822016ee1e9aSmrg test yes = "$hardcode_into_libs"; then 8221fda9279dSmrg # Hardcode the library path. 8222fda9279dSmrg # Skip directories that are in the system default run-time 8223fda9279dSmrg # search path. 8224fda9279dSmrg case " $sys_lib_dlsearch_path " in 8225fda9279dSmrg *" $absdir "*) ;; 8226fda9279dSmrg *) 8227fda9279dSmrg case "$compile_rpath " in 8228fda9279dSmrg *" $absdir "*) ;; 8229fda9279dSmrg *) func_append compile_rpath " $absdir" ;; 8230fda9279dSmrg esac 8231fda9279dSmrg ;; 8232fda9279dSmrg esac 8233fda9279dSmrg case " $sys_lib_dlsearch_path " in 8234fda9279dSmrg *" $libdir "*) ;; 8235fda9279dSmrg *) 8236fda9279dSmrg case "$finalize_rpath " in 8237fda9279dSmrg *" $libdir "*) ;; 8238fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 8239fda9279dSmrg esac 8240fda9279dSmrg ;; 8241fda9279dSmrg esac 8242fda9279dSmrg fi 8243fda9279dSmrg 8244fda9279dSmrg if test -n "$old_archive_from_expsyms_cmds"; then 8245fda9279dSmrg # figure out the soname 8246fda9279dSmrg set dummy $library_names 8247fda9279dSmrg shift 824816ee1e9aSmrg realname=$1 8249fda9279dSmrg shift 8250fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 8251fda9279dSmrg # use dlname if we got it. it's perfectly good, no? 8252fda9279dSmrg if test -n "$dlname"; then 825316ee1e9aSmrg soname=$dlname 8254fda9279dSmrg elif test -n "$soname_spec"; then 8255fda9279dSmrg # bleh windows 8256fda9279dSmrg case $host in 825716ee1e9aSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8258fda9279dSmrg func_arith $current - $age 8259fda9279dSmrg major=$func_arith_result 826016ee1e9aSmrg versuffix=-$major 8261fda9279dSmrg ;; 8262fda9279dSmrg esac 8263fda9279dSmrg eval soname=\"$soname_spec\" 8264fda9279dSmrg else 826516ee1e9aSmrg soname=$realname 8266fda9279dSmrg fi 8267fda9279dSmrg 8268fda9279dSmrg # Make a new name for the extract_expsyms_cmds to use 826916ee1e9aSmrg soroot=$soname 8270fda9279dSmrg func_basename "$soroot" 827116ee1e9aSmrg soname=$func_basename_result 8272fda9279dSmrg func_stripname 'lib' '.dll' "$soname" 8273fda9279dSmrg newlib=libimp-$func_stripname_result.a 8274fda9279dSmrg 8275fda9279dSmrg # If the library has no export list, then create one now 8276fda9279dSmrg if test -f "$output_objdir/$soname-def"; then : 8277fda9279dSmrg else 827816ee1e9aSmrg func_verbose "extracting exported symbol list from '$soname'" 8279fda9279dSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8280fda9279dSmrg fi 8281fda9279dSmrg 8282fda9279dSmrg # Create $newlib 8283fda9279dSmrg if test -f "$output_objdir/$newlib"; then :; else 828416ee1e9aSmrg func_verbose "generating import library for '$soname'" 8285fda9279dSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8286fda9279dSmrg fi 8287fda9279dSmrg # make sure the library variables are pointing to the new library 8288fda9279dSmrg dir=$output_objdir 8289fda9279dSmrg linklib=$newlib 8290fda9279dSmrg fi # test -n "$old_archive_from_expsyms_cmds" 8291fda9279dSmrg 829216ee1e9aSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8293fda9279dSmrg add_shlibpath= 8294fda9279dSmrg add_dir= 8295fda9279dSmrg add= 8296fda9279dSmrg lib_linked=yes 8297fda9279dSmrg case $hardcode_action in 8298fda9279dSmrg immediate | unsupported) 829916ee1e9aSmrg if test no = "$hardcode_direct"; then 830016ee1e9aSmrg add=$dir/$linklib 8301fda9279dSmrg case $host in 830216ee1e9aSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 830316ee1e9aSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8304fda9279dSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 830516ee1e9aSmrg *-*-unixware7*) add_dir=-L$dir ;; 8306fda9279dSmrg *-*-darwin* ) 830716ee1e9aSmrg # if the lib is a (non-dlopened) module then we cannot 8308fda9279dSmrg # link against it, someone is ignoring the earlier warnings 8309fda9279dSmrg if /usr/bin/file -L $add 2> /dev/null | 831016ee1e9aSmrg $GREP ": [^:]* bundle" >/dev/null; then 8311fda9279dSmrg if test "X$dlopenmodule" != "X$lib"; then 8312fda9279dSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 831316ee1e9aSmrg if test -z "$old_library"; then 8314fda9279dSmrg echo 8315fda9279dSmrg echo "*** And there doesn't seem to be a static archive available" 8316fda9279dSmrg echo "*** The link will probably fail, sorry" 8317fda9279dSmrg else 831816ee1e9aSmrg add=$dir/$old_library 8319fda9279dSmrg fi 8320fda9279dSmrg elif test -n "$old_library"; then 832116ee1e9aSmrg add=$dir/$old_library 8322fda9279dSmrg fi 8323fda9279dSmrg fi 8324fda9279dSmrg esac 832516ee1e9aSmrg elif test no = "$hardcode_minus_L"; then 8326fda9279dSmrg case $host in 832716ee1e9aSmrg *-*-sunos*) add_shlibpath=$dir ;; 8328fda9279dSmrg esac 832916ee1e9aSmrg add_dir=-L$dir 833016ee1e9aSmrg add=-l$name 833116ee1e9aSmrg elif test no = "$hardcode_shlibpath_var"; then 833216ee1e9aSmrg add_shlibpath=$dir 833316ee1e9aSmrg add=-l$name 8334fda9279dSmrg else 8335fda9279dSmrg lib_linked=no 8336fda9279dSmrg fi 8337fda9279dSmrg ;; 8338fda9279dSmrg relink) 833916ee1e9aSmrg if test yes = "$hardcode_direct" && 834016ee1e9aSmrg test no = "$hardcode_direct_absolute"; then 834116ee1e9aSmrg add=$dir/$linklib 834216ee1e9aSmrg elif test yes = "$hardcode_minus_L"; then 834316ee1e9aSmrg add_dir=-L$absdir 8344fda9279dSmrg # Try looking first in the location we're being installed to. 8345fda9279dSmrg if test -n "$inst_prefix_dir"; then 8346fda9279dSmrg case $libdir in 8347fda9279dSmrg [\\/]*) 8348fda9279dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8349fda9279dSmrg ;; 8350fda9279dSmrg esac 8351fda9279dSmrg fi 835216ee1e9aSmrg add=-l$name 835316ee1e9aSmrg elif test yes = "$hardcode_shlibpath_var"; then 835416ee1e9aSmrg add_shlibpath=$dir 835516ee1e9aSmrg add=-l$name 8356fda9279dSmrg else 8357fda9279dSmrg lib_linked=no 8358fda9279dSmrg fi 8359fda9279dSmrg ;; 8360fda9279dSmrg *) lib_linked=no ;; 8361fda9279dSmrg esac 8362fda9279dSmrg 836316ee1e9aSmrg if test yes != "$lib_linked"; then 8364fda9279dSmrg func_fatal_configuration "unsupported hardcode properties" 8365fda9279dSmrg fi 8366fda9279dSmrg 8367fda9279dSmrg if test -n "$add_shlibpath"; then 8368fda9279dSmrg case :$compile_shlibpath: in 8369fda9279dSmrg *":$add_shlibpath:"*) ;; 8370fda9279dSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8371fda9279dSmrg esac 8372fda9279dSmrg fi 837316ee1e9aSmrg if test prog = "$linkmode"; then 8374fda9279dSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8375fda9279dSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8376fda9279dSmrg else 8377fda9279dSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8378fda9279dSmrg test -n "$add" && deplibs="$add $deplibs" 837916ee1e9aSmrg if test yes != "$hardcode_direct" && 838016ee1e9aSmrg test yes != "$hardcode_minus_L" && 838116ee1e9aSmrg test yes = "$hardcode_shlibpath_var"; then 8382fda9279dSmrg case :$finalize_shlibpath: in 8383fda9279dSmrg *":$libdir:"*) ;; 8384fda9279dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8385fda9279dSmrg esac 8386fda9279dSmrg fi 8387fda9279dSmrg fi 8388fda9279dSmrg fi 8389fda9279dSmrg 839016ee1e9aSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8391fda9279dSmrg add_shlibpath= 8392fda9279dSmrg add_dir= 8393fda9279dSmrg add= 8394fda9279dSmrg # Finalize command for both is simple: just hardcode it. 839516ee1e9aSmrg if test yes = "$hardcode_direct" && 839616ee1e9aSmrg test no = "$hardcode_direct_absolute"; then 839716ee1e9aSmrg add=$libdir/$linklib 839816ee1e9aSmrg elif test yes = "$hardcode_minus_L"; then 839916ee1e9aSmrg add_dir=-L$libdir 840016ee1e9aSmrg add=-l$name 840116ee1e9aSmrg elif test yes = "$hardcode_shlibpath_var"; then 8402fda9279dSmrg case :$finalize_shlibpath: in 8403fda9279dSmrg *":$libdir:"*) ;; 8404fda9279dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8405fda9279dSmrg esac 840616ee1e9aSmrg add=-l$name 840716ee1e9aSmrg elif test yes = "$hardcode_automatic"; then 8408fda9279dSmrg if test -n "$inst_prefix_dir" && 840916ee1e9aSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 841016ee1e9aSmrg add=$inst_prefix_dir$libdir/$linklib 8411fda9279dSmrg else 841216ee1e9aSmrg add=$libdir/$linklib 8413fda9279dSmrg fi 8414fda9279dSmrg else 8415fda9279dSmrg # We cannot seem to hardcode it, guess we'll fake it. 841616ee1e9aSmrg add_dir=-L$libdir 8417fda9279dSmrg # Try looking first in the location we're being installed to. 8418fda9279dSmrg if test -n "$inst_prefix_dir"; then 8419fda9279dSmrg case $libdir in 8420fda9279dSmrg [\\/]*) 8421fda9279dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8422fda9279dSmrg ;; 8423fda9279dSmrg esac 8424fda9279dSmrg fi 842516ee1e9aSmrg add=-l$name 8426fda9279dSmrg fi 8427fda9279dSmrg 842816ee1e9aSmrg if test prog = "$linkmode"; then 8429fda9279dSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8430fda9279dSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8431fda9279dSmrg else 8432fda9279dSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8433fda9279dSmrg test -n "$add" && deplibs="$add $deplibs" 8434fda9279dSmrg fi 8435fda9279dSmrg fi 843616ee1e9aSmrg elif test prog = "$linkmode"; then 8437fda9279dSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8438fda9279dSmrg # is not unsupported. This is valid on all known static and 8439fda9279dSmrg # shared platforms. 844016ee1e9aSmrg if test unsupported != "$hardcode_direct"; then 844116ee1e9aSmrg test -n "$old_library" && linklib=$old_library 8442fda9279dSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 8443fda9279dSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8444fda9279dSmrg else 8445fda9279dSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8446fda9279dSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8447fda9279dSmrg fi 844816ee1e9aSmrg elif test yes = "$build_libtool_libs"; then 8449fda9279dSmrg # Not a shared library 845016ee1e9aSmrg if test pass_all != "$deplibs_check_method"; then 8451fda9279dSmrg # We're trying link a shared library against a static one 8452fda9279dSmrg # but the system doesn't support it. 8453fda9279dSmrg 8454fda9279dSmrg # Just print a warning and add the library to dependency_libs so 8455fda9279dSmrg # that the program can be linked against the static library. 8456fda9279dSmrg echo 845716ee1e9aSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8458fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 8459fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 8460fda9279dSmrg echo "*** shared version of the library, which you do not appear to have." 846116ee1e9aSmrg if test yes = "$module"; then 8462fda9279dSmrg echo "*** But as you try to build a module library, libtool will still create " 8463fda9279dSmrg echo "*** a static module, that should work as long as the dlopening application" 8464fda9279dSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8465fda9279dSmrg if test -z "$global_symbol_pipe"; then 8466fda9279dSmrg echo 8467fda9279dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 846816ee1e9aSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8469fda9279dSmrg echo "*** not find such a program. So, this module is probably useless." 847016ee1e9aSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8471fda9279dSmrg fi 847216ee1e9aSmrg if test no = "$build_old_libs"; then 8473fda9279dSmrg build_libtool_libs=module 8474fda9279dSmrg build_old_libs=yes 8475fda9279dSmrg else 8476fda9279dSmrg build_libtool_libs=no 8477fda9279dSmrg fi 8478fda9279dSmrg fi 8479fda9279dSmrg else 8480fda9279dSmrg deplibs="$dir/$old_library $deplibs" 8481fda9279dSmrg link_static=yes 8482fda9279dSmrg fi 8483fda9279dSmrg fi # link shared/static library? 8484fda9279dSmrg 848516ee1e9aSmrg if test lib = "$linkmode"; then 8486fda9279dSmrg if test -n "$dependency_libs" && 848716ee1e9aSmrg { test yes != "$hardcode_into_libs" || 848816ee1e9aSmrg test yes = "$build_old_libs" || 848916ee1e9aSmrg test yes = "$link_static"; }; then 8490fda9279dSmrg # Extract -R from dependency_libs 8491fda9279dSmrg temp_deplibs= 8492fda9279dSmrg for libdir in $dependency_libs; do 8493fda9279dSmrg case $libdir in 8494fda9279dSmrg -R*) func_stripname '-R' '' "$libdir" 8495fda9279dSmrg temp_xrpath=$func_stripname_result 8496fda9279dSmrg case " $xrpath " in 8497fda9279dSmrg *" $temp_xrpath "*) ;; 8498fda9279dSmrg *) func_append xrpath " $temp_xrpath";; 8499fda9279dSmrg esac;; 8500fda9279dSmrg *) func_append temp_deplibs " $libdir";; 8501fda9279dSmrg esac 8502fda9279dSmrg done 850316ee1e9aSmrg dependency_libs=$temp_deplibs 8504fda9279dSmrg fi 8505fda9279dSmrg 8506fda9279dSmrg func_append newlib_search_path " $absdir" 8507fda9279dSmrg # Link against this library 850816ee1e9aSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8509fda9279dSmrg # ... and its dependency_libs 8510fda9279dSmrg tmp_libs= 8511fda9279dSmrg for deplib in $dependency_libs; do 8512fda9279dSmrg newdependency_libs="$deplib $newdependency_libs" 8513fda9279dSmrg case $deplib in 8514fda9279dSmrg -L*) func_stripname '-L' '' "$deplib" 8515fda9279dSmrg func_resolve_sysroot "$func_stripname_result";; 8516fda9279dSmrg *) func_resolve_sysroot "$deplib" ;; 8517fda9279dSmrg esac 851816ee1e9aSmrg if $opt_preserve_dup_deps; then 8519fda9279dSmrg case "$tmp_libs " in 8520fda9279dSmrg *" $func_resolve_sysroot_result "*) 8521fda9279dSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8522fda9279dSmrg esac 8523fda9279dSmrg fi 8524fda9279dSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8525fda9279dSmrg done 8526fda9279dSmrg 852716ee1e9aSmrg if test no != "$link_all_deplibs"; then 8528fda9279dSmrg # Add the search paths of all dependency libraries 8529fda9279dSmrg for deplib in $dependency_libs; do 8530fda9279dSmrg path= 8531fda9279dSmrg case $deplib in 853216ee1e9aSmrg -L*) path=$deplib ;; 8533fda9279dSmrg *.la) 8534fda9279dSmrg func_resolve_sysroot "$deplib" 8535fda9279dSmrg deplib=$func_resolve_sysroot_result 8536fda9279dSmrg func_dirname "$deplib" "" "." 8537fda9279dSmrg dir=$func_dirname_result 8538fda9279dSmrg # We need an absolute path. 8539fda9279dSmrg case $dir in 854016ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8541fda9279dSmrg *) 8542fda9279dSmrg absdir=`cd "$dir" && pwd` 8543fda9279dSmrg if test -z "$absdir"; then 854416ee1e9aSmrg func_warning "cannot determine absolute directory name of '$dir'" 854516ee1e9aSmrg absdir=$dir 8546fda9279dSmrg fi 8547fda9279dSmrg ;; 8548fda9279dSmrg esac 8549fda9279dSmrg if $GREP "^installed=no" $deplib > /dev/null; then 8550fda9279dSmrg case $host in 8551fda9279dSmrg *-*-darwin*) 8552fda9279dSmrg depdepl= 855316ee1e9aSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 855416ee1e9aSmrg if test -n "$deplibrary_names"; then 855516ee1e9aSmrg for tmp in $deplibrary_names; do 8556fda9279dSmrg depdepl=$tmp 8557fda9279dSmrg done 855816ee1e9aSmrg if test -f "$absdir/$objdir/$depdepl"; then 855916ee1e9aSmrg depdepl=$absdir/$objdir/$depdepl 856016ee1e9aSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8561fda9279dSmrg if test -z "$darwin_install_name"; then 856216ee1e9aSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8563fda9279dSmrg fi 856416ee1e9aSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 856516ee1e9aSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8566fda9279dSmrg path= 8567fda9279dSmrg fi 8568fda9279dSmrg fi 8569fda9279dSmrg ;; 8570fda9279dSmrg *) 857116ee1e9aSmrg path=-L$absdir/$objdir 8572fda9279dSmrg ;; 8573fda9279dSmrg esac 8574fda9279dSmrg else 857516ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8576fda9279dSmrg test -z "$libdir" && \ 857716ee1e9aSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8578fda9279dSmrg test "$absdir" != "$libdir" && \ 857916ee1e9aSmrg func_warning "'$deplib' seems to be moved" 8580fda9279dSmrg 858116ee1e9aSmrg path=-L$absdir 8582fda9279dSmrg fi 8583fda9279dSmrg ;; 8584fda9279dSmrg esac 8585fda9279dSmrg case " $deplibs " in 8586fda9279dSmrg *" $path "*) ;; 8587fda9279dSmrg *) deplibs="$path $deplibs" ;; 8588fda9279dSmrg esac 8589fda9279dSmrg done 8590fda9279dSmrg fi # link_all_deplibs != no 8591fda9279dSmrg fi # linkmode = lib 8592fda9279dSmrg done # for deplib in $libs 859316ee1e9aSmrg if test link = "$pass"; then 859416ee1e9aSmrg if test prog = "$linkmode"; then 8595fda9279dSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8596fda9279dSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8597fda9279dSmrg else 8598fda9279dSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8599fda9279dSmrg fi 8600fda9279dSmrg fi 860116ee1e9aSmrg dependency_libs=$newdependency_libs 860216ee1e9aSmrg if test dlpreopen = "$pass"; then 8603fda9279dSmrg # Link the dlpreopened libraries before other libraries 8604fda9279dSmrg for deplib in $save_deplibs; do 8605fda9279dSmrg deplibs="$deplib $deplibs" 8606fda9279dSmrg done 8607fda9279dSmrg fi 860816ee1e9aSmrg if test dlopen != "$pass"; then 860916ee1e9aSmrg test conv = "$pass" || { 8610fda9279dSmrg # Make sure lib_search_path contains only unique directories. 8611fda9279dSmrg lib_search_path= 8612fda9279dSmrg for dir in $newlib_search_path; do 8613fda9279dSmrg case "$lib_search_path " in 8614fda9279dSmrg *" $dir "*) ;; 8615fda9279dSmrg *) func_append lib_search_path " $dir" ;; 8616fda9279dSmrg esac 8617fda9279dSmrg done 8618fda9279dSmrg newlib_search_path= 861916ee1e9aSmrg } 8620fda9279dSmrg 862116ee1e9aSmrg if test prog,link = "$linkmode,$pass"; then 8622fda9279dSmrg vars="compile_deplibs finalize_deplibs" 862316ee1e9aSmrg else 862416ee1e9aSmrg vars=deplibs 8625fda9279dSmrg fi 8626fda9279dSmrg for var in $vars dependency_libs; do 8627fda9279dSmrg # Add libraries to $var in reverse order 8628fda9279dSmrg eval tmp_libs=\"\$$var\" 8629fda9279dSmrg new_libs= 8630fda9279dSmrg for deplib in $tmp_libs; do 8631fda9279dSmrg # FIXME: Pedantically, this is the right thing to do, so 8632fda9279dSmrg # that some nasty dependency loop isn't accidentally 8633fda9279dSmrg # broken: 8634fda9279dSmrg #new_libs="$deplib $new_libs" 8635fda9279dSmrg # Pragmatically, this seems to cause very few problems in 8636fda9279dSmrg # practice: 8637fda9279dSmrg case $deplib in 8638fda9279dSmrg -L*) new_libs="$deplib $new_libs" ;; 8639fda9279dSmrg -R*) ;; 8640fda9279dSmrg *) 8641fda9279dSmrg # And here is the reason: when a library appears more 8642fda9279dSmrg # than once as an explicit dependence of a library, or 8643fda9279dSmrg # is implicitly linked in more than once by the 8644fda9279dSmrg # compiler, it is considered special, and multiple 8645fda9279dSmrg # occurrences thereof are not removed. Compare this 8646fda9279dSmrg # with having the same library being listed as a 8647fda9279dSmrg # dependency of multiple other libraries: in this case, 8648fda9279dSmrg # we know (pedantically, we assume) the library does not 8649fda9279dSmrg # need to be listed more than once, so we keep only the 8650fda9279dSmrg # last copy. This is not always right, but it is rare 8651fda9279dSmrg # enough that we require users that really mean to play 8652fda9279dSmrg # such unportable linking tricks to link the library 8653fda9279dSmrg # using -Wl,-lname, so that libtool does not consider it 8654fda9279dSmrg # for duplicate removal. 8655fda9279dSmrg case " $specialdeplibs " in 8656fda9279dSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8657fda9279dSmrg *) 8658fda9279dSmrg case " $new_libs " in 8659fda9279dSmrg *" $deplib "*) ;; 8660fda9279dSmrg *) new_libs="$deplib $new_libs" ;; 8661fda9279dSmrg esac 8662fda9279dSmrg ;; 8663fda9279dSmrg esac 8664fda9279dSmrg ;; 8665fda9279dSmrg esac 8666fda9279dSmrg done 8667fda9279dSmrg tmp_libs= 8668fda9279dSmrg for deplib in $new_libs; do 8669fda9279dSmrg case $deplib in 8670fda9279dSmrg -L*) 8671fda9279dSmrg case " $tmp_libs " in 8672fda9279dSmrg *" $deplib "*) ;; 8673fda9279dSmrg *) func_append tmp_libs " $deplib" ;; 8674fda9279dSmrg esac 8675fda9279dSmrg ;; 8676fda9279dSmrg *) func_append tmp_libs " $deplib" ;; 8677fda9279dSmrg esac 8678fda9279dSmrg done 8679fda9279dSmrg eval $var=\"$tmp_libs\" 8680fda9279dSmrg done # for var 8681fda9279dSmrg fi 868216ee1e9aSmrg 868316ee1e9aSmrg # Add Sun CC postdeps if required: 868416ee1e9aSmrg test CXX = "$tagname" && { 868516ee1e9aSmrg case $host_os in 868616ee1e9aSmrg linux*) 868716ee1e9aSmrg case `$CC -V 2>&1 | sed 5q` in 868816ee1e9aSmrg *Sun\ C*) # Sun C++ 5.9 868916ee1e9aSmrg func_suncc_cstd_abi 869016ee1e9aSmrg 869116ee1e9aSmrg if test no != "$suncc_use_cstd_abi"; then 869216ee1e9aSmrg func_append postdeps ' -library=Cstd -library=Crun' 869316ee1e9aSmrg fi 869416ee1e9aSmrg ;; 869516ee1e9aSmrg esac 869616ee1e9aSmrg ;; 869716ee1e9aSmrg 869816ee1e9aSmrg solaris*) 869916ee1e9aSmrg func_cc_basename "$CC" 870016ee1e9aSmrg case $func_cc_basename_result in 870116ee1e9aSmrg CC* | sunCC*) 870216ee1e9aSmrg func_suncc_cstd_abi 870316ee1e9aSmrg 870416ee1e9aSmrg if test no != "$suncc_use_cstd_abi"; then 870516ee1e9aSmrg func_append postdeps ' -library=Cstd -library=Crun' 870616ee1e9aSmrg fi 870716ee1e9aSmrg ;; 870816ee1e9aSmrg esac 870916ee1e9aSmrg ;; 871016ee1e9aSmrg esac 871116ee1e9aSmrg } 871216ee1e9aSmrg 8713fda9279dSmrg # Last step: remove runtime libs from dependency_libs 8714fda9279dSmrg # (they stay in deplibs) 8715fda9279dSmrg tmp_libs= 871616ee1e9aSmrg for i in $dependency_libs; do 8717fda9279dSmrg case " $predeps $postdeps $compiler_lib_search_path " in 8718fda9279dSmrg *" $i "*) 871916ee1e9aSmrg i= 8720fda9279dSmrg ;; 8721fda9279dSmrg esac 872216ee1e9aSmrg if test -n "$i"; then 8723fda9279dSmrg func_append tmp_libs " $i" 8724fda9279dSmrg fi 8725fda9279dSmrg done 8726fda9279dSmrg dependency_libs=$tmp_libs 8727fda9279dSmrg done # for pass 872816ee1e9aSmrg if test prog = "$linkmode"; then 872916ee1e9aSmrg dlfiles=$newdlfiles 8730fda9279dSmrg fi 873116ee1e9aSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 873216ee1e9aSmrg dlprefiles=$newdlprefiles 8733fda9279dSmrg fi 8734fda9279dSmrg 8735fda9279dSmrg case $linkmode in 8736fda9279dSmrg oldlib) 873716ee1e9aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 873816ee1e9aSmrg func_warning "'-dlopen' is ignored for archives" 8739fda9279dSmrg fi 8740fda9279dSmrg 8741fda9279dSmrg case " $deplibs" in 8742fda9279dSmrg *\ -l* | *\ -L*) 874316ee1e9aSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8744fda9279dSmrg esac 8745fda9279dSmrg 8746fda9279dSmrg test -n "$rpath" && \ 874716ee1e9aSmrg func_warning "'-rpath' is ignored for archives" 8748fda9279dSmrg 8749fda9279dSmrg test -n "$xrpath" && \ 875016ee1e9aSmrg func_warning "'-R' is ignored for archives" 8751fda9279dSmrg 8752fda9279dSmrg test -n "$vinfo" && \ 875316ee1e9aSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8754fda9279dSmrg 8755fda9279dSmrg test -n "$release" && \ 875616ee1e9aSmrg func_warning "'-release' is ignored for archives" 8757fda9279dSmrg 8758fda9279dSmrg test -n "$export_symbols$export_symbols_regex" && \ 875916ee1e9aSmrg func_warning "'-export-symbols' is ignored for archives" 8760fda9279dSmrg 8761fda9279dSmrg # Now set the variables for building old libraries. 8762fda9279dSmrg build_libtool_libs=no 876316ee1e9aSmrg oldlibs=$output 8764fda9279dSmrg func_append objs "$old_deplibs" 8765fda9279dSmrg ;; 8766fda9279dSmrg 8767fda9279dSmrg lib) 876816ee1e9aSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8769fda9279dSmrg case $outputname in 8770fda9279dSmrg lib*) 8771fda9279dSmrg func_stripname 'lib' '.la' "$outputname" 8772fda9279dSmrg name=$func_stripname_result 8773fda9279dSmrg eval shared_ext=\"$shrext_cmds\" 8774fda9279dSmrg eval libname=\"$libname_spec\" 8775fda9279dSmrg ;; 8776fda9279dSmrg *) 877716ee1e9aSmrg test no = "$module" \ 877816ee1e9aSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8779fda9279dSmrg 878016ee1e9aSmrg if test no != "$need_lib_prefix"; then 8781fda9279dSmrg # Add the "lib" prefix for modules if required 8782fda9279dSmrg func_stripname '' '.la' "$outputname" 8783fda9279dSmrg name=$func_stripname_result 8784fda9279dSmrg eval shared_ext=\"$shrext_cmds\" 8785fda9279dSmrg eval libname=\"$libname_spec\" 8786fda9279dSmrg else 8787fda9279dSmrg func_stripname '' '.la' "$outputname" 8788fda9279dSmrg libname=$func_stripname_result 8789fda9279dSmrg fi 8790fda9279dSmrg ;; 8791fda9279dSmrg esac 8792fda9279dSmrg 8793fda9279dSmrg if test -n "$objs"; then 879416ee1e9aSmrg if test pass_all != "$deplibs_check_method"; then 879516ee1e9aSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8796fda9279dSmrg else 8797fda9279dSmrg echo 8798fda9279dSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8799fda9279dSmrg $ECHO "*** objects $objs is not portable!" 8800fda9279dSmrg func_append libobjs " $objs" 8801fda9279dSmrg fi 8802fda9279dSmrg fi 8803fda9279dSmrg 880416ee1e9aSmrg test no = "$dlself" \ 880516ee1e9aSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8806fda9279dSmrg 8807fda9279dSmrg set dummy $rpath 8808fda9279dSmrg shift 880916ee1e9aSmrg test 1 -lt "$#" \ 881016ee1e9aSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8811fda9279dSmrg 881216ee1e9aSmrg install_libdir=$1 8813fda9279dSmrg 8814fda9279dSmrg oldlibs= 8815fda9279dSmrg if test -z "$rpath"; then 881616ee1e9aSmrg if test yes = "$build_libtool_libs"; then 8817fda9279dSmrg # Building a libtool convenience library. 881816ee1e9aSmrg # Some compilers have problems with a '.al' extension so 8819fda9279dSmrg # convenience libraries should have the same extension an 8820fda9279dSmrg # archive normally would. 8821fda9279dSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8822fda9279dSmrg build_libtool_libs=convenience 8823fda9279dSmrg build_old_libs=yes 8824fda9279dSmrg fi 8825fda9279dSmrg 8826fda9279dSmrg test -n "$vinfo" && \ 882716ee1e9aSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8828fda9279dSmrg 8829fda9279dSmrg test -n "$release" && \ 883016ee1e9aSmrg func_warning "'-release' is ignored for convenience libraries" 8831fda9279dSmrg else 8832fda9279dSmrg 8833fda9279dSmrg # Parse the version information argument. 883416ee1e9aSmrg save_ifs=$IFS; IFS=: 8835fda9279dSmrg set dummy $vinfo 0 0 0 8836fda9279dSmrg shift 883716ee1e9aSmrg IFS=$save_ifs 8838fda9279dSmrg 8839fda9279dSmrg test -n "$7" && \ 884016ee1e9aSmrg func_fatal_help "too many parameters to '-version-info'" 8841fda9279dSmrg 8842fda9279dSmrg # convert absolute version numbers to libtool ages 8843fda9279dSmrg # this retains compatibility with .la files and attempts 8844fda9279dSmrg # to make the code below a bit more comprehensible 8845fda9279dSmrg 8846fda9279dSmrg case $vinfo_number in 8847fda9279dSmrg yes) 884816ee1e9aSmrg number_major=$1 884916ee1e9aSmrg number_minor=$2 885016ee1e9aSmrg number_revision=$3 8851fda9279dSmrg # 8852fda9279dSmrg # There are really only two kinds -- those that 8853fda9279dSmrg # use the current revision as the major version 8854fda9279dSmrg # and those that subtract age and use age as 8855fda9279dSmrg # a minor version. But, then there is irix 885616ee1e9aSmrg # that has an extra 1 added just for fun 8857fda9279dSmrg # 8858fda9279dSmrg case $version_type in 8859fda9279dSmrg # correct linux to gnu/linux during the next big refactor 886016ee1e9aSmrg darwin|freebsd-elf|linux|osf|windows|none) 8861fda9279dSmrg func_arith $number_major + $number_minor 8862fda9279dSmrg current=$func_arith_result 886316ee1e9aSmrg age=$number_minor 886416ee1e9aSmrg revision=$number_revision 8865fda9279dSmrg ;; 886616ee1e9aSmrg freebsd-aout|qnx|sunos) 886716ee1e9aSmrg current=$number_major 886816ee1e9aSmrg revision=$number_minor 886916ee1e9aSmrg age=0 8870fda9279dSmrg ;; 8871fda9279dSmrg irix|nonstopux) 8872fda9279dSmrg func_arith $number_major + $number_minor 8873fda9279dSmrg current=$func_arith_result 887416ee1e9aSmrg age=$number_minor 887516ee1e9aSmrg revision=$number_minor 8876fda9279dSmrg lt_irix_increment=no 8877fda9279dSmrg ;; 8878fda9279dSmrg esac 8879fda9279dSmrg ;; 8880fda9279dSmrg no) 888116ee1e9aSmrg current=$1 888216ee1e9aSmrg revision=$2 888316ee1e9aSmrg age=$3 8884fda9279dSmrg ;; 8885fda9279dSmrg esac 8886fda9279dSmrg 8887fda9279dSmrg # Check that each of the things are valid numbers. 8888fda9279dSmrg case $current in 8889fda9279dSmrg 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]) ;; 8890fda9279dSmrg *) 889116ee1e9aSmrg func_error "CURRENT '$current' must be a nonnegative integer" 889216ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8893fda9279dSmrg ;; 8894fda9279dSmrg esac 8895fda9279dSmrg 8896fda9279dSmrg case $revision in 8897fda9279dSmrg 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]) ;; 8898fda9279dSmrg *) 889916ee1e9aSmrg func_error "REVISION '$revision' must be a nonnegative integer" 890016ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8901fda9279dSmrg ;; 8902fda9279dSmrg esac 8903fda9279dSmrg 8904fda9279dSmrg case $age in 8905fda9279dSmrg 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]) ;; 8906fda9279dSmrg *) 890716ee1e9aSmrg func_error "AGE '$age' must be a nonnegative integer" 890816ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8909fda9279dSmrg ;; 8910fda9279dSmrg esac 8911fda9279dSmrg 8912fda9279dSmrg if test "$age" -gt "$current"; then 891316ee1e9aSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 891416ee1e9aSmrg func_fatal_error "'$vinfo' is not valid version information" 8915fda9279dSmrg fi 8916fda9279dSmrg 8917fda9279dSmrg # Calculate the version variables. 8918fda9279dSmrg major= 8919fda9279dSmrg versuffix= 8920fda9279dSmrg verstring= 8921fda9279dSmrg case $version_type in 8922fda9279dSmrg none) ;; 8923fda9279dSmrg 8924fda9279dSmrg darwin) 8925fda9279dSmrg # Like Linux, but with the current version available in 8926fda9279dSmrg # verstring for coding it into the library header 8927fda9279dSmrg func_arith $current - $age 8928fda9279dSmrg major=.$func_arith_result 892916ee1e9aSmrg versuffix=$major.$age.$revision 8930fda9279dSmrg # Darwin ld doesn't like 0 for these options... 8931fda9279dSmrg func_arith $current + 1 8932fda9279dSmrg minor_current=$func_arith_result 893316ee1e9aSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8934fda9279dSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 893516ee1e9aSmrg # On Darwin other compilers 893616ee1e9aSmrg case $CC in 893716ee1e9aSmrg nagfor*) 893816ee1e9aSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 893916ee1e9aSmrg ;; 894016ee1e9aSmrg *) 894116ee1e9aSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 894216ee1e9aSmrg ;; 894316ee1e9aSmrg esac 8944fda9279dSmrg ;; 8945fda9279dSmrg 8946fda9279dSmrg freebsd-aout) 894716ee1e9aSmrg major=.$current 894816ee1e9aSmrg versuffix=.$current.$revision 8949fda9279dSmrg ;; 8950fda9279dSmrg 8951fda9279dSmrg freebsd-elf) 895216ee1e9aSmrg func_arith $current - $age 895316ee1e9aSmrg major=.$func_arith_result 895416ee1e9aSmrg versuffix=$major.$age.$revision 8955fda9279dSmrg ;; 8956fda9279dSmrg 8957fda9279dSmrg irix | nonstopux) 895816ee1e9aSmrg if test no = "$lt_irix_increment"; then 8959fda9279dSmrg func_arith $current - $age 8960fda9279dSmrg else 8961fda9279dSmrg func_arith $current - $age + 1 8962fda9279dSmrg fi 8963fda9279dSmrg major=$func_arith_result 8964fda9279dSmrg 8965fda9279dSmrg case $version_type in 8966fda9279dSmrg nonstopux) verstring_prefix=nonstopux ;; 8967fda9279dSmrg *) verstring_prefix=sgi ;; 8968fda9279dSmrg esac 896916ee1e9aSmrg verstring=$verstring_prefix$major.$revision 8970fda9279dSmrg 8971fda9279dSmrg # Add in all the interfaces that we are compatible with. 8972fda9279dSmrg loop=$revision 897316ee1e9aSmrg while test 0 -ne "$loop"; do 8974fda9279dSmrg func_arith $revision - $loop 8975fda9279dSmrg iface=$func_arith_result 8976fda9279dSmrg func_arith $loop - 1 8977fda9279dSmrg loop=$func_arith_result 897816ee1e9aSmrg verstring=$verstring_prefix$major.$iface:$verstring 8979fda9279dSmrg done 8980fda9279dSmrg 898116ee1e9aSmrg # Before this point, $major must not contain '.'. 8982fda9279dSmrg major=.$major 898316ee1e9aSmrg versuffix=$major.$revision 8984fda9279dSmrg ;; 8985fda9279dSmrg 8986fda9279dSmrg linux) # correct to gnu/linux during the next big refactor 8987fda9279dSmrg func_arith $current - $age 8988fda9279dSmrg major=.$func_arith_result 898916ee1e9aSmrg versuffix=$major.$age.$revision 8990fda9279dSmrg ;; 8991fda9279dSmrg 8992fda9279dSmrg osf) 8993fda9279dSmrg func_arith $current - $age 8994fda9279dSmrg major=.$func_arith_result 899516ee1e9aSmrg versuffix=.$current.$age.$revision 899616ee1e9aSmrg verstring=$current.$age.$revision 8997fda9279dSmrg 8998fda9279dSmrg # Add in all the interfaces that we are compatible with. 8999fda9279dSmrg loop=$age 900016ee1e9aSmrg while test 0 -ne "$loop"; do 9001fda9279dSmrg func_arith $current - $loop 9002fda9279dSmrg iface=$func_arith_result 9003fda9279dSmrg func_arith $loop - 1 9004fda9279dSmrg loop=$func_arith_result 900516ee1e9aSmrg verstring=$verstring:$iface.0 9006fda9279dSmrg done 9007fda9279dSmrg 9008fda9279dSmrg # Make executables depend on our current version. 900916ee1e9aSmrg func_append verstring ":$current.0" 9010fda9279dSmrg ;; 9011fda9279dSmrg 9012fda9279dSmrg qnx) 901316ee1e9aSmrg major=.$current 901416ee1e9aSmrg versuffix=.$current 901516ee1e9aSmrg ;; 901616ee1e9aSmrg 901716ee1e9aSmrg sco) 901816ee1e9aSmrg major=.$current 901916ee1e9aSmrg versuffix=.$current 9020fda9279dSmrg ;; 9021fda9279dSmrg 9022fda9279dSmrg sunos) 902316ee1e9aSmrg major=.$current 902416ee1e9aSmrg versuffix=.$current.$revision 9025fda9279dSmrg ;; 9026fda9279dSmrg 9027fda9279dSmrg windows) 9028fda9279dSmrg # Use '-' rather than '.', since we only want one 902916ee1e9aSmrg # extension on DOS 8.3 file systems. 9030fda9279dSmrg func_arith $current - $age 9031fda9279dSmrg major=$func_arith_result 903216ee1e9aSmrg versuffix=-$major 9033fda9279dSmrg ;; 9034fda9279dSmrg 9035fda9279dSmrg *) 903616ee1e9aSmrg func_fatal_configuration "unknown library version type '$version_type'" 9037fda9279dSmrg ;; 9038fda9279dSmrg esac 9039fda9279dSmrg 9040fda9279dSmrg # Clear the version info if we defaulted, and they specified a release. 9041fda9279dSmrg if test -z "$vinfo" && test -n "$release"; then 9042fda9279dSmrg major= 9043fda9279dSmrg case $version_type in 9044fda9279dSmrg darwin) 9045fda9279dSmrg # we can't check for "0.0" in archive_cmds due to quoting 9046fda9279dSmrg # problems, so we reset it completely 9047fda9279dSmrg verstring= 9048fda9279dSmrg ;; 9049fda9279dSmrg *) 905016ee1e9aSmrg verstring=0.0 9051fda9279dSmrg ;; 9052fda9279dSmrg esac 905316ee1e9aSmrg if test no = "$need_version"; then 9054fda9279dSmrg versuffix= 9055fda9279dSmrg else 905616ee1e9aSmrg versuffix=.0.0 9057fda9279dSmrg fi 9058fda9279dSmrg fi 9059fda9279dSmrg 9060fda9279dSmrg # Remove version info from name if versioning should be avoided 906116ee1e9aSmrg if test yes,no = "$avoid_version,$need_version"; then 9062fda9279dSmrg major= 9063fda9279dSmrg versuffix= 906416ee1e9aSmrg verstring= 9065fda9279dSmrg fi 9066fda9279dSmrg 9067fda9279dSmrg # Check to see if the archive will have undefined symbols. 906816ee1e9aSmrg if test yes = "$allow_undefined"; then 906916ee1e9aSmrg if test unsupported = "$allow_undefined_flag"; then 907016ee1e9aSmrg if test yes = "$build_old_libs"; then 907116ee1e9aSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 907216ee1e9aSmrg build_libtool_libs=no 907316ee1e9aSmrg else 907416ee1e9aSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 907516ee1e9aSmrg fi 9076fda9279dSmrg fi 9077fda9279dSmrg else 9078fda9279dSmrg # Don't allow undefined symbols. 907916ee1e9aSmrg allow_undefined_flag=$no_undefined_flag 9080fda9279dSmrg fi 9081fda9279dSmrg 9082fda9279dSmrg fi 9083fda9279dSmrg 908416ee1e9aSmrg func_generate_dlsyms "$libname" "$libname" : 9085fda9279dSmrg func_append libobjs " $symfileobj" 908616ee1e9aSmrg test " " = "$libobjs" && libobjs= 9087fda9279dSmrg 908816ee1e9aSmrg if test relink != "$opt_mode"; then 9089fda9279dSmrg # Remove our outputs, but don't remove object files since they 9090fda9279dSmrg # may have been created when compiling PIC objects. 9091fda9279dSmrg removelist= 9092fda9279dSmrg tempremovelist=`$ECHO "$output_objdir/*"` 9093fda9279dSmrg for p in $tempremovelist; do 9094fda9279dSmrg case $p in 9095fda9279dSmrg *.$objext | *.gcno) 9096fda9279dSmrg ;; 909716ee1e9aSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 909816ee1e9aSmrg if test -n "$precious_files_regex"; then 9099fda9279dSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9100fda9279dSmrg then 9101fda9279dSmrg continue 9102fda9279dSmrg fi 9103fda9279dSmrg fi 9104fda9279dSmrg func_append removelist " $p" 9105fda9279dSmrg ;; 9106fda9279dSmrg *) ;; 9107fda9279dSmrg esac 9108fda9279dSmrg done 9109fda9279dSmrg test -n "$removelist" && \ 9110fda9279dSmrg func_show_eval "${RM}r \$removelist" 9111fda9279dSmrg fi 9112fda9279dSmrg 9113fda9279dSmrg # Now set the variables for building old libraries. 911416ee1e9aSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9115fda9279dSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9116fda9279dSmrg 9117fda9279dSmrg # Transform .lo files to .o files. 911816ee1e9aSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9119fda9279dSmrg fi 9120fda9279dSmrg 9121fda9279dSmrg # Eliminate all temporary directories. 9122fda9279dSmrg #for path in $notinst_path; do 9123fda9279dSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9124fda9279dSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9125fda9279dSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9126fda9279dSmrg #done 9127fda9279dSmrg 9128fda9279dSmrg if test -n "$xrpath"; then 9129fda9279dSmrg # If the user specified any rpath flags, then add them. 9130fda9279dSmrg temp_xrpath= 9131fda9279dSmrg for libdir in $xrpath; do 9132fda9279dSmrg func_replace_sysroot "$libdir" 9133fda9279dSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9134fda9279dSmrg case "$finalize_rpath " in 9135fda9279dSmrg *" $libdir "*) ;; 9136fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 9137fda9279dSmrg esac 9138fda9279dSmrg done 913916ee1e9aSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9140fda9279dSmrg dependency_libs="$temp_xrpath $dependency_libs" 9141fda9279dSmrg fi 9142fda9279dSmrg fi 9143fda9279dSmrg 9144fda9279dSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 914516ee1e9aSmrg old_dlfiles=$dlfiles 9146fda9279dSmrg dlfiles= 9147fda9279dSmrg for lib in $old_dlfiles; do 9148fda9279dSmrg case " $dlprefiles $dlfiles " in 9149fda9279dSmrg *" $lib "*) ;; 9150fda9279dSmrg *) func_append dlfiles " $lib" ;; 9151fda9279dSmrg esac 9152fda9279dSmrg done 9153fda9279dSmrg 9154fda9279dSmrg # Make sure dlprefiles contains only unique files 915516ee1e9aSmrg old_dlprefiles=$dlprefiles 9156fda9279dSmrg dlprefiles= 9157fda9279dSmrg for lib in $old_dlprefiles; do 9158fda9279dSmrg case "$dlprefiles " in 9159fda9279dSmrg *" $lib "*) ;; 9160fda9279dSmrg *) func_append dlprefiles " $lib" ;; 9161fda9279dSmrg esac 9162fda9279dSmrg done 9163fda9279dSmrg 916416ee1e9aSmrg if test yes = "$build_libtool_libs"; then 9165fda9279dSmrg if test -n "$rpath"; then 9166fda9279dSmrg case $host in 9167fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9168fda9279dSmrg # these systems don't actually have a c library (as such)! 9169fda9279dSmrg ;; 9170fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9171fda9279dSmrg # Rhapsody C library is in the System framework 9172fda9279dSmrg func_append deplibs " System.ltframework" 9173fda9279dSmrg ;; 9174fda9279dSmrg *-*-netbsd*) 9175fda9279dSmrg # Don't link with libc until the a.out ld.so is fixed. 9176fda9279dSmrg ;; 9177fda9279dSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9178fda9279dSmrg # Do not include libc due to us having libc/libc_r. 9179fda9279dSmrg ;; 9180fda9279dSmrg *-*-sco3.2v5* | *-*-sco5v6*) 9181fda9279dSmrg # Causes problems with __ctype 9182fda9279dSmrg ;; 9183fda9279dSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9184fda9279dSmrg # Compiler inserts libc in the correct place for threads to work 9185fda9279dSmrg ;; 9186fda9279dSmrg *) 9187fda9279dSmrg # Add libc to deplibs on all other systems if necessary. 918816ee1e9aSmrg if test yes = "$build_libtool_need_lc"; then 9189fda9279dSmrg func_append deplibs " -lc" 9190fda9279dSmrg fi 9191fda9279dSmrg ;; 9192fda9279dSmrg esac 9193fda9279dSmrg fi 9194fda9279dSmrg 9195fda9279dSmrg # Transform deplibs into only deplibs that can be linked in shared. 9196fda9279dSmrg name_save=$name 9197fda9279dSmrg libname_save=$libname 9198fda9279dSmrg release_save=$release 9199fda9279dSmrg versuffix_save=$versuffix 9200fda9279dSmrg major_save=$major 9201fda9279dSmrg # I'm not sure if I'm treating the release correctly. I think 9202fda9279dSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 9203fda9279dSmrg # add it in twice. Is that correct? 920416ee1e9aSmrg release= 920516ee1e9aSmrg versuffix= 920616ee1e9aSmrg major= 9207fda9279dSmrg newdeplibs= 9208fda9279dSmrg droppeddeps=no 9209fda9279dSmrg case $deplibs_check_method in 9210fda9279dSmrg pass_all) 9211fda9279dSmrg # Don't check for shared/static. Everything works. 9212fda9279dSmrg # This might be a little naive. We might want to check 9213fda9279dSmrg # whether the library exists or not. But this is on 9214fda9279dSmrg # osf3 & osf4 and I'm not really sure... Just 9215fda9279dSmrg # implementing what was already the behavior. 9216fda9279dSmrg newdeplibs=$deplibs 9217fda9279dSmrg ;; 9218fda9279dSmrg test_compile) 9219fda9279dSmrg # This code stresses the "libraries are programs" paradigm to its 9220fda9279dSmrg # limits. Maybe even breaks it. We compile a program, linking it 9221fda9279dSmrg # against the deplibs as a proxy for the library. Then we can check 9222fda9279dSmrg # whether they linked in statically or dynamically with ldd. 9223fda9279dSmrg $opt_dry_run || $RM conftest.c 9224fda9279dSmrg cat > conftest.c <<EOF 9225fda9279dSmrg int main() { return 0; } 9226fda9279dSmrgEOF 9227fda9279dSmrg $opt_dry_run || $RM conftest 9228fda9279dSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9229fda9279dSmrg ldd_output=`ldd conftest` 9230fda9279dSmrg for i in $deplibs; do 9231fda9279dSmrg case $i in 9232fda9279dSmrg -l*) 9233fda9279dSmrg func_stripname -l '' "$i" 9234fda9279dSmrg name=$func_stripname_result 923516ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9236fda9279dSmrg case " $predeps $postdeps " in 9237fda9279dSmrg *" $i "*) 9238fda9279dSmrg func_append newdeplibs " $i" 923916ee1e9aSmrg i= 9240fda9279dSmrg ;; 9241fda9279dSmrg esac 9242fda9279dSmrg fi 924316ee1e9aSmrg if test -n "$i"; then 9244fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9245fda9279dSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9246fda9279dSmrg set dummy $deplib_matches; shift 9247fda9279dSmrg deplib_match=$1 924816ee1e9aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9249fda9279dSmrg func_append newdeplibs " $i" 9250fda9279dSmrg else 9251fda9279dSmrg droppeddeps=yes 9252fda9279dSmrg echo 9253fda9279dSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9254fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9255fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9256fda9279dSmrg echo "*** shared version of the library, which I believe you do not have" 9257fda9279dSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 9258fda9279dSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9259fda9279dSmrg fi 9260fda9279dSmrg fi 9261fda9279dSmrg ;; 9262fda9279dSmrg *) 9263fda9279dSmrg func_append newdeplibs " $i" 9264fda9279dSmrg ;; 9265fda9279dSmrg esac 9266fda9279dSmrg done 9267fda9279dSmrg else 9268fda9279dSmrg # Error occurred in the first compile. Let's try to salvage 9269fda9279dSmrg # the situation: Compile a separate program for each library. 9270fda9279dSmrg for i in $deplibs; do 9271fda9279dSmrg case $i in 9272fda9279dSmrg -l*) 9273fda9279dSmrg func_stripname -l '' "$i" 9274fda9279dSmrg name=$func_stripname_result 9275fda9279dSmrg $opt_dry_run || $RM conftest 9276fda9279dSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9277fda9279dSmrg ldd_output=`ldd conftest` 927816ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9279fda9279dSmrg case " $predeps $postdeps " in 9280fda9279dSmrg *" $i "*) 9281fda9279dSmrg func_append newdeplibs " $i" 928216ee1e9aSmrg i= 9283fda9279dSmrg ;; 9284fda9279dSmrg esac 9285fda9279dSmrg fi 928616ee1e9aSmrg if test -n "$i"; then 9287fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9288fda9279dSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9289fda9279dSmrg set dummy $deplib_matches; shift 9290fda9279dSmrg deplib_match=$1 929116ee1e9aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9292fda9279dSmrg func_append newdeplibs " $i" 9293fda9279dSmrg else 9294fda9279dSmrg droppeddeps=yes 9295fda9279dSmrg echo 9296fda9279dSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9297fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9298fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9299fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 9300fda9279dSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 9301fda9279dSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9302fda9279dSmrg fi 9303fda9279dSmrg fi 9304fda9279dSmrg else 9305fda9279dSmrg droppeddeps=yes 9306fda9279dSmrg echo 9307fda9279dSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9308fda9279dSmrg echo "*** make it link in! You will probably need to install it or some" 9309fda9279dSmrg echo "*** library that it depends on before this library will be fully" 9310fda9279dSmrg echo "*** functional. Installing it before continuing would be even better." 9311fda9279dSmrg fi 9312fda9279dSmrg ;; 9313fda9279dSmrg *) 9314fda9279dSmrg func_append newdeplibs " $i" 9315fda9279dSmrg ;; 9316fda9279dSmrg esac 9317fda9279dSmrg done 9318fda9279dSmrg fi 9319fda9279dSmrg ;; 9320fda9279dSmrg file_magic*) 9321fda9279dSmrg set dummy $deplibs_check_method; shift 9322fda9279dSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9323fda9279dSmrg for a_deplib in $deplibs; do 9324fda9279dSmrg case $a_deplib in 9325fda9279dSmrg -l*) 9326fda9279dSmrg func_stripname -l '' "$a_deplib" 9327fda9279dSmrg name=$func_stripname_result 932816ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9329fda9279dSmrg case " $predeps $postdeps " in 9330fda9279dSmrg *" $a_deplib "*) 9331fda9279dSmrg func_append newdeplibs " $a_deplib" 933216ee1e9aSmrg a_deplib= 9333fda9279dSmrg ;; 9334fda9279dSmrg esac 9335fda9279dSmrg fi 933616ee1e9aSmrg if test -n "$a_deplib"; then 9337fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9338fda9279dSmrg if test -n "$file_magic_glob"; then 9339fda9279dSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9340fda9279dSmrg else 9341fda9279dSmrg libnameglob=$libname 9342fda9279dSmrg fi 934316ee1e9aSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9344fda9279dSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 934516ee1e9aSmrg if test yes = "$want_nocaseglob"; then 9346fda9279dSmrg shopt -s nocaseglob 9347fda9279dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9348fda9279dSmrg $nocaseglob 9349fda9279dSmrg else 9350fda9279dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9351fda9279dSmrg fi 9352fda9279dSmrg for potent_lib in $potential_libs; do 9353fda9279dSmrg # Follow soft links. 9354fda9279dSmrg if ls -lLd "$potent_lib" 2>/dev/null | 9355fda9279dSmrg $GREP " -> " >/dev/null; then 9356fda9279dSmrg continue 9357fda9279dSmrg fi 9358fda9279dSmrg # The statement above tries to avoid entering an 9359fda9279dSmrg # endless loop below, in case of cyclic links. 9360fda9279dSmrg # We might still enter an endless loop, since a link 9361fda9279dSmrg # loop can be closed while we follow links, 9362fda9279dSmrg # but so what? 936316ee1e9aSmrg potlib=$potent_lib 9364fda9279dSmrg while test -h "$potlib" 2>/dev/null; do 936516ee1e9aSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9366fda9279dSmrg case $potliblink in 936716ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 936816ee1e9aSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9369fda9279dSmrg esac 9370fda9279dSmrg done 9371fda9279dSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9372fda9279dSmrg $SED -e 10q | 9373fda9279dSmrg $EGREP "$file_magic_regex" > /dev/null; then 9374fda9279dSmrg func_append newdeplibs " $a_deplib" 937516ee1e9aSmrg a_deplib= 9376fda9279dSmrg break 2 9377fda9279dSmrg fi 9378fda9279dSmrg done 9379fda9279dSmrg done 9380fda9279dSmrg fi 938116ee1e9aSmrg if test -n "$a_deplib"; then 9382fda9279dSmrg droppeddeps=yes 9383fda9279dSmrg echo 9384fda9279dSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9385fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9386fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9387fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 9388fda9279dSmrg echo "*** because I did check the linker path looking for a file starting" 938916ee1e9aSmrg if test -z "$potlib"; then 9390fda9279dSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9391fda9279dSmrg else 9392fda9279dSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9393fda9279dSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 9394fda9279dSmrg fi 9395fda9279dSmrg fi 9396fda9279dSmrg ;; 9397fda9279dSmrg *) 9398fda9279dSmrg # Add a -L argument. 9399fda9279dSmrg func_append newdeplibs " $a_deplib" 9400fda9279dSmrg ;; 9401fda9279dSmrg esac 9402fda9279dSmrg done # Gone through all deplibs. 9403fda9279dSmrg ;; 9404fda9279dSmrg match_pattern*) 9405fda9279dSmrg set dummy $deplibs_check_method; shift 9406fda9279dSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9407fda9279dSmrg for a_deplib in $deplibs; do 9408fda9279dSmrg case $a_deplib in 9409fda9279dSmrg -l*) 9410fda9279dSmrg func_stripname -l '' "$a_deplib" 9411fda9279dSmrg name=$func_stripname_result 941216ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9413fda9279dSmrg case " $predeps $postdeps " in 9414fda9279dSmrg *" $a_deplib "*) 9415fda9279dSmrg func_append newdeplibs " $a_deplib" 941616ee1e9aSmrg a_deplib= 9417fda9279dSmrg ;; 9418fda9279dSmrg esac 9419fda9279dSmrg fi 942016ee1e9aSmrg if test -n "$a_deplib"; then 9421fda9279dSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9422fda9279dSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9423fda9279dSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9424fda9279dSmrg for potent_lib in $potential_libs; do 942516ee1e9aSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9426fda9279dSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9427fda9279dSmrg $EGREP "$match_pattern_regex" > /dev/null; then 9428fda9279dSmrg func_append newdeplibs " $a_deplib" 942916ee1e9aSmrg a_deplib= 9430fda9279dSmrg break 2 9431fda9279dSmrg fi 9432fda9279dSmrg done 9433fda9279dSmrg done 9434fda9279dSmrg fi 943516ee1e9aSmrg if test -n "$a_deplib"; then 9436fda9279dSmrg droppeddeps=yes 9437fda9279dSmrg echo 9438fda9279dSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9439fda9279dSmrg echo "*** I have the capability to make that library automatically link in when" 9440fda9279dSmrg echo "*** you link to this library. But I can only do this if you have a" 9441fda9279dSmrg echo "*** shared version of the library, which you do not appear to have" 9442fda9279dSmrg echo "*** because I did check the linker path looking for a file starting" 944316ee1e9aSmrg if test -z "$potlib"; then 9444fda9279dSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9445fda9279dSmrg else 9446fda9279dSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9447fda9279dSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9448fda9279dSmrg fi 9449fda9279dSmrg fi 9450fda9279dSmrg ;; 9451fda9279dSmrg *) 9452fda9279dSmrg # Add a -L argument. 9453fda9279dSmrg func_append newdeplibs " $a_deplib" 9454fda9279dSmrg ;; 9455fda9279dSmrg esac 9456fda9279dSmrg done # Gone through all deplibs. 9457fda9279dSmrg ;; 9458fda9279dSmrg none | unknown | *) 945916ee1e9aSmrg newdeplibs= 9460fda9279dSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 946116ee1e9aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 946216ee1e9aSmrg for i in $predeps $postdeps; do 9463fda9279dSmrg # can't use Xsed below, because $i might contain '/' 946416ee1e9aSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9465fda9279dSmrg done 9466fda9279dSmrg fi 9467fda9279dSmrg case $tmp_deplibs in 9468fda9279dSmrg *[!\ \ ]*) 9469fda9279dSmrg echo 947016ee1e9aSmrg if test none = "$deplibs_check_method"; then 9471fda9279dSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9472fda9279dSmrg else 9473fda9279dSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 9474fda9279dSmrg fi 9475fda9279dSmrg echo "*** All declared inter-library dependencies are being dropped." 9476fda9279dSmrg droppeddeps=yes 9477fda9279dSmrg ;; 9478fda9279dSmrg esac 9479fda9279dSmrg ;; 9480fda9279dSmrg esac 9481fda9279dSmrg versuffix=$versuffix_save 9482fda9279dSmrg major=$major_save 9483fda9279dSmrg release=$release_save 9484fda9279dSmrg libname=$libname_save 9485fda9279dSmrg name=$name_save 9486fda9279dSmrg 9487fda9279dSmrg case $host in 9488fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9489fda9279dSmrg # On Rhapsody replace the C library with the System framework 9490fda9279dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9491fda9279dSmrg ;; 9492fda9279dSmrg esac 9493fda9279dSmrg 949416ee1e9aSmrg if test yes = "$droppeddeps"; then 949516ee1e9aSmrg if test yes = "$module"; then 9496fda9279dSmrg echo 9497fda9279dSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9498fda9279dSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9499fda9279dSmrg echo "*** a static module, that should work as long as the dlopening" 9500fda9279dSmrg echo "*** application is linked with the -dlopen flag." 9501fda9279dSmrg if test -z "$global_symbol_pipe"; then 9502fda9279dSmrg echo 9503fda9279dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 950416ee1e9aSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9505fda9279dSmrg echo "*** not find such a program. So, this module is probably useless." 950616ee1e9aSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9507fda9279dSmrg fi 950816ee1e9aSmrg if test no = "$build_old_libs"; then 950916ee1e9aSmrg oldlibs=$output_objdir/$libname.$libext 9510fda9279dSmrg build_libtool_libs=module 9511fda9279dSmrg build_old_libs=yes 9512fda9279dSmrg else 9513fda9279dSmrg build_libtool_libs=no 9514fda9279dSmrg fi 9515fda9279dSmrg else 9516fda9279dSmrg echo "*** The inter-library dependencies that have been dropped here will be" 9517fda9279dSmrg echo "*** automatically added whenever a program is linked with this library" 9518fda9279dSmrg echo "*** or is declared to -dlopen it." 9519fda9279dSmrg 952016ee1e9aSmrg if test no = "$allow_undefined"; then 9521fda9279dSmrg echo 9522fda9279dSmrg echo "*** Since this library must not contain undefined symbols," 9523fda9279dSmrg echo "*** because either the platform does not support them or" 9524fda9279dSmrg echo "*** it was explicitly requested with -no-undefined," 9525fda9279dSmrg echo "*** libtool will only create a static version of it." 952616ee1e9aSmrg if test no = "$build_old_libs"; then 952716ee1e9aSmrg oldlibs=$output_objdir/$libname.$libext 9528fda9279dSmrg build_libtool_libs=module 9529fda9279dSmrg build_old_libs=yes 9530fda9279dSmrg else 9531fda9279dSmrg build_libtool_libs=no 9532fda9279dSmrg fi 9533fda9279dSmrg fi 9534fda9279dSmrg fi 9535fda9279dSmrg fi 9536fda9279dSmrg # Done checking deplibs! 9537fda9279dSmrg deplibs=$newdeplibs 9538fda9279dSmrg fi 9539fda9279dSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9540fda9279dSmrg case $host in 9541fda9279dSmrg *-*-darwin*) 9542fda9279dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9543fda9279dSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9544fda9279dSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9545fda9279dSmrg ;; 9546fda9279dSmrg esac 9547fda9279dSmrg 9548fda9279dSmrg # move library search paths that coincide with paths to not yet 9549fda9279dSmrg # installed libraries to the beginning of the library search list 9550fda9279dSmrg new_libs= 9551fda9279dSmrg for path in $notinst_path; do 9552fda9279dSmrg case " $new_libs " in 9553fda9279dSmrg *" -L$path/$objdir "*) ;; 9554fda9279dSmrg *) 9555fda9279dSmrg case " $deplibs " in 9556fda9279dSmrg *" -L$path/$objdir "*) 9557fda9279dSmrg func_append new_libs " -L$path/$objdir" ;; 9558fda9279dSmrg esac 9559fda9279dSmrg ;; 9560fda9279dSmrg esac 9561fda9279dSmrg done 9562fda9279dSmrg for deplib in $deplibs; do 9563fda9279dSmrg case $deplib in 9564fda9279dSmrg -L*) 9565fda9279dSmrg case " $new_libs " in 9566fda9279dSmrg *" $deplib "*) ;; 9567fda9279dSmrg *) func_append new_libs " $deplib" ;; 9568fda9279dSmrg esac 9569fda9279dSmrg ;; 9570fda9279dSmrg *) func_append new_libs " $deplib" ;; 9571fda9279dSmrg esac 9572fda9279dSmrg done 957316ee1e9aSmrg deplibs=$new_libs 9574fda9279dSmrg 9575fda9279dSmrg # All the library-specific variables (install_libdir is set above). 9576fda9279dSmrg library_names= 9577fda9279dSmrg old_library= 9578fda9279dSmrg dlname= 9579fda9279dSmrg 9580fda9279dSmrg # Test again, we may have decided not to build it any more 958116ee1e9aSmrg if test yes = "$build_libtool_libs"; then 958216ee1e9aSmrg # Remove $wl instances when linking with ld. 9583fda9279dSmrg # FIXME: should test the right _cmds variable. 9584fda9279dSmrg case $archive_cmds in 9585fda9279dSmrg *\$LD\ *) wl= ;; 9586fda9279dSmrg esac 958716ee1e9aSmrg if test yes = "$hardcode_into_libs"; then 9588fda9279dSmrg # Hardcode the library paths 9589fda9279dSmrg hardcode_libdirs= 9590fda9279dSmrg dep_rpath= 959116ee1e9aSmrg rpath=$finalize_rpath 959216ee1e9aSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9593fda9279dSmrg for libdir in $rpath; do 9594fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 9595fda9279dSmrg if test -n "$hardcode_libdir_separator"; then 9596fda9279dSmrg func_replace_sysroot "$libdir" 9597fda9279dSmrg libdir=$func_replace_sysroot_result 9598fda9279dSmrg if test -z "$hardcode_libdirs"; then 959916ee1e9aSmrg hardcode_libdirs=$libdir 9600fda9279dSmrg else 9601fda9279dSmrg # Just accumulate the unique libdirs. 9602fda9279dSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9603fda9279dSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9604fda9279dSmrg ;; 9605fda9279dSmrg *) 9606fda9279dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9607fda9279dSmrg ;; 9608fda9279dSmrg esac 9609fda9279dSmrg fi 9610fda9279dSmrg else 9611fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 9612fda9279dSmrg func_append dep_rpath " $flag" 9613fda9279dSmrg fi 9614fda9279dSmrg elif test -n "$runpath_var"; then 9615fda9279dSmrg case "$perm_rpath " in 9616fda9279dSmrg *" $libdir "*) ;; 9617fda9279dSmrg *) func_append perm_rpath " $libdir" ;; 9618fda9279dSmrg esac 9619fda9279dSmrg fi 9620fda9279dSmrg done 9621fda9279dSmrg # Substitute the hardcoded libdirs into the rpath. 9622fda9279dSmrg if test -n "$hardcode_libdir_separator" && 9623fda9279dSmrg test -n "$hardcode_libdirs"; then 962416ee1e9aSmrg libdir=$hardcode_libdirs 9625fda9279dSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9626fda9279dSmrg fi 9627fda9279dSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9628fda9279dSmrg # We should set the runpath_var. 9629fda9279dSmrg rpath= 9630fda9279dSmrg for dir in $perm_rpath; do 9631fda9279dSmrg func_append rpath "$dir:" 9632fda9279dSmrg done 9633fda9279dSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9634fda9279dSmrg fi 9635fda9279dSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9636fda9279dSmrg fi 9637fda9279dSmrg 963816ee1e9aSmrg shlibpath=$finalize_shlibpath 963916ee1e9aSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9640fda9279dSmrg if test -n "$shlibpath"; then 9641fda9279dSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9642fda9279dSmrg fi 9643fda9279dSmrg 9644fda9279dSmrg # Get the real and link names of the library. 9645fda9279dSmrg eval shared_ext=\"$shrext_cmds\" 9646fda9279dSmrg eval library_names=\"$library_names_spec\" 9647fda9279dSmrg set dummy $library_names 9648fda9279dSmrg shift 964916ee1e9aSmrg realname=$1 9650fda9279dSmrg shift 9651fda9279dSmrg 9652fda9279dSmrg if test -n "$soname_spec"; then 9653fda9279dSmrg eval soname=\"$soname_spec\" 9654fda9279dSmrg else 965516ee1e9aSmrg soname=$realname 9656fda9279dSmrg fi 9657fda9279dSmrg if test -z "$dlname"; then 9658fda9279dSmrg dlname=$soname 9659fda9279dSmrg fi 9660fda9279dSmrg 966116ee1e9aSmrg lib=$output_objdir/$realname 9662fda9279dSmrg linknames= 9663fda9279dSmrg for link 9664fda9279dSmrg do 9665fda9279dSmrg func_append linknames " $link" 9666fda9279dSmrg done 9667fda9279dSmrg 9668fda9279dSmrg # Use standard objects if they are pic 9669fda9279dSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9670fda9279dSmrg test "X$libobjs" = "X " && libobjs= 9671fda9279dSmrg 9672fda9279dSmrg delfiles= 9673fda9279dSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9674fda9279dSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 967516ee1e9aSmrg export_symbols=$output_objdir/$libname.uexp 9676fda9279dSmrg func_append delfiles " $export_symbols" 9677fda9279dSmrg fi 9678fda9279dSmrg 9679fda9279dSmrg orig_export_symbols= 9680fda9279dSmrg case $host_os in 9681fda9279dSmrg cygwin* | mingw* | cegcc*) 9682fda9279dSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9683fda9279dSmrg # exporting using user supplied symfile 968416ee1e9aSmrg func_dll_def_p "$export_symbols" || { 9685fda9279dSmrg # and it's NOT already a .def file. Must figure out 9686fda9279dSmrg # which of the given symbols are data symbols and tag 9687fda9279dSmrg # them as such. So, trigger use of export_symbols_cmds. 9688fda9279dSmrg # export_symbols gets reassigned inside the "prepare 9689fda9279dSmrg # the list of exported symbols" if statement, so the 9690fda9279dSmrg # include_expsyms logic still works. 969116ee1e9aSmrg orig_export_symbols=$export_symbols 9692fda9279dSmrg export_symbols= 9693fda9279dSmrg always_export_symbols=yes 969416ee1e9aSmrg } 9695fda9279dSmrg fi 9696fda9279dSmrg ;; 9697fda9279dSmrg esac 9698fda9279dSmrg 9699fda9279dSmrg # Prepare the list of exported symbols 9700fda9279dSmrg if test -z "$export_symbols"; then 970116ee1e9aSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 970216ee1e9aSmrg func_verbose "generating symbol list for '$libname.la'" 970316ee1e9aSmrg export_symbols=$output_objdir/$libname.exp 9704fda9279dSmrg $opt_dry_run || $RM $export_symbols 9705fda9279dSmrg cmds=$export_symbols_cmds 970616ee1e9aSmrg save_ifs=$IFS; IFS='~' 9707fda9279dSmrg for cmd1 in $cmds; do 970816ee1e9aSmrg IFS=$save_ifs 9709fda9279dSmrg # Take the normal branch if the nm_file_list_spec branch 9710fda9279dSmrg # doesn't work or if tool conversion is not needed. 9711fda9279dSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9712fda9279dSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9713fda9279dSmrg try_normal_branch=yes 9714fda9279dSmrg eval cmd=\"$cmd1\" 9715fda9279dSmrg func_len " $cmd" 9716fda9279dSmrg len=$func_len_result 9717fda9279dSmrg ;; 9718fda9279dSmrg *) 9719fda9279dSmrg try_normal_branch=no 9720fda9279dSmrg ;; 9721fda9279dSmrg esac 972216ee1e9aSmrg if test yes = "$try_normal_branch" \ 9723fda9279dSmrg && { test "$len" -lt "$max_cmd_len" \ 9724fda9279dSmrg || test "$max_cmd_len" -le -1; } 9725fda9279dSmrg then 9726fda9279dSmrg func_show_eval "$cmd" 'exit $?' 9727fda9279dSmrg skipped_export=false 9728fda9279dSmrg elif test -n "$nm_file_list_spec"; then 9729fda9279dSmrg func_basename "$output" 9730fda9279dSmrg output_la=$func_basename_result 9731fda9279dSmrg save_libobjs=$libobjs 9732fda9279dSmrg save_output=$output 973316ee1e9aSmrg output=$output_objdir/$output_la.nm 9734fda9279dSmrg func_to_tool_file "$output" 9735fda9279dSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9736fda9279dSmrg func_append delfiles " $output" 9737fda9279dSmrg func_verbose "creating $NM input file list: $output" 9738fda9279dSmrg for obj in $save_libobjs; do 9739fda9279dSmrg func_to_tool_file "$obj" 9740fda9279dSmrg $ECHO "$func_to_tool_file_result" 9741fda9279dSmrg done > "$output" 9742fda9279dSmrg eval cmd=\"$cmd1\" 9743fda9279dSmrg func_show_eval "$cmd" 'exit $?' 9744fda9279dSmrg output=$save_output 9745fda9279dSmrg libobjs=$save_libobjs 9746fda9279dSmrg skipped_export=false 9747fda9279dSmrg else 9748fda9279dSmrg # The command line is too long to execute in one step. 9749fda9279dSmrg func_verbose "using reloadable object file for export list..." 9750fda9279dSmrg skipped_export=: 9751fda9279dSmrg # Break out early, otherwise skipped_export may be 9752fda9279dSmrg # set to false by a later but shorter cmd. 9753fda9279dSmrg break 9754fda9279dSmrg fi 9755fda9279dSmrg done 975616ee1e9aSmrg IFS=$save_ifs 975716ee1e9aSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9758fda9279dSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9759fda9279dSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9760fda9279dSmrg fi 9761fda9279dSmrg fi 9762fda9279dSmrg fi 9763fda9279dSmrg 9764fda9279dSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 976516ee1e9aSmrg tmp_export_symbols=$export_symbols 976616ee1e9aSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9767fda9279dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9768fda9279dSmrg fi 9769fda9279dSmrg 977016ee1e9aSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9771fda9279dSmrg # The given exports_symbols file has to be filtered, so filter it. 977216ee1e9aSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9773fda9279dSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 977416ee1e9aSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9775fda9279dSmrg # though. Also, the filter scales superlinearly with the number of 9776fda9279dSmrg # global variables. join(1) would be nice here, but unfortunately 9777fda9279dSmrg # isn't a blessed tool. 9778fda9279dSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9779fda9279dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9780fda9279dSmrg export_symbols=$output_objdir/$libname.def 9781fda9279dSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9782fda9279dSmrg fi 9783fda9279dSmrg 9784fda9279dSmrg tmp_deplibs= 9785fda9279dSmrg for test_deplib in $deplibs; do 9786fda9279dSmrg case " $convenience " in 9787fda9279dSmrg *" $test_deplib "*) ;; 9788fda9279dSmrg *) 9789fda9279dSmrg func_append tmp_deplibs " $test_deplib" 9790fda9279dSmrg ;; 9791fda9279dSmrg esac 9792fda9279dSmrg done 979316ee1e9aSmrg deplibs=$tmp_deplibs 9794fda9279dSmrg 9795fda9279dSmrg if test -n "$convenience"; then 9796fda9279dSmrg if test -n "$whole_archive_flag_spec" && 979716ee1e9aSmrg test yes = "$compiler_needs_object" && 9798fda9279dSmrg test -z "$libobjs"; then 9799fda9279dSmrg # extract the archives, so we have objects to list. 9800fda9279dSmrg # TODO: could optimize this to just extract one archive. 9801fda9279dSmrg whole_archive_flag_spec= 9802fda9279dSmrg fi 9803fda9279dSmrg if test -n "$whole_archive_flag_spec"; then 9804fda9279dSmrg save_libobjs=$libobjs 9805fda9279dSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9806fda9279dSmrg test "X$libobjs" = "X " && libobjs= 9807fda9279dSmrg else 980816ee1e9aSmrg gentop=$output_objdir/${outputname}x 9809fda9279dSmrg func_append generated " $gentop" 9810fda9279dSmrg 9811fda9279dSmrg func_extract_archives $gentop $convenience 9812fda9279dSmrg func_append libobjs " $func_extract_archives_result" 9813fda9279dSmrg test "X$libobjs" = "X " && libobjs= 9814fda9279dSmrg fi 9815fda9279dSmrg fi 9816fda9279dSmrg 981716ee1e9aSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9818fda9279dSmrg eval flag=\"$thread_safe_flag_spec\" 9819fda9279dSmrg func_append linker_flags " $flag" 9820fda9279dSmrg fi 9821fda9279dSmrg 9822fda9279dSmrg # Make a backup of the uninstalled library when relinking 982316ee1e9aSmrg if test relink = "$opt_mode"; then 9824fda9279dSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9825fda9279dSmrg fi 9826fda9279dSmrg 9827fda9279dSmrg # Do each of the archive commands. 982816ee1e9aSmrg if test yes = "$module" && test -n "$module_cmds"; then 9829fda9279dSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9830fda9279dSmrg eval test_cmds=\"$module_expsym_cmds\" 9831fda9279dSmrg cmds=$module_expsym_cmds 9832fda9279dSmrg else 9833fda9279dSmrg eval test_cmds=\"$module_cmds\" 9834fda9279dSmrg cmds=$module_cmds 9835fda9279dSmrg fi 9836fda9279dSmrg else 9837fda9279dSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9838fda9279dSmrg eval test_cmds=\"$archive_expsym_cmds\" 9839fda9279dSmrg cmds=$archive_expsym_cmds 9840fda9279dSmrg else 9841fda9279dSmrg eval test_cmds=\"$archive_cmds\" 9842fda9279dSmrg cmds=$archive_cmds 9843fda9279dSmrg fi 9844fda9279dSmrg fi 9845fda9279dSmrg 984616ee1e9aSmrg if test : != "$skipped_export" && 9847fda9279dSmrg func_len " $test_cmds" && 9848fda9279dSmrg len=$func_len_result && 9849fda9279dSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9850fda9279dSmrg : 9851fda9279dSmrg else 9852fda9279dSmrg # The command line is too long to link in one step, link piecewise 9853fda9279dSmrg # or, if using GNU ld and skipped_export is not :, use a linker 9854fda9279dSmrg # script. 9855fda9279dSmrg 9856fda9279dSmrg # Save the value of $output and $libobjs because we want to 9857fda9279dSmrg # use them later. If we have whole_archive_flag_spec, we 9858fda9279dSmrg # want to use save_libobjs as it was before 9859fda9279dSmrg # whole_archive_flag_spec was expanded, because we can't 9860fda9279dSmrg # assume the linker understands whole_archive_flag_spec. 9861fda9279dSmrg # This may have to be revisited, in case too many 9862fda9279dSmrg # convenience libraries get linked in and end up exceeding 9863fda9279dSmrg # the spec. 9864fda9279dSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9865fda9279dSmrg save_libobjs=$libobjs 9866fda9279dSmrg fi 9867fda9279dSmrg save_output=$output 9868fda9279dSmrg func_basename "$output" 9869fda9279dSmrg output_la=$func_basename_result 9870fda9279dSmrg 9871fda9279dSmrg # Clear the reloadable object creation command queue and 9872fda9279dSmrg # initialize k to one. 9873fda9279dSmrg test_cmds= 9874fda9279dSmrg concat_cmds= 9875fda9279dSmrg objlist= 9876fda9279dSmrg last_robj= 9877fda9279dSmrg k=1 9878fda9279dSmrg 987916ee1e9aSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 988016ee1e9aSmrg output=$output_objdir/$output_la.lnkscript 9881fda9279dSmrg func_verbose "creating GNU ld script: $output" 9882fda9279dSmrg echo 'INPUT (' > $output 9883fda9279dSmrg for obj in $save_libobjs 9884fda9279dSmrg do 9885fda9279dSmrg func_to_tool_file "$obj" 9886fda9279dSmrg $ECHO "$func_to_tool_file_result" >> $output 9887fda9279dSmrg done 9888fda9279dSmrg echo ')' >> $output 9889fda9279dSmrg func_append delfiles " $output" 9890fda9279dSmrg func_to_tool_file "$output" 9891fda9279dSmrg output=$func_to_tool_file_result 989216ee1e9aSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 989316ee1e9aSmrg output=$output_objdir/$output_la.lnk 9894fda9279dSmrg func_verbose "creating linker input file list: $output" 9895fda9279dSmrg : > $output 9896fda9279dSmrg set x $save_libobjs 9897fda9279dSmrg shift 9898fda9279dSmrg firstobj= 989916ee1e9aSmrg if test yes = "$compiler_needs_object"; then 9900fda9279dSmrg firstobj="$1 " 9901fda9279dSmrg shift 9902fda9279dSmrg fi 9903fda9279dSmrg for obj 9904fda9279dSmrg do 9905fda9279dSmrg func_to_tool_file "$obj" 9906fda9279dSmrg $ECHO "$func_to_tool_file_result" >> $output 9907fda9279dSmrg done 9908fda9279dSmrg func_append delfiles " $output" 9909fda9279dSmrg func_to_tool_file "$output" 9910fda9279dSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9911fda9279dSmrg else 9912fda9279dSmrg if test -n "$save_libobjs"; then 9913fda9279dSmrg func_verbose "creating reloadable object files..." 991416ee1e9aSmrg output=$output_objdir/$output_la-$k.$objext 9915fda9279dSmrg eval test_cmds=\"$reload_cmds\" 9916fda9279dSmrg func_len " $test_cmds" 9917fda9279dSmrg len0=$func_len_result 9918fda9279dSmrg len=$len0 9919fda9279dSmrg 9920fda9279dSmrg # Loop over the list of objects to be linked. 9921fda9279dSmrg for obj in $save_libobjs 9922fda9279dSmrg do 9923fda9279dSmrg func_len " $obj" 9924fda9279dSmrg func_arith $len + $func_len_result 9925fda9279dSmrg len=$func_arith_result 992616ee1e9aSmrg if test -z "$objlist" || 9927fda9279dSmrg test "$len" -lt "$max_cmd_len"; then 9928fda9279dSmrg func_append objlist " $obj" 9929fda9279dSmrg else 9930fda9279dSmrg # The command $test_cmds is almost too long, add a 9931fda9279dSmrg # command to the queue. 993216ee1e9aSmrg if test 1 -eq "$k"; then 9933fda9279dSmrg # The first file doesn't have a previous command to add. 9934fda9279dSmrg reload_objs=$objlist 9935fda9279dSmrg eval concat_cmds=\"$reload_cmds\" 9936fda9279dSmrg else 9937fda9279dSmrg # All subsequent reloadable object files will link in 9938fda9279dSmrg # the last one created. 9939fda9279dSmrg reload_objs="$objlist $last_robj" 9940fda9279dSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9941fda9279dSmrg fi 994216ee1e9aSmrg last_robj=$output_objdir/$output_la-$k.$objext 9943fda9279dSmrg func_arith $k + 1 9944fda9279dSmrg k=$func_arith_result 994516ee1e9aSmrg output=$output_objdir/$output_la-$k.$objext 9946fda9279dSmrg objlist=" $obj" 9947fda9279dSmrg func_len " $last_robj" 9948fda9279dSmrg func_arith $len0 + $func_len_result 9949fda9279dSmrg len=$func_arith_result 9950fda9279dSmrg fi 9951fda9279dSmrg done 9952fda9279dSmrg # Handle the remaining objects by creating one last 9953fda9279dSmrg # reloadable object file. All subsequent reloadable object 9954fda9279dSmrg # files will link in the last one created. 9955fda9279dSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9956fda9279dSmrg reload_objs="$objlist $last_robj" 995716ee1e9aSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9958fda9279dSmrg if test -n "$last_robj"; then 995916ee1e9aSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9960fda9279dSmrg fi 9961fda9279dSmrg func_append delfiles " $output" 9962fda9279dSmrg 9963fda9279dSmrg else 9964fda9279dSmrg output= 9965fda9279dSmrg fi 9966fda9279dSmrg 996716ee1e9aSmrg ${skipped_export-false} && { 996816ee1e9aSmrg func_verbose "generating symbol list for '$libname.la'" 996916ee1e9aSmrg export_symbols=$output_objdir/$libname.exp 9970fda9279dSmrg $opt_dry_run || $RM $export_symbols 9971fda9279dSmrg libobjs=$output 9972fda9279dSmrg # Append the command to create the export file. 9973fda9279dSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9974fda9279dSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9975fda9279dSmrg if test -n "$last_robj"; then 9976fda9279dSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9977fda9279dSmrg fi 997816ee1e9aSmrg } 9979fda9279dSmrg 9980fda9279dSmrg test -n "$save_libobjs" && 9981fda9279dSmrg func_verbose "creating a temporary reloadable object file: $output" 9982fda9279dSmrg 9983fda9279dSmrg # Loop through the commands generated above and execute them. 998416ee1e9aSmrg save_ifs=$IFS; IFS='~' 9985fda9279dSmrg for cmd in $concat_cmds; do 998616ee1e9aSmrg IFS=$save_ifs 998716ee1e9aSmrg $opt_quiet || { 9988fda9279dSmrg func_quote_for_expand "$cmd" 9989fda9279dSmrg eval "func_echo $func_quote_for_expand_result" 9990fda9279dSmrg } 9991fda9279dSmrg $opt_dry_run || eval "$cmd" || { 9992fda9279dSmrg lt_exit=$? 9993fda9279dSmrg 9994fda9279dSmrg # Restore the uninstalled library and exit 999516ee1e9aSmrg if test relink = "$opt_mode"; then 9996fda9279dSmrg ( cd "$output_objdir" && \ 9997fda9279dSmrg $RM "${realname}T" && \ 9998fda9279dSmrg $MV "${realname}U" "$realname" ) 9999fda9279dSmrg fi 10000fda9279dSmrg 10001fda9279dSmrg exit $lt_exit 10002fda9279dSmrg } 10003fda9279dSmrg done 1000416ee1e9aSmrg IFS=$save_ifs 10005fda9279dSmrg 10006fda9279dSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10007fda9279dSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10008fda9279dSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10009fda9279dSmrg fi 10010fda9279dSmrg fi 10011fda9279dSmrg 1001216ee1e9aSmrg ${skipped_export-false} && { 10013fda9279dSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 1001416ee1e9aSmrg tmp_export_symbols=$export_symbols 1001516ee1e9aSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10016fda9279dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10017fda9279dSmrg fi 10018fda9279dSmrg 10019fda9279dSmrg if test -n "$orig_export_symbols"; then 10020fda9279dSmrg # The given exports_symbols file has to be filtered, so filter it. 1002116ee1e9aSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10022fda9279dSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1002316ee1e9aSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10024fda9279dSmrg # though. Also, the filter scales superlinearly with the number of 10025fda9279dSmrg # global variables. join(1) would be nice here, but unfortunately 10026fda9279dSmrg # isn't a blessed tool. 10027fda9279dSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10028fda9279dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10029fda9279dSmrg export_symbols=$output_objdir/$libname.def 10030fda9279dSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10031fda9279dSmrg fi 1003216ee1e9aSmrg } 10033fda9279dSmrg 10034fda9279dSmrg libobjs=$output 10035fda9279dSmrg # Restore the value of output. 10036fda9279dSmrg output=$save_output 10037fda9279dSmrg 10038fda9279dSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10039fda9279dSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040fda9279dSmrg test "X$libobjs" = "X " && libobjs= 10041fda9279dSmrg fi 10042fda9279dSmrg # Expand the library linking commands again to reset the 10043fda9279dSmrg # value of $libobjs for piecewise linking. 10044fda9279dSmrg 10045fda9279dSmrg # Do each of the archive commands. 1004616ee1e9aSmrg if test yes = "$module" && test -n "$module_cmds"; then 10047fda9279dSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10048fda9279dSmrg cmds=$module_expsym_cmds 10049fda9279dSmrg else 10050fda9279dSmrg cmds=$module_cmds 10051fda9279dSmrg fi 10052fda9279dSmrg else 10053fda9279dSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10054fda9279dSmrg cmds=$archive_expsym_cmds 10055fda9279dSmrg else 10056fda9279dSmrg cmds=$archive_cmds 10057fda9279dSmrg fi 10058fda9279dSmrg fi 10059fda9279dSmrg fi 10060fda9279dSmrg 10061fda9279dSmrg if test -n "$delfiles"; then 10062fda9279dSmrg # Append the command to remove temporary files to $cmds. 10063fda9279dSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 10064fda9279dSmrg fi 10065fda9279dSmrg 10066fda9279dSmrg # Add any objects from preloaded convenience libraries 10067fda9279dSmrg if test -n "$dlprefiles"; then 1006816ee1e9aSmrg gentop=$output_objdir/${outputname}x 10069fda9279dSmrg func_append generated " $gentop" 10070fda9279dSmrg 10071fda9279dSmrg func_extract_archives $gentop $dlprefiles 10072fda9279dSmrg func_append libobjs " $func_extract_archives_result" 10073fda9279dSmrg test "X$libobjs" = "X " && libobjs= 10074fda9279dSmrg fi 10075fda9279dSmrg 1007616ee1e9aSmrg save_ifs=$IFS; IFS='~' 10077fda9279dSmrg for cmd in $cmds; do 1007816ee1e9aSmrg IFS=$sp$nl 10079fda9279dSmrg eval cmd=\"$cmd\" 1008016ee1e9aSmrg IFS=$save_ifs 1008116ee1e9aSmrg $opt_quiet || { 10082fda9279dSmrg func_quote_for_expand "$cmd" 10083fda9279dSmrg eval "func_echo $func_quote_for_expand_result" 10084fda9279dSmrg } 10085fda9279dSmrg $opt_dry_run || eval "$cmd" || { 10086fda9279dSmrg lt_exit=$? 10087fda9279dSmrg 10088fda9279dSmrg # Restore the uninstalled library and exit 1008916ee1e9aSmrg if test relink = "$opt_mode"; then 10090fda9279dSmrg ( cd "$output_objdir" && \ 10091fda9279dSmrg $RM "${realname}T" && \ 10092fda9279dSmrg $MV "${realname}U" "$realname" ) 10093fda9279dSmrg fi 10094fda9279dSmrg 10095fda9279dSmrg exit $lt_exit 10096fda9279dSmrg } 10097fda9279dSmrg done 1009816ee1e9aSmrg IFS=$save_ifs 10099fda9279dSmrg 10100fda9279dSmrg # Restore the uninstalled library and exit 1010116ee1e9aSmrg if test relink = "$opt_mode"; then 10102fda9279dSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10103fda9279dSmrg 10104fda9279dSmrg if test -n "$convenience"; then 10105fda9279dSmrg if test -z "$whole_archive_flag_spec"; then 10106fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10107fda9279dSmrg fi 10108fda9279dSmrg fi 10109fda9279dSmrg 10110fda9279dSmrg exit $EXIT_SUCCESS 10111fda9279dSmrg fi 10112fda9279dSmrg 10113fda9279dSmrg # Create links to the real library. 10114fda9279dSmrg for linkname in $linknames; do 10115fda9279dSmrg if test "$realname" != "$linkname"; then 10116fda9279dSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10117fda9279dSmrg fi 10118fda9279dSmrg done 10119fda9279dSmrg 10120fda9279dSmrg # If -module or -export-dynamic was specified, set the dlname. 1012116ee1e9aSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10122fda9279dSmrg # On all known operating systems, these are identical. 1012316ee1e9aSmrg dlname=$soname 10124fda9279dSmrg fi 10125fda9279dSmrg fi 10126fda9279dSmrg ;; 10127fda9279dSmrg 10128fda9279dSmrg obj) 1012916ee1e9aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1013016ee1e9aSmrg func_warning "'-dlopen' is ignored for objects" 10131fda9279dSmrg fi 10132fda9279dSmrg 10133fda9279dSmrg case " $deplibs" in 10134fda9279dSmrg *\ -l* | *\ -L*) 1013516ee1e9aSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10136fda9279dSmrg esac 10137fda9279dSmrg 10138fda9279dSmrg test -n "$rpath" && \ 1013916ee1e9aSmrg func_warning "'-rpath' is ignored for objects" 10140fda9279dSmrg 10141fda9279dSmrg test -n "$xrpath" && \ 1014216ee1e9aSmrg func_warning "'-R' is ignored for objects" 10143fda9279dSmrg 10144fda9279dSmrg test -n "$vinfo" && \ 1014516ee1e9aSmrg func_warning "'-version-info' is ignored for objects" 10146fda9279dSmrg 10147fda9279dSmrg test -n "$release" && \ 1014816ee1e9aSmrg func_warning "'-release' is ignored for objects" 10149fda9279dSmrg 10150fda9279dSmrg case $output in 10151fda9279dSmrg *.lo) 10152fda9279dSmrg test -n "$objs$old_deplibs" && \ 1015316ee1e9aSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10154fda9279dSmrg 10155fda9279dSmrg libobj=$output 10156fda9279dSmrg func_lo2o "$libobj" 10157fda9279dSmrg obj=$func_lo2o_result 10158fda9279dSmrg ;; 10159fda9279dSmrg *) 10160fda9279dSmrg libobj= 1016116ee1e9aSmrg obj=$output 10162fda9279dSmrg ;; 10163fda9279dSmrg esac 10164fda9279dSmrg 10165fda9279dSmrg # Delete the old objects. 10166fda9279dSmrg $opt_dry_run || $RM $obj $libobj 10167fda9279dSmrg 10168fda9279dSmrg # Objects from convenience libraries. This assumes 10169fda9279dSmrg # single-version convenience libraries. Whenever we create 10170fda9279dSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 10171fda9279dSmrg # the extraction. 10172fda9279dSmrg reload_conv_objs= 10173fda9279dSmrg gentop= 1017416ee1e9aSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 1017516ee1e9aSmrg # whole_archive_flag_spec and hope we can get by with turning comma 1017616ee1e9aSmrg # into space. 1017716ee1e9aSmrg case $reload_cmds in 1017816ee1e9aSmrg *\$LD[\ \$]*) wl= ;; 1017916ee1e9aSmrg esac 10180fda9279dSmrg if test -n "$convenience"; then 10181fda9279dSmrg if test -n "$whole_archive_flag_spec"; then 10182fda9279dSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1018316ee1e9aSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1018416ee1e9aSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10185fda9279dSmrg else 1018616ee1e9aSmrg gentop=$output_objdir/${obj}x 10187fda9279dSmrg func_append generated " $gentop" 10188fda9279dSmrg 10189fda9279dSmrg func_extract_archives $gentop $convenience 10190fda9279dSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10191fda9279dSmrg fi 10192fda9279dSmrg fi 10193fda9279dSmrg 10194fda9279dSmrg # If we're not building shared, we need to use non_pic_objs 1019516ee1e9aSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10196fda9279dSmrg 10197fda9279dSmrg # Create the old-style object. 1019816ee1e9aSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10199fda9279dSmrg 1020016ee1e9aSmrg output=$obj 10201fda9279dSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10202fda9279dSmrg 10203fda9279dSmrg # Exit if we aren't doing a library object file. 10204fda9279dSmrg if test -z "$libobj"; then 10205fda9279dSmrg if test -n "$gentop"; then 10206fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10207fda9279dSmrg fi 10208fda9279dSmrg 10209fda9279dSmrg exit $EXIT_SUCCESS 10210fda9279dSmrg fi 10211fda9279dSmrg 1021216ee1e9aSmrg test yes = "$build_libtool_libs" || { 10213fda9279dSmrg if test -n "$gentop"; then 10214fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10215fda9279dSmrg fi 10216fda9279dSmrg 10217fda9279dSmrg # Create an invalid libtool object if no PIC, so that we don't 10218fda9279dSmrg # accidentally link it into a program. 10219fda9279dSmrg # $show "echo timestamp > $libobj" 10220fda9279dSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10221fda9279dSmrg exit $EXIT_SUCCESS 1022216ee1e9aSmrg } 10223fda9279dSmrg 1022416ee1e9aSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10225fda9279dSmrg # Only do commands if we really have different PIC objects. 10226fda9279dSmrg reload_objs="$libobjs $reload_conv_objs" 1022716ee1e9aSmrg output=$libobj 10228fda9279dSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10229fda9279dSmrg fi 10230fda9279dSmrg 10231fda9279dSmrg if test -n "$gentop"; then 10232fda9279dSmrg func_show_eval '${RM}r "$gentop"' 10233fda9279dSmrg fi 10234fda9279dSmrg 10235fda9279dSmrg exit $EXIT_SUCCESS 10236fda9279dSmrg ;; 10237fda9279dSmrg 10238fda9279dSmrg prog) 10239fda9279dSmrg case $host in 10240fda9279dSmrg *cygwin*) func_stripname '' '.exe' "$output" 10241fda9279dSmrg output=$func_stripname_result.exe;; 10242fda9279dSmrg esac 10243fda9279dSmrg test -n "$vinfo" && \ 1024416ee1e9aSmrg func_warning "'-version-info' is ignored for programs" 10245fda9279dSmrg 10246fda9279dSmrg test -n "$release" && \ 1024716ee1e9aSmrg func_warning "'-release' is ignored for programs" 10248fda9279dSmrg 1024916ee1e9aSmrg $preload \ 1025016ee1e9aSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1025116ee1e9aSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10252fda9279dSmrg 10253fda9279dSmrg case $host in 10254fda9279dSmrg *-*-rhapsody* | *-*-darwin1.[012]) 10255fda9279dSmrg # On Rhapsody replace the C library is the System framework 10256fda9279dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10257fda9279dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10258fda9279dSmrg ;; 10259fda9279dSmrg esac 10260fda9279dSmrg 10261fda9279dSmrg case $host in 10262fda9279dSmrg *-*-darwin*) 10263fda9279dSmrg # Don't allow lazy linking, it breaks C++ global constructors 10264fda9279dSmrg # But is supposedly fixed on 10.4 or later (yay!). 1026516ee1e9aSmrg if test CXX = "$tagname"; then 10266fda9279dSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10267fda9279dSmrg 10.[0123]) 1026816ee1e9aSmrg func_append compile_command " $wl-bind_at_load" 1026916ee1e9aSmrg func_append finalize_command " $wl-bind_at_load" 10270fda9279dSmrg ;; 10271fda9279dSmrg esac 10272fda9279dSmrg fi 10273fda9279dSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10274fda9279dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10275fda9279dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10276fda9279dSmrg ;; 10277fda9279dSmrg esac 10278fda9279dSmrg 10279fda9279dSmrg 10280fda9279dSmrg # move library search paths that coincide with paths to not yet 10281fda9279dSmrg # installed libraries to the beginning of the library search list 10282fda9279dSmrg new_libs= 10283fda9279dSmrg for path in $notinst_path; do 10284fda9279dSmrg case " $new_libs " in 10285fda9279dSmrg *" -L$path/$objdir "*) ;; 10286fda9279dSmrg *) 10287fda9279dSmrg case " $compile_deplibs " in 10288fda9279dSmrg *" -L$path/$objdir "*) 10289fda9279dSmrg func_append new_libs " -L$path/$objdir" ;; 10290fda9279dSmrg esac 10291fda9279dSmrg ;; 10292fda9279dSmrg esac 10293fda9279dSmrg done 10294fda9279dSmrg for deplib in $compile_deplibs; do 10295fda9279dSmrg case $deplib in 10296fda9279dSmrg -L*) 10297fda9279dSmrg case " $new_libs " in 10298fda9279dSmrg *" $deplib "*) ;; 10299fda9279dSmrg *) func_append new_libs " $deplib" ;; 10300fda9279dSmrg esac 10301fda9279dSmrg ;; 10302fda9279dSmrg *) func_append new_libs " $deplib" ;; 10303fda9279dSmrg esac 10304fda9279dSmrg done 1030516ee1e9aSmrg compile_deplibs=$new_libs 10306fda9279dSmrg 10307fda9279dSmrg 10308fda9279dSmrg func_append compile_command " $compile_deplibs" 10309fda9279dSmrg func_append finalize_command " $finalize_deplibs" 10310fda9279dSmrg 10311fda9279dSmrg if test -n "$rpath$xrpath"; then 10312fda9279dSmrg # If the user specified any rpath flags, then add them. 10313fda9279dSmrg for libdir in $rpath $xrpath; do 10314fda9279dSmrg # This is the magic to use -rpath. 10315fda9279dSmrg case "$finalize_rpath " in 10316fda9279dSmrg *" $libdir "*) ;; 10317fda9279dSmrg *) func_append finalize_rpath " $libdir" ;; 10318fda9279dSmrg esac 10319fda9279dSmrg done 10320fda9279dSmrg fi 10321fda9279dSmrg 10322fda9279dSmrg # Now hardcode the library paths 10323fda9279dSmrg rpath= 10324fda9279dSmrg hardcode_libdirs= 10325fda9279dSmrg for libdir in $compile_rpath $finalize_rpath; do 10326fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 10327fda9279dSmrg if test -n "$hardcode_libdir_separator"; then 10328fda9279dSmrg if test -z "$hardcode_libdirs"; then 1032916ee1e9aSmrg hardcode_libdirs=$libdir 10330fda9279dSmrg else 10331fda9279dSmrg # Just accumulate the unique libdirs. 10332fda9279dSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10333fda9279dSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10334fda9279dSmrg ;; 10335fda9279dSmrg *) 10336fda9279dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10337fda9279dSmrg ;; 10338fda9279dSmrg esac 10339fda9279dSmrg fi 10340fda9279dSmrg else 10341fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10342fda9279dSmrg func_append rpath " $flag" 10343fda9279dSmrg fi 10344fda9279dSmrg elif test -n "$runpath_var"; then 10345fda9279dSmrg case "$perm_rpath " in 10346fda9279dSmrg *" $libdir "*) ;; 10347fda9279dSmrg *) func_append perm_rpath " $libdir" ;; 10348fda9279dSmrg esac 10349fda9279dSmrg fi 10350fda9279dSmrg case $host in 10351fda9279dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1035216ee1e9aSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10353fda9279dSmrg case :$dllsearchpath: in 10354fda9279dSmrg *":$libdir:"*) ;; 10355fda9279dSmrg ::) dllsearchpath=$libdir;; 10356fda9279dSmrg *) func_append dllsearchpath ":$libdir";; 10357fda9279dSmrg esac 10358fda9279dSmrg case :$dllsearchpath: in 10359fda9279dSmrg *":$testbindir:"*) ;; 10360fda9279dSmrg ::) dllsearchpath=$testbindir;; 10361fda9279dSmrg *) func_append dllsearchpath ":$testbindir";; 10362fda9279dSmrg esac 10363fda9279dSmrg ;; 10364fda9279dSmrg esac 10365fda9279dSmrg done 10366fda9279dSmrg # Substitute the hardcoded libdirs into the rpath. 10367fda9279dSmrg if test -n "$hardcode_libdir_separator" && 10368fda9279dSmrg test -n "$hardcode_libdirs"; then 1036916ee1e9aSmrg libdir=$hardcode_libdirs 10370fda9279dSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10371fda9279dSmrg fi 1037216ee1e9aSmrg compile_rpath=$rpath 10373fda9279dSmrg 10374fda9279dSmrg rpath= 10375fda9279dSmrg hardcode_libdirs= 10376fda9279dSmrg for libdir in $finalize_rpath; do 10377fda9279dSmrg if test -n "$hardcode_libdir_flag_spec"; then 10378fda9279dSmrg if test -n "$hardcode_libdir_separator"; then 10379fda9279dSmrg if test -z "$hardcode_libdirs"; then 1038016ee1e9aSmrg hardcode_libdirs=$libdir 10381fda9279dSmrg else 10382fda9279dSmrg # Just accumulate the unique libdirs. 10383fda9279dSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10384fda9279dSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10385fda9279dSmrg ;; 10386fda9279dSmrg *) 10387fda9279dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10388fda9279dSmrg ;; 10389fda9279dSmrg esac 10390fda9279dSmrg fi 10391fda9279dSmrg else 10392fda9279dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10393fda9279dSmrg func_append rpath " $flag" 10394fda9279dSmrg fi 10395fda9279dSmrg elif test -n "$runpath_var"; then 10396fda9279dSmrg case "$finalize_perm_rpath " in 10397fda9279dSmrg *" $libdir "*) ;; 10398fda9279dSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10399fda9279dSmrg esac 10400fda9279dSmrg fi 10401fda9279dSmrg done 10402fda9279dSmrg # Substitute the hardcoded libdirs into the rpath. 10403fda9279dSmrg if test -n "$hardcode_libdir_separator" && 10404fda9279dSmrg test -n "$hardcode_libdirs"; then 1040516ee1e9aSmrg libdir=$hardcode_libdirs 10406fda9279dSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10407fda9279dSmrg fi 1040816ee1e9aSmrg finalize_rpath=$rpath 10409fda9279dSmrg 1041016ee1e9aSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10411fda9279dSmrg # Transform all the library objects into standard objects. 10412fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10413fda9279dSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10414fda9279dSmrg fi 10415fda9279dSmrg 1041616ee1e9aSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10417fda9279dSmrg 10418fda9279dSmrg # template prelinking step 10419fda9279dSmrg if test -n "$prelink_cmds"; then 10420fda9279dSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 10421fda9279dSmrg fi 10422fda9279dSmrg 1042316ee1e9aSmrg wrappers_required=: 10424fda9279dSmrg case $host in 10425fda9279dSmrg *cegcc* | *mingw32ce*) 10426fda9279dSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1042716ee1e9aSmrg wrappers_required=false 10428fda9279dSmrg ;; 10429fda9279dSmrg *cygwin* | *mingw* ) 1043016ee1e9aSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10431fda9279dSmrg ;; 10432fda9279dSmrg *) 1043316ee1e9aSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1043416ee1e9aSmrg wrappers_required=false 10435fda9279dSmrg fi 10436fda9279dSmrg ;; 10437fda9279dSmrg esac 1043816ee1e9aSmrg $wrappers_required || { 10439fda9279dSmrg # Replace the output file specification. 10440fda9279dSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1044116ee1e9aSmrg link_command=$compile_command$compile_rpath 10442fda9279dSmrg 10443fda9279dSmrg # We have no uninstalled library dependencies, so finalize right now. 10444fda9279dSmrg exit_status=0 10445fda9279dSmrg func_show_eval "$link_command" 'exit_status=$?' 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 # Delete the generated files. 1045416ee1e9aSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 1045516ee1e9aSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10456fda9279dSmrg fi 10457fda9279dSmrg 10458fda9279dSmrg exit $exit_status 1045916ee1e9aSmrg } 10460fda9279dSmrg 10461fda9279dSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10462fda9279dSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10463fda9279dSmrg fi 10464fda9279dSmrg if test -n "$finalize_shlibpath"; then 10465fda9279dSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10466fda9279dSmrg fi 10467fda9279dSmrg 10468fda9279dSmrg compile_var= 10469fda9279dSmrg finalize_var= 10470fda9279dSmrg if test -n "$runpath_var"; then 10471fda9279dSmrg if test -n "$perm_rpath"; then 10472fda9279dSmrg # We should set the runpath_var. 10473fda9279dSmrg rpath= 10474fda9279dSmrg for dir in $perm_rpath; do 10475fda9279dSmrg func_append rpath "$dir:" 10476fda9279dSmrg done 10477fda9279dSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10478fda9279dSmrg fi 10479fda9279dSmrg if test -n "$finalize_perm_rpath"; then 10480fda9279dSmrg # We should set the runpath_var. 10481fda9279dSmrg rpath= 10482fda9279dSmrg for dir in $finalize_perm_rpath; do 10483fda9279dSmrg func_append rpath "$dir:" 10484fda9279dSmrg done 10485fda9279dSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10486fda9279dSmrg fi 10487fda9279dSmrg fi 10488fda9279dSmrg 1048916ee1e9aSmrg if test yes = "$no_install"; then 10490fda9279dSmrg # We don't need to create a wrapper script. 1049116ee1e9aSmrg link_command=$compile_var$compile_command$compile_rpath 10492fda9279dSmrg # Replace the output file specification. 10493fda9279dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10494fda9279dSmrg # Delete the old output file. 10495fda9279dSmrg $opt_dry_run || $RM $output 10496fda9279dSmrg # Link the executable and exit 10497fda9279dSmrg func_show_eval "$link_command" 'exit $?' 10498fda9279dSmrg 10499fda9279dSmrg if test -n "$postlink_cmds"; then 10500fda9279dSmrg func_to_tool_file "$output" 10501fda9279dSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10502fda9279dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10503fda9279dSmrg fi 10504fda9279dSmrg 10505fda9279dSmrg exit $EXIT_SUCCESS 10506fda9279dSmrg fi 10507fda9279dSmrg 1050816ee1e9aSmrg case $hardcode_action,$fast_install in 1050916ee1e9aSmrg relink,*) 1051016ee1e9aSmrg # Fast installation is not supported 1051116ee1e9aSmrg link_command=$compile_var$compile_command$compile_rpath 1051216ee1e9aSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10513fda9279dSmrg 1051416ee1e9aSmrg func_warning "this platform does not like uninstalled shared libraries" 1051516ee1e9aSmrg func_warning "'$output' will be relinked during installation" 1051616ee1e9aSmrg ;; 1051716ee1e9aSmrg *,yes) 1051816ee1e9aSmrg link_command=$finalize_var$compile_command$finalize_rpath 1051916ee1e9aSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1052016ee1e9aSmrg ;; 1052116ee1e9aSmrg *,no) 1052216ee1e9aSmrg link_command=$compile_var$compile_command$compile_rpath 1052316ee1e9aSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1052416ee1e9aSmrg ;; 1052516ee1e9aSmrg *,needless) 1052616ee1e9aSmrg link_command=$finalize_var$compile_command$finalize_rpath 1052716ee1e9aSmrg relink_command= 1052816ee1e9aSmrg ;; 1052916ee1e9aSmrg esac 10530fda9279dSmrg 10531fda9279dSmrg # Replace the output file specification. 10532fda9279dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10533fda9279dSmrg 10534fda9279dSmrg # Delete the old output files. 10535fda9279dSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10536fda9279dSmrg 10537fda9279dSmrg func_show_eval "$link_command" 'exit $?' 10538fda9279dSmrg 10539fda9279dSmrg if test -n "$postlink_cmds"; then 10540fda9279dSmrg func_to_tool_file "$output_objdir/$outputname" 10541fda9279dSmrg 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'` 10542fda9279dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10543fda9279dSmrg fi 10544fda9279dSmrg 10545fda9279dSmrg # Now create the wrapper script. 10546fda9279dSmrg func_verbose "creating $output" 10547fda9279dSmrg 10548fda9279dSmrg # Quote the relink command for shipping. 10549fda9279dSmrg if test -n "$relink_command"; then 10550fda9279dSmrg # Preserve any variables that may affect compiler behavior 10551fda9279dSmrg for var in $variables_saved_for_relink; do 10552fda9279dSmrg if eval test -z \"\${$var+set}\"; then 10553fda9279dSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10554fda9279dSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10555fda9279dSmrg relink_command="$var=; export $var; $relink_command" 10556fda9279dSmrg else 10557fda9279dSmrg func_quote_for_eval "$var_value" 10558fda9279dSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10559fda9279dSmrg fi 10560fda9279dSmrg done 10561dd52494dSmrg func_quote "(cd `pwd`; $relink_command)" 10562dd52494dSmrg relink_command=$func_quote_result 10563fda9279dSmrg fi 10564fda9279dSmrg 10565fda9279dSmrg # Only actually do things if not in dry run mode. 10566fda9279dSmrg $opt_dry_run || { 10567fda9279dSmrg # win32 will think the script is a binary if it has 10568fda9279dSmrg # a .exe suffix, so we strip it off here. 10569fda9279dSmrg case $output in 10570fda9279dSmrg *.exe) func_stripname '' '.exe' "$output" 10571fda9279dSmrg output=$func_stripname_result ;; 10572fda9279dSmrg esac 10573fda9279dSmrg # test for cygwin because mv fails w/o .exe extensions 10574fda9279dSmrg case $host in 10575fda9279dSmrg *cygwin*) 10576fda9279dSmrg exeext=.exe 10577fda9279dSmrg func_stripname '' '.exe' "$outputname" 10578fda9279dSmrg outputname=$func_stripname_result ;; 10579fda9279dSmrg *) exeext= ;; 10580fda9279dSmrg esac 10581fda9279dSmrg case $host in 10582fda9279dSmrg *cygwin* | *mingw* ) 10583fda9279dSmrg func_dirname_and_basename "$output" "" "." 10584fda9279dSmrg output_name=$func_basename_result 10585fda9279dSmrg output_path=$func_dirname_result 1058616ee1e9aSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1058716ee1e9aSmrg cwrapper=$output_path/$output_name.exe 10588fda9279dSmrg $RM $cwrappersource $cwrapper 10589fda9279dSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10590fda9279dSmrg 10591fda9279dSmrg func_emit_cwrapperexe_src > $cwrappersource 10592fda9279dSmrg 10593fda9279dSmrg # The wrapper executable is built using the $host compiler, 10594fda9279dSmrg # because it contains $host paths and files. If cross- 10595fda9279dSmrg # compiling, it, like the target executable, must be 10596fda9279dSmrg # executed on the $host or under an emulation environment. 10597fda9279dSmrg $opt_dry_run || { 10598fda9279dSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10599fda9279dSmrg $STRIP $cwrapper 10600fda9279dSmrg } 10601fda9279dSmrg 10602fda9279dSmrg # Now, create the wrapper script for func_source use: 10603fda9279dSmrg func_ltwrapper_scriptname $cwrapper 10604fda9279dSmrg $RM $func_ltwrapper_scriptname_result 10605fda9279dSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10606fda9279dSmrg $opt_dry_run || { 10607fda9279dSmrg # note: this script will not be executed, so do not chmod. 1060816ee1e9aSmrg if test "x$build" = "x$host"; then 10609fda9279dSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10610fda9279dSmrg else 10611fda9279dSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10612fda9279dSmrg fi 10613fda9279dSmrg } 10614fda9279dSmrg ;; 10615fda9279dSmrg * ) 10616fda9279dSmrg $RM $output 10617fda9279dSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10618fda9279dSmrg 10619fda9279dSmrg func_emit_wrapper no > $output 10620fda9279dSmrg chmod +x $output 10621fda9279dSmrg ;; 10622fda9279dSmrg esac 10623fda9279dSmrg } 10624fda9279dSmrg exit $EXIT_SUCCESS 10625fda9279dSmrg ;; 10626fda9279dSmrg esac 10627fda9279dSmrg 10628fda9279dSmrg # See if we need to build an old-fashioned archive. 10629fda9279dSmrg for oldlib in $oldlibs; do 10630fda9279dSmrg 1063116ee1e9aSmrg case $build_libtool_libs in 1063216ee1e9aSmrg convenience) 1063316ee1e9aSmrg oldobjs="$libobjs_save $symfileobj" 1063416ee1e9aSmrg addlibs=$convenience 10635fda9279dSmrg build_libtool_libs=no 1063616ee1e9aSmrg ;; 1063716ee1e9aSmrg module) 1063816ee1e9aSmrg oldobjs=$libobjs_save 1063916ee1e9aSmrg addlibs=$old_convenience 1064016ee1e9aSmrg build_libtool_libs=no 1064116ee1e9aSmrg ;; 1064216ee1e9aSmrg *) 10643fda9279dSmrg oldobjs="$old_deplibs $non_pic_objects" 1064416ee1e9aSmrg $preload && test -f "$symfileobj" \ 1064516ee1e9aSmrg && func_append oldobjs " $symfileobj" 1064616ee1e9aSmrg addlibs=$old_convenience 1064716ee1e9aSmrg ;; 1064816ee1e9aSmrg esac 10649fda9279dSmrg 10650fda9279dSmrg if test -n "$addlibs"; then 1065116ee1e9aSmrg gentop=$output_objdir/${outputname}x 10652fda9279dSmrg func_append generated " $gentop" 10653fda9279dSmrg 10654fda9279dSmrg func_extract_archives $gentop $addlibs 10655fda9279dSmrg func_append oldobjs " $func_extract_archives_result" 10656fda9279dSmrg fi 10657fda9279dSmrg 10658fda9279dSmrg # Do each command in the archive commands. 1065916ee1e9aSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10660fda9279dSmrg cmds=$old_archive_from_new_cmds 10661fda9279dSmrg else 10662fda9279dSmrg 10663fda9279dSmrg # Add any objects from preloaded convenience libraries 10664fda9279dSmrg if test -n "$dlprefiles"; then 1066516ee1e9aSmrg gentop=$output_objdir/${outputname}x 10666fda9279dSmrg func_append generated " $gentop" 10667fda9279dSmrg 10668fda9279dSmrg func_extract_archives $gentop $dlprefiles 10669fda9279dSmrg func_append oldobjs " $func_extract_archives_result" 10670fda9279dSmrg fi 10671fda9279dSmrg 10672fda9279dSmrg # POSIX demands no paths to be encoded in archives. We have 10673fda9279dSmrg # to avoid creating archives with duplicate basenames if we 10674fda9279dSmrg # might have to extract them afterwards, e.g., when creating a 10675fda9279dSmrg # static archive out of a convenience library, or when linking 10676fda9279dSmrg # the entirety of a libtool archive into another (currently 10677fda9279dSmrg # not supported by libtool). 10678fda9279dSmrg if (for obj in $oldobjs 10679fda9279dSmrg do 10680fda9279dSmrg func_basename "$obj" 10681fda9279dSmrg $ECHO "$func_basename_result" 10682fda9279dSmrg done | sort | sort -uc >/dev/null 2>&1); then 10683fda9279dSmrg : 10684fda9279dSmrg else 10685fda9279dSmrg echo "copying selected object files to avoid basename conflicts..." 1068616ee1e9aSmrg gentop=$output_objdir/${outputname}x 10687fda9279dSmrg func_append generated " $gentop" 10688fda9279dSmrg func_mkdir_p "$gentop" 10689fda9279dSmrg save_oldobjs=$oldobjs 10690fda9279dSmrg oldobjs= 10691fda9279dSmrg counter=1 10692fda9279dSmrg for obj in $save_oldobjs 10693fda9279dSmrg do 10694fda9279dSmrg func_basename "$obj" 1069516ee1e9aSmrg objbase=$func_basename_result 10696fda9279dSmrg case " $oldobjs " in 10697fda9279dSmrg " ") oldobjs=$obj ;; 10698fda9279dSmrg *[\ /]"$objbase "*) 10699fda9279dSmrg while :; do 10700fda9279dSmrg # Make sure we don't pick an alternate name that also 10701fda9279dSmrg # overlaps. 10702fda9279dSmrg newobj=lt$counter-$objbase 10703fda9279dSmrg func_arith $counter + 1 10704fda9279dSmrg counter=$func_arith_result 10705fda9279dSmrg case " $oldobjs " in 10706fda9279dSmrg *[\ /]"$newobj "*) ;; 10707fda9279dSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10708fda9279dSmrg esac 10709fda9279dSmrg done 10710fda9279dSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10711fda9279dSmrg func_append oldobjs " $gentop/$newobj" 10712fda9279dSmrg ;; 10713fda9279dSmrg *) func_append oldobjs " $obj" ;; 10714fda9279dSmrg esac 10715fda9279dSmrg done 10716fda9279dSmrg fi 10717fda9279dSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10718fda9279dSmrg tool_oldlib=$func_to_tool_file_result 10719fda9279dSmrg eval cmds=\"$old_archive_cmds\" 10720fda9279dSmrg 10721fda9279dSmrg func_len " $cmds" 10722fda9279dSmrg len=$func_len_result 10723fda9279dSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10724fda9279dSmrg cmds=$old_archive_cmds 10725fda9279dSmrg elif test -n "$archiver_list_spec"; then 10726fda9279dSmrg func_verbose "using command file archive linking..." 10727fda9279dSmrg for obj in $oldobjs 10728fda9279dSmrg do 10729fda9279dSmrg func_to_tool_file "$obj" 10730fda9279dSmrg $ECHO "$func_to_tool_file_result" 10731fda9279dSmrg done > $output_objdir/$libname.libcmd 10732fda9279dSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10733fda9279dSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10734fda9279dSmrg cmds=$old_archive_cmds 10735fda9279dSmrg else 10736fda9279dSmrg # the command line is too long to link in one step, link in parts 10737fda9279dSmrg func_verbose "using piecewise archive linking..." 10738fda9279dSmrg save_RANLIB=$RANLIB 10739fda9279dSmrg RANLIB=: 10740fda9279dSmrg objlist= 10741fda9279dSmrg concat_cmds= 10742fda9279dSmrg save_oldobjs=$oldobjs 10743fda9279dSmrg oldobjs= 10744fda9279dSmrg # Is there a better way of finding the last object in the list? 10745fda9279dSmrg for obj in $save_oldobjs 10746fda9279dSmrg do 10747fda9279dSmrg last_oldobj=$obj 10748fda9279dSmrg done 10749fda9279dSmrg eval test_cmds=\"$old_archive_cmds\" 10750fda9279dSmrg func_len " $test_cmds" 10751fda9279dSmrg len0=$func_len_result 10752fda9279dSmrg len=$len0 10753fda9279dSmrg for obj in $save_oldobjs 10754fda9279dSmrg do 10755fda9279dSmrg func_len " $obj" 10756fda9279dSmrg func_arith $len + $func_len_result 10757fda9279dSmrg len=$func_arith_result 10758fda9279dSmrg func_append objlist " $obj" 10759fda9279dSmrg if test "$len" -lt "$max_cmd_len"; then 10760fda9279dSmrg : 10761fda9279dSmrg else 10762fda9279dSmrg # the above command should be used before it gets too long 10763fda9279dSmrg oldobjs=$objlist 1076416ee1e9aSmrg if test "$obj" = "$last_oldobj"; then 10765fda9279dSmrg RANLIB=$save_RANLIB 10766fda9279dSmrg fi 10767fda9279dSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1076816ee1e9aSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10769fda9279dSmrg objlist= 10770fda9279dSmrg len=$len0 10771fda9279dSmrg fi 10772fda9279dSmrg done 10773fda9279dSmrg RANLIB=$save_RANLIB 10774fda9279dSmrg oldobjs=$objlist 1077516ee1e9aSmrg if test -z "$oldobjs"; then 10776fda9279dSmrg eval cmds=\"\$concat_cmds\" 10777fda9279dSmrg else 10778fda9279dSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10779fda9279dSmrg fi 10780fda9279dSmrg fi 10781fda9279dSmrg fi 10782fda9279dSmrg func_execute_cmds "$cmds" 'exit $?' 10783fda9279dSmrg done 10784fda9279dSmrg 10785fda9279dSmrg test -n "$generated" && \ 10786fda9279dSmrg func_show_eval "${RM}r$generated" 10787fda9279dSmrg 10788fda9279dSmrg # Now create the libtool archive. 10789fda9279dSmrg case $output in 10790fda9279dSmrg *.la) 10791fda9279dSmrg old_library= 1079216ee1e9aSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10793fda9279dSmrg func_verbose "creating $output" 10794fda9279dSmrg 10795fda9279dSmrg # Preserve any variables that may affect compiler behavior 10796fda9279dSmrg for var in $variables_saved_for_relink; do 10797fda9279dSmrg if eval test -z \"\${$var+set}\"; then 10798fda9279dSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10799fda9279dSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10800fda9279dSmrg relink_command="$var=; export $var; $relink_command" 10801fda9279dSmrg else 10802fda9279dSmrg func_quote_for_eval "$var_value" 10803fda9279dSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10804fda9279dSmrg fi 10805fda9279dSmrg done 10806fda9279dSmrg # Quote the link command for shipping. 1080716ee1e9aSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10808dd52494dSmrg func_quote "$relink_command" 10809dd52494dSmrg relink_command=$func_quote_result 1081016ee1e9aSmrg if test yes = "$hardcode_automatic"; then 10811fda9279dSmrg relink_command= 10812fda9279dSmrg fi 10813fda9279dSmrg 10814fda9279dSmrg # Only create the output if not a dry run. 10815fda9279dSmrg $opt_dry_run || { 10816fda9279dSmrg for installed in no yes; do 1081716ee1e9aSmrg if test yes = "$installed"; then 10818fda9279dSmrg if test -z "$install_libdir"; then 10819fda9279dSmrg break 10820fda9279dSmrg fi 1082116ee1e9aSmrg output=$output_objdir/${outputname}i 10822fda9279dSmrg # Replace all uninstalled libtool libraries with the installed ones 10823fda9279dSmrg newdependency_libs= 10824fda9279dSmrg for deplib in $dependency_libs; do 10825fda9279dSmrg case $deplib in 10826fda9279dSmrg *.la) 10827fda9279dSmrg func_basename "$deplib" 1082816ee1e9aSmrg name=$func_basename_result 10829fda9279dSmrg func_resolve_sysroot "$deplib" 1083016ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10831fda9279dSmrg test -z "$libdir" && \ 1083216ee1e9aSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 10833fda9279dSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10834fda9279dSmrg ;; 10835fda9279dSmrg -L*) 10836fda9279dSmrg func_stripname -L '' "$deplib" 10837fda9279dSmrg func_replace_sysroot "$func_stripname_result" 10838fda9279dSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10839fda9279dSmrg ;; 10840fda9279dSmrg -R*) 10841fda9279dSmrg func_stripname -R '' "$deplib" 10842fda9279dSmrg func_replace_sysroot "$func_stripname_result" 10843fda9279dSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10844fda9279dSmrg ;; 10845fda9279dSmrg *) func_append newdependency_libs " $deplib" ;; 10846fda9279dSmrg esac 10847fda9279dSmrg done 1084816ee1e9aSmrg dependency_libs=$newdependency_libs 10849fda9279dSmrg newdlfiles= 10850fda9279dSmrg 10851fda9279dSmrg for lib in $dlfiles; do 10852fda9279dSmrg case $lib in 10853fda9279dSmrg *.la) 10854fda9279dSmrg func_basename "$lib" 1085516ee1e9aSmrg name=$func_basename_result 1085616ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10857fda9279dSmrg test -z "$libdir" && \ 1085816ee1e9aSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10859fda9279dSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10860fda9279dSmrg ;; 10861fda9279dSmrg *) func_append newdlfiles " $lib" ;; 10862fda9279dSmrg esac 10863fda9279dSmrg done 1086416ee1e9aSmrg dlfiles=$newdlfiles 10865fda9279dSmrg newdlprefiles= 10866fda9279dSmrg for lib in $dlprefiles; do 10867fda9279dSmrg case $lib in 10868fda9279dSmrg *.la) 10869fda9279dSmrg # Only pass preopened files to the pseudo-archive (for 10870fda9279dSmrg # eventual linking with the app. that links it) if we 10871fda9279dSmrg # didn't already link the preopened objects directly into 10872fda9279dSmrg # the library: 10873fda9279dSmrg func_basename "$lib" 1087416ee1e9aSmrg name=$func_basename_result 1087516ee1e9aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10876fda9279dSmrg test -z "$libdir" && \ 1087716ee1e9aSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10878fda9279dSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10879fda9279dSmrg ;; 10880fda9279dSmrg esac 10881fda9279dSmrg done 1088216ee1e9aSmrg dlprefiles=$newdlprefiles 10883fda9279dSmrg else 10884fda9279dSmrg newdlfiles= 10885fda9279dSmrg for lib in $dlfiles; do 10886fda9279dSmrg case $lib in 1088716ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10888fda9279dSmrg *) abs=`pwd`"/$lib" ;; 10889fda9279dSmrg esac 10890fda9279dSmrg func_append newdlfiles " $abs" 10891fda9279dSmrg done 1089216ee1e9aSmrg dlfiles=$newdlfiles 10893fda9279dSmrg newdlprefiles= 10894fda9279dSmrg for lib in $dlprefiles; do 10895fda9279dSmrg case $lib in 1089616ee1e9aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10897fda9279dSmrg *) abs=`pwd`"/$lib" ;; 10898fda9279dSmrg esac 10899fda9279dSmrg func_append newdlprefiles " $abs" 10900fda9279dSmrg done 1090116ee1e9aSmrg dlprefiles=$newdlprefiles 10902fda9279dSmrg fi 10903fda9279dSmrg $RM $output 10904fda9279dSmrg # place dlname in correct position for cygwin 10905fda9279dSmrg # In fact, it would be nice if we could use this code for all target 10906fda9279dSmrg # systems that can't hard-code library paths into their executables 10907fda9279dSmrg # and that have no shared library path variable independent of PATH, 10908fda9279dSmrg # but it turns out we can't easily determine that from inspecting 10909fda9279dSmrg # libtool variables, so we have to hard-code the OSs to which it 10910fda9279dSmrg # applies here; at the moment, that means platforms that use the PE 10911fda9279dSmrg # object format with DLL files. See the long comment at the top of 10912fda9279dSmrg # tests/bindir.at for full details. 10913fda9279dSmrg tdlname=$dlname 10914fda9279dSmrg case $host,$output,$installed,$module,$dlname in 10915fda9279dSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10916fda9279dSmrg # If a -bindir argument was supplied, place the dll there. 1091716ee1e9aSmrg if test -n "$bindir"; then 10918fda9279dSmrg func_relative_path "$install_libdir" "$bindir" 1091916ee1e9aSmrg tdlname=$func_relative_path_result/$dlname 10920fda9279dSmrg else 10921fda9279dSmrg # Otherwise fall back on heuristic. 10922fda9279dSmrg tdlname=../bin/$dlname 10923fda9279dSmrg fi 10924fda9279dSmrg ;; 10925fda9279dSmrg esac 10926fda9279dSmrg $ECHO > $output "\ 10927fda9279dSmrg# $outputname - a libtool library file 1092816ee1e9aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10929fda9279dSmrg# 10930fda9279dSmrg# Please DO NOT delete this file! 10931fda9279dSmrg# It is necessary for linking the library. 10932fda9279dSmrg 10933fda9279dSmrg# The name that we can dlopen(3). 10934fda9279dSmrgdlname='$tdlname' 10935fda9279dSmrg 10936fda9279dSmrg# Names of this library. 10937fda9279dSmrglibrary_names='$library_names' 10938fda9279dSmrg 10939fda9279dSmrg# The name of the static archive. 10940fda9279dSmrgold_library='$old_library' 10941fda9279dSmrg 1094216ee1e9aSmrg# Linker flags that cannot go in dependency_libs. 10943fda9279dSmrginherited_linker_flags='$new_inherited_linker_flags' 10944fda9279dSmrg 10945fda9279dSmrg# Libraries that this one depends upon. 10946fda9279dSmrgdependency_libs='$dependency_libs' 10947fda9279dSmrg 10948fda9279dSmrg# Names of additional weak libraries provided by this library 10949fda9279dSmrgweak_library_names='$weak_libs' 10950fda9279dSmrg 10951fda9279dSmrg# Version information for $libname. 10952fda9279dSmrgcurrent=$current 10953fda9279dSmrgage=$age 10954fda9279dSmrgrevision=$revision 10955fda9279dSmrg 10956fda9279dSmrg# Is this an already installed library? 10957fda9279dSmrginstalled=$installed 10958fda9279dSmrg 10959fda9279dSmrg# Should we warn about portability when linking against -modules? 10960fda9279dSmrgshouldnotlink=$module 10961fda9279dSmrg 10962fda9279dSmrg# Files to dlopen/dlpreopen 10963fda9279dSmrgdlopen='$dlfiles' 10964fda9279dSmrgdlpreopen='$dlprefiles' 10965fda9279dSmrg 10966fda9279dSmrg# Directory that this library needs to be installed in: 10967fda9279dSmrglibdir='$install_libdir'" 1096816ee1e9aSmrg if test no,yes = "$installed,$need_relink"; then 10969fda9279dSmrg $ECHO >> $output "\ 10970fda9279dSmrgrelink_command=\"$relink_command\"" 10971fda9279dSmrg fi 10972fda9279dSmrg done 10973fda9279dSmrg } 10974fda9279dSmrg 10975fda9279dSmrg # Do a symbolic link so that the libtool archive can be found in 10976fda9279dSmrg # LD_LIBRARY_PATH before the program is installed. 10977fda9279dSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10978fda9279dSmrg ;; 10979fda9279dSmrg esac 10980fda9279dSmrg exit $EXIT_SUCCESS 10981fda9279dSmrg} 10982fda9279dSmrg 1098316ee1e9aSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1098416ee1e9aSmrg func_mode_link ${1+"$@"} 1098516ee1e9aSmrgfi 10986fda9279dSmrg 10987fda9279dSmrg 10988fda9279dSmrg# func_mode_uninstall arg... 10989fda9279dSmrgfunc_mode_uninstall () 10990fda9279dSmrg{ 1099116ee1e9aSmrg $debug_cmd 1099216ee1e9aSmrg 1099316ee1e9aSmrg RM=$nonopt 10994fda9279dSmrg files= 1099516ee1e9aSmrg rmforce=false 10996fda9279dSmrg exit_status=0 10997fda9279dSmrg 10998fda9279dSmrg # This variable tells wrapper scripts just to set variables rather 10999fda9279dSmrg # than running their programs. 1100016ee1e9aSmrg libtool_install_magic=$magic 11001fda9279dSmrg 11002fda9279dSmrg for arg 11003fda9279dSmrg do 11004fda9279dSmrg case $arg in 1100516ee1e9aSmrg -f) func_append RM " $arg"; rmforce=: ;; 11006fda9279dSmrg -*) func_append RM " $arg" ;; 11007fda9279dSmrg *) func_append files " $arg" ;; 11008fda9279dSmrg esac 11009fda9279dSmrg done 11010fda9279dSmrg 11011fda9279dSmrg test -z "$RM" && \ 11012fda9279dSmrg func_fatal_help "you must specify an RM program" 11013fda9279dSmrg 11014fda9279dSmrg rmdirs= 11015fda9279dSmrg 11016fda9279dSmrg for file in $files; do 11017fda9279dSmrg func_dirname "$file" "" "." 1101816ee1e9aSmrg dir=$func_dirname_result 1101916ee1e9aSmrg if test . = "$dir"; then 1102016ee1e9aSmrg odir=$objdir 11021fda9279dSmrg else 1102216ee1e9aSmrg odir=$dir/$objdir 11023fda9279dSmrg fi 11024fda9279dSmrg func_basename "$file" 1102516ee1e9aSmrg name=$func_basename_result 1102616ee1e9aSmrg test uninstall = "$opt_mode" && odir=$dir 11027fda9279dSmrg 11028fda9279dSmrg # Remember odir for removal later, being careful to avoid duplicates 1102916ee1e9aSmrg if test clean = "$opt_mode"; then 11030fda9279dSmrg case " $rmdirs " in 11031fda9279dSmrg *" $odir "*) ;; 11032fda9279dSmrg *) func_append rmdirs " $odir" ;; 11033fda9279dSmrg esac 11034fda9279dSmrg fi 11035fda9279dSmrg 11036fda9279dSmrg # Don't error if the file doesn't exist and rm -f was used. 11037fda9279dSmrg if { test -L "$file"; } >/dev/null 2>&1 || 11038fda9279dSmrg { test -h "$file"; } >/dev/null 2>&1 || 11039fda9279dSmrg test -f "$file"; then 11040fda9279dSmrg : 11041fda9279dSmrg elif test -d "$file"; then 11042fda9279dSmrg exit_status=1 11043fda9279dSmrg continue 1104416ee1e9aSmrg elif $rmforce; then 11045fda9279dSmrg continue 11046fda9279dSmrg fi 11047fda9279dSmrg 1104816ee1e9aSmrg rmfiles=$file 11049fda9279dSmrg 11050fda9279dSmrg case $name in 11051fda9279dSmrg *.la) 11052fda9279dSmrg # Possibly a libtool archive, so verify it. 11053fda9279dSmrg if func_lalib_p "$file"; then 11054fda9279dSmrg func_source $dir/$name 11055fda9279dSmrg 11056fda9279dSmrg # Delete the libtool libraries and symlinks. 11057fda9279dSmrg for n in $library_names; do 11058fda9279dSmrg func_append rmfiles " $odir/$n" 11059fda9279dSmrg done 11060fda9279dSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11061fda9279dSmrg 1106216ee1e9aSmrg case $opt_mode in 11063fda9279dSmrg clean) 11064fda9279dSmrg case " $library_names " in 11065fda9279dSmrg *" $dlname "*) ;; 11066fda9279dSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11067fda9279dSmrg esac 11068fda9279dSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11069fda9279dSmrg ;; 11070fda9279dSmrg uninstall) 11071fda9279dSmrg if test -n "$library_names"; then 11072fda9279dSmrg # Do each command in the postuninstall commands. 1107316ee1e9aSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11074fda9279dSmrg fi 11075fda9279dSmrg 11076fda9279dSmrg if test -n "$old_library"; then 11077fda9279dSmrg # Do each command in the old_postuninstall commands. 1107816ee1e9aSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11079fda9279dSmrg fi 11080fda9279dSmrg # FIXME: should reinstall the best remaining shared library. 11081fda9279dSmrg ;; 11082fda9279dSmrg esac 11083fda9279dSmrg fi 11084fda9279dSmrg ;; 11085fda9279dSmrg 11086fda9279dSmrg *.lo) 11087fda9279dSmrg # Possibly a libtool object, so verify it. 11088fda9279dSmrg if func_lalib_p "$file"; then 11089fda9279dSmrg 11090fda9279dSmrg # Read the .lo file 11091fda9279dSmrg func_source $dir/$name 11092fda9279dSmrg 11093fda9279dSmrg # Add PIC object to the list of files to remove. 1109416ee1e9aSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11095fda9279dSmrg func_append rmfiles " $dir/$pic_object" 11096fda9279dSmrg fi 11097fda9279dSmrg 11098fda9279dSmrg # Add non-PIC object to the list of files to remove. 1109916ee1e9aSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11100fda9279dSmrg func_append rmfiles " $dir/$non_pic_object" 11101fda9279dSmrg fi 11102fda9279dSmrg fi 11103fda9279dSmrg ;; 11104fda9279dSmrg 11105fda9279dSmrg *) 1110616ee1e9aSmrg if test clean = "$opt_mode"; then 11107fda9279dSmrg noexename=$name 11108fda9279dSmrg case $file in 11109fda9279dSmrg *.exe) 11110fda9279dSmrg func_stripname '' '.exe' "$file" 11111fda9279dSmrg file=$func_stripname_result 11112fda9279dSmrg func_stripname '' '.exe' "$name" 11113fda9279dSmrg noexename=$func_stripname_result 11114fda9279dSmrg # $file with .exe has already been added to rmfiles, 11115fda9279dSmrg # add $file without .exe 11116fda9279dSmrg func_append rmfiles " $file" 11117fda9279dSmrg ;; 11118fda9279dSmrg esac 11119fda9279dSmrg # Do a test to see if this is a libtool program. 11120fda9279dSmrg if func_ltwrapper_p "$file"; then 11121fda9279dSmrg if func_ltwrapper_executable_p "$file"; then 11122fda9279dSmrg func_ltwrapper_scriptname "$file" 11123fda9279dSmrg relink_command= 11124fda9279dSmrg func_source $func_ltwrapper_scriptname_result 11125fda9279dSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11126fda9279dSmrg else 11127fda9279dSmrg relink_command= 11128fda9279dSmrg func_source $dir/$noexename 11129fda9279dSmrg fi 11130fda9279dSmrg 11131fda9279dSmrg # note $name still contains .exe if it was in $file originally 11132fda9279dSmrg # as does the version of $file that was added into $rmfiles 1113316ee1e9aSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1113416ee1e9aSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11135fda9279dSmrg func_append rmfiles " $odir/lt-$name" 11136fda9279dSmrg fi 1113716ee1e9aSmrg if test "X$noexename" != "X$name"; then 1113816ee1e9aSmrg func_append rmfiles " $odir/lt-$noexename.c" 11139fda9279dSmrg fi 11140fda9279dSmrg fi 11141fda9279dSmrg fi 11142fda9279dSmrg ;; 11143fda9279dSmrg esac 11144fda9279dSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11145fda9279dSmrg done 11146fda9279dSmrg 1114716ee1e9aSmrg # Try to remove the $objdir's in the directories where we deleted files 11148fda9279dSmrg for dir in $rmdirs; do 11149fda9279dSmrg if test -d "$dir"; then 11150fda9279dSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11151fda9279dSmrg fi 11152fda9279dSmrg done 11153fda9279dSmrg 11154fda9279dSmrg exit $exit_status 11155fda9279dSmrg} 11156fda9279dSmrg 1115716ee1e9aSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1115816ee1e9aSmrg func_mode_uninstall ${1+"$@"} 1115916ee1e9aSmrgfi 11160fda9279dSmrg 11161fda9279dSmrgtest -z "$opt_mode" && { 1116216ee1e9aSmrg help=$generic_help 11163fda9279dSmrg func_fatal_help "you must specify a MODE" 11164fda9279dSmrg} 11165fda9279dSmrg 11166fda9279dSmrgtest -z "$exec_cmd" && \ 1116716ee1e9aSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11168fda9279dSmrg 11169fda9279dSmrgif test -n "$exec_cmd"; then 11170fda9279dSmrg eval exec "$exec_cmd" 11171fda9279dSmrg exit $EXIT_FAILURE 11172fda9279dSmrgfi 11173fda9279dSmrg 11174fda9279dSmrgexit $exit_status 11175fda9279dSmrg 11176fda9279dSmrg 11177fda9279dSmrg# The TAGs below are defined such that we never get into a situation 1117816ee1e9aSmrg# where we disable both kinds of libraries. Given conflicting 11179fda9279dSmrg# choices, we go for a static library, that is the most portable, 11180fda9279dSmrg# since we can't tell whether shared libraries were disabled because 11181fda9279dSmrg# the user asked for that or because the platform doesn't support 11182fda9279dSmrg# them. This is particularly important on AIX, because we don't 11183fda9279dSmrg# support having both static and shared libraries enabled at the same 11184fda9279dSmrg# time on that platform, so we default to a shared-only configuration. 11185fda9279dSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11186fda9279dSmrg# configuration. But we'll never go from static-only to shared-only. 11187fda9279dSmrg 11188fda9279dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11189fda9279dSmrgbuild_libtool_libs=no 11190fda9279dSmrgbuild_old_libs=yes 11191fda9279dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11192fda9279dSmrg 11193fda9279dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11194fda9279dSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11195fda9279dSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11196fda9279dSmrg 11197fda9279dSmrg# Local Variables: 11198fda9279dSmrg# mode:shell-script 11199fda9279dSmrg# sh-indentation:2 11200fda9279dSmrg# End: 11201